@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.
Files changed (242) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -0
  3. package/analyze.json.d.ts +8 -0
  4. package/bundle.d.ts +1 -0
  5. package/cdn/chunks/vidstack-2f5gzOW6.js +1 -0
  6. package/cdn/chunks/vidstack-BYgY9wmd.js +1 -0
  7. package/cdn/chunks/vidstack-BfBBPhXV.js +1 -0
  8. package/cdn/chunks/vidstack-Bjo5esRp.js +1 -0
  9. package/cdn/chunks/vidstack-BuL67v3q.js +1 -0
  10. package/cdn/chunks/vidstack-C0msPRTd.js +3 -0
  11. package/cdn/chunks/vidstack-CJNLoJPa.js +1 -0
  12. package/cdn/chunks/vidstack-CQSpZ7X8.js +16 -0
  13. package/cdn/chunks/vidstack-C_AxqLKV.js +1 -0
  14. package/cdn/chunks/vidstack-CioT3Yw2.js +1 -0
  15. package/cdn/chunks/vidstack-CrqkytHl.js +1 -0
  16. package/cdn/chunks/vidstack-D0M8R0ZU.js +1 -0
  17. package/cdn/chunks/vidstack-D40FSa5B.js +3 -0
  18. package/cdn/chunks/vidstack-DD2JwFVU.js +1 -0
  19. package/cdn/chunks/vidstack-DRH_1tFW.js +1 -0
  20. package/cdn/chunks/vidstack-DfDZuHNP.js +1 -0
  21. package/cdn/chunks/vidstack-DiNS2Vx5.js +1 -0
  22. package/cdn/chunks/vidstack-xjJ-ui_l.js +1 -0
  23. package/cdn/providers/vidstack-audio-2Dt_Ivbp.js +1 -0
  24. package/cdn/providers/vidstack-dash-CUtD4e6q.js +1 -0
  25. package/cdn/providers/vidstack-google-cast-BdORATUX.js +1 -0
  26. package/cdn/providers/vidstack-hls-R25Kb6DP.js +1 -0
  27. package/cdn/providers/vidstack-html-DaAUJYsD.js +1 -0
  28. package/cdn/providers/vidstack-video-Csvox7SO.js +1 -0
  29. package/cdn/providers/vidstack-vimeo-D4Z96kg2.js +1 -0
  30. package/cdn/providers/vidstack-youtube-DiND6h3s.js +1 -0
  31. package/cdn/vidstack.js +1 -0
  32. package/cdn/with-layouts/chunks/vidstack-2f5gzOW6.js +1 -0
  33. package/cdn/with-layouts/chunks/vidstack-45yH5los.js +1 -0
  34. package/cdn/with-layouts/chunks/vidstack-BBVMdOnf.js +1 -0
  35. package/cdn/with-layouts/chunks/vidstack-BB_ulI_T.js +1 -0
  36. package/cdn/with-layouts/chunks/vidstack-BcAewM33.js +1 -0
  37. package/cdn/with-layouts/chunks/vidstack-BfBBPhXV.js +1 -0
  38. package/cdn/with-layouts/chunks/vidstack-Bxv1Qnxe.js +1 -0
  39. package/cdn/with-layouts/chunks/vidstack-C2ZbG62f.js +3 -0
  40. package/cdn/with-layouts/chunks/vidstack-CCYIOKgL.js +1 -0
  41. package/cdn/with-layouts/chunks/vidstack-CL6PeIO1.js +1 -0
  42. package/cdn/with-layouts/chunks/vidstack-C_AxqLKV.js +1 -0
  43. package/cdn/with-layouts/chunks/vidstack-CifDkwDH.js +795 -0
  44. package/cdn/with-layouts/chunks/vidstack-Cry7aD59.js +3 -0
  45. package/cdn/with-layouts/chunks/vidstack-D065okCn.js +1 -0
  46. package/cdn/with-layouts/chunks/vidstack-DGuMoXmI.js +1 -0
  47. package/cdn/with-layouts/chunks/vidstack-DRH_1tFW.js +1 -0
  48. package/cdn/with-layouts/chunks/vidstack-DVBs1XoQ.js +1 -0
  49. package/cdn/with-layouts/chunks/vidstack-Dge3KT8k.js +1 -0
  50. package/cdn/with-layouts/chunks/vidstack-DiNS2Vx5.js +1 -0
  51. package/cdn/with-layouts/chunks/vidstack-HvYfJoen.js +1 -0
  52. package/cdn/with-layouts/providers/vidstack-audio-DE5vKIzW.js +1 -0
  53. package/cdn/with-layouts/providers/vidstack-dash-CA2agUuZ.js +1 -0
  54. package/cdn/with-layouts/providers/vidstack-google-cast-CGs-t8HM.js +1 -0
  55. package/cdn/with-layouts/providers/vidstack-hls-BHMbMFFR.js +1 -0
  56. package/cdn/with-layouts/providers/vidstack-html-Dm9gmNk6.js +1 -0
  57. package/cdn/with-layouts/providers/vidstack-video-C5it_Lbl.js +1 -0
  58. package/cdn/with-layouts/providers/vidstack-vimeo-BabLn9sy.js +1 -0
  59. package/cdn/with-layouts/providers/vidstack-youtube-D8UlccUL.js +1 -0
  60. package/cdn/with-layouts/vidstack.js +1 -0
  61. package/dev/chunks/vidstack-B7Zi3v_O.js +104 -0
  62. package/dev/chunks/vidstack-BFg1ZqiG.js +91 -0
  63. package/dev/chunks/vidstack-BGB2pa9s.js +58 -0
  64. package/dev/chunks/vidstack-BaIbHZE3.js +1519 -0
  65. package/dev/chunks/vidstack-Bb2rASIc.js +5188 -0
  66. package/dev/chunks/vidstack-Bcmx8pmK.js +224 -0
  67. package/dev/chunks/vidstack-Bl4b0Nen.js +29 -0
  68. package/dev/chunks/vidstack-Bo5OTJ06.js +58 -0
  69. package/dev/chunks/vidstack-BoAGnlRt.js +58 -0
  70. package/dev/chunks/vidstack-Bpr4fI4n.js +7 -0
  71. package/dev/chunks/vidstack-Bt8MP2DK.js +204 -0
  72. package/dev/chunks/vidstack-Bu2kfzUd.js +1637 -0
  73. package/dev/chunks/vidstack-C-ffXlSV.js +2995 -0
  74. package/dev/chunks/vidstack-C-ztJq-f.js +109 -0
  75. package/dev/chunks/vidstack-CFNlaVTR.js +55 -0
  76. package/dev/chunks/vidstack-C_l97D5j.js +254 -0
  77. package/dev/chunks/vidstack-CjhKISI0.js +114 -0
  78. package/dev/chunks/vidstack-CofXIJAy.js +57 -0
  79. package/dev/chunks/vidstack-CwTj4H1w.js +18 -0
  80. package/dev/chunks/vidstack-DDwbYVHV.js +66 -0
  81. package/dev/chunks/vidstack-DFImIcIL.js +11 -0
  82. package/dev/chunks/vidstack-DGDvUbvO.js +33 -0
  83. package/dev/chunks/vidstack-DO0kqA99.js +107 -0
  84. package/dev/chunks/vidstack-DXxIKXmd.js +50 -0
  85. package/dev/chunks/vidstack-DajrMUR0.js +297 -0
  86. package/dev/chunks/vidstack-DbBJlz7I.js +10 -0
  87. package/dev/chunks/vidstack-Dihypf8P.js +11 -0
  88. package/dev/chunks/vidstack-DlAhl87f.js +1193 -0
  89. package/dev/chunks/vidstack-Dm1xEU9Q.js +34 -0
  90. package/dev/chunks/vidstack-Dv_LIPFu.js +14 -0
  91. package/dev/chunks/vidstack-igYn0Apa.js +254 -0
  92. package/dev/chunks/vidstack-krOAtKMi.js +32 -0
  93. package/dev/chunks/vidstack-qh1N5_f_.js +26 -0
  94. package/dev/chunks/vidstack-rB-wqXw1.js +107 -0
  95. package/dev/chunks/vidstack-zG6PIeGg.js +66 -0
  96. package/dev/define/plyr-layout.js +51 -0
  97. package/dev/define/templates/plyr-layout.js +571 -0
  98. package/dev/define/templates/vidstack-audio-layout.js +167 -0
  99. package/dev/define/templates/vidstack-video-layout.js +390 -0
  100. package/dev/define/vidstack-icons.js +1 -0
  101. package/dev/define/vidstack-player-default-layout.js +21 -0
  102. package/dev/define/vidstack-player-layouts.js +25 -0
  103. package/dev/define/vidstack-player-ui.js +70 -0
  104. package/dev/define/vidstack-player.js +19 -0
  105. package/dev/global/plyr.js +501 -0
  106. package/dev/global/vidstack-player.js +129 -0
  107. package/dev/providers/vidstack-audio.js +35 -0
  108. package/dev/providers/vidstack-dash.js +516 -0
  109. package/dev/providers/vidstack-google-cast.js +474 -0
  110. package/dev/providers/vidstack-hls.js +408 -0
  111. package/dev/providers/vidstack-html.js +567 -0
  112. package/dev/providers/vidstack-video.js +207 -0
  113. package/dev/providers/vidstack-vimeo.js +554 -0
  114. package/dev/providers/vidstack-youtube.js +286 -0
  115. package/dev/vidstack-elements.js +36 -0
  116. package/dev/vidstack.js +91 -0
  117. package/dom.d.ts +91 -0
  118. package/elements.d.ts +1433 -0
  119. package/empty.vtt +1 -0
  120. package/global/player.d.ts +52 -0
  121. package/global/plyr.d.ts +343 -0
  122. package/google-cast.d.ts +1422 -0
  123. package/icons.d.ts +1 -0
  124. package/index.d.ts +402 -0
  125. package/package.json +199 -0
  126. package/player/index.d.ts +3 -0
  127. package/player/layouts/default.d.ts +3 -0
  128. package/player/layouts/index.d.ts +3 -0
  129. package/player/layouts/plyr.d.ts +3 -0
  130. package/player/styles/base.css +153 -0
  131. package/player/styles/default/buffering.css +55 -0
  132. package/player/styles/default/buttons.css +175 -0
  133. package/player/styles/default/captions.css +181 -0
  134. package/player/styles/default/chapter-title.css +26 -0
  135. package/player/styles/default/controls.css +56 -0
  136. package/player/styles/default/gestures.css +19 -0
  137. package/player/styles/default/icons.css +6 -0
  138. package/player/styles/default/keyboard.css +148 -0
  139. package/player/styles/default/layouts/audio.css +417 -0
  140. package/player/styles/default/layouts/video.css +590 -0
  141. package/player/styles/default/menus.css +959 -0
  142. package/player/styles/default/poster.css +52 -0
  143. package/player/styles/default/sliders.css +391 -0
  144. package/player/styles/default/theme.css +2461 -0
  145. package/player/styles/default/thumbnail.css +40 -0
  146. package/player/styles/default/time.css +45 -0
  147. package/player/styles/default/tooltips.css +141 -0
  148. package/player/styles/plyr/theme.css +1237 -0
  149. package/player/ui.d.ts +3 -0
  150. package/plugins.d.ts +19 -0
  151. package/plugins.js +13 -0
  152. package/prod/chunks/vidstack-B01xzxC4.js +7 -0
  153. package/prod/chunks/vidstack-BCeb7ryV.js +201 -0
  154. package/prod/chunks/vidstack-BGSTndAW.js +1590 -0
  155. package/prod/chunks/vidstack-BPitBBjh.js +1519 -0
  156. package/prod/chunks/vidstack-BQlOPwOu.js +45 -0
  157. package/prod/chunks/vidstack-BSDzlwxO.js +4778 -0
  158. package/prod/chunks/vidstack-BT0m6zEi.js +109 -0
  159. package/prod/chunks/vidstack-BTigPj2h.js +55 -0
  160. package/prod/chunks/vidstack-BiyXcJ_M.js +107 -0
  161. package/prod/chunks/vidstack-BoVf5n1M.js +2985 -0
  162. package/prod/chunks/vidstack-Bq6c3Bam.js +58 -0
  163. package/prod/chunks/vidstack-ByLCIBtB.js +297 -0
  164. package/prod/chunks/vidstack-C2US-gSO.js +248 -0
  165. package/prod/chunks/vidstack-C9vIqaYT.js +10 -0
  166. package/prod/chunks/vidstack-CF6fixCQ.js +1193 -0
  167. package/prod/chunks/vidstack-CTojmhKq.js +66 -0
  168. package/prod/chunks/vidstack-ChQTHmIQ.js +77 -0
  169. package/prod/chunks/vidstack-Cm6_unwd.js +246 -0
  170. package/prod/chunks/vidstack-CwTj4H1w.js +18 -0
  171. package/prod/chunks/vidstack-D3ltXc3a.js +33 -0
  172. package/prod/chunks/vidstack-D5EzK014.js +14 -0
  173. package/prod/chunks/vidstack-DDXt6fpN.js +58 -0
  174. package/prod/chunks/vidstack-DJDnh4xT.js +11 -0
  175. package/prod/chunks/vidstack-DXxIKXmd.js +50 -0
  176. package/prod/chunks/vidstack-D_-9AA6_.js +29 -0
  177. package/prod/chunks/vidstack-DbkZGjSn.js +107 -0
  178. package/prod/chunks/vidstack-Dihypf8P.js +11 -0
  179. package/prod/chunks/vidstack-Dm1xEU9Q.js +34 -0
  180. package/prod/chunks/vidstack-Dq5Yu0Vr.js +205 -0
  181. package/prod/chunks/vidstack-DqAw8m9J.js +26 -0
  182. package/prod/chunks/vidstack-DsPOyKtl.js +57 -0
  183. package/prod/chunks/vidstack-krOAtKMi.js +32 -0
  184. package/prod/chunks/vidstack-nLyr4NEP.js +58 -0
  185. package/prod/chunks/vidstack-xMS8dnYq.js +114 -0
  186. package/prod/chunks/vidstack-yEGTpgeA.js +104 -0
  187. package/prod/define/plyr-layout.js +51 -0
  188. package/prod/define/templates/plyr-layout.js +571 -0
  189. package/prod/define/templates/vidstack-audio-layout.js +167 -0
  190. package/prod/define/templates/vidstack-video-layout.js +390 -0
  191. package/prod/define/vidstack-icons.js +1 -0
  192. package/prod/define/vidstack-player-default-layout.js +21 -0
  193. package/prod/define/vidstack-player-layouts.js +25 -0
  194. package/prod/define/vidstack-player-ui.js +70 -0
  195. package/prod/define/vidstack-player.js +19 -0
  196. package/prod/global/plyr.js +493 -0
  197. package/prod/global/vidstack-player.js +129 -0
  198. package/prod/providers/vidstack-audio.js +35 -0
  199. package/prod/providers/vidstack-dash.js +501 -0
  200. package/prod/providers/vidstack-google-cast.js +468 -0
  201. package/prod/providers/vidstack-hls.js +393 -0
  202. package/prod/providers/vidstack-html.js +555 -0
  203. package/prod/providers/vidstack-video.js +204 -0
  204. package/prod/providers/vidstack-vimeo.js +548 -0
  205. package/prod/providers/vidstack-youtube.js +286 -0
  206. package/prod/vidstack-elements.js +36 -0
  207. package/prod/vidstack.js +158 -0
  208. package/server/chunks/vidstack-6juFdkKy.js +29 -0
  209. package/server/chunks/vidstack-B7iHmv7_.js +307 -0
  210. package/server/chunks/vidstack-BmxyML9v.js +1619 -0
  211. package/server/chunks/vidstack-BskfxwD3.js +566 -0
  212. package/server/chunks/vidstack-BvLV0SMz.js +4642 -0
  213. package/server/chunks/vidstack-BvWwluXZ.js +205 -0
  214. package/server/chunks/vidstack-C-413dj2.js +8 -0
  215. package/server/chunks/vidstack-C26K8z_-.js +55 -0
  216. package/server/chunks/vidstack-CJJiksDz.js +107 -0
  217. package/server/chunks/vidstack-CUNv52x1.js +141 -0
  218. package/server/chunks/vidstack-CqyBCODe.js +295 -0
  219. package/server/chunks/vidstack-CwTj4H1w.js +18 -0
  220. package/server/chunks/vidstack-DHAyGSOl.js +1502 -0
  221. package/server/chunks/vidstack-DLU3cjcp.js +381 -0
  222. package/server/chunks/vidstack-DXxIKXmd.js +50 -0
  223. package/server/chunks/vidstack-DbtDXDS2.js +104 -0
  224. package/server/chunks/vidstack-Dm1xEU9Q.js +34 -0
  225. package/server/chunks/vidstack-DzTHw_bw.js +207 -0
  226. package/server/chunks/vidstack-Wn3NH5Sg.js +1566 -0
  227. package/server/chunks/vidstack-krOAtKMi.js +32 -0
  228. package/server/chunks/vidstack-wNViAkr4.js +3045 -0
  229. package/server/define/plyr-layout.js +16 -0
  230. package/server/define/vidstack-icons.js +1 -0
  231. package/server/define/vidstack-player-default-layout.js +13 -0
  232. package/server/define/vidstack-player-layouts.js +16 -0
  233. package/server/define/vidstack-player-ui.js +11 -0
  234. package/server/define/vidstack-player.js +6 -0
  235. package/server/global/plyr.js +322 -0
  236. package/server/global/vidstack-player.js +58 -0
  237. package/server/vidstack-elements.js +46 -0
  238. package/server/vidstack.js +148 -0
  239. package/tailwind.cjs +101 -0
  240. package/tailwind.d.cts +15 -0
  241. package/types/vidstack-BOvzfZjK.d.ts +1269 -0
  242. package/types/vidstack-Cttpg6GU.d.ts +7474 -0
