cross-tab-worker-databus 0.21.21 → 0.21.22

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.
@@ -1830,10 +1830,11 @@ var DataBusTraceReporter = class {
1830
1830
  }
1831
1831
  /** Synchronous snapshot of the current metrics window without resetting it.
1832
1832
  * Returns the same derived counters as a periodic `message_metrics` event,
1833
- * or null when metrics recording is inactive (disabled or events-only mode).
1834
- * The window keeps accumulating until the next interval flush. */
1833
+ * or null when metrics recording is inactive, which covers each of disabled,
1834
+ * stopped and events-only mode. The window keeps accumulating until the next
1835
+ * interval flush. */
1835
1836
  getMetrics() {
1836
- if (!this.metricsActive || this.stopped) return null;
1837
+ if (!this.metricsActive) return null;
1837
1838
  const timestamp = this.now();
1838
1839
  const samples = this.latencySamples;
1839
1840
  return {
@@ -1909,15 +1910,28 @@ var DataBusTraceReporter = class {
1909
1910
  }
1910
1911
  /** True when metrics recording is active: enabled, not stopped, and the mode
1911
1912
  * includes metrics. Extracted so the seven readers — `getMetrics`, the five
1912
- * `record*` methods and `flush` — share one guard instead of repeating it.
1913
- * The `!stopped` term is part of the contract, not a bonus: `event()` does not
1914
- * go through this getter and gates on `stopped` itself. */
1913
+ * `record*` methods and `flush` — share one guard instead of repeating it, which
1914
+ * leaves `stopped` read in exactly two places: this term, and `event()`, which
1915
+ * skips metrics entirely and so gates on the field itself.
1916
+ *
1917
+ * Do not add a `|| this.stopped` back at a call site. `getMetrics` and `flush`
1918
+ * each carried one, and the repetition is what made this term look untestable:
1919
+ * deleting the term left all 37 test files green, because a read of a field the
1920
+ * guard consulted one expression earlier can never be the decider. With both
1921
+ * repeats gone the same deletion dies twice in `tests/trace.test.ts` — to
1922
+ * "starts a fresh metrics window after pause and resume, and stop prevents later
1923
+ * flushes", and to "getMetrics returns null while metrics recording is inactive",
1924
+ * whose name promises all three inactive cases and which tested two of them until
1925
+ * this file stopped absorbing the third. What the term holds: `stop()` resets the
1926
+ * counters through `pause()` before any later call can reach them, so without it a
1927
+ * `record*` during a stopped window accumulates unreset and `start()` — which
1928
+ * clears `stopped` without resetting — hands it to the new session's window. */
1915
1929
  get metricsActive() {
1916
1930
  return this.enabled && !this.stopped && this.mode !== TRACE_MODE.EVENTS;
1917
1931
  }
1918
1932
  /** Emit the accumulated metrics snapshot if the interval is active. */
1919
1933
  flush() {
1920
- if (!this.metricsActive || this.stopped) return;
1934
+ if (!this.metricsActive) return;
1921
1935
  this.flushNow();
1922
1936
  }
1923
1937
  flushNow() {
@@ -2558,14 +2572,14 @@ var DedupManager = class {
2558
2572
  var SDK_VERSION = (
2559
2573
  // The `''` arm has zero counts in every coverage run and cannot be lit from a
2560
2574
  // test: `vitest.config.ts` defines the global for the whole suite, and so does
2561
- // each bundle `scripts/build.mjs` emits, so reaching this side needs a consumer
2562
- // that bundles `src/` without passing the define — which is also the only
2563
- // consumer this module is read by at source level. It cannot be deleted either,
2564
- // since the declaration's type is `string | undefined` and the export's is
2565
- // `string` (dropping the conditional is TS2322, measured). Recorded here so the
2566
- // leg reads as a shape the harness cannot reach rather than as a case nobody
2567
- // exercised.
2568
- true ? "0.21.21" : ""
2575
+ // each bundle `scripts/build.mjs` emits, so reaching this side needs a tool that
2576
+ // consumes `src/` without passing the define — and this repository has none. The
2577
+ // two source-level readers are named in the header above, and only one of them
2578
+ // evaluates this expression. It cannot be deleted either, since the
2579
+ // declaration's type is `string | undefined` and the export's is `string`
2580
+ // (dropping the conditional is TS2322, measured). Recorded here so the leg reads
2581
+ // as a shape the harness cannot reach rather than as a case nobody exercised.
2582
+ true ? "0.21.22" : ""
2569
2583
  );
2570
2584
 
2571
2585
  // src/core/data-bus.ts