@mattebox/player 0.12.0 → 0.13.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.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Break marks: where the programme's ad breaks are, for the seek bar. Each
3
+ * owner gives its own, such as `@mattebox/player-ads` for the breaks the
4
+ * stream and the ad schedule name, so one owner never replaces another's.
5
+ * The owner clears its marks when its programme ends.
6
+ */
7
+ /** One break on the programme's timeline. */
8
+ export interface BreakMark {
9
+ /** Programme seconds. */
10
+ readonly start: number;
11
+ /** The end of the span it replaces, when it replaces one. */
12
+ readonly end?: number;
13
+ /** It played and plays no more: the seek bar draws it faded. */
14
+ readonly played?: boolean;
15
+ }
16
+ export interface BreakMarks {
17
+ /** Every owner's marks, by start. */
18
+ readonly list: readonly BreakMark[];
19
+ /** Sets the marks of `owner`. An empty list removes them. */
20
+ set(owner: string, marks: readonly BreakMark[]): void;
21
+ }
22
+ /** Break marks; `emit` reports each change as `breakschange`, with the list. */
23
+ export declare function createBreakMarks(emit: (list: readonly BreakMark[]) => void): BreakMarks;
24
+ //# sourceMappingURL=breaks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breaks.d.ts","sourceRoot":"","sources":["../../src/controls/breaks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,6CAA6C;AAC7C,MAAM,WAAW,SAAS;IACxB,yBAAyB;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,CAAC;IACpC,6DAA6D;IAC7D,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CAAC;CACvD;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,KAAK,IAAI,GAAG,UAAU,CAcvF"}
@@ -0,0 +1,20 @@
1
+ // src/controls/breaks.ts
2
+ /** Break marks; `emit` reports each change as `breakschange`, with the list. */
3
+ function createBreakMarks(emit) {
4
+ const owners = /* @__PURE__ */ new Map();
5
+ let list = [];
6
+ return {
7
+ get list() {
8
+ return list;
9
+ },
10
+ set(owner, marks) {
11
+ if (marks.length === 0) owners.delete(owner);
12
+ else owners.set(owner, marks);
13
+ list = [...owners.values()].flat().sort((a, b) => a.start - b.start);
14
+ emit(list);
15
+ }
16
+ };
17
+ }
18
+ export { createBreakMarks };
19
+
20
+ //# sourceMappingURL=breaks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breaks.js","names":[],"sources":["../../src/controls/breaks.ts"],"sourcesContent":["/**\n * Break marks: where the programme's ad breaks are, for the seek bar. Each\n * owner gives its own, such as `@mattebox/player-ads` for the breaks the\n * stream and the ad schedule name, so one owner never replaces another's.\n * The owner clears its marks when its programme ends.\n */\n\n/** One break on the programme's timeline. */\nexport interface BreakMark {\n /** Programme seconds. */\n readonly start: number;\n /** The end of the span it replaces, when it replaces one. */\n readonly end?: number;\n /** It played and plays no more: the seek bar draws it faded. */\n readonly played?: boolean;\n}\n\nexport interface BreakMarks {\n /** Every owner's marks, by start. */\n readonly list: readonly BreakMark[];\n /** Sets the marks of `owner`. An empty list removes them. */\n set(owner: string, marks: readonly BreakMark[]): void;\n}\n\n/** Break marks; `emit` reports each change as `breakschange`, with the list. */\nexport function createBreakMarks(emit: (list: readonly BreakMark[]) => void): BreakMarks {\n const owners = new Map<string, readonly BreakMark[]>();\n let list: readonly BreakMark[] = [];\n return {\n get list() {\n return list;\n },\n set(owner, marks) {\n if (marks.length === 0) owners.delete(owner);\n else owners.set(owner, marks);\n list = [...owners.values()].flat().sort((a, b) => a.start - b.start);\n emit(list);\n },\n };\n}\n"],"mappings":";;AAyBA,SAAgB,iBAAiB,MAAwD;CACvF,MAAM,yBAAS,IAAI,IAAkC;CACrD,IAAI,OAA6B,CAAC;CAClC,OAAO;EACL,IAAI,OAAO;GACT,OAAO;EACT;EACA,IAAI,OAAO,OAAO;GAChB,IAAI,MAAM,WAAW,GAAG,OAAO,OAAO,KAAK;QACtC,OAAO,IAAI,OAAO,KAAK;GAC5B,OAAO,CAAC,GAAG,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;GACnE,KAAK,IAAI;EACX;CACF;AACF"}
@@ -1,7 +1,7 @@
1
1
  export type { Connector, ConnectorSource, Programme, ProgrammeMetadata, ProgrammeSource, Resolution, Source, SourceDrm, } from '@mattebox/player-core';
