@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,554 @@
1
+ import { createScope, signal, effect, peek, isString, deferredPromise, listenEvent, isArray } from '../chunks/vidstack-Bu2kfzUd.js';
2
+ import { QualitySymbol } from '../chunks/vidstack-Bpr4fI4n.js';
3
+ import { TimeRange } from '../chunks/vidstack-BFg1ZqiG.js';
4
+ import { TextTrack } from '../chunks/vidstack-igYn0Apa.js';
5
+ import { ListSymbol } from '../chunks/vidstack-Dv_LIPFu.js';
6
+ import { RAFLoop } from '../chunks/vidstack-qh1N5_f_.js';
7
+ import { preconnect } from '../chunks/vidstack-zG6PIeGg.js';
8
+ import { EmbedProvider } from '../chunks/vidstack-BoAGnlRt.js';
9
+ import { resolveVimeoVideoId, getVimeoVideoInfo } from '../chunks/vidstack-krOAtKMi.js';
10
+ import '../chunks/vidstack-BGB2pa9s.js';
11
+ import '../chunks/vidstack-CjhKISI0.js';
12
+
13
+ const trackedVimeoEvents = [
14
+ "bufferend",
15
+ "bufferstart",
16
+ // 'cuechange',
17
+ "durationchange",
18
+ "ended",
19
+ "enterpictureinpicture",
20
+ "error",
21
+ "fullscreenchange",
22
+ "leavepictureinpicture",
23
+ "loaded",
24
+ // 'loadeddata',
25
+ // 'loadedmetadata',
26
+ // 'loadstart',
27
+ "playProgress",
28
+ "loadProgress",
29
+ "pause",
30
+ "play",
31
+ "playbackratechange",
32
+ // 'progress',
33
+ "qualitychange",
34
+ "seeked",
35
+ "seeking",
36
+ // 'texttrackchange',
37
+ "timeupdate",
38
+ "volumechange",
39
+ "waiting"
40
+ // 'adstarted',
41
+ // 'adcompleted',
42
+ // 'aderror',
43
+ // 'adskipped',
44
+ // 'adallcompleted',
45
+ // 'adclicked',
46
+ // 'chapterchange',
47
+ // 'chromecastconnected',
48
+ // 'remoteplaybackavailabilitychange',
49
+ // 'remoteplaybackconnecting',
50
+ // 'remoteplaybackconnect',
51
+ // 'remoteplaybackdisconnect',
52
+ // 'liveeventended',
53
+ // 'liveeventstarted',
54
+ // 'livestreamoffline',
55
+ // 'livestreamonline',
56
+ ];
57
+
58
+ class VimeoProvider extends EmbedProvider {
59
+ $$PROVIDER_TYPE = "VIMEO";
60
+ scope = createScope();
61
+ fullscreen;
62
+ #ctx;
63
+ #videoId = signal("");
64
+ #pro = signal(false);
65
+ #hash = null;
66
+ #currentSrc = null;
67
+ #fullscreenActive = false;
68
+ #seekableRange = new TimeRange(0, 0);
69
+ #timeRAF = new RAFLoop(this.#onAnimationFrame.bind(this));
70
+ #currentCue = null;
71
+ #chaptersTrack = null;
72
+ #promises = /* @__PURE__ */ new Map();
73
+ #videoInfoPromise = null;
74
+ constructor(iframe, ctx) {
75
+ super(iframe);
76
+ this.#ctx = ctx;
77
+ const self = this;
78
+ this.fullscreen = {
79
+ get active() {
80
+ return self.#fullscreenActive;
81
+ },
82
+ supported: true,
83
+ enter: () => this.#remote("requestFullscreen"),
84
+ exit: () => this.#remote("exitFullscreen")
85
+ };
86
+ }
87
+ /**
88
+ * Whether tracking session data should be enabled on the embed, including cookies and analytics.
89
+ * This is turned off by default to be GDPR-compliant.
90
+ *
91
+ * @defaultValue `false`
92
+ */
93
+ cookies = false;
94
+ title = true;
95
+ byline = true;
96
+ portrait = true;
97
+ color = "00ADEF";
98
+ get type() {
99
+ return "vimeo";
100
+ }
101
+ get currentSrc() {
102
+ return this.#currentSrc;
103
+ }
104
+ get videoId() {
105
+ return this.#videoId();
106
+ }
107
+ get hash() {
108
+ return this.#hash;
109
+ }
110
+ get isPro() {
111
+ return this.#pro();
112
+ }
113
+ preconnect() {
114
+ preconnect(this.getOrigin());
115
+ }
116
+ setup() {
117
+ super.setup();
118
+ effect(this.#watchVideoId.bind(this));
119
+ effect(this.#watchVideoInfo.bind(this));
120
+ effect(this.#watchPro.bind(this));
121
+ this.#ctx.notify("provider-setup", this);
122
+ }
123
+ destroy() {
124
+ this.#reset();
125
+ this.fullscreen = void 0;
126
+ const message = "provider destroyed";
127
+ for (const promises of this.#promises.values()) {
128
+ for (const { reject } of promises) reject(message);
129
+ }
130
+ this.#promises.clear();
131
+ this.#remote("destroy");
132
+ }
133
+ async play() {
134
+ return this.#remote("play");
135
+ }
136
+ async pause() {
137
+ return this.#remote("pause");
138
+ }
139
+ setMuted(muted) {
140
+ this.#remote("setMuted", muted);
141
+ }
142
+ setCurrentTime(time) {
143
+ this.#remote("seekTo", time);
144
+ this.#ctx.notify("seeking", time);
145
+ }
146
+ setVolume(volume) {
147
+ this.#remote("setVolume", volume);
148
+ this.#remote("setMuted", peek(this.#ctx.$state.muted));
149
+ }
150
+ setPlaybackRate(rate) {
151
+ this.#remote("setPlaybackRate", rate);
152
+ }
153
+ async loadSource(src) {
154
+ if (!isString(src.src)) {
155
+ this.#currentSrc = null;
156
+ this.#hash = null;
157
+ this.#videoId.set("");
158
+ return;
159
+ }
160
+ const { videoId, hash } = resolveVimeoVideoId(src.src);
161
+ this.#videoId.set(videoId ?? "");
162
+ this.#hash = hash ?? null;
163
+ this.#currentSrc = src;
164
+ }
165
+ #watchVideoId() {
166
+ this.#reset();
167
+ const videoId = this.#videoId();
168
+ if (!videoId) {
169
+ this.src.set("");
170
+ return;
171
+ }
172
+ this.src.set(`${this.getOrigin()}/video/${videoId}`);
173
+ this.#ctx.notify("load-start");
174
+ }
175
+ #watchVideoInfo() {
176
+ const videoId = this.#videoId();
177
+ if (!videoId) return;
178
+ const promise = deferredPromise(), abort = new AbortController();
179
+ this.#videoInfoPromise = promise;
180
+ getVimeoVideoInfo(videoId, abort, this.#hash).then((info) => {
181
+ promise.resolve(info);
182
+ }).catch((e) => {
183
+ promise.reject();
184
+ {
185
+ this.#ctx.logger?.warnGroup(`Failed to fetch vimeo video info for id \`${videoId}\`.`).labelledLog("Error", e).dispatch();
186
+ }
187
+ });
188
+ return () => {
189
+ promise.reject();
190
+ abort.abort();
191
+ };
192
+ }
193
+ #watchPro() {
194
+ const isPro = this.#pro(), { $state, qualities } = this.#ctx;
195
+ $state.canSetPlaybackRate.set(isPro);
196
+ qualities[ListSymbol.setReadonly](!isPro);
197
+ if (isPro) {
198
+ return listenEvent(qualities, "change", () => {
199
+ if (qualities.auto) return;
200
+ const id = qualities.selected?.id;
201
+ if (id) this.#remote("setQuality", id);
202
+ });
203
+ }
204
+ }
205
+ getOrigin() {
206
+ return "https://player.vimeo.com";
207
+ }
208
+ buildParams() {
209
+ const { keyDisabled } = this.#ctx.$props, { playsInline, nativeControls } = this.#ctx.$state, showControls = nativeControls();
210
+ return {
211
+ title: this.title,
212
+ byline: this.byline,
213
+ color: this.color,
214
+ portrait: this.portrait,
215
+ controls: showControls,
216
+ h: this.hash,
217
+ keyboard: showControls && !keyDisabled(),
218
+ transparent: true,
219
+ playsinline: playsInline(),
220
+ dnt: !this.cookies
221
+ };
222
+ }
223
+ #onAnimationFrame() {
224
+ this.#remote("getCurrentTime");
225
+ }
226
+ // Embed will sometimes dispatch 0 at end of playback.
227
+ #preventTimeUpdates = false;
228
+ #onTimeUpdate(time, trigger) {
229
+ if (this.#preventTimeUpdates && time === 0) return;
230
+ const { realCurrentTime, paused, bufferedEnd, seekableEnd, live } = this.#ctx.$state;
231
+ if (realCurrentTime() === time) return;
232
+ const prevTime = realCurrentTime();
233
+ this.#ctx.notify("time-change", time, trigger);
234
+ if (Math.abs(prevTime - time) > 1.5) {
235
+ this.#ctx.notify("seeking", time, trigger);
236
+ if (!paused() && bufferedEnd() < time) {
237
+ this.#ctx.notify("waiting", void 0, trigger);
238
+ }
239
+ }
240
+ if (!live() && seekableEnd() - time < 0.01) {
241
+ this.#ctx.notify("end", void 0, trigger);
242
+ this.#preventTimeUpdates = true;
243
+ setTimeout(() => {
244
+ this.#preventTimeUpdates = false;
245
+ }, 500);
246
+ }
247
+ }
248
+ #onSeeked(time, trigger) {
249
+ this.#ctx.notify("seeked", time, trigger);
250
+ }
251
+ #onLoaded(trigger) {
252
+ const videoId = this.#videoId();
253
+ this.#videoInfoPromise?.promise.then((info) => {
254
+ if (!info) return;
255
+ const { title, poster, duration, pro } = info;
256
+ this.#pro.set(pro);
257
+ this.#ctx.notify("title-change", title, trigger);
258
+ this.#ctx.notify("poster-change", poster, trigger);
259
+ this.#ctx.notify("duration-change", duration, trigger);
260
+ this.#onReady(duration, trigger);
261
+ }).catch(() => {
262
+ if (videoId !== this.#videoId()) return;
263
+ this.#remote("getVideoTitle");
264
+ this.#remote("getDuration");
265
+ });
266
+ }
267
+ #onReady(duration, trigger) {
268
+ const { nativeControls } = this.#ctx.$state, showEmbedControls = nativeControls();
269
+ this.#seekableRange = new TimeRange(0, duration);
270
+ const detail = {
271
+ buffered: new TimeRange(0, 0),
272
+ seekable: this.#seekableRange,
273
+ duration
274
+ };
275
+ this.#ctx.delegate.ready(detail, trigger);
276
+ if (!showEmbedControls) {
277
+ this.#remote("_hideOverlay");
278
+ }
279
+ this.#remote("getQualities");
280
+ this.#remote("getChapters");
281
+ }
282
+ #onMethod(method, data, trigger) {
283
+ switch (method) {
284
+ case "getVideoTitle":
285
+ const videoTitle = data;
286
+ this.#ctx.notify("title-change", videoTitle, trigger);
287
+ break;
288
+ case "getDuration":
289
+ const duration = data;
290
+ if (!this.#ctx.$state.canPlay()) {
291
+ this.#onReady(duration, trigger);
292
+ } else {
293
+ this.#ctx.notify("duration-change", duration, trigger);
294
+ }
295
+ break;
296
+ case "getCurrentTime":
297
+ this.#onTimeUpdate(data, trigger);
298
+ break;
299
+ case "getBuffered":
300
+ if (isArray(data) && data.length) {
301
+ this.#onLoadProgress(data[data.length - 1][1], trigger);
302
+ }
303
+ break;
304
+ case "setMuted":
305
+ case "getMuted":
306
+ this.#onVolumeChange(peek(this.#ctx.$state.volume), data, trigger);
307
+ break;
308
+ // case 'getTextTracks':
309
+ // this.#onTextTracksChange(data as VimeoTextTrack[], trigger);
310
+ // break;
311
+ case "getChapters":
312
+ this.#onChaptersChange(data);
313
+ break;
314
+ case "getQualities":
315
+ this.#onQualitiesChange(data, trigger);
316
+ break;
317
+ }
318
+ this.#getPromise(method)?.resolve();
319
+ }
320
+ #attachListeners() {
321
+ for (const type of trackedVimeoEvents) {
322
+ this.#remote("addEventListener", type);
323
+ }
324
+ }
325
+ #onPause(trigger) {
326
+ this.#timeRAF.stop();
327
+ this.#ctx.notify("pause", void 0, trigger);
328
+ }
329
+ async #onPlay(trigger) {
330
+ this.#timeRAF.start();
331
+ await this.#remote("getMuted");
332
+ this.#ctx.notify("play", void 0, trigger);
333
+ }
334
+ #onPlayProgress(trigger) {
335
+ const { paused } = this.#ctx.$state;
336
+ if (!paused() && !this.#preventTimeUpdates) {
337
+ this.#ctx.notify("playing", void 0, trigger);
338
+ }
339
+ }
340
+ #onLoadProgress(buffered, trigger) {
341
+ const detail = {
342
+ buffered: new TimeRange(0, buffered),
343
+ seekable: this.#seekableRange
344
+ };
345
+ this.#ctx.notify("progress", detail, trigger);
346
+ }
347
+ #onBufferStart(trigger) {
348
+ this.#ctx.notify("waiting", void 0, trigger);
349
+ }
350
+ #onBufferEnd(trigger) {
351
+ const { paused } = this.#ctx.$state;
352
+ if (!paused()) this.#ctx.notify("playing", void 0, trigger);
353
+ }
354
+ async #onWaiting(trigger) {
355
+ const { paused } = this.#ctx.$state;
356
+ if (paused()) {
357
+ await this.#remote("getMuted");
358
+ this.#ctx.notify("play", void 0, trigger);
359
+ }
360
+ this.#ctx.notify("waiting", void 0, trigger);
361
+ }
362
+ #onVolumeChange(volume, muted, trigger) {
363
+ const detail = { volume, muted };
364
+ this.#ctx.notify("volume-change", detail, trigger);
365
+ }
366
+ // #onTextTrackChange(track: VimeoTextTrack, trigger: Event) {
367
+ // const textTrack = this.#ctx.textTracks.toArray().find((t) => t.language === track.language);
368
+ // if (textTrack) textTrack.mode = track.mode;
369
+ // }
370
+ // #onTextTracksChange(tracks: VimeoTextTrack[], trigger: Event) {
371
+ // for (const init of tracks) {
372
+ // const textTrack = new TextTrack({
373
+ // ...init,
374
+ // label: init.label.replace('auto-generated', 'auto'),
375
+ // });
376
+ // textTrack[TextTrackSymbol.readyState] = 2;
377
+ // this.#ctx.textTracks.add(textTrack, trigger);
378
+ // textTrack.setMode(init.mode, trigger);
379
+ // }
380
+ // }
381
+ // #onCueChange(cue: VimeoTextCue, trigger: Event) {
382
+ // const { textTracks, $state } = this.#ctx,
383
+ // { currentTime } = $state,
384
+ // track = textTracks.selected;
385
+ // if (this.#currentCue) track?.removeCue(this.#currentCue, trigger);
386
+ // this.#currentCue = new window.VTTCue(currentTime(), Number.MAX_SAFE_INTEGER, cue.text);
387
+ // track?.addCue(this.#currentCue, trigger);
388
+ // }
389
+ #onChaptersChange(chapters) {
390
+ this.#removeChapters();
391
+ if (!chapters.length) return;
392
+ const track = new TextTrack({
393
+ kind: "chapters",
394
+ default: true
395
+ }), { seekableEnd } = this.#ctx.$state;
396
+ for (let i = 0; i < chapters.length; i++) {
397
+ const chapter = chapters[i], nextChapter = chapters[i + 1];
398
+ track.addCue(
399
+ new window.VTTCue(
400
+ chapter.startTime,
401
+ nextChapter?.startTime ?? seekableEnd(),
402
+ chapter.title
403
+ )
404
+ );
405
+ }
406
+ this.#chaptersTrack = track;
407
+ this.#ctx.textTracks.add(track);
408
+ }
409
+ #removeChapters() {
410
+ if (!this.#chaptersTrack) return;
411
+ this.#ctx.textTracks.remove(this.#chaptersTrack);
412
+ this.#chaptersTrack = null;
413
+ }
414
+ #onQualitiesChange(qualities, trigger) {
415
+ this.#ctx.qualities[QualitySymbol.enableAuto] = qualities.some((q) => q.id === "auto") ? () => this.#remote("setQuality", "auto") : void 0;
416
+ for (const quality of qualities) {
417
+ if (quality.id === "auto") continue;
418
+ const height = +quality.id.slice(0, -1);
419
+ if (isNaN(height)) continue;
420
+ this.#ctx.qualities[ListSymbol.add](
421
+ {
422
+ id: quality.id,
423
+ width: height * (16 / 9),
424
+ height,
425
+ codec: "avc1,h.264",
426
+ bitrate: -1
427
+ },
428
+ trigger
429
+ );
430
+ }
431
+ this.#onQualityChange(
432
+ qualities.find((q) => q.active),
433
+ trigger
434
+ );
435
+ }
436
+ #onQualityChange({ id } = {}, trigger) {
437
+ if (!id) return;
438
+ const isAuto = id === "auto", newQuality = this.#ctx.qualities.getById(id);
439
+ if (isAuto) {
440
+ this.#ctx.qualities[QualitySymbol.setAuto](isAuto, trigger);
441
+ this.#ctx.qualities[ListSymbol.select](void 0, true, trigger);
442
+ } else {
443
+ this.#ctx.qualities[ListSymbol.select](newQuality ?? void 0, true, trigger);
444
+ }
445
+ }
446
+ #onEvent(event, payload, trigger) {
447
+ switch (event) {
448
+ case "ready":
449
+ this.#attachListeners();
450
+ break;
451
+ case "loaded":
452
+ this.#onLoaded(trigger);
453
+ break;
454
+ case "play":
455
+ this.#onPlay(trigger);
456
+ break;
457
+ case "playProgress":
458
+ this.#onPlayProgress(trigger);
459
+ break;
460
+ case "pause":
461
+ this.#onPause(trigger);
462
+ break;
463
+ case "loadProgress":
464
+ this.#onLoadProgress(payload.seconds, trigger);
465
+ break;
466
+ case "waiting":
467
+ this.#onWaiting(trigger);
468
+ break;
469
+ case "bufferstart":
470
+ this.#onBufferStart(trigger);
471
+ break;
472
+ case "bufferend":
473
+ this.#onBufferEnd(trigger);
474
+ break;
475
+ case "volumechange":
476
+ this.#onVolumeChange(payload.volume, peek(this.#ctx.$state.muted), trigger);
477
+ break;
478
+ case "durationchange":
479
+ this.#seekableRange = new TimeRange(0, payload.duration);
480
+ this.#ctx.notify("duration-change", payload.duration, trigger);
481
+ break;
482
+ case "playbackratechange":
483
+ this.#ctx.notify("rate-change", payload.playbackRate, trigger);
484
+ break;
485
+ case "qualitychange":
486
+ this.#onQualityChange(payload, trigger);
487
+ break;
488
+ case "fullscreenchange":
489
+ this.#fullscreenActive = payload.fullscreen;
490
+ this.#ctx.notify("fullscreen-change", payload.fullscreen, trigger);
491
+ break;
492
+ case "enterpictureinpicture":
493
+ this.#ctx.notify("picture-in-picture-change", true, trigger);
494
+ break;
495
+ case "leavepictureinpicture":
496
+ this.#ctx.notify("picture-in-picture-change", false, trigger);
497
+ break;
498
+ case "ended":
499
+ this.#ctx.notify("end", void 0, trigger);
500
+ break;
501
+ case "error":
502
+ this.#onError(payload, trigger);
503
+ break;
504
+ case "seek":
505
+ case "seeked":
506
+ this.#onSeeked(payload.seconds, trigger);
507
+ break;
508
+ }
509
+ }
510
+ #onError(error, trigger) {
511
+ const { message, method } = error;
512
+ if (method === "setPlaybackRate") {
513
+ this.#pro.set(false);
514
+ }
515
+ if (method) {
516
+ this.#getPromise(method)?.reject(message);
517
+ }
518
+ {
519
+ this.#ctx.logger?.errorGroup(`[vimeo]: ${message}`).labelledLog("Error", error).labelledLog("Provider", this).labelledLog("Event", trigger).dispatch();
520
+ }
521
+ }
522
+ onMessage(message, event) {
523
+ if (message.event) {
524
+ this.#onEvent(message.event, message.data, event);
525
+ } else if (message.method) {
526
+ this.#onMethod(message.method, message.value, event);
527
+ }
528
+ }
529
+ onLoad() {
530
+ }
531
+ async #remote(command, arg) {
532
+ let promise = deferredPromise(), promises = this.#promises.get(command);
533
+ if (!promises) this.#promises.set(command, promises = []);
534
+ promises.push(promise);
535
+ this.postMessage({
536
+ method: command,
537
+ value: arg
538
+ });
539
+ return promise.promise;
540
+ }
541
+ #reset() {
542
+ this.#timeRAF.stop();
543
+ this.#seekableRange = new TimeRange(0, 0);
544
+ this.#videoInfoPromise = null;
545
+ this.#currentCue = null;
546
+ this.#pro.set(false);
547
+ this.#removeChapters();
548
+ }
549
+ #getPromise(command) {
550
+ return this.#promises.get(command)?.shift();
551
+ }
552
+ }
553
+
554
+ export { VimeoProvider };