avbridge 1.0.0 → 2.0.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.
package/dist/element.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkF7YS2XOA_cjs = require('./chunk-F7YS2XOA.cjs');
3
+ var chunkTTV56KDB_cjs = require('./chunk-TTV56KDB.cjs');
4
4
  require('./chunk-Y5FYF5KG.cjs');
5
5
  require('./chunk-Z2FJ5TJC.cjs');
6
6
  require('./chunk-NZU7W256.cjs');
7
7
 
8
- // src/element/avbridge-player.ts
8
+ // src/element/avbridge-video.ts
9
9
  var PREFERRED_STRATEGY_VALUES = /* @__PURE__ */ new Set([
10
10
  "auto",
11
11
  "native",
@@ -13,15 +13,39 @@ var PREFERRED_STRATEGY_VALUES = /* @__PURE__ */ new Set([
13
13
  "hybrid",
14
14
  "fallback"
15
15
  ]);
16
+ var FORWARDED_VIDEO_EVENTS = [
17
+ "loadstart",
18
+ "loadedmetadata",
19
+ "loadeddata",
20
+ "canplay",
21
+ "canplaythrough",
22
+ "play",
23
+ "playing",
24
+ "pause",
25
+ "seeking",
26
+ "seeked",
27
+ "volumechange",
28
+ "ratechange",
29
+ "durationchange",
30
+ "waiting",
31
+ "stalled",
32
+ "emptied",
33
+ "resize",
34
+ "error"
35
+ ];
16
36
  var HTMLElementCtor = typeof HTMLElement !== "undefined" ? HTMLElement : class {
17
37
  };
18
- var AvbridgePlayerElement = class extends HTMLElementCtor {
38
+ var AvbridgeVideoElement = class extends HTMLElementCtor {
19
39
  static observedAttributes = [
20
40
  "src",
21
41
  "autoplay",
22
42
  "muted",
23
43
  "loop",
24
44
  "preload",
45
+ "poster",
46
+ "playsinline",
47
+ "crossorigin",
48
+ "disableremoteplayback",
25
49
  "diagnostics",
26
50
  "preferstrategy"
27
51
  ];
@@ -53,12 +77,21 @@ var AvbridgePlayerElement = class extends HTMLElementCtor {
53
77
  _strategyClass = null;
54
78
  _audioTracks = [];
55
79
  _subtitleTracks = [];
56
- /** Strategy preference (does not currently affect routing — reserved). */
80
+ /**
81
+ * Initial strategy preference. `"auto"` means "let the classifier decide";
82
+ * any other value is passed to `createPlayer({ initialStrategy })` and
83
+ * skips classification on the next bootstrap. Note that this only affects
84
+ * the *initial* pick — runtime fallback escalation still applies, so a
85
+ * preference of `"native"` may still escalate to remux/hybrid/fallback if
86
+ * native fails.
87
+ */
57
88
  _preferredStrategy = "auto";
58
89
  /** Set if currentTime was assigned before the player was ready. */
59
90
  _pendingSeek = null;
60
91
  /** Set if play() was called before the player was ready. */
61
92
  _pendingPlay = false;
93
+ /** MutationObserver tracking light-DOM `<track>` children. */
94
+ _trackObserver = null;
62
95
  // ── Construction & lifecycle ───────────────────────────────────────────
63
96
  constructor() {
64
97
  super();
@@ -72,9 +105,20 @@ var AvbridgePlayerElement = class extends HTMLElementCtor {
72
105
  if (this._destroyed) return;
73
106
  this._dispatch("progress", { buffered: this._videoEl.buffered });
74
107
  });
108
+ for (const eventName of FORWARDED_VIDEO_EVENTS) {
109
+ this._videoEl.addEventListener(eventName, () => {
110
+ if (this._destroyed) return;
111
+ this.dispatchEvent(new Event(eventName, { bubbles: false }));
112
+ });
113
+ }
75
114
  }
76
115
  connectedCallback() {
77
116
  if (this._destroyed) return;
117
+ this._syncTextTracks();
118
+ if (!this._trackObserver) {
119
+ this._trackObserver = new MutationObserver(() => this._syncTextTracks());
120
+ this._trackObserver.observe(this, { childList: true, subtree: false });
121
+ }
78
122
  const source = this._activeSource();
79
123
  if (source != null) {
80
124
  void this._bootstrap(source);
@@ -82,6 +126,10 @@ var AvbridgePlayerElement = class extends HTMLElementCtor {
82
126
  }
83
127
  disconnectedCallback() {
84
128
  if (this._destroyed) return;
129
+ if (this._trackObserver) {
130
+ this._trackObserver.disconnect();
131
+ this._trackObserver = null;
132
+ }
85
133
  this._bootstrapId++;
86
134
  void this._teardown();
87
135
  }
@@ -95,12 +143,16 @@ var AvbridgePlayerElement = class extends HTMLElementCtor {
95
143
  case "autoplay":
96
144
  case "muted":
97
145
  case "loop":
146
+ case "playsinline":
147
+ case "disableremoteplayback":
98
148
  if (newValue == null) this._videoEl.removeAttribute(name);
99
149
  else this._videoEl.setAttribute(name, newValue);
100
150
  break;
101
151
  case "preload":
102
- if (newValue == null) this._videoEl.removeAttribute("preload");
103
- else this._videoEl.setAttribute("preload", newValue);
152
+ case "poster":
153
+ case "crossorigin":
154
+ if (newValue == null) this._videoEl.removeAttribute(name);
155
+ else this._videoEl.setAttribute(name, newValue);
104
156
  break;
105
157
  case "diagnostics":
106
158
  break;
@@ -120,6 +172,26 @@ var AvbridgePlayerElement = class extends HTMLElementCtor {
120
172
  if (this._src != null) return this._src;
121
173
  return null;
122
174
  }
175
+ /**
176
+ * Mirror light-DOM `<track>` children into the shadow `<video>` so that
177
+ * the browser's native text-track machinery picks them up. Called on
178
+ * connect, on every mutation of light-DOM children, and once after each
179
+ * source change so newly-set tracks survive a fresh `<video>`.
180
+ *
181
+ * Strategy: clone the children. We don't move them because the user's
182
+ * code may still hold references to the originals (e.g. to set `default`).
183
+ * The shadow copies are throwaway — we wipe them on every sync.
184
+ */
185
+ _syncTextTracks() {
186
+ const existing = this._videoEl.querySelectorAll("track");
187
+ for (const t of Array.from(existing)) t.remove();
188
+ for (const child of Array.from(this.children)) {
189
+ if (child.tagName === "TRACK") {
190
+ const clone = child.cloneNode(true);
191
+ this._videoEl.appendChild(clone);
192
+ }
193
+ }
194
+ }
123
195
  /** Internal src setter — separate from the property setter so the
124
196
  * attributeChangedCallback can use it without re-entering reflection. */
125
197
  _setSrcInternal(value) {
@@ -150,9 +222,13 @@ var AvbridgePlayerElement = class extends HTMLElementCtor {
150
222
  this._dispatch("loadstart", {});
151
223
  let player;
152
224
  try {
153
- player = await chunkF7YS2XOA_cjs.createPlayer({
225
+ player = await chunkTTV56KDB_cjs.createPlayer({
154
226
  source,
155
- target: this._videoEl
227
+ target: this._videoEl,
228
+ // Honor the consumer's preferred initial strategy. "auto" means
229
+ // "let the classifier decide" — the createPlayer call simply doesn't
230
+ // pass initialStrategy in that case.
231
+ ...this._preferredStrategy !== "auto" ? { initialStrategy: this._preferredStrategy } : {}
156
232
  });
157
233
  } catch (err) {
158
234
  if (id !== this._bootstrapId || this._destroyed) return;
@@ -167,6 +243,7 @@ var AvbridgePlayerElement = class extends HTMLElementCtor {
167
243
  return;
168
244
  }
169
245
  this._player = player;
246
+ this._syncTextTracks();
170
247
  player.on("strategy", ({ strategy, reason }) => {
171
248
  const cls = player.getDiagnostics().strategyClass;
172
249
  this._strategy = strategy;
@@ -346,12 +423,87 @@ var AvbridgePlayerElement = class extends HTMLElementCtor {
346
423
  * `<video>.buffered` `TimeRanges` API. For the native and remux strategies
347
424
  * this reflects the underlying SourceBuffer / progressive download state.
348
425
  * For the hybrid and fallback (canvas-rendered) strategies it currently
349
- * returns an empty TimeRanges; v1.1 will synthesize a coarse range from
350
- * the decoder's read position.
426
+ * returns an empty TimeRanges; a future release will synthesize a coarse
427
+ * range from the decoder's read position.
351
428
  */
352
429
  get buffered() {
353
430
  return this._videoEl.buffered;
354
431
  }
432
+ // ── HTMLMediaElement parity ───────────────────────────────────────────
433
+ // Mirror the standard <video> surface so consumers can drop the element
434
+ // in as a <video> replacement. Each property is a thin passthrough to the
435
+ // shadow `<video>`.
436
+ get poster() {
437
+ return this._videoEl.poster;
438
+ }
439
+ set poster(value) {
440
+ if (value == null || value === "") this.removeAttribute("poster");
441
+ else this.setAttribute("poster", value);
442
+ }
443
+ get volume() {
444
+ return this._videoEl.volume;
445
+ }
446
+ set volume(value) {
447
+ this._videoEl.volume = value;
448
+ }
449
+ get playbackRate() {
450
+ return this._videoEl.playbackRate;
451
+ }
452
+ set playbackRate(value) {
453
+ this._videoEl.playbackRate = value;
454
+ }
455
+ get videoWidth() {
456
+ return this._videoEl.videoWidth;
457
+ }
458
+ get videoHeight() {
459
+ return this._videoEl.videoHeight;
460
+ }
461
+ get played() {
462
+ return this._videoEl.played;
463
+ }
464
+ get seekable() {
465
+ return this._videoEl.seekable;
466
+ }
467
+ get crossOrigin() {
468
+ return this._videoEl.crossOrigin;
469
+ }
470
+ set crossOrigin(value) {
471
+ if (value == null) this.removeAttribute("crossorigin");
472
+ else this.setAttribute("crossorigin", value);
473
+ }
474
+ get disableRemotePlayback() {
475
+ return this._videoEl.disableRemotePlayback;
476
+ }
477
+ set disableRemotePlayback(value) {
478
+ if (value) this.setAttribute("disableremoteplayback", "");
479
+ else this.removeAttribute("disableremoteplayback");
480
+ }
481
+ /**
482
+ * Native `HTMLMediaElement.canPlayType()` passthrough. Note that this
483
+ * answers about the *browser's* native support, not avbridge's full
484
+ * capabilities — avbridge can play many formats this method returns ""
485
+ * for, by routing them to the remux/hybrid/fallback strategies.
486
+ */
487
+ canPlayType(mimeType) {
488
+ return this._videoEl.canPlayType(mimeType);
489
+ }
490
+ /**
491
+ * **Escape hatch.** The underlying shadow-DOM `<video>` element.
492
+ *
493
+ * Use for native browser APIs the wrapper doesn't expose:
494
+ * - `el.videoElement.requestPictureInPicture()`
495
+ * - `el.videoElement.audioTracks` (browser native, not avbridge's track list)
496
+ * - direct integration with libraries that need a real HTMLVideoElement
497
+ *
498
+ * **Caveat:** When the active strategy is `"fallback"` or `"hybrid"`,
499
+ * frames are rendered to a canvas overlay, not into this `<video>`.
500
+ * APIs that depend on the actual pixels (Picture-in-Picture, captureStream)
501
+ * will not show the playing content in those modes. Check `el.strategy`
502
+ * before using such APIs.
503
+ */
504
+ get videoElement() {
505
+ return this._videoEl;
506
+ }
355
507
  get strategy() {
356
508
  return this._strategy;
357
509
  }
@@ -424,10 +576,10 @@ var AvbridgePlayerElement = class extends HTMLElementCtor {
424
576
  };
425
577
 
426
578
  // src/element.ts
427
- if (typeof customElements !== "undefined" && !customElements.get("avbridge-player")) {
428
- customElements.define("avbridge-player", AvbridgePlayerElement);
579
+ if (typeof customElements !== "undefined" && !customElements.get("avbridge-video")) {
580
+ customElements.define("avbridge-video", AvbridgeVideoElement);
429
581
  }
430
582
 
431
- exports.AvbridgePlayerElement = AvbridgePlayerElement;
583
+ exports.AvbridgeVideoElement = AvbridgeVideoElement;
432
584
  //# sourceMappingURL=element.cjs.map
433
585
  //# sourceMappingURL=element.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/element/avbridge-player.ts","../src/element.ts"],"names":["createPlayer"],"mappings":";;;;;;;;AA+BA,IAAM,yBAAA,uBAAgC,GAAA,CAAuB;AAAA,EAC3D,MAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAC,CAAA;AAeD,IAAM,eAAA,GACJ,OAAO,WAAA,KAAgB,WAAA,GACnB,cACC,MAAM;AAAC,CAAA;AASP,IAAM,qBAAA,GAAN,cAAoC,eAAA,CAAgB;AAAA,EACzD,OAAgB,kBAAA,GAAqB;AAAA,IACnC,KAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF;AAAA;AAAA;AAAA,EAKQ,QAAA;AAAA;AAAA,EAGA,OAAA,GAAgC,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhC,YAAA,GAAe,CAAA;AAAA;AAAA,EAGf,UAAA,GAAa,KAAA;AAAA;AAAA,EAGb,IAAA,GAAsB,IAAA;AAAA,EACtB,OAAA,GAA6B,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,wBAAA,GAA2B,KAAA;AAAA;AAAA,EAG3B,SAAA,GAAiC,IAAA;AAAA,EACjC,cAAA,GAAuC,IAAA;AAAA,EACvC,eAAiC,EAAC;AAAA,EAClC,kBAAuC,EAAC;AAAA;AAAA,EAGxC,kBAAA,GAAwC,MAAA;AAAA;AAAA,EAGxC,YAAA,GAA8B,IAAA;AAAA;AAAA,EAE9B,YAAA,GAAe,KAAA;AAAA;AAAA,EAIvB,WAAA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AA,EAAS,cAAA,EAAe,IAAK,IAAA,EAAM,CAAA;AAAA,EACxF;AACF;;;ACziBA,IAAI,OAAO,cAAA,KAAmB,WAAA,IAAe,CAAC,cAAA,CAAe,GAAA,CAAI,iBAAiB,CAAA,EAAG;AACnF,EAAA,cAAA,CAAe,MAAA,CAAO,mBAAmB,qBAAqB,CAAA;AAChE","file":"element.cjs","sourcesContent":["/**\n * `<avbridge-player>` — reference web component for the avbridge engine.\n *\n * This is a *thin* wrapper around `createPlayer()`. Its purpose is to:\n *\n * 1. Validate the public API by being a real consumer of it.\n * 2. Drive lifecycle correctness in the core via adversarial integration tests.\n * 3. Provide a drop-in player for users who don't want to wire `createPlayer()`\n * themselves.\n *\n * It is **not** a player UI framework. See `docs/dev/WEB_COMPONENT_SPEC.md`\n * for the full spec, lifecycle invariants, and edge case list.\n *\n * Phase A scope (this file): lifecycle scaffold only — `src` / `source` /\n * `currentTime` / `play` / `pause` / `load` / `destroy` / events. No built-in\n * controls. Shadow DOM contains a single `<video part=\"video\">`.\n */\n\nimport { createPlayer, type UnifiedPlayer } from \"../player.js\";\nimport type {\n MediaInput,\n StrategyName,\n StrategyClass,\n AudioTrackInfo,\n SubtitleTrackInfo,\n DiagnosticsSnapshot,\n} from \"../types.js\";\n\n/** Strategy preference passed via the `preferstrategy` attribute. */\ntype PreferredStrategy = \"auto\" | StrategyName;\n\nconst PREFERRED_STRATEGY_VALUES = new Set<PreferredStrategy>([\n \"auto\",\n \"native\",\n \"remux\",\n \"hybrid\",\n \"fallback\",\n]);\n\n/**\n * `HTMLElement` is a browser-only global. SSR frameworks (Next.js, Astro,\n * Remix, etc.) commonly import library modules on the server to extract\n * types or do tree-shaking, even if the user only ends up using them in\n * the browser. If we extended `HTMLElement` directly, the `class extends`\n * expression would be evaluated at module load time and crash in Node.\n *\n * The fix: in non-browser environments, fall back to an empty stub class.\n * The element is never *constructed* server-side (the registration in\n * `element.ts` is guarded by `typeof customElements !== \"undefined\"`), so\n * the stub is never instantiated — it just lets the class declaration\n * evaluate cleanly so the module can be imported anywhere.\n */\nconst HTMLElementCtor: typeof HTMLElement =\n typeof HTMLElement !== \"undefined\"\n ? HTMLElement\n : (class {} as unknown as typeof HTMLElement);\n\n/**\n * Custom element. Lifecycle correctness is enforced via a monotonically\n * increasing `_bootstrapId`: every async bootstrap captures the ID at start\n * and discards itself if the ID has changed by the time it resolves. This\n * single pattern handles disconnect-during-bootstrap, rapid src reassignment,\n * bootstrap races, and destroy-during-bootstrap.\n */\nexport class AvbridgePlayerElement extends HTMLElementCtor {\n static readonly observedAttributes = [\n \"src\",\n \"autoplay\",\n \"muted\",\n \"loop\",\n \"preload\",\n \"diagnostics\",\n \"preferstrategy\",\n ];\n\n // ── Internal state ─────────────────────────────────────────────────────\n\n /** The shadow DOM `<video>` element that strategies render into. */\n private _videoEl!: HTMLVideoElement;\n\n /** Active player session, if any. Cleared on teardown. */\n private _player: UnifiedPlayer | null = null;\n\n /**\n * Monotonic counter incremented on every (re)bootstrap. Async bootstrap\n * work captures the current ID; if it doesn't match by the time the work\n * resolves, the work is discarded.\n */\n private _bootstrapId = 0;\n\n /** True after destroy() — element is permanently unusable. */\n private _destroyed = false;\n\n /** Internal source state. Either string-form (src) OR rich (source). */\n private _src: string | null = null;\n private _source: MediaInput | null = null;\n\n /**\n * Set when the `source` property setter is in the middle of clearing the\n * `src` attribute as part of mutual exclusion. The attributeChangedCallback\n * checks this flag and skips its normal \"clear source\" side effect, which\n * would otherwise wipe the value we just set.\n */\n private _suppressSrcAttrCallback = false;\n\n /** Last-known runtime state surfaced via getters. */\n private _strategy: StrategyName | null = null;\n private _strategyClass: StrategyClass | null = null;\n private _audioTracks: AudioTrackInfo[] = [];\n private _subtitleTracks: SubtitleTrackInfo[] = [];\n\n /** Strategy preference (does not currently affect routing — reserved). */\n private _preferredStrategy: PreferredStrategy = \"auto\";\n\n /** Set if currentTime was assigned before the player was ready. */\n private _pendingSeek: number | null = null;\n /** Set if play() was called before the player was ready. */\n private _pendingPlay = false;\n\n // ── Construction & lifecycle ───────────────────────────────────────────\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: \"open\" });\n this._videoEl = document.createElement(\"video\");\n this._videoEl.setAttribute(\"part\", \"video\");\n this._videoEl.style.cssText = \"width:100%;height:100%;display:block;background:#000;\";\n this._videoEl.playsInline = true;\n root.appendChild(this._videoEl);\n\n // Forward the underlying <video>'s `progress` event so consumers can\n // observe buffered-range updates without reaching into the shadow DOM.\n // This works for native + remux (real video element with buffered\n // ranges) and is a no-op for hybrid/fallback (canvas-rendered, no\n // buffered ranges yet).\n this._videoEl.addEventListener(\"progress\", () => {\n if (this._destroyed) return;\n this._dispatch(\"progress\", { buffered: this._videoEl.buffered });\n });\n }\n\n connectedCallback(): void {\n if (this._destroyed) return;\n // Connection is the trigger for bootstrap. If we have a pending source\n // (set before connect), kick off bootstrap now.\n const source = this._activeSource();\n if (source != null) {\n void this._bootstrap(source);\n }\n }\n\n disconnectedCallback(): void {\n if (this._destroyed) return;\n // Bump the bootstrap token so any in-flight async work is invalidated\n // before we tear down. _teardown() also bumps but we want the bump to\n // happen synchronously here so any awaited promise that resolves\n // between `disconnect` and `_teardown` sees the new ID.\n this._bootstrapId++;\n void this._teardown();\n }\n\n attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void {\n if (this._destroyed) return;\n switch (name) {\n case \"src\":\n if (this._suppressSrcAttrCallback) break;\n this._setSrcInternal(newValue);\n break;\n case \"autoplay\":\n case \"muted\":\n case \"loop\":\n // Reflect onto the underlying <video> element.\n if (newValue == null) this._videoEl.removeAttribute(name);\n else this._videoEl.setAttribute(name, newValue);\n break;\n case \"preload\":\n if (newValue == null) this._videoEl.removeAttribute(\"preload\");\n else this._videoEl.setAttribute(\"preload\", newValue);\n break;\n case \"diagnostics\":\n // Phase A: no UI. Property is observable for users via getDiagnostics().\n break;\n case \"preferstrategy\":\n if (newValue && PREFERRED_STRATEGY_VALUES.has(newValue as PreferredStrategy)) {\n this._preferredStrategy = newValue as PreferredStrategy;\n } else {\n this._preferredStrategy = \"auto\";\n }\n break;\n }\n }\n\n // ── Source handling ────────────────────────────────────────────────────\n\n /** Returns the currently-active source (src or source), whichever is set. */\n private _activeSource(): MediaInput | null {\n if (this._source != null) return this._source;\n if (this._src != null) return this._src;\n return null;\n }\n\n /** Internal src setter — separate from the property setter so the\n * attributeChangedCallback can use it without re-entering reflection. */\n private _setSrcInternal(value: string | null): void {\n // Same-value reassignment: no-op (#11 in the lifecycle list).\n if (value === this._src && this._source == null) return;\n this._src = value;\n this._source = null;\n this._onSourceChanged();\n }\n\n /** Called whenever the active source changes (src or source). */\n private _onSourceChanged(): void {\n if (this._destroyed) return;\n const source = this._activeSource();\n if (source == null) {\n // Null transition: tear down and stay idle.\n this._bootstrapId++;\n void this._teardown();\n return;\n }\n // Only bootstrap if we're connected to the DOM.\n if (this.isConnected) {\n void this._bootstrap(source);\n }\n }\n\n // ── Bootstrap (the only place a UnifiedPlayer is created) ──────────────\n\n private async _bootstrap(source: MediaInput): Promise<void> {\n if (this._destroyed) return;\n const id = ++this._bootstrapId;\n\n // Tear down any existing player before starting a new one. Pass the\n // bootstrap id we just claimed so teardown doesn't bump it again\n // (which would invalidate ourselves).\n await this._teardown(id);\n if (id !== this._bootstrapId || this._destroyed) return;\n\n this._dispatch(\"loadstart\", {});\n\n let player: UnifiedPlayer;\n try {\n player = await createPlayer({\n source,\n target: this._videoEl,\n });\n } catch (err) {\n // Stale or destroyed — silently abandon.\n if (id !== this._bootstrapId || this._destroyed) return;\n this._dispatchError(err);\n return;\n }\n\n // Race check: if anything happened during the await above, bail.\n if (id !== this._bootstrapId || this._destroyed || !this.isConnected) {\n try { await player.destroy(); } catch { /* ignore */ }\n return;\n }\n\n this._player = player;\n\n // Wire events. The unsubscribe handles are not stored individually\n // because destroy() will tear down the whole session anyway.\n player.on(\"strategy\", ({ strategy, reason }) => {\n // strategy event fires on initial classification AND any escalation.\n const cls = player.getDiagnostics().strategyClass;\n this._strategy = strategy;\n this._strategyClass = cls === \"pending\" ? null : cls;\n this._dispatch(\"strategychange\", {\n strategy,\n strategyClass: this._strategyClass,\n reason,\n diagnostics: player.getDiagnostics(),\n });\n });\n\n player.on(\"strategychange\", ({ from, to, reason, currentTime }) => {\n this._dispatch(\"strategychange\", {\n from,\n strategy: to,\n strategyClass: player.getDiagnostics().strategyClass === \"pending\" ? null : player.getDiagnostics().strategyClass,\n reason,\n currentTime,\n diagnostics: player.getDiagnostics(),\n });\n });\n\n player.on(\"tracks\", ({ video: _v, audio, subtitle }) => {\n this._audioTracks = audio;\n this._subtitleTracks = subtitle;\n this._dispatch(\"trackschange\", {\n audioTracks: audio,\n subtitleTracks: subtitle,\n });\n });\n\n player.on(\"error\", (err: Error) => {\n this._dispatchError(err);\n });\n\n player.on(\"timeupdate\", ({ currentTime }) => {\n this._dispatch(\"timeupdate\", { currentTime });\n });\n\n player.on(\"ended\", () => {\n this._dispatch(\"ended\", {});\n });\n\n player.on(\"ready\", () => {\n this._dispatch(\"ready\", { diagnostics: player.getDiagnostics() });\n // Apply any pending seek that was set before the player existed.\n if (this._pendingSeek != null) {\n const t = this._pendingSeek;\n this._pendingSeek = null;\n void player.seek(t).catch(() => { /* ignore */ });\n }\n // Honor any pending play() that was queued before bootstrap finished.\n if (this._pendingPlay) {\n this._pendingPlay = false;\n void player.play().catch(() => { /* ignore — autoplay may be blocked */ });\n } else if (this.autoplay) {\n void player.play().catch(() => { /* ignore */ });\n }\n });\n }\n\n /**\n * Tear down the active player and reset runtime state. Idempotent.\n * If `currentBootstrapId` is provided, the bootstrap counter is NOT\n * incremented (used by `_bootstrap()` to avoid invalidating itself).\n */\n private async _teardown(currentBootstrapId?: number): Promise<void> {\n if (currentBootstrapId == null) {\n // External callers (disconnect, destroy, source change) should bump\n // the counter so any in-flight bootstrap is invalidated. The internal\n // _bootstrap() call passes its own ID and we skip the bump.\n this._bootstrapId++;\n }\n const player = this._player;\n this._player = null;\n this._strategy = null;\n this._strategyClass = null;\n this._audioTracks = [];\n this._subtitleTracks = [];\n if (player) {\n try { await player.destroy(); } catch { /* ignore */ }\n }\n }\n\n // ── Public properties ──────────────────────────────────────────────────\n\n get src(): string | null {\n return this._src;\n }\n\n set src(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"src\");\n } else {\n this.setAttribute(\"src\", value);\n }\n // attributeChangedCallback handles the rest.\n }\n\n get source(): MediaInput | null {\n return this._source;\n }\n\n set source(value: MediaInput | null) {\n // Same-value reassignment for rich values is identity-based.\n if (value === this._source && this._src == null) return;\n this._source = value;\n if (value != null) {\n // Setting source clears src. Suppress the attribute callback so\n // removing the src attribute doesn't wipe the source we just set.\n this._src = null;\n if (this.hasAttribute(\"src\")) {\n this._suppressSrcAttrCallback = true;\n try {\n this.removeAttribute(\"src\");\n } finally {\n this._suppressSrcAttrCallback = false;\n }\n }\n }\n this._onSourceChanged();\n }\n\n get autoplay(): boolean {\n return this.hasAttribute(\"autoplay\");\n }\n\n set autoplay(value: boolean) {\n if (value) this.setAttribute(\"autoplay\", \"\");\n else this.removeAttribute(\"autoplay\");\n }\n\n get muted(): boolean {\n return this.hasAttribute(\"muted\");\n }\n\n set muted(value: boolean) {\n if (value) this.setAttribute(\"muted\", \"\");\n else this.removeAttribute(\"muted\");\n }\n\n get loop(): boolean {\n return this.hasAttribute(\"loop\");\n }\n\n set loop(value: boolean) {\n if (value) this.setAttribute(\"loop\", \"\");\n else this.removeAttribute(\"loop\");\n }\n\n get preload(): \"none\" | \"metadata\" | \"auto\" {\n const v = this.getAttribute(\"preload\");\n return v === \"none\" || v === \"metadata\" || v === \"auto\" ? v : \"auto\";\n }\n\n set preload(value: \"none\" | \"metadata\" | \"auto\") {\n this.setAttribute(\"preload\", value);\n }\n\n get diagnostics(): boolean {\n return this.hasAttribute(\"diagnostics\");\n }\n\n set diagnostics(value: boolean) {\n if (value) this.setAttribute(\"diagnostics\", \"\");\n else this.removeAttribute(\"diagnostics\");\n }\n\n get preferredStrategy(): PreferredStrategy {\n return this._preferredStrategy;\n }\n\n set preferredStrategy(value: PreferredStrategy) {\n if (PREFERRED_STRATEGY_VALUES.has(value)) {\n this.setAttribute(\"preferstrategy\", value);\n }\n }\n\n get currentTime(): number {\n return this._player?.getCurrentTime() ?? 0;\n }\n\n set currentTime(value: number) {\n if (this._player) {\n void this._player.seek(value).catch(() => { /* ignore */ });\n } else {\n // Defer to the next bootstrap. The `ready` handler applies it.\n this._pendingSeek = value;\n }\n }\n\n get duration(): number {\n return this._player?.getDuration() ?? NaN;\n }\n\n get paused(): boolean {\n return this._videoEl.paused;\n }\n\n get ended(): boolean {\n return this._videoEl.ended;\n }\n\n get readyState(): number {\n return this._videoEl.readyState;\n }\n\n /**\n * Buffered time ranges for the active source. Mirrors the standard\n * `<video>.buffered` `TimeRanges` API. For the native and remux strategies\n * this reflects the underlying SourceBuffer / progressive download state.\n * For the hybrid and fallback (canvas-rendered) strategies it currently\n * returns an empty TimeRanges; v1.1 will synthesize a coarse range from\n * the decoder's read position.\n */\n get buffered(): TimeRanges {\n return this._videoEl.buffered;\n }\n\n get strategy(): StrategyName | null {\n return this._strategy;\n }\n\n get strategyClass(): StrategyClass | null {\n return this._strategyClass;\n }\n\n get player(): UnifiedPlayer | null {\n return this._player;\n }\n\n get audioTracks(): AudioTrackInfo[] {\n return this._audioTracks;\n }\n\n get subtitleTracks(): SubtitleTrackInfo[] {\n return this._subtitleTracks;\n }\n\n // ── Public methods ─────────────────────────────────────────────────────\n\n /** Force a (re-)bootstrap if a source is currently set. */\n async load(): Promise<void> {\n if (this._destroyed) return;\n const source = this._activeSource();\n if (source == null) return;\n await this._bootstrap(source);\n }\n\n /**\n * Begin or resume playback. If the player isn't ready yet, the call is\n * queued and applied once `ready` fires.\n */\n async play(): Promise<void> {\n if (this._destroyed) return;\n if (this._player) {\n await this._player.play();\n } else {\n this._pendingPlay = true;\n }\n }\n\n pause(): void {\n if (this._destroyed) return;\n this._pendingPlay = false;\n this._player?.pause();\n }\n\n /**\n * Tear down the element permanently. After destroy(), the element ignores\n * all method calls and attribute changes.\n */\n async destroy(): Promise<void> {\n if (this._destroyed) return;\n this._destroyed = true;\n await this._teardown();\n this._dispatch(\"destroy\", {});\n }\n\n async setAudioTrack(id: number): Promise<void> {\n if (this._destroyed || !this._player) return;\n await this._player.setAudioTrack(id);\n }\n\n async setSubtitleTrack(id: number | null): Promise<void> {\n if (this._destroyed || !this._player) return;\n await this._player.setSubtitleTrack(id);\n }\n\n getDiagnostics(): DiagnosticsSnapshot | null {\n return this._player?.getDiagnostics() ?? null;\n }\n\n // ── Event helpers ──────────────────────────────────────────────────────\n\n private _dispatch<T>(name: string, detail: T): void {\n this.dispatchEvent(new CustomEvent(name, { detail, bubbles: false }));\n }\n\n private _dispatchError(err: unknown): void {\n const error = err instanceof Error ? err : new Error(String(err));\n this._dispatch(\"error\", { error, diagnostics: this._player?.getDiagnostics() ?? null });\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"avbridge-player\": AvbridgePlayerElement;\n }\n}\n","/**\n * Subpath entry: `import \"avbridge/element\"` registers the\n * `<avbridge-player>` custom element.\n *\n * This is a separate entry point from the core (`avbridge`) so that consumers\n * who only want the engine don't pay for the element code, and consumers who\n * want both pay for the element code exactly once.\n *\n * The registration is guarded so re-importing this module (e.g. via HMR or\n * multiple bundles) does not throw a \"name already defined\" error.\n */\n\nimport { AvbridgePlayerElement } from \"./element/avbridge-player.js\";\n\nexport { AvbridgePlayerElement };\n\nif (typeof customElements !== \"undefined\" && !customElements.get(\"avbridge-player\")) {\n customElements.define(\"avbridge-player\", AvbridgePlayerElement);\n}\n"]}
1
+ {"version":3,"sources":["../src/element/avbridge-video.ts","../src/element.ts"],"names":["createPlayer"],"mappings":";;;;;;;;AA+BA,IAAM,yBAAA,uBAAgC,GAAA,CAAuB;AAAA,EAC3D,MAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAC,CAAA;AAeD,IAAM,sBAAA,GAAyB;AA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9D","file":"element.cjs","sourcesContent":["/**\n * `<avbridge-video>` — `HTMLMediaElement`-compatible primitive backed by the\n * avbridge engine. Drop-in replacement for a `<video>` element with no\n * built-in UI.\n *\n * Purpose:\n *\n * 1. Validate the public API by being a real consumer of `createPlayer()`.\n * 2. Drive lifecycle correctness in the core via adversarial integration tests.\n * 3. Give consumers a `<video>`-compatible primitive they can wrap with\n * their own UI.\n *\n * **It is not a player UI framework.** The tag name `<avbridge-player>` is\n * reserved for a future controls-bearing element. See\n * `docs/dev/WEB_COMPONENT_SPEC.md` for the full spec, lifecycle invariants,\n * and edge case list.\n */\n\nimport { createPlayer, type UnifiedPlayer } from \"../player.js\";\nimport type {\n MediaInput,\n StrategyName,\n StrategyClass,\n AudioTrackInfo,\n SubtitleTrackInfo,\n DiagnosticsSnapshot,\n} from \"../types.js\";\n\n/** Strategy preference passed via the `preferstrategy` attribute. */\ntype PreferredStrategy = \"auto\" | StrategyName;\n\nconst PREFERRED_STRATEGY_VALUES = new Set<PreferredStrategy>([\n \"auto\",\n \"native\",\n \"remux\",\n \"hybrid\",\n \"fallback\",\n]);\n\n/**\n * Standard `HTMLMediaElement` events we forward from the inner `<video>`\n * to the wrapper element so consumers can `el.addEventListener(\"loadedmetadata\", ...)`\n * exactly like they would with a real `<video>`. The element also dispatches\n * its own custom events (`strategychange`, `ready`, `error`, etc.) — those\n * are NOT in this list because they're avbridge-specific.\n *\n * Note: `progress` and `timeupdate` are deliberately NOT forwarded here.\n * `progress` is dispatched by the constructor with our own `{ buffered }`\n * detail. `timeupdate` is dispatched by the player layer (so it works for\n * canvas-rendered fallback playback too, where the inner <video> never\n * fires its own timeupdate).\n */\nconst FORWARDED_VIDEO_EVENTS = [\n \"loadstart\",\n \"loadedmetadata\",\n \"loadeddata\",\n \"canplay\",\n \"canplaythrough\",\n \"play\",\n \"playing\",\n \"pause\",\n \"seeking\",\n \"seeked\",\n \"volumechange\",\n \"ratechange\",\n \"durationchange\",\n \"waiting\",\n \"stalled\",\n \"emptied\",\n \"resize\",\n \"error\",\n] as const;\n\n/**\n * `HTMLElement` is a browser-only global. SSR frameworks (Next.js, Astro,\n * Remix, etc.) commonly import library modules on the server to extract\n * types or do tree-shaking, even if the user only ends up using them in\n * the browser. If we extended `HTMLElement` directly, the `class extends`\n * expression would be evaluated at module load time and crash in Node.\n *\n * The fix: in non-browser environments, fall back to an empty stub class.\n * The element is never *constructed* server-side (the registration in\n * `element.ts` is guarded by `typeof customElements !== \"undefined\"`), so\n * the stub is never instantiated — it just lets the class declaration\n * evaluate cleanly so the module can be imported anywhere.\n */\nconst HTMLElementCtor: typeof HTMLElement =\n typeof HTMLElement !== \"undefined\"\n ? HTMLElement\n : (class {} as unknown as typeof HTMLElement);\n\n/**\n * Custom element. Lifecycle correctness is enforced via a monotonically\n * increasing `_bootstrapId`: every async bootstrap captures the ID at start\n * and discards itself if the ID has changed by the time it resolves. This\n * single pattern handles disconnect-during-bootstrap, rapid src reassignment,\n * bootstrap races, and destroy-during-bootstrap.\n */\nexport class AvbridgeVideoElement extends HTMLElementCtor {\n static readonly observedAttributes = [\n \"src\",\n \"autoplay\",\n \"muted\",\n \"loop\",\n \"preload\",\n \"poster\",\n \"playsinline\",\n \"crossorigin\",\n \"disableremoteplayback\",\n \"diagnostics\",\n \"preferstrategy\",\n ];\n\n // ── Internal state ─────────────────────────────────────────────────────\n\n /** The shadow DOM `<video>` element that strategies render into. */\n private _videoEl!: HTMLVideoElement;\n\n /** Active player session, if any. Cleared on teardown. */\n private _player: UnifiedPlayer | null = null;\n\n /**\n * Monotonic counter incremented on every (re)bootstrap. Async bootstrap\n * work captures the current ID; if it doesn't match by the time the work\n * resolves, the work is discarded.\n */\n private _bootstrapId = 0;\n\n /** True after destroy() — element is permanently unusable. */\n private _destroyed = false;\n\n /** Internal source state. Either string-form (src) OR rich (source). */\n private _src: string | null = null;\n private _source: MediaInput | null = null;\n\n /**\n * Set when the `source` property setter is in the middle of clearing the\n * `src` attribute as part of mutual exclusion. The attributeChangedCallback\n * checks this flag and skips its normal \"clear source\" side effect, which\n * would otherwise wipe the value we just set.\n */\n private _suppressSrcAttrCallback = false;\n\n /** Last-known runtime state surfaced via getters. */\n private _strategy: StrategyName | null = null;\n private _strategyClass: StrategyClass | null = null;\n private _audioTracks: AudioTrackInfo[] = [];\n private _subtitleTracks: SubtitleTrackInfo[] = [];\n\n /**\n * Initial strategy preference. `\"auto\"` means \"let the classifier decide\";\n * any other value is passed to `createPlayer({ initialStrategy })` and\n * skips classification on the next bootstrap. Note that this only affects\n * the *initial* pick — runtime fallback escalation still applies, so a\n * preference of `\"native\"` may still escalate to remux/hybrid/fallback if\n * native fails.\n */\n private _preferredStrategy: PreferredStrategy = \"auto\";\n\n /** Set if currentTime was assigned before the player was ready. */\n private _pendingSeek: number | null = null;\n /** Set if play() was called before the player was ready. */\n private _pendingPlay = false;\n\n /** MutationObserver tracking light-DOM `<track>` children. */\n private _trackObserver: MutationObserver | null = null;\n\n // ── Construction & lifecycle ───────────────────────────────────────────\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: \"open\" });\n this._videoEl = document.createElement(\"video\");\n this._videoEl.setAttribute(\"part\", \"video\");\n this._videoEl.style.cssText = \"width:100%;height:100%;display:block;background:#000;\";\n this._videoEl.playsInline = true;\n root.appendChild(this._videoEl);\n\n // Forward the underlying <video>'s `progress` event so consumers can\n // observe buffered-range updates without reaching into the shadow DOM.\n // This works for native + remux (real video element with buffered\n // ranges) and is a no-op for hybrid/fallback (canvas-rendered, no\n // buffered ranges yet).\n this._videoEl.addEventListener(\"progress\", () => {\n if (this._destroyed) return;\n this._dispatch(\"progress\", { buffered: this._videoEl.buffered });\n });\n\n // Forward all standard HTMLMediaElement events from the inner <video>\n // so consumers can use the element as a drop-in <video> replacement.\n // Each event is re-dispatched on the wrapper element with no detail —\n // listeners that need state should read it from the element directly.\n for (const eventName of FORWARDED_VIDEO_EVENTS) {\n this._videoEl.addEventListener(eventName, () => {\n if (this._destroyed) return;\n this.dispatchEvent(new Event(eventName, { bubbles: false }));\n });\n }\n }\n\n connectedCallback(): void {\n if (this._destroyed) return;\n // Pick up any <track> children that were declared in HTML before the\n // element upgraded, and watch for future additions/removals.\n this._syncTextTracks();\n if (!this._trackObserver) {\n this._trackObserver = new MutationObserver(() => this._syncTextTracks());\n this._trackObserver.observe(this, { childList: true, subtree: false });\n }\n // Connection is the trigger for bootstrap. If we have a pending source\n // (set before connect), kick off bootstrap now.\n const source = this._activeSource();\n if (source != null) {\n void this._bootstrap(source);\n }\n }\n\n disconnectedCallback(): void {\n if (this._destroyed) return;\n if (this._trackObserver) {\n this._trackObserver.disconnect();\n this._trackObserver = null;\n }\n // Bump the bootstrap token so any in-flight async work is invalidated\n // before we tear down. _teardown() also bumps but we want the bump to\n // happen synchronously here so any awaited promise that resolves\n // between `disconnect` and `_teardown` sees the new ID.\n this._bootstrapId++;\n void this._teardown();\n }\n\n attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void {\n if (this._destroyed) return;\n switch (name) {\n case \"src\":\n if (this._suppressSrcAttrCallback) break;\n this._setSrcInternal(newValue);\n break;\n case \"autoplay\":\n case \"muted\":\n case \"loop\":\n case \"playsinline\":\n case \"disableremoteplayback\":\n // Reflect onto the underlying <video> element.\n if (newValue == null) this._videoEl.removeAttribute(name);\n else this._videoEl.setAttribute(name, newValue);\n break;\n case \"preload\":\n case \"poster\":\n case \"crossorigin\":\n if (newValue == null) this._videoEl.removeAttribute(name);\n else this._videoEl.setAttribute(name, newValue);\n break;\n case \"diagnostics\":\n // Phase A: no UI. Property is observable for users via getDiagnostics().\n break;\n case \"preferstrategy\":\n if (newValue && PREFERRED_STRATEGY_VALUES.has(newValue as PreferredStrategy)) {\n this._preferredStrategy = newValue as PreferredStrategy;\n } else {\n this._preferredStrategy = \"auto\";\n }\n break;\n }\n }\n\n // ── Source handling ────────────────────────────────────────────────────\n\n /** Returns the currently-active source (src or source), whichever is set. */\n private _activeSource(): MediaInput | null {\n if (this._source != null) return this._source;\n if (this._src != null) return this._src;\n return null;\n }\n\n /**\n * Mirror light-DOM `<track>` children into the shadow `<video>` so that\n * the browser's native text-track machinery picks them up. Called on\n * connect, on every mutation of light-DOM children, and once after each\n * source change so newly-set tracks survive a fresh `<video>`.\n *\n * Strategy: clone the children. We don't move them because the user's\n * code may still hold references to the originals (e.g. to set `default`).\n * The shadow copies are throwaway — we wipe them on every sync.\n */\n private _syncTextTracks(): void {\n // Remove existing shadow tracks.\n const existing = this._videoEl.querySelectorAll(\"track\");\n for (const t of Array.from(existing)) t.remove();\n // Clone every <track> light-DOM child into the shadow video.\n for (const child of Array.from(this.children)) {\n if (child.tagName === \"TRACK\") {\n const clone = child.cloneNode(true) as HTMLTrackElement;\n this._videoEl.appendChild(clone);\n }\n }\n }\n\n /** Internal src setter — separate from the property setter so the\n * attributeChangedCallback can use it without re-entering reflection. */\n private _setSrcInternal(value: string | null): void {\n // Same-value reassignment: no-op (#11 in the lifecycle list).\n if (value === this._src && this._source == null) return;\n this._src = value;\n this._source = null;\n this._onSourceChanged();\n }\n\n /** Called whenever the active source changes (src or source). */\n private _onSourceChanged(): void {\n if (this._destroyed) return;\n const source = this._activeSource();\n if (source == null) {\n // Null transition: tear down and stay idle.\n this._bootstrapId++;\n void this._teardown();\n return;\n }\n // Only bootstrap if we're connected to the DOM.\n if (this.isConnected) {\n void this._bootstrap(source);\n }\n }\n\n // ── Bootstrap (the only place a UnifiedPlayer is created) ──────────────\n\n private async _bootstrap(source: MediaInput): Promise<void> {\n if (this._destroyed) return;\n const id = ++this._bootstrapId;\n\n // Tear down any existing player before starting a new one. Pass the\n // bootstrap id we just claimed so teardown doesn't bump it again\n // (which would invalidate ourselves).\n await this._teardown(id);\n if (id !== this._bootstrapId || this._destroyed) return;\n\n this._dispatch(\"loadstart\", {});\n\n let player: UnifiedPlayer;\n try {\n player = await createPlayer({\n source,\n target: this._videoEl,\n // Honor the consumer's preferred initial strategy. \"auto\" means\n // \"let the classifier decide\" — the createPlayer call simply doesn't\n // pass initialStrategy in that case.\n ...(this._preferredStrategy !== \"auto\"\n ? { initialStrategy: this._preferredStrategy }\n : {}),\n });\n } catch (err) {\n // Stale or destroyed — silently abandon.\n if (id !== this._bootstrapId || this._destroyed) return;\n this._dispatchError(err);\n return;\n }\n\n // Race check: if anything happened during the await above, bail.\n if (id !== this._bootstrapId || this._destroyed || !this.isConnected) {\n try { await player.destroy(); } catch { /* ignore */ }\n return;\n }\n\n this._player = player;\n\n // Resync any light-DOM <track> children into the (possibly fresh) shadow\n // <video>. Strategies that swap or reset the inner video state would\n // otherwise lose the tracks the user declared in HTML.\n this._syncTextTracks();\n\n // Wire events. The unsubscribe handles are not stored individually\n // because destroy() will tear down the whole session anyway.\n player.on(\"strategy\", ({ strategy, reason }) => {\n // strategy event fires on initial classification AND any escalation.\n const cls = player.getDiagnostics().strategyClass;\n this._strategy = strategy;\n this._strategyClass = cls === \"pending\" ? null : cls;\n this._dispatch(\"strategychange\", {\n strategy,\n strategyClass: this._strategyClass,\n reason,\n diagnostics: player.getDiagnostics(),\n });\n });\n\n player.on(\"strategychange\", ({ from, to, reason, currentTime }) => {\n this._dispatch(\"strategychange\", {\n from,\n strategy: to,\n strategyClass: player.getDiagnostics().strategyClass === \"pending\" ? null : player.getDiagnostics().strategyClass,\n reason,\n currentTime,\n diagnostics: player.getDiagnostics(),\n });\n });\n\n player.on(\"tracks\", ({ video: _v, audio, subtitle }) => {\n this._audioTracks = audio;\n this._subtitleTracks = subtitle;\n this._dispatch(\"trackschange\", {\n audioTracks: audio,\n subtitleTracks: subtitle,\n });\n });\n\n player.on(\"error\", (err: Error) => {\n this._dispatchError(err);\n });\n\n player.on(\"timeupdate\", ({ currentTime }) => {\n this._dispatch(\"timeupdate\", { currentTime });\n });\n\n player.on(\"ended\", () => {\n this._dispatch(\"ended\", {});\n });\n\n player.on(\"ready\", () => {\n this._dispatch(\"ready\", { diagnostics: player.getDiagnostics() });\n // Apply any pending seek that was set before the player existed.\n if (this._pendingSeek != null) {\n const t = this._pendingSeek;\n this._pendingSeek = null;\n void player.seek(t).catch(() => { /* ignore */ });\n }\n // Honor any pending play() that was queued before bootstrap finished.\n if (this._pendingPlay) {\n this._pendingPlay = false;\n void player.play().catch(() => { /* ignore — autoplay may be blocked */ });\n } else if (this.autoplay) {\n void player.play().catch(() => { /* ignore */ });\n }\n });\n }\n\n /**\n * Tear down the active player and reset runtime state. Idempotent.\n * If `currentBootstrapId` is provided, the bootstrap counter is NOT\n * incremented (used by `_bootstrap()` to avoid invalidating itself).\n */\n private async _teardown(currentBootstrapId?: number): Promise<void> {\n if (currentBootstrapId == null) {\n // External callers (disconnect, destroy, source change) should bump\n // the counter so any in-flight bootstrap is invalidated. The internal\n // _bootstrap() call passes its own ID and we skip the bump.\n this._bootstrapId++;\n }\n const player = this._player;\n this._player = null;\n this._strategy = null;\n this._strategyClass = null;\n this._audioTracks = [];\n this._subtitleTracks = [];\n if (player) {\n try { await player.destroy(); } catch { /* ignore */ }\n }\n }\n\n // ── Public properties ──────────────────────────────────────────────────\n\n get src(): string | null {\n return this._src;\n }\n\n set src(value: string | null) {\n if (value == null) {\n this.removeAttribute(\"src\");\n } else {\n this.setAttribute(\"src\", value);\n }\n // attributeChangedCallback handles the rest.\n }\n\n get source(): MediaInput | null {\n return this._source;\n }\n\n set source(value: MediaInput | null) {\n // Same-value reassignment for rich values is identity-based.\n if (value === this._source && this._src == null) return;\n this._source = value;\n if (value != null) {\n // Setting source clears src. Suppress the attribute callback so\n // removing the src attribute doesn't wipe the source we just set.\n this._src = null;\n if (this.hasAttribute(\"src\")) {\n this._suppressSrcAttrCallback = true;\n try {\n this.removeAttribute(\"src\");\n } finally {\n this._suppressSrcAttrCallback = false;\n }\n }\n }\n this._onSourceChanged();\n }\n\n get autoplay(): boolean {\n return this.hasAttribute(\"autoplay\");\n }\n\n set autoplay(value: boolean) {\n if (value) this.setAttribute(\"autoplay\", \"\");\n else this.removeAttribute(\"autoplay\");\n }\n\n get muted(): boolean {\n return this.hasAttribute(\"muted\");\n }\n\n set muted(value: boolean) {\n if (value) this.setAttribute(\"muted\", \"\");\n else this.removeAttribute(\"muted\");\n }\n\n get loop(): boolean {\n return this.hasAttribute(\"loop\");\n }\n\n set loop(value: boolean) {\n if (value) this.setAttribute(\"loop\", \"\");\n else this.removeAttribute(\"loop\");\n }\n\n get preload(): \"none\" | \"metadata\" | \"auto\" {\n const v = this.getAttribute(\"preload\");\n return v === \"none\" || v === \"metadata\" || v === \"auto\" ? v : \"auto\";\n }\n\n set preload(value: \"none\" | \"metadata\" | \"auto\") {\n this.setAttribute(\"preload\", value);\n }\n\n get diagnostics(): boolean {\n return this.hasAttribute(\"diagnostics\");\n }\n\n set diagnostics(value: boolean) {\n if (value) this.setAttribute(\"diagnostics\", \"\");\n else this.removeAttribute(\"diagnostics\");\n }\n\n get preferredStrategy(): PreferredStrategy {\n return this._preferredStrategy;\n }\n\n set preferredStrategy(value: PreferredStrategy) {\n if (PREFERRED_STRATEGY_VALUES.has(value)) {\n this.setAttribute(\"preferstrategy\", value);\n }\n }\n\n get currentTime(): number {\n return this._player?.getCurrentTime() ?? 0;\n }\n\n set currentTime(value: number) {\n if (this._player) {\n void this._player.seek(value).catch(() => { /* ignore */ });\n } else {\n // Defer to the next bootstrap. The `ready` handler applies it.\n this._pendingSeek = value;\n }\n }\n\n get duration(): number {\n return this._player?.getDuration() ?? NaN;\n }\n\n get paused(): boolean {\n return this._videoEl.paused;\n }\n\n get ended(): boolean {\n return this._videoEl.ended;\n }\n\n get readyState(): number {\n return this._videoEl.readyState;\n }\n\n /**\n * Buffered time ranges for the active source. Mirrors the standard\n * `<video>.buffered` `TimeRanges` API. For the native and remux strategies\n * this reflects the underlying SourceBuffer / progressive download state.\n * For the hybrid and fallback (canvas-rendered) strategies it currently\n * returns an empty TimeRanges; a future release will synthesize a coarse\n * range from the decoder's read position.\n */\n get buffered(): TimeRanges {\n return this._videoEl.buffered;\n }\n\n // ── HTMLMediaElement parity ───────────────────────────────────────────\n // Mirror the standard <video> surface so consumers can drop the element\n // in as a <video> replacement. Each property is a thin passthrough to the\n // shadow `<video>`.\n\n get poster(): string {\n return this._videoEl.poster;\n }\n set poster(value: string) {\n if (value == null || value === \"\") this.removeAttribute(\"poster\");\n else this.setAttribute(\"poster\", value);\n }\n\n get volume(): number {\n return this._videoEl.volume;\n }\n set volume(value: number) {\n this._videoEl.volume = value;\n }\n\n get playbackRate(): number {\n return this._videoEl.playbackRate;\n }\n set playbackRate(value: number) {\n this._videoEl.playbackRate = value;\n }\n\n get videoWidth(): number {\n return this._videoEl.videoWidth;\n }\n\n get videoHeight(): number {\n return this._videoEl.videoHeight;\n }\n\n get played(): TimeRanges {\n return this._videoEl.played;\n }\n\n get seekable(): TimeRanges {\n return this._videoEl.seekable;\n }\n\n get crossOrigin(): string | null {\n return this._videoEl.crossOrigin;\n }\n set crossOrigin(value: string | null) {\n if (value == null) this.removeAttribute(\"crossorigin\");\n else this.setAttribute(\"crossorigin\", value);\n }\n\n get disableRemotePlayback(): boolean {\n return this._videoEl.disableRemotePlayback;\n }\n set disableRemotePlayback(value: boolean) {\n if (value) this.setAttribute(\"disableremoteplayback\", \"\");\n else this.removeAttribute(\"disableremoteplayback\");\n }\n\n /**\n * Native `HTMLMediaElement.canPlayType()` passthrough. Note that this\n * answers about the *browser's* native support, not avbridge's full\n * capabilities — avbridge can play many formats this method returns \"\"\n * for, by routing them to the remux/hybrid/fallback strategies.\n */\n canPlayType(mimeType: string): CanPlayTypeResult {\n return this._videoEl.canPlayType(mimeType);\n }\n\n /**\n * **Escape hatch.** The underlying shadow-DOM `<video>` element.\n *\n * Use for native browser APIs the wrapper doesn't expose:\n * - `el.videoElement.requestPictureInPicture()`\n * - `el.videoElement.audioTracks` (browser native, not avbridge's track list)\n * - direct integration with libraries that need a real HTMLVideoElement\n *\n * **Caveat:** When the active strategy is `\"fallback\"` or `\"hybrid\"`,\n * frames are rendered to a canvas overlay, not into this `<video>`.\n * APIs that depend on the actual pixels (Picture-in-Picture, captureStream)\n * will not show the playing content in those modes. Check `el.strategy`\n * before using such APIs.\n */\n get videoElement(): HTMLVideoElement {\n return this._videoEl;\n }\n\n get strategy(): StrategyName | null {\n return this._strategy;\n }\n\n get strategyClass(): StrategyClass | null {\n return this._strategyClass;\n }\n\n get player(): UnifiedPlayer | null {\n return this._player;\n }\n\n get audioTracks(): AudioTrackInfo[] {\n return this._audioTracks;\n }\n\n get subtitleTracks(): SubtitleTrackInfo[] {\n return this._subtitleTracks;\n }\n\n // ── Public methods ─────────────────────────────────────────────────────\n\n /** Force a (re-)bootstrap if a source is currently set. */\n async load(): Promise<void> {\n if (this._destroyed) return;\n const source = this._activeSource();\n if (source == null) return;\n await this._bootstrap(source);\n }\n\n /**\n * Begin or resume playback. If the player isn't ready yet, the call is\n * queued and applied once `ready` fires.\n */\n async play(): Promise<void> {\n if (this._destroyed) return;\n if (this._player) {\n await this._player.play();\n } else {\n this._pendingPlay = true;\n }\n }\n\n pause(): void {\n if (this._destroyed) return;\n this._pendingPlay = false;\n this._player?.pause();\n }\n\n /**\n * Tear down the element permanently. After destroy(), the element ignores\n * all method calls and attribute changes.\n */\n async destroy(): Promise<void> {\n if (this._destroyed) return;\n this._destroyed = true;\n await this._teardown();\n this._dispatch(\"destroy\", {});\n }\n\n async setAudioTrack(id: number): Promise<void> {\n if (this._destroyed || !this._player) return;\n await this._player.setAudioTrack(id);\n }\n\n async setSubtitleTrack(id: number | null): Promise<void> {\n if (this._destroyed || !this._player) return;\n await this._player.setSubtitleTrack(id);\n }\n\n getDiagnostics(): DiagnosticsSnapshot | null {\n return this._player?.getDiagnostics() ?? null;\n }\n\n // ── Event helpers ──────────────────────────────────────────────────────\n\n private _dispatch<T>(name: string, detail: T): void {\n this.dispatchEvent(new CustomEvent(name, { detail, bubbles: false }));\n }\n\n private _dispatchError(err: unknown): void {\n const error = err instanceof Error ? err : new Error(String(err));\n this._dispatch(\"error\", { error, diagnostics: this._player?.getDiagnostics() ?? null });\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"avbridge-video\": AvbridgeVideoElement;\n }\n}\n","/**\n * Subpath entry: `import \"avbridge/element\"` registers the\n * `<avbridge-video>` custom element.\n *\n * This is a separate entry point from the core (`avbridge`) so that consumers\n * who only want the engine don't pay for the element code, and consumers who\n * want both pay for the element code exactly once.\n *\n * The registration is guarded so re-importing this module (e.g. via HMR or\n * multiple bundles) does not throw a \"name already defined\" error.\n *\n * The tag name `<avbridge-player>` is reserved for a future controls-bearing\n * element. Today, only `<avbridge-video>` (the bare HTMLMediaElement-compatible\n * primitive) is registered.\n */\n\nimport { AvbridgeVideoElement } from \"./element/avbridge-video.js\";\n\nexport { AvbridgeVideoElement };\n\nif (typeof customElements !== \"undefined\" && !customElements.get(\"avbridge-video\")) {\n customElements.define(\"avbridge-video\", AvbridgeVideoElement);\n}\n"]}
@@ -1,21 +1,21 @@
1
- import { a as MediaInput, m as StrategyName, S as StrategyClass, U as UnifiedPlayer, d as AudioTrackInfo, n as SubtitleTrackInfo, D as DiagnosticsSnapshot } from './player-BBwbCkdL.cjs';
1
+ import { a as MediaInput, m as StrategyName, S as StrategyClass, U as UnifiedPlayer, d as AudioTrackInfo, n as SubtitleTrackInfo, D as DiagnosticsSnapshot } from './player-BdtUG4rh.cjs';
2
2
 
3
3
  /**
4
- * `<avbridge-player>` — reference web component for the avbridge engine.
4
+ * `<avbridge-video>` — `HTMLMediaElement`-compatible primitive backed by the
5
+ * avbridge engine. Drop-in replacement for a `<video>` element with no
6
+ * built-in UI.
5
7
  *
6
- * This is a *thin* wrapper around `createPlayer()`. Its purpose is to:
8
+ * Purpose:
7
9
  *
8
- * 1. Validate the public API by being a real consumer of it.
10
+ * 1. Validate the public API by being a real consumer of `createPlayer()`.
9
11
  * 2. Drive lifecycle correctness in the core via adversarial integration tests.
10
- * 3. Provide a drop-in player for users who don't want to wire `createPlayer()`
11
- * themselves.
12
+ * 3. Give consumers a `<video>`-compatible primitive they can wrap with
13
+ * their own UI.
12
14
  *
13
- * It is **not** a player UI framework. See `docs/dev/WEB_COMPONENT_SPEC.md`
14
- * for the full spec, lifecycle invariants, and edge case list.
15
- *
16
- * Phase A scope (this file): lifecycle scaffold only — `src` / `source` /
17
- * `currentTime` / `play` / `pause` / `load` / `destroy` / events. No built-in
18
- * controls. Shadow DOM contains a single `<video part="video">`.
15
+ * **It is not a player UI framework.** The tag name `<avbridge-player>` is
16
+ * reserved for a future controls-bearing element. See
17
+ * `docs/dev/WEB_COMPONENT_SPEC.md` for the full spec, lifecycle invariants,
18
+ * and edge case list.
19
19
  */
20
20
 
21
21
  /** Strategy preference passed via the `preferstrategy` attribute. */
@@ -41,7 +41,7 @@ declare const HTMLElementCtor: typeof HTMLElement;
41
41
  * single pattern handles disconnect-during-bootstrap, rapid src reassignment,
42
42
  * bootstrap races, and destroy-during-bootstrap.
43
43
  */
44
- declare class AvbridgePlayerElement extends HTMLElementCtor {
44
+ declare class AvbridgeVideoElement extends HTMLElementCtor {
45
45
  static readonly observedAttributes: string[];
46
46
  /** The shadow DOM `<video>` element that strategies render into. */
47
47
  private _videoEl;
@@ -70,18 +70,38 @@ declare class AvbridgePlayerElement extends HTMLElementCtor {
70
70
  private _strategyClass;
71
71
  private _audioTracks;
72
72
  private _subtitleTracks;
73
- /** Strategy preference (does not currently affect routing — reserved). */
73
+ /**
74
+ * Initial strategy preference. `"auto"` means "let the classifier decide";
75
+ * any other value is passed to `createPlayer({ initialStrategy })` and
76
+ * skips classification on the next bootstrap. Note that this only affects
77
+ * the *initial* pick — runtime fallback escalation still applies, so a
78
+ * preference of `"native"` may still escalate to remux/hybrid/fallback if
79
+ * native fails.
80
+ */
74
81
  private _preferredStrategy;
75
82
  /** Set if currentTime was assigned before the player was ready. */
76
83
  private _pendingSeek;
77
84
  /** Set if play() was called before the player was ready. */
78
85
  private _pendingPlay;
86
+ /** MutationObserver tracking light-DOM `<track>` children. */
87
+ private _trackObserver;
79
88
  constructor();
80
89
  connectedCallback(): void;
81
90
  disconnectedCallback(): void;
82
91
  attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
83
92
  /** Returns the currently-active source (src or source), whichever is set. */
84
93
  private _activeSource;
94
+ /**
95
+ * Mirror light-DOM `<track>` children into the shadow `<video>` so that
96
+ * the browser's native text-track machinery picks them up. Called on
97
+ * connect, on every mutation of light-DOM children, and once after each
98
+ * source change so newly-set tracks survive a fresh `<video>`.
99
+ *
100
+ * Strategy: clone the children. We don't move them because the user's
101
+ * code may still hold references to the originals (e.g. to set `default`).
102
+ * The shadow copies are throwaway — we wipe them on every sync.
103
+ */
104
+ private _syncTextTracks;
85
105
  /** Internal src setter — separate from the property setter so the
86
106
  * attributeChangedCallback can use it without re-entering reflection. */
87
107
  private _setSrcInternal;
@@ -121,10 +141,46 @@ declare class AvbridgePlayerElement extends HTMLElementCtor {
121
141
  * `<video>.buffered` `TimeRanges` API. For the native and remux strategies
122
142
  * this reflects the underlying SourceBuffer / progressive download state.
123
143
  * For the hybrid and fallback (canvas-rendered) strategies it currently
124
- * returns an empty TimeRanges; v1.1 will synthesize a coarse range from
125
- * the decoder's read position.
144
+ * returns an empty TimeRanges; a future release will synthesize a coarse
145
+ * range from the decoder's read position.
126
146
  */
127
147
  get buffered(): TimeRanges;
148
+ get poster(): string;
149
+ set poster(value: string);
150
+ get volume(): number;
151
+ set volume(value: number);
152
+ get playbackRate(): number;
153
+ set playbackRate(value: number);
154
+ get videoWidth(): number;
155
+ get videoHeight(): number;
156
+ get played(): TimeRanges;
157
+ get seekable(): TimeRanges;
158
+ get crossOrigin(): string | null;
159
+ set crossOrigin(value: string | null);
160
+ get disableRemotePlayback(): boolean;
161
+ set disableRemotePlayback(value: boolean);
162
+ /**
163
+ * Native `HTMLMediaElement.canPlayType()` passthrough. Note that this
164
+ * answers about the *browser's* native support, not avbridge's full
165
+ * capabilities — avbridge can play many formats this method returns ""
166
+ * for, by routing them to the remux/hybrid/fallback strategies.
167
+ */
168
+ canPlayType(mimeType: string): CanPlayTypeResult;
169
+ /**
170
+ * **Escape hatch.** The underlying shadow-DOM `<video>` element.
171
+ *
172
+ * Use for native browser APIs the wrapper doesn't expose:
173
+ * - `el.videoElement.requestPictureInPicture()`
174
+ * - `el.videoElement.audioTracks` (browser native, not avbridge's track list)
175
+ * - direct integration with libraries that need a real HTMLVideoElement
176
+ *
177
+ * **Caveat:** When the active strategy is `"fallback"` or `"hybrid"`,
178
+ * frames are rendered to a canvas overlay, not into this `<video>`.
179
+ * APIs that depend on the actual pixels (Picture-in-Picture, captureStream)
180
+ * will not show the playing content in those modes. Check `el.strategy`
181
+ * before using such APIs.
182
+ */
183
+ get videoElement(): HTMLVideoElement;
128
184
  get strategy(): StrategyName | null;
129
185
  get strategyClass(): StrategyClass | null;
130
186
  get player(): UnifiedPlayer | null;
@@ -151,8 +207,8 @@ declare class AvbridgePlayerElement extends HTMLElementCtor {
151
207
  }
152
208
  declare global {
153
209
  interface HTMLElementTagNameMap {
154
- "avbridge-player": AvbridgePlayerElement;
210
+ "avbridge-video": AvbridgeVideoElement;
155
211
  }
156
212
  }
157
213
 
158
- export { AvbridgePlayerElement };
214
+ export { AvbridgeVideoElement };