@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
|
@@ -2319,8 +2319,17 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2319
2319
|
forceSync: null,
|
|
2320
2320
|
};
|
|
2321
2321
|
this.isConnected = true;
|
|
2322
|
-
this.boundBeforeUnload = this.beforeUnload.bind(this);
|
|
2323
2322
|
this.boundBroadcastChannelSubscriber = this.broadcastChannelSubscriber.bind(this);
|
|
2323
|
+
this.boundBeforeUnload = this.beforeUnload.bind(this);
|
|
2324
|
+
this.boundOnOpen = this.onOpen.bind(this);
|
|
2325
|
+
this.boundOnMessage = this.onMessage.bind(this);
|
|
2326
|
+
this.boundOnClose = this.onClose.bind(this);
|
|
2327
|
+
this.boundOnStatus = this.onStatus.bind(this);
|
|
2328
|
+
this.forwardConnect = (e) => this.emit('connect', e);
|
|
2329
|
+
this.forwardOpen = (e) => this.emit('open', e);
|
|
2330
|
+
this.forwardClose = (e) => this.emit('close', e);
|
|
2331
|
+
this.forwardDisconnect = (e) => this.emit('disconnect', e);
|
|
2332
|
+
this.forwardDestroy = (e) => this.emit('destroy', e);
|
|
2324
2333
|
this.setConfiguration(configuration);
|
|
2325
2334
|
this.configuration.document = configuration.document ? configuration.document : new Y.Doc();
|
|
2326
2335
|
this.configuration.awareness = configuration.awareness ? configuration.awareness : new Awareness(this.document);
|
|
@@ -2335,18 +2344,18 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2335
2344
|
this.on('authenticated', this.configuration.onAuthenticated);
|
|
2336
2345
|
this.on('authenticationFailed', this.configuration.onAuthenticationFailed);
|
|
2337
2346
|
this.configuration.websocketProvider.on('connect', this.configuration.onConnect);
|
|
2338
|
-
this.configuration.websocketProvider.on('connect',
|
|
2339
|
-
this.configuration.websocketProvider.on('open', this.
|
|
2340
|
-
this.configuration.websocketProvider.on('open',
|
|
2341
|
-
this.configuration.websocketProvider.on('message', this.
|
|
2342
|
-
this.configuration.websocketProvider.on('close', this.
|
|
2347
|
+
this.configuration.websocketProvider.on('connect', this.forwardConnect);
|
|
2348
|
+
this.configuration.websocketProvider.on('open', this.boundOnOpen);
|
|
2349
|
+
this.configuration.websocketProvider.on('open', this.forwardOpen);
|
|
2350
|
+
this.configuration.websocketProvider.on('message', this.boundOnMessage);
|
|
2351
|
+
this.configuration.websocketProvider.on('close', this.boundOnClose);
|
|
2343
2352
|
this.configuration.websocketProvider.on('close', this.configuration.onClose);
|
|
2344
|
-
this.configuration.websocketProvider.on('close',
|
|
2345
|
-
this.configuration.websocketProvider.on('status', this.
|
|
2353
|
+
this.configuration.websocketProvider.on('close', this.forwardClose);
|
|
2354
|
+
this.configuration.websocketProvider.on('status', this.boundOnStatus);
|
|
2346
2355
|
this.configuration.websocketProvider.on('disconnect', this.configuration.onDisconnect);
|
|
2347
|
-
this.configuration.websocketProvider.on('disconnect',
|
|
2356
|
+
this.configuration.websocketProvider.on('disconnect', this.forwardDisconnect);
|
|
2348
2357
|
this.configuration.websocketProvider.on('destroy', this.configuration.onDestroy);
|
|
2349
|
-
this.configuration.websocketProvider.on('destroy',
|
|
2358
|
+
this.configuration.websocketProvider.on('destroy', this.forwardDestroy);
|
|
2350
2359
|
this.awareness.on('update', () => {
|
|
2351
2360
|
this.emit('awarenessUpdate', { states: awarenessStatesToArray(this.awareness.getStates()) });
|
|
2352
2361
|
});
|
|
@@ -2511,6 +2520,19 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2511
2520
|
this.awareness.off('update', this.awarenessUpdateHandler);
|
|
2512
2521
|
this.document.off('update', this.documentUpdateHandler);
|
|
2513
2522
|
this.removeAllListeners();
|
|
2523
|
+
this.configuration.websocketProvider.off('connect', this.configuration.onConnect);
|
|
2524
|
+
this.configuration.websocketProvider.off('connect', this.forwardConnect);
|
|
2525
|
+
this.configuration.websocketProvider.off('open', this.boundOnOpen);
|
|
2526
|
+
this.configuration.websocketProvider.off('open', this.forwardOpen);
|
|
2527
|
+
this.configuration.websocketProvider.off('message', this.boundOnMessage);
|
|
2528
|
+
this.configuration.websocketProvider.off('close', this.boundOnClose);
|
|
2529
|
+
this.configuration.websocketProvider.off('close', this.configuration.onClose);
|
|
2530
|
+
this.configuration.websocketProvider.off('close', this.forwardClose);
|
|
2531
|
+
this.configuration.websocketProvider.off('status', this.boundOnStatus);
|
|
2532
|
+
this.configuration.websocketProvider.off('disconnect', this.configuration.onDisconnect);
|
|
2533
|
+
this.configuration.websocketProvider.off('disconnect', this.forwardDisconnect);
|
|
2534
|
+
this.configuration.websocketProvider.off('destroy', this.configuration.onDestroy);
|
|
2535
|
+
this.configuration.websocketProvider.off('destroy', this.forwardDestroy);
|
|
2514
2536
|
this.send(CloseMessage, { documentName: this.configuration.name });
|
|
2515
2537
|
this.isConnected = false;
|
|
2516
2538
|
if (typeof window === 'undefined') {
|