@blockcast/mmt-container 0.1.0-main.c71423b8a4e4 → 0.1.0-main.ce3c8aeb7f68

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.
Files changed (148) hide show
  1. package/dist/align.d.ts +6 -2
  2. package/dist/align.d.ts.map +1 -1
  3. package/dist/align.js.map +2 -2
  4. package/dist/audio-ring-buffer.js +23 -36
  5. package/dist/audio-ring-buffer.js.map +1 -1
  6. package/dist/browser-runtime.js +6865 -6485
  7. package/dist/browser-runtime.js.map +4 -4
  8. package/dist/carp-catalog.d.ts +3 -1
  9. package/dist/carp-catalog.d.ts.map +1 -1
  10. package/dist/carp-catalog.js +21 -2
  11. package/dist/carp-catalog.js.map +4 -4
  12. package/dist/catalog-fec-params.js +10 -0
  13. package/dist/catalog-fec-params.js.map +4 -4
  14. package/dist/cmaf-block-assembler.d.ts +42 -0
  15. package/dist/cmaf-block-assembler.d.ts.map +1 -1
  16. package/dist/cmaf-block-assembler.js +542 -535
  17. package/dist/cmaf-block-assembler.js.map +2 -2
  18. package/dist/cmaf-group-batcher.js +27 -46
  19. package/dist/cmaf-group-batcher.js.map +2 -2
  20. package/dist/cmcd-producer.js +45 -66
  21. package/dist/cmcd-producer.js.map +1 -1
  22. package/dist/fec-manager.d.ts +13 -1
  23. package/dist/fec-manager.d.ts.map +1 -1
  24. package/dist/fec-manager.js +1151 -871
  25. package/dist/fec-manager.js.map +2 -2
  26. package/dist/fec-starvation-detector.js +25 -40
  27. package/dist/fec-starvation-detector.js.map +1 -1
  28. package/dist/fec-worker-setup.js +242 -225
  29. package/dist/fec-worker-setup.js.map +3 -3
  30. package/dist/index.d.ts +3 -3
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js.map +2 -2
  33. package/dist/iso-bmff-timing.js +63 -88
  34. package/dist/iso-bmff-timing.js.map +1 -1
  35. package/dist/loc.js +7 -4
  36. package/dist/loc.js.map +1 -1
  37. package/dist/manifest-auth-plan.js +292 -311
  38. package/dist/manifest-auth-plan.js.map +1 -1
  39. package/dist/media-router.d.ts +0 -99
  40. package/dist/media-router.d.ts.map +1 -1
  41. package/dist/media-router.js +270 -504
  42. package/dist/media-router.js.map +3 -3
  43. package/dist/mfu-reassembler.js +597 -607
  44. package/dist/mfu-reassembler.js.map +3 -3
  45. package/dist/mmtp-container-parser.d.ts +37 -0
  46. package/dist/mmtp-container-parser.d.ts.map +1 -1
  47. package/dist/mmtp-container-parser.js +1531 -1522
  48. package/dist/mmtp-container-parser.js.map +3 -3
  49. package/dist/mmtp-container-parser.no-modules.js +179 -102
  50. package/dist/mmtp-container-parser.no-modules.js.map +3 -3
  51. package/dist/mmtp-decode-pipeline.js +1641 -1651
  52. package/dist/mmtp-decode-pipeline.js.map +3 -3
  53. package/dist/mmtp-router.d.ts +34 -0
  54. package/dist/mmtp-router.d.ts.map +1 -1
  55. package/dist/mmtp-router.js +3676 -3390
  56. package/dist/mmtp-router.js.map +3 -3
  57. package/dist/mmtp-to-cmaf.d.ts +7 -1
  58. package/dist/mmtp-to-cmaf.d.ts.map +1 -1
  59. package/dist/mmtp-to-cmaf.js +109 -134
  60. package/dist/mmtp-to-cmaf.js.map +2 -2
  61. package/dist/multicast-input.d.ts +7 -35
  62. package/dist/multicast-input.d.ts.map +1 -1
  63. package/dist/multicast-input.js +21 -2
  64. package/dist/multicast-input.js.map +4 -4
  65. package/dist/multicast-manager.d.ts +10 -1
  66. package/dist/multicast-manager.d.ts.map +1 -1
  67. package/dist/multicast-manager.js +5584 -4961
  68. package/dist/multicast-manager.js.map +4 -4
  69. package/dist/multicast-transport.d.ts +7 -0
  70. package/dist/multicast-transport.d.ts.map +1 -1
  71. package/dist/multicast-transport.js +369 -421
  72. package/dist/multicast-transport.js.map +4 -4
  73. package/dist/multicast-unwrap.js +53 -30
  74. package/dist/multicast-unwrap.js.map +2 -2
  75. package/dist/no-modules.js +2096 -2097
  76. package/dist/no-modules.js.map +3 -3
  77. package/dist/sample-combiner.js +118 -139
  78. package/dist/sample-combiner.js.map +1 -1
  79. package/dist/signaling.js.map +2 -2
  80. package/dist/source-auth.js +353 -382
  81. package/dist/source-auth.js.map +1 -1
  82. package/dist/switching-set-alignment.js +14 -29
  83. package/dist/switching-set-alignment.js.map +1 -1
  84. package/dist/timestamp-codec.js +17 -11
  85. package/dist/timestamp-codec.js.map +2 -2
  86. package/dist/track-pipeline-setup.js +105 -125
  87. package/dist/track-pipeline-setup.js.map +1 -1
  88. package/dist/track-pipeline.js +107 -127
  89. package/dist/track-pipeline.js.map +1 -1
  90. package/dist/track-session.d.ts +16 -0
  91. package/dist/track-session.d.ts.map +1 -1
  92. package/dist/track-session.js +230 -243
  93. package/dist/track-session.js.map +2 -2
  94. package/dist/transport-pool.js +24 -38
  95. package/dist/transport-pool.js.map +1 -1
  96. package/dist/wasm-mfu-reassembler.d.ts +6 -1
  97. package/dist/wasm-mfu-reassembler.d.ts.map +1 -1
  98. package/dist/wasm-mfu-reassembler.js +127 -144
  99. package/dist/wasm-mfu-reassembler.js.map +2 -2
  100. package/dist/wasm-mmtp-container-parser.js +1659 -1650
  101. package/dist/wasm-mmtp-container-parser.js.map +3 -3
  102. package/node_modules/@blockcast/fec-worker/README.md +5 -1
  103. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +8 -2
  104. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +1 -1
  105. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +89 -16
  106. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +1 -1
  107. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +48 -3
  108. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +1 -1
  109. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +55 -8
  110. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +2 -2
  111. package/node_modules/@blockcast/fec-worker/dist/index.d.ts +1 -1
  112. package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +1 -1
  113. package/node_modules/@blockcast/fec-worker/dist/index.js.map +1 -1
  114. package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +97 -17
  115. package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +46 -2
  116. package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +78 -10
  117. package/node_modules/@blockcast/fec-worker/src/index.ts +2 -0
  118. package/node_modules/@blockcast/mmt-base/README.md +1 -0
  119. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
  120. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
  121. package/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
  122. package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
  123. package/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
  124. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +1 -0
  125. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +52 -0
  126. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +1 -1
  127. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +142 -37
  128. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +1 -1
  129. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +158 -37
  130. package/package.json +7 -6
  131. package/schemas/catalog.schema.json +1 -1
  132. package/src/align.ts +6 -2
  133. package/src/carp-catalog.ts +13 -3
  134. package/src/cmaf-block-assembler.ts +90 -81
  135. package/src/fec-manager.ts +530 -146
  136. package/src/index.ts +2 -2
  137. package/src/media-router.ts +0 -397
  138. package/src/mmtp-container-parser.ts +97 -21
  139. package/src/mmtp-router.ts +302 -125
  140. package/src/mmtp-to-cmaf.ts +21 -7
  141. package/src/multicast-input.ts +23 -3
  142. package/src/multicast-manager.ts +83 -11
  143. package/src/multicast-transport.ts +56 -17
  144. package/src/track-session.ts +16 -0
  145. package/src/wasm-mfu-reassembler.ts +40 -24
  146. package/test-vectors/catalog/README.md +2 -0
  147. package/test-vectors/catalog/negative/multicast-packet-id-signaling.json +26 -0
  148. package/test-vectors/catalog-validation.json +11 -0
