@jupyter/docprovider
Advanced tools
Comparing version 2.0.0 to 2.0.1
export declare enum MessageType { | ||
ROOM = 124, | ||
CHAT = 125 | ||
} | ||
export declare enum RoomMessage { | ||
RELOAD = 0, | ||
OVERWRITE = 1, | ||
FILE_CHANGED = 2, | ||
FILE_OVERWRITTEN = 3, | ||
DOC_OVERWRITTEN = 4 | ||
} |
@@ -7,12 +7,3 @@ /* ----------------------------------------------------------------------------- | ||
(function (MessageType) { | ||
MessageType[MessageType["ROOM"] = 124] = "ROOM"; | ||
MessageType[MessageType["CHAT"] = 125] = "CHAT"; | ||
})(MessageType || (MessageType = {})); | ||
export var RoomMessage; | ||
(function (RoomMessage) { | ||
RoomMessage[RoomMessage["RELOAD"] = 0] = "RELOAD"; | ||
RoomMessage[RoomMessage["OVERWRITE"] = 1] = "OVERWRITE"; | ||
RoomMessage[RoomMessage["FILE_CHANGED"] = 2] = "FILE_CHANGED"; | ||
RoomMessage[RoomMessage["FILE_OVERWRITTEN"] = 3] = "FILE_OVERWRITTEN"; | ||
RoomMessage[RoomMessage["DOC_OVERWRITTEN"] = 4] = "DOC_OVERWRITTEN"; | ||
})(RoomMessage || (RoomMessage = {})); |
@@ -43,7 +43,2 @@ import { User } from '@jupyterlab/services'; | ||
private _onSync; | ||
private _handleRoomMessage; | ||
private _handleFileChanged; | ||
private _sendReloadMsg; | ||
private _sendOverwriteMsg; | ||
private _dialog; | ||
private _awareness; | ||
@@ -50,0 +45,0 @@ private _contentType; |
@@ -8,7 +8,4 @@ /* ----------------------------------------------------------------------------- | ||
import { Signal } from '@lumino/signaling'; | ||
import * as decoding from 'lib0/decoding'; | ||
import * as encoding from 'lib0/encoding'; | ||
import { WebsocketProvider as YWebsocketProvider } from 'y-websocket'; | ||
import { requestDocSession } from './requests'; | ||
import { MessageType, RoomMessage } from './utils'; | ||
/** | ||
@@ -45,3 +42,2 @@ * A class to provide Yjs synchronization over WebSocket. | ||
}; | ||
this._dialog = null; | ||
this._ready = new PromiseDelegate(); | ||
@@ -101,7 +97,2 @@ this._isDisposed = false; | ||
this._yWebsocketProvider.on('connection-close', this._onConnectionClosed); | ||
this._yWebsocketProvider.messageHandlers[MessageType.ROOM] = (encoder, decoder, provider, emitSynced, messageType) => { | ||
const msgType = decoding.readVarUint(decoder); | ||
const data = decoding.readVarString(decoder); | ||
this._handleRoomMessage(msgType, data); | ||
}; | ||
} | ||
@@ -111,51 +102,2 @@ _onUserChanged(user) { | ||
} | ||
_handleRoomMessage(type, data) { | ||
switch (type) { | ||
case RoomMessage.FILE_CHANGED: | ||
this._handleFileChanged(data); | ||
break; | ||
case RoomMessage.DOC_OVERWRITTEN: | ||
case RoomMessage.FILE_OVERWRITTEN: | ||
if (this._dialog) { | ||
this._dialog.close(); | ||
this._dialog = null; | ||
} | ||
break; | ||
} | ||
} | ||
_handleFileChanged(data) { | ||
this._dialog = new Dialog({ | ||
title: this._trans.__('File changed'), | ||
body: this._trans.__('Do you want to overwrite the file or reload it?'), | ||
buttons: [ | ||
Dialog.okButton({ label: 'Reload' }), | ||
Dialog.warnButton({ label: 'Overwrite' }) | ||
], | ||
hasClose: false | ||
}); | ||
this._dialog.launch().then(resp => { | ||
if (resp.button.label === 'Reload') { | ||
this._sendReloadMsg(data); | ||
} | ||
else if (resp.button.label === 'Overwrite') { | ||
this._sendOverwriteMsg(data); | ||
} | ||
}); | ||
} | ||
_sendReloadMsg(data) { | ||
var _a; | ||
const encoder = encoding.createEncoder(); | ||
encoding.writeVarUint(encoder, MessageType.ROOM); | ||
encoding.writeVarUint(encoder, RoomMessage.RELOAD); | ||
encoding.writeVarString(encoder, data); | ||
(_a = this._yWebsocketProvider) === null || _a === void 0 ? void 0 : _a.ws.send(encoding.toUint8Array(encoder)); | ||
} | ||
_sendOverwriteMsg(data) { | ||
var _a; | ||
const encoder = encoding.createEncoder(); | ||
encoding.writeVarUint(encoder, MessageType.ROOM); | ||
encoding.writeVarUint(encoder, RoomMessage.OVERWRITE); | ||
encoding.writeVarString(encoder, data); | ||
(_a = this._yWebsocketProvider) === null || _a === void 0 ? void 0 : _a.ws.send(encoding.toUint8Array(encoder)); | ||
} | ||
} |
{ | ||
"name": "@jupyter/docprovider", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "JupyterLab - Document Provider", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/jupyterlab/jupyter-collaboration", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25859
710