2
2
  export type { MatteboxPlayerOptions } from './element.js';
3
3
  export { MatteboxPlayerElement } from './element.js';
4
- export type { Block, PlayerHost } from './host.js';
4
+ export type { Block, PlayerAddon, PlayerHost } from './host.js';
5
5
  export type { Text } from './text.js';
6
6
  export type { Tracker, Trackers } from './trackers.js';
7
7
  //# sourceMappingURL=element-entry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"element-entry.d.ts","sourceRoot":"","sources":["../src/element-entry.ts"],"names":[],"mappings":"AAOA,YAAY,EACV,SAAS,EACT,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACnD,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"element-entry.d.ts","sourceRoot":"","sources":["../src/element-entry.ts"],"names":[],"mappings":"AAOA,YAAY,EACV,SAAS,EACT,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"element-entry.js","names":[],"sources":["../src/element-entry.ts"],"sourcesContent":["/**\n * `@mattebox/player/element`: registers <mattebox-player> and nothing else.\n * A page that takes this entry writes its own composition from the\n * `@mattebox/player/elements/*` entries it imports, and carries only those.\n */\nimport { MatteboxPlayerElement } from './element.js';\n\nexport type {\n Connector,\n ConnectorSource,\n Programme,\n ProgrammeMetadata,\n ProgrammeSource,\n Resolution,\n Source,\n SourceDrm,\n} from '@mattebox/player-core';\nexport type { MatteboxPlayerOptions } from './element.js';\nexport { MatteboxPlayerElement } from './element.js';\nexport type { Block, PlayerHost } from './host.js';\nexport type { Text } from './text.js';\nexport type { Tracker, Trackers } from './trackers.js';\n\nMatteboxPlayerElement.define();\n"],"mappings":";;;;;;;AAuBA,sBAAsB,OAAO"}
1
+ {"version":3,"file":"element-entry.js","names":[],"sources":["../src/element-entry.ts"],"sourcesContent":["/**\n * `@mattebox/player/element`: registers <mattebox-player> and nothing else.\n * A page that takes this entry writes its own composition from the\n * `@mattebox/player/elements/*` entries it imports, and carries only those.\n */\nimport { MatteboxPlayerElement } from './element.js';\n\nexport type {\n Connector,\n ConnectorSource,\n Programme,\n ProgrammeMetadata,\n ProgrammeSource,\n Resolution,\n Source,\n SourceDrm,\n} from '@mattebox/player-core';\nexport type { MatteboxPlayerOptions } from './element.js';\nexport { MatteboxPlayerElement } from './element.js';\nexport type { Block, PlayerAddon, PlayerHost } from './host.js';\nexport type { Text } from './text.js';\nexport type { Tracker, Trackers } from './trackers.js';\n\nMatteboxPlayerElement.define();\n"],"mappings":";;;;;;;AAuBA,sBAAsB,OAAO"}
package/dist/element.d.ts CHANGED
@@ -20,8 +20,9 @@
20
20
  import type { Connector, Handler, Player, PlayerError, Programme, ProgrammeSource, Session, Source, SourceVideoTrack } from '@mattebox/player-core';
21
21
  import type { KernelConfig, Mattebox, Stage } from 'mattebox';
22
22
  import type { AttachEmeOptions } from 'mattebox/eme';
23
+ import { type BreakMarks } from './controls/breaks.js';
23
24
  import type { Marker, Markers } from './controls/markers.js';
24
- import type { Block, PlayerHost } from './host.js';
25
+ import type { Block, PlayerAddon, PlayerHost } from './host.js';
25
26
  import type { LocaleSource } from './locales.js';
26
27
  import type { Messages } from './messages.js';
27
28
  import type { Tracker, Trackers } from './trackers.js';
@@ -78,6 +79,13 @@ export interface MatteboxPlayerOptions {
78
79
  * plays. Kept with `handlers`.
79
80
  */
80
81
  readonly connectors?: readonly Connector[];
82
+ /**
83
+ * Packages that add to every player, such as `ads()` from
84
+ * `@mattebox/player-ads`: their stages join the stack, and each runs on
85
+ * every player that connects. Ignored with `handlers`, apart from what
86
+ * they run on the player.
87
+ */
88
+ readonly addons?: readonly PlayerAddon[];
81
89
  }
