@norskvideo/moq-watch 0.1.8 → 0.2.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 (76) hide show
  1. package/README.md +43 -31
  2. package/audio/config.d.ts +19 -0
  3. package/audio/config.d.ts.map +1 -0
  4. package/audio/decoder.d.ts +9 -2
  5. package/audio/decoder.d.ts.map +1 -1
  6. package/audio/emitter.d.ts +6 -1
  7. package/audio/emitter.d.ts.map +1 -1
  8. package/audio/latency.d.ts +11 -0
  9. package/audio/latency.d.ts.map +1 -0
  10. package/audio/ring-buffer.d.ts.map +1 -1
  11. package/audio/shared-ring-buffer.d.ts +8 -1
  12. package/audio/shared-ring-buffer.d.ts.map +1 -1
  13. package/audio/source.d.ts.map +1 -1
  14. package/audio/terminal.d.ts +1 -0
  15. package/audio/terminal.d.ts.map +1 -1
  16. package/broadcast.d.ts +19 -5
  17. package/broadcast.d.ts.map +1 -1
  18. package/duration.d.ts +2 -0
  19. package/duration.d.ts.map +1 -0
  20. package/element.d.ts +50 -26
  21. package/element.d.ts.map +1 -1
  22. package/element.js +142 -160
  23. package/element.js.map +1 -1
  24. package/index.d.ts +4 -2
  25. package/index.d.ts.map +1 -1
  26. package/index.js +25 -17
  27. package/index.js.map +1 -1
  28. package/media.d.ts +2 -0
  29. package/media.d.ts.map +1 -0
  30. package/msf.d.ts.map +1 -1
  31. package/package.json +12 -7
  32. package/player-C19uf7Dc.js +2172 -0
  33. package/player-C19uf7Dc.js.map +1 -0
  34. package/player.d.ts +78 -0
  35. package/player.d.ts.map +1 -0
  36. package/sync.d.ts +27 -41
  37. package/sync.d.ts.map +1 -1
  38. package/text/index.d.ts +9 -0
  39. package/text/index.d.ts.map +1 -0
  40. package/text/renderer.d.ts +31 -0
  41. package/text/renderer.d.ts.map +1 -0
  42. package/text/source.d.ts +30 -0
  43. package/text/source.d.ts.map +1 -0
  44. package/ui/components/captions-button.d.ts +11 -0
  45. package/ui/components/captions-button.d.ts.map +1 -0
  46. package/ui/components/captions.d.ts +5 -0
  47. package/ui/components/captions.d.ts.map +1 -0
  48. package/ui/components/control-bar.d.ts.map +1 -1
  49. package/ui/components/hidden-indicator.d.ts +5 -0
  50. package/ui/components/hidden-indicator.d.ts.map +1 -0
  51. package/ui/components/latency.d.ts +1 -1
  52. package/ui/components/latency.d.ts.map +1 -1
  53. package/ui/components/settings-panel.d.ts.map +1 -1
  54. package/ui/element.d.ts.map +1 -1
  55. package/ui/element.js +257 -193
  56. package/ui/element.js.map +1 -1
  57. package/ui/icons.d.ts +2 -1
  58. package/ui/icons.d.ts.map +1 -1
  59. package/ui/state.d.ts +1 -1
  60. package/ui/state.d.ts.map +1 -1
  61. package/video/decoder.d.ts +10 -11
  62. package/video/decoder.d.ts.map +1 -1
  63. package/video/playhead.d.ts +14 -4
  64. package/video/playhead.d.ts.map +1 -1
  65. package/video/renderer.d.ts +6 -1
  66. package/video/renderer.d.ts.map +1 -1
  67. package/video/source.d.ts +1 -1
  68. package/video/source.d.ts.map +1 -1
  69. package/audio/subscription.d.ts +0 -10
  70. package/audio/subscription.d.ts.map +0 -1
  71. package/audio/unlock.d.ts +0 -20
  72. package/audio/unlock.d.ts.map +0 -1
  73. package/source-BeABanvB.js +0 -1723
  74. package/source-BeABanvB.js.map +0 -1
  75. package/sync-DNQkgnlX.js +0 -132
  76. package/sync-DNQkgnlX.js.map +0 -1
package/element.js CHANGED
@@ -1,133 +1,120 @@
1
- import { c as e, i as t, l as n, n as r, o as i, r as a, s as o, t as s } from "./source-BeABanvB.js";
2
- import { n as c, r as l, t as u } from "./sync-DNQkgnlX.js";
3
- import * as d from "@norskvideo/moq-net";
4
- import { Effect as f, Signal as p } from "@norskvideo/moq-signals";
1
+ import { h as e, t } from "./player-C19uf7Dc.js";
2
+ import * as n from "@norskvideo/moq-net";
3
+ import { Time as r } from "@norskvideo/moq-net";
4
+ import { Effect as i, Signal as a } from "@norskvideo/moq-signals";
5
+ //#region src/duration.ts
6
+ function o(e) {
7
+ let t = /^(\d+(?:\.\d+)?)(ms|s)?$/.exec(e.trim());
8
+ if (!t) return;
9
+ let n = Number.parseFloat(t[1]);
10
+ if (Number.isFinite(n)) return t[2] === void 0 ? n === 0 ? r.Milli.zero : void 0 : r.Milli(t[2] === "s" ? n * 1e3 : n);
11
+ }
12
+ function s(e) {
13
+ return `${e}ms`;
14
+ }
15
+ //#endregion
5
16
  //#region src/element.ts
