import type * as Y from 'yjs'; import type { HostAwareness } from './awareness.js'; import type { ConnectionStatus, SyncProvider } from './provider.js'; /** The event surface shared by y-websocket and y-webrtc providers. */ export interface YjsProviderLike { on: (event: string, listener: (payload: never) => void) => void; off?: (event: string, listener: (payload: never) => void) => void; connect?: () => void; disconnect?: () => void; destroy?: () => void; /** y-websocket: socket currently open. */ wsconnected?: boolean; /** y-websocket: `synced`; y-webrtc: `synced`. */ synced?: boolean; /** y-webrtc: `connected`. */ connected?: boolean; /** y-websocket: `wsconnecting`. */ wsconnecting?: boolean; } /** * Wrap a y-websocket or y-webrtc provider as a {@link SyncProvider}. Status maps from the * provider's `status` events (`{status}` for y-websocket, `{connected}` for y-webrtc) and * `connection-error`; `synced` from `sync` (y-websocket) or `synced` (y-webrtc). The wrapper owns * the provider: `destroy` destroys it. */ export declare function adaptYjsProvider(provider: YjsProviderLike): SyncProvider; /** Connection state a host reports for a borrowed session. */ export interface ExternalSnapshot { status: ConnectionStatus; /** * The host has loaded the authoritative document and permits local edits. Never inferred from * `status` and never opened by a timeout; keep true while offline to allow ordinary offline edits. */ synced: boolean; } /** Host-owned Yjs resources. The host creates, connects and destroys them. */ export interface ExternalSession { readonly doc: Y.Doc; /** Must belong to `doc`. One viewer publishes presence at a time. */ readonly awareness: HostAwareness; getSnapshot: () => ExternalSnapshot; /** Subscribe to status or synced changes; returns an unsubscribe function. */ subscribe: (listener: () => void) => () => void; } /** * Observe a host-owned session. Subscribes before reading so a sync that completes during * attachment is not lost; the initial snapshot is delivered synchronously, then only changes. */ export declare function observeExternalSession(session: ExternalSession, onSnapshot: (snapshot: ExternalSnapshot) => void): () => void; //# sourceMappingURL=external-provider.d.ts.map