mattebox 0.4.0 → 0.6.0

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 (85) hide show
  1. package/dist/cdn/mattebox.dash-drm.min.js +3 -3
  2. package/dist/cdn/mattebox.dash.min.js +3 -3
  3. package/dist/cdn/mattebox.dual-drm.min.js +3 -3
  4. package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
  5. package/dist/cdn/mattebox.dual-ts.min.js +3 -3
  6. package/dist/cdn/mattebox.dual.min.js +3 -3
  7. package/dist/cdn/mattebox.hls-drm.min.js +3 -3
  8. package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
  9. package/dist/cdn/mattebox.hls-ts.min.js +3 -3
  10. package/dist/cdn/mattebox.hls.min.js +3 -3
  11. package/dist/cdn/mattebox.kernel.min.js +1 -1
  12. package/dist/cdn/mattebox.min.js +3 -3
  13. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/asyncToGenerator.js +1 -1
  14. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/defineProperty.js +1 -1
  15. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/objectSpread2.js +1 -1
  16. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/objectWithoutProperties.js +1 -1
  17. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
  18. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/toPrimitive.js +1 -1
  19. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/toPropertyKey.js +1 -1
  20. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.148.0 → _@oxc-project_runtime@0.149.0}/helpers/esm/typeof.js +1 -1
  21. package/dist/es2015/containers/id3.js +1 -1
  22. package/dist/es2015/containers/ts-transmux/h264.js +1 -1
  23. package/dist/es2015/containers/ts-transmux/index.js +1 -1
  24. package/dist/es2015/index.js +10 -4
  25. package/dist/es2015/kernel/append-queue.js +1 -1
  26. package/dist/es2015/kernel/lifecycle.js +2 -2
  27. package/dist/es2015/kernel/mse.js +71 -23
  28. package/dist/es2015/kernel/reducer.js +55 -13
  29. package/dist/es2015/kernel/rendition-select.js +1 -1
  30. package/dist/es2015/kernel/scheduler.js +1 -1
  31. package/dist/es2015/kernel/trace.js +1 -1
  32. package/dist/es2015/kernel/transport.js +2 -2
  33. package/dist/es2015/presets/define.js +2 -2
  34. package/dist/es2015/protocols/dash-cmaf/index.js +2 -2
  35. package/dist/es2015/protocols/dash-cmaf/parse.js +1 -1
  36. package/dist/es2015/protocols/dash-live/index.js +36 -4
  37. package/dist/es2015/protocols/hls-cmaf/index.js +2 -2
  38. package/dist/es2015/protocols/hls-cmaf/parse.js +1 -1
  39. package/dist/es2015/protocols/hls-live/index.js +42 -5
  40. package/dist/es2015/stages/abr/index.js +1 -1
  41. package/dist/es2015/stages/abr-persist/index.js +1 -1
  42. package/dist/es2015/stages/aes-128/index.js +1 -1
  43. package/dist/es2015/stages/content-steering/index.js +30 -3
  44. package/dist/es2015/stages/eme-core/index.js +2 -2
  45. package/dist/es2015/stages/eme-fairplay/index.js +1 -1
  46. package/dist/es2015/stages/recovery/index.js +1 -1
  47. package/dist/es2015/stages/text-cea608/decode.js +1 -1
  48. package/dist/es2015/stages/text-webvtt/parse.js +1 -1
  49. package/dist/es2015/stages/thumbnails/index.js +1 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +8 -2
  52. package/dist/index.js.map +1 -1
  53. package/dist/kernel/lifecycle.d.ts +2 -1
  54. package/dist/kernel/lifecycle.d.ts.map +1 -1
  55. package/dist/kernel/lifecycle.js +2 -2
  56. package/dist/kernel/lifecycle.js.map +1 -1
  57. package/dist/kernel/mse.d.ts +8 -1
  58. package/dist/kernel/mse.d.ts.map +1 -1
  59. package/dist/kernel/mse.js +101 -25
  60. package/dist/kernel/mse.js.map +1 -1
  61. package/dist/kernel/reducer.d.ts.map +1 -1
  62. package/dist/kernel/reducer.js +82 -6
  63. package/dist/kernel/reducer.js.map +1 -1
  64. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  65. package/dist/protocols/dash-cmaf/index.js +4 -2
  66. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  67. package/dist/protocols/dash-live/index.d.ts.map +1 -1
  68. package/dist/protocols/dash-live/index.js +28 -2
  69. package/dist/protocols/dash-live/index.js.map +1 -1
  70. package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
  71. package/dist/protocols/hls-cmaf/index.js +7 -1
  72. package/dist/protocols/hls-cmaf/index.js.map +1 -1
  73. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  74. package/dist/protocols/hls-live/index.js +34 -2
  75. package/dist/protocols/hls-live/index.js.map +1 -1
  76. package/dist/stages/content-steering/index.d.ts.map +1 -1
  77. package/dist/stages/content-steering/index.js +23 -1
  78. package/dist/stages/content-steering/index.js.map +1 -1
  79. package/dist/types/facade.d.ts +28 -1
  80. package/dist/types/facade.d.ts.map +1 -1
  81. package/dist/types/kernel.d.ts +15 -2
  82. package/dist/types/kernel.d.ts.map +1 -1
  83. package/dist/types/messages.d.ts +8 -0
  84. package/dist/types/messages.d.ts.map +1 -1
  85. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/asyncToGenerator.js