@@ -0,0 +1,34 @@
1
+ const videoIdRE = /(?:youtu\.be|youtube|youtube\.com|youtube-nocookie\.com)(?:\/shorts)?\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|)((?:\w|-){11})/;
2
+ const posterCache = /* @__PURE__ */ new Map();
3
+ const pendingFetch = /* @__PURE__ */ new Map();
4
+ function resolveYouTubeVideoId(src) {
5
+ return src.match(videoIdRE)?.[1];
6
+ }
7
+ async function findYouTubePoster(videoId, abort) {
8
+ if (posterCache.has(videoId)) return posterCache.get(videoId);
9
+ if (pendingFetch.has(videoId)) return pendingFetch.get(videoId);
10
+ const pending = new Promise(async (resolve) => {
11
+ const sizes = ["maxresdefault", "sddefault", "hqdefault"];
12
+ for (const size of sizes) {
13
+ for (const webp of [true, false]) {
14
+ const url = resolveYouTubePosterURL(videoId, size, webp), response = await fetch(url, {
15
+ mode: "no-cors",
16
+ signal: abort.signal
17
+ });
18
+ if (response.status < 400) {
19
+ posterCache.set(videoId, url);
20
+ resolve(url);
21
+ return;
22
+ }
23
+ }
24
+ }
25
+ }).catch(() => "").finally(() => pendingFetch.delete(videoId));
26
+ pendingFetch.set(videoId, pending);
27
+ return pending;
28
+ }
29
+ function resolveYouTubePosterURL(videoId, size, webp) {
30
+ const type = webp ? "webp" : "jpg";
31
+ return `https://i.ytimg.com/${webp ? "vi_webp" : "vi"}/${videoId}/${size}.${type}`;
32
+ }
33
+
34
+ export { findYouTubePoster, resolveYouTubeVideoId };
@@ -0,0 +1,14 @@
1
+ const ADD = Symbol("LIST_ADD" ), REMOVE = Symbol("LIST_REMOVE" ), RESET = Symbol("LIST_RESET" ), SELECT = Symbol("LIST_SELECT" ), READONLY = Symbol("LIST_READONLY" ), SET_READONLY = Symbol("LIST_SET_READONLY" ), ON_RESET = Symbol("LIST_ON_RESET" ), ON_REMOVE = Symbol("LIST_ON_REMOVE" ), ON_USER_SELECT = Symbol("LIST_ON_USER_SELECT" );
2
+ const ListSymbol = {
3
+ add: ADD,
4
+ remove: REMOVE,
5
+ reset: RESET,
6
+ select: SELECT,
7
+ readonly: READONLY,
8
+ setReadonly: SET_READONLY,
9
+ onReset: ON_RESET,
10
+ onRemove: ON_REMOVE,
11
+ onUserSelect: ON_USER_SELECT
12
+ };
13
+
14
+ export { ListSymbol };
@@ -0,0 +1,254 @@
1
+ import { EventsTarget, DOMEvent, isString, isArray, isNumber } from './vidstack-Bu2kfzUd.js';
2
+ import { getRequestCredentials } from './vidstack-zG6PIeGg.js';
3
+ import { isCueActive } from './vidstack-BGB2pa9s.js';
4
+
5
+ const CROSS_ORIGIN = Symbol("TEXT_TRACK_CROSS_ORIGIN" ), READY_STATE = Symbol("TEXT_TRACK_READY_STATE" ), UPDATE_ACTIVE_CUES = Symbol("TEXT_TRACK_UPDATE_ACTIVE_CUES" ), CAN_LOAD = Symbol("TEXT_TRACK_CAN_LOAD" ), ON_MODE_CHANGE = Symbol("TEXT_TRACK_ON_MODE_CHANGE" ), NATIVE = Symbol("TEXT_TRACK_NATIVE" ), NATIVE_HLS = Symbol("TEXT_TRACK_NATIVE_HLS" );
6
+ const TextTrackSymbol = {
7
+ crossOrigin: CROSS_ORIGIN,
8
+ readyState: READY_STATE,
9
+ updateActiveCues: UPDATE_ACTIVE_CUES,
10
+ canLoad: CAN_LOAD,
11
+ onModeChange: ON_MODE_CHANGE,
12
+ native: NATIVE,
13
+ nativeHLS: NATIVE_HLS
14
+ };
15
+
16
+ class TextTrack extends EventsTarget {
17
+ static createId(track) {
18
+ return `vds-${track.type}-${track.kind}-${track.src ?? track.label ?? "?"}`;
19
+ }
20
+ src;
21
+ content;
22
+ type;
23
+ encoding;
24
+ id = "";
25
+ label = "";
26
+ language = "";
27
+ kind;
28
+ default = false;
29
+ #canLoad = false;
30
+ #currentTime = 0;
31
+ #mode = "disabled";
32
+ #metadata = {};
33
+ #regions = [];
34
+ #cues = [];
35
+ #activeCues = [];
36
+ #cueIds = /* @__PURE__ */ new Set();
37
+ /** @internal */
38
+ [TextTrackSymbol.readyState] = 0;
39
+ /** @internal */
40
+ [TextTrackSymbol.crossOrigin];
41
+ /** @internal */
42
+ [TextTrackSymbol.onModeChange] = null;
43
+ /** @internal */
44
+ [TextTrackSymbol.native] = null;
45
+ get metadata() {
46
+ return this.#metadata;
47
+ }
48
+ get regions() {
49
+ return this.#regions;
50
+ }
51
+ get cues() {
52
+ return this.#cues;
53
+ }
54
+ get activeCues() {
55
+ return this.#activeCues;
56
+ }
57
+ /**
58
+ * - 0: Not Loading
59
+ * - 1: Loading
60
+ * - 2: Ready
61
+ * - 3: Error
62
+ */
63
+ get readyState() {
64
+ return this[TextTrackSymbol.readyState];
65
+ }
66
+ get mode() {
67
+ return this.#mode;
68
+ }
69
+ set mode(mode) {
70
+ this.setMode(mode);
71
+ }
72
+ constructor(init) {
73
+ super();
74
+ for (const prop of Object.keys(init)) this[prop] = init[prop];
75
+ if (!this.type) this.type = "vtt";
76
+ if (init.content) {
77
+ this.#parseContent(init);
78
+ } else if (!init.src) {
79
+ this[TextTrackSymbol.readyState] = 2;
80
+ }
81
+ if (isTrackCaptionKind(this) && !this.label) {
82
+ console.warn(`[vidstack] captions text track created without label: \`${this.src}\``);
83
+ }
84
+ }
85
+ addCue(cue, trigger) {
86
+ if (cue.id) {
87
+ if (this.#cueIds.has(cue.id)) return;
88
+ this.#cueIds.add(cue.id);
89
+ }
90
+ let i = 0, length = this.#cues.length;
91
+ for (i = 0; i < length; i++) if (cue.endTime <= this.#cues[i].startTime) break;
92
+ if (i === length) this.#cues.push(cue);
93
+ else this.#cues.splice(i, 0, cue);
94
+ if (!(cue instanceof TextTrackCue)) {
95
+ this[TextTrackSymbol.native]?.track.addCue(cue);
96
+ }
97
+ this.dispatchEvent(new DOMEvent("add-cue", { detail: cue, trigger }));
98
+ if (isCueActive(cue, this.#currentTime)) {
99
+ this[TextTrackSymbol.updateActiveCues](this.#currentTime, trigger);
100
+ }
101
+ }
102
+ removeCue(cue, trigger) {
103
+ const index = this.#cues.indexOf(cue);
104
+ if (index >= 0) {
105
+ const isActive = this.#activeCues.includes(cue);
106
+ if (cue.id) this.#cueIds.delete(cue.id);
107
+ this.#cues.splice(index, 1);
108
+ this[TextTrackSymbol.native]?.track.removeCue(cue);
109
+ this.dispatchEvent(new DOMEvent("remove-cue", { detail: cue, trigger }));
110
+ if (isActive) {
111
+ this[TextTrackSymbol.updateActiveCues](this.#currentTime, trigger);
112
+ }
113
+ }
114
+ }
115
+ setMode(mode, trigger) {
116
+ if (this.#mode === mode) return;
117
+ this.#mode = mode;
118
+ if (mode === "disabled") {
119
+ this.#activeCues = [];
120
+ this.#activeCuesChanged();
121
+ } else if (this.readyState === 2) {
122
+ this[TextTrackSymbol.updateActiveCues](this.#currentTime, trigger);
123
+ } else {
124
+ this.#load();
125
+ }
126
+ this.dispatchEvent(new DOMEvent("mode-change", { detail: this, trigger }));
127
+ this[TextTrackSymbol.onModeChange]?.();
128
+ }
129
+ /** @internal */
130
+ [TextTrackSymbol.updateActiveCues](currentTime, trigger) {
131
+ this.#currentTime = currentTime;
132
+ if (this.mode === "disabled" || !this.#cues.length) return;
133
+ const activeCues = [];
134
+ for (let i = 0, length = this.#cues.length; i < length; i++) {
135
+ const cue = this.#cues[i];
136
+ if (isCueActive(cue, currentTime)) activeCues.push(cue);
137
+ }
138
+ let changed = activeCues.length !== this.#activeCues.length;
139
+ if (!changed) {
140
+ for (let i = 0; i < activeCues.length; i++) {
141
+ if (!this.#activeCues.includes(activeCues[i])) {
142
+ changed = true;
143
+ break;
144
+ }
145
+ }
146
+ }
147
+ this.#activeCues = activeCues;
148
+ if (changed) this.#activeCuesChanged(trigger);
149
+ }
150
+ /** @internal */
151
+ [TextTrackSymbol.canLoad]() {
152
+ this.#canLoad = true;
153
+ if (this.#mode !== "disabled") this.#load();
154
+ }
155
+ #parseContent(init) {
156
+ import('media-captions').then(({ parseText, VTTCue, VTTRegion }) => {
157
+ if (!isString(init.content) || init.type === "json") {
158
+ this.#parseJSON(init.content, VTTCue, VTTRegion);
159
+ if (this.readyState !== 3) this.#ready();
160
+ } else {
161
+ const content = init.content.split("\n").map((line) => line.trim()).join("\n").trim();
162
+ parseText(content, { type: init.type }).then(({ cues, regions }) => {
163
+ this.#cues = cues;
164
+ this.#regions = regions;
165
+ this.#ready();
166
+ });
167
+ }
168
+ });
169
+ }
170
+ async #load() {
171
+ if (!this.#canLoad || this[TextTrackSymbol.readyState] > 0) return;
172
+ this[TextTrackSymbol.readyState] = 1;
173
+ this.dispatchEvent(new DOMEvent("load-start"));
174
+ if (!this.src) {
175
+ this.#ready();
176
+ return;
177
+ }
178
+ try {
179
+ const { parseResponse, VTTCue, VTTRegion } = await import('media-captions'), crossOrigin = this[TextTrackSymbol.crossOrigin]?.();
180
+ const response = fetch(this.src, {
181
+ headers: this.type === "json" ? { "Content-Type": "application/json" } : void 0,
182
+ credentials: getRequestCredentials(crossOrigin)
183
+ });
184
+ if (this.type === "json") {
185
+ this.#parseJSON(await (await response).text(), VTTCue, VTTRegion);
186
+ } else {
187
+ const { errors, metadata, regions, cues } = await parseResponse(response, {
188
+ type: this.type,
189
+ encoding: this.encoding
190
+ });
191
+ if (errors[0]?.code === 0) {
192
+ throw errors[0];
193
+ } else {
194
+ this.#metadata = metadata;
195
+ this.#regions = regions;
196
+ this.#cues = cues;
197
+ }
198
+ }
199
+ this.#ready();
200
+ } catch (error) {
201
+ this.#error(error);
202
+ }
203
+ }
204
+ #ready() {
205
+ this[TextTrackSymbol.readyState] = 2;
206
+ if (!this.src || this.type !== "vtt") {
207
+ const native = this[TextTrackSymbol.native];
208
+ if (native && !native.managed) {
209
+ for (const cue of this.#cues) native.track.addCue(cue);
210
+ }
211
+ }
212
+ const loadEvent = new DOMEvent("load");
213
+ this[TextTrackSymbol.updateActiveCues](this.#currentTime, loadEvent);
214
+ this.dispatchEvent(loadEvent);
215
+ }
216
+ #error(error) {
217
+ this[TextTrackSymbol.readyState] = 3;
218
+ this.dispatchEvent(new DOMEvent("error", { detail: error }));
219
+ }
220
+ #parseJSON(json, VTTCue, VTTRegion) {
221
+ try {
222
+ const { regions, cues } = parseJSONCaptionsFile(json, VTTCue, VTTRegion);
223
+ this.#regions = regions;
224
+ this.#cues = cues;
225
+ } catch (error) {
226
+ {
227
+ console.error(`[vidstack] failed to parse JSON captions at: \`${this.src}\`
228
+
229
+ `, error);
230
+ }
231
+ this.#error(error);
232
+ }
233
+ }
234
+ #activeCuesChanged(trigger) {
235
+ this.dispatchEvent(new DOMEvent("cue-change", { trigger }));
236
+ }
237
+ }
238
+ const captionRE = /captions|subtitles/;
239
+ function isTrackCaptionKind(track) {
240
+ return captionRE.test(track.kind);
241
+ }
242
+ function parseJSONCaptionsFile(json, Cue, Region) {
243
+ const content = isString(json) ? JSON.parse(json) : json;
244
+ let regions = [], cues = [];
245
+ if (content.regions && Region) {
246
+ regions = content.regions.map((region) => Object.assign(new Region(), region));
247
+ }
248
+ if (content.cues || isArray(content)) {
249
+ cues = (isArray(content) ? content : content.cues).filter((content2) => isNumber(content2.startTime) && isNumber(content2.endTime)).map((cue) => Object.assign(new Cue(0, 0, ""), cue));
250
+ }
251
+ return { regions, cues };
252
+ }
253
+
254
+ export { TextTrack, TextTrackSymbol, isTrackCaptionKind, parseJSONCaptionsFile };
@@ -0,0 +1,32 @@
1
+ const videoIdRE = /(?:https:\/\/)?(?:player\.)?vimeo(?:\.com)?\/(?:video\/)?(\d+)(?:(?:\?hash=|\?h=|\/)(.*))?/;
2
+ const infoCache = /* @__PURE__ */ new Map();
3
+ const pendingFetch = /* @__PURE__ */ new Map();
4
+ function resolveVimeoVideoId(src) {
5
+ const matches = src.match(videoIdRE);
6
+ return { videoId: matches?.[1], hash: matches?.[2] };
7
+ }
8
+ async function getVimeoVideoInfo(videoId, abort, videoHash) {
9
+ if (infoCache.has(videoId)) return infoCache.get(videoId);
10
+ if (pendingFetch.has(videoId)) return pendingFetch.get(videoId);
11
+ let oembedSrc = `https://vimeo.com/api/oembed.json?url=https://player.vimeo.com/video/${videoId}`;
12
+ if (videoHash) {
13
+ oembedSrc = oembedSrc.concat(`?h=${videoHash}`);
14
+ }
15
+ const promise = window.fetch(oembedSrc, {
16
+ mode: "cors",
17
+ signal: abort.signal
18
+ }).then((response) => response.json()).then((data) => {
19
+ const thumnailRegex = /vimeocdn.com\/video\/(.*)?_/, thumbnailId = data?.thumbnail_url?.match(thumnailRegex)?.[1], poster = thumbnailId ? `https://i.vimeocdn.com/video/${thumbnailId}_1920x1080.webp` : "", info = {
20
+ title: data?.title ?? "",
21
+ duration: data?.duration ?? 0,
22
+ poster,
23
+ pro: data.account_type !== "basic"
24
+ };
25
+ infoCache.set(videoId, info);
26
+ return info;
27
+ }).finally(() => pendingFetch.delete(videoId));
28
+ pendingFetch.set(videoId, promise);
29
+ return promise;
30
+ }
31
+
32
+ export { getVimeoVideoInfo, resolveVimeoVideoId };
@@ -0,0 +1,26 @@
1
+ import { isUndefined, isNumber } from './vidstack-Bu2kfzUd.js';
2
+
3
+ class RAFLoop {
4
+ #id;
5
+ #callback;
6
+ constructor(callback) {
7
+ this.#callback = callback;
8
+ }
9
+ start() {
10
+ if (!isUndefined(this.#id)) return;
11
+ this.#loop();
12
+ }
13
+ stop() {
14
+ if (isNumber(this.#id)) window.cancelAnimationFrame(this.#id);
15
+ this.#id = void 0;
16
+ }
17
+ #loop() {
18
+ this.#id = window.requestAnimationFrame(() => {
19
+ if (isUndefined(this.#id)) return;
20
+ this.#callback();
21
+ this.#loop();
22
+ });
23
+ }
24
+ }
25
+
26
+ export { RAFLoop };
@@ -0,0 +1,107 @@
1
+ import { Component, State, effect, isNull, setAttribute, EventsController } from './vidstack-Bu2kfzUd.js';
2
+ import { useMediaContext } from './vidstack-DFImIcIL.js';
3
+ import { preconnect } from './vidstack-zG6PIeGg.js';
4
+
5
+ class Poster extends Component {
6
+ static props = {
7
+ src: null,
8
+ alt: null,
9
+ crossOrigin: null
10
+ };
11
+ static state = new State({
12
+ img: null,
13
+ src: null,
14
+ alt: null,
15
+ crossOrigin: null,
16
+ loading: true,
17
+ error: null,
18
+ hidden: false
19
+ });
20
+ #media;
21
+ onSetup() {
22
+ this.#media = useMediaContext();
23
+ this.#watchSrc();
24
+ this.#watchAlt();
25
+ this.#watchCrossOrigin();
26
+ this.#watchHidden();
27
+ }
28
+ onAttach(el) {
29
+ el.style.setProperty("pointer-events", "none");
30
+ effect(this.#watchImg.bind(this));
31
+ effect(this.#watchSrc.bind(this));
32
+ effect(this.#watchAlt.bind(this));
33
+ effect(this.#watchCrossOrigin.bind(this));
34
+ effect(this.#watchHidden.bind(this));
35
+ const { started } = this.#media.$state;
36
+ this.setAttributes({
37
+ "data-visible": () => !started() && !this.$state.hidden(),
38
+ "data-loading": this.#isLoading.bind(this),
39
+ "data-error": this.#hasError.bind(this),
40
+ "data-hidden": this.$state.hidden
41
+ });
42
+ }
43
+ onConnect(el) {
44
+ effect(this.#onPreconnect.bind(this));
45
+ effect(this.#onLoadStart.bind(this));
46
+ }
47
+ #hasError() {
48
+ const { error } = this.$state;
49
+ return !isNull(error());
50
+ }
51
+ #onPreconnect() {
52
+ const { canLoadPoster, poster } = this.#media.$state;
53
+ if (!canLoadPoster() && poster()) preconnect(poster(), "preconnect");
54
+ }
55
+ #watchHidden() {
56
+ const { src } = this.$props, { poster, nativeControls } = this.#media.$state;
57
+ this.el && setAttribute(this.el, "display", nativeControls() ? "none" : null);
58
+ this.$state.hidden.set(this.#hasError() || !(src() || poster()) || nativeControls());
59
+ }
60
+ #isLoading() {
61
+ const { loading, hidden } = this.$state;
62
+ return !hidden() && loading();
63
+ }
64
+ #watchImg() {
65
+ const img = this.$state.img();
66
+ if (!img) return;
67
+ new EventsController(img).add("load", this.#onLoad.bind(this)).add("error", this.#onError.bind(this));
68
+ if (img.complete) this.#onLoad();
69
+ }
70
+ #prevSrc = "";
71
+ #watchSrc() {
72
+ const { poster: defaultPoster } = this.#media.$props, { canLoadPoster, providedPoster, inferredPoster } = this.#media.$state;
73
+ const src = this.$props.src() || "", poster = src || defaultPoster() || inferredPoster();
74
+ if (this.#prevSrc === providedPoster()) {
75
+ providedPoster.set(src);
76
+ }
77
+ this.$state.src.set(canLoadPoster() && poster.length ? poster : null);
78
+ this.#prevSrc = src;
79
+ }
80
+ #watchAlt() {
81
+ const { src } = this.$props, { alt } = this.$state, { poster } = this.#media.$state;
82
+ alt.set(src() || poster() ? this.$props.alt() : null);
83
+ }
84
+ #watchCrossOrigin() {
85
+ const { crossOrigin: crossOriginProp } = this.$props, { crossOrigin: crossOriginState } = this.$state, { crossOrigin: mediaCrossOrigin, poster: src } = this.#media.$state, crossOrigin = crossOriginProp() !== null ? crossOriginProp() : mediaCrossOrigin();
86
+ crossOriginState.set(
87
+ /ytimg\.com|vimeo/.test(src() || "") ? null : crossOrigin === true ? "anonymous" : crossOrigin
88
+ );
89
+ }
90
+ #onLoadStart() {
91
+ const { loading, error } = this.$state, { canLoadPoster, poster } = this.#media.$state;
92
+ loading.set(canLoadPoster() && !!poster());
93
+ error.set(null);
94
+ }
95
+ #onLoad() {
96
+ const { loading, error } = this.$state;
97
+ loading.set(false);
98
+ error.set(null);
99
+ }
100
+ #onError(event) {
101
+ const { loading, error } = this.$state;
102
+ loading.set(false);
103
+ error.set(event);
104
+ }
105
+ }
106
+
107
+ export { Poster };
@@ -0,0 +1,66 @@
1
+ import { isNull, isString, deferredPromise, isBoolean } from './vidstack-Bu2kfzUd.js';
2
+ import { isAudioSrc, isVideoSrc } from './vidstack-CjhKISI0.js';
3
+
4
+ function appendParamsToURL(baseUrl, params) {
5
+ const url = new URL(baseUrl);
6
+ for (const key of Object.keys(params)) {
7
+ url.searchParams.set(key, params[key] + "");
8
+ }
9
+ return url.toString();
10
+ }
11
+ function preconnect(url, rel = "preconnect") {
12
+ const exists = document.querySelector(`link[href="${url}"]`);
13
+ if (!isNull(exists)) return true;
14
+ const link = document.createElement("link");
15
+ link.rel = rel;
16
+ link.href = url;
17
+ link.crossOrigin = "true";
18
+ document.head.append(link);
19
+ return true;
20
+ }
21
+ const pendingRequests = {};
22
+ function loadScript(src) {
23
+ if (pendingRequests[src]) return pendingRequests[src].promise;
24
+ const promise = deferredPromise(), exists = document.querySelector(`script[src="${src}"]`);
25
+ if (!isNull(exists)) {
26
+ promise.resolve();
27
+ return promise.promise;
28
+ }
29
+ pendingRequests[src] = promise;
30
+ const script = document.createElement("script");
31
+ script.src = src;
32
+ script.onload = () => {
33
+ promise.resolve();
34
+ delete pendingRequests[src];
35
+ };
36
+ script.onerror = () => {
37
+ promise.reject();
38
+ delete pendingRequests[src];
39
+ };
40
+ setTimeout(() => document.head.append(script), 0);
41
+ return promise.promise;
42
+ }
43
+ function getRequestCredentials(crossOrigin) {
44
+ return crossOrigin === "use-credentials" ? "include" : isString(crossOrigin) ? "same-origin" : void 0;
45
+ }
46
+ function getDownloadFile({
47
+ title,
48
+ src,
49
+ download
50
+ }) {
51
+ const url = isBoolean(download) || download === "" ? src.src : isString(download) ? download : download?.url;
52
+ if (!isValidFileDownload({ url, src, download })) return null;
53
+ return {
54
+ url,
55
+ name: !isBoolean(download) && !isString(download) && download?.filename || title.toLowerCase() || "media"
56
+ };
57
+ }
58
+ function isValidFileDownload({
59
+ url,
60
+ src,
61
+ download
62
+ }) {
63
+ return isString(url) && (download && download !== true || isAudioSrc(src) || isVideoSrc(src));
64
+ }
65
+
66
+ export { appendParamsToURL, getDownloadFile, getRequestCredentials, loadScript, preconnect };
@@ -0,0 +1,51 @@
1
+ import { defineCustomElement } from '../chunks/vidstack-Bu2kfzUd.js';
2
+ import { MediaPlayButtonElement, MediaMuteButtonElement, MediaCaptionButtonElement, MediaPIPButtonElement, MediaFullscreenButtonElement, MediaSeekButtonElement, MediaAirPlayButtonElement, MediaLiveButtonElement, MediaVolumeSliderElement, MediaTimeSliderElement, MediaSliderPreviewElement, MediaSliderThumbnailElement, MediaSliderValueElement, MediaMenuElement, MediaMenuButtonElement, MediaMenuItemsElement, MediaMenuItemElement, MediaAudioRadioGroupElement, MediaCaptionsRadioGroupElement, MediaSpeedRadioGroupElement, MediaQualityRadioGroupElement, MediaRadioElement, MediaTimeElement, MediaThumbnailElement } from '../chunks/vidstack-Bt8MP2DK.js';
3
+ import { MediaPlyrLayoutElement } from './templates/plyr-layout.js';
4
+ import { MediaPosterElement } from '../chunks/vidstack-DGDvUbvO.js';
5
+ import '../chunks/vidstack-C-ffXlSV.js';
6
+ import '../chunks/vidstack-DFImIcIL.js';
7
+ import '../chunks/vidstack-C_l97D5j.js';
8
+ import '@floating-ui/dom';
9
+ import '../chunks/vidstack-igYn0Apa.js';
10
+ import '../chunks/vidstack-zG6PIeGg.js';
11
+ import '../chunks/vidstack-CjhKISI0.js';
12
+ import '../chunks/vidstack-BGB2pa9s.js';
13
+ import '../chunks/vidstack-CofXIJAy.js';
14
+ import '../chunks/vidstack-Dihypf8P.js';
15
+ import '../chunks/vidstack-DbBJlz7I.js';
16
+ import 'lit-html';
17
+ import '../chunks/vidstack-DO0kqA99.js';
18
+ import '../chunks/vidstack-Bcmx8pmK.js';
19
+ import 'lit-html/directives/if-defined.js';
20
+ import 'lit-html/directives/unsafe-svg.js';
21
+ import 'lit-html/async-directive.js';
22
+ import '../chunks/vidstack-CwTj4H1w.js';
23
+ import 'lit-html/directives/unsafe-html.js';
24
+ import '../chunks/vidstack-rB-wqXw1.js';
25
+
26
+ defineCustomElement(MediaPlyrLayoutElement);
27
+ defineCustomElement(MediaPosterElement);
28
+ defineCustomElement(MediaPlayButtonElement);
29
+ defineCustomElement(MediaMuteButtonElement);
30
+ defineCustomElement(MediaCaptionButtonElement);
31
+ defineCustomElement(MediaPIPButtonElement);
32
+ defineCustomElement(MediaFullscreenButtonElement);
33
+ defineCustomElement(MediaSeekButtonElement);
34
+ defineCustomElement(MediaAirPlayButtonElement);
35
+ defineCustomElement(MediaLiveButtonElement);
36
+ defineCustomElement(MediaVolumeSliderElement);
37
+ defineCustomElement(MediaTimeSliderElement);
38
+ defineCustomElement(MediaSliderPreviewElement);
39
+ defineCustomElement(MediaSliderThumbnailElement);
40
+ defineCustomElement(MediaSliderValueElement);
41
+ defineCustomElement(MediaMenuElement);
42
+ defineCustomElement(MediaMenuButtonElement);
43
+ defineCustomElement(MediaMenuItemsElement);
44
+ defineCustomElement(MediaMenuItemElement);
45
+ defineCustomElement(MediaAudioRadioGroupElement);
46
+ defineCustomElement(MediaCaptionsRadioGroupElement);
47
+ defineCustomElement(MediaSpeedRadioGroupElement);
48
+ defineCustomElement(MediaQualityRadioGroupElement);
49
+ defineCustomElement(MediaRadioElement);
50
+ defineCustomElement(MediaTimeElement);
51
+ defineCustomElement(MediaThumbnailElement);