@loro-dev/streams-crdt 0.12.0 → 0.12.1
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/flock.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as InMemoryRemoteCursorStore, c as EphemeralStreamCrdt, i as StreamsCrdt, l as PayloadProtectionError, n as isValidBucketId, o as IndexedDbRemoteCursorStore, r as isValidRillId, s as createInitialRemoteCursor, t as createStreamUrl } from "./stream-id-
|
|
1
|
+
import { a as InMemoryRemoteCursorStore, c as EphemeralStreamCrdt, i as StreamsCrdt, l as PayloadProtectionError, n as isValidBucketId, o as IndexedDbRemoteCursorStore, r as isValidRillId, s as createInitialRemoteCursor, t as createStreamUrl } from "./stream-id-D-UirMkk.js";
|
|
2
2
|
import { Flock } from "@loro-dev/flock-wasm";
|
|
3
3
|
//#region src/flock.ts
|
|
4
4
|
function isAfter(entry, current) {
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as InMemoryRemoteCursorStore, c as EphemeralStreamCrdt, i as StreamsCrdt, l as PayloadProtectionError, n as isValidBucketId, o as IndexedDbRemoteCursorStore, r as isValidRillId, s as createInitialRemoteCursor, t as createStreamUrl } from "./stream-id-
|
|
1
|
+
import { a as InMemoryRemoteCursorStore, c as EphemeralStreamCrdt, i as StreamsCrdt, l as PayloadProtectionError, n as isValidBucketId, o as IndexedDbRemoteCursorStore, r as isValidRillId, s as createInitialRemoteCursor, t as createStreamUrl } from "./stream-id-D-UirMkk.js";
|
|
2
2
|
export { PayloadProtectionError as E2eeError, PayloadProtectionError, EphemeralStreamCrdt, InMemoryRemoteCursorStore, IndexedDbRemoteCursorStore, StreamsCrdt, createInitialRemoteCursor, createStreamUrl, isValidBucketId, isValidRillId };
|
package/dist/loro.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as InMemoryRemoteCursorStore, c as EphemeralStreamCrdt, i as StreamsCrdt, l as PayloadProtectionError, n as isValidBucketId, o as IndexedDbRemoteCursorStore, r as isValidRillId, s as createInitialRemoteCursor, t as createStreamUrl } from "./stream-id-
|
|
1
|
+
import { a as InMemoryRemoteCursorStore, c as EphemeralStreamCrdt, i as StreamsCrdt, l as PayloadProtectionError, n as isValidBucketId, o as IndexedDbRemoteCursorStore, r as isValidRillId, s as createInitialRemoteCursor, t as createStreamUrl } from "./stream-id-D-UirMkk.js";
|
|
2
2
|
import { LoroDoc, VersionVector, decodeImportBlobMeta } from "loro-crdt";
|
|
3
3
|
//#region src/loro.ts
|
|
4
4
|
function batchImportUpdates(doc, updates) {
|
|
@@ -141,6 +141,14 @@ const DEFAULT_RECONNECT_CONFIG = {
|
|
|
141
141
|
liveInactivityTimeoutMs: 45e3
|
|
142
142
|
};
|
|
143
143
|
/**
|
|
144
|
+
* Minimum time a live SSE must stay open before it counts as a "successful
|
|
145
|
+
* session". A read that stayed open at least this long before erroring is
|
|
146
|
+
* treated as a fresh disconnect (e.g. a routine server-side stream recycle)
|
|
147
|
+
* rather than a failing-to-connect retry, so its reconnect does not consume the
|
|
148
|
+
* backoff budget. Shared by the durable and ephemeral read loops.
|
|
149
|
+
*/
|
|
150
|
+
const MIN_SUCCESSFUL_SSE_DURATION_MS = 5e3;
|
|
151
|
+
/**
|
|
144
152
|
* Apply jitter of +/- fraction to a base delay.
|
|
145
153
|
* E.g. applyJitter(1000, 0.2) returns a value in [800, 1200].
|
|
146
154
|
*/
|
|
@@ -1680,9 +1688,11 @@ var EphemeralStreamCrdt = class {
|
|
|
1680
1688
|
while (!state.closed) {
|
|
1681
1689
|
state.requestController ??= new AbortController();
|
|
1682
1690
|
const capturedController = state.requestController;
|
|
1691
|
+
let sseOpenedAtMs = 0;
|
|
1683
1692
|
try {
|
|
1684
1693
|
const result = await this.client.readEphemeralSse(async (bootstrap) => {
|
|
1685
1694
|
if (bootstrap.byteLength > 0) await this.adaptor.applyRemoteUpdates([bootstrap]);
|
|
1695
|
+
sseOpenedAtMs = Date.now();
|
|
1686
1696
|
this.setReadStatus(state, "ok");
|
|
1687
1697
|
this.resolveFirstOpen(state);
|
|
1688
1698
|
}, async (update) => {
|
|
@@ -1715,6 +1725,7 @@ var EphemeralStreamCrdt = class {
|
|
|
1715
1725
|
return;
|
|
1716
1726
|
}
|
|
1717
1727
|
this.setReadStatus(state, "reconnecting");
|
|
1728
|
+
if (sseOpenedAtMs > 0 && Date.now() - sseOpenedAtMs >= 5e3) state.retryAttempt = 0;
|
|
1718
1729
|
if (state.retryAttempt >= this.reconnectConfig.maxAttempts) {
|
|
1719
1730
|
this.logError("ephemeral live reconnect exhausted", error, {
|
|
1720
1731
|
streamUrl: this.streamUrl,
|
|
@@ -2272,13 +2283,12 @@ async function disposeJoinState(state, options) {
|
|
|
2272
2283
|
//#endregion
|
|
2273
2284
|
//#region src/transport-runtime.ts
|
|
2274
2285
|
const MIN_RECONNECT_DELAY_MS = 1e3;
|
|
2275
|
-
const MIN_SUCCESSFUL_SSE_DURATION_MS = 5e3;
|
|
2276
2286
|
function reconnectDelayWithFloor(attempt, config) {
|
|
2277
2287
|
return Math.max(computeRetryDelay(attempt, config), MIN_RECONNECT_DELAY_MS);
|
|
2278
2288
|
}
|
|
2279
2289
|
function fastSseCloseDelay(startedAtMs) {
|
|
2280
2290
|
const elapsedMs = Math.max(0, Date.now() - startedAtMs);
|
|
2281
|
-
if (elapsedMs >=
|
|
2291
|
+
if (elapsedMs >= 5e3) return 0;
|
|
2282
2292
|
return Math.max(MIN_RECONNECT_DELAY_MS, MIN_SUCCESSFUL_SSE_DURATION_MS - elapsedMs);
|
|
2283
2293
|
}
|
|
2284
2294
|
/**
|
|
@@ -3265,6 +3275,7 @@ var StreamsCrdt = class StreamsCrdt {
|
|
|
3265
3275
|
const capturedController = state.requestController;
|
|
3266
3276
|
let inactivityTimer = null;
|
|
3267
3277
|
let inactivityTriggered = false;
|
|
3278
|
+
let sseOpenedAtMs = 0;
|
|
3268
3279
|
const clearInactivity = () => {
|
|
3269
3280
|
if (inactivityTimer != null) {
|
|
3270
3281
|
clearTimeout(inactivityTimer);
|
|
@@ -3351,6 +3362,7 @@ var StreamsCrdt = class StreamsCrdt {
|
|
|
3351
3362
|
});
|
|
3352
3363
|
}, () => {
|
|
3353
3364
|
resetInactivity();
|
|
3365
|
+
sseOpenedAtMs = Date.now();
|
|
3354
3366
|
this.setReadSubStatus(state, "ok");
|
|
3355
3367
|
}, capturedController?.signal, resetInactivity);
|
|
3356
3368
|
clearInactivity();
|
|
@@ -3451,6 +3463,7 @@ var StreamsCrdt = class StreamsCrdt {
|
|
|
3451
3463
|
return;
|
|
3452
3464
|
}
|
|
3453
3465
|
this.setReadSubStatus(state, "reconnecting");
|
|
3466
|
+
if (sseOpenedAtMs > 0 && Date.now() - sseOpenedAtMs >= 5e3) state.retryAttempt = 0;
|
|
3454
3467
|
const maxAttempts = this.reconnectConfig.maxAttempts;
|
|
3455
3468
|
if (state.retryAttempt >= maxAttempts) {
|
|
3456
3469
|
this.logError("live read reconnect exhausted", error, {
|
|
@@ -3679,4 +3692,4 @@ function createStreamUrl(input) {
|
|
|
3679
3692
|
//#endregion
|
|
3680
3693
|
export { InMemoryRemoteCursorStore as a, EphemeralStreamCrdt as c, StreamsCrdt as i, PayloadProtectionError as l, isValidBucketId as n, IndexedDbRemoteCursorStore as o, isValidRillId as r, createInitialRemoteCursor as s, createStreamUrl as t };
|
|
3681
3694
|
|
|
3682
|
-
//# sourceMappingURL=stream-id-
|
|
3695
|
+
//# sourceMappingURL=stream-id-D-UirMkk.js.map
|