@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
|
@@ -1,686 +0,0 @@
|
|
|
1
|
-
var f = Object.defineProperty;
|
|
2
|
-
var p = (r, t, e) => t in r ? f(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
-
var o = (r, t, e) => p(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { E as y } from "./core-events-DunPHKRE.js";
|
|
5
|
-
class l extends Error {
|
|
6
|
-
constructor(t, e, i, n) {
|
|
7
|
-
super(`Plugin '${t}' failed during ${e}: ${i}`), this.pluginName = t, this.phase = e, this.originalError = n, this.name = "PluginError";
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
class v extends l {
|
|
11
|
-
constructor(t, e) {
|
|
12
|
-
super(t, "initialize", `Missing dependencies: ${e.join(", ")}`), this.missingDependencies = e, this.name = "PluginDependencyError";
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
class w extends l {
|
|
16
|
-
constructor(t, e) {
|
|
17
|
-
super(t, "activate", `Conflicts with active plugins: ${e.join(", ")}`), this.conflictingPlugins = e, this.name = "PluginConflictError";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
class b {
|
|
21
|
-
constructor(t) {
|
|
22
|
-
o(this, "plugins", /* @__PURE__ */ new Map());
|
|
23
|
-
o(this, "pluginConfigs", /* @__PURE__ */ new Map());
|
|
24
|
-
o(this, "enabledPlugins", /* @__PURE__ */ new Set());
|
|
25
|
-
o(this, "eventBus", new y());
|
|
26
|
-
o(this, "logger");
|
|
27
|
-
this.logger = t;
|
|
28
|
-
}
|
|
29
|
-
// Register a plugin factory
|
|
30
|
-
async register(t, e = {}) {
|
|
31
|
-
try {
|
|
32
|
-
const i = t(e), { name: n, dependencies: s = [], conflicts: c = [] } = i.metadata;
|
|
33
|
-
if (this.plugins.has(n))
|
|
34
|
-
throw new l(n, "initialize", "Plugin already registered");
|
|
35
|
-
const u = s.filter((h) => !this.plugins.has(h));
|
|
36
|
-
if (u.length > 0)
|
|
37
|
-
throw new v(n, u);
|
|
38
|
-
const a = c.filter((h) => this.enabledPlugins.has(h));
|
|
39
|
-
if (a.length > 0)
|
|
40
|
-
throw new w(n, a);
|
|
41
|
-
this.plugins.set(n, i), this.pluginConfigs.set(n, e), this.logger.info(`Plugin '${n}' registered successfully`), this.eventBus.emit("plugin:registered", { name: n, plugin: i });
|
|
42
|
-
} catch (i) {
|
|
43
|
-
const n = t({}).metadata.name;
|
|
44
|
-
throw this.logger.error(`Failed to register plugin '${n}'`, i), this.eventBus.emit("plugin:error", { name: n, error: i }), i;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// Unregister a plugin
|
|
48
|
-
async unregister(t) {
|
|
49
|
-
if (!this.plugins.get(t))
|
|
50
|
-
throw new l(t, "destroy", "Plugin not found");
|
|
51
|
-
try {
|
|
52
|
-
this.enabledPlugins.has(t) && await this.disable(t), this.plugins.delete(t), this.pluginConfigs.delete(t), this.logger.info(`Plugin '${t}' unregistered successfully`);
|
|
53
|
-
} catch (i) {
|
|
54
|
-
throw this.logger.error(`Failed to unregister plugin '${t}'`, i), i;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// Get a plugin by name
|
|
58
|
-
get(t) {
|
|
59
|
-
return this.plugins.get(t);
|
|
60
|
-
}
|
|
61
|
-
// Get all plugins sorted by priority
|
|
62
|
-
getAll() {
|
|
63
|
-
return Array.from(this.plugins.values()).sort(this.sortByPriority);
|
|
64
|
-
}
|
|
65
|
-
// Check if plugin is enabled
|
|
66
|
-
isEnabled(t) {
|
|
67
|
-
return this.enabledPlugins.has(t);
|
|
68
|
-
}
|
|
69
|
-
// Enable a plugin
|
|
70
|
-
async enable(t) {
|
|
71
|
-
const e = this.plugins.get(t);
|
|
72
|
-
if (!e)
|
|
73
|
-
throw new l(t, "activate", "Plugin not found");
|
|
74
|
-
if (this.enabledPlugins.has(t)) {
|
|
75
|
-
this.logger.warn(`Plugin '${t}' is already enabled`);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
const i = this.createPluginContext(t), n = this.pluginConfigs.get(t);
|
|
80
|
-
await e.initialize(i, n), await e.activate(i), this.enabledPlugins.add(t), this.logger.info(`Plugin '${t}' enabled successfully`), this.eventBus.emit("plugin:enabled", { name: t, plugin: e });
|
|
81
|
-
} catch (i) {
|
|
82
|
-
throw this.logger.error(`Failed to enable plugin '${t}'`, i), this.eventBus.emit("plugin:error", { name: t, error: i }), i;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
// Disable a plugin
|
|
86
|
-
async disable(t) {
|
|
87
|
-
const e = this.plugins.get(t);
|
|
88
|
-
if (!e)
|
|
89
|
-
throw new l(t, "deactivate", "Plugin not found");
|
|
90
|
-
if (!this.enabledPlugins.has(t)) {
|
|
91
|
-
this.logger.warn(`Plugin '${t}' is already disabled`);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
const i = this.createPluginContext(t);
|
|
96
|
-
await e.deactivate(i), await e.destroy(i), this.enabledPlugins.delete(t), this.logger.info(`Plugin '${t}' disabled successfully`), this.eventBus.emit("plugin:disabled", { name: t, plugin: e });
|
|
97
|
-
} catch (i) {
|
|
98
|
-
throw this.logger.error(`Failed to disable plugin '${t}'`, i), this.eventBus.emit("plugin:error", { name: t, error: i }), i;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// Configure a plugin
|
|
102
|
-
async configure(t, e) {
|
|
103
|
-
const i = this.plugins.get(t);
|
|
104
|
-
if (!i)
|
|
105
|
-
throw new l(t, "initialize", "Plugin not found");
|
|
106
|
-
try {
|
|
107
|
-
this.pluginConfigs.set(t, { ...this.pluginConfigs.get(t), ...e }), i.configure && await i.configure(e), this.logger.info(`Plugin '${t}' configured successfully`), this.eventBus.emit("plugin:configured", { name: t, config: e });
|
|
108
|
-
} catch (n) {
|
|
109
|
-
throw this.logger.error(`Failed to configure plugin '${t}'`, n), this.eventBus.emit("plugin:error", { name: t, error: n }), n;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
// Enable multiple plugins with dependency resolution
|
|
113
|
-
async enablePlugins(t) {
|
|
114
|
-
const e = this.resolveDependencies(t);
|
|
115
|
-
for (const i of e)
|
|
116
|
-
this.enabledPlugins.has(i) || await this.enable(i);
|
|
117
|
-
}
|
|
118
|
-
// Disable multiple plugins
|
|
119
|
-
async disablePlugins(t) {
|
|
120
|
-
const e = [...t].reverse();
|
|
121
|
-
for (const i of e)
|
|
122
|
-
this.enabledPlugins.has(i) && await this.disable(i);
|
|
123
|
-
}
|
|
124
|
-
// Get enabled plugins
|
|
125
|
-
getEnabledPlugins() {
|
|
126
|
-
return Array.from(this.enabledPlugins).map((t) => this.plugins.get(t)).filter(Boolean).sort(this.sortByPriority);
|
|
127
|
-
}
|
|
128
|
-
// Health check for all enabled plugins
|
|
129
|
-
async healthCheck() {
|
|
130
|
-
const t = [];
|
|
131
|
-
for (const e of this.enabledPlugins) {
|
|
132
|
-
const i = this.plugins.get(e);
|
|
133
|
-
try {
|
|
134
|
-
const n = i.healthCheck ? await i.healthCheck() : !0;
|
|
135
|
-
t.push({ name: e, healthy: n });
|
|
136
|
-
} catch (n) {
|
|
137
|
-
t.push({ name: e, healthy: !1, error: n });
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return t;
|
|
141
|
-
}
|
|
142
|
-
// Event handling
|
|
143
|
-
on(t, e) {
|
|
144
|
-
return this.eventBus.on(t, e), () => this.eventBus.off(t, e);
|
|
145
|
-
}
|
|
146
|
-
// Create plugin context (will be implemented when we have the full context)
|
|
147
|
-
createPluginContext(t) {
|
|
148
|
-
return {
|
|
149
|
-
state: {},
|
|
150
|
-
controls: {},
|
|
151
|
-
plugins: this,
|
|
152
|
-
emit: (e, i) => this.eventBus.emit(e, i),
|
|
153
|
-
on: (e, i) => (this.eventBus.on(e, i), () => this.eventBus.off(e, i)),
|
|
154
|
-
element: null,
|
|
155
|
-
logger: this.createPluginLogger(t)
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
// Create plugin-specific logger
|
|
159
|
-
createPluginLogger(t) {
|
|
160
|
-
return {
|
|
161
|
-
info: (e, i) => this.logger.info(`[${t}] ${e}`, i),
|
|
162
|
-
warn: (e, i) => this.logger.warn(`[${t}] ${e}`, i),
|
|
163
|
-
error: (e, i) => this.logger.error(`[${t}] ${e}`, i),
|
|
164
|
-
debug: (e, i) => this.logger.debug(`[${t}] ${e}`, i)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
// Resolve plugin dependencies
|
|
168
|
-
resolveDependencies(t) {
|
|
169
|
-
const e = [], i = /* @__PURE__ */ new Set(), n = (s) => {
|
|
170
|
-
if (e.includes(s)) return;
|
|
171
|
-
if (i.has(s))
|
|
172
|
-
throw new l(s, "initialize", "Circular dependency detected");
|
|
173
|
-
i.add(s);
|
|
174
|
-
const c = this.plugins.get(s);
|
|
175
|
-
if (!c)
|
|
176
|
-
throw new l(s, "initialize", "Plugin not found");
|
|
177
|
-
for (const u of c.metadata.dependencies || [])
|
|
178
|
-
n(u);
|
|
179
|
-
i.delete(s), e.push(s);
|
|
180
|
-
};
|
|
181
|
-
for (const s of t)
|
|
182
|
-
n(s);
|
|
183
|
-
return e;
|
|
184
|
-
}
|
|
185
|
-
// Sort plugins by priority
|
|
186
|
-
sortByPriority(t, e) {
|
|
187
|
-
const i = {
|
|
188
|
-
high: 3,
|
|
189
|
-
medium: 2,
|
|
190
|
-
low: 1
|
|
191
|
-
};
|
|
192
|
-
return i[e.metadata.priority] - i[t.metadata.priority];
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
class m {
|
|
196
|
-
constructor(t) {
|
|
197
|
-
o(this, "metadata");
|
|
198
|
-
o(this, "context");
|
|
199
|
-
o(this, "config", {});
|
|
200
|
-
o(this, "initialized", !1);
|
|
201
|
-
o(this, "active", !1);
|
|
202
|
-
this.metadata = {
|
|
203
|
-
version: "1.0.0",
|
|
204
|
-
...t
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
// Plugin lifecycle methods - can be overridden by subclasses
|
|
208
|
-
async initialize(t, e = {}) {
|
|
209
|
-
if (this.initialized) {
|
|
210
|
-
t.logger.warn("Plugin already initialized");
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
this.context = t, this.config = { ...this.config, ...e };
|
|
214
|
-
try {
|
|
215
|
-
await this.onInitialize(), this.initialized = !0, t.logger.info("Plugin initialized");
|
|
216
|
-
} catch (i) {
|
|
217
|
-
throw t.logger.error("Failed to initialize plugin", i), i;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
async activate(t) {
|
|
221
|
-
if (!this.initialized)
|
|
222
|
-
throw new Error("Plugin must be initialized before activation");
|
|
223
|
-
if (this.active) {
|
|
224
|
-
t.logger.warn("Plugin already active");
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
try {
|
|
228
|
-
await this.onActivate(), this.active = !0, t.logger.info("Plugin activated");
|
|
229
|
-
} catch (e) {
|
|
230
|
-
throw t.logger.error("Failed to activate plugin", e), e;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
async deactivate(t) {
|
|
234
|
-
if (!this.active) {
|
|
235
|
-
t.logger.warn("Plugin already inactive");
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
try {
|
|
239
|
-
await this.onDeactivate(), this.active = !1, t.logger.info("Plugin deactivated");
|
|
240
|
-
} catch (e) {
|
|
241
|
-
throw t.logger.error("Failed to deactivate plugin", e), e;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
async destroy(t) {
|
|
245
|
-
this.active && await this.deactivate(t);
|
|
246
|
-
try {
|
|
247
|
-
await this.onDestroy(), this.initialized = !1, t.logger.info("Plugin destroyed");
|
|
248
|
-
} catch (e) {
|
|
249
|
-
throw t.logger.error("Failed to destroy plugin", e), e;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
async configure(t) {
|
|
253
|
-
const e = { ...this.config };
|
|
254
|
-
this.config = { ...this.config, ...t };
|
|
255
|
-
try {
|
|
256
|
-
await this.onConfigure(t, e), this.context?.logger.info("Plugin configured");
|
|
257
|
-
} catch (i) {
|
|
258
|
-
throw this.config = e, this.context?.logger.error("Failed to configure plugin", i), i;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
healthCheck() {
|
|
262
|
-
return this.initialized && this.onHealthCheck();
|
|
263
|
-
}
|
|
264
|
-
onDestroy() {
|
|
265
|
-
}
|
|
266
|
-
onConfigure(t, e) {
|
|
267
|
-
}
|
|
268
|
-
onHealthCheck() {
|
|
269
|
-
return !0;
|
|
270
|
-
}
|
|
271
|
-
// Utility methods for plugins
|
|
272
|
-
get state() {
|
|
273
|
-
return this.context?.state;
|
|
274
|
-
}
|
|
275
|
-
get controls() {
|
|
276
|
-
return this.context?.controls;
|
|
277
|
-
}
|
|
278
|
-
get element() {
|
|
279
|
-
return this.context?.element;
|
|
280
|
-
}
|
|
281
|
-
get logger() {
|
|
282
|
-
return this.context?.logger;
|
|
283
|
-
}
|
|
284
|
-
emit(t, e) {
|
|
285
|
-
this.context?.emit(t, e);
|
|
286
|
-
}
|
|
287
|
-
on(t, e) {
|
|
288
|
-
return this.context?.on(t, e) || (() => {
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
// Helper methods for common plugin patterns
|
|
292
|
-
addEventListeners(t, e) {
|
|
293
|
-
return Object.entries(e).forEach(([i, n]) => {
|
|
294
|
-
t.addEventListener(i, n);
|
|
295
|
-
}), () => {
|
|
296
|
-
Object.entries(e).forEach(([i, n]) => {
|
|
297
|
-
t.removeEventListener(i, n);
|
|
298
|
-
});
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
createConfig(t) {
|
|
302
|
-
return { ...t, ...this.config };
|
|
303
|
-
}
|
|
304
|
-
// Plugin status
|
|
305
|
-
get isInitialized() {
|
|
306
|
-
return this.initialized;
|
|
307
|
-
}
|
|
308
|
-
get isActive() {
|
|
309
|
-
return this.active;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
function k(r) {
|
|
313
|
-
return (t) => new r(t);
|
|
314
|
-
}
|
|
315
|
-
class P extends m {
|
|
316
|
-
constructor(e) {
|
|
317
|
-
super({
|
|
318
|
-
name: "analytics",
|
|
319
|
-
description: "Media player analytics and tracking",
|
|
320
|
-
category: "analytics",
|
|
321
|
-
priority: "low",
|
|
322
|
-
author: "BaroiPlayer Team"
|
|
323
|
-
});
|
|
324
|
-
o(this, "events", []);
|
|
325
|
-
o(this, "analyticsConfig");
|
|
326
|
-
o(this, "cleanupFunctions", []);
|
|
327
|
-
o(this, "reportTimer");
|
|
328
|
-
}
|
|
329
|
-
onInitialize() {
|
|
330
|
-
if (this.analyticsConfig = this.createConfig({
|
|
331
|
-
trackingId: "",
|
|
332
|
-
events: ["play", "pause", "seek", "ended", "error"],
|
|
333
|
-
samplingRate: 1,
|
|
334
|
-
debug: !1,
|
|
335
|
-
endpoint: "/api/analytics"
|
|
336
|
-
}), !this.analyticsConfig.trackingId)
|
|
337
|
-
throw new Error("Analytics plugin requires a tracking ID");
|
|
338
|
-
this.logger?.info("Analytics plugin initialized", {
|
|
339
|
-
trackingId: this.analyticsConfig.trackingId,
|
|
340
|
-
events: this.analyticsConfig.events
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
onActivate() {
|
|
344
|
-
const e = this.setupMediaEventListeners();
|
|
345
|
-
this.cleanupFunctions.push(e), this.analyticsConfig.endpoint && (this.reportTimer = setInterval(() => {
|
|
346
|
-
this.reportEvents();
|
|
347
|
-
}, 3e4), this.cleanupFunctions.push(() => {
|
|
348
|
-
this.reportTimer && clearInterval(this.reportTimer);
|
|
349
|
-
})), this.trackEvent("plugin_activated", { plugin: "analytics" }), this.logger?.info("Analytics tracking started");
|
|
350
|
-
}
|
|
351
|
-
onDeactivate() {
|
|
352
|
-
this.cleanupFunctions.forEach((e) => e()), this.cleanupFunctions = [], this.events.length > 0 && this.reportEvents(), this.trackEvent("plugin_deactivated", { plugin: "analytics" }), this.logger?.info("Analytics tracking stopped");
|
|
353
|
-
}
|
|
354
|
-
onConfigure(e) {
|
|
355
|
-
if (this.analyticsConfig = { ...this.analyticsConfig, ...e }, e.events) {
|
|
356
|
-
this.cleanupFunctions.forEach((n) => n()), this.cleanupFunctions = [];
|
|
357
|
-
const i = this.setupMediaEventListeners();
|
|
358
|
-
this.cleanupFunctions.push(i);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
setupMediaEventListeners() {
|
|
362
|
-
const e = [];
|
|
363
|
-
if (this.analyticsConfig.events.includes("play")) {
|
|
364
|
-
const i = this.on("media:play", (n) => {
|
|
365
|
-
this.trackEvent("play", n);
|
|
366
|
-
});
|
|
367
|
-
e.push(i);
|
|
368
|
-
}
|
|
369
|
-
if (this.analyticsConfig.events.includes("pause")) {
|
|
370
|
-
const i = this.on("media:pause", (n) => {
|
|
371
|
-
this.trackEvent("pause", n);
|
|
372
|
-
});
|
|
373
|
-
e.push(i);
|
|
374
|
-
}
|
|
375
|
-
if (this.analyticsConfig.events.includes("seek")) {
|
|
376
|
-
const i = this.on("media:seek", (n) => {
|
|
377
|
-
this.trackEvent("seek", n);
|
|
378
|
-
});
|
|
379
|
-
e.push(i);
|
|
380
|
-
}
|
|
381
|
-
if (this.analyticsConfig.events.includes("ended")) {
|
|
382
|
-
const i = this.on("media:ended", (n) => {
|
|
383
|
-
this.trackEvent("ended", n);
|
|
384
|
-
});
|
|
385
|
-
e.push(i);
|
|
386
|
-
}
|
|
387
|
-
if (this.analyticsConfig.events.includes("error")) {
|
|
388
|
-
const i = this.on("media:error", (n) => {
|
|
389
|
-
this.trackEvent("error", n);
|
|
390
|
-
});
|
|
391
|
-
e.push(i);
|
|
392
|
-
}
|
|
393
|
-
return () => {
|
|
394
|
-
e.forEach((i) => i());
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
trackEvent(e, i) {
|
|
398
|
-
if (Math.random() > this.analyticsConfig.samplingRate)
|
|
399
|
-
return;
|
|
400
|
-
const n = {
|
|
401
|
-
event: e,
|
|
402
|
-
timestamp: Date.now(),
|
|
403
|
-
data: {
|
|
404
|
-
...i,
|
|
405
|
-
trackingId: this.analyticsConfig.trackingId,
|
|
406
|
-
sessionId: this.generateSessionId(),
|
|
407
|
-
mediaState: {
|
|
408
|
-
currentTime: this.state?.currentTime,
|
|
409
|
-
duration: this.state?.duration,
|
|
410
|
-
volume: this.state?.volume,
|
|
411
|
-
isPlaying: this.state?.isPlaying
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
this.events.push(n), this.analyticsConfig.debug && this.logger?.info("Analytics event tracked", n), this.emit("analytics:event", n);
|
|
416
|
-
}
|
|
417
|
-
async reportEvents() {
|
|
418
|
-
if (this.events.length === 0 || !this.analyticsConfig.endpoint)
|
|
419
|
-
return;
|
|
420
|
-
const e = [...this.events];
|
|
421
|
-
this.events = [];
|
|
422
|
-
try {
|
|
423
|
-
const i = await fetch(this.analyticsConfig.endpoint, {
|
|
424
|
-
method: "POST",
|
|
425
|
-
headers: {
|
|
426
|
-
"Content-Type": "application/json"
|
|
427
|
-
},
|
|
428
|
-
body: JSON.stringify({
|
|
429
|
-
trackingId: this.analyticsConfig.trackingId,
|
|
430
|
-
events: e
|
|
431
|
-
})
|
|
432
|
-
});
|
|
433
|
-
if (!i.ok)
|
|
434
|
-
throw new Error(`Analytics report failed: ${i.status}`);
|
|
435
|
-
this.analyticsConfig.debug && this.logger?.info(`Reported ${e.length} analytics events`);
|
|
436
|
-
} catch (i) {
|
|
437
|
-
this.events.unshift(...e), this.logger?.error("Failed to report analytics events", i);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
generateSessionId() {
|
|
441
|
-
return `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
442
|
-
}
|
|
443
|
-
// Public API for manual event tracking
|
|
444
|
-
track(e, i) {
|
|
445
|
-
this.trackEvent(e, i);
|
|
446
|
-
}
|
|
447
|
-
// Get pending events count
|
|
448
|
-
getPendingEventsCount() {
|
|
449
|
-
return this.events.length;
|
|
450
|
-
}
|
|
451
|
-
// Flush all pending events
|
|
452
|
-
async flush() {
|
|
453
|
-
await this.reportEvents();
|
|
454
|
-
}
|
|
455
|
-
onHealthCheck() {
|
|
456
|
-
return this.events.length < 1e3;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
const x = (r) => new P(r);
|
|
460
|
-
class d {
|
|
461
|
-
constructor(t = "[Plugin]") {
|
|
462
|
-
o(this, "prefix");
|
|
463
|
-
this.prefix = t;
|
|
464
|
-
}
|
|
465
|
-
info(t, e) {
|
|
466
|
-
e ? console.info(`${this.prefix} ${t}`, e) : console.info(`${this.prefix} ${t}`);
|
|
467
|
-
}
|
|
468
|
-
warn(t, e) {
|
|
469
|
-
e ? console.warn(`${this.prefix} ${t}`, e) : console.warn(`${this.prefix} ${t}`);
|
|
470
|
-
}
|
|
471
|
-
error(t, e) {
|
|
472
|
-
e ? console.error(`${this.prefix} ${t}`, e) : console.error(`${this.prefix} ${t}`);
|
|
473
|
-
}
|
|
474
|
-
debug(t, e) {
|
|
475
|
-
process.env.NODE_ENV === "development" && (e ? console.debug(`${this.prefix} ${t}`, e) : console.debug(`${this.prefix} ${t}`));
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
class z {
|
|
479
|
-
static validateMetadata(t) {
|
|
480
|
-
const { metadata: e } = t;
|
|
481
|
-
if (!e.name || typeof e.name != "string")
|
|
482
|
-
throw new Error("Plugin metadata must include a valid name");
|
|
483
|
-
if (!e.version || typeof e.version != "string")
|
|
484
|
-
throw new Error("Plugin metadata must include a valid version");
|
|
485
|
-
if (!e.description || typeof e.description != "string")
|
|
486
|
-
throw new Error("Plugin metadata must include a valid description");
|
|
487
|
-
if (!e.category)
|
|
488
|
-
throw new Error("Plugin metadata must include a valid category");
|
|
489
|
-
if (!e.priority)
|
|
490
|
-
throw new Error("Plugin metadata must include a valid priority");
|
|
491
|
-
return !0;
|
|
492
|
-
}
|
|
493
|
-
static validateConfig(t, e) {
|
|
494
|
-
if (!e) return !0;
|
|
495
|
-
for (const [i, n] of Object.entries(e)) {
|
|
496
|
-
const s = t[i];
|
|
497
|
-
if (n.required && s == null)
|
|
498
|
-
throw new Error(`Configuration property '${i}' is required`);
|
|
499
|
-
if (s !== void 0 && n.type && typeof s !== n.type)
|
|
500
|
-
throw new Error(`Configuration property '${i}' must be of type '${n.type}'`);
|
|
501
|
-
if (n.enum && !n.enum.includes(s))
|
|
502
|
-
throw new Error(`Configuration property '${i}' must be one of: ${n.enum.join(", ")}`);
|
|
503
|
-
if (n.min !== void 0 && typeof s == "number" && s < n.min)
|
|
504
|
-
throw new Error(`Configuration property '${i}' must be at least ${n.min}`);
|
|
505
|
-
if (n.max !== void 0 && typeof s == "number" && s > n.max)
|
|
506
|
-
throw new Error(`Configuration property '${i}' must be at most ${n.max}`);
|
|
507
|
-
}
|
|
508
|
-
return !0;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
class $ {
|
|
512
|
-
constructor() {
|
|
513
|
-
o(this, "metrics", /* @__PURE__ */ new Map());
|
|
514
|
-
}
|
|
515
|
-
measure(t, e, i) {
|
|
516
|
-
const n = `${t}.${e}`, s = performance.now(), c = () => {
|
|
517
|
-
const a = performance.now(), h = a - s, g = this.metrics.get(n) || {
|
|
518
|
-
calls: 0,
|
|
519
|
-
totalTime: 0,
|
|
520
|
-
averageTime: 0,
|
|
521
|
-
lastCall: 0
|
|
522
|
-
};
|
|
523
|
-
g.calls++, g.totalTime += h, g.averageTime = g.totalTime / g.calls, g.lastCall = a, this.metrics.set(n, g);
|
|
524
|
-
}, u = i();
|
|
525
|
-
return u instanceof Promise ? u.then(
|
|
526
|
-
(a) => (c(), a),
|
|
527
|
-
(a) => {
|
|
528
|
-
throw c(), a;
|
|
529
|
-
}
|
|
530
|
-
) : (c(), u);
|
|
531
|
-
}
|
|
532
|
-
getMetrics(t) {
|
|
533
|
-
if (t) {
|
|
534
|
-
const e = {};
|
|
535
|
-
for (const [i, n] of this.metrics.entries())
|
|
536
|
-
if (i.startsWith(`${t}.`)) {
|
|
537
|
-
const s = i.substring(t.length + 1);
|
|
538
|
-
e[s] = n;
|
|
539
|
-
}
|
|
540
|
-
return e;
|
|
541
|
-
}
|
|
542
|
-
return Object.fromEntries(this.metrics.entries());
|
|
543
|
-
}
|
|
544
|
-
reset(t) {
|
|
545
|
-
if (t)
|
|
546
|
-
for (const e of this.metrics.keys())
|
|
547
|
-
e.startsWith(`${t}.`) && this.metrics.delete(e);
|
|
548
|
-
else
|
|
549
|
-
this.metrics.clear();
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
const F = {
|
|
553
|
-
// Create a mock plugin context for testing
|
|
554
|
-
createMockContext() {
|
|
555
|
-
return {
|
|
556
|
-
state: {
|
|
557
|
-
isPlaying: !1,
|
|
558
|
-
currentTime: 0,
|
|
559
|
-
duration: 0,
|
|
560
|
-
volume: 1,
|
|
561
|
-
isMuted: !1,
|
|
562
|
-
isLoading: !1,
|
|
563
|
-
error: null
|
|
564
|
-
},
|
|
565
|
-
controls: {
|
|
566
|
-
play: () => Promise.resolve(),
|
|
567
|
-
pause: () => Promise.resolve(),
|
|
568
|
-
seek: (r) => Promise.resolve(),
|
|
569
|
-
setVolume: (r) => Promise.resolve(),
|
|
570
|
-
mute: () => Promise.resolve(),
|
|
571
|
-
unmute: () => Promise.resolve(),
|
|
572
|
-
toggleMute: () => Promise.resolve()
|
|
573
|
-
},
|
|
574
|
-
plugins: {
|
|
575
|
-
get: () => {
|
|
576
|
-
},
|
|
577
|
-
getAll: () => [],
|
|
578
|
-
isEnabled: () => !1
|
|
579
|
-
},
|
|
580
|
-
emit: () => {
|
|
581
|
-
},
|
|
582
|
-
on: () => () => {
|
|
583
|
-
},
|
|
584
|
-
element: null,
|
|
585
|
-
logger: new d("[MockPlugin]")
|
|
586
|
-
};
|
|
587
|
-
},
|
|
588
|
-
// Create a test plugin for development
|
|
589
|
-
createTestPlugin(r, t = {}) {
|
|
590
|
-
return {
|
|
591
|
-
metadata: {
|
|
592
|
-
name: r,
|
|
593
|
-
version: "1.0.0",
|
|
594
|
-
description: `Test plugin: ${r}`,
|
|
595
|
-
category: "ui",
|
|
596
|
-
priority: "medium"
|
|
597
|
-
},
|
|
598
|
-
initialize: async () => {
|
|
599
|
-
},
|
|
600
|
-
activate: async () => {
|
|
601
|
-
},
|
|
602
|
-
deactivate: async () => {
|
|
603
|
-
},
|
|
604
|
-
destroy: async () => {
|
|
605
|
-
},
|
|
606
|
-
healthCheck: () => !0,
|
|
607
|
-
...t
|
|
608
|
-
};
|
|
609
|
-
},
|
|
610
|
-
// Plugin timing utilities
|
|
611
|
-
time: {
|
|
612
|
-
async: async (r, t) => {
|
|
613
|
-
console.time(r);
|
|
614
|
-
try {
|
|
615
|
-
const e = await t();
|
|
616
|
-
return console.timeEnd(r), e;
|
|
617
|
-
} catch (e) {
|
|
618
|
-
throw console.timeEnd(r), e;
|
|
619
|
-
}
|
|
620
|
-
},
|
|
621
|
-
sync: (r, t) => {
|
|
622
|
-
console.time(r);
|
|
623
|
-
try {
|
|
624
|
-
const e = t();
|
|
625
|
-
return console.timeEnd(r), e;
|
|
626
|
-
} catch (e) {
|
|
627
|
-
throw console.timeEnd(r), e;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
class I {
|
|
633
|
-
constructor(t) {
|
|
634
|
-
o(this, "prefix");
|
|
635
|
-
this.prefix = `baroi-plugin-${t}`;
|
|
636
|
-
}
|
|
637
|
-
get(t, e) {
|
|
638
|
-
try {
|
|
639
|
-
const i = localStorage.getItem(`${this.prefix}-${t}`);
|
|
640
|
-
return i ? JSON.parse(i) : e;
|
|
641
|
-
} catch {
|
|
642
|
-
return e;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
set(t, e) {
|
|
646
|
-
try {
|
|
647
|
-
localStorage.setItem(`${this.prefix}-${t}`, JSON.stringify(e));
|
|
648
|
-
} catch (i) {
|
|
649
|
-
console.warn(`Failed to store plugin data for key: ${t}`, i);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
remove(t) {
|
|
653
|
-
try {
|
|
654
|
-
localStorage.removeItem(`${this.prefix}-${t}`);
|
|
655
|
-
} catch (e) {
|
|
656
|
-
console.warn(`Failed to remove plugin data for key: ${t}`, e);
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
clear() {
|
|
660
|
-
try {
|
|
661
|
-
Object.keys(localStorage).filter((e) => e.startsWith(`${this.prefix}-`)).forEach((e) => localStorage.removeItem(e));
|
|
662
|
-
} catch (t) {
|
|
663
|
-
console.warn("Failed to clear plugin data", t);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
const B = new d(), M = new $(), T = "1.0.0";
|
|
668
|
-
export {
|
|
669
|
-
P as A,
|
|
670
|
-
m as B,
|
|
671
|
-
d as C,
|
|
672
|
-
b as P,
|
|
673
|
-
T as a,
|
|
674
|
-
l as b,
|
|
675
|
-
v as c,
|
|
676
|
-
w as d,
|
|
677
|
-
k as e,
|
|
678
|
-
x as f,
|
|
679
|
-
z as g,
|
|
680
|
-
$ as h,
|
|
681
|
-
F as i,
|
|
682
|
-
I as j,
|
|
683
|
-
B as k,
|
|
684
|
-
M as l
|
|
685
|
-
};
|
|
686
|
-
//# sourceMappingURL=core-plugins-CROGvQUy.js.map
|