@hocuspocus/provider 2.0.3 → 2.0.5

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.
@@ -1,5 +1,5 @@
1
1
  import * as Y from 'yjs';
2
- import { readAuthMessage, writeAuthentication, WsReadyStates, Unauthorized, Forbidden, awarenessStatesToArray } from '@hocuspocus/common';
2
+ import { readAuthMessage, writeAuthentication, WsReadyStates, Unauthorized, Forbidden, MessageTooBig, awarenessStatesToArray } from '@hocuspocus/common';
3
3
  import { retry } from '@lifeomic/attempt';
4
4
 
5
5
  /**
@@ -2206,6 +2206,10 @@ class HocuspocusProviderWebsocket extends EventEmitter {
2206
2206
  return; // TODO REMOVE ME
2207
2207
  }
2208
2208
  }
2209
+ if (event.code === MessageTooBig.code) {
2210
+ console.warn(`[HocuspocusProvider] Connection closed with status MessageTooBig: ${event.reason}`);
2211
+ this.shouldConnect = false;
2212
+ }
2209
2213
  if (this.connectionAttempt) {
2210
2214
  // That connection attempt failed.
2211
2215
  this.rejectConnectionAttempt();
@@ -2442,6 +2446,7 @@ class HocuspocusProvider extends EventEmitter {
2442
2446
  this.configuration.websocketProvider.detach(this);
2443
2447
  }
2444
2448
  async onOpen(event) {
2449
+ this.isAuthenticated = false;
2445
2450
  this.emit('open', { event });
2446
2451
  if (this.isAuthenticationRequired) {
2447
2452
  this.send(AuthenticationMessage, {
@@ -2574,17 +2579,23 @@ class HocuspocusProvider extends EventEmitter {
2574
2579
  }
2575
2580
  }
2576
2581
 
2582
+ class TiptapCollabProviderWebsocket extends HocuspocusProviderWebsocket {
2583
+ constructor(configuration) {
2584
+ super({ ...configuration, url: `wss://${configuration.appId}.collab.tiptap.cloud` });
2585
+ }
2586
+ }
2587
+
2577
2588
  class TiptapCollabProvider extends HocuspocusProvider {
2578
2589
  constructor(configuration) {
2579
2590
  if (!configuration.websocketProvider) {
2580
- configuration.websocketProvider = new HocuspocusProviderWebsocket({ url: `wss://${configuration.appId}.collab.tiptap.cloud` });
2591
+ configuration.websocketProvider = new TiptapCollabProviderWebsocket({ appId: configuration.appId });
2581
2592
  }
2582
2593
  if (!configuration.token) {
2583
- configuration.token = 'notoken';
2594
+ configuration.token = 'notoken'; // need to send a token anyway (which will be ignored)
2584
2595
  }
2585
2596
  super(configuration);
2586
2597
  }
2587
2598
  }
2588
2599
 
2589
- export { HocuspocusProvider, HocuspocusProviderWebsocket, MessageType, TiptapCollabProvider, WebSocketStatus };
2600
+ export { HocuspocusProvider, HocuspocusProviderWebsocket, MessageType, TiptapCollabProvider, TiptapCollabProviderWebsocket, WebSocketStatus };
2590
2601
  //# sourceMappingURL=hocuspocus-provider.esm.js.map