@norskvideo/moq-watch 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/element.js.map +1 -1
- package/package.json +6 -5
- package/source-lWNGIbmd.js.map +1 -1
- package/support/element.js.map +1 -1
- package/sync-DNQkgnlX.js.map +1 -1
- package/ui/element.js +1 -1
- package/ui/element.js.map +1 -1
package/element.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","names":["#enabled","#name","#reload","#catalogFormat","#catalog","#syncLatency","#videoPaced","#videoEnabled","#audioEnabled","#canvas","#unmuteVolume","#reflectLatency","#reflectingLatency","#parseBound","#parseLatency"],"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};\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\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,IA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AAS,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"}
|
|
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};\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\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;CAGA;CAGA;CAGA;CAKA,WAAoB;EACnB,QAAQ,IAAI,EAAO,EAAK;EACxB,QAAQ,IAAI,EAAO,EAAG;EACtB,OAAO,IAAI,EAAO,EAAK;EAEvB,SAAS,IAAI,EAAsB,KAAK;EACxC,SAAS,IAAI,EAAgB,WAAW;EAExC,QAAQ,IAAI,EAAiC,KAAA,CAAS;CACvD;CAGA,KAAQ,IAAI,EAAuB,EAAI,KAAK,MAAM,CAAC;CACnD,KAAU,IAAI,EAAO,EAAI;CACzB,KAAiB,IAAI,EAAkC,KAAA,CAAS;CAChE,KAAW,IAAI,EAAiC,KAAA,CAAS;CA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eAAe,OAAO,aAAa,CAAQ"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@norskvideo/moq-watch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.6",
|
|
5
5
|
"description": "Watch Media over QUIC broadcasts",
|
|
6
6
|
"license": "(MIT OR Apache-2.0)",
|
|
7
7
|
"repository": "github:moq-dev/moq",
|
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
"./support/element.js"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@norskvideo/moq-hang": "^0.1.
|
|
37
|
-
"@norskvideo/moq-
|
|
38
|
-
"@norskvideo/moq-msf": "^0.1.
|
|
39
|
-
"@norskvideo/moq-
|
|
36
|
+
"@norskvideo/moq-hang": "^0.1.6",
|
|
37
|
+
"@norskvideo/moq-json": "^0.1.6",
|
|
38
|
+
"@norskvideo/moq-msf": "^0.1.6",
|
|
39
|
+
"@norskvideo/moq-net": "^0.1.6",
|
|
40
|
+
"@norskvideo/moq-signals": "^0.1.6"
|
|
40
41
|
}
|
|
41
42
|
}
|