@jupyter/collaboration-extension 2.0.8 → 3.0.0-alpha.0

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.js CHANGED
@@ -4,18 +4,12 @@
4
4
  * @packageDocumentation
5
5
  * @module collaboration-extension
6
6
  */
7
- import { drive, yfile, ynotebook, defaultFileBrowser, logger } from './filebrowser';
8
7
  import { userMenuPlugin, menuBarPlugin, rtcGlobalAwarenessPlugin, rtcPanelPlugin, userEditorCursors } from './collaboration';
9
8
  import { sharedLink } from './sharedlink';
10
9
  /**
11
10
  * Export the plugins as default.
12
11
  */
13
12
  const plugins = [
14
- drive,
15
- yfile,
16
- ynotebook,
17
- defaultFileBrowser,
18
- logger,
19
13
  userMenuPlugin,
20
14
  menuBarPlugin,
21
15
  rtcGlobalAwarenessPlugin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter/collaboration-extension",
3
- "version": "2.0.8",
3
+ "version": "3.0.0-alpha.0",
4
4
  "description": "JupyterLab - Real-Time Collaboration Extension",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -45,7 +45,7 @@
45
45
  "build:labextension:dev": "jupyter labextension build --development True .",
46
46
  "clean": "jlpm run clean:lib",
47
47
  "clean:lib": "rimraf lib tsconfig.tsbuildinfo node_modules",
48
- "clean:labextension": "rimraf ../../jupyter_collaboration/labextension",
48
+ "clean:labextension": "rimraf ../../projects/jupyter-collaboration-ui/jupyter_collaboration_ui/labextension",
49
49
  "clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
50
50
  "install:extension": "jlpm run build",
51
51
  "watch": "run-p watch:src watch:labextension",
@@ -53,24 +53,17 @@
53
53
  "watch:labextension": "jupyter labextension watch ."
54
54
  },
