import { Deferred, DisposableCollection, ProtocolBroadcastConnection } from 'open-collaboration-protocol'; import * as Y from 'yjs'; import * as monaco from 'monaco-editor'; import * as awarenessProtocol from 'y-protocols/awareness'; import * as types from 'open-collaboration-protocol'; import { OpenCollaborationYjsProvider } from 'open-collaboration-yjs'; import { MonacoCollabCallbacks } from './monaco-api.js'; import { DisposablePeer } from './collaboration-peer.js'; export type UsersChangeEvent = () => void; export type FileNameChangeEvent = (fileName: string) => void; export type ProposedChangesEvent = (path: string, accepted: boolean) => void; export type CloseProposalEvent = (path: string) => void; export interface Disposable { dispose(): void; } export interface CollaborationInstanceOptions { connection: ProtocolBroadcastConnection; host: boolean; callbacks: MonacoCollabCallbacks; editor?: monaco.editor.IStandaloneCodeEditor; roomClaim: types.CreateRoomResponse | types.JoinRoomResponse; } export declare class CollaborationInstance implements Disposable { protected options: CollaborationInstanceOptions; protected readonly yjs: Y.Doc; protected readonly yjsAwareness: awarenessProtocol.Awareness; protected readonly yjsProvider: OpenCollaborationYjsProvider; protected readonly yjsMutex: import("lib0/mutex").mutex; protected readonly identity: Deferred; protected readonly documentDisposables: Map; protected readonly peers: Map; protected readonly throttles: Map void>; protected readonly decorations: Map; protected readonly usersChangedCallbacks: UsersChangeEvent[]; protected readonly fileNameChangeCallbacks: FileNameChangeEvent[]; protected readonly proposedChangesCallbacks: ProposedChangesEvent[]; protected readonly closeProposalCallbacks: CloseProposalEvent[]; protected currentPath?: string; protected stopPropagation: boolean; /** Path of the currently displayed proposal diff, if any. */ private currentDiffPath?; /** Cleanup callback for the currently displayed built-in diff editor, if any. */ private diffCleanup?; /** Re-entrancy guard so a received closeProposal does not re-broadcast. */ private receivingCloseProposal; protected _following?: string; protected _fileName: string; protected previousFileName?: string; protected _workspaceName: string; protected connection: ProtocolBroadcastConnection; private activeDiffEditor?; private diffEditorContainer?; get following(): string | undefined; get connectedUsers(): DisposablePeer[]; get ownUserData(): Promise; get isHost(): boolean; get host(): types.Peer | undefined; get roomId(): string; get fileName(): string; get workspaceName(): string; set workspaceName(_workspaceName: string); /** * access token for the room. allow to join or reconnect as host */ get roomToken(): string; onUsersChanged(callback: UsersChangeEvent): void; onFileNameChange(callback: FileNameChangeEvent): void; onProposedChanges(callback: ProposedChangesEvent): void; onCloseProposal(callback: CloseProposalEvent): void; constructor(options: CollaborationInstanceOptions); private setupConnectionHandlers; private setupFileSystemHandlers; private handleReadFile; private handleStat; private handleReaddir; private handleFileChange; private onDidProposeChanges; private notifyUsersChanged; private notifyFileNameChanged; private notifyProposedChanges; private notifyCloseProposal; /** * Handles a `closeProposal` broadcast received from a peer. Closes the local * diff view that matches the given path and notifies registered listeners. * The re-entrancy guard prevents the local cleanup from re-broadcasting. */ private onDidCloseProposal; /** * Broadcasts a `closeProposal` event so peers close the diff view for the given path. */ closeProposal(path: string): void; /** * Locally cancels the currently displayed proposal for `path`: resets * `stopPropagation` so local edits sync again, without broadcasting a * `closeProposal` (so a peer's merge editor stays open). */ cancelProposal(path: string): void; setEditor(editor: monaco.editor.IStandaloneCodeEditor): void; setFileName(fileName: string): Promise; dispose(): void; leaveRoom(): void; getCurrentConnection(): ProtocolBroadcastConnection; protected pushDocumentDisposable(path: string, disposable: Disposable): void; protected registerEditorEvents(): void; followUser(id?: string): void; protected updateFollow(): void; protected followSelection(selection: types.ClientTextSelection): Promise; protected updateTextSelection(editor: monaco.editor.IStandaloneCodeEditor): void; protected registerTextDocument(document: monaco.editor.ITextModel): Promise; protected registerTextObserver(path: string, document: monaco.editor.ITextModel, yjsText: Y.Text): void; protected updateDocument(document: monaco.editor.ITextModel, edits: monaco.editor.IIdentifiedSingleEditOperation[]): void; private createEditsFromTextEvent; protected updateTextDocument(event: monaco.editor.IModelContentChangedEvent, document: monaco.editor.ITextModel): void; protected getOrCreateThrottle(path: string, document: monaco.editor.ITextModel): () => void; private updateDocumentContent; protected rerenderPresence(): void; protected setDecorations(peer: DisposablePeer, decorations: monaco.editor.IModelDeltaDecoration[]): void; protected setSharedSelection(selection?: types.ClientSelection): void; protected updateSelectionPath(newPath: string): void; protected createSelectionFromRelative(selection: types.RelativeTextSelection, model: monaco.editor.ITextModel): monaco.Selection | undefined; protected getHostPath(path: string): string; initialize(data: types.InitData): Promise; getProtocolPath(uri?: monaco.Uri): string | undefined; getResourceUri(path?: string): monaco.Uri | undefined; readFile(): Promise; private adjustEol; } //# sourceMappingURL=collaboration-instance.d.ts.map