@locpd/vidstack 1.12.14
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/LICENSE +21 -0
- package/README.md +22 -0
- package/analyze.json.d.ts +8 -0
- package/bundle.d.ts +1 -0
- package/cdn/chunks/vidstack-2f5gzOW6.js +1 -0
- package/cdn/chunks/vidstack-BYgY9wmd.js +1 -0
- package/cdn/chunks/vidstack-BfBBPhXV.js +1 -0
- package/cdn/chunks/vidstack-Bjo5esRp.js +1 -0
- package/cdn/chunks/vidstack-BuL67v3q.js +1 -0
- package/cdn/chunks/vidstack-C0msPRTd.js +3 -0
- package/cdn/chunks/vidstack-CJNLoJPa.js +1 -0
- package/cdn/chunks/vidstack-CQSpZ7X8.js +16 -0
- package/cdn/chunks/vidstack-C_AxqLKV.js +1 -0
- package/cdn/chunks/vidstack-CioT3Yw2.js +1 -0
- package/cdn/chunks/vidstack-CrqkytHl.js +1 -0
- package/cdn/chunks/vidstack-D0M8R0ZU.js +1 -0
- package/cdn/chunks/vidstack-D40FSa5B.js +3 -0
- package/cdn/chunks/vidstack-DD2JwFVU.js +1 -0
- package/cdn/chunks/vidstack-DRH_1tFW.js +1 -0
- package/cdn/chunks/vidstack-DfDZuHNP.js +1 -0
- package/cdn/chunks/vidstack-DiNS2Vx5.js +1 -0
- package/cdn/chunks/vidstack-xjJ-ui_l.js +1 -0
- package/cdn/providers/vidstack-audio-2Dt_Ivbp.js +1 -0
- package/cdn/providers/vidstack-dash-CUtD4e6q.js +1 -0
- package/cdn/providers/vidstack-google-cast-BdORATUX.js +1 -0
- package/cdn/providers/vidstack-hls-R25Kb6DP.js +1 -0
- package/cdn/providers/vidstack-html-DaAUJYsD.js +1 -0
- package/cdn/providers/vidstack-video-Csvox7SO.js +1 -0
- package/cdn/providers/vidstack-vimeo-D4Z96kg2.js +1 -0
- package/cdn/providers/vidstack-youtube-DiND6h3s.js +1 -0
- package/cdn/vidstack.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-2f5gzOW6.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-45yH5los.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BBVMdOnf.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BB_ulI_T.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BcAewM33.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BfBBPhXV.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-Bxv1Qnxe.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-C2ZbG62f.js +3 -0
- package/cdn/with-layouts/chunks/vidstack-CCYIOKgL.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CL6PeIO1.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-C_AxqLKV.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CifDkwDH.js +795 -0
- package/cdn/with-layouts/chunks/vidstack-Cry7aD59.js +3 -0
- package/cdn/with-layouts/chunks/vidstack-D065okCn.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DGuMoXmI.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DRH_1tFW.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DVBs1XoQ.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-Dge3KT8k.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DiNS2Vx5.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-HvYfJoen.js +1 -0
- package/cdn/with-layouts/providers/vidstack-audio-DE5vKIzW.js +1 -0
- package/cdn/with-layouts/providers/vidstack-dash-CA2agUuZ.js +1 -0
- package/cdn/with-layouts/providers/vidstack-google-cast-CGs-t8HM.js +1 -0
- package/cdn/with-layouts/providers/vidstack-hls-BHMbMFFR.js +1 -0
- package/cdn/with-layouts/providers/vidstack-html-Dm9gmNk6.js +1 -0
- package/cdn/with-layouts/providers/vidstack-video-C5it_Lbl.js +1 -0
- package/cdn/with-layouts/providers/vidstack-vimeo-BabLn9sy.js +1 -0
- package/cdn/with-layouts/providers/vidstack-youtube-D8UlccUL.js +1 -0
- package/cdn/with-layouts/vidstack.js +1 -0
- package/dev/chunks/vidstack-B7Zi3v_O.js +104 -0
- package/dev/chunks/vidstack-BFg1ZqiG.js +91 -0
- package/dev/chunks/vidstack-BGB2pa9s.js +58 -0
- package/dev/chunks/vidstack-BaIbHZE3.js +1519 -0
- package/dev/chunks/vidstack-Bb2rASIc.js +5188 -0
- package/dev/chunks/vidstack-Bcmx8pmK.js +224 -0
- package/dev/chunks/vidstack-Bl4b0Nen.js +29 -0
- package/dev/chunks/vidstack-Bo5OTJ06.js +58 -0
- package/dev/chunks/vidstack-BoAGnlRt.js +58 -0
- package/dev/chunks/vidstack-Bpr4fI4n.js +7 -0
- package/dev/chunks/vidstack-Bt8MP2DK.js +204 -0
- package/dev/chunks/vidstack-Bu2kfzUd.js +1637 -0
- package/dev/chunks/vidstack-C-ffXlSV.js +2995 -0
- package/dev/chunks/vidstack-C-ztJq-f.js +109 -0
- package/dev/chunks/vidstack-CFNlaVTR.js +55 -0
- package/dev/chunks/vidstack-C_l97D5j.js +254 -0
- package/dev/chunks/vidstack-CjhKISI0.js +114 -0
- package/dev/chunks/vidstack-CofXIJAy.js +57 -0
- package/dev/chunks/vidstack-CwTj4H1w.js +18 -0
- package/dev/chunks/vidstack-DDwbYVHV.js +66 -0
- package/dev/chunks/vidstack-DFImIcIL.js +11 -0
- package/dev/chunks/vidstack-DGDvUbvO.js +33 -0
- package/dev/chunks/vidstack-DO0kqA99.js +107 -0
- package/dev/chunks/vidstack-DXxIKXmd.js +50 -0
- package/dev/chunks/vidstack-DajrMUR0.js +297 -0
- package/dev/chunks/vidstack-DbBJlz7I.js +10 -0
- package/dev/chunks/vidstack-Dihypf8P.js +11 -0
- package/dev/chunks/vidstack-DlAhl87f.js +1193 -0
- package/dev/chunks/vidstack-Dm1xEU9Q.js +34 -0
- package/dev/chunks/vidstack-Dv_LIPFu.js +14 -0
- package/dev/chunks/vidstack-igYn0Apa.js +254 -0
- package/dev/chunks/vidstack-krOAtKMi.js +32 -0
- package/dev/chunks/vidstack-qh1N5_f_.js +26 -0
- package/dev/chunks/vidstack-rB-wqXw1.js +107 -0
- package/dev/chunks/vidstack-zG6PIeGg.js +66 -0
- package/dev/define/plyr-layout.js +51 -0
- package/dev/define/templates/plyr-layout.js +571 -0
- package/dev/define/templates/vidstack-audio-layout.js +167 -0
- package/dev/define/templates/vidstack-video-layout.js +390 -0
- package/dev/define/vidstack-icons.js +1 -0
- package/dev/define/vidstack-player-default-layout.js +21 -0
- package/dev/define/vidstack-player-layouts.js +25 -0
- package/dev/define/vidstack-player-ui.js +70 -0
- package/dev/define/vidstack-player.js +19 -0
- package/dev/global/plyr.js +501 -0
- package/dev/global/vidstack-player.js +129 -0
- package/dev/providers/vidstack-audio.js +35 -0
- package/dev/providers/vidstack-dash.js +516 -0
- package/dev/providers/vidstack-google-cast.js +474 -0
- package/dev/providers/vidstack-hls.js +408 -0
- package/dev/providers/vidstack-html.js +567 -0
- package/dev/providers/vidstack-video.js +207 -0
- package/dev/providers/vidstack-vimeo.js +554 -0
- package/dev/providers/vidstack-youtube.js +286 -0
- package/dev/vidstack-elements.js +36 -0
- package/dev/vidstack.js +91 -0
- package/dom.d.ts +91 -0
- package/elements.d.ts +1433 -0
- package/empty.vtt +1 -0
- package/global/player.d.ts +52 -0
- package/global/plyr.d.ts +343 -0
- package/google-cast.d.ts +1422 -0
- package/icons.d.ts +1 -0
- package/index.d.ts +402 -0
- package/package.json +199 -0
- package/player/index.d.ts +3 -0
- package/player/layouts/default.d.ts +3 -0
- package/player/layouts/index.d.ts +3 -0
- package/player/layouts/plyr.d.ts +3 -0
- package/player/styles/base.css +153 -0
- package/player/styles/default/buffering.css +55 -0
- package/player/styles/default/buttons.css +175 -0
- package/player/styles/default/captions.css +181 -0
- package/player/styles/default/chapter-title.css +26 -0
- package/player/styles/default/controls.css +56 -0
- package/player/styles/default/gestures.css +19 -0
- package/player/styles/default/icons.css +6 -0
- package/player/styles/default/keyboard.css +148 -0
- package/player/styles/default/layouts/audio.css +417 -0
- package/player/styles/default/layouts/video.css +590 -0
- package/player/styles/default/menus.css +959 -0
- package/player/styles/default/poster.css +52 -0
- package/player/styles/default/sliders.css +391 -0
- package/player/styles/default/theme.css +2461 -0
- package/player/styles/default/thumbnail.css +40 -0
- package/player/styles/default/time.css +45 -0
- package/player/styles/default/tooltips.css +141 -0
- package/player/styles/plyr/theme.css +1237 -0
- package/player/ui.d.ts +3 -0
- package/plugins.d.ts +19 -0
- package/plugins.js +13 -0
- package/prod/chunks/vidstack-B01xzxC4.js +7 -0
- package/prod/chunks/vidstack-BCeb7ryV.js +201 -0
- package/prod/chunks/vidstack-BGSTndAW.js +1590 -0
- package/prod/chunks/vidstack-BPitBBjh.js +1519 -0
- package/prod/chunks/vidstack-BQlOPwOu.js +45 -0
- package/prod/chunks/vidstack-BSDzlwxO.js +4778 -0
- package/prod/chunks/vidstack-BT0m6zEi.js +109 -0
- package/prod/chunks/vidstack-BTigPj2h.js +55 -0
- package/prod/chunks/vidstack-BiyXcJ_M.js +107 -0
- package/prod/chunks/vidstack-BoVf5n1M.js +2985 -0
- package/prod/chunks/vidstack-Bq6c3Bam.js +58 -0
- package/prod/chunks/vidstack-ByLCIBtB.js +297 -0
- package/prod/chunks/vidstack-C2US-gSO.js +248 -0
- package/prod/chunks/vidstack-C9vIqaYT.js +10 -0
- package/prod/chunks/vidstack-CF6fixCQ.js +1193 -0
- package/prod/chunks/vidstack-CTojmhKq.js +66 -0
- package/prod/chunks/vidstack-ChQTHmIQ.js +77 -0
- package/prod/chunks/vidstack-Cm6_unwd.js +246 -0
- package/prod/chunks/vidstack-CwTj4H1w.js +18 -0
- package/prod/chunks/vidstack-D3ltXc3a.js +33 -0
- package/prod/chunks/vidstack-D5EzK014.js +14 -0
- package/prod/chunks/vidstack-DDXt6fpN.js +58 -0
- package/prod/chunks/vidstack-DJDnh4xT.js +11 -0
- package/prod/chunks/vidstack-DXxIKXmd.js +50 -0
- package/prod/chunks/vidstack-D_-9AA6_.js +29 -0
- package/prod/chunks/vidstack-DbkZGjSn.js +107 -0
- package/prod/chunks/vidstack-Dihypf8P.js +11 -0
- package/prod/chunks/vidstack-Dm1xEU9Q.js +34 -0
- package/prod/chunks/vidstack-Dq5Yu0Vr.js +205 -0
- package/prod/chunks/vidstack-DqAw8m9J.js +26 -0
- package/prod/chunks/vidstack-DsPOyKtl.js +57 -0
- package/prod/chunks/vidstack-krOAtKMi.js +32 -0
- package/prod/chunks/vidstack-nLyr4NEP.js +58 -0
- package/prod/chunks/vidstack-xMS8dnYq.js +114 -0
- package/prod/chunks/vidstack-yEGTpgeA.js +104 -0
- package/prod/define/plyr-layout.js +51 -0
- package/prod/define/templates/plyr-layout.js +571 -0
- package/prod/define/templates/vidstack-audio-layout.js +167 -0
- package/prod/define/templates/vidstack-video-layout.js +390 -0
- package/prod/define/vidstack-icons.js +1 -0
- package/prod/define/vidstack-player-default-layout.js +21 -0
- package/prod/define/vidstack-player-layouts.js +25 -0
- package/prod/define/vidstack-player-ui.js +70 -0
- package/prod/define/vidstack-player.js +19 -0
- package/prod/global/plyr.js +493 -0
- package/prod/global/vidstack-player.js +129 -0
- package/prod/providers/vidstack-audio.js +35 -0
- package/prod/providers/vidstack-dash.js +501 -0
- package/prod/providers/vidstack-google-cast.js +468 -0
- package/prod/providers/vidstack-hls.js +393 -0
- package/prod/providers/vidstack-html.js +555 -0
- package/prod/providers/vidstack-video.js +204 -0
- package/prod/providers/vidstack-vimeo.js +548 -0
- package/prod/providers/vidstack-youtube.js +286 -0
- package/prod/vidstack-elements.js +36 -0
- package/prod/vidstack.js +158 -0
- package/server/chunks/vidstack-6juFdkKy.js +29 -0
- package/server/chunks/vidstack-B7iHmv7_.js +307 -0
- package/server/chunks/vidstack-BmxyML9v.js +1619 -0
- package/server/chunks/vidstack-BskfxwD3.js +566 -0
- package/server/chunks/vidstack-BvLV0SMz.js +4642 -0
- package/server/chunks/vidstack-BvWwluXZ.js +205 -0
- package/server/chunks/vidstack-C-413dj2.js +8 -0
- package/server/chunks/vidstack-C26K8z_-.js +55 -0
- package/server/chunks/vidstack-CJJiksDz.js +107 -0
- package/server/chunks/vidstack-CUNv52x1.js +141 -0
- package/server/chunks/vidstack-CqyBCODe.js +295 -0
- package/server/chunks/vidstack-CwTj4H1w.js +18 -0
- package/server/chunks/vidstack-DHAyGSOl.js +1502 -0
- package/server/chunks/vidstack-DLU3cjcp.js +381 -0
- package/server/chunks/vidstack-DXxIKXmd.js +50 -0
- package/server/chunks/vidstack-DbtDXDS2.js +104 -0
- package/server/chunks/vidstack-Dm1xEU9Q.js +34 -0
- package/server/chunks/vidstack-DzTHw_bw.js +207 -0
- package/server/chunks/vidstack-Wn3NH5Sg.js +1566 -0
- package/server/chunks/vidstack-krOAtKMi.js +32 -0
- package/server/chunks/vidstack-wNViAkr4.js +3045 -0
- package/server/define/plyr-layout.js +16 -0
- package/server/define/vidstack-icons.js +1 -0
- package/server/define/vidstack-player-default-layout.js +13 -0
- package/server/define/vidstack-player-layouts.js +16 -0
- package/server/define/vidstack-player-ui.js +11 -0
- package/server/define/vidstack-player.js +6 -0
- package/server/global/plyr.js +322 -0
- package/server/global/vidstack-player.js +58 -0
- package/server/vidstack-elements.js +46 -0
- package/server/vidstack.js +148 -0
- package/tailwind.cjs +101 -0
- package/tailwind.d.cts +15 -0
- package/types/vidstack-BOvzfZjK.d.ts +1269 -0
- package/types/vidstack-Cttpg6GU.d.ts +7474 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { computed, peek, effect, onDispose, isDOMNode, animationFrameThrottle, isString } from './vidstack-Bu2kfzUd.js';
|
|
2
|
+
import { nothing, render, html } from 'lit-html';
|
|
3
|
+
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
4
|
+
import { unsafeSVG } from 'lit-html/directives/unsafe-svg.js';
|
|
5
|
+
import { directive, AsyncDirective, PartType } from 'lit-html/async-directive.js';
|
|
6
|
+
import { useMediaContext } from './vidstack-DFImIcIL.js';
|
|
7
|
+
|
|
8
|
+
class SignalDirective extends AsyncDirective {
|
|
9
|
+
#signal = null;
|
|
10
|
+
#isAttr = false;
|
|
11
|
+
#stop = null;
|
|
12
|
+
constructor(part) {
|
|
13
|
+
super(part);
|
|
14
|
+
this.#isAttr = part.type === PartType.ATTRIBUTE || part.type === PartType.BOOLEAN_ATTRIBUTE;
|
|
15
|
+
}
|
|
16
|
+
render(signal) {
|
|
17
|
+
if (signal !== this.#signal) {
|
|
18
|
+
this.disconnected();
|
|
19
|
+
this.#signal = signal;
|
|
20
|
+
if (this.isConnected) this.#watch();
|
|
21
|
+
}
|
|
22
|
+
return this.#signal ? this.#resolveValue(peek(this.#signal)) : nothing;
|
|
23
|
+
}
|
|
24
|
+
reconnected() {
|
|
25
|
+
this.#watch();
|
|
26
|
+
}
|
|
27
|
+
disconnected() {
|
|
28
|
+
this.#stop?.();
|
|
29
|
+
this.#stop = null;
|
|
30
|
+
}
|
|
31
|
+
#watch() {
|
|
32
|
+
if (!this.#signal) return;
|
|
33
|
+
this.#stop = effect(this.#onValueChange.bind(this));
|
|
34
|
+
}
|
|
35
|
+
#resolveValue(value) {
|
|
36
|
+
return this.#isAttr ? ifDefined(value) : value;
|
|
37
|
+
}
|
|
38
|
+
#setValue(value) {
|
|
39
|
+
this.setValue(this.#resolveValue(value));
|
|
40
|
+
}
|
|
41
|
+
#onValueChange() {
|
|
42
|
+
{
|
|
43
|
+
try {
|
|
44
|
+
this.#setValue(this.#signal?.());
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error instanceof Error && error.message.includes("This `ChildPart` has no `parentNode`")) {
|
|
47
|
+
const svelteDynamicImportExample = [
|
|
48
|
+
"{#await import('./Player.svelte') then {default: Player}}",
|
|
49
|
+
" <svelte:component this={Player} />",
|
|
50
|
+
"{/await}"
|
|
51
|
+
].join("\n");
|
|
52
|
+
console.warn(
|
|
53
|
+
`[vidstack] Failed to render most likely due to a hydration issue with your framework. Dynamically importing the player should resolve the issue.
|
|
54
|
+
|
|
55
|
+
Svelte Example:
|
|
56
|
+
|
|
57
|
+
${svelteDynamicImportExample}`
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
console.error(error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function $signal(compute) {
|
|
67
|
+
return directive(SignalDirective)(computed(compute));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
class SlotObserver {
|
|
71
|
+
#roots;
|
|
72
|
+
#callback;
|
|
73
|
+
elements = /* @__PURE__ */ new Set();
|
|
74
|
+
constructor(roots, callback) {
|
|
75
|
+
this.#roots = roots;
|
|
76
|
+
this.#callback = callback;
|
|
77
|
+
}
|
|
78
|
+
connect() {
|
|
79
|
+
this.#update();
|
|
80
|
+
const observer = new MutationObserver(this.#onMutation);
|
|
81
|
+
for (const root of this.#roots) observer.observe(root, { childList: true, subtree: true });
|
|
82
|
+
onDispose(() => observer.disconnect());
|
|
83
|
+
onDispose(this.disconnect.bind(this));
|
|
84
|
+
}
|
|
85
|
+
disconnect() {
|
|
86
|
+
this.elements.clear();
|
|
87
|
+
}
|
|
88
|
+
assign(template, slot) {
|
|
89
|
+
if (isDOMNode(template)) {
|
|
90
|
+
slot.textContent = "";
|
|
91
|
+
slot.append(template);
|
|
92
|
+
} else {
|
|
93
|
+
render(null, slot);
|
|
94
|
+
render(template, slot);
|
|
95
|
+
}
|
|
96
|
+
if (!slot.style.display) {
|
|
97
|
+
slot.style.display = "contents";
|
|
98
|
+
}
|
|
99
|
+
const el = slot.firstElementChild;
|
|
100
|
+
if (!el) return;
|
|
101
|
+
const classList = slot.getAttribute("data-class");
|
|
102
|
+
if (classList) el.classList.add(...classList.split(" "));
|
|
103
|
+
}
|
|
104
|
+
#onMutation = animationFrameThrottle(this.#update.bind(this));
|
|
105
|
+
#update(entries) {
|
|
106
|
+
if (entries && !entries.some((e) => e.addedNodes.length)) return;
|
|
107
|
+
let changed = false, slots = this.#roots.flatMap((root) => [...root.querySelectorAll("slot")]);
|
|
108
|
+
for (const slot of slots) {
|
|
109
|
+
if (!slot.hasAttribute("name") || this.elements.has(slot)) continue;
|
|
110
|
+
this.elements.add(slot);
|
|
111
|
+
changed = true;
|
|
112
|
+
}
|
|
113
|
+
if (changed) this.#callback(this.elements);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let id = 0, slotIdAttr = "data-slot-id";
|
|
118
|
+
class SlotManager {
|
|
119
|
+
#roots;
|
|
120
|
+
slots;
|
|
121
|
+
constructor(roots) {
|
|
122
|
+
this.#roots = roots;
|
|
123
|
+
this.slots = new SlotObserver(roots, this.#update.bind(this));
|
|
124
|
+
}
|
|
125
|
+
connect() {
|
|
126
|
+
this.slots.connect();
|
|
127
|
+
this.#update();
|
|
128
|
+
const mutations = new MutationObserver(this.#onMutation);
|
|
129
|
+
for (const root of this.#roots) mutations.observe(root, { childList: true });
|
|
130
|
+
onDispose(() => mutations.disconnect());
|
|
131
|
+
}
|
|
132
|
+
#onMutation = animationFrameThrottle(this.#update.bind(this));
|
|
133
|
+
#update() {
|
|
134
|
+
for (const root of this.#roots) {
|
|
135
|
+
for (const node of root.children) {
|
|
136
|
+
if (node.nodeType !== 1) continue;
|
|
137
|
+
const name = node.getAttribute("slot");
|
|
138
|
+
if (!name) continue;
|
|
139
|
+
node.style.display = "none";
|
|
140
|
+
let slotId = node.getAttribute(slotIdAttr);
|
|
141
|
+
if (!slotId) {
|
|
142
|
+
node.setAttribute(slotIdAttr, slotId = ++id + "");
|
|
143
|
+
}
|
|
144
|
+
for (const slot of this.slots.elements) {
|
|
145
|
+
if (slot.getAttribute("name") !== name || slot.getAttribute(slotIdAttr) === slotId) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const clone = document.importNode(node, true);
|
|
149
|
+
if (name.includes("-icon")) clone.classList.add("vds-icon");
|
|
150
|
+
clone.style.display = "";
|
|
151
|
+
clone.removeAttribute("slot");
|
|
152
|
+
this.slots.assign(clone, slot);
|
|
153
|
+
slot.setAttribute(slotIdAttr, slotId);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function Icon({ name, class: _class, state, paths, viewBox = "0 0 32 32" }) {
|
|
161
|
+
return html`<svg
|
|
162
|
+
class="${"vds-icon" + (_class ? ` ${_class}` : "")}"
|
|
163
|
+
viewBox="${viewBox}"
|
|
164
|
+
fill="none"
|
|
165
|
+
aria-hidden="true"
|
|
166
|
+
focusable="false"
|
|
167
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
168
|
+
data-icon=${ifDefined(name ?? state)}
|
|
169
|
+
>
|
|
170
|
+
${!isString(paths) ? $signal(paths) : unsafeSVG(paths)}
|
|
171
|
+
</svg>`;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
class IconsLoader {
|
|
175
|
+
#icons = {};
|
|
176
|
+
#loaded = false;
|
|
177
|
+
slots;
|
|
178
|
+
constructor(roots) {
|
|
179
|
+
this.slots = new SlotObserver(roots, this.#insertIcons.bind(this));
|
|
180
|
+
}
|
|
181
|
+
connect() {
|
|
182
|
+
this.slots.connect();
|
|
183
|
+
}
|
|
184
|
+
load() {
|
|
185
|
+
this.loadIcons().then((icons) => {
|
|
186
|
+
this.#icons = icons;
|
|
187
|
+
this.#loaded = true;
|
|
188
|
+
this.#insertIcons();
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
*#iterate() {
|
|
192
|
+
for (const iconName of Object.keys(this.#icons)) {
|
|
193
|
+
const slotName = `${iconName}-icon`;
|
|
194
|
+
for (const slot of this.slots.elements) {
|
|
195
|
+
if (slot.name !== slotName) continue;
|
|
196
|
+
yield { icon: this.#icons[iconName], slot };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
#insertIcons() {
|
|
201
|
+
if (!this.#loaded) return;
|
|
202
|
+
for (const { icon, slot } of this.#iterate()) {
|
|
203
|
+
this.slots.assign(icon, slot);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
class LayoutIconsLoader extends IconsLoader {
|
|
209
|
+
connect() {
|
|
210
|
+
super.connect();
|
|
211
|
+
const { player } = useMediaContext();
|
|
212
|
+
if (!player.el) return;
|
|
213
|
+
let dispose, observer = new IntersectionObserver((entries) => {
|
|
214
|
+
if (!entries[0]?.isIntersecting) return;
|
|
215
|
+
dispose?.();
|
|
216
|
+
dispose = void 0;
|
|
217
|
+
this.load();
|
|
218
|
+
});
|
|
219
|
+
observer.observe(player.el);
|
|
220
|
+
dispose = onDispose(() => observer.disconnect());
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export { $signal, Icon, LayoutIconsLoader, SlotManager };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Icon$24, effect } from './vidstack-Bu2kfzUd.js';
|
|
2
|
+
import { cloneTemplateContent, createTemplate } from './vidstack-C_l97D5j.js';
|
|
3
|
+
import '@floating-ui/dom';
|
|
4
|
+
|
|
5
|
+
const svgTemplate = /* @__PURE__ */ createTemplate(
|
|
6
|
+
`<svg viewBox="0 0 32 32" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"></svg>`
|
|
7
|
+
);
|
|
8
|
+
function insertContent(container, $state) {
|
|
9
|
+
const icon = cloneTemplateContent(svgTemplate);
|
|
10
|
+
icon.innerHTML = Icon$24;
|
|
11
|
+
container.append(icon);
|
|
12
|
+
const text = document.createElement("span");
|
|
13
|
+
text.classList.add("vds-google-cast-info");
|
|
14
|
+
container.append(text);
|
|
15
|
+
const deviceName = document.createElement("span");
|
|
16
|
+
deviceName.classList.add("vds-google-cast-device-name");
|
|
17
|
+
effect(() => {
|
|
18
|
+
const { remotePlaybackInfo } = $state, info = remotePlaybackInfo();
|
|
19
|
+
if (info?.deviceName) {
|
|
20
|
+
deviceName.textContent = info.deviceName;
|
|
21
|
+
text.append("Google Cast on ", deviceName);
|
|
22
|
+
}
|
|
23
|
+
return () => {
|
|
24
|
+
text.textContent = "";
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { insertContent };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { signal, effect, listenEvent, EventsController } from './vidstack-Bu2kfzUd.js';
|
|
2
|
+
import './vidstack-CjhKISI0.js';
|
|
3
|
+
|
|
4
|
+
class HTMLRemotePlaybackAdapter {
|
|
5
|
+
#media;
|
|
6
|
+
#ctx;
|
|
7
|
+
#state;
|
|
8
|
+
#supported = signal(false);
|
|
9
|
+
get supported() {
|
|
10
|
+
return this.#supported();
|
|
11
|
+
}
|
|
12
|
+
constructor(media, ctx) {
|
|
13
|
+
this.#media = media;
|
|
14
|
+
this.#ctx = ctx;
|
|
15
|
+
this.#setup();
|
|
16
|
+
}
|
|
17
|
+
#setup() {
|
|
18
|
+
if (!this.#media?.remote || !this.canPrompt) return;
|
|
19
|
+
this.#media.remote.watchAvailability((available) => {
|
|
20
|
+
this.#supported.set(available);
|
|
21
|
+
}).catch(() => {
|
|
22
|
+
this.#supported.set(false);
|
|
23
|
+
});
|
|
24
|
+
effect(this.#watchSupported.bind(this));
|
|
25
|
+
}
|
|
26
|
+
#watchSupported() {
|
|
27
|
+
if (!this.#supported()) return;
|
|
28
|
+
const events = ["connecting", "connect", "disconnect"], onStateChange = this.#onStateChange.bind(this);
|
|
29
|
+
onStateChange();
|
|
30
|
+
listenEvent(this.#media, "playing", onStateChange);
|
|
31
|
+
const remoteEvents = new EventsController(this.#media.remote);
|
|
32
|
+
for (const type of events) {
|
|
33
|
+
remoteEvents.add(type, onStateChange);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async prompt() {
|
|
37
|
+
if (!this.supported) throw Error("Not supported on this platform.");
|
|
38
|
+
if (this.type === "airplay" && this.#media.webkitShowPlaybackTargetPicker) {
|
|
39
|
+
return this.#media.webkitShowPlaybackTargetPicker();
|
|
40
|
+
}
|
|
41
|
+
return this.#media.remote.prompt();
|
|
42
|
+
}
|
|
43
|
+
#onStateChange(event) {
|
|
44
|
+
const state = this.#media.remote.state;
|
|
45
|
+
if (state === this.#state) return;
|
|
46
|
+
const detail = { type: this.type, state };
|
|
47
|
+
this.#ctx.notify("remote-playback-change", detail, event);
|
|
48
|
+
this.#state = state;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
class HTMLAirPlayAdapter extends HTMLRemotePlaybackAdapter {
|
|
52
|
+
type = "airplay";
|
|
53
|
+
get canPrompt() {
|
|
54
|
+
return "WebKitPlaybackTargetAvailabilityEvent" in window;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { HTMLAirPlayAdapter };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { signal, listenEvent, effect, peek, isString } from './vidstack-Bu2kfzUd.js';
|
|
2
|
+
import { appendParamsToURL } from './vidstack-zG6PIeGg.js';
|
|
3
|
+
|
|
4
|
+
class EmbedProvider {
|
|
5
|
+
#iframe;
|
|
6
|
+
src = signal("");
|
|
7
|
+
/**
|
|
8
|
+
* Defines which referrer is sent when fetching the resource.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/referrerPolicy}
|
|
11
|
+
*/
|
|
12
|
+
referrerPolicy = null;
|
|
13
|
+
get iframe() {
|
|
14
|
+
return this.#iframe;
|
|
15
|
+
}
|
|
16
|
+
constructor(iframe) {
|
|
17
|
+
this.#iframe = iframe;
|
|
18
|
+
iframe.setAttribute("frameBorder", "0");
|
|
19
|
+
iframe.setAttribute("aria-hidden", "true");
|
|
20
|
+
iframe.setAttribute(
|
|
21
|
+
"allow",
|
|
22
|
+
"autoplay; fullscreen; encrypted-media; picture-in-picture; accelerometer; gyroscope"
|
|
23
|
+
);
|
|
24
|
+
if (this.referrerPolicy !== null) {
|
|
25
|
+
iframe.setAttribute("referrerpolicy", this.referrerPolicy);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
setup() {
|
|
29
|
+
listenEvent(window, "message", this.#onWindowMessage.bind(this));
|
|
30
|
+
listenEvent(this.#iframe, "load", this.onLoad.bind(this));
|
|
31
|
+
effect(this.#watchSrc.bind(this));
|
|
32
|
+
}
|
|
33
|
+
#watchSrc() {
|
|
34
|
+
const src = this.src();
|
|
35
|
+
if (!src.length) {
|
|
36
|
+
this.#iframe.setAttribute("src", "");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const params = peek(() => this.buildParams());
|
|
40
|
+
this.#iframe.setAttribute("src", appendParamsToURL(src, params));
|
|
41
|
+
}
|
|
42
|
+
postMessage(message, target) {
|
|
43
|
+
this.#iframe.contentWindow?.postMessage(JSON.stringify(message), target ?? "*");
|
|
44
|
+
}
|
|
45
|
+
#onWindowMessage(event) {
|
|
46
|
+
const origin = this.getOrigin(), isOriginMatch = (event.source === null || event.source === this.#iframe?.contentWindow) && (!isString(origin) || origin === event.origin);
|
|
47
|
+
if (!isOriginMatch) return;
|
|
48
|
+
try {
|
|
49
|
+
const message = JSON.parse(event.data);
|
|
50
|
+
if (message) this.onMessage(message, event);
|
|
51
|
+
return;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
}
|
|
54
|
+
if (event.data) this.onMessage(event.data, event);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { EmbedProvider };
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { Host, effect, setAttribute, isString, useState, BOOLEAN } from './vidstack-Bu2kfzUd.js';
|
|
2
|
+
import { Thumbnail, Time, AirPlayButton, CaptionButton, FullscreenButton, LiveButton, MuteButton, PIPButton, PlayButton, SeekButton, AudioRadioGroup, CaptionsRadioGroup, Menu, MenuButton, MenuItem, MenuItems, SpeedRadioGroup, QualityRadioGroup, Radio, Slider, SliderValue, TimeSlider, SliderPreview, VolumeSlider } from './vidstack-C-ffXlSV.js';
|
|
3
|
+
import { cloneTemplateContent, createTemplate, requestScopedAnimationFrame, cloneTemplate } from './vidstack-C_l97D5j.js';
|
|
4
|
+
import { useMediaContext } from './vidstack-DFImIcIL.js';
|
|
5
|
+
|
|
6
|
+
const imgTemplate = /* @__PURE__ */ createTemplate(
|
|
7
|
+
'<img loading="eager" decoding="async" aria-hidden="true">'
|
|
8
|
+
);
|
|
9
|
+
class MediaThumbnailElement extends Host(HTMLElement, Thumbnail) {
|
|
10
|
+
static tagName = "media-thumbnail";
|
|
11
|
+
static attrs = {
|
|
12
|
+
crossOrigin: "crossorigin"
|
|
13
|
+
};
|
|
14
|
+
#media;
|
|
15
|
+
#img = this.#createImg();
|
|
16
|
+
onSetup() {
|
|
17
|
+
this.#media = useMediaContext();
|
|
18
|
+
this.$state.img.set(this.#img);
|
|
19
|
+
}
|
|
20
|
+
onConnect() {
|
|
21
|
+
const { src, crossOrigin } = this.$state;
|
|
22
|
+
if (this.#img.parentNode !== this) {
|
|
23
|
+
this.prepend(this.#img);
|
|
24
|
+
}
|
|
25
|
+
effect(() => {
|
|
26
|
+
setAttribute(this.#img, "src", src());
|
|
27
|
+
setAttribute(this.#img, "crossorigin", crossOrigin());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
#createImg() {
|
|
31
|
+
return cloneTemplateContent(imgTemplate);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class MediaTimeElement extends Host(HTMLElement, Time) {
|
|
36
|
+
static tagName = "media-time";
|
|
37
|
+
onConnect() {
|
|
38
|
+
effect(() => {
|
|
39
|
+
this.textContent = this.$state.timeText();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class MediaAirPlayButtonElement extends Host(HTMLElement, AirPlayButton) {
|
|
45
|
+
static tagName = "media-airplay-button";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class MediaCaptionButtonElement extends Host(HTMLElement, CaptionButton) {
|
|
49
|
+
static tagName = "media-caption-button";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class MediaFullscreenButtonElement extends Host(HTMLElement, FullscreenButton) {
|
|
53
|
+
static tagName = "media-fullscreen-button";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class MediaLiveButtonElement extends Host(HTMLElement, LiveButton) {
|
|
57
|
+
static tagName = "media-live-button";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class MediaMuteButtonElement extends Host(HTMLElement, MuteButton) {
|
|
61
|
+
static tagName = "media-mute-button";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class MediaPIPButtonElement extends Host(HTMLElement, PIPButton) {
|
|
65
|
+
static tagName = "media-pip-button";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
class MediaPlayButtonElement extends Host(HTMLElement, PlayButton) {
|
|
69
|
+
static tagName = "media-play-button";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
class MediaSeekButtonElement extends Host(HTMLElement, SeekButton) {
|
|
73
|
+
static tagName = "media-seek-button";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function renderMenuItemsTemplate(el, onCreate) {
|
|
77
|
+
requestScopedAnimationFrame(() => {
|
|
78
|
+
if (!el.connectScope) return;
|
|
79
|
+
const template = el.querySelector("template");
|
|
80
|
+
if (!template) return;
|
|
81
|
+
effect(() => {
|
|
82
|
+
if (!template.content.firstElementChild?.localName && !template.firstElementChild) {
|
|
83
|
+
throw Error("[vidstack] menu items template requires root element");
|
|
84
|
+
}
|
|
85
|
+
const options = el.getOptions();
|
|
86
|
+
cloneTemplate(template, options.length, (radio, i) => {
|
|
87
|
+
const { label, value } = options[i], labelEl = radio.querySelector(`[data-part="label"]`);
|
|
88
|
+
radio.setAttribute("value", value);
|
|
89
|
+
if (labelEl) {
|
|
90
|
+
if (isString(label)) {
|
|
91
|
+
labelEl.textContent = label;
|
|
92
|
+
} else {
|
|
93
|
+
effect(() => {
|
|
94
|
+
labelEl.textContent = label();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
onCreate?.(radio, options[i], i);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
class MediaAudioRadioGroupElement extends Host(HTMLElement, AudioRadioGroup) {
|
|
105
|
+
static tagName = "media-audio-radio-group";
|
|
106
|
+
onConnect() {
|
|
107
|
+
renderMenuItemsTemplate(this);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
class MediaCaptionsRadioGroupElement extends Host(HTMLElement, CaptionsRadioGroup) {
|
|
112
|
+
static tagName = "media-captions-radio-group";
|
|
113
|
+
onConnect() {
|
|
114
|
+
renderMenuItemsTemplate(this);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
class MediaMenuElement extends Host(HTMLElement, Menu) {
|
|
119
|
+
static tagName = "media-menu";
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
class MediaMenuButtonElement extends Host(HTMLElement, MenuButton) {
|
|
123
|
+
static tagName = "media-menu-button";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
class MediaMenuItemElement extends Host(HTMLElement, MenuItem) {
|
|
127
|
+
static tagName = "media-menu-item";
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
class MediaMenuItemsElement extends Host(HTMLElement, MenuItems) {
|
|
131
|
+
static tagName = "media-menu-items";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
class MediaSpeedRadioGroupElement extends Host(HTMLElement, SpeedRadioGroup) {
|
|
135
|
+
static tagName = "media-speed-radio-group";
|
|
136
|
+
onConnect() {
|
|
137
|
+
renderMenuItemsTemplate(this);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
class MediaQualityRadioGroupElement extends Host(HTMLElement, QualityRadioGroup) {
|
|
142
|
+
static tagName = "media-quality-radio-group";
|
|
143
|
+
onConnect() {
|
|
144
|
+
renderMenuItemsTemplate(this, (el, option) => {
|
|
145
|
+
const bitrate = option.bitrate, bitrateEl = el.querySelector('[data-part="bitrate"]');
|
|
146
|
+
if (bitrate && bitrateEl) {
|
|
147
|
+
effect(() => {
|
|
148
|
+
bitrateEl.textContent = bitrate() || "";
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
class MediaRadioElement extends Host(HTMLElement, Radio) {
|
|
156
|
+
static tagName = "media-radio";
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class MediaSliderThumbnailElement extends MediaThumbnailElement {
|
|
160
|
+
static tagName = "media-slider-thumbnail";
|
|
161
|
+
#media;
|
|
162
|
+
#slider;
|
|
163
|
+
onSetup() {
|
|
164
|
+
super.onSetup();
|
|
165
|
+
this.#media = useMediaContext();
|
|
166
|
+
this.#slider = useState(Slider.state);
|
|
167
|
+
}
|
|
168
|
+
onConnect() {
|
|
169
|
+
super.onConnect();
|
|
170
|
+
effect(this.#watchTime.bind(this));
|
|
171
|
+
}
|
|
172
|
+
#watchTime() {
|
|
173
|
+
const { duration, clipStartTime } = this.#media.$state;
|
|
174
|
+
this.time = clipStartTime() + this.#slider.pointerRate() * duration();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
class MediaSliderValueElement extends Host(HTMLElement, SliderValue) {
|
|
179
|
+
static tagName = "media-slider-value";
|
|
180
|
+
static attrs = {
|
|
181
|
+
padMinutes: {
|
|
182
|
+
converter: BOOLEAN
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
onConnect() {
|
|
186
|
+
effect(() => {
|
|
187
|
+
this.textContent = this.getValueText();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
class MediaTimeSliderElement extends Host(HTMLElement, TimeSlider) {
|
|
193
|
+
static tagName = "media-time-slider";
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
class MediaSliderPreviewElement extends Host(HTMLElement, SliderPreview) {
|
|
197
|
+
static tagName = "media-slider-preview";
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
class MediaVolumeSliderElement extends Host(HTMLElement, VolumeSlider) {
|
|
201
|
+
static tagName = "media-volume-slider";
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export { MediaAirPlayButtonElement, MediaAudioRadioGroupElement, MediaCaptionButtonElement, MediaCaptionsRadioGroupElement, MediaFullscreenButtonElement, MediaLiveButtonElement, MediaMenuButtonElement, MediaMenuElement, MediaMenuItemElement, MediaMenuItemsElement, MediaMuteButtonElement, MediaPIPButtonElement, MediaPlayButtonElement, MediaQualityRadioGroupElement, MediaRadioElement, MediaSeekButtonElement, MediaSliderPreviewElement, MediaSliderThumbnailElement, MediaSliderValueElement, MediaSpeedRadioGroupElement, MediaThumbnailElement, MediaTimeElement, MediaTimeSliderElement, MediaVolumeSliderElement, renderMenuItemsTemplate };
|