Skip to content

Commit

Permalink
Extract out ICollaborativeDrive to @jupyter/collaborative-drive (#353)
Browse files Browse the repository at this point in the history
* Extract out ICollaborativeDrive to @jupyter/collaborativedrive

* Rename @jupyter/collaborativedrive to @jupyter/collaborative-drive

* Move packages/collaborativedrive -> packages/collaborative-drive

* Update collaborative-drive dependencies

* Add collaborative-drive as shared package

---------

Co-authored-by: Jeremy Tuloup <jeremy.tuloup@gmail.com>
  • Loading branch information
davidbrochart and jtpio authored Oct 11, 2024
1 parent b68d3cd commit 60e55ea
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 34 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
Expand All @@ -71,6 +71,7 @@ jobs:
pip install "jupyterlab>=4.0.0,<5"
pip install -e .
jlpm
jlpm build
- name: Run Tests
run: |
Expand Down
5 changes: 5 additions & 0 deletions packages/collaboration-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
},
"dependencies": {
"@jupyter/collaboration": "^3.0.0-beta.6",
"@jupyter/collaborative-drive": "^3.0.0-beta.6",
"@jupyter/docprovider": "^3.0.0-beta.6",
"@jupyter/ydoc": "^2.0.0 || ^3.0.0-a3",
"@jupyterlab/application": "^4.2.0",
Expand Down Expand Up @@ -102,6 +103,10 @@
"bundled": true,
"singleton": true
},
"@jupyter/collaborative-drive": {
"bundled": true,
"singleton": true
},
"@jupyter/docprovider": {
"bundled": true,
"singleton": true
Expand Down
6 changes: 2 additions & 4 deletions packages/collaboration-extension/src/collaboration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import {
EditorExtensionRegistry,
IEditorExtensionRegistry
} from '@jupyterlab/codemirror';
import {
IGlobalAwareness,
WebSocketAwarenessProvider
} from '@jupyter/docprovider';
import { IGlobalAwareness } from '@jupyter/collaborative-drive';
import { WebSocketAwarenessProvider } from '@jupyter/docprovider';
import { SidePanel, usersIcon } from '@jupyterlab/ui-components';
import { URLExt } from '@jupyterlab/coreutils';
import { ServerConnection } from '@jupyterlab/services';
Expand Down
57 changes: 57 additions & 0 deletions packages/collaborative-drive/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "@jupyter/collaborative-drive",
"version": "3.0.0-beta.6",
"description": "JupyterLab - Collaborative Drive",
"homepage": "https://github.com/jupyterlab/jupyter-collaboration",
"bugs": {
"url": "https://github.com/jupyterlab/jupyter-collaboration/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/jupyterlab/jupyter-collaboration.git"
},
"license": "BSD-3-Clause",
"author": "Project Jupyter",
"sideEffects": [
"style/**/*"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"directories": {
"lib": "lib/"
},
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"schema/*.json",
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
"style/index.js"
],
"scripts": {
"build": "tsc -b",
"build:prod": "jlpm run build",
"build:test": "tsc --build tsconfig.test.json",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"clean:lib": "jlpm run clean:all",
"clean:all": "rimraf lib tsconfig.tsbuildinfo node_modules",
"install:extension": "jlpm run build",
"watch": "tsc -b --watch"
},
"dependencies": {
"@jupyter/ydoc": "^2.0.0 || ^3.0.0-a3",
"@jupyterlab/services": "^7.2.0",
"@lumino/coreutils": "^2.1.0",
"@lumino/disposable": "^2.1.0"
},
"devDependencies": {
"rimraf": "^4.1.2",
"typescript": "~5.0.4"
},
"publishConfig": {
"access": "public"
},
"typedoc": {
"entryPoint": "./src/index.ts",
"displayName": "@jupyter/collaborative-drive",
"tsconfig": "./tsconfig.json"
}
}
10 changes: 10 additions & 0 deletions packages/collaborative-drive/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
/**
* @packageDocumentation
* @module collaborative-drive
*/

export * from './tokens';
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import { DocumentChange, IAwareness, YDocument } from '@jupyter/ydoc';
import { Contents } from '@jupyterlab/services';
import { IDisposable } from '@lumino/disposable';

import { Token } from '@lumino/coreutils';
import { WebSocketProvider } from './yprovider';

