@jupyter/docprovider 1.0.0-alpha.5 → 1.0.0-alpha.7
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 +1 -0
- package/lib/index.js +1 -0
- package/lib/tokens.d.ts +33 -0
- package/lib/tokens.js +7 -0
- package/lib/ydrive.d.ts +3 -34
- package/lib/ydrive.js +11 -23
- package/package.json +4 -4
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/tokens.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DocumentChange, YDocument } from '@jupyter/ydoc';
|
|
2
|
+
import { Contents } from '@jupyterlab/services';
|
|
3
|
+
import { Token } from '@lumino/coreutils';
|
|
4
|
+
/**
|
|
5
|
+
* The collaborative drive.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ICollaborativeDrive: Token<ICollaborativeDrive>;
|
|
8
|
+
/**
|
|
9
|
+
* A document factory for registering shared models
|
|
10
|
+
*/
|
|
11
|
+
export type SharedDocumentFactory = (options: Contents.ISharedFactoryOptions) => YDocument<DocumentChange>;
|
|
12
|
+
/**
|
|
13
|
+
* A Collaborative implementation for an `IDrive`, talking to the
|
|
14
|
+
* server using the Jupyter REST API and a WebSocket connection.
|
|
15
|
+
*/
|
|
16
|
+
export interface ICollaborativeDrive extends Contents.IDrive {
|
|
17
|
+
/**
|
|
18
|
+
* SharedModel factory for the YDrive.
|
|
19
|
+
*/
|
|
20
|
+
readonly sharedModelFactory: ISharedModelFactory;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Yjs sharedModel factory for real-time collaboration.
|
|
24
|
+
*/
|
|
25
|
+
export interface ISharedModelFactory extends Contents.ISharedFactory {
|
|
26
|
+
/**
|
|
27
|
+
* Register a SharedDocumentFactory.
|
|
28
|
+
*
|
|
29
|
+
* @param type Document type
|
|
30
|
+
* @param factory Document factory
|
|
31
|
+
*/
|
|
32
|
+
registerDocumentFactory(type: Contents.ContentType, factory: SharedDocumentFactory): void;
|
|
33
|
+
}
|
package/lib/tokens.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
import { Token } from '@lumino/coreutils';
|
|
4
|
+
/**
|
|
5
|
+
* The collaborative drive.
|
|
6
|
+
*/
|
|
7
|
+
export const ICollaborativeDrive = new Token('@jupyter/collaboration-extension:ICollaborativeDrive');
|
package/lib/ydrive.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DocumentChange, ISharedDocument, YDocument } from '@jupyter/ydoc';
|
|
2
1
|
import { TranslationBundle } from '@jupyterlab/translation';
|
|
3
2
|
import { Contents, Drive, User } from '@jupyterlab/services';
|
|
3
|
+
import { ICollaborativeDrive, ISharedModelFactory } from './tokens';
|
|
4
4
|
/**
|
|
5
5
|
* A Collaborative implementation for an `IDrive`, talking to the
|
|
6
6
|
* server using the Jupyter REST API and a WebSocket connection.
|
|
7
7
|
*/
|
|
8
|
-
export declare class YDrive extends Drive {
|
|
8
|
+
export declare class YDrive extends Drive implements ICollaborativeDrive {
|
|
9
9
|
/**
|
|
10
10
|
* Construct a new drive object.
|
|
11
11
|
*
|
|
@@ -15,7 +15,7 @@ export declare class YDrive extends Drive {
|
|
|
15
15
|
/**
|
|
16
16
|
* SharedModel factory for the YDrive.
|
|
17
17
|
*/
|
|
18
|
-
readonly sharedModelFactory:
|
|
18
|
+
readonly sharedModelFactory: ISharedModelFactory;
|
|
19
19
|
/**
|
|
20
20
|
* Dispose of the resources held by the manager.
|
|
21
21
|
*/
|
|
@@ -48,34 +48,3 @@ export declare class YDrive extends Drive {
|
|
|
48
48
|
private _trans;
|
|
49
49
|
private _providers;
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Yjs sharedModel factory for real-time collaboration.
|
|
53
|
-
*/
|
|
54
|
-
declare class SharedModelFactory implements Contents.ISharedFactory {
|
|
55
|
-
private _onCreate;
|
|
56
|
-
private _documentOptions;
|
|
57
|
-
/**
|
|
58
|
-
* Shared model factory constructor
|
|
59
|
-
*
|
|
60
|
-
* @param _onCreate Callback on new document model creation
|
|
61
|
-
*/
|
|
62
|
-
constructor(_onCreate: (options: Contents.ISharedFactoryOptions, sharedModel: YDocument<DocumentChange>) => void);
|
|
63
|
-
/**
|
|
64
|
-
* Whether the IDrive supports real-time collaboration or not.
|
|
65
|
-
*/
|
|
66
|
-
readonly collaborative = true;
|
|
67
|
-
/**
|
|
68
|
-
* Set shared document model options
|
|
69
|
-
*
|
|
70
|
-
* @param type Document type
|
|
71
|
-
* @param value Document options
|
|
72
|
-
*/
|
|
73
|
-
setDocumentOptions(type: Contents.ContentType, value: Record<string, any>): void;
|
|
74
|
-
/**
|
|
75
|
-
* Create a new `ISharedDocument` instance.
|
|
76
|
-
*
|
|
77
|
-
* It should return `undefined` if the factory is not able to create a `ISharedDocument`.
|
|
78
|
-
*/
|
|
79
|
-
createNew(options: Contents.ISharedFactoryOptions): ISharedDocument | undefined;
|
|
80
|
-
}
|
|
81
|
-
export {};
|
package/lib/ydrive.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
|
-
import { YFile, YNotebook } from '@jupyter/ydoc';
|
|
4
3
|
import { URLExt } from '@jupyterlab/coreutils';
|
|
5
4
|
import { Drive } from '@jupyterlab/services';
|
|
6
5
|
import { WebSocketProvider } from './yprovider';
|
|
@@ -19,7 +18,7 @@ export class YDrive extends Drive {
|
|
|
19
18
|
* @param user - The user manager to add the identity to the awareness of documents.
|
|
20
19
|
*/
|
|
21
20
|
constructor(user, translator) {
|
|
22
|
-
super({ name: '
|
|
21
|
+
super({ name: 'RTC' });
|
|
23
22
|
this._onCreate = (options, sharedModel) => {
|
|
24
23
|
if (typeof options.format !== 'string') {
|
|
25
24
|
return;
|
|
@@ -127,19 +126,16 @@ class SharedModelFactory {
|
|
|
127
126
|
* Whether the IDrive supports real-time collaboration or not.
|
|
128
127
|
*/
|
|
129
128
|
this.collaborative = true;
|
|
130
|
-
this.
|
|
131
|
-
this._documentOptions.set('notebook', {
|
|
132
|
-
disableDocumentWideUndoRedo: true
|
|
133
|
-
});
|
|
129
|
+
this._documentFactories = new Map();
|
|
134
130
|
}
|
|
135
131
|
/**
|
|
136
|
-
*
|
|
132
|
+
* Register a SharedDocumentFactory.
|
|
137
133
|
*
|
|
138
134
|
* @param type Document type
|
|
139
|
-
* @param
|
|
135
|
+
* @param factory Document factory
|
|
140
136
|
*/
|
|
141
|
-
|
|
142
|
-
this.
|
|
137
|
+
registerDocumentFactory(type, factory) {
|
|
138
|
+
this._documentFactories.set(type, factory);
|
|
143
139
|
}
|
|
144
140
|
/**
|
|
145
141
|
* Create a new `ISharedDocument` instance.
|
|
@@ -156,20 +152,12 @@ class SharedModelFactory {
|
|
|
156
152
|
// the `sharedModel` will be the default one.
|
|
157
153
|
return;
|
|
158
154
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
sharedModel = new YFile();
|
|
163
|
-
break;
|
|
164
|
-
case 'notebook':
|
|
165
|
-
sharedModel = new YNotebook(this._documentOptions.get('notebook'));
|
|
166
|
-
break;
|
|
167
|
-
//default:
|
|
168
|
-
// FIXME we should request a registry for the proper sharedModel
|
|
169
|
-
}
|
|
170
|
-
if (sharedModel) {
|
|
155
|
+
if (this._documentFactories.has(options.contentType)) {
|
|
156
|
+
const factory = this._documentFactories.get(options.contentType);
|
|
157
|
+
const sharedModel = factory(options);
|
|
171
158
|
this._onCreate(options, sharedModel);
|
|
159
|
+
return sharedModel;
|
|
172
160
|
}
|
|
173
|
-
return
|
|
161
|
+
return;
|
|
174
162
|
}
|
|
175
163
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter/docprovider",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"description": "JupyterLab - Document Provider",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyter_collaboration",
|
|
6
6
|
"bugs": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@jupyter/ydoc": "^0.3.4",
|
|
45
|
-
"@jupyterlab/coreutils": "^6.0.0-
|
|
46
|
-
"@jupyterlab/services": "^7.0.0-
|
|
45
|
+
"@jupyterlab/coreutils": "^6.0.0-beta.0",
|
|
46
|
+
"@jupyterlab/services": "^7.0.0-beta.0",
|
|
47
47
|
"@lumino/coreutils": "^2.0.0",
|
|
48
48
|
"@lumino/disposable": "^2.0.0",
|
|
49
49
|
"@lumino/signaling": "^2.0.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"yjs": "^13.5.40"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@jupyterlab/testing": "^4.0.0-
|
|
55
|
+
"@jupyterlab/testing": "^4.0.0-beta.0",
|
|
56
56
|
"@types/jest": "^29.2.0",
|
|
57
57
|
"rimraf": "^4.1.2",
|
|
58
58
|
"typescript": "~5.0.2"
|