cross-tab-worker-databus 0.20.70 → 0.20.71

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.20.71] - 2026-09-05
4
+
5
+ ### Added
6
+ - Added optional bulk replay persistence via `appendBatch`, with IndexedDB transaction coalescing for burst publications while preserving legacy adapters.
7
+
3
8
  ## [0.20.70] - 2026-09-05
4
9
 
5
10
  ### Added
@@ -2,7 +2,7 @@ import {
2
2
  CrossTabDataBus,
3
3
  parseDataBusPublication,
4
4
  selectWorkerBackend
5
- } from "./chunk-IKBJIREH.js";
5
+ } from "./chunk-D2SIT473.js";
6
6
 
7
7
  // src/centrifuge-session.ts
8
8
  import { Centrifuge } from "centrifuge";
@@ -1401,6 +1401,8 @@ var CrossTabDataBus = class {
1401
1401
  persistenceRetryMaxAttempts;
1402
1402
  persistenceRetryBackoffMs;
1403
1403
  persistenceRetryGeneration = 0;
1404
+ pendingReplayPersistence = [];
1405
+ replayPersistenceFlushScheduled = false;
1404
1406
  replayHydration;
1405
1407
  // Retention cleanup is coalesced so a burst of publications does not issue
1406
1408
  // one IndexedDB read/write transaction per message. The newest cutoff wins.
@@ -2035,12 +2037,28 @@ var CrossTabDataBus = class {
2035
2037
  }
2036
2038
  }
2037
2039
  if (this.replayPersistence) {
2038
- void this.withPersistenceRetry("append", () => this.replayPersistence.append(storedMessage)).catch((error) => this.reportPersistenceError(error));
2040
+ if (this.replayPersistence.appendBatch) {
2041
+ this.pendingReplayPersistence.push(storedMessage);
2042
+ this.scheduleReplayPersistenceFlush();
2043
+ } else {
2044
+ void this.withPersistenceRetry("append", () => this.replayPersistence.append(storedMessage)).catch((error) => this.reportPersistenceError(error));
2045
+ }
2039
2046
  if (this.replayRetentionMs !== void 0 && this.replayPersistence.clearBefore) {
2040
2047
  this.scheduleReplayRetentionCleanup(this.now() - this.replayRetentionMs);
2041
2048
  }
2042
2049
  }
2043
2050
  }
2051
+ scheduleReplayPersistenceFlush() {
2052
+ if (this.replayPersistenceFlushScheduled) return;
2053
+ this.replayPersistenceFlushScheduled = true;
2054
+ queueMicrotask(() => {
2055
+ this.replayPersistenceFlushScheduled = false;
2056
+ const batch = this.pendingReplayPersistence.splice(0);
2057
+ if (batch.length === 0 || !this.replayPersistence) return;
2058
+ const operation = this.replayPersistence.appendBatch ? () => this.replayPersistence.appendBatch(batch) : () => Promise.all(batch.map((message) => this.replayPersistence.append(message))).then(() => void 0);
2059
+ void this.withPersistenceRetry("append", operation).catch((error) => this.reportPersistenceError(error));
2060
+ });
2061
+ }
2044
2062
  async hydrateReplay() {
2045
2063
  if (!this.replayBuffers || !this.replayPersistence) {
2046
2064
  return;
@@ -2386,4 +2404,4 @@ export {
2386
2404
  parseDataBusPublication,
2387
2405
  selectWorkerBackend
2388
2406
  };
2389
- //# sourceMappingURL=chunk-IKBJIREH.js.map
2407
+ //# sourceMappingURL=chunk-D2SIT473.js.map