@livepeer-frameworks/player-wc 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/fw-dev-mode-panel.js +845 -212
- package/dist/cjs/components/fw-dev-mode-panel.js.map +1 -1
- package/dist/cjs/components/fw-dvd-logo.js +211 -0
- package/dist/cjs/components/fw-dvd-logo.js.map +1 -0
- package/dist/cjs/components/fw-idle-screen.js +641 -97
- package/dist/cjs/components/fw-idle-screen.js.map +1 -1
- package/dist/cjs/components/fw-loading-screen.js +513 -0
- package/dist/cjs/components/fw-loading-screen.js.map +1 -0
- package/dist/cjs/components/fw-player-controls.js +347 -173
- package/dist/cjs/components/fw-player-controls.js.map +1 -1
- package/dist/cjs/components/fw-player.js +460 -60
- package/dist/cjs/components/fw-player.js.map +1 -1
- package/dist/cjs/components/fw-seek-bar.js +292 -142
- package/dist/cjs/components/fw-seek-bar.js.map +1 -1
- package/dist/cjs/components/fw-settings-menu.js +191 -81
- package/dist/cjs/components/fw-settings-menu.js.map +1 -1
- package/dist/cjs/components/fw-stats-panel.js +134 -70
- package/dist/cjs/components/fw-stats-panel.js.map +1 -1
- package/dist/cjs/components/fw-stream-state-overlay.js +338 -0
- package/dist/cjs/components/fw-stream-state-overlay.js.map +1 -0
- package/dist/cjs/components/fw-subtitle-renderer.js +174 -27
- package/dist/cjs/components/fw-subtitle-renderer.js.map +1 -1
- package/dist/cjs/components/fw-thumbnail-overlay.js +161 -0
- package/dist/cjs/components/fw-thumbnail-overlay.js.map +1 -0
- package/dist/cjs/components/fw-volume-control.js +150 -69
- package/dist/cjs/components/fw-volume-control.js.map +1 -1
- package/dist/cjs/components/shared/hitmarker-audio.js +76 -0
- package/dist/cjs/components/shared/hitmarker-audio.js.map +1 -0
- package/dist/cjs/constants/media-assets.js +11 -0
- package/dist/cjs/constants/media-assets.js.map +1 -0
- package/dist/cjs/controllers/player-controller-host.js +28 -1
- package/dist/cjs/controllers/player-controller-host.js.map +1 -1
- package/dist/cjs/define.js +8 -0
- package/dist/cjs/define.js.map +1 -1
- package/dist/cjs/icons/index.js +27 -0
- package/dist/cjs/icons/index.js.map +1 -1
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/fw-dev-mode-panel.js +846 -213
- package/dist/esm/components/fw-dev-mode-panel.js.map +1 -1
- package/dist/esm/components/fw-dvd-logo.js +211 -0
- package/dist/esm/components/fw-dvd-logo.js.map +1 -0
- package/dist/esm/components/fw-idle-screen.js +643 -99
- package/dist/esm/components/fw-idle-screen.js.map +1 -1
- package/dist/esm/components/fw-loading-screen.js +513 -0
- package/dist/esm/components/fw-loading-screen.js.map +1 -0
- package/dist/esm/components/fw-player-controls.js +348 -174
- package/dist/esm/components/fw-player-controls.js.map +1 -1
- package/dist/esm/components/fw-player.js +460 -60
- package/dist/esm/components/fw-player.js.map +1 -1
- package/dist/esm/components/fw-seek-bar.js +293 -143
- package/dist/esm/components/fw-seek-bar.js.map +1 -1
- package/dist/esm/components/fw-settings-menu.js +192 -82
- package/dist/esm/components/fw-settings-menu.js.map +1 -1
- package/dist/esm/components/fw-stats-panel.js +135 -71
- package/dist/esm/components/fw-stats-panel.js.map +1 -1
- package/dist/esm/components/fw-stream-state-overlay.js +338 -0
- package/dist/esm/components/fw-stream-state-overlay.js.map +1 -0
- package/dist/esm/components/fw-subtitle-renderer.js +175 -28
- package/dist/esm/components/fw-subtitle-renderer.js.map +1 -1
- package/dist/esm/components/fw-thumbnail-overlay.js +161 -0
- package/dist/esm/components/fw-thumbnail-overlay.js.map +1 -0
- package/dist/esm/components/fw-volume-control.js +150 -69
- package/dist/esm/components/fw-volume-control.js.map +1 -1
- package/dist/esm/components/shared/hitmarker-audio.js +74 -0
- package/dist/esm/components/shared/hitmarker-audio.js.map +1 -0
- package/dist/esm/constants/media-assets.js +8 -0
- package/dist/esm/constants/media-assets.js.map +1 -0
- package/dist/esm/controllers/player-controller-host.js +28 -1
- package/dist/esm/controllers/player-controller-host.js.map +1 -1
- package/dist/esm/define.js +8 -0
- package/dist/esm/define.js.map +1 -1
- package/dist/esm/icons/index.js +26 -2
- package/dist/esm/icons/index.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/fw-player.iife.js +2072 -880
- package/dist/types/components/fw-dev-mode-panel.d.ts +36 -9
- package/dist/types/components/fw-dvd-logo.d.ts +29 -0
- package/dist/types/components/fw-idle-screen.d.ts +36 -0
- package/dist/types/components/fw-loading-screen.d.ts +36 -0
- package/dist/types/components/fw-player-controls.d.ts +21 -6
- package/dist/types/components/fw-player.d.ts +28 -1
- package/dist/types/components/fw-seek-bar.d.ts +31 -14
- package/dist/types/components/fw-settings-menu.d.ts +15 -1
- package/dist/types/components/fw-stats-panel.d.ts +4 -4
- package/dist/types/components/fw-stream-state-overlay.d.ts +20 -0
- package/dist/types/components/fw-subtitle-renderer.d.ts +33 -2
- package/dist/types/components/fw-thumbnail-overlay.d.ts +17 -0
- package/dist/types/components/fw-volume-control.d.ts +11 -4
- package/dist/types/components/shared/hitmarker-audio.d.ts +1 -0
- package/dist/types/constants/media-assets.d.ts +5 -0
- package/dist/types/controllers/player-controller-host.d.ts +14 -1
- package/dist/types/iife-entry.d.ts +4 -0
- package/dist/types/index.d.ts +4 -0
- package/package.json +3 -3
- package/src/components/fw-dev-mode-panel.ts +929 -228
- package/src/components/fw-dvd-logo.ts +233 -0
- package/src/components/fw-idle-screen.ts +680 -100
- package/src/components/fw-loading-screen.ts +540 -0
- package/src/components/fw-player-controls.ts +435 -176
- package/src/components/fw-player.ts +505 -57
- package/src/components/fw-seek-bar.ts +336 -143
- package/src/components/fw-settings-menu.ts +208 -85
- package/src/components/fw-stats-panel.ts +150 -77
- package/src/components/fw-stream-state-overlay.ts +331 -0
- package/src/components/fw-subtitle-renderer.ts +216 -28
- package/src/components/fw-thumbnail-overlay.ts +148 -0
- package/src/components/fw-volume-control.ts +166 -66
- package/src/components/shared/hitmarker-audio.ts +92 -0
- package/src/constants/media-assets.ts +7 -0
- package/src/controllers/player-controller-host.ts +29 -2
- package/src/define.ts +8 -0
- package/src/iife-entry.ts +4 -0
- package/src/index.ts +4 -0
- package/dist/fw-player.iife.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fw-stats-panel.js","sources":["../../../../src/components/fw-stats-panel.ts"],"sourcesContent":["/**\n * <fw-stats-panel> — Stats for nerds overlay.\n * Port of StatsPanel.tsx from player-react.\n */\nimport { LitElement, html, css, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { sharedStyles } from \"../styles/shared-styles.js\";\nimport { utilityStyles } from \"../styles/utility-styles.js\";\nimport { closeIcon } from \"../icons/index.js\";\nimport type { PlayerControllerHost } from \"../controllers/player-controller-host.js\";\n\n@customElement(\"fw-stats-panel\")\nexport class FwStatsPanel extends LitElement {\n @property({ attribute: false }) pc!: PlayerControllerHost;\n\n static styles = [\n sharedStyles,\n utilityStyles,\n css`\n :host {\n display: contents;\n }\n .panel {\n position: absolute;\n top: 0.75rem;\n left: 0.75rem;\n z-index: 30;\n min-width: 240px;\n max-width: 320px;\n max-height: 80%;\n overflow: auto;\n border-radius: 0.5rem;\n border: 1px solid rgb(255 255 255 / 0.1);\n background: rgb(0 0 0 / 0.85);\n backdrop-filter: blur(8px);\n padding: 0.5rem 0.75rem;\n font-size: 0.6875rem;\n color: rgb(255 255 255 / 0.7);\n }\n .header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 0.5rem;\n }\n .title {\n font-size: 0.75rem;\n font-weight: 600;\n color: white;\n }\n .close {\n display: flex;\n background: none;\n border: none;\n color: rgb(255 255 255 / 0.5);\n cursor: pointer;\n padding: 0;\n }\n .close:hover {\n color: white;\n }\n .row {\n display: flex;\n justify-content: space-between;\n padding: 0.125rem 0;\n }\n .label {\n color: rgb(255 255 255 / 0.5);\n }\n .value {\n color: rgb(255 255 255 / 0.9);\n font-variant-numeric: tabular-nums;\n font-family: ui-monospace, monospace;\n }\n .sep {\n height: 1px;\n background: rgb(255 255 255 / 0.08);\n margin: 0.375rem 0;\n }\n `,\n ];\n\n private _resolution(): string | null {\n const video = this.pc.s.videoElement;\n if (!video || !video.videoWidth || !video.videoHeight) return null;\n return `${video.videoWidth}x${video.videoHeight}`;\n }\n\n private _stat(label: string, value: string | number | null | undefined) {\n if (value == null || value === \"\") return nothing;\n return html`<div class=\"row\">\n <span class=\"label\">${label}</span><span class=\"value\">${value}</span>\n </div>`;\n }\n\n protected render() {\n const s = this.pc.s;\n const q = s.playbackQuality;\n const meta = s.metadata;\n const ss = s.streamState;\n\n return html`\n <div class=\"panel fw-stats-panel\">\n <div class=\"header\">\n <span class=\"title\">Stats</span>\n <button\n class=\"close\"\n @click=${() =>\n this.dispatchEvent(new CustomEvent(\"fw-close\", { bubbles: true, composed: true }))}\n aria-label=\"Close stats\"\n >\n ${closeIcon()}\n </button>\n </div>\n\n ${this._stat(\"State\", s.state)} ${this._stat(\"Player\", s.currentPlayerInfo?.name)}\n ${this._stat(\"Source\", s.currentSourceInfo?.type)}\n\n <div class=\"sep\"></div>\n\n ${q\n ? html`\n ${this._stat(\"Resolution\", this._resolution())}\n ${this._stat(\"Bitrate\", q.bitrate ? `${Math.round(q.bitrate / 1000)} kbps` : null)}\n ${this._stat(\"Latency\", q.latency != null ? `${q.latency.toFixed(1)}s` : null)}\n ${this._stat(\n \"Buffer\",\n q.bufferedAhead != null ? `${q.bufferedAhead.toFixed(1)}s` : null\n )}\n ${this._stat(\"Quality\", q.score != null ? `${q.score.toFixed(0)}` : null)}\n ${this._stat(\n \"Frame drops\",\n q.frameDropRate != null ? `${q.frameDropRate.toFixed(1)}%` : null\n )}\n ${this._stat(\"Stalls\", q.stallCount ?? null)}\n `\n : nothing}\n ${meta || ss\n ? html`\n <div class=\"sep\"></div>\n ${this._stat(\"Viewers\", meta?.viewers ?? null)}\n ${this._stat(\"Stream status\", ss?.status ?? null)}\n `\n : nothing}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"fw-stats-panel\": FwStatsPanel;\n }\n}\n"],"names":["FwStatsPanel","LitElement","nothing","html","closeIcon","sharedStyles","utilityStyles","css","__decorate","property","customElement"],"mappings":";;;;;;;;;AAYaA,oBAAY,GAAlB,MAAM,YAAa,SAAQC,cAAU,CAAA;IAsElC,WAAW,GAAA;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY;QACpC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,WAAW;AAAE,YAAA,OAAO,IAAI;QAClE,OAAO,CAAA,EAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,WAAW,CAAA,CAAE;IACnD;IAEQ,KAAK,CAAC,KAAa,EAAE,KAAyC,EAAA;AACpE,QAAA,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE;AAAE,YAAA,OAAOC,WAAO;AACjD,QAAA,OAAOC,QAAI,CAAA,CAAA;AACa,0BAAA,EAAA,KAAK,8BAA8B,KAAK,CAAA;WACzD;IACT;IAEU,MAAM,GAAA;AACd,QAAA,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;AACnB,QAAA,MAAM,CAAC,GAAG,CAAC,CAAC,eAAe;AAC3B,QAAA,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ;AACvB,QAAA,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW;AAExB,QAAA,OAAOA,QAAI,CAAA;;;;;;qBAMM,MACP,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;;;AAGlF,YAAA,EAAAC,eAAS,EAAE;;;;UAIf,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,C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AAI,CAAC;AAC7C,YAAA;AACH,cAAED,WAAO;AACT,QAAA,EAAA,IAAI,IAAI;cACNC,QAAI,CAAA;;gBAEA,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC;gBAC5C,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,EAAE,MAAM,IAAI,IAAI,CAAC;AAClD,YAAA;AACH,cAAED,WAAO;;KAEd;IACH;;AAnIOF,oBAAA,CAAA,MAAM,GAAG;IACdK,yBAAY;IACZC,2BAAa;AACb,IAAAC,OAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DF,IAAA,CAAA;AACF,CAjEY;AAFmBC,oBAAA,CAAA;AAA/B,IAAAC,sBAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AAA4B,CAAA,EAAAT,oBAAA,CAAA,SAAA,EAAA,IAAA,EAAA,MAAA,CAAA;AAD/CA,oBAAY,GAAAQ,oBAAA,CAAA;IADxBE,2BAAa,CAAC,gBAAgB;AAClB,CAAA,EAAAV,oBAAY,CAuIxB;;"}
|
|
1
|
+
{"version":3,"file":"fw-stats-panel.js","sources":["../../../../src/components/fw-stats-panel.ts"],"sourcesContent":["/**\n * <fw-stats-panel> — Stats for nerds overlay aligned with wrapper diagnostics.\n */\nimport { LitElement, html, css } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { sharedStyles } from \"../styles/shared-styles.js\";\nimport { utilityStyles } from \"../styles/utility-styles.js\";\nimport { closeIcon } from \"../icons/index.js\";\nimport type { PlayerControllerHost } from \"../controllers/player-controller-host.js\";\n\ninterface StatRow {\n label: string;\n value: string;\n}\n\n@customElement(\"fw-stats-panel\")\nexport class FwStatsPanel extends LitElement {\n @property({ attribute: false }) pc!: PlayerControllerHost;\n\n static styles = [\n sharedStyles,\n utilityStyles,\n css`\n :host {\n display: contents;\n }\n .panel {\n position: absolute;\n top: 0.5rem;\n right: 0.5rem;\n z-index: 30;\n width: 18rem;\n max-height: 80%;\n overflow-y: auto;\n background: hsl(var(--tn-bg-dark) / 0.9);\n backdrop-filter: blur(4px);\n border: 1px solid hsl(var(--tn-fg-gutter) / 0.3);\n font-family: ui-monospace, monospace;\n font-size: 0.75rem;\n color: hsl(var(--tn-fg));\n }\n .header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0.5rem;\n border-bottom: 1px solid hsl(var(--tn-fg-gutter) / 0.3);\n }\n .title {\n font-size: 10px;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: hsl(var(--tn-fg-dark));\n }\n .close {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 1.5rem;\n height: 1.5rem;\n border: none;\n background: transparent;\n color: hsl(var(--tn-fg-dark));\n cursor: pointer;\n }\n .close:hover {\n color: hsl(var(--tn-fg));\n }\n .rows {\n padding: 0.5rem;\n }\n .row {\n display: flex;\n justify-content: space-between;\n gap: 0.5rem;\n padding: 0.125rem 0;\n }\n .label {\n color: hsl(var(--tn-fg-dark));\n }\n .value {\n color: hsl(var(--tn-fg));\n text-align: right;\n word-break: break-word;\n }\n `,\n ];\n\n private _deriveTracksFromMist(mistInfo: any) {\n const mistTracks = mistInfo?.meta?.tracks;\n if (!mistTracks) return undefined;\n return Object.values(mistTracks as Record<string, any>).map((track: any) => ({\n type: track.type,\n codec: track.codec,\n width: track.width,\n height: track.height,\n bitrate: typeof track.bps === \"number\" ? Math.round(track.bps) : undefined,\n fps: typeof track.fpks === \"number\" ? track.fpks / 1000 : undefined,\n channels: track.channels,\n sampleRate: track.rate,\n }));\n }\n\n private _formatTracks(metadata: any, mistInfo: any): string {\n const tracks = metadata?.tracks ?? this._deriveTracksFromMist(mistInfo);\n if (!tracks?.length) return \"—\";\n return tracks\n .map((track: any) => {\n if (track.type === \"video\") {\n const resolution = track.width && track.height ? `${track.width}x${track.height}` : \"?\";\n const bitrate = track.bitrate ? `${Math.round(track.bitrate / 1000)}kbps` : \"?\";\n return `${track.codec ?? \"?\"} ${resolution}@${bitrate}`;\n }\n const channels = track.channels ? `${track.channels}ch` : \"?\";\n return `${track.codec ?? \"?\"} ${channels}`;\n })\n .join(\", \");\n }\n\n private _collectStats(): StatRow[] {\n const s = this.pc.s;\n const video = s.videoElement;\n const quality = s.playbackQuality;\n const metadata = s.metadata;\n const streamState = s.streamState;\n const primaryEndpoint = s.endpoints?.primary as\n | { protocol?: string; nodeId?: string; geoDistance?: number }\n | undefined;\n\n const currentRes = video ? `${video.videoWidth}x${video.videoHeight}` : \"—\";\n const buffered =\n video && video.buffered.length > 0\n ? (video.buffered.end(video.buffered.length - 1) - video.currentTime).toFixed(1)\n : \"—\";\n const playbackRate = video?.playbackRate?.toFixed(2) ?? \"1.00\";\n const qualityScore = quality?.score?.toFixed(0) ?? \"—\";\n const bitrateKbps = quality?.bitrate ? `${(quality.bitrate / 1000).toFixed(0)} kbps` : \"—\";\n const frameDropRate = quality?.frameDropRate?.toFixed(1) ?? \"—\";\n const stallCount = quality?.stallCount ?? 0;\n const latency = quality?.latency ? `${Math.round(quality.latency)} ms` : \"—\";\n const viewers = metadata?.viewers ?? \"—\";\n const streamStatus = streamState?.status ?? metadata?.status ?? \"—\";\n const mistInfo = metadata?.mist ?? streamState?.streamInfo;\n const mistType = mistInfo?.type ?? \"—\";\n const mistBufferWindow = mistInfo?.meta?.buffer_window;\n const mistLastMs = mistInfo?.lastms;\n const mistUnixOffset = mistInfo?.unixoffset;\n\n const stats: StatRow[] = [\n { label: \"Resolution\", value: currentRes },\n { label: \"Buffer\", value: `${buffered}s` },\n { label: \"Latency\", value: latency },\n { label: \"Bitrate\", value: bitrateKbps },\n { label: \"Quality Score\", value: `${qualityScore}/100` },\n { label: \"Frame Drop Rate\", value: `${frameDropRate}%` },\n { label: \"Stalls\", value: String(stallCount) },\n { label: \"Playback Rate\", value: `${playbackRate}x` },\n { label: \"Protocol\", value: primaryEndpoint?.protocol ?? \"—\" },\n { label: \"Node\", value: primaryEndpoint?.nodeId ?? \"—\" },\n {\n label: \"Geo Distance\",\n value: primaryEndpoint?.geoDistance ? `${primaryEndpoint.geoDistance.toFixed(0)} km` : \"—\",\n },\n { label: \"Viewers\", value: String(viewers) },\n { label: \"Status\", value: streamStatus },\n { label: \"Tracks\", value: this._formatTracks(metadata, mistInfo) },\n { label: \"Mist Type\", value: mistType },\n {\n label: \"Mist Buffer Window\",\n value: mistBufferWindow != null ? String(mistBufferWindow) : \"—\",\n },\n { label: \"Mist Lastms\", value: mistLastMs != null ? String(mistLastMs) : \"—\" },\n { label: \"Mist Unixoffset\", value: mistUnixOffset != null ? String(mistUnixOffset) : \"—\" },\n ];\n\n if (metadata?.title) {\n stats.unshift({ label: \"Title\", value: metadata.title });\n }\n if (metadata?.durationSeconds) {\n const mins = Math.floor(metadata.durationSeconds / 60);\n const secs = metadata.durationSeconds % 60;\n stats.push({ label: \"Duration\", value: `${mins}:${String(secs).padStart(2, \"0\")}` });\n }\n if (metadata?.recordingSizeBytes) {\n const mb = (metadata.recordingSizeBytes / (1024 * 1024)).toFixed(1);\n stats.push({ label: \"Size\", value: `${mb} MB` });\n }\n\n return stats;\n }\n\n protected render() {\n const stats = this._collectStats();\n\n return html`\n <div class=\"panel fw-stats-panel\">\n <div class=\"header fw-stats-header\">\n <span class=\"title\">Stats Overlay</span>\n <button\n class=\"close\"\n @click=${() =>\n this.dispatchEvent(new CustomEvent(\"fw-close\", { bubbles: true, composed: true }))}\n aria-label=\"Close stats panel\"\n >\n ${closeIcon()}\n </button>\n </div>\n <div class=\"rows\">\n ${stats.map(\n (stat) =>\n html`<div class=\"row fw-stats-row\">\n <span class=\"label\">${stat.label}</span>\n <span class=\"value fw-stats-value\">${stat.value}</span>\n </div>`\n )}\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"fw-stats-panel\": FwStatsPanel;\n }\n}\n"],"names":["FwStatsPanel","LitElement","html","clos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EAAE,CAAC;QAClD;AAEA,QAAA,OAAO,KAAK;IACd;IAEU,MAAM,GAAA;AACd,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE;AAElC,QAAA,OAAOC,QAAI,CAAA;;;;;;qBAMM,MACP,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;;;AAGlF,YAAA,EAAAC,eAAS,EAAE;;;;YAIb,KAAK,CAAC,GAAG,CACT,CAAC,IAAI,KACHD,QAAI,CAAA,CAAA;AACoB,oCAAA,EAAA,IAAI,CAAC,KAAK,CAAA;AACK,mDAAA,EAAA,IAAI,CAAC,KAAK,CAAA;qBAC1C,CACV;;;KAGN;IACH;;AAxMOF,oBAAA,CAAA,MAAM,GAAG;IACdI,yBAAY;IACZC,2BAAa;AACb,IAAAC,OAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEF,IAAA,CAAA;AACF,CApEY;AAFmBC,oBAAA,CAAA;AAA/B,IAAAC,sBAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AAA4B,CAAA,EAAAR,oBAAA,CAAA,SAAA,EAAA,IAAA,EAAA,MAAA,CAAA;AAD/CA,oBAAY,GAAAO,oBAAA,CAAA;IADxBE,2BAAa,CAAC,gBAAgB;AAClB,CAAA,EAAAT,oBAAY,CA4MxB;;"}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('../node_modules/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.57.1_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
|
|
4
|
+
var lit = require('lit');
|
|
5
|
+
var decorators_js = require('lit/decorators.js');
|
|
6
|
+
var sharedStyles = require('../styles/shared-styles.js');
|
|
7
|
+
|
|
8
|
+
exports.FwStreamStateOverlay = class FwStreamStateOverlay extends lit.LitElement {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.status = "OFFLINE";
|
|
12
|
+
this.message = "";
|
|
13
|
+
this.visible = true;
|
|
14
|
+
this.retryEnabled = false;
|
|
15
|
+
this._handleRetry = () => {
|
|
16
|
+
if (this.onRetry) {
|
|
17
|
+
this.onRetry();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.dispatchEvent(new CustomEvent("fw-retry", { bubbles: true, composed: true }));
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
_getStatusLabel(status) {
|
|
24
|
+
switch (status) {
|
|
25
|
+
case "ONLINE":
|
|
26
|
+
return "ONLINE";
|
|
27
|
+
case "OFFLINE":
|
|
28
|
+
return "OFFLINE";
|
|
29
|
+
case "INITIALIZING":
|
|
30
|
+
return "INITIALIZING";
|
|
31
|
+
case "BOOTING":
|
|
32
|
+
return "STARTING";
|
|
33
|
+
case "WAITING_FOR_DATA":
|
|
34
|
+
return "WAITING";
|
|
35
|
+
case "SHUTTING_DOWN":
|
|
36
|
+
return "ENDING";
|
|
37
|
+
case "ERROR":
|
|
38
|
+
return "ERROR";
|
|
39
|
+
case "INVALID":
|
|
40
|
+
return "INVALID";
|
|
41
|
+
default:
|
|
42
|
+
return "STATUS";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
_renderStatusIcon(status) {
|
|
46
|
+
if (status === "OFFLINE") {
|
|
47
|
+
return lit.html `<svg
|
|
48
|
+
class="icon icon-offline"
|
|
49
|
+
fill="none"
|
|
50
|
+
viewBox="0 0 24 24"
|
|
51
|
+
stroke="currentColor"
|
|
52
|
+
>
|
|
53
|
+
<path
|
|
54
|
+
stroke-linecap="round"
|
|
55
|
+
stroke-linejoin="round"
|
|
56
|
+
stroke-width="2"
|
|
57
|
+
d="M18.364 5.636a9 9 0 010 12.728m0 0l-2.829-2.829m2.829 2.829L21 21M15.536 8.464a5 5 0 010 7.072m0 0l-2.829-2.829m-4.243 2.829a4.978 4.978 0 01-1.414-2.83m-1.414 5.658a9 9 0 01-2.167-9.238m7.824 2.167a1 1 0 111.414 1.414m-1.414-1.414L3 3m8.293 8.293l1.414 1.414"
|
|
58
|
+
></path>
|
|
59
|
+
</svg>`;
|
|
60
|
+
}
|
|
61
|
+
if (status === "INITIALIZING" || status === "BOOTING" || status === "WAITING_FOR_DATA") {
|
|
62
|
+
return lit.html `<svg class="icon icon-warning animate-spin" fill="none" viewBox="0 0 24 24">
|
|
63
|
+
<circle
|
|
64
|
+
class="opacity-25"
|
|
65
|
+
cx="12"
|
|
66
|
+
cy="12"
|
|
67
|
+
r="10"
|
|
68
|
+
stroke="currentColor"
|
|
69
|
+
stroke-width="4"
|
|
70
|
+
></circle>
|
|
71
|
+
<path
|
|
72
|
+
class="opacity-75"
|
|
73
|
+
fill="currentColor"
|
|
74
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
75
|
+
></path>
|
|
76
|
+
</svg>`;
|
|
77
|
+
}
|
|
78
|
+
if (status === "SHUTTING_DOWN") {
|
|
79
|
+
return lit.html `<svg
|
|
80
|
+
class="icon icon-warning"
|
|
81
|
+
fill="none"
|
|
82
|
+
viewBox="0 0 24 24"
|
|
83
|
+
stroke="currentColor"
|
|
84
|
+
>
|
|
85
|
+
<path
|
|
86
|
+
stroke-linecap="round"
|
|
87
|
+
stroke-linejoin="round"
|
|
88
|
+
stroke-width="2"
|
|
89
|
+
d="M13 10V3L4 14h7v7l9-11h-7z"
|
|
90
|
+
></path>
|
|
91
|
+
</svg>`;
|
|
92
|
+
}
|
|
93
|
+
return lit.html `<svg
|
|
94
|
+
class="icon icon-offline"
|
|
95
|
+
fill="none"
|
|
96
|
+
viewBox="0 0 24 24"
|
|
97
|
+
stroke="currentColor"
|
|
98
|
+
>
|
|
99
|
+
<path
|
|
100
|
+
stroke-linecap="round"
|
|
101
|
+
stroke-linejoin="round"
|
|
102
|
+
stroke-width="2"
|
|
103
|
+
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
104
|
+
></path>
|
|
105
|
+
</svg>`;
|
|
106
|
+
}
|
|
107
|
+
render() {
|
|
108
|
+
if (!this.visible || this.status === "ONLINE") {
|
|
109
|
+
return lit.nothing;
|
|
110
|
+
}
|
|
111
|
+
const showRetry = (this.status === "ERROR" || this.status === "INVALID" || this.status === "OFFLINE") &&
|
|
112
|
+
(this.retryEnabled || typeof this.onRetry === "function");
|
|
113
|
+
const showProgress = this.status === "INITIALIZING" && this.percentage !== undefined;
|
|
114
|
+
const progressWidth = `${Math.min(100, Math.max(0, this.percentage ?? 0))}%`;
|
|
115
|
+
return lit.html `
|
|
116
|
+
<div class="overlay-backdrop" role="status" aria-live="polite">
|
|
117
|
+
<div class="slab">
|
|
118
|
+
<div class="slab-header">
|
|
119
|
+
${this._renderStatusIcon(this.status)}
|
|
120
|
+
<span>${this._getStatusLabel(this.status)}</span>
|
|
121
|
+
</div>
|
|
122
|
+
<div class="slab-body">
|
|
123
|
+
<p class="slab-message">${this.message}</p>
|
|
124
|
+
${showProgress
|
|
125
|
+
? lit.html `
|
|
126
|
+
<div class="progress-wrap">
|
|
127
|
+
<div class="progress-bar">
|
|
128
|
+
<div class="progress-fill" style="width:${progressWidth};"></div>
|
|
129
|
+
</div>
|
|
130
|
+
<p class="progress-text">${Math.round(this.percentage ?? 0)}%</p>
|
|
131
|
+
</div>
|
|
132
|
+
`
|
|
133
|
+
: lit.nothing}
|
|
134
|
+
${this.status === "OFFLINE"
|
|
135
|
+
? lit.html `<p class="hint">The stream will start when the broadcaster goes live</p>`
|
|
136
|
+
: lit.nothing}
|
|
137
|
+
${this.status === "BOOTING" || this.status === "WAITING_FOR_DATA"
|
|
138
|
+
? lit.html `<p class="hint">Please wait while the stream prepares...</p>`
|
|
139
|
+
: lit.nothing}
|
|
140
|
+
${!showRetry
|
|
141
|
+
? lit.html `<div class="polling-indicator">
|
|
142
|
+
<span class="polling-dot"></span>
|
|
143
|
+
<span>Checking stream status...</span>
|
|
144
|
+
</div>`
|
|
145
|
+
: lit.nothing}
|
|
146
|
+
</div>
|
|
147
|
+
${showRetry
|
|
148
|
+
? lit.html `<div class="slab-actions">
|
|
149
|
+
<button
|
|
150
|
+
type="button"
|
|
151
|
+
class="btn-flush"
|
|
152
|
+
@click=${this._handleRetry}
|
|
153
|
+
aria-label="Retry connection"
|
|
154
|
+
>
|
|
155
|
+
Retry Connection
|
|
156
|
+
</button>
|
|
157
|
+
</div>`
|
|
158
|
+
: lit.nothing}
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
`;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
exports.FwStreamStateOverlay.styles = [
|
|
165
|
+
sharedStyles.sharedStyles,
|
|
166
|
+
lit.css `
|
|
167
|
+
:host {
|
|
168
|
+
display: contents;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.overlay-backdrop {
|
|
172
|
+
position: absolute;
|
|
173
|
+
inset: 0;
|
|
174
|
+
z-index: 20;
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
background-color: hsl(var(--tn-bg-dark, 235 21% 11%) / 0.8);
|
|
179
|
+
backdrop-filter: blur(4px);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.slab {
|
|
183
|
+
width: 280px;
|
|
184
|
+
max-width: 90%;
|
|
185
|
+
background-color: hsl(var(--tn-bg, 233 23% 17%) / 0.95);
|
|
186
|
+
border: 1px solid hsl(var(--tn-fg-gutter, 233 23% 25%) / 0.3);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.slab-header {
|
|
190
|
+
display: flex;
|
|
191
|
+
align-items: center;
|
|
192
|
+
gap: 0.5rem;
|
|
193
|
+
padding: 0.75rem 1rem;
|
|
194
|
+
border-bottom: 1px solid hsl(var(--tn-fg-gutter, 233 23% 25%) / 0.3);
|
|
195
|
+
font-size: 0.75rem;
|
|
196
|
+
font-weight: 600;
|
|
197
|
+
text-transform: uppercase;
|
|
198
|
+
letter-spacing: 0.05em;
|
|
199
|
+
color: hsl(var(--tn-fg-dark, 233 23% 60%));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.slab-body {
|
|
203
|
+
padding: 1rem;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.slab-message {
|
|
207
|
+
font-size: 0.875rem;
|
|
208
|
+
color: hsl(var(--tn-fg, 233 23% 75%));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.progress-wrap {
|
|
212
|
+
margin-top: 0.75rem;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.progress-bar {
|
|
216
|
+
height: 0.375rem;
|
|
217
|
+
width: 100%;
|
|
218
|
+
overflow: hidden;
|
|
219
|
+
background-color: hsl(var(--tn-bg-visual, 233 23% 20%));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.progress-fill {
|
|
223
|
+
height: 100%;
|
|
224
|
+
transition: width 0.3s ease;
|
|
225
|
+
background-color: hsl(var(--tn-yellow, 40 70% 64%));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.progress-text {
|
|
229
|
+
margin-top: 0.375rem;
|
|
230
|
+
font-size: 0.75rem;
|
|
231
|
+
font-family: monospace;
|
|
232
|
+
color: hsl(var(--tn-fg-dark, 233 23% 60%));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.hint {
|
|
236
|
+
margin-top: 0.5rem;
|
|
237
|
+
font-size: 0.75rem;
|
|
238
|
+
color: hsl(var(--tn-fg-dark, 233 23% 60%));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.polling-indicator {
|
|
242
|
+
display: flex;
|
|
243
|
+
align-items: center;
|
|
244
|
+
gap: 0.5rem;
|
|
245
|
+
margin-top: 0.75rem;
|
|
246
|
+
font-size: 0.75rem;
|
|
247
|
+
color: hsl(var(--tn-fg-dark, 233 23% 60%));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.polling-dot {
|
|
251
|
+
width: 0.375rem;
|
|
252
|
+
height: 0.375rem;
|
|
253
|
+
background-color: hsl(var(--tn-cyan, 192 78% 73%));
|
|
254
|
+
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.slab-actions {
|
|
258
|
+
border-top: 1px solid hsl(var(--tn-fg-gutter, 233 23% 25%) / 0.3);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.btn-flush {
|
|
262
|
+
width: 100%;
|
|
263
|
+
padding: 0.625rem 1rem;
|
|
264
|
+
background: none;
|
|
265
|
+
border: none;
|
|
266
|
+
cursor: pointer;
|
|
267
|
+
font-size: 0.75rem;
|
|
268
|
+
font-weight: 500;
|
|
269
|
+
text-transform: uppercase;
|
|
270
|
+
letter-spacing: 0.05em;
|
|
271
|
+
color: hsl(var(--tn-blue, 217 89% 71%));
|
|
272
|
+
transition: background-color 0.15s;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.btn-flush:hover {
|
|
276
|
+
background-color: hsl(var(--tn-bg-visual, 233 23% 20%) / 0.5);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.icon {
|
|
280
|
+
width: 1.25rem;
|
|
281
|
+
height: 1.25rem;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.icon-online {
|
|
285
|
+
color: hsl(var(--tn-green, 115 54% 57%));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.icon-offline {
|
|
289
|
+
color: hsl(var(--tn-red, 355 68% 65%));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.icon-warning {
|
|
293
|
+
color: hsl(var(--tn-yellow, 40 70% 64%));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.animate-spin {
|
|
297
|
+
animation: spin 1s linear infinite;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@keyframes spin {
|
|
301
|
+
to {
|
|
302
|
+
transform: rotate(360deg);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
@keyframes pulse {
|
|
307
|
+
0%,
|
|
308
|
+
100% {
|
|
309
|
+
opacity: 1;
|
|
310
|
+
}
|
|
311
|
+
50% {
|
|
312
|
+
opacity: 0.5;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
`,
|
|
316
|
+
];
|
|
317
|
+
tslib_es6.__decorate([
|
|
318
|
+
decorators_js.property({ type: String })
|
|
319
|
+
], exports.FwStreamStateOverlay.prototype, "status", void 0);
|
|
320
|
+
tslib_es6.__decorate([
|
|
321
|
+
decorators_js.property({ type: String })
|
|
322
|
+
], exports.FwStreamStateOverlay.prototype, "message", void 0);
|
|
323
|
+
tslib_es6.__decorate([
|
|
324
|
+
decorators_js.property({ type: Number })
|
|
325
|
+
], exports.FwStreamStateOverlay.prototype, "percentage", void 0);
|
|
326
|
+
tslib_es6.__decorate([
|
|
327
|
+
decorators_js.property({ type: Boolean })
|
|
328
|
+
], exports.FwStreamStateOverlay.prototype, "visible", void 0);
|
|
329
|
+
tslib_es6.__decorate([
|
|
330
|
+
decorators_js.property({ type: Boolean, attribute: "retry-enabled" })
|
|
331
|
+
], exports.FwStreamStateOverlay.prototype, "retryEnabled", void 0);
|
|
332
|
+
tslib_es6.__decorate([
|
|
333
|
+
decorators_js.property({ attribute: false })
|
|
334
|
+
], exports.FwStreamStateOverlay.prototype, "onRetry", void 0);
|
|
335
|
+
exports.FwStreamStateOverlay = tslib_es6.__decorate([
|
|
336
|
+
decorators_js.customElement("fw-stream-state-overlay")
|
|
337
|
+
], exports.FwStreamStateOverlay);
|
|
338
|
+
//# sourceMappingURL=fw-stream-state-overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fw-stream-state-overlay.js","sources":["../../../../src/components/fw-stream-state-overlay.ts"],"sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport type { StreamStatus } from \"@livepeer-frameworks/player-core\";\nimport { sharedStyles } from \"../styles/shared-styles.js\";\n\n@customElement(\"fw-stream-state-overlay\")\nexport class FwStreamStateOverlay extends LitElement {\n @property({ type: String }) status: StreamStatus = \"OFFLINE\";\n @property({ type: String }) message = \"\";\n @property({ type: Number }) percentage?: number;\n @property({ type: Boolean }) visible = true;\n @property({ type: Boolean, attribute: \"retry-enabled\" }) retryEnabled = false;\n @property({ attribute: false }) onRetry?: () => void;\n\n static styles = [\n sharedStyles,\n css`\n :host {\n display: contents;\n }\n\n .overlay-backdrop {\n position: absolute;\n inset: 0;\n z-index: 20;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: hsl(var(--tn-bg-dark, 235 21% 11%) / 0.8);\n backdrop-filter: blur(4px);\n }\n\n .slab {\n width: 280px;\n max-width: 90%;\n background-color: hsl(var(--tn-bg, 233 23% 17%) / 0.95);\n border: 1px solid hsl(var(--tn-fg-gutter, 233 23% 25%) / 0.3);\n }\n\n .slab-header {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.75rem 1rem;\n border-bottom: 1px solid hsl(var(--tn-fg-gutter, 233 23% 25%) / 0.3);\n font-size: 0.75rem;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: hsl(var(--tn-fg-dark, 233 23% 60%));\n }\n\n .slab-body {\n padding: 1rem;\n }\n\n .slab-message {\n font-size: 0.875rem;\n color: hsl(var(--tn-fg, 233 23% 75%));\n }\n\n .progress-wrap {\n margin-top: 0.75rem;\n }\n\n .progress-bar {\n height: 0.375rem;\n width: 100%;\n overflow: hidden;\n background-color: hsl(var(--tn-bg-visual, 233 23% 20%));\n }\n\n .progress-fill {\n height: 100%;\n transition: width 0.3s ease;\n background-color: hsl(var(--tn-yellow, 40 70% 64%));\n }\n\n .progress-text {\n margin-top: 0.375rem;\n font-size: 0.75rem;\n font-family: monospace;\n color: hsl(var(--tn-fg-dark, 233 23% 60%));\n }\n\n .hint {\n margin-top: 0.5rem;\n font-size: 0.75rem;\n color: hsl(var(--tn-fg-dark, 233 23% 60%));\n }\n\n .polling-indicator {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n margin-top: 0.75rem;\n font-size: 0.75rem;\n color: hsl(var(--tn-fg-dark, 233 23% 60%));\n }\n\n .polling-dot {\n width: 0.375rem;\n height: 0.375rem;\n background-color: hsl(var(--tn-cyan, 192 78% 73%));\n animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n }\n\n .slab-actions {\n border-top: 1px solid hsl(var(--tn-fg-gutter, 233 23% 25%) / 0.3);\n }\n\n .btn-flush {\n width: 100%;\n padding: 0.625rem 1rem;\n background: none;\n border: none;\n cursor: pointer;\n font-size: 0.75rem;\n font-weight: 500;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: hsl(var(--tn-blue, 217 89% 71%));\n transition: background-color 0.15s;\n }\n\n .btn-flush:hover {\n background-color: hsl(var(--tn-bg-visual, 233 23% 20%) / 0.5);\n }\n\n .icon {\n width: 1.25rem;\n height: 1.25rem;\n }\n\n .icon-online {\n color: hsl(var(--tn-green, 115 54% 57%));\n }\n\n .icon-offline {\n color: hsl(var(--tn-red, 355 68% 65%));\n }\n\n .icon-warning {\n color: hsl(var(--tn-yellow, 40 70% 64%));\n }\n\n .animate-spin {\n animation: spin 1s linear infinite;\n }\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n @keyframes pulse {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.5;\n }\n }\n `,\n ];\n\n private _getStatusLabel(status: StreamStatus): string {\n switch (status) {\n case \"ONLINE\":\n return \"ONLINE\";\n case \"OFFLINE\":\n return \"OFFLINE\";\n case \"INITIALIZING\":\n return \"INITIALIZING\";\n case \"BOOTING\":\n return \"STARTING\";\n case \"WAITING_FOR_DATA\":\n return \"WAITING\";\n case \"SHUTTING_DOWN\":\n return \"ENDING\";\n case \"ERROR\":\n return \"ERROR\";\n case \"INVALID\":\n return \"INVALID\";\n default:\n return \"STATUS\";\n }\n }\n\n private _renderStatusIcon(status: StreamStatus) {\n if (status === \"OFFLINE\") {\n return html`<svg\n class=\"icon icon-offline\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n d=\"M18.364 5.636a9 9 0 010 12.728m0 0l-2.829-2.829m2.829 2.829L21 21M15.536 8.464a5 5 0 010 7.072m0 0l-2.829-2.829m-4.243 2.829a4.978 4.978 0 01-1.414-2.83m-1.414 5.658a9 9 0 01-2.167-9.238m7.824 2.167a1 1 0 111.414 1.414m-1.414-1.414L3 3m8.293 8.293l1.414 1.414\"\n ></path>\n </svg>`;\n }\n\n if (status === \"INITIALIZING\" || status === \"BOOTING\" || status === \"WAITING_FOR_DATA\") {\n return html`<svg class=\"icon icon-warning animate-spin\" fill=\"none\" viewBox=\"0 0 24 24\">\n <circle\n class=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n stroke-width=\"4\"\n ></circle>\n <path\n class=\"opacity-75\"\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n ></path>\n </svg>`;\n }\n\n if (status === \"SHUTTING_DOWN\") {\n return html`<svg\n class=\"icon icon-warning\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n d=\"M13 10V3L4 14h7v7l9-11h-7z\"\n ></path>\n </svg>`;\n }\n\n return html`<svg\n class=\"icon icon-offline\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n ></path>\n </svg>`;\n }\n\n private _handleRetry = () => {\n if (this.onRetry) {\n this.onRetry();\n return;\n }\n this.dispatchEvent(new CustomEvent(\"fw-retry\", { bubbles: true, composed: true }));\n };\n\n protected render() {\n if (!this.visible || this.status === \"ONLINE\") {\n return nothing;\n }\n\n const showRetry =\n (this.status === \"ERROR\" || this.status === \"INVALID\" || this.status === \"OFFLINE\") &&\n (this.retryEnabled || typeof this.onRetry === \"function\");\n const showProgress = this.status === \"INITIALIZING\" && this.percentage !== undefined;\n const progressWidth = `${Math.min(100, Math.max(0, this.percentage ?? 0))}%`;\n\n return html`\n <div class=\"overlay-backdrop\" role=\"status\" aria-live=\"polite\">\n <div class=\"slab\">\n <div class=\"slab-header\">\n ${this._renderStatusIcon(this.status)}\n <span>${this._getStatusLabel(this.status)}</span>\n </div>\n <div class=\"slab-body\">\n <p class=\"slab-message\">${this.message}</p>\n ${showProgress\n ? html`\n <div class=\"progress-wrap\">\n <div class=\"progress-bar\">\n <div class=\"progress-fill\" style=\"width:${progressWidth};\"></div>\n </div>\n <p class=\"progress-text\">${Math.round(this.percentage ?? 0)}%</p>\n </div>\n `\n : nothing}\n ${this.status === \"OFFLINE\"\n ? html`<p class=\"hint\">The stream will start when the broadcaster goes live</p>`\n : nothing}\n ${this.status === \"BOOTING\" || this.status === \"WAITING_FOR_DATA\"\n ? html`<p class=\"hint\">Please wait while the stream prepares...</p>`\n : nothing}\n ${!showRetry\n ? html`<div class=\"polling-indicator\">\n <span class=\"polling-dot\"></span>\n <span>Checking stream status...</span>\n </div>`\n : nothing}\n </div>\n ${showRetry\n ? html`<div class=\"slab-actions\">\n <button\n type=\"button\"\n class=\"btn-flush\"\n @click=${this._handleRetry}\n aria-label=\"Retry connection\"\n >\n Retry Connection\n </button>\n </div>`\n : nothing}\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"fw-stream-state-overlay\": FwStreamStateOverlay;\n }\n}\n"],"names":["FwStreamStateOverlay","LitElement","html","nothing","sharedStyles","css","__decorate","property","customElement"],"mappings":";;;;;;;AAMaA,4BAAoB,GAA1B,MAAM,oBAAqB,SAAQC,cAAU,CAAA;AAA7C,IAAA,WAAA,GAAA;;QACuB,IAAA,CAAA,MAAM,GAAiB,SAAS;QAChC,IAAA,CAAA,OAAO,GAAG,EAAE;QAEX,IAAA,CAAA,OAAO,GAAG,IAAI;QACc,IAAA,CAAA,YAAY,GAAG,KAAK;QAsPrE,IAAA,CAAA,YAAY,GAAG,MAAK;AAC1B,YAAA,IAAI,IAAI,CAAC,OAAO,EAAE;gBAChB,IAAI,CAAC,OAAO,EAAE;gBACd;YACF;AACA,YAAA,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACpF,QAAA,CAAC;IA6DH;AA5JU,IAAA,eAAe,CAAC,MAAoB,EAAA;QAC1C,QAAQ,MAAM;AACZ,YAAA,KAAK,QAAQ;AACX,gBAAA,OAAO,QAAQ;AACjB,YAAA,KAAK,SAAS;AACZ,gBAAA,OAAO,SAAS;AAClB,YAAA,KAAK,cAAc;AACjB,gBAAA,OAAO,cAAc;AACvB,YAAA,KAAK,SAAS;AACZ,gBAAA,OAAO,UAAU;AACnB,YAAA,KAAK,kBAAkB;AACrB,gBAAA,OAAO,SAAS;AAClB,YAAA,KAAK,eAAe;AA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A;AAA3B,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AAAe,CAAA,EAAAP,4BAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AACbM,oBAAA,CAAA;AAA3B,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AAAsB,CAAA,EAAAP,4BAAA,CAAA,SAAA,EAAA,YAAA,EAAA,MAAA,CAAA;AACnBM,oBAAA,CAAA;AAA5B,IAAAC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;AAAiB,CAAA,EAAAP,4BAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AACaM,oBAAA,CAAA;IAAxDC,sBAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE;AAAuB,CAAA,EAAAP,4BAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAC9CM,oBAAA,CAAA;AAA/B,IAAAC,sBAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AAAuB,CAAA,EAAAP,4BAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAN1CA,4BAAoB,GAAAM,oBAAA,CAAA;IADhCE,2BAAa,CAAC,yBAAyB;AAC3B,CAAA,EAAAR,4BAAoB,CA8ThC;;"}
|
|
@@ -3,57 +3,186 @@
|
|
|
3
3
|
var tslib_es6 = require('../node_modules/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.57.1_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
|
|
4
4
|
var lit = require('lit');
|
|
5
5
|
var decorators_js = require('lit/decorators.js');
|
|
6
|
+
var styleMap_js = require('lit/directives/style-map.js');
|
|
6
7
|
|
|
8
|
+
const DEFAULT_STYLE = {
|
|
9
|
+
fontSize: "1.5rem",
|
|
10
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
11
|
+
color: "white",
|
|
12
|
+
backgroundColor: "rgba(0, 0, 0, 0.75)",
|
|
13
|
+
textShadow: "2px 2px 4px rgba(0, 0, 0, 0.5)",
|
|
14
|
+
bottom: "5%",
|
|
15
|
+
maxWidth: "90%",
|
|
16
|
+
padding: "0.5em 1em",
|
|
17
|
+
borderRadius: "4px",
|
|
18
|
+
};
|
|
7
19
|
exports.FwSubtitleRenderer = class FwSubtitleRenderer extends lit.LitElement {
|
|
8
20
|
constructor() {
|
|
9
21
|
super(...arguments);
|
|
10
22
|
this.currentTime = 0;
|
|
11
|
-
this.enabled =
|
|
23
|
+
this.enabled = true;
|
|
12
24
|
this.cues = [];
|
|
25
|
+
this.className = "";
|
|
26
|
+
this._liveCues = [];
|
|
27
|
+
this._displayedText = "";
|
|
28
|
+
this._unsubscribe = null;
|
|
29
|
+
this._handleMetaEvent = (event) => {
|
|
30
|
+
if (event.type !== "subtitle") {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const cue = this._parseSubtitleCue(event.data);
|
|
34
|
+
if (!cue) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this._liveCues = (() => {
|
|
38
|
+
const existing = this._liveCues.find((value) => value.id === cue.id);
|
|
39
|
+
if (existing) {
|
|
40
|
+
return this._liveCues;
|
|
41
|
+
}
|
|
42
|
+
return [...this._liveCues, cue].slice(-50);
|
|
43
|
+
})();
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
disconnectedCallback() {
|
|
47
|
+
super.disconnectedCallback();
|
|
48
|
+
this._teardownSubscription();
|
|
49
|
+
}
|
|
50
|
+
updated(changed) {
|
|
51
|
+
if (changed.has("enabled") ||
|
|
52
|
+
changed.has("subscribeToMetaTrack") ||
|
|
53
|
+
changed.has("metaTrackId")) {
|
|
54
|
+
this._syncSubscription();
|
|
55
|
+
}
|
|
56
|
+
if (changed.has("currentTime") || changed.has("_liveCues")) {
|
|
57
|
+
this._pruneExpiredLiveCues();
|
|
58
|
+
}
|
|
59
|
+
if (changed.has("enabled") ||
|
|
60
|
+
changed.has("currentTime") ||
|
|
61
|
+
changed.has("cues") ||
|
|
62
|
+
changed.has("_liveCues")) {
|
|
63
|
+
this._syncDisplayedCue();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
_syncSubscription() {
|
|
67
|
+
this._teardownSubscription();
|
|
68
|
+
if (!this.enabled || !this.subscribeToMetaTrack || !this.metaTrackId) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this._unsubscribe = this.subscribeToMetaTrack(this.metaTrackId, this._handleMetaEvent);
|
|
72
|
+
}
|
|
73
|
+
_teardownSubscription() {
|
|
74
|
+
if (this._unsubscribe) {
|
|
75
|
+
this._unsubscribe();
|
|
76
|
+
this._unsubscribe = null;
|
|
77
|
+
}
|
|
13
78
|
}
|
|
14
|
-
|
|
15
|
-
if (
|
|
79
|
+
_parseSubtitleCue(data) {
|
|
80
|
+
if (typeof data !== "object" || data === null) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const obj = data;
|
|
84
|
+
const text = typeof obj.text === "string" ? obj.text : String(obj.text ?? "");
|
|
85
|
+
if (!text) {
|
|
16
86
|
return null;
|
|
17
|
-
const t = this.currentTime * 1000; // Convert to ms
|
|
18
|
-
for (const cue of this.cues) {
|
|
19
|
-
if (t >= cue.startTime && t <= cue.endTime)
|
|
20
|
-
return cue.text;
|
|
21
87
|
}
|
|
22
|
-
|
|
88
|
+
const rawStart = "startTime" in obj ? Number(obj.startTime) : "start" in obj ? Number(obj.start) : 0;
|
|
89
|
+
const rawEnd = "endTime" in obj ? Number(obj.endTime) : "end" in obj ? Number(obj.end) : Infinity;
|
|
90
|
+
const startTime = Number.isFinite(rawStart) ? rawStart : 0;
|
|
91
|
+
const endTime = Number.isFinite(rawEnd) ? rawEnd : Infinity;
|
|
92
|
+
const id = typeof obj.id === "string" ? obj.id : String(Date.now() + Math.random());
|
|
93
|
+
return {
|
|
94
|
+
id,
|
|
95
|
+
text,
|
|
96
|
+
startTime,
|
|
97
|
+
endTime,
|
|
98
|
+
lang: typeof obj.lang === "string" ? obj.lang : undefined,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
_getAllCues() {
|
|
102
|
+
return [...(this.cues ?? []), ...this._liveCues];
|
|
103
|
+
}
|
|
104
|
+
_syncDisplayedCue() {
|
|
105
|
+
if (!this.enabled) {
|
|
106
|
+
if (this._displayedText) {
|
|
107
|
+
this._displayedText = "";
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const currentTimeMs = this.currentTime * 1000;
|
|
112
|
+
const activeCue = this._getAllCues().find((cue) => currentTimeMs >= cue.startTime && currentTimeMs < cue.endTime);
|
|
113
|
+
const nextText = activeCue?.text ?? "";
|
|
114
|
+
if (nextText !== this._displayedText) {
|
|
115
|
+
this._displayedText = nextText;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
_pruneExpiredLiveCues() {
|
|
119
|
+
if (this._liveCues.length === 0) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const currentTimeMs = this.currentTime * 1000;
|
|
123
|
+
const filtered = this._liveCues.filter((cue) => {
|
|
124
|
+
const endTime = cue.endTime === Infinity ? cue.startTime + 10000 : cue.endTime;
|
|
125
|
+
return endTime >= currentTimeMs - 30000;
|
|
126
|
+
});
|
|
127
|
+
if (filtered.length !== this._liveCues.length) {
|
|
128
|
+
this._liveCues = filtered;
|
|
129
|
+
}
|
|
23
130
|
}
|
|
24
131
|
render() {
|
|
25
|
-
|
|
26
|
-
if (!text)
|
|
132
|
+
if (!this.enabled || !this._displayedText) {
|
|
27
133
|
return lit.nothing;
|
|
28
|
-
|
|
134
|
+
}
|
|
135
|
+
const mergedStyle = {
|
|
136
|
+
...DEFAULT_STYLE,
|
|
137
|
+
...(this.subtitleStyle ?? {}),
|
|
138
|
+
};
|
|
139
|
+
return lit.html `
|
|
140
|
+
<div
|
|
141
|
+
class="subtitle-container ${this.className}"
|
|
142
|
+
style=${styleMap_js.styleMap({
|
|
143
|
+
bottom: mergedStyle.bottom,
|
|
144
|
+
maxWidth: mergedStyle.maxWidth,
|
|
145
|
+
})}
|
|
146
|
+
role="region"
|
|
147
|
+
aria-live="polite"
|
|
148
|
+
aria-label="Subtitles"
|
|
149
|
+
>
|
|
150
|
+
<span
|
|
151
|
+
class="subtitle-text"
|
|
152
|
+
style=${styleMap_js.styleMap({
|
|
153
|
+
fontSize: mergedStyle.fontSize,
|
|
154
|
+
fontFamily: mergedStyle.fontFamily,
|
|
155
|
+
color: mergedStyle.color,
|
|
156
|
+
backgroundColor: mergedStyle.backgroundColor,
|
|
157
|
+
textShadow: mergedStyle.textShadow,
|
|
158
|
+
padding: mergedStyle.padding,
|
|
159
|
+
borderRadius: mergedStyle.borderRadius,
|
|
160
|
+
})}
|
|
161
|
+
>
|
|
162
|
+
${this._displayedText}
|
|
163
|
+
</span>
|
|
164
|
+
</div>
|
|
165
|
+
`;
|
|
29
166
|
}
|
|
30
167
|
};
|
|
31
168
|
exports.FwSubtitleRenderer.styles = lit.css `
|
|
32
169
|
:host {
|
|
33
170
|
display: contents;
|
|
34
171
|
}
|
|
35
|
-
|
|
172
|
+
|
|
173
|
+
.subtitle-container {
|
|
36
174
|
position: absolute;
|
|
37
|
-
bottom: 5%;
|
|
38
175
|
left: 50%;
|
|
39
176
|
transform: translateX(-50%);
|
|
40
|
-
|
|
41
|
-
max-width: 90%;
|
|
42
|
-
padding: 0.5em 1em;
|
|
43
|
-
border-radius: 4px;
|
|
44
|
-
background: rgb(0 0 0 / 0.75);
|
|
45
|
-
color: white;
|
|
46
|
-
font-size: 1.5rem;
|
|
47
|
-
font-family:
|
|
48
|
-
system-ui,
|
|
49
|
-
-apple-system,
|
|
50
|
-
sans-serif;
|
|
51
|
-
text-shadow: 2px 2px 4px rgb(0 0 0 / 0.5);
|
|
52
|
-
white-space: pre-wrap;
|
|
177
|
+
z-index: 30;
|
|
53
178
|
text-align: center;
|
|
54
|
-
z-index: 15;
|
|
55
179
|
pointer-events: none;
|
|
56
180
|
}
|
|
181
|
+
|
|
182
|
+
.subtitle-text {
|
|
183
|
+
display: inline-block;
|
|
184
|
+
white-space: pre-wrap;
|
|
185
|
+
}
|
|
57
186
|
`;
|
|
58
187
|
tslib_es6.__decorate([
|
|
59
188
|
decorators_js.property({ type: Number })
|
|
@@ -64,6 +193,24 @@ tslib_es6.__decorate([
|
|
|
64
193
|
tslib_es6.__decorate([
|
|
65
194
|
decorators_js.property({ attribute: false })
|
|
66
195
|
], exports.FwSubtitleRenderer.prototype, "cues", void 0);
|
|
196
|
+
tslib_es6.__decorate([
|
|
197
|
+
decorators_js.property({ attribute: false })
|
|
198
|
+
], exports.FwSubtitleRenderer.prototype, "subscribeToMetaTrack", void 0);
|
|
199
|
+
tslib_es6.__decorate([
|
|
200
|
+
decorators_js.property({ type: String, attribute: "meta-track-id" })
|
|
201
|
+
], exports.FwSubtitleRenderer.prototype, "metaTrackId", void 0);
|
|
202
|
+
tslib_es6.__decorate([
|
|
203
|
+
decorators_js.property({ attribute: false })
|
|
204
|
+
], exports.FwSubtitleRenderer.prototype, "subtitleStyle", void 0);
|
|
205
|
+
tslib_es6.__decorate([
|
|
206
|
+
decorators_js.property({ type: String, attribute: "class-name" })
|
|
207
|
+
], exports.FwSubtitleRenderer.prototype, "className", void 0);
|
|
208
|
+
tslib_es6.__decorate([
|
|
209
|
+
decorators_js.state()
|
|
210
|
+
], exports.FwSubtitleRenderer.prototype, "_liveCues", void 0);
|
|
211
|
+
tslib_es6.__decorate([
|
|
212
|
+
decorators_js.state()
|
|
213
|
+
], exports.FwSubtitleRenderer.prototype, "_displayedText", void 0);
|
|
67
214
|
exports.FwSubtitleRenderer = tslib_es6.__decorate([
|
|
68
215
|
decorators_js.customElement("fw-subtitle-renderer")
|
|
69
216
|
], exports.FwSubtitleRenderer);
|