82
90
  /**
83
91
  * The interface above merges only `addEventListener` and `removeEventListener`
@@ -126,6 +134,7 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
126
134
  /** Stops listening to the current engine's track selection. */
127
135
  private offTracks;
128
136
  private readonly marks;
137
+ private readonly breakMarks;
129
138
  /** The chapters track element, while the `chapters` attribute names one and the engine takes none. */
130
139
  private track;
131
140
  /** The chapters URL the current session's engine was given, or null. */
@@ -153,6 +162,10 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
153
162
  /** The video waits for data: `waiting`, set on `waiting`, cleared once it can play. */
154
163
  private waiting;
155
164
  private offs;
165
+ /** Where `interrupt` left the programme: its time, whether it played, its tracks. */
166
+ private interruption;
167
+ /** The add-ons attached to this player, with what each returned, run when it leaves the page. */
168
+ private attached;
156
169
  /** Everything the element does to the player runs here, so it runs in order. */
157
170
  private queue;
158
171
  /** Whether a run is queued and not yet started, so a burst of changes loads once. */
@@ -172,6 +185,8 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
172
185
  get video(): HTMLVideoElement;
173
186
  /** The ranges the page named in this source: credits to skip, parts that must not play. */
174
187
  get markers(): Markers;
188
+ /** Where the programme's ad breaks are, which the seek bar draws: each add-on gives its own. */
189
+ get breaks(): BreakMarks;
175
190
  /**
176
191
  * The sources to try in order, set from script. The `src` attribute wins
177
192
  * over them, and they win over the `<source>` children. Setting them
@@ -211,6 +226,29 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
211
226
  * replaces it.
212
227
  */
213
228
  switchSource(source: Source): void;
229
+ /**
230
+ * Plays `source` on the video in the programme's place, such as an ad of
231
+ * `@mattebox/player-ads`. The programme, its markers and its trackers
232
+ * stay, no `sourcechange` fires, and the controls drive the source as
233
+ * they drive the programme. An error of the source is not the
234
+ * programme's: listen to the video. `resume()` plays the programme again
235
+ * where it stopped. Resolves once the source is loaded; rejects when no
236
+ * handler plays it.
237
+ */
238
+ interrupt(source: Source): Promise<void>;
239
+ /**
240
+ * Plays the programme again where `interrupt` left it, in the play state
241
+ * it had, or as `options` says: `at` another position, such as its end
242
+ * after a post-roll, and `playing`.
243
+ */
244
+ resume(options?: {
245
+ readonly at?: number | null;
246
+ readonly playing?: boolean;
247
+ }): Promise<void>;
248
+ /** `interrupt` plays in the programme's place. */
249
+ get interrupted(): boolean;
250
+ /** Runs `task` in the element's queue, and says how it went. */
251
+ private queued;
214
252
  /** The other versions of the picture the source names at their own URLs, for the video menu. */
215
253
  get videoSources(): readonly SourceVideoTrack[];
216
254
  /** The version of `videoSources` that plays, or null for the source itself. */
@@ -276,6 +314,13 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
276
314
  /** Puts the block on the row under the video, under native controls. */
277
315
  private showBlock;
278
316
  connectedCallback(): void;
317
+ /**
318
+ * Attaches each add-on of the options once. At connect, and again at each
319
+ * load: a page that imports the player registers it before its own
320
+ * `define()` gives the add-ons, and the players already on the page
321
+ * connected then.
322
+ */
323
+ private attachAddons;
279
324
  /** Sets `layout` from the element's box, unless the page fixed it. */
280
325
  private measure;
281
326
  /** The two states the video does not hold: whether it has played once, and whether it waits for data. */
