@therealtinhtute/baroiplayer 1.1.0 → 1.2.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 +1 -2
- package/dist/context/media.js +1 -2
- package/dist/context/media.mjs +3 -15
- package/dist/context/store.js +1 -2
- package/dist/context/store.mjs +3 -5
- package/dist/context-Bzd5QCKM.cjs +7 -0
- package/dist/context-Bzd5QCKM.cjs.map +1 -0
- package/dist/context-DD_SH4tT.js +1053 -0
- package/dist/context-DD_SH4tT.js.map +1 -0
- package/dist/core-events-BRnLMB7s.cjs +2 -0
- package/dist/core-events-BRnLMB7s.cjs.map +1 -0
- package/dist/core-events-v_mKdj5p.js +417 -0
- package/dist/core-events-v_mKdj5p.js.map +1 -0
- package/dist/core-plugins-CMBv-yVh.cjs +2 -0
- package/dist/core-plugins-CMBv-yVh.cjs.map +1 -0
- package/dist/core-plugins-CqCxLkbd.js +754 -0
- package/dist/core-plugins-CqCxLkbd.js.map +1 -0
- package/dist/core.js +7 -29
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +947 -1220
- package/dist/core.mjs.map +1 -1
- package/dist/enhanced-components-BwjBqSA1.js +2858 -0
- package/dist/enhanced-components-BwjBqSA1.js.map +1 -0
- package/dist/enhanced-components-C-ka-XLp.cjs +2 -0
- package/dist/enhanced-components-C-ka-XLp.cjs.map +1 -0
- package/dist/hooks-B-IIWPJr.js +1842 -0
- package/dist/hooks-B-IIWPJr.js.map +1 -0
- package/dist/hooks-DcHzmBwA.cjs +4 -0
- package/dist/hooks-DcHzmBwA.cjs.map +1 -0
- package/dist/index.js +27 -97
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5613 -6210
- package/dist/index.mjs.map +1 -1
- package/dist/minimal-components-BYsMQde5.js +1610 -0
- package/dist/minimal-components-BYsMQde5.js.map +1 -0
- package/dist/minimal-components-CsxQbDp7.cjs +2 -0
- package/dist/minimal-components-CsxQbDp7.cjs.map +1 -0
- package/dist/performance-monitor-DCSijLJg.js +312 -0
- package/dist/performance-monitor-DCSijLJg.js.map +1 -0
- package/dist/performance-monitor-wNFKmqMr.cjs +2 -0
- package/dist/performance-monitor-wNFKmqMr.cjs.map +1 -0
- package/dist/rolldown-runtime-BmowowmI.js +14 -0
- package/dist/rolldown-runtime-mLOUI7ql.cjs +1 -0
- package/dist/utils-D2gQ7c2R.js +64 -0
- package/dist/utils-D2gQ7c2R.js.map +1 -0
- package/dist/utils-DJaAwiZ9.cjs +2 -0
- package/dist/utils-DJaAwiZ9.cjs.map +1 -0
- package/dist/utils.js +1 -2
- package/dist/utils.mjs +3 -11
- package/package.json +28 -22
- package/src/components/AnimateLoading.tsx +14 -10
- package/src/components/accessibility/keyboard-help-overlay.tsx +2 -0
- package/src/components/enhanced/debug-panel.tsx +1 -1
- package/src/components/enhanced/enhanced-media-player.tsx +68 -25
- package/src/components/examples/loading-states-demo.tsx +1 -2
- package/src/components/examples/react-19-demo.tsx +6 -10
- package/src/components/examples/volume-orientation-demo.tsx +1 -2
- package/src/components/legacy.tsx +6 -6
- package/src/components/media-player-video.tsx +5 -12
- package/src/components/media-player.tsx +2 -2
- package/src/components/ui/blur-poster.tsx +18 -15
- package/src/components/ui/enhanced-seek-bar.tsx +2 -2
- package/src/components/ui/media-resource-preloader.tsx +21 -23
- package/src/components/unified/base-media-player.tsx +22 -10
- package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +58 -38
- package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +6 -6
- package/src/components/variants/minimal/components/VideoElement.tsx +3 -1
- package/src/core/optimization/bundle-optimizer.tsx +26 -27
- package/src/core/performance/media-loading-optimizer.ts +2 -1
- package/src/core/plugins/__tests__/registry.test.ts +1 -1
- package/src/core/plugins/enhanced-plugin-system.ts +26 -8
- package/src/core/plugins/registry.ts +319 -92
- package/src/core/plugins/types.ts +21 -3
- package/src/core/providers/enhanced-hls-provider.ts +11 -40
- package/src/core/providers/lazy-provider.tsx +5 -42
- package/src/features/media-session/media-session-manager.ts +4 -26
- package/src/features/picture-in-picture/pip-manager.ts +2 -2
- package/src/features/playlist/playlist-manager.ts +26 -18
- package/src/features/subtitles/subtitle-manager.ts +1 -1
- package/src/features/subtitles/subtitle-parser.ts +19 -16
- package/src/features/thumbnails/thumbnail-generator.ts +12 -5
- package/src/hooks/__tests__/currentTime-fix.test.ts +149 -0
- package/src/hooks/accessibility/use-accessibility-preferences.ts +1 -1
- package/src/hooks/accessibility/use-focus-management.ts +2 -2
- package/src/hooks/accessibility/use-keyboard-shortcuts.ts +2 -2
- package/src/hooks/accessibility/use-screen-reader.ts +1 -1
- package/src/hooks/core/index.ts +1 -1
- package/src/hooks/use-buffer-health.ts +1 -1
- package/src/hooks/use-enhanced-media-player.ts +107 -9
- package/src/hooks/use-focus-trap.tsx +2 -2
- package/src/hooks/use-intelligent-preloading.ts +23 -3
- package/src/hooks/use-keyboard-shortcuts.ts +2 -2
- package/src/hooks/use-media-player.ts +74 -43
- package/src/hooks/use-memory-optimization.ts +15 -15
- package/src/hooks/use-smart-preload.ts +1 -2
- package/src/hooks/useKeyboardShortcuts.ts +34 -2
- package/src/hooks/useScreenshot.ts +60 -44
- package/src/hooks/useVideoPlayer.ts +50 -4
- package/src/index-legacy.ts +3 -5
- package/src/test/accessibility-utils.ts +7 -7
- package/src/test/media-mocks.ts +41 -28
- package/src/test/setup.ts +22 -4
- package/src/types/assets.d.ts +29 -0
- package/src/types/index.ts +13 -0
- package/dist/context/media.js.map +0 -1
- package/dist/context/media.mjs.map +0 -1
- package/dist/context/store.js.map +0 -1
- package/dist/context/store.mjs.map +0 -1
- package/dist/context-BYwDoSRX.js +0 -1172
- package/dist/context-BYwDoSRX.js.map +0 -1
- package/dist/context-eNS62_ac.cjs +0 -23
- package/dist/context-eNS62_ac.cjs.map +0 -1
- package/dist/core-events-B1iM2F46.cjs +0 -2
- package/dist/core-events-B1iM2F46.cjs.map +0 -1
- package/dist/core-events-DunPHKRE.js +0 -484
- package/dist/core-events-DunPHKRE.js.map +0 -1
- package/dist/core-plugins-CROGvQUy.js +0 -686
- package/dist/core-plugins-CROGvQUy.js.map +0 -1
- package/dist/core-plugins-DtsHBOtF.cjs +0 -2
- package/dist/core-plugins-DtsHBOtF.cjs.map +0 -1
- package/dist/enhanced-components-DUw2KrmQ.js +0 -1142
- package/dist/enhanced-components-DUw2KrmQ.js.map +0 -1
- package/dist/enhanced-components-DXBCHU0v.cjs +0 -2
- package/dist/enhanced-components-DXBCHU0v.cjs.map +0 -1
- package/dist/hooks-BW-JjVgP.cjs +0 -4
- package/dist/hooks-BW-JjVgP.cjs.map +0 -1
- package/dist/hooks-CyX6De5M.js +0 -1693
- package/dist/hooks-CyX6De5M.js.map +0 -1
- package/dist/minimal-components-Bdcpxav5.cjs +0 -2
- package/dist/minimal-components-Bdcpxav5.cjs.map +0 -1
- package/dist/minimal-components-DlRK7Qu_.js +0 -1927
- package/dist/minimal-components-DlRK7Qu_.js.map +0 -1
- package/dist/performance-monitor-C5k6FDXw.js +0 -301
- package/dist/performance-monitor-C5k6FDXw.js.map +0 -1
- package/dist/performance-monitor-lJmuUjQQ.cjs +0 -2
- package/dist/performance-monitor-lJmuUjQQ.cjs.map +0 -1
- package/dist/utils-CFOue_9K.cjs +0 -9
- package/dist/utils-CFOue_9K.cjs.map +0 -1
- package/dist/utils-Dzpl2ArK.js +0 -2844
- package/dist/utils-Dzpl2ArK.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/dist/utils.mjs.map +0 -1
|
@@ -0,0 +1,1053 @@
|
|
|
1
|
+
import { r as e, t } from "./rolldown-runtime-BmowowmI.js";
|
|
2
|
+
import n from "react";
|
|
3
|
+
//#region src/context/media-context.tsx
|
|
4
|
+
var r = {
|
|
5
|
+
PLAY: "PLAY",
|
|
6
|
+
PAUSE: "PAUSE",
|
|
7
|
+
SEEK: "SEEK",
|
|
8
|
+
SET_VOLUME: "SET_VOLUME",
|
|
9
|
+
MUTE: "MUTE",
|
|
10
|
+
UNMUTE: "UNMUTE",
|
|
11
|
+
TOGGLE_MUTE: "TOGGLE_MUTE",
|
|
12
|
+
SET_DURATION: "SET_DURATION",
|
|
13
|
+
SET_CURRENT_TIME: "SET_CURRENT_TIME",
|
|
14
|
+
SET_BUFFERED: "SET_BUFFERED",
|
|
15
|
+
SET_LOADING: "SET_LOADING",
|
|
16
|
+
SET_ERROR: "SET_ERROR",
|
|
17
|
+
ENTER_FULLSCREEN: "ENTER_FULLSCREEN",
|
|
18
|
+
EXIT_FULLSCREEN: "EXIT_FULLSCREEN",
|
|
19
|
+
ENTER_PIP: "ENTER_PIP",
|
|
20
|
+
EXIT_PIP: "EXIT_PIP",
|
|
21
|
+
SET_PLAYBACK_RATE: "SET_PLAYBACK_RATE",
|
|
22
|
+
SET_SUBTITLE_TRACK: "SET_SUBTITLE_TRACK",
|
|
23
|
+
SET_RENDITION: "SET_RENDITION",
|
|
24
|
+
TOGGLE_SUBTITLES: "TOGGLE_SUBTITLES",
|
|
25
|
+
PREVIEW_TIME: "PREVIEW_TIME",
|
|
26
|
+
CLEAR_PREVIEW: "CLEAR_PREVIEW",
|
|
27
|
+
SET_BUFFERING: "SET_BUFFERING",
|
|
28
|
+
SET_QUALITY_LEVEL: "SET_QUALITY_LEVEL",
|
|
29
|
+
SET_BANDWIDTH_ESTIMATE: "SET_BANDWIDTH_ESTIMATE",
|
|
30
|
+
SET_ACTIVE_TEXT_TRACKS: "SET_ACTIVE_TEXT_TRACKS"
|
|
31
|
+
}, i = n.createContext(null);
|
|
32
|
+
function a() {
|
|
33
|
+
let e = n.useContext(i);
|
|
34
|
+
if (!e) throw Error("useMediaContext must be used within a MediaPlayer");
|
|
35
|
+
return e;
|
|
36
|
+
}
|
|
37
|
+
var o = n.createContext(null);
|
|
38
|
+
function s() {
|
|
39
|
+
let e = n.useContext(o);
|
|
40
|
+
if (!e) throw Error("useMediaStore must be used within a MediaPlayer");
|
|
41
|
+
return e;
|
|
42
|
+
}
|
|
43
|
+
function c(e, t) {
|
|
44
|
+
if (Object.is(e, t)) return !0;
|
|
45
|
+
if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
|
|
46
|
+
let n = Object.keys(e), r = Object.keys(t);
|
|
47
|
+
if (n.length !== r.length) return !1;
|
|
48
|
+
for (let i of n) if (!r.includes(i) || !Object.is(e[i], t[i])) return !1;
|
|
49
|
+
return !0;
|
|
50
|
+
}
|
|
51
|
+
function l(e) {
|
|
52
|
+
let t = s(), r = () => e(t.getState()), i = n.useRef(void 0), a = n.useCallback(() => {
|
|
53
|
+
let n = e(t.getState());
|
|
54
|
+
return i.current = n, n;
|
|
55
|
+
}, [e]), o = n.useSyncExternalStore(t.subscribe, r, a);
|
|
56
|
+
return n.useEffect(() => {
|
|
57
|
+
let e = i.current;
|
|
58
|
+
e !== void 0 && c(e, o) || (i.current = o);
|
|
59
|
+
}, [o]), o;
|
|
60
|
+
}
|
|
61
|
+
function u() {
|
|
62
|
+
return s().dispatch;
|
|
63
|
+
}
|
|
64
|
+
function d(e) {
|
|
65
|
+
let t = s(), r = "getOptimisticState" in t, i = () => e(r ? t.getOptimisticState() : t.getState());
|
|
66
|
+
return n.useSyncExternalStore(t.subscribe, i, i);
|
|
67
|
+
}
|
|
68
|
+
function f() {
|
|
69
|
+
let e = s(), t = a(), n = "getOptimisticState" in e;
|
|
70
|
+
return {
|
|
71
|
+
isEnhanced: n,
|
|
72
|
+
errorHandler: "errorHandler" in t ? t.errorHandler : null,
|
|
73
|
+
isRehydrated: "isRehydrated" in t ? t.isRehydrated : !0,
|
|
74
|
+
actionsState: n ? e.getActionState() : null
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
var p = {
|
|
78
|
+
isPlaying: !1,
|
|
79
|
+
currentTime: 0,
|
|
80
|
+
duration: 0,
|
|
81
|
+
buffered: null,
|
|
82
|
+
isLoading: !1,
|
|
83
|
+
isBuffering: !1,
|
|
84
|
+
error: null,
|
|
85
|
+
volume: 1,
|
|
86
|
+
isMuted: !1,
|
|
87
|
+
isFullscreen: !1,
|
|
88
|
+
isPictureInPicture: !1,
|
|
89
|
+
playbackRate: 1,
|
|
90
|
+
subtitlesShowing: !1,
|
|
91
|
+
selectedSubtitleTrack: null,
|
|
92
|
+
selectedRendition: null,
|
|
93
|
+
qualityLevel: -1,
|
|
94
|
+
bandwidthEstimate: 0,
|
|
95
|
+
activeTextTracks: [],
|
|
96
|
+
previewTime: null,
|
|
97
|
+
previewImage: null,
|
|
98
|
+
previewCoords: null,
|
|
99
|
+
subtitlesList: [],
|
|
100
|
+
renditionList: []
|
|
101
|
+
}, m = /* @__PURE__ */ t(((e) => {
|
|
102
|
+
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
103
|
+
function r(e, n, r) {
|
|
104
|
+
var i = null;
|
|
105
|
+
if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
|
|
106
|
+
else r = n;
|
|
107
|
+
return n = r.ref, {
|
|
108
|
+
$$typeof: t,
|
|
109
|
+
type: e,
|
|
110
|
+
key: i,
|
|
111
|
+
ref: n === void 0 ? null : n,
|
|
112
|
+
props: r
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
116
|
+
})), h = /* @__PURE__ */ t(((t) => {
|
|
117
|
+
process.env.NODE_ENV !== "production" && (function() {
|
|
118
|
+
function n(e) {
|
|
119
|
+
if (e == null) return null;
|
|
120
|
+
if (typeof e == "function") return e.$$typeof === k ? null : e.displayName || e.name || null;
|
|
121
|
+
if (typeof e == "string") return e;
|
|
122
|
+
switch (e) {
|
|
123
|
+
case v: return "Fragment";
|
|
124
|
+
case b: return "Profiler";
|
|
125
|
+
case y: return "StrictMode";
|
|
126
|
+
case w: return "Suspense";
|
|
127
|
+
case T: return "SuspenseList";
|
|
128
|
+
case O: return "Activity";
|
|
129
|
+
}
|
|
130
|
+
if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
|
|
131
|
+
case _: return "Portal";
|
|
132
|
+
case S: return e.displayName || "Context";
|
|
133
|
+
case x: return (e._context.displayName || "Context") + ".Consumer";
|
|
134
|
+
case C:
|
|
135
|
+
var t = e.render;
|
|
136
|
+
return e = e.displayName, e || (e = t.displayName || t.name || "", e = e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
|
|
137
|
+
case E: return t = e.displayName || null, t === null ? n(e.type) || "Memo" : t;
|
|
138
|
+
case D:
|
|
139
|
+
t = e._payload, e = e._init;
|
|
140
|
+
try {
|
|
141
|
+
return n(e(t));
|
|
142
|
+
} catch {}
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
function r(e) {
|
|
147
|
+
return "" + e;
|
|
148
|
+
}
|
|
149
|
+
function i(e) {
|
|
150
|
+
try {
|
|
151
|
+
r(e);
|
|
152
|
+
var t = !1;
|
|
153
|
+
} catch {
|
|
154
|
+
t = !0;
|
|
155
|
+
}
|
|
156
|
+
if (t) return t = console, t.error.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object"), r(e);
|
|
157
|
+
}
|
|
158
|
+
function a(e) {
|
|
159
|
+
if (e === v) return "<>";
|
|
160
|
+
if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
|
|
161
|
+
try {
|
|
162
|
+
var t = n(e);
|
|
163
|
+
return t ? "<" + t + ">" : "<...>";
|
|
164
|
+
} catch {
|
|
165
|
+
return "<...>";
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function o() {
|
|
169
|
+
var e = A.A;
|
|
170
|
+
return e === null ? null : e.getOwner();
|
|
171
|
+
}
|
|
172
|
+
function s() {
|
|
173
|
+
return Error("react-stack-top-frame");
|
|
174
|
+
}
|
|
175
|
+
function c(e) {
|
|
176
|
+
if (j.call(e, "key")) {
|
|
177
|
+
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
178
|
+
if (t && t.isReactWarning) return !1;
|
|
179
|
+
}
|
|
180
|
+
return e.key !== void 0;
|
|
181
|
+
}
|
|
182
|
+
function l(e, t) {
|
|
183
|
+
function n() {
|
|
184
|
+
P || (P = !0, console.error("%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)", t));
|
|
185
|
+
}
|
|
186
|
+
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
187
|
+
get: n,
|
|
188
|
+
configurable: !0
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function u() {
|
|
192
|
+
var e = n(this.type);
|
|
193
|
+
return F[e] || (F[e] = !0, console.error("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.")), e = this.props.ref, e === void 0 ? null : e;
|
|
194
|
+
}
|
|
195
|
+
function d(e, t, n, r, i, a) {
|
|
196
|
+
var o = n.ref;
|
|
197
|
+
return e = {
|
|
198
|
+
$$typeof: g,
|
|
199
|
+
type: e,
|
|
200
|
+
key: t,
|
|
201
|
+
props: n,
|
|
202
|
+
_owner: r
|
|
203
|
+
}, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
|
|
204
|
+
enumerable: !1,
|
|
205
|
+
value: null
|
|
206
|
+
}) : Object.defineProperty(e, "ref", {
|
|
207
|
+
enumerable: !1,
|
|
208
|
+
get: u
|
|
209
|
+
}), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
210
|
+
configurable: !1,
|
|
211
|
+
enumerable: !1,
|
|
212
|
+
writable: !0,
|
|
213
|
+
value: 0
|
|
214
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
215
|
+
configurable: !1,
|
|
216
|
+
enumerable: !1,
|
|
217
|
+
writable: !0,
|
|
218
|
+
value: null
|
|
219
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
220
|
+
configurable: !1,
|
|
221
|
+
enumerable: !1,
|
|
222
|
+
writable: !0,
|
|
223
|
+
value: i
|
|
224
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
225
|
+
configurable: !1,
|
|
226
|
+
enumerable: !1,
|
|
227
|
+
writable: !0,
|
|
228
|
+
value: a
|
|
229
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
230
|
+
}
|
|
231
|
+
function f(e, t, r, a, s, u) {
|
|
232
|
+
var f = t.children;
|
|
233
|
+
if (f !== void 0) if (a) if (M(f)) {
|
|
234
|
+
for (a = 0; a < f.length; a++) p(f[a]);
|
|
235
|
+
Object.freeze && Object.freeze(f);
|
|
236
|
+
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
237
|
+
else p(f);
|
|
238
|
+
if (j.call(t, "key")) {
|
|
239
|
+
f = n(e);
|
|
240
|
+
var m = Object.keys(t).filter(function(e) {
|
|
241
|
+
return e !== "key";
|
|
242
|
+
});
|
|
243
|
+
a = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + a] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", a, f, m, f), R[f + a] = !0);
|
|
244
|
+
}
|
|
245
|
+
if (f = null, r !== void 0 && (i(r), f = "" + r), c(t) && (i(t.key), f = "" + t.key), "key" in t) for (var h in r = {}, t) h !== "key" && (r[h] = t[h]);
|
|
246
|
+
else r = t;
|
|
247
|
+
return f && l(r, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, r, o(), s, u);
|
|
248
|
+
}
|
|
249
|
+
function p(e) {
|
|
250
|
+
m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
251
|
+
}
|
|
252
|
+
function m(e) {
|
|
253
|
+
return typeof e == "object" && !!e && e.$$typeof === g;
|
|
254
|
+
}
|
|
255
|
+
var h = e("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
|
|
256
|
+
return null;
|
|
257
|
+
};
|
|
258
|
+
h = { react_stack_bottom_frame: function(e) {
|
|
259
|
+
return e();
|
|
260
|
+
} };
|
|
261
|
+
var P, F = {}, I = h.react_stack_bottom_frame.bind(h, s)(), L = N(a(s)), R = {};
|
|
262
|
+
t.Fragment = v, t.jsx = function(e, t, n) {
|
|
263
|
+
var r = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(a(e)) : L);
|
|
265
|
+
}, t.jsxs = function(e, t, n) {
|
|
266
|
+
var r = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
267
|
+
return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(a(e)) : L);
|
|
268
|
+
};
|
|
269
|
+
})();
|
|
270
|
+
})), g = /* @__PURE__ */ t(((e, t) => {
|
|
271
|
+
process.env.NODE_ENV === "production" ? t.exports = m() : t.exports = h();
|
|
272
|
+
}));
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
|
|
275
|
+
function _(e) {
|
|
276
|
+
"@babel/helpers - typeof";
|
|
277
|
+
return _ = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
278
|
+
return typeof e;
|
|
279
|
+
} : function(e) {
|
|
280
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
281
|
+
}, _(e);
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
|
|
285
|
+
function v(e, t) {
|
|
286
|
+
if (_(e) != "object" || !e) return e;
|
|
287
|
+
var n = e[Symbol.toPrimitive];
|
|
288
|
+
if (n !== void 0) {
|
|
289
|
+
var r = n.call(e, t || "default");
|
|
290
|
+
if (_(r) != "object") return r;
|
|
291
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
292
|
+
}
|
|
293
|
+
return (t === "string" ? String : Number)(e);
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
|
|
297
|
+
function y(e) {
|
|
298
|
+
var t = v(e, "string");
|
|
299
|
+
return _(t) == "symbol" ? t : t + "";
|
|
300
|
+
}
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
|
|
303
|
+
function b(e, t, n) {
|
|
304
|
+
return (t = y(t)) in e ? Object.defineProperty(e, t, {
|
|
305
|
+
value: n,
|
|
306
|
+
enumerable: !0,
|
|
307
|
+
configurable: !0,
|
|
308
|
+
writable: !0
|
|
309
|
+
}) : e[t] = n, e;
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/context/error-handling.ts
|
|
313
|
+
var x = {
|
|
314
|
+
maxRetries: 3,
|
|
315
|
+
baseDelay: 1e3,
|
|
316
|
+
maxDelay: 1e4,
|
|
317
|
+
exponentialBackoff: !0,
|
|
318
|
+
retryableErrors: ["NETWORK_ERROR", "TIMEOUT_ERROR"],
|
|
319
|
+
retryableActions: [
|
|
320
|
+
"PLAY",
|
|
321
|
+
"PAUSE",
|
|
322
|
+
"SEEK",
|
|
323
|
+
"SET_VOLUME",
|
|
324
|
+
"ENTER_FULLSCREEN",
|
|
325
|
+
"EXIT_FULLSCREEN"
|
|
326
|
+
]
|
|
327
|
+
}, S = class {
|
|
328
|
+
canRecover(e) {
|
|
329
|
+
return e.type === "NETWORK_ERROR" && e.retryCount < 3;
|
|
330
|
+
}
|
|
331
|
+
async recover(e) {
|
|
332
|
+
navigator.onLine === !1 && await new Promise((e) => {
|
|
333
|
+
let t = () => {
|
|
334
|
+
window.removeEventListener("online", t), e(void 0);
|
|
335
|
+
};
|
|
336
|
+
window.addEventListener("online", t);
|
|
337
|
+
}), await new Promise((e) => setTimeout(e, 2e3));
|
|
338
|
+
}
|
|
339
|
+
}, C = class {
|
|
340
|
+
canRecover(e) {
|
|
341
|
+
return e.type === "PLAYBACK_ERROR" && e.retryCount < 2;
|
|
342
|
+
}
|
|
343
|
+
async recover(e) {
|
|
344
|
+
let t = document.querySelector("video, audio");
|
|
345
|
+
t && (t.load(), await new Promise((e) => {
|
|
346
|
+
let n = () => {
|
|
347
|
+
t.removeEventListener("canplay", n), e(void 0);
|
|
348
|
+
};
|
|
349
|
+
t.addEventListener("canplay", n);
|
|
350
|
+
}));
|
|
351
|
+
}
|
|
352
|
+
}, w = class {
|
|
353
|
+
canRecover(e) {
|
|
354
|
+
return e.type === "PERMISSION_ERROR" && e.action?.type === "ENTER_FULLSCREEN";
|
|
355
|
+
}
|
|
356
|
+
async recover(e) {
|
|
357
|
+
console.warn("Fullscreen requires user interaction");
|
|
358
|
+
}
|
|
359
|
+
}, T = class {
|
|
360
|
+
constructor(e = {}, t = []) {
|
|
361
|
+
b(this, "config", void 0), b(this, "recoveryStrategies", void 0), b(this, "errorQueue", /* @__PURE__ */ new Map()), b(this, "listeners", /* @__PURE__ */ new Set()), this.config = {
|
|
362
|
+
...x,
|
|
363
|
+
...e
|
|
364
|
+
}, this.recoveryStrategies = [
|
|
365
|
+
new S(),
|
|
366
|
+
new C(),
|
|
367
|
+
new w(),
|
|
368
|
+
...t
|
|
369
|
+
];
|
|
370
|
+
}
|
|
371
|
+
createMediaError(e, t, n = 0) {
|
|
372
|
+
let r = Date.now();
|
|
373
|
+
if (e instanceof Error) {
|
|
374
|
+
let i = this.categorizeError(e, t);
|
|
375
|
+
return {
|
|
376
|
+
type: i,
|
|
377
|
+
message: e.message,
|
|
378
|
+
action: t,
|
|
379
|
+
timestamp: r,
|
|
380
|
+
retryable: this.isRetryable(i, t),
|
|
381
|
+
retryCount: n,
|
|
382
|
+
originalError: e
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
return {
|
|
386
|
+
type: "UNKNOWN_ERROR",
|
|
387
|
+
message: typeof e == "string" ? e : "Unknown error occurred",
|
|
388
|
+
action: t,
|
|
389
|
+
timestamp: r,
|
|
390
|
+
retryable: this.isRetryable("UNKNOWN_ERROR", t),
|
|
391
|
+
retryCount: n
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
categorizeError(e, t) {
|
|
395
|
+
let n = e.message.toLowerCase();
|
|
396
|
+
return n.includes("network") || n.includes("fetch") || n.includes("connection") || e.name === "NetworkError" ? "NETWORK_ERROR" : n.includes("permission") || n.includes("denied") || n.includes("fullscreen") || e.name === "NotAllowedError" ? "PERMISSION_ERROR" : n.includes("decode") || n.includes("format") || n.includes("codec") || t?.type === "PLAY" ? "PLAYBACK_ERROR" : n.includes("timeout") || e.name === "TimeoutError" ? "TIMEOUT_ERROR" : n.includes("not supported") || n.includes("unsupported") || e.name === "NotSupportedError" ? "NOT_SUPPORTED_ERROR" : "UNKNOWN_ERROR";
|
|
397
|
+
}
|
|
398
|
+
isRetryable(e, t) {
|
|
399
|
+
let n = this.config.retryableErrors.includes(e), r = !t || this.config.retryableActions.includes(t.type);
|
|
400
|
+
return n && r;
|
|
401
|
+
}
|
|
402
|
+
calculateRetryDelay(e) {
|
|
403
|
+
if (!this.config.exponentialBackoff) return this.config.baseDelay;
|
|
404
|
+
let t = this.config.baseDelay * 2 ** e;
|
|
405
|
+
return Math.min(t, this.config.maxDelay);
|
|
406
|
+
}
|
|
407
|
+
async handleError(e, t, n) {
|
|
408
|
+
let r = this.createMediaError(e, t, t?.retryCount || 0), i = `${t?.type}-${r.timestamp}`;
|
|
409
|
+
this.errorQueue.set(i, r), this.listeners.forEach((e) => e(r));
|
|
410
|
+
for (let e of this.recoveryStrategies) if (e.canRecover(r)) try {
|
|
411
|
+
await e.recover(r);
|
|
412
|
+
break;
|
|
413
|
+
} catch (e) {
|
|
414
|
+
console.warn("Recovery strategy failed:", e);
|
|
415
|
+
}
|
|
416
|
+
if (r.retryable && r.retryCount < this.config.maxRetries && n && t) {
|
|
417
|
+
let e = this.calculateRetryDelay(r.retryCount);
|
|
418
|
+
console.log(`Retrying action ${t.type} in ${e}ms (attempt ${r.retryCount + 1}/${this.config.maxRetries})`), setTimeout(async () => {
|
|
419
|
+
try {
|
|
420
|
+
await n({
|
|
421
|
+
...t,
|
|
422
|
+
retryCount: r.retryCount + 1
|
|
423
|
+
}), this.errorQueue.delete(i);
|
|
424
|
+
} catch (e) {
|
|
425
|
+
await this.handleError(e, {
|
|
426
|
+
...t,
|
|
427
|
+
retryCount: r.retryCount + 1
|
|
428
|
+
}, n);
|
|
429
|
+
}
|
|
430
|
+
}, e);
|
|
431
|
+
}
|
|
432
|
+
return r;
|
|
433
|
+
}
|
|
434
|
+
subscribe(e) {
|
|
435
|
+
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
436
|
+
}
|
|
437
|
+
getErrors() {
|
|
438
|
+
return Array.from(this.errorQueue.values());
|
|
439
|
+
}
|
|
440
|
+
clearError(e) {
|
|
441
|
+
this.errorQueue.delete(e);
|
|
442
|
+
}
|
|
443
|
+
clearAllErrors() {
|
|
444
|
+
this.errorQueue.clear();
|
|
445
|
+
}
|
|
446
|
+
getErrorStats() {
|
|
447
|
+
let e = this.getErrors(), t = Date.now(), n = e.reduce((e, t) => (e[t.type] = (e[t.type] || 0) + 1, e), {}), r = e.filter((e) => e.retryable).length, i = e.filter((e) => t - e.timestamp < 3e5);
|
|
448
|
+
return {
|
|
449
|
+
totalErrors: e.length,
|
|
450
|
+
errorsByType: n,
|
|
451
|
+
retryableErrors: r,
|
|
452
|
+
recentErrors: i
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
}, E = {
|
|
456
|
+
enabled: !0,
|
|
457
|
+
key: "baroi-player-state",
|
|
458
|
+
persist: [
|
|
459
|
+
"volume",
|
|
460
|
+
"isMuted",
|
|
461
|
+
"playbackRate",
|
|
462
|
+
"subtitlesShowing"
|
|
463
|
+
],
|
|
464
|
+
debounceMs: 500
|
|
465
|
+
};
|
|
466
|
+
function D(e = p, t = {}) {
|
|
467
|
+
let n = { ...e }, i = { ...e }, a = {
|
|
468
|
+
pending: !1,
|
|
469
|
+
error: null,
|
|
470
|
+
lastAction: null,
|
|
471
|
+
retryCount: 0
|
|
472
|
+
}, o = {
|
|
473
|
+
...E,
|
|
474
|
+
...t
|
|
475
|
+
}, s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), l = null, u = (e) => (s.add(e), () => s.delete(e)), d = () => {
|
|
476
|
+
s.forEach((e) => e());
|
|
477
|
+
}, f = () => n, m = () => i, h = () => a, g = async () => {
|
|
478
|
+
if (!o.enabled || typeof window > "u") return;
|
|
479
|
+
let e = o.persist.reduce((e, t) => (e[t] = n[t], e), {});
|
|
480
|
+
try {
|
|
481
|
+
localStorage.setItem(o.key, JSON.stringify({
|
|
482
|
+
...e,
|
|
483
|
+
timestamp: Date.now()
|
|
484
|
+
}));
|
|
485
|
+
} catch (e) {
|
|
486
|
+
console.warn("Failed to persist media state:", e);
|
|
487
|
+
}
|
|
488
|
+
}, _ = () => {
|
|
489
|
+
l && clearTimeout(l), l = setTimeout(g, o.debounceMs);
|
|
490
|
+
}, v = async () => {
|
|
491
|
+
if (!(!o.enabled || typeof window > "u")) try {
|
|
492
|
+
let e = localStorage.getItem(o.key);
|
|
493
|
+
if (!e) return;
|
|
494
|
+
let { timestamp: t, ...r } = JSON.parse(e);
|
|
495
|
+
if (t && Date.now() - t > 10080 * 60 * 1e3) {
|
|
496
|
+
y();
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
let a = {
|
|
500
|
+
...n,
|
|
501
|
+
...r
|
|
502
|
+
};
|
|
503
|
+
JSON.stringify(a) !== JSON.stringify(n) && (n = a, i = { ...a }, d());
|
|
504
|
+
} catch (e) {
|
|
505
|
+
console.warn("Failed to rehydrate media state:", e);
|
|
506
|
+
}
|
|
507
|
+
}, y = () => {
|
|
508
|
+
if (!(typeof window > "u")) try {
|
|
509
|
+
localStorage.removeItem(o.key);
|
|
510
|
+
} catch (e) {
|
|
511
|
+
console.warn("Failed to clear persisted state:", e);
|
|
512
|
+
}
|
|
513
|
+
}, b = (e) => {
|
|
514
|
+
Object.assign(o, e);
|
|
515
|
+
}, x = (e) => {
|
|
516
|
+
let t = {
|
|
517
|
+
...n,
|
|
518
|
+
...e
|
|
519
|
+
};
|
|
520
|
+
JSON.stringify(t) !== JSON.stringify(n) && (n = t, i = { ...t }, _(), d());
|
|
521
|
+
}, S = (e) => {
|
|
522
|
+
let t = `${e.type}-${Date.now()}-${Math.random()}`;
|
|
523
|
+
c.set(t, {
|
|
524
|
+
...e,
|
|
525
|
+
timestamp: Date.now()
|
|
526
|
+
});
|
|
527
|
+
let n = w(i, e);
|
|
528
|
+
return i = {
|
|
529
|
+
...i,
|
|
530
|
+
...n
|
|
531
|
+
}, d(), t;
|
|
532
|
+
}, C = (e) => {
|
|
533
|
+
if (c.has(e)) {
|
|
534
|
+
c.delete(e), i = { ...n };
|
|
535
|
+
for (let [, e] of c) {
|
|
536
|
+
let t = w(i, e);
|
|
537
|
+
i = {
|
|
538
|
+
...i,
|
|
539
|
+
...t
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
d();
|
|
543
|
+
}
|
|
544
|
+
}, w = (e, t) => {
|
|
545
|
+
switch (t.type) {
|
|
546
|
+
case r.PLAY: return {
|
|
547
|
+
isPlaying: !0,
|
|
548
|
+
error: null
|
|
549
|
+
};
|
|
550
|
+
case r.PAUSE: return { isPlaying: !1 };
|
|
551
|
+
case r.SEEK: return { currentTime: t.detail };
|
|
552
|
+
case r.SET_VOLUME: return { volume: Math.max(0, Math.min(1, t.detail)) };
|
|
553
|
+
case r.MUTE: return { isMuted: !0 };
|
|
554
|
+
case r.UNMUTE: return { isMuted: !1 };
|
|
555
|
+
case r.TOGGLE_MUTE: return { isMuted: !e.isMuted };
|
|
556
|
+
case r.SET_DURATION: return { duration: t.detail };
|
|
557
|
+
case r.SET_CURRENT_TIME: return { currentTime: t.detail };
|
|
558
|
+
case r.SET_BUFFERED: return { buffered: t.detail };
|
|
559
|
+
case r.SET_LOADING: return { isLoading: t.detail };
|
|
560
|
+
case r.SET_ERROR: return {
|
|
561
|
+
error: t.detail,
|
|
562
|
+
isLoading: !1
|
|
563
|
+
};
|
|
564
|
+
case r.ENTER_FULLSCREEN: return { isFullscreen: !0 };
|
|
565
|
+
case r.EXIT_FULLSCREEN: return { isFullscreen: !1 };
|
|
566
|
+
case r.ENTER_PIP: return { isPictureInPicture: !0 };
|
|
567
|
+
case r.EXIT_PIP: return { isPictureInPicture: !1 };
|
|
568
|
+
case r.SET_PLAYBACK_RATE: return { playbackRate: t.detail };
|
|
569
|
+
case r.SET_SUBTITLE_TRACK: return { selectedSubtitleTrack: t.detail };
|
|
570
|
+
case r.SET_RENDITION: return { selectedRendition: t.detail };
|
|
571
|
+
case r.TOGGLE_SUBTITLES: return { subtitlesShowing: !e.subtitlesShowing };
|
|
572
|
+
case r.PREVIEW_TIME: return { previewTime: t.detail };
|
|
573
|
+
case r.CLEAR_PREVIEW: return {
|
|
574
|
+
previewTime: null,
|
|
575
|
+
previewImage: null,
|
|
576
|
+
previewCoords: null
|
|
577
|
+
};
|
|
578
|
+
default: return console.warn(`Unknown media action type: ${t.type}`), {};
|
|
579
|
+
}
|
|
580
|
+
}, T = (e) => {
|
|
581
|
+
let t = w(n, e);
|
|
582
|
+
x(t);
|
|
583
|
+
}, D = async (e) => {
|
|
584
|
+
a = {
|
|
585
|
+
pending: !0,
|
|
586
|
+
error: null,
|
|
587
|
+
lastAction: e,
|
|
588
|
+
retryCount: e.retryCount || 0
|
|
589
|
+
};
|
|
590
|
+
let t = S(e);
|
|
591
|
+
try {
|
|
592
|
+
await new Promise((e) => setTimeout(e, 0));
|
|
593
|
+
let r = w(n, e), o = {
|
|
594
|
+
...n,
|
|
595
|
+
...r
|
|
596
|
+
};
|
|
597
|
+
JSON.stringify(o) !== JSON.stringify(n) && (n = o, _()), c.delete(t), a = {
|
|
598
|
+
pending: !1,
|
|
599
|
+
error: null,
|
|
600
|
+
lastAction: e,
|
|
601
|
+
retryCount: 0
|
|
602
|
+
}, i = { ...n };
|
|
603
|
+
for (let [, e] of c) {
|
|
604
|
+
let t = w(i, e);
|
|
605
|
+
i = {
|
|
606
|
+
...i,
|
|
607
|
+
...t
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
} catch (n) {
|
|
611
|
+
C(t), a = {
|
|
612
|
+
pending: !1,
|
|
613
|
+
error: n instanceof Error ? n.message : "Unknown error occurred",
|
|
614
|
+
lastAction: e,
|
|
615
|
+
retryCount: (e.retryCount || 0) + 1
|
|
616
|
+
}, a.retryCount < 3 && O(e.type) && setTimeout(() => {
|
|
617
|
+
D({
|
|
618
|
+
...e,
|
|
619
|
+
retryCount: a.retryCount
|
|
620
|
+
});
|
|
621
|
+
}, 2 ** a.retryCount * 1e3);
|
|
622
|
+
}
|
|
623
|
+
d();
|
|
624
|
+
}, O = (e) => [
|
|
625
|
+
r.PLAY,
|
|
626
|
+
r.PAUSE,
|
|
627
|
+
r.SEEK,
|
|
628
|
+
r.SET_VOLUME,
|
|
629
|
+
r.MUTE,
|
|
630
|
+
r.UNMUTE,
|
|
631
|
+
r.TOGGLE_MUTE
|
|
632
|
+
].includes(e);
|
|
633
|
+
return v(), {
|
|
634
|
+
subscribe: u,
|
|
635
|
+
getState: f,
|
|
636
|
+
setState: x,
|
|
637
|
+
dispatch: T,
|
|
638
|
+
getOptimisticState: m,
|
|
639
|
+
dispatchOptimistic: D,
|
|
640
|
+
rollbackOptimistic: C,
|
|
641
|
+
getActionState: h,
|
|
642
|
+
setPersistenceConfig: b,
|
|
643
|
+
rehydrateFromStorage: v,
|
|
644
|
+
clearPersistedState: y
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
//#endregion
|
|
648
|
+
//#region src/context/persistence.ts
|
|
649
|
+
var O = {
|
|
650
|
+
USER_PREFERENCES: "baroi-player-preferences",
|
|
651
|
+
SESSION_STATE: "baroi-player-session",
|
|
652
|
+
PLAYBACK_HISTORY: "baroi-player-history",
|
|
653
|
+
CACHE_TIMESTAMP: "baroi-player-cache-ts"
|
|
654
|
+
}, k = class {
|
|
655
|
+
async getItem(e) {
|
|
656
|
+
if (typeof window > "u") return null;
|
|
657
|
+
try {
|
|
658
|
+
return localStorage.getItem(e);
|
|
659
|
+
} catch (e) {
|
|
660
|
+
return console.warn("Failed to read from localStorage:", e), null;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
async setItem(e, t) {
|
|
664
|
+
if (!(typeof window > "u")) try {
|
|
665
|
+
localStorage.setItem(e, t);
|
|
666
|
+
} catch (e) {
|
|
667
|
+
console.warn("Failed to write to localStorage:", e);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
async removeItem(e) {
|
|
671
|
+
if (!(typeof window > "u")) try {
|
|
672
|
+
localStorage.removeItem(e);
|
|
673
|
+
} catch (e) {
|
|
674
|
+
console.warn("Failed to remove from localStorage:", e);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
async clear() {
|
|
678
|
+
if (!(typeof window > "u")) try {
|
|
679
|
+
Object.values(O).forEach((e) => {
|
|
680
|
+
localStorage.removeItem(e);
|
|
681
|
+
});
|
|
682
|
+
} catch (e) {
|
|
683
|
+
console.warn("Failed to clear localStorage:", e);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}, A = {
|
|
687
|
+
userPreferences: !0,
|
|
688
|
+
sessionState: !0,
|
|
689
|
+
playbackHistory: !0,
|
|
690
|
+
maxHistoryItems: 50,
|
|
691
|
+
maxCacheAge: 10080 * 60 * 1e3,
|
|
692
|
+
debounceMs: 1e3,
|
|
693
|
+
storage: new k()
|
|
694
|
+
}, j = class {
|
|
695
|
+
constructor(e = {}) {
|
|
696
|
+
b(this, "config", void 0), b(this, "storage", void 0), b(this, "debounceTimeouts", /* @__PURE__ */ new Map()), this.config = {
|
|
697
|
+
...A,
|
|
698
|
+
...e
|
|
699
|
+
}, this.storage = this.config.storage;
|
|
700
|
+
}
|
|
701
|
+
async getUserPreferences() {
|
|
702
|
+
if (!this.config.userPreferences) return null;
|
|
703
|
+
try {
|
|
704
|
+
let e = await this.storage.getItem(O.USER_PREFERENCES);
|
|
705
|
+
if (!e) return null;
|
|
706
|
+
let t = JSON.parse(e);
|
|
707
|
+
return this.isCacheExpired(t.timestamp) ? (await this.clearUserPreferences(), null) : t.preferences;
|
|
708
|
+
} catch (e) {
|
|
709
|
+
return console.warn("Failed to get user preferences:", e), null;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
async saveUserPreferences(e) {
|
|
713
|
+
this.config.userPreferences && this.debounce(O.USER_PREFERENCES, async () => {
|
|
714
|
+
try {
|
|
715
|
+
let t = {
|
|
716
|
+
...await this.getUserPreferences() || {},
|
|
717
|
+
...e
|
|
718
|
+
};
|
|
719
|
+
await this.storage.setItem(O.USER_PREFERENCES, JSON.stringify({
|
|
720
|
+
preferences: t,
|
|
721
|
+
timestamp: Date.now()
|
|
722
|
+
}));
|
|
723
|
+
} catch (e) {
|
|
724
|
+
console.warn("Failed to save user preferences:", e);
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
async clearUserPreferences() {
|
|
729
|
+
try {
|
|
730
|
+
await this.storage.removeItem(O.USER_PREFERENCES);
|
|
731
|
+
} catch (e) {
|
|
732
|
+
console.warn("Failed to clear user preferences:", e);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
async getSessionState() {
|
|
736
|
+
if (!this.config.sessionState) return null;
|
|
737
|
+
try {
|
|
738
|
+
let e = await this.storage.getItem(O.SESSION_STATE);
|
|
739
|
+
return e ? JSON.parse(e).state : null;
|
|
740
|
+
} catch (e) {
|
|
741
|
+
return console.warn("Failed to get session state:", e), null;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
async saveSessionState(e) {
|
|
745
|
+
this.config.sessionState && this.debounce(O.SESSION_STATE, async () => {
|
|
746
|
+
try {
|
|
747
|
+
let t = {
|
|
748
|
+
...await this.getSessionState() || {
|
|
749
|
+
currentTime: 0,
|
|
750
|
+
playbackPosition: {}
|
|
751
|
+
},
|
|
752
|
+
...e
|
|
753
|
+
};
|
|
754
|
+
await this.storage.setItem(O.SESSION_STATE, JSON.stringify({
|
|
755
|
+
state: t,
|
|
756
|
+
timestamp: Date.now()
|
|
757
|
+
}));
|
|
758
|
+
} catch (e) {
|
|
759
|
+
console.warn("Failed to save session state:", e);
|
|
760
|
+
}
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
async clearSessionState() {
|
|
764
|
+
try {
|
|
765
|
+
await this.storage.removeItem(O.SESSION_STATE);
|
|
766
|
+
} catch (e) {
|
|
767
|
+
console.warn("Failed to clear session state:", e);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
async getPlaybackHistory() {
|
|
771
|
+
if (!this.config.playbackHistory) return [];
|
|
772
|
+
try {
|
|
773
|
+
let e = await this.storage.getItem(O.PLAYBACK_HISTORY);
|
|
774
|
+
if (!e) return [];
|
|
775
|
+
let t = JSON.parse(e);
|
|
776
|
+
return this.isCacheExpired(t.timestamp) ? (await this.clearPlaybackHistory(), []) : t.history || [];
|
|
777
|
+
} catch (e) {
|
|
778
|
+
return console.warn("Failed to get playback history:", e), [];
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
async addToPlaybackHistory(e) {
|
|
782
|
+
if (this.config.playbackHistory) try {
|
|
783
|
+
let t = await this.getPlaybackHistory(), n = [{
|
|
784
|
+
...e,
|
|
785
|
+
timestamp: Date.now()
|
|
786
|
+
}, ...t.filter((t) => t.mediaId !== e.mediaId)].slice(0, this.config.maxHistoryItems);
|
|
787
|
+
await this.storage.setItem(O.PLAYBACK_HISTORY, JSON.stringify({
|
|
788
|
+
history: n,
|
|
789
|
+
timestamp: Date.now()
|
|
790
|
+
}));
|
|
791
|
+
} catch (e) {
|
|
792
|
+
console.warn("Failed to add to playback history:", e);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
async clearPlaybackHistory() {
|
|
796
|
+
try {
|
|
797
|
+
await this.storage.removeItem(O.PLAYBACK_HISTORY);
|
|
798
|
+
} catch (e) {
|
|
799
|
+
console.warn("Failed to clear playback history:", e);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
async savePlaybackPosition(e, t) {
|
|
803
|
+
let n = (await this.getSessionState())?.playbackPosition || {};
|
|
804
|
+
await this.saveSessionState({ playbackPosition: {
|
|
805
|
+
...n,
|
|
806
|
+
[e]: t
|
|
807
|
+
} });
|
|
808
|
+
}
|
|
809
|
+
async getPlaybackPosition(e) {
|
|
810
|
+
return (await this.getSessionState())?.playbackPosition?.[e] || 0;
|
|
811
|
+
}
|
|
812
|
+
extractUserPreferences(e) {
|
|
813
|
+
return {
|
|
814
|
+
volume: e.volume,
|
|
815
|
+
isMuted: e.isMuted,
|
|
816
|
+
playbackRate: e.playbackRate,
|
|
817
|
+
subtitlesShowing: e.subtitlesShowing,
|
|
818
|
+
selectedSubtitleTrack: e.selectedSubtitleTrack?.id || null,
|
|
819
|
+
preferredRendition: e.selectedRendition,
|
|
820
|
+
autoplay: !1,
|
|
821
|
+
keyboardShortcuts: !0
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
extractSessionState(e, t) {
|
|
825
|
+
return {
|
|
826
|
+
currentTime: e.currentTime,
|
|
827
|
+
mediaId: t,
|
|
828
|
+
playbackPosition: {}
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
async clearAll() {
|
|
832
|
+
await this.storage.clear(), this.debounceTimeouts.clear();
|
|
833
|
+
}
|
|
834
|
+
isCacheExpired(e) {
|
|
835
|
+
return !e || Date.now() - e > this.config.maxCacheAge;
|
|
836
|
+
}
|
|
837
|
+
debounce(e, t) {
|
|
838
|
+
let n = this.debounceTimeouts.get(e);
|
|
839
|
+
n && clearTimeout(n);
|
|
840
|
+
let r = setTimeout(async () => {
|
|
841
|
+
await t(), this.debounceTimeouts.delete(e);
|
|
842
|
+
}, this.config.debounceMs);
|
|
843
|
+
this.debounceTimeouts.set(e, r);
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
function M(e) {
|
|
847
|
+
let [t] = n.useState(() => new j(e));
|
|
848
|
+
return n.useEffect(() => () => {
|
|
849
|
+
t.clearAll();
|
|
850
|
+
}, [t]), t;
|
|
851
|
+
}
|
|
852
|
+
function N(e, t, r) {
|
|
853
|
+
let i = M(r), [a, o] = n.useState(!1);
|
|
854
|
+
return n.useEffect(() => {
|
|
855
|
+
let e = !0;
|
|
856
|
+
return (async () => {
|
|
857
|
+
try {
|
|
858
|
+
let [n, r] = await Promise.all([i.getUserPreferences(), i.getSessionState()]);
|
|
859
|
+
if (!e) return;
|
|
860
|
+
let a = {
|
|
861
|
+
...n && {
|
|
862
|
+
volume: n.volume,
|
|
863
|
+
isMuted: n.isMuted,
|
|
864
|
+
playbackRate: n.playbackRate,
|
|
865
|
+
subtitlesShowing: n.subtitlesShowing
|
|
866
|
+
},
|
|
867
|
+
...r && t === r.mediaId && { currentTime: r.currentTime }
|
|
868
|
+
};
|
|
869
|
+
Object.keys(a).length > 0 && console.log("Rehydrated state:", a), o(!0);
|
|
870
|
+
} catch (e) {
|
|
871
|
+
console.warn("Failed to rehydrate state:", e), o(!0);
|
|
872
|
+
}
|
|
873
|
+
})(), () => {
|
|
874
|
+
e = !1;
|
|
875
|
+
};
|
|
876
|
+
}, [i, t]), n.useEffect(() => {
|
|
877
|
+
if (!a) return;
|
|
878
|
+
let n = i.extractUserPreferences(e);
|
|
879
|
+
if (i.saveUserPreferences(n), t) {
|
|
880
|
+
let n = i.extractSessionState(e, t);
|
|
881
|
+
i.saveSessionState(n), e.currentTime > 0 && e.duration > 0 && i.savePlaybackPosition(t, e.currentTime);
|
|
882
|
+
}
|
|
883
|
+
}, [
|
|
884
|
+
i,
|
|
885
|
+
e,
|
|
886
|
+
t,
|
|
887
|
+
a
|
|
888
|
+
]), {
|
|
889
|
+
manager: i,
|
|
890
|
+
isRehydrated: a
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
new k();
|
|
894
|
+
//#endregion
|
|
895
|
+
//#region src/context/media-provider.tsx
|
|
896
|
+
var P = g();
|
|
897
|
+
function F(e = p) {
|
|
898
|
+
let t = { ...e }, n = /* @__PURE__ */ new Set(), i = (e) => (n.add(e), () => n.delete(e)), a = () => t, o = (e) => {
|
|
899
|
+
let r = {
|
|
900
|
+
...t,
|
|
901
|
+
...e
|
|
902
|
+
};
|
|
903
|
+
JSON.stringify(r) !== JSON.stringify(t) && (t = r, n.forEach((e) => e()));
|
|
904
|
+
};
|
|
905
|
+
return {
|
|
906
|
+
subscribe: i,
|
|
907
|
+
getState: a,
|
|
908
|
+
setState: o,
|
|
909
|
+
dispatch: (e) => {
|
|
910
|
+
switch (e.type) {
|
|
911
|
+
case r.PLAY:
|
|
912
|
+
o({
|
|
913
|
+
isPlaying: !0,
|
|
914
|
+
error: null
|
|
915
|
+
});
|
|
916
|
+
break;
|
|
917
|
+
case r.PAUSE:
|
|
918
|
+
o({ isPlaying: !1 });
|
|
919
|
+
break;
|
|
920
|
+
case r.SEEK:
|
|
921
|
+
o({ currentTime: e.detail });
|
|
922
|
+
break;
|
|
923
|
+
case r.SET_VOLUME:
|
|
924
|
+
o({ volume: Math.max(0, Math.min(1, e.detail)) });
|
|
925
|
+
break;
|
|
926
|
+
case r.MUTE:
|
|
927
|
+
o({ isMuted: !0 });
|
|
928
|
+
break;
|
|
929
|
+
case r.UNMUTE:
|
|
930
|
+
o({ isMuted: !1 });
|
|
931
|
+
break;
|
|
932
|
+
case r.TOGGLE_MUTE:
|
|
933
|
+
o({ isMuted: !t.isMuted });
|
|
934
|
+
break;
|
|
935
|
+
case r.SET_DURATION:
|
|
936
|
+
o({ duration: e.detail });
|
|
937
|
+
break;
|
|
938
|
+
case r.SET_CURRENT_TIME:
|
|
939
|
+
o({ currentTime: e.detail });
|
|
940
|
+
break;
|
|
941
|
+
case r.SET_BUFFERED:
|
|
942
|
+
o({ buffered: e.detail });
|
|
943
|
+
break;
|
|
944
|
+
case r.SET_LOADING:
|
|
945
|
+
o({ isLoading: e.detail });
|
|
946
|
+
break;
|
|
947
|
+
case r.SET_ERROR:
|
|
948
|
+
o({
|
|
949
|
+
error: e.detail,
|
|
950
|
+
isLoading: !1
|
|
951
|
+
});
|
|
952
|
+
break;
|
|
953
|
+
case r.ENTER_FULLSCREEN:
|
|
954
|
+
o({ isFullscreen: !0 });
|
|
955
|
+
break;
|
|
956
|
+
case r.EXIT_FULLSCREEN:
|
|
957
|
+
o({ isFullscreen: !1 });
|
|
958
|
+
break;
|
|
959
|
+
case r.ENTER_PIP:
|
|
960
|
+
o({ isPictureInPicture: !0 });
|
|
961
|
+
break;
|
|
962
|
+
case r.EXIT_PIP:
|
|
963
|
+
o({ isPictureInPicture: !1 });
|
|
964
|
+
break;
|
|
965
|
+
case r.SET_PLAYBACK_RATE:
|
|
966
|
+
o({ playbackRate: e.detail });
|
|
967
|
+
break;
|
|
968
|
+
case r.SET_SUBTITLE_TRACK:
|
|
969
|
+
o({ selectedSubtitleTrack: e.detail });
|
|
970
|
+
break;
|
|
971
|
+
case r.SET_RENDITION:
|
|
972
|
+
o({ selectedRendition: e.detail });
|
|
973
|
+
break;
|
|
974
|
+
case r.TOGGLE_SUBTITLES:
|
|
975
|
+
o({ subtitlesShowing: !t.subtitlesShowing });
|
|
976
|
+
break;
|
|
977
|
+
case r.PREVIEW_TIME:
|
|
978
|
+
o({ previewTime: e.detail });
|
|
979
|
+
break;
|
|
980
|
+
case r.CLEAR_PREVIEW:
|
|
981
|
+
o({
|
|
982
|
+
previewTime: null,
|
|
983
|
+
previewImage: null,
|
|
984
|
+
previewCoords: null
|
|
985
|
+
});
|
|
986
|
+
break;
|
|
987
|
+
default: console.warn(`Unknown media action type: ${e.type}`);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
function I({ children: e, mediaId: t = "media-player", labelId: r = "media-player-label", descriptionId: a = "media-player-description", dir: s = "ltr", portalContainer: c, tooltipDelayDuration: l = 700, tooltipSideOffset: u = 4, disabled: d = !1, isVideo: f = !0, withoutTooltip: m = !1, initialState: h = {}, useEnhancedStore: g = !0, persistenceConfig: _, retryConfig: v, enableOptimisticUpdates: y = !0, enableErrorRecovery: b = !0, onStateRehydrated: x }) {
|
|
993
|
+
let S = n.useRef(null), C = n.useRef(null), w = n.useMemo(() => {
|
|
994
|
+
let e = {
|
|
995
|
+
...p,
|
|
996
|
+
...h
|
|
997
|
+
};
|
|
998
|
+
return g ? D(e, _) : F(e);
|
|
999
|
+
}, [g, _]), E = n.useMemo(() => b && g ? new T(v) : null, [
|
|
1000
|
+
b,
|
|
1001
|
+
g,
|
|
1002
|
+
v
|
|
1003
|
+
]), O = N(w.getState(), t, _);
|
|
1004
|
+
n.useEffect(() => {
|
|
1005
|
+
O?.isRehydrated && x && x(w.getState());
|
|
1006
|
+
}, [
|
|
1007
|
+
O?.isRehydrated,
|
|
1008
|
+
x,
|
|
1009
|
+
w
|
|
1010
|
+
]);
|
|
1011
|
+
let k = n.useMemo(() => ({
|
|
1012
|
+
mediaId: t,
|
|
1013
|
+
labelId: r,
|
|
1014
|
+
descriptionId: a,
|
|
1015
|
+
dir: s,
|
|
1016
|
+
rootRef: S,
|
|
1017
|
+
mediaRef: C,
|
|
1018
|
+
portalContainer: c,
|
|
1019
|
+
tooltipDelayDuration: l,
|
|
1020
|
+
tooltipSideOffset: u,
|
|
1021
|
+
disabled: d,
|
|
1022
|
+
isVideo: f,
|
|
1023
|
+
withoutTooltip: m,
|
|
1024
|
+
errorHandler: E,
|
|
1025
|
+
isEnhanced: g,
|
|
1026
|
+
isRehydrated: O?.isRehydrated
|
|
1027
|
+
}), [
|
|
1028
|
+
t,
|
|
1029
|
+
r,
|
|
1030
|
+
a,
|
|
1031
|
+
s,
|
|
1032
|
+
c,
|
|
1033
|
+
l,
|
|
1034
|
+
u,
|
|
1035
|
+
d,
|
|
1036
|
+
f,
|
|
1037
|
+
m,
|
|
1038
|
+
E,
|
|
1039
|
+
g,
|
|
1040
|
+
O?.isRehydrated
|
|
1041
|
+
]);
|
|
1042
|
+
return /* @__PURE__ */ (0, P.jsx)(i.Provider, {
|
|
1043
|
+
value: k,
|
|
1044
|
+
children: /* @__PURE__ */ (0, P.jsx)(o.Provider, {
|
|
1045
|
+
value: w,
|
|
1046
|
+
children: e
|
|
1047
|
+
})
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
//#endregion
|
|
1051
|
+
export { r as a, p as c, f as d, l as f, g as i, a as l, d as m, D as n, i as o, s as p, b as r, o as s, I as t, u };
|
|
1052
|
+
|
|
1053
|
+
//# sourceMappingURL=context-DD_SH4tT.js.map
|