Skip to content

Commit 39e5019

Browse files
committed
Remove document provider _isFork attribute
1 parent d035a80 commit 39e5019

File tree

2 files changed

+115
-46
lines changed

2 files changed

+115
-46
lines changed

packages/docprovider/src/yprovider.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ export class WebSocketProvider implements IDocumentProvider {
3232
*/
3333
constructor(options: WebSocketProvider.IOptions) {
3434
this._isDisposed = false;
35-
this._isFork = options.isFork || false;
36-
this._sessionId = options.sessionId || '';
35+
this._sessionId = options.sessionId ?? '';
3736
this._path = options.path;
3837
this._contentType = options.contentType;
3938
this._format = options.format;
@@ -83,8 +82,6 @@ export class WebSocketProvider implements IDocumentProvider {
8382
}
8483

8584
async fork(): Promise<void> {
86-
this._yWebsocketProvider?.disconnect();
87-
8885
const session = await requestDocSession(
8986
this._format,
9087
this._contentType,
@@ -94,6 +91,13 @@ export class WebSocketProvider implements IDocumentProvider {
9491
const response = await requestDocFork(`${session.format}:${session.type}:${session.fileId}`);
9592
const forkId = response.roomId;
9693

94+
this._sharedModel.forkId = forkId;
95+
96+
// the fork has to be advertised before the ydoc is connected to the forked room
97+
// so that it targets the root room
98+
this._sharedModel.addFork(forkId);
99+
100+
this._yWebsocketProvider?.disconnect();
97101
this._yWebsocketProvider = new YWebsocketProvider(
98102
this._serverUrl,
99103
forkId,
@@ -104,13 +108,12 @@ export class WebSocketProvider implements IDocumentProvider {
104108
awareness: this._awareness
105109
}
106110
);
107-
108-
this._sharedModel.addFork(forkId);
109111
}
110112

111113
connectFork(forkId: string, sharedModel: YDocument<DocumentChange>): IDocumentProvider {
114+
sharedModel.forkId = forkId;
115+
112116
return new WebSocketProvider({
113-
isFork: true,
114117
sessionId: this._sessionId,
115118
url: this._serverUrl,
116119
path: forkId,
@@ -124,10 +127,7 @@ export class WebSocketProvider implements IDocumentProvider {
124127

125128
private async _connect(): Promise<void> {
126129
var roomId: string;
127-
if (this._isFork) {
128-
roomId = this._path;
129-
}
130-
else {
130+
if (this._sharedModel.forkId === 'root') {
131131
const session = await requestDocSession(
132132
this._format,
133133
this._contentType,
@@ -136,6 +136,9 @@ export class WebSocketProvider implements IDocumentProvider {
136136
roomId = `${session.format}:${session.type}:${session.fileId}`;
137137
this._sessionId = session.sessionId;
138138
}
139+
else {
140+
roomId = this._path;
141+
}
139142

140143
this._yWebsocketProvider = new YWebsocketProvider(
141144
this._serverUrl,
@@ -181,7 +184,6 @@ export class WebSocketProvider implements IDocumentProvider {
181184
private _contentType: string;
182185
private _format: string;
183186
private _isDisposed: boolean;
184-
private _isFork: boolean;
185187
private _sessionId: string;
186188
private _path: string;
187189
private _ready = new PromiseDelegate<void>();
@@ -239,10 +241,5 @@ export namespace WebSocketProvider {
239241
* The document session ID, if the document is a fork
240242
*/
241243
sessionId?: string;
242-
243-
/**
244-
* Whether the document is a fork of a root document
245-
*/
246-
isFork?: boolean;
247244
}
248245
}

yarn.lock

Lines changed: 101 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ __metadata:
20352035
dependencies:
20362036
"@jupyter/collaboration": ^2.0.2
20372037
"@jupyter/docprovider": ^2.0.2
2038-
"@jupyter/ydoc": ^1.1.0-a0
2038+
"@jupyter/ydoc": "file:.yalc/@jupyter/ydoc"
20392039
"@jupyterlab/application": ^4.0.5
20402040
"@jupyterlab/apputils": ^4.0.5
20412041
"@jupyterlab/builder": ^4.0.5
@@ -2070,6 +2070,7 @@ __metadata:
20702070
"@codemirror/state": ^6.2.0
20712071
"@codemirror/view": ^6.7.0
20722072
"@jupyter/docprovider": ^2.0.2
2073+
"@jupyter/ydoc": "file:.yalc/@jupyter/ydoc"
20732074
"@jupyterlab/apputils": ^4.0.5
20742075
"@jupyterlab/coreutils": ^6.0.5
20752076
"@jupyterlab/services": ^7.0.5
@@ -2090,7 +2091,7 @@ __metadata:
20902091
version: 0.0.0-use.local
20912092
resolution: "@jupyter/docprovider@workspace:packages/docprovider"
20922093
dependencies:
2093-
"@jupyter/ydoc": ^1.1.0-a0
2094+
"@jupyter/ydoc": "file:.yalc/@jupyter/ydoc"
20942095
"@jupyterlab/coreutils": ^6.0.5
20952096
"@jupyterlab/services": ^7.0.5
20962097
"@jupyterlab/testing": ^4.0.5
@@ -2130,31 +2131,17 @@ __metadata:
21302131
languageName: unknown
21312132
linkType: soft
21322133

2133-
"@jupyter/ydoc@npm:^1.0.2":
2134-
version: 1.0.2
2135-
resolution: "@jupyter/ydoc@npm:1.0.2"
2136-
dependencies:
2137-
"@jupyterlab/nbformat": ^3.0.0 || ^4.0.0-alpha.21 || ^4.0.0
2138-
"@lumino/coreutils": ^1.11.0 || ^2.0.0
2139-
"@lumino/disposable": ^1.10.0 || ^2.0.0
2140-
"@lumino/signaling": ^1.10.0 || ^2.0.0
2141-
y-protocols: ^1.0.5
2142-
yjs: ^13.5.40
2143-
checksum: 739f9630940466b3cfcd7b742dd06479f81772ca13f863d057af0bbb5e318829506969066ab72977e7c721644982b5c8f88cf44e1ae81955ed1c27e87632d1f2
2144-
languageName: node
2145-
linkType: hard
2146-
2147-
"@jupyter/ydoc@npm:^1.1.0-a0":
2148-
version: 1.1.0-a0
2149-
resolution: "@jupyter/ydoc@npm:1.1.0-a0"
2134+
"@jupyter/ydoc@file:.yalc/@jupyter/ydoc::locator=%40jupyter%2Freal-time-collaboration%40workspace%3A.":
2135+
version: 2.0.1
2136+
resolution: "@jupyter/ydoc@file:.yalc/@jupyter/ydoc#.yalc/@jupyter/ydoc::hash=c66726&locator=%40jupyter%2Freal-time-collaboration%40workspace%3A."
21502137
dependencies:
21512138
"@jupyterlab/nbformat": ^3.0.0 || ^4.0.0-alpha.21 || ^4.0.0
21522139
"@lumino/coreutils": ^1.11.0 || ^2.0.0
21532140
"@lumino/disposable": ^1.10.0 || ^2.0.0
21542141
"@lumino/signaling": ^1.10.0 || ^2.0.0
21552142
y-protocols: ^1.0.5
21562143
yjs: ^13.5.40
2157-
checksum: 0099bacb2884a460867658e7f5a944e4d6eca7c4d3d68a6b31102be77d8fc9b6ba162af55c20f81c70f7fef4e9d9329eee4da32063c0caa0c6e3f10a488f95b5
2144+
checksum: f5cac20b6b88fb9ced006923ad7164bb53fcc7565b66bc4bd454bcf72595ed3f0689c479166caabff57bd5a5f73534ce3af08623123a30870e39382c74374d61
21582145
languageName: node
21592146
linkType: hard
21602147

@@ -2385,6 +2372,20 @@ __metadata:
23852372
languageName: node
23862373
linkType: hard
23872374

2375+
"@jupyterlab/coreutils@npm:^6.1.2":
2376+
version: 6.1.2
2377+
resolution: "@jupyterlab/coreutils@npm:6.1.2"
2378+
dependencies:
2379+
"@lumino/coreutils": ^2.1.2
2380+
"@lumino/disposable": ^2.1.2
2381+
"@lumino/signaling": ^2.1.2
2382+
minimist: ~1.2.0
2383+
path-browserify: ^1.0.0
2384+
url-parse: ~1.5.4
2385+
checksum: 6dcc812e0ebae28f902ece4acd58aee8103033b23a3bac0935d4d9d8c9c10f8797b422f4e8b0be53fac4781811fb9b82874ce499cd69a6d198986e0cdb4a97ff
2386+
languageName: node
2387+
linkType: hard
2388+
23882389
"@jupyterlab/docmanager@npm:^4.0.5":
23892390
version: 4.0.5
23902391
resolution: "@jupyterlab/docmanager@npm:4.0.5"
@@ -2562,6 +2563,15 @@ __metadata:
25622563
languageName: node
25632564
linkType: hard
25642565

2566+
"@jupyterlab/nbformat@npm:^4.1.2":
2567+
version: 4.1.2
2568+
resolution: "@jupyterlab/nbformat@npm:4.1.2"
2569+
dependencies:
2570+
"@lumino/coreutils": ^2.1.2
2571+
checksum: 6c55337b667dcc5a6282f93972a30d227ba7c3f576fc4b60069408dd114dff1bc9f743bb6f984da088dfda25b7c4f25f13a472cd5c05b24af2e32b6b17172c6b
2572+
languageName: node
2573+
linkType: hard
2574+
25652575
"@jupyterlab/notebook@npm:^4.0.5":
25662576
version: 4.0.5
25672577
resolution: "@jupyterlab/notebook@npm:4.0.5"
@@ -2663,22 +2673,22 @@ __metadata:
26632673
languageName: node
26642674
linkType: hard
26652675

2666-
"@jupyterlab/services@npm:^7.0.5":
2667-
version: 7.0.5
2668-
resolution: "@jupyterlab/services@npm:7.0.5"
2676+
"@jupyterlab/services@file:.yalc/@jupyterlab/services::locator=%40jupyter%2Freal-time-collaboration%40workspace%3A.":
2677+
version: 7.1.2
2678+
resolution: "@jupyterlab/services@file:.yalc/@jupyterlab/services#.yalc/@jupyterlab/services::hash=cec64c&locator=%40jupyter%2Freal-time-collaboration%40workspace%3A."
26692679
dependencies:
2670-
"@jupyter/ydoc": ^1.0.2
2671-
"@jupyterlab/coreutils": ^6.0.5
2672-
"@jupyterlab/nbformat": ^4.0.5
2673-
"@jupyterlab/settingregistry": ^4.0.5
2674-
"@jupyterlab/statedb": ^4.0.5
2680+
"@jupyter/ydoc": ^1.1.1
2681+
"@jupyterlab/coreutils": ^6.1.2
2682+
"@jupyterlab/nbformat": ^4.1.2
2683+
"@jupyterlab/settingregistry": ^4.1.2
2684+
"@jupyterlab/statedb": ^4.1.2
26752685
"@lumino/coreutils": ^2.1.2
26762686
"@lumino/disposable": ^2.1.2
26772687
"@lumino/polling": ^2.1.2
26782688
"@lumino/properties": ^2.0.1
26792689
"@lumino/signaling": ^2.1.2
26802690
ws: ^8.11.0
2681-
checksum: cf4176dbb73c08e777b5e6ca26cba6ad7a142fc76ae6b46ef17ac7d8c8021f62d66e95e2ee0dbce5c33a0b2380750d440783d0398d787b8e8028920e04dd1d0b
2691+
checksum: 466c391f75583f033d62676e7e4d3d3db3062913f2b8a58a6323711cdf1d0f2e3061ed12d9965c220a5bb7c0b1d5bbac5cef9ec692198ad41b0d6311d77edf6c
26822692
languageName: node
26832693
linkType: hard
26842694

@@ -2701,6 +2711,25 @@ __metadata:
27012711
languageName: node
27022712
linkType: hard
27032713

2714+
"@jupyterlab/settingregistry@npm:^4.1.2":
2715+
version: 4.1.2
2716+
resolution: "@jupyterlab/settingregistry@npm:4.1.2"
2717+
dependencies:
2718+
"@jupyterlab/nbformat": ^4.1.2
2719+
"@jupyterlab/statedb": ^4.1.2
2720+
"@lumino/commands": ^2.2.0
2721+
"@lumino/coreutils": ^2.1.2
2722+
"@lumino/disposable": ^2.1.2
2723+
"@lumino/signaling": ^2.1.2
2724+
"@rjsf/utils": ^5.13.4
2725+
ajv: ^8.12.0
2726+
json5: ^2.2.3
2727+
peerDependencies:
2728+
react: ">=16"
2729+
checksum: a0a1f9d3747caa3ac6e523df64b4023f9d3bc1c1c9a2982cdf8113a5ba3f191e10cd8a897e9bff111b9faa834b48c0666a6b03ce3749c9f9e5ffb43b9331c207
2730+
languageName: node
2731+
linkType: hard
2732+
27042733
"@jupyterlab/statedb@npm:^4.0.5":
27052734
version: 4.0.5
27062735
resolution: "@jupyterlab/statedb@npm:4.0.5"
@@ -2714,6 +2743,19 @@ __metadata:
27142743
languageName: node
27152744
linkType: hard
27162745

2746+
"@jupyterlab/statedb@npm:^4.1.2":
2747+
version: 4.1.2
2748+
resolution: "@jupyterlab/statedb@npm:4.1.2"
2749+
dependencies:
2750+
"@lumino/commands": ^2.2.0
2751+
"@lumino/coreutils": ^2.1.2
2752+
"@lumino/disposable": ^2.1.2
2753+
"@lumino/properties": ^2.0.1
2754+
"@lumino/signaling": ^2.1.2
2755+
checksum: 30314f4f93441aac6d62068c264c94c0e694829c64ce0dc59e867ef4d188d396edc9c6868dd92ca514f6e7b15dc2568ff3f2de078a20283f60cc5ae70723bacc
2756+
languageName: node
2757+
linkType: hard
2758+
27172759
"@jupyterlab/statusbar@npm:^4.0.5":
27182760
version: 4.0.5
27192761
resolution: "@jupyterlab/statusbar@npm:4.0.5"
@@ -3110,6 +3152,21 @@ __metadata:
31103152
languageName: node
31113153
linkType: hard
31123154

3155+
"@lumino/commands@npm:^2.2.0":
3156+
version: 2.2.0
3157+
resolution: "@lumino/commands@npm:2.2.0"
3158+
dependencies:
3159+
"@lumino/algorithm": ^2.0.1
3160+
"@lumino/coreutils": ^2.1.2
3161+
"@lumino/disposable": ^2.1.2
3162+
"@lumino/domutils": ^2.0.1
3163+
"@lumino/keyboard": ^2.0.1
3164+
"@lumino/signaling": ^2.1.2
3165+
"@lumino/virtualdom": ^2.0.1
3166+
checksum: 093e9715491e5cef24bc80665d64841417b400f2fa595f9b60832a3b6340c405c94a6aa276911944a2c46d79a6229f3cc087b73f50852bba25ece805abd0fae9
3167+
languageName: node
3168+
linkType: hard
3169+
31133170
"@lumino/coreutils@npm:^1.11.0 || ^2.0.0, @lumino/coreutils@npm:^1.11.0 || ^2.1.2, @lumino/coreutils@npm:^2.1.0, @lumino/coreutils@npm:^2.1.1, @lumino/coreutils@npm:^2.1.2":
31143171
version: 2.1.2
31153172
resolution: "@lumino/coreutils@npm:2.1.2"
@@ -3801,6 +3858,21 @@ __metadata:
38013858
languageName: node
38023859
linkType: hard
38033860

3861+
"@rjsf/utils@npm:^5.13.4":
3862+
version: 5.17.1
3863+
resolution: "@rjsf/utils@npm:5.17.1"
3864+
dependencies:
3865+
json-schema-merge-allof: ^0.8.1
3866+
jsonpointer: ^5.0.1
3867+
lodash: ^4.17.21
3868+
lodash-es: ^4.17.21
3869+
react-is: ^18.2.0
3870+
peerDependencies:
3871+
react: ^16.14.0 || >=17
3872+
checksum: 83010de66b06f1046b023a0b7d0bf30b5f47b152893c3b12f1f42faa89e7c7d18b2f04fe2e9035e5f63454317f09e6d5753fc014d43b933c8023b71fc50c3acf
3873+
languageName: node
3874+
linkType: hard
3875+
38043876
"@sigstore/protobuf-specs@npm:^0.1.0":
38053877
version: 0.1.0
38063878
resolution: "@sigstore/protobuf-specs@npm:0.1.0"

0 commit comments

Comments
 (0)