Skip to content

Commit 14c1488

Browse files
Use content providers to remove RTC prefix (#418)
* Use content providers (v2) Co-authored-by: davidbrochart <[email protected]> * Reduce the diff * Rewrite logic which used to rely on RTC prefix, cleanup * Update to JupyterLab v4.4.0a2 * Align TypeScript version with JupyterLab, re-enable lib check * Fix TypeScript tests * Bump JupyterLab version used in CI tests * Bump JupyterLab installed with `dev_install` * Fix "Test Minimum Versions" job * Run UI tests on 4.4.0a2 or newer * Expect the copied link to not have `RTC:` prefix * Set awareness for user regardless of RTC prefix * Match any file, not only files starting with letters * Fix opening collaborator's file (remove no-longer needed RTC prefix) --------- Co-authored-by: davidbrochart <[email protected]>
1 parent 0a75715 commit 14c1488

File tree

21 files changed

+849
-681
lines changed

21 files changed

+849
-681
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
- name: Install dependencies
2929
run: |
30-
pip install "jupyterlab>=4.0.0,<5"
30+
pip install "jupyterlab>=4.4.0a2,<5"
3131
jlpm install
3232
3333
- name: Run pre-commit
@@ -273,7 +273,7 @@ jobs:
273273
name: "sdist"
274274
- name: Install dependencies
275275
run: |
276-
pip install jupyterlab jupyter_collaboration_ui*.tar.gz jupyter_docprovider*.tar.gz jupyter_server_ydoc*.tar.gz
276+
pip install "jupyterlab>=4.4.0a2" jupyter_collaboration_ui*.tar.gz jupyter_docprovider*.tar.gz jupyter_server_ydoc*.tar.gz
277277
278278
- name: Install playwright
279279
env:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@
6565
"stylelint-config-standard": "^30.0.1",
6666
"stylelint-prettier": "^3.0.0",
6767
"typedoc": "~0.23.28",
68-
"typescript": "~5.0.4"
68+
"typescript": "~5.1.6"
6969
}
7070
}

