import { WebsocketProvider as YWebsocketProvider } from 'y-websocket'; import { JSONValue } from '@lumino/coreutils'; import { DocumentChange, YDocument } from '@jupyter/ydoc'; import { IDocumentProvider } from '@jupyter/collaborative-drive'; import { ServerConnection, User } from '@jupyterlab/services'; import { TranslationBundle } from '@jupyterlab/translation'; import { IForkProvider } from './ydrive'; /** * A class to provide Yjs synchronization over WebSocket. * * We specify custom messages that the server can interpret. For reference please look in yjs_ws_server. * */ export declare class WebSocketProvider implements IDocumentProvider, IForkProvider { /** * Construct a new WebSocketProvider * * @param options The instantiation options for a WebSocketProvider */ constructor(options: WebSocketProvider.IOptions); /** * Test whether the object has been disposed. */ get isDisposed(): boolean; /** * A promise that resolves when the document provider is ready. */ get ready(): Promise; get contentType(): string; get format(): string; /** * Dispose of the resources held by the object. */ dispose(): void; reconnect(): Promise; save(): Promise; private get _serverUrl(); private _connect; /** * Start the load timeout that shows a retry dialog if the document * hasn't synced within LOAD_TIMEOUT milliseconds. */ private _startLoadTimeout; /** * Clear the load timeout. */ private _clearLoadTimeout; /** * Callback when the load timeout fires. * Shows a dialog asking the user if they want to retry loading. */ private _onLoadTimeout; connectToForkDoc(forkRoomId: string, sessionId: string): Promise; get wsProvider(): YWebsocketProvider | null; private _disconnect; private _onUserChanged; private _buildSessionExpiredMessage; private _onConnectionClosed; private _attachConflictListener; private _handleConflictMessage; private _onSync; private _getCloseReasonMessage; private _awareness; private _contentType; private _format; private _isDisposed; private _path; private _ready; private _customServerUrl?; private _sharedModel; private _yWebsocketProvider; private _serverSettings; private _trans; private _hasSynced; private _saveCounter; private _conflictWs; private _onConflictSaveAs?; private _onConflictRevert?; private _loadTimeoutId; private _isShowingDialog; private _onConflictShowDiff?; } /** * A namespace for WebSocketProvider statics. */ export declare namespace WebSocketProvider { /** * The instantiation options for a WebSocketProvider. */ interface IOptions { /** * The server URL */ url?: string; /** * The document file path */ path: string; /** * Content type */ contentType: string; /** * The source format */ format: string; /** * The shared model */ model: YDocument; /** * The user data */ user: User.IManager; /** * The jupyterlab translator */ translator: TranslationBundle; /** * The server settings. */ serverSettings?: ServerConnection.ISettings; /** * Called when the user chooses "Save As" from the conflict dialog. */ onConflictSaveAs?: () => Promise; /** * Called when the user chooses "Revert" from the conflict dialog. */ onConflictRevert?: () => Promise; /** * Called when the user chooses "Show Diff" from the conflict dialog. * Receives the current local document content as JSON. */ onConflictShowDiff?: (localContent: JSONValue) => Promise; } }