@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.
Files changed (302) hide show
  1. package/README.md +90 -71
  2. package/dist/components/icons/index.d.ts +36 -0
  3. package/dist/components/icons/index.d.ts.map +1 -0
  4. package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts +4 -0
  5. package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts.map +1 -0
  6. package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts +5 -0
  7. package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts.map +1 -0
  8. package/dist/components/icons/svg-icons/AudioIcon.d.ts +5 -0
  9. package/dist/components/icons/svg-icons/AudioIcon.d.ts.map +1 -0
  10. package/dist/components/icons/svg-icons/BackwardIcon.d.ts +5 -0
  11. package/dist/components/icons/svg-icons/BackwardIcon.d.ts.map +1 -0
  12. package/dist/components/icons/svg-icons/CameraIcon.d.ts +5 -0
  13. package/dist/components/icons/svg-icons/CameraIcon.d.ts.map +1 -0
  14. package/dist/components/icons/svg-icons/CheckIcon.d.ts +5 -0
  15. package/dist/components/icons/svg-icons/CheckIcon.d.ts.map +1 -0
  16. package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts +4 -0
  17. package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts.map +1 -0
  18. package/dist/components/icons/svg-icons/ForwardIcon.d.ts +5 -0
  19. package/dist/components/icons/svg-icons/ForwardIcon.d.ts.map +1 -0
  20. package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts +5 -0
  21. package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts.map +1 -0
  22. package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts +5 -0
  23. package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts.map +1 -0
  24. package/dist/components/icons/svg-icons/LoadingIcon.d.ts +5 -0
  25. package/dist/components/icons/svg-icons/LoadingIcon.d.ts.map +1 -0
  26. package/dist/components/icons/svg-icons/PauseIcon.d.ts +5 -0
  27. package/dist/components/icons/svg-icons/PauseIcon.d.ts.map +1 -0
  28. package/dist/components/icons/svg-icons/PlayIcon.d.ts +5 -0
  29. package/dist/components/icons/svg-icons/PlayIcon.d.ts.map +1 -0
  30. package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts +5 -0
  31. package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts.map +1 -0
  32. package/dist/components/icons/svg-icons/QualityIcon.d.ts +5 -0
  33. package/dist/components/icons/svg-icons/QualityIcon.d.ts.map +1 -0
  34. package/dist/components/icons/svg-icons/SettingsIcon.d.ts +5 -0
  35. package/dist/components/icons/svg-icons/SettingsIcon.d.ts.map +1 -0
  36. package/dist/components/icons/svg-icons/SliderIcon.d.ts +5 -0
  37. package/dist/components/icons/svg-icons/SliderIcon.d.ts.map +1 -0
  38. package/dist/components/icons/svg-icons/SubtitleIcon.d.ts +5 -0
  39. package/dist/components/icons/svg-icons/SubtitleIcon.d.ts.map +1 -0
  40. package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts +5 -0
  41. package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts.map +1 -0
  42. package/dist/components/icons/svg-icons/UnPiPIcon.d.ts +4 -0
  43. package/dist/components/icons/svg-icons/UnPiPIcon.d.ts.map +1 -0
  44. package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts +5 -0
  45. package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts.map +1 -0
  46. package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts +5 -0
  47. package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts.map +1 -0
  48. package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts +5 -0
  49. package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts.map +1 -0
  50. package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts +5 -0
  51. package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts.map +1 -0
  52. package/dist/components/variants/gradient/gradient-audio.d.ts +13 -0
  53. package/dist/components/variants/gradient/gradient-audio.d.ts.map +1 -0
  54. package/dist/components/variants/gradient/gradient-controls.d.ts +4 -0
  55. package/dist/components/variants/gradient/gradient-controls.d.ts.map +1 -0
  56. package/dist/components/variants/gradient/gradient-glyphs.d.ts +30 -0
  57. package/dist/components/variants/gradient/gradient-glyphs.d.ts.map +1 -0
  58. package/dist/components/variants/gradient/gradient-video.d.ts +16 -0
  59. package/dist/components/variants/gradient/gradient-video.d.ts.map +1 -0
  60. package/dist/index.css +1 -1
  61. package/dist/index.d.ts +5 -0
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +1 -41
  64. package/dist/index.js.map +1 -1
  65. package/dist/index.mjs +750 -5640
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/package.json +3 -0
  68. package/package.json +110 -114
  69. package/src/components/variants/gradient/gradient-audio.tsx +47 -0
  70. package/src/components/variants/gradient/gradient-controls.tsx +254 -0
  71. package/src/components/variants/gradient/gradient-glyphs.test.tsx +69 -0
  72. package/src/components/variants/gradient/gradient-glyphs.tsx +129 -0
  73. package/src/components/variants/gradient/gradient-skin.css +211 -0
  74. package/src/components/variants/gradient/gradient-video.tsx +70 -0
  75. package/src/index.ts +5 -198
  76. package/src/test/accessibility-utils.ts +0 -59
  77. package/dist/context/media.js +0 -1
  78. package/dist/context/media.mjs +0 -3
  79. package/dist/context/store.js +0 -1
  80. package/dist/context/store.mjs +0 -3
  81. package/dist/context-Bzd5QCKM.cjs +0 -7
  82. package/dist/context-Bzd5QCKM.cjs.map +0 -1
  83. package/dist/context-DD_SH4tT.js +0 -1053
  84. package/dist/context-DD_SH4tT.js.map +0 -1
  85. package/dist/core-events-BRnLMB7s.cjs +0 -2
  86. package/dist/core-events-BRnLMB7s.cjs.map +0 -1
  87. package/dist/core-events-v_mKdj5p.js +0 -417
  88. package/dist/core-events-v_mKdj5p.js.map +0 -1
  89. package/dist/core-plugins-CMBv-yVh.cjs +0 -2
  90. package/dist/core-plugins-CMBv-yVh.cjs.map +0 -1
  91. package/dist/core-plugins-CqCxLkbd.js +0 -754
  92. package/dist/core-plugins-CqCxLkbd.js.map +0 -1
  93. package/dist/core.js +0 -15
  94. package/dist/core.js.map +0 -1
  95. package/dist/core.mjs +0 -960
  96. package/dist/core.mjs.map +0 -1
  97. package/dist/enhanced-components-BwjBqSA1.js +0 -2858
  98. package/dist/enhanced-components-BwjBqSA1.js.map +0 -1
  99. package/dist/enhanced-components-C-ka-XLp.cjs +0 -2
  100. package/dist/enhanced-components-C-ka-XLp.cjs.map +0 -1
  101. package/dist/hooks-B-IIWPJr.js +0 -1842
  102. package/dist/hooks-B-IIWPJr.js.map +0 -1
  103. package/dist/hooks-DcHzmBwA.cjs +0 -4
  104. package/dist/hooks-DcHzmBwA.cjs.map +0 -1
  105. package/dist/minimal-components-BYsMQde5.js +0 -1610
  106. package/dist/minimal-components-BYsMQde5.js.map +0 -1
  107. package/dist/minimal-components-CsxQbDp7.cjs +0 -2
  108. package/dist/minimal-components-CsxQbDp7.cjs.map +0 -1
  109. package/dist/minimal-components.css +0 -1
  110. package/dist/mona-loading.gif +0 -0
  111. package/dist/performance-monitor-DCSijLJg.js +0 -312
  112. package/dist/performance-monitor-DCSijLJg.js.map +0 -1
  113. package/dist/performance-monitor-wNFKmqMr.cjs +0 -2
  114. package/dist/performance-monitor-wNFKmqMr.cjs.map +0 -1
  115. package/dist/rolldown-runtime-BmowowmI.js +0 -14
  116. package/dist/rolldown-runtime-mLOUI7ql.cjs +0 -1
  117. package/dist/utils-D2gQ7c2R.js +0 -64
  118. package/dist/utils-D2gQ7c2R.js.map +0 -1
  119. package/dist/utils-DJaAwiZ9.cjs +0 -2
  120. package/dist/utils-DJaAwiZ9.cjs.map +0 -1
  121. package/dist/utils.js +0 -1
  122. package/dist/utils.mjs +0 -3
  123. package/src/adapters/videojs-adapter.tsx +0 -470
  124. package/src/assets/mona-loading.gif +0 -0
  125. package/src/components/AnimateLoading.tsx +0 -111
  126. package/src/components/LoadingState.tsx +0 -239
  127. package/src/components/__tests__/media-player-accessibility.test.tsx +0 -510
  128. package/src/components/__tests__/media-player-react19.test.tsx +0 -457
  129. package/src/components/accessibility/keyboard-help-overlay.tsx +0 -207
  130. package/src/components/audio-player.tsx +0 -85
  131. package/src/components/basic/index.ts +0 -37
  132. package/src/components/enhanced/advanced-features.tsx +0 -311
  133. package/src/components/enhanced/debug-panel.tsx +0 -448
  134. package/src/components/enhanced/enhanced-controls.tsx +0 -597
  135. package/src/components/enhanced/enhanced-media-player.tsx +0 -566
  136. package/src/components/enhanced/error-handling.tsx +0 -338
  137. package/src/components/enhanced/index.ts +0 -39
  138. package/src/components/enhanced/media-player-enhanced.tsx +0 -383
  139. package/src/components/examples/basic-video-player.tsx +0 -50
  140. package/src/components/examples/custom-controls-example.tsx +0 -63
  141. package/src/components/examples/enhanced-controls-example.tsx +0 -100
  142. package/src/components/examples/enhanced-media-player-example.tsx +0 -302
  143. package/src/components/examples/loading-states-demo.tsx +0 -141
  144. package/src/components/examples/react-19-demo.tsx +0 -349
  145. package/src/components/examples/volume-orientation-demo.tsx +0 -105
  146. package/src/components/icon-demo.tsx +0 -196
  147. package/src/components/legacy.tsx +0 -87
  148. package/src/components/media-metadata-display.tsx +0 -99
  149. package/src/components/media-player-audio.tsx +0 -39
  150. package/src/components/media-player-controls.tsx +0 -223
  151. package/src/components/media-player-error.tsx +0 -163
  152. package/src/components/media-player-fullscreen.tsx +0 -109
  153. package/src/components/media-player-hls.tsx +0 -111
  154. package/src/components/media-player-loading.tsx +0 -76
  155. package/src/components/media-player-play.tsx +0 -75
  156. package/src/components/media-player-root.tsx +0 -338
  157. package/src/components/media-player-seek.tsx +0 -168
  158. package/src/components/media-player-time.tsx +0 -99
  159. package/src/components/media-player-tooltip.tsx +0 -58
  160. package/src/components/media-player-video.tsx +0 -54
  161. package/src/components/media-player-volume.tsx +0 -155
  162. package/src/components/media-player.tsx +0 -292
  163. package/src/components/media-suspense.tsx +0 -344
  164. package/src/components/player-settings-form.tsx +0 -158
  165. package/src/components/react-player-wrapper.tsx +0 -651
  166. package/src/components/simple-video-player.tsx +0 -62
  167. package/src/components/ui/blur-poster.tsx +0 -96
  168. package/src/components/ui/empty-state.tsx +0 -91
  169. package/src/components/ui/enhanced-seek-bar.tsx +0 -254
  170. package/src/components/ui/error-state.tsx +0 -124
  171. package/src/components/ui/fullscreen-button.tsx +0 -81
  172. package/src/components/ui/loading-skeleton.tsx +0 -107
  173. package/src/components/ui/media-resource-preloader.tsx +0 -458
  174. package/src/components/ui/offline-message.tsx +0 -98
  175. package/src/components/ui/play-button.tsx +0 -99
  176. package/src/components/ui/seek-bar.tsx +0 -191
  177. package/src/components/ui/time-display.tsx +0 -61
  178. package/src/components/ui/volume-control.tsx +0 -190
  179. package/src/components/unified/base-media-player.tsx +0 -252
  180. package/src/components/unified/media-player.tsx +0 -75
  181. package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +0 -587
  182. package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +0 -573
  183. package/src/components/variants/minimal/MinimalControls.tsx +0 -124
  184. package/src/components/variants/minimal/MinimalLoading.tsx +0 -28
  185. package/src/components/variants/minimal/MinimalMediaPlayer.tsx +0 -318
  186. package/src/components/variants/minimal/MinimalOverlay.tsx +0 -58
  187. package/src/components/variants/minimal/MinimalPlayButton.tsx +0 -56
  188. package/src/components/variants/minimal/MinimalSeekBar.tsx +0 -140
  189. package/src/components/variants/minimal/MinimalVolumeControl.tsx +0 -75
  190. package/src/components/variants/minimal/SimpleMinimalPlayer.tsx +0 -206
  191. package/src/components/variants/minimal/components/CenterPlayButton.tsx +0 -22
  192. package/src/components/variants/minimal/components/ControlBar.tsx +0 -142
  193. package/src/components/variants/minimal/components/EnhancedSettingsMenu.tsx +0 -412
  194. package/src/components/variants/minimal/components/PlaybackControls.tsx +0 -46
  195. package/src/components/variants/minimal/components/RightControls.tsx +0 -164
  196. package/src/components/variants/minimal/components/SeekBar.tsx +0 -127
  197. package/src/components/variants/minimal/components/SettingsDropdown.tsx +0 -68
  198. package/src/components/variants/minimal/components/SubtitleDisplay.tsx +0 -21
  199. package/src/components/variants/minimal/components/TimeDisplay.tsx +0 -15
  200. package/src/components/variants/minimal/components/VideoElement.tsx +0 -35
  201. package/src/components/variants/minimal/components/VolumeControl.tsx +0 -220
  202. package/src/components/variants/minimal/index.ts +0 -23
  203. package/src/components/video-player.tsx +0 -100
  204. package/src/context/__tests__/media-store.test.ts +0 -509
  205. package/src/context/error-handling.ts +0 -398
  206. package/src/context/media-context.tsx +0 -254
  207. package/src/context/media-provider.tsx +0 -264
  208. package/src/context/media-store.ts +0 -387
  209. package/src/context/persistence.ts +0 -462
  210. package/src/core/events/event-system.ts +0 -448
  211. package/src/core/events/hooks.ts +0 -325
  212. package/src/core/events/index.ts +0 -22
  213. package/src/core/events/middleware.ts +0 -286
  214. package/src/core/index.ts +0 -22
  215. package/src/core/optimization/bundle-optimizer.tsx +0 -312
  216. package/src/core/performance/cicd.ts +0 -98
  217. package/src/core/performance/index.ts +0 -38
  218. package/src/core/performance/media-loading-optimizer.ts +0 -545
  219. package/src/core/performance/performance-budgets.ts +0 -437
  220. package/src/core/performance/performance-monitor.tsx +0 -488
  221. package/src/core/performance/performance-testing.ts +0 -461
  222. package/src/core/plugins/__tests__/registry.test.ts +0 -595
  223. package/src/core/plugins/base-plugin.ts +0 -225
  224. package/src/core/plugins/enhanced-plugin-system.ts +0 -435
  225. package/src/core/plugins/examples/analytics-plugin.ts +0 -241
  226. package/src/core/plugins/index.ts +0 -39
  227. package/src/core/plugins/registry.ts +0 -546
  228. package/src/core/plugins/types.ts +0 -169
  229. package/src/core/plugins/utils.ts +0 -317
  230. package/src/core/progressive-loading.tsx +0 -331
  231. package/src/core/providers/enhanced-hls-provider.ts +0 -307
  232. package/src/core/providers/lazy-provider.tsx +0 -14
  233. package/src/core/providers/service-provider.tsx +0 -164
  234. package/src/core/utils.tsx +0 -34
  235. package/src/features/media-session/media-session-manager.ts +0 -411
  236. package/src/features/picture-in-picture/pip-manager.ts +0 -428
  237. package/src/features/playlist/playlist-manager.ts +0 -626
  238. package/src/features/subtitles/subtitle-manager.ts +0 -435
  239. package/src/features/subtitles/subtitle-parser.ts +0 -284
  240. package/src/features/thumbnails/thumbnail-generator.ts +0 -528
  241. package/src/hooks/__tests__/currentTime-fix.test.ts +0 -149
  242. package/src/hooks/__tests__/use-media-player.test.ts +0 -712
  243. package/src/hooks/__tests__/use-media-state.test.tsx +0 -316
  244. package/src/hooks/accessibility/index.ts +0 -27
  245. package/src/hooks/accessibility/use-accessibility-preferences.ts +0 -190
  246. package/src/hooks/accessibility/use-focus-management.ts +0 -183
  247. package/src/hooks/accessibility/use-keyboard-shortcuts.ts +0 -152
  248. package/src/hooks/accessibility/use-screen-reader.ts +0 -212
  249. package/src/hooks/core/index.ts +0 -47
  250. package/src/hooks/legacy.ts +0 -21
  251. package/src/hooks/use-buffer-health.ts +0 -218
  252. package/src/hooks/use-enhanced-media-player.ts +0 -575
  253. package/src/hooks/use-focus-trap.tsx +0 -162
  254. package/src/hooks/use-intelligent-preloading.ts +0 -387
  255. package/src/hooks/use-keyboard-controls.ts +0 -115
  256. package/src/hooks/use-keyboard-shortcuts.ts +0 -255
  257. package/src/hooks/use-media-actions.ts +0 -184
  258. package/src/hooks/use-media-metadata.ts +0 -91
  259. package/src/hooks/use-media-optimistic.ts +0 -264
  260. package/src/hooks/use-media-player.ts +0 -343
  261. package/src/hooks/use-media-state.ts +0 -194
  262. package/src/hooks/use-memory-optimization.ts +0 -360
  263. package/src/hooks/use-network-status.ts +0 -124
  264. package/src/hooks/use-optimistic-controls.ts +0 -95
  265. package/src/hooks/use-optimized-media.ts +0 -283
  266. package/src/hooks/use-smart-preload.ts +0 -229
  267. package/src/hooks/use-touch-gestures.ts +0 -461
  268. package/src/hooks/useEnhancedSubtitles.ts +0 -258
  269. package/src/hooks/useKeyboardShortcuts.ts +0 -106
  270. package/src/hooks/useMediaControls.ts +0 -52
  271. package/src/hooks/useScreenshot.ts +0 -77
  272. package/src/hooks/useSubtitles.ts +0 -91
  273. package/src/hooks/useVideoPlayer.ts +0 -278
  274. package/src/icons/components/FullscreenIcon.tsx +0 -36
  275. package/src/icons/components/SettingsIcon.tsx +0 -37
  276. package/src/icons/components/animated/LoadingIcon.tsx +0 -27
  277. package/src/icons/components/animated/PlayPauseIcon.tsx +0 -42
  278. package/src/icons/components/media/PauseIcon.tsx +0 -38
  279. package/src/icons/components/media/PlayIcon.tsx +0 -37
  280. package/src/icons/components/volume/VolumeIcon.tsx +0 -38
  281. package/src/icons/components/volume/VolumeOffIcon.tsx +0 -38
  282. package/src/icons/index.ts +0 -56
  283. package/src/icons/provider.tsx +0 -58
  284. package/src/icons/types.ts +0 -60
  285. package/src/index-enhanced.ts +0 -35
  286. package/src/index-legacy.ts +0 -324
  287. package/src/index.css +0 -102
  288. package/src/lib/__tests__/async-utils.test.ts +0 -291
  289. package/src/lib/async-utils.ts +0 -194
  290. package/src/lib/deprecation.ts +0 -51
  291. package/src/lib/format-time.ts +0 -37
  292. package/src/lib/index.ts +0 -4
  293. package/src/lib/utils.ts +0 -6
  294. package/src/styles/globals.css +0 -462
  295. package/src/styles/minimal-player.css +0 -621
  296. package/src/styles/pixel-art.css +0 -41
  297. package/src/styles/videojs.css +0 -100
  298. package/src/types/assets.d.ts +0 -29
  299. package/src/types/events.ts +0 -47
  300. package/src/types/formats.ts +0 -79
  301. package/src/types/index.ts +0 -203
  302. package/src/types/videojs-plugins.d.ts +0 -14