@@ -1 +1 @@
1
- {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAS,MAAM,eAAe,CAAC;AAQrD,OAAO,KAAK,EAAE,OAAO,EAAiB,QAAQ,EAAE,MAAM,eAAe,CAAC;AA+HtE;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC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wEAAwE;IACxE,OAAO,CAAC,SAAS;IAMjB,iBAAiB,IAAI,IAAI;IAgBzB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAMpB,sEAAsE;IACtE,OAAO,CAAC,OAAO;IAmBf,yGAAyG;IACzG,OAAO,CAAC,IAAI;IAsBZ,0EAA0E;IAC1E,OAAO,CAAC,IAAI;IAgBZ;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAqCd,oFAAoF;IACpF,OAAO,CAAC,OAAO;IAqBf;;;;;;OAMG;IACH,OAAO,CAAC,KAAK;IAUb,oBAAoB,IAAI,IAAI;IAkB5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IA6C5C;;;;OAIG;IACH,OAAO,CAAC,IAAI;IAmBZ,0GAA0G;IAC1G,OAAO,CAAC,QAAQ;IAmChB,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,OAAO;IAIf;;;;OAIG;IACH,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,MAAM;YAgBA,GAAG;IAsBjB;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAwCd,oGAAoG;IACpG,OAAO,CAAC,KAAK;YAiBC,MAAM;IAqCpB;;;;OAIG;IACH,OAAO,KAAK,OAAO,GAElB;YAEa,KAAK;IA0CnB;;;;OAIG;IACH,OAAO,CAAC,GAAG;IAeX,8EAA8E;IAC9E,OAAO,CAAC,SAAS;IA6BjB,OAAO,CAAC,OAAO;YAID,QAAQ;IAKtB,mFAAmF;YACrE,OAAO;CAMtB"}
package/dist/element.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { announcer } from "./announcer.js";
2
+ import { createBreakMarks } from "./controls/breaks.js";
2
3
  import { createMarkers } from "./controls/markers.js";
3
4
  import { languageName } from "./controls/track-names.js";
4
5
  import { addLocale, load, onLocales, registered, wordsNow } from "./locales.js";
@@ -188,6 +189,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
188
189
  this.started = false;
189
190
  this.waiting = false;
190
191
  this.offs = [];
192
+ this.attached = /* @__PURE__ */ new Map();
193
+ this.interruption = null;
191
194
  this.queue = Promise.resolve();
192
195
  this.pending = false;
193
196
  this.original = null;
@@ -221,6 +224,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
221
224
  this.reflect();
222
225
  });
223
226
  this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));
227
+ this.breakMarks = createBreakMarks((list) => this.emit("breakschange", list));
224
228
  this.tracking = createTrackers(this, () => this.emit("trackerschange", this.tracking.list));
225
229
  this.stage = document.createElement("div");
226
230
  this.stage.setAttribute("part", "stage");
@@ -246,6 +250,10 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
246
250
  get markers() {
247
251
  return this.marks;
248
252
  }
253
+ /** Where the programme's ad breaks are, which the seek bar draws: each add-on gives its own. */
254
+ get breaks() {
255
+ return this.breakMarks;
256
+ }
249
257
  /**
250
258
  * The sources to try in order, set from script. The `src` attribute wins
251
259
  * over them, and they win over the `<source>` children. Setting them
@@ -257,6 +265,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
257
265
  set sources(value) {
258
266
  this.list = value;
259
267
  if (this.marks.list.length > 0) this.marks.set([]);
268
+ this.interruption = null;
260
269
  this.unblock();
261
270
  this.reload();
262
271
  }
@@ -354,6 +363,58 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
354
363
  if (was !== null) this.emit("videosourcechange", null);
355
364
  this.swap(clean, at, playing, had, true);
356
365
  }
366
+ /**
367
+ * Plays `source` on the video in the programme's place, such as an ad of
368
+ * `@mattebox/player-ads`. The programme, its markers and its trackers
369
+ * stay, no `sourcechange` fires, and the controls drive the source as
370
+ * they drive the programme. An error of the source is not the
371
+ * programme's: listen to the video. `resume()` plays the programme again
372
+ * where it stopped. Resolves once the source is loaded; rejects when no
373
+ * handler plays it.
374
+ */
375
+ interrupt(source) {
376
+ const media = this.media;
377
+ this.interruption ??= {
378
+ at: Number.isFinite(media.duration) ? media.currentTime : null,
379
+ playing: !media.paused,
380
+ had: chosen(this.current?.engine ?? null)
381
+ };
382
+ return this.queued(async () => {
383
+ const core = await this.ensure();
384
+ await core.interrupt(source);
385
+ this.current = core.session;
386
+ media.play().catch(() => void 0);
387
+ });
388
+ }
389
+ /**
390
+ * Plays the programme again where `interrupt` left it, in the play state
391
+ * it had, or as `options` says: `at` another position, such as its end
392
+ * after a post-roll, and `playing`.
393
+ */
394
+ resume(options = {}) {
395
+ const left = this.interruption;
396
+ if (left === null) return Promise.resolve();
397
+ this.interruption = null;
398
+ const at = options.at === void 0 ? left.at : options.at;
399
+ const playing = options.playing ?? left.playing;
400
+ return this.queued(async () => {
401
+ const core = await this.ensure();
402
+ await core.resume(at ?? void 0);
403
+ this.current = core.session;
404
+ restore(this.current?.engine ?? null, left.had);
405
+ if (playing) this.media.play().catch(() => void 0);
406
+ });
407
+ }
408
+ /** `interrupt` plays in the programme's place. */
409
+ get interrupted() {
410
+ return this.interruption !== null;
411
+ }
412
+ /** Runs `task` in the element's queue, and says how it went. */
413
+ queued(task) {
414
+ return new Promise((resolve, reject) => {
415
+ this.enqueue(() => task().then(resolve, reject));
416
+ });
417
+ }
357
418
  /** The other versions of the picture the source names at their own URLs, for the video menu. */
