@therealtinhtute/baroiplayer 1.1.0 → 1.2.0

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.
Files changed (78) hide show
  1. package/dist/core-plugins-By-4-kGs.cjs +2 -0
  2. package/dist/core-plugins-By-4-kGs.cjs.map +1 -0
  3. package/dist/{core-plugins-CROGvQUy.js → core-plugins-DSBWcTuX.js} +444 -309
  4. package/dist/core-plugins-DSBWcTuX.js.map +1 -0
  5. package/dist/core.js +2 -2
  6. package/dist/core.mjs +19 -19
  7. package/dist/{enhanced-components-DUw2KrmQ.js → enhanced-components-B_l3cist.js} +2 -2
  8. package/dist/{enhanced-components-DUw2KrmQ.js.map → enhanced-components-B_l3cist.js.map} +1 -1
  9. package/dist/{enhanced-components-DXBCHU0v.cjs → enhanced-components-BspFs9OO.cjs} +2 -2
  10. package/dist/{enhanced-components-DXBCHU0v.cjs.map → enhanced-components-BspFs9OO.cjs.map} +1 -1
  11. package/dist/hooks-BXwI8QG6.cjs +4 -0
  12. package/dist/hooks-BXwI8QG6.cjs.map +1 -0
  13. package/dist/hooks-Bpi-jDiO.js +1816 -0
  14. package/dist/hooks-Bpi-jDiO.js.map +1 -0
  15. package/dist/index.js +2 -2
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +18 -20
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/{minimal-components-DlRK7Qu_.js → minimal-components-C4z900Ro.js} +297 -298
  20. package/dist/minimal-components-C4z900Ro.js.map +1 -0
  21. package/dist/minimal-components-v4qBp6jv.cjs +2 -0
  22. package/dist/minimal-components-v4qBp6jv.cjs.map +1 -0
  23. package/package.json +1 -1
  24. package/src/components/accessibility/keyboard-help-overlay.tsx +2 -0
  25. package/src/components/enhanced/debug-panel.tsx +1 -1
  26. package/src/components/enhanced/enhanced-media-player.tsx +68 -25
  27. package/src/components/legacy.tsx +6 -6
  28. package/src/components/media-player-video.tsx +5 -12
  29. package/src/components/media-player.tsx +2 -2
  30. package/src/components/ui/enhanced-seek-bar.tsx +2 -2
  31. package/src/components/ui/media-resource-preloader.tsx +21 -23
  32. package/src/components/unified/base-media-player.tsx +22 -10
  33. package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +58 -38
  34. package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +6 -6
  35. package/src/core/optimization/bundle-optimizer.tsx +26 -27
  36. package/src/core/plugins/__tests__/registry.test.ts +1 -1
  37. package/src/core/plugins/enhanced-plugin-system.ts +26 -8
  38. package/src/core/plugins/registry.ts +319 -92
  39. package/src/core/plugins/types.ts +21 -3
  40. package/src/core/providers/enhanced-hls-provider.ts +11 -40
  41. package/src/core/providers/lazy-provider.tsx +5 -42
  42. package/src/features/media-session/media-session-manager.ts +4 -26
  43. package/src/features/picture-in-picture/pip-manager.ts +2 -2
  44. package/src/features/playlist/playlist-manager.ts +26 -18
  45. package/src/features/subtitles/subtitle-manager.ts +1 -1
  46. package/src/features/subtitles/subtitle-parser.ts +19 -16
  47. package/src/features/thumbnails/thumbnail-generator.ts +12 -5
  48. package/src/hooks/__tests__/currentTime-fix.test.ts +149 -0
  49. package/src/hooks/accessibility/use-accessibility-preferences.ts +1 -1
  50. package/src/hooks/accessibility/use-focus-management.ts +2 -2
  51. package/src/hooks/accessibility/use-keyboard-shortcuts.ts +2 -2
  52. package/src/hooks/accessibility/use-screen-reader.ts +1 -1
  53. package/src/hooks/core/index.ts +1 -1
  54. package/src/hooks/use-buffer-health.ts +1 -1
  55. package/src/hooks/use-enhanced-media-player.ts +107 -9
  56. package/src/hooks/use-focus-trap.tsx +2 -2
  57. package/src/hooks/use-intelligent-preloading.ts +23 -3
  58. package/src/hooks/use-keyboard-shortcuts.ts +2 -2
  59. package/src/hooks/use-media-player.ts +74 -43
  60. package/src/hooks/use-memory-optimization.ts +15 -15
  61. package/src/hooks/use-smart-preload.ts +1 -2
  62. package/src/hooks/useKeyboardShortcuts.ts +34 -2
  63. package/src/hooks/useVideoPlayer.ts +50 -4
  64. package/src/index-legacy.ts +3 -5
  65. package/src/test/accessibility-utils.ts +7 -7
  66. package/src/test/media-mocks.ts +41 -28
  67. package/src/test/setup.ts +22 -4
  68. package/src/types/index.ts +13 -0
  69. package/dist/core-plugins-CROGvQUy.js.map +0 -1
  70. package/dist/core-plugins-DtsHBOtF.cjs +0 -2
  71. package/dist/core-plugins-DtsHBOtF.cjs.map +0 -1
  72. package/dist/hooks-BW-JjVgP.cjs +0 -4
  73. package/dist/hooks-BW-JjVgP.cjs.map +0 -1
  74. package/dist/hooks-CyX6De5M.js +0 -1693
  75. package/dist/hooks-CyX6De5M.js.map +0 -1
  76. package/dist/minimal-components-Bdcpxav5.cjs +0 -2
  77. package/dist/minimal-components-Bdcpxav5.cjs.map +0 -1
  78. package/dist/minimal-components-DlRK7Qu_.js.map +0 -1
@@ -8,6 +8,29 @@ interface UseKeyboardShortcutsProps {
8
8
  duration: number
9
9
  }
10
10
 
