cross-tab-worker-databus 0.20.92 → 0.20.93

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,6 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
- No unreleased changes yet.
3
+ ## [0.20.93] - 2026-09-19
4
+
5
+ ### Fixed
6
+ - The compatibility gate now rejects disabled public exports, removed worker default conditions, conditional exports replaced with untyped strings or null type targets, incompatible package-level `types`/`typesVersions` metadata, unavailable unconditional targets, destructive fallback-array changes, and removed nested or custom export conditions.
7
+ - Storage capability detection now requires a complete write-read-delete round trip, so write-only or unreadable adapters enter the existing local-mode fallback instead of starting coordination against an unusable registry.
8
+ - Cluster startup now degrades safely when channel construction throws, and tab identity remains stable within the document when session storage is unavailable or unreadable.
9
+ - Storage writer cleanup now cancels pending retries and resets backoff before a failing clear and after final cluster teardown flushes, preventing background writes from surviving page hide or stop.
10
+
11
+ ### Changed
12
+ - Refreshed patch-level development dependencies used by the test and lint toolchain.
4
13
 
5
14
  ## [0.20.92] - 2026-09-18
6
15
 
@@ -5,7 +5,7 @@ import {
5
5
  parseDataBusPublication,
6
6
  publicationMetadata,
7
7
  selectWorkerBackend
8
- } from "./chunk-QB74C4EH.js";
8
+ } from "./chunk-OXEPZGXR.js";
9
9
  import {
10
10
  CENTRIFUGE_INPUT_TYPE,
11
11
  CENTRIFUGE_OUTPUT_TYPE,
@@ -85,6 +85,7 @@ function createStorageEventChannel(options) {
85
85
  };
86
86
  }
87
87
  var tabIdentityInitialized = false;
88
+ var cachedTabId = null;
88
89
  function createBrowserEnvironment(options) {
89
90
  const channelFallback = options?.channelFallback ?? CHANNEL_FALLBACK.NONE;
90
91
  return {
@@ -130,8 +131,9 @@ function canUseStorage(storage, probeKey) {
130
131
  if (!storage) return false;
131
132
  try {
132
133
  storage.setItem(probeKey, "1");
134
+ const readable = storage.getItem(probeKey) === "1";
133
135
  storage.removeItem(probeKey);
134
- return true;
136
+ return readable;
135
137
  } catch {
136
138
  return false;
137
139
  }
@@ -143,14 +145,21 @@ function getOrCreateTabId(environment, key = TAB_ID_STORAGE_KEY) {
143
145
  const hasOpener = typeof window !== "undefined" && Boolean(window.opener);
144
146
  if (existing && (!hasOpener || tabIdentityInitialized)) {
145
147
  tabIdentityInitialized = true;
148
+ cachedTabId = existing;
146
149
  return existing;
147
150
  }
151
+ if (tabIdentityInitialized && cachedTabId) return cachedTabId;
148
152
  const created = `tab-${environment.randomId()}`;
149
153
  storage?.setItem(key, created);
150
154
  tabIdentityInitialized = true;
155
+ cachedTabId = created;
151
156
  return created;
152
157
  } catch {
153
- return `tab-${environment.randomId()}`;
158
+ if (cachedTabId) return cachedTabId;
159
+ const created = `tab-${environment.randomId()}`;
160
+ tabIdentityInitialized = true;
161
+ cachedTabId = created;
162
+ return created;
154
163
  }
155
164
  }
156
165
 
@@ -428,7 +437,17 @@ var BatchingStorageWriter = class {
428
437
  clear() {
429
438
  this.pending.clear();
430
439
  this.flushScheduled = false;
440
+ this.cancelRetry();
441
+ this.retryCount.clear();
442
+ this.retryDelayMs = INITIAL_RETRY_DELAY_MS;
431
443
  this.storage.clear();
444
+ }
445
+ /** Drop queued mutations and cancel retry state without clearing storage.
446
+ * Used when the owning runtime is torn down: final best-effort writes have
447
+ * already been flushed, and failed writes must not keep timers alive. */
448
+ discardPending() {
449
+ this.pending.clear();
450
+ this.flushScheduled = false;
432
451
  this.cancelRetry();
433
452
  this.retryCount.clear();
434
453
  this.retryDelayMs = INITIAL_RETRY_DELAY_MS;
@@ -688,7 +707,15 @@ var WorkerClusterRuntime = class {
688
707
  activate() {
689
708
  if (this.started) return;
690
709
  this.started = true;
691
- this.channel = this.storage ? this.environment.createChannel(this.channelName) : null;
710
+ if (this.storage) {
711
+ try {
712
+ this.channel = this.environment.createChannel(this.channelName);
713
+ } catch {
714
+ this.channel = null;
715
+ }
716
+ } else {
717
+ this.channel = null;
718
+ }
692
719
  if (!this.channel) this.storage = null;
693
720
  this.channel?.addEventListener("message", this.handleMessage);
694
721
  const now = this.environment.now();
@@ -734,6 +761,7 @@ var WorkerClusterRuntime = class {
734
761
  this.removeStorage(this.workerStorageKey(this.workerId));
735
762
  this.flushStorage();
736
763
  this.notifyRegistry();
764
+ if (this.storage instanceof BatchingStorageWriter) this.storage.discardPending();
737
765
  const channel = this.channel;
738
766
  this.channel = null;
739
767
  this.handlers.onSuspend?.();
@@ -2308,7 +2336,7 @@ var DedupManager = class {
2308
2336
  };
2309
2337
 
2310
2338
  // src/core/version.ts
2311
- var SDK_VERSION = true ? "0.20.92" : "";
2339
+ var SDK_VERSION = true ? "0.20.93" : "";
2312
2340
 
2313
2341
  // src/core/data-bus.ts
2314
2342
  var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
@@ -3500,4 +3528,4 @@ export {
3500
3528
  parseDataBusPublication,
3501
3529
  selectWorkerBackend
3502
3530
  };
3503
- //# sourceMappingURL=chunk-QB74C4EH.js.map
3531
+ //# sourceMappingURL=chunk-OXEPZGXR.js.map