import { IServiceID } from "../../../types/kernel.js"; import "../../../types/index.js"; import { Doc } from "yjs"; import { Binding, Provider, UserState } from "@lexical/yjs"; interface YjsAwarenessUser { clientId: number; state: UserState; } interface YjsPluginState { binding: Binding; doc: Doc | undefined; docMap: Map; id: string; provider: Provider; } type YjsPluginStateListener = (state: YjsPluginState | null) => void; type YjsAwarenessUsersListener = (users: YjsAwarenessUser[]) => void; declare class YjsService { private awarenessUsers; private awarenessUsersListeners; private listeners; private state; getAwarenessUsers(): YjsAwarenessUser[]; getState(): YjsPluginState | null; /** * Apply a server-produced editor snapshot to the shared document exactly once. * * A normal `IEditor.setDocument` call replaces the local Lexical state without * knowing about the Yjs binding. When the binding sees that state it can treat * every imported node as a new local node and append a second copy to the * shared tree. This path first hydrates from the shared tree, then applies the * snapshot with the collaboration-skip tag and replaces the shared root in a * single Yjs transaction. A second client receiving the same snapshot * therefore becomes a no-op. * * @returns whether the shared document was changed */ applyExternalEditorData(editorData: Record): boolean; setAwarenessUsers(users: YjsAwarenessUser[]): void; setState(state: YjsPluginState | null): void; subscribeAwarenessUsers(listener: YjsAwarenessUsersListener): () => void; subscribe(listener: YjsPluginStateListener): () => void; } declare const IYjsService: IServiceID; export { IYjsService, YjsAwarenessUser, YjsPluginState, YjsService };