@jupyterlab/docprovider
Advanced tools
Comparing version 3.3.0-alpha.15 to 3.3.0-alpha.16
import { WebsocketProvider } from 'y-websocket'; | ||
import { IDocumentProvider, IDocumentProviderFactory } from './tokens'; | ||
import { IStateDB } from '@jupyterlab/statedb'; | ||
/** | ||
@@ -73,7 +72,3 @@ * A class to provide Yjs synchronization over WebSocket. | ||
url: string; | ||
/** | ||
* The state database | ||
*/ | ||
state: IStateDB | null; | ||
} | ||
} |
@@ -12,4 +12,2 @@ /* ----------------------------------------------------------------------------- | ||
import * as env from 'lib0/environment'; | ||
const PREFIX = '@jupyterlab/docprovider:yprovider'; | ||
const USER = `${PREFIX}:user`; | ||
/** | ||
@@ -41,6 +39,13 @@ * A class to provide Yjs synchronization over WebSocket. | ||
this._serverUrl = options.url; | ||
const color = '#' + env.getParam('--usercolor', getRandomColor().slice(1)); | ||
const name = env.getParam('--username', getAnonymousUserName()); | ||
const awareness = options.ymodel.awareness; | ||
const currState = awareness.getLocalState(); | ||
let color = '#' + env.getParam('--usercolor', ''); | ||
let name = env.getParam('--username', ''); | ||
// only set if this was not already set by another plugin | ||
if (currState && ((_a = currState.user) === null || _a === void 0 ? void 0 : _a.name) == null) { | ||
options.ymodel.awareness.setLocalStateField('user', { | ||
name, | ||
color | ||
}); | ||
} | ||
// Message handler that confirms when a lock has been acquired | ||
@@ -75,40 +80,2 @@ this.messageHandlers[127] = (encoder, decoder, provider, emitSynced, messageType) => { | ||
this.on('status', this._onConnectionStatus); | ||
const state = options.state; | ||
if (name != '' || color != '#' || state == null) { | ||
if (name == '') { | ||
name = getAnonymousUserName(); | ||
} | ||
if (color == '#') { | ||
color = '#' + getRandomColor().slice(1); | ||
} | ||
// only set if this was not already set by another plugin | ||
if (currState && ((_a = currState.user) === null || _a === void 0 ? void 0 : _a.name) == null) { | ||
options.ymodel.awareness.setLocalStateField('user', { | ||
name, | ||
color | ||
}); | ||
} | ||
return; | ||
} | ||
const user = state.fetch(USER); | ||
void user.then(param => { | ||
var _a; | ||
if (param === undefined) { | ||
name = getAnonymousUserName(); | ||
color = '#' + getRandomColor().slice(1); | ||
void state.save(USER, { userName: name, userColor: color }); | ||
} | ||
else { | ||
const { userName, userColor } = param; | ||
name = userName; | ||
color = userColor; | ||
} | ||
// only set if this was not already set by another plugin | ||
if (currState && ((_a = currState.user) === null || _a === void 0 ? void 0 : _a.name) == null) { | ||
options.ymodel.awareness.setLocalStateField('user', { | ||
name, | ||
color | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -115,0 +82,0 @@ setPath(newPath) { |
{ | ||
"name": "@jupyterlab/docprovider", | ||
"version": "3.3.0-alpha.15", | ||
"version": "3.3.0-alpha.16", | ||
"description": "JupyterLab - Document Provider", | ||
@@ -40,5 +40,4 @@ "homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"dependencies": { | ||
"@jupyterlab/shared-models": "^3.3.0-alpha.15", | ||
"@jupyterlab/statedb": "^3.3.0-alpha.15", | ||
"@lumino/coreutils": "^1.10.0", | ||
"@jupyterlab/shared-models": "^3.3.0-alpha.16", | ||
"@lumino/coreutils": "^1.5.3", | ||
"lib0": "^0.2.42", | ||
@@ -49,3 +48,3 @@ "y-websocket": "^1.3.15", | ||
"devDependencies": { | ||
"@jupyterlab/testutils": "^3.3.0-alpha.15", | ||
"@jupyterlab/testutils": "^3.3.0-alpha.16", | ||
"@types/jest": "^26.0.10", | ||
@@ -52,0 +51,0 @@ "jest": "^26.4.2", |
Sorry, the diff of this file is not supported yet
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
5
25455
498
- Removed@jupyterlab/statedb@^3.3.0-alpha.15
- Removed@jupyterlab/statedb@3.6.8(transitive)
- Removed@lumino/algorithm@1.9.2(transitive)
- Removed@lumino/commands@1.21.1(transitive)
- Removed@lumino/disposable@1.10.4(transitive)
- Removed@lumino/domutils@1.8.2(transitive)
- Removed@lumino/keyboard@1.8.2(transitive)
- Removed@lumino/properties@1.8.2(transitive)
- Removed@lumino/signaling@1.11.1(transitive)
- Removed@lumino/virtualdom@1.14.3(transitive)
Updated@lumino/coreutils@^1.5.3