11
+ /**
12
+ * Safely sets currentTime on a video element, ensuring the value is finite
13
+ */
14
+ function safeSetCurrentTime(video: HTMLVideoElement, time: number): boolean {
15
+ if (!Number.isFinite(time)) {
16
+ console.warn(`Attempted to set non-finite currentTime: ${time}`)
17
+ return false
18
+ }
19
+
20
+ if (time < 0) {
21
+ console.warn(`Attempted to set negative currentTime: ${time}`)
22
+ return false
23
+ }
24
+
25
+ try {
26
+ video.currentTime = time
27
+ return true
28
+ } catch (error) {
29
+ console.error(`Failed to set currentTime to ${time}:`, error)
30
+ return false
31
+ }
32
+ }
33
+
11
34
  export function useKeyboardShortcuts({
12
35
  videoControls,
13
36
  toggleSubtitles,
@@ -34,11 +57,20 @@ export function useKeyboardShortcuts({
34
57
  break
35
58
  case "arrowleft":
36
59
  e.preventDefault()
37
- video.currentTime = Math.max(0, video.currentTime - 5)
60
+ const currentTime = Number.isFinite(video.currentTime) ? video.currentTime : 0
61
+ const newTimeLeft = Math.max(0, currentTime - 5)
62
+ safeSetCurrentTime(video, newTimeLeft)
38
63
  break
39
64
  case "arrowright":
40
65
  e.preventDefault()
41
- video.currentTime = Math.min(duration, video.currentTime + 5)
66
+ const validDuration = Number.isFinite(duration) && duration > 0 ? duration : Number.isFinite(video.duration) ? video.duration : 0
67
+ if (validDuration === 0) {
68
+ console.warn("Cannot seek: duration is not available")
69
+ break
70
+ }
71
+ const currentTimeRight = Number.isFinite(video.currentTime) ? video.currentTime : 0
72
+ const newTimeRight = Math.min(validDuration, currentTimeRight + 5)
73
+ safeSetCurrentTime(video, newTimeRight)
42
74
  break
43
75
  case "arrowup":
44
76
  e.preventDefault()
@@ -29,6 +29,32 @@ export interface VideoControls {
29
29
  seekTo: (time: number) => void
30
30
  }
31
31
 
32
+ /**
33
+ * Safely sets currentTime on a video element, ensuring the value is finite
34
+ * @param video - The video element
35
+ * @param time - The desired time value
36
+ * @returns true if successfully set, false otherwise
37
+ */
38
+ function safeSetCurrentTime(video: HTMLVideoElement, time: number): boolean {
39
+ if (!Number.isFinite(time)) {
40
+ console.warn(`Attempted to set non-finite currentTime: ${time}`)
41
+ return false
42
+ }
43
+
44
+ if (time < 0) {
45
+ console.warn(`Attempted to set negative currentTime: ${time}`)
46
+ return false
47
+ }
48
+
49
+ try {
50
+ video.currentTime = time
51
+ return true
52
+ } catch (error) {
53
+ console.error(`Failed to set currentTime to ${time}:`, error)
54
+ return false
55
+ }
56
+ }
57
+
32
58
  export function useVideoPlayer(containerRef: React.RefObject<HTMLDivElement | null>) {
33
59
  const videoRef = useRef<HTMLVideoElement>(null)
34
60
  const [state, setState] = useState<VideoState>({
@@ -168,13 +194,25 @@ export function useVideoPlayer(containerRef: React.RefObject<HTMLDivElement | nu
168
194
  const seekForward = (seconds = 10) => {
169
195
  const video = videoRef.current
170
196
  if (!video) return
171
- video.currentTime = Math.min(state.duration, video.currentTime + seconds)
197
+
198
+ const duration = Number.isFinite(video.duration) ? video.duration : Number.isFinite(state.duration) ? state.duration : 0
199
+ if (duration === 0) {
200
+ console.warn("Cannot seek forward: duration is not available")
201
+ return
202
+ }
203
+
204
+ const currentTime = Number.isFinite(video.currentTime) ? video.currentTime : 0
205
+ const newTime = Math.min(duration, currentTime + seconds)
206
+ safeSetCurrentTime(video, newTime)
172
207
  }
173
208
 
174
209
  const seekBackward = (seconds = 10) => {
175
210
  const video = videoRef.current
176
211
  if (!video) return
177
- video.currentTime = Math.max(0, video.currentTime - seconds)
212
+
213
+ const currentTime = Number.isFinite(video.currentTime) ? video.currentTime : 0
214
+ const newTime = Math.max(0, currentTime - seconds)
215
+ safeSetCurrentTime(video, newTime)
178
216
  }
179
217
 
180
218
  const toggleMute = () => {
@@ -210,8 +248,16 @@ export function useVideoPlayer(containerRef: React.RefObject<HTMLDivElement | nu
210
248
 
211
249
  const seekTo = (time: number) => {
212
250
  const video = videoRef.current
213
- if (!video || state.duration === 0) return
214
- video.currentTime = Math.max(0, Math.min(state.duration, time))
251
+ if (!video) return
252
+
253
+ const duration = Number.isFinite(video.duration) ? video.duration : Number.isFinite(state.duration) ? state.duration : 0
254
+ if (duration === 0) {
255
+ console.warn("Cannot seek: duration is not available")
256
+ return
257
+ }
258
+
259
+ const clampedTime = Math.max(0, Math.min(duration, time))
260
+ safeSetCurrentTime(video, clampedTime)
215
261
  }
216
262
 
217
263
  const controls: VideoControls = {
@@ -131,11 +131,9 @@ export { useIntelligentPreloading } from "./hooks/use-intelligent-preloading"
131
131
  export { useEnhancedMediaPlayer } from "./hooks/use-enhanced-media-player"
132
132
 
133
133
  // Performance Monitoring
134
- export {
135
- PerformanceMonitor,
136
- PerformanceMetrics,
137
- usePerformanceMonitor as usePerformanceMonitoring
138
- } from "./core/performance"
134
+ export { PerformanceMonitor } from "./core/performance"
135
+ export type { PerformanceMetrics } from "./core/performance"
136
+ export { usePerformanceMonitor as usePerformanceMonitoring } from "./core/performance"
139
137
 
140
138
  // Media Resource Preloader
141
139
  export { MediaResourcePreloader } from "./components/ui/media-resource-preloader"
@@ -42,7 +42,7 @@ export const a11yTestUtils = {
42
42
 
43
43
  // Test ARIA attributes
44
44
  testAriaAttributes: (container: HTMLElement) => {
45
- const violations = []
45
+ const violations: Array<{ element: Element; issue: string }> = []
46
46
 
47
47
  // Check for required ARIA attributes
48
48
  const elementsNeedingAria = container.querySelectorAll(
@@ -77,7 +77,7 @@ export const a11yTestUtils = {
77
77
 
78
78
  // Test color contrast (mock implementation)
79
79
  testColorContrast: (container: HTMLElement) => {
80
- const violations = []
80
+ const violations: Array<{ element: Element; issue: string }> = []
81
81
  const textElements = container.querySelectorAll("p, span, div, button, a")
82
82
 
83
83
  textElements.forEach((element) => {
@@ -100,7 +100,7 @@ export const a11yTestUtils = {
100
100
  // Test screen reader announcements
101
101
  testScreenReaderAnnouncements: (container: HTMLElement) => {
102
102
  const liveRegions = container.querySelectorAll('[aria-live], [role="status"], [role="alert"]')
103
- const announcements = []
103
+ const announcements: Array<{ region: Element; text: string; priority: string }> = []
104
104
 
105
105
  liveRegions.forEach((region) => {
106
106
  const text = region.textContent?.trim()
@@ -118,7 +118,7 @@ export const a11yTestUtils = {
118
118
 
119
119
  // Test focus management
120
120
  testFocusManagement: (container: HTMLElement) => {
121
- const issues = []
121
+ const issues: Array<{ element: Element; issue: string }> = []
122
122
 
123
123
  // Test for focus traps
124
124
  const focusTraps = container.querySelectorAll('[data-focus-trap="true"]')
@@ -164,7 +164,7 @@ export const mockAxe = {
164
164
  export const accessibilityMatchers = {
165
165
  toBeAccessible: async (container: HTMLElement) => {
166
166
  const axeResults = await mockAxe.run(container)
167
- const keyboardResults = a11yTestUtils.testKeyboardNavigation(container)
167
+ const keyboardResults = await a11yTestUtils.testKeyboardNavigation(container)
168
168
  const ariaResults = a11yTestUtils.testAriaAttributes(container)
169
169
 
170
170
  const allViolations = [...axeResults.violations, ...keyboardResults, ...ariaResults]
@@ -194,8 +194,8 @@ export const accessibilityMatchers = {
194
194
  }
195
195
  },
196
196
 
197
- toSupportKeyboardNavigation: (container: HTMLElement) => {
198
- const issues = a11yTestUtils.testKeyboardNavigation(container)
197
+ toSupportKeyboardNavigation: async (container: HTMLElement) => {
198
+ const issues = await a11yTestUtils.testKeyboardNavigation(container)
199
199
 
200
200
  return {
201
201
  pass: issues.length === 0,
@@ -14,14 +14,18 @@ export class MockMediaStream {
14
14
  }
15
15
 
16
16
  export const createMockHTMLMediaElement = () => {
17
+ // Internal state
18
+ let _currentTime = 0
19
+ let _paused = true
20
+ let _volume = 1
21
+ let _muted = false
22
+
17
23
  const mockElement = {
18
24
  // Basic properties
19
25
  src: "",
20
- currentTime: 0,
21
26
  duration: NaN,
22
27
  volume: 1,
23
28
  muted: false,
24
- paused: true,
25
29
  ended: false,
26
30
  seeking: false,
27
31
  readyState: 0,
@@ -71,34 +75,26 @@ export const createMockHTMLMediaElement = () => {
71
75
  // Capture stream
72
76
  captureStream: vi.fn().mockReturnValue(new MockMediaStream()),
73
77
 
74
- // Setters with side effects
78
+ // Getters and setters with side effects
79
+ get currentTime() {
80
+ return _currentTime
81
+ },
75
82
  set currentTime(value: number) {
76
- this._currentTime = value
83
+ _currentTime = value
77
84
  // Trigger timeupdate event
78
85
  const event = new Event("timeupdate")
79
86
  this.dispatchEvent(event)
80
87
  },
81
88
 
82
- get currentTime() {
83
- return this._currentTime || 0
89
+ get paused() {
90
+ return _paused
84
91
  },
85
-
86
92
  set paused(value: boolean) {
87
- this._paused = value
93
+ _paused = value
88
94
  // Trigger play or pause events
89
95
  const event = new Event(value ? "pause" : "play")
90
96
  this.dispatchEvent(event)
91
- },
92
-
93
- get paused() {
94
- return this._paused !== false
95
- },
96
-
97
- // Internal state
98
- _currentTime: 0,
99
- _paused: true,
100
- _volume: 1,
101
- _muted: false
97
+ }
102
98
  }
103
99
 
104
100
  return mockElement
@@ -114,14 +110,23 @@ export const setupMediaMocks = () => {
114
110
  } as any
115
111
 
116
112
  // Mock MediaDevices API
117
- global.navigator.mediaDevices = {
118
- getUserMedia: vi.fn().mockResolvedValue(new MockMediaStream()),
119
- enumerateDevices: vi.fn().mockResolvedValue([])
120
- } as any
113
+ Object.defineProperty(global.navigator, "mediaDevices", {
114
+ writable: true,
115
+ value: {
116
+ getUserMedia: vi.fn().mockResolvedValue(new MockMediaStream()),
117
+ enumerateDevices: vi.fn().mockResolvedValue([])
118
+ }
119
+ })
121
120
 
122
121
  // Mock Picture-in-Picture API
123
- global.document.pictureInPictureEnabled = true
124
- global.document.pictureInPictureElement = null
122
+ Object.defineProperty(global.document, "pictureInPictureEnabled", {
123
+ writable: true,
124
+ value: true
125
+ })
126
+ Object.defineProperty(global.document, "pictureInPictureElement", {
127
+ writable: true,
128
+ value: null
129
+ })
125
130
 
126
131
  // Mock Fullscreen API
127
132
  Object.defineProperty(document, "fullscreenEnabled", {
@@ -136,8 +141,12 @@ export const setupMediaMocks = () => {
136
141
 
137
142
  Object.defineProperty(Element.prototype, "requestFullscreen", {
138
143
  writable: true,
139
- value: vi.fn().mockImplementation(function () {
140
- document.fullscreenElement = this
144
+ value: vi.fn().mockImplementation(function (this: Element) {
145
+ Object.defineProperty(document, "fullscreenElement", {
146
+ writable: true,
147
+ configurable: true,
148
+ value: this
149
+ })
141
150
  const event = new Event("fullscreenchange")
142
151
  document.dispatchEvent(event)
143
152
  return Promise.resolve()
@@ -147,7 +156,11 @@ export const setupMediaMocks = () => {
147
156
  Object.defineProperty(document, "exitFullscreen", {
148
157
  writable: true,
149
158
  value: vi.fn().mockImplementation(function () {
150
- document.fullscreenElement = null
159
+ Object.defineProperty(document, "fullscreenElement", {
160
+ writable: true,
161
+ configurable: true,
162
+ value: null
163
+ })
151
164
  const event = new Event("fullscreenchange")
152
165
  document.dispatchEvent(event)
153
166
  return Promise.resolve()
package/src/test/setup.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import "@testing-library/jest-dom"
2
- import { vi } from "vitest"
2
+ import { afterEach, vi } from "vitest"
3
3
  import { setupMediaMocks } from "./media-mocks"
4
4
 
5
5
  // Setup comprehensive media mocking
@@ -20,8 +20,8 @@ global.ResizeObserver = vi.fn().mockImplementation(() => ({
20
20
  }))
21
21
 
22
22
  // Mock requestAnimationFrame for performance testing
23
- global.requestAnimationFrame = vi.fn((cb) => setTimeout(cb, 16))
24
- global.cancelAnimationFrame = vi.fn(clearTimeout)
23
+ global.requestAnimationFrame = vi.fn((cb: FrameRequestCallback) => setTimeout(cb, 16) as unknown as number)
24
+ global.cancelAnimationFrame = vi.fn((id: number) => clearTimeout(id as unknown as NodeJS.Timeout))
25
25
 
26
26
  // Mock performance API
27
27
  Object.defineProperty(global, "performance", {
@@ -54,7 +54,17 @@ global.MediaSource = vi.fn().mockImplementation(() => ({
54
54
  sourceBuffers: [],
55
55
  addSourceBuffer: vi.fn(),
56
56
  endOfStream: vi.fn()
57
- }))
57
+ })) as unknown as typeof MediaSource
58
+
59
+ Object.defineProperty(global.MediaSource, "canConstructInDedicatedWorker", {
60
+ writable: true,
61
+ value: false
62
+ })
63
+
64
+ Object.defineProperty(global.MediaSource, "isTypeSupported", {
65
+ writable: true,
66
+ value: vi.fn((type: string) => true)
67
+ })
58
68
 
59
69
  global.SourceBuffer = vi.fn().mockImplementation(() => ({
60
70
  appendBuffer: vi.fn(),
@@ -173,6 +183,14 @@ global.AudioContext = vi.fn().mockImplementation(() => ({
173
183
  }))
174
184
 
175
185
  // Custom test utilities
186
+ declare global {
187
+ var testUtils: {
188
+ simulateMediaEvent: (element: HTMLMediaElement, eventType: string, properties?: any) => void
189
+ simulateNetworkCondition: (condition: "slow" | "fast" | "offline") => void
190
+ simulateDevice: (device: "mobile" | "tablet" | "desktop") => void
191
+ }
192
+ }
193
+
176
194
  global.testUtils = {
177
195
  // Helper to simulate media events
178
196
  simulateMediaEvent: (element: HTMLMediaElement, eventType: string, properties?: any) => {
@@ -69,6 +69,7 @@ export interface MediaPlayerControls {
69
69
  pause: () => void
70
70
  toggle: () => void
71
71
  seek: (time: number) => void
72
+ setCurrentTime: (time: number) => void
72
73
  setVolume: (volume: number) => void
73
74
  mute: () => void
74
75
  unmute: () => void
@@ -89,6 +90,10 @@ export interface MediaPlayerConfig {
89
90
  keyboardControls?: boolean
90
91
  showControls?: boolean
91
92
  customControls?: boolean
93
+ enablePerformanceMonitoring?: boolean
94
+ bufferingStrategy?: "aggressive" | "conservative" | "adaptive"
95
+ preloadStrategy?: "eager" | "lazy" | "progressive"
96
+ enableOptimizations?: boolean
92
97
  }
93
98
 
94
99
  export interface MediaPlayerProps extends MediaPlayerConfig {
@@ -188,3 +193,11 @@ export type VolumeOrientation = "horizontal" | "vertical"
188
193
 
189
194
  // Import BufferedRange type for external use
190
195
  import type { BufferedRange } from "../hooks/useVideoPlayer"
196
+
197
+ // Media Player Instance for plugins
198
+ export interface MediaPlayerInstance {
199
+ state: MediaPlayerState
200
+ controls: MediaPlayerControls
201
+ element: HTMLVideoElement | HTMLAudioElement | null
202
+ config: MediaPlayerConfig
203
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-plugins-CROGvQUy.js","sources":["../src/core/plugins/types.ts","../src/core/plugins/registry.ts","../src/core/plugins/base-plugin.ts","../src/core/plugins/examples/analytics-plugin.ts","../src/core/plugins/utils.ts","../src/core/plugins/index.ts"],"sourcesContent":["// TODO: Import proper types when integrated\nexport interface MediaState {\n\tisPlaying: boolean\n\tcurrentTime: number\n\tduration: number\n\tvolume: number\n\tisMuted: boolean\n}\n\nexport interface MediaPlayerControls {\n\tplay(): void\n\tpause(): void\n\tseek(time: number): void\n\tsetVolume(volume: number): void\n}\n\n// Plugin lifecycle phases\nexport type PluginPhase = \"initialize\" | \"activate\" | \"deactivate\" | \"destroy\"\n\n// Plugin categories for organization\nexport type PluginCategory =\n\t| \"controls\"\n\t| \"analytics\"\n\t| \"streaming\"\n\t| \"subtitle\"\n\t| \"quality\"\n\t| \"ui\"\n\t| \"accessibility\"\n\t| \"performance\"\n\n// Plugin priority for execution order\nexport type PluginPriority = \"high\" | \"medium\" | \"low\"\n\n// Plugin configuration interface\nexport interface PluginConfig {\n\t[key: string]: any\n}\n\n// Plugin context provided to each plugin\nexport interface PluginContext {\n\t// Core media player state and controls\n\tstate: MediaState\n\tcontrols: MediaPlayerControls\n\n\t// Plugin management\n\tplugins: PluginRegistry\n\n\t// Event system\n\temit: (event: string, data?: any) => void\n\ton: (event: string, handler: (data: any) => void) => () => void\n\n\t// Utilities\n\telement: HTMLElement | null\n\tlogger: PluginLogger\n}\n\n// Plugin metadata\nexport interface PluginMetadata {\n\tname: string\n\tversion: string\n\tdescription: string\n\tauthor?: string\n\tcategory: PluginCategory\n\tpriority: PluginPriority\n\tdependencies?: string[]\n\tconflicts?: string[]\n}\n\n// Plugin interface that all plugins must implement\nexport interface Plugin {\n\tmetadata: PluginMetadata\n\n\t// Plugin lifecycle methods\n\tinitialize(context: PluginContext, config?: PluginConfig): Promise<void> | void\n\tactivate(context: PluginContext): Promise<void> | void\n\tdeactivate(context: PluginContext): Promise<void> | void\n\tdestroy(context: PluginContext): Promise<void> | void\n\n\t// Configuration handling\n\tconfigure?(config: PluginConfig): Promise<void> | void\n\n\t// Health check for plugin status\n\thealthCheck?(): Promise<boolean> | boolean\n}\n\n// Plugin factory function type\nexport type PluginFactory<T extends Plugin = Plugin> = (config?: PluginConfig) => T\n\n// Plugin registry interface\nexport interface PluginRegistry {\n\tregister(factory: PluginFactory, config?: PluginConfig): Promise<void>\n\tunregister(name: string): Promise<void>\n\tget(name: string): Plugin | undefined\n\tgetAll(): Plugin[]\n\tisEnabled(name: string): boolean\n\tenable(name: string): Promise<void>\n\tdisable(name: string): Promise<void>\n\tconfigure(name: string, config: PluginConfig): Promise<void>\n}\n\n// Plugin logger interface\nexport interface PluginLogger {\n\tinfo(message: string, data?: any): void\n\twarn(message: string, data?: any): void\n\terror(message: string, data?: any): void\n\tdebug(message: string, data?: any): void\n}\n\n// Plugin event types\nexport interface PluginEvents {\n\t\"plugin:registered\": { name: string; plugin: Plugin }\n\t\"plugin:enabled\": { name: string; plugin: Plugin }\n\t\"plugin:disabled\": { name: string; plugin: Plugin }\n\t\"plugin:error\": { name: string; error: Error }\n\t\"plugin:configured\": { name: string; config: PluginConfig }\n}\n\n// Plugin error types\nexport class PluginError extends Error {\n\tconstructor(\n\t\tpublic pluginName: string,\n\t\tpublic phase: PluginPhase,\n\t\tmessage: string,\n\t\tpublic originalError?: Error\n\t) {\n\t\tsuper(`Plugin '${pluginName}' failed during ${phase}: ${message}`)\n\t\tthis.name = \"PluginError\"\n\t}\n}\n\n// Plugin dependency error\nexport class PluginDependencyError extends PluginError {\n\tconstructor(\n\t\tpluginName: string,\n\t\tpublic missingDependencies: string[]\n\t) {\n\t\tsuper(pluginName, \"initialize\", `Missing dependencies: ${missingDependencies.join(\", \")}`)\n\t\tthis.name = \"PluginDependencyError\"\n\t}\n}\n\n// Plugin conflict error\nexport class PluginConflictError extends PluginError {\n\tconstructor(\n\t\tpluginName: string,\n\t\tpublic conflictingPlugins: string[]\n\t) {\n\t\tsuper(pluginName, \"activate\", `Conflicts with active plugins: ${conflictingPlugins.join(\", \")}`)\n\t\tthis.name = \"PluginConflictError\"\n\t}\n}\n","import { EventBus } from \"../events/event-system\"\nimport type {\n\tPluginRegistry as IPluginRegistry,\n\tPlugin,\n\tPluginConfig,\n\tPluginContext,\n\tPluginEvents,\n\tPluginFactory,\n\tPluginLogger,\n\tPluginPriority\n} from \"./types\"\nimport { PluginConflictError, PluginDependencyError, PluginError } from \"./types\"\n\n// Plugin registry implementation\nexport class PluginRegistry implements IPluginRegistry {\n\tprivate plugins = new Map<string, Plugin>()\n\tprivate pluginConfigs = new Map<string, PluginConfig>()\n\tprivate enabledPlugins = new Set<string>()\n\tprivate eventBus = new EventBus()\n\tprivate logger: PluginLogger\n\n\tconstructor(logger: PluginLogger) {\n\t\tthis.logger = logger\n\t}\n\n\t// Register a plugin factory\n\tasync register(factory: PluginFactory, config: PluginConfig = {}): Promise<void> {\n\t\ttry {\n\t\t\tconst plugin = factory(config)\n\t\t\tconst { name, dependencies = [], conflicts = [] } = plugin.metadata\n\n\t\t\t// Check if plugin already exists\n\t\t\tif (this.plugins.has(name)) {\n\t\t\t\tthrow new PluginError(name, \"initialize\", \"Plugin already registered\")\n\t\t\t}\n\n\t\t\t// Validate dependencies\n\t\t\tconst missingDependencies = dependencies.filter((dep) => !this.plugins.has(dep))\n\t\t\tif (missingDependencies.length > 0) {\n\t\t\t\tthrow new PluginDependencyError(name, missingDependencies)\n\t\t\t}\n\n\t\t\t// Check for conflicts with enabled plugins\n\t\t\tconst activeConflicts = conflicts.filter((conflict) => this.enabledPlugins.has(conflict))\n\t\t\tif (activeConflicts.length > 0) {\n\t\t\t\tthrow new PluginConflictError(name, activeConflicts)\n\t\t\t}\n\n\t\t\t// Store plugin and configuration\n\t\t\tthis.plugins.set(name, plugin)\n\t\t\tthis.pluginConfigs.set(name, config)\n\n\t\t\tthis.logger.info(`Plugin '${name}' registered successfully`)\n\t\t\t;(this.eventBus as any).emit(\"plugin:registered\", { name, plugin })\n\t\t} catch (error) {\n\t\t\tconst pluginName = factory({}).metadata.name\n\t\t\tthis.logger.error(`Failed to register plugin '${pluginName}'`, error)\n\t\t\t;(this.eventBus as any).emit(\"plugin:error\", { name: pluginName, error: error as Error })\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Unregister a plugin\n\tasync unregister(name: string): Promise<void> {\n\t\tconst plugin = this.plugins.get(name)\n\t\tif (!plugin) {\n\t\t\tthrow new PluginError(name, \"destroy\", \"Plugin not found\")\n\t\t}\n\n\t\ttry {\n\t\t\t// Disable plugin if enabled\n\t\t\tif (this.enabledPlugins.has(name)) {\n\t\t\t\tawait this.disable(name)\n\t\t\t}\n\n\t\t\t// Remove from registry\n\t\t\tthis.plugins.delete(name)\n\t\t\tthis.pluginConfigs.delete(name)\n\n\t\t\tthis.logger.info(`Plugin '${name}' unregistered successfully`)\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Failed to unregister plugin '${name}'`, error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Get a plugin by name\n\tget(name: string): Plugin | undefined {\n\t\treturn this.plugins.get(name)\n\t}\n\n\t// Get all plugins sorted by priority\n\tgetAll(): Plugin[] {\n\t\treturn Array.from(this.plugins.values()).sort(this.sortByPriority)\n\t}\n\n\t// Check if plugin is enabled\n\tisEnabled(name: string): boolean {\n\t\treturn this.enabledPlugins.has(name)\n\t}\n\n\t// Enable a plugin\n\tasync enable(name: string): Promise<void> {\n\t\tconst plugin = this.plugins.get(name)\n\t\tif (!plugin) {\n\t\t\tthrow new PluginError(name, \"activate\", \"Plugin not found\")\n\t\t}\n\n\t\tif (this.enabledPlugins.has(name)) {\n\t\t\tthis.logger.warn(`Plugin '${name}' is already enabled`)\n\t\t\treturn\n\t\t}\n\n\t\ttry {\n\t\t\tconst context = this.createPluginContext(name)\n\t\t\tconst config = this.pluginConfigs.get(name)\n\n\t\t\t// Initialize plugin\n\t\t\tawait plugin.initialize(context, config)\n\n\t\t\t// Activate plugin\n\t\t\tawait plugin.activate(context)\n\n\t\t\tthis.enabledPlugins.add(name)\n\t\t\tthis.logger.info(`Plugin '${name}' enabled successfully`)\n\t\t\t;(this.eventBus as any).emit(\"plugin:enabled\", { name, plugin })\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Failed to enable plugin '${name}'`, error)\n\t\t\t;(this.eventBus as any).emit(\"plugin:error\", { name, error: error as Error })\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Disable a plugin\n\tasync disable(name: string): Promise<void> {\n\t\tconst plugin = this.plugins.get(name)\n\t\tif (!plugin) {\n\t\t\tthrow new PluginError(name, \"deactivate\", \"Plugin not found\")\n\t\t}\n\n\t\tif (!this.enabledPlugins.has(name)) {\n\t\t\tthis.logger.warn(`Plugin '${name}' is already disabled`)\n\t\t\treturn\n\t\t}\n\n\t\ttry {\n\t\t\tconst context = this.createPluginContext(name)\n\n\t\t\t// Deactivate plugin\n\t\t\tawait plugin.deactivate(context)\n\n\t\t\t// Destroy plugin resources\n\t\t\tawait plugin.destroy(context)\n\n\t\t\tthis.enabledPlugins.delete(name)\n\t\t\tthis.logger.info(`Plugin '${name}' disabled successfully`)\n\t\t\t;(this.eventBus as any).emit(\"plugin:disabled\", { name, plugin })\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Failed to disable plugin '${name}'`, error)\n\t\t\t;(this.eventBus as any).emit(\"plugin:error\", { name, error: error as Error })\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Configure a plugin\n\tasync configure(name: string, config: PluginConfig): Promise<void> {\n\t\tconst plugin = this.plugins.get(name)\n\t\tif (!plugin) {\n\t\t\tthrow new PluginError(name, \"initialize\", \"Plugin not found\")\n\t\t}\n\n\t\ttry {\n\t\t\t// Update stored configuration\n\t\t\tthis.pluginConfigs.set(name, { ...this.pluginConfigs.get(name), ...config })\n\n\t\t\t// If plugin has configure method, call it\n\t\t\tif (plugin.configure) {\n\t\t\t\tawait plugin.configure(config)\n\t\t\t}\n\n\t\t\tthis.logger.info(`Plugin '${name}' configured successfully`)\n\t\t\t;(this.eventBus as any).emit(\"plugin:configured\", { name, config })\n\t\t} catch (error) {\n\t\t\tthis.logger.error(`Failed to configure plugin '${name}'`, error)\n\t\t\t;(this.eventBus as any).emit(\"plugin:error\", { name, error: error as Error })\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Enable multiple plugins with dependency resolution\n\tasync enablePlugins(names: string[]): Promise<void> {\n\t\tconst resolved = this.resolveDependencies(names)\n\n\t\tfor (const name of resolved) {\n\t\t\tif (!this.enabledPlugins.has(name)) {\n\t\t\t\tawait this.enable(name)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Disable multiple plugins\n\tasync disablePlugins(names: string[]): Promise<void> {\n\t\t// Disable in reverse order to handle dependencies\n\t\tconst reversed = [...names].reverse()\n\n\t\tfor (const name of reversed) {\n\t\t\tif (this.enabledPlugins.has(name)) {\n\t\t\t\tawait this.disable(name)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Get enabled plugins\n\tgetEnabledPlugins(): Plugin[] {\n\t\treturn Array.from(this.enabledPlugins)\n\t\t\t.map((name) => this.plugins.get(name)!)\n\t\t\t.filter(Boolean)\n\t\t\t.sort(this.sortByPriority)\n\t}\n\n\t// Health check for all enabled plugins\n\tasync healthCheck(): Promise<{ name: string; healthy: boolean; error?: Error }[]> {\n\t\tconst results = []\n\n\t\tfor (const name of this.enabledPlugins) {\n\t\t\tconst plugin = this.plugins.get(name)!\n\t\t\ttry {\n\t\t\t\tconst healthy = plugin.healthCheck ? await plugin.healthCheck() : true\n\t\t\t\tresults.push({ name, healthy })\n\t\t\t} catch (error) {\n\t\t\t\tresults.push({ name, healthy: false, error: error as Error })\n\t\t\t}\n\t\t}\n\n\t\treturn results\n\t}\n\n\t// Event handling\n\ton<K extends keyof PluginEvents>(\n\t\tevent: K,\n\t\tlistener: (data: PluginEvents[K]) => void\n\t): () => void {\n\t\t;(this.eventBus as any).on(event, listener)\n\t\treturn () => (this.eventBus as any).off(event, listener)\n\t}\n\n\t// Create plugin context (will be implemented when we have the full context)\n\tprivate createPluginContext(pluginName: string): PluginContext {\n\t\t// This will be implemented when we integrate with the media player\n\t\t// For now, return a minimal context\n\t\treturn {\n\t\t\tstate: {} as any,\n\t\t\tcontrols: {} as any,\n\t\t\tplugins: this,\n\t\t\temit: (event: string, data?: any) => (this.eventBus as any).emit(event, data),\n\t\t\ton: (event: string, handler: (data: any) => void) => {\n\t\t\t\t;(this.eventBus as any).on(event, handler)\n\t\t\t\treturn () => (this.eventBus as any).off(event, handler)\n\t\t\t},\n\t\t\telement: null,\n\t\t\tlogger: this.createPluginLogger(pluginName)\n\t\t}\n\t}\n\n\t// Create plugin-specific logger\n\tprivate createPluginLogger(pluginName: string): PluginLogger {\n\t\treturn {\n\t\t\tinfo: (message: string, data?: any) => this.logger.info(`[${pluginName}] ${message}`, data),\n\t\t\twarn: (message: string, data?: any) => this.logger.warn(`[${pluginName}] ${message}`, data),\n\t\t\terror: (message: string, data?: any) => this.logger.error(`[${pluginName}] ${message}`, data),\n\t\t\tdebug: (message: string, data?: any) => this.logger.debug(`[${pluginName}] ${message}`, data)\n\t\t}\n\t}\n\n\t// Resolve plugin dependencies\n\tprivate resolveDependencies(names: string[]): string[] {\n\t\tconst resolved: string[] = []\n\t\tconst visiting = new Set<string>()\n\n\t\tconst visit = (name: string) => {\n\t\t\tif (resolved.includes(name)) return\n\t\t\tif (visiting.has(name)) {\n\t\t\t\tthrow new PluginError(name, \"initialize\", \"Circular dependency detected\")\n\t\t\t}\n\n\t\t\tvisiting.add(name)\n\n\t\t\tconst plugin = this.plugins.get(name)\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new PluginError(name, \"initialize\", \"Plugin not found\")\n\t\t\t}\n\n\t\t\t// Visit dependencies first\n\t\t\tfor (const dep of plugin.metadata.dependencies || []) {\n\t\t\t\tvisit(dep)\n\t\t\t}\n\n\t\t\tvisiting.delete(name)\n\t\t\tresolved.push(name)\n\t\t}\n\n\t\tfor (const name of names) {\n\t\t\tvisit(name)\n\t\t}\n\n\t\treturn resolved\n\t}\n\n\t// Sort plugins by priority\n\tprivate sortByPriority(a: Plugin, b: Plugin): number {\n\t\tconst priorityOrder: Record<PluginPriority, number> = {\n\t\t\thigh: 3,\n\t\t\tmedium: 2,\n\t\t\tlow: 1\n\t\t}\n\n\t\treturn priorityOrder[b.metadata.priority] - priorityOrder[a.metadata.priority]\n\t}\n}\n","import type {\n\tPlugin,\n\tPluginCategory,\n\tPluginConfig,\n\tPluginContext,\n\tPluginMetadata,\n\tPluginPriority\n} from \"./types\"\n\n// Abstract base plugin class\nexport abstract class BasePlugin implements Plugin {\n\tpublic readonly metadata: PluginMetadata\n\n\tprotected context?: PluginContext\n\tprotected config: PluginConfig = {}\n\tprotected initialized = false\n\tprotected active = false\n\n\tconstructor(metadata: Omit<PluginMetadata, \"version\"> & { version?: string }) {\n\t\tthis.metadata = {\n\t\t\tversion: \"1.0.0\",\n\t\t\t...metadata\n\t\t}\n\t}\n\n\t// Plugin lifecycle methods - can be overridden by subclasses\n\tasync initialize(context: PluginContext, config: PluginConfig = {}): Promise<void> {\n\t\tif (this.initialized) {\n\t\t\tcontext.logger.warn(\"Plugin already initialized\")\n\t\t\treturn\n\t\t}\n\n\t\tthis.context = context\n\t\tthis.config = { ...this.config, ...config }\n\n\t\ttry {\n\t\t\tawait this.onInitialize()\n\t\t\tthis.initialized = true\n\t\t\tcontext.logger.info(`Plugin initialized`)\n\t\t} catch (error) {\n\t\t\tcontext.logger.error(\"Failed to initialize plugin\", error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync activate(context: PluginContext): Promise<void> {\n\t\tif (!this.initialized) {\n\t\t\tthrow new Error(\"Plugin must be initialized before activation\")\n\t\t}\n\n\t\tif (this.active) {\n\t\t\tcontext.logger.warn(\"Plugin already active\")\n\t\t\treturn\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.onActivate()\n\t\t\tthis.active = true\n\t\t\tcontext.logger.info(`Plugin activated`)\n\t\t} catch (error) {\n\t\t\tcontext.logger.error(\"Failed to activate plugin\", error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync deactivate(context: PluginContext): Promise<void> {\n\t\tif (!this.active) {\n\t\t\tcontext.logger.warn(\"Plugin already inactive\")\n\t\t\treturn\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.onDeactivate()\n\t\t\tthis.active = false\n\t\t\tcontext.logger.info(`Plugin deactivated`)\n\t\t} catch (error) {\n\t\t\tcontext.logger.error(\"Failed to deactivate plugin\", error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync destroy(context: PluginContext): Promise<void> {\n\t\tif (this.active) {\n\t\t\tawait this.deactivate(context)\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.onDestroy()\n\t\t\tthis.initialized = false\n\t\t\tcontext.logger.info(`Plugin destroyed`)\n\t\t} catch (error) {\n\t\t\tcontext.logger.error(\"Failed to destroy plugin\", error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync configure(config: PluginConfig): Promise<void> {\n\t\tconst oldConfig = { ...this.config }\n\t\tthis.config = { ...this.config, ...config }\n\n\t\ttry {\n\t\t\tawait this.onConfigure(config, oldConfig)\n\t\t\tthis.context?.logger.info(\"Plugin configured\")\n\t\t} catch (error) {\n\t\t\t// Rollback configuration on error\n\t\t\tthis.config = oldConfig\n\t\t\tthis.context?.logger.error(\"Failed to configure plugin\", error)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\thealthCheck(): boolean {\n\t\treturn this.initialized && this.onHealthCheck()\n\t}\n\n\t// Template methods for subclasses to override\n\tprotected abstract onInitialize(): Promise<void> | void\n\tprotected abstract onActivate(): Promise<void> | void\n\tprotected abstract onDeactivate(): Promise<void> | void\n\n\tprotected onDestroy(): Promise<void> | void {\n\t\t// Default implementation - subclasses can override\n\t}\n\n\tprotected onConfigure(newConfig: PluginConfig, oldConfig: PluginConfig): Promise<void> | void {\n\t\t// Default implementation - subclasses can override\n\t}\n\n\tprotected onHealthCheck(): boolean {\n\t\t// Default implementation - subclasses can override\n\t\treturn true\n\t}\n\n\t// Utility methods for plugins\n\tprotected get state() {\n\t\treturn this.context?.state\n\t}\n\n\tprotected get controls() {\n\t\treturn this.context?.controls\n\t}\n\n\tprotected get element() {\n\t\treturn this.context?.element\n\t}\n\n\tprotected get logger() {\n\t\treturn this.context?.logger\n\t}\n\n\tprotected emit(event: string, data?: any): void {\n\t\tthis.context?.emit(event, data)\n\t}\n\n\tprotected on(event: string, handler: (data: any) => void): () => void {\n\t\treturn this.context?.on(event, handler) || (() => {})\n\t}\n\n\t// Helper methods for common plugin patterns\n\tprotected addEventListeners(\n\t\telement: HTMLElement,\n\t\tevents: Record<string, (e: Event) => void>\n\t): () => void {\n\t\tObject.entries(events).forEach(([event, handler]) => {\n\t\t\telement.addEventListener(event, handler)\n\t\t})\n\n\t\t// Return cleanup function\n\t\treturn () => {\n\t\t\tObject.entries(events).forEach(([event, handler]) => {\n\t\t\t\telement.removeEventListener(event, handler)\n\t\t\t})\n\t\t}\n\t}\n\n\tprotected createConfig<T extends PluginConfig>(defaults: T): T {\n\t\treturn { ...defaults, ...this.config } as T\n\t}\n\n\t// Plugin status\n\tget isInitialized(): boolean {\n\t\treturn this.initialized\n\t}\n\n\tget isActive(): boolean {\n\t\treturn this.active\n\t}\n}\n\n// Simple plugin factory helper\nexport function createPlugin<T extends BasePlugin>(PluginClass: new (config?: PluginConfig) => T) {\n\treturn (config?: PluginConfig) => new PluginClass(config)\n}\n\n// Plugin decorator for metadata - TODO: Fix implementation\n// export function plugin(metadata: Omit<PluginMetadata, 'version'> & { version?: string }) {\n// return function<T extends { new (...args: any[]): BasePlugin }>(constructor: T) {\n// return class extends constructor {\n// constructor(...args: any[]) {\n// super(metadata, ...args)\n// }\n// }\n// }\n// }\n\n// Common plugin configurations\nexport interface UIPluginConfig extends PluginConfig {\n\tposition?: \"top\" | \"bottom\" | \"left\" | \"right\" | \"center\"\n\tzIndex?: number\n\tclassName?: string\n\tstyle?: Record<string, string>\n}\n\nexport interface AnalyticsPluginConfig extends PluginConfig {\n\ttrackingId?: string\n\tevents?: string[]\n\tsamplingRate?: number\n\tdebug?: boolean\n}\n\nexport interface PerformancePluginConfig extends PluginConfig {\n\tenableMetrics?: boolean\n\treportInterval?: number\n\tthresholds?: Record<string, number>\n}\n","import { type AnalyticsPluginConfig, BasePlugin } from \"../base-plugin\"\n\ninterface AnalyticsEvent {\n\tevent: string\n\ttimestamp: number\n\tdata?: any\n}\n\ninterface AnalyticsConfig extends AnalyticsPluginConfig {\n\ttrackingId: string\n\tevents: string[]\n\tsamplingRate: number\n\tdebug: boolean\n\tendpoint?: string\n}\n\nexport class AnalyticsPlugin extends BasePlugin {\n\tprivate events: AnalyticsEvent[] = []\n\tprivate analyticsConfig!: AnalyticsConfig\n\tprivate cleanupFunctions: Array<() => void> = []\n\tprivate reportTimer?: NodeJS.Timeout\n\n\tconstructor(config?: AnalyticsPluginConfig) {\n\t\tsuper({\n\t\t\tname: \"analytics\",\n\t\t\tdescription: \"Media player analytics and tracking\",\n\t\t\tcategory: \"analytics\",\n\t\t\tpriority: \"low\",\n\t\t\tauthor: \"BaroiPlayer Team\"\n\t\t})\n\t}\n\n\tprotected onInitialize(): void {\n\t\tthis.analyticsConfig = this.createConfig<AnalyticsConfig>({\n\t\t\ttrackingId: \"\",\n\t\t\tevents: [\"play\", \"pause\", \"seek\", \"ended\", \"error\"],\n\t\t\tsamplingRate: 1.0,\n\t\t\tdebug: false,\n\t\t\tendpoint: \"/api/analytics\"\n\t\t})\n\n\t\tif (!this.analyticsConfig.trackingId) {\n\t\t\tthrow new Error(\"Analytics plugin requires a tracking ID\")\n\t\t}\n\n\t\tthis.logger?.info(\"Analytics plugin initialized\", {\n\t\t\ttrackingId: this.analyticsConfig.trackingId,\n\t\t\tevents: this.analyticsConfig.events\n\t\t})\n\t}\n\n\tprotected onActivate(): void {\n\t\t// Set up event listeners for media events\n\t\tconst mediaEventCleanup = this.setupMediaEventListeners()\n\t\tthis.cleanupFunctions.push(mediaEventCleanup)\n\n\t\t// Set up periodic reporting\n\t\tif (this.analyticsConfig.endpoint) {\n\t\t\tthis.reportTimer = setInterval(() => {\n\t\t\t\tthis.reportEvents()\n\t\t\t}, 30000) // Report every 30 seconds\n\n\t\t\tthis.cleanupFunctions.push(() => {\n\t\t\t\tif (this.reportTimer) {\n\t\t\t\t\tclearInterval(this.reportTimer)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\tthis.trackEvent(\"plugin_activated\", { plugin: \"analytics\" })\n\t\tthis.logger?.info(\"Analytics tracking started\")\n\t}\n\n\tprotected onDeactivate(): void {\n\t\t// Clean up all event listeners and timers\n\t\tthis.cleanupFunctions.forEach((cleanup) => cleanup())\n\t\tthis.cleanupFunctions = []\n\n\t\t// Report any remaining events\n\t\tif (this.events.length > 0) {\n\t\t\tthis.reportEvents()\n\t\t}\n\n\t\tthis.trackEvent(\"plugin_deactivated\", { plugin: \"analytics\" })\n\t\tthis.logger?.info(\"Analytics tracking stopped\")\n\t}\n\n\tprotected onConfigure(newConfig: AnalyticsConfig): void {\n\t\t// Update tracking configuration\n\t\tthis.analyticsConfig = { ...this.analyticsConfig, ...newConfig }\n\t\tif (newConfig.events) {\n\t\t\t// Re-setup event listeners if events changed\n\t\t\tthis.cleanupFunctions.forEach((cleanup) => cleanup())\n\t\t\tthis.cleanupFunctions = []\n\n\t\t\tconst mediaEventCleanup = this.setupMediaEventListeners()\n\t\t\tthis.cleanupFunctions.push(mediaEventCleanup)\n\t\t}\n\t}\n\n\tprivate setupMediaEventListeners(): () => void {\n\t\tconst cleanupFunctions: Array<() => void> = []\n\n\t\t// Listen for media state changes\n\t\tif (this.analyticsConfig.events.includes(\"play\")) {\n\t\t\tconst unsubscribe = this.on(\"media:play\", (data) => {\n\t\t\t\tthis.trackEvent(\"play\", data)\n\t\t\t})\n\t\t\tcleanupFunctions.push(unsubscribe)\n\t\t}\n\n\t\tif (this.analyticsConfig.events.includes(\"pause\")) {\n\t\t\tconst unsubscribe = this.on(\"media:pause\", (data) => {\n\t\t\t\tthis.trackEvent(\"pause\", data)\n\t\t\t})\n\t\t\tcleanupFunctions.push(unsubscribe)\n\t\t}\n\n\t\tif (this.analyticsConfig.events.includes(\"seek\")) {\n\t\t\tconst unsubscribe = this.on(\"media:seek\", (data) => {\n\t\t\t\tthis.trackEvent(\"seek\", data)\n\t\t\t})\n\t\t\tcleanupFunctions.push(unsubscribe)\n\t\t}\n\n\t\tif (this.analyticsConfig.events.includes(\"ended\")) {\n\t\t\tconst unsubscribe = this.on(\"media:ended\", (data) => {\n\t\t\t\tthis.trackEvent(\"ended\", data)\n\t\t\t})\n\t\t\tcleanupFunctions.push(unsubscribe)\n\t\t}\n\n\t\tif (this.analyticsConfig.events.includes(\"error\")) {\n\t\t\tconst unsubscribe = this.on(\"media:error\", (data) => {\n\t\t\t\tthis.trackEvent(\"error\", data)\n\t\t\t})\n\t\t\tcleanupFunctions.push(unsubscribe)\n\t\t}\n\n\t\t// Return cleanup function\n\t\treturn () => {\n\t\t\tcleanupFunctions.forEach((cleanup) => cleanup())\n\t\t}\n\t}\n\n\tprivate trackEvent(event: string, data?: any): void {\n\t\t// Apply sampling rate\n\t\tif (Math.random() > this.analyticsConfig.samplingRate) {\n\t\t\treturn\n\t\t}\n\n\t\tconst analyticsEvent: AnalyticsEvent = {\n\t\t\tevent,\n\t\t\ttimestamp: Date.now(),\n\t\t\tdata: {\n\t\t\t\t...data,\n\t\t\t\ttrackingId: this.analyticsConfig.trackingId,\n\t\t\t\tsessionId: this.generateSessionId(),\n\t\t\t\tmediaState: {\n\t\t\t\t\tcurrentTime: this.state?.currentTime,\n\t\t\t\t\tduration: this.state?.duration,\n\t\t\t\t\tvolume: this.state?.volume,\n\t\t\t\t\tisPlaying: this.state?.isPlaying\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.events.push(analyticsEvent)\n\n\t\tif (this.analyticsConfig.debug) {\n\t\t\tthis.logger?.info(\"Analytics event tracked\", analyticsEvent)\n\t\t}\n\n\t\t// Emit event for other plugins or applications to use\n\t\tthis.emit(\"analytics:event\", analyticsEvent)\n\t}\n\n\tprivate async reportEvents(): Promise<void> {\n\t\tif (this.events.length === 0 || !this.analyticsConfig.endpoint) {\n\t\t\treturn\n\t\t}\n\n\t\tconst eventsToReport = [...this.events]\n\t\tthis.events = []\n\n\t\ttry {\n\t\t\tconst response = await fetch(this.analyticsConfig.endpoint, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": \"application/json\"\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\ttrackingId: this.analyticsConfig.trackingId,\n\t\t\t\t\tevents: eventsToReport\n\t\t\t\t})\n\t\t\t})\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Analytics report failed: ${response.status}`)\n\t\t\t}\n\n\t\t\tif (this.analyticsConfig.debug) {\n\t\t\t\tthis.logger?.info(`Reported ${eventsToReport.length} analytics events`)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Put events back in queue on failure\n\t\t\tthis.events.unshift(...eventsToReport)\n\t\t\tthis.logger?.error(\"Failed to report analytics events\", error)\n\t\t}\n\t}\n\n\tprivate generateSessionId(): string {\n\t\t// Simple session ID generation - could be more sophisticated\n\t\treturn `session_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`\n\t}\n\n\t// Public API for manual event tracking\n\tpublic track(event: string, data?: any): void {\n\t\tthis.trackEvent(event, data)\n\t}\n\n\t// Get pending events count\n\tpublic getPendingEventsCount(): number {\n\t\treturn this.events.length\n\t}\n\n\t// Flush all pending events\n\tpublic async flush(): Promise<void> {\n\t\tawait this.reportEvents()\n\t}\n\n\tprotected onHealthCheck(): boolean {\n\t\t// Check if we're not accumulating too many events\n\t\treturn this.events.length < 1000\n\t}\n}\n\n// Plugin factory\nexport const createAnalyticsPlugin = (config?: AnalyticsPluginConfig) => {\n\treturn new AnalyticsPlugin(config)\n}\n","import type { Plugin, PluginConfig, PluginLogger } from \"./types\"\n\n// Simple console logger implementation\nexport class ConsolePluginLogger implements PluginLogger {\n\tprivate prefix: string\n\n\tconstructor(prefix = \"[Plugin]\") {\n\t\tthis.prefix = prefix\n\t}\n\n\tinfo(message: string, data?: any): void {\n\t\tif (data) {\n\t\t\tconsole.info(`${this.prefix} ${message}`, data)\n\t\t} else {\n\t\t\tconsole.info(`${this.prefix} ${message}`)\n\t\t}\n\t}\n\n\twarn(message: string, data?: any): void {\n\t\tif (data) {\n\t\t\tconsole.warn(`${this.prefix} ${message}`, data)\n\t\t} else {\n\t\t\tconsole.warn(`${this.prefix} ${message}`)\n\t\t}\n\t}\n\n\terror(message: string, data?: any): void {\n\t\tif (data) {\n\t\t\tconsole.error(`${this.prefix} ${message}`, data)\n\t\t} else {\n\t\t\tconsole.error(`${this.prefix} ${message}`)\n\t\t}\n\t}\n\n\tdebug(message: string, data?: any): void {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tif (data) {\n\t\t\t\tconsole.debug(`${this.prefix} ${message}`, data)\n\t\t\t} else {\n\t\t\t\tconsole.debug(`${this.prefix} ${message}`)\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Plugin validation utilities\nexport class PluginValidator {\n\tstatic validateMetadata(plugin: Plugin): boolean {\n\t\tconst { metadata } = plugin\n\n\t\tif (!metadata.name || typeof metadata.name !== \"string\") {\n\t\t\tthrow new Error(\"Plugin metadata must include a valid name\")\n\t\t}\n\n\t\tif (!metadata.version || typeof metadata.version !== \"string\") {\n\t\t\tthrow new Error(\"Plugin metadata must include a valid version\")\n\t\t}\n\n\t\tif (!metadata.description || typeof metadata.description !== \"string\") {\n\t\t\tthrow new Error(\"Plugin metadata must include a valid description\")\n\t\t}\n\n\t\tif (!metadata.category) {\n\t\t\tthrow new Error(\"Plugin metadata must include a valid category\")\n\t\t}\n\n\t\tif (!metadata.priority) {\n\t\t\tthrow new Error(\"Plugin metadata must include a valid priority\")\n\t\t}\n\n\t\treturn true\n\t}\n\n\tstatic validateConfig(config: PluginConfig, schema?: Record<string, any>): boolean {\n\t\tif (!schema) return true\n\n\t\t// Simple schema validation - could be enhanced with a proper schema validator\n\t\tfor (const [key, rules] of Object.entries(schema)) {\n\t\t\tconst value = config[key]\n\n\t\t\tif (rules.required && (value === undefined || value === null)) {\n\t\t\t\tthrow new Error(`Configuration property '${key}' is required`)\n\t\t\t}\n\n\t\t\tif (value !== undefined && rules.type && typeof value !== rules.type) {\n\t\t\t\tthrow new Error(`Configuration property '${key}' must be of type '${rules.type}'`)\n\t\t\t}\n\n\t\t\tif (rules.enum && !rules.enum.includes(value)) {\n\t\t\t\tthrow new Error(`Configuration property '${key}' must be one of: ${rules.enum.join(\", \")}`)\n\t\t\t}\n\n\t\t\tif (rules.min !== undefined && typeof value === \"number\" && value < rules.min) {\n\t\t\t\tthrow new Error(`Configuration property '${key}' must be at least ${rules.min}`)\n\t\t\t}\n\n\t\t\tif (rules.max !== undefined && typeof value === \"number\" && value > rules.max) {\n\t\t\t\tthrow new Error(`Configuration property '${key}' must be at most ${rules.max}`)\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\t}\n}\n\n// Plugin performance monitoring\nexport class PluginPerformanceMonitor {\n\tprivate metrics = new Map<\n\t\tstring,\n\t\t{\n\t\t\tcalls: number\n\t\t\ttotalTime: number\n\t\t\taverageTime: number\n\t\t\tlastCall: number\n\t\t}\n\t>()\n\n\tmeasure<T>(pluginName: string, operation: string, fn: () => T | Promise<T>): T | Promise<T> {\n\t\tconst key = `${pluginName}.${operation}`\n\t\tconst startTime = performance.now()\n\n\t\tconst updateMetrics = () => {\n\t\t\tconst endTime = performance.now()\n\t\t\tconst duration = endTime - startTime\n\n\t\t\tconst existing = this.metrics.get(key) || {\n\t\t\t\tcalls: 0,\n\t\t\t\ttotalTime: 0,\n\t\t\t\taverageTime: 0,\n\t\t\t\tlastCall: 0\n\t\t\t}\n\n\t\t\texisting.calls++\n\t\t\texisting.totalTime += duration\n\t\t\texisting.averageTime = existing.totalTime / existing.calls\n\t\t\texisting.lastCall = endTime\n\n\t\t\tthis.metrics.set(key, existing)\n\t\t}\n\n\t\tconst result = fn()\n\n\t\tif (result instanceof Promise) {\n\t\t\treturn result.then(\n\t\t\t\t(value) => {\n\t\t\t\t\tupdateMetrics()\n\t\t\t\t\treturn value\n\t\t\t\t},\n\t\t\t\t(error) => {\n\t\t\t\t\tupdateMetrics()\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\t\t\t)\n\t\t} else {\n\t\t\tupdateMetrics()\n\t\t\treturn result\n\t\t}\n\t}\n\n\tgetMetrics(pluginName?: string) {\n\t\tif (pluginName) {\n\t\t\tconst pluginMetrics: Record<string, any> = {}\n\t\t\tfor (const [key, value] of this.metrics.entries()) {\n\t\t\t\tif (key.startsWith(`${pluginName}.`)) {\n\t\t\t\t\tconst operation = key.substring(pluginName.length + 1)\n\t\t\t\t\tpluginMetrics[operation] = value\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn pluginMetrics\n\t\t}\n\n\t\treturn Object.fromEntries(this.metrics.entries())\n\t}\n\n\treset(pluginName?: string): void {\n\t\tif (pluginName) {\n\t\t\tfor (const key of this.metrics.keys()) {\n\t\t\t\tif (key.startsWith(`${pluginName}.`)) {\n\t\t\t\t\tthis.metrics.delete(key)\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthis.metrics.clear()\n\t\t}\n\t}\n}\n\n// Plugin development helpers\nexport const PluginDevelopmentHelpers = {\n\t// Create a mock plugin context for testing\n\tcreateMockContext(): any {\n\t\treturn {\n\t\t\tstate: {\n\t\t\t\tisPlaying: false,\n\t\t\t\tcurrentTime: 0,\n\t\t\t\tduration: 0,\n\t\t\t\tvolume: 1,\n\t\t\t\tisMuted: false,\n\t\t\t\tisLoading: false,\n\t\t\t\terror: null\n\t\t\t},\n\t\t\tcontrols: {\n\t\t\t\tplay: () => Promise.resolve(),\n\t\t\t\tpause: () => Promise.resolve(),\n\t\t\t\tseek: (time: number) => Promise.resolve(),\n\t\t\t\tsetVolume: (volume: number) => Promise.resolve(),\n\t\t\t\tmute: () => Promise.resolve(),\n\t\t\t\tunmute: () => Promise.resolve(),\n\t\t\t\ttoggleMute: () => Promise.resolve()\n\t\t\t},\n\t\t\tplugins: {\n\t\t\t\tget: () => undefined,\n\t\t\t\tgetAll: () => [],\n\t\t\t\tisEnabled: () => false\n\t\t\t},\n\t\t\temit: () => {},\n\t\t\ton: () => () => {},\n\t\t\telement: null,\n\t\t\tlogger: new ConsolePluginLogger(\"[MockPlugin]\")\n\t\t}\n\t},\n\n\t// Create a test plugin for development\n\tcreateTestPlugin(name: string, hooks: Partial<Plugin> = {}): Plugin {\n\t\treturn {\n\t\t\tmetadata: {\n\t\t\t\tname,\n\t\t\t\tversion: \"1.0.0\",\n\t\t\t\tdescription: `Test plugin: ${name}`,\n\t\t\t\tcategory: \"ui\",\n\t\t\t\tpriority: \"medium\"\n\t\t\t},\n\t\t\tinitialize: async () => {},\n\t\t\tactivate: async () => {},\n\t\t\tdeactivate: async () => {},\n\t\t\tdestroy: async () => {},\n\t\t\thealthCheck: () => true,\n\t\t\t...hooks\n\t\t}\n\t},\n\n\t// Plugin timing utilities\n\ttime: {\n\t\tasync: async <T>(label: string, fn: () => Promise<T>): Promise<T> => {\n\t\t\tconsole.time(label)\n\t\t\ttry {\n\t\t\t\tconst result = await fn()\n\t\t\t\tconsole.timeEnd(label)\n\t\t\t\treturn result\n\t\t\t} catch (error) {\n\t\t\t\tconsole.timeEnd(label)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\n\t\tsync: <T>(label: string, fn: () => T): T => {\n\t\t\tconsole.time(label)\n\t\t\ttry {\n\t\t\t\tconst result = fn()\n\t\t\t\tconsole.timeEnd(label)\n\t\t\t\treturn result\n\t\t\t} catch (error) {\n\t\t\t\tconsole.timeEnd(label)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t}\n\t}\n}\n\n// Plugin storage utilities for persistent data\nexport class PluginStorage {\n\tprivate prefix: string\n\n\tconstructor(pluginName: string) {\n\t\tthis.prefix = `baroi-plugin-${pluginName}`\n\t}\n\n\tget<T>(key: string, defaultValue?: T): T | undefined {\n\t\ttry {\n\t\t\tconst item = localStorage.getItem(`${this.prefix}-${key}`)\n\t\t\treturn item ? (JSON.parse(item) as T) : defaultValue\n\t\t} catch {\n\t\t\treturn defaultValue\n\t\t}\n\t}\n\n\tset<T>(key: string, value: T): void {\n\t\ttry {\n\t\t\tlocalStorage.setItem(`${this.prefix}-${key}`, JSON.stringify(value))\n\t\t} catch (error) {\n\t\t\tconsole.warn(`Failed to store plugin data for key: ${key}`, error)\n\t\t}\n\t}\n\n\tremove(key: string): void {\n\t\ttry {\n\t\t\tlocalStorage.removeItem(`${this.prefix}-${key}`)\n\t\t} catch (error) {\n\t\t\tconsole.warn(`Failed to remove plugin data for key: ${key}`, error)\n\t\t}\n\t}\n\n\tclear(): void {\n\t\ttry {\n\t\t\tconst keys = Object.keys(localStorage).filter((key) => key.startsWith(`${this.prefix}-`))\n\t\t\tkeys.forEach((key) => localStorage.removeItem(key))\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"Failed to clear plugin data\", error)\n\t\t}\n\t}\n}\n\n// Export default logger instance\nexport const defaultPluginLogger = new ConsolePluginLogger()\n\n// Export default performance monitor instance\nexport const defaultPerformanceMonitor = new PluginPerformanceMonitor()\n","// Plugin system core exports\nexport type {\n\tPlugin,\n\tPluginFactory,\n\tPluginConfig,\n\tPluginRegistry as IPluginRegistry,\n\tPluginContext,\n\tPluginLogger,\n\tPluginMetadata,\n\tPluginCategory,\n\tPluginPriority,\n\tPluginPhase,\n\tPluginEvents\n} from \"./types\"\n\nexport {\n\tPluginError,\n\tPluginDependencyError,\n\tPluginConflictError\n} from \"./types\"\n\nexport { PluginRegistry } from \"./registry\"\n\nexport {\n\tBasePlugin,\n\tcreatePlugin,\n\ttype UIPluginConfig,\n\ttype AnalyticsPluginConfig,\n\ttype PerformancePluginConfig\n} from \"./base-plugin\"\n\n// Example plugins\nexport { AnalyticsPlugin, createAnalyticsPlugin } from \"./examples/analytics-plugin\"\n\n// Plugin utilities\nexport * from \"./utils\"\n\n// Version\nexport const PLUGIN_SYSTEM_VERSION = \"1.0.0\"\n"],"names":["PluginError","pluginName","phase","message","originalError","PluginDependencyError","missingDependencies","PluginConflictError","conflictingPlugins","PluginRegistry","logger","__publicField","EventBus","factory","config","plugin","name","dependencies","conflicts","dep","activeConflicts","conflict","error","context","names","resolved","reversed","results","healthy","event","listener","data","handler","visiting","visit","a","b","priorityOrder","BasePlugin","metadata","oldConfig","newConfig","element","events","defaults","createPlugin","PluginClass","AnalyticsPlugin","mediaEventCleanup","cleanup","cleanupFunctions","unsubscribe","analyticsEvent","eventsToReport","response","createAnalyticsPlugin","ConsolePluginLogger","prefix","PluginValidator","schema","key","rules","value","PluginPerformanceMonitor","operation","fn","startTime","updateMetrics","endTime","duration","existing","result","pluginMetrics","PluginDevelopmentHelpers","time","volume","hooks","label","PluginStorage","defaultValue","item","defaultPluginLogger","defaultPerformanceMonitor","PLUGIN_SYSTEM_VERSION"],"mappings":";;;;AAsHO,M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A,EACD;AAAA,EAEA,QAAc;AACb,QAAI;AAEH,MADa,OAAO,KAAK,YAAY,EAAE,OAAO,CAACsC,MAAQA,EAAI,WAAW,GAAG,KAAK,MAAM,GAAG,CAAC,EACnF,QAAQ,CAACA,MAAQ,aAAa,WAAWA,CAAG,CAAC;AAAA,IACnD,SAAStC,GAAO;AACf,cAAQ,KAAK,+BAA+BA,CAAK;AAAA,IAClD;AAAA,EACD;AACD;AAGO,MAAM2D,IAAsB,IAAIzB,EAAA,GAG1B0B,IAA4B,IAAInB,EAAA,GCtRhCoB,IAAwB;"}
@@ -1,2 +0,0 @@
1
- "use strict";var w=Object.defineProperty;var P=(r,t,e)=>t in r?w(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var o=(r,t,e)=>P(r,typeof t!="symbol"?t+"":t,e);const E=require("./core-events-B1iM2F46.cjs");class a extends Error{constructor(t,e,i,n){super(`Plugin '${t}' failed during ${e}: ${i}`),this.pluginName=t,this.phase=e,this.originalError=n,this.name="PluginError"}}class f extends a{constructor(t,e){super(t,"initialize",`Missing dependencies: ${e.join(", ")}`),this.missingDependencies=e,this.name="PluginDependencyError"}}class p extends a{constructor(t,e){super(t,"activate",`Conflicts with active plugins: ${e.join(", ")}`),this.conflictingPlugins=e,this.name="PluginConflictError"}}class ${constructor(t){o(this,"plugins",new Map);o(this,"pluginConfigs",new Map);o(this,"enabledPlugins",new Set);o(this,"eventBus",new E.EventBus);o(this,"logger");this.logger=t}async register(t,e={}){try{const i=t(e),{name:n,dependencies:s=[],conflicts:c=[]}=i.metadata;if(this.plugins.has(n))throw new a(n,"initialize","Plugin already registered");const u=s.filter(h=>!this.plugins.has(h));if(u.length>0)throw new f(n,u);const l=c.filter(h=>this.enabledPlugins.has(h));if(l.length>0)throw new p(n,l);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})}catch(i){const n=t({}).metadata.name;throw this.logger.error(`Failed to register plugin '${n}'`,i),this.eventBus.emit("plugin:error",{name:n,error:i}),i}}async unregister(t){if(!this.plugins.get(t))throw new a(t,"destroy","Plugin not found");try{this.enabledPlugins.has(t)&&await this.disable(t),this.plugins.delete(t),this.pluginConfigs.delete(t),this.logger.info(`Plugin '${t}' unregistered successfully`)}catch(i){throw this.logger.error(`Failed to unregister plugin '${t}'`,i),i}}get(t){return this.plugins.get(t)}getAll(){return Array.from(this.plugins.values()).sort(this.sortByPriority)}isEnabled(t){return this.enabledPlugins.has(t)}async enable(t){const e=this.plugins.get(t);if(!e)throw new a(t,"activate","Plugin not found");if(this.enabledPlugins.has(t)){this.logger.warn(`Plugin '${t}' is already enabled`);return}try{const i=this.createPluginContext(t),n=this.pluginConfigs.get(t);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})}catch(i){throw this.logger.error(`Failed to enable plugin '${t}'`,i),this.eventBus.emit("plugin:error",{name:t,error:i}),i}}async disable(t){const e=this.plugins.get(t);if(!e)throw new a(t,"deactivate","Plugin not found");if(!this.enabledPlugins.has(t)){this.logger.warn(`Plugin '${t}' is already disabled`);return}try{const i=this.createPluginContext(t);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})}catch(i){throw this.logger.error(`Failed to disable plugin '${t}'`,i),this.eventBus.emit("plugin:error",{name:t,error:i}),i}}async configure(t,e){const i=this.plugins.get(t);if(!i)throw new a(t,"initialize","Plugin not found");try{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})}catch(n){throw this.logger.error(`Failed to configure plugin '${t}'`,n),this.eventBus.emit("plugin:error",{name:t,error:n}),n}}async enablePlugins(t){const e=this.resolveDependencies(t);for(const i of e)this.enabledPlugins.has(i)||await this.enable(i)}async disablePlugins(t){const e=[...t].reverse();for(const i of e)this.enabledPlugins.has(i)&&await this.disable(i)}getEnabledPlugins(){return Array.from(this.enabledPlugins).map(t=>this.plugins.get(t)).filter(Boolean).sort(this.sortByPriority)}async healthCheck(){const t=[];for(const e of this.enabledPlugins){const i=this.plugins.get(e);try{const n=i.healthCheck?await i.healthCheck():!0;t.push({name:e,healthy:n})}catch(n){t.push({name:e,healthy:!1,error:n})}}return t}on(t,e){return this.eventBus.on(t,e),()=>this.eventBus.off(t,e)}createPluginContext(t){return{state:{},controls:{},plugins:this,emit:(e,i)=>this.eventBus.emit(e,i),on:(e,i)=>(this.eventBus.on(e,i),()=>this.eventBus.off(e,i)),element:null,logger:this.createPluginLogger(t)}}createPluginLogger(t){return{info:(e,i)=>this.logger.info(`[${t}] ${e}`,i),warn:(e,i)=>this.logger.warn(`[${t}] ${e}`,i),error:(e,i)=>this.logger.error(`[${t}] ${e}`,i),debug:(e,i)=>this.logger.debug(`[${t}] ${e}`,i)}}resolveDependencies(t){const e=[],i=new Set,n=s=>{if(e.includes(s))return;if(i.has(s))throw new a(s,"initialize","Circular dependency detected");i.add(s);const c=this.plugins.get(s);if(!c)throw new a(s,"initialize","Plugin not found");for(const u of c.metadata.dependencies||[])n(u);i.delete(s),e.push(s)};for(const s of t)n(s);return e}sortByPriority(t,e){const i={high:3,medium:2,low:1};return i[e.metadata.priority]-i[t.metadata.priority]}}class y{constructor(t){o(this,"metadata");o(this,"context");o(this,"config",{});o(this,"initialized",!1);o(this,"active",!1);this.metadata={version:"1.0.0",...t}}async initialize(t,e={}){if(this.initialized){t.logger.warn("Plugin already initialized");return}this.context=t,this.config={...this.config,...e};try{await this.onInitialize(),this.initialized=!0,t.logger.info("Plugin initialized")}catch(i){throw t.logger.error("Failed to initialize plugin",i),i}}async activate(t){if(!this.initialized)throw new Error("Plugin must be initialized before activation");if(this.active){t.logger.warn("Plugin already active");return}try{await this.onActivate(),this.active=!0,t.logger.info("Plugin activated")}catch(e){throw t.logger.error("Failed to activate plugin",e),e}}async deactivate(t){if(!this.active){t.logger.warn("Plugin already inactive");return}try{await this.onDeactivate(),this.active=!1,t.logger.info("Plugin deactivated")}catch(e){throw t.logger.error("Failed to deactivate plugin",e),e}}async destroy(t){this.active&&await this.deactivate(t);try{await this.onDestroy(),this.initialized=!1,t.logger.info("Plugin destroyed")}catch(e){throw t.logger.error("Failed to destroy plugin",e),e}}async configure(t){const e={...this.config};this.config={...this.config,...t};try{await this.onConfigure(t,e),this.context?.logger.info("Plugin configured")}catch(i){throw this.config=e,this.context?.logger.error("Failed to configure plugin",i),i}}healthCheck(){return this.initialized&&this.onHealthCheck()}onDestroy(){}onConfigure(t,e){}onHealthCheck(){return!0}get state(){return this.context?.state}get controls(){return this.context?.controls}get element(){return this.context?.element}get logger(){return this.context?.logger}emit(t,e){this.context?.emit(t,e)}on(t,e){return this.context?.on(t,e)||(()=>{})}addEventListeners(t,e){return Object.entries(e).forEach(([i,n])=>{t.addEventListener(i,n)}),()=>{Object.entries(e).forEach(([i,n])=>{t.removeEventListener(i,n)})}}createConfig(t){return{...t,...this.config}}get isInitialized(){return this.initialized}get isActive(){return this.active}}function C(r){return t=>new r(t)}class v extends y{constructor(e){super({name:"analytics",description:"Media player analytics and tracking",category:"analytics",priority:"low",author:"BaroiPlayer Team"});o(this,"events",[]);o(this,"analyticsConfig");o(this,"cleanupFunctions",[]);o(this,"reportTimer")}onInitialize(){if(this.analyticsConfig=this.createConfig({trackingId:"",events:["play","pause","seek","ended","error"],samplingRate:1,debug:!1,endpoint:"/api/analytics"}),!this.analyticsConfig.trackingId)throw new Error("Analytics plugin requires a tracking ID");this.logger?.info("Analytics plugin initialized",{trackingId:this.analyticsConfig.trackingId,events:this.analyticsConfig.events})}onActivate(){const e=this.setupMediaEventListeners();this.cleanupFunctions.push(e),this.analyticsConfig.endpoint&&(this.reportTimer=setInterval(()=>{this.reportEvents()},3e4),this.cleanupFunctions.push(()=>{this.reportTimer&&clearInterval(this.reportTimer)})),this.trackEvent("plugin_activated",{plugin:"analytics"}),this.logger?.info("Analytics tracking started")}onDeactivate(){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")}onConfigure(e){if(this.analyticsConfig={...this.analyticsConfig,...e},e.events){this.cleanupFunctions.forEach(n=>n()),this.cleanupFunctions=[];const i=this.setupMediaEventListeners();this.cleanupFunctions.push(i)}}setupMediaEventListeners(){const e=[];if(this.analyticsConfig.events.includes("play")){const i=this.on("media:play",n=>{this.trackEvent("play",n)});e.push(i)}if(this.analyticsConfig.events.includes("pause")){const i=this.on("media:pause",n=>{this.trackEvent("pause",n)});e.push(i)}if(this.analyticsConfig.events.includes("seek")){const i=this.on("media:seek",n=>{this.trackEvent("seek",n)});e.push(i)}if(this.analyticsConfig.events.includes("ended")){const i=this.on("media:ended",n=>{this.trackEvent("ended",n)});e.push(i)}if(this.analyticsConfig.events.includes("error")){const i=this.on("media:error",n=>{this.trackEvent("error",n)});e.push(i)}return()=>{e.forEach(i=>i())}}trackEvent(e,i){if(Math.random()>this.analyticsConfig.samplingRate)return;const n={event:e,timestamp:Date.now(),data:{...i,trackingId:this.analyticsConfig.trackingId,sessionId:this.generateSessionId(),mediaState:{currentTime:this.state?.currentTime,duration:this.state?.duration,volume:this.state?.volume,isPlaying:this.state?.isPlaying}}};this.events.push(n),this.analyticsConfig.debug&&this.logger?.info("Analytics event tracked",n),this.emit("analytics:event",n)}async reportEvents(){if(this.events.length===0||!this.analyticsConfig.endpoint)return;const e=[...this.events];this.events=[];try{const i=await fetch(this.analyticsConfig.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trackingId:this.analyticsConfig.trackingId,events:e})});if(!i.ok)throw new Error(`Analytics report failed: ${i.status}`);this.analyticsConfig.debug&&this.logger?.info(`Reported ${e.length} analytics events`)}catch(i){this.events.unshift(...e),this.logger?.error("Failed to report analytics events",i)}}generateSessionId(){return`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}track(e,i){this.trackEvent(e,i)}getPendingEventsCount(){return this.events.length}async flush(){await this.reportEvents()}onHealthCheck(){return this.events.length<1e3}}const b=r=>new v(r);class d{constructor(t="[Plugin]"){o(this,"prefix");this.prefix=t}info(t,e){e?console.info(`${this.prefix} ${t}`,e):console.info(`${this.prefix} ${t}`)}warn(t,e){e?console.warn(`${this.prefix} ${t}`,e):console.warn(`${this.prefix} ${t}`)}error(t,e){e?console.error(`${this.prefix} ${t}`,e):console.error(`${this.prefix} ${t}`)}debug(t,e){process.env.NODE_ENV==="development"&&(e?console.debug(`${this.prefix} ${t}`,e):console.debug(`${this.prefix} ${t}`))}}class k{static validateMetadata(t){const{metadata:e}=t;if(!e.name||typeof e.name!="string")throw new Error("Plugin metadata must include a valid name");if(!e.version||typeof e.version!="string")throw new Error("Plugin metadata must include a valid version");if(!e.description||typeof e.description!="string")throw new Error("Plugin metadata must include a valid description");if(!e.category)throw new Error("Plugin metadata must include a valid category");if(!e.priority)throw new Error("Plugin metadata must include a valid priority");return!0}static validateConfig(t,e){if(!e)return!0;for(const[i,n]of Object.entries(e)){const s=t[i];if(n.required&&s==null)throw new Error(`Configuration property '${i}' is required`);if(s!==void 0&&n.type&&typeof s!==n.type)throw new Error(`Configuration property '${i}' must be of type '${n.type}'`);if(n.enum&&!n.enum.includes(s))throw new Error(`Configuration property '${i}' must be one of: ${n.enum.join(", ")}`);if(n.min!==void 0&&typeof s=="number"&&s<n.min)throw new Error(`Configuration property '${i}' must be at least ${n.min}`);if(n.max!==void 0&&typeof s=="number"&&s>n.max)throw new Error(`Configuration property '${i}' must be at most ${n.max}`)}return!0}}class m{constructor(){o(this,"metrics",new Map)}measure(t,e,i){const n=`${t}.${e}`,s=performance.now(),c=()=>{const l=performance.now(),h=l-s,g=this.metrics.get(n)||{calls:0,totalTime:0,averageTime:0,lastCall:0};g.calls++,g.totalTime+=h,g.averageTime=g.totalTime/g.calls,g.lastCall=l,this.metrics.set(n,g)},u=i();return u instanceof Promise?u.then(l=>(c(),l),l=>{throw c(),l}):(c(),u)}getMetrics(t){if(t){const e={};for(const[i,n]of this.metrics.entries())if(i.startsWith(`${t}.`)){const s=i.substring(t.length+1);e[s]=n}return e}return Object.fromEntries(this.metrics.entries())}reset(t){if(t)for(const e of this.metrics.keys())e.startsWith(`${t}.`)&&this.metrics.delete(e);else this.metrics.clear()}}const x={createMockContext(){return{state:{isPlaying:!1,currentTime:0,duration:0,volume:1,isMuted:!1,isLoading:!1,error:null},controls:{play:()=>Promise.resolve(),pause:()=>Promise.resolve(),seek:r=>Promise.resolve(),setVolume:r=>Promise.resolve(),mute:()=>Promise.resolve(),unmute:()=>Promise.resolve(),toggleMute:()=>Promise.resolve()},plugins:{get:()=>{},getAll:()=>[],isEnabled:()=>!1},emit:()=>{},on:()=>()=>{},element:null,logger:new d("[MockPlugin]")}},createTestPlugin(r,t={}){return{metadata:{name:r,version:"1.0.0",description:`Test plugin: ${r}`,category:"ui",priority:"medium"},initialize:async()=>{},activate:async()=>{},deactivate:async()=>{},destroy:async()=>{},healthCheck:()=>!0,...t}},time:{async:async(r,t)=>{console.time(r);try{const e=await t();return console.timeEnd(r),e}catch(e){throw console.timeEnd(r),e}},sync:(r,t)=>{console.time(r);try{const e=t();return console.timeEnd(r),e}catch(e){throw console.timeEnd(r),e}}}};class I{constructor(t){o(this,"prefix");this.prefix=`baroi-plugin-${t}`}get(t,e){try{const i=localStorage.getItem(`${this.prefix}-${t}`);return i?JSON.parse(i):e}catch{return e}}set(t,e){try{localStorage.setItem(`${this.prefix}-${t}`,JSON.stringify(e))}catch(i){console.warn(`Failed to store plugin data for key: ${t}`,i)}}remove(t){try{localStorage.removeItem(`${this.prefix}-${t}`)}catch(e){console.warn(`Failed to remove plugin data for key: ${t}`,e)}}clear(){try{Object.keys(localStorage).filter(e=>e.startsWith(`${this.prefix}-`)).forEach(e=>localStorage.removeItem(e))}catch(t){console.warn("Failed to clear plugin data",t)}}}const M=new d,z=new m,F="1.0.0";exports.AnalyticsPlugin=v;exports.BasePlugin=y;exports.ConsolePluginLogger=d;exports.PLUGIN_SYSTEM_VERSION=F;exports.PluginConflictError=p;exports.PluginDependencyError=f;exports.PluginDevelopmentHelpers=x;exports.PluginError=a;exports.PluginPerformanceMonitor=m;exports.PluginRegistry=$;exports.PluginStorage=I;exports.PluginValidator=k;exports.createAnalyticsPlugin=b;exports.createPlugin=C;exports.defaultPerformanceMonitor=z;exports.defaultPluginLogger=M;
2
- //# sourceMappingURL=core-plugins-DtsHBOtF.cjs.map