mattebox 0.21.0 → 0.21.2

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 (114) hide show
  1. package/README.md +1 -1
  2. package/dist/cdn/mattebox.dash-drm.min.js +3 -3
  3. package/dist/cdn/mattebox.dash-ll.min.js +3 -3
  4. package/dist/cdn/mattebox.dash.min.js +3 -3
  5. package/dist/cdn/mattebox.dual-drm.min.js +3 -3
  6. package/dist/cdn/mattebox.dual-ll.min.js +3 -3
  7. package/dist/cdn/mattebox.dual-ts-drm.min.js +2 -2
  8. package/dist/cdn/mattebox.dual-ts.min.js +2 -2
  9. package/dist/cdn/mattebox.dual.min.js +3 -3
  10. package/dist/cdn/mattebox.hls-drm.min.js +3 -3
  11. package/dist/cdn/mattebox.hls-ll.min.js +3 -3
  12. package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
  13. package/dist/cdn/mattebox.hls-ts.min.js +3 -3
  14. package/dist/cdn/mattebox.hls.min.js +3 -3
  15. package/dist/cdn/mattebox.kernel.min.js +1 -1
  16. package/dist/cdn/mattebox.min.js +5 -5
  17. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.159.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/asyncToGenerator.js +1 -1
  18. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.159.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/defineProperty.js +1 -1
  19. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.159.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/objectSpread2.js +1 -1
  20. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.159.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/objectWithoutProperties.js +1 -1
  21. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.159.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
  22. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.159.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/toPrimitive.js +1 -1
  23. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.159.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/toPropertyKey.js +1 -1
  24. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.159.0 → _@oxc-project_runtime@0.160.0}/helpers/esm/typeof.js +1 -1
  25. package/dist/es2015/containers/fmp4/fit.js +1 -1
  26. package/dist/es2015/containers/id3.js +1 -1
  27. package/dist/es2015/containers/scte35.js +1 -1
  28. package/dist/es2015/containers/ts-transmux/h264.js +1 -1
  29. package/dist/es2015/containers/ts-transmux/h265.js +1 -1
  30. package/dist/es2015/containers/ts-transmux/index.js +1 -1
  31. package/dist/es2015/containers/ts-transmux/runner.js +2 -2
  32. package/dist/es2015/containers/ts-transmux/transmux.js +1 -1
  33. package/dist/es2015/containers/webm/index.js +1 -1
  34. package/dist/es2015/containers/webvtt.js +1 -1
  35. package/dist/es2015/containers/wvtt.js +1 -1
  36. package/dist/es2015/eme/index.js +3 -3
  37. package/dist/es2015/index.js +2 -2
  38. package/dist/es2015/kernel/append-queue.js +1 -1
  39. package/dist/es2015/kernel/bus.js +26 -6
  40. package/dist/es2015/kernel/context.js +1 -1
  41. package/dist/es2015/kernel/dry-run.js +1 -1
  42. package/dist/es2015/kernel/mse.js +5 -2
  43. package/dist/es2015/kernel/prepare.js +2 -2
  44. package/dist/es2015/kernel/reducer.js +163 -11
  45. package/dist/es2015/kernel/refresh.js +1 -1
  46. package/dist/es2015/kernel/rendition-select.js +2 -2
  47. package/dist/es2015/kernel/scheduler.js +1 -1
  48. package/dist/es2015/kernel/timeline.js +1 -1
  49. package/dist/es2015/kernel/trace.js +1 -1
  50. package/dist/es2015/kernel/transport.js +2 -2
  51. package/dist/es2015/presets/define.js +2 -2
  52. package/dist/es2015/protocols/dash-cmaf/index.js +1 -1
  53. package/dist/es2015/protocols/dash-cmaf/parse.js +1 -1
  54. package/dist/es2015/protocols/dash-cmaf/periods-runtime.js +1 -1
  55. package/dist/es2015/protocols/dash-cmaf/periods.js +1 -1
  56. package/dist/es2015/protocols/dash-live/index.js +1 -1
  57. package/dist/es2015/protocols/hls-cmaf/index.js +1 -1
  58. package/dist/es2015/protocols/hls-cmaf/parse.js +1 -1
  59. package/dist/es2015/protocols/hls-cmaf/unavailable.js +1 -1
  60. package/dist/es2015/protocols/hls-live/index.js +3 -2
  61. package/dist/es2015/protocols/hls-ll/parse.js +1 -1
  62. package/dist/es2015/stages/abr/index.js +1 -1
  63. package/dist/es2015/stages/aes-128/index.js +1 -1
  64. package/dist/es2015/stages/chapters/index.js +2 -2
  65. package/dist/es2015/stages/chapters/parse.js +2 -2
  66. package/dist/es2015/stages/codec-probe/index.js +1 -1
  67. package/dist/es2015/stages/content-steering/index.js +1 -1
  68. package/dist/es2015/stages/eme-core/index.js +2 -2
  69. package/dist/es2015/stages/eme-fairplay/index.js +1 -1
  70. package/dist/es2015/stages/hdr/index.js +1 -1
  71. package/dist/es2015/stages/interstitials/breaks.js +1 -1
  72. package/dist/es2015/stages/interstitials/index.js +2 -2
  73. package/dist/es2015/stages/live-catchup/index.js +21 -10
  74. package/dist/es2015/stages/qoe/index.js +29 -13
  75. package/dist/es2015/stages/recovery/index.js +1 -1
  76. package/dist/es2015/stages/rendition-names/index.js +1 -1
  77. package/dist/es2015/stages/text-cea608/decode.js +1 -1
  78. package/dist/es2015/stages/text-cea708/decode.js +2 -2
  79. package/dist/es2015/stages/text-cea708/index.js +1 -1
  80. package/dist/es2015/stages/text-ttml/index.js +1 -1
  81. package/dist/es2015/stages/text-ttml/parse.js +1 -1
  82. package/dist/es2015/stages/thumbnails/index.js +1 -1
  83. package/dist/es2015/stages/timed-metadata/index.js +1 -1
  84. package/dist/es2015/stages/transcript/index.js +2 -2
  85. package/dist/es2015/stages/trick-play/index.js +56 -5
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +3 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/kernel/bus.d.ts.map +1 -1
  90. package/dist/kernel/bus.js +26 -7
  91. package/dist/kernel/bus.js.map +1 -1
  92. package/dist/kernel/mse.d.ts.map +1 -1
  93. package/dist/kernel/mse.js +14 -3
  94. package/dist/kernel/mse.js.map +1 -1
  95. package/dist/kernel/reducer.d.ts.map +1 -1
  96. package/dist/kernel/reducer.js +178 -3
  97. package/dist/kernel/reducer.js.map +1 -1
  98. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  99. package/dist/protocols/hls-live/index.js +11 -1
  100. package/dist/protocols/hls-live/index.js.map +1 -1
  101. package/dist/stages/live-catchup/index.d.ts.map +1 -1
  102. package/dist/stages/live-catchup/index.js +21 -11
  103. package/dist/stages/live-catchup/index.js.map +1 -1
  104. package/dist/stages/qoe/index.d.ts +0 -15
  105. package/dist/stages/qoe/index.d.ts.map +1 -1
  106. package/dist/stages/qoe/index.js +27 -15
  107. package/dist/stages/qoe/index.js.map +1 -1
  108. package/dist/stages/trick-play/index.d.ts +10 -5
  109. package/dist/stages/trick-play/index.d.ts.map +1 -1
  110. package/dist/stages/trick-play/index.js +55 -6
  111. package/dist/stages/trick-play/index.js.map +1 -1
  112. package/dist/types/kernel.d.ts +6 -0
  113. package/dist/types/kernel.d.ts.map +1 -1
  114. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- // \0@oxc-project+runtime@0.159.0/helpers/esm/asyncToGenerator.js