@@ -1,225 +0,0 @@
1
- import type {
2
- Plugin,
3
- PluginCategory,
4
- PluginConfig,
5
- PluginContext,
6
- PluginMetadata,
7
- PluginPriority
8
- } from "./types"
9
-
10
- // Abstract base plugin class
11
- export abstract class BasePlugin implements Plugin {
12
- public readonly metadata: PluginMetadata
13
-
14
- protected context?: PluginContext
15
- protected config: PluginConfig = {}
16
- protected initialized = false
17
- protected active = false
18
-
19
- constructor(metadata: Omit<PluginMetadata, "version"> & { version?: string }) {
20
- this.metadata = {
21
- version: "1.0.0",
22
- ...metadata
23
- }
24
- }
25
-
26
- // Plugin lifecycle methods - can be overridden by subclasses
27
- async initialize(context: PluginContext, config: PluginConfig = {}): Promise<void> {
28
- if (this.initialized) {
29
- context.logger.warn("Plugin already initialized")
30
- return
31
- }
32
-
33
- this.context = context
34
- this.config = { ...this.config, ...config }
35
-
36
- try {
37
- await this.onInitialize()
38
- this.initialized = true
39
- context.logger.info(`Plugin initialized`)
40
- } catch (error) {
41
- context.logger.error("Failed to initialize plugin", error)
42
- throw error
43
- }
44
- }
45
-
46
- async activate(context: PluginContext): Promise<void> {
47
- if (!this.initialized) {
48
- throw new Error("Plugin must be initialized before activation")
49
- }
50
-
51
- if (this.active) {
52
- context.logger.warn("Plugin already active")
53
- return
54
- }
55
-
56
- try {
57
- await this.onActivate()
58
- this.active = true
59
- context.logger.info(`Plugin activated`)
60
- } catch (error) {
61
- context.logger.error("Failed to activate plugin", error)
62
- throw error
63
- }
64
- }
65
-
66
- async deactivate(context: PluginContext): Promise<void> {
67
- if (!this.active) {
68
- context.logger.warn("Plugin already inactive")
69
- return
70
- }
71
-
72
- try {
73
- await this.onDeactivate()
74
- this.active = false
75
- context.logger.info(`Plugin deactivated`)
76
- } catch (error) {
77
- context.logger.error("Failed to deactivate plugin", error)
78
- throw error
79
- }
80
- }
81
-
82
- async destroy(context: PluginContext): Promise<void> {
83
- if (this.active) {
84
- await this.deactivate(context)
85
- }
86
-
87
- try {
88
- await this.onDestroy()
89
- this.initialized = false
90
- context.logger.info(`Plugin destroyed`)
91
- } catch (error) {
92
- context.logger.error("Failed to destroy plugin", error)
93
- throw error
94
- }
95
- }
96
-
97
- async configure(config: PluginConfig): Promise<void> {
98
- const oldConfig = { ...this.config }
99
- this.config = { ...this.config, ...config }
100
-
101
- try {
102
- await this.onConfigure(config, oldConfig)
103
- this.context?.logger.info("Plugin configured")
104
- } catch (error) {
105
- // Rollback configuration on error
106
- this.config = oldConfig
107
- this.context?.logger.error("Failed to configure plugin", error)
108
- throw error
109
- }
110
- }
111
-
112
- healthCheck(): boolean {
113
- return this.initialized && this.onHealthCheck()
114
- }
115
-
116
- // Template methods for subclasses to override
117
- protected abstract onInitialize(): Promise<void> | void
118
- protected abstract onActivate(): Promise<void> | void
119
- protected abstract onDeactivate(): Promise<void> | void
120
-
121
- protected onDestroy(): Promise<void> | void {
122
- // Default implementation - subclasses can override
123
- }
124
-
125
- protected onConfigure(newConfig: PluginConfig, oldConfig: PluginConfig): Promise<void> | void {
126
- // Default implementation - subclasses can override
127
- }
128
-
129
- protected onHealthCheck(): boolean {
130
- // Default implementation - subclasses can override
131
- return true
132
- }
133
-
134
- // Utility methods for plugins
135
- protected get state() {
136
- return this.context?.state
137
- }
138
-
139
- protected get controls() {
140
- return this.context?.controls
141
- }
142
-
143
- protected get element() {
144
- return this.context?.element
145
- }
146
-
147
- protected get logger() {
148
- return this.context?.logger
149
- }
150
-
151
- protected emit(event: string, data?: any): void {
152
- this.context?.emit(event, data)
153
- }
154
-
155
- protected on(event: string, handler: (data: any) => void): () => void {
156
- return this.context?.on(event, handler) || (() => {})
157
- }
158
-
159
- // Helper methods for common plugin patterns
160
- protected addEventListeners(
161
- element: HTMLElement,
162
- events: Record<string, (e: Event) => void>
163
- ): () => void {
164
- Object.entries(events).forEach(([event, handler]) => {
165
- element.addEventListener(event, handler)
166
- })
167
-
168
- // Return cleanup function
169
- return () => {
170
- Object.entries(events).forEach(([event, handler]) => {
171
- element.removeEventListener(event, handler)
172
- })
173
- }
174
- }
175
-
176
- protected createConfig<T extends PluginConfig>(defaults: T): T {
177
- return { ...defaults, ...this.config } as T
178
- }
179
-
180
- // Plugin status
181
- get isInitialized(): boolean {
182
- return this.initialized
183
- }
184
-
185
- get isActive(): boolean {
186
- return this.active
187
- }
188
- }
189
-
190
- // Simple plugin factory helper
191
- export function createPlugin<T extends BasePlugin>(PluginClass: new (config?: PluginConfig) => T) {
192
- return (config?: PluginConfig) => new PluginClass(config)
193
- }
194
-
195
- // Plugin decorator for metadata - TODO: Fix implementation
196
- // export function plugin(metadata: Omit<PluginMetadata, 'version'> & { version?: string }) {
197
- // return function<T extends { new (...args: any[]): BasePlugin }>(constructor: T) {
198
- // return class extends constructor {
199
- // constructor(...args: any[]) {
200
- // super(metadata, ...args)
201
- // }
202
- // }
203
- // }
204
- // }
205
-
206
- // Common plugin configurations
207
- export interface UIPluginConfig extends PluginConfig {
208
- position?: "top" | "bottom" | "left" | "right" | "center"
209
- zIndex?: number
210
- className?: string
211
- style?: Record<string, string>
212
- }
213
-
214
- export interface AnalyticsPluginConfig extends PluginConfig {
215
- trackingId?: string
216
- events?: string[]
217
- samplingRate?: number
218
- debug?: boolean
219
- }
220
-
221
- export interface PerformancePluginConfig extends PluginConfig {
222
- enableMetrics?: boolean
223
- reportInterval?: number
224
- thresholds?: Record<string, number>
225
- }
@@ -1,435 +0,0 @@
1
- /**
2
- * Enhanced Plugin System with Video.js-inspired hooks architecture
3
- * Provides middleware-based extensibility while maintaining backward compatibility
4
- */
5
-
6
- import type { MediaPlayerConfig, MediaPlayerInstance } from "../../types"
7
- import { BasePlugin } from "./base-plugin"
8
-
9
- // Plugin hooks interface inspired by Video.js architecture
10
- export interface MediaPluginHooks {
11
- /** Called before player setup, can modify configuration */
12
- beforeSetup?: (element: HTMLElement, options: MediaPlayerConfig) => MediaPlayerConfig
13
- /** Called during player setup */
14
- setup?: (player: MediaPlayerInstance) => MediaPlayerInstance | void
15
- /** Called when player is ready */
16
- ready?: (player: MediaPlayerInstance) => void
17
- /** Called when media source is loaded */
18
- sourceLoaded?: (player: MediaPlayerInstance, source: string) => void
19
- /** Called on playback state changes */
20
- playbackChange?: (player: MediaPlayerInstance, isPlaying: boolean) => void
21
- /** Called on error events */
22
- error?: (player: MediaPlayerInstance, error: MediaError) => MediaError | void
23
- /** Called before player disposal */
24
- beforeDispose?: (player: MediaPlayerInstance) => void
25
- /** Called during quality changes */
26
- qualityChange?: (player: MediaPlayerInstance, quality: number) => void
27
- /** Called during volume changes */
28
- volumeChange?: (player: MediaPlayerInstance, volume: number) => void
29
- /** Called during fullscreen changes */
30
- fullscreenChange?: (player: MediaPlayerInstance, isFullscreen: boolean) => void
31
- }
32
-
33
- // Enhanced plugin with hooks support
34
- export abstract class EnhancedMediaPlugin extends BasePlugin {
35
- protected hooks: Partial<MediaPluginHooks> = {}
36
- protected priority: number = 0
37
- protected middleware?: PluginMiddleware
38
-
39
- constructor(metadata: Parameters<(...args: any) => any>[0], config: any = {}) {
40
- super(metadata)
41
- this.priority = config.priority || 0
42
- this.setupHooks()
43
- }
44
-
45
- /**
46
- * Get plugin name from metadata
47
- */
48
- public getName(): string {
49
- return this.metadata.name
50
- }
51
-
52
- /**
53
- * Override to setup plugin-specific hooks
54
- */
55
- protected setupHooks(): void {
56
- // Override in subclasses
57
- }
58
-
59
- /**
60
- * Register a hook
61
- */
62
- public registerHook<K extends keyof MediaPluginHooks>(
63
- hookType: K,
64
- handler: MediaPluginHooks[K]
65
- ): void {
66
- this.hooks[hookType] = handler
67
- }
68
-
69
- /**
70
- * Execute a hook if it exists
71
- */
72
- public executeHook<K extends keyof MediaPluginHooks>(
73
- hookType: K,
74
- ...args: Parameters<NonNullable<MediaPluginHooks[K]>>
75
- ): ReturnType<NonNullable<MediaPluginHooks[K]>> | void {
76
- const hook = this.hooks[hookType]
77
- if (hook) {
78
- return (hook as any)(...args)
79
- }
80
- }
81
-
82
- /**
83
- * Get plugin priority
84
- */
85
- public getPriority(): number {
86
- return this.priority
87
- }
88
-
89
- /**
90
- * Set middleware for advanced plugin behavior
91
- */
92
- public setMiddleware(middleware: PluginMiddleware): void {
93
- this.middleware = middleware
94
- }
95
-
96
- /**
97
- * Get middleware for advanced plugin behavior
98
- */
99
- public getMiddleware(): PluginMiddleware | undefined {
100
- return this.middleware
101
- }
102
- }
103
-
104
- // Middleware interface for plugin system
105
- export interface PluginMiddleware {
106
- name: string
107
- priority: number
108
- execute: (
109
- context: PluginContext,
110
- next: () => PluginContext | Promise<PluginContext>
111
- ) => PluginContext | Promise<PluginContext>
112
- }
113
-
114
- // Plugin execution context
115
- export interface PluginContext {
116
- player: MediaPlayerInstance
117
- event: string
118
- data: any
119
- originalData: any
120
- modified: boolean
121
- stopped: boolean
122
- }
123
-
124
- /**
125
- * Enhanced Plugin Registry with hooks and middleware support
126
- */
127
- export class EnhancedPluginRegistry {
128
- private plugins: Map<string, EnhancedMediaPlugin> = new Map()
129
- private middlewares: PluginMiddleware[] = []
130
- private hooks: Map<keyof MediaPluginHooks, Array<{ plugin: string; handler: Function }>> =
131
- new Map()
132
-
133
- /**
134
- * Register a plugin with the system
135
- */
136
- public register(plugin: EnhancedMediaPlugin): void {
137
- this.plugins.set(plugin.getName(), plugin)
138
-
139
- // Register plugin hooks
140
- this.registerPluginHooks(plugin)
141
-
142
- // Register plugin middleware if available
143
- const middleware = plugin.getMiddleware()
144
- if (middleware) {
145
- this.addMiddleware(middleware)
146
- }
147
- }
148
-
149
- /**
150
- * Unregister a plugin
151
- */
152
- public unregister(pluginName: string): void {
153
- const plugin = this.plugins.get(pluginName)
154
- if (plugin) {
155
- this.unregisterPluginHooks(plugin)
156
- this.plugins.delete(pluginName)
157
- }
158
- }
159
-
160
- /**
161
- * Get a registered plugin
162
- */
163
- public getPlugin(name: string): EnhancedMediaPlugin | undefined {
164
- return this.plugins.get(name)
165
- }
166
-
167
- /**
168
- * Get all registered plugins
169
- */
170
- public getPlugins(): EnhancedMediaPlugin[] {
171
- return Array.from(this.plugins.values())
172
- }
173
-
174
- /**
175
- * Get plugins sorted by priority
176
- */
177
- public getPluginsByPriority(): EnhancedMediaPlugin[] {
178
- return Array.from(this.plugins.values()).sort((a, b) => a.getPriority() - b.getPriority())
179
- }
180
-
181
- /**
182
- * Execute a hook across all registered plugins
183
- */
184
- public async executeHook<K extends keyof MediaPluginHooks>(
185
- hookType: K,
186
- ...args: Parameters<NonNullable<MediaPluginHooks[K]>>
187
- ): Promise<any[]> {
188
- const hookHandlers = this.hooks.get(hookType) || []
189
- const results: any[] = []
190
-
191
- for (const { plugin, handler } of hookHandlers) {
192
- try {
193
- const result = await (handler as any)(...args)
194
- results.push({ plugin, result })
195
- } catch (error) {
196
- console.error(`Error executing hook ${hookType} in plugin ${plugin}:`, error)
197
- }
198
- }
199
-
200
- return results
201
- }
202
-
203
- /**
204
- * Add middleware to the execution chain
205
- */
206
- public addMiddleware(middleware: PluginMiddleware): void {
207
- this.middlewares.push(middleware)
208
- // Sort by priority
209
- this.middlewares.sort((a, b) => a.priority - b.priority)
210
- }
211
-
212
- /**
213
- * Remove middleware
214
- */
215
- public removeMiddleware(name: string): void {
216
- this.middlewares = this.middlewares.filter((m) => m.name !== name)
217
- }
218
-
219
- /**
220
- * Execute middleware chain
221
- */
222
- public async executeMiddleware(context: PluginContext): Promise<PluginContext> {
223
- let index = 0
224
-
225
- const next = (): Promise<PluginContext> => {
226
- if (index >= this.middlewares.length || context.stopped) {
227
- return Promise.resolve(context)
228
- }
229
-
230
- const middleware = this.middlewares[index++]
231
- if (middleware) {
232
- return Promise.resolve(middleware.execute(context, next))
233
- }
234
- return Promise.resolve(context)
235
- }
236
-
237
- return next()
238
- }
239
-
240
- /**
241
- * Register hooks from a plugin
242
- */
243
- private registerPluginHooks(plugin: EnhancedMediaPlugin): void {
244
- const hooks = (plugin as any).hooks || {}
245
-
246
- Object.entries(hooks).forEach(([hookType, handler]) => {
247
- if (handler) {
248
- if (!this.hooks.has(hookType as keyof MediaPluginHooks)) {
249
- this.hooks.set(hookType as keyof MediaPluginHooks, [])
250
- }
251
-
252
- this.hooks.get(hookType as keyof MediaPluginHooks)!.push({
253
- plugin: plugin.getName(),
254
- handler: handler as any
255
- })
256
- }
257
- })
258
- }
259
-
260
- /**
261
- * Unregister hooks from a plugin
262
- */
263
- private unregisterPluginHooks(plugin: EnhancedMediaPlugin): void {
264
- const hooks = (plugin as any).hooks || {}
265
-
266
- Object.keys(hooks).forEach((hookType) => {
267
- const handlers = this.hooks.get(hookType as keyof MediaPluginHooks)
268
- if (handlers) {
269
- this.hooks.set(
270
- hookType as keyof MediaPluginHooks,
271
- handlers.filter((h) => h.plugin !== plugin.getName())
272
- )
273
- }
274
- })
275
- }
276
-
277
- /**
278
- * Clear all plugins and middleware
279
- */
280
- public clear(): void {
281
- this.plugins.clear()
282
- this.middlewares = []
283
- this.hooks.clear()
284
- }
285
- }
286
-
287
- /**
288
- * Plugin Manager for enhanced plugin system integration
289
- */
290
- export class EnhancedPluginManager {
291
- private registry: EnhancedPluginRegistry
292
- private player: MediaPlayerInstance
293
-
294
- constructor(player: MediaPlayerInstance) {
295
- this.player = player
296
- this.registry = new EnhancedPluginRegistry()
297
- }
298
-
299
- /**
300
- * Setup plugin system for player
301
- */
302
- public async setup(options: MediaPlayerConfig = {}): Promise<void> {
303
- // Execute beforeSetup hooks
304
- const setupResults = await this.registry.executeHook(
305
- "beforeSetup",
306
- this.player.element as HTMLElement,
307
- options
308
- )
309
-
310
- // Apply configuration modifications from hooks
311
- const modifiedOptions = setupResults.reduce((acc, { result }) => {
312
- return result || acc
313
- }, options)
314
-
315
- // Execute setup hooks
316
- await this.registry.executeHook("setup", this.player)
317
-
318
- // Execute ready hooks
319
- await this.registry.executeHook("ready", this.player)
320
- }
321
-
322
- /**
323
- * Register a plugin
324
- */
325
- public register(plugin: EnhancedMediaPlugin): void {
326
- this.registry.register(plugin)
327
- }
328
-
329
- /**
330
- * Unregister a plugin
331
- */
332
- public unregister(pluginName: string): void {
333
- this.registry.unregister(pluginName)
334
- }
335
-
336
- /**
337
- * Execute hooks for specific events
338
- */
339
- public async handleEvent(event: string, data: any): Promise<void> {
340
- const context: PluginContext = {
341
- player: this.player,
342
- event,
343
- data,
344
- originalData: data,
345
- modified: false,
346
- stopped: false
347
- }
348
-
349
- // Execute middleware chain
350
- const processedContext = await this.registry.executeMiddleware(context)
351
-
352
- // Execute relevant hooks based on event
353
- switch (event) {
354
- case "sourceLoaded":
355
- await this.registry.executeHook("sourceLoaded", this.player, data.source)
356
- break
357
- case "playbackChange":
358
- await this.registry.executeHook("playbackChange", this.player, data.isPlaying)
359
- break
360
- case "error":
361
- await this.registry.executeHook("error", this.player, data.error)
362
- break
363
- case "qualityChange":
364
- await this.registry.executeHook("qualityChange", this.player, data.quality)
365
- break
366
- case "volumeChange":
367
- await this.registry.executeHook("volumeChange", this.player, data.volume)
368
- break
369
- case "fullscreenChange":
370
- await this.registry.executeHook("fullscreenChange", this.player, data.isFullscreen)
371
- break
372
- }
373
- }
374
-
375
- /**
376
- * Dispose plugin manager
377
- */
378
- public async dispose(): Promise<void> {
379
- // Execute beforeDispose hooks
380
- await this.registry.executeHook("beforeDispose", this.player)
381
-
382
- // Clear registry
383
- this.registry.clear()
384
- }
385
-
386
- /**
387
- * Get plugin registry
388
- */
389
- public getRegistry(): EnhancedPluginRegistry {
390
- return this.registry
391
- }
392
- }
393
-
394
- // Default middlewares
395
- export const createPerformanceMiddleware = (): PluginMiddleware => ({
396
- name: "performance",
397
- priority: 0,
398
- execute: async (context, next) => {
399
- const start = performance.now()
400
- const result = await next()
401
- const duration = performance.now() - start
402
-
403
- if (duration > 16) {
404
- // Log slow operations
405
- console.warn(`Slow plugin operation: ${context.event} took ${duration.toFixed(2)}ms`)
406
- }
407
-
408
- return result
409
- }
410
- })
411
-
412
- export const createErrorHandlingMiddleware = (): PluginMiddleware => ({
413
- name: "errorHandling",
414
- priority: -1000, // Run last
415
- execute: async (context, next) => {
416
- try {
417
- return await next()
418
- } catch (error) {
419
- console.error(`Plugin error in ${context.event}:`, error)
420
- context.stopped = true
421
- return context
422
- }
423
- }
424
- })
425
-
426
- export const createLoggingMiddleware = (): PluginMiddleware => ({
427
- name: "logging",
428
- priority: 1000, // Run first
429
- execute: async (context, next) => {
430
- console.debug(`Plugin event: ${context.event}`, context.data)
431
- return next()
432
- }
433
- })
434
-
435
- export default EnhancedPluginManager