@norskvideo/moq-watch 0.1.8 → 0.2.1

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 +57 -26
  21. package/element.d.ts.map +1 -1
  22. package/element.js +171 -174
  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-BFRzc5zw.js +2172 -0
  33. package/player-BFRzc5zw.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,137 +1,131 @@
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-BFRzc5zw.js";
2
+ import * as n from "@norskvideo/moq-net";
3
+ import { Time as r } from "@norskvideo/moq-net";
4
+ import { Computed as i, Effect as a, Signal as o } from "@norskvideo/moq-signals";
5
+ //#region src/duration.ts
6
+ function s(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 c(e) {
13
+ return `${e}ms`;
14
+ }
15
+ //#endregion
5
16
  //#region src/element.ts
6
- var m = [
17
+ var l = [
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 u(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 d(e) {
39
+ let t = e?.trim();
40
+ if (!t || t === "auto") return "auto";
41
+ if (t === "instant") return "instant";
42
+ let n = s(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 f(e) {
46
+ let t = e?.trim();
47
+ if (!t) return n.Time.Milli.zero;
48
+ let r = s(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 p(t) {
52
+ if (t !== null) return e.find((e) => e === t);
53
+ }
54
+ function m(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;
31
- connection;
59
+ var h = new FinalizationRegistry((e) => e.close()), g = class extends HTMLElement {
60
+ static observedAttributes = l;
61
+ get connection() {
62
+ return this.#e.peek();
63
+ }
64
+ #e;
65
+ #t = new o(void 0);
66
+ player;
32
67
  broadcast;
33
68
  video;
34
69
  audio;
35
70
  renderer;
36
71
  emitter;
72
+ text;
73
+ textRenderer;
37
74
  sync;
38
75
  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)
76
+ paused: new o(!1),
77
+ volume: new o(.5),
78
+ muted: new o(!1),
79
+ visible: new o("20%"),
80
+ delay: new o("auto"),
81
+ buffer: new o(n.Time.Milli.zero),
82
+ target: new o(void 0),
83
+ audioTarget: new o(void 0),
84
+ captions: new o(void 0)
46
85
  };
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();
86
+ #n = new o(n.Path.empty());
87
+ #r = new o(!0);
88
+ #i = new o(void 0);
89
+ #a = new o(void 0);
90
+ #o = new o(void 0);
91
+ #s = new o(void 0);
92
+ #c;
93
+ #l = new o(!1);
94
+ #u = .5;
95
+ signals = new a();
60
96
  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,
64
- name: this.#e,
65
- reload: this.#t,
66
- 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
- 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);
97
+ super(), h.register(this, this.signals), this.#e = new o(new n.Connection({
98
+ url: this.#t,
99
+ enabled: this.#l
100
+ })), this.signals.cleanup(() => this.connection.close()), this.player = new t({
101
+ origin: new i((e) => e.get(e.get(this.#e).origin)),
102
+ probe: new i((e) => e.get(e.get(this.#e).probe)),
103
+ enabled: this.#l,
104
+ name: this.#n,
105
+ announced: this.#r,
106
+ catalogFormat: this.#i,
107
+ catalog: this.#a,
108
+ canvas: this.#o,
109
+ container: this.#s,
110
+ ...this.controls
111
+ }), 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) => {
112
+ e.get(this.controls.muted) ? (this.#u = this.controls.volume.peek() || .5, this.controls.volume.set(0)) : this.controls.volume.set(this.#u);
119
113
  }), this.signals.run((e) => {
120
114
  let t = e.get(this.controls.volume);
121
115
  this.controls.muted.set(t === 0);
122
116
  });
123
- let f = () => {
117
+ let e = () => {
124
118
  let e = this.querySelector("canvas") ?? void 0;
125
- !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, {
119
+ !e && this.querySelector("video") && console.warn("moq-watch: rendering requires a <canvas> child; a <video> child does nothing."), this.#o.set(e);
120
+ }, r = new MutationObserver(e);
121
+ r.observe(this, {
128
122
  childList: !0,
129
123
  subtree: !0
130
- }), this.signals.cleanup(() => p.disconnect()), f(), this.signals.run((e) => {
131
- let t = e.get(this.connection.url);
124
+ }), this.signals.cleanup(() => r.disconnect()), e(), this.signals.run((e) => {
125
+ let t = e.get(this.#t);
132
126
  t ? this.setAttribute("url", t.toString()) : this.removeAttribute("url");
133
127
  }), this.signals.run((e) => {
134
- let t = e.get(this.#e);
128
+ let t = e.get(this.#n);
135
129
  this.setAttribute("name", t.toString());
136
130
  }), this.signals.run((e) => {
137
131
  e.get(this.controls.muted) ? this.setAttribute("muted", "") : this.removeAttribute("muted");
@@ -144,23 +138,12 @@ var _ = new FinalizationRegistry((e) => e.close()), v = class extends HTMLElemen
144
138
  let t = e.get(this.controls.visible);
145
139
  this.setAttribute("visible", t);
146
140
  }), 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
- }
141
+ let t = e.get(this.controls.delay);
142
+ this.setAttribute("delay", typeof t == "number" ? c(t) : t);
143
+ }), this.signals.run((e) => {
144
+ this.setAttribute("buffer", c(e.get(this.controls.buffer)));
162
145
  });
163
- let m = (e, t) => {
146
+ let a = (e, t) => {
164
147
  if (e <= 0 || t <= 0) return;
165
148
  let n = window.devicePixelRatio || 1;
166
149
  this.controls.target.update((r) => ({
@@ -168,67 +151,62 @@ var _ = new FinalizationRegistry((e) => e.close()), v = class extends HTMLElemen
168
151
  width: Math.round(e * n),
169
152
  height: Math.round(t * n)
170
153
  }));
171
- }, h = new ResizeObserver((e) => {
154
+ }, s = new ResizeObserver((e) => {
172
155
  let t = e[0];
173
- t && m(t.contentRect.width, t.contentRect.height);
156
+ t && a(t.contentRect.width, t.contentRect.height);
174
157
  });
175
- h.observe(this), this.signals.cleanup(() => h.disconnect());
176
- let g = this.getBoundingClientRect();
177
- m(g.width, g.height);
158
+ s.observe(this), this.signals.cleanup(() => s.disconnect());
159
+ let l = this.getBoundingClientRect();
160
+ a(l.width, l.height);
178
161
  }
179
162
  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;
163
+ if (this.#l.set(!0), this.style.display = "block", this.style.position = "relative", !this.#c) {
164
+ let e = document.createElement("div");
165
+ e.style.position = "absolute", e.style.inset = "0", e.style.pointerEvents = "none", e.style.zIndex = "1", this.appendChild(e), this.#c = e, this.#s.set(e);
197
166
  }
198
167
  }
199
- #m(e) {
200
- return e?.trim() === "instant" ? "instant" : this.#f(e);
168
+ disconnectedCallback() {
169
+ this.#l.set(!1);
201
170
  }
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));
171
+ attributeChangedCallback(e, t, r) {
172
+ if (t !== r) {
173
+ if (e === "url") this.#t.set(r ? new URL(r) : void 0);
174
+ else if (e === "name") this.#n.set(n.Path.from(r ?? ""));
175
+ else if (e === "paused") this.controls.paused.set(m(r, !1));
207
176
  else if (e === "volume") {
208
- let e = n ? Number.parseFloat(n) : .5;
177
+ let e = r ? Number.parseFloat(r) : .5;
209
178
  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));
179
+ } else if (e === "muted") this.controls.muted.set(m(r, !1));
180
+ else if (e === "visible") this.controls.visible.set(u(r));
181
+ else if (e === "announced") this.#r.set(m(r, !0));
182
+ else if (e === "delay") this.controls.delay.set(d(r));
183
+ else if (e === "buffer") this.controls.buffer.set(f(r));
184
+ else if (e === "reload") console.warn("moq-watch: `reload` was renamed to `announced`");
185
+ else if (e === "latency" || e === "latency-min" || e === "jitter") console.warn(`moq-watch: \`${e}\` is gone; use \`delay\` and \`buffer\``);
186
+ else if (e === "catalog-format") this.#i.set(p(r));
187
+ else if (e === "captions") this.controls.captions.set(r || void 0);
218
188
  else throw Error(`Invalid attribute: ${e}`);
219
189
  }
220
190
  }
221
191
  get url() {
222
- return this.connection.url.peek();
192
+ return this.#t.peek();
223
193
  }
224
194
  set url(e) {
225
- this.connection.url.set(e ? new URL(e) : void 0);
195
+ this.#t.set(e ? new URL(e) : void 0);
196
+ }
197
+ set connectionProps(e) {
198
+ let t = this.#e.peek();
199
+ this.#e.set(new n.Connection({
200
+ ...e,
201
+ url: this.#t,
202
+ enabled: this.#l
203
+ })), t.close();
226
204
  }
227
205
  get name() {
228
- return this.#e.peek();
206
+ return this.#n.peek();
229
207
  }
230
208
  set name(e) {
231
- this.#e.set(d.Path.from(e));
209
+ this.#n.set(n.Path.from(e));
232
210
  }
233
211
  get paused() {
234
212
  return this.controls.paused.peek();
@@ -254,53 +232,72 @@ var _ = new FinalizationRegistry((e) => e.close()), v = class extends HTMLElemen
254
232
  set visible(e) {
255
233
  this.controls.visible.set(e);
256
234
  }
257
- get reload() {
258
- return this.#t.peek();
235
+ get announced() {
236
+ return this.#r.peek();
237
+ }
238
+ set announced(e) {
239
+ this.#r.set(e);
259
240
  }
260
241
  set reload(e) {
261
- this.#t.set(e);
242
+ throw Error("moq-watch: `reload` was renamed to `announced`");
243
+ }
244
+ get delay() {
245
+ return this.controls.delay.peek();
246
+ }
247
+ set delay(e) {
248
+ this.controls.delay.set(e);
249
+ }
250
+ get buffer() {
251
+ return this.controls.buffer.peek();
252
+ }
253
+ set buffer(e) {
254
+ this.controls.buffer.set(e);
262
255
  }
263
256
  get latency() {
264
- return this.controls.latency.peek();
257
+ return this.controls.delay.peek();
265
258
  }
266
259
  set latency(e) {
267
- this.controls.latency.set(e);
260
+ throw Error("moq-watch: `latency` is gone; use `delay` and `buffer`");
268
261
  }
269
262
  get latencyMin() {
270
- return c(this.controls.latency.peek()).min;
263
+ return this.controls.delay.peek();
271
264
  }
272
265
  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;
266
+ throw Error("moq-watch: `latencyMin` is gone; use `delay` and `buffer`");
278
267
  }
279
268
  set latencyMax(e) {
280
- let { min: t } = c(this.controls.latency.peek());
281
- this.controls.latency.set(l(t, e));
269
+ 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
270
  }
283
271
  get jitter() {
284
272
  return this.sync.out.jitter.peek();
285
273
  }
274
+ set jitter(e) {
275
+ throw Error("moq-watch: `jitter` is a readout; set `delay` instead");
276
+ }
286
277
  reset() {
287
- this.sync.reset(), this.audio.reset();
278
+ this.player.reset();
288
279
  }
289
280
  get catalogFormat() {
290
- return this.#n.peek();
281
+ return this.#i.peek();
291
282
  }
292
283
  set catalogFormat(e) {
293
- this.#n.set(e);
284
+ this.#i.set(e);
294
285
  }
295
286
  get catalog() {
296
287
  return this.broadcast.out.catalog.peek();
297
288
  }
298
289
  set catalog(e) {
299
- this.#r.set(e);
290
+ this.#a.set(e);
291
+ }
292
+ get captions() {
293
+ return this.controls.captions.peek();
294
+ }
295
+ set captions(e) {
296
+ this.controls.captions.set(e || void 0);
300
297
  }
301
298
  };
302
- customElements.define("moq-watch", v);
299
+ customElements.define("moq-watch", g);
303
300
  //#endregion
304
- export { v as default };
301
+ export { g as default, p as parseCatalogFormat };
305
302
 
306
303
  //# 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;CAC1D,IAAM,IAAU,GAAO,KAAK;CAQ5B,OAPK,IACD,MAAY,WAAW,MAAY,YAEnC,wBAAwB,KAAK,CAAO,IAAU,IAE9C,kBAAkB,KAAK,CAAO,IAAU,GAAG,EAAQ,OACvD,QAAQ,KAAK,+BAA+B,EAAM,4DAA4D,GACvG,SAPc;AAQtB;AAOA,SAAS,EAAa,GAAsB,GAAgC;CAC3E,IAAI,MAAU,MAAM,OAAO;CAC3B,IAAM,IAAa,EAAM,KAAK,CAAC,CAAC,YAAY;CAC5C,OAAO,MAAe,WAAW,MAAe;AACjD;AAKA,IAAM,IAAU,IAAI,sBAA8B,MAAY,EAAQ,MAAM,CAAC,GAGxD,IAArB,cAAsC,YAAY;CACjD,OAAO,qBAAqB;CAG5B;CAGA;CAGA;CAGA;CAG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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, Computed } 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. Replaced by {@link connectionProps}.\n\t */\n\tget connection(): Moq.Connection {\n\t\treturn this.#connection.peek();\n\t}\n\t#connection: Signal<Moq.Connection>;\n\t// The URL, one signal for every connection this element builds, so a rebuild keeps it.\n\t#url = new Signal<URL | undefined>(undefined);\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 Signal(\n\t\t\tnew Moq.Connection({\n\t\t\t\turl: this.#url,\n\t\t\t\tenabled: this.#enabled,\n\t\t\t}),\n\t\t);\n\t\tthis.signals.cleanup(() => this.connection.close());\n\n\t\tthis.player = new Player({\n\t\t\t// through the signal, so a connection rebuilt by `connectionProps` is the one played\n\t\t\torigin: new Computed((effect) => effect.get(effect.get(this.#connection).origin)),\n\t\t\tprobe: new Computed((effect) => effect.get(effect.get(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.#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.#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.#url.peek();\n\t}\n\n\tset url(value: string | URL | undefined) {\n\t\tthis.#url.set(value ? new URL(value) : undefined);\n\t}\n\n\t/**\n\t * Rebuild the connection with these options, for a relay the shared pool cannot reach on\n\t * its own: a self-signed certificate pinned with `webtransport.serverCertificateHashes`,\n\t * no WebSocket fallback, no discovery. The URL and the enabled state carry over, and the\n\t * player follows the new connection. Set it before the URL to spare a wasted attempt.\n\t */\n\tset connectionProps(props: Omit<Moq.Connection.Props, \"url\" | \"enabled\">) {\n\t\tconst prev = this.#connection.peek();\n\t\tthis.#connection.set(new Moq.Connection({ ...props, url: this.#url, enabled: this.#enabled }));\n\t\tprev.close();\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\"moq-watch\": MoqWatch;\n\t}\n}\n"],"mappings":";;;;;AAaA,SAAgB,EAAc,GAAuC;CACpE,IAAM,IAAQ,2BAA2B,KAAK,EAAM,KAAK,CAAC;CAC1D,IAAI,CAAC,GAAO;CAEZ,IAAM,IAAS,OAAO,WAAW,EAAM,EAAE;CACpC,WAAO,SAAS,CAAM,GAG3B,OAFI,EAAM,OAAO,KAAA,IAAkB,MAAW,IAAI,EAAK,MAAM,OAAO,KAAA,IAE7D,EAAK,MAAM,EAAM,OAAO,MAAM,IAAS,MAAO,CAAM;AAC5D;AAWA,SAAgB,EAAe,GAA2B;CACzD,OAAO,GAAG,EAAM;AACjB;;;AChBA,IAAM,IAAW;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;AACD;AAIA,SAAS,EAAa,GAAqC;CAC1D,IAAM,IAAU,GAAO,KAAK;CAQ5B,OAPK,IACD,MAAY,WAAW,MAAY,YAEnC,wBAAwB,KAAK,CAAO,IAAU,IAE9C,kBAAkB,KAAK,CAAO,IAAU,GAAG,EAAQ,OACvD,QAAQ,KAAK,+BAA+B,EAAM,4DAA4D,GACvG,SAPc;AAQtB;AAGA,SAAS,EAAW,GAA6B;CAChD,IAAM,IAAU,GAAO,KAAK;CAC5B,IAAI,CAAC,KAAW,MAAY,QAAQ,OAAO;CAC3C,IAAI,MAAY,WAAW,OAAO;CAClC,IAAM,IAAS,EAAc,CAAO;CAGpC,OAFI,MAAW,KAAA,KACf,QAAQ,KAAK,6BAA6B,EAAM,0DAA0D,GACnG,UAF0B;AAGlC;AAGA,SAAS,EAAY,GAAkC;CACtD,IAAM,IAAU,GAAO,KAAK;CAC5B,IAAI,CAAC,GAAS,OAAO,EAAI,KAAK,MAAM;CACpC,IAAM,IAAS,E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AI,CAAK;CAC/B;CAGA,IAAI,UAAiB;EACpB,OAAO,KAAK,SAAS,MAAM,KAAK;CACjC;CAEA,IAAI,QAAQ,GAAiB;EAC5B,MAAU,MAAM,wDAAwD;CACzE;CAGA,IAAI,aAAoB;EACvB,OAAO,KAAK,SAAS,MAAM,KAAK;CACjC;CAEA,IAAI,WAAW,GAAiB;EAC/B,MAAU,MAAM,2DAA2D;CAC5E;CAGA,IAAI,WAAW,GAAiB;EAC/B,MAAU,MACT,wJACD;CACD;CAGA,IAAI,SAAqB;EACxB,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK;CAClC;CAEA,IAAI,OAAO,GAAiB;EAC3B,MAAU,MAAM,uDAAuD;CACxE;CAMA,QAAc;EACb,KAAK,OAAO,MAAM;CACnB;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;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"}