1
+ //#region \0@oxc-project+runtime@0.149.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
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/defineProperty.js
2
+ //#region \0@oxc-project+runtime@0.149.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
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/objectSpread2.js
2
+ //#region \0@oxc-project+runtime@0.149.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
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/objectWithoutProperties.js
2
+ //#region \0@oxc-project+runtime@0.149.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
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/objectWithoutPropertiesLoose.js
1
+ //#region \0@oxc-project+runtime@0.149.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
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/toPrimitive.js
2
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
3
3
  function toPrimitive(t, r) {
4
4
  if ("object" != _typeof(t) || !t) return t;
5
5
  var e = t[Symbol.toPrimitive];
@@ -1,6 +1,6 @@
1
1
  import _typeof from "./typeof.js";
2
2
  import toPrimitive from "./toPrimitive.js";
3
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/toPropertyKey.js
3
+ //#region \0@oxc-project+runtime@0.149.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
- //#region \0@oxc-project+runtime@0.148.0/helpers/esm/typeof.js
1
+ //#region \0@oxc-project+runtime@0.149.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,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
2
  //#region src/containers/id3.ts
3
3
  const HEADER_SIZE = 10;
4
4
  function isId3(data, offset) {
@@ -1,4 +1,4 @@
1
- import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/defineProperty.js";
1
+ import _defineProperty from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/defineProperty.js";
2
2
  //#region src/containers/ts-transmux/h264.ts
3
3
  /**
4
4
  * H.264 Annex B to AVCC. The elementary stream separates NAL units with
@@ -1,4 +1,4 @@
1
- import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/asyncToGenerator.js";
1
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/asyncToGenerator.js";
2
2
  import { captionsWanted, deliverCaptions } from "../captions.js";
3
3
  import { looksLikeTransportStream } from "./demux.js";
4
4
  import { createTransmuxRunner } from "./runner.js";
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
2
  import { exportTrace, replay } from "./kernel/trace.js";
3
3
  import { createBus } from "./kernel/bus.js";
4
4
  import { createEffectRunner } from "./kernel/effects.js";
@@ -8,7 +8,7 @@ import { createMseSink } from "./kernel/sinks/mse-sink.js";
8
8
  import { createReducer, initialState, resolveConfig } from "./kernel/reducer.js";
9
9
  import { createLifecycle } from "./kernel/lifecycle.js";
10
10
  import { compose } from "./kernel/loader.js";
11
- import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/asyncToGenerator.js";
11
+ import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/asyncToGenerator.js";
12
12
  import { createMseController } from "./kernel/mse.js";
13
13
  import { createTrackRegistry } from "./kernel/track-registry.js";
14
14
  import { createTransport } from "./kernel/transport.js";
@@ -273,9 +273,9 @@ function mattebox(options) {
273
273
  get error() {
274
274
  return lastError;
275
275
  },
276
- attach(el) {
276
+ attach(el, attachOptions) {
277
277
  return _asyncToGenerator(function* () {
278
- lifecycle.attach(el);
278
+ lifecycle.attach(el, attachOptions);
279
279
  })();
280
280
  },
281
281
  detach() {
@@ -300,6 +300,12 @@ function mattebox(options) {
300
300
  unload() {
301
301
  bus.dispatch({ type: "UNLOAD" });
302
302
  },
303
+ suspend() {
304
+ bus.dispatch({ type: "SUSPEND" });
305
+ },
306
+ resume() {
307
+ bus.dispatch({ type: "RESUME" });
308
+ },
303
309
  dispatch(cmd) {
304
310
  bus.dispatch(cmd);
305
311
  },
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
2
  //#region src/kernel/append-queue.ts
3
3
  function isQuotaError(err) {
4
4
  return err instanceof DOMException && err.name === "QuotaExceededError";
@@ -22,7 +22,7 @@ function createLifecycle(deps) {
22
22
  fn
23
23
  });
24
24
  }
25
- function attach(el) {
25
+ function attach(el, options = {}) {
26
26
  if (element !== null) throw Object.assign(/* @__PURE__ */ new Error("this engine is already attached"), {
27
27
  category: "config",
28
28
  code: "CONFIG_ELEMENT_OCCUPIED"
@@ -50,7 +50,7 @@ function createLifecycle(deps) {
50
50
  element: el
51
51
  });
52
52
  try {
53
- deps.mse.attach(el);
53
+ deps.mse.attach(el, options);
54
54
  } catch (err) {
55
55
  for (const fn of [...teardowns].reverse()) fn();
56
56
  teardowns = [];
@@ -1,7 +1,7 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
2
  import { createAppendQueue } from "./append-queue.js";
3
3
  import { createEvictor } from "./evictor.js";
4
- import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/asyncToGenerator.js";
4
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/asyncToGenerator.js";
5
5
  //#region src/kernel/mse.ts
6
6
  function managedMediaSource() {
7
7
  return globalThis.ManagedMediaSource;
@@ -37,8 +37,14 @@ function createMseController(options) {
37
37
  const appendChains = /* @__PURE__ */ new Map();
38
38
  /** Buffers requested without codecs, waiting for their first bytes to be typed. */
39
39
  const deferred = /* @__PURE__ */ new Map();
40
+ /** Appends that arrived while their buffer's create was still pending. */
41
+ const heldAppends = /* @__PURE__ */ new Map();
40
42
  let objectUrl = null;
41
43
  let liveObjectUrls = 0;
44
+ /** The `<source>` children this controller added, to take back on detach. */
45
+ let sourceNodes = [];
46
+ /** The options of the current attach, so a reset reattaches the same way. */
47
+ let attachOptions;
42
48
  let pendingEndOfStream = null;
43
49
  let pendingDuration = null;
44
50
  let pendingLiveRange = null;
@@ -151,7 +157,15 @@ function createMseController(options) {
151
157
  });
152
158
  }
153
159
  }
154
- function attach(el) {
160
+ /** Appends one `<source>` child and answers it. */
161
+ function sourceElement(el, src, type) {
162
+ const node = el.ownerDocument.createElement("source");
163
+ node.src = src;
164
+ node.type = type;
165
+ el.append(node);
166
+ return node;
167
+ }
168
+ function attach(el, options_ = {}) {
155
169
  if (element !== null) throw Object.assign(/* @__PURE__ */ new Error("already attached"), {
156
170
  category: "config",
157
171
  code: "CONFIG_ELEMENT_OCCUPIED"
@@ -163,6 +177,8 @@ function createMseController(options) {
163
177
  el.removeAttribute("src");
164
178
  while (el.firstChild) el.removeChild(el.firstChild);
165
179
  el.load();
180
+ const airplay = options_.airplay;
181
+ attachOptions = options_;
166
182
  const Managed = options.preferManaged === false ? void 0 : managedMediaSource();
167
183
  managed = Managed !== void 0;
168
184
  const ms = Managed !== void 0 ? new Managed() : new MediaSource();
@@ -170,7 +186,7 @@ function createMseController(options) {
170
186
  mediaSource = ms;
171
187
  opened = false;
172
188
  listen(ms, "sourceopen", () => {
173
- if (objectUrl !== null) {
189
+ if (objectUrl !== null && sourceNodes.length === 0) {
174
190
  URL.revokeObjectURL(objectUrl);
175
191
  objectUrl = null;
176
192
  liveObjectUrls -= 1;
@@ -184,19 +200,27 @@ function createMseController(options) {
184
200
  });
185
201
  if (managed) {
186
202
  unobserveManaged = evictor.observeManaged(ms, trimAllBackBuffers);
187
- el.disableRemotePlayback = true;
203
+ if (airplay === void 0) el.disableRemotePlayback = true;
188
204
  }
189
- let useSrcObject = options.attachMode !== "object-url" && "srcObject" in el;
190
- if (useSrcObject) try {
191
- el.srcObject = ms;
192
- useSrcObject = el.srcObject === ms;
193
- } catch (_unused4) {
194
- useSrcObject = false;
195
- }
196
- if (!useSrcObject) {
205
+ if (airplay !== void 0) {
206
+ var _airplay$type;
197
207
  objectUrl = URL.createObjectURL(ms);
198
208
  liveObjectUrls += 1;
199
- el.src = objectUrl;
209
+ sourceNodes = [sourceElement(el, objectUrl, "video/mp4"), sourceElement(el, airplay.url, (_airplay$type = airplay.type) !== null && _airplay$type !== void 0 ? _airplay$type : "application/x-mpegURL")];
210
+ el.load();
211
+ } else {
212
+ let useSrcObject = options.attachMode !== "object-url" && "srcObject" in el;
213
+ if (useSrcObject) try {
214
+ el.srcObject = ms;
215
+ useSrcObject = el.srcObject === ms;
216
+ } catch (_unused4) {
217
+ useSrcObject = false;
218
+ }
219
+ if (!useSrcObject) {
220
+ objectUrl = URL.createObjectURL(ms);
221
+ liveObjectUrls += 1;
222
+ el.src = objectUrl;
223
+ }
200
224
  }
201
225
  absorb({
202
226
  type: "ELEMENT_ATTACHED",
@@ -217,6 +241,7 @@ function createMseController(options) {
217
241
  buffers.clear();
218
242
  appendChains.clear();
219
243
  deferred.clear();
244
+ heldAppends.clear();
220
245
  pendingCreates.length = 0;
221
246
  if (ms !== null && ms.readyState === "open") try {
222
247
  ms.endOfStream();
@@ -225,6 +250,8 @@ function createMseController(options) {
225
250
  unobserveManaged = null;
226
251
  unlistenAll();
227
252
  if (el !== null) {
253
+ for (const node of sourceNodes) node.remove();
254
+ sourceNodes = [];
228
255
  if ("srcObject" in el) el.srcObject = null;
229
256
  el.removeAttribute("src");
230
257
  if (objectUrl !== null) {
@@ -237,6 +264,7 @@ function createMseController(options) {
237
264
  element = null;
238
265
  mediaSource = null;
239
266
  managed = false;
267
+ attachOptions = void 0;
240
268
  pendingEndOfStream = null;
241
269
  pendingDuration = null;
242
270
  pendingLiveRange = null;
@@ -246,11 +274,18 @@ function createMseController(options) {
246
274
  const ms = mediaSource;
247
275
  if (ms === null) return false;
248
276
  try {
277
+ var _heldAppends$get;
249
278
  const sb = ms.addSourceBuffer(type);
279
+ const queue = createQueue(sbId, sb);
250
280
  buffers.set(sbId, {
251
281
  sb,
252
- queue: createQueue(sbId, sb)
282
+ queue
283
+ });
284
+ for (const data of (_heldAppends$get = heldAppends.get(sbId)) !== null && _heldAppends$get !== void 0 ? _heldAppends$get : []) queue.enqueue({
285
+ op: "append",
286
+ data
253
287
  });
288
+ heldAppends.delete(sbId);
254
289
  absorb({
255
290
  type: "SOURCEBUFFER_CREATED",
256
291
  sbId,
@@ -258,6 +293,7 @@ function createMseController(options) {
258
293
  });
259
294
  return true;
260
295
  } catch (err) {
296
+ heldAppends.delete(sbId);
261
297
  absorb({
262
298
  type: "SOURCEBUFFER_ERROR",
263
299
  sbId,
@@ -279,8 +315,8 @@ function createMseController(options) {
279
315
  * Hands bytes to the buffer's queue, first opening a deferred buffer with
280
316
  * the type the probe reads from them, or with the bare type when the probe
281
317
  * reads nothing, which is what an unprobed composition does from the
282
- * start. Bytes for a buffer that does not exist and is not deferred are
283
- * dropped, as before.
318
+ * start. Bytes whose buffer is still waiting for sourceopen are held until
319
+ * it opens. Bytes for a buffer that was never requested are dropped.
284
320
  */
285
321
  function enqueueAppend(sbId, data) {
286
322
  var _buffers$get;
@@ -290,6 +326,12 @@ function createMseController(options) {
290
326
  deferred.delete(sbId);
291
327
  if (!open(sbId, (_options$inferType = (_options$inferType2 = options.inferType) === null || _options$inferType2 === void 0 ? void 0 : _options$inferType2.call(options, new Uint8Array(data))) !== null && _options$inferType !== void 0 ? _options$inferType : bare)) return;
292
328
  }
329
+ if (!buffers.has(sbId) && pendingCreates.some((create) => create.sbId === sbId)) {
330
+ const held = heldAppends.get(sbId);
331
+ if (held === void 0) heldAppends.set(sbId, [data]);
332
+ else held.push(data);
333
+ return;
334
+ }
293
335
  (_buffers$get = buffers.get(sbId)) === null || _buffers$get === void 0 || _buffers$get.queue.enqueue({
294
336
  op: "append",
295
337
  data
@@ -303,6 +345,7 @@ function createMseController(options) {
303
345
  return;
304
346
  }
305
347
  if (ms === null || ms.readyState !== "open") {
348
+ heldAppends.delete(effect.sbId);
306
349
  absorb({
307
350
  type: "SOURCEBUFFER_ERROR",
308
351
  sbId: effect.sbId,
@@ -329,8 +372,9 @@ function createMseController(options) {
329
372
  runner.register("resetSource", () => {
330
373
  const el = element;
331
374
  if (el === null) return void 0;
375
+ const held = attachOptions;
332
376
  detach();
333
- attach(el);
377
+ attach(el, held);
334
378
  });
335
379
  runner.register("append", (effect) => {
336
380
  var _appendChains$get;
@@ -429,11 +473,15 @@ function createMseController(options) {
429
473
  const entry = buffers.get(sbId);
430
474
  if (entry === void 0) return [];
431
475
  const out = [];
432
- const { buffered } = entry.sb;
433
- for (let i = 0; i < buffered.length; i += 1) out.push({
434
- start: buffered.start(i),
435
- end: buffered.end(i)
436
- });
476
+ try {
477
+ const { buffered } = entry.sb;
478
+ for (let i = 0; i < buffered.length; i += 1) out.push({
479
+ start: buffered.start(i),
480
+ end: buffered.end(i)
481
+ });
482
+ } catch (_unused7) {
483
+ return [];
484
+ }
437
485
  return out;
438
486
  },
439
487
  diagnostics() {
@@ -1,13 +1,14 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
2
  import { normalizeMimeType } from "./mime.js";
3
3
  import { segmentAtTime } from "./timeline.js";
4
4
  import { bufferedEndFrom, schedule } from "./scheduler.js";
5
5
  import { canSwitchTo, codecFamily, createArbiter, planPinApply } from "./rendition-select.js";
6
6
  import { sbIdFor } from "./sinks/mse-sink.js";
7
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectWithoutProperties.js";
7
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectWithoutProperties.js";
8
8
  //#region src/kernel/reducer.ts
9
- const _excluded = ["repeat"];
10
- const _excluded2 = ["initFor"];
9
+ const _excluded = ["pendingInit"];
10
+ const _excluded2 = ["repeat"];
11
+ const _excluded3 = ["initFor"];
11
12
  /**
12
13
  * The default tuning. Every value is overridable through the `config`
13
14
  * parameters of `initialState` and `createReducer`; these are starting
@@ -71,6 +72,19 @@ function initialState(config) {
71
72
  }
72
73
  /** Gap width treated as continuous when measuring buffered spans. */
73
74
  const GAP_TOLERANCE = .25;
75
+ /** Drops one buffer's held init. */
76
+ function withoutPendingInit(pending, sbId) {
77
+ if (pending === void 0 || !pending.has(sbId)) return pending;
78
+ const next = new Map(pending);
79
+ next.delete(sbId);
80
+ return next.size === 0 ? void 0 : next;
81
+ }
82
+ /** Writes held inits back into a scheduling slice; the field stays absent while empty. */
83
+ function withPendingInit(scheduling, pending) {
84
+ if (pending !== void 0 && pending.size > 0) return _objectSpread2(_objectSpread2({}, scheduling), {}, { pendingInit: pending });
85
+ const { pendingInit: _pendingInit } = scheduling;
86
+ return _objectWithoutProperties(scheduling, _excluded);
87
+ }
74
88
  /** The codecs part of an MSE type string ('video/mp4; codecs="avc1.42c00d"' -> 'avc1.42c00d'). */
75
89
  function bufferCodecString(type) {
76
90
  var _match$;
@@ -123,7 +137,7 @@ function bumped(quality) {
123
137
  function clearRepeat(scheduling) {
124
138
  if (scheduling.repeat === void 0) return scheduling;
125
139
  const { repeat: _repeat } = scheduling;
126
- return _objectWithoutProperties(scheduling, _excluded);
140
+ return _objectWithoutProperties(scheduling, _excluded2);
127
141
  }
128
142
  function ewma(previous, sample, alpha) {
129
143
  return previous === 0 ? sample : alpha * sample + (1 - alpha) * previous;
@@ -273,6 +287,17 @@ function reduceCommand(state, msg, cfg, hooks) {
273
287
  ...reset
274
288
  ]];
275
289
  }
290
+ case "SUSPEND": {
291
+ if (state.lifecycle.phase !== "ready") return reject(state, msg.type, "not ready");
292
+ const [next, aborts] = abortInflight(state);
293
+ return [_objectSpread2(_objectSpread2({}, next), {}, {
294
+ lifecycle: { phase: "suspended" },
295
+ live: null
296
+ }), aborts];
297
+ }
298
+ case "RESUME":
299
+ if (state.lifecycle.phase !== "suspended") return reject(state, msg.type, "not suspended");
300
+ return driveScheduling(_objectSpread2(_objectSpread2({}, state), {}, { lifecycle: { phase: "ready" } }), hooks, cfg);
276
301
  case "SEEK": {
277
302
  if (state.presentation === null) return reject(state, msg.type, "no source");
278
303
  const [next, aborts] = abortInflight(state);
@@ -322,7 +347,7 @@ function reduceCommand(state, msg, cfg, hooks) {
322
347
  });
323
348
  for (const effect of plan.effects) if (effect.kind !== "seekElement" || track.contentType === "video") effects.push(effect);
324
349
  const next = new Map(state.buffers);
325
- const { initFor: _initFor } = buffer, rest = _objectWithoutProperties(buffer, _excluded2);
350
+ const { initFor: _initFor } = buffer, rest = _objectWithoutProperties(buffer, _excluded3);
326
351
  next.set(sbId, rest);
327
352
  buffers = next;
328
353
  const pruned = new Map(state.scheduling.inflight);
@@ -501,6 +526,7 @@ function reduceFact(state, msg, cfg, hooks) {
501
526
  throughputFastEwma: ewma(state.stats.throughputFastEwma, sampleBps, cfg.ewmaFastAlpha)
502
527
  };
503
528
  let buffers = state.buffers;
529
+ let pendingInit = state.scheduling.pendingInit;
504
530
  let timeline = state.timeline;
505
531
  let quality = state.quality;
506
532
  let cues = state.cues;
@@ -552,11 +578,15 @@ function reduceFact(state, msg, cfg, hooks) {
552
578
  codecs: targetCodecs
553
579
  }));
554
580
  buffers = nextBuffers;
581
+ pendingInit = withoutPendingInit(pendingInit, matched.sbId);
582
+ } else {
583
+ var _pendingInit2;
584
+ pendingInit = new Map((_pendingInit2 = pendingInit) !== null && _pendingInit2 !== void 0 ? _pendingInit2 : []).set(matched.sbId, matched.renditionId);
555
585
  }
556
586
  }
557
587
  const initFor = (_buffers$get = buffers.get(matched.sbId)) === null || _buffers$get === void 0 ? void 0 : _buffers$get.initFor;
558
588
  if (matched.seq >= 0 && matched.renditionId !== void 0 && initFor !== void 0 && initFor !== matched.renditionId) return [_objectSpread2(_objectSpread2({}, state), {}, {
559
- scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }),
589
+ scheduling: withPendingInit(_objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }), pendingInit),
560
590
  stats,
561
591
  buffers,
562
592
  cues
@@ -605,7 +635,7 @@ function reduceFact(state, msg, cfg, hooks) {
605
635
  timeline,
606
636
  quality,
607
637
  cues,
608
- scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }),
638
+ scheduling: withPendingInit(_objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight }), pendingInit),
609
639
  stats
610
640
  }), effects];
611
641
  }
@@ -664,13 +694,19 @@ function reduceFact(state, msg, cfg, hooks) {
664
694
  }), failEffects];
665
695
  }
666
696
  case "SOURCEBUFFER_CREATED": {
697
+ var _state$scheduling$pen;
667
698
  const buffers = new Map(state.buffers);
668
- buffers.set(msg.sbId, {
699
+ const held = (_state$scheduling$pen = state.scheduling.pendingInit) === null || _state$scheduling$pen === void 0 ? void 0 : _state$scheduling$pen.get(msg.sbId);
700
+ buffers.set(msg.sbId, _objectSpread2({
669
701
  codecs: msg.codecs,
670
702
  ranges: [],
671
703
  pendingAppends: 0
672
- });
673
- return [_objectSpread2(_objectSpread2({}, state), {}, { buffers }), []];
704
+ }, held !== void 0 ? { initFor: held } : {}));
705
+ const scheduling = withPendingInit(state.scheduling, withoutPendingInit(state.scheduling.pendingInit, msg.sbId));
706
+ return [_objectSpread2(_objectSpread2({}, state), {}, {
707
+ buffers,
708
+ scheduling
709
+ }), []];
674
710
  }
675
711
  case "SOURCEBUFFER_UPDATEEND": {
676
712
  const buffer = state.buffers.get(msg.sbId);
@@ -692,6 +728,7 @@ function reduceFact(state, msg, cfg, hooks) {
692
728
  const count = ((_state$bufferErrors$g = state.bufferErrors.get(msg.sbId)) !== null && _state$bufferErrors$g !== void 0 ? _state$bufferErrors$g : 0) + 1;
693
729
  const bufferErrors = new Map(state.bufferErrors);
694
730
  bufferErrors.set(msg.sbId, count);
731
+ const scheduling = withPendingInit(state.scheduling, withoutPendingInit(state.scheduling.pendingInit, msg.sbId));
695
732
  const fatal = msg.error.fatal || count >= cfg.bufferErrorLimit;
696
733
  const phase = fatal ? "error" : state.lifecycle.phase;
697
734
  const effects = [{
@@ -720,7 +757,7 @@ function reduceFact(state, msg, cfg, hooks) {
720
757
  return [_objectSpread2(_objectSpread2({}, state), {}, {
721
758
  bufferErrors,
722
759
  lifecycle: { phase },
723
- scheduling: _objectSpread2(_objectSpread2({}, state.scheduling), {}, { inflight })
760
+ scheduling: _objectSpread2(_objectSpread2({}, scheduling), {}, { inflight })
724
761
  }), effects];
725
762
  }
726
763
  case "QUOTA_EXCEEDED": {
@@ -877,7 +914,8 @@ function driveScheduling(state, hooks, cfg) {
877
914
  });
878
915
  }
879
916
  if (rendition.init !== void 0 && ((_state$buffers$get4 = state.buffers.get(sbId)) === null || _state$buffers$get4 === void 0 ? void 0 : _state$buffers$get4.initFor) !== rendition.id && inflight.length === 0) {
880
- initFetches.push({
917
+ var _state$scheduling$pen2;
918
+ if (((_state$scheduling$pen2 = state.scheduling.pendingInit) === null || _state$scheduling$pen2 === void 0 ? void 0 : _state$scheduling$pen2.get(sbId)) !== rendition.id) initFetches.push({
881
919
  trackId,
882
920
  sbId,
883
921
  rendition: rendition.id,
@@ -1006,6 +1044,8 @@ const COMMAND_TYPES = {
1006
1044
  DETACH: true,
1007
1045
  LOAD: true,
1008
1046
  UNLOAD: true,
1047
+ SUSPEND: true,
1048
+ RESUME: true,
1009
1049
  SEEK: true,
1010
1050
  SEEK_TO_LIVE_EDGE: true,
1011
1051
  DESELECT_TRACK: true,
@@ -1033,6 +1073,7 @@ function createReducer(slices, config, hooks = {}) {
1033
1073
  const DRIVING_FACTS = /* @__PURE__ */ new Set([
1034
1074
  "MANIFEST_LOADED",
1035
1075
  "SEGMENT_LOADED",
1076
+ "SOURCEBUFFER_CREATED",
1036
1077
  "SOURCEBUFFER_UPDATEEND",
1037
1078
  "SEEKING",
1038
1079
  "SEEKED",
@@ -1042,6 +1083,7 @@ function createReducer(slices, config, hooks = {}) {
1042
1083
  return (state, msg) => {
1043
1084
  const manifestRequest = !isCommand(msg) && msg.type === "SEGMENT_LOADED" ? manifestRequestFor(state, msg) : null;
1044
1085
  let [next, effects] = isCommand(msg) ? reduceCommand(state, msg, cfg, hooks) : reduceFact(state, msg, cfg, hooks);
1086
+ if (isCommand(msg) && effects.some((effect) => effect.kind === "emit" && effect.event === "command:rejected")) return [next, effects];
1045
1087
  if (!isCommand(msg) && DRIVING_FACTS.has(msg.type)) {
1046
1088
  const [driven, driveEffects] = driveScheduling(next, hooks, cfg);
1047
1089
  next = driven;
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
2
  import { segmentAtTime } from "./timeline.js";
3
3
  import { bufferedEndFrom } from "./scheduler.js";
4
4
  //#region src/kernel/rendition-select.ts
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
2
  import { buildEpochs, epochForSeq, segmentAtTime, timestampOffsetFor } from "./timeline.js";
3
3
  //#region src/kernel/scheduler.ts
4
4
  const DEFAULT_GAP_TOLERANCE = .25;
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.149.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 _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
2
- import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/asyncToGenerator.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/asyncToGenerator.js";
3
3
  //#region src/kernel/transport.ts
4
4
  const DEFAULT_RETRY_POLICY = {
5
5
  maxAttempts: 3,
@@ -1,5 +1,5 @@
1
- import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
2
- import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectWithoutProperties.js";
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectWithoutProperties.js";
3
3
  import { mattebox } from "../index.js";
4
4
  //#region src/presets/define.ts
5
5
  const _excluded = ["stages", "without"];
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
2
  import { normalizeMimeType } from "../../kernel/mime.js";
3
3
  import { mergeSidx, parse, sidxToSegments } from "./parse.js";
4
4
  //#region src/protocols/dash-cmaf/index.ts
@@ -122,7 +122,7 @@ const reduceDash = (slice, msg, kernel) => {
122
122
  presentation: merged
123
123
  })]];
124
124
  }
125
- if (msg.type === "MANIFEST_LOADED" || msg.type === "TIME_UPDATE") {
125
+ if ((msg.type === "MANIFEST_LOADED" || msg.type === "TIME_UPDATE" || msg.type === "RESUME") && kernel.lifecycle.phase !== "suspended") {
126
126
  const needed = neededIndexes(kernel).filter((rendition) => !Object.values(state.pending).includes(rendition.id));
127
127
  if (needed.length === 0) return [state, []];
128
128
  const effects = [];
@@ -1,4 +1,4 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.148.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
2
  import { findBox, parseSidx } from "../../containers/mp4-box/index.js";
3
3
  //#region src/protocols/dash-cmaf/parse.ts
4
4
  /**