@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 CHANGED
@@ -7,5 +7,4 @@ export * from './notebookCellExecutor';
7
7
  export * from './requests';
8
8
  export * from './ydrive';
9
9
  export * from './yprovider';
10
- export * from './tokens';
11
10
  export * from './TimelineSlider';
package/lib/index.js CHANGED
@@ -11,5 +11,4 @@ export * from './notebookCellExecutor';
11
11
  export * from './requests';
12
12
  export * from './ydrive';
13
13
  export * from './yprovider';
14
- export * from './tokens';
15
14
  export * from './TimelineSlider';
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 './tokens';
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._documentFactories = new Map();
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._documentFactories.has(type)) {
209
+ if (this.documentFactories.has(type)) {
208
210
  throw new Error(`The content type ${type} already exists`);
209
211
  }
210
- this._documentFactories.set(type, factory);
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._documentFactories.has(options.contentType)) {
228
- const factory = this._documentFactories.get(options.contentType);
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;
@@ -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-beta.6",
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');