/**
* The collaborative drive.
Expand Down Expand Up @@ -38,7 +38,7 @@ export interface ICollaborativeDrive extends Contents.IDrive {
*/
readonly sharedModelFactory: ISharedModelFactory;

readonly providers: Map<string, WebSocketProvider>;
readonly providers: Map<string, IDocumentProvider>;
}

/**
Expand All @@ -55,4 +55,16 @@ export interface ISharedModelFactory extends Contents.ISharedFactory {
type: Contents.ContentType,
factory: SharedDocumentFactory
): void;

documentFactories: Map<Contents.ContentType, SharedDocumentFactory>;
}

/**
* An interface for a document provider.
*/
export interface IDocumentProvider extends IDisposable {
/**
* Returns a Promise that resolves when the document provider is ready.
*/
readonly ready: Promise<void>;
}
9 changes: 9 additions & 0 deletions packages/collaborative-drive/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": ["src/*"],
"exclude": ["src/__tests__/*"]
}
5 changes: 5 additions & 0 deletions packages/docprovider-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyter/collaborative-drive": "^3.0.0-beta.6",
"@jupyter/docprovider": "^3.0.0-beta.6",
"@jupyter/ydoc": "^2.0.0 || ^3.0.0-a3",
"@jupyterlab/application": "^4.2.0",
Expand Down Expand Up @@ -105,6 +106,10 @@
"bundled": false,
"singleton": true
},
"@jupyter/collaborative-drive": {
"bundled": true,
"singleton": true
},
"@jupyter/docprovider": {
"bundled": true,
"singleton": true
Expand Down
10 changes: 4 additions & 6 deletions packages/docprovider-extension/src/filebrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ import { YFile, YNotebook } from '@jupyter/ydoc';

import {
ICollaborativeDrive,
IForkProvider,
IGlobalAwareness,
TimelineWidget,
YDrive
} from '@jupyter/docprovider';
IGlobalAwareness
} from '@jupyter/collaborative-drive';
import { IForkProvider, TimelineWidget, YDrive } from '@jupyter/docprovider';
import { Awareness } from 'y-protocols/awareness';
import { URLExt } from '@jupyterlab/coreutils';

Expand Down Expand Up @@ -167,7 +165,7 @@ export const statusBarTimeline: JupyterFrontEndPlugin<void> = {
const [format, type] = documentId.split(':');
const provider = drive.providers.get(
`${format}:${type}:${documentPath}`
) as IForkProvider;
) as unknown as IForkProvider;
const fullPath = URLExt.join(
app.serviceManager.serverSettings.baseUrl,
DOCUMENT_TIMELINE_URL,
Expand Down
9 changes: 9 additions & 0 deletions packages/docprovider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"watch": "tsc -b --watch"
},
"dependencies": {
"@jupyter/collaborative-drive": "^3.0.0-beta.6",
"@jupyter/ydoc": "^2.0.0 || ^3.0.0-a3",
"@jupyterlab/apputils": "^4.2.0",
"@jupyterlab/cells": "^4.2.0",
Expand Down Expand Up @@ -70,5 +71,13 @@
"entryPoint": "./src/index.ts",
"displayName": "@jupyter/docprovider",
"tsconfig": "./tsconfig.json"
},
"jupyterlab": {
"sharedPackages": {
"@jupyter/collaborative-drive": {
"bundled": true,
"singleton": true
}
}
}
}
1 change: 0 additions & 1 deletion packages/docprovider/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ export * from './notebookCellExecutor';
export * from './requests';
export * from './ydrive';
export * from './yprovider';
export * from './tokens';
export * from './TimelineSlider';
14 changes: 7 additions & 7 deletions packages/docprovider/src/ydrive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ICollaborativeDrive,
ISharedModelFactory,
SharedDocumentFactory
} from './tokens';
} from '@jupyter/collaborative-drive';
import { Awareness } from 'y-protocols/awareness';

const DISABLE_RTC =
Expand Down Expand Up @@ -251,7 +251,7 @@ export class YDrive extends Drive implements ICollaborativeDrive {
* Yjs sharedModel factory for real-time collaboration.
*/
class SharedModelFactory implements ISharedModelFactory {
private _documentFactories: Map<Contents.ContentType, SharedDocumentFactory>;
documentFactories: Map<Contents.ContentType, SharedDocumentFactory>;

/**
* Shared model factory constructor
Expand All @@ -264,7 +264,7 @@ class SharedModelFactory implements ISharedModelFactory {
sharedModel: YDocument<DocumentChange>
) => void
) {
this._documentFactories = new Map();
this.documentFactories = new Map();
}

/**
Expand All @@ -282,10 +282,10 @@ class SharedModelFactory implements ISharedModelFactory {
type: Contents.ContentType,
factory: SharedDocumentFactory
) {
if (this._documentFactories.has(type)) {
if (this.documentFactories.has(type)) {
throw new Error(`The content type ${type} already exists`);
}
this._documentFactories.set(type, factory);
this.documentFactories.set(type, factory);
}

/**
Expand All @@ -307,8 +307,8 @@ class SharedModelFactory implements ISharedModelFactory {
return;
}

if (this._documentFactories.has(options.contentType)) {
const factory = this._documentFactories.get(options.contentType)!;
if (this.documentFactories.has(options.contentType)) {
const factory = this.documentFactories.get(options.contentType)!;
const sharedModel = factory(options);
this._onCreate(options, sharedModel);
return sharedModel;
Expand Down
12 changes: 1 addition & 11 deletions packages/docprovider/src/yprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/

import { IDocumentProvider } from '@jupyter/collaborative-drive';
import { showErrorMessage, Dialog } from '@jupyterlab/apputils';
import { User } from '@jupyterlab/services';
import { TranslationBundle } from '@jupyterlab/translation';

import { PromiseDelegate } from '@lumino/coreutils';
import { IDisposable } from '@lumino/disposable';
import { Signal } from '@lumino/signaling';

import { DocumentChange, YDocument } from '@jupyter/ydoc';
Expand All @@ -19,16 +19,6 @@ import { WebsocketProvider as YWebsocketProvider } from 'y-websocket';
import { requestDocSession } from './requests';
import { IForkProvider } from './ydrive';

/**
* An interface for a document provider.
*/
export interface IDocumentProvider extends IDisposable {
/**
* Returns a Promise that resolves when the document provider is ready.
*/
readonly ready: Promise<void>;
}

/**
* A class to provide Yjs synchronization over WebSocket.
*
Expand Down
16 changes: 16 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2076,6 +2076,7 @@ __metadata:
resolution: "@jupyter/collaboration-extension@workspace:packages/collaboration-extension"
dependencies:
"@jupyter/collaboration": ^3.0.0-beta.6
"@jupyter/collaborative-drive": ^3.0.0-beta.6
"@jupyter/docprovider": ^3.0.0-beta.6
"@jupyter/ydoc": ^2.0.0 || ^3.0.0-a3
"@jupyterlab/application": ^4.2.0
Expand Down Expand Up @@ -2122,10 +2123,24 @@ __metadata:
languageName: unknown
linkType: soft

"@jupyter/collaborative-drive@^3.0.0-beta.6, @jupyter/collaborative-drive@workspace:packages/collaborative-drive":
version: 0.0.0-use.local
resolution: "@jupyter/collaborative-drive@workspace:packages/collaborative-drive"
dependencies:
"@jupyter/ydoc": ^2.0.0 || ^3.0.0-a3
"@jupyterlab/services": ^7.2.0
"@lumino/coreutils": ^2.1.0
"@lumino/disposable": ^2.1.0
rimraf: ^4.1.2
typescript: ~5.0.4
languageName: unknown
linkType: soft

"@jupyter/docprovider-extension@workspace:packages/docprovider-extension":
version: 0.0.0-use.local
resolution: "@jupyter/docprovider-extension@workspace:packages/docprovider-extension"
dependencies:
"@jupyter/collaborative-drive": ^3.0.0-beta.6
"@jupyter/docprovider": ^3.0.0-beta.6
"@jupyter/ydoc": ^2.0.0 || ^3.0.0-a3
"@jupyterlab/application": ^4.2.0
Expand Down Expand Up @@ -2153,6 +2168,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@jupyter/docprovider@workspace:packages/docprovider"
dependencies:
"@jupyter/collaborative-drive": ^3.0.0-beta.6
"@jupyter/ydoc": ^2.0.0 || ^3.0.0-a3
"@jupyterlab/apputils": ^4.2.0
"@jupyterlab/cells": ^4.2.0
Expand Down

0 comments on commit 60e55ea

Please sign in to comment.