/** Read side of a store: the minimal contract scaffolds consume state through. */ export interface StateController { get(): S; subscribe(listener: (state: S, prev: S) => void): () => void; } /** What a scaffold accepts as its state input. */ export type StateSource = S | StateController; /** Type guard: `true` when `source` is a `{ get, subscribe }` controller rather than a plain state object. */ export declare function isStateController(source: StateSource | undefined): source is StateController; /** * Normalize any state source to a controller. Plain objects become a fresh * store seeded with the object, so downstream code has one code path. */ export declare function toController(source: StateSource): StateController; /** * Mirror an external controller into an app: seed with `resolveInitialState`, * then keep the app state following the controller with `bindStateSource`. * Data flows controller -> app only; the returned function detaches. */ export declare function resolveInitialState(source: StateSource | undefined, fallback: S): S; type TargetType = { setState(patch: Partial): void; }; /** * Keep an app's state following an external controller. Subscribes to the * controller and forwards every commit into `app.setState`; plain-object * sources are a no-op (the seed already happened via `resolveInitialState`). * * @param app - Anything with a `setState(partial)` method. * @param source - The state source the scaffold was given. * @returns A detach function that unsubscribes the mirror. * @remarks Data flows controller → app only; nothing writes back. */ export declare function bindStateSource(target: TargetType, source: StateSource | undefined): () => void; export {}; //# sourceMappingURL=controller.d.ts.map