@yaneart/yaneplayer 0.0.0-stage → 0.1.1
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.
- package/GUIDE.md +716 -0
- package/LICENSE +21 -0
- package/README.md +62 -2
- package/THIRD_PARTY_NOTICES.md +46 -0
- package/assets/player-preview.jpg +0 -0
- package/dist/ass-renderer-DmsQqR82.js +84 -0
- package/dist/auto-captions/assets.js +9 -0
- package/dist/auto-captions/audio.js +42 -0
- package/dist/auto-captions/ort-wasm-simd-threaded.asyncify.mjs +124 -0
- package/dist/auto-captions/ort-wasm-simd-threaded.asyncify.wasm +0 -0
- package/dist/auto-captions/translation-worker.js +49 -0
- package/dist/auto-captions/worker.js +51 -0
- package/dist/core/ass-renderer.d.ts +5 -0
- package/dist/core/async.d.ts +5 -0
- package/dist/core/auto-caption-assets.d.ts +7 -0
- package/dist/core/auto-captions.d.ts +14 -0
- package/dist/core/caption-publication.d.ts +22 -0
- package/dist/core/commands.d.ts +10 -0
- package/dist/core/errors.d.ts +7 -0
- package/dist/core/hls.d.ts +4 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/platform.d.ts +22 -0
- package/dist/core/preferences.d.ts +10 -0
- package/dist/core/runtime.d.ts +3 -0
- package/dist/core/source.d.ts +6 -0
- package/dist/core/subtitle-assets.d.ts +6 -0
- package/dist/core/subtitle-data.d.ts +11 -0
- package/dist/core/subtitles.d.ts +22 -0
- package/dist/core/tracks.d.ts +7 -0
- package/dist/core/translation-model.d.ts +6 -0
- package/dist/core/transport.d.ts +15 -0
- package/dist/core/types.d.ts +333 -0
- package/dist/core-Bl9Ox_wM.js +3352 -0
- package/dist/core.js +1 -0
- package/dist/element.d.ts +89 -0
- package/dist/hls-CrUfIOS7.js +20700 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4771 -0
- package/dist/licenses/@fontsource-variable-manrope.txt +93 -0
- package/dist/licenses/@huggingface-jinja.txt +21 -0
- package/dist/licenses/@huggingface-tokenizers.txt +201 -0
- package/dist/licenses/@huggingface-transformers.txt +202 -0
- package/dist/licenses/@mingcute-icons.txt +202 -0
- package/dist/licenses/@videojs-core.txt +20 -0
- package/dist/licenses/@videojs-element.txt +20 -0
- package/dist/licenses/@videojs-hlsjs-video.txt +20 -0
- package/dist/licenses/@videojs-html.txt +20 -0
- package/dist/licenses/@videojs-media.txt +20 -0
- package/dist/licenses/@videojs-native-hls-video.txt +20 -0
- package/dist/licenses/@videojs-spf.txt +20 -0
- package/dist/licenses/@videojs-store.txt +20 -0
- package/dist/licenses/@videojs-utils.txt +20 -0
- package/dist/licenses/flatbuffers.txt +202 -0
- package/dist/licenses/hls.js.txt +28 -0
- package/dist/licenses/jassub.txt +22 -0
- package/dist/licenses/long.txt +202 -0
- package/dist/licenses/platform.txt +21 -0
- package/dist/licenses/protobufjs.txt +39 -0
- package/dist/licenses/third-party.txt +7941 -0
- package/dist/react.d.ts +56 -0
- package/dist/subtitles/assets.js +7 -0
- package/dist/subtitles/default.woff2 +0 -0
- package/dist/subtitles/jassub.js +1 -0
- package/dist/subtitles/wasm/jassub-worker-modern.wasm +0 -0
- package/dist/subtitles/wasm/jassub-worker.wasm +0 -0
- package/dist/subtitles/worker/worker.js +144 -0
- package/dist/ui/auto-captions.d.ts +6 -0
- package/dist/ui/captions.d.ts +6 -0
- package/dist/ui/controls.d.ts +28 -0
- package/dist/ui/fonts.d.ts +2 -0
- package/dist/ui/generated-captions.d.ts +7 -0
- package/dist/ui/icons.d.ts +24 -0
- package/dist/ui/labels.d.ts +74 -0
- package/dist/ui/rolling-captions.d.ts +10 -0
- package/dist/ui/settings.d.ts +17 -0
- package/dist/ui/speed.d.ts +9 -0
- package/dist/ui/subtitle-settings.d.ts +5 -0
- package/dist/ui/tooltips.d.ts +5 -0
- package/dist/ui/touch.d.ts +5 -0
- package/dist/ui/types.d.ts +1 -0
- package/package.json +77 -4
|
@@ -0,0 +1,3352 @@
|
|
|
1
|
+
import { subtitleAssets as e } from "./subtitles/assets.js";
|
|
2
|
+
import { autoCaptionAssets as t } from "./auto-captions/assets.js";
|
|
3
|
+
// node_modules/@videojs/utils/dist/predicate/predicate.js
|
|
4
|
+
function n(e) {
|
|
5
|
+
return typeof e == "string";
|
|
6
|
+
}
|
|
7
|
+
function r(e) {
|
|
8
|
+
return typeof e == "function";
|
|
9
|
+
}
|
|
10
|
+
function i(e) {
|
|
11
|
+
return e === null;
|
|
12
|
+
}
|
|
13
|
+
function a(e) {
|
|
14
|
+
return e === void 0;
|
|
15
|
+
}
|
|
16
|
+
function o(e) {
|
|
17
|
+
return e == null;
|
|
18
|
+
}
|
|
19
|
+
function s(e) {
|
|
20
|
+
return e instanceof Promise;
|
|
21
|
+
}
|
|
22
|
+
function c(e) {
|
|
23
|
+
return typeof e == "object" && !!e;
|
|
24
|
+
}
|
|
25
|
+
function l(e, t) {
|
|
26
|
+
return c(e) ? t.every((t) => r(e[t])) : !1;
|
|
27
|
+
}
|
|
28
|
+
function u(e) {
|
|
29
|
+
if (!c(e)) return !1;
|
|
30
|
+
let t = Object.getPrototypeOf(e);
|
|
31
|
+
return t === null || t === Object.prototype;
|
|
32
|
+
}
|
|
33
|
+
function d(e) {
|
|
34
|
+
return e instanceof Error && e.name === "AbortError";
|
|
35
|
+
}
|
|
36
|
+
// node_modules/@videojs/media/dist/default/core/constants.js
|
|
37
|
+
var f = Object.freeze({
|
|
38
|
+
length: 0,
|
|
39
|
+
start: () => 0,
|
|
40
|
+
end: () => 0
|
|
41
|
+
}), p = Object.assign(new EventTarget(), {
|
|
42
|
+
length: 0,
|
|
43
|
+
*[Symbol.iterator]() {},
|
|
44
|
+
getTrackById: () => null
|
|
45
|
+
}), m = new EventTarget(), h = Symbol.for("@videojs/media/registered");
|
|
46
|
+
function g(e) {
|
|
47
|
+
return e?.[h] ?? e;
|
|
48
|
+
}
|
|
49
|
+
// node_modules/@videojs/media/dist/default/core/types.js
|
|
50
|
+
function _(e) {
|
|
51
|
+
return o(e) ? null : e.toLowerCase() === "use-credentials" ? "use-credentials" : "anonymous";
|
|
52
|
+
}
|
|
53
|
+
var v = {
|
|
54
|
+
HAVE_NOTHING: 0,
|
|
55
|
+
HAVE_METADATA: 1,
|
|
56
|
+
HAVE_CURRENT_DATA: 2,
|
|
57
|
+
HAVE_FUTURE_DATA: 3,
|
|
58
|
+
HAVE_ENOUGH_DATA: 4
|
|
59
|
+
}, y = {
|
|
60
|
+
ON_DEMAND: "on-demand",
|
|
61
|
+
LIVE: "live",
|
|
62
|
+
UNKNOWN: "unknown"
|
|
63
|
+
};
|
|
64
|
+
// node_modules/@videojs/media/dist/default/core/predicate.js
|
|
65
|
+
function b(e) {
|
|
66
|
+
return e.readyState >= v.HAVE_METADATA;
|
|
67
|
+
}
|
|
68
|
+
function x(e) {
|
|
69
|
+
if (!c(e)) return !1;
|
|
70
|
+
let t = e;
|
|
71
|
+
return !a(t.paused) && !a(t.ended) && r(t.pause);
|
|
72
|
+
}
|
|
73
|
+
function S(e) {
|
|
74
|
+
if (!c(e)) return !1;
|
|
75
|
+
let t = e;
|
|
76
|
+
return !a(t.currentTime) && !a(t.duration) && !a(t.seeking);
|
|
77
|
+
}
|
|
78
|
+
function C(e) {
|
|
79
|
+
if (!c(e)) return !1;
|
|
80
|
+
let t = e;
|
|
81
|
+
return !a(t.src) && !a(t.currentSrc) && !a(t.readyState) && r(t.load);
|
|
82
|
+
}
|
|
83
|
+
function w(e) {
|
|
84
|
+
if (!c(e)) return !1;
|
|
85
|
+
let t = e;
|
|
86
|
+
return !a(t.volume) && !a(t.muted);
|
|
87
|
+
}
|
|
88
|
+
function T(e) {
|
|
89
|
+
return c(e) ? !a(e.muted) : !1;
|
|
90
|
+
}
|
|
91
|
+
function E(e) {
|
|
92
|
+
return c(e) ? !a(e.playbackRate) : !1;
|
|
93
|
+
}
|
|
94
|
+
function D(e) {
|
|
95
|
+
return c(e) ? r(e.requestPictureInPicture) : !1;
|
|
96
|
+
}
|
|
97
|
+
function O(e) {
|
|
98
|
+
if (!c(e)) return !1;
|
|
99
|
+
let t = e;
|
|
100
|
+
return !a(t.buffered) && t.buffered !== f && !a(t.seekable) && t.seekable !== f;
|
|
101
|
+
}
|
|
102
|
+
function k(e) {
|
|
103
|
+
return c(e) ? !a(e.error) : !1;
|
|
104
|
+
}
|
|
105
|
+
function A(e) {
|
|
106
|
+
if (!c(e)) return !1;
|
|
107
|
+
let t = e;
|
|
108
|
+
return !a(t.textTracks) && t.textTracks !== p;
|
|
109
|
+
}
|
|
110
|
+
function j(e) {
|
|
111
|
+
return c(e) ? !a(e.videoRenditions) : !1;
|
|
112
|
+
}
|
|
113
|
+
function M(e) {
|
|
114
|
+
return c(e) ? !a(e.audioTracks) : !1;
|
|
115
|
+
}
|
|
116
|
+
function N(e) {
|
|
117
|
+
if (!c(e)) return !1;
|
|
118
|
+
let t = e;
|
|
119
|
+
return !a(t.videoWidth) && !a(t.videoHeight);
|
|
120
|
+
}
|
|
121
|
+
function P(e) {
|
|
122
|
+
if (!c(e)) return !1;
|
|
123
|
+
let t = e;
|
|
124
|
+
return c(t.remote) && t.remote !== m;
|
|
125
|
+
}
|
|
126
|
+
function F(e) {
|
|
127
|
+
return c(e) ? !a(e.streamType) : !1;
|
|
128
|
+
}
|
|
129
|
+
function I(e) {
|
|
130
|
+
return c(e) ? !a(e.contentData) : !1;
|
|
131
|
+
}
|
|
132
|
+
function L(e) {
|
|
133
|
+
if (!c(e)) return !1;
|
|
134
|
+
let t = e;
|
|
135
|
+
return !a(t.liveEdgeStart) && !a(t.targetLiveWindow);
|
|
136
|
+
}
|
|
137
|
+
function R(e) {
|
|
138
|
+
return c(e) && "querySelectorAll" in e && r(e.querySelectorAll);
|
|
139
|
+
}
|
|
140
|
+
// node_modules/@videojs/core/dist/default/dom/feature.js
|
|
141
|
+
function z(e) {
|
|
142
|
+
let t = Object.values(e.config ?? {}).map((e) => e.state);
|
|
143
|
+
return {
|
|
144
|
+
...e,
|
|
145
|
+
...t.length > 0 ? { preserve: t } : {}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
// node_modules/@videojs/utils/dist/dom/animation-frame.js
|
|
149
|
+
function B(e) {
|
|
150
|
+
let t = requestAnimationFrame(e);
|
|
151
|
+
return () => cancelAnimationFrame(t);
|
|
152
|
+
}
|
|
153
|
+
// node_modules/@videojs/utils/dist/dom/listen.js
|
|
154
|
+
function V(e, t, n, r) {
|
|
155
|
+
return e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r);
|
|
156
|
+
}
|
|
157
|
+
// node_modules/@videojs/utils/dist/function/noop.js
|
|
158
|
+
function ee(...e) {}
|
|
159
|
+
// node_modules/@videojs/utils/dist/dom/event.js
|
|
160
|
+
function H(e, t, n) {
|
|
161
|
+
return new Promise((r, i) => {
|
|
162
|
+
let a = () => {
|
|
163
|
+
i(n?.signal?.reason ?? "Aborted");
|
|
164
|
+
};
|
|
165
|
+
n?.signal?.aborted ? a() : (n?.signal?.addEventListener("abort", a, { once: !0 }), e.addEventListener(t, (e) => {
|
|
166
|
+
n?.signal?.removeEventListener("abort", a), r(e);
|
|
167
|
+
}, {
|
|
168
|
+
...n,
|
|
169
|
+
once: !0
|
|
170
|
+
}));
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// node_modules/@videojs/utils/dist/string/casing.js
|
|
174
|
+
function U(e) {
|
|
175
|
+
return e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
|
|
176
|
+
}
|
|
177
|
+
// node_modules/@videojs/utils/dist/dom/style.js
|
|
178
|
+
function W(e) {
|
|
179
|
+
return e.startsWith("--") ? e : U(e);
|
|
180
|
+
}
|
|
181
|
+
function te(e) {
|
|
182
|
+
let t = e.style.getPropertyValue("anchor-name").trim();
|
|
183
|
+
return !t || t === "none" ? [] : t.split(",").map((e) => e.trim()).filter(Boolean);
|
|
184
|
+
}
|
|
185
|
+
function G(e, t) {
|
|
186
|
+
for (let [n, r] of Object.entries(t)) typeof r == "string" && e.style.setProperty(W(n), r);
|
|
187
|
+
}
|
|
188
|
+
function K(e, t) {
|
|
189
|
+
return [...t].map((t) => {
|
|
190
|
+
let n = W(t);
|
|
191
|
+
return {
|
|
192
|
+
property: n,
|
|
193
|
+
value: e.style.getPropertyValue(n),
|
|
194
|
+
priority: e.style.getPropertyPriority(n)
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function ne(e, t) {
|
|
199
|
+
for (let { property: n, value: r, priority: i } of t) r ? e.style.setProperty(n, r, i) : e.style.removeProperty(n);
|
|
200
|
+
}
|
|
201
|
+
function re(e, t, n) {
|
|
202
|
+
let r = K(e, Object.keys(t));
|
|
203
|
+
try {
|
|
204
|
+
return G(e, t), n();
|
|
205
|
+
} finally {
|
|
206
|
+
ne(e, r);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function ie(e, t, { source: n = "inline-or-computed" } = {}) {
|
|
210
|
+
let r = W(t), i = n !== "computed" && e instanceof HTMLElement ? e.style.getPropertyValue(r) : "";
|
|
211
|
+
return !i && n !== "inline" && (i = getComputedStyle(e).getPropertyValue(r)), i.trim() ? ae(e, i) : null;
|
|
212
|
+
}
|
|
213
|
+
function ae(e, t) {
|
|
214
|
+
let n = t.trim();
|
|
215
|
+
if (!n) return 0;
|
|
216
|
+
let r = Number.parseFloat(n);
|
|
217
|
+
if (!Number.isNaN(r) && (/^-?\d*\.?\d+$/.test(n) || n.endsWith("px"))) return r;
|
|
218
|
+
let i = e.ownerDocument, a = i?.documentElement;
|
|
219
|
+
if (!Number.isNaN(r) && n.endsWith("rem")) return r * (a && Number.parseFloat(getComputedStyle(a).fontSize) || 16);
|
|
220
|
+
if (!Number.isNaN(r) && n.endsWith("em")) return r * (e instanceof HTMLElement && Number.parseFloat(getComputedStyle(e).fontSize) || 16);
|
|
221
|
+
if (!i) return Number.isNaN(r) ? 0 : r;
|
|
222
|
+
let o = i.createElement("div");
|
|
223
|
+
if (o.style.position = "absolute", o.style.visibility = "hidden", o.style.pointerEvents = "none", o.style.inlineSize = n, !o.style.inlineSize) return 0;
|
|
224
|
+
o.style.blockSize = "0", o.style.padding = "0", o.style.border = "0", o.style.inset = "0";
|
|
225
|
+
let s = getComputedStyle(e);
|
|
226
|
+
o.style.fontSize = s.fontSize;
|
|
227
|
+
for (let e = 0; e < s.length; e++) {
|
|
228
|
+
let t = s.item(e);
|
|
229
|
+
t.startsWith("--") && o.style.setProperty(t, s.getPropertyValue(t));
|
|
230
|
+
}
|
|
231
|
+
let c = i.body ?? i.documentElement;
|
|
232
|
+
if (!c) return Number.isNaN(r) ? 0 : r;
|
|
233
|
+
if (c.appendChild(o), getComputedStyle(o).inlineSize === "auto") return o.remove(), 0;
|
|
234
|
+
let l = o.getBoundingClientRect().width;
|
|
235
|
+
return o.remove(), Number.isFinite(l) ? l : Number.isNaN(r) ? 0 : r;
|
|
236
|
+
}
|
|
237
|
+
// node_modules/@videojs/utils/dist/dom/layout.js
|
|
238
|
+
function oe(e, { box: t = "bounding", overflow: n = "none" } = {}) {
|
|
239
|
+
let r = e.getBoundingClientRect(), i = t === "layout" && e.offsetWidth || r.width, a = t === "layout" && e.offsetHeight || r.height;
|
|
240
|
+
return (n === "width" || n === "both") && (i = Math.max(i, e.scrollWidth)), (n === "height" || n === "both") && (a = Math.max(a, e.scrollHeight)), {
|
|
241
|
+
width: i,
|
|
242
|
+
height: a
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function se(e, t) {
|
|
246
|
+
let n = e.getBoundingClientRect();
|
|
247
|
+
return n.width > 0 && n.height > 0 && t.clientX >= n.left && t.clientX < n.right && t.clientY >= n.top && t.clientY < n.bottom;
|
|
248
|
+
}
|
|
249
|
+
function ce(e, t = {}) {
|
|
250
|
+
let { styles: n, ...r } = t, i = () => oe(e, r);
|
|
251
|
+
return n ? re(e, n, i) : i();
|
|
252
|
+
}
|
|
253
|
+
function le(e) {
|
|
254
|
+
let t = getComputedStyle(e);
|
|
255
|
+
return {
|
|
256
|
+
inlineStart: Number.parseFloat(t.paddingInlineStart) || 0,
|
|
257
|
+
inlineEnd: Number.parseFloat(t.paddingInlineEnd) || 0,
|
|
258
|
+
blockStart: Number.parseFloat(t.paddingBlockStart) || 0,
|
|
259
|
+
blockEnd: Number.parseFloat(t.paddingBlockEnd) || 0
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function q(e) {
|
|
263
|
+
return e.inlineStart + e.inlineEnd;
|
|
264
|
+
}
|
|
265
|
+
function ue(e) {
|
|
266
|
+
return e.blockStart + e.blockEnd;
|
|
267
|
+
}
|
|
268
|
+
function de(e) {
|
|
269
|
+
let t = getComputedStyle(e);
|
|
270
|
+
return {
|
|
271
|
+
x: Number.parseFloat(t.paddingLeft) || 0,
|
|
272
|
+
y: Number.parseFloat(t.paddingTop) || 0
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function fe(e) {
|
|
276
|
+
if (e.length === 0) return {
|
|
277
|
+
width: 0,
|
|
278
|
+
height: 0
|
|
279
|
+
};
|
|
280
|
+
let t = Math.max(...e.map(({ offsetLeft: e, size: t }) => e + t.width)), n = e[0].offsetTop;
|
|
281
|
+
return {
|
|
282
|
+
width: t,
|
|
283
|
+
height: e.some(({ offsetTop: e }) => e !== n) ? Math.max(...e.map(({ offsetTop: e, size: t }) => e + t.height)) : e.reduce((e, { size: t }) => e + t.height, 0)
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function pe(e, { children: t, includePadding: n = !1, maxWidth: r = null, measure: i = (e, t) => ce(e, t === void 0 ? void 0 : { styles: { width: `${t}px` } }), resolveSize: a = fe } = {}) {
|
|
287
|
+
let o = [...t ?? Array.from(e.children).filter((e) => e instanceof HTMLElement)].filter((e) => !e.hidden), s = n ? le(e) : {
|
|
288
|
+
inlineStart: 0,
|
|
289
|
+
inlineEnd: 0,
|
|
290
|
+
blockStart: 0,
|
|
291
|
+
blockEnd: 0
|
|
292
|
+
}, c = q(s), l = ue(s), u = n ? de(e) : {
|
|
293
|
+
x: 0,
|
|
294
|
+
y: 0
|
|
295
|
+
};
|
|
296
|
+
if (o.length === 0) return {
|
|
297
|
+
width: c,
|
|
298
|
+
height: l
|
|
299
|
+
};
|
|
300
|
+
let d = (e) => o.map((t) => ({
|
|
301
|
+
element: t,
|
|
302
|
+
size: i(t, e),
|
|
303
|
+
offsetLeft: t.offsetLeft - u.x,
|
|
304
|
+
offsetTop: t.offsetTop - u.y
|
|
305
|
+
})), f = d(), p = a(f).width + c, m = r === null ? p : Math.min(p, Math.max(0, r));
|
|
306
|
+
return m < p && (f = d(Math.max(0, m - c))), {
|
|
307
|
+
width: m,
|
|
308
|
+
height: a(f).height + l
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
// node_modules/@videojs/utils/dist/dom/text-track.js
|
|
312
|
+
function me(e) {
|
|
313
|
+
return e.kind === "captions" || e.kind === "subtitles";
|
|
314
|
+
}
|
|
315
|
+
function he(e) {
|
|
316
|
+
return Array.from(e).filter(me).sort(_e);
|
|
317
|
+
}
|
|
318
|
+
function ge(e, t) {
|
|
319
|
+
if (!(e instanceof HTMLElement)) return null;
|
|
320
|
+
for (let n of e.querySelectorAll("track")) if (n.track === t) return n;
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
function _e(e, t) {
|
|
324
|
+
return e.kind > t.kind ? 1 : e.kind < t.kind ? -1 : 0;
|
|
325
|
+
}
|
|
326
|
+
// node_modules/@videojs/utils/dist/dom/time-ranges.js
|
|
327
|
+
function ve(e) {
|
|
328
|
+
let t = [];
|
|
329
|
+
for (let n = 0; n < e.length; n++) t.push([e.start(n), e.end(n)]);
|
|
330
|
+
return t;
|
|
331
|
+
}
|
|
332
|
+
// node_modules/@videojs/utils/dist/dom/webkit.js
|
|
333
|
+
function ye() {
|
|
334
|
+
return "WebKitPlaybackTargetAvailabilityEvent" in globalThis;
|
|
335
|
+
}
|
|
336
|
+
function be(e) {
|
|
337
|
+
return ye() && "webkitCurrentPlaybackTargetIsWireless" in e;
|
|
338
|
+
}
|
|
339
|
+
// node_modules/@videojs/core/dist/default/dom/store/features/audio-track.js
|
|
340
|
+
function xe(e, t) {
|
|
341
|
+
return e.id || String(t);
|
|
342
|
+
}
|
|
343
|
+
function Se(e, t) {
|
|
344
|
+
return {
|
|
345
|
+
id: xe(e, t),
|
|
346
|
+
...e.kind !== void 0 && { kind: e.kind },
|
|
347
|
+
label: e.label,
|
|
348
|
+
language: e.language,
|
|
349
|
+
enabled: e.enabled
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
var Ce = z({
|
|
353
|
+
name: "audioTrack",
|
|
354
|
+
state: ({ target: e }) => ({
|
|
355
|
+
audioTrackList: [],
|
|
356
|
+
selectAudioTrack(t) {
|
|
357
|
+
let { media: n } = e();
|
|
358
|
+
if (!M(n)) return;
|
|
359
|
+
let r = [...n.audioTracks], i = r.find((e, n) => xe(e, n) === t);
|
|
360
|
+
if (i) for (let e of r) e.enabled = e === i;
|
|
361
|
+
}
|
|
362
|
+
}),
|
|
363
|
+
attach({ target: e, signal: t, set: n }) {
|
|
364
|
+
let { media: r } = e, i = null, a = null, o = () => M(r) ? r.audioTracks : null, s = (e = o()) => {
|
|
365
|
+
n({ audioTrackList: e ? [...e].map(Se) : [] });
|
|
366
|
+
}, c = () => {
|
|
367
|
+
let e = o();
|
|
368
|
+
e === i ? s(e) : (a?.abort(), a = new AbortController(), i = e, i && (V(i, "addtrack", () => s(i), { signal: a.signal }), V(i, "removetrack", () => s(i), { signal: a.signal }), V(i, "change", () => s(i), { signal: a.signal })), s(i));
|
|
369
|
+
};
|
|
370
|
+
c(), V(r, "loadstart", c, { signal: t }), t.addEventListener("abort", () => a?.abort(), { once: !0 });
|
|
371
|
+
}
|
|
372
|
+
}), we = z({
|
|
373
|
+
name: "buffer",
|
|
374
|
+
state: () => ({
|
|
375
|
+
buffered: [],
|
|
376
|
+
seekable: []
|
|
377
|
+
}),
|
|
378
|
+
attach({ target: e, signal: t, set: n }) {
|
|
379
|
+
let { media: r } = e;
|
|
380
|
+
if (!O(r)) return;
|
|
381
|
+
let i = () => n({
|
|
382
|
+
buffered: ve(r.buffered),
|
|
383
|
+
seekable: ve(r.seekable)
|
|
384
|
+
});
|
|
385
|
+
i(), V(r, "loadedmetadata", i, { signal: t }), V(r, "durationchange", i, { signal: t }), V(r, "progress", i, { signal: t }), V(r, "emptied", i, { signal: t });
|
|
386
|
+
}
|
|
387
|
+
}), Te = /* @__PURE__ */ new WeakMap();
|
|
388
|
+
function Ee(e) {
|
|
389
|
+
return Te.get(e);
|
|
390
|
+
}
|
|
391
|
+
// node_modules/@videojs/core/dist/default/dom/presentation/remote-playback.js
|
|
392
|
+
function De(e) {
|
|
393
|
+
let t = e;
|
|
394
|
+
if (c(t.remote) && "state" in t.remote && "prompt" in t.remote) return t.remote;
|
|
395
|
+
}
|
|
396
|
+
function Oe(e) {
|
|
397
|
+
return De(e)?.state === "connected";
|
|
398
|
+
}
|
|
399
|
+
function ke(e) {
|
|
400
|
+
return De(e)?.state === "connecting";
|
|
401
|
+
}
|
|
402
|
+
async function Ae(e) {
|
|
403
|
+
let t = De(e);
|
|
404
|
+
if (!t) throw new DOMException("Remote playback not supported", "NotSupportedError");
|
|
405
|
+
return t.prompt();
|
|
406
|
+
}
|
|
407
|
+
// node_modules/@videojs/core/dist/default/dom/store/features/controls.js
|
|
408
|
+
var je = 2e3, Me = 250, Ne = 500, Pe = 100, Fe = /* @__PURE__ */ new WeakMap(), Ie = z({
|
|
409
|
+
name: "controls",
|
|
410
|
+
state: ({ get: e, set: t }) => {
|
|
411
|
+
let n = Le(() => (t({ controlsVisible: !0 }), () => {}), (n) => {
|
|
412
|
+
let r = n ?? !e().userActive;
|
|
413
|
+
return t({
|
|
414
|
+
userActive: r,
|
|
415
|
+
controlsVisible: r
|
|
416
|
+
}), r;
|
|
417
|
+
});
|
|
418
|
+
return Fe.set(n.requestControlsLock, n), {
|
|
419
|
+
userActive: !0,
|
|
420
|
+
controlsVisible: !0,
|
|
421
|
+
requestControlsLock: n.requestControlsLock,
|
|
422
|
+
toggleControls: n.toggleControls
|
|
423
|
+
};
|
|
424
|
+
},
|
|
425
|
+
attach({ target: e, signal: t, get: n, set: r }) {
|
|
426
|
+
let { media: a, container: o } = e;
|
|
427
|
+
if (!x(a) || i(o)) return;
|
|
428
|
+
let s, c = 0, l = (e) => c > 0 || e || a.paused || Oe(a) || ke(a);
|
|
429
|
+
function u() {
|
|
430
|
+
clearTimeout(s), s = void 0;
|
|
431
|
+
}
|
|
432
|
+
function d() {
|
|
433
|
+
u(), !(c > 0) && (s = setTimeout(p, je));
|
|
434
|
+
}
|
|
435
|
+
function f() {
|
|
436
|
+
n().userActive || r({
|
|
437
|
+
userActive: !0,
|
|
438
|
+
controlsVisible: !0
|
|
439
|
+
}), d();
|
|
440
|
+
}
|
|
441
|
+
function p() {
|
|
442
|
+
u(), r({
|
|
443
|
+
userActive: !1,
|
|
444
|
+
controlsVisible: l(!1)
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function m() {
|
|
448
|
+
c++, u(), n().controlsVisible || r({ controlsVisible: !0 });
|
|
449
|
+
let e = !1;
|
|
450
|
+
return () => {
|
|
451
|
+
e || t.aborted || (e = !0, c--, c === 0 && f());
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function h(e) {
|
|
455
|
+
return e ?? !n().controlsVisible ? f() : p(), n().controlsVisible;
|
|
456
|
+
}
|
|
457
|
+
let _ = Fe.get(n().requestControlsLock);
|
|
458
|
+
_.setDelegates(m, h);
|
|
459
|
+
let v = 0, y = 0, b = () => y > 0 && Date.now() - y < Ne, S = 0, C = () => S > 0 && Date.now() - S < Pe;
|
|
460
|
+
function w(e) {
|
|
461
|
+
v = Date.now(), e.pointerType === "touch" && (y = v);
|
|
462
|
+
}
|
|
463
|
+
function T(e) {
|
|
464
|
+
if (e.pointerType === "touch" && (y = Date.now()), e.pointerType === "touch" && Date.now() - v < Me) {
|
|
465
|
+
if (Ee(o)?.claimsTap(e, "toggleControls")) return;
|
|
466
|
+
let t = [g(a), o].includes(e.target);
|
|
467
|
+
n().controlsVisible && t ? p() : f();
|
|
468
|
+
} else f();
|
|
469
|
+
}
|
|
470
|
+
let E = () => {
|
|
471
|
+
let { userActive: e } = n();
|
|
472
|
+
r({ controlsVisible: l(e) }), !a.paused && e && d();
|
|
473
|
+
};
|
|
474
|
+
function D(e) {
|
|
475
|
+
e.pointerType === "touch" ? n().userActive && d() : f();
|
|
476
|
+
}
|
|
477
|
+
if (V(o, "pointermove", D, { signal: t }), V(o, "pointerdown", w, { signal: t }), V(o, "pointerup", T, { signal: t }), V(o, "lostpointercapture", () => {
|
|
478
|
+
S = Date.now();
|
|
479
|
+
}, { signal: t }), V(o, "keydown", f, { signal: t }), V(o, "keyup", f, { signal: t }), V(o, "focusin", () => {
|
|
480
|
+
b() || f();
|
|
481
|
+
}, { signal: t }), V(o, "mouseleave", (e) => {
|
|
482
|
+
b() || C() && e instanceof MouseEvent && se(o, e) || p();
|
|
483
|
+
}, { signal: t }), V(a, "play", E, { signal: t }), V(a, "pause", E, { signal: t }), V(a, "ended", E, { signal: t }), P(a)) {
|
|
484
|
+
let e = () => {
|
|
485
|
+
let { userActive: e } = n();
|
|
486
|
+
r({ controlsVisible: l(e) });
|
|
487
|
+
};
|
|
488
|
+
V(a.remote, "connect", e, { signal: t }), V(a.remote, "connecting", e, { signal: t }), V(a.remote, "disconnect", e, { signal: t });
|
|
489
|
+
}
|
|
490
|
+
t.addEventListener("abort", () => {
|
|
491
|
+
_.reset(), c = 0, u();
|
|
492
|
+
}, { once: !0 }), d();
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
function Le(e, t) {
|
|
496
|
+
let n = e, r = t, i = /* @__PURE__ */ new Set(), a = {
|
|
497
|
+
requestControlsLock: () => {
|
|
498
|
+
let e = { release: n() }, t = !1;
|
|
499
|
+
return i.add(e), () => {
|
|
500
|
+
t || (t = !0, i.delete(e), e.release());
|
|
501
|
+
};
|
|
502
|
+
},
|
|
503
|
+
toggleControls: (e) => r(e),
|
|
504
|
+
setDelegates(e, t) {
|
|
505
|
+
if (e !== n) {
|
|
506
|
+
n = e;
|
|
507
|
+
for (let t of i) t.release(), t.release = e();
|
|
508
|
+
}
|
|
509
|
+
r = t;
|
|
510
|
+
},
|
|
511
|
+
reset() {
|
|
512
|
+
a.setDelegates(e, t);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
return a;
|
|
516
|
+
}
|
|
517
|
+
// node_modules/@videojs/core/dist/default/dom/store/features/error.js
|
|
518
|
+
var Re = z({
|
|
519
|
+
name: "error",
|
|
520
|
+
state: ({ set: e }) => ({
|
|
521
|
+
error: null,
|
|
522
|
+
dismissError() {
|
|
523
|
+
e({ error: null });
|
|
524
|
+
}
|
|
525
|
+
}),
|
|
526
|
+
attach({ target: e, signal: t, set: n }) {
|
|
527
|
+
let { media: r } = e;
|
|
528
|
+
k(r) && (V(r, "error", () => n({ error: r.error }), { signal: t }), V(r, "emptied", () => n({ error: null }), { signal: t }));
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
// node_modules/@videojs/core/dist/default/dom/presentation/fullscreen.js
|
|
532
|
+
function ze() {
|
|
533
|
+
let e = document;
|
|
534
|
+
return e.fullscreenEnabled || e.webkitFullscreenEnabled ? !0 : r(document.createElement("video").webkitSetPresentationMode);
|
|
535
|
+
}
|
|
536
|
+
function Be() {
|
|
537
|
+
let e = document;
|
|
538
|
+
return e.fullscreenElement ?? e.webkitFullscreenElement ?? null;
|
|
539
|
+
}
|
|
540
|
+
function Ve(e) {
|
|
541
|
+
if (!(e instanceof Element)) return !1;
|
|
542
|
+
try {
|
|
543
|
+
return e.matches(":fullscreen");
|
|
544
|
+
} catch {
|
|
545
|
+
return !1;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function He(e, t) {
|
|
549
|
+
if (t.webkitPresentationMode === "fullscreen") return !0;
|
|
550
|
+
let n = Be();
|
|
551
|
+
return n && (n === e || n === g(t)) || Ve(e) || Ve(t) ? !0 : t.isFullscreen ?? !1;
|
|
552
|
+
}
|
|
553
|
+
async function Ue(e, t) {
|
|
554
|
+
let n = document;
|
|
555
|
+
if (e && (n.fullscreenEnabled || n.webkitFullscreenEnabled)) {
|
|
556
|
+
let t = e;
|
|
557
|
+
if (r(t.requestFullscreen)) return t.requestFullscreen();
|
|
558
|
+
if (r(t.webkitRequestFullscreen)) return t.webkitRequestFullscreen();
|
|
559
|
+
}
|
|
560
|
+
let i = t;
|
|
561
|
+
if (r(i.webkitSetPresentationMode)) {
|
|
562
|
+
i.webkitSetPresentationMode("fullscreen");
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
let a = t;
|
|
566
|
+
if (r(a.requestFullscreen)) return a.requestFullscreen();
|
|
567
|
+
}
|
|
568
|
+
async function We(e) {
|
|
569
|
+
let t = document, n = e;
|
|
570
|
+
if (n.webkitPresentationMode === "fullscreen" && r(n.webkitSetPresentationMode)) {
|
|
571
|
+
n.webkitSetPresentationMode("inline");
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
if (r(t.exitFullscreen)) return t.exitFullscreen();
|
|
575
|
+
if (r(t.webkitExitFullscreen)) return t.webkitExitFullscreen();
|
|
576
|
+
let i = e;
|
|
577
|
+
if (r(i.exitFullscreen)) return i.exitFullscreen();
|
|
578
|
+
}
|
|
579
|
+
// node_modules/@videojs/core/dist/default/dom/presentation/pip.js
|
|
580
|
+
function Ge() {
|
|
581
|
+
if (document.pictureInPictureEnabled) {
|
|
582
|
+
let e = /.*Version\/.*Safari\/.*/.test(navigator.userAgent), t = typeof matchMedia == "function" && matchMedia("(display-mode: standalone)").matches;
|
|
583
|
+
return !e || !t;
|
|
584
|
+
}
|
|
585
|
+
return r(document.createElement("video").webkitSetPresentationMode);
|
|
586
|
+
}
|
|
587
|
+
function Ke(e) {
|
|
588
|
+
return r(e.webkitSetPresentationMode) ? !0 : D(e);
|
|
589
|
+
}
|
|
590
|
+
function qe(e) {
|
|
591
|
+
return e.webkitPresentationMode === "picture-in-picture" || document.pictureInPictureElement === g(e) ? !0 : e.isPictureInPicture ?? !1;
|
|
592
|
+
}
|
|
593
|
+
async function Je(e) {
|
|
594
|
+
let t = e;
|
|
595
|
+
if (r(t.webkitSetPresentationMode)) {
|
|
596
|
+
t.webkitSetPresentationMode("picture-in-picture");
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
let n = e;
|
|
600
|
+
if (r(n.requestPictureInPicture)) return n.requestPictureInPicture();
|
|
601
|
+
}
|
|
602
|
+
async function Ye(e) {
|
|
603
|
+
let t = e;
|
|
604
|
+
if (t.webkitPresentationMode === "picture-in-picture" && r(t.webkitSetPresentationMode)) {
|
|
605
|
+
t.webkitSetPresentationMode("inline");
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (r(document.exitPictureInPicture)) return document.exitPictureInPicture();
|
|
609
|
+
let n = e;
|
|
610
|
+
if (r(n.exitPictureInPicture)) return n.exitPictureInPicture();
|
|
611
|
+
}
|
|
612
|
+
// node_modules/@videojs/core/dist/default/dom/store/features/fullscreen.js
|
|
613
|
+
var Xe = z({
|
|
614
|
+
name: "fullscreen",
|
|
615
|
+
state: ({ target: e }) => ({
|
|
616
|
+
isFullscreen: !1,
|
|
617
|
+
fullscreenAvailability: "unavailable",
|
|
618
|
+
async requestFullscreen() {
|
|
619
|
+
let { media: t, container: n } = e();
|
|
620
|
+
return qe(t) && await Ye(t), Ue(n, t);
|
|
621
|
+
},
|
|
622
|
+
async exitFullscreen() {
|
|
623
|
+
let { media: t } = e();
|
|
624
|
+
return We(t);
|
|
625
|
+
}
|
|
626
|
+
}),
|
|
627
|
+
attach({ target: e, signal: t, set: n }) {
|
|
628
|
+
let { media: r, container: i } = e;
|
|
629
|
+
n({ fullscreenAvailability: ze() ? "available" : "unsupported" });
|
|
630
|
+
let a = () => n({ isFullscreen: He(i, r) });
|
|
631
|
+
a(), V(document, "fullscreenchange", a, { signal: t }), V(document, "webkitfullscreenchange", a, { signal: t }), "webkitPresentationMode" in r && V(r, "webkitpresentationmodechanged", a, { signal: t });
|
|
632
|
+
}
|
|
633
|
+
}), Ze = Symbol("@videojs/media-title"), Qe = Symbol("@videojs/user-title"), $e = Symbol("@videojs/set-user-title"), et = "", tt = Symbol("@videojs/media-poster"), nt = Symbol("@videojs/user-poster"), rt = Symbol("@videojs/set-user-poster"), it = "", at = z({
|
|
634
|
+
name: "metadata",
|
|
635
|
+
config: {
|
|
636
|
+
title: {
|
|
637
|
+
action: $e,
|
|
638
|
+
state: Qe,
|
|
639
|
+
html: { attribute: "content-title" }
|
|
640
|
+
},
|
|
641
|
+
poster: {
|
|
642
|
+
action: rt,
|
|
643
|
+
state: nt
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
state: ({ set: e }) => ({
|
|
647
|
+
[Ze]: void 0,
|
|
648
|
+
[Qe]: void 0,
|
|
649
|
+
[$e]: (t) => e({ [Qe]: t }),
|
|
650
|
+
[tt]: void 0,
|
|
651
|
+
[nt]: void 0,
|
|
652
|
+
[rt]: (t) => e({ [nt]: t })
|
|
653
|
+
}),
|
|
654
|
+
derived: {
|
|
655
|
+
title: ({ get: e }) => e()[Qe] ?? e()[Ze] ?? et,
|
|
656
|
+
poster: ({ get: e }) => e()[nt] ?? e()[tt] ?? it
|
|
657
|
+
},
|
|
658
|
+
attach({ target: e, signal: t, set: n }) {
|
|
659
|
+
let { media: r } = e, i = () => {
|
|
660
|
+
let e = I(r) ? r.contentData : void 0;
|
|
661
|
+
n({
|
|
662
|
+
[Ze]: e?.title,
|
|
663
|
+
[tt]: e?.poster
|
|
664
|
+
});
|
|
665
|
+
}, a = () => {
|
|
666
|
+
i(), I(r) && V(r, "contentdatachange", i, { signal: t });
|
|
667
|
+
};
|
|
668
|
+
a(), V(r, "loadstart", a, { signal: t });
|
|
669
|
+
}
|
|
670
|
+
}), ot = z({
|
|
671
|
+
name: "pip",
|
|
672
|
+
state: ({ target: e }) => ({
|
|
673
|
+
isPictureInPicture: !1,
|
|
674
|
+
pictureInPictureAvailability: "unavailable",
|
|
675
|
+
async requestPictureInPicture() {
|
|
676
|
+
let { media: t, container: n } = e();
|
|
677
|
+
if (Ke(t)) {
|
|
678
|
+
if (!C(t) || !b(t)) throw new DOMException("The media has no video data yet.", "InvalidStateError");
|
|
679
|
+
return He(n, t) && await We(t), Je(t);
|
|
680
|
+
}
|
|
681
|
+
},
|
|
682
|
+
async exitPictureInPicture() {
|
|
683
|
+
let { media: t } = e();
|
|
684
|
+
return Ye(t);
|
|
685
|
+
}
|
|
686
|
+
}),
|
|
687
|
+
attach({ target: e, signal: t, set: n }) {
|
|
688
|
+
let { media: r } = e, i = Ge() && Ke(r), a = () => n({
|
|
689
|
+
isPictureInPicture: qe(r),
|
|
690
|
+
pictureInPictureAvailability: i ? C(r) && b(r) ? "available" : "unavailable" : "unsupported"
|
|
691
|
+
});
|
|
692
|
+
a(), V(r, "enterpictureinpicture", a, { signal: t }), V(r, "leavepictureinpicture", a, { signal: t }), V(r, "loadstart", a, { signal: t }), V(r, "loadedmetadata", a, { signal: t }), V(r, "emptied", a, { signal: t }), "webkitPresentationMode" in r && V(r, "webkitpresentationmodechanged", a, { signal: t });
|
|
693
|
+
}
|
|
694
|
+
}), st = z({
|
|
695
|
+
name: "playback",
|
|
696
|
+
state: ({ target: e, set: t }) => ({
|
|
697
|
+
paused: !0,
|
|
698
|
+
ended: !1,
|
|
699
|
+
started: !1,
|
|
700
|
+
waiting: !1,
|
|
701
|
+
play() {
|
|
702
|
+
let { media: n } = e(), r = n.play();
|
|
703
|
+
return x(n) && !n.paused && t({
|
|
704
|
+
paused: !1,
|
|
705
|
+
ended: !1,
|
|
706
|
+
started: !0
|
|
707
|
+
}), r;
|
|
708
|
+
},
|
|
709
|
+
pause() {
|
|
710
|
+
let { media: n } = e();
|
|
711
|
+
x(n) && (n.pause(), t({ paused: n.paused }));
|
|
712
|
+
}
|
|
713
|
+
}),
|
|
714
|
+
attach({ target: e, signal: t, set: n }) {
|
|
715
|
+
let { media: r } = e;
|
|
716
|
+
if (!x(r) || !S(r) || !C(r)) return;
|
|
717
|
+
let i = null, a = () => {
|
|
718
|
+
let e = r.readyState < HTMLMediaElement.HAVE_FUTURE_DATA && !r.paused;
|
|
719
|
+
e ? i ??= r.currentTime : i = null, n({
|
|
720
|
+
paused: r.paused,
|
|
721
|
+
ended: r.ended,
|
|
722
|
+
started: !r.paused || r.currentTime > 0,
|
|
723
|
+
waiting: e && i === r.currentTime
|
|
724
|
+
});
|
|
725
|
+
}, o = () => {
|
|
726
|
+
i = r.currentTime, a();
|
|
727
|
+
};
|
|
728
|
+
a(), V(r, "emptied", o, { signal: t }), V(r, "play", o, { signal: t }), V(r, "pause", a, { signal: t }), V(r, "ended", a, { signal: t }), V(r, "playing", a, { signal: t }), V(r, "waiting", o, { signal: t }), V(r, "seeking", o, { signal: t }), V(r, "seeked", a, { signal: t }), V(r, "canplay", a, { signal: t }), V(r, "timeupdate", a, { signal: t });
|
|
729
|
+
}
|
|
730
|
+
}), ct = [
|
|
731
|
+
.2,
|
|
732
|
+
.5,
|
|
733
|
+
.7,
|
|
734
|
+
1,
|
|
735
|
+
1.2,
|
|
736
|
+
1.5,
|
|
737
|
+
1.7,
|
|
738
|
+
2
|
|
739
|
+
], lt = z({
|
|
740
|
+
name: "playbackRate",
|
|
741
|
+
state: ({ target: e }) => ({
|
|
742
|
+
playbackRates: ct,
|
|
743
|
+
playbackRate: 1,
|
|
744
|
+
setPlaybackRate(t) {
|
|
745
|
+
let { media: n } = e();
|
|
746
|
+
E(n) && (n.playbackRate = t);
|
|
747
|
+
}
|
|
748
|
+
}),
|
|
749
|
+
attach({ target: e, signal: t, set: n }) {
|
|
750
|
+
let { media: r } = e;
|
|
751
|
+
if (!E(r)) return;
|
|
752
|
+
let i = () => n({ playbackRate: r.playbackRate });
|
|
753
|
+
i(), V(r, "ratechange", i, { signal: t });
|
|
754
|
+
}
|
|
755
|
+
}), ut = "auto";
|
|
756
|
+
function dt(e, t) {
|
|
757
|
+
return e.id || String(t);
|
|
758
|
+
}
|
|
759
|
+
function ft(e, t) {
|
|
760
|
+
return {
|
|
761
|
+
id: dt(e, t),
|
|
762
|
+
...e.width !== void 0 && { width: e.width },
|
|
763
|
+
...e.height !== void 0 && { height: e.height },
|
|
764
|
+
...e.bitrate !== void 0 && { bitrate: e.bitrate },
|
|
765
|
+
...e.frameRate !== void 0 && { frameRate: e.frameRate },
|
|
766
|
+
...e.codec !== void 0 && { codec: e.codec },
|
|
767
|
+
selected: e.selected
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
function pt(e) {
|
|
771
|
+
return e.width && e.height ? Math.min(e.width, e.height) : e.height ?? e.width;
|
|
772
|
+
}
|
|
773
|
+
var mt = z({
|
|
774
|
+
name: "quality",
|
|
775
|
+
state: ({ target: e }) => ({
|
|
776
|
+
videoRenditionList: [],
|
|
777
|
+
activeVideoRendition: null,
|
|
778
|
+
selectVideoRendition(t) {
|
|
779
|
+
let { media: n } = e();
|
|
780
|
+
if (!j(n)) return;
|
|
781
|
+
if (t === ut) {
|
|
782
|
+
n.videoRenditions.selectedIndex = -1;
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
let r = [...n.videoRenditions].findIndex((e, n) => dt(e, n) === t);
|
|
786
|
+
r !== -1 && (n.videoRenditions.selectedIndex = r);
|
|
787
|
+
}
|
|
788
|
+
}),
|
|
789
|
+
attach({ target: e, signal: t, set: n }) {
|
|
790
|
+
let { media: r } = e, i = null, a = null, o = () => j(r) ? r.videoRenditions : null, s = (e) => {
|
|
791
|
+
if (!e) return null;
|
|
792
|
+
let t = [...e], n = t.find((e) => e.active);
|
|
793
|
+
if (n) return n;
|
|
794
|
+
if (!N(r) || !r.videoWidth && !r.videoHeight) return null;
|
|
795
|
+
let i = pt({
|
|
796
|
+
width: r.videoWidth || void 0,
|
|
797
|
+
height: r.videoHeight || void 0
|
|
798
|
+
}), a = t.filter((e) => pt(e) === i);
|
|
799
|
+
return a.length === 1 ? a[0] : null;
|
|
800
|
+
}, c = (e = o()) => {
|
|
801
|
+
let t = e ? [...e] : [], r = s(e);
|
|
802
|
+
n({
|
|
803
|
+
videoRenditionList: t.map(ft),
|
|
804
|
+
activeVideoRendition: r ? ft(r, t.indexOf(r)) : null
|
|
805
|
+
});
|
|
806
|
+
}, l = () => {
|
|
807
|
+
let e = o();
|
|
808
|
+
e === i ? c(e) : (a?.abort(), a = new AbortController(), i = e, i && (V(i, "addrendition", () => c(i), { signal: a.signal }), V(i, "removerendition", () => c(i), { signal: a.signal }), V(i, "change", () => c(i), { signal: a.signal }), V(i, "activechange", () => c(i), { signal: a.signal })), c(i));
|
|
809
|
+
};
|
|
810
|
+
l(), V(r, "loadstart", l, { signal: t }), V(r, "resize", () => c(i), { signal: t }), t.addEventListener("abort", () => a?.abort(), { once: !0 });
|
|
811
|
+
}
|
|
812
|
+
}), ht = z({
|
|
813
|
+
name: "remotePlayback",
|
|
814
|
+
state: ({ target: e }) => ({
|
|
815
|
+
remotePlaybackState: "disconnected",
|
|
816
|
+
remotePlaybackAvailability: "unsupported",
|
|
817
|
+
async promptRemotePlayback() {
|
|
818
|
+
let { media: t, container: n } = e();
|
|
819
|
+
return Oe(t) ? Ae(t) : (He(n, t) && await We(t), await Ae(t));
|
|
820
|
+
}
|
|
821
|
+
}),
|
|
822
|
+
attach({ target: e, signal: t, set: n }) {
|
|
823
|
+
let { media: r } = e;
|
|
824
|
+
if (!P(r)) return;
|
|
825
|
+
if (be(r)) {
|
|
826
|
+
let e = () => {
|
|
827
|
+
n({ remotePlaybackState: r.webkitCurrentPlaybackTargetIsWireless ? "connected" : "disconnected" });
|
|
828
|
+
};
|
|
829
|
+
V(r, "webkitplaybacktargetavailabilitychanged", (e) => {
|
|
830
|
+
let { availability: t } = e;
|
|
831
|
+
n({ remotePlaybackAvailability: t === "available" ? "available" : "unavailable" });
|
|
832
|
+
}, { signal: t }), V(r, "webkitcurrentplaybacktargetiswirelesschanged", e, { signal: t }), e();
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
let i = () => n({ remotePlaybackState: r.remote.state });
|
|
836
|
+
i(), V(r.remote, "connect", i, { signal: t }), V(r.remote, "connecting", i, { signal: t }), V(r.remote, "disconnect", i, { signal: t }), r.remote.watchAvailability((e) => {
|
|
837
|
+
n({ remotePlaybackAvailability: e ? "available" : "unavailable" });
|
|
838
|
+
}).catch(() => {
|
|
839
|
+
n({ remotePlaybackAvailability: "unsupported" });
|
|
840
|
+
}), t.addEventListener("abort", () => {
|
|
841
|
+
r.remote?.cancelWatchAvailability?.().catch(() => {});
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
}), gt = z({
|
|
845
|
+
name: "source",
|
|
846
|
+
state: () => ({
|
|
847
|
+
currentSrc: "",
|
|
848
|
+
canPlay: !1
|
|
849
|
+
}),
|
|
850
|
+
attach({ target: e, signal: t, set: n }) {
|
|
851
|
+
let { media: r } = e;
|
|
852
|
+
if (!C(r)) return;
|
|
853
|
+
let i = () => n({
|
|
854
|
+
currentSrc: r.currentSrc,
|
|
855
|
+
canPlay: r.readyState >= v.HAVE_FUTURE_DATA
|
|
856
|
+
});
|
|
857
|
+
i(), V(r, "canplay", i, { signal: t }), V(r, "canplaythrough", i, { signal: t }), V(r, "loadstart", i, { signal: t }), V(r, "emptied", i, { signal: t });
|
|
858
|
+
}
|
|
859
|
+
}), _t = Object.prototype.hasOwnProperty;
|
|
860
|
+
function vt(e, t) {
|
|
861
|
+
if (Object.is(e, t)) return !0;
|
|
862
|
+
if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
|
|
863
|
+
let n = Reflect.ownKeys(e), r = Reflect.ownKeys(t);
|
|
864
|
+
if (n.length !== r.length) return !1;
|
|
865
|
+
for (let r of n) if (!_t.call(t, r) || !Object.is(e[r], t[r])) return !1;
|
|
866
|
+
return !0;
|
|
867
|
+
}
|
|
868
|
+
// node_modules/@videojs/core/dist/default/core/i18n/registry.js
|
|
869
|
+
var yt = Symbol.for("@videojs/i18n-registry");
|
|
870
|
+
function bt() {
|
|
871
|
+
let e = globalThis, t = e[yt];
|
|
872
|
+
if (t) return t;
|
|
873
|
+
let n = {
|
|
874
|
+
layers: /* @__PURE__ */ new Map(),
|
|
875
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
876
|
+
};
|
|
877
|
+
return e[yt] = n, n;
|
|
878
|
+
}
|
|
879
|
+
function xt(e) {
|
|
880
|
+
return e.trim().replaceAll("_", "-").toLowerCase();
|
|
881
|
+
}
|
|
882
|
+
function St(e) {
|
|
883
|
+
let t = e.indexOf("-x-"), n = (t === -1 ? e : e.slice(0, t)).indexOf("-u-");
|
|
884
|
+
return n === -1 ? e : e.slice(0, n) + (t === -1 ? "" : e.slice(t));
|
|
885
|
+
}
|
|
886
|
+
function Ct(e) {
|
|
887
|
+
if (e[0] !== "zh") return;
|
|
888
|
+
let t = e.find((e) => e === "hant" || e === "hans");
|
|
889
|
+
return t === "hant" ? "zh-tw" : t === "hans" ? "zh-cn" : void 0;
|
|
890
|
+
}
|
|
891
|
+
function wt(e) {
|
|
892
|
+
return St(xt(e));
|
|
893
|
+
}
|
|
894
|
+
function Tt(e) {
|
|
895
|
+
let t = wt(e);
|
|
896
|
+
if (!t) return ["en"];
|
|
897
|
+
let n = t.split("-").filter(Boolean), r = [];
|
|
898
|
+
for (let e = n.length; e >= 1; e--) r.push(n.slice(0, e).join("-"));
|
|
899
|
+
let i = Ct(n), a = r.indexOf("zh");
|
|
900
|
+
i && a !== -1 && r.splice(a, 0, i);
|
|
901
|
+
let o = [], s = /* @__PURE__ */ new Set();
|
|
902
|
+
for (let e of r) s.has(e) || (s.add(e), o.push(e));
|
|
903
|
+
return s.has("en") || o.push("en"), o;
|
|
904
|
+
}
|
|
905
|
+
function Et(e) {
|
|
906
|
+
let { layers: t } = bt(), n = {};
|
|
907
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
908
|
+
let i = e[r], a = t.get(i);
|
|
909
|
+
a && Object.assign(n, a);
|
|
910
|
+
}
|
|
911
|
+
return n;
|
|
912
|
+
}
|
|
913
|
+
function Dt(e) {
|
|
914
|
+
return Et(Tt(e));
|
|
915
|
+
}
|
|
916
|
+
function Ot(e) {
|
|
917
|
+
let { subscribers: t } = bt();
|
|
918
|
+
return t.add(e), () => {
|
|
919
|
+
t.delete(e);
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
// node_modules/@videojs/core/dist/default/dom/store/text-cues.js
|
|
923
|
+
function kt(e, t) {
|
|
924
|
+
if (!e) return [];
|
|
925
|
+
let n = Number.isFinite(t) && t > 0 ? t : Infinity;
|
|
926
|
+
return Array.from(e, (e) => ({
|
|
927
|
+
startTime: e.startTime,
|
|
928
|
+
endTime: Math.min(e.endTime, n),
|
|
929
|
+
text: e.text ?? ""
|
|
930
|
+
}));
|
|
931
|
+
}
|
|
932
|
+
// node_modules/@videojs/core/dist/default/dom/store/features/text-track.js
|
|
933
|
+
function At(e, t) {
|
|
934
|
+
return e.id || `track:${t}:${e.kind}:${e.language}:${e.label}`;
|
|
935
|
+
}
|
|
936
|
+
function jt(e) {
|
|
937
|
+
return he(Array.from(e.textTracks, (e, t) => ({
|
|
938
|
+
id: At(e, t),
|
|
939
|
+
kind: e.kind,
|
|
940
|
+
track: e
|
|
941
|
+
})));
|
|
942
|
+
}
|
|
943
|
+
function Mt(e, t) {
|
|
944
|
+
for (let { track: n } of e) {
|
|
945
|
+
let e = n === t ? "showing" : "disabled";
|
|
946
|
+
n.mode !== e && (n.mode = e);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
function Nt(e, t) {
|
|
950
|
+
let n = wt(t), r = Tt(t);
|
|
951
|
+
n !== "en" && !n.startsWith("en-") && r.pop();
|
|
952
|
+
for (let t of r) {
|
|
953
|
+
let n = e.find(({ track: e }) => wt(e.language) === t);
|
|
954
|
+
if (n) return n;
|
|
955
|
+
let r = e.find(({ track: e }) => wt(e.language).startsWith(`${t}-`));
|
|
956
|
+
if (r) return r;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
var Pt = z({
|
|
960
|
+
name: "textTrack",
|
|
961
|
+
state: ({ target: e }) => {
|
|
962
|
+
let t = null;
|
|
963
|
+
return {
|
|
964
|
+
textTrackList: [],
|
|
965
|
+
subtitlesShowing: !1,
|
|
966
|
+
toggleSubtitles(n) {
|
|
967
|
+
let { media: r } = e();
|
|
968
|
+
if (!A(r)) return !1;
|
|
969
|
+
let i = jt(r);
|
|
970
|
+
if (!i.length) return !1;
|
|
971
|
+
let a = i.find(({ track: e }) => e.mode === "showing"), o = n ?? !a;
|
|
972
|
+
if (a && (t = a.id), !o) return Mt(i, null), !1;
|
|
973
|
+
let s = a ?? i.find(({ id: e }) => e === t) ?? Nt(i, globalThis.navigator?.language ?? "") ?? i[0];
|
|
974
|
+
return t = s.id, Mt(i, s.track), !0;
|
|
975
|
+
},
|
|
976
|
+
selectSubtitlesTrack(n) {
|
|
977
|
+
let { media: r } = e();
|
|
978
|
+
if (!A(r)) return;
|
|
979
|
+
let a = jt(r);
|
|
980
|
+
if (!a.length) return;
|
|
981
|
+
if (i(n)) {
|
|
982
|
+
let e = a.find(({ track: e }) => e.mode === "showing");
|
|
983
|
+
e && (t = e.id), Mt(a, null);
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
let o = a.find((e) => e.id === n);
|
|
987
|
+
o && (t = o.id, Mt(a, o.track));
|
|
988
|
+
},
|
|
989
|
+
chaptersCues: [],
|
|
990
|
+
thumbnailsTrack: null
|
|
991
|
+
};
|
|
992
|
+
},
|
|
993
|
+
attach({ target: e, signal: t, set: n }) {
|
|
994
|
+
let { media: r } = e;
|
|
995
|
+
if (!A(r)) return;
|
|
996
|
+
let i = null, a = () => {
|
|
997
|
+
i?.abort(), i = new AbortController();
|
|
998
|
+
let e = null, t = null, o = [], s = !1;
|
|
999
|
+
for (let n = 0; n < r.textTracks.length; n++) {
|
|
1000
|
+
let i = r.textTracks[n];
|
|
1001
|
+
!e && i.kind === "chapters" && (e = i), !t && i.kind === "metadata" && i.label === "thumbnails" && (t = i), o.push({
|
|
1002
|
+
id: At(i, n),
|
|
1003
|
+
kind: i.kind,
|
|
1004
|
+
label: i.label,
|
|
1005
|
+
language: i.language,
|
|
1006
|
+
mode: i.mode
|
|
1007
|
+
}), me(i) && i.mode === "showing" && (s = !0);
|
|
1008
|
+
}
|
|
1009
|
+
let c = kt(e?.cues, S(r) ? r.duration : NaN), l = null;
|
|
1010
|
+
t && (l = {
|
|
1011
|
+
cues: t.cues ? Array.from(t.cues) : [],
|
|
1012
|
+
src: ge(r, t)?.src ?? null,
|
|
1013
|
+
crossOrigin: C(r) ? _(r.crossOrigin) : null
|
|
1014
|
+
});
|
|
1015
|
+
let u = R(r) && r.querySelectorAll("track") || [], d = r instanceof HTMLElement && r.shadowRoot?.querySelectorAll("track") || [];
|
|
1016
|
+
for (let e of [...u, ...d]) e.track?.cues?.length || V(e, "load", a, { signal: i.signal });
|
|
1017
|
+
n({
|
|
1018
|
+
textTrackList: o,
|
|
1019
|
+
subtitlesShowing: s,
|
|
1020
|
+
chaptersCues: c,
|
|
1021
|
+
thumbnailsTrack: l
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
a();
|
|
1025
|
+
let o = r.textTracks;
|
|
1026
|
+
o instanceof EventTarget && (V(o, "addtrack", a, { signal: t }), V(o, "removetrack", a, { signal: t }), V(o, "change", a, { signal: t })), V(r, "loadstart", a, { signal: t }), V(r, "durationchange", a, { signal: t }), t.addEventListener("abort", () => i?.abort(), { once: !0 });
|
|
1027
|
+
}
|
|
1028
|
+
}), Ft = { seek: Symbol.for("@videojs/seek") }, It = z({
|
|
1029
|
+
name: "time",
|
|
1030
|
+
state: ({ target: e, signals: t, set: n }) => ({
|
|
1031
|
+
currentTime: 0,
|
|
1032
|
+
duration: 0,
|
|
1033
|
+
seeking: !1,
|
|
1034
|
+
async seek(r) {
|
|
1035
|
+
let { media: i } = e(), a = t.supersede(Ft.seek);
|
|
1036
|
+
if (!S(i) || !C(i)) return 0;
|
|
1037
|
+
if (V(i, "emptied", () => t.supersede(Ft.seek), {
|
|
1038
|
+
signal: a,
|
|
1039
|
+
once: !0
|
|
1040
|
+
}), !b(i) && !await H(i, "loadedmetadata", { signal: a }).catch(() => !1)) return i.currentTime;
|
|
1041
|
+
let o = Math.max(0, Math.min(r, i.duration || Infinity));
|
|
1042
|
+
return n({
|
|
1043
|
+
currentTime: o,
|
|
1044
|
+
seeking: !0
|
|
1045
|
+
}), i.currentTime = o, await H(i, "seeked", { signal: a }).catch(ee), i.currentTime;
|
|
1046
|
+
}
|
|
1047
|
+
}),
|
|
1048
|
+
attach({ target: e, signal: t, set: n, get: r }) {
|
|
1049
|
+
let { media: i } = e;
|
|
1050
|
+
if (!S(i)) return;
|
|
1051
|
+
let a = () => {
|
|
1052
|
+
let { duration: e } = i;
|
|
1053
|
+
if (e === Infinity && O(i)) {
|
|
1054
|
+
let { seekable: e } = i;
|
|
1055
|
+
return e.length > 0 ? e.end(e.length - 1) : 0;
|
|
1056
|
+
}
|
|
1057
|
+
return Number.isFinite(e) ? e : 0;
|
|
1058
|
+
}, o = () => n({
|
|
1059
|
+
currentTime: i.currentTime,
|
|
1060
|
+
duration: a(),
|
|
1061
|
+
seeking: i.seeking
|
|
1062
|
+
}), s = () => {
|
|
1063
|
+
r().seeking || o();
|
|
1064
|
+
}, c, l = () => {
|
|
1065
|
+
c?.(), c = void 0;
|
|
1066
|
+
}, u = () => {
|
|
1067
|
+
if (!x(i) || i.paused || i.ended) {
|
|
1068
|
+
l();
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
let e = r(), t = i.currentTime;
|
|
1072
|
+
!e.seeking && t !== e.currentTime && n({ currentTime: t }), c = B(u);
|
|
1073
|
+
}, d = () => {
|
|
1074
|
+
!c && x(i) && !i.paused && !i.ended && (c = B(u));
|
|
1075
|
+
}, f = () => {
|
|
1076
|
+
l(), s();
|
|
1077
|
+
};
|
|
1078
|
+
o(), d(), t.addEventListener("abort", l, { once: !0 }), V(i, "play", d, { signal: t }), V(i, "playing", d, { signal: t }), V(i, "pause", f, { signal: t }), V(i, "ended", f, { signal: t }), V(i, "timeupdate", () => {
|
|
1079
|
+
(!c || document.hidden) && s();
|
|
1080
|
+
}, { signal: t }), V(i, "durationchange", o, { signal: t }), V(i, "seeking", o, { signal: t }), V(i, "seeked", o, { signal: t }), V(i, "loadedmetadata", o, { signal: t }), V(i, "emptied", () => {
|
|
1081
|
+
l(), o();
|
|
1082
|
+
}, { signal: t }), V(i, "progress", s, { signal: t });
|
|
1083
|
+
}
|
|
1084
|
+
}), Lt = .25, Rt = z({
|
|
1085
|
+
name: "volume",
|
|
1086
|
+
state: ({ target: e, set: t }) => ({
|
|
1087
|
+
volume: 1,
|
|
1088
|
+
muted: !1,
|
|
1089
|
+
volumeAvailability: "unavailable",
|
|
1090
|
+
mutedAvailability: "unavailable",
|
|
1091
|
+
setVolume(n) {
|
|
1092
|
+
let { media: r } = e();
|
|
1093
|
+
if (!w(r)) return 0;
|
|
1094
|
+
let i = Math.max(0, Math.min(1, n));
|
|
1095
|
+
return i > 0 && r.muted && (r.muted = !1), r.volume = i, t({
|
|
1096
|
+
volume: r.volume,
|
|
1097
|
+
muted: r.muted
|
|
1098
|
+
}), r.volume;
|
|
1099
|
+
},
|
|
1100
|
+
setMuted(n) {
|
|
1101
|
+
let { media: r } = e();
|
|
1102
|
+
if (!T(r)) return !1;
|
|
1103
|
+
r.muted = n;
|
|
1104
|
+
let i = w(r);
|
|
1105
|
+
return !n && i && r.volume === 0 && (r.volume = Lt), t({
|
|
1106
|
+
volume: i ? r.volume : 1,
|
|
1107
|
+
muted: r.muted
|
|
1108
|
+
}), r.muted;
|
|
1109
|
+
}
|
|
1110
|
+
}),
|
|
1111
|
+
attach({ target: e, signal: t, set: n }) {
|
|
1112
|
+
let { media: r } = e, i = w(r), a = T(r);
|
|
1113
|
+
if (!i && !a) return;
|
|
1114
|
+
n({
|
|
1115
|
+
volumeAvailability: i ? zt() : "unavailable",
|
|
1116
|
+
mutedAvailability: a ? "available" : "unavailable"
|
|
1117
|
+
});
|
|
1118
|
+
let o = () => n({
|
|
1119
|
+
volume: i ? r.volume : 1,
|
|
1120
|
+
muted: a ? r.muted : !1
|
|
1121
|
+
});
|
|
1122
|
+
o(), V(r, "volumechange", o, { signal: t });
|
|
1123
|
+
}
|
|
1124
|
+
});
|
|
1125
|
+
function zt() {
|
|
1126
|
+
let e = document.createElement("video");
|
|
1127
|
+
try {
|
|
1128
|
+
return e.volume = .5, e.volume === .5 ? "available" : "unsupported";
|
|
1129
|
+
} catch {
|
|
1130
|
+
return "unsupported";
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
// node_modules/@videojs/utils/dist/events/abort.js
|
|
1134
|
+
function Bt(e) {
|
|
1135
|
+
if ("any" in AbortSignal) return AbortSignal.any(e);
|
|
1136
|
+
let t = new AbortController();
|
|
1137
|
+
for (let n of e) {
|
|
1138
|
+
if (n.aborted) return t.abort(n.reason), t.signal;
|
|
1139
|
+
n.addEventListener("abort", () => t.abort(n.reason), { signal: t.signal });
|
|
1140
|
+
}
|
|
1141
|
+
return t.signal;
|
|
1142
|
+
}
|
|
1143
|
+
// node_modules/@videojs/store/dist/default/core/abort-controller-registry.js
|
|
1144
|
+
var Vt = class {
|
|
1145
|
+
#e;
|
|
1146
|
+
#t = /* @__PURE__ */ new Map();
|
|
1147
|
+
get base() {
|
|
1148
|
+
return (this.#e ??= new AbortController()).signal;
|
|
1149
|
+
}
|
|
1150
|
+
clear() {
|
|
1151
|
+
for (let e of this.#t.values()) e.abort();
|
|
1152
|
+
this.#t.clear();
|
|
1153
|
+
}
|
|
1154
|
+
reset() {
|
|
1155
|
+
this.clear(), this.#e?.abort(), this.#e = void 0;
|
|
1156
|
+
}
|
|
1157
|
+
supersede(e) {
|
|
1158
|
+
this.#t.get(e)?.abort();
|
|
1159
|
+
let t = new AbortController();
|
|
1160
|
+
return this.#t.set(e, t), Bt([this.base, t.signal]);
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
// node_modules/@videojs/store/dist/default/core/combine.js
|
|
1164
|
+
function Ht(...e) {
|
|
1165
|
+
let t = e.map((e) => e.derived ?? {});
|
|
1166
|
+
return {
|
|
1167
|
+
state: (t) => {
|
|
1168
|
+
let n = e.map((e) => e.state(t));
|
|
1169
|
+
return Object.assign({}, ...n);
|
|
1170
|
+
},
|
|
1171
|
+
preserve: Array.from(new Set(e.flatMap((e) => e.preserve ?? []))),
|
|
1172
|
+
derived: Object.assign({}, ...t),
|
|
1173
|
+
attach: (t) => {
|
|
1174
|
+
for (let n of e) try {
|
|
1175
|
+
n.attach?.(t);
|
|
1176
|
+
} catch (e) {
|
|
1177
|
+
t.reportError(e);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
// node_modules/@videojs/store/dist/default/core/errors.js
|
|
1183
|
+
var Ut = class extends Error {
|
|
1184
|
+
code;
|
|
1185
|
+
cause;
|
|
1186
|
+
constructor(e, t) {
|
|
1187
|
+
super(t?.message ?? e), this.name = "StoreError", this.code = e, this.cause = t?.cause;
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
function Wt() {
|
|
1191
|
+
throw new Ut("NO_TARGET");
|
|
1192
|
+
}
|
|
1193
|
+
function Gt() {
|
|
1194
|
+
throw new Ut("DESTROYED");
|
|
1195
|
+
}
|
|
1196
|
+
// node_modules/@videojs/store/dist/default/core/state.js
|
|
1197
|
+
var Kt = !1;
|
|
1198
|
+
function qt() {
|
|
1199
|
+
Kt || (Kt = !0, queueMicrotask(Yt));
|
|
1200
|
+
}
|
|
1201
|
+
var Jt = /* @__PURE__ */ new Set();
|
|
1202
|
+
function Yt() {
|
|
1203
|
+
Kt = !1;
|
|
1204
|
+
for (let e of Jt) e.flush();
|
|
1205
|
+
Jt.clear();
|
|
1206
|
+
}
|
|
1207
|
+
var Xt = Object.prototype.hasOwnProperty, Zt = class {
|
|
1208
|
+
#e;
|
|
1209
|
+
#t = /* @__PURE__ */ new Set();
|
|
1210
|
+
#n = !1;
|
|
1211
|
+
constructor(e) {
|
|
1212
|
+
this.#e = Object.freeze({ ...e });
|
|
1213
|
+
}
|
|
1214
|
+
get current() {
|
|
1215
|
+
return this.#e;
|
|
1216
|
+
}
|
|
1217
|
+
patch(e) {
|
|
1218
|
+
let t = { ...this.#e }, n = !1;
|
|
1219
|
+
for (let r of Reflect.ownKeys(e)) {
|
|
1220
|
+
if (!Xt.call(e, r)) continue;
|
|
1221
|
+
let i = e[r];
|
|
1222
|
+
Object.is(this.#e[r], i) || (t[r] = i, n = !0);
|
|
1223
|
+
}
|
|
1224
|
+
n && (this.#e = Object.freeze(t), this.#r());
|
|
1225
|
+
}
|
|
1226
|
+
replace(e) {
|
|
1227
|
+
vt(this.#e, e) || (this.#e = Object.freeze({ ...e }), this.#r());
|
|
1228
|
+
}
|
|
1229
|
+
subscribe(e, t) {
|
|
1230
|
+
let n = t?.signal;
|
|
1231
|
+
if (n?.aborted) return ee;
|
|
1232
|
+
if (this.#t.add(e), !n) return () => this.#t.delete(e);
|
|
1233
|
+
let r = () => this.#t.delete(e);
|
|
1234
|
+
return n.addEventListener("abort", r, { once: !0 }), () => {
|
|
1235
|
+
n.removeEventListener("abort", r), this.#t.delete(e);
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1238
|
+
flush() {
|
|
1239
|
+
if (this.#n) {
|
|
1240
|
+
this.#n = !1;
|
|
1241
|
+
for (let e of this.#t) e();
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
#r() {
|
|
1245
|
+
this.#n = !0, Jt.add(this), qt();
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
function Qt(e) {
|
|
1249
|
+
return new Zt(e);
|
|
1250
|
+
}
|
|
1251
|
+
// node_modules/@videojs/store/dist/default/core/store.js
|
|
1252
|
+
var $t = Symbol.for("@videojs/store"), en = Object.prototype.hasOwnProperty;
|
|
1253
|
+
function tn() {
|
|
1254
|
+
return ((e, t = {}) => {
|
|
1255
|
+
let n = null, a = !1, o = new AbortController(), l = new Vt(), u = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakSet(), f, p;
|
|
1256
|
+
function m() {
|
|
1257
|
+
a && Gt(), n || Wt();
|
|
1258
|
+
}
|
|
1259
|
+
let h = nn(e.state({
|
|
1260
|
+
target: () => (m(), n),
|
|
1261
|
+
signals: l,
|
|
1262
|
+
get: () => f,
|
|
1263
|
+
set: (e) => x(e)
|
|
1264
|
+
}));
|
|
1265
|
+
f = h;
|
|
1266
|
+
let g = v(f);
|
|
1267
|
+
p = Qt(y(f, g));
|
|
1268
|
+
let _ = {
|
|
1269
|
+
[$t]: !0,
|
|
1270
|
+
get $state() {
|
|
1271
|
+
return p;
|
|
1272
|
+
},
|
|
1273
|
+
get target() {
|
|
1274
|
+
return n;
|
|
1275
|
+
},
|
|
1276
|
+
get destroyed() {
|
|
1277
|
+
return a;
|
|
1278
|
+
},
|
|
1279
|
+
get state() {
|
|
1280
|
+
return p.current;
|
|
1281
|
+
},
|
|
1282
|
+
attach: S,
|
|
1283
|
+
destroy: w,
|
|
1284
|
+
subscribe: T
|
|
1285
|
+
};
|
|
1286
|
+
for (let e of Object.keys(p.current)) Object.defineProperty(_, e, {
|
|
1287
|
+
get: () => p.current[e],
|
|
1288
|
+
enumerable: !0
|
|
1289
|
+
});
|
|
1290
|
+
for (let e of Object.getOwnPropertySymbols(f)) typeof f[e] == "function" && Object.defineProperty(_, e, { get: () => f[e] });
|
|
1291
|
+
try {
|
|
1292
|
+
t.onSetup?.({
|
|
1293
|
+
store: _,
|
|
1294
|
+
signal: o.signal
|
|
1295
|
+
});
|
|
1296
|
+
} catch (e) {
|
|
1297
|
+
E(e);
|
|
1298
|
+
}
|
|
1299
|
+
return _;
|
|
1300
|
+
function v(t) {
|
|
1301
|
+
let n = {}, r = e.derived;
|
|
1302
|
+
if (!r) return n;
|
|
1303
|
+
let i = { get: () => t };
|
|
1304
|
+
for (let e of Object.keys(r)) n[e] = r[e](i);
|
|
1305
|
+
return n;
|
|
1306
|
+
}
|
|
1307
|
+
function y(e, t) {
|
|
1308
|
+
let n = {};
|
|
1309
|
+
for (let t of Object.keys(e)) n[t] = e[t];
|
|
1310
|
+
Object.assign(n, t);
|
|
1311
|
+
for (let e of Object.keys(n)) {
|
|
1312
|
+
let t = n[e];
|
|
1313
|
+
r(t) && (n[e] = b(t));
|
|
1314
|
+
}
|
|
1315
|
+
return n;
|
|
1316
|
+
}
|
|
1317
|
+
function b(e) {
|
|
1318
|
+
let n = u.get(e);
|
|
1319
|
+
if (n) return n;
|
|
1320
|
+
let r = function(...n) {
|
|
1321
|
+
try {
|
|
1322
|
+
let r = e.apply(this, n);
|
|
1323
|
+
return t.onError && s(r) && r.catch(E), r;
|
|
1324
|
+
} catch (e) {
|
|
1325
|
+
throw t.onError && E(e), e;
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1328
|
+
return u.set(e, r), r;
|
|
1329
|
+
}
|
|
1330
|
+
function x(e) {
|
|
1331
|
+
let t = rn(f, e);
|
|
1332
|
+
if (!t) return;
|
|
1333
|
+
let n = v(t.next);
|
|
1334
|
+
f = t.next, p.replace(y(f, n));
|
|
1335
|
+
}
|
|
1336
|
+
function S(r) {
|
|
1337
|
+
a && Gt(), l.reset(), n = r;
|
|
1338
|
+
let i = {
|
|
1339
|
+
target: r,
|
|
1340
|
+
signal: l.base,
|
|
1341
|
+
get: () => f,
|
|
1342
|
+
set: (e) => {
|
|
1343
|
+
try {
|
|
1344
|
+
x(e);
|
|
1345
|
+
} catch (e) {
|
|
1346
|
+
E(e);
|
|
1347
|
+
}
|
|
1348
|
+
},
|
|
1349
|
+
reportError: E,
|
|
1350
|
+
store: {
|
|
1351
|
+
get state() {
|
|
1352
|
+
return p.current;
|
|
1353
|
+
},
|
|
1354
|
+
subscribe: T
|
|
1355
|
+
}
|
|
1356
|
+
};
|
|
1357
|
+
try {
|
|
1358
|
+
e.attach?.(i);
|
|
1359
|
+
} catch (e) {
|
|
1360
|
+
E(e);
|
|
1361
|
+
}
|
|
1362
|
+
try {
|
|
1363
|
+
t.onAttach?.({
|
|
1364
|
+
store: _,
|
|
1365
|
+
target: r,
|
|
1366
|
+
signal: l.base
|
|
1367
|
+
});
|
|
1368
|
+
} catch (e) {
|
|
1369
|
+
E(e);
|
|
1370
|
+
}
|
|
1371
|
+
return C;
|
|
1372
|
+
}
|
|
1373
|
+
function C() {
|
|
1374
|
+
if (i(n)) return;
|
|
1375
|
+
l.reset(), n = null;
|
|
1376
|
+
let t = { ...h };
|
|
1377
|
+
for (let n of e.preserve ?? []) t[n] = f[n];
|
|
1378
|
+
x(t);
|
|
1379
|
+
}
|
|
1380
|
+
function w() {
|
|
1381
|
+
a || (a = !0, C(), o.abort());
|
|
1382
|
+
}
|
|
1383
|
+
function T(e, t) {
|
|
1384
|
+
return p.subscribe(e, t);
|
|
1385
|
+
}
|
|
1386
|
+
function E(e) {
|
|
1387
|
+
if (c(e)) {
|
|
1388
|
+
if (d.has(e)) return;
|
|
1389
|
+
d.add(e);
|
|
1390
|
+
}
|
|
1391
|
+
t.onError ? t.onError({
|
|
1392
|
+
store: _,
|
|
1393
|
+
error: e
|
|
1394
|
+
}) : console.error("[vjs-store]", e);
|
|
1395
|
+
}
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
function nn(e) {
|
|
1399
|
+
return Object.freeze({ ...e });
|
|
1400
|
+
}
|
|
1401
|
+
function rn(e, t) {
|
|
1402
|
+
let n = { ...e }, r = !1;
|
|
1403
|
+
for (let i of Reflect.ownKeys(t)) {
|
|
1404
|
+
if (!en.call(t, i)) continue;
|
|
1405
|
+
let a = t[i];
|
|
1406
|
+
Object.is(e[i], a) || (n[i] = a, r = !0);
|
|
1407
|
+
}
|
|
1408
|
+
return r ? { next: Object.freeze(n) } : null;
|
|
1409
|
+
}
|
|
1410
|
+
function an(e) {
|
|
1411
|
+
return c(e) && $t in e;
|
|
1412
|
+
}
|
|
1413
|
+
// node_modules/@videojs/core/dist/default/dom/store/features/presets.js
|
|
1414
|
+
var on = [
|
|
1415
|
+
st,
|
|
1416
|
+
lt,
|
|
1417
|
+
mt,
|
|
1418
|
+
Ce,
|
|
1419
|
+
Rt,
|
|
1420
|
+
It,
|
|
1421
|
+
gt,
|
|
1422
|
+
we,
|
|
1423
|
+
Xe,
|
|
1424
|
+
ot,
|
|
1425
|
+
ht,
|
|
1426
|
+
Ie,
|
|
1427
|
+
Pt,
|
|
1428
|
+
Re,
|
|
1429
|
+
at
|
|
1430
|
+
], J = () => new DOMException("Operation cancelled", "AbortError");
|
|
1431
|
+
function Y(e) {
|
|
1432
|
+
if (e.aborted) throw e.reason ?? J();
|
|
1433
|
+
}
|
|
1434
|
+
function sn(e, t, n, r, i = () => {}) {
|
|
1435
|
+
return new Promise((a, o) => {
|
|
1436
|
+
let s = () => {}, c, l = !1, u = (e) => {
|
|
1437
|
+
l || (l = !0, s(), clearTimeout(c), n.removeEventListener("abort", d), e ? o(e) : a());
|
|
1438
|
+
}, d = () => u(n.reason ?? J()), f = () => {
|
|
1439
|
+
try {
|
|
1440
|
+
t() && u();
|
|
1441
|
+
} catch (e) {
|
|
1442
|
+
u(e);
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
if (n.aborted) return d();
|
|
1446
|
+
if (n.addEventListener("abort", d, { once: !0 }), s = e(f), l) s();
|
|
1447
|
+
else {
|
|
1448
|
+
c = setTimeout(() => u(new DOMException("Media confirmation timed out", "TimeoutError")), r);
|
|
1449
|
+
try {
|
|
1450
|
+
i(), f();
|
|
1451
|
+
} catch (e) {
|
|
1452
|
+
u(e);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
function X(e, t) {
|
|
1458
|
+
return new Promise((n, r) => {
|
|
1459
|
+
let i = () => r(t.reason ?? J());
|
|
1460
|
+
if (t.aborted) return e.catch(() => {}), i();
|
|
1461
|
+
t.addEventListener("abort", i, { once: !0 }), e.then(n, r).finally(() => t.removeEventListener("abort", i));
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
// src/core/commands.ts
|
|
1465
|
+
function cn(e, t, n) {
|
|
1466
|
+
let r, i, a = {};
|
|
1467
|
+
function o(e) {
|
|
1468
|
+
e?.controller.abort(J()), e?.reject(J());
|
|
1469
|
+
}
|
|
1470
|
+
async function s() {
|
|
1471
|
+
for (; i;) {
|
|
1472
|
+
let t = i;
|
|
1473
|
+
i = void 0, r = t;
|
|
1474
|
+
try {
|
|
1475
|
+
await e(t.command, t.id, t.controller.signal), Y(t.controller.signal), t.resolve();
|
|
1476
|
+
} catch (e) {
|
|
1477
|
+
t.reject(e);
|
|
1478
|
+
}
|
|
1479
|
+
r = void 0;
|
|
1480
|
+
}
|
|
1481
|
+
a = {}, t(null);
|
|
1482
|
+
}
|
|
1483
|
+
return {
|
|
1484
|
+
enqueue(e) {
|
|
1485
|
+
o(r), o(i);
|
|
1486
|
+
let c = e.type === "seek" ? { positionSeconds: e.seconds } : e.type === "audio" ? { audioId: e.id } : e.type === "text" ? { textId: e.id } : { qualityId: e.id };
|
|
1487
|
+
a = {
|
|
1488
|
+
...a,
|
|
1489
|
+
...c
|
|
1490
|
+
};
|
|
1491
|
+
let l = new Promise((t, r) => {
|
|
1492
|
+
i = {
|
|
1493
|
+
id: n(),
|
|
1494
|
+
command: {
|
|
1495
|
+
...e,
|
|
1496
|
+
target: a
|
|
1497
|
+
},
|
|
1498
|
+
controller: new AbortController(),
|
|
1499
|
+
resolve: t,
|
|
1500
|
+
reject: r
|
|
1501
|
+
};
|
|
1502
|
+
});
|
|
1503
|
+
return t({
|
|
1504
|
+
type: e.type,
|
|
1505
|
+
commandId: i.id
|
|
1506
|
+
}), r || s(), l;
|
|
1507
|
+
},
|
|
1508
|
+
clear() {
|
|
1509
|
+
o(r), o(i), i = void 0, a = {}, t(null);
|
|
1510
|
+
}
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
// src/core/errors.ts
|
|
1514
|
+
var ln = class extends Error {
|
|
1515
|
+
detail;
|
|
1516
|
+
constructor(e) {
|
|
1517
|
+
super(e.message), this.detail = e, this.name = "PlayerError";
|
|
1518
|
+
}
|
|
1519
|
+
};
|
|
1520
|
+
function Z(e, t, n, r = !1) {
|
|
1521
|
+
return new ln({
|
|
1522
|
+
code: e,
|
|
1523
|
+
stage: t,
|
|
1524
|
+
message: n,
|
|
1525
|
+
retryable: r
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
function un(e, t) {
|
|
1529
|
+
return e instanceof ln ? e : e instanceof Error && e.name === "TimeoutError" ? Z("timeout", t, "Media confirmation timed out. Retry the operation.", !0) : e instanceof Error && e.name === "NotAllowedError" ? Z("autoplay-blocked", "play", "Playback was blocked. Press Play to continue.", !0) : Z(t === "play" || t === "media" ? "media" : "host", t, "The operation failed. Retry or choose another source.", !0);
|
|
1530
|
+
}
|
|
1531
|
+
// src/core/subtitle-data.ts
|
|
1532
|
+
var dn = 1048576, fn = (e) => `subtitle:${e}`, pn = "subtitle:local", mn = [
|
|
1533
|
+
"vtt",
|
|
1534
|
+
"srt",
|
|
1535
|
+
"ass",
|
|
1536
|
+
"ssa",
|
|
1537
|
+
"pgs",
|
|
1538
|
+
"vobsub"
|
|
1539
|
+
], Q = (e) => Z("unsupported", "text", e, !0);
|
|
1540
|
+
function hn(e, t) {
|
|
1541
|
+
if (e !== void 0) {
|
|
1542
|
+
if (!Array.isArray(e) || e.length > 100 || new Set(e.map((e) => e?.id)).size !== e.length) throw Q("Invalid subtitle descriptors.");
|
|
1543
|
+
for (let n of e) {
|
|
1544
|
+
if (!n || typeof n.id != "string" || !n.id || n.id === "local" || !mn.includes(n.format) || [
|
|
1545
|
+
"label",
|
|
1546
|
+
"language",
|
|
1547
|
+
"description"
|
|
1548
|
+
].some((e) => Reflect.get(n, e) !== void 0 && typeof Reflect.get(n, e) != "string") || [
|
|
1549
|
+
"default",
|
|
1550
|
+
"forced",
|
|
1551
|
+
"sdh",
|
|
1552
|
+
"available"
|
|
1553
|
+
].some((e) => Reflect.get(n, e) !== void 0 && typeof Reflect.get(n, e) != "boolean") || n.fonts !== void 0 && (!Array.isArray(n.fonts) || n.fonts.length > 8)) throw Q("Invalid subtitle metadata, format or font count.");
|
|
1554
|
+
for (let e of [n, ...n.fonts ?? []]) gn(e, t);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
function gn(e, t) {
|
|
1559
|
+
if (!e || typeof e.src != "string" || !e.src.trim()) throw Q("A subtitle resource requires a URL.");
|
|
1560
|
+
let n;
|
|
1561
|
+
try {
|
|
1562
|
+
n = new URL(e.src, t);
|
|
1563
|
+
} catch {
|
|
1564
|
+
throw Q("Invalid subtitle resource URL.");
|
|
1565
|
+
}
|
|
1566
|
+
if (!["http:", "https:"].includes(n.protocol) || n.username || n.password) throw Q("Subtitle resources require HTTP URLs without credentials.");
|
|
1567
|
+
let r = e.request;
|
|
1568
|
+
if (r && (!Array.isArray(r.allowedOrigins) || !r.allowedOrigins.includes(n.origin) || r.allowedOrigins.some((e) => {
|
|
1569
|
+
try {
|
|
1570
|
+
let t = new URL(e);
|
|
1571
|
+
return t.origin !== e || !["http:", "https:"].includes(t.protocol);
|
|
1572
|
+
} catch {
|
|
1573
|
+
return !0;
|
|
1574
|
+
}
|
|
1575
|
+
}) || r.credentials !== void 0 && ![
|
|
1576
|
+
"omit",
|
|
1577
|
+
"same-origin",
|
|
1578
|
+
"include"
|
|
1579
|
+
].includes(r.credentials))) throw Q("Subtitle resource is blocked by request policy.");
|
|
1580
|
+
return n;
|
|
1581
|
+
}
|
|
1582
|
+
async function _n(e, t, n, r) {
|
|
1583
|
+
let i = gn(e, t), a = e.request, o = await fetch(i, {
|
|
1584
|
+
signal: r,
|
|
1585
|
+
redirect: "error",
|
|
1586
|
+
credentials: a?.credentials ?? "same-origin",
|
|
1587
|
+
headers: a?.headers ?? {}
|
|
1588
|
+
});
|
|
1589
|
+
if (!o.ok || !o.body) throw Q("The subtitle resource could not be loaded. Retry or choose a local file.");
|
|
1590
|
+
let s = o.body.getReader(), c = [], l = 0;
|
|
1591
|
+
try {
|
|
1592
|
+
if (Number(o.headers.get("content-length")) > n) throw Q("Subtitle resource exceeds the size limit.");
|
|
1593
|
+
for (;;) {
|
|
1594
|
+
let { value: e, done: t } = await s.read();
|
|
1595
|
+
if (t) break;
|
|
1596
|
+
if (l += e.byteLength, l > n) throw Q("Subtitle resource exceeds the size limit.");
|
|
1597
|
+
c.push(e);
|
|
1598
|
+
}
|
|
1599
|
+
} finally {
|
|
1600
|
+
await s.cancel().catch(() => {}), s.releaseLock();
|
|
1601
|
+
}
|
|
1602
|
+
let u = new Uint8Array(l), d = 0;
|
|
1603
|
+
for (let e of c) u.set(e, d), d += e.byteLength;
|
|
1604
|
+
return u;
|
|
1605
|
+
}
|
|
1606
|
+
function vn(e) {
|
|
1607
|
+
try {
|
|
1608
|
+
return new TextDecoder("utf-8", { fatal: !0 }).decode(e).replace(/\r\n?/g, "\n");
|
|
1609
|
+
} catch {
|
|
1610
|
+
throw Q("Subtitles must use UTF-8 encoding. Save the file as UTF-8 and retry.");
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
function yn(e, t) {
|
|
1614
|
+
if (t === "ass" || t === "ssa") {
|
|
1615
|
+
if (!/^\[Script Info\]/im.test(e) || !/^\[Events\]/im.test(e) || !/^Dialogue\s*:/im.test(e)) throw Q("The ASS/SSA file has no valid script or dialogue.");
|
|
1616
|
+
if (/^\[(Fonts|Graphics)\]/im.test(e)) throw Q("Embedded ASS resources are unsupported. Provide fonts through the subtitle descriptor.");
|
|
1617
|
+
if ((e.match(/^Dialogue\s*:/gim) ?? []).length > 1e5) throw Q("Subtitles exceed the 100000 event limit.");
|
|
1618
|
+
return e;
|
|
1619
|
+
}
|
|
1620
|
+
if (t === "srt") {
|
|
1621
|
+
let t = (e) => {
|
|
1622
|
+
let t = /^(\d{2,}):([0-5]\d):([0-5]\d)[,.](\d{3})$/.exec(e);
|
|
1623
|
+
if (!t) throw Q("Invalid SRT timestamp.");
|
|
1624
|
+
return Number(t[1]) * 3600 + Number(t[2]) * 60 + Number(t[3]) + Number(t[4]) / 1e3;
|
|
1625
|
+
}, n = e.trim().split(/\n[\t ]*\n/);
|
|
1626
|
+
if (n.length > 1e5) throw Q("Subtitles exceed the 100000 cue limit.");
|
|
1627
|
+
e = `WEBVTT\n\n${n.map((e) => {
|
|
1628
|
+
let n = e.split("\n");
|
|
1629
|
+
/^\d+$/.test(n[0] ?? "") && n.shift();
|
|
1630
|
+
let r = /^(\S+)\s+-->\s+(\S+)\s*$/.exec(n.shift() ?? "");
|
|
1631
|
+
if (!r || t(r[2]) <= t(r[1]) || !n.length) throw Q("Invalid SRT cue. Check timestamps and text.");
|
|
1632
|
+
return `${r[1].replace(",", ".")} --> ${r[2].replace(",", ".")}\n${n.join("\n")}`;
|
|
1633
|
+
}).join("\n\n")}\n`;
|
|
1634
|
+
}
|
|
1635
|
+
if (!/^WEBVTT(?:[ \t].*)?\n/.test(e) || !e.includes("-->")) throw Q("The WebVTT file has no valid header or cues.");
|
|
1636
|
+
if ((e.match(/-->/g) ?? []).length > 1e5) throw Q("Subtitles exceed the 100000 cue limit.");
|
|
1637
|
+
return e;
|
|
1638
|
+
}
|
|
1639
|
+
// src/core/source.ts
|
|
1640
|
+
function bn(e) {
|
|
1641
|
+
if (e && typeof e == "object" && !Object.isFrozen(e)) {
|
|
1642
|
+
for (let t of Object.values(e)) bn(t);
|
|
1643
|
+
Object.freeze(e);
|
|
1644
|
+
}
|
|
1645
|
+
return e;
|
|
1646
|
+
}
|
|
1647
|
+
function xn(e, t) {
|
|
1648
|
+
if (!e || [
|
|
1649
|
+
e.id,
|
|
1650
|
+
e.revision,
|
|
1651
|
+
e.src
|
|
1652
|
+
].some((e) => typeof e != "string" || !e.trim()) || !["mp4", "hls"].includes(e.kind)) throw Z("invalid-source", "source", "A source requires an id, revision and supported kind.");
|
|
1653
|
+
let n;
|
|
1654
|
+
if (e.crossOrigin !== void 0 && !["anonymous", "use-credentials"].includes(e.crossOrigin)) throw Z("invalid-source", "source", "Invalid browser credentials mode.");
|
|
1655
|
+
try {
|
|
1656
|
+
n = new URL(e.src, t);
|
|
1657
|
+
} catch {
|
|
1658
|
+
throw Z("invalid-source", "source", "Invalid source URL.");
|
|
1659
|
+
}
|
|
1660
|
+
if (![
|
|
1661
|
+
"http:",
|
|
1662
|
+
"https:",
|
|
1663
|
+
"blob:"
|
|
1664
|
+
].includes(n.protocol) || n.username || n.password) throw Z("invalid-source", "source", "Unsupported source URL.");
|
|
1665
|
+
let r = e.timeline;
|
|
1666
|
+
if (e.chapters !== void 0 && (!Array.isArray(e.chapters) || e.chapters.length > 500 || e.chapters.some((t, n) => !t || !Number.isFinite(t.startSeconds) || t.startSeconds < 0 || typeof t.title != "string" || !t.title.trim() || t.title.length > 200 || n > 0 && t.startSeconds <= e.chapters[n - 1].startSeconds || r?.durationSeconds != null && t.startSeconds > r.durationSeconds))) throw Z("invalid-source", "source", "Invalid chapter times or titles.");
|
|
1667
|
+
let i = e.metadata;
|
|
1668
|
+
if (i !== void 0 && (!i || typeof i != "object" || [i.artist, i.album].some((e) => e !== void 0 && (typeof e != "string" || e.length > 500)) || i.artwork !== void 0 && (!Array.isArray(i.artwork) || i.artwork.length > 8))) throw Z("invalid-source", "source", "Invalid media metadata.");
|
|
1669
|
+
for (let e of i?.artwork ?? []) {
|
|
1670
|
+
let n;
|
|
1671
|
+
try {
|
|
1672
|
+
n = new URL(e.src, t);
|
|
1673
|
+
} catch {
|
|
1674
|
+
throw Z("invalid-source", "source", "Invalid artwork URL.");
|
|
1675
|
+
}
|
|
1676
|
+
if (![
|
|
1677
|
+
"http:",
|
|
1678
|
+
"https:",
|
|
1679
|
+
"blob:"
|
|
1680
|
+
].includes(n.protocol) || n.username || n.password || [e.sizes, e.type].some((e) => e !== void 0 && typeof e != "string")) throw Z("invalid-source", "source", "Invalid artwork descriptor.");
|
|
1681
|
+
}
|
|
1682
|
+
if (hn(e.subtitles, t), r) {
|
|
1683
|
+
let e = [r.absoluteAnchorSeconds, r.mediaAnchorSeconds];
|
|
1684
|
+
if (![
|
|
1685
|
+
"vod",
|
|
1686
|
+
"live",
|
|
1687
|
+
"windowed-vod"
|
|
1688
|
+
].includes(r.mode) || e.some((e) => e !== null && !Number.isFinite(e)) || e[0] === null != (e[1] === null) || r.durationSeconds !== null && (!Number.isFinite(r.durationSeconds) || r.durationSeconds < 0) || r.seekableRanges?.some(([e, t]) => !Number.isFinite(e) || !Number.isFinite(t) || e > t)) throw Z("invalid-source", "source", "Invalid timeline anchors, duration or ranges.");
|
|
1689
|
+
}
|
|
1690
|
+
for (let t of [
|
|
1691
|
+
e.audioTracks,
|
|
1692
|
+
e.textTracks,
|
|
1693
|
+
e.qualities
|
|
1694
|
+
]) if (t && (!Array.isArray(t) || t.some((e) => !e || typeof e != "object" || typeof e.id != "string" || !e.id || e.id.startsWith("subtitle:") || e.id === "auto" || [
|
|
1695
|
+
"label",
|
|
1696
|
+
"language",
|
|
1697
|
+
"channels",
|
|
1698
|
+
"description",
|
|
1699
|
+
"codec",
|
|
1700
|
+
"format",
|
|
1701
|
+
"unavailableReason"
|
|
1702
|
+
].some((t) => Reflect.get(e, t) !== void 0 && typeof Reflect.get(e, t) != "string") || [
|
|
1703
|
+
"default",
|
|
1704
|
+
"forced",
|
|
1705
|
+
"sdh",
|
|
1706
|
+
"available"
|
|
1707
|
+
].some((t) => Reflect.get(e, t) !== void 0 && typeof Reflect.get(e, t) != "boolean")) || new Set(t.map((e) => e.id)).size !== t.length)) throw Z("invalid-source", "source", "Track ids must be unique within the source revision.");
|
|
1708
|
+
if (e.capabilities?.playbackRates?.some((e) => !Number.isFinite(e) || e <= 0)) throw Z("invalid-source", "source", "Invalid supported playback rates.");
|
|
1709
|
+
if (e.request) {
|
|
1710
|
+
for (let t of e.request.allowedOrigins) {
|
|
1711
|
+
let e;
|
|
1712
|
+
try {
|
|
1713
|
+
e = new URL(t);
|
|
1714
|
+
} catch {
|
|
1715
|
+
throw Z("invalid-source", "source", "Invalid allowed origin.");
|
|
1716
|
+
}
|
|
1717
|
+
if (e.origin !== t || !["http:", "https:"].includes(e.protocol)) throw Z("invalid-source", "source", "Allowed origins must be HTTP origins.");
|
|
1718
|
+
}
|
|
1719
|
+
if (!e.request.allowedOrigins.includes(n.origin)) throw Z("unsupported", "source", "Source origin is not allowed by request policy.");
|
|
1720
|
+
}
|
|
1721
|
+
return bn(structuredClone({
|
|
1722
|
+
...e,
|
|
1723
|
+
src: n.href,
|
|
1724
|
+
...i ? { metadata: {
|
|
1725
|
+
...i,
|
|
1726
|
+
...i.artwork ? { artwork: i.artwork.map((e) => ({
|
|
1727
|
+
...e,
|
|
1728
|
+
src: new URL(e.src, t).href
|
|
1729
|
+
})) } : {}
|
|
1730
|
+
} } : {},
|
|
1731
|
+
...e.subtitles ? { subtitles: e.subtitles.map((e) => ({
|
|
1732
|
+
...e,
|
|
1733
|
+
src: new URL(e.src, t).href,
|
|
1734
|
+
...e.fonts ? { fonts: e.fonts.map((e) => ({
|
|
1735
|
+
...e,
|
|
1736
|
+
src: new URL(e.src, t).href
|
|
1737
|
+
})) } : {}
|
|
1738
|
+
})) } : {}
|
|
1739
|
+
}));
|
|
1740
|
+
}
|
|
1741
|
+
function $(e) {
|
|
1742
|
+
let t = e?.timeline;
|
|
1743
|
+
return t ? t.absoluteAnchorSeconds === null || t.mediaAnchorSeconds === null ? null : t.absoluteAnchorSeconds - t.mediaAnchorSeconds : 0;
|
|
1744
|
+
}
|
|
1745
|
+
function Sn(e, t) {
|
|
1746
|
+
return t === null ? [] : e.map(([e, n]) => [e + t, n + t]);
|
|
1747
|
+
}
|
|
1748
|
+
var Cn = (e, t) => e.some(([e, n]) => t >= e && t <= n);
|
|
1749
|
+
// src/core/transport.ts
|
|
1750
|
+
async function wn(e, t) {
|
|
1751
|
+
let n = !!e.canPlayType("application/vnd.apple.mpegurl"), r = t.kind === "mp4" || t.hlsPlayback === "native";
|
|
1752
|
+
if (t.kind === "hls" && t.hlsPlayback === "native" && (!n || t.request)) throw Z("unsupported", "source", "Native HLS cannot play this source or enforce its request policy.");
|
|
1753
|
+
if (!r) {
|
|
1754
|
+
let { hlsTransport: i, supportsMse: a } = await import("./hls-CrUfIOS7.js");
|
|
1755
|
+
if (a()) return i(e, t);
|
|
1756
|
+
if (r = t.hlsPlayback !== "mse" && n && !t.request, !r) throw Z("unsupported", "source", "No supported HLS transport can enforce this source's requirements.");
|
|
1757
|
+
}
|
|
1758
|
+
if (t.request) throw Z("unsupported", "source", "Native media cannot enforce headers, allowed origins and redirect policy. Use browser-compatible authentication.");
|
|
1759
|
+
return {
|
|
1760
|
+
media: e,
|
|
1761
|
+
attach() {},
|
|
1762
|
+
start() {
|
|
1763
|
+
e.crossOrigin = t.crossOrigin ?? "anonymous", e.src = t.src, e.load();
|
|
1764
|
+
},
|
|
1765
|
+
destroy() {}
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
// src/core/tracks.ts
|
|
1769
|
+
var Tn = (e) => e.toLowerCase().replaceAll("_", "-");
|
|
1770
|
+
function En(e, t = [], n = {}) {
|
|
1771
|
+
let r = e.filter((e) => e.available !== !1 && (n.forced === void 0 || !!e.forced === n.forced) && (n.sdh === void 0 || !!e.sdh === n.sdh)).sort((e, t) => Number(!!t.default) - Number(!!e.default));
|
|
1772
|
+
if (!t.length) return r[0];
|
|
1773
|
+
for (let e of t.map(Tn)) {
|
|
1774
|
+
let t = r.find((t) => t.language && Tn(t.language) === e);
|
|
1775
|
+
if (t) return t;
|
|
1776
|
+
let n = r.find((t) => t.language && Tn(t.language).split("-")[0] === e.split("-")[0]);
|
|
1777
|
+
if (n) return n;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
function Dn(e) {
|
|
1781
|
+
if (e === void 0) return;
|
|
1782
|
+
let t = (e) => e === void 0 || Array.isArray(e) && e.length <= 20 && e.every((e) => typeof e == "string" && /^[a-z]{2,8}(?:[-_][a-z0-9]{1,8})*$/i.test(e));
|
|
1783
|
+
if (!e || typeof e != "object" || Array.isArray(e) || Object.keys(e).some((e) => !["audioLanguages", "text"].includes(e)) || !t(e.audioLanguages) || e.text != null && (typeof e.text != "object" || Array.isArray(e.text) || Object.keys(e.text).some((e) => ![
|
|
1784
|
+
"languages",
|
|
1785
|
+
"forced",
|
|
1786
|
+
"sdh"
|
|
1787
|
+
].includes(e)) || !t(e.text.languages) || [e.text.forced, e.text.sdh].some((e) => e !== void 0 && typeof e != "boolean"))) throw TypeError("Invalid track preferences");
|
|
1788
|
+
}
|
|
1789
|
+
// src/core/subtitles.ts
|
|
1790
|
+
var On = {
|
|
1791
|
+
fontScale: 1,
|
|
1792
|
+
color: "#ffffff",
|
|
1793
|
+
background: "transparent",
|
|
1794
|
+
edge: "outline",
|
|
1795
|
+
presentation: "native"
|
|
1796
|
+
};
|
|
1797
|
+
function kn(t, n, r, i) {
|
|
1798
|
+
let a = t.ownerDocument, o = a.defaultView, s = null, c, l = null, u = null, d = {
|
|
1799
|
+
delaySeconds: 0,
|
|
1800
|
+
style: On,
|
|
1801
|
+
renderer: null,
|
|
1802
|
+
status: "off",
|
|
1803
|
+
warning: null
|
|
1804
|
+
}, f = new AbortController(), p, m, h, g = /* @__PURE__ */ new Map(), _ = new AbortController(), v = new o.CSSStyleSheet(), y, b = `yp-captions-${o.crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(2)).join("-")}`;
|
|
1805
|
+
t.setAttribute("data-yp-captions", b);
|
|
1806
|
+
let x = !1;
|
|
1807
|
+
function S(e) {
|
|
1808
|
+
d = {
|
|
1809
|
+
...d,
|
|
1810
|
+
...e
|
|
1811
|
+
}, n();
|
|
1812
|
+
}
|
|
1813
|
+
function C() {
|
|
1814
|
+
for (let [e, t] of g) e.startTime === t.start + t.applied && (e.startTime = t.start), e.endTime === t.end + t.applied && (e.endTime = t.end);
|
|
1815
|
+
g.clear();
|
|
1816
|
+
}
|
|
1817
|
+
function w() {
|
|
1818
|
+
m = void 0, f.abort(), f = new AbortController(), h?.dispose(), h = void 0, p &&= (p.track.mode = "disabled", p.remove(), void 0), C(), l = null, u = null;
|
|
1819
|
+
}
|
|
1820
|
+
function T() {
|
|
1821
|
+
let e = t.getRootNode();
|
|
1822
|
+
if (!(e instanceof o.Document || e instanceof o.ShadowRoot)) return;
|
|
1823
|
+
y !== e && (y && (y.adoptedStyleSheets = y.adoptedStyleSheets.filter((e) => e !== v)), y = e, e.adoptedStyleSheets = [...e.adoptedStyleSheets, v]);
|
|
1824
|
+
let n = d.style;
|
|
1825
|
+
t.dataset.captionScale = String(n.fontScale);
|
|
1826
|
+
let r = Math.max(14, Math.min(26, t.clientWidth * .025)) * n.fontScale, i = {
|
|
1827
|
+
none: "none",
|
|
1828
|
+
outline: "1px 1px 2px #000,-1px -1px 2px #000,1px -1px 2px #000,-1px 1px 2px #000",
|
|
1829
|
+
shadow: "0 2px 4px #000,0 0 10px #000b"
|
|
1830
|
+
}[n.edge];
|
|
1831
|
+
v.replaceSync(`video[data-yp-captions="${b}"]::cue { font-size:${r}px; color:${n.color}; background-color:${n.background}; text-shadow:${i}; ${n.presentation === "card" ? "font-family:var(--yp-font-family,\"YanePlayer Manrope\",system-ui,sans-serif);font-weight:600" : ""} }`);
|
|
1832
|
+
}
|
|
1833
|
+
function E() {
|
|
1834
|
+
if (!x) {
|
|
1835
|
+
x = !0;
|
|
1836
|
+
try {
|
|
1837
|
+
let e = /* @__PURE__ */ new Set();
|
|
1838
|
+
for (let n of t.textTracks) {
|
|
1839
|
+
if (n.mode === "disabled" || !["captions", "subtitles"].includes(n.kind)) continue;
|
|
1840
|
+
let t = d.delaySeconds - (p?.track === n ? $(s) ?? 0 : 0);
|
|
1841
|
+
for (let r of n.cues ?? []) {
|
|
1842
|
+
if (!(r instanceof o.VTTCue)) continue;
|
|
1843
|
+
e.add(r);
|
|
1844
|
+
let n = g.get(r), i = n && r.startTime === n.start + n.applied ? n.start : r.startTime, a = n && r.endTime === n.end + n.applied ? n.end : r.endTime;
|
|
1845
|
+
r.startTime !== i + t && (r.startTime = i + t), r.endTime !== a + t && (r.endTime = a + t), g.set(r, {
|
|
1846
|
+
start: i,
|
|
1847
|
+
end: a,
|
|
1848
|
+
applied: t
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
for (let [t, n] of g) e.has(t) || (t.startTime === n.start + n.applied && (t.startTime = n.start), t.endTime === n.end + n.applied && (t.endTime = n.end), g.delete(t));
|
|
1853
|
+
} finally {
|
|
1854
|
+
x = !1;
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
let D = () => {
|
|
1859
|
+
E();
|
|
1860
|
+
}, O = /* @__PURE__ */ new Set();
|
|
1861
|
+
function k() {
|
|
1862
|
+
for (let e of O) [...t.textTracks].includes(e) || (e.removeEventListener("cuechange", D), O.delete(e));
|
|
1863
|
+
for (let e of t.textTracks) O.has(e) || (O.add(e), e.addEventListener("cuechange", D, { signal: _.signal }));
|
|
1864
|
+
E();
|
|
1865
|
+
}
|
|
1866
|
+
for (let e of [
|
|
1867
|
+
"addtrack",
|
|
1868
|
+
"removetrack",
|
|
1869
|
+
"change"
|
|
1870
|
+
]) t.textTracks.addEventListener(e, k, { signal: _.signal });
|
|
1871
|
+
for (let e of ["timeupdate", "seeked"]) t.addEventListener(e, D, { signal: _.signal });
|
|
1872
|
+
let A = new o.ResizeObserver(T);
|
|
1873
|
+
A.observe(t);
|
|
1874
|
+
let j = a.pictureInPictureElement === t, M = !1, N = () => t.webkitPresentationMode, P = () => j || M || N() === "picture-in-picture" || N() === "fullscreen" || a.fullscreenElement === t;
|
|
1875
|
+
function F() {
|
|
1876
|
+
S({ warning: d.renderer === "ass" ? P() ? "video-only" : "ass-style" : P() && d.renderer ? "video-only" : null });
|
|
1877
|
+
}
|
|
1878
|
+
t.addEventListener("webkitpresentationmodechanged", F, { signal: _.signal }), t.addEventListener("enterpictureinpicture", () => {
|
|
1879
|
+
j = !0, F();
|
|
1880
|
+
}, { signal: _.signal }), t.addEventListener("leavepictureinpicture", () => {
|
|
1881
|
+
j = !1, F();
|
|
1882
|
+
}, { signal: _.signal }), t.addEventListener("webkitbeginfullscreen", () => {
|
|
1883
|
+
M = !0, F();
|
|
1884
|
+
}, { signal: _.signal }), t.addEventListener("webkitendfullscreen", () => {
|
|
1885
|
+
M = !1, F();
|
|
1886
|
+
}, { signal: _.signal }), a.addEventListener("fullscreenchange", () => {
|
|
1887
|
+
F();
|
|
1888
|
+
}, { signal: _.signal });
|
|
1889
|
+
function I() {
|
|
1890
|
+
return [...(s?.subtitles ?? []).map(({ src: e, request: t, fonts: n, ...r }) => ({
|
|
1891
|
+
...r,
|
|
1892
|
+
id: fn(r.id)
|
|
1893
|
+
})), ...c ? [c.metadata] : []].map((e) => {
|
|
1894
|
+
let n = ["pgs", "vobsub"].includes(e.format ?? "") ? "Bitmap subtitles require a host burn-in source. Choose text subtitles or a local file." : $(s) === null ? "The absolute subtitle timeline anchor is unknown." : ["ass", "ssa"].includes(e.format ?? "") && (!o.Worker || !o.OffscreenCanvas || !o.WebAssembly || !t.requestVideoFrameCallback) ? "Styled subtitles need Workers, OffscreenCanvas, WASM and video frame callbacks. Choose text subtitles." : null;
|
|
1895
|
+
return n ? {
|
|
1896
|
+
...e,
|
|
1897
|
+
available: !1,
|
|
1898
|
+
unavailableReason: n
|
|
1899
|
+
} : e;
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
async function L(n, m) {
|
|
1903
|
+
let g = s?.subtitles?.find((e) => fn(e.id) === n), _ = n === "subtitle:local" ? c : void 0;
|
|
1904
|
+
if (!g && !_ || $(s) === null) throw Q("This subtitle track is unavailable on the current timeline.");
|
|
1905
|
+
w(), u = n;
|
|
1906
|
+
let v = f, y = AbortSignal.any([m, v.signal]), b = setTimeout(() => v.abort(new DOMException("Subtitle loading timed out", "TimeoutError")), r);
|
|
1907
|
+
S({
|
|
1908
|
+
status: "loading",
|
|
1909
|
+
renderer: null,
|
|
1910
|
+
warning: null
|
|
1911
|
+
});
|
|
1912
|
+
try {
|
|
1913
|
+
let c = _?.format ?? g.format, m = _ ? void 0 : await _n(g, a.baseURI, ["ass", "ssa"].includes(c) ? 10 * dn : 5 * dn, y), b = _?.content ?? yn(vn(m), c);
|
|
1914
|
+
if (Y(y), c === "ass" || c === "ssa") {
|
|
1915
|
+
let n = 0, r = [];
|
|
1916
|
+
for (let e of g?.fonts ?? []) {
|
|
1917
|
+
let t = await _n(e, a.baseURI, 5 * dn, y);
|
|
1918
|
+
if (n += t.byteLength, n > 20971520) throw Q("Subtitle fonts exceed the 20 MiB total limit.");
|
|
1919
|
+
let i = new DataView(t.buffer, t.byteOffset, t.byteLength), s = t.length >= 4 ? i.getUint32(0) : 0;
|
|
1920
|
+
if (![
|
|
1921
|
+
65536,
|
|
1922
|
+
1330926671,
|
|
1923
|
+
2001684038,
|
|
1924
|
+
2001684018
|
|
1925
|
+
].includes(s) || [2001684038, 2001684018].includes(s) && (t.length < 20 || i.getUint32(16) > 5242880)) throw Q("Unsupported or oversized font. Use a valid TTF, OTF, WOFF or WOFF2 font.");
|
|
1926
|
+
try {
|
|
1927
|
+
await X(new o.FontFace("YanePlayer subtitle validation", t).load(), y);
|
|
1928
|
+
} catch {
|
|
1929
|
+
throw Y(y), Q("The subtitle font could not be decoded. Check the font descriptor.");
|
|
1930
|
+
}
|
|
1931
|
+
r.push(t);
|
|
1932
|
+
}
|
|
1933
|
+
let c = await _n({ src: e.font }, a.baseURI, 5 * dn, y);
|
|
1934
|
+
r.push(c);
|
|
1935
|
+
let { createAssRenderer: l } = await X(import("./ass-renderer-DmsQqR82.js"), y);
|
|
1936
|
+
h = await l(t, b, r, $(s) - d.delaySeconds, y, () => {
|
|
1937
|
+
f === v && (w(), S({
|
|
1938
|
+
status: "error",
|
|
1939
|
+
renderer: null,
|
|
1940
|
+
warning: null
|
|
1941
|
+
}), i(Q("The ASS renderer stopped. Retry the track or choose text subtitles.")));
|
|
1942
|
+
}), await h.setOffset($(s) - d.delaySeconds);
|
|
1943
|
+
} else {
|
|
1944
|
+
let e = a.createElement("track");
|
|
1945
|
+
e.id = n, e.kind = "subtitles", e.label = _?.metadata.label ?? g?.label ?? "Subtitles", e.srclang = _?.metadata.language ?? g?.language ?? "";
|
|
1946
|
+
let i = URL.createObjectURL(new Blob([b], { type: "text/vtt" }));
|
|
1947
|
+
p = e;
|
|
1948
|
+
try {
|
|
1949
|
+
if (await sn((t) => (e.addEventListener("load", t), e.addEventListener("error", t), () => {
|
|
1950
|
+
e.removeEventListener("load", t), e.removeEventListener("error", t);
|
|
1951
|
+
}), () => {
|
|
1952
|
+
if (e.readyState === 3) throw Q("The WebVTT file could not be parsed.");
|
|
1953
|
+
return e.readyState === 2;
|
|
1954
|
+
}, y, r, () => {
|
|
1955
|
+
e.src = i, t.append(e), e.track.mode = "hidden";
|
|
1956
|
+
}), e.track.mode = "hidden", !e.track.cues?.length) throw Q("The subtitle file has no supported cues.");
|
|
1957
|
+
E(), e.track.mode = "showing";
|
|
1958
|
+
} finally {
|
|
1959
|
+
URL.revokeObjectURL(i);
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
Y(y), l = n, u = null, S({
|
|
1963
|
+
status: "ready",
|
|
1964
|
+
renderer: h ? "ass" : "native"
|
|
1965
|
+
}), F();
|
|
1966
|
+
} catch (e) {
|
|
1967
|
+
throw f === v && (w(), S({
|
|
1968
|
+
status: y.aborted && m.aborted ? "off" : "error",
|
|
1969
|
+
renderer: null,
|
|
1970
|
+
warning: null
|
|
1971
|
+
})), e;
|
|
1972
|
+
} finally {
|
|
1973
|
+
clearTimeout(b);
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
return {
|
|
1977
|
+
tracks: I,
|
|
1978
|
+
get selected() {
|
|
1979
|
+
return l;
|
|
1980
|
+
},
|
|
1981
|
+
get localActive() {
|
|
1982
|
+
return l === "subtitle:local" || u === "subtitle:local";
|
|
1983
|
+
},
|
|
1984
|
+
get state() {
|
|
1985
|
+
return d;
|
|
1986
|
+
},
|
|
1987
|
+
owns: (e) => !!e?.startsWith("subtitle:"),
|
|
1988
|
+
select: L,
|
|
1989
|
+
openAuto() {
|
|
1990
|
+
w(), p = a.createElement("track"), p.id = "subtitle:auto", p.kind = "subtitles", p.label = "Automatic subtitles", l = p.id, t.append(p), p.track.mode = "showing", S({
|
|
1991
|
+
status: "ready",
|
|
1992
|
+
renderer: "native"
|
|
1993
|
+
}), F();
|
|
1994
|
+
},
|
|
1995
|
+
clearAuto() {
|
|
1996
|
+
if (l === "subtitle:auto" && p) {
|
|
1997
|
+
for (let e of [...p.track.cues ?? []]) p.track.removeCue(e);
|
|
1998
|
+
m = void 0, E();
|
|
1999
|
+
}
|
|
2000
|
+
},
|
|
2001
|
+
showAuto(e, n) {
|
|
2002
|
+
if (l !== "subtitle:auto" || !p) return;
|
|
2003
|
+
let r = t.currentTime + ($(s) ?? 0), i = e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), a = r + Math.min(8, Math.max(3, e.length / 18)) * t.playbackRate;
|
|
2004
|
+
if (m?.id === String(n)) {
|
|
2005
|
+
let e = g.get(m);
|
|
2006
|
+
e && (m.startTime = e.start), g.delete(m), m.endTime = a, m.text = i;
|
|
2007
|
+
} else {
|
|
2008
|
+
if (m) {
|
|
2009
|
+
let e = g.get(m);
|
|
2010
|
+
e && (m.startTime = e.start), g.delete(m), m.endTime = Math.max(m.startTime + .001, r);
|
|
2011
|
+
}
|
|
2012
|
+
m = new o.VTTCue(r, a, i), m.id = String(n), p.track.addCue(m);
|
|
2013
|
+
}
|
|
2014
|
+
E();
|
|
2015
|
+
let c = [...p.track.cues ?? []];
|
|
2016
|
+
for (let [e, n] of c.entries()) n !== m && (n.endTime <= t.currentTime || e < c.length - 128) && p.track.removeCue(n);
|
|
2017
|
+
},
|
|
2018
|
+
off() {
|
|
2019
|
+
w(), S({
|
|
2020
|
+
status: "off",
|
|
2021
|
+
renderer: null,
|
|
2022
|
+
warning: null
|
|
2023
|
+
});
|
|
2024
|
+
},
|
|
2025
|
+
transport(e, t) {
|
|
2026
|
+
if (!l && d.status !== "loading" && d.status !== "error") {
|
|
2027
|
+
let n = e ? "native" : null;
|
|
2028
|
+
d = {
|
|
2029
|
+
...d,
|
|
2030
|
+
renderer: n,
|
|
2031
|
+
status: e || t ? "ready" : "off",
|
|
2032
|
+
warning: t ? "host-rendered" : P() && e ? "video-only" : null
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
},
|
|
2036
|
+
setSource(e, t = !1) {
|
|
2037
|
+
w(), s = e, t || (c = void 0), S({
|
|
2038
|
+
renderer: null,
|
|
2039
|
+
status: "off",
|
|
2040
|
+
warning: null
|
|
2041
|
+
}), T();
|
|
2042
|
+
},
|
|
2043
|
+
async loadFile(e, t, r) {
|
|
2044
|
+
if (!(e instanceof o.File)) throw Q("Choose a subtitle file from this device.");
|
|
2045
|
+
let i = e?.name?.split(".").at(-1)?.toLowerCase();
|
|
2046
|
+
if (!i || ![
|
|
2047
|
+
"vtt",
|
|
2048
|
+
"srt",
|
|
2049
|
+
"ass",
|
|
2050
|
+
"ssa"
|
|
2051
|
+
].includes(i)) throw Q("Choose a VTT, SRT, ASS or SSA file.");
|
|
2052
|
+
if (e.size > (["ass", "ssa"].includes(i) ? 10 : 5) * 1048576) throw Q("The local subtitle file exceeds the size limit.");
|
|
2053
|
+
let a = yn(vn(new Uint8Array(await X(e.arrayBuffer(), t))), i);
|
|
2054
|
+
if (Y(t), !r()) throw new DOMException("Local subtitle selection superseded", "AbortError");
|
|
2055
|
+
c = {
|
|
2056
|
+
metadata: {
|
|
2057
|
+
id: pn,
|
|
2058
|
+
label: e.name,
|
|
2059
|
+
format: i
|
|
2060
|
+
},
|
|
2061
|
+
format: i,
|
|
2062
|
+
content: a
|
|
2063
|
+
}, n();
|
|
2064
|
+
},
|
|
2065
|
+
removeLocal() {
|
|
2066
|
+
l === "subtitle:local" && (w(), S({
|
|
2067
|
+
status: "off",
|
|
2068
|
+
renderer: null,
|
|
2069
|
+
warning: null
|
|
2070
|
+
})), c = void 0, n();
|
|
2071
|
+
},
|
|
2072
|
+
async setDelay(e) {
|
|
2073
|
+
if (!Number.isFinite(e) || Math.abs(e) > 60) throw Z("invalid-command", "text", "Subtitle delay must be between -60 and 60 seconds.");
|
|
2074
|
+
d = {
|
|
2075
|
+
...d,
|
|
2076
|
+
delaySeconds: e
|
|
2077
|
+
}, E(), await h?.setOffset(($(s) ?? 0) - e), n();
|
|
2078
|
+
},
|
|
2079
|
+
setStyle(e) {
|
|
2080
|
+
let t = {
|
|
2081
|
+
...d.style,
|
|
2082
|
+
...e
|
|
2083
|
+
};
|
|
2084
|
+
if (!e || typeof e != "object" || Array.isArray(e) || Object.keys(e).some((e) => ![
|
|
2085
|
+
"fontScale",
|
|
2086
|
+
"color",
|
|
2087
|
+
"background",
|
|
2088
|
+
"edge",
|
|
2089
|
+
"presentation"
|
|
2090
|
+
].includes(e)) || !Number.isFinite(t.fontScale) || t.fontScale < .75 || t.fontScale > 2 || !/^#[\da-f]{6}$/i.test(t.color) || !(t.background === "transparent" || /^#[\da-f]{6}([\da-f]{2})?$/i.test(t.background)) || ![
|
|
2091
|
+
"none",
|
|
2092
|
+
"outline",
|
|
2093
|
+
"shadow"
|
|
2094
|
+
].includes(t.edge) || t.presentation !== void 0 && !["native", "card"].includes(t.presentation)) throw Z("invalid-command", "text", "Invalid subtitle appearance settings.");
|
|
2095
|
+
d = {
|
|
2096
|
+
...d,
|
|
2097
|
+
style: t
|
|
2098
|
+
}, T(), n();
|
|
2099
|
+
},
|
|
2100
|
+
dispose() {
|
|
2101
|
+
w(), _.abort(), A.disconnect(), O.clear(), y && (y.adoptedStyleSheets = y.adoptedStyleSheets.filter((e) => e !== v)), t.removeAttribute("data-yp-captions"), delete t.dataset.captionScale;
|
|
2102
|
+
}
|
|
2103
|
+
};
|
|
2104
|
+
}
|
|
2105
|
+
// src/core/platform.ts
|
|
2106
|
+
var An = /* @__PURE__ */ new WeakMap(), jn = /* @__PURE__ */ new WeakMap();
|
|
2107
|
+
function Mn(e, t, n, r, i, a = {}, o = 15e3) {
|
|
2108
|
+
let s = e.ownerDocument, c = s.defaultView, l = c.navigator, u = c.screen.orientation, d = new AbortController(), f = {}, p = { ...a }, m = !1, h = 0, g = new AbortController(), _ = null, v, y, b = !1, x = !1, S = !1, C = !1, w = !1, T = !1, E = null, D = null, O = () => n.state.isFullscreen, k = () => n.state.isPictureInPicture, A = () => e.getRootNode().pictureInPictureElement === e || s.pictureInPictureElement === e;
|
|
2109
|
+
function j(n) {
|
|
2110
|
+
let r = e, i = n === "fullscreen" ? "fullscreen" : "picture-in-picture";
|
|
2111
|
+
if (r.webkitPresentationMode === i) r.webkitSetPresentationMode?.("inline");
|
|
2112
|
+
else if (n === "pictureInPicture") A() && s.exitPictureInPicture().catch(() => {});
|
|
2113
|
+
else if (s.fullscreenElement === t || s.fullscreenElement === e) s.exitFullscreen().catch(() => {});
|
|
2114
|
+
else {
|
|
2115
|
+
let n = s;
|
|
2116
|
+
(n.webkitFullscreenElement === t || n.webkitFullscreenElement === e) && Promise.resolve(n.webkitExitFullscreen?.()).catch(() => {});
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
let M = () => {
|
|
2120
|
+
m || r();
|
|
2121
|
+
};
|
|
2122
|
+
function N(e) {
|
|
2123
|
+
let t = `The browser could not enable ${e}. Check permissions and try again.`;
|
|
2124
|
+
return D?.feature !== e && (D = {
|
|
2125
|
+
feature: e,
|
|
2126
|
+
message: t
|
|
2127
|
+
}, M()), Error(t);
|
|
2128
|
+
}
|
|
2129
|
+
function P(e) {
|
|
2130
|
+
return D?.feature === e && (D = null, !0);
|
|
2131
|
+
}
|
|
2132
|
+
function F() {
|
|
2133
|
+
let e = y;
|
|
2134
|
+
y = void 0, e && e.release().catch(() => {});
|
|
2135
|
+
}
|
|
2136
|
+
function I() {
|
|
2137
|
+
return !m && p.wakeLock !== !1 && s.visibilityState === "visible" && !!_ && !e.paused && !e.ended && v?.intent === "playing" && (v.playback === "playing" || v.playback === "buffering");
|
|
2138
|
+
}
|
|
2139
|
+
function L() {
|
|
2140
|
+
if (!I()) {
|
|
2141
|
+
x = !1, F();
|
|
2142
|
+
return;
|
|
2143
|
+
}
|
|
2144
|
+
if (!l.wakeLock || y || b || x) return;
|
|
2145
|
+
b = !0, x = !0;
|
|
2146
|
+
let e = h;
|
|
2147
|
+
l.wakeLock.request("screen").then((t) => {
|
|
2148
|
+
e !== h || !I() ? t.release().catch(() => {}) : (y = t, P("wakeLock"), t.addEventListener("release", () => {
|
|
2149
|
+
y === t && (y = void 0, M());
|
|
2150
|
+
}, {
|
|
2151
|
+
once: !0,
|
|
2152
|
+
signal: d.signal
|
|
2153
|
+
}), M());
|
|
2154
|
+
}, () => {
|
|
2155
|
+
!m && e === h && I() && N("wakeLock");
|
|
2156
|
+
}).finally(() => {
|
|
2157
|
+
b = !1, !m && e !== h && L();
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
function R() {
|
|
2161
|
+
if (u && jn.get(u) === f) {
|
|
2162
|
+
jn.delete(u);
|
|
2163
|
+
try {
|
|
2164
|
+
u.unlock();
|
|
2165
|
+
} catch {}
|
|
2166
|
+
}
|
|
2167
|
+
C = !1;
|
|
2168
|
+
}
|
|
2169
|
+
function z() {
|
|
2170
|
+
if (!O() || !p.orientation || s.visibilityState !== "visible") {
|
|
2171
|
+
T = !1, R();
|
|
2172
|
+
return;
|
|
2173
|
+
}
|
|
2174
|
+
if (!u?.lock || C || w || T) return;
|
|
2175
|
+
w = !0, T = !0;
|
|
2176
|
+
let e = h;
|
|
2177
|
+
jn.set(u, f), u.lock("landscape").then(() => {
|
|
2178
|
+
m || e !== h || !O() || !p.orientation || s.visibilityState !== "visible" ? R() : (C = jn.get(u) === f, P("orientation"), M());
|
|
2179
|
+
}, () => {
|
|
2180
|
+
jn.get(u) === f && jn.delete(u), !m && e === h && N("orientation");
|
|
2181
|
+
}).finally(() => {
|
|
2182
|
+
w = !1, !m && e !== h && (T = !1, z());
|
|
2183
|
+
});
|
|
2184
|
+
}
|
|
2185
|
+
let B = l.mediaSession;
|
|
2186
|
+
function V() {
|
|
2187
|
+
if (S && B && (S = !1, An.get(B) === V)) {
|
|
2188
|
+
An.delete(B);
|
|
2189
|
+
for (let e of [
|
|
2190
|
+
"play",
|
|
2191
|
+
"pause",
|
|
2192
|
+
"stop",
|
|
2193
|
+
"seekto",
|
|
2194
|
+
"seekbackward",
|
|
2195
|
+
"seekforward",
|
|
2196
|
+
"previoustrack",
|
|
2197
|
+
"nexttrack"
|
|
2198
|
+
]) try {
|
|
2199
|
+
B.setActionHandler(e, null);
|
|
2200
|
+
} catch {}
|
|
2201
|
+
try {
|
|
2202
|
+
B.metadata = null, B.playbackState = "none";
|
|
2203
|
+
} catch {}
|
|
2204
|
+
try {
|
|
2205
|
+
B.setPositionState();
|
|
2206
|
+
} catch {}
|
|
2207
|
+
M();
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
function ee(t = !1) {
|
|
2211
|
+
if (B) {
|
|
2212
|
+
if (p.mediaSession === !1 || !_) V();
|
|
2213
|
+
else if (t && !S && (An.get(B)?.(), An.set(B, V), S = !0), S && v) try {
|
|
2214
|
+
let t = (e) => {
|
|
2215
|
+
e().catch(() => {});
|
|
2216
|
+
}, n = (e) => {
|
|
2217
|
+
if (!v || !Number.isFinite(e)) return;
|
|
2218
|
+
let n = Math.max(0, Math.min(v.durationSeconds ?? Infinity, e));
|
|
2219
|
+
if (v.capabilities.seek === "local") {
|
|
2220
|
+
let e = v.seekable;
|
|
2221
|
+
if (!e.length) return;
|
|
2222
|
+
e.some(([e, t]) => n >= e && n <= t) || (n = e.flat().reduce((e, t) => Math.abs(t - n) < Math.abs(e - n) ? t : e));
|
|
2223
|
+
}
|
|
2224
|
+
t(() => i().seek(n));
|
|
2225
|
+
}, r = {
|
|
2226
|
+
play: () => t(() => i().play()),
|
|
2227
|
+
pause: () => t(() => i().pause()),
|
|
2228
|
+
stop: () => t(() => i().pause()),
|
|
2229
|
+
seekto: v.capabilities.seek === "none" ? null : (e) => {
|
|
2230
|
+
e.seekTime !== void 0 && n(e.seekTime);
|
|
2231
|
+
},
|
|
2232
|
+
seekbackward: v.capabilities.seek === "none" ? null : (e) => n((v?.positionSeconds ?? 0) - (e.seekOffset ?? 10)),
|
|
2233
|
+
seekforward: v.capabilities.seek === "none" ? null : (e) => n((v?.positionSeconds ?? 0) + (e.seekOffset ?? 10)),
|
|
2234
|
+
previoustrack: v.navigation.previous ? () => t(() => i().navigate("previous")) : null,
|
|
2235
|
+
nexttrack: v.navigation.next ? () => t(() => i().navigate("next")) : null
|
|
2236
|
+
};
|
|
2237
|
+
for (let [e, t] of Object.entries(r)) try {
|
|
2238
|
+
B.setActionHandler(e, t ?? null);
|
|
2239
|
+
} catch {}
|
|
2240
|
+
B.playbackState = !e.paused && !e.ended ? "playing" : "paused";
|
|
2241
|
+
let { durationSeconds: a, positionSeconds: o, playbackRate: s } = v;
|
|
2242
|
+
a !== null && a > 0 && o !== null && o >= 0 && o <= a && s > 0 ? B.setPositionState?.({
|
|
2243
|
+
duration: a,
|
|
2244
|
+
position: o,
|
|
2245
|
+
playbackRate: s
|
|
2246
|
+
}) : B.setPositionState?.(), P("mediaSession") && M();
|
|
2247
|
+
} catch {
|
|
2248
|
+
N("mediaSession");
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
function H() {
|
|
2253
|
+
if (S && B) try {
|
|
2254
|
+
B.metadata = new c.MediaMetadata({
|
|
2255
|
+
title: _?.title ?? "",
|
|
2256
|
+
..._?.metadata,
|
|
2257
|
+
artwork: _?.metadata?.artwork?.map((e) => ({ ...e })) ?? []
|
|
2258
|
+
});
|
|
2259
|
+
} catch {
|
|
2260
|
+
N("mediaSession");
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
for (let t of [
|
|
2264
|
+
"play",
|
|
2265
|
+
"playing",
|
|
2266
|
+
"pause",
|
|
2267
|
+
"ended"
|
|
2268
|
+
]) e.addEventListener(t, () => {
|
|
2269
|
+
t === "play" && (x = !1);
|
|
2270
|
+
let e = S;
|
|
2271
|
+
ee(t === "play"), !e && S && H(), L(), M();
|
|
2272
|
+
}, { signal: d.signal });
|
|
2273
|
+
let U = [
|
|
2274
|
+
[s, "fullscreenchange"],
|
|
2275
|
+
[s, "webkitfullscreenchange"],
|
|
2276
|
+
[e, "webkitpresentationmodechanged"],
|
|
2277
|
+
[e, "enterpictureinpicture"],
|
|
2278
|
+
[e, "leavepictureinpicture"]
|
|
2279
|
+
];
|
|
2280
|
+
for (let [e, t] of U) e.addEventListener(t, () => {
|
|
2281
|
+
z(), M();
|
|
2282
|
+
}, { signal: d.signal });
|
|
2283
|
+
s.addEventListener("visibilitychange", () => {
|
|
2284
|
+
++h, x = !1, T = !1, L(), z(), M();
|
|
2285
|
+
}, { signal: d.signal });
|
|
2286
|
+
async function W(e, t, r = !1) {
|
|
2287
|
+
if (m) throw J();
|
|
2288
|
+
if (E) throw Error("Wait for the current platform command.");
|
|
2289
|
+
let i = g.signal, a = new AbortController(), s = AbortSignal.any([i, a.signal]);
|
|
2290
|
+
E = e, P(e), M();
|
|
2291
|
+
try {
|
|
2292
|
+
let i = Promise.resolve(), a = sn((e) => {
|
|
2293
|
+
let t = n.subscribe(e);
|
|
2294
|
+
for (let [t, n] of U) t.addEventListener(n, e);
|
|
2295
|
+
return () => {
|
|
2296
|
+
t();
|
|
2297
|
+
for (let [t, n] of U) t.removeEventListener(n, e);
|
|
2298
|
+
};
|
|
2299
|
+
}, () => (e === "fullscreen" ? O() : k()) === !r, s, o, () => {
|
|
2300
|
+
i = Promise.resolve(t()), i.then(() => {
|
|
2301
|
+
!r && (m || s.aborted) && j(e);
|
|
2302
|
+
}, () => {});
|
|
2303
|
+
});
|
|
2304
|
+
await Promise.all([a, X(i, s)]), e === "fullscreen" && z();
|
|
2305
|
+
} catch {
|
|
2306
|
+
throw m || i.aborted ? J() : N(e);
|
|
2307
|
+
} finally {
|
|
2308
|
+
a.abort(), E = null, M();
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
return {
|
|
2312
|
+
bindMedia(e) {
|
|
2313
|
+
let t = Object.getOwnPropertyDescriptor(e, "isPictureInPicture");
|
|
2314
|
+
return Object.defineProperty(e, "isPictureInPicture", {
|
|
2315
|
+
configurable: !0,
|
|
2316
|
+
get: A
|
|
2317
|
+
}), () => {
|
|
2318
|
+
t ? Object.defineProperty(e, "isPictureInPicture", t) : Reflect.deleteProperty(e, "isPictureInPicture");
|
|
2319
|
+
};
|
|
2320
|
+
},
|
|
2321
|
+
capabilities() {
|
|
2322
|
+
return {
|
|
2323
|
+
fullscreen: n.state.fullscreenAvailability === "available",
|
|
2324
|
+
pictureInPicture: n.state.pictureInPictureAvailability === "available" && !e.disablePictureInPicture,
|
|
2325
|
+
wakeLock: !!l.wakeLock,
|
|
2326
|
+
mediaSession: !!B,
|
|
2327
|
+
orientation: typeof u?.lock == "function",
|
|
2328
|
+
preservesPitch: "preservesPitch" in e
|
|
2329
|
+
};
|
|
2330
|
+
},
|
|
2331
|
+
get state() {
|
|
2332
|
+
return {
|
|
2333
|
+
fullscreen: O(),
|
|
2334
|
+
pictureInPicture: k(),
|
|
2335
|
+
wakeLock: !!y && !y.released,
|
|
2336
|
+
orientationLocked: C,
|
|
2337
|
+
mediaSessionActive: S,
|
|
2338
|
+
pending: E,
|
|
2339
|
+
error: D
|
|
2340
|
+
};
|
|
2341
|
+
},
|
|
2342
|
+
update(e) {
|
|
2343
|
+
v = e, L(), z(), ee();
|
|
2344
|
+
},
|
|
2345
|
+
setSource(e) {
|
|
2346
|
+
++h, g.abort(), g = new AbortController(), _ = e, D = null, F(), x = !1, T = !1, R(), V(), j("pictureInPicture");
|
|
2347
|
+
},
|
|
2348
|
+
setOptions(t) {
|
|
2349
|
+
(p.wakeLock !== t.wakeLock || p.mediaSession !== t.mediaSession || p.orientation !== t.orientation) && (p = { ...t }, ++h, x = !1, T = !1, L(), z(), ee(!e.paused && !e.ended), H(), M());
|
|
2350
|
+
},
|
|
2351
|
+
enterFullscreen: () => W("fullscreen", () => {
|
|
2352
|
+
if (n.state.fullscreenAvailability !== "available") throw Error("Fullscreen is unavailable");
|
|
2353
|
+
return O() ? Promise.resolve() : n.requestFullscreen();
|
|
2354
|
+
}),
|
|
2355
|
+
exitFullscreen: () => W("fullscreen", () => O() ? n.exitFullscreen() : Promise.resolve(), !0),
|
|
2356
|
+
requestPictureInPicture: () => W("pictureInPicture", () => {
|
|
2357
|
+
if (n.state.pictureInPictureAvailability !== "available" || e.disablePictureInPicture) throw Error("Picture in picture is unavailable");
|
|
2358
|
+
return k() ? Promise.resolve() : n.requestPictureInPicture();
|
|
2359
|
+
}),
|
|
2360
|
+
exitPictureInPicture: () => W("pictureInPicture", () => k() ? n.exitPictureInPicture() : Promise.resolve(), !0),
|
|
2361
|
+
dispose() {
|
|
2362
|
+
m = !0, ++h, g.abort(), d.abort(), F(), R(), V(), j("fullscreen"), j("pictureInPicture");
|
|
2363
|
+
}
|
|
2364
|
+
};
|
|
2365
|
+
}
|
|
2366
|
+
// src/core/preferences.ts
|
|
2367
|
+
function Nn(e) {
|
|
2368
|
+
if (!e || typeof e != "object" || Array.isArray(e) || Object.keys(e).some((e) => ![
|
|
2369
|
+
"volume",
|
|
2370
|
+
"muted",
|
|
2371
|
+
"playbackRate",
|
|
2372
|
+
"preservesPitch",
|
|
2373
|
+
"tracks",
|
|
2374
|
+
"captionStyle",
|
|
2375
|
+
"captionDelaySeconds"
|
|
2376
|
+
].includes(e))) throw TypeError("Invalid player preferences");
|
|
2377
|
+
for (let [t, n, r] of [
|
|
2378
|
+
[
|
|
2379
|
+
"volume",
|
|
2380
|
+
0,
|
|
2381
|
+
1
|
|
2382
|
+
],
|
|
2383
|
+
[
|
|
2384
|
+
"playbackRate",
|
|
2385
|
+
.1,
|
|
2386
|
+
4
|
|
2387
|
+
],
|
|
2388
|
+
[
|
|
2389
|
+
"captionDelaySeconds",
|
|
2390
|
+
-60,
|
|
2391
|
+
60
|
|
2392
|
+
]
|
|
2393
|
+
]) {
|
|
2394
|
+
let i = e[t];
|
|
2395
|
+
if (i !== void 0 && (!Number.isFinite(i) || i < n || i > r)) throw TypeError("Invalid preference range");
|
|
2396
|
+
}
|
|
2397
|
+
for (let t of [e.muted, e.preservesPitch]) if (t !== void 0 && typeof t != "boolean") throw TypeError("Invalid preference flag");
|
|
2398
|
+
Dn(e.tracks);
|
|
2399
|
+
let t = e.captionStyle;
|
|
2400
|
+
if (t !== void 0 && (!t || typeof t != "object" || Array.isArray(t) || Object.keys(t).some((e) => ![
|
|
2401
|
+
"fontScale",
|
|
2402
|
+
"color",
|
|
2403
|
+
"background",
|
|
2404
|
+
"edge",
|
|
2405
|
+
"presentation"
|
|
2406
|
+
].includes(e)) || t.fontScale !== void 0 && (!Number.isFinite(t.fontScale) || t.fontScale < .75 || t.fontScale > 2) || t.color !== void 0 && !/^#[\da-f]{6}$/i.test(t.color) || t.background !== void 0 && t.background !== "transparent" && !/^#[\da-f]{6}([\da-f]{2})?$/i.test(t.background) || t.edge !== void 0 && ![
|
|
2407
|
+
"outline",
|
|
2408
|
+
"none",
|
|
2409
|
+
"shadow"
|
|
2410
|
+
].includes(t.edge) || t.presentation !== void 0 && !["native", "card"].includes(t.presentation))) throw TypeError("Invalid caption preferences");
|
|
2411
|
+
return structuredClone(e);
|
|
2412
|
+
}
|
|
2413
|
+
function Pn(e, t, n) {
|
|
2414
|
+
let r = new AbortController(), i, a = "idle", o = null, s = !1, c = !1, l = !1, u, d = !1;
|
|
2415
|
+
function f() {
|
|
2416
|
+
d || n();
|
|
2417
|
+
}
|
|
2418
|
+
async function p() {
|
|
2419
|
+
if (!i || d || s || c || !l) return;
|
|
2420
|
+
let e = i, n = r.signal;
|
|
2421
|
+
c = !0, l = !1, a = "saving", o = null, f();
|
|
2422
|
+
try {
|
|
2423
|
+
let r = Nn(t());
|
|
2424
|
+
await X(Promise.resolve().then(() => e.save(r, { signal: n })), n), Y(n), a = "ready";
|
|
2425
|
+
} catch {
|
|
2426
|
+
n.aborted || (a = "error", o = "Preferences could not be saved. Change a setting to retry.");
|
|
2427
|
+
} finally {
|
|
2428
|
+
n.aborted || (c = !1, f(), l && p());
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
return {
|
|
2432
|
+
get state() {
|
|
2433
|
+
return {
|
|
2434
|
+
status: a,
|
|
2435
|
+
error: o
|
|
2436
|
+
};
|
|
2437
|
+
},
|
|
2438
|
+
get applying() {
|
|
2439
|
+
return s;
|
|
2440
|
+
},
|
|
2441
|
+
async setAdapter(t) {
|
|
2442
|
+
if (d) throw J();
|
|
2443
|
+
r.abort(), r = new AbortController();
|
|
2444
|
+
let n = r.signal;
|
|
2445
|
+
clearTimeout(u), i = t, c = !1, l = !1, s = !0, a = t ? "loading" : "idle", o = null, f();
|
|
2446
|
+
try {
|
|
2447
|
+
if (await e({}, n), Y(n), t) {
|
|
2448
|
+
let r = await X(Promise.resolve().then(() => t.load({ signal: n })), n);
|
|
2449
|
+
Y(n), await e(r === null ? {} : Nn(r), n), Y(n), a = "ready";
|
|
2450
|
+
}
|
|
2451
|
+
} catch {
|
|
2452
|
+
throw n.aborted ? J() : (a = "error", o = "Preferences could not be loaded. Reconnect the preference adapter to retry.", Error(o));
|
|
2453
|
+
} finally {
|
|
2454
|
+
n.aborted || (s = !1, f());
|
|
2455
|
+
}
|
|
2456
|
+
},
|
|
2457
|
+
schedule() {
|
|
2458
|
+
!i || d || s || (l = !0, clearTimeout(u), u = setTimeout(() => {
|
|
2459
|
+
p();
|
|
2460
|
+
}, 100));
|
|
2461
|
+
},
|
|
2462
|
+
dispose() {
|
|
2463
|
+
d = !0, r.abort(), clearTimeout(u);
|
|
2464
|
+
}
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
// src/core/auto-captions.ts
|
|
2468
|
+
function Fn(e, n, r) {
|
|
2469
|
+
let i = e.ownerDocument.defaultView, a = {
|
|
2470
|
+
available: !1,
|
|
2471
|
+
reason: "source",
|
|
2472
|
+
status: "off",
|
|
2473
|
+
progress: null,
|
|
2474
|
+
error: null,
|
|
2475
|
+
backend: null,
|
|
2476
|
+
latencySeconds: null
|
|
2477
|
+
}, o, s, c, l, u, d, f, p, m = 0, h = 0, g = [], _ = 0, v = 0, y = 0, b = "", x = -1, S = !1, C, w, T = !1, E = !1, D = null, O = "", k = -Infinity, A = 0, j, M = new AbortController();
|
|
2478
|
+
function N(e) {
|
|
2479
|
+
a = {
|
|
2480
|
+
...a,
|
|
2481
|
+
...e
|
|
2482
|
+
}, n();
|
|
2483
|
+
}
|
|
2484
|
+
function P() {
|
|
2485
|
+
m++, g = [], _ = 0, v = 0, y++, b = "", x = -1, S = !1, w = void 0, O = "", k = -Infinity, r.clear(), d?.port.postMessage({
|
|
2486
|
+
epoch: m,
|
|
2487
|
+
enabled: F()
|
|
2488
|
+
});
|
|
2489
|
+
}
|
|
2490
|
+
function F() {
|
|
2491
|
+
return a.status === "listening" && !e.paused && !e.ended && !e.seeking && !T && !E;
|
|
2492
|
+
}
|
|
2493
|
+
function I() {
|
|
2494
|
+
let e = !!o;
|
|
2495
|
+
o?.abort(), o = void 0, clearTimeout(f), clearTimeout(p), s?.terminate(), s = void 0, j?.reject(J()), j = void 0, d?.port.close(), d?.disconnect(), d = void 0, u?.disconnect(), u = void 0, l && (l.onaddtrack = (e) => e.track.stop(), l.getTracks().forEach((e) => e.stop())), l = void 0, c && c.close().catch(() => {}), c = void 0, C = void 0, A = 0, w = void 0, g = [], _ = 0, v = 0, b = "", x = -1, S = !1, m++, e && r.off();
|
|
2496
|
+
}
|
|
2497
|
+
function L() {
|
|
2498
|
+
if (c && d && !e.paused && !u) {
|
|
2499
|
+
if (l = e.captureStream(), l.getVideoTracks().forEach((e) => e.stop()), !l.getAudioTracks().length) throw Error("No accessible audio track.");
|
|
2500
|
+
u = c.createMediaStreamSource(new i.MediaStream(l.getAudioTracks())), u.connect(d);
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
function R() {
|
|
2504
|
+
a = {
|
|
2505
|
+
...a,
|
|
2506
|
+
status: "off",
|
|
2507
|
+
progress: null,
|
|
2508
|
+
error: null,
|
|
2509
|
+
backend: null,
|
|
2510
|
+
latencySeconds: null
|
|
2511
|
+
}, I(), n();
|
|
2512
|
+
}
|
|
2513
|
+
function z(e) {
|
|
2514
|
+
let t = j;
|
|
2515
|
+
j = void 0, a = {
|
|
2516
|
+
...a,
|
|
2517
|
+
status: "error",
|
|
2518
|
+
progress: null,
|
|
2519
|
+
error: e
|
|
2520
|
+
}, I(), t?.reject(Error(e)), n();
|
|
2521
|
+
}
|
|
2522
|
+
function B(e, t) {
|
|
2523
|
+
clearTimeout(f), f = setTimeout(() => z(t), e);
|
|
2524
|
+
}
|
|
2525
|
+
function V(e) {
|
|
2526
|
+
s && (C = e, B(15e3, "Recognition is too slow on this device. Try again or use prepared subtitles."), s.postMessage({
|
|
2527
|
+
type: "transcribe",
|
|
2528
|
+
id: e.id,
|
|
2529
|
+
epoch: e.epoch,
|
|
2530
|
+
segment: e.segment,
|
|
2531
|
+
audio: e.audio
|
|
2532
|
+
}, [e.audio.buffer]));
|
|
2533
|
+
}
|
|
2534
|
+
function ee(e) {
|
|
2535
|
+
if (!F() || !(e instanceof Float32Array) || e.length !== 4e3) return;
|
|
2536
|
+
let t = 0;
|
|
2537
|
+
for (let n of e) t += n * n;
|
|
2538
|
+
let n = Math.sqrt(t / e.length) >= .006;
|
|
2539
|
+
n && _++, v = n ? 0 : v + 1, g.push(e);
|
|
2540
|
+
let r = a.backend === "gpu";
|
|
2541
|
+
r && v >= 1 && _ >= 2 || g.length >= (r ? 24 : 16) ? H() : r && g.length >= 4 && v < 2 ? H(!1) : !_ && g.length >= 4 && (g = g.slice(-1));
|
|
2542
|
+
}
|
|
2543
|
+
function H(t = !0) {
|
|
2544
|
+
if (g.length < (a.backend === "gpu" ? 3 : 4)) {
|
|
2545
|
+
t && (g = [], _ = v = 0, y++, S = !1);
|
|
2546
|
+
return;
|
|
2547
|
+
}
|
|
2548
|
+
let n = new Float32Array(g.length * 4e3);
|
|
2549
|
+
g.forEach((e, t) => n.set(e, t * 4e3));
|
|
2550
|
+
let r = _ >= 2, i = {
|
|
2551
|
+
audio: n,
|
|
2552
|
+
epoch: m,
|
|
2553
|
+
id: ++h,
|
|
2554
|
+
end: e.currentTime,
|
|
2555
|
+
capturedAt: performance.now(),
|
|
2556
|
+
duration: n.length / 16e3,
|
|
2557
|
+
segment: y,
|
|
2558
|
+
overlap: S
|
|
2559
|
+
};
|
|
2560
|
+
t && (g = a.backend === "gpu" && v === 0 ? g.slice(-4) : [], S = g.length > 0, _ = g.length, v = 0, y++), r && (C ? w = i : V(i));
|
|
2561
|
+
}
|
|
2562
|
+
function U(t) {
|
|
2563
|
+
if (o && !o.signal.aborted) {
|
|
2564
|
+
if (t.type === "progress" && a.status === "loading") B(6e4, "The speech model download stalled. Check the connection and retry."), Number.isFinite(t.progress) && N({ progress: Math.max(0, Math.min(1, t.progress)) });
|
|
2565
|
+
else if (t.type === "ready" && a.status === "loading") {
|
|
2566
|
+
clearTimeout(f), clearTimeout(p);
|
|
2567
|
+
try {
|
|
2568
|
+
L();
|
|
2569
|
+
} catch {
|
|
2570
|
+
z("The video does not expose readable audio. Use prepared subtitles.");
|
|
2571
|
+
return;
|
|
2572
|
+
}
|
|
2573
|
+
r.open(), N({
|
|
2574
|
+
status: "listening",
|
|
2575
|
+
progress: null,
|
|
2576
|
+
backend: t.backend ?? "cpu"
|
|
2577
|
+
}), P(), j?.resolve(), j = void 0;
|
|
2578
|
+
} else if (t.type === "error") z("Local speech recognition failed. Check model access and retry.");
|
|
2579
|
+
else if ((t.type === "result" || t.type === "partial") && C && t.id === C.id) {
|
|
2580
|
+
let n = C, i = t.type === "result";
|
|
2581
|
+
i && (clearTimeout(f), C = void 0);
|
|
2582
|
+
let a = (performance.now() - n.capturedAt) / 1e3 + n.duration;
|
|
2583
|
+
if (i && n.epoch === m && !e.paused && (A = a - n.duration > n.duration * 1.5 ? A + 1 : 0, A >= 3)) {
|
|
2584
|
+
z("Recognition cannot keep up with this video on this device. Use prepared subtitles or retry at a lower speed.");
|
|
2585
|
+
return;
|
|
2586
|
+
}
|
|
2587
|
+
let o = typeof t.text == "string" ? t.text.trim().replace(/\s+/g, " ") : "";
|
|
2588
|
+
n.segment !== x && (b = n.overlap ? O : "");
|
|
2589
|
+
let s = o.split(" "), c = b.split(" "), l = (e) => e.toLowerCase().replace(/[^\p{L}\p{N}]/gu, "");
|
|
2590
|
+
for (let e = Math.min(12, s.length, c.length); e >= 2; e--) if (s.slice(0, e).every((t, n) => l(t) === l(c[c.length - e + n]))) {
|
|
2591
|
+
o = s.slice(e).join(" ");
|
|
2592
|
+
break;
|
|
2593
|
+
}
|
|
2594
|
+
if (n.epoch === m && !T && !e.seeking && a <= 15 && o.length > 1 && o.length <= 300 && /\p{L}/u.test(o) && (i || n.segment !== x || o.length > O.length) && !(n.segment === x && o === O && n.end - k < 12) && (O = o, k = n.end, x = n.segment, r.show(o, n.segment), N({ latencySeconds: Math.round(Math.max(0, a) * 10) / 10 })), i && w) {
|
|
2595
|
+
let e = w;
|
|
2596
|
+
w = void 0, e.epoch === m && V(e);
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
for (let t of [
|
|
2602
|
+
"play",
|
|
2603
|
+
"playing",
|
|
2604
|
+
"pause",
|
|
2605
|
+
"waiting",
|
|
2606
|
+
"seeking",
|
|
2607
|
+
"seeked",
|
|
2608
|
+
"ratechange",
|
|
2609
|
+
"ended"
|
|
2610
|
+
]) e.addEventListener(t, () => {
|
|
2611
|
+
if (t === "waiting" && (E = !0), (t === "playing" || t === "seeked") && (E = !1), o) {
|
|
2612
|
+
if (t === "playing") try {
|
|
2613
|
+
L();
|
|
2614
|
+
} catch {
|
|
2615
|
+
z("The video does not expose readable audio. Use prepared subtitles.");
|
|
2616
|
+
return;
|
|
2617
|
+
}
|
|
2618
|
+
t === "pause" || t === "ended" ? (H(), d?.port.postMessage({
|
|
2619
|
+
epoch: m,
|
|
2620
|
+
enabled: !1
|
|
2621
|
+
})) : P();
|
|
2622
|
+
}
|
|
2623
|
+
}, { signal: M.signal });
|
|
2624
|
+
return {
|
|
2625
|
+
get state() {
|
|
2626
|
+
return a;
|
|
2627
|
+
},
|
|
2628
|
+
update(t, n, r, s) {
|
|
2629
|
+
let c = t ? n ? "tracks" : !i.isSecureContext || !e.captureStream || !i.AudioContext || !i.AudioWorkletNode || !i.Worker || !i.WebAssembly ? "browser" : null : "source";
|
|
2630
|
+
a = {
|
|
2631
|
+
...a,
|
|
2632
|
+
available: c === null,
|
|
2633
|
+
reason: c
|
|
2634
|
+
}, c && o ? R() : (T !== r || D !== s) && (T = r, D = s, o && P());
|
|
2635
|
+
},
|
|
2636
|
+
off: R,
|
|
2637
|
+
async setEnabled(e) {
|
|
2638
|
+
if (!e) {
|
|
2639
|
+
R();
|
|
2640
|
+
return;
|
|
2641
|
+
}
|
|
2642
|
+
if (!a.available) throw Error("Automatic subtitles are unavailable for this source or browser.");
|
|
2643
|
+
if (a.status === "loading" || a.status === "listening") return;
|
|
2644
|
+
if (T) throw Error("Wait for the current player command before enabling automatic subtitles.");
|
|
2645
|
+
R();
|
|
2646
|
+
let n = new AbortController();
|
|
2647
|
+
o = n;
|
|
2648
|
+
let r = n.signal;
|
|
2649
|
+
N({
|
|
2650
|
+
status: "loading",
|
|
2651
|
+
progress: null
|
|
2652
|
+
}), p = setTimeout(() => z("Speech recognition preparation timed out. Retry on a faster connection."), 6e5);
|
|
2653
|
+
try {
|
|
2654
|
+
B(15e3, "Audio capture could not start. Retry automatic subtitles."), c = new i.AudioContext({ sampleRate: 16e3 });
|
|
2655
|
+
let e = c;
|
|
2656
|
+
await X(e.resume(), r), Y(r), await X(e.audioWorklet.addModule(t.worklet), r), Y(r), d = new i.AudioWorkletNode(e, "yaneplayer-captions");
|
|
2657
|
+
let l = d;
|
|
2658
|
+
d.port.onmessage = ({ data: t }) => {
|
|
2659
|
+
o !== n || r.aborted || (l.port.postMessage({ ack: !0 }), t.epoch === m && (e.currentTime - t.capturedAt > .5 ? P() : ee(t.audio)));
|
|
2660
|
+
}, d.onprocessorerror = () => {
|
|
2661
|
+
o === n && !r.aborted && z("Audio capture stopped. Retry automatic subtitles.");
|
|
2662
|
+
}, d.connect(e.destination), L();
|
|
2663
|
+
let u = new Promise((e, t) => {
|
|
2664
|
+
j = {
|
|
2665
|
+
resolve: e,
|
|
2666
|
+
reject: t
|
|
2667
|
+
};
|
|
2668
|
+
}), f = (e = !1) => {
|
|
2669
|
+
let c = new i.Worker(t.worker, {
|
|
2670
|
+
type: "module",
|
|
2671
|
+
name: "yaneplayer-captions"
|
|
2672
|
+
});
|
|
2673
|
+
s = c, c.onmessage = ({ data: t }) => {
|
|
2674
|
+
if (!(o !== n || r.aborted || s !== c)) {
|
|
2675
|
+
if (t.type === "fallback" && !e) {
|
|
2676
|
+
c.terminate(), C = w = void 0, a.status !== "loading" && (p = setTimeout(() => z("Speech recognition preparation timed out. Retry on a faster connection."), 6e5)), N({
|
|
2677
|
+
status: "loading",
|
|
2678
|
+
progress: null,
|
|
2679
|
+
backend: null
|
|
2680
|
+
}), P();
|
|
2681
|
+
try {
|
|
2682
|
+
f(!0);
|
|
2683
|
+
} catch {
|
|
2684
|
+
z("The local speech worker could not restart. Retry automatic subtitles.");
|
|
2685
|
+
}
|
|
2686
|
+
} else U(t);
|
|
2687
|
+
}
|
|
2688
|
+
}, c.onerror = (e) => {
|
|
2689
|
+
e.preventDefault(), !(o !== n || r.aborted || s !== c) && z("The local speech worker could not start. Check browser permissions and retry.");
|
|
2690
|
+
}, B(6e4, "The speech model could not load. Check the connection and retry."), c.postMessage({
|
|
2691
|
+
type: "load",
|
|
2692
|
+
forceCpu: e,
|
|
2693
|
+
wasm: t.wasm,
|
|
2694
|
+
wasmModule: t.wasmModule
|
|
2695
|
+
});
|
|
2696
|
+
};
|
|
2697
|
+
f(), await u, Y(r);
|
|
2698
|
+
} catch (e) {
|
|
2699
|
+
if (r.aborted) throw a.status === "error" && a.error ? Error(a.error) : J();
|
|
2700
|
+
let t = "Automatic subtitles could not start. Check audio access and model downloads, then retry.";
|
|
2701
|
+
throw a.status !== "error" && z(t), e instanceof Error && a.error === e.message ? e : Error(a.error ?? t);
|
|
2702
|
+
}
|
|
2703
|
+
},
|
|
2704
|
+
dispose() {
|
|
2705
|
+
R(), M.abort();
|
|
2706
|
+
}
|
|
2707
|
+
};
|
|
2708
|
+
}
|
|
2709
|
+
// src/core/runtime.ts
|
|
2710
|
+
var In = [
|
|
2711
|
+
"loadstart",
|
|
2712
|
+
"loadedmetadata",
|
|
2713
|
+
"loadeddata",
|
|
2714
|
+
"canplay",
|
|
2715
|
+
"playing",
|
|
2716
|
+
"play",
|
|
2717
|
+
"pause",
|
|
2718
|
+
"waiting",
|
|
2719
|
+
"seeking",
|
|
2720
|
+
"seeked",
|
|
2721
|
+
"timeupdate",
|
|
2722
|
+
"progress",
|
|
2723
|
+
"durationchange",
|
|
2724
|
+
"ratechange",
|
|
2725
|
+
"volumechange",
|
|
2726
|
+
"ended",
|
|
2727
|
+
"error",
|
|
2728
|
+
"audioselectionchange",
|
|
2729
|
+
"textselectionchange"
|
|
2730
|
+
];
|
|
2731
|
+
function Ln(e) {
|
|
2732
|
+
let { media: t, host: n, onEvent: r } = e;
|
|
2733
|
+
if (!t?.ownerDocument?.defaultView) throw Error("createPlayer requires a browser video element");
|
|
2734
|
+
let i = e.commandTimeoutMs ?? 15e3;
|
|
2735
|
+
if (!Number.isFinite(i) || i <= 0) throw RangeError("commandTimeoutMs must be positive");
|
|
2736
|
+
let a = tn()(Ht(...on)), o = /* @__PURE__ */ new Set(), s = !1, c = 0, l = null, u = new AbortController(), d, f = () => {}, p = new AbortController(), m = !1, h = !1, g = !1, _ = "paused", v = null, y = null, b = null, x = {
|
|
2737
|
+
audioId: null,
|
|
2738
|
+
textId: null,
|
|
2739
|
+
qualityId: null
|
|
2740
|
+
}, S = performance.now(), C, w = "", T = e.navigation ?? {}, E = null, D = null, O = 0, k = e.thumbnail, A = new AbortController(), j, M = t.playbackRate, N, P = 0, F = kn(t, () => {
|
|
2741
|
+
C && U();
|
|
2742
|
+
}, i, (e) => {
|
|
2743
|
+
G(e, "text");
|
|
2744
|
+
}), I = 0, L = Fn(t, () => {
|
|
2745
|
+
C && U();
|
|
2746
|
+
}, {
|
|
2747
|
+
open: () => F.openAuto(),
|
|
2748
|
+
clear: () => F.clearAuto(),
|
|
2749
|
+
show: (e, t) => F.showAuto(e, t),
|
|
2750
|
+
off: () => {
|
|
2751
|
+
F.selected === "subtitle:auto" && F.off();
|
|
2752
|
+
}
|
|
2753
|
+
}), R = Mn(t, e.container ?? t.parentElement ?? t, a, () => {
|
|
2754
|
+
C && U();
|
|
2755
|
+
}, () => de, e.platform, i), z = Pn(async (e, n) => {
|
|
2756
|
+
Y(n), j = structuredClone(e.tracks), M = e.playbackRate ?? 1, t.volume = e.volume ?? 1, t.muted = e.muted ?? !1, "preservesPitch" in t && (t.preservesPitch = e.preservesPitch ?? !0), t.playbackRate = !l || ee().playbackRates.includes(M) ? M : 1, F.setStyle({
|
|
2757
|
+
...On,
|
|
2758
|
+
...e.captionStyle
|
|
2759
|
+
}), await F.setDelay(e.captionDelaySeconds ?? 0), Y(n), U();
|
|
2760
|
+
}, () => ({
|
|
2761
|
+
volume: t.volume,
|
|
2762
|
+
muted: t.muted,
|
|
2763
|
+
playbackRate: M,
|
|
2764
|
+
preservesPitch: t.preservesPitch,
|
|
2765
|
+
...j ? { tracks: j } : {},
|
|
2766
|
+
captionStyle: F.state.style,
|
|
2767
|
+
captionDelaySeconds: F.state.delaySeconds
|
|
2768
|
+
}), () => {
|
|
2769
|
+
C && U();
|
|
2770
|
+
}), B = Promise.resolve();
|
|
2771
|
+
function V(e) {
|
|
2772
|
+
s || r?.(Object.freeze({
|
|
2773
|
+
type: e,
|
|
2774
|
+
source: C.source,
|
|
2775
|
+
snapshot: C
|
|
2776
|
+
}));
|
|
2777
|
+
}
|
|
2778
|
+
function ee() {
|
|
2779
|
+
let e = a.state, t = l?.capabilities, r = l !== null && $(l) !== null, i = (e, r) => {
|
|
2780
|
+
let i = t?.[e];
|
|
2781
|
+
return i === "none" ? "none" : i === "host" ? n ? "host" : "none" : r ? "transport" : "none";
|
|
2782
|
+
}, o = !r || t?.seek === "none" ? "none" : t?.seek === "host" && n ? "host" : H().length ? "local" : "none", s = i("audio", e.audioTrackList.length > 0), c = i("text", F.tracks().length > 0 || e.textTrackList.some((e) => e.kind === "subtitles" || e.kind === "captions")), u = F.tracks().length > 0 && c !== "host" ? "transport" : c, d = i("quality", e.videoRenditionList.length > 1), f = {}, p = R.capabilities();
|
|
2783
|
+
for (let e of [
|
|
2784
|
+
"fullscreen",
|
|
2785
|
+
"pictureInPicture",
|
|
2786
|
+
"wakeLock",
|
|
2787
|
+
"mediaSession",
|
|
2788
|
+
"orientation"
|
|
2789
|
+
]) p[e] || (f[e] = `The browser does not expose ${e} for this player.`);
|
|
2790
|
+
o === "none" && (f.seek = r ? "No seek range or host seek capability is available." : "The absolute timeline anchor is unknown.");
|
|
2791
|
+
for (let [e, t] of Object.entries({
|
|
2792
|
+
audio: s,
|
|
2793
|
+
text: u,
|
|
2794
|
+
quality: d
|
|
2795
|
+
})) t === "none" && (f[e] = `No ${e} controller is available for this source.`);
|
|
2796
|
+
return {
|
|
2797
|
+
...p,
|
|
2798
|
+
seek: o,
|
|
2799
|
+
audio: s,
|
|
2800
|
+
text: u,
|
|
2801
|
+
quality: d,
|
|
2802
|
+
autoQuality: d === "transport" && e.videoRenditionList.length > 1,
|
|
2803
|
+
playbackRates: l ? (t?.playbackRates ?? e.playbackRates).filter((t) => e.playbackRates.includes(t)) : [],
|
|
2804
|
+
volume: !!l && e.volumeAvailability === "available",
|
|
2805
|
+
muted: !!l && e.mutedAvailability === "available",
|
|
2806
|
+
reasons: f
|
|
2807
|
+
};
|
|
2808
|
+
}
|
|
2809
|
+
function H() {
|
|
2810
|
+
let e = Sn(a.state.seekable, $(l)), t = l?.timeline?.seekableRanges;
|
|
2811
|
+
return t ? e.flatMap(([e, n]) => t.flatMap(([t, r]) => {
|
|
2812
|
+
let i = Math.max(e, t), a = Math.min(n, r);
|
|
2813
|
+
return i <= a ? [[i, a]] : [];
|
|
2814
|
+
})) : e;
|
|
2815
|
+
}
|
|
2816
|
+
function U() {
|
|
2817
|
+
if (s) return;
|
|
2818
|
+
let e = a.state, n = ee(), r = n.audio === "host" ? l?.audioTracks ?? [] : e.audioTrackList.map(({ enabled: e, ...t }) => ({
|
|
2819
|
+
...t,
|
|
2820
|
+
...d?.trackMetadata?.("audio", t)
|
|
2821
|
+
})), i = [...l?.capabilities?.text === "none" ? [] : n.text === "host" ? l?.textTracks ?? [] : e.textTrackList.filter((e) => !F.owns(e.id) && (e.kind === "subtitles" || e.kind === "captions")).map(({ mode: e, ...t }) => ({
|
|
2822
|
+
...t,
|
|
2823
|
+
...d?.trackMetadata?.("text", t)
|
|
2824
|
+
})), ...F.tracks()], c = n.quality === "host" ? l?.qualities ?? [] : e.videoRenditionList.map(({ selected: e, ...t }) => ({
|
|
2825
|
+
...t,
|
|
2826
|
+
label: t.height ? `${t.height}p` : t.id
|
|
2827
|
+
})), u = e.textTrackList.find((e) => e.mode === "showing" && !F.owns(e.id) && (e.kind === "subtitles" || e.kind === "captions"))?.id ?? null, f = n.audio === "host" ? x.audioId : d?.confirmedAudioId === void 0 ? e.audioTrackList.find((e) => e.enabled)?.id ?? null : d.confirmedAudioId;
|
|
2828
|
+
L.update(!!l && !m && !h && $(l) !== null, i.some((e) => e.available !== !1), !!v, f);
|
|
2829
|
+
let p = {
|
|
2830
|
+
audioId: f,
|
|
2831
|
+
textId: F.selected ?? (n.text === "host" ? x.textId : u && !(d?.textReady?.(u) ?? !0) ? null : u),
|
|
2832
|
+
qualityId: n.quality === "host" ? x.qualityId : n.autoQuality ? e.videoRenditionList.find((e) => e.selected)?.id ?? "auto" : null
|
|
2833
|
+
};
|
|
2834
|
+
F.transport(u !== null, n.text === "host" && p.textId !== null && !F.selected && u === null);
|
|
2835
|
+
let g = t.duration, S = {
|
|
2836
|
+
platform: R.state,
|
|
2837
|
+
preferences: z.state,
|
|
2838
|
+
navigation: {
|
|
2839
|
+
previous: !!T.previous,
|
|
2840
|
+
next: !!T.next,
|
|
2841
|
+
pending: E,
|
|
2842
|
+
error: D
|
|
2843
|
+
},
|
|
2844
|
+
chapters: l?.chapters ?? [],
|
|
2845
|
+
preservesPitch: t.preservesPitch,
|
|
2846
|
+
source: l ? {
|
|
2847
|
+
id: l.id,
|
|
2848
|
+
revision: l.revision,
|
|
2849
|
+
kind: l.kind
|
|
2850
|
+
} : null,
|
|
2851
|
+
playback: h ? "error" : l ? m ? "loading" : e.ended ? "ended" : e.waiting ? "buffering" : e.paused ? e.started ? "paused" : "ready" : "playing" : "idle",
|
|
2852
|
+
intent: _,
|
|
2853
|
+
pending: v,
|
|
2854
|
+
positionSeconds: b,
|
|
2855
|
+
durationSeconds: l?.timeline ? l.timeline.durationSeconds : Number.isFinite(g) && g >= 0 ? g : null,
|
|
2856
|
+
buffered: m ? [] : Sn(e.buffered, $(l)),
|
|
2857
|
+
seekable: m ? [] : H(),
|
|
2858
|
+
audioTracks: r,
|
|
2859
|
+
textTracks: i,
|
|
2860
|
+
qualities: c,
|
|
2861
|
+
selection: p,
|
|
2862
|
+
volume: e.volume,
|
|
2863
|
+
muted: e.muted,
|
|
2864
|
+
playbackRate: e.playbackRate,
|
|
2865
|
+
captions: F.state,
|
|
2866
|
+
autoCaptions: L.state,
|
|
2867
|
+
capabilities: n,
|
|
2868
|
+
error: y
|
|
2869
|
+
}, O = JSON.stringify(S);
|
|
2870
|
+
if (O === w) return;
|
|
2871
|
+
let k = C;
|
|
2872
|
+
w = O, C = bn(structuredClone(S)), R.update(C);
|
|
2873
|
+
for (let e of o) e();
|
|
2874
|
+
V("statechange"), k && JSON.stringify(k.pending) !== JSON.stringify(S.pending) && V("commandchange"), k && JSON.stringify(k.capabilities) !== JSON.stringify(S.capabilities) && V("capabilitieschange"), k && (k.selection.audioId !== p.audioId || k.selection.textId !== p.textId) && V("trackchange"), k && k.selection.qualityId !== p.qualityId && V("qualitychange"), y && y !== k?.error && JSON.stringify(y) !== JSON.stringify(k?.error) && V("error");
|
|
2875
|
+
}
|
|
2876
|
+
function W(e = !1) {
|
|
2877
|
+
if (!l || b === null) return;
|
|
2878
|
+
let t = performance.now();
|
|
2879
|
+
(e || t - S >= 5e3) && (S = t, V("positionchange"));
|
|
2880
|
+
}
|
|
2881
|
+
function te() {
|
|
2882
|
+
let e = $(l);
|
|
2883
|
+
!m && !t.seeking && !g && t.readyState >= 2 && (b = e === null ? null : e + t.currentTime);
|
|
2884
|
+
}
|
|
2885
|
+
function G(e, t, n = !1) {
|
|
2886
|
+
if (e instanceof Error && e.name === "AbortError") return e;
|
|
2887
|
+
let r = un(e, t);
|
|
2888
|
+
return y = r.detail, h ||= n, U(), r;
|
|
2889
|
+
}
|
|
2890
|
+
function K() {
|
|
2891
|
+
if (s) throw J();
|
|
2892
|
+
}
|
|
2893
|
+
function ne(e) {
|
|
2894
|
+
return e === 2 ? Z("network", "media", "The media request failed. Retry the source.", !0) : e === 4 ? Z("unsupported", "media", "The media format is unsupported.") : Z("media", "media", "The media could not be decoded or loaded.", !0);
|
|
2895
|
+
}
|
|
2896
|
+
function re(e, n, r) {
|
|
2897
|
+
let s = /* @__PURE__ */ new Set([t]);
|
|
2898
|
+
d && s.add(d.media);
|
|
2899
|
+
let c = d;
|
|
2900
|
+
return sn((e) => {
|
|
2901
|
+
for (let t of s) for (let n of In) t.addEventListener(n, e);
|
|
2902
|
+
o.add(e);
|
|
2903
|
+
let t = a.subscribe(e);
|
|
2904
|
+
return () => {
|
|
2905
|
+
o.delete(e), t();
|
|
2906
|
+
for (let t of s) for (let n of In) t.removeEventListener(n, e);
|
|
2907
|
+
};
|
|
2908
|
+
}, () => {
|
|
2909
|
+
if (h && y) throw Z(y.code, y.stage, y.message, y.retryable);
|
|
2910
|
+
if (c?.media.error) throw ne(c.media.error.code);
|
|
2911
|
+
return e();
|
|
2912
|
+
}, n, i, r);
|
|
2913
|
+
}
|
|
2914
|
+
function ie() {
|
|
2915
|
+
L.off(), F.off(), p.abort(), f(), f = () => {}, d?.destroy(), d = void 0, t.pause(), t.removeAttribute("src"), t.load();
|
|
2916
|
+
}
|
|
2917
|
+
let ae = () => ({
|
|
2918
|
+
volume: t.volume,
|
|
2919
|
+
muted: t.muted,
|
|
2920
|
+
playbackRate: M
|
|
2921
|
+
});
|
|
2922
|
+
async function oe(n, r, i = ae(), o = !0) {
|
|
2923
|
+
let c = await X(wn(t, n).then((e) => (r.aborted && e.destroy(), e)), r);
|
|
2924
|
+
r.aborted && (c.destroy(), Y(r)), F.setSource(n, o), ie(), l = n, R.setSource(n), m = !0, h = !1, b = null, g = !1, d = c, p = new AbortController();
|
|
2925
|
+
let u = p.signal;
|
|
2926
|
+
c.attach();
|
|
2927
|
+
let y = R.bindMedia(c.media), x = a.attach({
|
|
2928
|
+
media: c.media,
|
|
2929
|
+
container: e.container ?? t.parentElement
|
|
2930
|
+
});
|
|
2931
|
+
f = () => {
|
|
2932
|
+
x(), y();
|
|
2933
|
+
};
|
|
2934
|
+
let S = c.media;
|
|
2935
|
+
for (let e of In) S.addEventListener(e, () => {
|
|
2936
|
+
if (!(s || u.aborted || d !== c)) {
|
|
2937
|
+
if (e === "play" && (_ = "playing"), e === "pause" && (!m || t.readyState >= 2) && (_ = "paused"), e === "error") G(ne(c.media.error?.code), "media", !0), m || queueMicrotask(() => {
|
|
2938
|
+
!s && d === c && h && (ie(), U());
|
|
2939
|
+
});
|
|
2940
|
+
else {
|
|
2941
|
+
if (e === "seeked" && (g = !1), ["volumechange", "ratechange"].includes(e) && !m) {
|
|
2942
|
+
let n = e === "ratechange" && N === t.playbackRate;
|
|
2943
|
+
e === "ratechange" && (N = void 0, !n && !z.applying && (M = t.playbackRate)), n || z.schedule();
|
|
2944
|
+
}
|
|
2945
|
+
[
|
|
2946
|
+
"timeupdate",
|
|
2947
|
+
"seeked",
|
|
2948
|
+
"pause",
|
|
2949
|
+
"ended",
|
|
2950
|
+
"loadeddata"
|
|
2951
|
+
].includes(e) && te(), U(), [
|
|
2952
|
+
"pause",
|
|
2953
|
+
"seeked",
|
|
2954
|
+
"ended"
|
|
2955
|
+
].includes(e) ? W(!0) : e === "timeupdate" && W(), e === "ended" && (V("ended"), T.autoAdvance && T.next && !v && d === c && de.navigate("next").catch(() => {}));
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
}, { signal: u });
|
|
2959
|
+
U();
|
|
2960
|
+
try {
|
|
2961
|
+
await re(() => t.readyState >= 2, r, () => {
|
|
2962
|
+
Promise.resolve(c.start()).catch((e) => {
|
|
2963
|
+
!u.aborted && !r.aborted && (G(e, "source", !0), c.media.dispatchEvent(new Event("error")));
|
|
2964
|
+
});
|
|
2965
|
+
}), Y(r), m = !1, t.volume = i.volume, t.muted = i.muted;
|
|
2966
|
+
let e = (n.capabilities?.playbackRates ?? a.state.playbackRates).includes(i.playbackRate) ? i.playbackRate : 1;
|
|
2967
|
+
await re(() => a.state.playbackRate === e, r, () => {
|
|
2968
|
+
N = t.playbackRate === e ? void 0 : e, t.playbackRate = e;
|
|
2969
|
+
}), a.selectSubtitlesTrack(null), c.disableText?.(), te(), U();
|
|
2970
|
+
} catch (e) {
|
|
2971
|
+
throw r.aborted || (m = !1, ie(), G(e, "source", !0)), e;
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
async function se(e, n) {
|
|
2975
|
+
let r = $(l);
|
|
2976
|
+
if (r === null || !Cn(H(), e)) throw Z("unsupported", "seek", "Position is outside the available local seek ranges.");
|
|
2977
|
+
let i = e - r;
|
|
2978
|
+
if (!(Math.abs(t.currentTime - i) < .001 && !t.seeking)) {
|
|
2979
|
+
g = !0;
|
|
2980
|
+
try {
|
|
2981
|
+
await re(() => !g && !t.seeking, n, () => {
|
|
2982
|
+
a.seek(i).catch(() => {});
|
|
2983
|
+
}), Y(n), te(), U();
|
|
2984
|
+
} finally {
|
|
2985
|
+
g = !1;
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
async function ce(e) {
|
|
2990
|
+
if (_ === "paused") {
|
|
2991
|
+
a.pause(), U();
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2994
|
+
let t = AbortSignal.any([e, p.signal]);
|
|
2995
|
+
try {
|
|
2996
|
+
Y(t), await X(a.play(), t), Y(t), de.getSnapshot().intent === "paused" && a.pause();
|
|
2997
|
+
} catch (e) {
|
|
2998
|
+
throw t.aborted ? e : (_ = "paused", a.pause(), G(e, "play"));
|
|
2999
|
+
}
|
|
3000
|
+
U();
|
|
3001
|
+
}
|
|
3002
|
+
let le = cn(async (e, r, i) => {
|
|
3003
|
+
let o = u.signal, s = AbortSignal.any([i, o]);
|
|
3004
|
+
if (Y(s), !l) throw Z("invalid-command", e.type, "Choose a source first.");
|
|
3005
|
+
let c = { ...e.target }, f = ee(), p = c.positionSeconds !== void 0 && !Cn(H(), c.positionSeconds) && f.seek === "host", m = F.owns(c.textId), h = m ? {
|
|
3006
|
+
...c,
|
|
3007
|
+
textId: null
|
|
3008
|
+
} : c, g = p || c.audioId !== void 0 && f.audio === "host" || c.textId !== void 0 && f.text === "host" || c.qualityId !== void 0 && f.quality === "host";
|
|
3009
|
+
y = null, U();
|
|
3010
|
+
try {
|
|
3011
|
+
if (g) {
|
|
3012
|
+
if (!n) throw Z("unsupported", e.type, "No host adapter is available.");
|
|
3013
|
+
let i = {
|
|
3014
|
+
sourceId: l.id,
|
|
3015
|
+
revision: l.revision,
|
|
3016
|
+
commandId: r,
|
|
3017
|
+
signal: s,
|
|
3018
|
+
positionSeconds: b,
|
|
3019
|
+
get intent() {
|
|
3020
|
+
return _;
|
|
3021
|
+
}
|
|
3022
|
+
}, a = await n.execute(e.type === "text" && m ? {
|
|
3023
|
+
...e,
|
|
3024
|
+
id: null,
|
|
3025
|
+
target: h
|
|
3026
|
+
} : {
|
|
3027
|
+
...e,
|
|
3028
|
+
target: h
|
|
3029
|
+
}, i);
|
|
3030
|
+
if (Y(s), p && !a.source) throw Z("host", "seek", "Host seek requires a ready replacement with actual timeline anchors.", !0);
|
|
3031
|
+
let u = a.source ? xn(a.source, t.ownerDocument.baseURI) : null;
|
|
3032
|
+
if (u) {
|
|
3033
|
+
if (u.id !== l.id) throw Z("invalid-source", e.type, "A host replacement must retain the source id.");
|
|
3034
|
+
if (u.revision === l.revision) throw Z("invalid-source", e.type, "A host replacement requires a new source revision.");
|
|
3035
|
+
}
|
|
3036
|
+
for (let e of [
|
|
3037
|
+
"audioId",
|
|
3038
|
+
"textId",
|
|
3039
|
+
"qualityId"
|
|
3040
|
+
]) {
|
|
3041
|
+
let t = e === "audioId" ? "audio" : e === "textId" ? "text" : "quality", n = a.selection?.[e], r = t === "audio" ? (u ?? l).audioTracks : t === "text" ? (u ?? l).textTracks : (u ?? l).qualities, i = n !== void 0 && (n === null ? h[e] === void 0 || h[e] === null : !!r?.some((e) => e.id === n && e.available !== !1)), o = a.source && h[e] !== null ? i : n === h[e];
|
|
3042
|
+
if (n !== void 0 && !i || c[e] !== void 0 && f[t] === "host" && (!i || !o)) throw Z("host", t, "The host did not confirm the requested selection.", !0);
|
|
3043
|
+
}
|
|
3044
|
+
if (u) {
|
|
3045
|
+
let e = C, t = b;
|
|
3046
|
+
x = {
|
|
3047
|
+
audioId: null,
|
|
3048
|
+
textId: null,
|
|
3049
|
+
qualityId: null
|
|
3050
|
+
}, await oe(u, o), Y(s), f = ee(), !p && c.positionSeconds === void 0 && t !== null && Cn(H(), t) && (c.positionSeconds = t);
|
|
3051
|
+
for (let t of [
|
|
3052
|
+
"audio",
|
|
3053
|
+
"text",
|
|
3054
|
+
"quality"
|
|
3055
|
+
]) {
|
|
3056
|
+
if (f[t] !== "transport" && !(t === "text" && F.owns(e.selection.textId))) continue;
|
|
3057
|
+
let n = t === "audio" ? "audioId" : t === "text" ? "textId" : "qualityId", r = c[n] === void 0 ? e.selection[n] : c[n];
|
|
3058
|
+
if (r == null || r === "auto") continue;
|
|
3059
|
+
let i = t === "audio" ? "audioTracks" : t === "text" ? "textTracks" : "qualities", a = e[i].find((e) => e.id === r), o = a && C[i].find((e) => e.available !== !1 && e.language === a.language && e.label === a.label && e.channels === a.channels && e.description === a.description && !!e.forced == !!a.forced && !!e.sdh == !!a.sdh);
|
|
3060
|
+
if (o) c = {
|
|
3061
|
+
...c,
|
|
3062
|
+
[n]: o.id
|
|
3063
|
+
};
|
|
3064
|
+
else if (c[n] !== void 0) throw Z("unsupported", t, "This selection is unavailable in the replacement source.");
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
a.selection && (x = {
|
|
3068
|
+
...x,
|
|
3069
|
+
...a.selection
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
if (Y(s), !p && c.positionSeconds !== void 0 && Cn(H(), c.positionSeconds)) await se(c.positionSeconds, s);
|
|
3073
|
+
else if (c.positionSeconds !== void 0 && !g) throw Z("unsupported", "seek", "Position is outside the available seek ranges.");
|
|
3074
|
+
for (let e of [
|
|
3075
|
+
"audio",
|
|
3076
|
+
"text",
|
|
3077
|
+
"quality"
|
|
3078
|
+
]) {
|
|
3079
|
+
let n = e === "audio" ? c.audioId : e === "text" ? c.textId : c.qualityId;
|
|
3080
|
+
if (e === "text" && n !== void 0) {
|
|
3081
|
+
if (L.off(), F.owns(n)) {
|
|
3082
|
+
a.selectSubtitlesTrack(null), d?.disableText?.(), await F.select(n, s), F.state.renderer === "native" && a.selectSubtitlesTrack(n);
|
|
3083
|
+
continue;
|
|
3084
|
+
}
|
|
3085
|
+
F.off();
|
|
3086
|
+
}
|
|
3087
|
+
n !== void 0 && f[e] === "transport" && (await re(() => {
|
|
3088
|
+
let r = a.state;
|
|
3089
|
+
return e === "audio" ? d?.confirmedAudioId === void 0 ? r.audioTrackList.some((e) => e.id === n && e.enabled) : d.confirmedAudioId === n : e === "text" ? n === null ? !r.subtitlesShowing : !t.seeking && r.textTrackList.some((e) => e.id === n && e.mode === "showing") && (d?.textReady?.(n) ?? !0) : n === "auto" ? !r.videoRenditionList.some((e) => e.selected) : r.activeVideoRendition?.id === n;
|
|
3090
|
+
}, s, () => {
|
|
3091
|
+
e === "audio" ? a.selectAudioTrack(n) : e === "text" ? (a.selectSubtitlesTrack(n), n === null && d?.disableText?.()) : a.selectVideoRendition(n);
|
|
3092
|
+
}), e === "text" && n !== null && d?.refreshText?.(n));
|
|
3093
|
+
}
|
|
3094
|
+
Y(s), U(), await ce(s), p && W(!0);
|
|
3095
|
+
} catch (t) {
|
|
3096
|
+
throw s.aborted ? t : G(t, e.type);
|
|
3097
|
+
}
|
|
3098
|
+
}, (e) => {
|
|
3099
|
+
(e || v?.type !== "source") && (v = e, U());
|
|
3100
|
+
}, () => ++c);
|
|
3101
|
+
function q(e) {
|
|
3102
|
+
if (K(), m && v?.type === "source" || !l || h) return Promise.reject(Z("invalid-command", e.type, "Wait for a ready source before issuing this command."));
|
|
3103
|
+
if (e.type === "seek") {
|
|
3104
|
+
if (!Number.isFinite(e.seconds) || e.seconds < 0 || C.durationSeconds !== null && e.seconds > C.durationSeconds) return Promise.reject(Z("invalid-command", "seek", "Seek position must be within the absolute timeline."));
|
|
3105
|
+
if (C.capabilities.seek === "none") return Promise.reject(Z("unsupported", "seek", C.capabilities.reasons.seek));
|
|
3106
|
+
} else {
|
|
3107
|
+
let t = e.type, n = t === "audio" ? C.audioTracks : t === "text" ? C.textTracks : C.qualities;
|
|
3108
|
+
if (C.capabilities[t] === "none" || (t !== "text" || e.id !== null) && !(t === "quality" && e.id === "auto" && C.capabilities.autoQuality) && !n.some((t) => t.id === e.id && t.available !== !1)) return Promise.reject(Z("unsupported", t, "This selection is unavailable for the current source revision."));
|
|
3109
|
+
}
|
|
3110
|
+
return le.enqueue(e);
|
|
3111
|
+
}
|
|
3112
|
+
let ue = a.subscribe(U);
|
|
3113
|
+
U();
|
|
3114
|
+
let de = {
|
|
3115
|
+
getSnapshot: () => C,
|
|
3116
|
+
subscribe(e) {
|
|
3117
|
+
return K(), o.add(e), () => {
|
|
3118
|
+
o.delete(e);
|
|
3119
|
+
};
|
|
3120
|
+
},
|
|
3121
|
+
async setSource(e, n = {}) {
|
|
3122
|
+
K(), await B, K();
|
|
3123
|
+
let r;
|
|
3124
|
+
try {
|
|
3125
|
+
r = xn(e, t.ownerDocument.baseURI), Dn(n.trackPreferences);
|
|
3126
|
+
} catch (e) {
|
|
3127
|
+
throw G(e, "source", !l);
|
|
3128
|
+
}
|
|
3129
|
+
if (n.positionSeconds !== void 0 && (!Number.isFinite(n.positionSeconds) || n.positionSeconds < 0)) throw Z("invalid-command", "source", "Initial position must be a finite nonnegative absolute time.");
|
|
3130
|
+
W(!0);
|
|
3131
|
+
let i = ae(), a = structuredClone(n.trackPreferences ?? j);
|
|
3132
|
+
D = null, u.abort(J()), ++I, le.clear(), ie(), u = new AbortController();
|
|
3133
|
+
let o = u.signal;
|
|
3134
|
+
_ = n.intent ?? "paused";
|
|
3135
|
+
let s = ++c;
|
|
3136
|
+
v = {
|
|
3137
|
+
type: "source",
|
|
3138
|
+
commandId: s
|
|
3139
|
+
}, x = {
|
|
3140
|
+
audioId: null,
|
|
3141
|
+
textId: null,
|
|
3142
|
+
qualityId: null
|
|
3143
|
+
}, y = null, l = r, b = null, m = !0, h = !1, S = performance.now(), U();
|
|
3144
|
+
try {
|
|
3145
|
+
if (await oe(r, o, i, !1), a) {
|
|
3146
|
+
let e = a.audioLanguages?.length ? En(C.audioTracks, a.audioLanguages) : void 0;
|
|
3147
|
+
e && C.capabilities.audio !== "none" && e.id !== C.selection.audioId && await q({
|
|
3148
|
+
type: "audio",
|
|
3149
|
+
id: e.id
|
|
3150
|
+
}), Y(o);
|
|
3151
|
+
let t = a.text && En(C.textTracks, a.text.languages, a.text);
|
|
3152
|
+
t && C.capabilities.text !== "none" && await q({
|
|
3153
|
+
type: "text",
|
|
3154
|
+
id: t.id
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
if (n.positionSeconds !== void 0) {
|
|
3158
|
+
let e = C.durationSeconds, r = e === null ? n.positionSeconds : Math.min(n.positionSeconds, e), i = $(l);
|
|
3159
|
+
(i === null || Math.abs(t.currentTime + i - r) >= .001) && (l?.capabilities?.seek !== "host" && await re(() => Cn(H(), r), o), Y(o), await q({
|
|
3160
|
+
type: "seek",
|
|
3161
|
+
seconds: r
|
|
3162
|
+
}));
|
|
3163
|
+
}
|
|
3164
|
+
Y(o), await ce(o);
|
|
3165
|
+
} catch (e) {
|
|
3166
|
+
if (!o.aborted) {
|
|
3167
|
+
let t = m || h;
|
|
3168
|
+
throw m = !1, G(e, "source", t);
|
|
3169
|
+
}
|
|
3170
|
+
throw e;
|
|
3171
|
+
} finally {
|
|
3172
|
+
!o.aborted && v?.commandId === s && (v = null, U());
|
|
3173
|
+
}
|
|
3174
|
+
},
|
|
3175
|
+
async play() {
|
|
3176
|
+
if (K(), !l || h) throw Z("invalid-command", "play", "Choose a ready source before playing.");
|
|
3177
|
+
_ = "playing", y = null, U();
|
|
3178
|
+
let e = u.signal;
|
|
3179
|
+
m && await re(() => !m && t.readyState >= 2, e), await ce(e);
|
|
3180
|
+
},
|
|
3181
|
+
async pause() {
|
|
3182
|
+
K(), _ = "paused", d && a.pause(), te(), U(), W(!0);
|
|
3183
|
+
},
|
|
3184
|
+
seek: (e) => q({
|
|
3185
|
+
type: "seek",
|
|
3186
|
+
seconds: e
|
|
3187
|
+
}),
|
|
3188
|
+
async selectAudio(e) {
|
|
3189
|
+
let t = P, n = u.signal;
|
|
3190
|
+
if (await q({
|
|
3191
|
+
type: "audio",
|
|
3192
|
+
id: e
|
|
3193
|
+
}), Y(n), t !== P) throw J();
|
|
3194
|
+
let r = C.audioTracks.find((t) => t.id === e)?.language;
|
|
3195
|
+
r && (j = {
|
|
3196
|
+
...j,
|
|
3197
|
+
audioLanguages: [r]
|
|
3198
|
+
}), z.schedule();
|
|
3199
|
+
},
|
|
3200
|
+
async selectText(e) {
|
|
3201
|
+
if (K(), L.off(), e === null && C.capabilities.text === "none") return;
|
|
3202
|
+
let t = P, n = u.signal;
|
|
3203
|
+
if (await q({
|
|
3204
|
+
type: "text",
|
|
3205
|
+
id: e
|
|
3206
|
+
}), Y(n), t !== P) throw J();
|
|
3207
|
+
let r = C.textTracks.find((t) => t.id === e);
|
|
3208
|
+
(e === null || r?.language) && (j = {
|
|
3209
|
+
...j,
|
|
3210
|
+
text: e === null ? null : {
|
|
3211
|
+
languages: [r.language],
|
|
3212
|
+
forced: !!r.forced,
|
|
3213
|
+
sdh: !!r.sdh
|
|
3214
|
+
}
|
|
3215
|
+
}, z.schedule());
|
|
3216
|
+
},
|
|
3217
|
+
async loadSubtitles(e) {
|
|
3218
|
+
if (K(), !l || m || h) throw Z("invalid-command", "text", "Choose a ready source before loading subtitles.");
|
|
3219
|
+
let t = ++I;
|
|
3220
|
+
L.off();
|
|
3221
|
+
let n = u.signal;
|
|
3222
|
+
try {
|
|
3223
|
+
if (await F.loadFile(e, n, () => t === I), Y(n), t !== I) throw J();
|
|
3224
|
+
await q({
|
|
3225
|
+
type: "text",
|
|
3226
|
+
id: pn
|
|
3227
|
+
});
|
|
3228
|
+
} catch (e) {
|
|
3229
|
+
throw !n.aborted && t === I ? G(e, "text") : e;
|
|
3230
|
+
}
|
|
3231
|
+
},
|
|
3232
|
+
async removeLocalSubtitles() {
|
|
3233
|
+
K(), ++I, F.localActive && await q({
|
|
3234
|
+
type: "text",
|
|
3235
|
+
id: null
|
|
3236
|
+
}), F.removeLocal(), U();
|
|
3237
|
+
},
|
|
3238
|
+
async setCaptionStyle(e) {
|
|
3239
|
+
K(), F.setStyle(e), U(), z.schedule();
|
|
3240
|
+
},
|
|
3241
|
+
async setCaptionDelay(e) {
|
|
3242
|
+
K(), await F.setDelay(e), U(), z.schedule();
|
|
3243
|
+
},
|
|
3244
|
+
async setAutoCaptions(e) {
|
|
3245
|
+
if (K(), typeof e != "boolean") throw TypeError("Expected an automatic subtitle toggle.");
|
|
3246
|
+
await L.setEnabled(e);
|
|
3247
|
+
},
|
|
3248
|
+
selectQuality: (e) => q({
|
|
3249
|
+
type: "quality",
|
|
3250
|
+
id: e
|
|
3251
|
+
}),
|
|
3252
|
+
async setVolume(e) {
|
|
3253
|
+
if (K(), !C.capabilities.volume || !Number.isFinite(e) || e < 0 || e > 1) throw Z("invalid-command", "media", "Volume must be supported and between 0 and 1.");
|
|
3254
|
+
await re(() => Math.abs(t.volume - e) < .001, u.signal, () => a.setVolume(e)), U(), z.schedule();
|
|
3255
|
+
},
|
|
3256
|
+
async setMuted(e) {
|
|
3257
|
+
if (K(), !C.capabilities.muted) throw Z("unsupported", "media", "Muting is unavailable.");
|
|
3258
|
+
await re(() => t.muted === e, u.signal, () => a.setMuted(e)), U(), z.schedule();
|
|
3259
|
+
},
|
|
3260
|
+
async setPlaybackRate(e) {
|
|
3261
|
+
if (K(), !C.capabilities.playbackRates.includes(e)) throw Z("unsupported", "media", "This playback rate is unavailable.");
|
|
3262
|
+
await re(() => a.state.playbackRate === e, u.signal, () => a.setPlaybackRate(e)), U(), M = t.playbackRate, z.schedule();
|
|
3263
|
+
},
|
|
3264
|
+
async setPreservesPitch(e) {
|
|
3265
|
+
if (K(), typeof e != "boolean" || !C.capabilities.preservesPitch) throw Error("Pitch preservation is unavailable.");
|
|
3266
|
+
t.preservesPitch = e, U(), z.schedule();
|
|
3267
|
+
},
|
|
3268
|
+
enterFullscreen: () => R.enterFullscreen(),
|
|
3269
|
+
exitFullscreen: () => R.exitFullscreen(),
|
|
3270
|
+
requestPictureInPicture: () => R.requestPictureInPicture(),
|
|
3271
|
+
exitPictureInPicture: () => R.exitPictureInPicture(),
|
|
3272
|
+
setPlatformOptions(e) {
|
|
3273
|
+
K(), R.setOptions(e);
|
|
3274
|
+
},
|
|
3275
|
+
async setPreferences(e) {
|
|
3276
|
+
K(), L.off();
|
|
3277
|
+
let t = ++P;
|
|
3278
|
+
le.clear();
|
|
3279
|
+
let n = z.setAdapter(e);
|
|
3280
|
+
if (B = n.catch(() => {}), await n, t !== P || s) throw J();
|
|
3281
|
+
if (l && !m && !h) {
|
|
3282
|
+
let e = u.signal, n = En(C.audioTracks, j?.audioLanguages);
|
|
3283
|
+
if (n && C.capabilities.audio !== "none" && await q({
|
|
3284
|
+
type: "audio",
|
|
3285
|
+
id: n.id
|
|
3286
|
+
}), Y(e), t !== P || s) throw J();
|
|
3287
|
+
let r = j?.text ? En(C.textTracks, j.text.languages, j.text) : void 0;
|
|
3288
|
+
C.capabilities.text !== "none" && await q({
|
|
3289
|
+
type: "text",
|
|
3290
|
+
id: r?.id ?? null
|
|
3291
|
+
});
|
|
3292
|
+
}
|
|
3293
|
+
},
|
|
3294
|
+
setNavigation(e) {
|
|
3295
|
+
K(), T = { ...e }, U();
|
|
3296
|
+
},
|
|
3297
|
+
async navigate(e) {
|
|
3298
|
+
K();
|
|
3299
|
+
let t = T[e];
|
|
3300
|
+
if (!t || E) throw Error("Episode navigation is unavailable or already pending.");
|
|
3301
|
+
let n = ++O, r = u.signal;
|
|
3302
|
+
E = e, D = null, U();
|
|
3303
|
+
try {
|
|
3304
|
+
await t();
|
|
3305
|
+
} catch {
|
|
3306
|
+
throw s || r.aborted || n !== O ? J() : (!s && n === O && (D = "The episode could not be opened. Try again."), Error("The episode could not be opened. Try again."));
|
|
3307
|
+
} finally {
|
|
3308
|
+
!s && n === O && (E = null, U());
|
|
3309
|
+
}
|
|
3310
|
+
},
|
|
3311
|
+
setThumbnailResolver(e) {
|
|
3312
|
+
K(), k !== e && (A.abort(), A = new AbortController(), k = e);
|
|
3313
|
+
},
|
|
3314
|
+
async getThumbnail(e, n) {
|
|
3315
|
+
if (K(), !Number.isFinite(e) || e < 0 || C.durationSeconds !== null && e > C.durationSeconds) throw RangeError("Invalid thumbnail time");
|
|
3316
|
+
if (!k || !C.source) return null;
|
|
3317
|
+
let r = k, i = C.source, a = AbortSignal.any([
|
|
3318
|
+
n,
|
|
3319
|
+
u.signal,
|
|
3320
|
+
A.signal
|
|
3321
|
+
]);
|
|
3322
|
+
Y(a);
|
|
3323
|
+
let o = await X(Promise.resolve().then(() => r({
|
|
3324
|
+
source: i,
|
|
3325
|
+
seconds: e,
|
|
3326
|
+
signal: a
|
|
3327
|
+
})), a);
|
|
3328
|
+
if (Y(a), !o) return null;
|
|
3329
|
+
let s = new URL(o.src, t.ownerDocument.baseURI);
|
|
3330
|
+
if (![
|
|
3331
|
+
"http:",
|
|
3332
|
+
"https:",
|
|
3333
|
+
"blob:"
|
|
3334
|
+
].includes(s.protocol) || s.username || s.password) throw Error("Invalid thumbnail URL");
|
|
3335
|
+
return Object.freeze({ src: s.href });
|
|
3336
|
+
},
|
|
3337
|
+
dispose() {
|
|
3338
|
+
s || (W(!0), s = !0, z.dispose(), A.abort(), R.dispose(), L.dispose(), ++I, u.abort(J()), le.clear(), ue(), o.clear(), F.dispose(), ie(), a.destroy(), C = bn({
|
|
3339
|
+
...C,
|
|
3340
|
+
pending: null,
|
|
3341
|
+
autoCaptions: L.state
|
|
3342
|
+
}));
|
|
3343
|
+
}
|
|
3344
|
+
};
|
|
3345
|
+
return e.preferences && (B = de.setPreferences(e.preferences).catch(() => {})), de;
|
|
3346
|
+
}
|
|
3347
|
+
// src/core/index.ts
|
|
3348
|
+
var Rn = "0.1.1";
|
|
3349
|
+
function zn(e) {
|
|
3350
|
+
return Ln(e);
|
|
3351
|
+
}
|
|
3352
|
+
export { y as $, be as A, te as B, ot as C, Ie as D, Re as E, q as F, U as G, ae as H, se as I, z as J, ee as K, ce as L, ue as M, le as N, we as O, oe as P, F as Q, pe as R, st as S, Xe as T, ne as U, ie as V, K as W, L as X, O as Y, S as Z, vt as _, Z as a, r as at, mt as b, an as c, n as ct, Vt as d, m as et, Rt as f, Ot as g, Dt as h, Q as i, d as it, me as j, Ce as k, Qt as l, a as lt, Pt as m, Rn as n, f as nt, Y as o, i as ot, It as p, V as q, Ln as r, l as rt, X as s, u as st, zn as t, p as tt, Wt as u, gt as v, at as w, lt as x, ht as y, G as z };
|