@jupyterlite/application-extension 0.1.0-alpha.17 → 0.1.0-alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -1,3 +1,13 @@
1
1
  import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ import { IDocumentProviderFactory } from '@jupyterlab/docprovider';
3
+ /**
4
+ * A public namespace for WebRTC options
5
+ */
6
+ export declare namespace IWebRtcProvider {
7
+ interface IOptions extends IDocumentProviderFactory.IOptions {
8
+ room: string;
9
+ signalingUrls?: string[];
10
+ }
11
+ }
2
12
  declare const plugins: JupyterFrontEndPlugin<any>[];
3
13
  export default plugins;
package/lib/index.js CHANGED
@@ -15,6 +15,7 @@ import { UUID, PromiseDelegate } from '@lumino/coreutils';
15
15
  import { Widget } from '@lumino/widgets';
16
16
  import { getParam } from 'lib0/environment';
17
17
  import { WebrtcProvider } from 'y-webrtc';
18
+ import { Awareness } from 'y-protocols/awareness';
18
19
  import React from 'react';
19
20
  /**
20
21
  * The default notebook factory.
@@ -30,7 +31,7 @@ const EDITOR_FACTORY = 'Editor';
30
31
  const URL_PATTERN = new RegExp('/(lab|notebooks|edit|consoles)\\/?');
31
32
  class WebRtcProvider extends WebrtcProvider {
32
33
  constructor(options) {
33
- super(`${options.room}${options.path}`, options.ymodel.ydoc);
34
+ super(`${options.room}${options.path}`, options.ymodel.ydoc, WebRtcProvider.yProviderOptions(options));
34
35
  this._initialRequest = null;
35
36
  this.awareness = options.ymodel.awareness;
36
37
  const color = `#${getParam('--usercolor', getRandomColor().slice(1))}`;
@@ -77,6 +78,31 @@ class WebRtcProvider extends WebrtcProvider {
77
78
  // no-op
78
79
  }
79
80
  }
81
+ /**
82
+ * A private (so far) namespace for Yjs/WebRTC implementation details
83
+ */
84
+ (function (WebRtcProvider) {
85
+ /**
86
+ * Re-map Lab provider options to yjs ones.
87
+ */
88
+ function yProviderOptions(options) {
89
+ return {
90
+ signaling: options.signalingUrls && options.signalingUrls.length
91
+ ? options.signalingUrls
92
+ : [
93
+ 'wss://signaling.yjs.dev',
94
+ 'wss://y-webrtc-signaling-eu.herokuapp.com',
95
+ 'wss://y-webrtc-signaling-us.herokuapp.com'
96
+ ],
97
+ password: null,
98
+ awareness: new Awareness(options.ymodel.ydoc),
99
+ maxConns: 20 + Math.floor(Math.random() * 15),
100
+ filterBcConns: true,
101
+ peerOpts: {} // simple-peer options. See https://github.com/feross/simple-peer#peer--new-peeropts
102
+ };
103
+ }
104
+ WebRtcProvider.yProviderOptions = yProviderOptions;
105
+ })(WebRtcProvider || (WebRtcProvider = {}));
80
106
  /**
81
107
  * The command IDs used by the application extension.
82
108
  */
@@ -150,13 +176,15 @@ const docProviderPlugin = {
150
176
  const host = window.location.host;
151
177
  // enable if both the page config option (deployment wide) and the room name (user) are defined
152
178
  const collaborative = PageConfig.getOption('collaborative') === 'true' && roomName;
179
+ const signalingUrls = JSON.parse(PageConfig.getOption('fullWebRtcSignalingUrls') || 'null');
153
180
  // default to a random id to not collaborate with others by default
154
181
  const room = `${host}-${roomName || UUID.uuid4()}`;
155
182
  const factory = (options) => {
156
183
  return collaborative
157
184
  ? new WebRtcProvider({
158
185
  room,
159
- ...options
186
+ ...options,
187
+ ...(signalingUrls && signalingUrls.length ? { signalingUrls } : {})
160
188
  })
161
189
  : new ProviderMock();
162
190
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlite/application-extension",
3
- "version": "0.1.0-alpha.17",
3
+ "version": "0.1.0-alpha.18",
4
4
  "description": "JupyterLite - Application Extension",
5
5
  "homepage": "https://github.com/jupyterlite/jupyterlite",
6
6
  "bugs": {
@@ -47,7 +47,7 @@
47
47
  "@jupyterlab/services": "~6.2.0",
48
48
  "@jupyterlab/translation": "~3.2.0",
49
49
  "@jupyterlab/ui-components": "~3.2.0",
50
- "@jupyterlite/ui-components": "^0.1.0-alpha.17",
50
+ "@jupyterlite/ui-components": "^0.1.0-alpha.18",
51
51
  "@lumino/algorithm": "^1.6.0",
52
52
  "@lumino/coreutils": "^1.8.0",
53
53
  "@lumino/widgets": "^1.23.0",