@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,548 @@
1
+ import { createScope, signal, effect, peek, isString, deferredPromise, listenEvent, isArray } from '../chunks/vidstack-BGSTndAW.js';
2
+ import { QualitySymbol } from '../chunks/vidstack-B01xzxC4.js';
3
+ import { TimeRange } from '../chunks/vidstack-ChQTHmIQ.js';
4
+ import { TextTrack } from '../chunks/vidstack-Cm6_unwd.js';
5
+ import { ListSymbol } from '../chunks/vidstack-D5EzK014.js';
6
+ import { RAFLoop } from '../chunks/vidstack-DqAw8m9J.js';
7
+ import { preconnect } from '../chunks/vidstack-CTojmhKq.js';
8
+ import { EmbedProvider } from '../chunks/vidstack-DDXt6fpN.js';
9
+ import { resolveVimeoVideoId, getVimeoVideoInfo } from '../chunks/vidstack-krOAtKMi.js';
10
+ import '../chunks/vidstack-nLyr4NEP.js';
11
+ import '../chunks/vidstack-xMS8dnYq.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
+ return () => {
186
+ promise.reject();
187
+ abort.abort();
188
+ };
189
+ }
190
+ #watchPro() {
191
+ const isPro = this.#pro(), { $state, qualities } = this.#ctx;
192
+ $state.canSetPlaybackRate.set(isPro);
193
+ qualities[ListSymbol.setReadonly](!isPro);
194
+ if (isPro) {
195
+ return listenEvent(qualities, "change", () => {
196
+ if (qualities.auto) return;
197
+ const id = qualities.selected?.id;
198
+ if (id) this.#remote("setQuality", id);
199
+ });
200
+ }
201
+ }
202
+ getOrigin() {
203
+ return "https://player.vimeo.com";
204
+ }
205
+ buildParams() {
206
+ const { keyDisabled } = this.#ctx.$props, { playsInline, nativeControls } = this.#ctx.$state, showControls = nativeControls();
207
+ return {
208
+ title: this.title,
209
+ byline: this.byline,
210
+ color: this.color,
211
+ portrait: this.portrait,
212
+ controls: showControls,
213
+ h: this.hash,
214
+ keyboard: showControls && !keyDisabled(),
215
+ transparent: true,
216
+ playsinline: playsInline(),
217
+ dnt: !this.cookies
218
+ };
219
+ }
220
+ #onAnimationFrame() {
221
+ this.#remote("getCurrentTime");
222
+ }
223
+ // Embed will sometimes dispatch 0 at end of playback.
224
+ #preventTimeUpdates = false;
225
+ #onTimeUpdate(time, trigger) {
226
+ if (this.#preventTimeUpdates && time === 0) return;
227
+ const { realCurrentTime, paused, bufferedEnd, seekableEnd, live } = this.#ctx.$state;
228
+ if (realCurrentTime() === time) return;
229
+ const prevTime = realCurrentTime();
230
+ this.#ctx.notify("time-change", time, trigger);
231
+ if (Math.abs(prevTime - time) > 1.5) {
232
+ this.#ctx.notify("seeking", time, trigger);
233
+ if (!paused() && bufferedEnd() < time) {
234
+ this.#ctx.notify("waiting", void 0, trigger);
235
+ }
236
+ }
237
+ if (!live() && seekableEnd() - time < 0.01) {
238
+ this.#ctx.notify("end", void 0, trigger);
239
+ this.#preventTimeUpdates = true;
240
+ setTimeout(() => {
241
+ this.#preventTimeUpdates = false;
242
+ }, 500);
243
+ }
244
+ }
245
+ #onSeeked(time, trigger) {
246
+ this.#ctx.notify("seeked", time, trigger);
247
+ }
248
+ #onLoaded(trigger) {
249
+ const videoId = this.#videoId();
250
+ this.#videoInfoPromise?.promise.then((info) => {
251
+ if (!info) return;
252
+ const { title, poster, duration, pro } = info;
253
+ this.#pro.set(pro);
254
+ this.#ctx.notify("title-change", title, trigger);
255
+ this.#ctx.notify("poster-change", poster, trigger);
256
+ this.#ctx.notify("duration-change", duration, trigger);
257
+ this.#onReady(duration, trigger);
258
+ }).catch(() => {
259
+ if (videoId !== this.#videoId()) return;
260
+ this.#remote("getVideoTitle");
261
+ this.#remote("getDuration");
262
+ });
263
+ }
264
+ #onReady(duration, trigger) {
265
+ const { nativeControls } = this.#ctx.$state, showEmbedControls = nativeControls();
266
+ this.#seekableRange = new TimeRange(0, duration);
267
+ const detail = {
268
+ buffered: new TimeRange(0, 0),
269
+ seekable: this.#seekableRange,
270
+ duration
271
+ };
272
+ this.#ctx.delegate.ready(detail, trigger);
273
+ if (!showEmbedControls) {
274
+ this.#remote("_hideOverlay");
275
+ }
276
+ this.#remote("getQualities");
277
+ this.#remote("getChapters");
278
+ }
279
+ #onMethod(method, data, trigger) {
280
+ switch (method) {
281
+ case "getVideoTitle":
282
+ const videoTitle = data;
283
+ this.#ctx.notify("title-change", videoTitle, trigger);
284
+ break;
285
+ case "getDuration":
286
+ const duration = data;
287
+ if (!this.#ctx.$state.canPlay()) {
288
+ this.#onReady(duration, trigger);
289
+ } else {
290
+ this.#ctx.notify("duration-change", duration, trigger);
291
+ }
292
+ break;
293
+ case "getCurrentTime":
294
+ this.#onTimeUpdate(data, trigger);
295
+ break;
296
+ case "getBuffered":
297
+ if (isArray(data) && data.length) {
298
+ this.#onLoadProgress(data[data.length - 1][1], trigger);
299
+ }
300
+ break;
301
+ case "setMuted":
302
+ case "getMuted":
303
+ this.#onVolumeChange(peek(this.#ctx.$state.volume), data, trigger);
304
+ break;
305
+ // case 'getTextTracks':
306
+ // this.#onTextTracksChange(data as VimeoTextTrack[], trigger);
307
+ // break;
308
+ case "getChapters":
309
+ this.#onChaptersChange(data);
310
+ break;
311
+ case "getQualities":
312
+ this.#onQualitiesChange(data, trigger);
313
+ break;
314
+ }
315
+ this.#getPromise(method)?.resolve();
316
+ }
317
+ #attachListeners() {
318
+ for (const type of trackedVimeoEvents) {
319
+ this.#remote("addEventListener", type);
320
+ }
321
+ }
322
+ #onPause(trigger) {
323
+ this.#timeRAF.stop();
324
+ this.#ctx.notify("pause", void 0, trigger);
325
+ }
326
+ async #onPlay(trigger) {
327
+ this.#timeRAF.start();
328
+ await this.#remote("getMuted");
329
+ this.#ctx.notify("play", void 0, trigger);
330
+ }
331
+ #onPlayProgress(trigger) {
332
+ const { paused } = this.#ctx.$state;
333
+ if (!paused() && !this.#preventTimeUpdates) {
334
+ this.#ctx.notify("playing", void 0, trigger);
335
+ }
336
+ }
337
+ #onLoadProgress(buffered, trigger) {
338
+ const detail = {
339
+ buffered: new TimeRange(0, buffered),
340
+ seekable: this.#seekableRange
341
+ };
342
+ this.#ctx.notify("progress", detail, trigger);
343
+ }
344
+ #onBufferStart(trigger) {
345
+ this.#ctx.notify("waiting", void 0, trigger);
346
+ }
347
+ #onBufferEnd(trigger) {
348
+ const { paused } = this.#ctx.$state;
349
+ if (!paused()) this.#ctx.notify("playing", void 0, trigger);
350
+ }
351
+ async #onWaiting(trigger) {
352
+ const { paused } = this.#ctx.$state;
353
+ if (paused()) {
354
+ await this.#remote("getMuted");
355
+ this.#ctx.notify("play", void 0, trigger);
356
+ }
357
+ this.#ctx.notify("waiting", void 0, trigger);
358
+ }
359
+ #onVolumeChange(volume, muted, trigger) {
360
+ const detail = { volume, muted };
361
+ this.#ctx.notify("volume-change", detail, trigger);
362
+ }
363
+ // #onTextTrackChange(track: VimeoTextTrack, trigger: Event) {
364
+ // const textTrack = this.#ctx.textTracks.toArray().find((t) => t.language === track.language);
365
+ // if (textTrack) textTrack.mode = track.mode;
366
+ // }
367
+ // #onTextTracksChange(tracks: VimeoTextTrack[], trigger: Event) {
368
+ // for (const init of tracks) {
369
+ // const textTrack = new TextTrack({
370
+ // ...init,
371
+ // label: init.label.replace('auto-generated', 'auto'),
372
+ // });
373
+ // textTrack[TextTrackSymbol.readyState] = 2;
374
+ // this.#ctx.textTracks.add(textTrack, trigger);
375
+ // textTrack.setMode(init.mode, trigger);
376
+ // }
377
+ // }
378
+ // #onCueChange(cue: VimeoTextCue, trigger: Event) {
379
+ // const { textTracks, $state } = this.#ctx,
380
+ // { currentTime } = $state,
381
+ // track = textTracks.selected;
382
+ // if (this.#currentCue) track?.removeCue(this.#currentCue, trigger);
383
+ // this.#currentCue = new window.VTTCue(currentTime(), Number.MAX_SAFE_INTEGER, cue.text);
384
+ // track?.addCue(this.#currentCue, trigger);
385
+ // }
386
+ #onChaptersChange(chapters) {
387
+ this.#removeChapters();
388
+ if (!chapters.length) return;
389
+ const track = new TextTrack({
390
+ kind: "chapters",
391
+ default: true
392
+ }), { seekableEnd } = this.#ctx.$state;
393
+ for (let i = 0; i < chapters.length; i++) {
394
+ const chapter = chapters[i], nextChapter = chapters[i + 1];
395
+ track.addCue(
396
+ new window.VTTCue(
397
+ chapter.startTime,
398
+ nextChapter?.startTime ?? seekableEnd(),
399
+ chapter.title
400
+ )
401
+ );
402
+ }
403
+ this.#chaptersTrack = track;
404
+ this.#ctx.textTracks.add(track);
405
+ }
406
+ #removeChapters() {
407
+ if (!this.#chaptersTrack) return;
408
+ this.#ctx.textTracks.remove(this.#chaptersTrack);
409
+ this.#chaptersTrack = null;
410
+ }
411
+ #onQualitiesChange(qualities, trigger) {
412
+ this.#ctx.qualities[QualitySymbol.enableAuto] = qualities.some((q) => q.id === "auto") ? () => this.#remote("setQuality", "auto") : void 0;
413
+ for (const quality of qualities) {
414
+ if (quality.id === "auto") continue;
415
+ const height = +quality.id.slice(0, -1);
416
+ if (isNaN(height)) continue;
417
+ this.#ctx.qualities[ListSymbol.add](
418
+ {
419
+ id: quality.id,
420
+ width: height * (16 / 9),
421
+ height,
422
+ codec: "avc1,h.264",
423
+ bitrate: -1
424
+ },
425
+ trigger
426
+ );
427
+ }
428
+ this.#onQualityChange(
429
+ qualities.find((q) => q.active),
430
+ trigger
431
+ );
432
+ }
433
+ #onQualityChange({ id } = {}, trigger) {
434
+ if (!id) return;
435
+ const isAuto = id === "auto", newQuality = this.#ctx.qualities.getById(id);
436
+ if (isAuto) {
437
+ this.#ctx.qualities[QualitySymbol.setAuto](isAuto, trigger);
438
+ this.#ctx.qualities[ListSymbol.select](void 0, true, trigger);
439
+ } else {
440
+ this.#ctx.qualities[ListSymbol.select](newQuality ?? void 0, true, trigger);
441
+ }
442
+ }
443
+ #onEvent(event, payload, trigger) {
444
+ switch (event) {
445
+ case "ready":
446
+ this.#attachListeners();
447
+ break;
448
+ case "loaded":
449
+ this.#onLoaded(trigger);
450
+ break;
451
+ case "play":
452
+ this.#onPlay(trigger);
453
+ break;
454
+ case "playProgress":
455
+ this.#onPlayProgress(trigger);
456
+ break;
457
+ case "pause":
458
+ this.#onPause(trigger);
459
+ break;
460
+ case "loadProgress":
461
+ this.#onLoadProgress(payload.seconds, trigger);
462
+ break;
463
+ case "waiting":
464
+ this.#onWaiting(trigger);
465
+ break;
466
+ case "bufferstart":
467
+ this.#onBufferStart(trigger);
468
+ break;
469
+ case "bufferend":
470
+ this.#onBufferEnd(trigger);
471
+ break;
472
+ case "volumechange":
473
+ this.#onVolumeChange(payload.volume, peek(this.#ctx.$state.muted), trigger);
474
+ break;
475
+ case "durationchange":
476
+ this.#seekableRange = new TimeRange(0, payload.duration);
477
+ this.#ctx.notify("duration-change", payload.duration, trigger);
478
+ break;
479
+ case "playbackratechange":
480
+ this.#ctx.notify("rate-change", payload.playbackRate, trigger);
481
+ break;
482
+ case "qualitychange":
483
+ this.#onQualityChange(payload, trigger);
484
+ break;
485
+ case "fullscreenchange":
486
+ this.#fullscreenActive = payload.fullscreen;
487
+ this.#ctx.notify("fullscreen-change", payload.fullscreen, trigger);
488
+ break;
489
+ case "enterpictureinpicture":
490
+ this.#ctx.notify("picture-in-picture-change", true, trigger);
491
+ break;
492
+ case "leavepictureinpicture":
493
+ this.#ctx.notify("picture-in-picture-change", false, trigger);
494
+ break;
495
+ case "ended":
496
+ this.#ctx.notify("end", void 0, trigger);
497
+ break;
498
+ case "error":
499
+ this.#onError(payload, trigger);
500
+ break;
501
+ case "seek":
502
+ case "seeked":
503
+ this.#onSeeked(payload.seconds, trigger);
504
+ break;
505
+ }
506
+ }
507
+ #onError(error, trigger) {
508
+ const { message, method } = error;
509
+ if (method === "setPlaybackRate") {
510
+ this.#pro.set(false);
511
+ }
512
+ if (method) {
513
+ this.#getPromise(method)?.reject(message);
514
+ }
515
+ }
516
+ onMessage(message, event) {
517
+ if (message.event) {
518
+ this.#onEvent(message.event, message.data, event);
519
+ } else if (message.method) {
520
+ this.#onMethod(message.method, message.value, event);
521
+ }
522
+ }
523
+ onLoad() {
524
+ }
525
+ async #remote(command, arg) {
526
+ let promise = deferredPromise(), promises = this.#promises.get(command);
527
+ if (!promises) this.#promises.set(command, promises = []);
528
+ promises.push(promise);
529
+ this.postMessage({
530
+ method: command,
531
+ value: arg
532
+ });
533
+ return promise.promise;
534
+ }
535
+ #reset() {
536
+ this.#timeRAF.stop();
537
+ this.#seekableRange = new TimeRange(0, 0);
538
+ this.#videoInfoPromise = null;
539
+ this.#currentCue = null;
540
+ this.#pro.set(false);
541
+ this.#removeChapters();
542
+ }
543
+ #getPromise(command) {
544
+ return this.#promises.get(command)?.shift();
545
+ }
546
+ }
547
+
548
+ export { VimeoProvider };