@hanifhan1f/vidstack 1.12.25 → 1.12.27

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 (92) hide show
  1. package/cdn/chunks/vidstack-8JHLDxl5.js +1 -0
  2. package/cdn/chunks/vidstack-Bpnl-N6k.js +1 -0
  3. package/cdn/chunks/vidstack-CnWKPIKT.js +16 -0
  4. package/cdn/chunks/vidstack-CqzAnF2W.js +16 -0
  5. package/cdn/vidstack.js +1 -1
  6. package/cdn/with-layouts/chunks/vidstack-BD5YoTt5.js +937 -0
  7. package/cdn/with-layouts/chunks/vidstack-DCaNJN4T.js +1 -0
  8. package/cdn/with-layouts/chunks/vidstack-Dd3L-eQj.js +1 -0
  9. package/cdn/with-layouts/chunks/vidstack-T2rZVigk.js +912 -0
  10. package/cdn/with-layouts/vidstack.js +1 -1
  11. package/dev/chunks/vidstack--aukHYxl.js +1520 -0
  12. package/dev/chunks/vidstack-B__DfQsT.js +1621 -0
  13. package/dev/chunks/vidstack-BoLIUOyq.js +204 -0
  14. package/dev/chunks/vidstack-CSryZFvY.js +1521 -0
  15. package/dev/chunks/vidstack-Cky9ors4.js +297 -0
  16. package/dev/chunks/vidstack-Crz0ROkT.js +3009 -0
  17. package/dev/chunks/vidstack-D-sqb6YI.js +308 -0
  18. package/dev/chunks/vidstack-DLXCqdYV.js +3010 -0
  19. package/dev/chunks/vidstack-DS7nRfge.js +204 -0
  20. package/dev/chunks/vidstack-Dco6kA4h.js +104 -0
  21. package/dev/chunks/vidstack-DpS0Kt4b.js +297 -0
  22. package/dev/chunks/vidstack-zJT-7ncH.js +5182 -0
  23. package/dev/define/plyr-layout.js +3 -4
  24. package/dev/define/templates/vidstack-audio-layout.js +4 -4
  25. package/dev/define/templates/vidstack-video-layout.js +4 -4
  26. package/dev/define/vidstack-player-default-layout.js +4 -4
  27. package/dev/define/vidstack-player-layouts.js +4 -4
  28. package/dev/define/vidstack-player-ui.js +5 -6
  29. package/dev/define/vidstack-player.js +3 -4
  30. package/dev/global/plyr.js +5 -6
  31. package/dev/global/vidstack-player.js +3 -4
  32. package/dev/providers/vidstack-dash.js +1 -2
  33. package/dev/providers/vidstack-hls.js +1 -2
  34. package/dev/providers/vidstack-video.js +1 -2
  35. package/dev/providers/vidstack-vimeo.js +1 -2
  36. package/dev/vidstack-elements.js +8 -9
  37. package/dev/vidstack.js +6 -7
  38. package/package.json +2 -1
  39. package/prod/chunks/vidstack-BVSJtdRd.js +297 -0
  40. package/prod/chunks/vidstack-BnEo_Sla.js +1621 -0
  41. package/prod/chunks/vidstack-CFXAYpuh.js +1521 -0
  42. package/prod/chunks/vidstack-CIvL96_j.js +297 -0
  43. package/prod/chunks/vidstack-CLTPjjXX.js +4772 -0
  44. package/prod/chunks/vidstack-CSHHV2zO.js +201 -0
  45. package/prod/chunks/vidstack-CYVCrFjx.js +201 -0
  46. package/prod/chunks/vidstack-D_atbNqH.js +3000 -0
  47. package/prod/chunks/vidstack-Eo46ZHu7.js +2999 -0
  48. package/prod/chunks/vidstack-sP7TQMB1.js +300 -0
  49. package/prod/chunks/vidstack-uVm3xX8H.js +104 -0
  50. package/prod/chunks/vidstack-zknLxihl.js +1520 -0
  51. package/prod/define/plyr-layout.js +3 -4
  52. package/prod/define/templates/vidstack-audio-layout.js +4 -4
  53. package/prod/define/templates/vidstack-video-layout.js +4 -4
  54. package/prod/define/vidstack-player-default-layout.js +4 -4
  55. package/prod/define/vidstack-player-layouts.js +4 -4
  56. package/prod/define/vidstack-player-ui.js +5 -6
  57. package/prod/define/vidstack-player.js +3 -4
  58. package/prod/global/plyr.js +5 -6
  59. package/prod/global/vidstack-player.js +3 -4
  60. package/prod/providers/vidstack-dash.js +1 -2
  61. package/prod/providers/vidstack-hls.js +1 -2
  62. package/prod/providers/vidstack-video.js +1 -2
  63. package/prod/providers/vidstack-vimeo.js +1 -2
  64. package/prod/vidstack-elements.js +8 -9
  65. package/prod/vidstack.js +6 -7
  66. package/server/chunks/vidstack-B3eA67nX.js +205 -0
  67. package/server/chunks/vidstack-B8P1aUCK.js +1503 -0
  68. package/server/chunks/vidstack-B8_v1VQn.js +3059 -0
  69. package/server/chunks/vidstack-BK4xGWUK.js +207 -0
  70. package/server/chunks/vidstack-BO8FLks6.js +295 -0
  71. package/server/chunks/vidstack-BaXvZgx2.js +141 -0
  72. package/server/chunks/vidstack-BlvJg_5A.js +4636 -0
  73. package/server/chunks/vidstack-CBhikwSz.js +67 -0
  74. package/server/chunks/vidstack-COczNXom.js +3059 -0
  75. package/server/chunks/vidstack-CyZPtpwO.js +1503 -0
  76. package/server/chunks/vidstack-Db22EuE_.js +207 -0
  77. package/server/chunks/vidstack-Dh1ZDEI-.js +29 -0
  78. package/server/chunks/vidstack-Dm-ETAZh.js +295 -0
  79. package/server/chunks/vidstack-NpAD9hfP.js +620 -0
  80. package/server/chunks/vidstack-O4BgIcQI.js +104 -0
  81. package/server/chunks/vidstack-n4zAyLEV.js +2139 -0
  82. package/server/chunks/vidstack-za5Yh5DQ.js +566 -0
  83. package/server/chunks/vidstack-zoXyfYxa.js +107 -0
  84. package/server/define/plyr-layout.js +7 -7
  85. package/server/define/vidstack-player-default-layout.js +3 -3
  86. package/server/define/vidstack-player-layouts.js +5 -5
  87. package/server/define/vidstack-player-ui.js +6 -6
  88. package/server/define/vidstack-player.js +4 -4
  89. package/server/global/plyr.js +9 -9
  90. package/server/global/vidstack-player.js +4 -4
  91. package/server/vidstack-elements.js +13 -13
  92. package/server/vidstack.js +8 -8
