@jupyter/docprovider-extension 3.1.0-rc.0 → 4.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/filebrowser.d.ts +2 -10
- package/lib/filebrowser.js +57 -123
- package/lib/forkManager.js +4 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -3
- package/package.json +15 -15
package/lib/filebrowser.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The default collaborative drive provider.
|
|
6
|
-
*/
|
|
7
|
-
export declare const drive: JupyterFrontEndPlugin<ICollaborativeDrive>;
|
|
2
|
+
import { ICollaborativeContentProvider } from '@jupyter/collaborative-drive';
|
|
3
|
+
export declare const rtcContentProvider: JupyterFrontEndPlugin<ICollaborativeContentProvider>;
|
|
8
4
|
/**
|
|
9
5
|
* Plugin to register the shared model factory for the content type 'file'.
|
|
10
6
|
*/
|
|
@@ -17,10 +13,6 @@ export declare const ynotebook: JupyterFrontEndPlugin<void>;
|
|
|
17
13
|
* A plugin to add a timeline slider status item to the status bar.
|
|
18
14
|
*/
|
|
19
15
|
export declare const statusBarTimeline: JupyterFrontEndPlugin<void>;
|
|
20
|
-
/**
|
|
21
|
-
* The default file browser factory provider.
|
|
22
|
-
*/
|
|
23
|
-
export declare const defaultFileBrowser: JupyterFrontEndPlugin<IDefaultFileBrowser>;
|
|
24
16
|
/**
|
|
25
17
|
* The default collaborative drive provider.
|
|
26
18
|
*/
|
package/lib/filebrowser.js
CHANGED
|
@@ -2,45 +2,48 @@
|
|
|
2
2
|
* Copyright (c) Jupyter Development Team.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
import { ILabShell, IRouter, JupyterFrontEnd } from '@jupyterlab/application';
|
|
6
5
|
import { Dialog, showDialog } from '@jupyterlab/apputils';
|
|
7
6
|
import { Widget } from '@lumino/widgets';
|
|
8
|
-
import { IDefaultFileBrowser, IFileBrowserFactory } from '@jupyterlab/filebrowser';
|
|
9
7
|
import { IStatusBar } from '@jupyterlab/statusbar';
|
|
10
|
-
import { IEditorTracker } from '@jupyterlab/fileeditor';
|
|
8
|
+
import { IEditorTracker, IEditorWidgetFactory } from '@jupyterlab/fileeditor';
|
|
11
9
|
import { ILoggerRegistry } from '@jupyterlab/logconsole';
|
|
12
|
-
import { INotebookTracker } from '@jupyterlab/notebook';
|
|
10
|
+
import { INotebookTracker, INotebookWidgetFactory } from '@jupyterlab/notebook';
|
|
13
11
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
14
12
|
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
15
13
|
import { YFile, YNotebook } from '@jupyter/ydoc';
|
|
16
|
-
import {
|
|
17
|
-
import { TimelineWidget,
|
|
14
|
+
import { ICollaborativeContentProvider, IGlobalAwareness } from '@jupyter/collaborative-drive';
|
|
15
|
+
import { TimelineWidget, RtcContentProvider } from '@jupyter/docprovider';
|
|
18
16
|
import { URLExt } from '@jupyterlab/coreutils';
|
|
19
|
-
/**
|
|
20
|
-
* The command IDs used by the file browser plugin.
|
|
21
|
-
*/
|
|
22
|
-
var CommandIDs;
|
|
23
|
-
(function (CommandIDs) {
|
|
24
|
-
CommandIDs.openPath = 'filebrowser:open-path';
|
|
25
|
-
})(CommandIDs || (CommandIDs = {}));
|
|
26
17
|
const DOCUMENT_TIMELINE_URL = 'api/collaboration/timeline';
|
|
27
18
|
const TWO_SESSIONS_WARNING = 'The file %1 has been opened with two different views. ' +
|
|
28
19
|
'This is not supported. Please close this view; otherwise, ' +
|
|
29
20
|
'some of your edits may not be saved properly.';
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
id: '@jupyter/docprovider-extension:drive',
|
|
35
|
-
description: 'The default collaborative drive provider',
|
|
36
|
-
provides: ICollaborativeDrive,
|
|
21
|
+
export const rtcContentProvider = {
|
|
22
|
+
id: '@jupyter/docprovider-extension:content-provider',
|
|
23
|
+
description: 'The RTC content provider',
|
|
24
|
+
provides: ICollaborativeContentProvider,
|
|
37
25
|
requires: [ITranslator],
|
|
38
26
|
optional: [IGlobalAwareness],
|
|
39
27
|
activate: (app, translator, globalAwareness) => {
|
|
40
28
|
const trans = translator.load('jupyter_collaboration');
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
const defaultDrive = app.serviceManager.contents
|
|
30
|
+
.defaultDrive;
|
|
31
|
+
if (!defaultDrive) {
|
|
32
|
+
throw Error('Cannot initialize content provider: default drive property not accessible on contents manager instance.');
|
|
33
|
+
}
|
|
34
|
+
const registry = defaultDrive.contentProviderRegistry;
|
|
35
|
+
if (!registry) {
|
|
36
|
+
throw Error('Cannot initialize content provider: no content provider registry.');
|
|
37
|
+
}
|
|
38
|
+
const rtcContentProvider = new RtcContentProvider({
|
|
39
|
+
apiEndpoint: '/api/contents',
|
|
40
|
+
serverSettings: defaultDrive.serverSettings,
|
|
41
|
+
user: app.serviceManager.user,
|
|
42
|
+
trans,
|
|
43
|
+
globalAwareness
|
|
44
|
+
});
|
|
45
|
+
registry.register('rtc', rtcContentProvider);
|
|
46
|
+
return rtcContentProvider;
|
|
44
47
|
}
|
|
45
48
|
};
|
|
46
49
|
/**
|
|
@@ -50,13 +53,13 @@ export const yfile = {
|
|
|
50
53
|
id: '@jupyter/docprovider-extension:yfile',
|
|
51
54
|
description: "Plugin to register the shared model factory for the content type 'file'",
|
|
52
55
|
autoStart: true,
|
|
53
|
-
requires: [
|
|
54
|
-
|
|
55
|
-
activate: (app, drive) => {
|
|
56
|
+
requires: [ICollaborativeContentProvider, IEditorWidgetFactory],
|
|
57
|
+
activate: (app, contentProvider, editorFactory) => {
|
|
56
58
|
const yFileFactory = () => {
|
|
57
59
|
return new YFile();
|
|
58
60
|
};
|
|
59
|
-
|
|
61
|
+
contentProvider.sharedModelFactory.registerDocumentFactory('file', yFileFactory);
|
|
62
|
+
editorFactory.contentProviderId = 'rtc';
|
|
60
63
|
}
|
|
61
64
|
};
|
|
62
65
|
/**
|
|
@@ -66,9 +69,9 @@ export const ynotebook = {
|
|
|
66
69
|
id: '@jupyter/docprovider-extension:ynotebook',
|
|
67
70
|
description: "Plugin to register the shared model factory for the content type 'notebook'",
|
|
68
71
|
autoStart: true,
|
|
69
|
-
requires: [
|
|
72
|
+
requires: [ICollaborativeContentProvider, INotebookWidgetFactory],
|
|
70
73
|
optional: [ISettingRegistry],
|
|
71
|
-
activate: (app,
|
|
74
|
+
activate: (app, contentProvider, notebookFactory, settingRegistry) => {
|
|
72
75
|
let disableDocumentWideUndoRedo = true;
|
|
73
76
|
// Fetch settings if possible.
|
|
74
77
|
if (settingRegistry) {
|
|
@@ -89,7 +92,8 @@ export const ynotebook = {
|
|
|
89
92
|
disableDocumentWideUndoRedo
|
|
90
93
|
});
|
|
91
94
|
};
|
|
92
|
-
|
|
95
|
+
contentProvider.sharedModelFactory.registerDocumentFactory('notebook', yNotebookFactory);
|
|
96
|
+
notebookFactory.contentProviderId = 'rtc';
|
|
93
97
|
}
|
|
94
98
|
};
|
|
95
99
|
/**
|
|
@@ -99,30 +103,32 @@ export const statusBarTimeline = {
|
|
|
99
103
|
id: '@jupyter/docprovider-extension:statusBarTimeline',
|
|
100
104
|
description: 'Plugin to add a timeline slider to the status bar',
|
|
101
105
|
autoStart: true,
|
|
102
|
-
requires: [IStatusBar,
|
|
103
|
-
activate: async (app, statusBar,
|
|
106
|
+
requires: [IStatusBar, ICollaborativeContentProvider],
|
|
107
|
+
activate: async (app, statusBar, contentProvider) => {
|
|
104
108
|
try {
|
|
105
109
|
let sliderItem = null;
|
|
106
110
|
let timelineWidget = null;
|
|
107
111
|
const updateTimelineForDocument = async (documentPath, documentId) => {
|
|
108
|
-
if (documentId
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
112
|
+
if (!documentId) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// Dispose of the previous timelineWidget if it exists
|
|
116
|
+
if (timelineWidget) {
|
|
117
|
+
timelineWidget.dispose();
|
|
118
|
+
timelineWidget = null;
|
|
119
|
+
}
|
|
120
|
+
const [format, type] = documentId.split(':');
|
|
121
|
+
const provider = contentProvider.providers.get(`${format}:${type}:${documentPath}`);
|
|
122
|
+
if (!provider) {
|
|
123
|
+
// this can happen for documents which are not provisioned with RTC
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const forkProvider = provider;
|
|
127
|
+
const fullPath = URLExt.join(app.serviceManager.serverSettings.baseUrl, DOCUMENT_TIMELINE_URL, documentPath);
|
|
128
|
+
timelineWidget = new TimelineWidget(fullPath, forkProvider, forkProvider.contentType, forkProvider.format, DOCUMENT_TIMELINE_URL);
|
|
129
|
+
const elt = document.getElementById('jp-slider-status-bar');
|
|
130
|
+
if (elt && !timelineWidget.isAttached) {
|
|
131
|
+
Widget.attach(timelineWidget, elt);
|
|
126
132
|
}
|
|
127
133
|
};
|
|
128
134
|
if (app.shell.currentChanged) {
|
|
@@ -155,9 +161,8 @@ export const statusBarTimeline = {
|
|
|
155
161
|
if (currentWidget &&
|
|
156
162
|
currentWidget.context &&
|
|
157
163
|
typeof currentWidget.context.path === 'string') {
|
|
158
|
-
const documentPath = currentWidget.context.path;
|
|
159
164
|
const documentId = currentWidget.context.model.sharedModel.getState('document_id');
|
|
160
|
-
return !!documentId &&
|
|
165
|
+
return (!!documentId && !!currentWidget.context.model.collaborative);
|
|
161
166
|
}
|
|
162
167
|
return false;
|
|
163
168
|
}
|
|
@@ -170,31 +175,6 @@ export const statusBarTimeline = {
|
|
|
170
175
|
}
|
|
171
176
|
}
|
|
172
177
|
};
|
|
173
|
-
/**
|
|
174
|
-
* The default file browser factory provider.
|
|
175
|
-
*/
|
|
176
|
-
export const defaultFileBrowser = {
|
|
177
|
-
id: '@jupyter/docprovider-extension:defaultFileBrowser',
|
|
178
|
-
description: 'The default file browser factory provider',
|
|
179
|
-
provides: IDefaultFileBrowser,
|
|
180
|
-
requires: [ICollaborativeDrive, IFileBrowserFactory],
|
|
181
|
-
optional: [IRouter, JupyterFrontEnd.ITreeResolver, ILabShell, ITranslator],
|
|
182
|
-
activate: async (app, drive, fileBrowserFactory, router, tree, labShell, translator) => {
|
|
183
|
-
const { commands } = app;
|
|
184
|
-
const trans = (translator !== null && translator !== void 0 ? translator : nullTranslator).load('jupyterlab');
|
|
185
|
-
app.serviceManager.contents.addDrive(drive);
|
|
186
|
-
// Manually restore and load the default file browser.
|
|
187
|
-
const defaultBrowser = fileBrowserFactory.createFileBrowser('filebrowser', {
|
|
188
|
-
auto: false,
|
|
189
|
-
restore: false,
|
|
190
|
-
driveName: drive.name
|
|
191
|
-
});
|
|
192
|
-
defaultBrowser.node.setAttribute('role', 'region');
|
|
193
|
-
defaultBrowser.node.setAttribute('aria-label', trans.__('File Browser Section'));
|
|
194
|
-
void Private.restoreBrowser(defaultBrowser, commands, router, tree, labShell);
|
|
195
|
-
return defaultBrowser;
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
178
|
/**
|
|
199
179
|
* The default collaborative drive provider.
|
|
200
180
|
*/
|
|
@@ -259,49 +239,3 @@ export const logger = {
|
|
|
259
239
|
})();
|
|
260
240
|
}
|
|
261
241
|
};
|
|
262
|
-
var Private;
|
|
263
|
-
(function (Private) {
|
|
264
|
-
/**
|
|
265
|
-
* Restores file browser state and overrides state if tree resolver resolves.
|
|
266
|
-
*/
|
|
267
|
-
async function restoreBrowser(browser, commands, router, tree, labShell) {
|
|
268
|
-
const restoring = 'jp-mod-restoring';
|
|
269
|
-
browser.addClass(restoring);
|
|
270
|
-
if (!router) {
|
|
271
|
-
await browser.model.restore(browser.id);
|
|
272
|
-
await browser.model.refresh();
|
|
273
|
-
browser.removeClass(restoring);
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
const listener = async () => {
|
|
277
|
-
router.routed.disconnect(listener);
|
|
278
|
-
const paths = await (tree === null || tree === void 0 ? void 0 : tree.paths);
|
|
279
|
-
if ((paths === null || paths === void 0 ? void 0 : paths.file) || (paths === null || paths === void 0 ? void 0 : paths.browser)) {
|
|
280
|
-
// Restore the model without populating it.
|
|
281
|
-
await browser.model.restore(browser.id, false);
|
|
282
|
-
if (paths.file) {
|
|
283
|
-
await commands.execute(CommandIDs.openPath, {
|
|
284
|
-
path: paths.file,
|
|
285
|
-
dontShowBrowser: true
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
if (paths.browser) {
|
|
289
|
-
await commands.execute(CommandIDs.openPath, {
|
|
290
|
-
path: paths.browser,
|
|
291
|
-
dontShowBrowser: true
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
await browser.model.restore(browser.id);
|
|
297
|
-
await browser.model.refresh();
|
|
298
|
-
}
|
|
299
|
-
browser.removeClass(restoring);
|
|
300
|
-
if (labShell === null || labShell === void 0 ? void 0 : labShell.isEmpty('main')) {
|
|
301
|
-
void commands.execute('launcher:create');
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
router.routed.connect(listener);
|
|
305
|
-
}
|
|
306
|
-
Private.restoreBrowser = restoreBrowser;
|
|
307
|
-
})(Private || (Private = {}));
|
package/lib/forkManager.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Copyright (c) Jupyter Development Team.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { ICollaborativeContentProvider } from '@jupyter/collaborative-drive';
|
|
6
6
|
import { ForkManager, IForkManagerToken } from '@jupyter/docprovider';
|
|
7
7
|
export const forkManagerPlugin = {
|
|
8
8
|
id: '@jupyter/docprovider-extension:forkManager',
|
|
9
9
|
autoStart: true,
|
|
10
|
-
requires: [
|
|
10
|
+
requires: [ICollaborativeContentProvider],
|
|
11
11
|
provides: IForkManagerToken,
|
|
12
|
-
activate: (app,
|
|
12
|
+
activate: (app, contentProvider) => {
|
|
13
13
|
const eventManager = app.serviceManager.events;
|
|
14
|
-
const manager = new ForkManager({
|
|
14
|
+
const manager = new ForkManager({ contentProvider, eventManager });
|
|
15
15
|
return manager;
|
|
16
16
|
}
|
|
17
17
|
};
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -4,17 +4,16 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
* @module collaboration-extension
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { rtcContentProvider, yfile, ynotebook, logger, statusBarTimeline } from './filebrowser';
|
|
8
8
|
import { notebookCellExecutor } from './executor';
|
|
9
9
|
import { forkManagerPlugin } from './forkManager';
|
|
10
10
|
/**
|
|
11
11
|
* Export the plugins as default.
|
|
12
12
|
*/
|
|
13
13
|
const plugins = [
|
|
14
|
-
|
|
14
|
+
rtcContentProvider,
|
|
15
15
|
yfile,
|
|
16
16
|
ynotebook,
|
|
17
|
-
defaultFileBrowser,
|
|
18
17
|
logger,
|
|
19
18
|
notebookCellExecutor,
|
|
20
19
|
statusBarTimeline,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter/docprovider-extension",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "JupyterLab - Collaborative Shared Models",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -53,29 +53,29 @@
|
|
|
53
53
|
"watch:labextension": "jupyter labextension watch ."
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@jupyter/collaborative-drive": "^
|
|
57
|
-
"@jupyter/docprovider": "^
|
|
58
|
-
"@jupyter/ydoc": "^2.
|
|
59
|
-
"@jupyterlab/application": "^4.
|
|
60
|
-
"@jupyterlab/apputils": "^4.
|
|
61
|
-
"@jupyterlab/docregistry": "^4.
|
|
62
|
-
"@jupyterlab/filebrowser": "^4.
|
|
63
|
-
"@jupyterlab/fileeditor": "^4.
|
|
64
|
-
"@jupyterlab/logconsole": "^4.
|
|
65
|
-
"@jupyterlab/notebook": "^4.
|
|
66
|
-
"@jupyterlab/settingregistry": "^4.
|
|
67
|
-
"@jupyterlab/translation": "^4.
|
|
56
|
+
"@jupyter/collaborative-drive": "^4.0.0-alpha.0",
|
|
57
|
+
"@jupyter/docprovider": "^4.0.0-alpha.0",
|
|
58
|
+
"@jupyter/ydoc": "^2.1.3 || ^3.0.0",
|
|
59
|
+
"@jupyterlab/application": "^4.4.0-alpha.2",
|
|
60
|
+
"@jupyterlab/apputils": "^4.4.0-alpha.2",
|
|
61
|
+
"@jupyterlab/docregistry": "^4.4.0-alpha.2",
|
|
62
|
+
"@jupyterlab/filebrowser": "^4.4.0-alpha.2",
|
|
63
|
+
"@jupyterlab/fileeditor": "^4.4.0-alpha.2",
|
|
64
|
+
"@jupyterlab/logconsole": "^4.4.0-alpha.2",
|
|
65
|
+
"@jupyterlab/notebook": "^4.4.0-alpha.2",
|
|
66
|
+
"@jupyterlab/settingregistry": "^4.4.0-alpha.2",
|
|
67
|
+
"@jupyterlab/translation": "^4.4.0-alpha.2",
|
|
68
68
|
"@lumino/commands": "^2.1.0",
|
|
69
69
|
"y-protocols": "^1.0.5",
|
|
70
70
|
"y-websocket": "^1.3.15",
|
|
71
71
|
"yjs": "^13.5.40"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@jupyterlab/builder": "^4.0.
|
|
74
|
+
"@jupyterlab/builder": "^4.4.0-alpha.2",
|
|
75
75
|
"@types/react": "~18.3.1",
|
|
76
76
|
"npm-run-all": "^4.1.5",
|
|
77
77
|
"rimraf": "^4.1.2",
|
|
78
|
-
"typescript": "~5.
|
|
78
|
+
"typescript": "~5.1.6"
|
|
79
79
|
},
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|