/** * YjsDocumentManager - Manages local Y.Doc instances for collaborative editing. * * Responsibilities: * - Create and manage Y.Doc instances per document field * - Handle Yjs sync protocol (state vector exchange) * - Apply local and remote updates * - Track connection state per document * - Generate derived content from Y.Doc */ import * as Y from "yjs"; import type { ConnectOptions, DocumentConnectionState, DocumentKey, YjsDocumentManagerConfig, YjsTransport } from "./types.js"; /** * Manages Y.Doc instances for collaborative editing. */ export declare class YjsDocumentManager { private readonly docs; private readonly remoteUpdateOrigin; private readonly config; private readonly liveEditingRetryConfig; private persistenceKeyPrefix; private transport; private transportConnectionState; private unsubscribeTransportMessage; private unsubscribeTransportConnection; private readonly connectionStateCallbacks; private readonly contentCallbacks; private reconnectReplayGeneration; constructor(config: YjsDocumentManagerConfig); setPersistenceKeyPrefix(prefix: string): void; clearPersistedDocuments(): void; setTransport(transport: YjsTransport): void; getDocument(docKey: DocumentKey): Y.Doc; /** * Connect to a document for collaborative editing. */ connect(docKey: DocumentKey, options?: ConnectOptions): void; disconnect(docKey: DocumentKey): void; getConnectionState(docKey: DocumentKey): DocumentConnectionState; onConnectionStateChange(docKey: DocumentKey, callback: (state: DocumentConnectionState) => void): () => void; onContentChange(docKey: DocumentKey, callback: (content: string) => void): () => void; /** * Apply a remote update to a document. */ applyRemoteUpdate(docKey: DocumentKey, update: Uint8Array): void; /** * Apply a snapshot (full state) to a document. * Semantically identical to applyRemoteUpdate. A Yjs snapshot * is applied using the same Y.applyUpdate mechanism. */ applySnapshot(docKey: DocumentKey, snapshot: Uint8Array): void; getDerivedContent(docKey: DocumentKey): string; getStateVector(docKey: DocumentKey): Uint8Array; getUpdatesSince(docKey: DocumentKey, stateVector: Uint8Array): Uint8Array | null; getEncodedState(docKey: DocumentKey): Uint8Array | null; destroy(docKey: DocumentKey): void; destroyAll(): void; private getOrCreateState; private static createDocumentState; private handleTransportConnectionStateChange; private markActiveDocumentsAsConnecting; private getActiveReconnectReplayTargets; private requestSyncStep1; /** * Seed pending initial content into the Y.Doc. Returns true if content was seeded. */ private static seedPendingContent; private static getEncodedDocumentState; private static clearRetryTimer; private static resetRetryState; private scheduleRetrySyncStep1; private attachLocalUpdateHandler; private static detachLocalUpdateHandler; private static isDocActive; private shouldApplyRemoteMessage; private sendIfConnected; private setConnectionState; private notifyContentChange; private sendSyncStep1; private sendUpdate; private flushPendingLocalUpdates; private handleMessage; private handleSyncStep2; private handleUpdate; private handleError; private getPersistedDocumentKey; private restorePersistedDocument; private persistDocument; } //# sourceMappingURL=document-manager.d.ts.map