@@ -0,0 +1,300 @@
1
+ import { listenEvent, scoped, isString, getScope, EventsTarget, DOMEvent, isArray, isNumber } from './vidstack-BNpgCJJ1.js';
2
+ import { getRequestCredentials } from './vidstack-KShKSmYu.js';
3
+
4
+ const CROSS_ORIGIN = Symbol(0), READY_STATE = Symbol(0), UPDATE_ACTIVE_CUES = Symbol(0), CAN_LOAD = Symbol(0), ON_MODE_CHANGE = Symbol(0), NATIVE = Symbol(0), NATIVE_HLS = Symbol(0);
5
+ const TextTrackSymbol = {
6
+ crossOrigin: CROSS_ORIGIN,
7
+ readyState: READY_STATE,
8
+ updateActiveCues: UPDATE_ACTIVE_CUES,
9
+ canLoad: CAN_LOAD,
10
+ onModeChange: ON_MODE_CHANGE,
11
+ native: NATIVE,
12
+ nativeHLS: NATIVE_HLS
13
+ };
14
+
15
+ function findActiveCue(cues, time) {
16
+ for (let i = 0, len = cues.length; i < len; i++) {
17
+ if (isCueActive(cues[i], time)) return cues[i];
18
+ }
19
+ return null;
20
+ }
21
+ function isCueActive(cue, time) {
22
+ return time >= cue.startTime && time < cue.endTime;
23
+ }
24
+ function watchActiveTextTrack(tracks, kind, onChange) {
25
+ let currentTrack = null, scope = getScope();
26
+ function onModeChange() {
27
+ const kinds = isString(kind) ? [kind] : kind, track = tracks.toArray().find((track2) => kinds.includes(track2.kind) && track2.mode === "showing");
28
+ if (track === currentTrack) return;
29
+ if (!track) {
30
+ onChange(null);
31
+ currentTrack = null;
32
+ return;
33
+ }
34
+ if (track.readyState == 2) {
35
+ onChange(track);
36
+ } else {
37
+ onChange(null);
38
+ scoped(() => {
39
+ const off = listenEvent(
40
+ track,
41
+ "load",
42
+ () => {
43
+ onChange(track);
44
+ off();
45
+ },
46
+ { once: true }
47
+ );
48
+ }, scope);
49
+ }
50
+ currentTrack = track;
51
+ }
52
+ onModeChange();
53
+ return listenEvent(tracks, "mode-change", onModeChange);
54
+ }
55
+ function watchCueTextChange(tracks, kind, callback) {
56
+ watchActiveTextTrack(tracks, kind, (track) => {
57
+ if (!track) {
58
+ callback("");
59
+ return;
60
+ }
61
+ const onCueChange = () => {
62
+ const activeCue = track?.activeCues[0];
63
+ callback(activeCue?.text || "");
64
+ };
65
+ onCueChange();
66
+ listenEvent(track, "cue-change", onCueChange);
67
+ });
68
+ }
69
+
70
+ class TextTrack extends EventsTarget {
71
+ static createId(track) {
72
+ return `vds-${track.type}-${track.kind}-${track.src ?? track.label ?? "?"}`;
73
+ }
74
+ src;
75
+ content;
76
+ type;
77
+ encoding;
78
+ id = "";
79
+ label = "";
80
+ language = "";
81
+ kind;
82
+ default = false;
83
+ #canLoad = false;
84
+ #currentTime = 0;
85
+ #mode = "disabled";
86
+ #metadata = {};
87
+ #regions = [];
88
+ #cues = [];
89
+ #activeCues = [];
90
+ #cueIds = /* @__PURE__ */ new Set();
91
+ /** @internal */
92
+ [TextTrackSymbol.readyState] = 0;
93
+ /** @internal */
94
+ [TextTrackSymbol.crossOrigin];
95
+ /** @internal */
96
+ [TextTrackSymbol.onModeChange] = null;
97
+ /** @internal */
98
+ [TextTrackSymbol.native] = null;
99
+ get metadata() {
100
+ return this.#metadata;
101
+ }
102
+ get regions() {
103
+ return this.#regions;
104
+ }
105
+ get cues() {
106
+ return this.#cues;
107
+ }
108
+ get activeCues() {
109
+ return this.#activeCues;
110
+ }
111
+ /**
112
+ * - 0: Not Loading
113
+ * - 1: Loading
114
+ * - 2: Ready
115
+ * - 3: Error
116
+ */
117
+ get readyState() {
118
+ return this[TextTrackSymbol.readyState];
119
+ }
120
+ get mode() {
121
+ return this.#mode;
122
+ }
123
+ set mode(mode) {
124
+ this.setMode(mode);
125
+ }
126
+ constructor(init) {
127
+ super();
128
+ for (const prop of Object.keys(init)) this[prop] = init[prop];
129
+ if (!this.type) this.type = "vtt";
130
+ if (init.content) {
131
+ this.#parseContent(init);
132
+ } else if (!init.src) {
133
+ this[TextTrackSymbol.readyState] = 2;
134
+ }
135
+ }
136
+ addCue(cue, trigger) {
137
+ if (cue.id) {
138
+ if (this.#cueIds.has(cue.id)) return;
139
+ this.#cueIds.add(cue.id);
140
+ }
141
+ let i = 0, length = this.#cues.length;
142
+ for (i = 0; i < length; i++) if (cue.endTime <= this.#cues[i].startTime) break;
143
+ if (i === length) this.#cues.push(cue);
144
+ else this.#cues.splice(i, 0, cue);
145
+ if (!(cue instanceof TextTrackCue)) {
146
+ this[TextTrackSymbol.native]?.track.addCue(cue);
147
+ }
148
+ this.dispatchEvent(new DOMEvent("add-cue", { detail: cue, trigger }));
149
+ if (isCueActive(cue, this.#currentTime)) {
150
+ this[TextTrackSymbol.updateActiveCues](this.#currentTime, trigger);
151
+ }
152
+ }
153
+ removeCue(cue, trigger) {
154
+ const index = this.#cues.indexOf(cue);
155
+ if (index >= 0) {
156
+ const isActive = this.#activeCues.includes(cue);
157
+ if (cue.id) this.#cueIds.delete(cue.id);
158
+ this.#cues.splice(index, 1);
159
+ this[TextTrackSymbol.native]?.track.removeCue(cue);
160
+ this.dispatchEvent(new DOMEvent("remove-cue", { detail: cue, trigger }));
161
+ if (isActive) {
162
+ this[TextTrackSymbol.updateActiveCues](this.#currentTime, trigger);
163
+ }
164
+ }
165
+ }
166
+ setMode(mode, trigger) {
167
+ if (this.#mode === mode) return;
168
+ this.#mode = mode;
169
+ if (mode === "disabled") {
170
+ this.#activeCues = [];
171
+ this.#activeCuesChanged();
172
+ } else if (this.readyState === 2) {
173
+ this[TextTrackSymbol.updateActiveCues](this.#currentTime, trigger);
174
+ } else {
175
+ this.#load();
176
+ }
177
+ this.dispatchEvent(new DOMEvent("mode-change", { detail: this, trigger }));
178
+ this[TextTrackSymbol.onModeChange]?.();
179
+ }
180
+ /** @internal */
181
+ [TextTrackSymbol.updateActiveCues](currentTime, trigger) {
182
+ this.#currentTime = currentTime;
183
+ if (this.mode === "disabled" || !this.#cues.length) return;
184
+ const activeCues = [];
185
+ for (let i = 0, length = this.#cues.length; i < length; i++) {
186
+ const cue = this.#cues[i];
187
+ if (isCueActive(cue, currentTime)) activeCues.push(cue);
188
+ }
189
+ let changed = activeCues.length !== this.#activeCues.length;
190
+ if (!changed) {
191
+ for (let i = 0; i < activeCues.length; i++) {
192
+ if (!this.#activeCues.includes(activeCues[i])) {
193
+ changed = true;
194
+ break;
195
+ }
196
+ }
197
+ }
198
+ this.#activeCues = activeCues;
199
+ if (changed) this.#activeCuesChanged(trigger);
200
+ }
201
+ /** @internal */
202
+ [TextTrackSymbol.canLoad]() {
203
+ this.#canLoad = true;
204
+ if (this.#mode !== "disabled") this.#load();
205
+ }
206
+ #parseContent(init) {
207
+ import('media-captions').then(({ parseText, VTTCue, VTTRegion }) => {
208
+ if (!isString(init.content) || init.type === "json") {
209
+ this.#parseJSON(init.content, VTTCue, VTTRegion);
210
+ if (this.readyState !== 3) this.#ready();
211
+ } else {
212
+ const content = init.content.split("\n").map((line) => line.trim()).join("\n").trim();
213
+ parseText(content, { type: init.type }).then(({ cues, regions }) => {
214
+ this.#cues = cues;
215
+ this.#regions = regions;
216
+ this.#ready();
217
+ });
218
+ }
219
+ });
220
+ }
221
+ async #load() {
222
+ if (!this.#canLoad || this[TextTrackSymbol.readyState] > 0) return;
223
+ this[TextTrackSymbol.readyState] = 1;
224
+ this.dispatchEvent(new DOMEvent("load-start"));
225
+ if (!this.src) {
226
+ this.#ready();
227
+ return;
228
+ }
229
+ try {
230
+ const { parseResponse, VTTCue, VTTRegion } = await import('media-captions'), crossOrigin = this[TextTrackSymbol.crossOrigin]?.();
231
+ const response = fetch(this.src, {
232
+ headers: this.type === "json" ? { "Content-Type": "application/json" } : void 0,
233
+ credentials: getRequestCredentials(crossOrigin)
234
+ });
235
+ if (this.type === "json") {
236
+ this.#parseJSON(await (await response).text(), VTTCue, VTTRegion);
237
+ } else {
238
+ const { errors, metadata, regions, cues } = await parseResponse(response, {
239
+ type: this.type,
240
+ encoding: this.encoding
241
+ });
242
+ if (errors[0]?.code === 0) {
243
+ throw errors[0];
244
+ } else {
245
+ this.#metadata = metadata;
246
+ this.#regions = regions;
247
+ this.#cues = cues;
248
+ }
249
+ }
250
+ this.#ready();
251
+ } catch (error) {
252
+ this.#error(error);
253
+ }
254
+ }
255
+ #ready() {
256
+ this[TextTrackSymbol.readyState] = 2;
257
+ if (!this.src || this.type !== "vtt") {
258
+ const native = this[TextTrackSymbol.native];
259
+ if (native && !native.managed) {
260
+ for (const cue of this.#cues) native.track.addCue(cue);
261
+ }
262
+ }
263
+ const loadEvent = new DOMEvent("load");
264
+ this[TextTrackSymbol.updateActiveCues](this.#currentTime, loadEvent);
265
+ this.dispatchEvent(loadEvent);
266
+ }
267
+ #error(error) {
268
+ this[TextTrackSymbol.readyState] = 3;
269
+ this.dispatchEvent(new DOMEvent("error", { detail: error }));
270
+ }
271
+ #parseJSON(json, VTTCue, VTTRegion) {
272
+ try {
273
+ const { regions, cues } = parseJSONCaptionsFile(json, VTTCue, VTTRegion);
274
+ this.#regions = regions;
275
+ this.#cues = cues;
276
+ } catch (error) {
277
+ this.#error(error);
278
+ }
279
+ }
280
+ #activeCuesChanged(trigger) {
281
+ this.dispatchEvent(new DOMEvent("cue-change", { trigger }));
282
+ }
283
+ }
284
+ const captionRE = /captions|subtitles/;
285
+ function isTrackCaptionKind(track) {
286
+ return captionRE.test(track.kind);
287
+ }
288
+ function parseJSONCaptionsFile(json, Cue, Region) {
289
+ const content = isString(json) ? JSON.parse(json) : json;
290
+ let regions = [], cues = [];
291
+ if (content.regions && Region) {
292
+ regions = content.regions.map((region) => Object.assign(new Region(), region));
293
+ }
294
+ if (content.cues || isArray(content)) {
295
+ cues = (isArray(content) ? content : content.cues).filter((content2) => isNumber(content2.startTime) && isNumber(content2.endTime)).map((cue) => Object.assign(new Cue(0, 0, ""), cue));
296
+ }
297
+ return { regions, cues };
298
+ }
299
+
300
+ export { TextTrack, TextTrackSymbol, findActiveCue, isCueActive, isTrackCaptionKind, parseJSONCaptionsFile, watchActiveTextTrack, watchCueTextChange };
@@ -0,0 +1,104 @@
1
+ import { Host, effect, computed, setAttribute } from './vidstack-BNpgCJJ1.js';
2
+ import { MediaProvider, MediaPlayer } from './vidstack-CLTPjjXX.js';
3
+ import { useMediaContext } from './vidstack-tt3O1zL6.js';
4
+
5
+ class MediaProviderElement extends Host(HTMLElement, MediaProvider) {
6
+ static tagName = "media-provider";
7
+ #media;
8
+ #target = null;
9
+ #blocker = null;
10
+ onSetup() {
11
+ this.#media = useMediaContext();
12
+ this.setAttribute("keep-alive", "");
13
+ }
14
+ onDestroy() {
15
+ this.#blocker?.remove();
16
+ this.#blocker = null;
17
+ this.#target?.remove();
18
+ this.#target = null;
19
+ }
20
+ onConnect() {
21
+ effect(() => {
22
+ const loader = this.$state.loader(), isYouTubeEmbed = loader?.name === "youtube", isVimeoEmbed = loader?.name === "vimeo", isEmbed = isYouTubeEmbed || isVimeoEmbed, isGoogleCast = loader?.name === "google-cast";
23
+ const target = loader ? isGoogleCast ? this.#createGoogleCastContainer() : isEmbed ? this.#createIFrame() : loader.mediaType() === "audio" ? this.#createAudio() : this.#createVideo() : null;
24
+ if (this.#target !== target) {
25
+ const parent = this.#target?.parentElement ?? this;
26
+ this.#target?.remove();
27
+ this.#target = target;
28
+ if (target) parent.prepend(target);
29
+ if (isEmbed && target) {
30
+ effect(() => {
31
+ const { nativeControls, viewType } = this.#media.$state, showNativeControls = nativeControls(), isAudioView = viewType() === "audio", showBlocker = !showNativeControls && !isAudioView;
32
+ if (showBlocker) {
33
+ this.#blocker = this.querySelector(".vds-blocker");
34
+ if (!this.#blocker) {
35
+ this.#blocker = document.createElement("div");
36
+ this.#blocker.classList.add("vds-blocker");
37
+ target.after(this.#blocker);
38
+ }
39
+ } else {
40
+ this.#blocker?.remove();
41
+ this.#blocker = null;
42
+ }
43
+ setAttribute(target, "data-no-controls", !showNativeControls);
44
+ });
45
+ }
46
+ }
47
+ if (isYouTubeEmbed) target?.classList.add("vds-youtube");
48
+ else if (isVimeoEmbed) target?.classList.add("vds-vimeo");
49
+ if (!isEmbed) {
50
+ this.#blocker?.remove();
51
+ this.#blocker = null;
52
+ }
53
+ this.load(target);
54
+ });
55
+ }
56
+ #createAudio() {
57
+ const audio = this.#target instanceof HTMLAudioElement ? this.#target : document.createElement("audio");
58
+ const { controls, crossOrigin } = this.#media.$state;
59
+ effect(() => {
60
+ setAttribute(audio, "controls", controls());
61
+ setAttribute(audio, "crossorigin", crossOrigin());
62
+ });
63
+ return audio;
64
+ }
65
+ #createVideo() {
66
+ const video = this.#target instanceof HTMLVideoElement ? this.#target : document.createElement("video");
67
+ const { crossOrigin, poster, nativeControls } = this.#media.$state, $controls = computed(() => nativeControls() ? "true" : null), $poster = computed(() => poster() && nativeControls() ? poster() : null);
68
+ effect(() => {
69
+ setAttribute(video, "controls", $controls());
70
+ setAttribute(video, "crossorigin", crossOrigin());
71
+ setAttribute(video, "poster", $poster());
72
+ });
73
+ return video;
74
+ }
75
+ #createIFrame() {
76
+ const iframe = this.#target instanceof HTMLIFrameElement ? this.#target : document.createElement("iframe"), { nativeControls } = this.#media.$state;
77
+ effect(() => setAttribute(iframe, "tabindex", !nativeControls() ? -1 : null));
78
+ return iframe;
79
+ }
80
+ #createGoogleCastContainer() {
81
+ if (this.#target?.classList.contains("vds-google-cast")) {
82
+ return this.#target;
83
+ }
84
+ const container = document.createElement("div");
85
+ container.classList.add("vds-google-cast");
86
+ import('./vidstack-Oq65llxr.js').then(({ insertContent }) => {
87
+ insertContent(container, this.#media.$state);
88
+ });
89
+ return container;
90
+ }
91
+ }
92
+
93
+ class MediaPlayerElement extends Host(HTMLElement, MediaPlayer) {
94
+ static tagName = "media-player";
95
+ static attrs = {
96
+ autoPlay: "autoplay",
97
+ crossOrigin: "crossorigin",
98
+ playsInline: "playsinline",
99
+ preferNativeHLS: "prefer-native-hls",
100
+ minLiveDVRWindow: "min-live-dvr-window"
101
+ };
102
+ }
103
+
104
+ export { MediaPlayerElement, MediaProviderElement };