@hocuspocus/provider 2.0.2 → 2.0.4
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 +23 -4
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +24 -6
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/common/src/CloseEvents.d.ts +6 -0
- package/dist/packages/extension-redis/src/Redis.d.ts +6 -1
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +1 -0
- package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +11 -0
- package/dist/packages/provider/src/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/HocuspocusProvider.ts +13 -2
- package/src/HocuspocusProviderWebsocket.ts +6 -1
- package/src/MessageReceiver.ts +1 -1
- package/src/TiptapCollabProvider.ts +4 -5
- package/src/TiptapCollabProviderWebsocket.ts +21 -0
- package/src/index.ts +1 -0
- package/dist/packages/provider/src/HocuspocusCloudProvider.d.ts +0 -12
- package/src/HocuspocusCloudProvider.ts +0 -41
|
@@ -1806,7 +1806,7 @@ class MessageReceiver {
|
|
|
1806
1806
|
}
|
|
1807
1807
|
if (syncMessageType === messageYjsUpdate || syncMessageType === messageYjsSyncStep2) {
|
|
1808
1808
|
if (provider.unsyncedChanges > 0) {
|
|
1809
|
-
provider.
|
|
1809
|
+
provider.updateUnsyncedChanges(-1);
|
|
1810
1810
|
}
|
|
1811
1811
|
}
|
|
1812
1812
|
}
|
|
@@ -2230,6 +2230,10 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
2230
2230
|
return; // TODO REMOVE ME
|
|
2231
2231
|
}
|
|
2232
2232
|
}
|
|
2233
|
+
if (event.code === common.MessageTooBig.code) {
|
|
2234
|
+
console.warn(`[HocuspocusProvider] Connection closed with status MessageTooBig: ${event.reason}`);
|
|
2235
|
+
this.shouldConnect = false;
|
|
2236
|
+
}
|
|
2233
2237
|
if (this.connectionAttempt) {
|
|
2234
2238
|
// That connection attempt failed.
|
|
2235
2239
|
this.rejectConnectionAttempt();
|
|
@@ -2403,6 +2407,10 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2403
2407
|
get hasUnsyncedChanges() {
|
|
2404
2408
|
return this.unsyncedChanges > 0;
|
|
2405
2409
|
}
|
|
2410
|
+
updateUnsyncedChanges(unsyncedChanges = 0) {
|
|
2411
|
+
this.unsyncedChanges += unsyncedChanges;
|
|
2412
|
+
this.emit('unsyncedChanges', this.unsyncedChanges);
|
|
2413
|
+
}
|
|
2406
2414
|
forceSync() {
|
|
2407
2415
|
this.send(SyncStepOneMessage, { document: this.document, documentName: this.configuration.name });
|
|
2408
2416
|
}
|
|
@@ -2422,7 +2430,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2422
2430
|
if (origin === this) {
|
|
2423
2431
|
return;
|
|
2424
2432
|
}
|
|
2425
|
-
this.
|
|
2433
|
+
this.updateUnsyncedChanges(1);
|
|
2426
2434
|
this.send(UpdateMessage, { update, documentName: this.configuration.name }, true);
|
|
2427
2435
|
}
|
|
2428
2436
|
awarenessUpdateHandler({ added, updated, removed }, origin) {
|
|
@@ -2440,6 +2448,9 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2440
2448
|
if (this.isSynced === state) {
|
|
2441
2449
|
return;
|
|
2442
2450
|
}
|
|
2451
|
+
if (state && this.unsyncedChanges > 0) {
|
|
2452
|
+
this.updateUnsyncedChanges(-1 * this.unsyncedChanges);
|
|
2453
|
+
}
|
|
2443
2454
|
this.isSynced = state;
|
|
2444
2455
|
this.emit('synced', { state });
|
|
2445
2456
|
this.emit('sync', { state });
|
|
@@ -2459,6 +2470,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2459
2470
|
this.configuration.websocketProvider.detach(this);
|
|
2460
2471
|
}
|
|
2461
2472
|
async onOpen(event) {
|
|
2473
|
+
this.isAuthenticated = false;
|
|
2462
2474
|
this.emit('open', { event });
|
|
2463
2475
|
if (this.isAuthenticationRequired) {
|
|
2464
2476
|
this.send(AuthenticationMessage, {
|
|
@@ -2591,13 +2603,19 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2591
2603
|
}
|
|
2592
2604
|
}
|
|
2593
2605
|
|
|
2606
|
+
class TiptapCollabProviderWebsocket extends HocuspocusProviderWebsocket {
|
|
2607
|
+
constructor(configuration) {
|
|
2608
|
+
super({ ...configuration, url: `wss://${configuration.appId}.collab.tiptap.cloud` });
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2594
2612
|
class TiptapCollabProvider extends HocuspocusProvider {
|
|
2595
2613
|
constructor(configuration) {
|
|
2596
2614
|
if (!configuration.websocketProvider) {
|
|
2597
|
-
configuration.websocketProvider = new
|
|
2615
|
+
configuration.websocketProvider = new TiptapCollabProviderWebsocket({ appId: configuration.appId });
|
|
2598
2616
|
}
|
|
2599
2617
|
if (!configuration.token) {
|
|
2600
|
-
configuration.token = 'notoken';
|
|
2618
|
+
configuration.token = 'notoken'; // need to send a token anyway (which will be ignored)
|
|
2601
2619
|
}
|
|
2602
2620
|
super(configuration);
|
|
2603
2621
|
}
|
|
@@ -2606,4 +2624,5 @@ class TiptapCollabProvider extends HocuspocusProvider {
|
|
|
2606
2624
|
exports.HocuspocusProvider = HocuspocusProvider;
|
|
2607
2625
|
exports.HocuspocusProviderWebsocket = HocuspocusProviderWebsocket;
|
|
2608
2626
|
exports.TiptapCollabProvider = TiptapCollabProvider;
|
|
2627
|
+
exports.TiptapCollabProviderWebsocket = TiptapCollabProviderWebsocket;
|
|
2609
2628
|
//# sourceMappingURL=hocuspocus-provider.cjs.map
|