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.
@@ -1864,10 +1864,11 @@ var DataBusTraceReporter = class {
1864
1864
  }
1865
1865
  /** Synchronous snapshot of the current metrics window without resetting it.
1866
1866
  * Returns the same derived counters as a periodic `message_metrics` event,
1867
- * or null when metrics recording is inactive (disabled or events-only mode).
1868
- * The window keeps accumulating until the next interval flush. */
1867
+ * or null when metrics recording is inactive, which covers each of disabled,
1868
+ * stopped and events-only mode. The window keeps accumulating until the next
1869
+ * interval flush. */
1869
1870
  getMetrics() {
1870
- if (!this.metricsActive || this.stopped) return null;
1871
+ if (!this.metricsActive) return null;
1871
1872
  const timestamp = this.now();
1872
1873
  const samples = this.latencySamples;
1873
1874
  return {
@@ -1943,15 +1944,28 @@ var DataBusTraceReporter = class {
1943
1944
  }
1944
1945
  /** True when metrics recording is active: enabled, not stopped, and the mode
1945
1946
  * includes metrics. Extracted so the seven readers — `getMetrics`, the five
1946
- * `record*` methods and `flush` — share one guard instead of repeating it.
1947
- * The `!stopped` term is part of the contract, not a bonus: `event()` does not
1948
- * go through this getter and gates on `stopped` itself. */
1947
+ * `record*` methods and `flush` — share one guard instead of repeating it, which
1948
+ * leaves `stopped` read in exactly two places: this term, and `event()`, which
1949
+ * skips metrics entirely and so gates on the field itself.
1950
+ *
1951
+ * Do not add a `|| this.stopped` back at a call site. `getMetrics` and `flush`
1952
+ * each carried one, and the repetition is what made this term look untestable:
1953
+ * deleting the term left all 37 test files green, because a read of a field the
1954
+ * guard consulted one expression earlier can never be the decider. With both
1955
+ * repeats gone the same deletion dies twice in `tests/trace.test.ts` — to
1956
+ * "starts a fresh metrics window after pause and resume, and stop prevents later
1957
+ * flushes", and to "getMetrics returns null while metrics recording is inactive",
1958
+ * whose name promises all three inactive cases and which tested two of them until
1959
+ * this file stopped absorbing the third. What the term holds: `stop()` resets the
1960
+ * counters through `pause()` before any later call can reach them, so without it a
1961
+ * `record*` during a stopped window accumulates unreset and `start()` — which
1962
+ * clears `stopped` without resetting — hands it to the new session's window. */
1949
1963
  get metricsActive() {
1950
1964
  return this.enabled && !this.stopped && this.mode !== TRACE_MODE.EVENTS;
1951
1965
  }
1952
1966
  /** Emit the accumulated metrics snapshot if the interval is active. */
1953
1967
  flush() {
1954
- if (!this.metricsActive || this.stopped) return;
1968
+ if (!this.metricsActive) return;
1955
1969
  this.flushNow();
1956
1970
  }
1957
1971
  flushNow() {
@@ -2592,14 +2606,14 @@ var DedupManager = class {
2592
2606
  var SDK_VERSION = (
2593
2607
  // The `''` arm has zero counts in every coverage run and cannot be lit from a
2594
2608
  // test: `vitest.config.ts` defines the global for the whole suite, and so does
2595
- // each bundle `scripts/build.mjs` emits, so reaching this side needs a consumer
2596
- // that bundles `src/` without passing the define — which is also the only
2597
- // consumer this module is read by at source level. It cannot be deleted either,
2598
- // since the declaration's type is `string | undefined` and the export's is
2599
- // `string` (dropping the conditional is TS2322, measured). Recorded here so the
2600
- // leg reads as a shape the harness cannot reach rather than as a case nobody
2601
- // exercised.
2602
- true ? "0.21.21" : ""
2609
+ // each bundle `scripts/build.mjs` emits, so reaching this side needs a tool that
2610
+ // consumes `src/` without passing the define — and this repository has none. The
2611
+ // two source-level readers are named in the header above, and only one of them
2612
+ // evaluates this expression. It cannot be deleted either, since the
2613
+ // declaration's type is `string | undefined` and the export's is `string`
2614
+ // (dropping the conditional is TS2322, measured). Recorded here so the leg reads
2615
+ // as a shape the harness cannot reach rather than as a case nobody exercised.
2616
+ true ? "0.21.22" : ""
2603
2617
  );
2604
2618
 
2605
2619
  // src/core/data-bus.ts