@moq/watch 0.3.1 → 0.4.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 (73) hide show
  1. package/README.md +1 -2
  2. package/audio/decoder.d.ts +25 -15
  3. package/audio/decoder.d.ts.map +1 -1
  4. package/audio/emitter.d.ts +13 -10
  5. package/audio/emitter.d.ts.map +1 -1
  6. package/audio/index.d.ts +0 -2
  7. package/audio/index.d.ts.map +1 -1
  8. package/audio/source.d.ts +21 -17
  9. package/audio/source.d.ts.map +1 -1
  10. package/audio/unlock.d.ts +20 -0
  11. package/audio/unlock.d.ts.map +1 -0
  12. package/audio/unlock.test.d.ts +2 -0
  13. package/audio/unlock.test.d.ts.map +1 -0
  14. package/broadcast.d.ts +27 -57
  15. package/broadcast.d.ts.map +1 -1
  16. package/element.d.ts +42 -12
  17. package/element.d.ts.map +1 -1
  18. package/element.js +146 -90
  19. package/element.js.map +1 -1
  20. package/index.d.ts +9 -6
  21. package/index.d.ts.map +1 -1
  22. package/index.js +24 -5
  23. package/index.js.map +1 -0
  24. package/package.json +5 -6
  25. package/source-CWtgjSC_.js +1359 -0
  26. package/source-CWtgjSC_.js.map +1 -0
  27. package/support/element.d.ts.map +1 -1
  28. package/support/element.js.map +1 -1
  29. package/support/index.d.ts +3 -3
  30. package/support/index.d.ts.map +1 -1
  31. package/support/index.js +18 -17
  32. package/support/index.js.map +1 -1
  33. package/sync-zdwVEj9u.js +129 -0
  34. package/sync-zdwVEj9u.js.map +1 -0
  35. package/sync.d.ts +19 -18
  36. package/sync.d.ts.map +1 -1
  37. package/ui/components/buffer-control.d.ts +1 -1
  38. package/ui/components/buffer-control.d.ts.map +1 -1
  39. package/ui/components/fullscreen-button.d.ts +1 -2
  40. package/ui/components/fullscreen-button.d.ts.map +1 -1
  41. package/ui/components/play-pause.d.ts +1 -1
  42. package/ui/components/play-pause.d.ts.map +1 -1
  43. package/ui/element.d.ts.map +1 -1
  44. package/ui/element.js +269 -265
  45. package/ui/element.js.map +1 -1
  46. package/ui/fullscreen.d.ts +1 -2
  47. package/ui/fullscreen.d.ts.map +1 -1
  48. package/video/decoder.d.ts +32 -16
  49. package/video/decoder.d.ts.map +1 -1
  50. package/video/index.d.ts +0 -2
  51. package/video/index.d.ts.map +1 -1
  52. package/video/renderer.d.ts +14 -17
  53. package/video/renderer.d.ts.map +1 -1
  54. package/video/source.d.ts +23 -20
  55. package/video/source.d.ts.map +1 -1
  56. package/audio/backend.d.ts +0 -26
  57. package/audio/backend.d.ts.map +0 -1
  58. package/audio/mse.d.ts +0 -22
  59. package/audio/mse.d.ts.map +0 -1
  60. package/backend.d.ts +0 -65
  61. package/backend.d.ts.map +0 -1
  62. package/broadcast-C2qofUBv.js +0 -1701
  63. package/broadcast-C2qofUBv.js.map +0 -1
  64. package/buffered.d.ts +0 -19
  65. package/buffered.d.ts.map +0 -1
  66. package/mse.d.ts +0 -19
  67. package/mse.d.ts.map +0 -1
  68. package/sync-D67IxmxJ.js +0 -128
  69. package/sync-D67IxmxJ.js.map +0 -1
  70. package/video/backend.d.ts +0 -25
  71. package/video/backend.d.ts.map +0 -1
  72. package/video/mse.d.ts +0 -23
  73. package/video/mse.d.ts.map +0 -1
