@jupyter/docprovider 4.1.2 → 4.2.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/ydrive.d.ts +7 -4
- package/lib/ydrive.js +17 -6
- package/package.json +9 -9
package/lib/ydrive.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TranslationBundle } from '@jupyterlab/translation';
|
|
2
|
-
import { Contents, IContentProvider,
|
|
2
|
+
import { Contents, IContentProvider, ServerConnection, User } from '@jupyterlab/services';
|
|
3
3
|
import { ISignal } from '@lumino/signaling';
|
|
4
4
|
import { IDocumentProvider, ISharedModelFactory } from '@jupyter/collaborative-drive';
|
|
5
5
|
import { Awareness } from 'y-protocols/awareness';
|
|
@@ -11,15 +11,17 @@ export interface IForkProvider {
|
|
|
11
11
|
format: string;
|
|
12
12
|
}
|
|
13
13
|
declare namespace RtcContentProvider {
|
|
14
|
-
interface IOptions
|
|
14
|
+
interface IOptions {
|
|
15
15
|
user: User.IManager;
|
|
16
16
|
trans: TranslationBundle;
|
|
17
17
|
globalAwareness: Awareness | null;
|
|
18
|
+
serverSettings: ServerConnection.ISettings;
|
|
18
19
|
docmanagerSettings: ISettingRegistry.ISettings | null;
|
|
20
|
+
currentDrive: Contents.IDrive;
|
|
19
21
|
fileChanged?: ISignal<Contents.IDrive, Contents.IChangedArgs>;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
|
-
export declare class RtcContentProvider
|
|
24
|
+
export declare class RtcContentProvider implements IContentProvider {
|
|
23
25
|
constructor(options: RtcContentProvider.IOptions);
|
|
24
26
|
/**
|
|
25
27
|
* SharedModel factory for the content provider.
|
|
@@ -46,7 +48,7 @@ export declare class RtcContentProvider extends RestContentProvider implements I
|
|
|
46
48
|
* @returns A promise which resolves with the file content model when the
|
|
47
49
|
* file is saved.
|
|
48
50
|
*/
|
|
49
|
-
save(localPath: string, options?: Partial<Contents.IModel>): Promise<Contents.IModel>;
|
|
51
|
+
save(localPath: string, options?: Partial<Contents.IModel> & Contents.IContentProvisionOptions): Promise<Contents.IModel>;
|
|
50
52
|
/**
|
|
51
53
|
* A signal emitted when a file operation takes place.
|
|
52
54
|
*/
|
|
@@ -54,6 +56,7 @@ export declare class RtcContentProvider extends RestContentProvider implements I
|
|
|
54
56
|
private _onCreate;
|
|
55
57
|
private _user;
|
|
56
58
|
private _saveCounter;
|
|
59
|
+
private _currentDrive;
|
|
57
60
|
private _trans;
|
|
58
61
|
private _globalAwareness;
|
|
59
62
|
private _providers;
|
package/lib/ydrive.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
import { PageConfig, URLExt } from '@jupyterlab/coreutils';
|
|
4
|
-
import { RestContentProvider } from '@jupyterlab/services';
|
|
5
4
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
6
5
|
import { Signal } from '@lumino/signaling';
|
|
7
6
|
import { WebSocketProvider } from './yprovider';
|
|
@@ -13,9 +12,8 @@ const RAW_MESSAGE_TYPE = 2;
|
|
|
13
12
|
* The url for the default drive service.
|
|
14
13
|
*/
|
|
15
14
|
const DOCUMENT_PROVIDER_URL = 'api/collaboration/room';
|
|
16
|
-
export class RtcContentProvider
|
|
15
|
+
export class RtcContentProvider {
|
|
17
16
|
constructor(options) {
|
|
18
|
-
super(options);
|
|
19
17
|
this._onCreate = (options, sharedModel) => {
|
|
20
18
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
21
19
|
if (typeof options.format !== 'string') {
|
|
@@ -174,6 +172,7 @@ export class RtcContentProvider extends RestContentProvider {
|
|
|
174
172
|
this._trans = options.trans;
|
|
175
173
|
this._globalAwareness = options.globalAwareness;
|
|
176
174
|
this._serverSettings = options.serverSettings;
|
|
175
|
+
this._currentDrive = options.currentDrive;
|
|
177
176
|
this.sharedModelFactory = new SharedModelFactory(this._onCreate);
|
|
178
177
|
this._providers = new Map();
|
|
179
178
|
this._docmanagerSettings = options.docmanagerSettings;
|
|
@@ -201,7 +200,12 @@ export class RtcContentProvider extends RestContentProvider {
|
|
|
201
200
|
// Use `Promise.all` to reject as soon as possible. The Context will
|
|
202
201
|
// show a dialog to the user.
|
|
203
202
|
const [model] = await Promise.all([
|
|
204
|
-
|
|
203
|
+
// Not calling get() with options.contentProviderId otherwise it's an infinite loop
|
|
204
|
+
this._currentDrive.get(localPath, {
|
|
205
|
+
...options,
|
|
206
|
+
content: false,
|
|
207
|
+
contentProviderId: undefined
|
|
208
|
+
}),
|
|
205
209
|
provider.ready
|
|
206
210
|
]);
|
|
207
211
|
// The server doesn't return a model with a format when content is false,
|
|
@@ -209,7 +213,11 @@ export class RtcContentProvider extends RestContentProvider {
|
|
|
209
213
|
return { ...model, format: options.format };
|
|
210
214
|
}
|
|
211
215
|
}
|
|
212
|
-
|
|
216
|
+
// Not calling get() with options.contentProviderId otherwise it's an infinite loop
|
|
217
|
+
return this._currentDrive.get(localPath, {
|
|
218
|
+
...options,
|
|
219
|
+
contentProviderId: undefined
|
|
220
|
+
});
|
|
213
221
|
}
|
|
214
222
|
/**
|
|
215
223
|
* Save a file.
|
|
@@ -290,7 +298,10 @@ export class RtcContentProvider extends RestContentProvider {
|
|
|
290
298
|
console.warn(`Could not find a provider for ${localPath}, falling back to REST API save`);
|
|
291
299
|
}
|
|
292
300
|
}
|
|
293
|
-
return
|
|
301
|
+
return this._currentDrive.save(localPath, {
|
|
302
|
+
...options,
|
|
303
|
+
contentProviderId: undefined
|
|
304
|
+
});
|
|
294
305
|
}
|
|
295
306
|
/**
|
|
296
307
|
* A signal emitted when a file operation takes place.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter/docprovider",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0-alpha.0",
|
|
4
4
|
"description": "JupyterLab - Document Provider",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyter-collaboration",
|
|
6
6
|
"bugs": {
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"watch": "tsc -b --watch"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@jupyter/collaborative-drive": "^4.
|
|
44
|
+
"@jupyter/collaborative-drive": "^4.2.0-alpha.0",
|
|
45
45
|
"@jupyter/ydoc": "^2.1.3 || ^3.0.0",
|
|
46
|
-
"@jupyterlab/apputils": "^4.
|
|
47
|
-
"@jupyterlab/cells": "^4.
|
|
48
|
-
"@jupyterlab/coreutils": "^6.
|
|
49
|
-
"@jupyterlab/notebook": "^4.
|
|
50
|
-
"@jupyterlab/services": "^7.
|
|
51
|
-
"@jupyterlab/translation": "^4.
|
|
46
|
+
"@jupyterlab/apputils": "^4.5.0",
|
|
47
|
+
"@jupyterlab/cells": "^4.5.0",
|
|
48
|
+
"@jupyterlab/coreutils": "^6.5.0",
|
|
49
|
+
"@jupyterlab/notebook": "^4.5.0",
|
|
50
|
+
"@jupyterlab/services": "^7.5.0",
|
|
51
|
+
"@jupyterlab/translation": "^4.5.0",
|
|
52
52
|
"@lumino/coreutils": "^2.2.1",
|
|
53
53
|
"@lumino/disposable": "^2.1.4",
|
|
54
54
|
"@lumino/signaling": "^2.1.4",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"yjs": "^13.5.40"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@jupyterlab/testing": "^4.
|
|
61
|
+
"@jupyterlab/testing": "^4.5.0",
|
|
62
62
|
"@types/jest": "^29.2.0",
|
|
63
63
|
"jest": "^29.5.0",
|
|
64
64
|
"rimraf": "^4.1.2",
|