358
419
  get videoSources() {
359
420
  return this.original?.videoTracks ?? [];
@@ -523,8 +584,18 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
523
584
  }
524
585
  this.measure();
525
586
  this.watchLanguage();
587
+ this.attachAddons();
526
588
  this.reload();
527
589
  }
590
+ /**
591
+ * Attaches each add-on of the options once. At connect, and again at each
592
+ * load: a page that imports the player registers it before its own
593
+ * `define()` gives the add-ons, and the players already on the page
594
+ * connected then.
595
+ */
596
+ attachAddons() {
597
+ for (const addon of this.options.addons ?? []) if (!this.attached.has(addon)) this.attached.set(addon, addon.attach?.(this));
598
+ }
528
599
  /** Sets `layout` from the element's box, unless the page fixed it. */
529
600
  measure() {
530
601
  if (this.fixed) return;
@@ -630,7 +701,10 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
630
701
  this.unwatch?.();
631
702
  this.unwatch = null;
632
703
  queueMicrotask(() => {
633
- if (!this.isConnected) this.enqueue(() => this.teardown());
704
+ if (this.isConnected) return;
705
+ for (const off of this.attached.values()) off?.();
706
+ this.attached.clear();
707
+ this.enqueue(() => this.teardown());
634
708
  });
635
709
  }
636
710
  attributeChangedCallback(name) {
@@ -665,6 +739,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
665
739
  if (name === "preset") this.enqueue(() => this.discard());
666
740
  if (name === "src" || name === "type") this.toggleAttribute("audio", this.audio());
667
741
  if (name === "src" && this.marks.list.length > 0) this.marks.set([]);
742
+ if (name === "src") this.interruption = null;
668
743
  if (name === "src") this.unblock();
669
744
  this.reload();
670
745
  }
@@ -859,13 +934,19 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
859
934
  if (this.options.handlers !== void 0) return this.options.handlers;
860
935
  const config = this.options.config === void 0 ? {} : { config: this.options.config };
861
936
  const native = (stages) => nativeHandler({
862
- prefer: (source, env) => this.getAttribute(NATIVE_HLS) !== "off" && preferNativeHls(source, env),
937
+ prefer: (source, env) => this.getAttribute(NATIVE_HLS) !== "off" && !(this.options.addons ?? []).some((addon) => addon.engine === true) && preferNativeHls(source, env),
863
938
  drm: () => this.drm(stages)
864
939
  });
865
- if (this.options.stages !== void 0) return [matteboxHandler({
866
- stages: this.options.stages,
867
- ...config
868
- }), native(() => this.options.stages ?? [])];
940
+ if (this.isConnected) this.attachAddons();
941
+ const added = (this.options.addons ?? []).flatMap((addon) => addon.stages?.() ?? []);
942
+ if (this.options.stages !== void 0) {
943
+ const own = this.options.stages;
944
+ const stages = [...own, ...added.filter((stage) => !own.some((o) => o.name === stage.name))];
945
+ return [matteboxHandler({
946
+ stages,
947
+ ...config
948
+ }), native(() => stages)];
949
+ }
869
950
  const name = this.getAttribute("preset") ?? DEFAULT_PRESET;
870
951
  const preset = await resolvePreset(name);
871
952
  if (preset === null) {
@@ -879,8 +960,10 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
879
960
  });
880
961
  return [nativeHandler()];
881
962
  }
963
+ const extra = added.length === 0 ? {} : { stages: added };
882
964
  return [matteboxHandler({
883
965
  preset,
966
+ ...extra,
884
967
  ...config,
885
968
  ...drmGuard()
886
969
  }), native(() => preset.stages())];