@therealtinhtute/baroiplayer 1.2.1 → 2.0.0-beta.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 +90 -71
- package/dist/components/icons/index.d.ts +36 -0
- package/dist/components/icons/index.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/AudioIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/AudioIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/BackwardIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/BackwardIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/CameraIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/CameraIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/CheckIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/CheckIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ForwardIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/ForwardIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/LoadingIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/LoadingIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PauseIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PauseIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PlayIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PlayIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/QualityIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/QualityIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SettingsIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SettingsIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SliderIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SliderIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SubtitleIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SubtitleIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/UnPiPIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/UnPiPIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-audio.d.ts +13 -0
- package/dist/components/variants/gradient/gradient-audio.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-controls.d.ts +4 -0
- package/dist/components/variants/gradient/gradient-controls.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-glyphs.d.ts +30 -0
- package/dist/components/variants/gradient/gradient-glyphs.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-video.d.ts +16 -0
- package/dist/components/variants/gradient/gradient-video.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +750 -5640
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +3 -0
- package/package.json +110 -114
- package/src/components/variants/gradient/gradient-audio.tsx +47 -0
- package/src/components/variants/gradient/gradient-controls.tsx +254 -0
- package/src/components/variants/gradient/gradient-glyphs.test.tsx +69 -0
- package/src/components/variants/gradient/gradient-glyphs.tsx +129 -0
- package/src/components/variants/gradient/gradient-skin.css +211 -0
- package/src/components/variants/gradient/gradient-video.tsx +70 -0
- package/src/index.ts +5 -198
- package/src/test/accessibility-utils.ts +0 -59
- package/dist/context/media.js +0 -1
- package/dist/context/media.mjs +0 -3
- package/dist/context/store.js +0 -1
- package/dist/context/store.mjs +0 -3
- package/dist/context-Bzd5QCKM.cjs +0 -7
- package/dist/context-Bzd5QCKM.cjs.map +0 -1
- package/dist/context-DD_SH4tT.js +0 -1053
- package/dist/context-DD_SH4tT.js.map +0 -1
- package/dist/core-events-BRnLMB7s.cjs +0 -2
- package/dist/core-events-BRnLMB7s.cjs.map +0 -1
- package/dist/core-events-v_mKdj5p.js +0 -417
- package/dist/core-events-v_mKdj5p.js.map +0 -1
- package/dist/core-plugins-CMBv-yVh.cjs +0 -2
- package/dist/core-plugins-CMBv-yVh.cjs.map +0 -1
- package/dist/core-plugins-CqCxLkbd.js +0 -754
- package/dist/core-plugins-CqCxLkbd.js.map +0 -1
- package/dist/core.js +0 -15
- package/dist/core.js.map +0 -1
- package/dist/core.mjs +0 -960
- package/dist/core.mjs.map +0 -1
- package/dist/enhanced-components-BwjBqSA1.js +0 -2858
- package/dist/enhanced-components-BwjBqSA1.js.map +0 -1
- package/dist/enhanced-components-C-ka-XLp.cjs +0 -2
- package/dist/enhanced-components-C-ka-XLp.cjs.map +0 -1
- package/dist/hooks-B-IIWPJr.js +0 -1842
- package/dist/hooks-B-IIWPJr.js.map +0 -1
- package/dist/hooks-DcHzmBwA.cjs +0 -4
- package/dist/hooks-DcHzmBwA.cjs.map +0 -1
- package/dist/minimal-components-BYsMQde5.js +0 -1610
- package/dist/minimal-components-BYsMQde5.js.map +0 -1
- package/dist/minimal-components-CsxQbDp7.cjs +0 -2
- package/dist/minimal-components-CsxQbDp7.cjs.map +0 -1
- package/dist/minimal-components.css +0 -1
- package/dist/mona-loading.gif +0 -0
- package/dist/performance-monitor-DCSijLJg.js +0 -312
- package/dist/performance-monitor-DCSijLJg.js.map +0 -1
- package/dist/performance-monitor-wNFKmqMr.cjs +0 -2
- package/dist/performance-monitor-wNFKmqMr.cjs.map +0 -1
- package/dist/rolldown-runtime-BmowowmI.js +0 -14
- package/dist/rolldown-runtime-mLOUI7ql.cjs +0 -1
- package/dist/utils-D2gQ7c2R.js +0 -64
- package/dist/utils-D2gQ7c2R.js.map +0 -1
- package/dist/utils-DJaAwiZ9.cjs +0 -2
- package/dist/utils-DJaAwiZ9.cjs.map +0 -1
- package/dist/utils.js +0 -1
- package/dist/utils.mjs +0 -3
- package/src/adapters/videojs-adapter.tsx +0 -470
- package/src/assets/mona-loading.gif +0 -0
- package/src/components/AnimateLoading.tsx +0 -111
- package/src/components/LoadingState.tsx +0 -239
- package/src/components/__tests__/media-player-accessibility.test.tsx +0 -510
- package/src/components/__tests__/media-player-react19.test.tsx +0 -457
- package/src/components/accessibility/keyboard-help-overlay.tsx +0 -207
- package/src/components/audio-player.tsx +0 -85
- package/src/components/basic/index.ts +0 -37
- package/src/components/enhanced/advanced-features.tsx +0 -311
- package/src/components/enhanced/debug-panel.tsx +0 -448
- package/src/components/enhanced/enhanced-controls.tsx +0 -597
- package/src/components/enhanced/enhanced-media-player.tsx +0 -566
- package/src/components/enhanced/error-handling.tsx +0 -338
- package/src/components/enhanced/index.ts +0 -39
- package/src/components/enhanced/media-player-enhanced.tsx +0 -383
- package/src/components/examples/basic-video-player.tsx +0 -50
- package/src/components/examples/custom-controls-example.tsx +0 -63
- package/src/components/examples/enhanced-controls-example.tsx +0 -100
- package/src/components/examples/enhanced-media-player-example.tsx +0 -302
- package/src/components/examples/loading-states-demo.tsx +0 -141
- package/src/components/examples/react-19-demo.tsx +0 -349
- package/src/components/examples/volume-orientation-demo.tsx +0 -105
- package/src/components/icon-demo.tsx +0 -196
- package/src/components/legacy.tsx +0 -87
- package/src/components/media-metadata-display.tsx +0 -99
- package/src/components/media-player-audio.tsx +0 -39
- package/src/components/media-player-controls.tsx +0 -223
- package/src/components/media-player-error.tsx +0 -163
- package/src/components/media-player-fullscreen.tsx +0 -109
- package/src/components/media-player-hls.tsx +0 -111
- package/src/components/media-player-loading.tsx +0 -76
- package/src/components/media-player-play.tsx +0 -75
- package/src/components/media-player-root.tsx +0 -338
- package/src/components/media-player-seek.tsx +0 -168
- package/src/components/media-player-time.tsx +0 -99
- package/src/components/media-player-tooltip.tsx +0 -58
- package/src/components/media-player-video.tsx +0 -54
- package/src/components/media-player-volume.tsx +0 -155
- package/src/components/media-player.tsx +0 -292
- package/src/components/media-suspense.tsx +0 -344
- package/src/components/player-settings-form.tsx +0 -158
- package/src/components/react-player-wrapper.tsx +0 -651
- package/src/components/simple-video-player.tsx +0 -62
- package/src/components/ui/blur-poster.tsx +0 -96
- package/src/components/ui/empty-state.tsx +0 -91
- package/src/components/ui/enhanced-seek-bar.tsx +0 -254
- package/src/components/ui/error-state.tsx +0 -124
- package/src/components/ui/fullscreen-button.tsx +0 -81
- package/src/components/ui/loading-skeleton.tsx +0 -107
- package/src/components/ui/media-resource-preloader.tsx +0 -458
- package/src/components/ui/offline-message.tsx +0 -98
- package/src/components/ui/play-button.tsx +0 -99
- package/src/components/ui/seek-bar.tsx +0 -191
- package/src/components/ui/time-display.tsx +0 -61
- package/src/components/ui/volume-control.tsx +0 -190
- package/src/components/unified/base-media-player.tsx +0 -252
- package/src/components/unified/media-player.tsx +0 -75
- package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +0 -587
- package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +0 -573
- package/src/components/variants/minimal/MinimalControls.tsx +0 -124
- package/src/components/variants/minimal/MinimalLoading.tsx +0 -28
- package/src/components/variants/minimal/MinimalMediaPlayer.tsx +0 -318
- package/src/components/variants/minimal/MinimalOverlay.tsx +0 -58
- package/src/components/variants/minimal/MinimalPlayButton.tsx +0 -56
- package/src/components/variants/minimal/MinimalSeekBar.tsx +0 -140
- package/src/components/variants/minimal/MinimalVolumeControl.tsx +0 -75
- package/src/components/variants/minimal/SimpleMinimalPlayer.tsx +0 -206
- package/src/components/variants/minimal/components/CenterPlayButton.tsx +0 -22
- package/src/components/variants/minimal/components/ControlBar.tsx +0 -142
- package/src/components/variants/minimal/components/EnhancedSettingsMenu.tsx +0 -412
- package/src/components/variants/minimal/components/PlaybackControls.tsx +0 -46
- package/src/components/variants/minimal/components/RightControls.tsx +0 -164
- package/src/components/variants/minimal/components/SeekBar.tsx +0 -127
- package/src/components/variants/minimal/components/SettingsDropdown.tsx +0 -68
- package/src/components/variants/minimal/components/SubtitleDisplay.tsx +0 -21
- package/src/components/variants/minimal/components/TimeDisplay.tsx +0 -15
- package/src/components/variants/minimal/components/VideoElement.tsx +0 -35
- package/src/components/variants/minimal/components/VolumeControl.tsx +0 -220
- package/src/components/variants/minimal/index.ts +0 -23
- package/src/components/video-player.tsx +0 -100
- package/src/context/__tests__/media-store.test.ts +0 -509
- package/src/context/error-handling.ts +0 -398
- package/src/context/media-context.tsx +0 -254
- package/src/context/media-provider.tsx +0 -264
- package/src/context/media-store.ts +0 -387
- package/src/context/persistence.ts +0 -462
- package/src/core/events/event-system.ts +0 -448
- package/src/core/events/hooks.ts +0 -325
- package/src/core/events/index.ts +0 -22
- package/src/core/events/middleware.ts +0 -286
- package/src/core/index.ts +0 -22
- package/src/core/optimization/bundle-optimizer.tsx +0 -312
- package/src/core/performance/cicd.ts +0 -98
- package/src/core/performance/index.ts +0 -38
- package/src/core/performance/media-loading-optimizer.ts +0 -545
- package/src/core/performance/performance-budgets.ts +0 -437
- package/src/core/performance/performance-monitor.tsx +0 -488
- package/src/core/performance/performance-testing.ts +0 -461
- package/src/core/plugins/__tests__/registry.test.ts +0 -595
- package/src/core/plugins/base-plugin.ts +0 -225
- package/src/core/plugins/enhanced-plugin-system.ts +0 -435
- package/src/core/plugins/examples/analytics-plugin.ts +0 -241
- package/src/core/plugins/index.ts +0 -39
- package/src/core/plugins/registry.ts +0 -546
- package/src/core/plugins/types.ts +0 -169
- package/src/core/plugins/utils.ts +0 -317
- package/src/core/progressive-loading.tsx +0 -331
- package/src/core/providers/enhanced-hls-provider.ts +0 -307
- package/src/core/providers/lazy-provider.tsx +0 -14
- package/src/core/providers/service-provider.tsx +0 -164
- package/src/core/utils.tsx +0 -34
- package/src/features/media-session/media-session-manager.ts +0 -411
- package/src/features/picture-in-picture/pip-manager.ts +0 -428
- package/src/features/playlist/playlist-manager.ts +0 -626
- package/src/features/subtitles/subtitle-manager.ts +0 -435
- package/src/features/subtitles/subtitle-parser.ts +0 -284
- package/src/features/thumbnails/thumbnail-generator.ts +0 -528
- package/src/hooks/__tests__/currentTime-fix.test.ts +0 -149
- package/src/hooks/__tests__/use-media-player.test.ts +0 -712
- package/src/hooks/__tests__/use-media-state.test.tsx +0 -316
- package/src/hooks/accessibility/index.ts +0 -27
- package/src/hooks/accessibility/use-accessibility-preferences.ts +0 -190
- package/src/hooks/accessibility/use-focus-management.ts +0 -183
- package/src/hooks/accessibility/use-keyboard-shortcuts.ts +0 -152
- package/src/hooks/accessibility/use-screen-reader.ts +0 -212
- package/src/hooks/core/index.ts +0 -47
- package/src/hooks/legacy.ts +0 -21
- package/src/hooks/use-buffer-health.ts +0 -218
- package/src/hooks/use-enhanced-media-player.ts +0 -575
- package/src/hooks/use-focus-trap.tsx +0 -162
- package/src/hooks/use-intelligent-preloading.ts +0 -387
- package/src/hooks/use-keyboard-controls.ts +0 -115
- package/src/hooks/use-keyboard-shortcuts.ts +0 -255
- package/src/hooks/use-media-actions.ts +0 -184
- package/src/hooks/use-media-metadata.ts +0 -91
- package/src/hooks/use-media-optimistic.ts +0 -264
- package/src/hooks/use-media-player.ts +0 -343
- package/src/hooks/use-media-state.ts +0 -194
- package/src/hooks/use-memory-optimization.ts +0 -360
- package/src/hooks/use-network-status.ts +0 -124
- package/src/hooks/use-optimistic-controls.ts +0 -95
- package/src/hooks/use-optimized-media.ts +0 -283
- package/src/hooks/use-smart-preload.ts +0 -229
- package/src/hooks/use-touch-gestures.ts +0 -461
- package/src/hooks/useEnhancedSubtitles.ts +0 -258
- package/src/hooks/useKeyboardShortcuts.ts +0 -106
- package/src/hooks/useMediaControls.ts +0 -52
- package/src/hooks/useScreenshot.ts +0 -77
- package/src/hooks/useSubtitles.ts +0 -91
- package/src/hooks/useVideoPlayer.ts +0 -278
- package/src/icons/components/FullscreenIcon.tsx +0 -36
- package/src/icons/components/SettingsIcon.tsx +0 -37
- package/src/icons/components/animated/LoadingIcon.tsx +0 -27
- package/src/icons/components/animated/PlayPauseIcon.tsx +0 -42
- package/src/icons/components/media/PauseIcon.tsx +0 -38
- package/src/icons/components/media/PlayIcon.tsx +0 -37
- package/src/icons/components/volume/VolumeIcon.tsx +0 -38
- package/src/icons/components/volume/VolumeOffIcon.tsx +0 -38
- package/src/icons/index.ts +0 -56
- package/src/icons/provider.tsx +0 -58
- package/src/icons/types.ts +0 -60
- package/src/index-enhanced.ts +0 -35
- package/src/index-legacy.ts +0 -324
- package/src/index.css +0 -102
- package/src/lib/__tests__/async-utils.test.ts +0 -291
- package/src/lib/async-utils.ts +0 -194
- package/src/lib/deprecation.ts +0 -51
- package/src/lib/format-time.ts +0 -37
- package/src/lib/index.ts +0 -4
- package/src/lib/utils.ts +0 -6
- package/src/styles/globals.css +0 -462
- package/src/styles/minimal-player.css +0 -621
- package/src/styles/pixel-art.css +0 -41
- package/src/styles/videojs.css +0 -100
- package/src/types/assets.d.ts +0 -29
- package/src/types/events.ts +0 -47
- package/src/types/formats.ts +0 -79
- package/src/types/index.ts +0 -203
- package/src/types/videojs-plugins.d.ts +0 -14
|
@@ -1,754 +0,0 @@
|
|
|
1
|
-
import { r as e } from "./context-DD_SH4tT.js";
|
|
2
|
-
import { _ as t } from "./core-events-v_mKdj5p.js";
|
|
3
|
-
//#region src/core/plugins/types.ts
|
|
4
|
-
var n = class extends Error {
|
|
5
|
-
constructor(t, n, r, i) {
|
|
6
|
-
super(`Plugin '${t}' failed during ${n}: ${r}`), e(this, "pluginName", void 0), e(this, "phase", void 0), e(this, "originalError", void 0), this.pluginName = t, this.phase = n, this.originalError = i, this.name = "PluginError";
|
|
7
|
-
}
|
|
8
|
-
}, r = class extends n {
|
|
9
|
-
constructor(t, n) {
|
|
10
|
-
super(t, "initialize", `Missing dependencies: ${n.join(", ")}`), e(this, "missingDependencies", void 0), this.missingDependencies = n, this.name = "PluginDependencyError";
|
|
11
|
-
}
|
|
12
|
-
}, i = class extends n {
|
|
13
|
-
constructor(t, n) {
|
|
14
|
-
super(t, "activate", `Conflicts with active plugins: ${n.join(", ")}`), e(this, "conflictingPlugins", void 0), this.conflictingPlugins = n, this.name = "PluginConflictError";
|
|
15
|
-
}
|
|
16
|
-
}, a = class {
|
|
17
|
-
constructor(t = "[Plugin]") {
|
|
18
|
-
e(this, "prefix", void 0), this.prefix = t;
|
|
19
|
-
}
|
|
20
|
-
info(e, t) {
|
|
21
|
-
t ? console.info(`${this.prefix} ${e}`, t) : console.info(`${this.prefix} ${e}`);
|
|
22
|
-
}
|
|
23
|
-
warn(e, t) {
|
|
24
|
-
t ? console.warn(`${this.prefix} ${e}`, t) : console.warn(`${this.prefix} ${e}`);
|
|
25
|
-
}
|
|
26
|
-
error(e, t) {
|
|
27
|
-
t ? console.error(`${this.prefix} ${e}`, t) : console.error(`${this.prefix} ${e}`);
|
|
28
|
-
}
|
|
29
|
-
debug(e, t) {
|
|
30
|
-
process.env.NODE_ENV === "development" && (t ? console.debug(`${this.prefix} ${e}`, t) : console.debug(`${this.prefix} ${e}`));
|
|
31
|
-
}
|
|
32
|
-
}, o = class {
|
|
33
|
-
static validateMetadata(e) {
|
|
34
|
-
let { metadata: t } = e;
|
|
35
|
-
if (!t.name || typeof t.name != "string") throw Error("Plugin metadata must include a valid name");
|
|
36
|
-
if (!t.version || typeof t.version != "string") throw Error("Plugin metadata must include a valid version");
|
|
37
|
-
if (!t.description || typeof t.description != "string") throw Error("Plugin metadata must include a valid description");
|
|
38
|
-
if (!t.category) throw Error("Plugin metadata must include a valid category");
|
|
39
|
-
if (!t.priority) throw Error("Plugin metadata must include a valid priority");
|
|
40
|
-
return !0;
|
|
41
|
-
}
|
|
42
|
-
static validateConfig(e, t) {
|
|
43
|
-
if (!t) return !0;
|
|
44
|
-
for (let [n, r] of Object.entries(t)) {
|
|
45
|
-
let t = e[n];
|
|
46
|
-
if (r.required && t == null) throw Error(`Configuration property '${n}' is required`);
|
|
47
|
-
if (t !== void 0 && r.type && typeof t !== r.type) throw Error(`Configuration property '${n}' must be of type '${r.type}'`);
|
|
48
|
-
if (r.enum && !r.enum.includes(t)) throw Error(`Configuration property '${n}' must be one of: ${r.enum.join(", ")}`);
|
|
49
|
-
if (r.min !== void 0 && typeof t == "number" && t < r.min) throw Error(`Configuration property '${n}' must be at least ${r.min}`);
|
|
50
|
-
if (r.max !== void 0 && typeof t == "number" && t > r.max) throw Error(`Configuration property '${n}' must be at most ${r.max}`);
|
|
51
|
-
}
|
|
52
|
-
return !0;
|
|
53
|
-
}
|
|
54
|
-
}, s = class {
|
|
55
|
-
constructor() {
|
|
56
|
-
e(this, "metrics", /* @__PURE__ */ new Map());
|
|
57
|
-
}
|
|
58
|
-
measure(e, t, n) {
|
|
59
|
-
let r = `${e}.${t}`, i = performance.now(), a = () => {
|
|
60
|
-
let e = performance.now(), t = e - i, n = this.metrics.get(r) || {
|
|
61
|
-
calls: 0,
|
|
62
|
-
totalTime: 0,
|
|
63
|
-
averageTime: 0,
|
|
64
|
-
lastCall: 0
|
|
65
|
-
};
|
|
66
|
-
n.calls++, n.totalTime += t, n.averageTime = n.totalTime / n.calls, n.lastCall = e, this.metrics.set(r, n);
|
|
67
|
-
}, o = n();
|
|
68
|
-
return o instanceof Promise ? o.then((e) => (a(), e), (e) => {
|
|
69
|
-
throw a(), e;
|
|
70
|
-
}) : (a(), o);
|
|
71
|
-
}
|
|
72
|
-
getMetrics(e) {
|
|
73
|
-
if (e) {
|
|
74
|
-
let t = {};
|
|
75
|
-
for (let [n, r] of this.metrics.entries()) if (n.startsWith(`${e}.`)) {
|
|
76
|
-
let i = n.substring(e.length + 1);
|
|
77
|
-
t[i] = r;
|
|
78
|
-
}
|
|
79
|
-
return t;
|
|
80
|
-
}
|
|
81
|
-
return Object.fromEntries(this.metrics.entries());
|
|
82
|
-
}
|
|
83
|
-
reset(e) {
|
|
84
|
-
if (e) for (let t of this.metrics.keys()) t.startsWith(`${e}.`) && this.metrics.delete(t);
|
|
85
|
-
else this.metrics.clear();
|
|
86
|
-
}
|
|
87
|
-
}, c = {
|
|
88
|
-
createMockContext() {
|
|
89
|
-
return {
|
|
90
|
-
state: {
|
|
91
|
-
isPlaying: !1,
|
|
92
|
-
currentTime: 0,
|
|
93
|
-
duration: 0,
|
|
94
|
-
volume: 1,
|
|
95
|
-
isMuted: !1,
|
|
96
|
-
isLoading: !1,
|
|
97
|
-
error: null
|
|
98
|
-
},
|
|
99
|
-
controls: {
|
|
100
|
-
play: () => Promise.resolve(),
|
|
101
|
-
pause: () => Promise.resolve(),
|
|
102
|
-
seek: (e) => Promise.resolve(),
|
|
103
|
-
setVolume: (e) => Promise.resolve(),
|
|
104
|
-
mute: () => Promise.resolve(),
|
|
105
|
-
unmute: () => Promise.resolve(),
|
|
106
|
-
toggleMute: () => Promise.resolve()
|
|
107
|
-
},
|
|
108
|
-
plugins: {
|
|
109
|
-
get: () => void 0,
|
|
110
|
-
getAll: () => [],
|
|
111
|
-
isEnabled: () => !1
|
|
112
|
-
},
|
|
113
|
-
emit: () => {},
|
|
114
|
-
on: () => () => {},
|
|
115
|
-
element: null,
|
|
116
|
-
logger: new a("[MockPlugin]")
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
createTestPlugin(e, t = {}) {
|
|
120
|
-
return {
|
|
121
|
-
metadata: {
|
|
122
|
-
name: e,
|
|
123
|
-
version: "1.0.0",
|
|
124
|
-
description: `Test plugin: ${e}`,
|
|
125
|
-
category: "ui",
|
|
126
|
-
priority: "medium"
|
|
127
|
-
},
|
|
128
|
-
initialize: async () => {},
|
|
129
|
-
activate: async () => {},
|
|
130
|
-
deactivate: async () => {},
|
|
131
|
-
destroy: async () => {},
|
|
132
|
-
healthCheck: () => !0,
|
|
133
|
-
...t
|
|
134
|
-
};
|
|
135
|
-
},
|
|
136
|
-
time: {
|
|
137
|
-
async: async (e, t) => {
|
|
138
|
-
console.time(e);
|
|
139
|
-
try {
|
|
140
|
-
let n = await t();
|
|
141
|
-
return console.timeEnd(e), n;
|
|
142
|
-
} catch (t) {
|
|
143
|
-
throw console.timeEnd(e), t;
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
sync: (e, t) => {
|
|
147
|
-
console.time(e);
|
|
148
|
-
try {
|
|
149
|
-
let n = t();
|
|
150
|
-
return console.timeEnd(e), n;
|
|
151
|
-
} catch (t) {
|
|
152
|
-
throw console.timeEnd(e), t;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}, l = class {
|
|
157
|
-
constructor(t) {
|
|
158
|
-
e(this, "prefix", void 0), this.prefix = `baroi-plugin-${t}`;
|
|
159
|
-
}
|
|
160
|
-
get(e, t) {
|
|
161
|
-
try {
|
|
162
|
-
let n = localStorage.getItem(`${this.prefix}-${e}`);
|
|
163
|
-
return n ? JSON.parse(n) : t;
|
|
164
|
-
} catch {
|
|
165
|
-
return t;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
set(e, t) {
|
|
169
|
-
try {
|
|
170
|
-
localStorage.setItem(`${this.prefix}-${e}`, JSON.stringify(t));
|
|
171
|
-
} catch (t) {
|
|
172
|
-
console.warn(`Failed to store plugin data for key: ${e}`, t);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
remove(e) {
|
|
176
|
-
try {
|
|
177
|
-
localStorage.removeItem(`${this.prefix}-${e}`);
|
|
178
|
-
} catch (t) {
|
|
179
|
-
console.warn(`Failed to remove plugin data for key: ${e}`, t);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
clear() {
|
|
183
|
-
try {
|
|
184
|
-
Object.keys(localStorage).filter((e) => e.startsWith(`${this.prefix}-`)).forEach((e) => localStorage.removeItem(e));
|
|
185
|
-
} catch (e) {
|
|
186
|
-
console.warn("Failed to clear plugin data", e);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}, u = new a(), d = new s(), f = class {
|
|
190
|
-
constructor(n) {
|
|
191
|
-
e(this, "plugins", /* @__PURE__ */ new Map()), e(this, "pluginConfigs", /* @__PURE__ */ new Map()), e(this, "pluginContexts", /* @__PURE__ */ new Map()), e(this, "enabledPlugins", /* @__PURE__ */ new Set()), e(this, "eventBus", new t()), e(this, "logger", void 0), this.logger = n || new a("[PluginRegistry]");
|
|
192
|
-
}
|
|
193
|
-
register(e, t, r = {}) {
|
|
194
|
-
let i, a, o = {};
|
|
195
|
-
try {
|
|
196
|
-
if (typeof e == "string") i = e, a = t, o = r;
|
|
197
|
-
else {
|
|
198
|
-
let n = e;
|
|
199
|
-
o = t || {}, a = n(o), i = a?.metadata?.name;
|
|
200
|
-
}
|
|
201
|
-
if (!i || !a) throw new n("unknown", "initialize", "Invalid plugin registration payload");
|
|
202
|
-
if (this.plugins.has(i)) throw new n(i, "initialize", "Plugin already registered");
|
|
203
|
-
this.plugins.set(i, a), this.pluginConfigs.set(i, o), this.logger.info(`Plugin '${i}' registered successfully`), this.eventBus.emit("plugin:registered", {
|
|
204
|
-
name: i,
|
|
205
|
-
plugin: a
|
|
206
|
-
});
|
|
207
|
-
} catch (e) {
|
|
208
|
-
let t = i || a?.metadata?.name || "unknown";
|
|
209
|
-
throw this.logger.error(`Failed to register plugin '${t}'`, e), this.eventBus.emit("plugin:error", {
|
|
210
|
-
name: t,
|
|
211
|
-
error: e
|
|
212
|
-
}), e;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
async unregister(e, t) {
|
|
216
|
-
let r = this.plugins.get(e);
|
|
217
|
-
if (!r) throw new n(e, "destroy", "Plugin not found");
|
|
218
|
-
try {
|
|
219
|
-
let n = t || this.pluginContexts.get(e) || this.createPluginContext(e);
|
|
220
|
-
this.enabledPlugins.has(e) && await this.deactivate(e, n), r.isInitialized && await r.destroy(n), this.plugins.delete(e), this.pluginConfigs.delete(e), this.pluginContexts.delete(e), this.enabledPlugins.delete(e), this.logger.info(`Plugin '${e}' unregistered successfully`);
|
|
221
|
-
} catch (t) {
|
|
222
|
-
throw this.logger.error(`Failed to unregister plugin '${e}'`, t), t;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
get(e) {
|
|
226
|
-
return this.plugins.get(e);
|
|
227
|
-
}
|
|
228
|
-
has(e) {
|
|
229
|
-
return this.plugins.has(e);
|
|
230
|
-
}
|
|
231
|
-
getAll() {
|
|
232
|
-
return Array.from(this.plugins.values()).sort(this.sortByPriority);
|
|
233
|
-
}
|
|
234
|
-
getByCategory(e) {
|
|
235
|
-
return this.getAll().filter((t) => t.metadata.category === e);
|
|
236
|
-
}
|
|
237
|
-
getActive() {
|
|
238
|
-
return Array.from(this.enabledPlugins).map((e) => this.plugins.get(e)).filter((e) => !!e).sort(this.sortByPriority);
|
|
239
|
-
}
|
|
240
|
-
isEnabled(e) {
|
|
241
|
-
return this.enabledPlugins.has(e);
|
|
242
|
-
}
|
|
243
|
-
async initialize(e, t, r = {}) {
|
|
244
|
-
let i = this.plugins.get(e);
|
|
245
|
-
if (!i) throw new n(e, "initialize", "Plugin not found");
|
|
246
|
-
this.ensureDependenciesExist(e);
|
|
247
|
-
let a = {
|
|
248
|
-
...this.pluginConfigs.get(e) || {},
|
|
249
|
-
...r
|
|
250
|
-
};
|
|
251
|
-
this.pluginConfigs.set(e, a), this.pluginContexts.set(e, t);
|
|
252
|
-
try {
|
|
253
|
-
await i.initialize(t, a);
|
|
254
|
-
} catch (t) {
|
|
255
|
-
throw this.logger.error(`Failed to initialize plugin '${e}'`, t), this.eventBus.emit("plugin:error", {
|
|
256
|
-
name: e,
|
|
257
|
-
error: t
|
|
258
|
-
}), t;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
async activate(e, t) {
|
|
262
|
-
let r = this.plugins.get(e);
|
|
263
|
-
if (!r) throw new n(e, "activate", "Plugin not found");
|
|
264
|
-
this.ensureDependenciesActive(e), this.ensureNoActiveConflicts(e), this.pluginContexts.set(e, t);
|
|
265
|
-
try {
|
|
266
|
-
await r.activate(t), this.enabledPlugins.add(e), this.eventBus.emit("plugin:enabled", {
|
|
267
|
-
name: e,
|
|
268
|
-
plugin: r
|
|
269
|
-
});
|
|
270
|
-
} catch (t) {
|
|
271
|
-
throw this.logger.error(`Failed to activate plugin '${e}'`, t), this.eventBus.emit("plugin:error", {
|
|
272
|
-
name: e,
|
|
273
|
-
error: t
|
|
274
|
-
}), t;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
async deactivate(e, t) {
|
|
278
|
-
let r = this.plugins.get(e);
|
|
279
|
-
if (!r) throw new n(e, "deactivate", "Plugin not found");
|
|
280
|
-
this.pluginContexts.set(e, t);
|
|
281
|
-
try {
|
|
282
|
-
await r.deactivate(t), this.enabledPlugins.delete(e), this.eventBus.emit("plugin:disabled", {
|
|
283
|
-
name: e,
|
|
284
|
-
plugin: r
|
|
285
|
-
});
|
|
286
|
-
} catch (t) {
|
|
287
|
-
throw this.logger.error(`Failed to deactivate plugin '${e}'`, t), this.eventBus.emit("plugin:error", {
|
|
288
|
-
name: e,
|
|
289
|
-
error: t
|
|
290
|
-
}), t;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
async initializeAll(e) {
|
|
294
|
-
this.validateDependencies();
|
|
295
|
-
let t = this.getAll().map((e) => this.findPluginKey(e)).filter(Boolean);
|
|
296
|
-
for (let n of t) await this.initialize(n, e);
|
|
297
|
-
}
|
|
298
|
-
async activateAll(e) {
|
|
299
|
-
let t = this.getAll().map((e) => this.findPluginKey(e)).filter(Boolean);
|
|
300
|
-
for (let n of t) {
|
|
301
|
-
let t = this.plugins.get(n);
|
|
302
|
-
t && (t.isInitialized || await this.initialize(n, e), await this.activate(n, e));
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
async deactivateAll(e) {
|
|
306
|
-
let t = this.getAll().map((e) => this.findPluginKey(e)).filter(Boolean).reverse();
|
|
307
|
-
for (let n of t) this.enabledPlugins.has(n) && await this.deactivate(n, e);
|
|
308
|
-
}
|
|
309
|
-
async destroyAll(e) {
|
|
310
|
-
await this.deactivateAll(e);
|
|
311
|
-
let t = Array.from(this.plugins.keys());
|
|
312
|
-
for (let n of t) {
|
|
313
|
-
let t = this.plugins.get(n);
|
|
314
|
-
t && t.isInitialized && await t.destroy(e);
|
|
315
|
-
}
|
|
316
|
-
this.plugins.clear(), this.pluginConfigs.clear(), this.pluginContexts.clear(), this.enabledPlugins.clear();
|
|
317
|
-
}
|
|
318
|
-
validateDependencies() {
|
|
319
|
-
for (let [e, t] of this.plugins.entries()) {
|
|
320
|
-
let n = (t.metadata.dependencies || []).filter((e) => !this.plugins.has(e));
|
|
321
|
-
if (n.length > 0) throw new r(e, n);
|
|
322
|
-
}
|
|
323
|
-
let e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), i = (r) => {
|
|
324
|
-
if (e.has(r)) return;
|
|
325
|
-
if (t.has(r)) throw new n(r, "initialize", "Circular dependency detected");
|
|
326
|
-
t.add(r);
|
|
327
|
-
let a = this.plugins.get(r);
|
|
328
|
-
if (a) {
|
|
329
|
-
for (let e of a.metadata.dependencies || []) i(e);
|
|
330
|
-
t.delete(r), e.add(r);
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
for (let e of this.plugins.keys()) i(e);
|
|
334
|
-
}
|
|
335
|
-
validateConflicts() {
|
|
336
|
-
for (let [e, t] of this.plugins.entries()) {
|
|
337
|
-
let n = (t.metadata.conflicts || []).filter((e) => this.plugins.has(e));
|
|
338
|
-
if (n.length > 0) throw new i(e, n);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
healthCheck(e) {
|
|
342
|
-
if (typeof e == "string") {
|
|
343
|
-
let t = this.plugins.get(e);
|
|
344
|
-
if (!t) return !1;
|
|
345
|
-
try {
|
|
346
|
-
let e = t.onInitializeCalled;
|
|
347
|
-
return typeof e == "boolean" ? e : t.healthCheck ? !!t.healthCheck() : typeof t.isInitialized == "boolean" && t.isInitialized;
|
|
348
|
-
} catch {
|
|
349
|
-
return !1;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
return this.healthCheckEnabledPlugins();
|
|
353
|
-
}
|
|
354
|
-
healthCheckAll() {
|
|
355
|
-
let e = {};
|
|
356
|
-
for (let t of this.plugins.keys()) e[t] = this.healthCheck(t);
|
|
357
|
-
return e;
|
|
358
|
-
}
|
|
359
|
-
async enable(e) {
|
|
360
|
-
let t = this.plugins.get(e);
|
|
361
|
-
if (!t) throw new n(e, "activate", "Plugin not found");
|
|
362
|
-
if (this.enabledPlugins.has(e)) {
|
|
363
|
-
this.logger.warn(`Plugin '${e}' is already enabled`);
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
let r = this.pluginContexts.get(e) || this.createPluginContext(e);
|
|
367
|
-
t.isInitialized || await this.initialize(e, r), await this.activate(e, r);
|
|
368
|
-
}
|
|
369
|
-
async disable(e) {
|
|
370
|
-
let t = this.plugins.get(e);
|
|
371
|
-
if (!t) throw new n(e, "deactivate", "Plugin not found");
|
|
372
|
-
if (!this.enabledPlugins.has(e)) {
|
|
373
|
-
this.logger.warn(`Plugin '${e}' is already disabled`);
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
let r = this.pluginContexts.get(e) || this.createPluginContext(e);
|
|
377
|
-
await this.deactivate(e, r), await t.destroy(r);
|
|
378
|
-
}
|
|
379
|
-
async configure(e, t) {
|
|
380
|
-
let r = this.plugins.get(e);
|
|
381
|
-
if (!r) throw new n(e, "initialize", "Plugin not found");
|
|
382
|
-
try {
|
|
383
|
-
this.pluginConfigs.set(e, {
|
|
384
|
-
...this.pluginConfigs.get(e),
|
|
385
|
-
...t
|
|
386
|
-
}), r.configure && await r.configure(t), this.logger.info(`Plugin '${e}' configured successfully`), this.eventBus.emit("plugin:configured", {
|
|
387
|
-
name: e,
|
|
388
|
-
config: t
|
|
389
|
-
});
|
|
390
|
-
} catch (t) {
|
|
391
|
-
throw this.logger.error(`Failed to configure plugin '${e}'`, t), this.eventBus.emit("plugin:error", {
|
|
392
|
-
name: e,
|
|
393
|
-
error: t
|
|
394
|
-
}), t;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
async enablePlugins(e) {
|
|
398
|
-
let t = this.resolveDependencies(e);
|
|
399
|
-
for (let e of t) this.enabledPlugins.has(e) || await this.enable(e);
|
|
400
|
-
}
|
|
401
|
-
async disablePlugins(e) {
|
|
402
|
-
let t = [...e].reverse();
|
|
403
|
-
for (let e of t) this.enabledPlugins.has(e) && await this.disable(e);
|
|
404
|
-
}
|
|
405
|
-
getEnabledPlugins() {
|
|
406
|
-
return this.getActive();
|
|
407
|
-
}
|
|
408
|
-
on(e, t) {
|
|
409
|
-
return this.eventBus.on(e, t), () => this.eventBus.off(e, t);
|
|
410
|
-
}
|
|
411
|
-
async healthCheckEnabledPlugins() {
|
|
412
|
-
let e = [];
|
|
413
|
-
for (let t of this.enabledPlugins) {
|
|
414
|
-
let n = this.plugins.get(t);
|
|
415
|
-
if (n) try {
|
|
416
|
-
let r = !n.healthCheck || n.healthCheck(), i = r instanceof Promise ? await r : !!r;
|
|
417
|
-
e.push({
|
|
418
|
-
name: t,
|
|
419
|
-
healthy: i
|
|
420
|
-
});
|
|
421
|
-
} catch (n) {
|
|
422
|
-
e.push({
|
|
423
|
-
name: t,
|
|
424
|
-
healthy: !1,
|
|
425
|
-
error: n
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
return e;
|
|
430
|
-
}
|
|
431
|
-
findPluginKey(e) {
|
|
432
|
-
for (let [t, n] of this.plugins.entries()) if (n === e) return t;
|
|
433
|
-
}
|
|
434
|
-
ensureDependenciesExist(e) {
|
|
435
|
-
let t = this.plugins.get(e);
|
|
436
|
-
if (!t) return;
|
|
437
|
-
let n = (t.metadata.dependencies || []).filter((e) => !this.plugins.has(e));
|
|
438
|
-
if (n.length > 0) throw new r(e, n);
|
|
439
|
-
}
|
|
440
|
-
ensureDependenciesActive(e) {
|
|
441
|
-
let t = this.plugins.get(e);
|
|
442
|
-
if (!t) return;
|
|
443
|
-
let n = (t.metadata.dependencies || []).filter((e) => !this.enabledPlugins.has(e));
|
|
444
|
-
if (n.length > 0) throw new r(e, n);
|
|
445
|
-
}
|
|
446
|
-
ensureNoActiveConflicts(e) {
|
|
447
|
-
let t = this.plugins.get(e);
|
|
448
|
-
if (!t) return;
|
|
449
|
-
let n = (t.metadata.conflicts || []).filter((e) => this.enabledPlugins.has(e));
|
|
450
|
-
if (n.length > 0) throw new i(e, n);
|
|
451
|
-
}
|
|
452
|
-
createPluginContext(e) {
|
|
453
|
-
return {
|
|
454
|
-
state: {},
|
|
455
|
-
controls: {},
|
|
456
|
-
plugins: this,
|
|
457
|
-
emit: (e, t) => this.eventBus.emit(e, t),
|
|
458
|
-
on: (e, t) => (this.eventBus.on(e, t), () => this.eventBus.off(e, t)),
|
|
459
|
-
element: null,
|
|
460
|
-
logger: this.createPluginLogger(e)
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
createPluginLogger(e) {
|
|
464
|
-
return {
|
|
465
|
-
info: (t, n) => this.logger.info(`[${e}] ${t}`, n),
|
|
466
|
-
warn: (t, n) => this.logger.warn(`[${e}] ${t}`, n),
|
|
467
|
-
error: (t, n) => this.logger.error(`[${e}] ${t}`, n),
|
|
468
|
-
debug: (t, n) => this.logger.debug(`[${e}] ${t}`, n)
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
resolveDependencies(e) {
|
|
472
|
-
let t = [], r = /* @__PURE__ */ new Set(), i = (e) => {
|
|
473
|
-
if (t.includes(e)) return;
|
|
474
|
-
if (r.has(e)) throw new n(e, "initialize", "Circular dependency detected");
|
|
475
|
-
r.add(e);
|
|
476
|
-
let a = this.plugins.get(e);
|
|
477
|
-
if (!a) throw new n(e, "initialize", "Plugin not found");
|
|
478
|
-
for (let e of a.metadata.dependencies || []) i(e);
|
|
479
|
-
r.delete(e), t.push(e);
|
|
480
|
-
};
|
|
481
|
-
for (let t of e) i(t);
|
|
482
|
-
return t;
|
|
483
|
-
}
|
|
484
|
-
sortByPriority(e, t) {
|
|
485
|
-
let n = {
|
|
486
|
-
high: 3,
|
|
487
|
-
medium: 2,
|
|
488
|
-
normal: 2,
|
|
489
|
-
low: 1
|
|
490
|
-
};
|
|
491
|
-
return (n[t.metadata.priority] || 1) - (n[e.metadata.priority] || 1);
|
|
492
|
-
}
|
|
493
|
-
}, p = class {
|
|
494
|
-
constructor(t) {
|
|
495
|
-
e(this, "metadata", void 0), e(this, "context", void 0), e(this, "config", {}), e(this, "initialized", !1), e(this, "active", !1), this.metadata = {
|
|
496
|
-
version: "1.0.0",
|
|
497
|
-
...t
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
async initialize(e, t = {}) {
|
|
501
|
-
if (this.initialized) {
|
|
502
|
-
e.logger.warn("Plugin already initialized");
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
this.context = e, this.config = {
|
|
506
|
-
...this.config,
|
|
507
|
-
...t
|
|
508
|
-
};
|
|
509
|
-
try {
|
|
510
|
-
await this.onInitialize(), this.initialized = !0, e.logger.info("Plugin initialized");
|
|
511
|
-
} catch (t) {
|
|
512
|
-
throw e.logger.error("Failed to initialize plugin", t), t;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
async activate(e) {
|
|
516
|
-
if (!this.initialized) throw Error("Plugin must be initialized before activation");
|
|
517
|
-
if (this.active) {
|
|
518
|
-
e.logger.warn("Plugin already active");
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
try {
|
|
522
|
-
await this.onActivate(), this.active = !0, e.logger.info("Plugin activated");
|
|
523
|
-
} catch (t) {
|
|
524
|
-
throw e.logger.error("Failed to activate plugin", t), t;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
async deactivate(e) {
|
|
528
|
-
if (!this.active) {
|
|
529
|
-
e.logger.warn("Plugin already inactive");
|
|
530
|
-
return;
|
|
531
|
-
}
|
|
532
|
-
try {
|
|
533
|
-
await this.onDeactivate(), this.active = !1, e.logger.info("Plugin deactivated");
|
|
534
|
-
} catch (t) {
|
|
535
|
-
throw e.logger.error("Failed to deactivate plugin", t), t;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
async destroy(e) {
|
|
539
|
-
this.active && await this.deactivate(e);
|
|
540
|
-
try {
|
|
541
|
-
await this.onDestroy(), this.initialized = !1, e.logger.info("Plugin destroyed");
|
|
542
|
-
} catch (t) {
|
|
543
|
-
throw e.logger.error("Failed to destroy plugin", t), t;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
async configure(e) {
|
|
547
|
-
let t = { ...this.config };
|
|
548
|
-
this.config = {
|
|
549
|
-
...this.config,
|
|
550
|
-
...e
|
|
551
|
-
};
|
|
552
|
-
try {
|
|
553
|
-
await this.onConfigure(e, t), this.context?.logger.info("Plugin configured");
|
|
554
|
-
} catch (e) {
|
|
555
|
-
throw this.config = t, this.context?.logger.error("Failed to configure plugin", e), e;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
healthCheck() {
|
|
559
|
-
return this.initialized && this.onHealthCheck();
|
|
560
|
-
}
|
|
561
|
-
onDestroy() {}
|
|
562
|
-
onConfigure(e, t) {}
|
|
563
|
-
onHealthCheck() {
|
|
564
|
-
return !0;
|
|
565
|
-
}
|
|
566
|
-
get state() {
|
|
567
|
-
return this.context?.state;
|
|
568
|
-
}
|
|
569
|
-
get controls() {
|
|
570
|
-
return this.context?.controls;
|
|
571
|
-
}
|
|
572
|
-
get element() {
|
|
573
|
-
return this.context?.element;
|
|
574
|
-
}
|
|
575
|
-
get logger() {
|
|
576
|
-
return this.context?.logger;
|
|
577
|
-
}
|
|
578
|
-
emit(e, t) {
|
|
579
|
-
this.context?.emit(e, t);
|
|
580
|
-
}
|
|
581
|
-
on(e, t) {
|
|
582
|
-
return this.context?.on(e, t) || (() => {});
|
|
583
|
-
}
|
|
584
|
-
addEventListeners(e, t) {
|
|
585
|
-
return Object.entries(t).forEach(([t, n]) => {
|
|
586
|
-
e.addEventListener(t, n);
|
|
587
|
-
}), () => {
|
|
588
|
-
Object.entries(t).forEach(([t, n]) => {
|
|
589
|
-
e.removeEventListener(t, n);
|
|
590
|
-
});
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
createConfig(e) {
|
|
594
|
-
return {
|
|
595
|
-
...e,
|
|
596
|
-
...this.config
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
get isInitialized() {
|
|
600
|
-
return this.initialized;
|
|
601
|
-
}
|
|
602
|
-
get isActive() {
|
|
603
|
-
return this.active;
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
function m(e) {
|
|
607
|
-
return (t) => new e(t);
|
|
608
|
-
}
|
|
609
|
-
//#endregion
|
|
610
|
-
//#region src/core/plugins/examples/analytics-plugin.ts
|
|
611
|
-
var h = class extends p {
|
|
612
|
-
constructor(t) {
|
|
613
|
-
super({
|
|
614
|
-
name: "analytics",
|
|
615
|
-
description: "Media player analytics and tracking",
|
|
616
|
-
category: "analytics",
|
|
617
|
-
priority: "low",
|
|
618
|
-
author: "BaroiPlayer Team"
|
|
619
|
-
}), e(this, "events", []), e(this, "analyticsConfig", void 0), e(this, "cleanupFunctions", []), e(this, "reportTimer", void 0);
|
|
620
|
-
}
|
|
621
|
-
onInitialize() {
|
|
622
|
-
if (this.analyticsConfig = this.createConfig({
|
|
623
|
-
trackingId: "",
|
|
624
|
-
events: [
|
|
625
|
-
"play",
|
|
626
|
-
"pause",
|
|
627
|
-
"seek",
|
|
628
|
-
"ended",
|
|
629
|
-
"error"
|
|
630
|
-
],
|
|
631
|
-
samplingRate: 1,
|
|
632
|
-
debug: !1,
|
|
633
|
-
endpoint: "/api/analytics"
|
|
634
|
-
}), !this.analyticsConfig.trackingId) throw Error("Analytics plugin requires a tracking ID");
|
|
635
|
-
this.logger?.info("Analytics plugin initialized", {
|
|
636
|
-
trackingId: this.analyticsConfig.trackingId,
|
|
637
|
-
events: this.analyticsConfig.events
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
onActivate() {
|
|
641
|
-
let e = this.setupMediaEventListeners();
|
|
642
|
-
this.cleanupFunctions.push(e), this.analyticsConfig.endpoint && (this.reportTimer = setInterval(() => {
|
|
643
|
-
this.reportEvents();
|
|
644
|
-
}, 3e4), this.cleanupFunctions.push(() => {
|
|
645
|
-
this.reportTimer && clearInterval(this.reportTimer);
|
|
646
|
-
})), this.trackEvent("plugin_activated", { plugin: "analytics" }), this.logger?.info("Analytics tracking started");
|
|
647
|
-
}
|
|
648
|
-
onDeactivate() {
|
|
649
|
-
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");
|
|
650
|
-
}
|
|
651
|
-
onConfigure(e) {
|
|
652
|
-
if (this.analyticsConfig = {
|
|
653
|
-
...this.analyticsConfig,
|
|
654
|
-
...e
|
|
655
|
-
}, e.events) {
|
|
656
|
-
this.cleanupFunctions.forEach((e) => e()), this.cleanupFunctions = [];
|
|
657
|
-
let e = this.setupMediaEventListeners();
|
|
658
|
-
this.cleanupFunctions.push(e);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
setupMediaEventListeners() {
|
|
662
|
-
let e = [];
|
|
663
|
-
if (this.analyticsConfig.events.includes("play")) {
|
|
664
|
-
let t = this.on("media:play", (e) => {
|
|
665
|
-
this.trackEvent("play", e);
|
|
666
|
-
});
|
|
667
|
-
e.push(t);
|
|
668
|
-
}
|
|
669
|
-
if (this.analyticsConfig.events.includes("pause")) {
|
|
670
|
-
let t = this.on("media:pause", (e) => {
|
|
671
|
-
this.trackEvent("pause", e);
|
|
672
|
-
});
|
|
673
|
-
e.push(t);
|
|
674
|
-
}
|
|
675
|
-
if (this.analyticsConfig.events.includes("seek")) {
|
|
676
|
-
let t = this.on("media:seek", (e) => {
|
|
677
|
-
this.trackEvent("seek", e);
|
|
678
|
-
});
|
|
679
|
-
e.push(t);
|
|
680
|
-
}
|
|
681
|
-
if (this.analyticsConfig.events.includes("ended")) {
|
|
682
|
-
let t = this.on("media:ended", (e) => {
|
|
683
|
-
this.trackEvent("ended", e);
|
|
684
|
-
});
|
|
685
|
-
e.push(t);
|
|
686
|
-
}
|
|
687
|
-
if (this.analyticsConfig.events.includes("error")) {
|
|
688
|
-
let t = this.on("media:error", (e) => {
|
|
689
|
-
this.trackEvent("error", e);
|
|
690
|
-
});
|
|
691
|
-
e.push(t);
|
|
692
|
-
}
|
|
693
|
-
return () => {
|
|
694
|
-
e.forEach((e) => e());
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
trackEvent(e, t) {
|
|
698
|
-
if (Math.random() > this.analyticsConfig.samplingRate) return;
|
|
699
|
-
let n = {
|
|
700
|
-
event: e,
|
|
701
|
-
timestamp: Date.now(),
|
|
702
|
-
data: {
|
|
703
|
-
...t,
|
|
704
|
-
trackingId: this.analyticsConfig.trackingId,
|
|
705
|
-
sessionId: this.generateSessionId(),
|
|
706
|
-
mediaState: {
|
|
707
|
-
currentTime: this.state?.currentTime,
|
|
708
|
-
duration: this.state?.duration,
|
|
709
|
-
volume: this.state?.volume,
|
|
710
|
-
isPlaying: this.state?.isPlaying
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
};
|
|
714
|
-
this.events.push(n), this.analyticsConfig.debug && this.logger?.info("Analytics event tracked", n), this.emit("analytics:event", n);
|
|
715
|
-
}
|
|
716
|
-
async reportEvents() {
|
|
717
|
-
if (this.events.length === 0 || !this.analyticsConfig.endpoint) return;
|
|
718
|
-
let e = [...this.events];
|
|
719
|
-
this.events = [];
|
|
720
|
-
try {
|
|
721
|
-
let t = await fetch(this.analyticsConfig.endpoint, {
|
|
722
|
-
method: "POST",
|
|
723
|
-
headers: { "Content-Type": "application/json" },
|
|
724
|
-
body: JSON.stringify({
|
|
725
|
-
trackingId: this.analyticsConfig.trackingId,
|
|
726
|
-
events: e
|
|
727
|
-
})
|
|
728
|
-
});
|
|
729
|
-
if (!t.ok) throw Error(`Analytics report failed: ${t.status}`);
|
|
730
|
-
this.analyticsConfig.debug && this.logger?.info(`Reported ${e.length} analytics events`);
|
|
731
|
-
} catch (t) {
|
|
732
|
-
this.events.unshift(...e), this.logger?.error("Failed to report analytics events", t);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
generateSessionId() {
|
|
736
|
-
return `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
737
|
-
}
|
|
738
|
-
track(e, t) {
|
|
739
|
-
this.trackEvent(e, t);
|
|
740
|
-
}
|
|
741
|
-
getPendingEventsCount() {
|
|
742
|
-
return this.events.length;
|
|
743
|
-
}
|
|
744
|
-
async flush() {
|
|
745
|
-
await this.reportEvents();
|
|
746
|
-
}
|
|
747
|
-
onHealthCheck() {
|
|
748
|
-
return this.events.length < 1e3;
|
|
749
|
-
}
|
|
750
|
-
}, g = (e) => new h(e), _ = "1.0.0";
|
|
751
|
-
//#endregion
|
|
752
|
-
export { m as a, c, o as d, d as f, n as g, r as h, p as i, s as l, i as m, h as n, f as o, u as p, g as r, a as s, _ as t, l as u };
|
|
753
|
-
|
|
754
|
-
//# sourceMappingURL=core-plugins-CqCxLkbd.js.map
|