package/element.js CHANGED
@@ -1,9 +1,9 @@
1
- import { i as e, r as t, t as n } from "./broadcast-C2qofUBv.js";
2
- import { n as r, r as i } from "./sync-D67IxmxJ.js";
3
- import * as a from "@moq/net";
4
- import { Effect as o, Signal as s } from "@moq/signals";
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-CWtgjSC_.js";
2
+ import { n as c, r as l, t as u } from "./sync-zdwVEj9u.js";
3
+ import * as d from "@moq/net";
4
+ import { Effect as f, Signal as p } from "@moq/signals";
5
5
  //#region src/element.ts
6
- var c = [
6
+ var m = [
7
7
  "url",
8
8
  "name",
9
9
  "paused",
@@ -17,105 +17,164 @@ var c = [
17
17
  "jitter",
18
18
  "catalog-format"
19
19
  ];
20
- function l(e) {
20
+ function h(e) {
21
21
  let t = e?.trim();
22
22
  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
23
  }
24
- function u(e, t) {
24
+ function g(e, t) {
25
25
  if (e === null) return t;
26
26
  let n = e.trim().toLowerCase();
27
27
  return n !== "false" && n !== "0";
28
28
  }
29
- var d = new FinalizationRegistry((e) => e.close()), f = class extends HTMLElement {
30
- static observedAttributes = c;
29
+ var _ = new FinalizationRegistry((e) => e.close()), v = class extends HTMLElement {
30
+ static observedAttributes = m;
31
31
  connection;
32
32
  broadcast;
33
- backend;
34
- #e = new s(!1);
35
- signals = new o();
33
+ video;
34
+ audio;
35
+ renderer;
36
+ emitter;
37
+ sync;
38
+ 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
+ };
46
+ #e = new p(d.Path.empty());
47
+ #t = new p(!0);
48
+ #n = new p(void 0);
49
+ #r = new p(void 0);
50
+ #i = new p(void 0);
51
+ #a = new p(!1);
52
+ #o = new p(!1);
53
+ #s = new p(!1);
54
+ #c = .5;
55
+ signals = new f();
36
56
  constructor() {
37
- super(), d.register(this, this.signals), this.connection = new a.Connection.Reload({ enabled: this.#e }), this.signals.cleanup(() => this.connection.close()), this.broadcast = new n({
57
+ super(), _.register(this, this.signals), this.connection = new d.Connection.Reload({ enabled: this.#s }), this.signals.cleanup(() => this.connection.close()), this.broadcast = new t({
38
58
  connection: this.connection.established,
39
- announced: this.connection.announced,
40
- enabled: this.#e
41
- }), this.signals.cleanup(() => this.broadcast.close()), this.backend = new e({
59
+ enabled: this.#s,
60
+ name: this.#e,
61
+ reload: this.#t,
62
+ catalogFormat: this.#n,
63
+ catalog: this.#r
64
+ }), this.signals.cleanup(() => this.broadcast.close());
65
+ let i = new s({
42
66
  broadcast: this.broadcast,
43
- connection: this.connection.established
44
- }), this.signals.cleanup(() => this.backend.close());
45
- let t = () => {
46
- let e = this.querySelector("canvas"), t = this.querySelector("video");
47
- if (e && t) throw Error("Cannot have both canvas and video elements");
48
- this.backend.element.set(e ?? t);
49
- }, i = new MutationObserver(t);
50
- i.observe(this, {
67
+ target: this.controls.target,
68
+ supported: a.supported
69
+ }), l = new o({
70
+ broadcast: this.broadcast,
71
+ supported: n.supported
72
+ });
73
+ this.signals.cleanup(() => {
74
+ i.close(), l.close();
75
+ }), this.sync = new u({
76
+ latency: this.controls.latency,
77
+ connection: this.connection.established,
78
+ video: i.out.jitter,
79
+ audio: l.out.jitter
80
+ }), this.signals.cleanup(() => this.sync.close()), this.video = new a(i, this.sync, { enabled: this.#a }), this.audio = new n(l, this.sync, { enabled: this.#o }), this.signals.cleanup(() => {
81
+ this.video.close(), this.audio.close();
82
+ }), this.emitter = new e(this.audio, {
83
+ volume: this.controls.volume,
84
+ muted: this.controls.muted,
85
+ paused: this.controls.paused
86
+ }), this.renderer = new r(this.video, {
87
+ canvas: this.#i,
88
+ visible: this.controls.visible
89
+ }), this.signals.cleanup(() => {
90
+ this.emitter.close(), this.renderer.close();
91
+ }), this.signals.proxy(this.#o, this.emitter.out.enabled), this.signals.run((e) => {
92
+ let t = e.get(this.renderer.out.visible);
93
+ if (!e.get(this.controls.paused)) {
94
+ this.#a.set(t);
95
+ return;
96
+ }
97
+ let n = e.get(this.renderer.out.frame);
98
+ this.#a.set(t && !n);
99
+ }), this.signals.run((e) => {
100
+ e.get(this.controls.muted) ? (this.#c = this.controls.volume.peek() || .5, this.controls.volume.set(0)) : this.controls.volume.set(this.#c);
101
+ }), this.signals.run((e) => {
102
+ let t = e.get(this.controls.volume);
103
+ this.controls.muted.set(t === 0);
104
+ });
105
+ let f = () => {
106
+ let e = this.querySelector("canvas") ?? void 0;
107
+ !e && this.querySelector("video") && console.warn("moq-watch: rendering requires a <canvas> child; a <video> child does nothing."), this.#i.set(e);
108
+ }, p = new MutationObserver(f);
109
+ p.observe(this, {
51
110
  childList: !0,
52
111
  subtree: !0
53
- }), this.signals.cleanup(() => i.disconnect()), t(), this.signals.run((e) => {
112
+ }), this.signals.cleanup(() => p.disconnect()), f(), this.signals.run((e) => {
54
113
  let t = e.get(this.connection.url);
55
114
  t ? this.setAttribute("url", t.toString()) : this.removeAttribute("url");
56
115
  }), this.signals.run((e) => {
57
- let t = e.get(this.broadcast.name);
116
+ let t = e.get(this.#e);
58
117
  this.setAttribute("name", t.toString());
59
118
  }), this.signals.run((e) => {
60
- e.get(this.backend.audio.muted) ? this.setAttribute("muted", "") : this.removeAttribute("muted");
61
- }), this.signals.run((e) => {
62
- e.get(this.backend.paused) ? this.setAttribute("paused", "true") : this.removeAttribute("paused");
119
+ e.get(this.controls.muted) ? this.setAttribute("muted", "") : this.removeAttribute("muted");
63
120
  }), this.signals.run((e) => {
64
- let t = e.get(this.backend.visible);
65
- this.setAttribute("visible", t);
121
+ e.get(this.controls.paused) ? this.setAttribute("paused", "") : this.removeAttribute("paused");
66
122
  }), this.signals.run((e) => {
67
- let t = e.get(this.backend.audio.volume);
123
+ let t = e.get(this.controls.volume);
68
124
  this.setAttribute("volume", t.toString());
69
125
  }), this.signals.run((e) => {
70
- let { min: t, max: n } = r(e.get(this.backend.latency));
126
+ let t = e.get(this.controls.visible);
127
+ this.setAttribute("visible", t);
128
+ }), this.signals.run((e) => {
129
+ let { min: t, max: n } = c(e.get(this.controls.latency));
71
130
  if (t === n) if (t === "real-time") this.setAttribute("latency", "real-time");
72
131
  else {
73
- let t = Math.floor(e.get(this.backend.jitter));
132
+ let t = Math.floor(e.get(this.sync.out.jitter));
74
133
  this.setAttribute("latency", t.toString());
75
134
  }
76
135
  });
77
- let o = (e, t) => {
136
+ let m = (e, t) => {
78
137
  if (e <= 0 || t <= 0) return;
79
138
  let n = window.devicePixelRatio || 1;
80
- this.backend.video.source.target.update((r) => ({
139
+ this.controls.target.update((r) => ({
81
140
  ...r,
82
141
  width: Math.round(e * n),
83
142
  height: Math.round(t * n)
84
143
  }));
85
- }, s = new ResizeObserver((e) => {
144
+ }, h = new ResizeObserver((e) => {
86
145
  let t = e[0];
87
- t && o(t.contentRect.width, t.contentRect.height);
146
+ t && m(t.contentRect.width, t.contentRect.height);
88
147
  });
89
- s.observe(this), this.signals.cleanup(() => s.disconnect());
90
- let c = this.getBoundingClientRect();
91
- o(c.width, c.height);
148
+ h.observe(this), this.signals.cleanup(() => h.disconnect());
149
+ let g = this.getBoundingClientRect();
150
+ m(g.width, g.height);
92
151
  }
93
152
  connectedCallback() {
94
- this.#e.set(!0), this.style.display = "block", this.style.position = "relative";
153
+ this.#s.set(!0), this.style.display = "block", this.style.position = "relative";
95
154
  }
96
155
  disconnectedCallback() {
97
- this.#e.set(!1);
156
+ this.#s.set(!1);
98
157
  }
99
- #t(e) {
158
+ #l(e) {
100
159
  if (!e || e === "real-time") return "real-time";
101
160
  let t = Number.parseFloat(e);
102
- return Number.isFinite(t) ? t : 100;
161
+ return d.Time.Milli(Number.isFinite(t) ? t : 100);
103
162
  }
104
- attributeChangedCallback(e, n, r) {
105
- if (n !== r) if (e === "url") this.connection.url.set(r ? new URL(r) : void 0);
106
- else if (e === "name") this.broadcast.name.set(a.Path.from(r ?? ""));
107
- else if (e === "paused") this.backend.paused.set(r !== null);
163
+ attributeChangedCallback(e, t, n) {
164
+ if (t !== n) if (e === "url") this.connection.url.set(n ? new URL(n) : void 0);
165
+ else if (e === "name") this.#e.set(d.Path.from(n ?? ""));
166
+ else if (e === "paused") this.controls.paused.set(g(n, !1));
108
167
  else if (e === "volume") {
109
- let e = r ? Number.parseFloat(r) : .5;
110
- this.backend.audio.volume.set(e);
111
- } else if (e === "muted") this.backend.audio.muted.set(r !== null);
112
- else if (e === "visible") this.backend.visible.set(l(r));
113
- else if (e === "reload") this.broadcast.reload.set(u(r, !0));
114
- else if (e === "latency") this.latency = this.#t(r);
115
- else if (e === "latency-min") this.latencyMin = this.#t(r);
116
- else if (e === "latency-max") this.latencyMax = this.#t(r);
117
- else if (e === "jitter") this.latency = this.#t(r);
118
- else if (e === "catalog-format") this.broadcast.catalogFormat.set(t(r));
168
+ let e = n ? Number.parseFloat(n) : .5;
169
+ this.controls.volume.set(e);
170
+ } else if (e === "muted") this.controls.muted.set(g(n, !1));
171
+ else if (e === "visible") this.controls.visible.set(h(n));
172
+ else if (e === "reload") this.#t.set(g(n, !0));
173
+ else if (e === "latency") this.latency = this.#l(n);
174
+ else if (e === "latency-min") this.latencyMin = this.#l(n);
175
+ else if (e === "latency-max") this.latencyMax = this.#l(n);
176
+ else if (e === "jitter") this.latency = this.#l(n);
177
+ else if (e === "catalog-format") this.#n.set(i(n));
119
178
  else throw Error(`Invalid attribute: ${e}`);
120
179
  }
121
180
  get url() {
@@ -125,85 +184,82 @@ var d = new FinalizationRegistry((e) => e.close()), f = class extends HTMLElemen
125
184
  this.connection.url.set(e ? new URL(e) : void 0);
126
185
  }
127
186
  get name() {
128
- return this.broadcast.name.peek();
187
+ return this.#e.peek();
129
188
  }
130
189
  set name(e) {
131
- this.broadcast.name.set(a.Path.from(e));
190
+ this.#e.set(d.Path.from(e));
132
191
  }
133
192
  get paused() {
134
- return this.backend.paused.peek();
193
+ return this.controls.paused.peek();
135
194
  }
136
195
  set paused(e) {
137
- this.backend.paused.set(e);
196
+ this.controls.paused.set(e);
138
197
  }
139
198
  get volume() {
140
- return this.backend.audio.volume.peek();
199
+ return this.controls.volume.peek();
141
200
  }
142
201
  set volume(e) {
143
- this.backend.audio.volume.set(e);
202
+ this.controls.volume.set(e);
144
203
  }
145
204
  get muted() {
146
- return this.backend.audio.muted.peek();
205
+ return this.controls.muted.peek();
147
206
  }
148
207
  set muted(e) {
149
- this.backend.audio.muted.set(e);
208
+ this.controls.muted.set(e);
150
209
  }
151
210
  get visible() {
152
- return this.backend.visible.peek();
211
+ return this.controls.visible.peek();
153
212
  }
154
213
  set visible(e) {
155
- this.backend.visible.set(e);
214
+ this.controls.visible.set(e);
156
215
  }
157
216
  get reload() {
158
- return this.broadcast.reload.peek();
217
+ return this.#t.peek();
159
218
  }
160
219
  set reload(e) {
161
- this.broadcast.reload.set(e);
220
+ this.#t.set(e);
162
221
  }
163
222
  get latency() {
164
- return this.backend.latency.peek();
223
+ return this.controls.latency.peek();
165
224
  }
166
225
  set latency(e) {
167
- this.backend.latency.set(e);
226
+ this.controls.latency.set(e);
168
227
  }
169
228
  get latencyMin() {
170
- return r(this.backend.latency.peek()).min;
229
+ return c(this.controls.latency.peek()).min;
171
230
  }
172
231
  set latencyMin(e) {
173
- let { max: t } = r(this.backend.latency.peek());
174
- this.backend.latency.set(i(e, t));
232
+ let { max: t } = c(this.controls.latency.peek());
233
+ this.controls.latency.set(l(e, t));
175
234
  }
176
235
  get latencyMax() {
177
- return r(this.backend.latency.peek()).max;
236
+ return c(this.controls.latency.peek()).max;
178
237
  }
179
238
  set latencyMax(e) {
180
- let { min: t } = r(this.backend.latency.peek());
181
- this.backend.latency.set(i(t, e));
239
+ let { min: t } = c(this.controls.latency.peek());
240
+ this.controls.latency.set(l(t, e));
182
241
  }
183
242
  get jitter() {
184
- return this.backend.jitter.peek();
185
- }
186
- set jitter(e) {
187
- this.latency = e;
243
+ return this.sync.out.jitter.peek();
188
244
  }
189
245
  reset() {
190
- this.backend.reset();
246
+ this.sync.reset(), this.audio.reset();
191
247
  }
192
248
  get catalogFormat() {
193
- return this.broadcast.catalogFormat.peek();
249
+ return this.#n.peek();
194
250
  }
195
251
  set catalogFormat(e) {
196
- this.broadcast.catalogFormat.set(e);
252
+ this.#n.set(e);
197
253
  }
198
254
  get catalog() {
199
- return this.broadcast.catalog.peek();
255
+ return this.broadcast.out.catalog.peek();
200
256
  }
201
257
  set catalog(e) {
202
- this.broadcast.catalog.set(e);
258
+ this.#r.set(e);
203
259
  }
204
260
  };
205
- customElements.define("moq-watch", f);
261
+ customElements.define("moq-watch", v);
206
262
  //#endregion
207
- export { f as default };
263
+ export { v as default };
208
264
 
209
265
  //# sourceMappingURL=element.js.map
package/element.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"element.js","names":["#enabled","#parseBound"],"sources":["../src/element.ts"],"sourcesContent":["import 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 { MultiBackend } from \"./backend\";\nimport { Broadcast, type CatalogFormat, parseCatalogFormat } from \"./broadcast\";\nimport { type Bound, type Latency, latencyBounds, latencyFromBounds } from \"./sync\";\nimport type { Visible } 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): 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\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// The backend that powers this element.\n\tbackend: MultiBackend;\n\n\t// Set when the element is connected to the DOM.\n\t#enabled = new Signal(false);\n\n\t// Expose the Effect class, so users can easily create effects scoped to this element.\n\tsignals = 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\tannounced: this.connection.announced,\n\t\t\tenabled: this.#enabled,\n\t\t});\n\t\tthis.signals.cleanup(() => this.broadcast.close());\n\n\t\tthis.backend = new MultiBackend({\n\t\t\tbroadcast: this.broadcast,\n\t\t\tconnection: this.connection.established,\n\t\t});\n\t\tthis.signals.cleanup(() => this.backend.close());\n\n\t\t// Watch to see if the canvas element is added or removed.\n\t\tconst setElement = () => {\n\t\t\tconst canvas = this.querySelector(\"canvas\") as HTMLCanvasElement | undefined;\n\t\t\tconst video = this.querySelector(\"video\") as HTMLVideoElement | undefined;\n\t\t\tif (canvas && video) {\n\t\t\t\tthrow new Error(\"Cannot have both canvas and video elements\");\n\t\t\t}\n\t\t\tthis.backend.element.set(canvas ?? video);\n\t\t};\n\n\t\tconst observer = new MutationObserver(setElement);\n\t\tobserver.observe(this, { childList: true, subtree: true });\n\t\tthis.signals.cleanup(() => observer.disconnect());\n\t\tsetElement();\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.broadcast.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.backend.audio.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.backend.paused);\n\t\t\tif (paused) {\n\t\t\t\tthis.setAttribute(\"paused\", \"true\");\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 visible = effect.get(this.backend.visible);\n\t\t\tthis.setAttribute(\"visible\", visible);\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst volume = effect.get(this.backend.audio.volume);\n\t\t\tthis.setAttribute(\"volume\", volume.toString());\n\t\t});\n\n\t\tthis.signals.run((effect) => {\n\t\t\tconst { min, max } = latencyBounds(effect.get(this.backend.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) return;\n\t\t\tif (min === \"real-time\") {\n\t\t\t\tthis.setAttribute(\"latency\", \"real-time\");\n\t\t\t} else {\n\t\t\t\tconst jitter = Math.floor(effect.get(this.backend.jitter));\n\t\t\t\tthis.setAttribute(\"latency\", 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.backend.video.source.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\tconst parsed = Number.parseFloat(value);\n\t\treturn (Number.isFinite(parsed) ? parsed : 100) as Time.Milli;\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.broadcast.name.set(Moq.Path.from(newValue ?? \"\"));\n\t\t} else if (name === \"paused\") {\n\t\t\tthis.backend.paused.set(newValue !== null);\n\t\t} else if (name === \"volume\") {\n\t\t\tconst volume = newValue ? Number.parseFloat(newValue) : 0.5;\n\t\t\tthis.backend.audio.volume.set(volume);\n\t\t} else if (name === \"muted\") {\n\t\t\tthis.backend.audio.muted.set(newValue !== null);\n\t\t} else if (name === \"visible\") {\n\t\t\tthis.backend.visible.set(parseVisible(newValue));\n\t\t} else if (name === \"reload\") {\n\t\t\tthis.broadcast.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\tthis.latency = this.#parseBound(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.broadcast.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.broadcast.name.peek();\n\t}\n\n\tset name(value: string | Moq.Path.Valid) {\n\t\tthis.broadcast.name.set(Moq.Path.from(value));\n\t}\n\n\tget paused(): boolean {\n\t\treturn this.backend.paused.peek();\n\t}\n\n\tset paused(value: boolean) {\n\t\tthis.backend.paused.set(value);\n\t}\n\n\tget volume(): number {\n\t\treturn this.backend.audio.volume.peek();\n\t}\n\n\tset volume(value: number) {\n\t\tthis.backend.audio.volume.set(value);\n\t}\n\n\tget muted(): boolean {\n\t\treturn this.backend.audio.muted.peek();\n\t}\n\n\tset muted(value: boolean) {\n\t\tthis.backend.audio.muted.set(value);\n\t}\n\n\t/** When video is downloaded relative to the canvas position. See {@link Visible}. */\n\tget visible(): Visible {\n\t\treturn this.backend.visible.peek();\n\t}\n\n\tset visible(value: Visible) {\n\t\tthis.backend.visible.set(value);\n\t}\n\n\tget reload(): boolean {\n\t\treturn this.broadcast.reload.peek();\n\t}\n\n\tset reload(value: boolean) {\n\t\tthis.broadcast.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\tget latency(): Latency {\n\t\treturn this.backend.latency.peek();\n\t}\n\n\tset latency(value: Latency) {\n\t\tthis.backend.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.backend.latency.peek()).min;\n\t}\n\n\tset latencyMin(value: Bound) {\n\t\tconst { max } = latencyBounds(this.backend.latency.peek());\n\t\tthis.backend.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.backend.latency.peek()).max;\n\t}\n\n\tset latencyMax(value: Bound) {\n\t\tconst { min } = latencyBounds(this.backend.latency.peek());\n\t\tthis.backend.latency.set(latencyFromBounds(min, value));\n\t}\n\n\t/** The jitter buffer in milliseconds. */\n\tget jitter(): Time.Milli {\n\t\treturn this.backend.jitter.peek();\n\t}\n\n\t/** @deprecated Use `latency = <number>` instead. */\n\tset jitter(value: number) {\n\t\tthis.latency = value as Time.Milli;\n\t}\n\n\t/** Re-anchor playback and flush the audio buffer at an utterance boundary (buffered mode). */\n\treset(): void {\n\t\tthis.backend.reset();\n\t}\n\n\tget catalogFormat(): CatalogFormat | undefined {\n\t\treturn this.broadcast.catalogFormat.peek();\n\t}\n\n\tset catalogFormat(value: CatalogFormat | undefined) {\n\t\tthis.broadcast.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.catalog.peek();\n\t}\n\n\tset catalog(value: Catalog.Root | undefined) {\n\t\tthis.broadcast.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":";;;;;AASA,IAAM,IAAW;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAIA,SAAS,EAAa,GAA+B;CACpD,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;AAEA,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,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,KAAK,QAAQ,QAAQ,KAAK;CAClC;CAEA,IAAI,QAAQ,GAAgB;EAC3B,KAAK,QAAQ,QAAQ,IAAI,CAAK;CAC/B;CAGA,IAAI,aAAoB;EACvB,OAAO,EAAc,KAAK,QAAQ,QAAQ,KAAK,CAAC,CAAC,CAAC;CACnD;CAEA,IAAI,WAAW,GAAc;EAC5B,IAAM,EAAE,WAAQ,EAAc,KAAK,QAAQ,QAAQ,KAAK,CAAC;EACzD,KAAK,QAAQ,QAAQ,IAAI,EAAkB,GAAO,CAAG,CAAC;CACvD;CAQA,IAAI,aAAoB;EACvB,OAAO,EAAc,KAAK,QAAQ,QAAQ,KAAK,CAAC,CAAC,CAAC;CACnD;CAEA,IAAI,WAAW,GAAc;EAC5B,IAAM,EAAE,WAAQ,EAAc,KAAK,QAAQ,QAAQ,KAAK,CAAC;EACzD,KAAK,QAAQ,QAAQ,IAAI,EAAkB,GAAK,CAAK,CAAC;CACvD;CAGA,IAAI,SAAqB;EACxB,OAAO,KAAK,QAAQ,OAAO,KAAK;CACjC;CAGA,IAAI,OAAO,GAAe;EACzB,KAAK,UAAU;CAChB;CAGA,QAAc;EACb,KAAK,QAAQ,MAAM;CACpB;CAEA,IAAI,gBAA2C;EAC9C,OAAO,KAAK,UAAU,cAAc,KAAK;CAC1C;CAEA,IAAI,cAAc,GAAkC;EACnD,KAAK,UAAU,cAAc,IAAI,CAAK;CACvC;CAMA,IAAI,UAAoC;EACvC,OAAO,KAAK,UAAU,QAAQ,KAAK;CACpC;CAEA,IAAI,QAAQ,GAAiC;EAC5C,KAAK,UAAU,QAAQ,IAAI,CAAK;CACjC;AACD;AAEA,eAAe,OAAO,aAAa,CAAQ"}
1
+ {"version":3,"file":"element.js","names":["#enabled","#name","#reload","#catalogFormat","#catalog","#videoEnabled","#audioEnabled","#canvas","#unmuteVolume","#parseBound"],"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, 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};\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 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\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\tthis.sync = new Sync({\n\t\t\tlatency: this.controls.latency,\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\tthis.video = new Video.Decoder(videoSource, this.sync, { enabled: this.#videoEnabled });\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).\n\t\tthis.signals.proxy(this.#audioEnabled, this.emitter.out.enabled);\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 { min, max } = latencyBounds(effect.get(this.controls.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) return;\n\t\t\tif (min === \"real-time\") {\n\t\t\t\tthis.setAttribute(\"latency\", \"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.setAttribute(\"latency\", 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\tconst parsed = Number.parseFloat(value);\n\t\treturn Moq.Time.Milli(Number.isFinite(parsed) ? parsed : 100);\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\tthis.latency = this.#parseBound(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\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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AO,KAAK,SAAS,QAAQ,KAAK;CACnC;CAEA,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,KAAKC,GAAe,KAAK;CACjC;CAEA,IAAI,cAAc,GAAkC;EACnD,KAAKA,GAAe,IAAI,CAAK;CAC9B;CAMA,IAAI,UAAoC;EACvC,OAAO,KAAK,UAAU,IAAI,QAAQ,KAAK;CACxC;CAEA,IAAI,QAAQ,GAAiC;EAC5C,KAAKC,GAAS,IAAI,CAAK;CACxB;AACD;AAEA,eAAe,OAAO,aAAa,CAAQ"}
package/index.d.ts CHANGED
@@ -1,14 +1,17 @@
1
+ /**
2
+ * Subscribe to a broadcast, decode it, and render it.
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 `@moq/watch/element` instead.
6
+ *
7
+ * @module
8
+ */
1
9
  export * as Hang from "@moq/hang";
2
- export * as Json from "@moq/json";
10
+ export type { BufferedRange, BufferedRanges } from "@moq/hang/container";
3
11
  export * as Net from "@moq/net";
4
- /** @deprecated Use `Net` instead. */
5
- export * as Lite from "@moq/net";
6
12
  export * as Signals from "@moq/signals";
7
13
  export * as Audio from "./audio";
8
- export * from "./backend";
9
14
  export * from "./broadcast";
10
- export * from "./buffered";
11
- export * as Mse from "./mse";
12
15
  export * from "./sync";
13
16
  export * as Video from "./video";
14
17
  //# 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,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,qCAAqC;AACrC,OAAO,KAAK,IAAI,MAAM,UAAU,CAAC;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,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,QAAQ,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
package/index.js CHANGED
@@ -1,7 +1,26 @@
1
- import { a as e, c as t, i as n, n as r, o as i, r as a, s as o, t as s } from "./broadcast-C2qofUBv.js";
2
- import { n as c, r as l, t as u } from "./sync-D67IxmxJ.js";
3
- import * as d from "@moq/hang";
4
- import * as f from "@moq/json";
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-CWtgjSC_.js";
2
+ import { n as l, r as u, t as d } from "./sync-zdwVEj9u.js";
3
+ import * as f from "@moq/hang";
5
4
  import * as p from "@moq/net";
6
5
  import * as m from "@moq/signals";
7
- export { o as Audio, s as Broadcast, r as CATALOG_FORMATS, d as Hang, f as Json, p as Lite, p as Net, i as Mse, n as MultiBackend, m as Signals, u as Sync, e as Video, c as latencyBounds, l as latencyFromBounds, a as parseCatalogFormat, t as timeRangesToArray };
6
+ //#region \0rolldown/runtime.js
7
+ var h = Object.defineProperty, g = (e, t) => {
8
+ let n = {};
9
+ for (var r in e) h(n, r, {
10
+ get: e[r],
11
+ enumerable: !0
12
+ });
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
22
+ });
23
+ //#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 };
25
+
26
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +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":""}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moq/watch",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.4.0",
5
5
  "description": "Watch Media over QUIC broadcasts",
6
6
  "license": "(MIT OR Apache-2.0)",
7
7
  "repository": "github:moq-dev/moq",
@@ -33,10 +33,9 @@
33
33
  "./support/element.js"
34
34
  ],
35
35
  "dependencies": {
36
- "@moq/hang": "^0.2.15",
37
- "@moq/json": "^0.2.0",
38
- "@moq/net": "^0.1.9",
39
- "@moq/msf": "^0.1.4",
40
- "@moq/signals": "^0.1.10"
36
+ "@moq/hang": "^0.3.0",
37
+ "@moq/net": "^0.2.0",
38
+ "@moq/msf": "^0.2.0",
39
+ "@moq/signals": "^0.2.0"
41
40
  }
42
41
  }