1
+ // \0@oxc-project+runtime@0.160.0/helpers/esm/asyncToGenerator.js
2
2
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
3
3
  try {
4
4
  var i = n[a](c), u = i.value;
@@ -1,5 +1,5 @@
1
1
  import toPropertyKey from "./toPropertyKey.js";
2
- // \0@oxc-project+runtime@0.159.0/helpers/esm/defineProperty.js
2
+ // \0@oxc-project+runtime@0.160.0/helpers/esm/defineProperty.js
3
3
  function _defineProperty(e, r, t) {
4
4
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5
5
  value: t,
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "./defineProperty.js";
2
- // \0@oxc-project+runtime@0.159.0/helpers/esm/objectSpread2.js
2
+ // \0@oxc-project+runtime@0.160.0/helpers/esm/objectSpread2.js
3
3
  function ownKeys(e, r) {
4
4
  var t = Object.keys(e);
5
5
  if (Object.getOwnPropertySymbols) {
@@ -1,5 +1,5 @@
1
1
  import _objectWithoutPropertiesLoose from "./objectWithoutPropertiesLoose.js";
2
- // \0@oxc-project+runtime@0.159.0/helpers/esm/objectWithoutProperties.js
2
+ // \0@oxc-project+runtime@0.160.0/helpers/esm/objectWithoutProperties.js
3
3
  function _objectWithoutProperties(e, t) {
4
4
  if (null == e) return {};
5
5
  var o, r, i = _objectWithoutPropertiesLoose(e, t);
@@ -1,4 +1,4 @@
1
- // \0@oxc-project+runtime@0.159.0/helpers/esm/objectWithoutPropertiesLoose.js
1
+ // \0@oxc-project+runtime@0.160.0/helpers/esm/objectWithoutPropertiesLoose.js
2
2
  function _objectWithoutPropertiesLoose(r, e) {
3
3
  if (null == r) return {};
4
4
  var t = {};
@@ -1,5 +1,5 @@
1
1
  import _typeof from "./typeof.js";
2
- // \0@oxc-project+runtime@0.159.0/helpers/esm/toPrimitive.js
2
+ // \0@oxc-project+runtime@0.160.0/helpers/esm/toPrimitive.js
3
3
  function toPrimitive(t, e) {
4
4
  if ("object" != _typeof(t) || !t) return t;
5
5
  var r;
@@ -1,6 +1,6 @@
1
1
  import _typeof from "./typeof.js";
2
2
  import toPrimitive from "./toPrimitive.js";
3
- // \0@oxc-project+runtime@0.159.0/helpers/esm/toPropertyKey.js
3
+ // \0@oxc-project+runtime@0.160.0/helpers/esm/toPropertyKey.js
4
4
  function toPropertyKey(t) {
5
5
  var i = toPrimitive(t, "string");
6
6
  return "symbol" == _typeof(i) ? i : i + "";
@@ -1,4 +1,4 @@
1
- // \0@oxc-project+runtime@0.159.0/helpers/esm/typeof.js
1
+ // \0@oxc-project+runtime@0.160.0/helpers/esm/typeof.js
2
2
  function _typeof(o) {
3
3
  "@babel/helpers - typeof";
4
4
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -1,6 +1,6 @@
1
1
  import { findBox, fragmentSamples, fullBox, viewOf } from "../mp4-box/index.js";
2
2
  import { writeMediaSegment } from "./writer.js";
3
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
3
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
4
4
  // src/containers/fmp4/fit.ts
5
5
  /**
6
6
  * The first traf's per-sample encryption entries, null for a clear
@@ -1,5 +1,5 @@
1
1
  import { fourcc } from "./mp4-box/index.js";
2
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
2
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
3
3
  // src/containers/id3.ts
4
4
  const HEADER_SIZE = 10;
5
5
  function isId3(data, offset) {
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
2
2
  // src/containers/scte35.ts
3
3
  const TABLE_ID = 252;
4
4
  const SPLICE_INSERT = 5;
@@ -1,5 +1,5 @@
1
1
  import { toRbsp } from "../sei.js";
2
- import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/defineProperty.js";
2
+ import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/defineProperty.js";
3
3
  // src/containers/ts-transmux/h264.ts
4
4
  /**
5
5
  * H.264 Annex B to AVCC. The elementary stream separates NAL units with
@@ -1,5 +1,5 @@
1
1
  import { toRbsp } from "../sei.js";
2
- import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/defineProperty.js";
2
+ import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/defineProperty.js";
3
3
  // src/containers/ts-transmux/h265.ts
4
4
  /**
5
5
  * H.265 Annex B to the hvc1 sample format. The NAL units split on start
@@ -4,7 +4,7 @@ import { deliverMetadata, metadataWanted } from "../metadata.js";
4
4
  import { createTransmuxRunner } from "./runner.js";
5
5
  import { looksLikeTransportStream } from "./sniff.js";
6
6
  import { transmuxSource } from "./source.js";
7
- import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/asyncToGenerator.js";
7
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/asyncToGenerator.js";
8
8
  // src/containers/ts-transmux/index.ts
9
9
  /** Runs after decrypt-class steps (lower order) and before caption extraction. */
10
10
  const TRANSMUX_ORDER = 100;
@@ -1,5 +1,5 @@
1
- import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/asyncToGenerator.js";
2
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
1
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/asyncToGenerator.js";
2
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
3
3
  // src/containers/ts-transmux/runner.ts
4
4
  function createTransmuxRunner(options, source) {
5
5
  let worker = null;
@@ -4,7 +4,7 @@ import { ccTriplesFromSei } from "../sei.js";
4
4
  import { STREAM_TYPE, demux, unrollTimestamps } from "./demux.js";
5
5
  import { NAL_TYPE, accessUnitFromNals, nalType, splitNalUnits, spsDimensions, toAccessUnit } from "./h264.js";
6
6
  import { HEVC_NAL_TYPE, hevcAccessUnitFromNals, hevcDecoderConfiguration, hevcNalType, hevcSpsInfo } from "./h265.js";
7
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
7
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
8
8
  // src/containers/ts-transmux/transmux.ts
9
9
  /**
10
10
  * The transmux core: MPEG-TS bytes to a self-contained fragmented MP4. Each
@@ -3,7 +3,7 @@ import { findRendition } from "../../kernel/presentation.js";
3
3
  import { activeRenditions } from "../../kernel/rendition-select.js";
4
4
  import { isUnresolved } from "../../kernel/timeline.js";
5
5
  import { cuesToSegments, readCues, readInit } from "./cues.js";
6
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
6
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
7
7
  // src/containers/webm/index.ts
8
8
  /**
9
9
  * WebM segments in DASH. MSE takes `video/webm` and `audio/webm` as they
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
2
2
  // src/containers/webvtt.ts
3
3
  /** `HH:MM:SS.mmm` or `MM:SS.mmm` to seconds, or null. */
4
4
  function parseTimestamp(text) {
@@ -1,5 +1,5 @@
1
1
  import { fourcc, viewOf } from "./mp4-box/index.js";
2
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
2
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
3
3
  // src/containers/wvtt.ts
4
4
  /** The child boxes of `bytes`, as type and payload. */
5
5
  function boxes(bytes) {
@@ -1,8 +1,8 @@
1
1
  import { fetchWithin } from "../kernel/transport.js";
2
2
  import emeCore from "../stages/eme-core/index.js";
3
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectWithoutProperties.js";
4
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
5
- import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/asyncToGenerator.js";
3
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectWithoutProperties.js";
4
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
5
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/asyncToGenerator.js";
6
6
  // src/eme/index.ts
7
7
  /**
8
8
  * The engine's DRM on an element the engine does not drive. On Safari a
@@ -12,8 +12,8 @@ import { activeAudio, availableGroups, canSwitchTo, createArbiter, exclusionsOf
12
12
  import { createMseSink } from "./kernel/sinks/mse-sink.js";
13
13
  import { createTrackRegistry } from "./kernel/track-registry.js";
14
14
  import { createTransport } from "./kernel/transport.js";
15
- import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
16
- import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/asyncToGenerator.js";
15
+ import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
16
+ import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/asyncToGenerator.js";
17
17
  import { isAudioDescription, isEnhancedSpeech, isOriginal, isSdh, videoKind } from "./kernel/characteristics.js";
18
18
  import { exportTrace, replay } from "./kernel/trace.js";
19
19
  // src/index.ts
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
2
2
  // src/kernel/append-queue.ts
3
3
  function isQuotaError(err) {
4
4
  return err instanceof DOMException && err.name === "QuotaExceededError";
@@ -1,5 +1,30 @@
1
1
  import { createTraceBuffer, digest, lighten } from "./trace.js";
2
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
2
3
  // src/kernel/bus.ts
4
+ /**
5
+ * One trace entry. The digest walks the state, which on every message is
6
+ * the cost of tracing. The ring pays it at once: its entries outlive the
7
+ * state they describe. An entry only handed to listeners computes it when
8
+ * one reads it, from the state it holds until then, so a listener that
9
+ * reads the message alone pays nothing for the digest.
10
+ */
11
+ function traceEntry(t, msg, effects, state, kept) {
12
+ const light = {
13
+ t,
14
+ msg: lighten(msg),
15
+ effects: effects.map(lighten)
16
+ };
17
+ if (kept) return _objectSpread2(_objectSpread2({}, light), {}, { digest: digest(state) });
18
+ let pending = state;
19
+ let value = "";
20
+ return _objectSpread2(_objectSpread2({}, light), {}, { get digest() {
21
+ if (pending !== null) {
22
+ value = digest(pending);
23
+ pending = null;
24
+ }
25
+ return value;
26
+ } });
27
+ }
3
28
  function createBus(options) {
4
29
  var _options$now, _options$traceCapacit;
5
30
  let reducer = options.reducer;
@@ -25,12 +50,7 @@ function createBus(options) {
25
50
  const [next, effects] = reducer(state, msg);
26
51
  state = next;
27
52
  if (traceBuffer.capacity > 0 || ((_listeners$get$size = (_listeners$get = listeners.get("trace")) === null || _listeners$get === void 0 ? void 0 : _listeners$get.size) !== null && _listeners$get$size !== void 0 ? _listeners$get$size : 0) > 0) {
28
- const entry = {
29
- t: now(),
30
- msg: lighten(msg),
31
- effects: effects.map(lighten),
32
- digest: digest(state)
33
- };
53
+ const entry = traceEntry(now(), msg, effects, state, traceBuffer.capacity > 0);
34
54
  traceBuffer.push(entry);
35
55
  emitEvent("trace", entry);
36
56
  }
@@ -1,4 +1,4 @@
1
- import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/asyncToGenerator.js";
1
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/asyncToGenerator.js";
2
2
  // src/kernel/context.ts
3
3
  /**
4
4
  * Builds one stage's context and returns the registrations' own teardown,
@@ -2,7 +2,7 @@ import { createBus } from "./bus.js";
2
2
  import { createEffectRunner } from "./effects.js";
3
3
  import { createSegmentPreparer } from "./prepare.js";
4
4
  import { createReducer, initialState } from "./reducer.js";
5
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
5
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
6
6
  // src/kernel/dry-run.ts
7
7
  /** The whole run ends here, whatever it has fetched: a preload must not outlive its use. */
8
8
  const LIMIT_MS = 1e4;
@@ -1,6 +1,6 @@
1
1
  import { createAppendQueue } from "./append-queue.js";
2
2
  import { createEvictor } from "./evictor.js";
3
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
3
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
4
4
  // src/kernel/mse.ts
5
5
  function managedMediaSource() {
6
6
  return globalThis.ManagedMediaSource;
@@ -384,7 +384,7 @@ function createMseController(options) {
384
384
  function registerHandlers(runner) {
385
385
  createSourceBuffer = (effect) => {
386
386
  const ms = mediaSource;
387
- if (ms !== null && !opened && ms.readyState === "closed") {
387
+ if (ms !== null && !opened) {
388
388
  pendingCreates.push(effect);
389
389
  return;
390
390
  }
@@ -406,6 +406,9 @@ function createMseController(options) {
406
406
  if (buffers.has(effect.sbId) || deferred.has(effect.sbId)) return;
407
407
  if (options.inferType !== void 0 && !declaresCodecs(effect.codecs)) {
408
408
  deferred.set(effect.sbId, effect.codecs);
409
+ const held = heldAppends.get(effect.sbId);
410
+ heldAppends.delete(effect.sbId);
411
+ for (const data of held !== null && held !== void 0 ? held : []) enqueueAppend(effect.sbId, data);
409
412
  return;
410
413
  }
411
414
  open(effect.sbId, effect.codecs);
@@ -1,5 +1,5 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
2
- import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/asyncToGenerator.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
2
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/asyncToGenerator.js";
3
3
  // src/kernel/prepare.ts
4
4
  /**
5
5
  * The boundary meta a transform and the probe receive. The content type
@@ -6,8 +6,8 @@ import { activeAudio, audioGroup, audioInGroup, availableGroups, canSwitchTo, co
6
6
  import { bufferedEndFrom, reachesEnd, schedule } from "./scheduler.js";
7
7
  import { sbIdFor } from "./sinks/mse-sink.js";
8
8
  import { reconciledOffset, segmentAtTime } from "./timeline.js";
9
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
10
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectWithoutProperties.js";
9
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
10
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectWithoutProperties.js";
11
11
  // src/kernel/reducer.ts
12
12
  const _excluded = ["pendingInit"];
13
13
  const _excluded2 = ["repeat"];
@@ -15,8 +15,9 @@ const _excluded3 = ["appended"];
15
15
  const _excluded4 = ["initFor"];
16
16
  const _excluded5 = ["serverThroughput"];
17
17
  const _excluded6 = ["behindTrick"];
18
- const _excluded7 = ["start"];
18
+ const _excluded7 = ["behindTrick"];
19
19
  const _excluded8 = ["start"];
20
+ const _excluded9 = ["start"];
20
21
  /**
21
22
  * The default tuning. Every value is overridable through the `config`
22
23
  * parameters of `initialState` and `createReducer`; these are starting
@@ -299,6 +300,36 @@ const EDGE_INSET = .05;
299
300
  function edgeStart(spanStart, edge) {
300
301
  return Math.max(spanStart, edge - EDGE_INSET);
301
302
  }
303
+ /**
304
+ * Seconds past the start of a buffered range that a seek to it lands. A
305
+ * browser reports the start rounded, so a seek to the reported value can
306
+ * fall just before the media. The playback watcher in
307
+ * videojs-http-streaming lands past the start for the same reason.
308
+ */
309
+ const RANGE_INSET = .05;
310
+ /**
311
+ * Where a pending seek has to move for the element to complete it, or null
312
+ * when it can stay. The scheduler counts a range that starts within the gap
313
+ * tolerance of the playhead as covering it, and fetches nothing before it.
314
+ * A seek to just before a segment boundary therefore gets a buffer that
315
+ * starts at the boundary, and the live start is such a seek. An element
316
+ * completes a seek only with media at the target itself: Chrome waits
317
+ * there, Firefox plays across. The seek moves to where every buffer has
318
+ * media, because no fetch will fill what lies before.
319
+ */
320
+ function seekIntoBuffered(buffers, time) {
321
+ let start = time;
322
+ let end = Number.POSITIVE_INFINITY;
323
+ for (const buffer of buffers.values()) {
324
+ const range = buffer.ranges.find((r) => r.start <= time + GAP_TOLERANCE && r.end > time);
325
+ if (range === void 0) return null;
326
+ start = Math.max(start, range.start);
327
+ end = Math.min(end, range.end);
328
+ }
329
+ if (start <= time) return null;
330
+ const to = start + RANGE_INSET;
331
+ return to < end ? to : null;
332
+ }
302
333
  /** Abort effects for every matching in-flight request, plus the state with them removed. */
303
334
  function abortInflight(state, trackId) {
304
335
  const effects = [];
@@ -452,6 +483,7 @@ function reduceCommand(state, msg, cfg, hooks) {
452
483
  const track = findTrack(state.presentation, msg.trackId);
453
484
  if (track === null) return reject(state, msg.type, `unknown track: ${msg.trackId}`);
454
485
  if (isUndecodable(state, track)) return reject(state, msg.type, `undecodable track: ${msg.trackId}`);
486
+ if (isTrick(track) && state.tracks.trickFailed === true) return reject(state, msg.type, `failed trick track: ${msg.trackId}`);
455
487
  const previous = state.tracks.active.get(track.contentType);
456
488
  const active = new Map(state.tracks.active);
457
489
  active.set(track.contentType, track.id);
@@ -739,6 +771,81 @@ function behindTrick(tracks, track, previous) {
739
771
  return tracks;
740
772
  }
741
773
  /**
774
+ * A failure that would end playback while an I-frame track stands in for
775
+ * the video track ends the I-frame track instead. `state` is the state
776
+ * before the failing message and `failed` what its reduction emitted. The
777
+ * element may be in its error state, which no buffer operation leaves, so
778
+ * the media source is replaced: every buffer goes, the track behind the
779
+ * I-frame track returns, and scheduling starts again at the playhead. The
780
+ * error is reported as it was, except that it is not fatal and names the
781
+ * I-frame track. Null when no track is left to return to: the failure
782
+ * stays fatal.
783
+ */
784
+ function leaveFailedTrick(state, failed, hooks, cfg) {
785
+ const behind = state.tracks.behindTrick;
786
+ const trick = state.tracks.active.get("video");
787
+ const presentation = state.presentation;
788
+ if (behind === void 0 || presentation === null || findTrack(presentation, behind) === null) return null;
789
+ const [stopped, aborts] = abortInflight(state);
790
+ const to = state.playback.currentTime;
791
+ const active = new Map(state.tracks.active).set("video", behind);
792
+ const _state$tracks = state.tracks, { behindTrick: _behind } = _state$tracks, tracks = _objectWithoutProperties(_state$tracks, _excluded7);
793
+ const rebuilt = _objectSpread2(_objectSpread2({}, stopped), {}, {
794
+ lifecycle: { phase: state.lifecycle.phase === "ended" ? "ready" : state.lifecycle.phase },
795
+ buffers: /* @__PURE__ */ new Map(),
796
+ bufferErrors: /* @__PURE__ */ new Map(),
797
+ timeline: _objectSpread2(_objectSpread2({}, state.timeline), {}, { periodOffsets: /* @__PURE__ */ new Map() }),
798
+ scheduling: clearRepeat(withPendingInit(stopped.scheduling, void 0)),
799
+ tracks: _objectSpread2(_objectSpread2({}, tracks), {}, {
800
+ active,
801
+ trickFailed: true
802
+ }),
803
+ quality: _objectSpread2(_objectSpread2({}, bumped(state.quality)), {}, { appendLog: [] }),
804
+ playback: _objectSpread2(_objectSpread2({}, state.playback), {}, {
805
+ currentTime: to,
806
+ seeking: false
807
+ })
808
+ });
809
+ const effects = [...aborts];
810
+ for (const effect of failed) {
811
+ if (effect.kind !== "emit") continue;
812
+ effects.push(effect.event === "error" ? _objectSpread2(_objectSpread2({}, effect), {}, { payload: _objectSpread2(_objectSpread2({}, effect.payload), {}, {
813
+ fatal: false,
814
+ recoverable: true,
815
+ trackId: trick
816
+ }) }) : effect);
817
+ }
818
+ effects.push({ kind: "resetSource" });
819
+ if (!presentation.isLive && presentation.duration !== void 0) effects.push({
820
+ kind: "setDuration",
821
+ seconds: presentation.duration
822
+ });
823
+ else if (state.live !== null) {
824
+ if (presentation.duration === void 0) effects.push({
825
+ kind: "setDuration",
826
+ seconds: Number.POSITIVE_INFINITY
827
+ });
828
+ effects.push({
829
+ kind: "setLiveSeekableRange",
830
+ start: state.live.span.start,
831
+ end: state.live.span.end
832
+ });
833
+ }
834
+ effects.push({
835
+ kind: "seekElement",
836
+ to
837
+ }, {
838
+ kind: "emit",
839
+ event: "tracks:selected",
840
+ payload: {
841
+ contentType: "video",
842
+ trackId: behind
843
+ }
844
+ });
845
+ const [driven, driveEffects] = driveScheduling(rebuilt, hooks, cfg);
846
+ return [driven, [...effects, ...driveEffects]];
847
+ }
848
+ /**
742
849
  * A presentation replaces the one held: a manifest landed, or a playlist
743
850
  * merged into it. Activates default tracks and reports what changed.
744
851
  */
@@ -788,7 +895,7 @@ function loadPresentation(state, merged, undecodableIds = /* @__PURE__ */ new Se
788
895
  if (start !== void 0 && !presentation.isLive) {
789
896
  var _presentation$duratio;
790
897
  const to = Math.max(0, Math.min(start, (_presentation$duratio = presentation.duration) !== null && _presentation$duratio !== void 0 ? _presentation$duratio : start));
791
- const _loaded$playback = loaded.playback, { start: _ } = _loaded$playback, rest = _objectWithoutProperties(_loaded$playback, _excluded7);
898
+ const _loaded$playback = loaded.playback, { start: _ } = _loaded$playback, rest = _objectWithoutProperties(_loaded$playback, _excluded8);
792
899
  manifestEffects.push({
793
900
  kind: "seekElement",
794
901
  to
@@ -1019,7 +1126,7 @@ function reduceFact(state, msg, cfg, hooks) {
1019
1126
  }), effects];
1020
1127
  }
1021
1128
  case "SEGMENT_FAILED": {
1022
- var _msg$status2;
1129
+ var _msg$status3;
1023
1130
  const inflight = new Map(state.scheduling.inflight);
1024
1131
  for (const [token, request] of inflight) if (request.trackId === msg.trackId && request.seq === msg.seq) inflight.delete(token);
1025
1132
  if (msg.preload === true) return [_objectSpread2(_objectSpread2({}, state), {}, { scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }) }), []];
@@ -1031,6 +1138,35 @@ function reduceFact(state, msg, cfg, hooks) {
1031
1138
  recoverable: false
1032
1139
  }), _objectSpread2({ status: (_msg$status = msg.status) !== null && _msg$status !== void 0 ? _msg$status : null }, typeof contentType === "string" ? { contentType } : {}));
1033
1140
  }
1141
+ const behind = state.tracks.behindTrick;
1142
+ const failedSite = msg.renditionId === void 0 ? null : findRendition(state.presentation, msg.renditionId);
1143
+ if (behind !== void 0 && failedSite !== null && isTrick(failedSite.track)) {
1144
+ const [left, leftEffects] = reduceCommand(_objectSpread2(_objectSpread2({}, state), {}, { scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }) }), {
1145
+ type: "SELECT_TRACK",
1146
+ trackId: behind,
1147
+ apply: "now"
1148
+ }, cfg, hooks);
1149
+ if (left.tracks.active.get("video") === behind) {
1150
+ var _msg$status2;
1151
+ return [_objectSpread2(_objectSpread2({}, left), {}, { tracks: _objectSpread2(_objectSpread2({}, left.tracks), {}, { trickFailed: true }) }), [
1152
+ {
1153
+ kind: "emit",
1154
+ event: "error",
1155
+ payload: {
1156
+ category: msg.error.category,
1157
+ code: msg.error.code,
1158
+ fatal: false,
1159
+ recoverable: true,
1160
+ trackId: failedSite.track.id,
1161
+ seq: msg.seq,
1162
+ status: (_msg$status2 = msg.status) !== null && _msg$status2 !== void 0 ? _msg$status2 : null
1163
+ }
1164
+ },
1165
+ ...leftEffects,
1166
+ tickAfter("kernel:retry", 0)
1167
+ ]];
1168
+ }
1169
+ }
1034
1170
  const failedTrack = findTrack(state.presentation, msg.trackId);
1035
1171
  const isCueTrack = failedTrack !== null && (failedTrack.contentType === "text" || failedTrack.contentType === "metadata");
1036
1172
  let cues = state.cues;
@@ -1058,7 +1194,7 @@ function reduceFact(state, msg, cfg, hooks) {
1058
1194
  recoverable: msg.error.recoverable,
1059
1195
  trackId: msg.trackId,
1060
1196
  seq: msg.seq,
1061
- status: (_msg$status2 = msg.status) !== null && _msg$status2 !== void 0 ? _msg$status2 : null
1197
+ status: (_msg$status3 = msg.status) !== null && _msg$status3 !== void 0 ? _msg$status3 : null
1062
1198
  }
1063
1199
  }];
1064
1200
  if (!isCueTrack) failEffects.push(tickAfter("kernel:retry", cfg.baseRetryDelayMs));
@@ -1098,10 +1234,21 @@ function reduceFact(state, msg, cfg, hooks) {
1098
1234
  bufferErrors = new Map(bufferErrors);
1099
1235
  bufferErrors.delete(msg.sbId);
1100
1236
  }
1101
- return driveScheduling(_objectSpread2(_objectSpread2({}, state), {}, {
1237
+ const updated = _objectSpread2(_objectSpread2({}, state), {}, {
1102
1238
  buffers,
1103
1239
  bufferErrors
1104
- }), hooks, cfg);
1240
+ });
1241
+ if (state.lifecycle.phase === "ready" && state.playback.seeking) {
1242
+ const to = seekIntoBuffered(buffers, state.playback.currentTime);
1243
+ if (to !== null) {
1244
+ const [scheduled, effects] = driveScheduling(_objectSpread2(_objectSpread2({}, updated), {}, { playback: _objectSpread2(_objectSpread2({}, updated.playback), {}, { currentTime: to }) }), hooks, cfg);
1245
+ return [scheduled, [{
1246
+ kind: "seekElement",
1247
+ to
1248
+ }, ...effects]];
1249
+ }
1250
+ }
1251
+ return driveScheduling(updated, hooks, cfg);
1105
1252
  }
1106
1253
  case "SOURCEBUFFER_ERROR": {
1107
1254
  var _state$bufferErrors$g;
@@ -1110,7 +1257,8 @@ function reduceFact(state, msg, cfg, hooks) {
1110
1257
  bufferErrors.set(msg.sbId, count);
1111
1258
  const scheduling = withPendingInit(state.scheduling, withoutPendingInit(state.scheduling.pendingInit, msg.sbId));
1112
1259
  let buffers = forgetAppended(state.buffers, msg.sbId);
1113
- const fatal = msg.error.fatal || count >= cfg.bufferErrorLimit;
1260
+ const trickAppend = state.tracks.behindTrick !== void 0 && msg.sbId === sbIdFor("video") && msg.error.code === "MEDIA_APPEND_FAILED";
1261
+ const fatal = msg.error.fatal || count >= cfg.bufferErrorLimit || trickAppend;
1114
1262
  const phase = fatal ? "error" : state.lifecycle.phase;
1115
1263
  const neverAppended = msg.error.code === "MEDIA_CONTAINER_INVALID";
1116
1264
  const waiting = buffers.get(msg.sbId);
@@ -1124,7 +1272,7 @@ function reduceFact(state, msg, cfg, hooks) {
1124
1272
  fatal,
1125
1273
  recoverable: msg.error.recoverable,
1126
1274
  sbId: msg.sbId
1127
- }, fatal && !msg.error.fatal ? { consecutiveFailures: count } : {}), msg.error.context !== void 0 ? { context: msg.error.context } : {})
1275
+ }, fatal && !msg.error.fatal && !trickAppend ? { consecutiveFailures: count } : {}), msg.error.context !== void 0 ? { context: msg.error.context } : {})
1128
1276
  }];
1129
1277
  if (neverAppended && !fatal) effects.push(tickAfter("kernel:retry", cfg.baseRetryDelayMs));
1130
1278
  let inflight = state.scheduling.inflight;
@@ -1233,7 +1381,7 @@ function reduceFact(state, msg, cfg, hooks) {
1233
1381
  const start = state.playback.start;
1234
1382
  if (firstWindow && start !== void 0) {
1235
1383
  const to = start >= msg.start && start <= msg.edge ? start : edgeStart(msg.start, msg.edge);
1236
- const _withLive$playback = withLive.playback, { start: _ } = _withLive$playback, rest = _objectWithoutProperties(_withLive$playback, _excluded8);
1384
+ const _withLive$playback = withLive.playback, { start: _ } = _withLive$playback, rest = _objectWithoutProperties(_withLive$playback, _excluded9);
1237
1385
  const [scheduled, effects] = driveScheduling(_objectSpread2(_objectSpread2({}, withLive), {}, { playback: _objectSpread2(_objectSpread2({}, rest), {}, { currentTime: to }) }), hooks, cfg);
1238
1386
  return [scheduled, [
1239
1387
  ...spanEffects,
@@ -1520,6 +1668,10 @@ function createReducer(slices, config, shared = {}) {
1520
1668
  return (state, msg) => {
1521
1669
  const manifestRequest = !isCommand(msg) && msg.type === "SEGMENT_LOADED" ? manifestRequestFor(state, msg) : null;
1522
1670
  let [next, effects] = isCommand(msg) ? reduceCommand(state, msg, cfg, hooks) : reduceFact(state, msg, cfg, hooks);
1671
+ if (next.lifecycle.phase === "error" && state.lifecycle.phase !== "error") {
1672
+ const left = leaveFailedTrick(state, effects, hooks, cfg);
1673
+ if (left !== null) [next, effects] = left;
1674
+ }
1523
1675
  if (isCommand(msg) && effects.some((effect) => effect.kind === "emit" && effect.event === "command:rejected")) return [next, effects];
1524
1676
  const merged = msg.type !== "PLAYLIST_REFRESHED" || next.presentation !== state.presentation;
1525
1677
  if (!isCommand(msg) && DRIVING_FACTS.has(msg.type) && merged) {
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
2
2
  // src/kernel/refresh.ts
3
3
  /** The presentation with the refresh merged, or null when it names no rendition the presentation holds. */
4
4
  function applyRefresh(presentation, refresh) {
@@ -1,8 +1,8 @@
1
1
  import { findRendition, findTrackSite } from "./presentation.js";
2
2
  import { bufferedEndFrom } from "./scheduler.js";
3
3
  import { segmentAtTime } from "./timeline.js";
4
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectWithoutProperties.js";
5
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
4
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectWithoutProperties.js";
5
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
6
6
  // src/kernel/rendition-select.ts
7
7
  const _excluded = [
8
8
  "maxHeight",
@@ -1,5 +1,5 @@
1
1
  import { buildEpochs, epochForSeq, epochKey, isIndexed, segmentAtTime, timestampOffsetFor } from "./timeline.js";
2
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
2
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
3
3
  // src/kernel/scheduler.ts
4
4
  const DEFAULT_GAP_TOLERANCE = .25;
5
5
  /**
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
2
2
  // src/kernel/timeline.ts
3
3
  function isIndexed(addressing) {
4
4
  return !Array.isArray(addressing) && addressing.kind === "indexed";
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
2
2
  function isBytes(value) {
3
3
  return value instanceof ArrayBuffer || ArrayBuffer.isView(value);
4
4
  }
@@ -1,5 +1,5 @@
1
- import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/asyncToGenerator.js";
2
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
1
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/asyncToGenerator.js";
2
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
3
3
  // src/kernel/transport.ts
4
4
  const DEFAULT_RETRY_POLICY = {
5
5
  maxAttempts: 3,
@@ -1,6 +1,6 @@
1
1
  import { mattebox } from "../index.js";
2
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectWithoutProperties.js";
3
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.159.0/helpers/esm/objectSpread2.js";
2
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectWithoutProperties.js";
3
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.160.0/helpers/esm/objectSpread2.js";
4
4
  // src/presets/define.ts
5
5
  const _excluded = ["stages", "without"];
6
6
  /** Applies the merge rule. Exported for tests; presets call it through `stages`. */