@abraca/dabra 2.78.0 → 2.80.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
|
@@ -1714,7 +1714,11 @@ var MessageReceiver = class {
|
|
|
1714
1714
|
if (emitSynced && syncMessageType === messageYjsSyncStep2) provider.synced = true;
|
|
1715
1715
|
}
|
|
1716
1716
|
applySyncStatusMessage(provider, applied) {
|
|
1717
|
-
if (applied)
|
|
1717
|
+
if (applied) {
|
|
1718
|
+
provider.decrementUnsyncedChanges();
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
provider.reportWriteRejected("server did not apply the update (permission or validation)", "validation");
|
|
1718
1722
|
}
|
|
1719
1723
|
applyAwarenessMessage(provider) {
|
|
1720
1724
|
if (!provider.awareness) return;
|
|
@@ -2457,6 +2461,7 @@ var AbracadabraBaseProvider = class AbracadabraBaseProvider extends EventEmitter
|
|
|
2457
2461
|
forceSyncInterval: false,
|
|
2458
2462
|
onAuthenticated: () => null,
|
|
2459
2463
|
onAuthenticationFailed: () => null,
|
|
2464
|
+
onWriteRejected: () => null,
|
|
2460
2465
|
onRateLimited: () => null,
|
|
2461
2466
|
onOpen: () => null,
|
|
2462
2467
|
onReconnected: () => null,
|
|
@@ -2496,6 +2501,8 @@ var AbracadabraBaseProvider = class AbracadabraBaseProvider extends EventEmitter
|
|
|
2496
2501
|
this.forwardDisconnect = (e) => this.emit("disconnect", e);
|
|
2497
2502
|
this.forwardDestroy = () => this.emit("destroy");
|
|
2498
2503
|
this.forwardRateLimited = () => this.emit("rateLimited");
|
|
2504
|
+
this.lastWriteRejection = null;
|
|
2505
|
+
this.writeRejectionCount = 0;
|
|
2499
2506
|
this.setConfiguration(configuration);
|
|
2500
2507
|
this.configuration.document = configuration.document ? configuration.document : new Y.Doc();
|
|
2501
2508
|
this.configuration.awareness = configuration.awareness !== void 0 ? configuration.awareness : new Awareness(this.document);
|
|
@@ -2513,6 +2520,7 @@ var AbracadabraBaseProvider = class AbracadabraBaseProvider extends EventEmitter
|
|
|
2513
2520
|
this.on("unsyncedChanges", this.configuration.onUnsyncedChanges);
|
|
2514
2521
|
this.on("authenticated", this.configuration.onAuthenticated);
|
|
2515
2522
|
this.on("authenticationFailed", this.configuration.onAuthenticationFailed);
|
|
2523
|
+
this.on("writeRejected", this.configuration.onWriteRejected);
|
|
2516
2524
|
this.on("rateLimited", this.configuration.onRateLimited);
|
|
2517
2525
|
this.awareness?.on("update", () => {
|
|
2518
2526
|
this.emit("awarenessUpdate", { states: awarenessStatesToArray(this.awareness.getStates()) });
|
|
@@ -2784,6 +2792,7 @@ var AbracadabraBaseProvider = class AbracadabraBaseProvider extends EventEmitter
|
|
|
2784
2792
|
this.configuration.websocketProvider.attach(this);
|
|
2785
2793
|
}
|
|
2786
2794
|
permissionDeniedHandler(reason) {
|
|
2795
|
+
if (this._hasEverAuthenticated && this.isSynced) this.reportWriteRejected(reason, "permission");
|
|
2787
2796
|
this.emit("authenticationFailed", { reason });
|
|
2788
2797
|
this.isAuthenticated = false;
|
|
2789
2798
|
if (this.manageSocket && !this._hasEverAuthenticated) try {
|
|
@@ -2792,6 +2801,23 @@ var AbracadabraBaseProvider = class AbracadabraBaseProvider extends EventEmitter
|
|
|
2792
2801
|
if (!this.manageSocket && !this.isSynced && this._isAttached && this._resubscribeAttempts < AbracadabraBaseProvider.MAX_RESUBSCRIBE_ATTEMPTS && AbracadabraBaseProvider.isTransientSubscribeDenial(reason)) this.scheduleResubscribe();
|
|
2793
2802
|
}
|
|
2794
2803
|
/**
|
|
2804
|
+
* Record and announce a server-refused local change.
|
|
2805
|
+
*
|
|
2806
|
+
* Called from both nack paths: the permission-denied auth frame and
|
|
2807
|
+
* `SyncStatus(applied=0)`. Deliberately does NOT touch the unsynced counter
|
|
2808
|
+
* — the update stays queued so a retry can land it once the cause is fixed.
|
|
2809
|
+
*/
|
|
2810
|
+
reportWriteRejected(reason, kind) {
|
|
2811
|
+
const data = {
|
|
2812
|
+
documentName: this.configuration.name,
|
|
2813
|
+
reason,
|
|
2814
|
+
kind
|
|
2815
|
+
};
|
|
2816
|
+
this.lastWriteRejection = data;
|
|
2817
|
+
this.writeRejectionCount += 1;
|
|
2818
|
+
this.emit("writeRejected", data);
|
|
2819
|
+
}
|
|
2820
|
+
/**
|
|
2795
2821
|
* Whether a permission-denied reason reflects a *transient* server condition
|
|
2796
2822
|
* a retry can clear (a freshly-created doc not yet visible on this replica, or
|
|
2797
2823
|
* a dropped subscribe-ordering) rather than a permanent authorization failure.
|