6
- var m = [
17
+ var c = [
7
18
  "url",
8
19
  "name",
9
20
  "paused",
10
21
  "volume",
11
22
  "muted",
12
23
  "visible",
24
+ "announced",
25
+ "delay",
26
+ "buffer",
13
27
  "reload",
14
28
  "latency",
15
29
  "latency-min",
16
- "latency-max",
17
30
  "jitter",
18
- "catalog-format"
31
+ "catalog-format",
32
+ "captions"
19
33
  ];
20
- function h(e) {
34
+ function l(e) {
21
35
  let t = e?.trim();
22
36
  return t ? t === "never" || t === "always" || /^-?\d+(\.\d+)?(px|%)$/.test(t) ? t : /^-?\d+(\.\d+)?$/.test(t) ? `${t}px` : (console.warn(`moq-watch: invalid visible="${e}", expected "never", "always", or a CSS length like "200px"`), "20%") : "20%";
23
37
  }
24
- function g(e, t) {
38
+ function u(e) {
39
+ let t = e?.trim();
40
+ if (!t || t === "auto") return "auto";
41
+ if (t === "instant") return "instant";
42
+ let n = o(t);
43
+ return n === void 0 ? (console.warn(`moq-watch: invalid delay="${e}", expected "auto", "instant", or a duration like "300ms"`), "auto") : n;
44
+ }
45
+ function d(e) {
46
+ let t = e?.trim();
47
+ if (!t) return n.Time.Milli.zero;
48
+ let r = o(t);
49
+ return r === void 0 ? (console.warn(`moq-watch: invalid buffer="${e}", expected a duration like "30s"`), n.Time.Milli.zero) : r;
50
+ }
51
+ function f(t) {
52
+ if (t !== null) return e.find((e) => e === t);
53
+ }
54
+ function p(e, t) {
25
55
  if (e === null) return t;
26
56
  let n = e.trim().toLowerCase();
27
57
  return n !== "false" && n !== "0";
28
58
  }
29
- var _ = new FinalizationRegistry((e) => e.close()), v = class extends HTMLElement {
30
- static observedAttributes = m;
59
+ var m = new FinalizationRegistry((e) => e.close()), h = class extends HTMLElement {
60
+ static observedAttributes = c;
31
61
  connection;
62
+ player;
32
63
  broadcast;
33
64
  video;
34
65
  audio;
35
66
  renderer;
36
67
  emitter;
68
+ text;
69
+ textRenderer;
37
70
  sync;
38
71
  controls = {
39
- paused: new p(!1),
40
- volume: new p(.5),
41
- muted: new p(!1),
42
- visible: new p("20%"),
43
- latency: new p("real-time"),
44
- target: new p(void 0),
45
- audioTarget: new p(void 0)
72
+ paused: new a(!1),
73
+ volume: new a(.5),
74
+ muted: new a(!1),
75
+ visible: new a("20%"),
76
+ delay: new a("auto"),
77
+ buffer: new a(n.Time.Milli.zero),
78
+ target: new a(void 0),
79
+ audioTarget: new a(void 0),
80
+ captions: new a(void 0)
46
81
  };
47
- #e = new p(d.Path.empty());
48
- #t = new p(!0);
49
- #n = new p(void 0);
50
- #r = new p(void 0);
51
- #i = new p(void 0);
52
- #a = new p(!1);
53
- #o = new p(!1);
54
- #s = !1;
55
- #c = new p(!0);
56
- #l = new p("real-time");
57
- #u = new p(!1);
58
- #d = .5;
59
- signals = new f();
82
+ #e = new a(n.Path.empty());
83
+ #t = new a(!0);
84
+ #n = new a(void 0);
85
+ #r = new a(void 0);
86
+ #i = new a(void 0);
87
+ #a = new a(void 0);
88
+ #o;
89
+ #s = new a(!1);
90
+ #c = .5;
91
+ signals = new i();
60
92
  constructor() {
61
- super(), _.register(this, this.signals), this.connection = new d.Connection.Reload({ enabled: this.#u }), this.signals.cleanup(() => this.connection.close()), this.broadcast = new t({
62
- connection: this.connection.established,
63
- enabled: this.#u,
93
+ super(), m.register(this, this.signals), this.connection = new n.Connection({ enabled: this.#s }), this.signals.cleanup(() => this.connection.close()), this.player = new t({
94
+ origin: this.connection.origin,
95
+ probe: this.connection.probe,
96
+ enabled: this.#s,
64
97
  name: this.#e,
65
- reload: this.#t,
98
+ announced: this.#t,
66
99
  catalogFormat: this.#n,
67
- catalog: this.#r
68
- }), this.signals.cleanup(() => this.broadcast.close());
69
- let i = new s({
70
- broadcast: this.broadcast,
71
- target: this.controls.target,
72
- supported: a.supported
73
- }), l = new o({
74
- broadcast: this.broadcast,
75
- target: this.controls.audioTarget,
76
- supported: n.supported
77
- });
78
- this.signals.cleanup(() => {
79
- i.close(), l.close();
80
- }), this.signals.run((e) => {
81
- let t = e.get(this.controls.latency);
82
- this.#l.set(t === "instant" ? d.Time.Milli.zero : t);
83
- }), this.sync = new u({
84
- latency: this.#l,
85
- connection: this.connection.established,
86
- video: i.out.jitter,
87
- audio: l.out.jitter
88
- }), this.signals.cleanup(() => this.sync.close()), this.signals.run((e) => {
89
- this.#c.set(e.get(this.controls.latency) !== "instant");
90
- }), this.video = new a(i, this.sync, {
91
- enabled: this.#a,
92
- paced: this.#c
93
- }), this.audio = new n(l, this.sync, { enabled: this.#o }), this.signals.cleanup(() => {
94
- this.video.close(), this.audio.close();
95
- }), this.emitter = new e(this.audio, {
96
- volume: this.controls.volume,
97
- muted: this.controls.muted,
98
- paused: this.controls.paused
99
- }), this.renderer = new r(this.video, {
100
+ catalog: this.#r,
100
101
  canvas: this.#i,
101
- visible: this.controls.visible
102
- }), this.signals.cleanup(() => {
103
- this.emitter.close(), this.renderer.close();
104
- }), this.signals.run((e) => {
105
- let t = e.get(this.emitter.out.enabled);
106
- this.#o.set(t && e.get(this.controls.latency) !== "instant");
107
- }), this.signals.run((e) => {
108
- e.get(this.controls.latency) === "instant" && this.audio.reset();
109
- }), this.signals.run((e) => {
110
- let t = e.get(this.renderer.out.visible);
111
- if (!e.get(this.controls.paused)) {
112
- this.#a.set(t);
113
- return;
114
- }
115
- let n = e.get(this.renderer.out.frame);
116
- this.#a.set(t && !n);
117
- }), this.signals.run((e) => {
118
- e.get(this.controls.muted) ? (this.#d = this.controls.volume.peek() || .5, this.controls.volume.set(0)) : this.controls.volume.set(this.#d);
102
+ container: this.#a,
103
+ ...this.controls
104
+ }), this.signals.cleanup(() => this.player.close()), this.broadcast = this.player.broadcast, this.video = this.player.video, this.audio = this.player.audio, this.renderer = this.player.renderer, this.emitter = this.player.emitter, this.text = this.player.text, this.textRenderer = this.player.textRenderer, this.sync = this.player.sync, this.signals.run((e) => {
105
+ e.get(this.controls.muted) ? (this.#c = this.controls.volume.peek() || .5, this.controls.volume.set(0)) : this.controls.volume.set(this.#c);
119
106
  }), this.signals.run((e) => {
120
107
  let t = e.get(this.controls.volume);
121
108
  this.controls.muted.set(t === 0);
122
109
  });
123
- let f = () => {
110
+ let e = () => {
124
111
  let e = this.querySelector("canvas") ?? void 0;
125
112
  !e && this.querySelector("video") && console.warn("moq-watch: rendering requires a <canvas> child; a <video> child does nothing."), this.#i.set(e);
126
- }, p = new MutationObserver(f);
127
- p.observe(this, {
113
+ }, r = new MutationObserver(e);
114
+ r.observe(this, {
128
115
  childList: !0,
129
116
  subtree: !0
130
- }), this.signals.cleanup(() => p.disconnect()), f(), this.signals.run((e) => {
117
+ }), this.signals.cleanup(() => r.disconnect()), e(), this.signals.run((e) => {
131
118
  let t = e.get(this.connection.url);
132
119
  t ? this.setAttribute("url", t.toString()) : this.removeAttribute("url");
133
120
  }), this.signals.run((e) => {
@@ -144,23 +131,12 @@ var _ = new FinalizationRegistry((e) => e.close()), v = class extends HTMLElemen
144
131
  let t = e.get(this.controls.visible);
145
132
  this.setAttribute("visible", t);
146
133
  }), this.signals.run((e) => {
147
- let t = e.get(this.controls.latency);
148
- if (t === "instant") {
149
- this.#p("instant");
150
- return;
151
- }
152
- let { min: n, max: r } = c(t);
153
- if (n !== r) {
154
- this.getAttribute("latency") === "instant" && this.#p(void 0);
155
- return;
156
- }
157
- if (n === "real-time") this.#p("real-time");
158
- else {
159
- let t = Math.floor(e.get(this.sync.out.jitter));
160
- this.#p(t.toString());
161
- }
134
+ let t = e.get(this.controls.delay);
135
+ this.setAttribute("delay", typeof t == "number" ? s(t) : t);
136
+ }), this.signals.run((e) => {
137
+ this.setAttribute("buffer", s(e.get(this.controls.buffer)));
162
138
  });
163
- let m = (e, t) => {
139
+ let i = (e, t) => {
164
140
  if (e <= 0 || t <= 0) return;
165
141
  let n = window.devicePixelRatio || 1;
166
142
  this.controls.target.update((r) => ({
@@ -168,53 +144,40 @@ var _ = new FinalizationRegistry((e) => e.close()), v = class extends HTMLElemen
168
144
  width: Math.round(e * n),
169
145
  height: Math.round(t * n)
170
146
  }));
171
- }, h = new ResizeObserver((e) => {
147
+ }, a = new ResizeObserver((e) => {
172
148
  let t = e[0];
173
- t && m(t.contentRect.width, t.contentRect.height);
149
+ t && i(t.contentRect.width, t.contentRect.height);
174
150
  });
175
- h.observe(this), this.signals.cleanup(() => h.disconnect());
176
- let g = this.getBoundingClientRect();
177
- m(g.width, g.height);
151
+ a.observe(this), this.signals.cleanup(() => a.disconnect());
152
+ let o = this.getBoundingClientRect();
153
+ i(o.width, o.height);
178
154
  }
179
155
  connectedCallback() {
180
- this.#u.set(!0), this.style.display = "block", this.style.position = "relative";
181
- }
182
- disconnectedCallback() {
183
- this.#u.set(!1);
184
- }
185
- #f(e) {
186
- if (!e || e === "real-time") return "real-time";
187
- if (e === "instant") return console.warn("moq-watch: \"instant\" is not a bound, use latency=\"instant\""), "real-time";
188
- let t = Number.parseFloat(e);
189
- return d.Time.Milli(Number.isFinite(t) ? t : 100);
190
- }
191
- #p(e) {
192
- this.#s = !0;
193
- try {
194
- e === void 0 ? this.removeAttribute("latency") : this.setAttribute("latency", e);
195
- } finally {
196
- this.#s = !1;
156
+ if (this.#s.set(!0), this.style.display = "block", this.style.position = "relative", !this.#o) {
157
+ let e = document.createElement("div");
158
+ e.style.position = "absolute", e.style.inset = "0", e.style.pointerEvents = "none", e.style.zIndex = "1", this.appendChild(e), this.#o = e, this.#a.set(e);
197
159
  }
198
160
  }
199
- #m(e) {
200
- return e?.trim() === "instant" ? "instant" : this.#f(e);
161
+ disconnectedCallback() {
162
+ this.#s.set(!1);
201
163
  }
202
- attributeChangedCallback(e, t, n) {
203
- if (t !== n) {
204
- if (e === "url") this.connection.url.set(n ? new URL(n) : void 0);
205
- else if (e === "name") this.#e.set(d.Path.from(n ?? ""));
206
- else if (e === "paused") this.controls.paused.set(g(n, !1));
164
+ attributeChangedCallback(e, t, r) {
165
+ if (t !== r) {
166
+ if (e === "url") this.connection.url.set(r ? new URL(r) : void 0);
167
+ else if (e === "name") this.#e.set(n.Path.from(r ?? ""));
168
+ else if (e === "paused") this.controls.paused.set(p(r, !1));
207
169
  else if (e === "volume") {
208
- let e = n ? Number.parseFloat(n) : .5;
170
+ let e = r ? Number.parseFloat(r) : .5;
209
171
  this.controls.volume.set(e);
210
- } else if (e === "muted") this.controls.muted.set(g(n, !1));
211
- else if (e === "visible") this.controls.visible.set(h(n));
212
- else if (e === "reload") this.#t.set(g(n, !0));
213
- else if (e === "latency") this.#s || (this.latency = this.#m(n));
214
- else if (e === "latency-min") this.latencyMin = this.#f(n);
215
- else if (e === "latency-max") this.latencyMax = this.#f(n);
216
- else if (e === "jitter") this.latency = this.#f(n);
217
- else if (e === "catalog-format") this.#n.set(i(n));
172
+ } else if (e === "muted") this.controls.muted.set(p(r, !1));
173
+ else if (e === "visible") this.controls.visible.set(l(r));
174
+ else if (e === "announced") this.#t.set(p(r, !0));
175
+ else if (e === "delay") this.controls.delay.set(u(r));
176
+ else if (e === "buffer") this.controls.buffer.set(d(r));
177
+ else if (e === "reload") console.warn("moq-watch: `reload` was renamed to `announced`");
178
+ else if (e === "latency" || e === "latency-min" || e === "jitter") console.warn(`moq-watch: \`${e}\` is gone; use \`delay\` and \`buffer\``);
179
+ else if (e === "catalog-format") this.#n.set(f(r));
180
+ else if (e === "captions") this.controls.captions.set(r || void 0);
218
181
  else throw Error(`Invalid attribute: ${e}`);
219
182
  }
220
183
  }
@@ -228,7 +191,7 @@ var _ = new FinalizationRegistry((e) => e.close()), v = class extends HTMLElemen
228
191
  return this.#e.peek();
229
192
  }
230
193
  set name(e) {
231
- this.#e.set(d.Path.from(e));
194
+ this.#e.set(n.Path.from(e));
232
195
  }
233
196
  get paused() {
234
197
  return this.controls.paused.peek();
@@ -254,37 +217,50 @@ var _ = new FinalizationRegistry((e) => e.close()), v = class extends HTMLElemen
254
217
  set visible(e) {
255
218
  this.controls.visible.set(e);
256
219
  }
257
- get reload() {
220
+ get announced() {
258
221
  return this.#t.peek();
259
222
  }
260
- set reload(e) {
223
+ set announced(e) {
261
224
  this.#t.set(e);
262
225
  }
226
+ set reload(e) {
227
+ throw Error("moq-watch: `reload` was renamed to `announced`");
228
+ }
229
+ get delay() {
230
+ return this.controls.delay.peek();
231
+ }
232
+ set delay(e) {
233
+ this.controls.delay.set(e);
234
+ }
235
+ get buffer() {
236
+ return this.controls.buffer.peek();
237
+ }
238
+ set buffer(e) {
239
+ this.controls.buffer.set(e);
240
+ }
263
241
  get latency() {
264
- return this.controls.latency.peek();
242
+ return this.controls.delay.peek();
265
243
  }
266
244
  set latency(e) {
267
- this.controls.latency.set(e);
245
+ throw Error("moq-watch: `latency` is gone; use `delay` and `buffer`");
268
246
  }
269
247
  get latencyMin() {
270
- return c(this.controls.latency.peek()).min;
248
+ return this.controls.delay.peek();
271
249
  }
272
250
  set latencyMin(e) {
273
- let { max: t } = c(this.controls.latency.peek());
274
- this.controls.latency.set(l(e, t));
275
- }
276
- get latencyMax() {
277
- return c(this.controls.latency.peek()).max;
251
+ throw Error("moq-watch: `latencyMin` is gone; use `delay` and `buffer`");
278
252
  }
279
253
  set latencyMax(e) {
280
- let { min: t } = c(this.controls.latency.peek());
281
- this.controls.latency.set(l(t, e));
254
+ throw Error("moq-watch: `latencyMax` is gone. Use `buffer`, the media held beyond the live edge; the old ceiling included the floor, so it is `latencyMax - delay`.");
282
255
  }
283
256
  get jitter() {
284
257
  return this.sync.out.jitter.peek();
285
258
  }
259
+ set jitter(e) {
260
+ throw Error("moq-watch: `jitter` is a readout; set `delay` instead");
261
+ }
286
262
  reset() {
287
- this.sync.reset(), this.audio.reset();
263
+ this.player.reset();
288
264
  }
289
265
  get catalogFormat() {
290
266
  return this.#n.peek();
@@ -298,9 +274,15 @@ var _ = new FinalizationRegistry((e) => e.close()), v = class extends HTMLElemen
298
274
  set catalog(e) {
299
275
  this.#r.set(e);
300
276
  }
277
+ get captions() {
278
+ return this.controls.captions.peek();
279
+ }
280
+ set captions(e) {
281
+ this.controls.captions.set(e || void 0);
282
+ }
301
283
  };
302
- customElements.define("moq-watch", v);
284
+ customElements.define("moq-watch", h);
303
285
  //#endregion
304
- export { v as default };
286
+ export { h as default, f as parseCatalogFormat };
305
287
 
306
288
  //# sourceMappingURL=element.js.map
package/element.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"element.js","names":[],"sources":["../src/element.ts"],"sourcesContent":["/**\n * The `<moq-watch>` custom element: a broadcast player driven by HTML attributes.\n *\n * Side-effectful: importing this registers the element.\n *\n * @module\n */\nimport type * as Catalog from \"@moq/hang/catalog\";\nimport type { Time } from \"@moq/net\";\nimport * as Moq from \"@moq/net\";\nimport { Effect, Signal } from \"@moq/signals\";\nimport * as Audio from \"./audio\";\nimport { Broadcast, type CatalogFormat, parseCatalogFormat } from \"./broadcast\";\nimport { type Bound, type Latency, latencyBounds, latencyFromBounds, type Paced, Sync } from \"./sync\";\nimport * as Video from \"./video\";\n\nconst OBSERVED = [\n\t\"url\",\n\t\"name\",\n\t\"paused\",\n\t\"volume\",\n\t\"muted\",\n\t\"visible\",\n\t\"reload\",\n\t\"latency\",\n\t\"latency-min\",\n\t\"latency-max\",\n\t\"jitter\",\n\t\"catalog-format\",\n] as const;\ntype Observed = (typeof OBSERVED)[number];\n\n// Parse the `visible` attribute into a Visible value, falling back to \"20%\".\nfunction parseVisible(value: string | null): Video.Visible {\n\tconst trimmed = value?.trim();\n\tif (!trimmed) return \"20%\";\n\tif (trimmed === \"never\" || trimmed === \"always\") return trimmed;\n\t// A CSS length usable as an IntersectionObserver rootMargin (px or %).\n\tif (/^-?\\d+(\\.\\d+)?(px|%)$/.test(trimmed)) return trimmed;\n\t// Allow a bare number as a px convenience (e.g. visible=\"200\").\n\tif (/^-?\\d+(\\.\\d+)?$/.test(trimmed)) return `${trimmed}px`;\n\tconsole.warn(`moq-watch: invalid visible=\"${value}\", expected \"never\", \"always\", or a CSS length like \"200px\"`);\n\treturn \"20%\";\n}\n\n/**\n * Parse a boolean attribute: absent uses `defaultValue`, bare presence is true, and an explicit\n * `\"false\"`/`\"0\"` is false. Presence alone can't express false, and attributes that default to\n * true (`reload`) need to, so every boolean attribute accepts the explicit form.\n */\nfunction parseBoolean(value: string | null, defaultValue: boolean): boolean {\n\tif (value === null) return defaultValue;\n\tconst normalized = value.trim().toLowerCase();\n\treturn normalized !== \"false\" && normalized !== \"0\";\n}\n\n// Close everything when this element is garbage collected.\n// This is primarily to avoid a console.warn that we didn't close() before GC.\n// There's no destructor for web components so this is the best we can do.\nconst cleanup = new FinalizationRegistry<Effect>((signals) => signals.close());\n\n// An optional web component that wraps a <canvas>\nexport default class MoqWatch extends HTMLElement {\n\tstatic observedAttributes = OBSERVED;\n\n\t// The connection to the moq-relay server.\n\tconnection: Moq.Connection.Reload;\n\n\t// The broadcast being watched.\n\tbroadcast: Broadcast;\n\n\t/** Downloads and decodes the video track. `video.source` picks the rendition. */\n\tvideo: Video.Decoder;\n\n\t/** Downloads and decodes the audio track. `audio.source` picks the rendition. */\n\taudio: Audio.Decoder;\n\n\t/** Paints decoded frames to the nested <canvas>. */\n\trenderer: Video.Renderer;\n\n\t/** Plays decoded samples through the speakers. */\n\temitter: Audio.Emitter;\n\n\t/** Keeps audio and video playing at the target latency. */\n\tsync: Sync;\n\n\t// The mutable user controls. As the top of the tree, this element owns the\n\t// writable Signals and wires read-only views into the pipeline. The UI and\n\t// the attribute/property accessors read and write these directly.\n\treadonly controls = {\n\t\tpaused: new Signal(false),\n\t\tvolume: new Signal(0.5),\n\t\tmuted: new Signal(false),\n\t\t// When video is downloaded relative to the canvas position. See {@link Video.Visible}.\n\t\tvisible: new Signal<Video.Visible>(\"20%\"),\n\t\tlatency: new Signal<Latency>(\"real-time\"),\n\t\t// The desired video rendition (resolution/bitrate cap).\n\t\ttarget: new Signal<Video.Target | undefined>(undefined),\n\t\t// The desired audio rendition, by track name — a player choosing one sound\n\t\t// among several (a language, say). Unset, the first playable is taken.\n\t\taudioTarget: new Signal<Audio.Target | undefined>(undefined),\n\t};\n\n\t// Broadcast configuration owned here and wired into `broadcast` as inputs.\n\t#name = new Signal<Moq.Path.Valid>(Moq.Path.empty());\n\t#reload = new Signal(true);\n\t#catalogFormat = new Signal<CatalogFormat | undefined>(undefined);\n\t#catalog = new Signal<Catalog.Root | undefined>(undefined);\n\n\t// The canvas element to render into.\n\t#canvas = new Signal<HTMLCanvasElement | undefined>(undefined);\n\n\t// Whether to download. Driven by the renderer/emitter policy, read by the decoders.\n\t#videoEnabled = new Signal(false);\n\t#audioEnabled = new Signal(false);\n\n\t// Set while this element writes the `latency` attribute itself, so attributeChangedCallback\n\t// ignores the echo. Dropping a stale value would otherwise parse back as \"real-time\" and\n\t// clobber the range that replaced it.\n\t#reflectingLatency = false;\n\n\t// Whether video paces off the clock, cleared while the latency is \"instant\".\n\t#videoPaced = new Signal(true);\n\n\t// The latency handed to Sync, which has no way to express \"instant\".\n\t#syncLatency = new Signal<Paced>(\"real-time\");\n\n\t// Set when the element is connected to the DOM.\n\t#enabled = new Signal(false);\n\n\t// Stashed volume to restore on unmute.\n\t#unmuteVolume = 0.5;\n\n\t/**\n\t * Effects scoped to this element's lifetime, closed on disconnect.\n\t *\n\t * Public because the element is the top of the tree: it's where an application hangs its own\n\t * reactivity. The components underneath keep theirs private, so `close()` is the only handle.\n\t */\n\treadonly signals = new Effect();\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tcleanup.register(this, this.signals);\n\n\t\tthis.connection = new Moq.Connection.Reload({\n\t\t\tenabled: this.#enabled,\n\t\t});\n\t\tthis.signals.cleanup(() => this.connection.close());\n\n\t\tthis.broadcast = new Broadcast({\n\t\t\tconnection: this.connection.established,\n\t\t\tenabled: this.#enabled,\n\t\t\tname: this.#name,\n\t\t\treload: this.#reload,\n\t\t\tcatalogFormat: this.#catalogFormat,\n\t\t\tcatalog: this.#catalog,\n\t\t});\n\t\tthis.signals.cleanup(() => this.broadcast.close());\n\n\t\t// The decoders' support probes drive rendition selection: anything WebCodecs can't play is filtered out.\n\t\tconst videoSource = new Video.Source({\n\t\t\tbroadcast: this.broadcast,\n\t\t\ttarget: this.controls.target,\n\t\t\tsupported: Video.Decoder.supported,\n\t\t});\n\t\tconst audioSource = new Audio.Source({\n\t\t\tbroadcast: this.broadcast,\n\t\t\ttarget: this.controls.audioTarget,\n\t\t\tsupported: Audio.Decoder.supported,\n\t\t});\n\t\tthis.signals.cleanup(() => {\n\t\t\tvideoSource.close();\n\t\t\taudioSource.close();\n\t\t});\n\n\t\t// Sources produce the per-rendition jitter that Sync reads, so they're created\n\t\t// before Sync to avoid a construction cycle.\n\t\t//\n\t\t// Sync can't implement \"instant\" on its own: not pacing video and disabling audio happens\n\t\t// here. Hand it a zero buffer instead.\n\t\tthis.signals.run((effect) => {\n\t\t\tconst latency = effect.get(this.controls.latency);\n\t\t\tthis.#syncLatency.set(latency === \"instant\" ? Moq.Time.Milli.zero : latency);\n\t\t});\n\n\t\tthis.sync = new Sync({\n\t\t\tlatency: this.#syncLatency,\n\t\t\tconnection: this.connection.established,\n\t\t\tvideo: videoSource.out.jitter,\n\t\t\taudio: audioSource.out.jitter,\n\t\t});\n\t\tthis.signals.cleanup(() => this.sync.close());\n\n\t\t// `latency=\"instant\"` stops video waiting on the clock, so frames paint the moment they\n\t\t// decode. The clock stays wired: it still tracks receipts and rewinds.\n\t\tthis.signals.run((effect) => {\n\t\t\tthis.#videoPaced.set(effect.get(this.controls.latency) !== \"instant\");\n\t\t});\n\n\t\tthis.video = new Video.Decoder(videoSource, this.sync, {\n\t\t\tenabled: this.#videoEnabled,\n\t\t\tpaced: this.#videoPaced,\n\t\t});\n\t\tthis.audio = new Audio.Decoder(audioSource, this.sync, { enabled: this.#audioEnabled });\n\t\tthis.signals.cleanup(() => {\n\t\t\tthis.video.close();\n\t\t\tthis.audio.close();\n\t\t});\n\n\t\tthis.emitter = new Audio.Emitter(this.audio, {\n\t\t\tvolume: this.controls.volume,\n\t\t\tmuted: this.controls.muted,\n\t\t\tpaused: this.controls.paused,\n\t\t});\n\t\tthis.renderer = new Video.Renderer(this.video, {\n\t\t\tcanvas: this.#canvas,\n\t\t\tvisible: this.controls.visible,\n\t\t});\n\t\tthis.signals.cleanup(() => {\n\t\t\tthis.emitter.close();\n\t\t\tthis.renderer.close();\n\t\t});\n\n\t\t// Audio download follows the emitter's enable policy (paused/muted), except an instant\n\t\t// latency turns it off outright: the ring needs a target depth to avoid underrunning, and\n\t\t// unpaced video has nothing pulling it back toward the audio clock.\n\t\tthis.signals.run((effect) => {\n\t\t\tconst enabled = effect.get(this.emitter.out.enabled);\n\t\t\tthis.#audioEnabled.set(enabled && effect.get(this.controls.latency) !== \"instant\");\n\t\t});\n\n\t\t// Stopping the download leaves the ring holding a floor's worth of PCM, and the emitter\n\t\t// stays connected to drain it. Flush on the way in so audio stops now instead of playing\n\t\t// against video that just jumped to the live edge.\n\t\tthis.signals.run((effect) => {\n\t\t\tif (effect.get(this.controls.latency) !== \"instant\") return;\n\t\t\tthis.audio.reset();\n\t\t});\n\n\t\t// Video downloads while playing and on-screen. When paused, keep downloading only\n\t\t// until a frame is on the canvas, then stop: a cold paused start still shows a poster\n\t\t// instead of black, without streaming while paused. Read the rendered frame only in\n\t\t// the paused branch so playback doesn't re-run this every painted frame.\n\t\tthis.signals.run((effect) => {\n\t\t\tconst visible = effect.get(this.renderer.out.visible);\n\t\t\tif (!effect.get(this.controls.paused)) {\n\t\t\t\tthis.#videoEnabled.set(visible);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst frame = effect.get(this.renderer.out.frame);\n\t\t\tthis.#videoEnabled.set(visible && !frame);\n\t\t});\n\n\t\t// Mute/volume coupling. The element owns the writable volume/muted Signals, so\n\t\t// the policy lives here: muting stashes and zeroes the volume; a zero volume\n\t\t// reports as muted.\n\t\tthis.signals.run((effect) => {\n\t\t\tconst muted = effect.get(this.controls.muted);\n\t\t\tif (muted) {\n\t\t\t\tthis.#unmuteVolume = this.controls.volume.peek() || 0.5;\n\t\t\t\tthis.controls.volume.set(0);\n\t\t\t} else {\n\t\t\t\tthis.controls.volume.set(this.#unmuteVolume);\n\t\t\t}\n\t\t});\n\t\tthis.signals.run((effect) => {\n\t\t\tconst volume = effect.get(this.controls.volume);\n\t\t\tthis.controls.muted.set(volume === 0);\n\t\t});\n\n\t\t// Watch to see if the canvas element is added or removed.\n\t\tconst setCanvas = () => {\n\t\t\tconst canvas = this.querySelector(\"canvas\") ?? undefined;\n\n\t\t\t// A <video> child used to render via MSE. Nothing renders it now, and audio still plays,\n\t\t\t// so the failure looks like a bug in the page instead of a removed feature.\n\t\t\tif (!canvas && this.querySelector(\"video\")) {\n\t\t\t\tconsole.warn(\"moq-watch: rendering requires a <canvas> child; a <video> child does nothing.\");\n\t\t\t}\n\n\t\t\tthis.#canvas.set(canvas);\n\t\t};\n\n\t\tconst observer = new MutationObserver(setCanvas);\n\t\tobserver.observe(this, { childList: true, subtree: true });\n\t\tthis.signals.cleanup(() => observer.disconnect());\n\t\tsetCanvas();\n\n\t\t// Optionally update attributes to match the library state.\n\t\t// This is kind of dangerous because it can create loops.\n\t\t// NOTE: This only runs when the element is connected to the DOM, which is not obvious.\n\t\t// This is because there's no destructor for web components to clean up our effects.\n\t\tthis.signals.run((effect) => {\n\t\t\tconst url = effect.get(this.connection.url);\n\t\t\tif (url) {\n\t\t\t\tthis.setAttribute(\"url\", url.toString());\n\t\t\t} else {\n\t\t\t\tthis.removeAttribute(\"url\");\n\t\t\t}\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst name = effect.get(this.#name);\n\t\t\tthis.setAttribute(\"name\", name.toString());\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst muted = effect.get(this.controls.muted);\n\t\t\tif (muted) {\n\t\t\t\tthis.setAttribute(\"muted\", \"\");\n\t\t\t} else {\n\t\t\t\tthis.removeAttribute(\"muted\");\n\t\t\t}\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst paused = effect.get(this.controls.paused);\n\t\t\tif (paused) {\n\t\t\t\tthis.setAttribute(\"paused\", \"\");\n\t\t\t} else {\n\t\t\t\tthis.removeAttribute(\"paused\");\n\t\t\t}\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst volume = effect.get(this.controls.volume);\n\t\t\tthis.setAttribute(\"volume\", volume.toString());\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst visible = effect.get(this.controls.visible);\n\t\t\tthis.setAttribute(\"visible\", visible);\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst latency = effect.get(this.controls.latency);\n\t\t\tif (latency === \"instant\") {\n\t\t\t\tthis.#reflectLatency(\"instant\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { min, max } = latencyBounds(latency);\n\t\t\t// Only reflect the collapsed `latency` sugar attribute when the range is actually\n\t\t\t// collapsed. An open range is expressed via latency-min/latency-max, and writing\n\t\t\t// `latency` here would round-trip back through attributeChangedCallback and collapse it.\n\t\t\tif (min !== max) {\n\t\t\t\t// Still drop a stale \"instant\": leaving it would advertise a mode the element is no\n\t\t\t\t// longer in, and a clone would come back up in it.\n\t\t\t\tif (this.getAttribute(\"latency\") === \"instant\") this.#reflectLatency(undefined);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (min === \"real-time\") {\n\t\t\t\tthis.#reflectLatency(\"real-time\");\n\t\t\t} else {\n\t\t\t\tconst jitter = Math.floor(effect.get(this.sync.out.jitter));\n\t\t\t\tthis.#reflectLatency(jitter.toString());\n\t\t\t}\n\t\t});\n\n\t\t// Track the element's rendered size and feed it into the rendition picker,\n\t\t// scaled by devicePixelRatio so high-DPI screens still get sharp renditions.\n\t\tconst updateDimensions = (width: number, height: number) => {\n\t\t\tif (width <= 0 || height <= 0) return;\n\t\t\tconst dpr = window.devicePixelRatio || 1;\n\t\t\tthis.controls.target.update((prev) => ({\n\t\t\t\t...prev,\n\t\t\t\twidth: Math.round(width * dpr),\n\t\t\t\theight: Math.round(height * dpr),\n\t\t\t}));\n\t\t};\n\n\t\tconst resizeObserver = new ResizeObserver((entries) => {\n\t\t\tconst entry = entries[0];\n\t\t\tif (!entry) return;\n\t\t\tupdateDimensions(entry.contentRect.width, entry.contentRect.height);\n\t\t});\n\t\tresizeObserver.observe(this);\n\t\tthis.signals.cleanup(() => resizeObserver.disconnect());\n\n\t\t// Seed with the current size in case the observer doesn't fire immediately\n\t\t// (e.g. the element is still 0x0 when we attach).\n\t\tconst rect = this.getBoundingClientRect();\n\t\tupdateDimensions(rect.width, rect.height);\n\t}\n\n\t// Annoyingly, we have to use these callbacks to figure out when the element is connected to the DOM.\n\t// This wouldn't be so bad if there was a destructor for web components to clean up our effects.\n\tconnectedCallback() {\n\t\tthis.#enabled.set(true);\n\t\tthis.style.display = \"block\";\n\t\tthis.style.position = \"relative\";\n\t}\n\n\tdisconnectedCallback() {\n\t\t// Stop everything but don't actually cleanup just in case we get added back to the DOM.\n\t\tthis.#enabled.set(false);\n\t}\n\n\t// Parse a single latency bound: absent or \"real-time\" is adaptive, otherwise a fixed ms value.\n\t#parseBound(value: string | null): Bound {\n\t\tif (!value || value === \"real-time\") return \"real-time\";\n\t\tif (value === \"instant\") {\n\t\t\tconsole.warn('moq-watch: \"instant\" is not a bound, use latency=\"instant\"');\n\t\t\treturn \"real-time\";\n\t\t}\n\t\tconst parsed = Number.parseFloat(value);\n\t\treturn Moq.Time.Milli(Number.isFinite(parsed) ? parsed : 100);\n\t}\n\n\t// Write the `latency` attribute (undefined removes it) without the echo coming back through\n\t// attributeChangedCallback. Custom element reactions run before setAttribute/removeAttribute\n\t// returns, so the flag still covers the callback.\n\t#reflectLatency(value: string | undefined): void {\n\t\tthis.#reflectingLatency = true;\n\t\ttry {\n\t\t\tif (value === undefined) this.removeAttribute(\"latency\");\n\t\t\telse this.setAttribute(\"latency\", value);\n\t\t} finally {\n\t\t\tthis.#reflectingLatency = false;\n\t\t}\n\t}\n\n\t// Parse the `latency` attribute, which also accepts the range-replacing \"instant\".\n\t#parseLatency(value: string | null): Latency {\n\t\treturn value?.trim() === \"instant\" ? \"instant\" : this.#parseBound(value);\n\t}\n\n\tattributeChangedCallback(name: Observed, oldValue: string | null, newValue: string | null) {\n\t\tif (oldValue === newValue) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (name === \"url\") {\n\t\t\tthis.connection.url.set(newValue ? new URL(newValue) : undefined);\n\t\t} else if (name === \"name\") {\n\t\t\tthis.#name.set(Moq.Path.from(newValue ?? \"\"));\n\t\t} else if (name === \"paused\") {\n\t\t\tthis.controls.paused.set(parseBoolean(newValue, false));\n\t\t} else if (name === \"volume\") {\n\t\t\tconst volume = newValue ? Number.parseFloat(newValue) : 0.5;\n\t\t\tthis.controls.volume.set(volume);\n\t\t} else if (name === \"muted\") {\n\t\t\tthis.controls.muted.set(parseBoolean(newValue, false));\n\t\t} else if (name === \"visible\") {\n\t\t\tthis.controls.visible.set(parseVisible(newValue));\n\t\t} else if (name === \"reload\") {\n\t\t\tthis.#reload.set(parseBoolean(newValue, true));\n\t\t} else if (name === \"latency\") {\n\t\t\t// Sugar: collapse the floor and ceiling to a single value.\n\t\t\tif (!this.#reflectingLatency) this.latency = this.#parseLatency(newValue);\n\t\t} else if (name === \"latency-min\") {\n\t\t\tthis.latencyMin = this.#parseBound(newValue);\n\t\t} else if (name === \"latency-max\") {\n\t\t\tthis.latencyMax = this.#parseBound(newValue);\n\t\t} else if (name === \"jitter\") {\n\t\t\t// Deprecated: use latency=\"<number>\" instead.\n\t\t\tthis.latency = this.#parseBound(newValue);\n\t\t} else if (name === \"catalog-format\") {\n\t\t\tthis.#catalogFormat.set(parseCatalogFormat(newValue));\n\t\t} else {\n\t\t\tconst exhaustive: never = name;\n\t\t\tthrow new Error(`Invalid attribute: ${exhaustive}`);\n\t\t}\n\t}\n\n\tget url(): URL | undefined {\n\t\treturn this.connection.url.peek();\n\t}\n\n\tset url(value: string | URL | undefined) {\n\t\tthis.connection.url.set(value ? new URL(value) : undefined);\n\t}\n\n\tget name(): Moq.Path.Valid {\n\t\treturn this.#name.peek();\n\t}\n\n\tset name(value: string | Moq.Path.Valid) {\n\t\tthis.#name.set(Moq.Path.from(value));\n\t}\n\n\tget paused(): boolean {\n\t\treturn this.controls.paused.peek();\n\t}\n\n\tset paused(value: boolean) {\n\t\tthis.controls.paused.set(value);\n\t}\n\n\tget volume(): number {\n\t\treturn this.controls.volume.peek();\n\t}\n\n\tset volume(value: number) {\n\t\tthis.controls.volume.set(value);\n\t}\n\n\tget muted(): boolean {\n\t\treturn this.controls.muted.peek();\n\t}\n\n\tset muted(value: boolean) {\n\t\tthis.controls.muted.set(value);\n\t}\n\n\tget visible(): Video.Visible {\n\t\treturn this.controls.visible.peek();\n\t}\n\n\tset visible(value: Video.Visible) {\n\t\tthis.controls.visible.set(value);\n\t}\n\n\tget reload(): boolean {\n\t\treturn this.#reload.peek();\n\t}\n\n\tset reload(value: boolean) {\n\t\tthis.#reload.set(value);\n\t}\n\n\t/**\n\t * The latency target. Assign a scalar (or `\"real-time\"`) to minimize latency, or an object\n\t * `{ min, max }` to open a range and buffer future-dated frames. See {@link Latency}.\n\t *\n\t * `\"instant\"` drops the clock instead: video paints the moment it decodes and audio is\n\t * disabled. Assigning `latencyMin` or `latencyMax` leaves that mode, since both write a range.\n\t */\n\tget latency(): Latency {\n\t\treturn this.controls.latency.peek();\n\t}\n\n\tset latency(value: Latency) {\n\t\tthis.controls.latency.set(value);\n\t}\n\n\t/** The latency floor (jitter/startup buffer). Read-modify-writes `latency`, leaving the ceiling. */\n\tget latencyMin(): Bound {\n\t\treturn latencyBounds(this.controls.latency.peek()).min;\n\t}\n\n\tset latencyMin(value: Bound) {\n\t\tconst { max } = latencyBounds(this.controls.latency.peek());\n\t\tthis.controls.latency.set(latencyFromBounds(value, max));\n\t}\n\n\t/**\n\t * The latency ceiling: `\"real-time\"` (default) minimizes, a number caps at that many ms. A\n\t * ceiling above the floor enables buffered playback: build up a buffer from future-dated frames\n\t * (e.g. TTS written faster than real-time) and only skip ahead past the cap. Call `reset()` at\n\t * each utterance boundary. Read-modify-writes `latency`, leaving the floor untouched.\n\t */\n\tget latencyMax(): Bound {\n\t\treturn latencyBounds(this.controls.latency.peek()).max;\n\t}\n\n\tset latencyMax(value: Bound) {\n\t\tconst { min } = latencyBounds(this.controls.latency.peek());\n\t\tthis.controls.latency.set(latencyFromBounds(min, value));\n\t}\n\n\t/** The jitter buffer in milliseconds. */\n\tget jitter(): Time.Milli {\n\t\treturn this.sync.out.jitter.peek();\n\t}\n\n\t/**\n\t * Re-anchor playback at an utterance boundary in buffered mode: reset the sync reference\n\t * and flush the audio buffer so the next utterance plays from its own first frame.\n\t */\n\treset(): void {\n\t\tthis.sync.reset();\n\t\tthis.audio.reset();\n\t}\n\n\tget catalogFormat(): CatalogFormat | undefined {\n\t\treturn this.#catalogFormat.peek();\n\t}\n\n\tset catalogFormat(value: CatalogFormat | undefined) {\n\t\tthis.#catalogFormat.set(value);\n\t}\n\n\t/**\n\t * The active catalog. Assign directly when `catalogFormat` is `\"manual\"`;\n\t * for `\"hang\"` and `\"msf\"` this is overwritten by the fetch loop.\n\t */\n\tget catalog(): Catalog.Root | undefined {\n\t\treturn this.broadcast.out.catalog.peek();\n\t}\n\n\tset catalog(value: Catalog.Root | undefined) {\n\t\tthis.#catalog.set(value);\n\t}\n}\n\ncustomElements.define(\"moq-watch\", MoqWatch);\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"moq-watch\": MoqWatch;\n\t}\n}\n"],"mappings":";;;;;AAgBA,IAAM,IAAW;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAIA,SAAS,EAAa,GAAqC;CA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,IAAI,QAAQ,GAAgB;EAC3B,KAAK,SAAS,QAAQ,IAAI,CAAK;CAChC;CAGA,IAAI,aAAoB;EACvB,OAAO,EAAc,KAAK,SAAS,QAAQ,KAAK,CAAC,CAAC,CAAC;CACpD;CAEA,IAAI,WAAW,GAAc;EAC5B,IAAM,EAAE,WAAQ,EAAc,KAAK,SAAS,QAAQ,KAAK,CAAC;EAC1D,KAAK,SAAS,QAAQ,IAAI,EAAkB,GAAO,CAAG,CAAC;CACxD;CAQA,IAAI,aAAoB;EACvB,OAAO,EAAc,KAAK,SAAS,QAAQ,KAAK,CAAC,CAAC,CAAC;CACpD;CAEA,IAAI,WAAW,GAAc;EAC5B,IAAM,EAAE,WAAQ,EAAc,KAAK,SAAS,QAAQ,KAAK,CAAC;EAC1D,KAAK,SAAS,QAAQ,IAAI,EAAkB,GAAK,CAAK,CAAC;CACxD;CAGA,IAAI,SAAqB;EACxB,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK;CAClC;CAMA,QAAc;EAEb,AADA,KAAK,KAAK,MAAM,GAChB,KAAK,MAAM,MAAM;CAClB;CAEA,IAAI,gBAA2C;EAC9C,OAAO,KAAK,GAAe,KAAK;CACjC;CAEA,IAAI,cAAc,GAAkC;EACnD,KAAK,GAAe,IAAI,CAAK;CAC9B;CAMA,IAAI,UAAoC;EACvC,OAAO,KAAK,UAAU,IAAI,QAAQ,KAAK;CACxC;CAEA,IAAI,QAAQ,GAAiC;EAC5C,KAAK,GAAS,IAAI,CAAK;CACxB;AACD;AAEA,eAAe,OAAO,aAAa,CAAQ"}
1
+ {"version":3,"file":"element.js","names":[],"sources":["../src/duration.ts","../src/element.ts"],"sourcesContent":["import { Time } from \"@moq/net\";\n\n/**\n * Parse a duration attribute: `\"300ms\"`, `\"30s\"`, or a bare `\"0\"`.\n *\n * A bare number other than zero is rejected rather than guessed at. Most players measure these in\n * seconds while we store milliseconds, so assuming a unit would turn a value copied from another\n * player into a 1000x error. Zero is exempt because `0ms` and `0s` are the same value.\n *\n * Returns undefined when the value doesn't parse, leaving the fallback to the caller.\n *\n * @internal\n */\nexport function parseDuration(value: string): Time.Milli | undefined {\n\tconst match = /^(\\d+(?:\\.\\d+)?)(ms|s)?$/.exec(value.trim());\n\tif (!match) return undefined;\n\n\tconst amount = Number.parseFloat(match[1]);\n\tif (!Number.isFinite(amount)) return undefined;\n\tif (match[2] === undefined) return amount === 0 ? Time.Milli.zero : undefined;\n\n\treturn Time.Milli(match[2] === \"s\" ? amount * 1000 : amount);\n}\n\n/**\n * Render a duration back out as an attribute value, in the canonical unit.\n *\n * Not rounded: the reflected attribute is parsed straight back into the signal, so rounding here\n * would rewrite the value behind the caller (`1.5ms` becoming `2ms`, and `0.4ms` becoming zero,\n * which also switches buffered playback off).\n *\n * @internal\n */\nexport function formatDuration(value: Time.Milli): string {\n\treturn `${value}ms`;\n}\n","/**\n * The `<moq-watch>` custom element: a broadcast player driven by HTML attributes.\n *\n * Side-effectful: importing this registers the element.\n *\n * @module\n */\nimport type * as Catalog from \"@moq/hang/catalog\";\nimport type { Time } from \"@moq/net\";\nimport * as Moq from \"@moq/net\";\nimport { Effect, Signal } from \"@moq/signals\";\nimport type * as Audio from \"./audio\";\nimport { type Broadcast, CATALOG_FORMATS, type CatalogFormat } from \"./broadcast\";\nimport { formatDuration, parseDuration } from \"./duration\";\nimport { Player } from \"./player\";\nimport type { Delay, Sync } from \"./sync\";\nimport type * as Text from \"./text\";\nimport type * as Video from \"./video\";\n\nconst OBSERVED = [\n\t\"url\",\n\t\"name\",\n\t\"paused\",\n\t\"volume\",\n\t\"muted\",\n\t\"visible\",\n\t\"announced\",\n\t\"delay\",\n\t\"buffer\",\n\t// Released spellings are observed only so assigning them can fail loudly instead of being ignored.\n\t\"reload\",\n\t\"latency\",\n\t\"latency-min\",\n\t\"jitter\",\n\t\"catalog-format\",\n\t\"captions\",\n] as const;\ntype Observed = (typeof OBSERVED)[number];\n\n// Parse the `visible` attribute into a Visible value, falling back to \"20%\".\nfunction parseVisible(value: string | null): Video.Visible {\n\tconst trimmed = value?.trim();\n\tif (!trimmed) return \"20%\";\n\tif (trimmed === \"never\" || trimmed === \"always\") return trimmed;\n\t// A CSS length usable as an IntersectionObserver rootMargin (px or %).\n\tif (/^-?\\d+(\\.\\d+)?(px|%)$/.test(trimmed)) return trimmed;\n\t// Allow a bare number as a px convenience (e.g. visible=\"200\").\n\tif (/^-?\\d+(\\.\\d+)?$/.test(trimmed)) return `${trimmed}px`;\n\tconsole.warn(`moq-watch: invalid visible=\"${value}\", expected \"never\", \"always\", or a CSS length like \"200px\"`);\n\treturn \"20%\";\n}\n\n// Parse the `delay` attribute: \"auto\" (adaptive), \"instant\" (no buffer, no pacing), or a duration.\nfunction parseDelay(value: string | null): Delay {\n\tconst trimmed = value?.trim();\n\tif (!trimmed || trimmed === \"auto\") return \"auto\";\n\tif (trimmed === \"instant\") return \"instant\";\n\tconst parsed = parseDuration(trimmed);\n\tif (parsed !== undefined) return parsed;\n\tconsole.warn(`moq-watch: invalid delay=\"${value}\", expected \"auto\", \"instant\", or a duration like \"300ms\"`);\n\treturn \"auto\";\n}\n\n// Parse the `buffer` attribute: a duration, or none when absent.\nfunction parseBuffer(value: string | null): Time.Milli {\n\tconst trimmed = value?.trim();\n\tif (!trimmed) return Moq.Time.Milli.zero;\n\tconst parsed = parseDuration(trimmed);\n\tif (parsed !== undefined) return parsed;\n\tconsole.warn(`moq-watch: invalid buffer=\"${value}\", expected a duration like \"30s\"`);\n\treturn Moq.Time.Milli.zero;\n}\n\n/** Parse the element's catalog-format attribute. */\nexport function parseCatalogFormat(value: string | null): CatalogFormat | undefined {\n\tif (value === null) return undefined;\n\treturn CATALOG_FORMATS.find((format) => format === value);\n}\n\n/**\n * Parse a boolean attribute: absent uses `defaultValue`, bare presence is true, and an explicit\n * `\"false\"`/`\"0\"` is false. Presence alone can't express false, and attributes that default to\n * true (`announced`) need to, so every boolean attribute accepts the explicit form.\n */\nfunction parseBoolean(value: string | null, defaultValue: boolean): boolean {\n\tif (value === null) return defaultValue;\n\tconst normalized = value.trim().toLowerCase();\n\treturn normalized !== \"false\" && normalized !== \"0\";\n}\n\n// Close everything when this element is garbage collected.\n// This is primarily to avoid a console.warn that we didn't close() before GC.\n// There's no destructor for web components so this is the best we can do.\nconst cleanup = new FinalizationRegistry<Effect>((signals) => signals.close());\n\n// An optional web component that wraps a <canvas>\nexport default class MoqWatch extends HTMLElement {\n\tstatic observedAttributes = OBSERVED;\n\n\t// The connection to the moq-relay server.\n\t/**\n\t * The relay connection, shared with every other element on the page pointing at the\n\t * same URL. Its `origin` is where the broadcasts live.\n\t */\n\tconnection: Moq.Connection;\n\n\t/** Headless playback pipeline behind this element. */\n\treadonly player: Player;\n\n\t// The broadcast being watched.\n\tbroadcast: Broadcast;\n\n\t/** Downloads and decodes the video track. `video.source` picks the rendition. */\n\tvideo: Video.Decoder;\n\n\t/** Downloads and decodes the audio track. `audio.source` picks the rendition. */\n\taudio: Audio.Decoder;\n\n\t/** Paints decoded frames to the nested <canvas>. */\n\trenderer: Video.Renderer;\n\n\t/** Plays decoded samples through the speakers. */\n\temitter: Audio.Emitter;\n\n\t/** Selects the caption track. `text.out.available` lists the renditions for a picker. */\n\ttext: Text.Source;\n\n\t/** Renders the selected text cues into an overlay above the canvas. */\n\ttextRenderer: Text.Renderer;\n\n\t/** Keeps audio and video playing at the configured delay. */\n\tsync: Sync;\n\n\t// The mutable user controls. As the top of the tree, this element owns the\n\t// writable Signals and wires read-only views into the pipeline. The UI and\n\t// the attribute/property accessors read and write these directly.\n\treadonly controls = {\n\t\tpaused: new Signal(false),\n\t\tvolume: new Signal(0.5),\n\t\tmuted: new Signal(false),\n\t\t// When video is downloaded relative to the canvas position. See {@link Video.Visible}.\n\t\tvisible: new Signal<Video.Visible>(\"20%\"),\n\t\t// How far playback trails the live edge.\n\t\tdelay: new Signal<Delay>(\"auto\"),\n\t\t// Future-dated media held beyond the live edge before playback skips ahead.\n\t\tbuffer: new Signal<Time.Milli>(Moq.Time.Milli.zero),\n\t\t// The desired video rendition (resolution/bitrate cap).\n\t\ttarget: new Signal<Video.Target | undefined>(undefined),\n\t\t// The desired audio rendition, by track name: a player choosing one sound\n\t\t// among several (a language, say). Unset, the first playable is taken.\n\t\taudioTarget: new Signal<Audio.Target | undefined>(undefined),\n\t\t// The selected caption track name, or undefined for off (the default; captions are opt-in).\n\t\tcaptions: new Signal<string | undefined>(undefined),\n\t};\n\n\t// Broadcast configuration owned here and wired into `broadcast` as inputs.\n\t#name = new Signal<Moq.Path.Valid>(Moq.Path.empty());\n\t#announced = new Signal(true);\n\t#catalogFormat = new Signal<CatalogFormat | undefined>(undefined);\n\t#catalog = new Signal<Catalog.Root | undefined>(undefined);\n\n\t// The canvas element to render into.\n\t#canvas = new Signal<HTMLCanvasElement | undefined>(undefined);\n\n\t// The overlay element captions are drawn into, created lazily on connect (custom elements may not\n\t// touch children in their constructor). Positioned to fill the element, above the canvas.\n\t#captionsOverlay = new Signal<HTMLElement | undefined>(undefined);\n\t#captionsOverlayEl?: HTMLDivElement;\n\n\t// Set when the element is connected to the DOM.\n\t#enabled = new Signal(false);\n\n\t// Stashed volume to restore on unmute.\n\t#unmuteVolume = 0.5;\n\n\t/**\n\t * Effects scoped to this element's lifetime, closed on disconnect.\n\t *\n\t * Public because the element is the top of the tree: it's where an application hangs its own\n\t * reactivity. The components underneath keep theirs private, so `close()` is the only handle.\n\t */\n\treadonly signals = new Effect();\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tcleanup.register(this, this.signals);\n\n\t\tthis.connection = new Moq.Connection({\n\t\t\tenabled: this.#enabled,\n\t\t});\n\t\tthis.signals.cleanup(() => this.connection.close());\n\n\t\tthis.player = new Player({\n\t\t\torigin: this.connection.origin,\n\t\t\tprobe: this.connection.probe,\n\t\t\tenabled: this.#enabled,\n\t\t\tname: this.#name,\n\t\t\tannounced: this.#announced,\n\t\t\tcatalogFormat: this.#catalogFormat,\n\t\t\tcatalog: this.#catalog,\n\t\t\tcanvas: this.#canvas,\n\t\t\tcontainer: this.#captionsOverlay,\n\t\t\t...this.controls,\n\t\t});\n\t\tthis.signals.cleanup(() => this.player.close());\n\t\tthis.broadcast = this.player.broadcast;\n\t\tthis.video = this.player.video;\n\t\tthis.audio = this.player.audio;\n\t\tthis.renderer = this.player.renderer;\n\t\tthis.emitter = this.player.emitter;\n\t\tthis.text = this.player.text;\n\t\tthis.textRenderer = this.player.textRenderer;\n\t\tthis.sync = this.player.sync;\n\n\t\t// Mute/volume coupling. The element owns the writable volume/muted Signals, so\n\t\t// the policy lives here: muting stashes and zeroes the volume; a zero volume\n\t\t// reports as muted.\n\t\tthis.signals.run((effect) => {\n\t\t\tconst muted = effect.get(this.controls.muted);\n\t\t\tif (muted) {\n\t\t\t\tthis.#unmuteVolume = this.controls.volume.peek() || 0.5;\n\t\t\t\tthis.controls.volume.set(0);\n\t\t\t} else {\n\t\t\t\tthis.controls.volume.set(this.#unmuteVolume);\n\t\t\t}\n\t\t});\n\t\tthis.signals.run((effect) => {\n\t\t\tconst volume = effect.get(this.controls.volume);\n\t\t\tthis.controls.muted.set(volume === 0);\n\t\t});\n\n\t\t// Watch to see if the canvas element is added or removed.\n\t\tconst setCanvas = () => {\n\t\t\tconst canvas = this.querySelector(\"canvas\") ?? undefined;\n\n\t\t\t// A <video> child used to render via MSE. Nothing renders it now, and audio still plays,\n\t\t\t// so the failure looks like a bug in the page instead of a removed feature.\n\t\t\tif (!canvas && this.querySelector(\"video\")) {\n\t\t\t\tconsole.warn(\"moq-watch: rendering requires a <canvas> child; a <video> child does nothing.\");\n\t\t\t}\n\n\t\t\tthis.#canvas.set(canvas);\n\t\t};\n\n\t\tconst observer = new MutationObserver(setCanvas);\n\t\tobserver.observe(this, { childList: true, subtree: true });\n\t\tthis.signals.cleanup(() => observer.disconnect());\n\t\tsetCanvas();\n\n\t\t// Optionally update attributes to match the library state.\n\t\t// This is kind of dangerous because it can create loops.\n\t\t// NOTE: This only runs when the element is connected to the DOM, which is not obvious.\n\t\t// This is because there's no destructor for web components to clean up our effects.\n\t\tthis.signals.run((effect) => {\n\t\t\tconst url = effect.get(this.connection.url);\n\t\t\tif (url) {\n\t\t\t\tthis.setAttribute(\"url\", url.toString());\n\t\t\t} else {\n\t\t\t\tthis.removeAttribute(\"url\");\n\t\t\t}\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst name = effect.get(this.#name);\n\t\t\tthis.setAttribute(\"name\", name.toString());\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst muted = effect.get(this.controls.muted);\n\t\t\tif (muted) {\n\t\t\t\tthis.setAttribute(\"muted\", \"\");\n\t\t\t} else {\n\t\t\t\tthis.removeAttribute(\"muted\");\n\t\t\t}\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst paused = effect.get(this.controls.paused);\n\t\t\tif (paused) {\n\t\t\t\tthis.setAttribute(\"paused\", \"\");\n\t\t\t} else {\n\t\t\t\tthis.removeAttribute(\"paused\");\n\t\t\t}\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst volume = effect.get(this.controls.volume);\n\t\t\tthis.setAttribute(\"volume\", volume.toString());\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst visible = effect.get(this.controls.visible);\n\t\t\tthis.setAttribute(\"visible\", visible);\n\t\t});\n\n\t\t// Each knob is 1:1 with its attribute, so the echo back through attributeChangedCallback\n\t\t// parses to the value already held and the effect settles.\n\t\tthis.signals.run((effect) => {\n\t\t\tconst delay = effect.get(this.controls.delay);\n\t\t\tthis.setAttribute(\"delay\", typeof delay === \"number\" ? formatDuration(delay) : delay);\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tthis.setAttribute(\"buffer\", formatDuration(effect.get(this.controls.buffer)));\n\t\t});\n\n\t\t// Track the element's rendered size and feed it into the rendition picker,\n\t\t// scaled by devicePixelRatio so high-DPI screens still get sharp renditions.\n\t\tconst updateDimensions = (width: number, height: number) => {\n\t\t\tif (width <= 0 || height <= 0) return;\n\t\t\tconst dpr = window.devicePixelRatio || 1;\n\t\t\tthis.controls.target.update((prev) => ({\n\t\t\t\t...prev,\n\t\t\t\twidth: Math.round(width * dpr),\n\t\t\t\theight: Math.round(height * dpr),\n\t\t\t}));\n\t\t};\n\n\t\tconst resizeObserver = new ResizeObserver((entries) => {\n\t\t\tconst entry = entries[0];\n\t\t\tif (!entry) return;\n\t\t\tupdateDimensions(entry.contentRect.width, entry.contentRect.height);\n\t\t});\n\t\tresizeObserver.observe(this);\n\t\tthis.signals.cleanup(() => resizeObserver.disconnect());\n\n\t\t// Seed with the current size in case the observer doesn't fire immediately\n\t\t// (e.g. the element is still 0x0 when we attach).\n\t\tconst rect = this.getBoundingClientRect();\n\t\tupdateDimensions(rect.width, rect.height);\n\t}\n\n\t// Annoyingly, we have to use these callbacks to figure out when the element is connected to the DOM.\n\t// This wouldn't be so bad if there was a destructor for web components to clean up our effects.\n\tconnectedCallback() {\n\t\tthis.#enabled.set(true);\n\t\tthis.style.display = \"block\";\n\t\tthis.style.position = \"relative\";\n\n\t\t// Create the caption overlay once, on first connect (the constructor may not add children).\n\t\tif (!this.#captionsOverlayEl) {\n\t\t\tconst overlay = document.createElement(\"div\");\n\t\t\toverlay.style.position = \"absolute\";\n\t\t\toverlay.style.inset = \"0\";\n\t\t\toverlay.style.pointerEvents = \"none\";\n\t\t\t// Above the canvas, which paints at the default stacking level.\n\t\t\toverlay.style.zIndex = \"1\";\n\t\t\tthis.appendChild(overlay);\n\t\t\tthis.#captionsOverlayEl = overlay;\n\t\t\tthis.#captionsOverlay.set(overlay);\n\t\t}\n\t}\n\n\tdisconnectedCallback() {\n\t\t// Stop everything but don't actually cleanup just in case we get added back to the DOM.\n\t\tthis.#enabled.set(false);\n\t}\n\n\tattributeChangedCallback(name: Observed, oldValue: string | null, newValue: string | null) {\n\t\tif (oldValue === newValue) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (name === \"url\") {\n\t\t\tthis.connection.url.set(newValue ? new URL(newValue) : undefined);\n\t\t} else if (name === \"name\") {\n\t\t\tthis.#name.set(Moq.Path.from(newValue ?? \"\"));\n\t\t} else if (name === \"paused\") {\n\t\t\tthis.controls.paused.set(parseBoolean(newValue, false));\n\t\t} else if (name === \"volume\") {\n\t\t\tconst volume = newValue ? Number.parseFloat(newValue) : 0.5;\n\t\t\tthis.controls.volume.set(volume);\n\t\t} else if (name === \"muted\") {\n\t\t\tthis.controls.muted.set(parseBoolean(newValue, false));\n\t\t} else if (name === \"visible\") {\n\t\t\tthis.controls.visible.set(parseVisible(newValue));\n\t\t} else if (name === \"announced\") {\n\t\t\tthis.#announced.set(parseBoolean(newValue, true));\n\t\t} else if (name === \"delay\") {\n\t\t\tthis.controls.delay.set(parseDelay(newValue));\n\t\t} else if (name === \"buffer\") {\n\t\t\tthis.controls.buffer.set(parseBuffer(newValue));\n\t\t} else if (name === \"reload\") {\n\t\t\tconsole.warn(\"moq-watch: `reload` was renamed to `announced`\");\n\t\t} else if (name === \"latency\" || name === \"latency-min\" || name === \"jitter\") {\n\t\t\tconsole.warn(`moq-watch: \\`${name}\\` is gone; use \\`delay\\` and \\`buffer\\``);\n\t\t} else if (name === \"catalog-format\") {\n\t\t\tthis.#catalogFormat.set(parseCatalogFormat(newValue));\n\t\t} else if (name === \"captions\") {\n\t\t\t// The selected caption track name; absent or empty turns captions off.\n\t\t\tthis.controls.captions.set(newValue || undefined);\n\t\t} else {\n\t\t\tconst exhaustive: never = name;\n\t\t\tthrow new Error(`Invalid attribute: ${exhaustive}`);\n\t\t}\n\t}\n\n\tget url(): URL | undefined {\n\t\treturn this.connection.url.peek();\n\t}\n\n\tset url(value: string | URL | undefined) {\n\t\tthis.connection.url.set(value ? new URL(value) : undefined);\n\t}\n\n\tget name(): Moq.Path.Valid {\n\t\treturn this.#name.peek();\n\t}\n\n\tset name(value: string | Moq.Path.Valid) {\n\t\tthis.#name.set(Moq.Path.from(value));\n\t}\n\n\tget paused(): boolean {\n\t\treturn this.controls.paused.peek();\n\t}\n\n\tset paused(value: boolean) {\n\t\tthis.controls.paused.set(value);\n\t}\n\n\tget volume(): number {\n\t\treturn this.controls.volume.peek();\n\t}\n\n\tset volume(value: number) {\n\t\tthis.controls.volume.set(value);\n\t}\n\n\tget muted(): boolean {\n\t\treturn this.controls.muted.peek();\n\t}\n\n\tset muted(value: boolean) {\n\t\tthis.controls.muted.set(value);\n\t}\n\n\tget visible(): Video.Visible {\n\t\treturn this.controls.visible.peek();\n\t}\n\n\tset visible(value: Video.Visible) {\n\t\tthis.controls.visible.set(value);\n\t}\n\n\tget announced(): boolean {\n\t\treturn this.#announced.peek();\n\t}\n\n\tset announced(value: boolean) {\n\t\tthis.#announced.set(value);\n\t}\n\n\t/** @internal */\n\tset reload(_value: unknown) {\n\t\tthrow new Error(\"moq-watch: `reload` was renamed to `announced`\");\n\t}\n\n\t/**\n\t * How far playback trails the live edge, in milliseconds. See {@link Delay}.\n\t *\n\t * `\"auto\"` (the default) sizes the jitter buffer from the connection RTT. `\"instant\"` drops the\n\t * clock instead: video paints the moment it decodes and audio is disabled.\n\t */\n\tget delay(): Delay {\n\t\treturn this.controls.delay.peek();\n\t}\n\n\tset delay(value: Delay) {\n\t\tthis.controls.delay.set(value);\n\t}\n\n\t/**\n\t * Future-dated media held beyond the live edge before playback skips ahead, in milliseconds.\n\t *\n\t * Zero (the default) minimizes latency. A larger value enables buffered playback: build up a\n\t * buffer from future-dated frames (e.g. TTS written faster than real-time) and only skip ahead\n\t * once they would sit further than `delay + buffer` past the playhead. Call `reset()` at each\n\t * utterance boundary.\n\t */\n\tget buffer(): Time.Milli {\n\t\treturn this.controls.buffer.peek();\n\t}\n\n\tset buffer(value: Time.Milli) {\n\t\tthis.controls.buffer.set(value);\n\t}\n\n\t/** @internal */\n\tget latency(): Delay {\n\t\treturn this.controls.delay.peek();\n\t}\n\n\tset latency(_value: unknown) {\n\t\tthrow new Error(\"moq-watch: `latency` is gone; use `delay` and `buffer`\");\n\t}\n\n\t/** @internal */\n\tget latencyMin(): Delay {\n\t\treturn this.controls.delay.peek();\n\t}\n\n\tset latencyMin(_value: unknown) {\n\t\tthrow new Error(\"moq-watch: `latencyMin` is gone; use `delay` and `buffer`\");\n\t}\n\n\t/** @internal */\n\tset latencyMax(_value: unknown) {\n\t\tthrow new Error(\n\t\t\t\"moq-watch: `latencyMax` is gone. Use `buffer`, the media held beyond the live edge; the old ceiling included the floor, so it is `latencyMax - delay`.\",\n\t\t);\n\t}\n\n\t/** The jitter buffer in milliseconds. */\n\tget jitter(): Time.Milli {\n\t\treturn this.sync.out.jitter.peek();\n\t}\n\n\tset jitter(_value: unknown) {\n\t\tthrow new Error(\"moq-watch: `jitter` is a readout; set `delay` instead\");\n\t}\n\n\t/**\n\t * Re-anchor playback at an utterance boundary in buffered mode: reset the sync reference\n\t * and flush the audio buffer so the next utterance plays from its own first frame.\n\t */\n\treset(): void {\n\t\tthis.player.reset();\n\t}\n\n\tget catalogFormat(): CatalogFormat | undefined {\n\t\treturn this.#catalogFormat.peek();\n\t}\n\n\tset catalogFormat(value: CatalogFormat | undefined) {\n\t\tthis.#catalogFormat.set(value);\n\t}\n\n\t/**\n\t * The active catalog. Assign directly when `catalogFormat` is `\"manual\"`;\n\t * for `\"hang\"` and `\"msf\"` this is overwritten by the fetch loop.\n\t */\n\tget catalog(): Catalog.Root | undefined {\n\t\treturn this.broadcast.out.catalog.peek();\n\t}\n\n\tset catalog(value: Catalog.Root | undefined) {\n\t\tthis.#catalog.set(value);\n\t}\n\n\t/**\n\t * The selected caption track name, or `undefined` for off (the default). Captions are opt-in:\n\t * assign a track name from `text.out.available` to turn them on. See the `text` source for the\n\t * list of renditions the broadcast publishes.\n\t */\n\tget captions(): string | undefined {\n\t\treturn this.controls.captions.peek();\n\t}\n\n\tset captions(value: string | undefined) {\n\t\tthis.controls.captions.set(value || undefined);\n\t}\n}\n\ncustomElements.define(\"moq-watch\", MoqWatch);\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t\"mo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Ac,GAAkC;EACnD,KAAK,GAAe,IAAI,CAAK;CAC9B;CAMA,IAAI,UAAoC;EACvC,OAAO,KAAK,UAAU,IAAI,QAAQ,KAAK;CACxC;CAEA,IAAI,QAAQ,GAAiC;EAC5C,KAAK,GAAS,IAAI,CAAK;CACxB;CAOA,IAAI,WAA+B;EAClC,OAAO,KAAK,SAAS,SAAS,KAAK;CACpC;CAEA,IAAI,SAAS,GAA2B;EACvC,KAAK,SAAS,SAAS,IAAI,KAAS,KAAA,CAAS;CAC9C;AACD;AAEA,eAAe,OAAO,aAAa,CAAQ"}
package/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Subscribe to a broadcast, decode it, and render it.
3
3
  *
4
- * The JS API: compose {@link Broadcast}, {@link Sync}, and the per-track `Video`/`Audio` pipelines
5
- * yourself. For a drop-in element, import `@norskvideo/moq-watch/element` instead.
4
+ * Use {@link Player} for a complete headless pipeline, or compose {@link Broadcast}, {@link Sync},
5
+ * and the per-track components yourself. For an element, import `@norskvideo/moq-watch/element` instead.
6
6
  *
7
7
  * @module
8
8
  */
@@ -12,6 +12,8 @@ export * as Net from "@norskvideo/moq-net";
12
12
  export * as Signals from "@norskvideo/moq-signals";
13
13
  export * as Audio from "./audio";
14
14
  export * from "./broadcast";
15
+ export * from "./player";
15
16
  export * from "./sync";
17
+ export * as Text from "./text";
16
18
  export * as Video from "./video";
17
19
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
package/index.js CHANGED
@@ -1,26 +1,34 @@
1
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "./source-BeABanvB.js";
2
- import { n as l, r as u, t as d } from "./sync-DNQkgnlX.js";
3
- import * as f from "@norskvideo/moq-hang";
4
- import * as p from "@norskvideo/moq-net";
5
- import * as m from "@norskvideo/moq-signals";
1
+ import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g, v as _ } from "./player-C19uf7Dc.js";
2
+ import * as v from "@norskvideo/moq-hang";
3
+ import * as y from "@norskvideo/moq-net";
4
+ import * as b from "@norskvideo/moq-signals";
6
5
  //#region \0rolldown/runtime.js
7
- var h = Object.defineProperty, g = (e, t) => {
6
+ var x = Object.defineProperty, S = (e, t) => {
8
7
  let n = {};
9
- for (var r in e) h(n, r, {
8
+ for (var r in e) x(n, r, {
10
9
  get: e[r],
11
10
  enumerable: !0
12
11
  });
13
- return t || h(n, Symbol.toStringTag, { value: "Module" }), n;
14
- }, _ = /* @__PURE__ */ g({
15
- Decoder: () => r,
16
- Emitter: () => t,
17
- Source: () => s
18
- }), v = /* @__PURE__ */ g({
19
- Decoder: () => o,
20
- Renderer: () => i,
21
- Source: () => c
12
+ return t || x(n, Symbol.toStringTag, { value: "Module" }), n;
13
+ }, C = /* @__PURE__ */ S({
14
+ Decoder: () => _,
15
+ Emitter: () => e,
16
+ Source: () => a
17
+ }), w = /* @__PURE__ */ S({
18
+ Renderer: () => m,
19
+ Source: () => t,
20
+ clearCue: () => n,
21
+ insertCue: () => c,
22
+ pruneCues: () => g,
23
+ renderable: () => d,
24
+ rollUp: () => r,
25
+ sanitizeCue: () => i
26
+ }), T = /* @__PURE__ */ S({
27
+ Decoder: () => s,
28
+ Renderer: () => p,
29
+ Source: () => u
22
30
  });
23
31
  //#endregion
24
- export { _ as Audio, n as Broadcast, e as CATALOG_FORMATS, f as Hang, p as Net, m as Signals, d as Sync, v as Video, l as latencyBounds, u as latencyFromBounds, a as parseCatalogFormat };
32
+ export { C as Audio, l as Broadcast, o as CATALOG_FORMATS, v as Hang, y as Net, h as Player, b as Signals, f as Sync, w as Text, T as Video };
25
33
 
26
34
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/audio/index.ts","../src/video/index.ts"],"sourcesContent":["export * from \"./decoder\";\nexport * from \"./emitter\";\nexport * from \"./source\";\n","export * from \"./decoder\";\nexport * from \"./renderer\";\nexport * from \"./source\";\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/audio/index.ts","../src/text/index.ts","../src/video/index.ts"],"sourcesContent":["export * from \"./decoder\";\nexport * from \"./emitter\";\nexport * from \"./source\";\n","/**\n * Caption / subtitle playback: select a text rendition from the catalog and render its cues into an\n * overlay element, synced to the shared media clock.\n *\n * @module\n */\nexport * from \"./renderer\";\nexport * from \"./source\";\n","export * from \"./decoder\";\nexport * from \"./renderer\";\nexport * from \"./source\";\n"],"mappings":""}