@jupyter/docprovider 3.0.0-beta.6 → 3.0.0-rc.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.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/ydrive.d.ts +1 -1
- package/lib/ydrive.js +8 -6
- package/lib/yprovider.d.ts +1 -10
- package/package.json +10 -1
- package/lib/tokens.d.ts +0 -39
- package/lib/tokens.js +0 -11
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/ydrive.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { TranslationBundle } from '@jupyterlab/translation';
|
|
|
2
2
|
import { Contents, Drive, User } from '@jupyterlab/services';
|
|
3
3
|
import { ISignal } from '@lumino/signaling';
|
|
4
4
|
import { WebSocketProvider } from './yprovider';
|
|
5
|
-
import { ICollaborativeDrive, ISharedModelFactory } from '
|
|
5
|
+
import { ICollaborativeDrive, ISharedModelFactory } from '@jupyter/collaborative-drive';
|
|
6
6
|
import { Awareness } from 'y-protocols/awareness';
|
|
7
7
|
export interface IForkProvider {
|
|
8
8
|
connectToForkDoc: (forkRoomId: string, sessionId: string) => Promise<void>;
|
package/lib/ydrive.js
CHANGED
|
@@ -141,7 +141,9 @@ export class YDrive extends Drive {
|
|
|
141
141
|
super.get(localPath, { ...options, content: false }),
|
|
142
142
|
provider.ready
|
|
143
143
|
]);
|
|
144
|
-
return model
|
|
144
|
+
// The server doesn't return a model with a format when content is false,
|
|
145
|
+
// so set it back.
|
|
146
|
+
return { ...model, format: options.format };
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
return super.get(localPath, options);
|
|
@@ -195,7 +197,7 @@ class SharedModelFactory {
|
|
|
195
197
|
* Whether the IDrive supports real-time collaboration or not.
|
|
196
198
|
*/
|
|
197
199
|
this.collaborative = !DISABLE_RTC;
|
|
198
|
-
this.
|
|
200
|
+
this.documentFactories = new Map();
|
|
199
201
|
}
|
|
200
202
|
/**
|
|
201
203
|
* Register a SharedDocumentFactory.
|
|
@@ -204,10 +206,10 @@ class SharedModelFactory {
|
|
|
204
206
|
* @param factory Document factory
|
|
205
207
|
*/
|
|
206
208
|
registerDocumentFactory(type, factory) {
|
|
207
|
-
if (this.
|
|
209
|
+
if (this.documentFactories.has(type)) {
|
|
208
210
|
throw new Error(`The content type ${type} already exists`);
|
|
209
211
|
}
|
|
210
|
-
this.
|
|
212
|
+
this.documentFactories.set(type, factory);
|
|
211
213
|
}
|
|
212
214
|
/**
|
|
213
215
|
* Create a new `ISharedDocument` instance.
|
|
@@ -224,8 +226,8 @@ class SharedModelFactory {
|
|
|
224
226
|
// the `sharedModel` will be the default one.
|
|
225
227
|
return;
|
|
226
228
|
}
|
|
227
|
-
if (this.
|
|
228
|
-
const factory = this.
|
|
229
|
+
if (this.documentFactories.has(options.contentType)) {
|
|
230
|
+
const factory = this.documentFactories.get(options.contentType);
|
|
229
231
|
const sharedModel = factory(options);
|
|
230
232
|
this._onCreate(options, sharedModel);
|
|
231
233
|
return sharedModel;
|
package/lib/yprovider.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
+
import { IDocumentProvider } from '@jupyter/collaborative-drive';
|
|
1
2
|
import { User } from '@jupyterlab/services';
|
|
2
3
|
import { TranslationBundle } from '@jupyterlab/translation';
|
|
3
|
-
import { IDisposable } from '@lumino/disposable';
|
|
4
4
|
import { DocumentChange, YDocument } from '@jupyter/ydoc';
|
|
5
5
|
import { WebsocketProvider as YWebsocketProvider } from 'y-websocket';
|
|
6
6
|
import { IForkProvider } from './ydrive';
|
|
7
|
-
/**
|
|
8
|
-
* An interface for a document provider.
|
|
9
|
-
*/
|
|
10
|
-
export interface IDocumentProvider extends IDisposable {
|
|
11
|
-
/**
|
|
12
|
-
* Returns a Promise that resolves when the document provider is ready.
|
|
13
|
-
*/
|
|
14
|
-
readonly ready: Promise<void>;
|
|
15
|
-
}
|
|
16
7
|
/**
|
|
17
8
|
* A class to provide Yjs synchronization over WebSocket.
|
|
18
9
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter/docprovider",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.0",
|
|
4
4
|
"description": "JupyterLab - Document Provider",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyter-collaboration",
|
|
6
6
|
"bugs": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"watch": "tsc -b --watch"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"@jupyter/collaborative-drive": "^3.0.0-rc.0",
|
|
44
45
|
"@jupyter/ydoc": "^2.0.0 || ^3.0.0-a3",
|
|
45
46
|
"@jupyterlab/apputils": "^4.2.0",
|
|
46
47
|
"@jupyterlab/cells": "^4.2.0",
|
|
@@ -70,5 +71,13 @@
|
|
|
70
71
|
"entryPoint": "./src/index.ts",
|
|
71
72
|
"displayName": "@jupyter/docprovider",
|
|
72
73
|
"tsconfig": "./tsconfig.json"
|
|
74
|
+
},
|
|
75
|
+
"jupyterlab": {
|
|
76
|
+
"sharedPackages": {
|
|
77
|
+
"@jupyter/collaborative-drive": {
|
|
78
|
+
"bundled": true,
|
|
79
|
+
"singleton": true
|
|
80
|
+
}
|
|
81
|
+
}
|
|
73
82
|
}
|
|
74
83
|
}
|
package/lib/tokens.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { DocumentChange, YDocument } from '@jupyter/ydoc';
|
|
2
|
-
import { Contents } from '@jupyterlab/services';
|
|
3
|
-
import { Token } from '@lumino/coreutils';
|
|
4
|
-
import { WebSocketProvider } from './yprovider';
|
|
5
|
-
/**
|
|
6
|
-
* The collaborative drive.
|
|
7
|
-
*/
|
|
8
|
-
export declare const ICollaborativeDrive: Token<ICollaborativeDrive>;
|
|
9
|
-
/**
|
|
10
|
-
* The global awareness token.
|
|
11
|
-
*/
|
|
12
|
-
export declare const IGlobalAwareness: Token<import("y-protocols/awareness").Awareness>;
|
|
13
|
-
/**
|
|
14
|
-
* A document factory for registering shared models
|
|
15
|
-
*/
|
|
16
|
-
export type SharedDocumentFactory = (options: Contents.ISharedFactoryOptions) => YDocument<DocumentChange>;
|
|
17
|
-
/**
|
|
18
|
-
* A Collaborative implementation for an `IDrive`, talking to the
|
|
19
|
-
* server using the Jupyter REST API and a WebSocket connection.
|
|
20
|
-
*/
|
|
21
|
-
export interface ICollaborativeDrive extends Contents.IDrive {
|
|
22
|
-
/**
|
|
23
|
-
* SharedModel factory for the YDrive.
|
|
24
|
-
*/
|
|
25
|
-
readonly sharedModelFactory: ISharedModelFactory;
|
|
26
|
-
readonly providers: Map<string, WebSocketProvider>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Yjs sharedModel factory for real-time collaboration.
|
|
30
|
-
*/
|
|
31
|
-
export interface ISharedModelFactory extends Contents.ISharedFactory {
|
|
32
|
-
/**
|
|
33
|
-
* Register a SharedDocumentFactory.
|
|
34
|
-
*
|
|
35
|
-
* @param type Document type
|
|
36
|
-
* @param factory Document factory
|
|
37
|
-
*/
|
|
38
|
-
registerDocumentFactory(type: Contents.ContentType, factory: SharedDocumentFactory): void;
|
|
39
|
-
}
|
package/lib/tokens.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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');
|
|
8
|
-
/**
|
|
9
|
-
* The global awareness token.
|
|
10
|
-
*/
|
|
11
|
-
export const IGlobalAwareness = new Token('@jupyter/collaboration:IGlobalAwareness');
|