UNPKG

open-collaboration-monaco

Version:

Connect a single Monaco Editor to an Open Collaboration Tools session

94 lines 4.82 kB
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 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<types.Peer>; protected readonly documentDisposables: Map<string, DisposableCollection>; protected readonly peers: Map<string, DisposablePeer>; protected readonly throttles: Map<string, () => void>; protected readonly decorations: Map<DisposablePeer, monaco.editor.IEditorDecorationsCollection>; protected readonly usersChangedCallbacks: UsersChangeEvent[]; protected readonly fileNameChangeCallbacks: FileNameChangeEvent[]; protected currentPath?: string; protected stopPropagation: boolean; protected _following?: string; protected _fileName: string; protected previousFileName?: string; protected _workspaceName: string; protected connection: ProtocolBroadcastConnection; get following(): string | undefined; get connectedUsers(): DisposablePeer[]; get ownUserData(): Promise<types.Peer>; 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; constructor(options: CollaborationInstanceOptions); private setupConnectionHandlers; private setupFileSystemHandlers; private handleReadFile; private handleStat; private handleReaddir; private handleFileChange; private notifyUsersChanged; private notifyFileNameChanged; setEditor(editor: monaco.editor.IStandaloneCodeEditor): void; setFileName(fileName: string): Promise<void>; 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<void>; protected updateTextSelection(editor: monaco.editor.IStandaloneCodeEditor): void; protected registerTextDocument(document: monaco.editor.ITextModel): Promise<void>; 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<void>; getProtocolPath(uri?: monaco.Uri): string | undefined; getResourceUri(path?: string): monaco.Uri | undefined; readFile(): Promise<string>; } //# sourceMappingURL=collaboration-instance.d.ts.map