@jupyter/docprovider 3.1.0 → 4.0.0-beta.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.
@@ -1,4 +1,4 @@
1
- import { ICollaborativeDrive } from '@jupyter/collaborative-drive';
1
+ import { ICollaborativeContentProvider } from '@jupyter/collaborative-drive';
2
2
  import { Event } from '@jupyterlab/services';
3
3
  import { ISignal } from '@lumino/signaling';
4
4
  import { IAllForksResponse, IForkChangedEvent, IForkCreationResponse, IForkManager } from './tokens';
@@ -28,14 +28,14 @@ export declare class ForkManager implements IForkManager {
28
28
  }): IForkProvider | undefined;
29
29
  private _handleEvent;
30
30
  private _disposed;
31
- private _drive;
31
+ private _contentProvider;
32
32
  private _eventManager;
33
33
  private _forkAddedSignal;
34
34
  private _forkDeletedSignal;
35
35
  }
36
36
  export declare namespace ForkManager {
37
37
  interface IOptions {
38
- drive: ICollaborativeDrive;
38
+ contentProvider: ICollaborativeContentProvider;
39
39
  eventManager: Event.IManager;
40
40
  }
41
41
  }
@@ -11,8 +11,8 @@ export class ForkManager {
11
11
  this._disposed = false;
12
12
  this._forkAddedSignal = new Signal(this);
13
13
  this._forkDeletedSignal = new Signal(this);
14
- const { drive, eventManager } = options;
15
- this._drive = drive;
14
+ const { contentProvider, eventManager } = options;
15
+ this._contentProvider = contentProvider;
16
16
  this._eventManager = eventManager;
17
17
  this._eventManager.stream.connect(this._handleEvent, this);
18
18
  }
@@ -58,14 +58,10 @@ export class ForkManager {
58
58
  }
