@hocuspocus/provider 2.2.1 → 2.2.2
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.
- package/dist/hocuspocus-provider.cjs +32 -10
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +32 -10
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +11 -2
- package/dist/packages/provider/src/TiptapCollabProvider.d.ts +4 -2
- package/dist/packages/server/src/DirectConnection.d.ts +1 -1
- package/package.json +2 -2
- package/src/HocuspocusProvider.ts +45 -13
- package/src/TiptapCollabProvider.ts +6 -3
|
@@ -2343,8 +2343,17 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2343
2343
|
forceSync: null,
|
|
2344
2344
|
};
|
|
2345
2345
|
this.isConnected = true;
|
|
2346
|
-
this.boundBeforeUnload = this.beforeUnload.bind(this);
|
|
2347
2346
|
this.boundBroadcastChannelSubscriber = this.broadcastChannelSubscriber.bind(this);
|
|
2347
|
+
this.boundBeforeUnload = this.beforeUnload.bind(this);
|
|
2348
|
+
this.boundOnOpen = this.onOpen.bind(this);
|
|
2349
|
+
this.boundOnMessage = this.onMessage.bind(this);
|
|
2350
|
+
this.boundOnClose = this.onClose.bind(this);
|
|
2351
|
+
this.boundOnStatus = this.onStatus.bind(this);
|
|
2352
|
+
this.forwardConnect = (e) => this.emit('connect', e);
|
|
2353
|
+
this.forwardOpen = (e) => this.emit('open', e);
|
|
2354
|
+
this.forwardClose = (e) => this.emit('close', e);
|
|
2355
|
+
this.forwardDisconnect = (e) => this.emit('disconnect', e);
|
|
2356
|
+
this.forwardDestroy = (e) => this.emit('destroy', e);
|
|
2348
2357
|
this.setConfiguration(configuration);
|
|
2349
2358
|
this.configuration.document = configuration.document ? configuration.document : new Y__namespace.Doc();
|
|
2350
2359
|
this.configuration.awareness = configuration.awareness ? configuration.awareness : new Awareness(this.document);
|
|
@@ -2359,18 +2368,18 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2359
2368
|
this.on('authenticated', this.configuration.onAuthenticated);
|
|
2360
2369
|
this.on('authenticationFailed', this.configuration.onAuthenticationFailed);
|
|
2361
2370
|
this.configuration.websocketProvider.on('connect', this.configuration.onConnect);
|
|
2362
|
-
this.configuration.websocketProvider.on('connect',
|
|
2363
|
-
this.configuration.websocketProvider.on('open', this.
|
|
2364
|
-
this.configuration.websocketProvider.on('open',
|
|
2365
|
-
this.configuration.websocketProvider.on('message', this.
|
|
2366
|
-
this.configuration.websocketProvider.on('close', this.
|
|
2371
|
+
this.configuration.websocketProvider.on('connect', this.forwardConnect);
|
|
2372
|
+
this.configuration.websocketProvider.on('open', this.boundOnOpen);
|
|
2373
|
+
this.configuration.websocketProvider.on('open', this.forwardOpen);
|
|
2374
|
+
this.configuration.websocketProvider.on('message', this.boundOnMessage);
|
|
2375
|
+
this.configuration.websocketProvider.on('close', this.boundOnClose);
|
|
2367
2376
|
this.configuration.websocketProvider.on('close', this.configuration.onClose);
|
|
2368
|
-
this.configuration.websocketProvider.on('close',
|
|
2369
|
-
this.configuration.websocketProvider.on('status', this.
|
|
2377
|
+
this.configuration.websocketProvider.on('close', this.forwardClose);
|
|
2378
|
+
this.configuration.websocketProvider.on('status', this.boundOnStatus);
|
|
2370
2379
|
this.configuration.websocketProvider.on('disconnect', this.configuration.onDisconnect);
|
|
2371
|
-
this.configuration.websocketProvider.on('disconnect',
|
|
2380
|
+
this.configuration.websocketProvider.on('disconnect', this.forwardDisconnect);
|
|
2372
2381
|
this.configuration.websocketProvider.on('destroy', this.configuration.onDestroy);
|
|
2373
|
-
this.configuration.websocketProvider.on('destroy',
|
|
2382
|
+
this.configuration.websocketProvider.on('destroy', this.forwardDestroy);
|
|
2374
2383
|
this.awareness.on('update', () => {
|
|
2375
2384
|
this.emit('awarenessUpdate', { states: common.awarenessStatesToArray(this.awareness.getStates()) });
|
|
2376
2385
|
});
|
|
@@ -2535,6 +2544,19 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2535
2544
|
this.awareness.off('update', this.awarenessUpdateHandler);
|
|
2536
2545
|
this.document.off('update', this.documentUpdateHandler);
|
|
2537
2546
|
this.removeAllListeners();
|
|
2547
|
+
this.configuration.websocketProvider.off('connect', this.configuration.onConnect);
|
|
2548
|
+
this.configuration.websocketProvider.off('connect', this.forwardConnect);
|
|
2549
|
+
this.configuration.websocketProvider.off('open', this.boundOnOpen);
|
|
2550
|
+
this.configuration.websocketProvider.off('open', this.forwardOpen);
|
|
2551
|
+
this.configuration.websocketProvider.off('message', this.boundOnMessage);
|
|
2552
|
+
this.configuration.websocketProvider.off('close', this.boundOnClose);
|
|
2553
|
+
this.configuration.websocketProvider.off('close', this.configuration.onClose);
|
|
2554
|
+
this.configuration.websocketProvider.off('close', this.forwardClose);
|
|
2555
|
+
this.configuration.websocketProvider.off('status', this.boundOnStatus);
|
|
2556
|
+
this.configuration.websocketProvider.off('disconnect', this.configuration.onDisconnect);
|
|
2557
|
+
this.configuration.websocketProvider.off('disconnect', this.forwardDisconnect);
|
|
2558
|
+
this.configuration.websocketProvider.off('destroy', this.configuration.onDestroy);
|
|
2559
|
+
this.configuration.websocketProvider.off('destroy', this.forwardDestroy);
|
|
2538
2560
|
this.send(CloseMessage, { documentName: this.configuration.name });
|
|
2539
2561
|
this.isConnected = false;
|
|
2540
2562
|
if (typeof window === 'undefined') {
|