import { Reactive, type Disposable } from "./reactive.ts"; export interface Derived { /** 現在値を読む。 */ (): T; readonly reactive: Reactive; /** 購読せずに覗く。 */ peek(): T; subscribe(cb: (value: T) => void): () => void; [Symbol.toPrimitive](hint: string): unknown; } export interface State extends Derived { /** 値を書く。 */ (next: T): void; /** 関数で更新する。 count(n => n + 1) */ (updater: (current: T) => T): void; } /** * Signal / Computed を関数ハンドルに包む。 * readonly を立てると、書き込もうとした時点で分かるように例外を投げる。 */ export declare function toHandle(source: Reactive, readonly?: boolean): State; /** 読み取り専用ハンドル(loading / error / computed の公開用)。 */ export declare function toReadonly(source: Reactive): Derived; /** 書き込めるハンドルか。 */ export declare function isState(v: unknown): v is State; /** * 「リアクティブに読める何か」を読み取り関数に正規化する。 * state / computed ハンドル / Reactive / 素の関数 → () => 値 * それ以外 → null(= 静的な値なのでそのまま扱う) * * 注: 関数はすべて「値を返すリアクティブな式」として扱う(jQuery の .text(fn) と同じ発想)。 */ export declare function readerOf(value: unknown): (() => T) | null; export type { Disposable };