59
59
  getProvider(options) {
60
60
  const { documentPath, format, type } = options;
61
- const drive = this._drive;
62
- if (drive) {
63
- const driveName = drive.name;
64
- let docPath = documentPath;
65
- if (documentPath.startsWith(driveName)) {
66
- docPath = documentPath.slice(driveName.length + 1);
67
- }
68
- const provider = drive.providers.get(`${format}:${type}:${docPath}`);
61
+ const contentProvider = this._contentProvider;
62
+ if (contentProvider) {
63
+ const docPath = documentPath;
64
+ const provider = contentProvider.providers.get(`${format}:${type}:${docPath}`);
69
65
  return provider;
70
66
  }
71
67
  return;
package/lib/ydrive.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { TranslationBundle } from '@jupyterlab/translation';
2
- import { Contents, Drive, User } from '@jupyterlab/services';
2
+ import { Contents, IContentProvider, RestContentProvider, User } from '@jupyterlab/services';
3
3
  import { ISignal } from '@lumino/signaling';
4
- import { WebSocketProvider } from './yprovider';
5
- import { ICollaborativeDrive, ISharedModelFactory } from '@jupyter/collaborative-drive';
4
+ import { IDocumentProvider, ISharedModelFactory } from '@jupyter/collaborative-drive';
6
5
  import { Awareness } from 'y-protocols/awareness';
7
6
  export interface IForkProvider {
8
7
  connectToForkDoc: (forkRoomId: string, sessionId: string) => Promise<void>;
@@ -10,26 +9,20 @@ export interface IForkProvider {
10
9
  contentType: string;
11
10
  format: string;
12
11
  }
13
- /**
14
- * A Collaborative implementation for an `IDrive`, talking to the
15
- * server using the Jupyter REST API and a WebSocket connection.
16
- */
17
- export declare class YDrive extends Drive implements ICollaborativeDrive {
18
- /**
19
- * Construct a new drive object.
20
- *
21
- * @param user - The user manager to add the identity to the awareness of documents.
22
- */
23
- constructor(user: User.IManager, translator: TranslationBundle, globalAwareness: Awareness | null);
12
+ declare namespace RtcContentProvider {
13
+ interface IOptions extends RestContentProvider.IOptions {
14
+ user: User.IManager;
15
+ trans: TranslationBundle;
16
+ globalAwareness: Awareness | null;
17
+ }
18
+ }
19
+ export declare class RtcContentProvider extends RestContentProvider implements IContentProvider {
20
+ constructor(options: RtcContentProvider.IOptions);
24
21
  /**
25
- * SharedModel factory for the YDrive.
22
+ * SharedModel factory for the content provider.
26
23
  */
27
24
  readonly sharedModelFactory: ISharedModelFactory;
28
- get providers(): Map<string, WebSocketProvider>;
29
- /**
30
- * Dispose of the resources held by the manager.
31
- */
32
- dispose(): void;
25
+ get providers(): Map<string, IDocumentProvider>;
33
26
  /**
34
27
  * Get a file or directory.
35
28
  *
@@ -38,8 +31,6 @@ export declare class YDrive extends Drive implements ICollaborativeDrive {
38
31
  * @param options: The options used to fetch the file.
39
32
  *
40
33
  * @returns A promise which resolves with the file content.
41
- *
42
- * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/contents) and validates the response model.
43
34
  */
44
35
  get(localPath: string, options?: Contents.IFetchOptions): Promise<Contents.IModel>;
45
36
  /**
@@ -60,7 +51,9 @@ export declare class YDrive extends Drive implements ICollaborativeDrive {
60
51
  private _onCreate;
61
52
  private _user;
62
53
  private _trans;
63
- private _providers;
64
54
  private _globalAwareness;
55
+ private _providers;
65
56
  private _ydriveFileChanged;
57
+ private _serverSettings;
66
58
  }
59
+ export {};
package/lib/ydrive.js CHANGED
@@ -1,7 +1,7 @@
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 { Drive } from '@jupyterlab/services';
4
+ import { RestContentProvider } from '@jupyterlab/services';
5
5
  import { Signal } from '@lumino/signaling';
6
6
  import { WebSocketProvider } from './yprovider';
7
7
  const DISABLE_RTC = PageConfig.getOption('disableRTC') === 'true' ? true : false;
@@ -9,18 +9,9 @@ const DISABLE_RTC = PageConfig.getOption('disableRTC') === 'true' ? true : false
9
9
  * The url for the default drive service.
10
10
  */
11
11
  const DOCUMENT_PROVIDER_URL = 'api/collaboration/room';
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 class YDrive extends Drive {
17
- /**
18
- * Construct a new drive object.
19
- *
20
- * @param user - The user manager to add the identity to the awareness of documents.
21
- */
22
- constructor(user, translator, globalAwareness) {
23
- super({ name: 'RTC' });
12
+ export class RtcContentProvider extends RestContentProvider {
13
+ constructor(options) {
14
+ super(options);
24
15
  this._onCreate = (options, sharedModel) => {
25
16
  var _a, _b;
26
17
  if (typeof options.format !== 'string') {
@@ -28,7 +19,7 @@ export class YDrive extends Drive {
28
19
  }
29
20
  try {
30
21
  const provider = new WebSocketProvider({
31
- url: URLExt.join(this.serverSettings.wsUrl, DOCUMENT_PROVIDER_URL),
22
+ url: URLExt.join(this._serverSettings.wsUrl, DOCUMENT_PROVIDER_URL),
32
23
  path: options.path,
33
24
  format: options.format,
34
25
  contentType: options.contentType,
@@ -40,7 +31,7 @@ export class YDrive extends Drive {
40
31
  const state = ((_a = this._globalAwareness) === null || _a === void 0 ? void 0 : _a.getLocalState()) || {};
41
32
  const documents = state.documents || [];
42
33
  if (!documents.includes(options.path)) {
43
- documents.push(`${this.name}:${options.path}`);
34
+ documents.push(options.path);
44
35
  (_b = this._globalAwareness) === null || _b === void 0 ? void 0 : _b.setLocalStateField('documents', documents);
45
36
  }
46
37
  const key = `${options.format}:${options.contentType}:${options.path}`;
@@ -81,7 +72,7 @@ export class YDrive extends Drive {
81
72
  // Remove the document path from the list of opened ones for this user.
82
73
  const state = ((_a = this._globalAwareness) === null || _a === void 0 ? void 0 : _a.getLocalState()) || {};
83
74
  const documents = state.documents || [];
84
- const index = documents.indexOf(`${this.name}:${options.path}`);
75
+ const index = documents.indexOf(options.path);
85
76
  if (index > -1) {
86
77
  documents.splice(index, 1);
87
78
  }
@@ -95,30 +86,16 @@ export class YDrive extends Drive {
95
86
  }
96
87
  };
97
88
  this._ydriveFileChanged = new Signal(this);
98
- this._user = user;
99
- this._trans = translator;
100
- this._globalAwareness = globalAwareness;
101
- this._providers = new Map();
89
+ this._user = options.user;
90
+ this._trans = options.trans;
91
+ this._globalAwareness = options.globalAwareness;
92
+ this._serverSettings = options.serverSettings;
102
93
  this.sharedModelFactory = new SharedModelFactory(this._onCreate);
103
- super.fileChanged.connect((_, change) => {
104
- // pass through any events from the Drive superclass
105
- this._ydriveFileChanged.emit(change);
106
- });
94
+ this._providers = new Map();
107
95
  }
108
96
  get providers() {
109
97
  return this._providers;
110
98
  }
111
- /**
112
- * Dispose of the resources held by the manager.
113
- */
114
- dispose() {
115
- if (this.isDisposed) {
116
- return;
117
- }
118
- this._providers.forEach(p => p.dispose());
119
- this._providers.clear();
120
- super.dispose();
121
- }
122
99
  /**
123
100
  * Get a file or directory.
124
101
  *
@@ -127,8 +104,6 @@ export class YDrive extends Drive {
127
104
  * @param options: The options used to fetch the file.
128
105
  *
129
106
  * @returns A promise which resolves with the file content.
130
- *
131
- * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/contents) and validates the response model.
132
107
  */
133
108
  async get(localPath, options) {
134
109
  if (options && options.format && options.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter/docprovider",
3
- "version": "3.1.0",
3
+ "version": "4.0.0-beta.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": "^3.1.0",
45
- "@jupyter/ydoc": "^2.0.0 || ^3.0.0",
46
- "@jupyterlab/apputils": "^4.2.0",
47
- "@jupyterlab/cells": "^4.2.0",
48
- "@jupyterlab/coreutils": "^6.2.0",
49
- "@jupyterlab/notebook": "^4.2.0",
50
- "@jupyterlab/services": "^7.2.0",
51
- "@jupyterlab/translation": "^4.2.0",
44
+ "@jupyter/collaborative-drive": "^4.0.0-beta.0",
45
+ "@jupyter/ydoc": "^2.1.3 || ^3.0.0",
46
+ "@jupyterlab/apputils": "^4.4.0-alpha.2",
47
+ "@jupyterlab/cells": "^4.4.0-alpha.2",
48
+ "@jupyterlab/coreutils": "^6.4.0-alpha.2",
49
+ "@jupyterlab/notebook": "^4.4.0-alpha.2",
50
+ "@jupyterlab/services": "^7.4.0-alpha.2",
51
+ "@jupyterlab/translation": "^4.4.0-alpha.2",
52
52
  "@lumino/coreutils": "^2.1.0",
53
53
  "@lumino/disposable": "^2.1.0",
54
54
  "@lumino/signaling": "^2.1.0",
@@ -58,11 +58,11 @@
58
58
  "yjs": "^13.5.40"
59
59
  },
60
60
  "devDependencies": {
61
- "@jupyterlab/testing": "^4.0.0",
61
+ "@jupyterlab/testing": "^4.4.0-alpha.2",
62
62
  "@types/jest": "^29.2.0",
63
63
  "jest": "^29.5.0",
64
64
  "rimraf": "^4.1.2",
65
- "typescript": "~5.0.4"
65
+ "typescript": "~5.1.6"
66
66
  },
67
67
  "publishConfig": {
68
68
  "access": "public"