@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,595 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest"
2
- import { BasePlugin } from "../base-plugin"
3
- import { PluginRegistry } from "../registry"
4
- import type { PluginConfig, PluginContext, PluginMetadata } from "../types"
5
-
6
- // Mock plugin for testing
7
- class TestPlugin extends BasePlugin {
8
- onInitializeCalled = false
9
- onActivateCalled = false
10
- onDeactivateCalled = false
11
- onDestroyCalled = false
12
-
13
- protected onInitialize(): void {
14
- this.onInitializeCalled = true
15
- }
16
-
17
- protected onActivate(): void {
18
- this.onActivateCalled = true
19
- }
20
-
21
- protected onDeactivate(): void {
22
- this.onDeactivateCalled = true
23
- }
24
-
25
- protected onDestroy(): void {
26
- this.onDestroyCalled = true
27
- }
28
- }
29
-
30
- class AnalyticsPlugin extends BasePlugin {
31
- protected onInitialize(): void {}
32
- protected onActivate(): void {}
33
- protected onDeactivate(): void {}
34
- }
35
-
36
- class CustomControlsPlugin extends BasePlugin {
37
- protected onInitialize(): void {}
38
- protected onActivate(): void {}
39
- protected onDeactivate(): void {}
40
- }
41
-
42
- describe.sequential("PluginRegistry", () => {
43
- let registry: PluginRegistry
44
- let mockContext: PluginContext
45
-
46
- beforeEach(() => {
47
- registry = new PluginRegistry()
48
- mockContext = {
49
- state: {
50
- isPlaying: false,
51
- currentTime: 0,
52
- duration: 100,
53
- volume: 1,
54
- isMuted: false
55
- } as any,
56
- controls: {
57
- play: vi.fn(),
58
- pause: vi.fn(),
59
- seek: vi.fn()
60
- } as any,
61
- element: document.createElement("video"),
62
- plugins: registry,
63
- logger: {
64
- info: vi.fn(),
65
- warn: vi.fn(),
66
- error: vi.fn()
67
- } as any,
68
- emit: vi.fn(),
69
- on: vi.fn()
70
- }
71
- })
72
-
73
- describe("Plugin Registration", () => {
74
- it("should register a plugin", () => {
75
- const plugin = new TestPlugin({
76
- name: "test-plugin",
77
- category: "ui",
78
- priority: "normal"
79
- })
80
-
81
- registry.register("test", plugin)
82
-
83
- expect(registry.has("test")).toBe(true)
84
- expect(registry.get("test")).toBe(plugin)
85
- })
86
-
87
- it("should throw error when registering duplicate plugin", () => {
88
- const plugin1 = new TestPlugin({
89
- name: "test-plugin",
90
- category: "ui",
91
- priority: "normal"
92
- })
93
-
94
- const plugin2 = new TestPlugin({
95
- name: "test-plugin",
96
- category: "ui",
97
- priority: "normal"
98
- })
99
-
100
- registry.register("test", plugin1)
101
-
102
- expect(() => registry.register("test", plugin2)).toThrow()
103
- })
104
-
105
- it("should register multiple plugins", () => {
106
- const plugin1 = new TestPlugin({
107
- name: "plugin1",
108
- category: "ui",
109
- priority: "normal"
110
- })
111
-
112
- const plugin2 = new AnalyticsPlugin({
113
- name: "plugin2",
114
- category: "analytics",
115
- priority: "high"
116
- })
117
-
118
- registry.register("plugin1", plugin1)
119
- registry.register("plugin2", plugin2)
120
-
121
- expect(registry.has("plugin1")).toBe(true)
122
- expect(registry.has("plugin2")).toBe(true)
123
- expect(registry.getAll()).toHaveLength(2)
124
- })
125
- })
126
-
127
- describe("Plugin Unregistration", () => {
128
- it("should unregister a plugin", async () => {
129
- const plugin = new TestPlugin({
130
- name: "test-plugin",
131
- category: "ui",
132
- priority: "normal"
133
- })
134
-
135
- registry.register("test", plugin)
136
- await registry.initialize("test", mockContext)
137
- await registry.activate("test", mockContext)
138
-
139
- await registry.unregister("test", mockContext)
140
-
141
- expect(registry.has("test")).toBe(false)
142
- expect(plugin.onDestroyCalled).toBe(true)
143
- })
144
-
145
- it("should throw error when unregistering non-existent plugin", async () => {
146
- await expect(registry.unregister("non-existent", mockContext)).rejects.toThrow()
147
- })
148
- })
149
-
150
- describe("Plugin Lifecycle", () => {
151
- it("should initialize a plugin", async () => {
152
- const plugin = new TestPlugin({
153
- name: "test-plugin",
154
- category: "ui",
155
- priority: "normal"
156
- })
157
-
158
- registry.register("test", plugin)
159
- await registry.initialize("test", mockContext, { debug: true })
160
-
161
- expect(plugin.onInitializeCalled).toBe(true)
162
- expect(plugin.isInitialized).toBe(true)
163
- })
164
-
165
- it("should activate a plugin", async () => {
166
- const plugin = new TestPlugin({
167
- name: "test-plugin",
168
- category: "ui",
169
- priority: "normal"
170
- })
171
-
172
- registry.register("test", plugin)
173
- await registry.initialize("test", mockContext)
174
- await registry.activate("test", mockContext)
175
-
176
- expect(plugin.onActivateCalled).toBe(true)
177
- expect(plugin.isActive).toBe(true)
178
- })
179
-
180
- it("should deactivate a plugin", async () => {
181
- const plugin = new TestPlugin({
182
- name: "test-plugin",
183
- category: "ui",
184
- priority: "normal"
185
- })
186
-
187
- registry.register("test", plugin)
188
- await registry.initialize("test", mockContext)
189
- await registry.activate("test", mockContext)
190
- await registry.deactivate("test", mockContext)
191
-
192
- expect(plugin.onDeactivateCalled).toBe(true)
193
- expect(plugin.isActive).toBe(false)
194
- })
195
-
196
- it("should require initialization before activation", async () => {
197
- const plugin = new TestPlugin({
198
- name: "test-plugin",
199
- category: "ui",
200
- priority: "normal"
201
- })
202
-
203
- registry.register("test", plugin)
204
-
205
- await expect(registry.activate("test", mockContext)).rejects.toThrow()
206
- })
207
- })
208
-
209
- describe("Plugin Dependencies", () => {
210
- it("should handle plugin dependencies", async () => {
211
- const basePlugin = new TestPlugin({
212
- name: "base-plugin",
213
- category: "ui",
214
- priority: "high"
215
- })
216
-
217
- const dependentPlugin = new AnalyticsPlugin({
218
- name: "dependent-plugin",
219
- category: "analytics",
220
- priority: "normal",
221
- dependencies: ["base"]
222
- })
223
-
224
- registry.register("base", basePlugin)
225
- registry.register("dependent", dependentPlugin)
226
-
227
- await registry.initialize("base", mockContext)
228
- await registry.activate("base", mockContext)
229
-
230
- await registry.initialize("dependent", mockContext)
231
- await registry.activate("dependent", mockContext)
232
-
233
- expect(basePlugin.isActive).toBe(true)
234
- expect(dependentPlugin.isActive).toBe(true)
235
- })
236
-
237
- it("should detect circular dependencies", () => {
238
- const plugin1 = new TestPlugin({
239
- name: "plugin1",
240
- category: "ui",
241
- priority: "normal",
242
- dependencies: ["plugin2"]
243
- })
244
-
245
- const plugin2 = new AnalyticsPlugin({
246
- name: "plugin2",
247
- category: "analytics",
248
- priority: "normal",
249
- dependencies: ["plugin1"]
250
- })
251
-
252
- registry.register("plugin1", plugin1)
253
- registry.register("plugin2", plugin2)
254
-
255
- // Should detect and handle circular dependency
256
- expect(() => registry.validateDependencies()).toThrow(/circular/i)
257
- })
258
-
259
- it("should throw error when dependency is missing", async () => {
260
- const plugin = new TestPlugin({
261
- name: "test-plugin",
262
- category: "ui",
263
- priority: "normal",
264
- dependencies: ["missing-plugin"]
265
- })
266
-
267
- registry.register("test", plugin)
268
-
269
- await expect(registry.initialize("test", mockContext)).rejects.toThrow()
270
- })
271
- })
272
-
273
- describe("Plugin Conflicts", () => {
274
- it("should detect plugin conflicts", () => {
275
- const plugin1 = new TestPlugin({
276
- name: "plugin1",
277
- category: "ui",
278
- priority: "normal",
279
- conflicts: ["plugin2"]
280
- })
281
-
282
- const plugin2 = new AnalyticsPlugin({
283
- name: "plugin2",
284
- category: "ui",
285
- priority: "normal"
286
- })
287
-
288
- registry.register("plugin1", plugin1)
289
- registry.register("plugin2", plugin2)
290
-
291
- expect(() => registry.validateConflicts()).toThrow(/conflict/i)
292
- })
293
-
294
- it("should allow non-conflicting plugins", () => {
295
- const plugin1 = new TestPlugin({
296
- name: "plugin1",
297
- category: "ui",
298
- priority: "normal"
299
- })
300
-
301
- const plugin2 = new AnalyticsPlugin({
302
- name: "plugin2",
303
- category: "analytics",
304
- priority: "normal"
305
- })
306
-
307
- registry.register("plugin1", plugin1)
308
- registry.register("plugin2", plugin2)
309
-
310
- expect(() => registry.validateConflicts()).not.toThrow()
311
- })
312
- })
313
-
314
- describe("Plugin Priority", () => {
315
- it("should activate plugins in priority order", async () => {
316
- const activationOrder: string[] = []
317
-
318
- class TrackingPlugin extends BasePlugin {
319
- constructor(
320
- metadata: PluginMetadata,
321
- private trackingName: string
322
- ) {
323
- super(metadata)
324
- }
325
-
326
- protected onInitialize(): void {}
327
-
328
- protected onActivate(): void {
329
- activationOrder.push(this.trackingName)
330
- }
331
-
332
- protected onDeactivate(): void {}
333
- }
334
-
335
- const highPriorityPlugin = new TrackingPlugin(
336
- {
337
- name: "high-priority",
338
- category: "ui",
339
- priority: "high"
340
- },
341
- "high"
342
- )
343
-
344
- const normalPriorityPlugin = new TrackingPlugin(
345
- {
346
- name: "normal-priority",
347
- category: "ui",
348
- priority: "normal"
349
- },
350
- "normal"
351
- )
352
-
353
- const lowPriorityPlugin = new TrackingPlugin(
354
- {
355
- name: "low-priority",
356
- category: "ui",
357
- priority: "low"
358
- },
359
- "low"
360
- )
361
-
362
- registry.register("high", highPriorityPlugin)
363
- registry.register("normal", normalPriorityPlugin)
364
- registry.register("low", lowPriorityPlugin)
365
-
366
- await registry.initialize("high", mockContext)
367
- await registry.initialize("normal", mockContext)
368
- await registry.initialize("low", mockContext)
369
-
370
- await registry.activateAll(mockContext)
371
-
372
- expect(activationOrder).toEqual(["high", "normal", "low"])
373
- })
374
- })
375
-
376
- describe("Plugin Health Checks", () => {
377
- it("should run health check on plugin", () => {
378
- const plugin = new TestPlugin({
379
- name: "test-plugin",
380
- category: "ui",
381
- priority: "normal"
382
- })
383
-
384
- registry.register("test", plugin)
385
-
386
- const isHealthy = registry.healthCheck("test")
387
- expect(isHealthy).toBe(false) // Not initialized yet
388
-
389
- plugin.onInitializeCalled = true
390
- expect(registry.healthCheck("test")).toBe(true)
391
- })
392
-
393
- it("should run health check on all plugins", async () => {
394
- const plugin1 = new TestPlugin({
395
- name: "plugin1",
396
- category: "ui",
397
- priority: "normal"
398
- })
399
-
400
- const plugin2 = new AnalyticsPlugin({
401
- name: "plugin2",
402
- category: "analytics",
403
- priority: "normal"
404
- })
405
-
406
- registry.register("plugin1", plugin1)
407
- registry.register("plugin2", plugin2)
408
-
409
- await registry.initialize("plugin1", mockContext)
410
- await registry.initialize("plugin2", mockContext)
411
-
412
- const healthStatus = registry.healthCheckAll()
413
-
414
- expect(healthStatus.plugin1).toBe(true)
415
- expect(healthStatus.plugin2).toBe(true)
416
- })
417
- })
418
-
419
- describe("Plugin Queries", () => {
420
- beforeEach(async () => {
421
- const plugin1 = new TestPlugin({
422
- name: "test-ui-plugin",
423
- category: "ui",
424
- priority: "high"
425
- })
426
-
427
- const plugin2 = new AnalyticsPlugin({
428
- name: "analytics-plugin",
429
- category: "analytics",
430
- priority: "normal"
431
- })
432
-
433
- const plugin3 = new CustomControlsPlugin({
434
- name: "controls-plugin",
435
- category: "ui",
436
- priority: "low"
437
- })
438
-
439
- registry.register("test-ui", plugin1)
440
- registry.register("analytics", plugin2)
441
- registry.register("controls", plugin3)
442
-
443
- await registry.initialize("test-ui", mockContext)
444
- await registry.initialize("analytics", mockContext)
445
- })
446
-
447
- it("should get all plugins", () => {
448
- const plugins = registry.getAll()
449
- expect(plugins).toHaveLength(3)
450
- })
451
-
452
- it("should get plugins by category", () => {
453
- const uiPlugins = registry.getByCategory("ui")
454
- expect(uiPlugins).toHaveLength(2)
455
-
456
- const analyticsPlugins = registry.getByCategory("analytics")
457
- expect(analyticsPlugins).toHaveLength(1)
458
- })
459
-
460
- it("should get active plugins", async () => {
461
- await registry.activate("test-ui", mockContext)
462
-
463
- const activePlugins = registry.getActive()
464
- expect(activePlugins).toHaveLength(1)
465
- expect(activePlugins[0].metadata.name).toBe("test-ui-plugin")
466
- })
467
-
468
- it("should check if plugin exists", () => {
469
- expect(registry.has("test-ui")).toBe(true)
470
- expect(registry.has("non-existent")).toBe(false)
471
- })
472
-
473
- it("should get plugin by name", () => {
474
- const plugin = registry.get("test-ui")
475
- expect(plugin).toBeDefined()
476
- expect(plugin?.metadata.name).toBe("test-ui-plugin")
477
- })
478
- })
479
-
480
- describe("Bulk Operations", () => {
481
- beforeEach(() => {
482
- const plugin1 = new TestPlugin({
483
- name: "plugin1",
484
- category: "ui",
485
- priority: "normal"
486
- })
487
-
488
- const plugin2 = new AnalyticsPlugin({
489
- name: "plugin2",
490
- category: "analytics",
491
- priority: "normal"
492
- })
493
-
494
- const plugin3 = new CustomControlsPlugin({
495
- name: "plugin3",
496
- category: "ui",
497
- priority: "normal"
498
- })
499
-
500
- registry.register("plugin1", plugin1)
501
- registry.register("plugin2", plugin2)
502
- registry.register("plugin3", plugin3)
503
- })
504
-
505
- it("should initialize all plugins", async () => {
506
- await registry.initializeAll(mockContext)
507
-
508
- const plugins = registry.getAll()
509
- plugins.forEach((plugin) => {
510
- expect(plugin.isInitialized).toBe(true)
511
- })
512
- })
513
-
514
- it("should activate all plugins", async () => {
515
- await registry.initializeAll(mockContext)
516
- await registry.activateAll(mockContext)
517
-
518
- const plugins = registry.getAll()
519
- plugins.forEach((plugin) => {
520
- expect(plugin.isActive).toBe(true)
521
- })
522
- })
523
-
524
- it("should deactivate all plugins", async () => {
525
- await registry.initializeAll(mockContext)
526
- await registry.activateAll(mockContext)
527
- await registry.deactivateAll(mockContext)
528
-
529
- const plugins = registry.getAll()
530
- plugins.forEach((plugin) => {
531
- expect(plugin.isActive).toBe(false)
532
- })
533
- })
534
-
535
- it("should destroy all plugins", async () => {
536
- await registry.initializeAll(mockContext)
537
- await registry.destroyAll(mockContext)
538
-
539
- expect(registry.getAll()).toHaveLength(0)
540
- })
541
- })
542
-
543
- describe("Error Handling", () => {
544
- it("should handle plugin initialization errors", async () => {
545
- class FailingPlugin extends BasePlugin {
546
- protected onInitialize(): void {
547
- throw new Error("Initialization failed")
548
- }
549
-
550
- protected onActivate(): void {}
551
- protected onDeactivate(): void {}
552
- }
553
-
554
- const plugin = new FailingPlugin({
555
- name: "failing-plugin",
556
- category: "ui",
557
- priority: "normal"
558
- })
559
-
560
- registry.register("failing", plugin)
561
-
562
- await expect(registry.initialize("failing", mockContext)).rejects.toThrow(
563
- "Initialization failed"
564
- )
565
- })
566
-
567
- it("should handle plugin activation errors", async () => {
568
- class FailingActivationPlugin extends BasePlugin {
569
- protected onInitialize(): void {}
570
-
571
- protected onActivate(): void {
572
- throw new Error("Activation failed")
573
- }
574
-
575
- protected onDeactivate(): void {}
576
- }
577
-
578
- const plugin = new FailingActivationPlugin({
579
- name: "failing-activation",
580
- category: "ui",
581
- priority: "normal"
582
- })
583
-
584
- registry.register("failing", plugin)
585
- await registry.initialize("failing", mockContext)
586
-
587
- await expect(registry.activate("failing", mockContext)).rejects.toThrow("Activation failed")
588
- })
589
-
590
- it("should handle missing plugin gracefully", () => {
591
- expect(registry.get("non-existent")).toBeUndefined()
592
- expect(registry.has("non-existent")).toBe(false)
593
- })
594
- })
595
- })