@abraca/dabra 2.78.0 → 2.79.0
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/abracadabra-provider.cjs +27 -1
- package/dist/abracadabra-provider.cjs.map +1 -1
- package/dist/abracadabra-provider.esm.js +27 -1
- package/dist/abracadabra-provider.esm.js.map +1 -1
- package/dist/index.d.ts +57 -1
- package/package.json +2 -2
- package/src/AbracadabraBaseProvider.ts +47 -0
- package/src/MessageReceiver.ts +15 -0
- package/src/types.ts +38 -0
|
@@ -1744,7 +1744,11 @@ var MessageReceiver = class {
|
|
|
1744
1744
|
if (emitSynced && syncMessageType === messageYjsSyncStep2) provider.synced = true;
|
|
1745
1745
|
}
|
|
1746
1746
|
applySyncStatusMessage(provider, applied) {
|
|
1747
|
-
if (applied)
|
|
1747
|
+
if (applied) {
|
|
1748
|
+
provider.decrementUnsyncedChanges();
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
provider.reportWriteRejected("server did not apply the update (permission or validation)", "validation");
|
|
1748
1752
|
}
|
|
1749
1753
|
applyAwarenessMessage(provider) {
|
|
1750
1754
|
if (!provider.awareness) return;
|
|
@@ -2487,6 +2491,7 @@ var AbracadabraBaseProvider = class AbracadabraBaseProvider extends EventEmitter
|
|
|
2487
2491
|
forceSyncInterval: false,
|
|
2488
2492
|
onAuthenticated: () => null,
|
|
2489
2493
|
onAuthenticationFailed: () => null,
|
|
2494
|
+
onWriteRejected: () => null,
|
|
2490
2495
|
onRateLimited: () => null,
|
|
2491
2496
|
onOpen: () => null,
|
|
2492
2497
|
onReconnected: () => null,
|
|
@@ -2526,6 +2531,8 @@ var AbracadabraBaseProvider = class AbracadabraBaseProvider extends EventEmitter
|
|
|
2526
2531
|
this.forwardDisconnect = (e) => this.emit("disconnect", e);
|
|
2527
2532
|
this.forwardDestroy = () => this.emit("destroy");
|
|
2528
2533
|
this.forwardRateLimited = () => this.emit("rateLimited");
|
|
2534
|
+
this.lastWriteRejection = null;
|
|
2535
|
+
this.writeRejectionCount = 0;
|
|
2529
2536
|
this.setConfiguration(configuration);
|
|
2530
2537
|
this.configuration.document = configuration.document ? configuration.document : new yjs.Doc();
|
|
2531
2538
|
this.configuration.awareness = configuration.awareness !== void 0 ? configuration.awareness : new Awareness(this.document);
|
|
@@ -2543,6 +2550,7 @@ var AbracadabraBaseProvider = class AbracadabraBaseProvider extends EventEmitter
|
|
|
2543
2550
|
this.on("unsyncedChanges", this.configuration.onUnsyncedChanges);
|
|
2544
2551
|
this.on("authenticated", this.configuration.onAuthenticated);
|
|
2545
2552
|
this.on("authenticationFailed", this.configuration.onAuthenticationFailed);
|
|
2553
|
+
this.on("writeRejected", this.configuration.onWriteRejected);
|
|
2546
2554
|
this.on("rateLimited", this.configuration.onRateLimited);
|
|
2547
2555
|
this.awareness?.on("update", () => {
|
|
2548
2556
|
this.emit("awarenessUpdate", { states: awarenessStatesToArray(this.awareness.getStates()) });
|
|
@@ -2814,6 +2822,7 @@ var AbracadabraBaseProvider = class AbracadabraBaseProvider extends EventEmitter
|
|
|
2814
2822
|
this.configuration.websocketProvider.attach(this);
|
|
2815
2823
|
}
|
|
2816
2824
|
permissionDeniedHandler(reason) {
|
|
2825
|
+
if (this._hasEverAuthenticated && this.isSynced) this.reportWriteRejected(reason, "permission");
|
|
2817
2826
|
this.emit("authenticationFailed", { reason });
|
|
2818
2827
|
this.isAuthenticated = false;
|
|
2819
2828
|
if (this.manageSocket && !this._hasEverAuthenticated) try {
|
|
@@ -2822,6 +2831,23 @@ var AbracadabraBaseProvider = class AbracadabraBaseProvider extends EventEmitter
|
|
|
2822
2831
|
if (!this.manageSocket && !this.isSynced && this._isAttached && this._resubscribeAttempts < AbracadabraBaseProvider.MAX_RESUBSCRIBE_ATTEMPTS && AbracadabraBaseProvider.isTransientSubscribeDenial(reason)) this.scheduleResubscribe();
|
|
2823
2832
|
}
|
|
2824
2833
|
/**
|
|
2834
|
+
* Record and announce a server-refused local change.
|
|
2835
|
+
*
|
|
2836
|
+
* Called from both nack paths: the permission-denied auth frame and
|
|
2837
|
+
* `SyncStatus(applied=0)`. Deliberately does NOT touch the unsynced counter
|
|
2838
|
+
* — the update stays queued so a retry can land it once the cause is fixed.
|
|
2839
|
+
*/
|
|
2840
|
+
reportWriteRejected(reason, kind) {
|
|
2841
|
+
const data = {
|
|
2842
|
+
documentName: this.configuration.name,
|
|
2843
|
+
reason,
|
|
2844
|
+
kind
|
|
2845
|
+
};
|
|
2846
|
+
this.lastWriteRejection = data;
|
|
2847
|
+
this.writeRejectionCount += 1;
|
|
2848
|
+
this.emit("writeRejected", data);
|
|
2849
|
+
}
|
|
2850
|
+
/**
|
|
2825
2851
|
* Whether a permission-denied reason reflects a *transient* server condition
|
|
2826
2852
|
* a retry can clear (a freshly-created doc not yet visible on this replica, or
|
|
2827
2853
|
* a dropped subscribe-ordering) rather than a permanent authorization failure.
|