packages/collaboration-extension/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,25 @@
5757
"@jupyter/collaborative-drive": "^3.1.0",
5858
"@jupyter/docprovider": "^3.1.0",
5959
"@jupyter/ydoc": "^2.1.3 || ^3.0.0",
60-
"@jupyterlab/application": "^4.2.0",
61-
"@jupyterlab/apputils": "^4.2.0",
62-
"@jupyterlab/codemirror": "^4.2.0",
63-
"@jupyterlab/coreutils": "^6.0.5",
64-
"@jupyterlab/services": "^7.0.5",
65-
"@jupyterlab/statedb": "^4.2.0",
66-
"@jupyterlab/translation": "^4.2.0",
67-
"@jupyterlab/ui-components": "^4.2.0",
60+
"@jupyterlab/application": "^4.4.0-alpha.2",
61+
"@jupyterlab/apputils": "^4.4.0-alpha.2",
62+
"@jupyterlab/codemirror": "^4.4.0-alpha.2",
63+
"@jupyterlab/coreutils": "^6.4.0-alpha.2",
64+
"@jupyterlab/services": "^7.4.0-alpha.2",
65+
"@jupyterlab/statedb": "^4.4.0-alpha.2",
66+
"@jupyterlab/translation": "^4.4.0-alpha.2",
67+
"@jupyterlab/ui-components": "^4.4.0-alpha.2",
6868
"@lumino/widgets": "^2.1.0",
6969
"y-protocols": "^1.0.5",
7070
"y-websocket": "^1.3.15",
7171
"yjs": "^13.5.40"
7272
},
7373
"devDependencies": {
74-
"@jupyterlab/builder": "^4.0.5",
74+
"@jupyterlab/builder": "^4.4.0-alpha.2",
7575
"@types/react": "~18.3.1",
7676
"npm-run-all": "^4.1.5",
7777
"rimraf": "^4.1.2",
78-
"typescript": "~5.0.4"
78+
"typescript": "~5.1.6"
7979
},
8080
"publishConfig": {
8181
"access": "public"

packages/collaboration-extension/src/collaboration.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ export const rtcGlobalAwarenessPlugin: JupyterFrontEndPlugin<IAwareness> = {
111111
const data: any = await state.toJSON();
112112
const current: string = data['layout-restorer:data']?.main?.current || '';
113113

114-
if (current.match(/^\w+:RTC:/)) {
114+
// For example matches `notebook:Untitled.ipynb` or `editor:untitled.txt`,
115+
// but not when in launcher or terminal.
116+
if (current.match(/^\w+:.+/)) {
115117
awareness.setLocalStateField('current', current);
116118
} else {
117119
awareness.setLocalStateField('current', null);

packages/collaboration/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
"dependencies": {
4242
"@codemirror/state": "^6.2.0",
4343
"@codemirror/view": "^6.7.0",
44-
"@jupyterlab/apputils": "^4.0.5",
45-
"@jupyterlab/coreutils": "^6.0.5",
46-
"@jupyterlab/docregistry": "^4.0.5",
47-
"@jupyterlab/services": "^7.0.5",
48-
"@jupyterlab/ui-components": "^4.0.5",
44+
"@jupyterlab/apputils": "^4.4.0-alpha.2",
45+
"@jupyterlab/coreutils": "^6.4.0-alpha.2",
46+
"@jupyterlab/docregistry": "^4.4.0-alpha.2",
47+
"@jupyterlab/services": "^7.4.0-alpha.2",
48+
"@jupyterlab/ui-components": "^4.4.0-alpha.2",
4949
"@lumino/coreutils": "^2.1.0",
5050
"@lumino/signaling": "^2.0.0",
5151
"@lumino/virtualdom": "^2.0.0",
@@ -57,7 +57,7 @@
5757
"devDependencies": {
5858
"@types/react": "~18.3.1",
5959
"rimraf": "^4.1.2",
60-
"typescript": "~5.0.4"
60+
"typescript": "~5.1.6"
6161
},
6262
"publishConfig": {
6363
"access": "public"

packages/collaboration/src/collaboratorspanel.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,31 +155,30 @@ export function Collaborator(props: {
155155
let currentMain = '';
156156

157157
if (collaborator.current) {
158+
// Discard widget tracker prefix (e.g. `notebook:` or `editor:`)
158159
const path = collaborator.current.split(':');
159-
currentMain = `${path[1]}:${path[2]}`;
160+
currentMain = `${path[1]}`;
160161
}
161162

162163
const documents: string[] = collaborator.documents || [];
163164

164165
const docs = documents.map(document => {
165-
const path = document.split(':');
166166
const fileTypes = props.docRegistry
167-
?.getFileTypesForPath(path[1])
167+
?.getFileTypesForPath(document)
168168
?.filter(ft => ft.icon !== undefined);
169169
const icon = fileTypes ? fileTypes[0].icon! : fileIcon;
170170
const iconClass: string | undefined = fileTypes
171171
? fileTypes[0].iconClass
172172
: undefined;
173173

174174
return {
175-
filepath: path[1],
176175
filename:
177-
path[1].length > 40
178-
? path[1]
176+
document.length > 40
177+
? document
179178
.slice(0, 10)
180179
.concat('…')
181-
.concat(path[1].slice(path[1].length - 15))
182-
: path[1],
180+
.concat(document.slice(document.length - 15))
181+
: document,
183182
fileLocation: document,
184183
icon,
185184
iconClass
@@ -242,7 +241,10 @@ export function Collaborator(props: {
242241
className={'jp-DirListing-itemIcon'}
243242
stylesheet={'listing'}
244243
/>
245-
<span className={'jp-DirListing-itemText'} title={doc.filepath}>
244+
<span
245+
className={'jp-DirListing-itemText'}
246+
title={doc.fileLocation}
247+
>
246248
{doc.filename}
247249
</span>
248250
</li>

packages/collaborative-drive/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
},
3939
"dependencies": {
4040
"@jupyter/ydoc": "^2.1.3 || ^3.0.0",
41-
"@jupyterlab/services": "^7.2.0",
41+
"@jupyterlab/services": "^7.4.0-alpha.2",
4242
"@lumino/coreutils": "^2.1.0",
4343
"@lumino/disposable": "^2.1.0"
4444
},
4545
"devDependencies": {
4646
"rimraf": "^4.1.2",
47-
"typescript": "~5.0.4"
47+
"typescript": "~5.1.6"
4848
},
4949
"publishConfig": {
5050
"access": "public"

packages/collaborative-drive/src/tokens.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
// Copyright (c) Jupyter Development Team.
22
// Distributed under the terms of the Modified BSD License.
33

4-
import { DocumentChange, IAwareness, YDocument } from '@jupyter/ydoc';
5-
import { Contents } from '@jupyterlab/services';
4+
import { IAwareness } from '@jupyter/ydoc';
5+
import { Contents, SharedDocumentFactory } from '@jupyterlab/services';
66
import { IDisposable } from '@lumino/disposable';
77

88
import { Token } from '@lumino/coreutils';
99

1010
/**
1111
* The collaborative drive.
1212
*/
13-
export const ICollaborativeDrive = new Token<ICollaborativeDrive>(
14-
'@jupyter/collaboration-extension:ICollaborativeDrive'
15-
);
13+
export const ICollaborativeContentProvider =
14+
new Token<ICollaborativeContentProvider>(
15+
'@jupyter/collaboration-extension:ICollaborativeContentProvider'
16+
);
1617

1718
/**
1819
* The global awareness token.
@@ -21,18 +22,7 @@ export const IGlobalAwareness = new Token<IAwareness>(
2122
'@jupyter/collaboration:IGlobalAwareness'
2223
);
2324

24-
/**
25-
* A document factory for registering shared models
26-
*/
27-
export type SharedDocumentFactory = (
28-
options: Contents.ISharedFactoryOptions
29-
) => YDocument<DocumentChange>;
30-
31-
/**
32-
* A Collaborative implementation for an `IDrive`, talking to the
33-
* server using the Jupyter REST API and a WebSocket connection.
34-
*/
35-
export interface ICollaborativeDrive extends Contents.IDrive {
25+
export interface ICollaborativeContentProvider {
3626
/**
3727
* SharedModel factory for the YDrive.
3828
*/

packages/docprovider-extension/package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,26 @@
5656
"@jupyter/collaborative-drive": "^3.1.0",
5757
"@jupyter/docprovider": "^3.1.0",
5858
"@jupyter/ydoc": "^2.1.3 || ^3.0.0",
59-
"@jupyterlab/application": "^4.2.0",
60-
"@jupyterlab/apputils": "^4.2.0",
61-
"@jupyterlab/docregistry": "^4.2.0",
62-
"@jupyterlab/filebrowser": "^4.2.0",
63-
"@jupyterlab/fileeditor": "^4.2.0",
64-
"@jupyterlab/logconsole": "^4.2.0",
65-
"@jupyterlab/notebook": "^4.2.0",
66-
"@jupyterlab/settingregistry": "^4.2.0",
67-
"@jupyterlab/translation": "^4.2.0",
59+
"@jupyterlab/application": "^4.4.0-alpha.2",
60+
"@jupyterlab/apputils": "^4.4.0-alpha.2",
61+
"@jupyterlab/docregistry": "^4.4.0-alpha.2",
62+
"@jupyterlab/filebrowser": "^4.4.0-alpha.2",
63+
"@jupyterlab/fileeditor": "^4.4.0-alpha.2",
64+
"@jupyterlab/logconsole": "^4.4.0-alpha.2",
65+
"@jupyterlab/notebook": "^4.4.0-alpha.2",
66+
"@jupyterlab/settingregistry": "^4.4.0-alpha.2",
67+
"@jupyterlab/translation": "^4.4.0-alpha.2",
6868
"@lumino/commands": "^2.1.0",
6969
"y-protocols": "^1.0.5",
7070
"y-websocket": "^1.3.15",
7171
"yjs": "^13.5.40"
7272
},
7373
"devDependencies": {
74-
"@jupyterlab/builder": "^4.0.0",
74+
"@jupyterlab/builder": "^4.4.0-alpha.2",
7575
"@types/react": "~18.3.1",
7676
"npm-run-all": "^4.1.5",
7777
"rimraf": "^4.1.2",
78-
"typescript": "~5.0.4"
78+
"typescript": "~5.1.6"
7979
},
8080
"publishConfig": {
8181
"access": "public"

0 commit comments

Comments
 (0)