import WebSocket from 'ws'; import { Awareness } from 'y-protocols/awareness'; import { Doc } from 'yjs'; import { mutex } from 'lib0/mutex.js'; import Connection from './Connection'; import { MessageLogger } from './Debugger'; export declare class Document extends Doc { awareness: Awareness; callbacks: { onUpdate: (document: Document, connection: Connection, update: Uint8Array) => void; }; connections: Map; connection: Connection; }>; name: string; mux: mutex; debugger: MessageLogger; /** * Constructor. */ constructor(name: string); /** * Check if the Document is empty */ isEmpty(fieldName: string): boolean; /** * Merge the given document(s) into this one */ merge(documents: Doc | Array): Document; /** * Set a callback that will be triggered when the document is updated */ onUpdate(callback: (document: Document, connection: Connection, update: Uint8Array) => void): Document; /** * Register a connection and a set of clients on this document keyed by the * underlying websocket connection */ addConnection(connection: Connection): Document; /** * Is the given connection registered on this document */ hasConnection(connection: Connection): boolean; /** * Remove the given connection from this document */ removeConnection(connection: Connection): Document; /** * Get the number of active connections for this document */ getConnectionsCount(): number; /** * Get an array of registered connections */ getConnections(): Array; /** * Get the client ids for the given connection instance */ getClients(connectionInstance: WebSocket): Set; /** * Has the document awareness states */ hasAwarenessStates(): boolean; /** * Apply the given awareness update */ applyAwarenessUpdate(connection: Connection, update: Uint8Array): Document; /** * Handle an awareness update and sync changes to clients * @private */ private handleAwarenessUpdate; /** * Handle an updated document and sync changes to clients */ private handleUpdate; } export default Document;