@hanifhan1f/vidstack 1.12.18 → 1.12.24

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 (107) hide show
  1. package/cdn/chunks/vidstack-BF7lZRtq.js +3 -0
  2. package/cdn/chunks/vidstack-BYpysj84.js +1 -0
  3. package/cdn/chunks/vidstack-C1FlyyzK.js +1 -0
  4. package/cdn/chunks/vidstack-Cj0I-Rec.js +1 -0
  5. package/cdn/chunks/vidstack-D84Fzc__.js +16 -0
  6. package/cdn/chunks/vidstack-DQvyz7Mm.js +1 -0
  7. package/cdn/chunks/vidstack-Dd9fqVv6.js +1 -0
  8. package/cdn/chunks/vidstack-uMxrPflF.js +1 -0
  9. package/cdn/chunks/vidstack-zemsqC5d.js +1 -0
  10. package/cdn/providers/vidstack-audio-BOGYlExy.js +1 -0
  11. package/cdn/providers/vidstack-dash-D4ZARr66.js +1 -0
  12. package/cdn/providers/vidstack-hls-8-552IuX.js +1 -0
  13. package/cdn/providers/vidstack-html-BvVaN2VT.js +1 -0
  14. package/cdn/providers/vidstack-video-BnwQZKER.js +1 -0
  15. package/cdn/providers/vidstack-vimeo-gJmBqtLK.js +1 -0
  16. package/cdn/providers/vidstack-youtube-Chl_dTAz.js +1 -0
  17. package/cdn/vidstack.js +1 -1
  18. package/cdn/with-layouts/chunks/vidstack-4liSokT6.js +1 -0
  19. package/cdn/with-layouts/chunks/vidstack-B97B8XDc.js +3 -0
  20. package/cdn/with-layouts/chunks/vidstack-BbFHhcVG.js +1 -0
  21. package/cdn/with-layouts/chunks/vidstack-CXEcXyBI.js +1 -0
  22. package/cdn/with-layouts/chunks/vidstack-Ciq-n5rg.js +1 -0
  23. package/cdn/with-layouts/chunks/vidstack-CmuGllcj.js +1 -0
  24. package/cdn/with-layouts/chunks/vidstack-CyNByJUW.js +912 -0
  25. package/cdn/with-layouts/chunks/vidstack-DhNpv7SU.js +1 -0
  26. package/cdn/with-layouts/providers/vidstack-audio-CwoQJvl2.js +1 -0
  27. package/cdn/with-layouts/providers/vidstack-dash-CJsKJfLI.js +1 -0
  28. package/cdn/with-layouts/providers/vidstack-hls-ji26kFdQ.js +1 -0
  29. package/cdn/with-layouts/providers/vidstack-html-BvHMxtoe.js +1 -0
  30. package/cdn/with-layouts/providers/vidstack-video-1Uj5cNP2.js +1 -0
  31. package/cdn/with-layouts/providers/vidstack-vimeo-DACTbJaQ.js +1 -0
  32. package/cdn/with-layouts/providers/vidstack-youtube-RoLp-I6u.js +1 -0
  33. package/cdn/with-layouts/vidstack.js +1 -1
  34. package/dev/chunks/vidstack-0XhA3AD_.js +5181 -0
  35. package/dev/chunks/vidstack-5oWWZmVl.js +58 -0
  36. package/dev/chunks/vidstack-BnBLcaA5.js +115 -0
  37. package/dev/chunks/vidstack-Bo8BNFJ2.js +2986 -0
  38. package/dev/chunks/vidstack-C3N4zIuV.js +254 -0
  39. package/dev/chunks/vidstack-CAL4iu_K.js +1482 -0
  40. package/dev/chunks/vidstack-CGyAjz8G.js +58 -0
  41. package/dev/chunks/vidstack-CJCnHmKE.js +104 -0
  42. package/dev/chunks/vidstack-CzCQJ29U.js +107 -0
  43. package/dev/chunks/vidstack-DD_3HszA.js +1520 -0
  44. package/dev/chunks/vidstack-DV4g4XvL.js +33 -0
  45. package/dev/chunks/vidstack-D_LvMxPr.js +204 -0
  46. package/dev/chunks/vidstack-DdTXMZro.js +66 -0
  47. package/dev/chunks/vidstack-DrczgsqN.js +297 -0
  48. package/dev/chunks/vidstack-gF_qqvCK.js +109 -0
  49. package/dev/define/plyr-layout.js +7 -7
  50. package/dev/define/templates/plyr-layout.js +2 -2
  51. package/dev/define/templates/vidstack-audio-layout.js +3 -3
  52. package/dev/define/templates/vidstack-video-layout.js +7 -9
  53. package/dev/define/vidstack-player-default-layout.js +3 -3
  54. package/dev/define/vidstack-player-layouts.js +3 -3
  55. package/dev/define/vidstack-player-ui.js +9 -9
  56. package/dev/define/vidstack-player.js +5 -5
  57. package/dev/global/plyr.js +9 -9
  58. package/dev/global/vidstack-player.js +6 -6
  59. package/dev/providers/vidstack-audio.js +2 -2
  60. package/dev/providers/vidstack-dash.js +4 -4
  61. package/dev/providers/vidstack-hls.js +4 -4
  62. package/dev/providers/vidstack-html.js +1 -1
  63. package/dev/providers/vidstack-video.js +4 -4
  64. package/dev/providers/vidstack-vimeo.js +4 -4
  65. package/dev/providers/vidstack-youtube.js +3 -3
  66. package/dev/vidstack-elements.js +12 -12
  67. package/dev/vidstack.js +9 -9
  68. package/package.json +1 -1
  69. package/player/styles/default/layouts/video.css +113 -79
  70. package/prod/chunks/vidstack-BAqdCFIm.js +4771 -0
  71. package/prod/chunks/vidstack-BRnfTkxi.js +297 -0
  72. package/prod/chunks/vidstack-BexQYZop.js +2976 -0
  73. package/prod/chunks/vidstack-Bf1Q6kqO.js +109 -0
  74. package/prod/chunks/vidstack-Bn9yLryd.js +58 -0
  75. package/prod/chunks/vidstack-C4PTiuot.js +107 -0
  76. package/prod/chunks/vidstack-DMDDSV3t.js +104 -0
  77. package/prod/chunks/vidstack-Dg71uhRc.js +58 -0
  78. package/prod/chunks/vidstack-DlLwMLBL.js +33 -0
  79. package/prod/chunks/vidstack-KShKSmYu.js +66 -0
  80. package/prod/chunks/vidstack-ShUhyBfI.js +201 -0
  81. package/prod/chunks/vidstack-V9U6gsde.js +1482 -0
  82. package/prod/chunks/vidstack-kdaDngIm.js +1520 -0
  83. package/prod/chunks/vidstack-oNEzlviH.js +246 -0
  84. package/prod/chunks/vidstack-wTTCvdqe.js +115 -0
  85. package/prod/define/plyr-layout.js +7 -7
  86. package/prod/define/templates/plyr-layout.js +2 -2
  87. package/prod/define/templates/vidstack-audio-layout.js +3 -3
  88. package/prod/define/templates/vidstack-video-layout.js +7 -9
  89. package/prod/define/vidstack-player-default-layout.js +3 -3
  90. package/prod/define/vidstack-player-layouts.js +3 -3
  91. package/prod/define/vidstack-player-ui.js +9 -9
  92. package/prod/define/vidstack-player.js +5 -5
  93. package/prod/global/plyr.js +9 -9
  94. package/prod/global/vidstack-player.js +6 -6
  95. package/prod/providers/vidstack-audio.js +2 -2
  96. package/prod/providers/vidstack-dash.js +4 -4
  97. package/prod/providers/vidstack-hls.js +4 -4
  98. package/prod/providers/vidstack-html.js +1 -1
  99. package/prod/providers/vidstack-video.js +4 -4
  100. package/prod/providers/vidstack-vimeo.js +4 -4
  101. package/prod/providers/vidstack-youtube.js +3 -3
  102. package/prod/vidstack-elements.js +12 -12
  103. package/prod/vidstack.js +9 -9
  104. package/server/chunks/vidstack-B2Bc9g7_.js +2000 -0
  105. package/server/define/vidstack-player-default-layout.js +1 -1
  106. package/server/define/vidstack-player-layouts.js +1 -1
  107. package/server/vidstack-elements.js +1 -1
@@ -0,0 +1,254 @@
1
+ import { EventsTarget, DOMEvent, isString, isArray, isNumber } from './vidstack-C1PwJD_4.js';
2
+ import { getRequestCredentials } from './vidstack-DdTXMZro.js';
3
+ import { isCueActive } from './vidstack-CcQdBWil.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 };