55
55
  "dependencies": {
56
- "@jupyter/collaboration": "^2.0.8",
57
- "@jupyter/docprovider": "^2.0.8",
56
+ "@jupyter/collaboration": "^3.0.0-alpha.0",
57
+ "@jupyter/docprovider": "^3.0.0-alpha.0",
58
58
  "@jupyter/ydoc": "^1.1.0-a0",
59
- "@jupyterlab/application": "^4.0.5",
60
- "@jupyterlab/apputils": "^4.0.5",
61
- "@jupyterlab/codemirror": "^4.0.5",
59
+ "@jupyterlab/application": "^4.2.0-beta.0",
60
+ "@jupyterlab/apputils": "^4.2.0-beta.0",
61
+ "@jupyterlab/codemirror": "^4.2.0-beta.0",
62
62
  "@jupyterlab/coreutils": "^6.0.5",
63
- "@jupyterlab/docregistry": "^4.0.5",
64
- "@jupyterlab/filebrowser": "^4.0.5",
65
- "@jupyterlab/fileeditor": "^4.0.5",
66
- "@jupyterlab/logconsole": "^4.0.5",
67
- "@jupyterlab/notebook": "^4.0.5",
68
63
  "@jupyterlab/services": "^7.0.5",
69
- "@jupyterlab/settingregistry": "^4.0.5",
70
- "@jupyterlab/statedb": "^4.0.5",
71
- "@jupyterlab/translation": "^4.0.5",
72
- "@jupyterlab/ui-components": "^4.0.5",
73
- "@lumino/commands": "^2.1.0",
64
+ "@jupyterlab/statedb": "^4.2.0-beta.0",
65
+ "@jupyterlab/translation": "^4.2.0-beta.0",
66
+ "@jupyterlab/ui-components": "^4.2.0-beta.0",
74
67
  "@lumino/widgets": "^2.1.0",
75
68
  "y-protocols": "^1.0.5",
76
69
  "y-websocket": "^1.3.15",
@@ -95,10 +88,7 @@
95
88
  "jupyterlab": {
96
89
  "extension": true,
97
90
  "schemaDir": "./schema",
98
- "outputDir": "../../jupyter_collaboration/labextension",
99
- "disabledExtensions": [
100
- "@jupyterlab/filebrowser-extension:defaultFileBrowser"
101
- ],
91
+ "outputDir": "../../projects/jupyter-collaboration-ui/jupyter_collaboration_ui/labextension",
102
92
  "sharedPackages": {
103
93
  "@codemirror/state": {
104
94
  "bundled": false,
@@ -1,23 +0,0 @@
1
- import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
- import { IDefaultFileBrowser } from '@jupyterlab/filebrowser';
3
- import { ICollaborativeDrive } from '@jupyter/docprovider';
4
- /**
5
- * The default collaborative drive provider.
6
- */
7
- export declare const drive: JupyterFrontEndPlugin<ICollaborativeDrive>;
8
- /**
9
- * Plugin to register the shared model factory for the content type 'file'.
10
- */
11
- export declare const yfile: JupyterFrontEndPlugin<void>;
12
- /**
13
- * Plugin to register the shared model factory for the content type 'notebook'.
14
- */
15
- export declare const ynotebook: JupyterFrontEndPlugin<void>;
16
- /**
17
- * The default file browser factory provider.
18
- */
19
- export declare const defaultFileBrowser: JupyterFrontEndPlugin<IDefaultFileBrowser>;
20
- /**
21
- * The default collaborative drive provider.
22
- */
23
- export declare const logger: JupyterFrontEndPlugin<void>;
@@ -1,225 +0,0 @@
1
- /*
2
- * Copyright (c) Jupyter Development Team.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- import { ILabShell, IRouter, JupyterFrontEnd } from '@jupyterlab/application';
6
- import { Dialog, showDialog } from '@jupyterlab/apputils';
7
- import { IDefaultFileBrowser, IFileBrowserFactory } from '@jupyterlab/filebrowser';
8
- import { IEditorTracker } from '@jupyterlab/fileeditor';
9
- import { ILoggerRegistry } from '@jupyterlab/logconsole';
10
- import { INotebookTracker } from '@jupyterlab/notebook';
11
- import { ISettingRegistry } from '@jupyterlab/settingregistry';
12
- import { ITranslator, nullTranslator } from '@jupyterlab/translation';
13
- import { YFile, YNotebook } from '@jupyter/ydoc';
14
- import { ICollaborativeDrive, YDrive } from '@jupyter/docprovider';
15
- /**
16
- * The command IDs used by the file browser plugin.
17
- */
18
- var CommandIDs;
19
- (function (CommandIDs) {
20
- CommandIDs.openPath = 'filebrowser:open-path';
21
- })(CommandIDs || (CommandIDs = {}));
22
- /**
23
- * The default collaborative drive provider.
24
- */
25
- export const drive = {
26
- id: '@jupyter/collaboration-extension:drive',
27
- description: 'The default collaborative drive provider',
28
- provides: ICollaborativeDrive,
29
- requires: [ITranslator],
30
- optional: [],
31
- activate: (app, translator) => {
32
- const trans = translator.load('jupyter_collaboration');
33
- const drive = new YDrive(app.serviceManager.user, trans);
34
- app.serviceManager.contents.addDrive(drive);
35
- return drive;
36
- }
37
- };
38
- /**
39
- * Plugin to register the shared model factory for the content type 'file'.
40
- */
41
- export const yfile = {
42
- id: '@jupyter/collaboration-extension:yfile',
43
- description: "Plugin to register the shared model factory for the content type 'file'",
44
- autoStart: true,
45
- requires: [ICollaborativeDrive],
46
- optional: [],
47
- activate: (app, drive) => {
48
- const yFileFactory = () => {
49
- return new YFile();
50
- };
51
- drive.sharedModelFactory.registerDocumentFactory('file', yFileFactory);
52
- }
53
- };
54
- /**
55
- * Plugin to register the shared model factory for the content type 'notebook'.
56
- */
57
- export const ynotebook = {
58
- id: '@jupyter/collaboration-extension:ynotebook',
59
- description: "Plugin to register the shared model factory for the content type 'notebook'",
60
- autoStart: true,
61
- requires: [ICollaborativeDrive],
62
- optional: [ISettingRegistry],
63
- activate: (app, drive, settingRegistry) => {
64
- let disableDocumentWideUndoRedo = true;
65
- // Fetch settings if possible.
66
- if (settingRegistry) {
67
- settingRegistry
68
- .load('@jupyterlab/notebook-extension:tracker')
69
- .then(settings => {
70
- const updateSettings = (settings) => {
71
- var _a;
72
- const enableDocWideUndo = settings === null || settings === void 0 ? void 0 : settings.get('experimentalEnableDocumentWideUndoRedo').composite;
73
- disableDocumentWideUndoRedo = (_a = !enableDocWideUndo) !== null && _a !== void 0 ? _a : true;
74
- };
75
- updateSettings(settings);
76
- settings.changed.connect((settings) => updateSettings(settings));
77
- });
78
- }
79
- const yNotebookFactory = () => {
80
- return new YNotebook({
81
- disableDocumentWideUndoRedo
82
- });
83
- };
84
- drive.sharedModelFactory.registerDocumentFactory('notebook', yNotebookFactory);
85
- }
86
- };
87
- /**
88
- * The default file browser factory provider.
89
- */
90
- export const defaultFileBrowser = {
91
- id: '@jupyter/collaboration-extension:defaultFileBrowser',
92
- description: 'The default file browser factory provider',
93
- provides: IDefaultFileBrowser,
94
- requires: [ICollaborativeDrive, IFileBrowserFactory],
95
- optional: [
96
- IRouter,
97
- JupyterFrontEnd.ITreeResolver,
98
- ILabShell,
99
- ISettingRegistry
100
- ],
101
- activate: async (app, drive, fileBrowserFactory, router, tree, labShell) => {
102
- const { commands } = app;
103
- app.serviceManager.contents.addDrive(drive);
104
- // Manually restore and load the default file browser.
105
- const defaultBrowser = fileBrowserFactory.createFileBrowser('filebrowser', {
106
- auto: false,
107
- restore: false,
108
- driveName: drive.name
109
- });
110
- void Private.restoreBrowser(defaultBrowser, commands, router, tree, labShell);
111
- return defaultBrowser;
112
- }
113
- };
114
- /**
115
- * The default collaborative drive provider.
116
- */
117
- export const logger = {
118
- id: '@jupyter/collaboration-extension:logger',
119
- description: 'A logging plugin for debugging purposes.',
120
- autoStart: true,
121
- optional: [ILoggerRegistry, IEditorTracker, INotebookTracker, ITranslator],
122
- activate: (app, loggerRegistry, fileTracker, nbTracker, translator) => {
123
- const trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyter_collaboration');
124
- const schemaID = 'https://schema.jupyter.org/jupyter_collaboration/session/v1';
125
- if (!loggerRegistry) {
126
- app.serviceManager.events.stream.connect((_, emission) => {
127
- var _a, _b;
128
- if (emission.schema_id === schemaID) {
129
- console.debug(`[${emission.room}(${emission.path})] ${(_a = emission.action) !== null && _a !== void 0 ? _a : ''}: ${(_b = emission.msg) !== null && _b !== void 0 ? _b : ''}`);
130
- if (emission.level === 'WARNING') {
131
- showDialog({
132
- title: trans.__('Warning'),
133
- body: trans.__(`Two collaborative sessions are accessing the file ${emission.path} simultaneously.
134
- \nOpening the same file using different views simultaneously is not supported. Please, close one view; otherwise, you might lose some of your progress.`),
135
- buttons: [Dialog.okButton()]
136
- });
137
- }
138
- }
139
- });
140
- return;
141
- }
142
- const loggers = new Map();
143
- const addLogger = (sender, document) => {
144
- const logger = loggerRegistry.getLogger(document.context.path);
145
- loggers.set(document.context.localPath, logger);
146
- document.disposed.connect(document => {
147
- loggers.delete(document.context.localPath);
148
- });
149
- };
150
- if (fileTracker) {
151
- fileTracker.widgetAdded.connect(addLogger);
152
- }
153
- if (nbTracker) {
154
- nbTracker.widgetAdded.connect(addLogger);
155
- }
156
- void (async () => {
157
- var _a, _b;
158
- const { events } = app.serviceManager;
159
- for await (const emission of events.stream) {
160
- if (emission.schema_id === schemaID) {
161
- const logger = loggers.get(emission.path);
162
- logger === null || logger === void 0 ? void 0 : logger.log({
163
- type: 'text',
164
- level: emission.level.toLowerCase(),
165
- data: `[${emission.room}] ${(_a = emission.action) !== null && _a !== void 0 ? _a : ''}: ${(_b = emission.msg) !== null && _b !== void 0 ? _b : ''}`
166
- });
167
- if (emission.level === 'WARNING') {
168
- showDialog({
169
- title: trans.__('Warning'),
170
- body: trans.__(`Two collaborative sessions are accessing the file %1 simultaneously.
171
- \nOpening a document with multiple views simultaneously is not supported. Please close one view; otherwise, you might lose some of your progress.`, emission.path),
172
- buttons: [Dialog.warnButton({ label: trans.__('Ok') })]
173
- });
174
- }
175
- }
176
- }
177
- })();
178
- }
179
- };
180
- var Private;
181
- (function (Private) {
182
- /**
183
- * Restores file browser state and overrides state if tree resolver resolves.
184
- */
185
- async function restoreBrowser(browser, commands, router, tree, labShell) {
186
- const restoring = 'jp-mod-restoring';
187
- browser.addClass(restoring);
188
- if (!router) {
189
- await browser.model.restore(browser.id);
190
- await browser.model.refresh();
191
- browser.removeClass(restoring);
192
- return;
193
- }
194
- const listener = async () => {
195
- router.routed.disconnect(listener);
196
- const paths = await (tree === null || tree === void 0 ? void 0 : tree.paths);
197
- if ((paths === null || paths === void 0 ? void 0 : paths.file) || (paths === null || paths === void 0 ? void 0 : paths.browser)) {
198
- // Restore the model without populating it.
199
- await browser.model.restore(browser.id, false);
200
- if (paths.file) {
201
- await commands.execute(CommandIDs.openPath, {
202
- path: paths.file,
203
- dontShowBrowser: true
204
- });
205
- }
206
- if (paths.browser) {
207
- await commands.execute(CommandIDs.openPath, {
208
- path: paths.browser,
209
- dontShowBrowser: true
210
- });
211
- }
212
- }
213
- else {
214
- await browser.model.restore(browser.id);
215
- await browser.model.refresh();
216
- }
217
- browser.removeClass(restoring);
218
- if (labShell === null || labShell === void 0 ? void 0 : labShell.isEmpty('main')) {
219
- void commands.execute('launcher:create');
220
- }
221
- };
222
- router.routed.connect(listener);
223
- }
224
- Private.restoreBrowser = restoreBrowser;
225
- })(Private || (Private = {}));