@openrails/contentkit-ui 0.90.3 → 0.92.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/README.md +6 -4
- package/dist/client/client.d.ts +1 -1
- package/dist/client/client.js.map +1 -1
- package/dist/client/generated/routes.d.ts +7 -7
- package/dist/client/generated/routes.js +6 -6
- package/dist/client/generated/routes.js.map +1 -1
- package/dist/client/http.d.ts +13 -8
- package/dist/client/http.js +16 -4
- package/dist/client/http.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/media/client.d.ts +3 -3
- package/dist/client/media/client.js +2 -2
- package/dist/client/media/client.js.map +1 -1
- package/dist/components/hover-preview.js +1 -1
- package/dist/components/hover-preview.js.map +1 -1
- package/dist/components/media-gallery.d.ts +2 -2
- package/dist/components/media-gallery.js +4 -4
- package/dist/components/media-gallery.js.map +1 -1
- package/dist/components/video-mini-player.js +1 -1
- package/dist/components/video-mini-player.js.map +1 -1
- package/dist/components/video-player.d.ts +3 -3
- package/dist/components/video-player.js +3 -3
- package/dist/components/video-player.js.map +1 -1
- package/dist/react/gallery.d.ts +6 -3
- package/dist/react/gallery.js +303 -228
- package/dist/react/gallery.js.map +1 -1
- package/dist/react/player.d.ts +4 -6
- package/dist/react/player.js +54 -61
- package/dist/react/player.js.map +1 -1
- package/package.json +2 -2
package/dist/react/gallery.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { abrHlsConfig as e, capRung as t, classifyHlsError as n, classifyMediaError as r, expiryDelay as i, hlsConfig as a, initialEstimate as o, otherCodecLevels as s, refreshable as c, startRung as ee, statusKind as l } from "../client/playback.js";
|
|
2
|
-
import { PLAYER_TRACKS_KEY as u, PLAYER_VOLUME_KEY as d, pickTrack as f, readTrackPrefs as p, readVolume as
|
|
3
|
-
import { useCallback as
|
|
2
|
+
import { PLAYER_TRACKS_KEY as u, PLAYER_VOLUME_KEY as d, pickTrack as f, readTrackPrefs as p, readVolume as te, writeTrackPrefs as m } from "../client/player.js";
|
|
3
|
+
import { useCallback as h, useEffect as g, useRef as _, useState as v } from "react";
|
|
4
4
|
//#region src/react/gallery.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
5
|
+
var y = "ckui.media-gallery.view";
|
|
6
|
+
function b(e) {
|
|
7
7
|
if (e) try {
|
|
8
8
|
let t = globalThis.localStorage?.getItem(e);
|
|
9
9
|
return t === "grid" || t === "carousel" ? t : void 0;
|
|
@@ -11,8 +11,8 @@ function x(e) {
|
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
let [i, a] =
|
|
14
|
+
function x({ view: e, defaultView: t = "carousel", onViewChange: n, storageKey: r = y } = {}) {
|
|
15
|
+
let [i, a] = v(() => b(r) ?? t), o = h((e) => {
|
|
16
16
|
if (a(e), r) try {
|
|
17
17
|
globalThis.localStorage?.setItem(r, e);
|
|
18
18
|
} catch {}
|
|
@@ -20,15 +20,15 @@ function S({ view: e, defaultView: t = "carousel", onViewChange: n, storageKey:
|
|
|
20
20
|
}, [r, n]);
|
|
21
21
|
return [e ?? i, o];
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function S(e) {
|
|
24
24
|
let t = e.target;
|
|
25
25
|
return t.closest?.("[data-ckui-noswipe]") ? !0 : !(t instanceof HTMLVideoElement) || !t.controls ? !1 : e.pointerType === "mouse" || e.clientY > t.getBoundingClientRect().bottom - 56;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
let [i, a] =
|
|
27
|
+
function C({ count: e, index: t, defaultIndex: n = 0, onIndexChange: r }) {
|
|
28
|
+
let [i, a] = v(n), o = Math.min(Math.max(0, t ?? i), Math.max(0, e - 1)), s = h((t) => {
|
|
29
29
|
let n = Math.min(Math.max(0, t), Math.max(0, e - 1));
|
|
30
30
|
a(n), r?.(n);
|
|
31
|
-
}, [e, r]), [c, ee] =
|
|
31
|
+
}, [e, r]), [c, ee] = v(0), [l, u] = v(!1), d = _(null), f = _(!1), p = (e, t) => {
|
|
32
32
|
let n = d.current;
|
|
33
33
|
if (!n || n.id !== e.pointerId || (d.current = null, n.axis !== "x")) return;
|
|
34
34
|
let r = e.clientX - n.x, i = Math.abs(r) / Math.max(1, e.timeStamp - n.t) > .5;
|
|
@@ -43,7 +43,7 @@ function w({ count: e, index: t, defaultIndex: n = 0, onIndexChange: r }) {
|
|
|
43
43
|
dragging: l,
|
|
44
44
|
swipe: {
|
|
45
45
|
onPointerDown: (t) => {
|
|
46
|
-
f.current = !1, !(e < 2 || t.pointerType === "mouse" && t.button !== 0 ||
|
|
46
|
+
f.current = !1, !(e < 2 || t.pointerType === "mouse" && t.button !== 0 || S(t)) && (d.current = {
|
|
47
47
|
id: t.pointerId,
|
|
48
48
|
x: t.clientX,
|
|
49
49
|
y: t.clientY,
|
|
@@ -83,42 +83,116 @@ function w({ count: e, index: t, defaultIndex: n = 0, onIndexChange: r }) {
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
var
|
|
87
|
-
function
|
|
88
|
-
|
|
86
|
+
var w = "ckui.player.quality", T = /* @__PURE__ */ new Map();
|
|
87
|
+
function E(e, t) {
|
|
88
|
+
g(() => {
|
|
89
89
|
let n = i(e);
|
|
90
90
|
if (n === null || !e || !t) return;
|
|
91
|
-
let r =
|
|
91
|
+
let r = T.get(t);
|
|
92
92
|
if (r?.expires !== e) {
|
|
93
93
|
r && clearTimeout(r.timer);
|
|
94
94
|
let i = {
|
|
95
95
|
expires: e,
|
|
96
96
|
subs: 0,
|
|
97
97
|
timer: setTimeout(() => {
|
|
98
|
-
|
|
98
|
+
T.get(t) === i && T.delete(t), Promise.resolve().then(t).catch(() => {});
|
|
99
99
|
}, n)
|
|
100
100
|
};
|
|
101
|
-
|
|
101
|
+
T.set(t, r = i);
|
|
102
102
|
}
|
|
103
103
|
let a = r;
|
|
104
104
|
return a.subs++, () => {
|
|
105
|
-
--a.subs > 0 ||
|
|
105
|
+
--a.subs > 0 || T.get(t) !== a || (clearTimeout(a.timer), T.delete(t));
|
|
106
106
|
};
|
|
107
107
|
}, [e, t]);
|
|
108
108
|
}
|
|
109
|
-
var
|
|
110
|
-
function
|
|
111
|
-
|
|
109
|
+
var ne = "application/vnd.apple.mpegurl", D = !1;
|
|
110
|
+
function re() {
|
|
111
|
+
D || typeof console > "u" || (D = !0, console.warn(`contentkit: video requests failed with no response (status 0). If media is served from another origin, media-gateway must allow this page: set MEDIA_GATEWAY_CORS_ORIGINS to include ${globalThis.location?.origin ?? "the app origin"}.`));
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
r.readyState === 0 && r.open("GET", e, !0), r.onload = () => n(r.status), r.onerror = r.ontimeout = () => n(0), r.timeout = 8e3, r.send();
|
|
118
|
-
}, () => n(0));
|
|
119
|
-
});
|
|
113
|
+
var ie = (e, t, n) => e ? e.playlist(t, n) : fetch(t, { signal: n ?? null });
|
|
114
|
+
function ae(e, t) {
|
|
115
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), 8e3);
|
|
116
|
+
return ie(t, e, n.signal).then((e) => e.status, () => 0).finally(() => clearTimeout(r));
|
|
120
117
|
}
|
|
121
|
-
function
|
|
118
|
+
function oe(e) {
|
|
119
|
+
return class {
|
|
120
|
+
context = null;
|
|
121
|
+
stats = {
|
|
122
|
+
aborted: !1,
|
|
123
|
+
loaded: 0,
|
|
124
|
+
retry: 0,
|
|
125
|
+
total: 0,
|
|
126
|
+
chunkCount: 0,
|
|
127
|
+
bwEstimate: 0,
|
|
128
|
+
loading: {
|
|
129
|
+
start: 0,
|
|
130
|
+
first: 0,
|
|
131
|
+
end: 0
|
|
132
|
+
},
|
|
133
|
+
parsing: {
|
|
134
|
+
start: 0,
|
|
135
|
+
end: 0
|
|
136
|
+
},
|
|
137
|
+
buffering: {
|
|
138
|
+
start: 0,
|
|
139
|
+
first: 0,
|
|
140
|
+
end: 0
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
ctrl = null;
|
|
144
|
+
timer;
|
|
145
|
+
headers = null;
|
|
146
|
+
callbacks = null;
|
|
147
|
+
load(t, n, r) {
|
|
148
|
+
let i = new AbortController();
|
|
149
|
+
Object.assign(this, {
|
|
150
|
+
context: t,
|
|
151
|
+
callbacks: r,
|
|
152
|
+
ctrl: i
|
|
153
|
+
});
|
|
154
|
+
let a = this.stats;
|
|
155
|
+
a.loading.start = performance.now();
|
|
156
|
+
let o = n.loadPolicy.maxLoadTimeMs;
|
|
157
|
+
o > 0 && Number.isFinite(o) && (this.timer = setTimeout(() => {
|
|
158
|
+
i.abort(), this.ctrl === i && r.onTimeout(a, t, null);
|
|
159
|
+
}, o)), e(t.url, i.signal).then(async (e) => {
|
|
160
|
+
a.loading.first = performance.now();
|
|
161
|
+
let n = await e.text();
|
|
162
|
+
if (!(this.ctrl !== i || i.signal.aborted)) {
|
|
163
|
+
if (clearTimeout(this.timer), this.headers = e.headers, a.loaded = a.total = n.length, a.loading.end = performance.now(), !e.ok) return r.onError({
|
|
164
|
+
code: e.status,
|
|
165
|
+
text: e.statusText
|
|
166
|
+
}, t, e, a);
|
|
167
|
+
r.onSuccess({
|
|
168
|
+
url: e.url || t.url,
|
|
169
|
+
data: n,
|
|
170
|
+
code: e.status
|
|
171
|
+
}, a, t, e);
|
|
172
|
+
}
|
|
173
|
+
}, (e) => {
|
|
174
|
+
this.ctrl !== i || i.signal.aborted || (clearTimeout(this.timer), r.onError({
|
|
175
|
+
code: 0,
|
|
176
|
+
text: String(e)
|
|
177
|
+
}, t, null, a));
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
abort() {
|
|
181
|
+
clearTimeout(this.timer), this.ctrl?.abort(), this.stats.aborted = !0, this.context && this.callbacks?.onAbort?.(this.stats, this.context, null);
|
|
182
|
+
}
|
|
183
|
+
destroy() {
|
|
184
|
+
clearTimeout(this.timer), this.ctrl?.abort(), this.ctrl = this.callbacks = this.context = null;
|
|
185
|
+
}
|
|
186
|
+
getResponseHeader(e) {
|
|
187
|
+
return this.headers?.get(e) ?? null;
|
|
188
|
+
}
|
|
189
|
+
getCacheAge() {
|
|
190
|
+
let e = this.headers?.get("age");
|
|
191
|
+
return e ? Number(e) : null;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function se(e) {
|
|
122
196
|
if (!e) return null;
|
|
123
197
|
try {
|
|
124
198
|
let t = globalThis.localStorage?.getItem(e);
|
|
@@ -127,12 +201,12 @@ function re(e) {
|
|
|
127
201
|
return null;
|
|
128
202
|
}
|
|
129
203
|
}
|
|
130
|
-
function
|
|
204
|
+
function ce(e, t) {
|
|
131
205
|
if (e) try {
|
|
132
206
|
globalThis.localStorage?.setItem(e, String(t));
|
|
133
207
|
} catch {}
|
|
134
208
|
}
|
|
135
|
-
var
|
|
209
|
+
var le = (e) => Array.from(e.textTracks).filter((e) => e.kind === "subtitles" || e.kind === "captions"), O = (e) => e.map((e, t) => {
|
|
136
210
|
let n = e.lang || e.language || void 0;
|
|
137
211
|
return {
|
|
138
212
|
index: t,
|
|
@@ -140,15 +214,15 @@ var ae = (e) => Array.from(e.textTracks).filter((e) => e.kind === "subtitles" ||
|
|
|
140
214
|
lang: n,
|
|
141
215
|
...e.forced ? { forced: !0 } : {}
|
|
142
216
|
};
|
|
143
|
-
}),
|
|
144
|
-
function
|
|
217
|
+
}), ue = 0;
|
|
218
|
+
function de() {
|
|
145
219
|
let e = globalThis.navigator?.connection;
|
|
146
220
|
return e ? {
|
|
147
221
|
downlink: e.downlink,
|
|
148
222
|
saveData: e.saveData
|
|
149
223
|
} : null;
|
|
150
224
|
}
|
|
151
|
-
function
|
|
225
|
+
function fe(e, n) {
|
|
152
226
|
if (e) return class extends e {
|
|
153
227
|
getMaxLevel(e) {
|
|
154
228
|
let r = this.hls?.levels ?? [];
|
|
@@ -156,206 +230,207 @@ function ce(e, n) {
|
|
|
156
230
|
}
|
|
157
231
|
};
|
|
158
232
|
}
|
|
159
|
-
function
|
|
160
|
-
let [
|
|
161
|
-
|
|
162
|
-
let Y =
|
|
163
|
-
|
|
164
|
-
refresh:
|
|
165
|
-
abr:
|
|
166
|
-
qualityKey:
|
|
167
|
-
startAt:
|
|
168
|
-
audioLanguage:
|
|
169
|
-
subtitleLanguage:
|
|
170
|
-
volumeKey:
|
|
171
|
-
trackKey:
|
|
233
|
+
function pe({ src: i, loader: y, refresh: b, expires: x, active: S = !0, stallTimeout: C = 1e4, abr: T, qualityKey: D = w, startAt: pe, autoPlay: me, audioLanguage: he, subtitleLanguage: ge, volumeKey: _e = d, trackKey: ve = u }) {
|
|
234
|
+
let [k, ye] = v(null), [A, j] = v("idle"), [M, N] = v(), [P, be] = v(!1), [xe, F] = v(!1), [Se, I] = v(0), [Ce, L] = v(!1), R = _(null), z = _(() => {}), B = _(!1), V = _(null), H = _(!1), U = _(0), W = _(0), [we, Te] = v([]), [Ee, De] = v(-1), [Oe, ke] = v(-1), G = _(() => {}), [Ae, je] = v([]), [Me, Ne] = v(-1), [Pe, Fe] = v([]), [Ie, K] = v(-1), q = _(() => {}), J = _(() => {}), Le = _(P);
|
|
235
|
+
Le.current = P;
|
|
236
|
+
let Y = _(() => {}), X = _({
|
|
237
|
+
loader: y,
|
|
238
|
+
refresh: b,
|
|
239
|
+
abr: T,
|
|
240
|
+
qualityKey: D,
|
|
241
|
+
startAt: pe,
|
|
242
|
+
audioLanguage: he,
|
|
243
|
+
subtitleLanguage: ge,
|
|
244
|
+
volumeKey: _e,
|
|
245
|
+
trackKey: ve
|
|
172
246
|
});
|
|
173
247
|
X.current = {
|
|
174
|
-
|
|
175
|
-
refresh:
|
|
176
|
-
abr:
|
|
177
|
-
qualityKey:
|
|
178
|
-
startAt:
|
|
179
|
-
audioLanguage:
|
|
180
|
-
subtitleLanguage:
|
|
181
|
-
volumeKey:
|
|
182
|
-
trackKey:
|
|
248
|
+
loader: y,
|
|
249
|
+
refresh: b,
|
|
250
|
+
abr: T,
|
|
251
|
+
qualityKey: D,
|
|
252
|
+
startAt: pe,
|
|
253
|
+
audioLanguage: he,
|
|
254
|
+
subtitleLanguage: ge,
|
|
255
|
+
volumeKey: _e,
|
|
256
|
+
trackKey: ve
|
|
183
257
|
};
|
|
184
|
-
let Z =
|
|
185
|
-
|
|
186
|
-
let
|
|
187
|
-
|
|
188
|
-
let e =
|
|
189
|
-
|
|
190
|
-
}, [
|
|
258
|
+
let Z = _(() => {});
|
|
259
|
+
E(x, b);
|
|
260
|
+
let Re = _(x);
|
|
261
|
+
g(() => {
|
|
262
|
+
let e = Re.current;
|
|
263
|
+
Re.current = x, x && e && x > e && Z.current();
|
|
264
|
+
}, [x]), g(() => {
|
|
191
265
|
U.current = X.current.startAt ?? 0;
|
|
192
|
-
}, [i]),
|
|
193
|
-
if (!
|
|
194
|
-
let u = !1, d = () => {},
|
|
195
|
-
|
|
196
|
-
let
|
|
266
|
+
}, [i]), g(() => {
|
|
267
|
+
if (!k || !i || !xe) return;
|
|
268
|
+
let u = !1, d = () => {}, te = 0, m = !1;
|
|
269
|
+
N(void 0), Te([]), De(-1), ke(-1), je([]), Ne(-1), Fe([]), K(-1), G.current = () => {}, q.current = () => {}, J.current = () => {}, Y.current = () => {}, Z.current = () => {};
|
|
270
|
+
let h = () => {
|
|
197
271
|
if (!u) {
|
|
198
272
|
if (R.current !== null) return z.current();
|
|
199
|
-
U.current =
|
|
273
|
+
U.current = k.currentTime || 0, u = !0, d(), I((e) => e + 1);
|
|
200
274
|
}
|
|
201
275
|
};
|
|
202
|
-
|
|
203
|
-
let
|
|
276
|
+
j(B.current ? "loading" : "idle");
|
|
277
|
+
let g = (e) => {
|
|
204
278
|
if (u) return;
|
|
205
279
|
let t = X.current.refresh;
|
|
206
280
|
if (c(e) && t && !H.current) {
|
|
207
|
-
H.current = !0, U.current =
|
|
281
|
+
H.current = !0, U.current = k.currentTime || 0, R.current !== null && (R.current = U.current || R.current), u = !0, d(), j("loading"), Promise.resolve().then(t).catch(() => {}).finally(() => I((e) => e + 1));
|
|
208
282
|
return;
|
|
209
283
|
}
|
|
210
284
|
if (R.current !== null) return z.current();
|
|
211
|
-
e.kind === "network" &&
|
|
212
|
-
},
|
|
213
|
-
u || e?.name !== "NotAllowedError" || (B.current = !1,
|
|
214
|
-
}),
|
|
215
|
-
let t =
|
|
285
|
+
e.kind === "network" && re(), u = !0, d(), B.current = !1, N(e), j("error");
|
|
286
|
+
}, _ = () => m && g(r(k.error)), v = () => k.play().catch((e) => {
|
|
287
|
+
u || e?.name !== "NotAllowedError" || (B.current = !1, j((e) => e === "error" ? e : Le.current ? "paused" : "idle"));
|
|
288
|
+
}), y = () => p(X.current.trackKey), b = (e) => {
|
|
289
|
+
let t = y().subtitles;
|
|
216
290
|
return f(e.map((e) => ({ lang: e.lang || e.language })), t === "off" ? null : t ?? X.current.subtitleLanguage);
|
|
217
291
|
};
|
|
218
|
-
return
|
|
292
|
+
return k.addEventListener("error", _), import("hls.js").then(({ default: r }) => {
|
|
219
293
|
if (!u) {
|
|
220
294
|
if (r.isSupported()) {
|
|
221
|
-
let c = !1, l =
|
|
295
|
+
let c = !1, l = de(), p = l?.saveData ? {
|
|
222
296
|
...X.current.abr,
|
|
223
297
|
preferHighRes: !1
|
|
224
|
-
} : X.current.abr,
|
|
298
|
+
} : X.current.abr, m = o(p, l, ue), _ = new r({
|
|
225
299
|
...a,
|
|
226
|
-
...e(p,
|
|
227
|
-
capLevelController:
|
|
300
|
+
...e(p, m),
|
|
301
|
+
capLevelController: fe(r.DefaultConfig.capLevelController, p),
|
|
228
302
|
autoStartLoad: !1,
|
|
229
|
-
|
|
303
|
+
pLoader: oe((e, t) => ie(X.current.loader, e, t)),
|
|
304
|
+
xhrSetup: (e, t) => X.current.loader?.segment(e, t)
|
|
230
305
|
});
|
|
231
|
-
d = () =>
|
|
232
|
-
let
|
|
233
|
-
|
|
234
|
-
},
|
|
235
|
-
|
|
306
|
+
d = () => _.destroy(), _.subtitleDisplay = !1;
|
|
307
|
+
let x = () => {
|
|
308
|
+
je(O(_.audioTracks)), Ne(_.audioTrack);
|
|
309
|
+
}, S = () => {
|
|
310
|
+
Fe(O(_.subtitleTracks)), K(_.subtitleTrack);
|
|
236
311
|
};
|
|
237
|
-
|
|
238
|
-
let e = f(
|
|
239
|
-
e >= 0 && e !==
|
|
240
|
-
}),
|
|
241
|
-
let
|
|
242
|
-
R.current === null &&
|
|
312
|
+
_.on(r.Events.AUDIO_TRACKS_UPDATED, () => {
|
|
313
|
+
let e = f(_.audioTracks, y().audio ?? X.current.audioLanguage);
|
|
314
|
+
e >= 0 && e !== _.audioTrack && (_.audioTrack = e), x();
|
|
315
|
+
}), _.on(r.Events.AUDIO_TRACK_SWITCHED, x);
|
|
316
|
+
let C = () => {
|
|
317
|
+
R.current === null && _.subtitleTracks.length && (_.subtitleTrack = b(_.subtitleTracks));
|
|
243
318
|
};
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
u || (
|
|
319
|
+
_.on(r.Events.SUBTITLE_TRACKS_UPDATED, () => {
|
|
320
|
+
S(), queueMicrotask(() => {
|
|
321
|
+
u || (C(), S());
|
|
247
322
|
});
|
|
248
|
-
}),
|
|
249
|
-
|
|
323
|
+
}), _.on(r.Events.SUBTITLE_TRACK_SWITCH, S), q.current = (e) => {
|
|
324
|
+
_.audioTrack = e;
|
|
250
325
|
}, J.current = (e) => {
|
|
251
|
-
|
|
252
|
-
},
|
|
326
|
+
_.subtitleTrack = e, K(e);
|
|
327
|
+
}, _.on(r.Events.ERROR, (e, t) => {
|
|
253
328
|
let r = n(t);
|
|
254
|
-
(t.fatal || r.kind === "access" || r.kind === "not_found" || r.kind === "rate_limited" || r.kind === "network" && ++
|
|
329
|
+
(t.fatal || r.kind === "access" || r.kind === "not_found" || r.kind === "rate_limited" || r.kind === "network" && ++te >= 3) && g(r);
|
|
255
330
|
});
|
|
256
|
-
let
|
|
257
|
-
let e =
|
|
258
|
-
return ee(
|
|
259
|
-
},
|
|
260
|
-
|
|
331
|
+
let w = -1, T = () => {
|
|
332
|
+
let e = k.getBoundingClientRect(), n = globalThis.devicePixelRatio || 1, r = t(_.levels, e.width * n, e.height * n, p);
|
|
333
|
+
return ee(_.levels, _.bandwidthEstimate || m, r, l);
|
|
334
|
+
}, E = !1, ne = (e) => {
|
|
335
|
+
E = !0, _.currentLevel = e;
|
|
261
336
|
};
|
|
262
|
-
|
|
263
|
-
|
|
337
|
+
_.on(r.Events.BUFFER_FLUSHED, () => {
|
|
338
|
+
E && (E = !1, k.currentTime = k.currentTime);
|
|
264
339
|
}), G.current = (e) => {
|
|
265
|
-
|
|
340
|
+
w = e, De(e), c && (e >= 0 ? ne(e) : _.nextLevel = -1);
|
|
266
341
|
}, Y.current = () => {
|
|
267
|
-
|
|
268
|
-
},
|
|
269
|
-
|
|
342
|
+
C(), c && (ne(w), w < 0 && (_.nextAutoLevel = T()));
|
|
343
|
+
}, _.on(r.Events.LEVEL_SWITCHED, (e, t) => ke(t.level)), _.on(r.Events.FRAG_LOADED, () => {
|
|
344
|
+
te = 0, W.current = Date.now(), ue = _.bandwidthEstimate;
|
|
270
345
|
});
|
|
271
|
-
let
|
|
346
|
+
let D = () => _.levels.some((e) => /[?&]t=/.test(e.details?.fragments[0]?.url ?? ""));
|
|
272
347
|
Z.current = () => {
|
|
273
|
-
c &&
|
|
348
|
+
c && D() && h();
|
|
274
349
|
};
|
|
275
|
-
let
|
|
350
|
+
let re = !1;
|
|
276
351
|
V.current = () => {
|
|
277
|
-
if (
|
|
352
|
+
if (re) {
|
|
278
353
|
if (!c) {
|
|
279
354
|
c = !0;
|
|
280
355
|
let e = R.current;
|
|
281
|
-
e === null ? (
|
|
356
|
+
e === null ? (_.startLevel = w >= 0 ? w : T(), w >= 0 && (_.loadLevel = w), _.startLoad(U.current || -1)) : (_.startLevel = 0, _.startLoad(e)), U.current = 0;
|
|
282
357
|
}
|
|
283
|
-
|
|
358
|
+
v();
|
|
284
359
|
}
|
|
285
|
-
},
|
|
286
|
-
|
|
287
|
-
for (let e of s(
|
|
288
|
-
let e = p?.maxHeight ?? Infinity, t =
|
|
360
|
+
}, _.on(r.Events.MANIFEST_PARSED, () => {
|
|
361
|
+
re = !0;
|
|
362
|
+
for (let e of s(_.levels, _.firstLevel)) _.removeLevel(e);
|
|
363
|
+
let e = p?.maxHeight ?? Infinity, t = _.levels.map((e, t) => ({
|
|
289
364
|
index: t,
|
|
290
365
|
height: Math.min(e.width, e.height) || e.height,
|
|
291
366
|
width: e.width,
|
|
292
367
|
bitrate: e.bitrate
|
|
293
368
|
})).filter((t) => t.height > 0 && t.height <= e);
|
|
294
|
-
|
|
295
|
-
let n =
|
|
369
|
+
Te(t);
|
|
370
|
+
let n = se(X.current.qualityKey), r = typeof n == "number" ? t.find((e) => e.height === n) : void 0;
|
|
296
371
|
r && G.current(r.index), B.current && V.current?.();
|
|
297
|
-
}),
|
|
372
|
+
}), _.loadSource(i), _.attachMedia(k);
|
|
298
373
|
return;
|
|
299
374
|
}
|
|
300
|
-
if (!
|
|
375
|
+
if (!k.canPlayType(ne)) return g({
|
|
301
376
|
kind: "unsupported",
|
|
302
377
|
code: "no-hls"
|
|
303
378
|
});
|
|
304
|
-
|
|
379
|
+
ae(i, X.current.loader).then((e) => {
|
|
305
380
|
if (u) return;
|
|
306
|
-
if (e < 200 || e >= 400) return
|
|
381
|
+
if (e < 200 || e >= 400) return g({
|
|
307
382
|
kind: l(e),
|
|
308
383
|
code: `probe/${e}`,
|
|
309
384
|
status: e
|
|
310
385
|
});
|
|
311
|
-
|
|
312
|
-
let t =
|
|
386
|
+
m = !0, Z.current = h;
|
|
387
|
+
let t = k.audioTracks, n = () => {
|
|
313
388
|
let e = t ? Array.from(t) : [];
|
|
314
|
-
|
|
315
|
-
let n =
|
|
316
|
-
|
|
389
|
+
je(O(e)), Ne(e.findIndex((e) => e.enabled));
|
|
390
|
+
let n = le(k);
|
|
391
|
+
Fe(O(n)), K(n.findIndex((e) => e.mode !== "disabled"));
|
|
317
392
|
};
|
|
318
393
|
q.current = (e) => {
|
|
319
394
|
let r = t?.[e];
|
|
320
395
|
r && (r.enabled = !0), n();
|
|
321
396
|
};
|
|
322
397
|
let r = !1, a = (e) => {
|
|
323
|
-
|
|
398
|
+
le(k).forEach((t, n) => t.mode = n === e ? "hidden" : "disabled"), n();
|
|
324
399
|
};
|
|
325
400
|
J.current = (e) => {
|
|
326
401
|
r = !0, a(e);
|
|
327
402
|
};
|
|
328
403
|
let o = () => {
|
|
329
404
|
if (r || R.current !== null) return n();
|
|
330
|
-
a(
|
|
405
|
+
a(b(O(le(k))));
|
|
331
406
|
}, s = () => {
|
|
332
|
-
let e = t ? Array.from(t) : [], n = f(
|
|
407
|
+
let e = t ? Array.from(t) : [], n = f(O(e), y().audio ?? X.current.audioLanguage);
|
|
333
408
|
n >= 0 && !e[n].enabled && (e[n].enabled = !0), o();
|
|
334
409
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}, Y.current = o, V.current = () => void
|
|
410
|
+
k.addEventListener("loadedmetadata", s, { once: !0 }), k.textTracks.addEventListener?.("addtrack", o), t?.addEventListener("change", n), k.src = i, R.current === null ? U.current && (k.currentTime = U.current) : k.currentTime = R.current, U.current = 0, d = () => {
|
|
411
|
+
k.removeEventListener("loadedmetadata", s), k.textTracks.removeEventListener?.("addtrack", o), t?.removeEventListener("change", n), k.removeAttribute("src"), k.load();
|
|
412
|
+
}, Y.current = o, V.current = () => void v(), B.current && V.current();
|
|
338
413
|
});
|
|
339
414
|
}
|
|
340
|
-
}, () =>
|
|
415
|
+
}, () => g({
|
|
341
416
|
kind: "unsupported",
|
|
342
417
|
code: "hls.js"
|
|
343
418
|
})), () => {
|
|
344
|
-
u = !0, Z.current = () => {}, V.current = null,
|
|
419
|
+
u = !0, Z.current = () => {}, V.current = null, k.removeEventListener("error", _), d();
|
|
345
420
|
};
|
|
346
421
|
}, [
|
|
347
|
-
|
|
422
|
+
k,
|
|
348
423
|
i,
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
]),
|
|
352
|
-
if (!
|
|
353
|
-
let e = (e) => () =>
|
|
424
|
+
xe,
|
|
425
|
+
Se
|
|
426
|
+
]), g(() => {
|
|
427
|
+
if (!k) return;
|
|
428
|
+
let e = (e) => () => j((t) => t === "error" ? t : e), t = {
|
|
354
429
|
playing: () => {
|
|
355
|
-
R.current === null &&
|
|
430
|
+
R.current === null && be(!0), H.current = !1, W.current = Date.now(), e("playing")();
|
|
356
431
|
},
|
|
357
432
|
pause: () => {
|
|
358
|
-
|
|
433
|
+
k.ended || e("paused")();
|
|
359
434
|
},
|
|
360
435
|
waiting: () => B.current && e("buffering")(),
|
|
361
436
|
ended: () => R.current === null ? e("ended")() : z.current(),
|
|
@@ -364,114 +439,114 @@ function le({ src: i, xhrSetup: b, refresh: x, expires: S, active: C = !0, stall
|
|
|
364
439
|
B.current = !0, W.current = Date.now();
|
|
365
440
|
}
|
|
366
441
|
};
|
|
367
|
-
for (let [e, n] of Object.entries(t))
|
|
442
|
+
for (let [e, n] of Object.entries(t)) k.addEventListener(e, n);
|
|
368
443
|
return () => {
|
|
369
|
-
for (let [e, n] of Object.entries(t))
|
|
444
|
+
for (let [e, n] of Object.entries(t)) k.removeEventListener(e, n);
|
|
370
445
|
};
|
|
371
|
-
}, [
|
|
372
|
-
!
|
|
373
|
-
}, [
|
|
374
|
-
let
|
|
375
|
-
|
|
376
|
-
if (!
|
|
377
|
-
let e =
|
|
446
|
+
}, [k]), g(() => {
|
|
447
|
+
!S && k && !k.paused && k.pause(), S || (B.current = !1);
|
|
448
|
+
}, [S, k]);
|
|
449
|
+
let ze = A === "loading" || A === "buffering" || A === "playing";
|
|
450
|
+
g(() => {
|
|
451
|
+
if (!ze || !k) return;
|
|
452
|
+
let e = k.currentTime;
|
|
378
453
|
W.current = Math.max(W.current, Date.now());
|
|
379
454
|
let t = setInterval(() => {
|
|
380
|
-
if (B.current && !
|
|
381
|
-
if (
|
|
382
|
-
else if (Date.now() - W.current >
|
|
455
|
+
if (B.current && !k.paused) {
|
|
456
|
+
if (k.currentTime !== e) e = k.currentTime, W.current = Date.now();
|
|
457
|
+
else if (Date.now() - W.current > C) {
|
|
383
458
|
if (R.current !== null) return z.current();
|
|
384
|
-
|
|
459
|
+
k.pause(), B.current = !1, N({
|
|
385
460
|
kind: "stalled",
|
|
386
461
|
code: "stall"
|
|
387
|
-
}),
|
|
462
|
+
}), j("error");
|
|
388
463
|
}
|
|
389
464
|
}
|
|
390
465
|
}, 1e3);
|
|
391
466
|
return () => clearInterval(t);
|
|
392
467
|
}, [
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
468
|
+
ze,
|
|
469
|
+
k,
|
|
470
|
+
C
|
|
396
471
|
]);
|
|
397
|
-
let
|
|
398
|
-
B.current = !0, H.current = !1, W.current = Date.now(),
|
|
399
|
-
}, []), Q =
|
|
400
|
-
if (!
|
|
401
|
-
let e =
|
|
402
|
-
|
|
403
|
-
}, [
|
|
404
|
-
R.current !== null && (R.current = null, B.current = !1,
|
|
405
|
-
}, [
|
|
406
|
-
z.current =
|
|
407
|
-
let
|
|
408
|
-
!
|
|
409
|
-
}, [
|
|
410
|
-
j,
|
|
411
|
-
I,
|
|
412
|
-
P
|
|
413
|
-
]), $ = g(() => {
|
|
414
|
-
if (P) return Re();
|
|
415
|
-
R.current === null ? Fe.current || Q() : (R.current = null, xe(!1), j && (Q(), j.currentTime = X.current.startAt ?? 0), Y.current(), ge(!0)), B.current = !0, W.current = Date.now(), N("loading"), L(!0), V.current?.();
|
|
472
|
+
let Be = h(() => {
|
|
473
|
+
B.current = !0, H.current = !1, W.current = Date.now(), N(void 0), j("loading"), F(!0), I((e) => e + 1);
|
|
474
|
+
}, []), Q = h(() => {
|
|
475
|
+
if (!k) return;
|
|
476
|
+
let e = te(X.current.volumeKey);
|
|
477
|
+
k.volume = e.volume, k.muted = e.muted;
|
|
478
|
+
}, [k]), Ve = h(() => {
|
|
479
|
+
R.current !== null && (R.current = null, B.current = !1, L(!1), F(!1), j("idle"), k && (k.pause(), Q()));
|
|
480
|
+
}, [k, Q]);
|
|
481
|
+
z.current = Ve;
|
|
482
|
+
let He = h((e) => {
|
|
483
|
+
!k || P || M || B.current || R.current !== null || (R.current = Math.max(0, e), k.muted = !0, B.current = !0, W.current = Date.now(), L(!0), F(!0), V.current?.());
|
|
416
484
|
}, [
|
|
485
|
+
k,
|
|
417
486
|
P,
|
|
418
|
-
|
|
419
|
-
|
|
487
|
+
M
|
|
488
|
+
]), $ = h(() => {
|
|
489
|
+
if (M) return Be();
|
|
490
|
+
R.current === null ? Le.current || Q() : (R.current = null, L(!1), k && (Q(), k.currentTime = X.current.startAt ?? 0), Y.current(), be(!0)), B.current = !0, W.current = Date.now(), j("loading"), F(!0), V.current?.();
|
|
491
|
+
}, [
|
|
492
|
+
M,
|
|
493
|
+
Be,
|
|
494
|
+
k,
|
|
420
495
|
Q
|
|
421
|
-
]),
|
|
422
|
-
|
|
423
|
-
let
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}, [
|
|
427
|
-
let
|
|
428
|
-
|
|
429
|
-
let
|
|
496
|
+
]), Ue = _($);
|
|
497
|
+
Ue.current = $;
|
|
498
|
+
let We = _(me);
|
|
499
|
+
We.current = me, g(() => {
|
|
500
|
+
k && i && We.current && Ue.current();
|
|
501
|
+
}, [k, i]);
|
|
502
|
+
let Ge = _(we);
|
|
503
|
+
Ge.current = we;
|
|
504
|
+
let Ke = h((e) => {
|
|
430
505
|
G.current(e);
|
|
431
|
-
let t =
|
|
432
|
-
|
|
433
|
-
}, []),
|
|
434
|
-
|
|
435
|
-
let
|
|
436
|
-
|
|
437
|
-
let
|
|
506
|
+
let t = Ge.current.find((t) => t.index === e)?.height;
|
|
507
|
+
ce(X.current.qualityKey, e === -1 || !t ? "auto" : t);
|
|
508
|
+
}, []), qe = _(Ae);
|
|
509
|
+
qe.current = Ae;
|
|
510
|
+
let Je = _(Pe);
|
|
511
|
+
Je.current = Pe;
|
|
512
|
+
let Ye = h((e) => {
|
|
438
513
|
q.current(e);
|
|
439
|
-
let t =
|
|
440
|
-
t &&
|
|
441
|
-
}, []),
|
|
514
|
+
let t = qe.current[e]?.lang;
|
|
515
|
+
t && m(X.current.trackKey, { audio: t });
|
|
516
|
+
}, []), Xe = h((e) => {
|
|
442
517
|
J.current(e);
|
|
443
|
-
let t = e < 0 ? "off" :
|
|
444
|
-
t &&
|
|
518
|
+
let t = e < 0 ? "off" : Je.current[e]?.lang;
|
|
519
|
+
t && m(X.current.trackKey, { subtitles: t });
|
|
445
520
|
}, []);
|
|
446
521
|
return {
|
|
447
|
-
ref:
|
|
448
|
-
status:
|
|
449
|
-
error:
|
|
450
|
-
started:
|
|
522
|
+
ref: ye,
|
|
523
|
+
status: A,
|
|
524
|
+
error: M,
|
|
525
|
+
started: P,
|
|
451
526
|
play: $,
|
|
452
|
-
preview:
|
|
453
|
-
unload:
|
|
454
|
-
previewing:
|
|
455
|
-
retry:
|
|
527
|
+
preview: He,
|
|
528
|
+
unload: Ve,
|
|
529
|
+
previewing: Ce,
|
|
530
|
+
retry: Be,
|
|
456
531
|
quality: {
|
|
457
|
-
levels:
|
|
458
|
-
selected:
|
|
459
|
-
current:
|
|
460
|
-
select:
|
|
532
|
+
levels: we,
|
|
533
|
+
selected: Ee,
|
|
534
|
+
current: Oe,
|
|
535
|
+
select: Ke
|
|
461
536
|
},
|
|
462
537
|
audio: {
|
|
463
|
-
list:
|
|
464
|
-
selected:
|
|
465
|
-
select:
|
|
538
|
+
list: Ae,
|
|
539
|
+
selected: Me,
|
|
540
|
+
select: Ye
|
|
466
541
|
},
|
|
467
542
|
subtitles: {
|
|
468
|
-
list:
|
|
469
|
-
selected:
|
|
470
|
-
select:
|
|
543
|
+
list: Pe,
|
|
544
|
+
selected: Ie,
|
|
545
|
+
select: Xe
|
|
471
546
|
}
|
|
472
547
|
};
|
|
473
548
|
}
|
|
474
549
|
//#endregion
|
|
475
|
-
export {
|
|
550
|
+
export { y as GALLERY_VIEW_KEY, w as PLAYER_QUALITY_KEY, ie as fetchPlaylist, C as useCarousel, x as useGalleryView, pe as useHlsPlayer, E as useRefreshBeforeExpiry };
|
|
476
551
|
|
|
477
552
|
//# sourceMappingURL=gallery.js.map
|