import type * as Y from 'yjs'; import { type LoadOrigin } from './policy.js'; import type { CollabSession } from './session.js'; /** Transaction origin used for the adapter's own writes, so observers can skip echoes. */ export declare const LOCAL_ORIGIN: unique symbol; export interface DocumentAdapter { /** True when nothing has been seeded into the shared document yet. */ isEmpty: (doc: Y.Doc) => boolean; /** Materialise the shared document as the product model. */ read: (doc: Y.Doc) => TModel; /** * Write `model` into the document inside `doc.transact(fn, origin)`. Prefer reconciling only what * changed over replacing the whole structure so concurrent edits merge per field. */ write: (doc: Y.Doc, model: TModel, origin: typeof LOCAL_ORIGIN) => void; /** Observe changes (deep); return an unsubscribe. The handler receives the transaction origin. */ observe: (doc: Y.Doc, onChange: (origin: unknown) => void) => () => void; } export interface BindingOptions { /** The product's current local model, used to seed an empty room. */ getLocalModel: () => TModel; /** The shared document changed remotely (or the room replaced the bootstrap model): adopt it. */ onRemoteModel: (model: TModel) => void; } export interface DocumentBinding { /** Publish a local edit. Returns false (and writes nothing) while writes are not allowed. */ push: (model: TModel) => boolean; /** * A load finished. Returns true when the room replaced it (bootstrap into a non-empty room); * otherwise a user load is published to the room. */ handleLoad: (origin: LoadOrigin | undefined, model: TModel) => boolean; dispose: () => void; } export declare function bindDocument(session: CollabSession

, adapter: DocumentAdapter, options: BindingOptions): DocumentBinding; //# sourceMappingURL=binding.d.ts.map