@@ -1,20 +1,3 @@
1
- var __typeError = (msg) => {
2
- throw TypeError(msg);
3
- };
4
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
- var __privateWrapper = (obj, member, setter, getter) => ({
10
- set _(value) {
11
- __privateSet(obj, member, value, setter);
12
- },
13
- get _() {
14
- return __privateGet(obj, member, getter);
15
- }
16
- });
17
-
18
1
  // ../mmt-alta-parse/dist/index.js
19
2
  var MPU_HEADER_SIZE = 8;
20
3
  var MPU_LENGTH_FIELD_SIZE = 2;
@@ -1900,52 +1883,61 @@ function asNumber(value) {
1900
1883
  function timestampU32(timestamp) {
1901
1884
  return Number(BigInt.asUintN(32, timestamp));
1902
1885
  }
1903
- var _bindings, _core, _now, _timeoutMs, _cleanupTimer, _nextStreamIdentity, _streamIdentityByKey, _streamNameByIdentity, _coreTotalFragments, _rejectedBeforeCore, _rejectedFragments, _WasmMfuReassembler_instances, refreshStats_fn, streamIdentityFor_fn, asReassemblyError_fn, scheduleCleanup_fn, clearCleanupTimer_fn;
1904
1886
  var WasmMfuReassembler = class {
1887
+ #bindings;
1888
+ #core;
1889
+ #now;
1890
+ #timeoutMs;
1891
+ #cleanupTimer = null;
1892
+ #nextStreamIdentity = 1;
1893
+ #streamIdentityByKey = /* @__PURE__ */ new Map();
1894
+ #streamNameByIdentity = /* @__PURE__ */ new Map();
1895
+ // Every fragment handed to the core, including ones it rejected. This is
1896
+ // what `coreTotal + rejectedBeforeCore` computed with a core stats() round
1897
+ // trip before and after every fragment (BLO-36599).
1898
+ #offeredFragments = 0;
1899
+ #rejectedFragments = 0;
1900
+ #stats = {
1901
+ totalFragments: 0,
1902
+ reassembledMFUs: 0,
1903
+ rejectedFragments: 0,
1904
+ timedOutMFUs: 0,
1905
+ evictedMemoryLimit: 0,
1906
+ outOfOrderFragments: 0
1907
+ };
1905
1908
  constructor(options) {
1906
- __privateAdd(this, _WasmMfuReassembler_instances);
1907
- __privateAdd(this, _bindings);
1908
- __privateAdd(this, _core);
1909
- __privateAdd(this, _now);
1910
- __privateAdd(this, _timeoutMs);
1911
- __privateAdd(this, _cleanupTimer, null);
1912
- __privateAdd(this, _nextStreamIdentity, 1);
1913
- __privateAdd(this, _streamIdentityByKey, /* @__PURE__ */ new Map());
1914
- __privateAdd(this, _streamNameByIdentity, /* @__PURE__ */ new Map());
1915
- __privateAdd(this, _coreTotalFragments, 0);
1916
- __privateAdd(this, _rejectedBeforeCore, 0);
1917
- __privateAdd(this, _rejectedFragments, 0);
1918
- this.stats = {
1919
- totalFragments: 0,
1920
- reassembledMFUs: 0,
1921
- rejectedFragments: 0,
1922
- timedOutMFUs: 0,
1923
- evictedMemoryLimit: 0,
1924
- outOfOrderFragments: 0
1925
- };
1926
1909
  const maxBuffered = options.maxBuffered ?? 100;
1927
1910
  if (!Number.isInteger(maxBuffered) || maxBuffered <= 0) {
1928
1911
  throw new Error("[WasmMfuReassembler] maxBuffered must be a positive integer");
1929
1912
  }
1930
- __privateSet(this, _bindings, options.bindings);
1931
- __privateSet(this, _timeoutMs, options.timeoutMs);
1932
- __privateSet(this, _now, options.now ?? (() => globalThis.performance?.now() ?? Date.now()));
1933
- __privateSet(this, _core, options.timeoutMs === null ? options.bindings.MmtReassembler.clock_free(maxBuffered) : new options.bindings.MmtReassembler(options.timeoutMs, maxBuffered));
1913
+ this.#bindings = options.bindings;
1914
+ this.#timeoutMs = options.timeoutMs;
1915
+ this.#now = options.now ?? (() => globalThis.performance?.now() ?? Date.now());
1916
+ this.#core = options.timeoutMs === null ? options.bindings.MmtReassembler.clock_free(maxBuffered) : new options.bindings.MmtReassembler(options.timeoutMs, maxBuffered);
1934
1917
  }
1935
1918
  get timeoutMs() {
1936
- return __privateGet(this, _timeoutMs);
1919
+ return this.#timeoutMs;
1920
+ }
1921
+ /**
1922
+ * Host-observable reassembly statistics, read from the core when asked.
1923
+ * Reading them is a wasm crossing plus six counter getters, so neither
1924
+ * addFragment nor the router's per-packet path refreshes them (BLO-36599).
1925
+ */
1926
+ get stats() {
1927
+ this.#refreshStats();
1928
+ return this.#stats;
1937
1929
  }
1938
1930
  set timeoutMs(timeoutMs) {
1939
1931
  if (timeoutMs !== null && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) {
1940
1932
  throw new Error("[WasmMfuReassembler] timeoutMs must be a finite number > 0");
1941
1933
  }
1942
- __privateSet(this, _timeoutMs, timeoutMs);
1943
- if (timeoutMs === null) __privateGet(this, _core).set_clock_free();
1944
- else __privateGet(this, _core).set_timeout(Math.ceil(timeoutMs));
1945
- __privateMethod(this, _WasmMfuReassembler_instances, scheduleCleanup_fn).call(this);
1934
+ this.#timeoutMs = timeoutMs;
1935
+ if (timeoutMs === null) this.#core.set_clock_free();
1936
+ else this.#core.set_timeout(Math.ceil(timeoutMs));
1937
+ this.#scheduleCleanup();
1946
1938
  }
1947
1939
  addFragment(fragment) {
1948
- const wasmFragment = new (__privateGet(this, _bindings)).MfuFragmentJs(
1940
+ const wasmFragment = new this.#bindings.MfuFragmentJs(
1949
1941
  fragment.mpuSequenceNumber,
1950
1942
  fragment.fragmentationIndicator,
1951
1943
  fragment.fragmentCounter,
@@ -1971,30 +1963,26 @@ var WasmMfuReassembler = class {
1971
1963
  if (fragment.source !== void 0) {
1972
1964
  wasmFragment.set_attribution(fragment.source === "multicast" ? 1 : 2);
1973
1965
  }
1974
- const streamIdentity = __privateMethod(this, _WasmMfuReassembler_instances, streamIdentityFor_fn).call(this, fragment);
1966
+ const streamIdentity = this.#streamIdentityFor(fragment);
1975
1967
  if (streamIdentity !== void 0) {
1976
1968
  wasmFragment.set_stream_identity(streamIdentity);
1977
1969
  }
1978
1970
  let output;
1979
- const coreTotalBefore = __privateGet(this, _coreTotalFragments);
1980
1971
  try {
1981
- output = __privateGet(this, _core).add_fragment(__privateGet(this, _now).call(this), wasmFragment);
1972
+ output = this.#core.add_fragment(this.#now(), wasmFragment);
1982
1973
  } catch (error) {
1983
- const rejection = __privateMethod(this, _WasmMfuReassembler_instances, asReassemblyError_fn).call(this, error);
1974
+ const rejection = this.#asReassemblyError(error);
1984
1975
  if (rejection === null) throw error;
1985
- __privateMethod(this, _WasmMfuReassembler_instances, refreshStats_fn).call(this);
1986
- if (__privateGet(this, _coreTotalFragments) === coreTotalBefore) __privateWrapper(this, _rejectedBeforeCore)._++;
1987
- __privateWrapper(this, _rejectedFragments)._++;
1988
- this.stats.totalFragments = __privateGet(this, _coreTotalFragments) + __privateGet(this, _rejectedBeforeCore);
1989
- this.stats.rejectedFragments = __privateGet(this, _rejectedFragments);
1990
- __privateMethod(this, _WasmMfuReassembler_instances, scheduleCleanup_fn).call(this);
1976
+ this.#offeredFragments++;
1977
+ this.#rejectedFragments++;
1978
+ this.#ensureCleanupArmed();
1991
1979
  throw rejection;
1992
1980
  }
1993
- __privateMethod(this, _WasmMfuReassembler_instances, refreshStats_fn).call(this);
1994
- __privateMethod(this, _WasmMfuReassembler_instances, scheduleCleanup_fn).call(this);
1981
+ this.#offeredFragments++;
1982
+ this.#ensureCleanupArmed();
1995
1983
  if (!output) return null;
1996
1984
  try {
1997
- const catalogTrackName = output.stream_identity === void 0 ? void 0 : __privateGet(this, _streamNameByIdentity).get(output.stream_identity);
1985
+ const catalogTrackName = output.stream_identity === void 0 ? void 0 : this.#streamNameByIdentity.get(output.stream_identity);
1998
1986
  const packetSequenceNumbers = output.packet_sequence_numbers === void 0 ? void 0 : Array.from(output.packet_sequence_numbers);
1999
1987
  const repairedPacketSequenceNumbers = output.repaired_packet_sequence_numbers === void 0 ? void 0 : Array.from(output.repaired_packet_sequence_numbers);
2000
1988
  return {
@@ -2024,105 +2012,100 @@ var WasmMfuReassembler = class {
2024
2012
  }
2025
2013
  }
2026
2014
  flush() {
2027
- __privateMethod(this, _WasmMfuReassembler_instances, clearCleanupTimer_fn).call(this);
2028
- __privateGet(this, _core).flush();
2015
+ this.#clearCleanupTimer();
2016
+ this.#core.flush();
2029
2017
  }
2030
2018
  resetStream(catalogTrackName) {
2031
- const streamIdentity = __privateGet(this, _streamIdentityByKey).get(`catalog:${catalogTrackName}`);
2019
+ const streamIdentity = this.#streamIdentityByKey.get(`catalog:${catalogTrackName}`);
2032
2020
  if (streamIdentity === void 0) return;
2033
- __privateMethod(this, _WasmMfuReassembler_instances, clearCleanupTimer_fn).call(this);
2034
- __privateGet(this, _core).reset_stream(streamIdentity);
2035
- __privateMethod(this, _WasmMfuReassembler_instances, refreshStats_fn).call(this);
2036
- __privateMethod(this, _WasmMfuReassembler_instances, scheduleCleanup_fn).call(this);
2021
+ this.#clearCleanupTimer();
2022
+ this.#core.reset_stream(streamIdentity);
2023
+ this.#scheduleCleanup();
2037
2024
  }
2038
2025
  reset() {
2039
- __privateMethod(this, _WasmMfuReassembler_instances, clearCleanupTimer_fn).call(this);
2040
- __privateGet(this, _core).reset();
2041
- __privateSet(this, _nextStreamIdentity, 1);
2042
- __privateGet(this, _streamIdentityByKey).clear();
2043
- __privateGet(this, _streamNameByIdentity).clear();
2044
- __privateSet(this, _coreTotalFragments, 0);
2045
- __privateSet(this, _rejectedBeforeCore, 0);
2046
- __privateSet(this, _rejectedFragments, 0);
2047
- __privateMethod(this, _WasmMfuReassembler_instances, refreshStats_fn).call(this);
2026
+ this.#clearCleanupTimer();
2027
+ this.#core.reset();
2028
+ this.#nextStreamIdentity = 1;
2029
+ this.#streamIdentityByKey.clear();
2030
+ this.#streamNameByIdentity.clear();
2031
+ this.#offeredFragments = 0;
2032
+ this.#rejectedFragments = 0;
2048
2033
  }
2049
2034
  get pendingCount() {
2050
- return __privateGet(this, _core).buffered_count;
2035
+ return this.#core.buffered_count;
2051
2036
  }
2052
2037
  getStatus() {
2053
- __privateMethod(this, _WasmMfuReassembler_instances, refreshStats_fn).call(this);
2038
+ this.#refreshStats();
2054
2039
  return {
2055
- bufferedMFUs: __privateGet(this, _core).buffered_count,
2056
- pendingFragments: __privateGet(this, _core).pending_fragment_count,
2040
+ bufferedMFUs: this.#core.buffered_count,
2041
+ pendingFragments: this.#core.pending_fragment_count,
2057
2042
  // Detailed fragment coordinates remain internal to the Rust core. Counts
2058
2043
  // and health statistics stay available to MmtpRouter diagnostics.
2059
2044
  pendingSamples: [],
2060
- stats: { ...this.stats }
2045
+ stats: { ...this.#stats }
2061
2046
  };
2062
2047
  }
2063
- };
2064
- _bindings = new WeakMap();
2065
- _core = new WeakMap();
2066
- _now = new WeakMap();
2067
- _timeoutMs = new WeakMap();
2068
- _cleanupTimer = new WeakMap();
2069
- _nextStreamIdentity = new WeakMap();
2070
- _streamIdentityByKey = new WeakMap();
2071
- _streamNameByIdentity = new WeakMap();
2072
- _coreTotalFragments = new WeakMap();
2073
- _rejectedBeforeCore = new WeakMap();
2074
- _rejectedFragments = new WeakMap();
2075
- _WasmMfuReassembler_instances = new WeakSet();
2076
- refreshStats_fn = function() {
2077
- const stats = __privateGet(this, _core).stats();
2078
- __privateSet(this, _coreTotalFragments, asNumber(stats.total_fragments));
2079
- this.stats.totalFragments = __privateGet(this, _coreTotalFragments) + __privateGet(this, _rejectedBeforeCore);
2080
- this.stats.reassembledMFUs = asNumber(stats.reassembled_mfus);
2081
- this.stats.rejectedFragments = __privateGet(this, _rejectedFragments);
2082
- this.stats.timedOutMFUs = asNumber(stats.timed_out_mfus);
2083
- this.stats.evictedMemoryLimit = asNumber(stats.evicted_memory_limit) + asNumber(stats.evicted_data_units ?? 0);
2084
- this.stats.outOfOrderFragments = asNumber(stats.out_of_order_fragments);
2085
- stats.free?.();
2086
- };
2087
- streamIdentityFor_fn = function(fragment) {
2088
- const key = fragment.catalogTrackName !== void 0 ? `catalog:${fragment.catalogTrackName}` : fragment.packetId !== void 0 ? `packet:${fragment.packetId}` : void 0;
2089
- if (key === void 0) return void 0;
2090
- const existing = __privateGet(this, _streamIdentityByKey).get(key);
2091
- if (existing !== void 0) return existing;
2092
- const identity = __privateWrapper(this, _nextStreamIdentity)._++;
2093
- __privateGet(this, _streamIdentityByKey).set(key, identity);
2094
- if (fragment.catalogTrackName !== void 0) {
2095
- __privateGet(this, _streamNameByIdentity).set(identity, fragment.catalogTrackName);
2048
+ #refreshStats() {
2049
+ const stats = this.#core.stats();
2050
+ this.#stats.totalFragments = this.#offeredFragments;
2051
+ this.#stats.reassembledMFUs = asNumber(stats.reassembled_mfus);
2052
+ this.#stats.rejectedFragments = this.#rejectedFragments;
2053
+ this.#stats.timedOutMFUs = asNumber(stats.timed_out_mfus);
2054
+ this.#stats.evictedMemoryLimit = asNumber(stats.evicted_memory_limit) + asNumber(stats.evicted_data_units ?? 0);
2055
+ this.#stats.outOfOrderFragments = asNumber(stats.out_of_order_fragments);
2056
+ stats.free?.();
2057
+ }
2058
+ #streamIdentityFor(fragment) {
2059
+ const key = fragment.catalogTrackName !== void 0 ? `catalog:${fragment.catalogTrackName}` : fragment.packetId !== void 0 ? `packet:${fragment.packetId}` : void 0;
2060
+ if (key === void 0) return void 0;
2061
+ const existing = this.#streamIdentityByKey.get(key);
2062
+ if (existing !== void 0) return existing;
2063
+ const identity = this.#nextStreamIdentity++;
2064
+ this.#streamIdentityByKey.set(key, identity);
2065
+ if (fragment.catalogTrackName !== void 0) {
2066
+ this.#streamNameByIdentity.set(identity, fragment.catalogTrackName);
2067
+ }
2068
+ return identity;
2069
+ }
2070
+ #asReassemblyError(error) {
2071
+ if (typeof error !== "object" && typeof error !== "function" || error === null) return null;
2072
+ const code = Reflect.get(error, "code");
2073
+ if (!isMfuReassemblyErrorCode(code)) return null;
2074
+ const message = Reflect.get(error, "message");
2075
+ return new MfuReassemblyError(
2076
+ code,
2077
+ typeof message === "string" ? message : `MFU reassembly rejected: ${code}`
2078
+ );
2079
+ }
2080
+ /**
2081
+ * Arm the cleanup wake-up only when none is armed. A fragment can only add
2082
+ * a data unit whose deadline is its own arrival plus the one configured
2083
+ * timeout, which is never earlier than the deadline already armed; the
2084
+ * armed wake-up re-reads the core's next deadline after cleanup. Only a
2085
+ * timeout change can move the next deadline earlier, and the timeoutMs
2086
+ * setter re-arms for that. This replaces a next_timeout_at() crossing and a
2087
+ * clear+set timer pair on every fragment (BLO-36599).
2088
+ */
2089
+ #ensureCleanupArmed() {
2090
+ if (this.#cleanupTimer === null) this.#scheduleCleanup();
2091
+ }
2092
+ #scheduleCleanup() {
2093
+ this.#clearCleanupTimer();
2094
+ if (this.#timeoutMs === null) return;
2095
+ const next = this.#core.next_timeout_at();
2096
+ if (next === void 0) return;
2097
+ const delay = Math.max(0, Math.ceil(next - this.#now()));
2098
+ this.#cleanupTimer = setTimeout(() => {
2099
+ this.#cleanupTimer = null;
2100
+ this.#core.cleanup_timeouts(this.#now());
2101
+ this.#scheduleCleanup();
2102
+ }, delay);
2103
+ }
2104
+ #clearCleanupTimer() {
2105
+ if (this.#cleanupTimer === null) return;
2106
+ clearTimeout(this.#cleanupTimer);
2107
+ this.#cleanupTimer = null;
2096
2108
  }
2097
- return identity;
2098
- };
2099
- asReassemblyError_fn = function(error) {
2100
- if (typeof error !== "object" && typeof error !== "function" || error === null) return null;
2101
- const code = Reflect.get(error, "code");
2102
- if (!isMfuReassemblyErrorCode(code)) return null;
2103
- const message = Reflect.get(error, "message");
2104
- return new MfuReassemblyError(
2105
- code,
2106
- typeof message === "string" ? message : `MFU reassembly rejected: ${code}`
2107
- );
2108
- };
2109
- scheduleCleanup_fn = function() {
2110
- __privateMethod(this, _WasmMfuReassembler_instances, clearCleanupTimer_fn).call(this);
2111
- if (__privateGet(this, _timeoutMs) === null) return;
2112
- const next = __privateGet(this, _core).next_timeout_at();
2113
- if (next === void 0) return;
2114
- const delay = Math.max(0, Math.ceil(next - __privateGet(this, _now).call(this)));
2115
- __privateSet(this, _cleanupTimer, setTimeout(() => {
2116
- __privateSet(this, _cleanupTimer, null);
2117
- __privateGet(this, _core).cleanup_timeouts(__privateGet(this, _now).call(this));
2118
- __privateMethod(this, _WasmMfuReassembler_instances, refreshStats_fn).call(this);
2119
- __privateMethod(this, _WasmMfuReassembler_instances, scheduleCleanup_fn).call(this);
2120
- }, delay));
2121
- };
2122
- clearCleanupTimer_fn = function() {
2123
- if (__privateGet(this, _cleanupTimer) === null) return;
2124
- clearTimeout(__privateGet(this, _cleanupTimer));
2125
- __privateSet(this, _cleanupTimer, null);
2126
2109
  };
2127
2110
  function resolveGlobalMmtWasmBindings() {
2128
2111
  const globals = globalThis;