Skip to content

Commit

Permalink
Split up the backend, frontend, and the docprovider
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Apr 12, 2024
1 parent cf774a4 commit 8167995
Show file tree
Hide file tree
Showing 50 changed files with 979 additions and 518 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ node_modules/
*.tsbuildinfo
package-lock.json
docs/source/ts
jupyter_collaboration/labextension

# Version file is handled by hatchling
jupyter_collaboration/_version.py
.jupyter
labextension

# Integration tests
ui-tests/test-results/
Expand Down
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ header:
- 'coverage'
- 'LICENSE'
- 'yarn.lock'
- '**/_version.py'

comment: on-failure
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Jupyter Real-Time Collaboration

[![Build Status](https://github.com/jupyterlab/jupyter_collaboration/actions/workflows/test.yml/badge.svg?query=branch%3Amain++)](https://github.com/jupyterlab/jupyter_collaboration/actions?query=branch%3Amain++)[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyterlab/jupyter_collaboration/main)[![PyPI](https://img.shields.io/pypi/v/jupyter-collaboration)](https://pypi.org/project/jupyter-collaboration)[![npm](https://img.shields.io/npm/v/@jupyter/collaboration-extension)](https://www.npmjs.com/package/@jupyter/collaboration-extension)
[![Build Status](https://github.com/jupyterlab/jupyter_collaboration/actions/workflows/test.yml/badge.svg?query=branch%3Amain++)](https://github.com/jupyterlab/jupyter_collaboration/actions?query=branch%3Amain++)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyterlab/jupyter_collaboration/main)
[![PyPI](https://img.shields.io/pypi/v/jupyter-collaboration)](https://pypi.org/project/jupyter-collaboration)
[![npm](https://img.shields.io/npm/v/@jupyter/collaboration-extension)](https://www.npmjs.com/package/@jupyter/collaboration-extension)

JupyterLab Real-Time Collaboration is a Jupyter Server Extension and JupyterLab extensions providing support for [Y documents](https://github.com/jupyter-server/jupyter_ydoc) and adding collaboration UI elements in JupyterLab.

Expand Down
7 changes: 6 additions & 1 deletion docs/source/developer/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ steps:
pip install --upgrade pip
git clone https://github.com/jupyterlab/jupyter_collaboration
cd jupyter_collaboration
# install monorepo
pip install -e ".[dev,test]"
jupyter labextension develop --overwrite .
# install local dependencies as editable
pip install -e projects/jupyter-collaboration-ui -e projects/jupyter-docprovider -e projects/jupyter-server-ydoc
# link lab extensions
jupyter labextension develop --overwrite projects/jupyter-collaboration-ui
jupyter labextension develop --overwrite projects/jupyter-docprovider
If you are using a system-wide Python installation and you only want to install the server for you,
Expand Down
15 changes: 2 additions & 13 deletions packages/collaboration-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"build:labextension:dev": "jupyter labextension build --development True .",
"clean": "jlpm run clean:lib",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo node_modules",
"clean:labextension": "rimraf ../../jupyter_collaboration/labextension",
"clean:labextension": "rimraf ../../projects/jupyter-collaboration-ui/jupyter_collaboration_ui/labextension",
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
"install:extension": "jlpm run build",
"watch": "run-p watch:src watch:labextension",
Expand All @@ -60,17 +60,10 @@
"@jupyterlab/apputils": "^4.2.0-beta.0",
"@jupyterlab/codemirror": "^4.2.0-beta.0",
"@jupyterlab/coreutils": "^6.0.5",
"@jupyterlab/docregistry": "^4.2.0-beta.0",
"@jupyterlab/filebrowser": "^4.2.0-beta.0",
"@jupyterlab/fileeditor": "^4.2.0-beta.0",
"@jupyterlab/logconsole": "^4.2.0-beta.0",
"@jupyterlab/notebook": "^4.2.0-beta.0",
"@jupyterlab/services": "^7.0.5",
"@jupyterlab/settingregistry": "^4.2.0-beta.0",
"@jupyterlab/statedb": "^4.2.0-beta.0",
"@jupyterlab/translation": "^4.2.0-beta.0",
"@jupyterlab/ui-components": "^4.2.0-beta.0",
"@lumino/commands": "^2.1.0",
"@lumino/widgets": "^2.1.0",
"y-protocols": "^1.0.5",
"y-websocket": "^1.3.15",
Expand All @@ -95,11 +88,7 @@
"jupyterlab": {
"extension": true,
"schemaDir": "./schema",
"outputDir": "../../jupyter_collaboration/labextension",
"disabledExtensions": [
"@jupyterlab/filebrowser-extension:defaultFileBrowser",
"@jupyterlab/notebook-extension:cell-executor"
],
"outputDir": "../../projects/jupyter-collaboration-ui/jupyter_collaboration_ui/labextension",
"sharedPackages": {
"@codemirror/state": {
"bundled": false,
Expand Down
64 changes: 1 addition & 63 deletions packages/collaboration-extension/src/collaboration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ import {
EditorExtensionRegistry,
IEditorExtensionRegistry
} from '@jupyterlab/codemirror';
import { type MarkdownCell } from '@jupyterlab/cells';
import { INotebookCellExecutor, runCell } from '@jupyterlab/notebook';
import { WebSocketAwarenessProvider } from '@jupyter/docprovider';
import { SidePanel, usersIcon } from '@jupyterlab/ui-components';
import { PageConfig, URLExt } from '@jupyterlab/coreutils';
import { URLExt } from '@jupyterlab/coreutils';
import { ServerConnection } from '@jupyterlab/services';
import { IStateDB, StateDB } from '@jupyterlab/statedb';
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
Expand Down Expand Up @@ -191,63 +189,3 @@ export const userEditorCursors: JupyterFrontEndPlugin<void> = {
});
}
};

export const notebookCellExecutor: JupyterFrontEndPlugin<INotebookCellExecutor> =
{
id: '@jupyter/collaboration-extension:notebook-cell-executor',
description:
'Add notebook cell executor that uses REST API instead of kernel protocol over WebSocket.',
autoStart: true,
provides: INotebookCellExecutor,
activate: (app: JupyterFrontEnd): INotebookCellExecutor => {
if (PageConfig.getOption('serverSideExecution') === 'true') {
return Object.freeze({ runCell: runCellServerSide });
}
return Object.freeze({ runCell });
}
};

async function runCellServerSide({
cell,
notebook,
notebookConfig,
onCellExecuted,
onCellExecutionScheduled,
sessionContext,
sessionDialogs,
translator
}: INotebookCellExecutor.IRunCellOptions): Promise<boolean> {
switch (cell.model.type) {
case 'markdown':
(cell as MarkdownCell).rendered = true;
cell.inputHidden = false;
onCellExecuted({ cell, success: true });
break;
case 'code': {
const kernelId = sessionContext?.session?.kernel?.id;
const settings = ServerConnection.makeSettings();
const apiURL = URLExt.join(
settings.baseUrl,
`api/kernels/${kernelId}/execute`
);
const cellId = cell.model.sharedModel.getId();
const documentId = `json:notebook:${notebook.sharedModel.getState(
'file_id'
)}`;
const body = `{"cell_id":"${cellId}","document_id":"${documentId}"}`;
const init = {
method: 'POST',
body
};
try {
await ServerConnection.makeRequest(apiURL, init, settings);
} catch (error: any) {
throw new ServerConnection.NetworkError(error);
}
break;
}
default:
break;
}
return Promise.resolve(true);
}
18 changes: 2 additions & 16 deletions packages/collaboration-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,25 @@

import { JupyterFrontEndPlugin } from '@jupyterlab/application';

import {
drive,
yfile,
ynotebook,
defaultFileBrowser,
logger
} from './filebrowser';
import {
userMenuPlugin,
menuBarPlugin,
rtcGlobalAwarenessPlugin,
rtcPanelPlugin,
userEditorCursors,
notebookCellExecutor
userEditorCursors
} from './collaboration';
import { sharedLink } from './sharedlink';

/**
* Export the plugins as default.
*/
const plugins: JupyterFrontEndPlugin<any>[] = [
drive,
yfile,
ynotebook,
defaultFileBrowser,
logger,
userMenuPlugin,
menuBarPlugin,
rtcGlobalAwarenessPlugin,
rtcPanelPlugin,
sharedLink,
userEditorCursors,
notebookCellExecutor
userEditorCursors
];

export default plugins;
3 changes: 3 additions & 0 deletions packages/docprovider-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @jupyter/docprovider-extension

A JupyterLab package which provides a set of plugins for collaborative shared models.
122 changes: 122 additions & 0 deletions packages/docprovider-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"name": "@jupyter/docprovider-extension",
"version": "2.0.11",
"description": "JupyterLab - Collaborative Shared Models",
"keywords": [
"jupyter",
"jupyterlab",
"jupyterlab-extension"
],
"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/*.css",
"style/index.js"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"style": "style/index.css",
"styleModule": "style/index.js",
"directories": {
"lib": "lib/"
},
"files": [
"lib/*.d.ts",
"lib/*.js.map",
"lib/*.js",
"schema/*.json",
"style/*.css",
"style/index.js"
],
"scripts": {
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
"build:lib": "tsc --sourceMap",
"build:lib:prod": "tsc",
"build:prod": "jlpm run clean && jlpm run build:lib:prod && jlpm run build:labextension",
"build:labextension": "jupyter labextension build .",
"build:labextension:dev": "jupyter labextension build --development True .",
"clean": "jlpm run clean:lib",
"clean:lib": "rimraf lib tsconfig.tsbuildinfo node_modules",
"clean:labextension": "rimraf ../../projects/jupyter-docprovider/jupyter_docprovider/labextension",
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
"install:extension": "jlpm run build",
"watch": "run-p watch:src watch:labextension",
"watch:src": "tsc -w",
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyter/docprovider": "^2.0.11",
"@jupyter/ydoc": "^1.1.0-a0",
"@jupyterlab/application": "^4.2.0-beta.0",
"@jupyterlab/apputils": "^4.2.0-beta.0",
"@jupyterlab/docregistry": "^4.2.0-beta.0",
"@jupyterlab/filebrowser": "^4.2.0-beta.0",
"@jupyterlab/fileeditor": "^4.2.0-beta.0",
"@jupyterlab/logconsole": "^4.2.0-beta.0",
"@jupyterlab/notebook": "^4.2.0-beta.0",
"@jupyterlab/settingregistry": "^4.2.0-beta.0",
"@jupyterlab/translation": "^4.2.0-beta.0",
"@lumino/commands": "^2.1.0",
"y-protocols": "^1.0.5",
"y-websocket": "^1.3.15",
"yjs": "^13.5.40"
},
"devDependencies": {
"@jupyterlab/builder": "^4.0.5",
"@types/react": "~18.0.26",
"npm-run-all": "^4.1.5",
"rimraf": "^4.1.2",
"typescript": "~5.0.4"
},
"publishConfig": {
"access": "public"
},
"typedoc": {
"entryPoint": "./src/index.ts",
"readmeFile": "./README.md",
"displayName": "@jupyter/docprovider-extension",
"tsconfig": "./tsconfig.json"
},
"jupyterlab": {
"extension": true,
"outputDir": "../../projects/jupyter-docprovider/jupyter_docprovider/labextension",
"disabledExtensions": [
"@jupyterlab/filebrowser-extension:defaultFileBrowser",
"@jupyterlab/notebook-extension:cell-executor"
],
"sharedPackages": {
"@codemirror/state": {
"bundled": false,
"singleton": true
},
"@codemirror/view": {
"bundled": false,
"singleton": true
},
"@jupyter/docprovider": {
"bundled": true,
"singleton": true
},
"@jupyter/ydoc": {
"bundled": false,
"singleton": true
},
"y-protocols": {
"bundled": false,
"singleton": true
},
"yjs": {
"bundled": false,
"singleton": true
}
}
}
}
Loading

0 comments on commit 8167995

Please sign in to comment.