import type { LiveInput } from './protocol.js'; export type { LiveDeltaFrame, LiveFrame, LiveHeartbeatFrame, LiveInput, LiveRemoveFrame, LiveSnapshotFrame, LiveUpsertFrame, } from './protocol.js'; export { applyLiveFrame } from './apply.js'; export { parseSseFrames, type ByteStream } from './sse.js'; export type LiveStatus = 'connecting' | 'live' | 'reconnecting' | 'failed'; export type LiveView = { /** The current rows. A new array appears only when the view changes. */ getRows: () => readonly TRow[]; getStatus: () => LiveStatus; getError: () => unknown; /** Register a listener; the return value removes it. */ subscribe: (listener: () => void) => () => void; /** * Write to the view before the server confirms. Replace a row rather than * mutating it, so consumers that compare by identity see the change: * `patch((rows) => { rows[0] = { ...rows[0], done: true } })`. * The server echo replaces the write, and `resync()` discards it. */ patch: (recipe: (rows: TRow[]) => void) => void; /** Reconnect. The new snapshot is the resynchronisation. */ resync: () => void; /** Stop the loop and abort the request. */ close: () => void; }; export type CreateLiveViewOptions = { input?: LiveInput; /** For tests, and for a fetch that carries credentials or a base URL. */ fetch?: (input: string, init?: RequestInit) => Promise; /** Delay in milliseconds before retry number `attempt`, counted from zero. */ backoff?: (attempt: number) => number; }; /** * One live view: a reconnecting loop over `GET /api/live/{table}` that folds * frames into an immutable array of rows. * * The view holds no cache and no second copy of the data. Every connection * opens with a snapshot, so a reconnect is the resynchronisation, and the * server places each row, so this module never sorts. * * `subscribe` plus `getRows` is the pair `useSyncExternalStore` expects. A * Solid or Vue binding writes `getRows()` into a store from the same listener. */ export declare function createLiveView(url: string, options?: CreateLiveViewOptions): LiveView; //# sourceMappingURL=index.d.ts.map