@therealtinhtute/baroiplayer 1.0.1 → 1.0.2
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/dist/context/media.js +2 -0
- package/dist/context/media.js.map +1 -0
- package/dist/context/media.mjs +15 -0
- package/dist/context/media.mjs.map +1 -0
- package/dist/context/store.js +2 -0
- package/dist/context/store.js.map +1 -0
- package/dist/context/store.mjs +5 -0
- package/dist/context/store.mjs.map +1 -0
- package/dist/context-Af84FynT.js +1179 -0
- package/dist/context-Af84FynT.js.map +1 -0
- package/dist/context-CwZnPdz0.cjs +23 -0
- package/dist/context-CwZnPdz0.cjs.map +1 -0
- package/dist/core-events-B5W_j8yU.js +480 -0
- package/dist/core-events-B5W_j8yU.js.map +1 -0
- package/dist/core-events-CN0-Vhhq.cjs +2 -0
- package/dist/core-events-CN0-Vhhq.cjs.map +1 -0
- package/dist/core-plugins-Bq9KLany.js +696 -0
- package/dist/core-plugins-Bq9KLany.js.map +1 -0
- package/dist/core-plugins-CPDSHMiQ.cjs +2 -0
- package/dist/core-plugins-CPDSHMiQ.cjs.map +1 -0
- package/dist/core.js +37 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +1217 -0
- package/dist/core.mjs.map +1 -0
- package/dist/enhanced-components-CXnYiOt6.cjs +2 -0
- package/dist/enhanced-components-CXnYiOt6.cjs.map +1 -0
- package/dist/enhanced-components-Da0TSvKe.js +1073 -0
- package/dist/enhanced-components-Da0TSvKe.js.map +1 -0
- package/dist/hooks-BhW_i-9L.js +2013 -0
- package/dist/hooks-BhW_i-9L.js.map +1 -0
- package/dist/hooks-DTXeB5Z-.cjs +4 -0
- package/dist/hooks-DTXeB5Z-.cjs.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -0
- package/dist/index.mjs.map +1 -0
- package/dist/minimal-components-B0bILe18.js +2002 -0
- package/dist/minimal-components-B0bILe18.js.map +1 -0
- package/dist/minimal-components-BsqodtY8.cjs +2 -0
- package/dist/minimal-components-BsqodtY8.cjs.map +1 -0
- package/dist/minimal-components.css +589 -0
- package/dist/mona-loading.gif +0 -0
- package/dist/performance-monitor--rzKTlbj.js +302 -0
- package/dist/performance-monitor--rzKTlbj.js.map +1 -0
- package/dist/performance-monitor-cjIvZE2D.cjs +2 -0
- package/dist/performance-monitor-cjIvZE2D.cjs.map +1 -0
- package/dist/src/components/AnimateLoading.tsx +1 -1
- package/dist/src/components/enhanced/debug-panel.tsx +1 -1
- package/dist/src/components/media-player.tsx +2 -2
- package/dist/src/components/ui/media-resource-preloader.tsx +9 -11
- package/dist/src/components/ui/seek-bar.tsx +1 -1
- package/dist/src/core/plugins/enhanced-plugin-system.ts +14 -8
- package/dist/src/core/providers/enhanced-hls-provider.ts +22 -53
- package/dist/src/hooks/use-enhanced-media-player.ts +19 -2
- package/dist/src/types/index.ts +40 -5
- package/dist/styles/minimal-player.css +589 -0
- package/dist/utils-Db13763z.cjs +9 -0
- package/dist/utils-Db13763z.cjs.map +1 -0
- package/dist/utils-nTO4AnHo.js +2809 -0
- package/dist/utils-nTO4AnHo.js.map +1 -0
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +7 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +1 -1
- package/src/components/AnimateLoading.tsx +1 -1
- package/src/components/enhanced/debug-panel.tsx +1 -1
- package/src/components/media-player.tsx +2 -2
- package/src/components/ui/media-resource-preloader.tsx +9 -11
- package/src/components/ui/seek-bar.tsx +1 -1
- package/src/core/plugins/enhanced-plugin-system.ts +14 -8
- package/src/core/providers/enhanced-hls-provider.ts +22 -53
- package/src/hooks/use-enhanced-media-player.ts +19 -2
- package/src/types/index.ts +40 -5
|
@@ -0,0 +1,1179 @@
|
|
|
1
|
+
var le = Object.defineProperty;
|
|
2
|
+
var ue = (o, e, t) => e in o ? le(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var v = (o, e, t) => ue(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import S from "react";
|
|
5
|
+
var W = { exports: {} }, K = {};
|
|
6
|
+
/**
|
|
7
|
+
* @license React
|
|
8
|
+
* react-jsx-runtime.production.js
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*/
|
|
15
|
+
var re;
|
|
16
|
+
function Ee() {
|
|
17
|
+
if (re) return K;
|
|
18
|
+
re = 1;
|
|
19
|
+
var o = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
20
|
+
function t(s, n, a) {
|
|
21
|
+
var d = null;
|
|
22
|
+
if (a !== void 0 && (d = "" + a), n.key !== void 0 && (d = "" + n.key), "key" in n) {
|
|
23
|
+
a = {};
|
|
24
|
+
for (var c in n)
|
|
25
|
+
c !== "key" && (a[c] = n[c]);
|
|
26
|
+
} else a = n;
|
|
27
|
+
return n = a.ref, {
|
|
28
|
+
$$typeof: o,
|
|
29
|
+
type: s,
|
|
30
|
+
key: d,
|
|
31
|
+
ref: n !== void 0 ? n : null,
|
|
32
|
+
props: a
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return K.Fragment = e, K.jsx = t, K.jsxs = t, K;
|
|
36
|
+
}
|
|
37
|
+
var V = {};
|
|
38
|
+
/**
|
|
39
|
+
* @license React
|
|
40
|
+
* react-jsx-runtime.development.js
|
|
41
|
+
*
|
|
42
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the MIT license found in the
|
|
45
|
+
* LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/
|
|
47
|
+
var se;
|
|
48
|
+
function de() {
|
|
49
|
+
return se || (se = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
50
|
+
function o(r) {
|
|
51
|
+
if (r == null) return null;
|
|
52
|
+
if (typeof r == "function")
|
|
53
|
+
return r.$$typeof === l ? null : r.displayName || r.name || null;
|
|
54
|
+
if (typeof r == "string") return r;
|
|
55
|
+
switch (r) {
|
|
56
|
+
case M:
|
|
57
|
+
return "Fragment";
|
|
58
|
+
case O:
|
|
59
|
+
return "Profiler";
|
|
60
|
+
case C:
|
|
61
|
+
return "StrictMode";
|
|
62
|
+
case k:
|
|
63
|
+
return "Suspense";
|
|
64
|
+
case h:
|
|
65
|
+
return "SuspenseList";
|
|
66
|
+
case H:
|
|
67
|
+
return "Activity";
|
|
68
|
+
}
|
|
69
|
+
if (typeof r == "object")
|
|
70
|
+
switch (typeof r.tag == "number" && console.error(
|
|
71
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
72
|
+
), r.$$typeof) {
|
|
73
|
+
case D:
|
|
74
|
+
return "Portal";
|
|
75
|
+
case Y:
|
|
76
|
+
return (r.displayName || "Context") + ".Provider";
|
|
77
|
+
case j:
|
|
78
|
+
return (r._context.displayName || "Context") + ".Consumer";
|
|
79
|
+
case N:
|
|
80
|
+
var E = r.render;
|
|
81
|
+
return r = r.displayName, r || (r = E.displayName || E.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
82
|
+
case B:
|
|
83
|
+
return E = r.displayName || null, E !== null ? E : o(r.type) || "Memo";
|
|
84
|
+
case w:
|
|
85
|
+
E = r._payload, r = r._init;
|
|
86
|
+
try {
|
|
87
|
+
return o(r(E));
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
function e(r) {
|
|
94
|
+
return "" + r;
|
|
95
|
+
}
|
|
96
|
+
function t(r) {
|
|
97
|
+
try {
|
|
98
|
+
var E = !1;
|
|
99
|
+
} catch {
|
|
100
|
+
E = !0;
|
|
101
|
+
}
|
|
102
|
+
if (E) {
|
|
103
|
+
E = console;
|
|
104
|
+
var T = E.error, y = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
105
|
+
return T.call(
|
|
106
|
+
E,
|
|
107
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
108
|
+
y
|
|
109
|
+
), e(r);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function s(r) {
|
|
113
|
+
if (r === M) return "<>";
|
|
114
|
+
if (typeof r == "object" && r !== null && r.$$typeof === w)
|
|
115
|
+
return "<...>";
|
|
116
|
+
try {
|
|
117
|
+
var E = o(r);
|
|
118
|
+
return E ? "<" + E + ">" : "<...>";
|
|
119
|
+
} catch {
|
|
120
|
+
return "<...>";
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function n() {
|
|
124
|
+
var r = u.A;
|
|
125
|
+
return r === null ? null : r.getOwner();
|
|
126
|
+
}
|
|
127
|
+
function a() {
|
|
128
|
+
return Error("react-stack-top-frame");
|
|
129
|
+
}
|
|
130
|
+
function d(r) {
|
|
131
|
+
if (R.call(r, "key")) {
|
|
132
|
+
var E = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
133
|
+
if (E && E.isReactWarning) return !1;
|
|
134
|
+
}
|
|
135
|
+
return r.key !== void 0;
|
|
136
|
+
}
|
|
137
|
+
function c(r, E) {
|
|
138
|
+
function T() {
|
|
139
|
+
L || (L = !0, console.error(
|
|
140
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
141
|
+
E
|
|
142
|
+
));
|
|
143
|
+
}
|
|
144
|
+
T.isReactWarning = !0, Object.defineProperty(r, "key", {
|
|
145
|
+
get: T,
|
|
146
|
+
configurable: !0
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function f() {
|
|
150
|
+
var r = o(this.type);
|
|
151
|
+
return z[r] || (z[r] = !0, console.error(
|
|
152
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
153
|
+
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
154
|
+
}
|
|
155
|
+
function g(r, E, T, y, U, P, J, X) {
|
|
156
|
+
return T = P.ref, r = {
|
|
157
|
+
$$typeof: A,
|
|
158
|
+
type: r,
|
|
159
|
+
key: E,
|
|
160
|
+
props: P,
|
|
161
|
+
_owner: U
|
|
162
|
+
}, (T !== void 0 ? T : null) !== null ? Object.defineProperty(r, "ref", {
|
|
163
|
+
enumerable: !1,
|
|
164
|
+
get: f
|
|
165
|
+
}) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
|
|
166
|
+
configurable: !1,
|
|
167
|
+
enumerable: !1,
|
|
168
|
+
writable: !0,
|
|
169
|
+
value: 0
|
|
170
|
+
}), Object.defineProperty(r, "_debugInfo", {
|
|
171
|
+
configurable: !1,
|
|
172
|
+
enumerable: !1,
|
|
173
|
+
writable: !0,
|
|
174
|
+
value: null
|
|
175
|
+
}), Object.defineProperty(r, "_debugStack", {
|
|
176
|
+
configurable: !1,
|
|
177
|
+
enumerable: !1,
|
|
178
|
+
writable: !0,
|
|
179
|
+
value: J
|
|
180
|
+
}), Object.defineProperty(r, "_debugTask", {
|
|
181
|
+
configurable: !1,
|
|
182
|
+
enumerable: !1,
|
|
183
|
+
writable: !0,
|
|
184
|
+
value: X
|
|
185
|
+
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
186
|
+
}
|
|
187
|
+
function _(r, E, T, y, U, P, J, X) {
|
|
188
|
+
var m = E.children;
|
|
189
|
+
if (m !== void 0)
|
|
190
|
+
if (y)
|
|
191
|
+
if (x(m)) {
|
|
192
|
+
for (y = 0; y < m.length; y++)
|
|
193
|
+
F(m[y]);
|
|
194
|
+
Object.freeze && Object.freeze(m);
|
|
195
|
+
} else
|
|
196
|
+
console.error(
|
|
197
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
198
|
+
);
|
|
199
|
+
else F(m);
|
|
200
|
+
if (R.call(E, "key")) {
|
|
201
|
+
m = o(r);
|
|
202
|
+
var G = Object.keys(E).filter(function(ce) {
|
|
203
|
+
return ce !== "key";
|
|
204
|
+
});
|
|
205
|
+
y = 0 < G.length ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}", te[m + y] || (G = 0 < G.length ? "{" + G.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
206
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
207
|
+
let props = %s;
|
|
208
|
+
<%s {...props} />
|
|
209
|
+
React keys must be passed directly to JSX without using spread:
|
|
210
|
+
let props = %s;
|
|
211
|
+
<%s key={someKey} {...props} />`,
|
|
212
|
+
y,
|
|
213
|
+
m,
|
|
214
|
+
G,
|
|
215
|
+
m
|
|
216
|
+
), te[m + y] = !0);
|
|
217
|
+
}
|
|
218
|
+
if (m = null, T !== void 0 && (t(T), m = "" + T), d(E) && (t(E.key), m = "" + E.key), "key" in E) {
|
|
219
|
+
T = {};
|
|
220
|
+
for (var q in E)
|
|
221
|
+
q !== "key" && (T[q] = E[q]);
|
|
222
|
+
} else T = E;
|
|
223
|
+
return m && c(
|
|
224
|
+
T,
|
|
225
|
+
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
226
|
+
), g(
|
|
227
|
+
r,
|
|
228
|
+
m,
|
|
229
|
+
P,
|
|
230
|
+
U,
|
|
231
|
+
n(),
|
|
232
|
+
T,
|
|
233
|
+
J,
|
|
234
|
+
X
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
function F(r) {
|
|
238
|
+
typeof r == "object" && r !== null && r.$$typeof === A && r._store && (r._store.validated = 1);
|
|
239
|
+
}
|
|
240
|
+
var p = S, A = Symbol.for("react.transitional.element"), D = Symbol.for("react.portal"), M = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), O = Symbol.for("react.profiler"), j = Symbol.for("react.consumer"), Y = Symbol.for("react.context"), N = Symbol.for("react.forward_ref"), k = Symbol.for("react.suspense"), h = Symbol.for("react.suspense_list"), B = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), H = Symbol.for("react.activity"), l = Symbol.for("react.client.reference"), u = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, R = Object.prototype.hasOwnProperty, x = Array.isArray, I = console.createTask ? console.createTask : function() {
|
|
241
|
+
return null;
|
|
242
|
+
};
|
|
243
|
+
p = {
|
|
244
|
+
"react-stack-bottom-frame": function(r) {
|
|
245
|
+
return r();
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
var L, z = {}, Z = p["react-stack-bottom-frame"].bind(
|
|
249
|
+
p,
|
|
250
|
+
a
|
|
251
|
+
)(), ee = I(s(a)), te = {};
|
|
252
|
+
V.Fragment = M, V.jsx = function(r, E, T, y, U) {
|
|
253
|
+
var P = 1e4 > u.recentlyCreatedOwnerStacks++;
|
|
254
|
+
return _(
|
|
255
|
+
r,
|
|
256
|
+
E,
|
|
257
|
+
T,
|
|
258
|
+
!1,
|
|
259
|
+
y,
|
|
260
|
+
U,
|
|
261
|
+
P ? Error("react-stack-top-frame") : Z,
|
|
262
|
+
P ? I(s(r)) : ee
|
|
263
|
+
);
|
|
264
|
+
}, V.jsxs = function(r, E, T, y, U) {
|
|
265
|
+
var P = 1e4 > u.recentlyCreatedOwnerStacks++;
|
|
266
|
+
return _(
|
|
267
|
+
r,
|
|
268
|
+
E,
|
|
269
|
+
T,
|
|
270
|
+
!0,
|
|
271
|
+
y,
|
|
272
|
+
U,
|
|
273
|
+
P ? Error("react-stack-top-frame") : Z,
|
|
274
|
+
P ? I(s(r)) : ee
|
|
275
|
+
);
|
|
276
|
+
};
|
|
277
|
+
})()), V;
|
|
278
|
+
}
|
|
279
|
+
var ne;
|
|
280
|
+
function Te() {
|
|
281
|
+
return ne || (ne = 1, process.env.NODE_ENV === "production" ? W.exports = /* @__PURE__ */ Ee() : W.exports = /* @__PURE__ */ de()), W.exports;
|
|
282
|
+
}
|
|
283
|
+
var ae = /* @__PURE__ */ Te();
|
|
284
|
+
const ve = {
|
|
285
|
+
PLAY: "PLAY",
|
|
286
|
+
PAUSE: "PAUSE",
|
|
287
|
+
SEEK: "SEEK",
|
|
288
|
+
SET_VOLUME: "SET_VOLUME",
|
|
289
|
+
MUTE: "MUTE",
|
|
290
|
+
UNMUTE: "UNMUTE",
|
|
291
|
+
TOGGLE_MUTE: "TOGGLE_MUTE",
|
|
292
|
+
SET_DURATION: "SET_DURATION",
|
|
293
|
+
SET_CURRENT_TIME: "SET_CURRENT_TIME",
|
|
294
|
+
SET_BUFFERED: "SET_BUFFERED",
|
|
295
|
+
SET_LOADING: "SET_LOADING",
|
|
296
|
+
SET_ERROR: "SET_ERROR",
|
|
297
|
+
ENTER_FULLSCREEN: "ENTER_FULLSCREEN",
|
|
298
|
+
EXIT_FULLSCREEN: "EXIT_FULLSCREEN",
|
|
299
|
+
ENTER_PIP: "ENTER_PIP",
|
|
300
|
+
EXIT_PIP: "EXIT_PIP",
|
|
301
|
+
SET_PLAYBACK_RATE: "SET_PLAYBACK_RATE",
|
|
302
|
+
SET_SUBTITLE_TRACK: "SET_SUBTITLE_TRACK",
|
|
303
|
+
SET_RENDITION: "SET_RENDITION",
|
|
304
|
+
TOGGLE_SUBTITLES: "TOGGLE_SUBTITLES",
|
|
305
|
+
PREVIEW_TIME: "PREVIEW_TIME",
|
|
306
|
+
CLEAR_PREVIEW: "CLEAR_PREVIEW"
|
|
307
|
+
};
|
|
308
|
+
S.createContext(null);
|
|
309
|
+
const fe = S.createContext(null);
|
|
310
|
+
function Se() {
|
|
311
|
+
const o = S.useContext(fe);
|
|
312
|
+
if (!o)
|
|
313
|
+
throw new Error("useMediaStore must be used within a MediaPlayer");
|
|
314
|
+
return o;
|
|
315
|
+
}
|
|
316
|
+
function Me(o) {
|
|
317
|
+
const e = Se(), t = () => o(e.getState());
|
|
318
|
+
return S.useSyncExternalStore(e.subscribe, t, t);
|
|
319
|
+
}
|
|
320
|
+
const i = {
|
|
321
|
+
PLAY: "PLAY",
|
|
322
|
+
PAUSE: "PAUSE",
|
|
323
|
+
SEEK: "SEEK",
|
|
324
|
+
SET_VOLUME: "SET_VOLUME",
|
|
325
|
+
MUTE: "MUTE",
|
|
326
|
+
UNMUTE: "UNMUTE",
|
|
327
|
+
TOGGLE_MUTE: "TOGGLE_MUTE",
|
|
328
|
+
SET_DURATION: "SET_DURATION",
|
|
329
|
+
SET_CURRENT_TIME: "SET_CURRENT_TIME",
|
|
330
|
+
SET_BUFFERED: "SET_BUFFERED",
|
|
331
|
+
SET_LOADING: "SET_LOADING",
|
|
332
|
+
SET_ERROR: "SET_ERROR",
|
|
333
|
+
ENTER_FULLSCREEN: "ENTER_FULLSCREEN",
|
|
334
|
+
EXIT_FULLSCREEN: "EXIT_FULLSCREEN",
|
|
335
|
+
ENTER_PIP: "ENTER_PIP",
|
|
336
|
+
EXIT_PIP: "EXIT_PIP",
|
|
337
|
+
SET_PLAYBACK_RATE: "SET_PLAYBACK_RATE",
|
|
338
|
+
SET_SUBTITLE_TRACK: "SET_SUBTITLE_TRACK",
|
|
339
|
+
SET_RENDITION: "SET_RENDITION",
|
|
340
|
+
TOGGLE_SUBTITLES: "TOGGLE_SUBTITLES",
|
|
341
|
+
PREVIEW_TIME: "PREVIEW_TIME",
|
|
342
|
+
CLEAR_PREVIEW: "CLEAR_PREVIEW",
|
|
343
|
+
// New actions for Video.js adapter
|
|
344
|
+
SET_BUFFERING: "SET_BUFFERING",
|
|
345
|
+
SET_QUALITY_LEVEL: "SET_QUALITY_LEVEL",
|
|
346
|
+
SET_BANDWIDTH_ESTIMATE: "SET_BANDWIDTH_ESTIMATE",
|
|
347
|
+
SET_ACTIVE_TEXT_TRACKS: "SET_ACTIVE_TEXT_TRACKS"
|
|
348
|
+
}, oe = S.createContext(null);
|
|
349
|
+
function Re() {
|
|
350
|
+
const o = S.useContext(oe);
|
|
351
|
+
if (!o)
|
|
352
|
+
throw new Error("useMediaContext must be used within a MediaPlayer");
|
|
353
|
+
return o;
|
|
354
|
+
}
|
|
355
|
+
const ie = S.createContext(null);
|
|
356
|
+
function $() {
|
|
357
|
+
const o = S.useContext(ie);
|
|
358
|
+
if (!o)
|
|
359
|
+
throw new Error("useMediaStore must be used within a MediaPlayer");
|
|
360
|
+
return o;
|
|
361
|
+
}
|
|
362
|
+
function Ce(o) {
|
|
363
|
+
const e = $(), t = () => o(e.getState());
|
|
364
|
+
return S.useSyncExternalStore(e.subscribe, t, t);
|
|
365
|
+
}
|
|
366
|
+
function ke() {
|
|
367
|
+
return $().dispatch;
|
|
368
|
+
}
|
|
369
|
+
function xe(o) {
|
|
370
|
+
const e = $(), t = "getOptimisticState" in e, s = () => o(t ? e.getOptimisticState() : e.getState());
|
|
371
|
+
return S.useSyncExternalStore(e.subscribe, s, s);
|
|
372
|
+
}
|
|
373
|
+
function Fe() {
|
|
374
|
+
const o = $(), e = Re(), t = "getOptimisticState" in o, s = "errorHandler" in e ? e.errorHandler : null, n = "isRehydrated" in e ? e.isRehydrated : !0;
|
|
375
|
+
return {
|
|
376
|
+
isEnhanced: t,
|
|
377
|
+
errorHandler: s,
|
|
378
|
+
isRehydrated: n,
|
|
379
|
+
actionsState: t ? o.getActionState() : null
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
const Q = {
|
|
383
|
+
isPlaying: !1,
|
|
384
|
+
currentTime: 0,
|
|
385
|
+
duration: 0,
|
|
386
|
+
buffered: null,
|
|
387
|
+
isLoading: !1,
|
|
388
|
+
isBuffering: !1,
|
|
389
|
+
error: null,
|
|
390
|
+
volume: 1,
|
|
391
|
+
isMuted: !1,
|
|
392
|
+
isFullscreen: !1,
|
|
393
|
+
isPictureInPicture: !1,
|
|
394
|
+
playbackRate: 1,
|
|
395
|
+
subtitlesShowing: !1,
|
|
396
|
+
selectedSubtitleTrack: null,
|
|
397
|
+
selectedRendition: null,
|
|
398
|
+
qualityLevel: -1,
|
|
399
|
+
bandwidthEstimate: 0,
|
|
400
|
+
activeTextTracks: [],
|
|
401
|
+
previewTime: null,
|
|
402
|
+
previewImage: null,
|
|
403
|
+
previewCoords: null,
|
|
404
|
+
subtitlesList: [],
|
|
405
|
+
renditionList: []
|
|
406
|
+
}, ye = {
|
|
407
|
+
enabled: !0,
|
|
408
|
+
key: "baroi-player-state",
|
|
409
|
+
persist: ["volume", "isMuted", "playbackRate", "subtitlesShowing"],
|
|
410
|
+
debounceMs: 500
|
|
411
|
+
};
|
|
412
|
+
function me(o = Q, e = {}) {
|
|
413
|
+
let t = { ...o }, s = { ...o }, n = {
|
|
414
|
+
pending: !1,
|
|
415
|
+
error: null,
|
|
416
|
+
lastAction: null,
|
|
417
|
+
retryCount: 0
|
|
418
|
+
};
|
|
419
|
+
const a = { ...ye, ...e }, d = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
|
|
420
|
+
let f = null;
|
|
421
|
+
const g = (l) => (d.add(l), () => d.delete(l)), _ = () => {
|
|
422
|
+
d.forEach((l) => l());
|
|
423
|
+
}, F = () => t, p = () => s, A = () => n, D = async () => {
|
|
424
|
+
if (!a.enabled || typeof window > "u") return;
|
|
425
|
+
const l = a.persist.reduce((u, R) => (u[R] = t[R], u), {});
|
|
426
|
+
try {
|
|
427
|
+
localStorage.setItem(a.key, JSON.stringify({
|
|
428
|
+
...l,
|
|
429
|
+
timestamp: Date.now()
|
|
430
|
+
}));
|
|
431
|
+
} catch (u) {
|
|
432
|
+
console.warn("Failed to persist media state:", u);
|
|
433
|
+
}
|
|
434
|
+
}, M = () => {
|
|
435
|
+
f && clearTimeout(f), f = setTimeout(D, a.debounceMs);
|
|
436
|
+
}, C = async () => {
|
|
437
|
+
if (!(!a.enabled || typeof window > "u"))
|
|
438
|
+
try {
|
|
439
|
+
const l = localStorage.getItem(a.key);
|
|
440
|
+
if (!l) return;
|
|
441
|
+
const u = JSON.parse(l), { timestamp: R, ...x } = u, I = 10080 * 60 * 1e3;
|
|
442
|
+
if (R && Date.now() - R > I) {
|
|
443
|
+
O();
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const L = { ...t, ...x };
|
|
447
|
+
JSON.stringify(L) !== JSON.stringify(t) && (t = L, s = { ...L }, _());
|
|
448
|
+
} catch (l) {
|
|
449
|
+
console.warn("Failed to rehydrate media state:", l);
|
|
450
|
+
}
|
|
451
|
+
}, O = () => {
|
|
452
|
+
if (!(typeof window > "u"))
|
|
453
|
+
try {
|
|
454
|
+
localStorage.removeItem(a.key);
|
|
455
|
+
} catch (l) {
|
|
456
|
+
console.warn("Failed to clear persisted state:", l);
|
|
457
|
+
}
|
|
458
|
+
}, j = (l) => {
|
|
459
|
+
Object.assign(a, l);
|
|
460
|
+
}, Y = (l) => {
|
|
461
|
+
const u = { ...t, ...l };
|
|
462
|
+
JSON.stringify(u) !== JSON.stringify(t) && (t = u, s = { ...u }, M(), _());
|
|
463
|
+
}, N = (l) => {
|
|
464
|
+
const u = `${l.type}-${Date.now()}-${Math.random()}`;
|
|
465
|
+
c.set(u, { ...l, timestamp: Date.now() });
|
|
466
|
+
const R = h(s, l);
|
|
467
|
+
return s = { ...s, ...R }, _(), u;
|
|
468
|
+
}, k = (l) => {
|
|
469
|
+
if (c.has(l)) {
|
|
470
|
+
c.delete(l), s = { ...t };
|
|
471
|
+
for (const [, u] of c) {
|
|
472
|
+
const R = h(s, u);
|
|
473
|
+
s = { ...s, ...R };
|
|
474
|
+
}
|
|
475
|
+
_();
|
|
476
|
+
}
|
|
477
|
+
}, h = (l, u) => {
|
|
478
|
+
switch (u.type) {
|
|
479
|
+
case i.PLAY:
|
|
480
|
+
return { isPlaying: !0, error: null };
|
|
481
|
+
case i.PAUSE:
|
|
482
|
+
return { isPlaying: !1 };
|
|
483
|
+
case i.SEEK:
|
|
484
|
+
return { currentTime: u.detail };
|
|
485
|
+
case i.SET_VOLUME:
|
|
486
|
+
return { volume: Math.max(0, Math.min(1, u.detail)) };
|
|
487
|
+
case i.MUTE:
|
|
488
|
+
return { isMuted: !0 };
|
|
489
|
+
case i.UNMUTE:
|
|
490
|
+
return { isMuted: !1 };
|
|
491
|
+
case i.TOGGLE_MUTE:
|
|
492
|
+
return { isMuted: !l.isMuted };
|
|
493
|
+
case i.SET_DURATION:
|
|
494
|
+
return { duration: u.detail };
|
|
495
|
+
case i.SET_CURRENT_TIME:
|
|
496
|
+
return { currentTime: u.detail };
|
|
497
|
+
case i.SET_BUFFERED:
|
|
498
|
+
return { buffered: u.detail };
|
|
499
|
+
case i.SET_LOADING:
|
|
500
|
+
return { isLoading: u.detail };
|
|
501
|
+
case i.SET_ERROR:
|
|
502
|
+
return { error: u.detail, isLoading: !1 };
|
|
503
|
+
case i.ENTER_FULLSCREEN:
|
|
504
|
+
return { isFullscreen: !0 };
|
|
505
|
+
case i.EXIT_FULLSCREEN:
|
|
506
|
+
return { isFullscreen: !1 };
|
|
507
|
+
case i.ENTER_PIP:
|
|
508
|
+
return { isPictureInPicture: !0 };
|
|
509
|
+
case i.EXIT_PIP:
|
|
510
|
+
return { isPictureInPicture: !1 };
|
|
511
|
+
case i.SET_PLAYBACK_RATE:
|
|
512
|
+
return { playbackRate: u.detail };
|
|
513
|
+
case i.SET_SUBTITLE_TRACK:
|
|
514
|
+
return { selectedSubtitleTrack: u.detail };
|
|
515
|
+
case i.SET_RENDITION:
|
|
516
|
+
return { selectedRendition: u.detail };
|
|
517
|
+
case i.TOGGLE_SUBTITLES:
|
|
518
|
+
return { subtitlesShowing: !l.subtitlesShowing };
|
|
519
|
+
case i.PREVIEW_TIME:
|
|
520
|
+
return { previewTime: u.detail };
|
|
521
|
+
case i.CLEAR_PREVIEW:
|
|
522
|
+
return { previewTime: null, previewImage: null, previewCoords: null };
|
|
523
|
+
default:
|
|
524
|
+
return console.warn(`Unknown media action type: ${u.type}`), {};
|
|
525
|
+
}
|
|
526
|
+
}, B = (l) => {
|
|
527
|
+
const u = h(t, l);
|
|
528
|
+
Y(u);
|
|
529
|
+
}, w = async (l) => {
|
|
530
|
+
n = {
|
|
531
|
+
pending: !0,
|
|
532
|
+
error: null,
|
|
533
|
+
lastAction: l,
|
|
534
|
+
retryCount: l.retryCount || 0
|
|
535
|
+
};
|
|
536
|
+
const u = N(l);
|
|
537
|
+
try {
|
|
538
|
+
await new Promise((I) => setTimeout(I, 0));
|
|
539
|
+
const R = h(t, l), x = { ...t, ...R };
|
|
540
|
+
JSON.stringify(x) !== JSON.stringify(t) && (t = x, M()), c.delete(u), n = {
|
|
541
|
+
pending: !1,
|
|
542
|
+
error: null,
|
|
543
|
+
lastAction: l,
|
|
544
|
+
retryCount: 0
|
|
545
|
+
}, s = { ...t };
|
|
546
|
+
for (const [, I] of c) {
|
|
547
|
+
const L = h(s, I);
|
|
548
|
+
s = { ...s, ...L };
|
|
549
|
+
}
|
|
550
|
+
} catch (R) {
|
|
551
|
+
k(u), n = {
|
|
552
|
+
pending: !1,
|
|
553
|
+
error: R instanceof Error ? R.message : "Unknown error occurred",
|
|
554
|
+
lastAction: l,
|
|
555
|
+
retryCount: (l.retryCount || 0) + 1
|
|
556
|
+
}, n.retryCount < 3 && H(l.type) && setTimeout(() => {
|
|
557
|
+
w({
|
|
558
|
+
...l,
|
|
559
|
+
retryCount: n.retryCount
|
|
560
|
+
});
|
|
561
|
+
}, Math.pow(2, n.retryCount) * 1e3);
|
|
562
|
+
}
|
|
563
|
+
_();
|
|
564
|
+
}, H = (l) => [
|
|
565
|
+
i.PLAY,
|
|
566
|
+
i.PAUSE,
|
|
567
|
+
i.SEEK,
|
|
568
|
+
i.SET_VOLUME,
|
|
569
|
+
i.MUTE,
|
|
570
|
+
i.UNMUTE,
|
|
571
|
+
i.TOGGLE_MUTE
|
|
572
|
+
].includes(l);
|
|
573
|
+
return C(), {
|
|
574
|
+
subscribe: g,
|
|
575
|
+
getState: F,
|
|
576
|
+
setState: Y,
|
|
577
|
+
dispatch: B,
|
|
578
|
+
getOptimisticState: p,
|
|
579
|
+
dispatchOptimistic: w,
|
|
580
|
+
rollbackOptimistic: k,
|
|
581
|
+
getActionState: A,
|
|
582
|
+
setPersistenceConfig: j,
|
|
583
|
+
rehydrateFromStorage: C,
|
|
584
|
+
clearPersistedState: O
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
const b = {
|
|
588
|
+
USER_PREFERENCES: "baroi-player-preferences",
|
|
589
|
+
SESSION_STATE: "baroi-player-session",
|
|
590
|
+
PLAYBACK_HISTORY: "baroi-player-history",
|
|
591
|
+
CACHE_TIMESTAMP: "baroi-player-cache-ts"
|
|
592
|
+
};
|
|
593
|
+
class _e {
|
|
594
|
+
async getItem(e) {
|
|
595
|
+
if (typeof window > "u") return null;
|
|
596
|
+
try {
|
|
597
|
+
return localStorage.getItem(e);
|
|
598
|
+
} catch (t) {
|
|
599
|
+
return console.warn("Failed to read from localStorage:", t), null;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
async setItem(e, t) {
|
|
603
|
+
if (!(typeof window > "u"))
|
|
604
|
+
try {
|
|
605
|
+
localStorage.setItem(e, t);
|
|
606
|
+
} catch (s) {
|
|
607
|
+
console.warn("Failed to write to localStorage:", s);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
async removeItem(e) {
|
|
611
|
+
if (!(typeof window > "u"))
|
|
612
|
+
try {
|
|
613
|
+
localStorage.removeItem(e);
|
|
614
|
+
} catch (t) {
|
|
615
|
+
console.warn("Failed to remove from localStorage:", t);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
async clear() {
|
|
619
|
+
if (!(typeof window > "u"))
|
|
620
|
+
try {
|
|
621
|
+
Object.values(b).forEach((e) => {
|
|
622
|
+
localStorage.removeItem(e);
|
|
623
|
+
});
|
|
624
|
+
} catch (e) {
|
|
625
|
+
console.warn("Failed to clear localStorage:", e);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
const pe = {
|
|
630
|
+
userPreferences: !0,
|
|
631
|
+
sessionState: !0,
|
|
632
|
+
playbackHistory: !0,
|
|
633
|
+
maxHistoryItems: 50,
|
|
634
|
+
maxCacheAge: 10080 * 60 * 1e3,
|
|
635
|
+
// 7 days
|
|
636
|
+
debounceMs: 1e3,
|
|
637
|
+
storage: new _e()
|
|
638
|
+
};
|
|
639
|
+
class ge {
|
|
640
|
+
constructor(e = {}) {
|
|
641
|
+
v(this, "config");
|
|
642
|
+
v(this, "storage");
|
|
643
|
+
v(this, "debounceTimeouts", /* @__PURE__ */ new Map());
|
|
644
|
+
this.config = { ...pe, ...e }, this.storage = this.config.storage;
|
|
645
|
+
}
|
|
646
|
+
// User preferences methods
|
|
647
|
+
async getUserPreferences() {
|
|
648
|
+
if (!this.config.userPreferences) return null;
|
|
649
|
+
try {
|
|
650
|
+
const e = await this.storage.getItem(b.USER_PREFERENCES);
|
|
651
|
+
if (!e) return null;
|
|
652
|
+
const t = JSON.parse(e);
|
|
653
|
+
return this.isCacheExpired(t.timestamp) ? (await this.clearUserPreferences(), null) : t.preferences;
|
|
654
|
+
} catch (e) {
|
|
655
|
+
return console.warn("Failed to get user preferences:", e), null;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
async saveUserPreferences(e) {
|
|
659
|
+
this.config.userPreferences && this.debounce(b.USER_PREFERENCES, async () => {
|
|
660
|
+
try {
|
|
661
|
+
const s = { ...await this.getUserPreferences() || {}, ...e };
|
|
662
|
+
await this.storage.setItem(b.USER_PREFERENCES, JSON.stringify({
|
|
663
|
+
preferences: s,
|
|
664
|
+
timestamp: Date.now()
|
|
665
|
+
}));
|
|
666
|
+
} catch (t) {
|
|
667
|
+
console.warn("Failed to save user preferences:", t);
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
async clearUserPreferences() {
|
|
672
|
+
try {
|
|
673
|
+
await this.storage.removeItem(b.USER_PREFERENCES);
|
|
674
|
+
} catch (e) {
|
|
675
|
+
console.warn("Failed to clear user preferences:", e);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
// Session state methods
|
|
679
|
+
async getSessionState() {
|
|
680
|
+
if (!this.config.sessionState) return null;
|
|
681
|
+
try {
|
|
682
|
+
const e = await this.storage.getItem(b.SESSION_STATE);
|
|
683
|
+
return e ? JSON.parse(e).state : null;
|
|
684
|
+
} catch (e) {
|
|
685
|
+
return console.warn("Failed to get session state:", e), null;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
async saveSessionState(e) {
|
|
689
|
+
this.config.sessionState && this.debounce(b.SESSION_STATE, async () => {
|
|
690
|
+
try {
|
|
691
|
+
const s = { ...await this.getSessionState() || {
|
|
692
|
+
currentTime: 0,
|
|
693
|
+
playbackPosition: {}
|
|
694
|
+
}, ...e };
|
|
695
|
+
await this.storage.setItem(b.SESSION_STATE, JSON.stringify({
|
|
696
|
+
state: s,
|
|
697
|
+
timestamp: Date.now()
|
|
698
|
+
}));
|
|
699
|
+
} catch (t) {
|
|
700
|
+
console.warn("Failed to save session state:", t);
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
async clearSessionState() {
|
|
705
|
+
try {
|
|
706
|
+
await this.storage.removeItem(b.SESSION_STATE);
|
|
707
|
+
} catch (e) {
|
|
708
|
+
console.warn("Failed to clear session state:", e);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
// Playback history methods
|
|
712
|
+
async getPlaybackHistory() {
|
|
713
|
+
if (!this.config.playbackHistory) return [];
|
|
714
|
+
try {
|
|
715
|
+
const e = await this.storage.getItem(b.PLAYBACK_HISTORY);
|
|
716
|
+
if (!e) return [];
|
|
717
|
+
const t = JSON.parse(e);
|
|
718
|
+
return this.isCacheExpired(t.timestamp) ? (await this.clearPlaybackHistory(), []) : t.history || [];
|
|
719
|
+
} catch (e) {
|
|
720
|
+
return console.warn("Failed to get playback history:", e), [];
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
async addToPlaybackHistory(e) {
|
|
724
|
+
if (this.config.playbackHistory)
|
|
725
|
+
try {
|
|
726
|
+
const t = await this.getPlaybackHistory(), s = {
|
|
727
|
+
...e,
|
|
728
|
+
timestamp: Date.now()
|
|
729
|
+
}, n = t.filter((d) => d.mediaId !== e.mediaId), a = [s, ...n].slice(0, this.config.maxHistoryItems);
|
|
730
|
+
await this.storage.setItem(b.PLAYBACK_HISTORY, JSON.stringify({
|
|
731
|
+
history: a,
|
|
732
|
+
timestamp: Date.now()
|
|
733
|
+
}));
|
|
734
|
+
} catch (t) {
|
|
735
|
+
console.warn("Failed to add to playback history:", t);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
async clearPlaybackHistory() {
|
|
739
|
+
try {
|
|
740
|
+
await this.storage.removeItem(b.PLAYBACK_HISTORY);
|
|
741
|
+
} catch (e) {
|
|
742
|
+
console.warn("Failed to clear playback history:", e);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
// Utility methods
|
|
746
|
+
async savePlaybackPosition(e, t) {
|
|
747
|
+
const n = (await this.getSessionState())?.playbackPosition || {};
|
|
748
|
+
await this.saveSessionState({
|
|
749
|
+
playbackPosition: {
|
|
750
|
+
...n,
|
|
751
|
+
[e]: t
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
async getPlaybackPosition(e) {
|
|
756
|
+
return (await this.getSessionState())?.playbackPosition?.[e] || 0;
|
|
757
|
+
}
|
|
758
|
+
// Extract preferences from MediaState
|
|
759
|
+
extractUserPreferences(e) {
|
|
760
|
+
return {
|
|
761
|
+
volume: e.volume,
|
|
762
|
+
isMuted: e.isMuted,
|
|
763
|
+
playbackRate: e.playbackRate,
|
|
764
|
+
subtitlesShowing: e.subtitlesShowing,
|
|
765
|
+
selectedSubtitleTrack: e.selectedSubtitleTrack?.id || null,
|
|
766
|
+
preferredRendition: e.selectedRendition,
|
|
767
|
+
autoplay: !1,
|
|
768
|
+
// This would come from config
|
|
769
|
+
keyboardShortcuts: !0
|
|
770
|
+
// This would come from config
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
// Extract session state from MediaState
|
|
774
|
+
extractSessionState(e, t) {
|
|
775
|
+
return {
|
|
776
|
+
currentTime: e.currentTime,
|
|
777
|
+
mediaId: t,
|
|
778
|
+
playbackPosition: {}
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
// Clear all persisted data
|
|
782
|
+
async clearAll() {
|
|
783
|
+
await this.storage.clear(), this.debounceTimeouts.clear();
|
|
784
|
+
}
|
|
785
|
+
// Private helper methods
|
|
786
|
+
isCacheExpired(e) {
|
|
787
|
+
return e ? Date.now() - e > this.config.maxCacheAge : !0;
|
|
788
|
+
}
|
|
789
|
+
debounce(e, t) {
|
|
790
|
+
const s = this.debounceTimeouts.get(e);
|
|
791
|
+
s && clearTimeout(s);
|
|
792
|
+
const n = setTimeout(async () => {
|
|
793
|
+
await t(), this.debounceTimeouts.delete(e);
|
|
794
|
+
}, this.config.debounceMs);
|
|
795
|
+
this.debounceTimeouts.set(e, n);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
function he(o) {
|
|
799
|
+
const [e] = S.useState(() => new ge(o));
|
|
800
|
+
return S.useEffect(() => () => {
|
|
801
|
+
e.clearAll();
|
|
802
|
+
}, [e]), e;
|
|
803
|
+
}
|
|
804
|
+
function be(o, e, t) {
|
|
805
|
+
const s = he(t), [n, a] = S.useState(!1);
|
|
806
|
+
return S.useEffect(() => {
|
|
807
|
+
let d = !0;
|
|
808
|
+
return (async () => {
|
|
809
|
+
try {
|
|
810
|
+
const [f, g] = await Promise.all([
|
|
811
|
+
s.getUserPreferences(),
|
|
812
|
+
s.getSessionState()
|
|
813
|
+
]);
|
|
814
|
+
if (!d) return;
|
|
815
|
+
const _ = {
|
|
816
|
+
...f && {
|
|
817
|
+
volume: f.volume,
|
|
818
|
+
isMuted: f.isMuted,
|
|
819
|
+
playbackRate: f.playbackRate,
|
|
820
|
+
subtitlesShowing: f.subtitlesShowing
|
|
821
|
+
},
|
|
822
|
+
...g && e === g.mediaId && {
|
|
823
|
+
currentTime: g.currentTime
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
Object.keys(_).length > 0 && console.log("Rehydrated state:", _), a(!0);
|
|
827
|
+
} catch (f) {
|
|
828
|
+
console.warn("Failed to rehydrate state:", f), a(!0);
|
|
829
|
+
}
|
|
830
|
+
})(), () => {
|
|
831
|
+
d = !1;
|
|
832
|
+
};
|
|
833
|
+
}, [s, e]), S.useEffect(() => {
|
|
834
|
+
if (!n) return;
|
|
835
|
+
const d = s.extractUserPreferences(o);
|
|
836
|
+
if (s.saveUserPreferences(d), e) {
|
|
837
|
+
const c = s.extractSessionState(o, e);
|
|
838
|
+
s.saveSessionState(c), o.currentTime > 0 && o.duration > 0 && s.savePlaybackPosition(e, o.currentTime);
|
|
839
|
+
}
|
|
840
|
+
}, [s, o, e, n]), {
|
|
841
|
+
manager: s,
|
|
842
|
+
isRehydrated: n
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
const we = {
|
|
846
|
+
maxRetries: 3,
|
|
847
|
+
baseDelay: 1e3,
|
|
848
|
+
maxDelay: 1e4,
|
|
849
|
+
exponentialBackoff: !0,
|
|
850
|
+
retryableErrors: [
|
|
851
|
+
"NETWORK_ERROR",
|
|
852
|
+
"TIMEOUT_ERROR"
|
|
853
|
+
/* TIMEOUT_ERROR */
|
|
854
|
+
],
|
|
855
|
+
retryableActions: [
|
|
856
|
+
"PLAY",
|
|
857
|
+
"PAUSE",
|
|
858
|
+
"SEEK",
|
|
859
|
+
"SET_VOLUME",
|
|
860
|
+
"ENTER_FULLSCREEN",
|
|
861
|
+
"EXIT_FULLSCREEN"
|
|
862
|
+
]
|
|
863
|
+
};
|
|
864
|
+
class Pe {
|
|
865
|
+
canRecover(e) {
|
|
866
|
+
return e.type === "NETWORK_ERROR" && e.retryCount < 3;
|
|
867
|
+
}
|
|
868
|
+
async recover(e) {
|
|
869
|
+
navigator.onLine === !1 && await new Promise((t) => {
|
|
870
|
+
const s = () => {
|
|
871
|
+
window.removeEventListener("online", s), t(void 0);
|
|
872
|
+
};
|
|
873
|
+
window.addEventListener("online", s);
|
|
874
|
+
}), await new Promise((t) => setTimeout(t, 2e3));
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
class Ie {
|
|
878
|
+
canRecover(e) {
|
|
879
|
+
return e.type === "PLAYBACK_ERROR" && e.retryCount < 2;
|
|
880
|
+
}
|
|
881
|
+
async recover(e) {
|
|
882
|
+
const t = document.querySelector("video, audio");
|
|
883
|
+
t && (t.load(), await new Promise((s) => {
|
|
884
|
+
const n = () => {
|
|
885
|
+
t.removeEventListener("canplay", n), s(void 0);
|
|
886
|
+
};
|
|
887
|
+
t.addEventListener("canplay", n);
|
|
888
|
+
}));
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
class Ae {
|
|
892
|
+
canRecover(e) {
|
|
893
|
+
return e.type === "PERMISSION_ERROR" && e.action?.type === "ENTER_FULLSCREEN";
|
|
894
|
+
}
|
|
895
|
+
async recover(e) {
|
|
896
|
+
console.warn("Fullscreen requires user interaction");
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
class Oe {
|
|
900
|
+
constructor(e = {}, t = []) {
|
|
901
|
+
v(this, "config");
|
|
902
|
+
v(this, "recoveryStrategies");
|
|
903
|
+
v(this, "errorQueue", /* @__PURE__ */ new Map());
|
|
904
|
+
v(this, "listeners", /* @__PURE__ */ new Set());
|
|
905
|
+
this.config = { ...we, ...e }, this.recoveryStrategies = [
|
|
906
|
+
new Pe(),
|
|
907
|
+
new Ie(),
|
|
908
|
+
new Ae(),
|
|
909
|
+
...t
|
|
910
|
+
];
|
|
911
|
+
}
|
|
912
|
+
// Create a media error from a generic error
|
|
913
|
+
createMediaError(e, t, s = 0) {
|
|
914
|
+
const n = Date.now();
|
|
915
|
+
if (e instanceof Error) {
|
|
916
|
+
const a = this.categorizeError(e, t);
|
|
917
|
+
return {
|
|
918
|
+
type: a,
|
|
919
|
+
message: e.message,
|
|
920
|
+
action: t,
|
|
921
|
+
timestamp: n,
|
|
922
|
+
retryable: this.isRetryable(a, t),
|
|
923
|
+
retryCount: s,
|
|
924
|
+
originalError: e
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
return {
|
|
928
|
+
type: "UNKNOWN_ERROR",
|
|
929
|
+
message: typeof e == "string" ? e : "Unknown error occurred",
|
|
930
|
+
action: t,
|
|
931
|
+
timestamp: n,
|
|
932
|
+
retryable: this.isRetryable("UNKNOWN_ERROR", t),
|
|
933
|
+
retryCount: s
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
// Categorize errors based on error properties and action context
|
|
937
|
+
categorizeError(e, t) {
|
|
938
|
+
const s = e.message.toLowerCase();
|
|
939
|
+
return s.includes("network") || s.includes("fetch") || s.includes("connection") || e.name === "NetworkError" ? "NETWORK_ERROR" : s.includes("permission") || s.includes("denied") || s.includes("fullscreen") || e.name === "NotAllowedError" ? "PERMISSION_ERROR" : s.includes("decode") || s.includes("format") || s.includes("codec") || t?.type === "PLAY" ? "PLAYBACK_ERROR" : s.includes("timeout") || e.name === "TimeoutError" ? "TIMEOUT_ERROR" : s.includes("not supported") || s.includes("unsupported") || e.name === "NotSupportedError" ? "NOT_SUPPORTED_ERROR" : "UNKNOWN_ERROR";
|
|
940
|
+
}
|
|
941
|
+
// Check if an error/action combination is retryable
|
|
942
|
+
isRetryable(e, t) {
|
|
943
|
+
const s = this.config.retryableErrors.includes(e), n = !t || this.config.retryableActions.includes(t.type);
|
|
944
|
+
return s && n;
|
|
945
|
+
}
|
|
946
|
+
// Calculate retry delay with exponential backoff
|
|
947
|
+
calculateRetryDelay(e) {
|
|
948
|
+
if (!this.config.exponentialBackoff)
|
|
949
|
+
return this.config.baseDelay;
|
|
950
|
+
const t = this.config.baseDelay * Math.pow(2, e);
|
|
951
|
+
return Math.min(t, this.config.maxDelay);
|
|
952
|
+
}
|
|
953
|
+
// Handle an error with automatic retry logic
|
|
954
|
+
async handleError(e, t, s) {
|
|
955
|
+
const n = this.createMediaError(e, t, t?.retryCount || 0), a = `${t?.type}-${n.timestamp}`;
|
|
956
|
+
this.errorQueue.set(a, n), this.listeners.forEach((d) => d(n));
|
|
957
|
+
for (const d of this.recoveryStrategies)
|
|
958
|
+
if (d.canRecover(n))
|
|
959
|
+
try {
|
|
960
|
+
await d.recover(n);
|
|
961
|
+
break;
|
|
962
|
+
} catch (c) {
|
|
963
|
+
console.warn("Recovery strategy failed:", c);
|
|
964
|
+
}
|
|
965
|
+
if (n.retryable && n.retryCount < this.config.maxRetries && s && t) {
|
|
966
|
+
const d = this.calculateRetryDelay(n.retryCount);
|
|
967
|
+
console.log(`Retrying action ${t.type} in ${d}ms (attempt ${n.retryCount + 1}/${this.config.maxRetries})`), setTimeout(async () => {
|
|
968
|
+
try {
|
|
969
|
+
await s({
|
|
970
|
+
...t,
|
|
971
|
+
retryCount: n.retryCount + 1
|
|
972
|
+
}), this.errorQueue.delete(a);
|
|
973
|
+
} catch (c) {
|
|
974
|
+
await this.handleError(c, {
|
|
975
|
+
...t,
|
|
976
|
+
retryCount: n.retryCount + 1
|
|
977
|
+
}, s);
|
|
978
|
+
}
|
|
979
|
+
}, d);
|
|
980
|
+
}
|
|
981
|
+
return n;
|
|
982
|
+
}
|
|
983
|
+
// Subscribe to error events
|
|
984
|
+
subscribe(e) {
|
|
985
|
+
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
986
|
+
}
|
|
987
|
+
// Get current errors
|
|
988
|
+
getErrors() {
|
|
989
|
+
return Array.from(this.errorQueue.values());
|
|
990
|
+
}
|
|
991
|
+
// Clear specific error
|
|
992
|
+
clearError(e) {
|
|
993
|
+
this.errorQueue.delete(e);
|
|
994
|
+
}
|
|
995
|
+
// Clear all errors
|
|
996
|
+
clearAllErrors() {
|
|
997
|
+
this.errorQueue.clear();
|
|
998
|
+
}
|
|
999
|
+
// Get error statistics
|
|
1000
|
+
getErrorStats() {
|
|
1001
|
+
const e = this.getErrors(), t = Date.now(), s = 300 * 1e3, n = e.reduce((c, f) => (c[f.type] = (c[f.type] || 0) + 1, c), {}), a = e.filter((c) => c.retryable).length, d = e.filter((c) => t - c.timestamp < s);
|
|
1002
|
+
return {
|
|
1003
|
+
totalErrors: e.length,
|
|
1004
|
+
errorsByType: n,
|
|
1005
|
+
retryableErrors: a,
|
|
1006
|
+
recentErrors: d
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
function Ne(o = Q) {
|
|
1011
|
+
let e = { ...o };
|
|
1012
|
+
const t = /* @__PURE__ */ new Set(), s = (c) => (t.add(c), () => t.delete(c)), n = () => e, a = (c) => {
|
|
1013
|
+
const f = { ...e, ...c };
|
|
1014
|
+
JSON.stringify(f) !== JSON.stringify(e) && (e = f, t.forEach((g) => g()));
|
|
1015
|
+
};
|
|
1016
|
+
return { subscribe: s, getState: n, setState: a, dispatch: (c) => {
|
|
1017
|
+
switch (c.type) {
|
|
1018
|
+
case i.PLAY:
|
|
1019
|
+
a({ isPlaying: !0, error: null });
|
|
1020
|
+
break;
|
|
1021
|
+
case i.PAUSE:
|
|
1022
|
+
a({ isPlaying: !1 });
|
|
1023
|
+
break;
|
|
1024
|
+
case i.SEEK:
|
|
1025
|
+
a({ currentTime: c.detail });
|
|
1026
|
+
break;
|
|
1027
|
+
case i.SET_VOLUME:
|
|
1028
|
+
a({ volume: Math.max(0, Math.min(1, c.detail)) });
|
|
1029
|
+
break;
|
|
1030
|
+
case i.MUTE:
|
|
1031
|
+
a({ isMuted: !0 });
|
|
1032
|
+
break;
|
|
1033
|
+
case i.UNMUTE:
|
|
1034
|
+
a({ isMuted: !1 });
|
|
1035
|
+
break;
|
|
1036
|
+
case i.TOGGLE_MUTE:
|
|
1037
|
+
a({ isMuted: !e.isMuted });
|
|
1038
|
+
break;
|
|
1039
|
+
case i.SET_DURATION:
|
|
1040
|
+
a({ duration: c.detail });
|
|
1041
|
+
break;
|
|
1042
|
+
case i.SET_CURRENT_TIME:
|
|
1043
|
+
a({ currentTime: c.detail });
|
|
1044
|
+
break;
|
|
1045
|
+
case i.SET_BUFFERED:
|
|
1046
|
+
a({ buffered: c.detail });
|
|
1047
|
+
break;
|
|
1048
|
+
case i.SET_LOADING:
|
|
1049
|
+
a({ isLoading: c.detail });
|
|
1050
|
+
break;
|
|
1051
|
+
case i.SET_ERROR:
|
|
1052
|
+
a({ error: c.detail, isLoading: !1 });
|
|
1053
|
+
break;
|
|
1054
|
+
case i.ENTER_FULLSCREEN:
|
|
1055
|
+
a({ isFullscreen: !0 });
|
|
1056
|
+
break;
|
|
1057
|
+
case i.EXIT_FULLSCREEN:
|
|
1058
|
+
a({ isFullscreen: !1 });
|
|
1059
|
+
break;
|
|
1060
|
+
case i.ENTER_PIP:
|
|
1061
|
+
a({ isPictureInPicture: !0 });
|
|
1062
|
+
break;
|
|
1063
|
+
case i.EXIT_PIP:
|
|
1064
|
+
a({ isPictureInPicture: !1 });
|
|
1065
|
+
break;
|
|
1066
|
+
case i.SET_PLAYBACK_RATE:
|
|
1067
|
+
a({ playbackRate: c.detail });
|
|
1068
|
+
break;
|
|
1069
|
+
case i.SET_SUBTITLE_TRACK:
|
|
1070
|
+
a({ selectedSubtitleTrack: c.detail });
|
|
1071
|
+
break;
|
|
1072
|
+
case i.SET_RENDITION:
|
|
1073
|
+
a({ selectedRendition: c.detail });
|
|
1074
|
+
break;
|
|
1075
|
+
case i.TOGGLE_SUBTITLES:
|
|
1076
|
+
a({ subtitlesShowing: !e.subtitlesShowing });
|
|
1077
|
+
break;
|
|
1078
|
+
case i.PREVIEW_TIME:
|
|
1079
|
+
a({ previewTime: c.detail });
|
|
1080
|
+
break;
|
|
1081
|
+
case i.CLEAR_PREVIEW:
|
|
1082
|
+
a({ previewTime: null, previewImage: null, previewCoords: null });
|
|
1083
|
+
break;
|
|
1084
|
+
default:
|
|
1085
|
+
console.warn(`Unknown media action type: ${c.type}`);
|
|
1086
|
+
}
|
|
1087
|
+
} };
|
|
1088
|
+
}
|
|
1089
|
+
function De({
|
|
1090
|
+
children: o,
|
|
1091
|
+
mediaId: e = "media-player",
|
|
1092
|
+
labelId: t = "media-player-label",
|
|
1093
|
+
descriptionId: s = "media-player-description",
|
|
1094
|
+
dir: n = "ltr",
|
|
1095
|
+
portalContainer: a,
|
|
1096
|
+
tooltipDelayDuration: d = 700,
|
|
1097
|
+
tooltipSideOffset: c = 4,
|
|
1098
|
+
disabled: f = !1,
|
|
1099
|
+
isVideo: g = !0,
|
|
1100
|
+
withoutTooltip: _ = !1,
|
|
1101
|
+
initialState: F = {},
|
|
1102
|
+
// React 19 enhancements
|
|
1103
|
+
useEnhancedStore: p = !0,
|
|
1104
|
+
persistenceConfig: A,
|
|
1105
|
+
retryConfig: D,
|
|
1106
|
+
enableOptimisticUpdates: M = !0,
|
|
1107
|
+
enableErrorRecovery: C = !0,
|
|
1108
|
+
onStateRehydrated: O
|
|
1109
|
+
}) {
|
|
1110
|
+
const j = S.useRef(null), Y = S.useRef(null), N = S.useMemo(() => {
|
|
1111
|
+
const w = { ...Q, ...F };
|
|
1112
|
+
return p ? me(w, A) : Ne(w);
|
|
1113
|
+
}, [p, A]), k = S.useMemo(() => C && p ? new Oe(D) : null, [C, p, D]), h = p ? be(
|
|
1114
|
+
N.getState(),
|
|
1115
|
+
e,
|
|
1116
|
+
A
|
|
1117
|
+
) : null;
|
|
1118
|
+
S.useEffect(() => {
|
|
1119
|
+
if (h?.isRehydrated && O) {
|
|
1120
|
+
const w = N.getState();
|
|
1121
|
+
O(w);
|
|
1122
|
+
}
|
|
1123
|
+
}, [h?.isRehydrated, O, N]);
|
|
1124
|
+
const B = S.useMemo(
|
|
1125
|
+
() => ({
|
|
1126
|
+
mediaId: e,
|
|
1127
|
+
labelId: t,
|
|
1128
|
+
descriptionId: s,
|
|
1129
|
+
dir: n,
|
|
1130
|
+
rootRef: j,
|
|
1131
|
+
mediaRef: Y,
|
|
1132
|
+
portalContainer: a,
|
|
1133
|
+
tooltipDelayDuration: d,
|
|
1134
|
+
tooltipSideOffset: c,
|
|
1135
|
+
disabled: f,
|
|
1136
|
+
isVideo: g,
|
|
1137
|
+
withoutTooltip: _,
|
|
1138
|
+
// React 19 enhancements
|
|
1139
|
+
errorHandler: k,
|
|
1140
|
+
isEnhanced: p,
|
|
1141
|
+
isRehydrated: h?.isRehydrated
|
|
1142
|
+
}),
|
|
1143
|
+
[
|
|
1144
|
+
e,
|
|
1145
|
+
t,
|
|
1146
|
+
s,
|
|
1147
|
+
n,
|
|
1148
|
+
a,
|
|
1149
|
+
d,
|
|
1150
|
+
c,
|
|
1151
|
+
f,
|
|
1152
|
+
g,
|
|
1153
|
+
_,
|
|
1154
|
+
k,
|
|
1155
|
+
p,
|
|
1156
|
+
h?.isRehydrated
|
|
1157
|
+
]
|
|
1158
|
+
);
|
|
1159
|
+
return /* @__PURE__ */ ae.jsx(oe.Provider, { value: B, children: /* @__PURE__ */ ae.jsx(ie.Provider, { value: N, children: o }) });
|
|
1160
|
+
}
|
|
1161
|
+
export {
|
|
1162
|
+
i as M,
|
|
1163
|
+
ke as a,
|
|
1164
|
+
Ce as b,
|
|
1165
|
+
ve as c,
|
|
1166
|
+
Se as d,
|
|
1167
|
+
Me as e,
|
|
1168
|
+
De as f,
|
|
1169
|
+
xe as g,
|
|
1170
|
+
me as h,
|
|
1171
|
+
oe as i,
|
|
1172
|
+
ae as j,
|
|
1173
|
+
ie as k,
|
|
1174
|
+
$ as l,
|
|
1175
|
+
Fe as m,
|
|
1176
|
+
Q as n,
|
|
1177
|
+
Re as u
|
|
1178
|
+
};
|
|
1179
|
+
//# sourceMappingURL=context-Af84FynT.js.map
|