@therealtinhtute/baroiplayer 1.2.0 → 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 (305) hide show
  1. package/README.md +91 -73
  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 +2 -112
  64. package/dist/index.js.map +1 -1
  65. package/dist/index.mjs +786 -6271
  66. package/dist/index.mjs.map +1 -1
  67. package/dist/package.json +3 -0
  68. package/package.json +110 -108
  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 -2
  78. package/dist/context/media.js.map +0 -1
  79. package/dist/context/media.mjs +0 -15
  80. package/dist/context/media.mjs.map +0 -1
  81. package/dist/context/store.js +0 -2
  82. package/dist/context/store.js.map +0 -1
  83. package/dist/context/store.mjs +0 -5
  84. package/dist/context/store.mjs.map +0 -1
  85. package/dist/context-BYwDoSRX.js +0 -1172
  86. package/dist/context-BYwDoSRX.js.map +0 -1
  87. package/dist/context-eNS62_ac.cjs +0 -23
  88. package/dist/context-eNS62_ac.cjs.map +0 -1
  89. package/dist/core-events-B1iM2F46.cjs +0 -2
  90. package/dist/core-events-B1iM2F46.cjs.map +0 -1
  91. package/dist/core-events-DunPHKRE.js +0 -484
  92. package/dist/core-events-DunPHKRE.js.map +0 -1
  93. package/dist/core-plugins-By-4-kGs.cjs +0 -2
  94. package/dist/core-plugins-By-4-kGs.cjs.map +0 -1
  95. package/dist/core-plugins-DSBWcTuX.js +0 -821
  96. package/dist/core-plugins-DSBWcTuX.js.map +0 -1
  97. package/dist/core.js +0 -37
  98. package/dist/core.js.map +0 -1
  99. package/dist/core.mjs +0 -1233
  100. package/dist/core.mjs.map +0 -1
  101. package/dist/enhanced-components-B_l3cist.js +0 -1142
  102. package/dist/enhanced-components-B_l3cist.js.map +0 -1
  103. package/dist/enhanced-components-BspFs9OO.cjs +0 -2
  104. package/dist/enhanced-components-BspFs9OO.cjs.map +0 -1
  105. package/dist/hooks-BXwI8QG6.cjs +0 -4
  106. package/dist/hooks-BXwI8QG6.cjs.map +0 -1
  107. package/dist/hooks-Bpi-jDiO.js +0 -1816
  108. package/dist/hooks-Bpi-jDiO.js.map +0 -1
  109. package/dist/minimal-components-C4z900Ro.js +0 -1926
  110. package/dist/minimal-components-C4z900Ro.js.map +0 -1
  111. package/dist/minimal-components-v4qBp6jv.cjs +0 -2
  112. package/dist/minimal-components-v4qBp6jv.cjs.map +0 -1
  113. package/dist/minimal-components.css +0 -1
  114. package/dist/mona-loading.gif +0 -0
  115. package/dist/performance-monitor-C5k6FDXw.js +0 -301
  116. package/dist/performance-monitor-C5k6FDXw.js.map +0 -1
  117. package/dist/performance-monitor-lJmuUjQQ.cjs +0 -2
  118. package/dist/performance-monitor-lJmuUjQQ.cjs.map +0 -1
  119. package/dist/utils-CFOue_9K.cjs +0 -9
  120. package/dist/utils-CFOue_9K.cjs.map +0 -1
  121. package/dist/utils-Dzpl2ArK.js +0 -2844
  122. package/dist/utils-Dzpl2ArK.js.map +0 -1
  123. package/dist/utils.js +0 -2
  124. package/dist/utils.js.map +0 -1
  125. package/dist/utils.mjs +0 -11
  126. package/dist/utils.mjs.map +0 -1
  127. package/src/adapters/videojs-adapter.tsx +0 -470
  128. package/src/assets/mona-loading.gif +0 -0
  129. package/src/components/AnimateLoading.tsx +0 -107
  130. package/src/components/LoadingState.tsx +0 -239
  131. package/src/components/__tests__/media-player-accessibility.test.tsx +0 -510
  132. package/src/components/__tests__/media-player-react19.test.tsx +0 -457
  133. package/src/components/accessibility/keyboard-help-overlay.tsx +0 -207
  134. package/src/components/audio-player.tsx +0 -85
  135. package/src/components/basic/index.ts +0 -37
  136. package/src/components/enhanced/advanced-features.tsx +0 -311
  137. package/src/components/enhanced/debug-panel.tsx +0 -448
  138. package/src/components/enhanced/enhanced-controls.tsx +0 -597
  139. package/src/components/enhanced/enhanced-media-player.tsx +0 -566
  140. package/src/components/enhanced/error-handling.tsx +0 -338
  141. package/src/components/enhanced/index.ts +0 -39
  142. package/src/components/enhanced/media-player-enhanced.tsx +0 -383
  143. package/src/components/examples/basic-video-player.tsx +0 -50
  144. package/src/components/examples/custom-controls-example.tsx +0 -63
  145. package/src/components/examples/enhanced-controls-example.tsx +0 -100
  146. package/src/components/examples/enhanced-media-player-example.tsx +0 -302
  147. package/src/components/examples/loading-states-demo.tsx +0 -142
  148. package/src/components/examples/react-19-demo.tsx +0 -353
  149. package/src/components/examples/volume-orientation-demo.tsx +0 -106
  150. package/src/components/icon-demo.tsx +0 -196
  151. package/src/components/legacy.tsx +0 -87
  152. package/src/components/media-metadata-display.tsx +0 -99
  153. package/src/components/media-player-audio.tsx +0 -39
  154. package/src/components/media-player-controls.tsx +0 -223
  155. package/src/components/media-player-error.tsx +0 -163
  156. package/src/components/media-player-fullscreen.tsx +0 -109
  157. package/src/components/media-player-hls.tsx +0 -111
  158. package/src/components/media-player-loading.tsx +0 -76
  159. package/src/components/media-player-play.tsx +0 -75
  160. package/src/components/media-player-root.tsx +0 -338
  161. package/src/components/media-player-seek.tsx +0 -168
  162. package/src/components/media-player-time.tsx +0 -99
  163. package/src/components/media-player-tooltip.tsx +0 -58
  164. package/src/components/media-player-video.tsx +0 -54
  165. package/src/components/media-player-volume.tsx +0 -155
  166. package/src/components/media-player.tsx +0 -292
  167. package/src/components/media-suspense.tsx +0 -344
  168. package/src/components/player-settings-form.tsx +0 -158
  169. package/src/components/react-player-wrapper.tsx +0 -651
  170. package/src/components/simple-video-player.tsx +0 -62
  171. package/src/components/ui/blur-poster.tsx +0 -93
  172. package/src/components/ui/empty-state.tsx +0 -91
  173. package/src/components/ui/enhanced-seek-bar.tsx +0 -254
  174. package/src/components/ui/error-state.tsx +0 -124
  175. package/src/components/ui/fullscreen-button.tsx +0 -81
  176. package/src/components/ui/loading-skeleton.tsx +0 -107
  177. package/src/components/ui/media-resource-preloader.tsx +0 -458
  178. package/src/components/ui/offline-message.tsx +0 -98
  179. package/src/components/ui/play-button.tsx +0 -99
  180. package/src/components/ui/seek-bar.tsx +0 -191
  181. package/src/components/ui/time-display.tsx +0 -61
  182. package/src/components/ui/volume-control.tsx +0 -190
  183. package/src/components/unified/base-media-player.tsx +0 -252
  184. package/src/components/unified/media-player.tsx +0 -75
  185. package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +0 -587
  186. package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +0 -573
  187. package/src/components/variants/minimal/MinimalControls.tsx +0 -124
  188. package/src/components/variants/minimal/MinimalLoading.tsx +0 -28
  189. package/src/components/variants/minimal/MinimalMediaPlayer.tsx +0 -318
  190. package/src/components/variants/minimal/MinimalOverlay.tsx +0 -58
  191. package/src/components/variants/minimal/MinimalPlayButton.tsx +0 -56
  192. package/src/components/variants/minimal/MinimalSeekBar.tsx +0 -140
  193. package/src/components/variants/minimal/MinimalVolumeControl.tsx +0 -75
  194. package/src/components/variants/minimal/SimpleMinimalPlayer.tsx +0 -206
  195. package/src/components/variants/minimal/components/CenterPlayButton.tsx +0 -22
  196. package/src/components/variants/minimal/components/ControlBar.tsx +0 -142
  197. package/src/components/variants/minimal/components/EnhancedSettingsMenu.tsx +0 -412
  198. package/src/components/variants/minimal/components/PlaybackControls.tsx +0 -46
  199. package/src/components/variants/minimal/components/RightControls.tsx +0 -164
  200. package/src/components/variants/minimal/components/SeekBar.tsx +0 -127
  201. package/src/components/variants/minimal/components/SettingsDropdown.tsx +0 -68
  202. package/src/components/variants/minimal/components/SubtitleDisplay.tsx +0 -21
  203. package/src/components/variants/minimal/components/TimeDisplay.tsx +0 -15
  204. package/src/components/variants/minimal/components/VideoElement.tsx +0 -33
  205. package/src/components/variants/minimal/components/VolumeControl.tsx +0 -220
  206. package/src/components/variants/minimal/index.ts +0 -23
  207. package/src/components/video-player.tsx +0 -100
  208. package/src/context/__tests__/media-store.test.ts +0 -509
  209. package/src/context/error-handling.ts +0 -398
  210. package/src/context/media-context.tsx +0 -254
  211. package/src/context/media-provider.tsx +0 -264
  212. package/src/context/media-store.ts +0 -387
  213. package/src/context/persistence.ts +0 -462
  214. package/src/core/events/event-system.ts +0 -448
  215. package/src/core/events/hooks.ts +0 -325
  216. package/src/core/events/index.ts +0 -22
  217. package/src/core/events/middleware.ts +0 -286
  218. package/src/core/index.ts +0 -22
  219. package/src/core/optimization/bundle-optimizer.tsx +0 -312
  220. package/src/core/performance/cicd.ts +0 -98
  221. package/src/core/performance/index.ts +0 -38
  222. package/src/core/performance/media-loading-optimizer.ts +0 -544
  223. package/src/core/performance/performance-budgets.ts +0 -437
  224. package/src/core/performance/performance-monitor.tsx +0 -488
  225. package/src/core/performance/performance-testing.ts +0 -461
  226. package/src/core/plugins/__tests__/registry.test.ts +0 -595
  227. package/src/core/plugins/base-plugin.ts +0 -225
  228. package/src/core/plugins/enhanced-plugin-system.ts +0 -435
  229. package/src/core/plugins/examples/analytics-plugin.ts +0 -241
  230. package/src/core/plugins/index.ts +0 -39
  231. package/src/core/plugins/registry.ts +0 -546
  232. package/src/core/plugins/types.ts +0 -169
  233. package/src/core/plugins/utils.ts +0 -317
  234. package/src/core/progressive-loading.tsx +0 -331
  235. package/src/core/providers/enhanced-hls-provider.ts +0 -307
  236. package/src/core/providers/lazy-provider.tsx +0 -14
  237. package/src/core/providers/service-provider.tsx +0 -164
  238. package/src/core/utils.tsx +0 -34
  239. package/src/features/media-session/media-session-manager.ts +0 -411
  240. package/src/features/picture-in-picture/pip-manager.ts +0 -428
  241. package/src/features/playlist/playlist-manager.ts +0 -626
  242. package/src/features/subtitles/subtitle-manager.ts +0 -435
  243. package/src/features/subtitles/subtitle-parser.ts +0 -284
  244. package/src/features/thumbnails/thumbnail-generator.ts +0 -528
  245. package/src/hooks/__tests__/currentTime-fix.test.ts +0 -149
  246. package/src/hooks/__tests__/use-media-player.test.ts +0 -712
  247. package/src/hooks/__tests__/use-media-state.test.tsx +0 -316
  248. package/src/hooks/accessibility/index.ts +0 -27
  249. package/src/hooks/accessibility/use-accessibility-preferences.ts +0 -190
  250. package/src/hooks/accessibility/use-focus-management.ts +0 -183
  251. package/src/hooks/accessibility/use-keyboard-shortcuts.ts +0 -152
  252. package/src/hooks/accessibility/use-screen-reader.ts +0 -212
  253. package/src/hooks/core/index.ts +0 -47
  254. package/src/hooks/legacy.ts +0 -21
  255. package/src/hooks/use-buffer-health.ts +0 -218
  256. package/src/hooks/use-enhanced-media-player.ts +0 -575
  257. package/src/hooks/use-focus-trap.tsx +0 -162
  258. package/src/hooks/use-intelligent-preloading.ts +0 -387
  259. package/src/hooks/use-keyboard-controls.ts +0 -115
  260. package/src/hooks/use-keyboard-shortcuts.ts +0 -255
  261. package/src/hooks/use-media-actions.ts +0 -184
  262. package/src/hooks/use-media-metadata.ts +0 -91
  263. package/src/hooks/use-media-optimistic.ts +0 -264
  264. package/src/hooks/use-media-player.ts +0 -343
  265. package/src/hooks/use-media-state.ts +0 -194
  266. package/src/hooks/use-memory-optimization.ts +0 -360
  267. package/src/hooks/use-network-status.ts +0 -124
  268. package/src/hooks/use-optimistic-controls.ts +0 -95
  269. package/src/hooks/use-optimized-media.ts +0 -283
  270. package/src/hooks/use-smart-preload.ts +0 -229
  271. package/src/hooks/use-touch-gestures.ts +0 -461
  272. package/src/hooks/useEnhancedSubtitles.ts +0 -258
  273. package/src/hooks/useKeyboardShortcuts.ts +0 -106
  274. package/src/hooks/useMediaControls.ts +0 -52
  275. package/src/hooks/useScreenshot.ts +0 -61
  276. package/src/hooks/useSubtitles.ts +0 -91
  277. package/src/hooks/useVideoPlayer.ts +0 -278
  278. package/src/icons/components/FullscreenIcon.tsx +0 -36
  279. package/src/icons/components/SettingsIcon.tsx +0 -37
  280. package/src/icons/components/animated/LoadingIcon.tsx +0 -27
  281. package/src/icons/components/animated/PlayPauseIcon.tsx +0 -42
  282. package/src/icons/components/media/PauseIcon.tsx +0 -38
  283. package/src/icons/components/media/PlayIcon.tsx +0 -37
  284. package/src/icons/components/volume/VolumeIcon.tsx +0 -38
  285. package/src/icons/components/volume/VolumeOffIcon.tsx +0 -38
  286. package/src/icons/index.ts +0 -56
  287. package/src/icons/provider.tsx +0 -58
  288. package/src/icons/types.ts +0 -60
  289. package/src/index-enhanced.ts +0 -35
  290. package/src/index-legacy.ts +0 -324
  291. package/src/index.css +0 -102
  292. package/src/lib/__tests__/async-utils.test.ts +0 -291
  293. package/src/lib/async-utils.ts +0 -194
  294. package/src/lib/deprecation.ts +0 -51
  295. package/src/lib/format-time.ts +0 -37
  296. package/src/lib/index.ts +0 -4
  297. package/src/lib/utils.ts +0 -6
  298. package/src/styles/globals.css +0 -462
  299. package/src/styles/minimal-player.css +0 -621
  300. package/src/styles/pixel-art.css +0 -41
  301. package/src/styles/videojs.css +0 -100
  302. package/src/types/events.ts +0 -47
  303. package/src/types/formats.ts +0 -79
  304. package/src/types/index.ts +0 -203
  305. package/src/types/videojs-plugins.d.ts +0 -14
package/dist/core.mjs DELETED
@@ -1,1233 +0,0 @@
1
- var k = Object.defineProperty;
2
- var A = (o, e, t) => e in o ? k(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var u = (o, e, t) => A(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { C as B, P as R } from "./core-plugins-DSBWcTuX.js";
5
- import { A as ye, B as we, a as Te, d as Se, c as ve, i as be, b as Pe, h as Me, j as Le, g as Ee, f as Ce, e as ke, l as Ae, k as Be } from "./core-plugins-DSBWcTuX.js";
6
- import { E as I } from "./core-events-DunPHKRE.js";
7
- import { a as Ie, b as Ne, M as $e, f as Fe, c as xe, d as Ue, e as De, n as Oe, u as ze, m as _e, p as Ve, h as He, j as je, k as Ye, g as Qe, l as We, i as Ke, o as Je } from "./core-events-DunPHKRE.js";
8
- import { j as f } from "./context-BYwDoSRX.js";
9
- import m, { useMemo as N, createContext as $, useContext as F, lazy as h } from "react";
10
- import { a as x } from "./performance-monitor-C5k6FDXw.js";
11
- import { b as Ge, P as Xe, d as Ze, p as et, u as tt, w as rt } from "./performance-monitor-C5k6FDXw.js";
12
- class P {
13
- constructor() {
14
- u(this, "results", []);
15
- u(this, "regressionDetector", new x());
16
- }
17
- async runTest(e, t) {
18
- const r = [];
19
- let n = 0, s = 0, i;
20
- try {
21
- for (let d = 0; d < e.warmupIterations; d++)
22
- await t();
23
- global.gc && global.gc(), n = this.getMemoryUsage();
24
- for (let d = 0; d < e.iterations; d++) {
25
- const S = performance.now();
26
- await t();
27
- const C = performance.now();
28
- r.push(C - S);
29
- }
30
- s = this.getMemoryUsage();
31
- } catch (d) {
32
- i = d instanceof Error ? d.message : String(d);
33
- }
34
- const a = r.reduce((d, S) => d + S, 0) / r.length, c = Math.min(...r), g = Math.max(...r), T = s - n, y = !i && a <= e.expectedThreshold.renderTime && T <= e.expectedThreshold.memoryUsage, w = {
35
- testName: e.name,
36
- passed: y,
37
- metrics: {
38
- averageRenderTime: a,
39
- minRenderTime: isFinite(c) ? c : 0,
40
- maxRenderTime: isFinite(g) ? g : 0,
41
- memoryUsage: T,
42
- iterations: e.iterations
43
- },
44
- threshold: e.expectedThreshold,
45
- error: i
46
- };
47
- return this.results.push(w), w;
48
- }
49
- getMemoryUsage() {
50
- return "memory" in performance && performance.memory.usedJSHeapSize || 0;
51
- }
52
- // Component rendering performance test
53
- async testComponentRender(e, t, r = 16) {
54
- const n = {
55
- name: `${e} Render Performance`,
56
- iterations: 100,
57
- warmupIterations: 10,
58
- timeout: 5e3,
59
- expectedThreshold: {
60
- renderTime: r,
61
- memoryUsage: 1048576
62
- // 1MB
63
- }
64
- };
65
- return this.runTest(n, t);
66
- }
67
- // Bundle loading performance test
68
- async testBundleLoading(e, t = 1e3) {
69
- const r = {
70
- name: `Bundle Loading: ${e}`,
71
- iterations: 5,
72
- warmupIterations: 1,
73
- timeout: 1e4,
74
- expectedThreshold: {
75
- renderTime: t,
76
- memoryUsage: 5242880
77
- // 5MB
78
- }
79
- };
80
- return this.runTest(r, async () => {
81
- const n = performance.now();
82
- try {
83
- const i = await fetch(e);
84
- if (!i.ok)
85
- throw new Error(`Failed to load bundle: ${i.status}`);
86
- await i.blob();
87
- } catch (i) {
88
- console.warn(`Bundle loading test failed for ${e}:`, i);
89
- }
90
- return performance.now() - n;
91
- });
92
- }
93
- // Memory leak detection test
94
- async testMemoryLeaks(e, t = 1e3) {
95
- const r = {
96
- name: "Memory Leak Detection",
97
- iterations: t,
98
- warmupIterations: 100,
99
- timeout: 3e4,
100
- expectedThreshold: {
101
- renderTime: 1 / 0,
102
- // Not testing render time
103
- memoryUsage: 10485760
104
- // 10MB max increase
105
- }
106
- }, n = this.getMemoryUsage(), s = await this.runTest(r, e), a = this.getMemoryUsage() - n, c = a > r.expectedThreshold.memoryUsage;
107
- return {
108
- ...s,
109
- passed: s.passed && !c,
110
- error: c ? `Potential memory leak detected: ${Math.round(a / 1024 / 1024)}MB increase` : s.error
111
- };
112
- }
113
- // Interaction delay test
114
- async testInteractionDelay(e, t = 100) {
115
- const r = {
116
- name: "Interaction Delay",
117
- iterations: 50,
118
- warmupIterations: 5,
119
- timeout: 5e3,
120
- expectedThreshold: {
121
- renderTime: t,
122
- memoryUsage: 1048576
123
- // 1MB
124
- }
125
- };
126
- return this.runTest(r, e);
127
- }
128
- // Regression testing
129
- async runRegressionTests(e, t) {
130
- t && this.regressionDetector.setBaseline(t);
131
- const r = this.regressionDetector.detectRegression(e);
132
- return { passed: r.length === 0, regressions: r };
133
- }
134
- // Get all test results
135
- getResults() {
136
- return [...this.results];
137
- }
138
- // Get test summary
139
- getSummary() {
140
- const e = this.results.length, t = this.results.filter((s) => s.passed).length, r = e - t, n = e > 0 ? t / e * 100 : 0;
141
- return { totalTests: e, passedTests: t, failedTests: r, passRate: n };
142
- }
143
- // Clear test results
144
- clearResults() {
145
- this.results = [];
146
- }
147
- // Generate performance report
148
- generateReport() {
149
- const e = this.getSummary();
150
- let t = `Performance Test Report
151
- `;
152
- return t += `========================
153
-
154
- `, t += `Total Tests: ${e.totalTests}
155
- `, t += `Passed: ${e.passedTests}
156
- `, t += `Failed: ${e.failedTests}
157
- `, t += `Pass Rate: ${e.passRate.toFixed(1)}%
158
-
159
- `, this.results.length > 0 && (t += `Detailed Results:
160
- `, t += `-----------------
161
-
162
- `, this.results.forEach((r, n) => {
163
- t += `${n + 1}. ${r.testName}
164
- `, t += ` Status: ${r.passed ? "PASS" : "FAIL"}
165
- `, t += ` Average Render Time: ${r.metrics.averageRenderTime.toFixed(2)}ms
166
- `, t += ` Min/Max Render Time: ${r.metrics.minRenderTime.toFixed(2)}ms / ${r.metrics.maxRenderTime.toFixed(2)}ms
167
- `, t += ` Memory Usage: ${Math.round(r.metrics.memoryUsage / 1024)} KB
168
- `, t += ` Iterations: ${r.metrics.iterations}
169
- `, r.error && (t += ` Error: ${r.error}
170
- `), t += `
171
- `;
172
- })), t;
173
- }
174
- }
175
- const v = new P(), te = {
176
- // Test component rendering performance
177
- async testComponent(o, e = {}, t = 16) {
178
- return v.testComponentRender(
179
- o.displayName || o.name || "Component",
180
- () => ({ type: o, props: e }),
181
- t
182
- );
183
- },
184
- // Test hook performance
185
- async testHook(o, e, t = 1) {
186
- const r = {
187
- name: `Hook Performance: ${e}`,
188
- iterations: 1e3,
189
- warmupIterations: 100,
190
- timeout: 5e3,
191
- expectedThreshold: {
192
- renderTime: t,
193
- memoryUsage: 1048576
194
- // 1MB
195
- }
196
- };
197
- return v.runTest(r, o);
198
- },
199
- // Test async operation performance
200
- async testAsyncOperation(o, e, t = 1e3) {
201
- const r = {
202
- name: `Async Operation: ${e}`,
203
- iterations: 10,
204
- warmupIterations: 2,
205
- timeout: 3e4,
206
- expectedThreshold: {
207
- renderTime: t,
208
- memoryUsage: 2097152
209
- // 2MB
210
- }
211
- };
212
- return v.runTest(r, o);
213
- },
214
- // Test bundle size impact
215
- async measureBundleImpact(o, e, t) {
216
- const r = performance.memory?.usedJSHeapSize || 0, n = performance.now();
217
- o();
218
- const s = performance.memory?.usedJSHeapSize || 0, i = performance.now();
219
- e();
220
- const a = performance.memory?.usedJSHeapSize || 0, c = performance.now();
221
- return {
222
- bundleIncrease: a - r,
223
- memoryIncrease: s - r,
224
- renderTimeImpact: c - i - (i - n)
225
- };
226
- }
227
- };
228
- class U {
229
- constructor() {
230
- u(this, "benchmark", new P());
231
- u(this, "suites", /* @__PURE__ */ new Map());
232
- }
233
- // Register a test suite
234
- registerSuite(e, t) {
235
- this.suites.set(e, t);
236
- }
237
- // Run all tests in a suite
238
- async runSuite(e, t) {
239
- const r = this.suites.get(e);
240
- if (!r)
241
- throw new Error(`Test suite '${e}' not found`);
242
- const n = [];
243
- for (const s of r) {
244
- const i = t.get(s.name);
245
- if (!i) {
246
- console.warn(`No implementation found for test '${s.name}'`);
247
- continue;
248
- }
249
- const a = await this.benchmark.runTest(s, i);
250
- n.push(a);
251
- }
252
- return n;
253
- }
254
- // Run all registered test suites
255
- async runAllSuites(e) {
256
- const t = /* @__PURE__ */ new Map();
257
- for (const [r] of this.suites) {
258
- const n = e.get(r);
259
- if (!n) {
260
- console.warn(`No implementations found for suite '${r}'`);
261
- continue;
262
- }
263
- const s = await this.runSuite(r, n);
264
- t.set(r, s);
265
- }
266
- return t;
267
- }
268
- // Generate comprehensive report
269
- generateComprehensiveReport() {
270
- this.benchmark.getSummary();
271
- let e = this.benchmark.generateReport();
272
- if (this.suites.size > 0) {
273
- e += `
274
- Test Suites:
275
- `, e += `============
276
-
277
- `;
278
- for (const [t, r] of this.suites)
279
- e += `Suite: ${t}
280
- `, e += `Tests: ${r.length}
281
-
282
- `;
283
- }
284
- return e;
285
- }
286
- }
287
- const re = new U(), D = [
288
- // Bundle size budgets
289
- {
290
- name: "Main Bundle Size (ESM)",
291
- category: "bundle",
292
- limit: 250 * 1024,
293
- // 250KB
294
- unit: "bytes",
295
- severity: "error",
296
- description: "Main bundle should stay under 250KB for fast initial loading"
297
- },
298
- {
299
- name: "Main Bundle Size (CJS)",
300
- category: "bundle",
301
- limit: 200 * 1024,
302
- // 200KB
303
- unit: "bytes",
304
- severity: "error",
305
- description: "CJS bundle should be smaller due to better compression"
306
- },
307
- {
308
- name: "Core Module Size",
309
- category: "bundle",
310
- limit: 15 * 1024,
311
- // 15KB
312
- unit: "bytes",
313
- severity: "warning",
314
- description: "Core architecture should remain lightweight"
315
- },
316
- {
317
- name: "Enhanced Components Size",
318
- category: "bundle",
319
- limit: 40 * 1024,
320
- // 40KB
321
- unit: "bytes",
322
- severity: "warning",
323
- description: "Enhanced components bundle size"
324
- },
325
- // Runtime performance budgets
326
- {
327
- name: "Component Render Time",
328
- category: "runtime",
329
- limit: 16,
330
- // 16ms for 60fps
331
- unit: "ms",
332
- severity: "error",
333
- description: "Component rendering should complete within one frame"
334
- },
335
- {
336
- name: "First Input Delay",
337
- category: "runtime",
338
- limit: 100,
339
- // 100ms
340
- unit: "ms",
341
- severity: "error",
342
- description: "First Input Delay should be under 100ms for good UX"
343
- },
344
- {
345
- name: "Largest Contentful Paint",
346
- category: "runtime",
347
- limit: 2500,
348
- // 2.5s
349
- unit: "ms",
350
- severity: "warning",
351
- description: "LCP should be under 2.5s for good Core Web Vitals score"
352
- },
353
- {
354
- name: "Cumulative Layout Shift",
355
- category: "runtime",
356
- limit: 0.1,
357
- unit: "score",
358
- severity: "warning",
359
- description: "CLS should be under 0.1 for good visual stability"
360
- },
361
- // Memory budgets
362
- {
363
- name: "Memory Usage",
364
- category: "memory",
365
- limit: 50 * 1024 * 1024,
366
- // 50MB
367
- unit: "bytes",
368
- severity: "warning",
369
- description: "Memory usage should stay under 50MB for good performance"
370
- },
371
- {
372
- name: "Memory Increase Per Operation",
373
- category: "memory",
374
- limit: 1024 * 1024,
375
- // 1MB
376
- unit: "bytes",
377
- severity: "error",
378
- description: "Each operation should not increase memory by more than 1MB"
379
- },
380
- // Network budgets (for media loading)
381
- {
382
- name: "Media Load Time",
383
- category: "network",
384
- limit: 3e3,
385
- // 3s
386
- unit: "ms",
387
- severity: "warning",
388
- description: "Media should start loading within 3 seconds"
389
- }
390
- ];
391
- class O {
392
- constructor(e = D, t = {
393
- enabled: !0,
394
- channels: [{ type: "console", config: {} }],
395
- threshold: 1,
396
- cooldown: 300 * 1e3
397
- // 5 minutes
398
- }) {
399
- u(this, "budgets", /* @__PURE__ */ new Map());
400
- u(this, "violations", []);
401
- u(this, "alertConfig");
402
- u(this, "lastAlertTime", 0);
403
- e.forEach((r) => {
404
- this.budgets.set(r.name, r);
405
- }), this.alertConfig = t;
406
- }
407
- // Check a single metric against budgets
408
- checkMetric(e, t, r = "runtime") {
409
- const n = [];
410
- for (const [s, i] of this.budgets)
411
- if (i.category === r && (s.includes(e) || e.includes(s.split(" ")[0]?.toLowerCase() || "")) && t > i.limit) {
412
- const a = {
413
- budget: i,
414
- actualValue: t,
415
- overageAmount: t - i.limit,
416
- overagePercentage: (t - i.limit) / i.limit * 100,
417
- timestamp: Date.now()
418
- };
419
- n.push(a), this.violations.push(a);
420
- }
421
- return n.length > 0 && this.handleViolations(n), n;
422
- }
423
- // Check bundle sizes
424
- async checkBundleSizes(e) {
425
- const t = [];
426
- return typeof window < "u" || typeof process > "u" ? (console.warn("Bundle size checking is only available in Node.js environment"), t) : (console.warn(
427
- "Bundle size checking disabled - use Node.js cicdIntegration from @therealtinhtute/baroiplayer/core/performance/cicd for CI/CD environments"
428
- ), t);
429
- }
430
- // Check runtime performance
431
- checkRuntimeMetrics(e) {
432
- const t = [];
433
- return e.renderTime !== void 0 && t.push(
434
- ...this.checkMetric("Component Render Time", e.renderTime, "runtime")
435
- ), e.fid !== void 0 && t.push(...this.checkMetric("First Input Delay", e.fid, "runtime")), e.lcp !== void 0 && t.push(...this.checkMetric("Largest Contentful Paint", e.lcp, "runtime")), e.cls !== void 0 && t.push(...this.checkMetric("Cumulative Layout Shift", e.cls, "runtime")), e.memoryUsage !== void 0 && t.push(...this.checkMetric("Memory Usage", e.memoryUsage, "memory")), e.mediaLoadTime !== void 0 && t.push(...this.checkMetric("Media Load Time", e.mediaLoadTime, "network")), t;
436
- }
437
- // Handle budget violations
438
- async handleViolations(e) {
439
- if (!this.alertConfig.enabled) return;
440
- const t = Date.now();
441
- e.filter((n) => n.budget.severity === "error").length >= this.alertConfig.threshold && t - this.lastAlertTime >= this.alertConfig.cooldown && (await this.sendAlerts(e), this.lastAlertTime = t);
442
- }
443
- // Send alerts through configured channels
444
- async sendAlerts(e) {
445
- const t = this.formatAlertMessage(e);
446
- for (const r of this.alertConfig.channels)
447
- try {
448
- await this.sendAlert(r, t);
449
- } catch (n) {
450
- console.error(`Failed to send alert via ${r.type}:`, n);
451
- }
452
- }
453
- // Format alert message
454
- formatAlertMessage(e) {
455
- let t = `🚨 Performance Budget Violations Detected!
456
-
457
- `;
458
- return e.forEach((r) => {
459
- const { budget: n, actualValue: s, overageAmount: i, overagePercentage: a } = r;
460
- this.getUnitDisplay(n.unit), t += `❌ ${n.name}
461
- `, t += ` Limit: ${this.formatValue(n.limit, n.unit)}
462
- `, t += ` Actual: ${this.formatValue(s, n.unit)}
463
- `, t += ` Overage: ${this.formatValue(i, n.unit)} (+${a.toFixed(1)}%)
464
- `, t += ` Severity: ${n.severity.toUpperCase()}
465
-
466
- `;
467
- }), t += `Time: ${(/* @__PURE__ */ new Date()).toISOString()}
468
- `, t += `Total Violations: ${e.length}`, t;
469
- }
470
- // Send alert to specific channel
471
- async sendAlert(e, t) {
472
- switch (e.type) {
473
- case "console":
474
- console.error(t);
475
- break;
476
- case "webhook":
477
- if (e.config.url) {
478
- const r = await fetch(e.config.url, {
479
- method: "POST",
480
- headers: { "Content-Type": "application/json" },
481
- body: JSON.stringify({ text: t, timestamp: Date.now() })
482
- });
483
- if (!r.ok)
484
- throw new Error(`Webhook failed: ${r.status}`);
485
- }
486
- break;
487
- case "slack":
488
- if (e.config.url) {
489
- const r = await fetch(e.config.url, {
490
- method: "POST",
491
- headers: { "Content-Type": "application/json" },
492
- body: JSON.stringify({
493
- text: t,
494
- channel: e.config.channel,
495
- username: "BaroiPlayer Performance Monitor"
496
- })
497
- });
498
- if (!r.ok)
499
- throw new Error(`Slack webhook failed: ${r.status}`);
500
- }
501
- break;
502
- default:
503
- console.warn(`Unsupported alert channel: ${e.type}`);
504
- }
505
- }
506
- // Helper methods
507
- formatValue(e, t) {
508
- switch (t) {
509
- case "bytes":
510
- return this.formatBytes(e);
511
- case "ms":
512
- return `${e.toFixed(2)}ms`;
513
- case "score":
514
- return e.toFixed(3);
515
- case "percent":
516
- return `${e.toFixed(1)}%`;
517
- default:
518
- return e.toString();
519
- }
520
- }
521
- formatBytes(e) {
522
- return e >= 1024 * 1024 ? `${(e / 1024 / 1024).toFixed(2)}MB` : e >= 1024 ? `${(e / 1024).toFixed(2)}KB` : `${e}B`;
523
- }
524
- getUnitDisplay(e) {
525
- return {
526
- bytes: "bytes",
527
- ms: "milliseconds",
528
- score: "score",
529
- percent: "percent"
530
- }[e] || e;
531
- }
532
- // Management methods
533
- addBudget(e) {
534
- this.budgets.set(e.name, e);
535
- }
536
- removeBudget(e) {
537
- this.budgets.delete(e);
538
- }
539
- updateBudget(e, t) {
540
- const r = this.budgets.get(e);
541
- r && this.budgets.set(e, { ...r, ...t });
542
- }
543
- getBudgets() {
544
- return Array.from(this.budgets.values());
545
- }
546
- getViolations(e) {
547
- return e ? this.violations.filter((t) => t.timestamp >= e) : [...this.violations];
548
- }
549
- clearViolations() {
550
- this.violations = [];
551
- }
552
- getViolationSummary() {
553
- const e = {}, t = {};
554
- return this.violations.forEach((r) => {
555
- const n = r.budget.category, s = r.budget.severity;
556
- e[n] = (e[n] || 0) + 1, t[s] = (t[s] || 0) + 1;
557
- }), {
558
- total: this.violations.length,
559
- byCategory: e,
560
- bySeverity: t
561
- };
562
- }
563
- }
564
- const ne = new O(), z = {
565
- preloadStrategy: "metadata",
566
- adaptiveBitrate: !0,
567
- maxPreloadSize: 2 * 1024 * 1024,
568
- // 2MB
569
- networkThresholds: {
570
- "2g": { maxBitrate: 128, preload: !1 },
571
- // 128 kbps
572
- "3g": { maxBitrate: 500, preload: !1 },
573
- // 500 kbps
574
- "4g": { maxBitrate: 2e3, preload: !0 },
575
- // 2 Mbps
576
- "5g": { maxBitrate: 1e4, preload: !0 }
577
- // 10 Mbps
578
- },
579
- bufferSize: 10,
580
- // 10 seconds
581
- enableServiceWorker: !0
582
- };
583
- class _ {
584
- constructor() {
585
- u(this, "connection");
586
- u(this, "listeners", /* @__PURE__ */ new Set());
587
- u(this, "currentInfo");
588
- if (typeof window > "u" || typeof navigator > "u") {
589
- this.connection = null, this.currentInfo = {
590
- effectiveType: "unknown",
591
- downlink: 0,
592
- rtt: 0,
593
- saveData: !1,
594
- isOnline: !0
595
- };
596
- return;
597
- }
598
- this.connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection, this.currentInfo = this.getNetworkInfo(), this.initializeListeners();
599
- }
600
- getNetworkInfo() {
601
- if (typeof navigator > "u")
602
- return {
603
- effectiveType: "unknown",
604
- downlink: 0,
605
- rtt: 0,
606
- saveData: !1,
607
- isOnline: !0
608
- };
609
- const e = navigator.onLine;
610
- return this.connection ? {
611
- effectiveType: this.connection.effectiveType || "unknown",
612
- downlink: this.connection.downlink || 0,
613
- rtt: this.connection.rtt || 0,
614
- saveData: this.connection.saveData || !1,
615
- isOnline: e
616
- } : {
617
- effectiveType: "unknown",
618
- downlink: 0,
619
- rtt: 0,
620
- saveData: !1,
621
- isOnline: e
622
- };
623
- }
624
- initializeListeners() {
625
- typeof window > "u" || (this.connection && this.connection.addEventListener("change", this.handleNetworkChange.bind(this)), window.addEventListener("online", this.handleNetworkChange.bind(this)), window.addEventListener("offline", this.handleNetworkChange.bind(this)));
626
- }
627
- handleNetworkChange() {
628
- const e = this.getNetworkInfo();
629
- this.currentInfo = e, this.listeners.forEach((t) => t(e));
630
- }
631
- getCurrentNetworkInfo() {
632
- return { ...this.currentInfo };
633
- }
634
- subscribe(e) {
635
- return this.listeners.add(e), () => this.listeners.delete(e);
636
- }
637
- // Estimate available bandwidth with fallback detection
638
- async estimateBandwidth() {
639
- if (this.connection && this.connection.downlink)
640
- return this.connection.downlink * 1e3;
641
- try {
642
- const e = performance.now(), n = await (await fetch("/api/bandwidth-test?size=100kb")).blob(), i = (performance.now() - e) / 1e3;
643
- return n.size * 8 / i / 1e3;
644
- } catch (e) {
645
- return console.warn("Bandwidth estimation failed:", e), 1e3;
646
- }
647
- }
648
- }
649
- class M {
650
- constructor(e = {}) {
651
- u(this, "config");
652
- u(this, "networkMonitor");
653
- u(this, "loadingMetrics", /* @__PURE__ */ new Map());
654
- u(this, "preloadCache", /* @__PURE__ */ new Map());
655
- this.config = { ...z, ...e }, this.networkMonitor = new _(), this.initializeNetworkMonitoring();
656
- }
657
- initializeNetworkMonitoring() {
658
- this.networkMonitor.subscribe((e) => {
659
- this.handleNetworkChange(e);
660
- });
661
- }
662
- handleNetworkChange(e) {
663
- console.log("Network changed:", e), this.config.adaptiveBitrate && this.adjustQualityForNetwork(e), (e.effectiveType === "2g" || e.saveData) && this.clearPreloadCache();
664
- }
665
- // Optimize media loading based on network conditions
666
- async optimizeMediaLoading(e, t, r = {}) {
667
- const n = performance.now(), s = this.networkMonitor.getCurrentNetworkInfo(), i = {
668
- loadStartTime: n,
669
- bytesLoaded: 0,
670
- loadSpeed: 0,
671
- networkType: s.effectiveType,
672
- quality: r.quality || "auto",
673
- bufferHealth: 0,
674
- stallsCount: 0,
675
- stallsDuration: 0
676
- };
677
- this.loadingMetrics.set(e, i);
678
- try {
679
- const a = this.chooseLoadingStrategy(s, r);
680
- return a.shouldPreload && await this.preloadMedia(e, a.preloadAmount), t.preload = a.preloadAttribute, this.monitorLoadingProgress(t, i), this.config.adaptiveBitrate && a.suggestedQuality && this.applyQualitySettings(t, a.suggestedQuality), i;
681
- } catch (a) {
682
- return console.error("Media loading optimization failed:", a), i;
683
- }
684
- }
685
- chooseLoadingStrategy(e, t) {
686
- const r = e.effectiveType === "unknown" ? "4g" : e.effectiveType, n = this.config.networkThresholds[r] || this.config.networkThresholds["4g"];
687
- return {
688
- shouldPreload: t.preload !== !1 && n.preload && !e.saveData,
689
- preloadAmount: e.saveData ? 0 : this.config.maxPreloadSize,
690
- preloadAttribute: this.getPreloadAttribute(e),
691
- suggestedQuality: this.getSuggestedQuality(e, n.maxBitrate),
692
- bufferTarget: this.getBufferTarget(e)
693
- };
694
- }
695
- getPreloadAttribute(e) {
696
- return e.saveData || e.effectiveType === "2g" ? "none" : e.effectiveType === "3g" ? "metadata" : this.config.preloadStrategy;
697
- }
698
- getSuggestedQuality(e, t) {
699
- const r = e.downlink * 1e3;
700
- return r >= t * 2 ? "high" : r >= t ? "medium" : "low";
701
- }
702
- getBufferTarget(e) {
703
- switch (e.effectiveType) {
704
- case "2g":
705
- return 2;
706
- // 2 seconds
707
- case "3g":
708
- return 5;
709
- // 5 seconds
710
- case "4g":
711
- return this.config.bufferSize;
712
- case "5g":
713
- return this.config.bufferSize * 1.5;
714
- default:
715
- return this.config.bufferSize;
716
- }
717
- }
718
- // Preload media content
719
- async preloadMedia(e, t) {
720
- if (this.preloadCache.has(e))
721
- return;
722
- const r = this.fetchWithProgress(e, t);
723
- this.preloadCache.set(e, r);
724
- try {
725
- await r;
726
- } catch (n) {
727
- console.warn(`Preload failed for ${e}:`, n), this.preloadCache.delete(e);
728
- }
729
- }
730
- async fetchWithProgress(e, t) {
731
- const r = await fetch(e, {
732
- headers: {
733
- Range: `bytes=0-${t - 1}`
734
- // Limit preload size
735
- }
736
- });
737
- if (!r.ok)
738
- throw new Error(`Failed to preload: ${r.status}`);
739
- const n = r.body?.getReader();
740
- if (!n)
741
- throw new Error("Response body not readable");
742
- const s = [];
743
- let i = 0;
744
- try {
745
- for (; i < t; ) {
746
- const { done: a, value: c } = await n.read();
747
- if (a) break;
748
- s.push(c), i += c.length;
749
- }
750
- } finally {
751
- n.releaseLock();
752
- }
753
- return new Blob(s);
754
- }
755
- // Monitor loading progress and update metrics
756
- monitorLoadingProgress(e, t) {
757
- let r = null;
758
- const n = () => {
759
- if (e.buffered.length > 0) {
760
- const y = e.buffered.end(e.buffered.length - 1), w = e.currentTime;
761
- t.bufferHealth = Math.min((y - w) / this.config.bufferSize, 1);
762
- }
763
- }, s = () => {
764
- t.firstByteTime = performance.now();
765
- }, i = () => {
766
- t.loadCompleteTime = performance.now(), t.totalLoadTime = t.loadCompleteTime - t.loadStartTime, t.totalLoadTime && t.bytesLoaded > 0 && (t.loadSpeed = t.bytesLoaded / (t.totalLoadTime / 1e3));
767
- }, a = () => {
768
- r === null && (r = performance.now(), t.stallsCount++);
769
- }, c = () => {
770
- r !== null && (t.stallsDuration += performance.now() - r, r = null), n();
771
- }, g = () => {
772
- if (e.buffered.length > 0) {
773
- const y = e.buffered.end(0) * 1e3;
774
- t.bytesLoaded = y;
775
- }
776
- n();
777
- };
778
- e.addEventListener("loadstart", s), e.addEventListener("canplay", i), e.addEventListener("waiting", a), e.addEventListener("playing", c), e.addEventListener("progress", g), setTimeout(() => {
779
- e.removeEventListener("loadstart", s), e.removeEventListener("canplay", i), e.removeEventListener("waiting", a), e.removeEventListener("playing", c), e.removeEventListener("progress", g);
780
- }, 300 * 1e3);
781
- }
782
- // Apply quality settings (would integrate with HLS.js or similar)
783
- applyQualitySettings(e, t) {
784
- console.log(`Applying quality setting: ${t} to`, e);
785
- }
786
- adjustQualityForNetwork(e) {
787
- console.log("Adjusting quality for network conditions:", e.effectiveType);
788
- }
789
- // Clear preload cache to save memory
790
- clearPreloadCache() {
791
- this.preloadCache.clear();
792
- }
793
- // Get loading metrics for a specific media URL
794
- getLoadingMetrics(e) {
795
- return this.loadingMetrics.get(e);
796
- }
797
- // Get all loading metrics
798
- getAllMetrics() {
799
- return Array.from(this.loadingMetrics.values());
800
- }
801
- // Calculate average loading performance
802
- getAverageLoadingTime() {
803
- const t = this.getAllMetrics().filter((n) => n.totalLoadTime !== void 0);
804
- return t.length === 0 ? 0 : t.reduce((n, s) => n + (s.totalLoadTime || 0), 0) / t.length;
805
- }
806
- // Get network-specific performance stats
807
- getNetworkPerformanceStats() {
808
- const e = /* @__PURE__ */ new Map();
809
- return this.getAllMetrics().forEach((t) => {
810
- const r = t.networkType;
811
- e.has(r) || e.set(r, []), e.get(r).push(t);
812
- }), Array.from(e.entries()).map(([t, r]) => ({
813
- networkType: t,
814
- avgLoadTime: r.reduce((n, s) => n + (s.totalLoadTime || 0), 0) / r.length,
815
- avgStalls: r.reduce((n, s) => n + s.stallsCount, 0) / r.length,
816
- avgBufferHealth: r.reduce((n, s) => n + s.bufferHealth, 0) / r.length
817
- }));
818
- }
819
- }
820
- const V = new M();
821
- function oe(o) {
822
- const [e] = m.useState(
823
- () => o ? new M(o) : V
824
- ), [t, r] = m.useState(null), [n, s] = m.useState([]);
825
- m.useEffect(() => {
826
- const a = e.networkMonitor.subscribe(r);
827
- r(e.networkMonitor.getCurrentNetworkInfo());
828
- const c = setInterval(() => {
829
- s(e.getAllMetrics());
830
- }, 1e3);
831
- return () => {
832
- a(), clearInterval(c);
833
- };
834
- }, [e]);
835
- const i = m.useCallback(
836
- (a, c, g) => e.optimizeMediaLoading(a, c, g),
837
- [e]
838
- );
839
- return {
840
- networkInfo: t,
841
- loadingMetrics: n,
842
- optimizeLoading: i,
843
- averageLoadTime: e.getAverageLoadingTime(),
844
- networkStats: e.getNetworkPerformanceStats()
845
- };
846
- }
847
- class H {
848
- get(e) {
849
- try {
850
- const t = localStorage.getItem(`baroi-player-${e}`);
851
- return t ? JSON.parse(t) : null;
852
- } catch {
853
- return null;
854
- }
855
- }
856
- set(e, t) {
857
- try {
858
- localStorage.setItem(`baroi-player-${e}`, JSON.stringify(t));
859
- } catch (r) {
860
- console.warn("Failed to store data:", r);
861
- }
862
- }
863
- remove(e) {
864
- try {
865
- localStorage.removeItem(`baroi-player-${e}`);
866
- } catch (t) {
867
- console.warn("Failed to remove data:", t);
868
- }
869
- }
870
- clear() {
871
- try {
872
- Object.keys(localStorage).forEach((e) => {
873
- e.startsWith("baroi-player-") && localStorage.removeItem(e);
874
- });
875
- } catch (e) {
876
- console.warn("Failed to clear data:", e);
877
- }
878
- }
879
- }
880
- class j {
881
- track(e, t) {
882
- console.log("Analytics:", e, t);
883
- }
884
- identify(e, t) {
885
- console.log("Analytics identify:", e, t);
886
- }
887
- page(e, t) {
888
- console.log("Analytics page:", e, t);
889
- }
890
- }
891
- const L = $(null);
892
- function Y({ children: o, services: e = {} }) {
893
- const t = N(() => {
894
- const r = e.logger || new B("[BaroiPlayer]"), n = e.eventBus || new I(), s = e.pluginRegistry || new R(r), i = e.storage || new H(), a = e.analytics || new j();
895
- return {
896
- eventBus: n,
897
- pluginRegistry: s,
898
- storage: i,
899
- analytics: a,
900
- logger: r
901
- };
902
- }, [e]);
903
- return /* @__PURE__ */ f.jsx(L.Provider, { value: t, children: o });
904
- }
905
- function p() {
906
- const o = F(L);
907
- if (!o)
908
- throw new Error("useServices must be used within ServiceProvider");
909
- return o;
910
- }
911
- function se() {
912
- return p().eventBus;
913
- }
914
- function ie() {
915
- return p().pluginRegistry;
916
- }
917
- function ae() {
918
- return p().storage;
919
- }
920
- function ce() {
921
- return p().analytics;
922
- }
923
- function le() {
924
- return p().logger;
925
- }
926
- function ue(o) {
927
- return function(t) {
928
- const r = p();
929
- return /* @__PURE__ */ f.jsx(o, { ...t, services: r });
930
- };
931
- }
932
- function de(o = {}) {
933
- return function({ children: t }) {
934
- return /* @__PURE__ */ f.jsx(Y, { services: o.services, children: t });
935
- };
936
- }
937
- const l = {
938
- SUBTITLES: "subtitles",
939
- PLAYLISTS: "playlists",
940
- ADVANCED_CONTROLS: "advanced_controls",
941
- ANALYTICS: "analytics",
942
- PICTURE_IN_PICTURE: "picture_in_picture",
943
- QUALITY_SELECTOR: "quality_selector",
944
- PLAYBACK_SPEED: "playback_speed",
945
- CHAPTERS: "chapters",
946
- THUMBNAILS: "thumbnails",
947
- KEYBOARD_SHORTCUTS: "keyboard_shortcuts"
948
- }, Q = {
949
- enabledFeatures: [l.SUBTITLES, l.ADVANCED_CONTROLS, l.KEYBOARD_SHORTCUTS],
950
- loadingStrategy: "lazy",
951
- fallbackTimeout: 5e3,
952
- retryAttempts: 3
953
- }, me = {
954
- // Subtitle system
955
- SubtitleSelector: h(
956
- () => import("./enhanced-components-B_l3cist.js").then((o) => o.g).then((o) => ({
957
- default: o.SubtitleSelector
958
- }))
959
- ),
960
- // Playlist functionality
961
- PlaylistManager: h(
962
- () => import("./enhanced-components-B_l3cist.js").then((o) => o.g).then((o) => ({
963
- default: o.SubtitleSelector
964
- }))
965
- // Use existing component as placeholder
966
- ),
967
- // Advanced controls
968
- QualitySelector: h(
969
- () => import("./enhanced-components-B_l3cist.js").then((o) => o.g).then((o) => ({
970
- default: o.QualitySelector
971
- }))
972
- ),
973
- PlaybackSpeedSelector: h(
974
- () => import("./enhanced-components-B_l3cist.js").then((o) => o.g).then((o) => ({
975
- default: o.PlaybackSpeedSelector
976
- }))
977
- ),
978
- ChaptersPanel: h(
979
- () => import("./enhanced-components-B_l3cist.js").then((o) => o.g).then((o) => ({
980
- default: o.ChaptersPanel
981
- }))
982
- ),
983
- PictureInPictureButton: h(
984
- () => import("./enhanced-components-B_l3cist.js").then((o) => o.g).then((o) => ({
985
- default: o.PictureInPictureButton
986
- }))
987
- ),
988
- // Analytics
989
- AnalyticsTracker: h(
990
- () => import("./enhanced-components-B_l3cist.js").then((o) => o.g).then((o) => ({
991
- default: o.SubtitleSelector
992
- }))
993
- // Use existing component as placeholder
994
- )
995
- };
996
- class E {
997
- static async isSupported(e) {
998
- if (this.cache.has(e))
999
- return this.cache.get(e);
1000
- const t = await this.checkFeatureSupport(e);
1001
- return this.cache.set(e, t), t;
1002
- }
1003
- static async checkFeatureSupport(e) {
1004
- if (typeof window > "u" || typeof document > "u")
1005
- return !0;
1006
- switch (e) {
1007
- case l.SUBTITLES:
1008
- return "TextTrack" in window;
1009
- case l.PICTURE_IN_PICTURE:
1010
- return "pictureInPictureEnabled" in document;
1011
- case l.ADVANCED_CONTROLS:
1012
- return !0;
1013
- // Always supported
1014
- case l.PLAYLISTS:
1015
- return "MediaSession" in window;
1016
- case l.ANALYTICS:
1017
- return "IntersectionObserver" in window;
1018
- case l.QUALITY_SELECTOR:
1019
- return "MediaSource" in window;
1020
- case l.PLAYBACK_SPEED:
1021
- return !0;
1022
- // HTML5 video supports this
1023
- case l.CHAPTERS:
1024
- return "TextTrack" in window;
1025
- case l.THUMBNAILS:
1026
- return "OffscreenCanvas" in window || "canvas" in document.createElement("canvas");
1027
- case l.KEYBOARD_SHORTCUTS:
1028
- return "KeyboardEvent" in window;
1029
- default:
1030
- return !1;
1031
- }
1032
- }
1033
- }
1034
- u(E, "cache", /* @__PURE__ */ new Map());
1035
- class W {
1036
- constructor(e = {}) {
1037
- u(this, "config");
1038
- u(this, "loadedFeatures", /* @__PURE__ */ new Set());
1039
- u(this, "loadingPromises", /* @__PURE__ */ new Map());
1040
- this.config = { ...Q, ...e };
1041
- }
1042
- async loadFeature(e) {
1043
- if (!this.config.enabledFeatures.includes(e))
1044
- return null;
1045
- if (this.loadedFeatures.has(e))
1046
- return this.getLoadedFeature(e);
1047
- if (this.loadingPromises.has(e))
1048
- return this.loadingPromises.get(e);
1049
- if (!await E.isSupported(e))
1050
- return console.warn(`Feature ${e} is not supported in this browser`), null;
1051
- const r = this.loadWithRetry(e);
1052
- this.loadingPromises.set(e, r);
1053
- try {
1054
- const n = await r;
1055
- return this.loadedFeatures.add(e), n;
1056
- } catch (n) {
1057
- return console.error(`Failed to load feature ${e}:`, n), this.loadingPromises.delete(e), null;
1058
- }
1059
- }
1060
- async loadWithRetry(e, t = 1) {
1061
- try {
1062
- return await this.loadFeatureModule(e);
1063
- } catch (r) {
1064
- if (t < this.config.retryAttempts)
1065
- return console.warn(
1066
- `Loading feature ${e} failed, retrying (${t}/${this.config.retryAttempts})`
1067
- ), await new Promise((n) => setTimeout(n, 1e3 * t)), this.loadWithRetry(e, t + 1);
1068
- throw r;
1069
- }
1070
- }
1071
- async loadFeatureModule(e) {
1072
- switch (e) {
1073
- case l.SUBTITLES:
1074
- return import("./hooks-Bpi-jDiO.js").then((t) => t.v);
1075
- case l.PLAYLISTS:
1076
- return import("./enhanced-components-B_l3cist.js").then((t) => t.g);
1077
- // Use existing features
1078
- case l.ADVANCED_CONTROLS:
1079
- return import("./enhanced-components-B_l3cist.js").then((t) => t.g);
1080
- case l.ANALYTICS:
1081
- return import("./enhanced-components-B_l3cist.js").then((t) => t.g);
1082
- // Use existing features
1083
- case l.PICTURE_IN_PICTURE:
1084
- return import("./enhanced-components-B_l3cist.js").then((t) => t.g);
1085
- // Use existing features
1086
- case l.QUALITY_SELECTOR:
1087
- return import("./enhanced-components-B_l3cist.js").then((t) => t.g);
1088
- // Use existing features
1089
- case l.PLAYBACK_SPEED:
1090
- return import("./enhanced-components-B_l3cist.js").then((t) => t.g);
1091
- // Use existing features
1092
- case l.CHAPTERS:
1093
- return import("./enhanced-components-B_l3cist.js").then((t) => t.g);
1094
- // Use existing features
1095
- case l.THUMBNAILS:
1096
- return import("./enhanced-components-B_l3cist.js").then((t) => t.g);
1097
- // Use existing features
1098
- case l.KEYBOARD_SHORTCUTS:
1099
- return import("./hooks-Bpi-jDiO.js").then((t) => t.t);
1100
- default:
1101
- throw new Error(`Unknown feature: ${e}`);
1102
- }
1103
- }
1104
- getLoadedFeature(e) {
1105
- return this.loadingPromises.get(e);
1106
- }
1107
- // Preload features for faster access
1108
- async preloadFeatures(e = this.config.enabledFeatures) {
1109
- const t = e.map((r) => this.loadFeature(r));
1110
- await Promise.allSettled(t);
1111
- }
1112
- // Get loading state
1113
- getLoadingState() {
1114
- return {
1115
- loaded: Array.from(this.loadedFeatures),
1116
- loading: Array.from(this.loadingPromises.keys()),
1117
- enabled: this.config.enabledFeatures
1118
- };
1119
- }
1120
- }
1121
- const b = new W();
1122
- function K(o) {
1123
- const [e, t] = m.useState(null), [r, n] = m.useState(!1), [s, i] = m.useState(null), a = m.useCallback(async () => {
1124
- if (!(r || e)) {
1125
- n(!0), i(null);
1126
- try {
1127
- const c = await b.loadFeature(o);
1128
- t(c);
1129
- } catch (c) {
1130
- i(c);
1131
- } finally {
1132
- n(!1);
1133
- }
1134
- }
1135
- }, [o, r, e]);
1136
- return m.useEffect(() => {
1137
- b.config.loadingStrategy === "immediate" && a();
1138
- }, [a]), {
1139
- feature: e,
1140
- loading: r,
1141
- error: s,
1142
- load: a
1143
- };
1144
- }
1145
- function ge(o, e, t) {
1146
- return function(n) {
1147
- const { feature: s, loading: i, error: a } = K(e);
1148
- if (i)
1149
- return /* @__PURE__ */ f.jsx("div", { className: "h-8 animate-pulse rounded bg-gray-200" });
1150
- if (a || !s) {
1151
- const c = t;
1152
- return c ? /* @__PURE__ */ f.jsx(c, { ...n }) : null;
1153
- }
1154
- return /* @__PURE__ */ f.jsx(o, { ...n });
1155
- };
1156
- }
1157
- const he = "1.0.0";
1158
- export {
1159
- ye as AnalyticsPlugin,
1160
- we as BasePlugin,
1161
- he as CORE_ARCHITECTURE_VERSION,
1162
- B as ConsolePluginLogger,
1163
- Ie as EVENT_SYSTEM_VERSION,
1164
- I as EventBus,
1165
- Ne as EventDelegator,
1166
- l as FEATURES,
1167
- E as FeatureDetector,
1168
- M as MediaLoadingOptimizer,
1169
- $e as MiddlewareBuilder,
1170
- _ as NetworkMonitor,
1171
- Te as PLUGIN_SYSTEM_VERSION,
1172
- P as PerformanceBenchmark,
1173
- O as PerformanceBudgetMonitor,
1174
- Ge as PerformanceDashboard,
1175
- Xe as PerformanceMonitor,
1176
- x as PerformanceRegressionDetector,
1177
- U as PerformanceTestFramework,
1178
- Se as PluginConflictError,
1179
- ve as PluginDependencyError,
1180
- be as PluginDevelopmentHelpers,
1181
- Pe as PluginError,
1182
- Me as PluginPerformanceMonitor,
1183
- R as PluginRegistry,
1184
- Le as PluginStorage,
1185
- Ee as PluginValidator,
1186
- W as ProgressiveLoader,
1187
- Y as ServiceProvider,
1188
- Fe as commonMiddlewares,
1189
- Ce as createAnalyticsPlugin,
1190
- de as createArchitecture,
1191
- xe as createMiddleware,
1192
- ke as createPlugin,
1193
- Ue as defaultEventBus,
1194
- z as defaultMediaLoadingConfig,
1195
- D as defaultPerformanceBudgets,
1196
- Ae as defaultPerformanceMonitor,
1197
- Be as defaultPluginLogger,
1198
- Q as defaultProgressiveConfig,
1199
- Ze as defaultThresholds,
1200
- De as eventMiddlewares,
1201
- me as lazyComponents,
1202
- V as mediaLoadingOptimizer,
1203
- v as performanceBenchmark,
1204
- ne as performanceBudgetMonitor,
1205
- et as performanceMonitor,
1206
- re as performanceTestFramework,
1207
- te as performanceTestUtils,
1208
- b as progressiveLoader,
1209
- ce as useAnalytics,
1210
- Oe as useConditionalEventListener,
1211
- ze as useEventBus,
1212
- _e as useEventDebugger,
1213
- Ve as useEventEffect,
1214
- He as useEventEmitter,
1215
- je as useEventHandlers,
1216
- Ye as useEventHistory,
1217
- Qe as useEventListener,
1218
- We as useEventMetrics,
1219
- Ke as useEventOnce,
1220
- Je as useEventState,
1221
- le as useLogger,
1222
- oe as useMediaLoadingOptimizer,
1223
- tt as usePerformanceMonitor,
1224
- ie as usePluginRegistry,
1225
- K as useProgressiveFeature,
1226
- se as useServiceEventBus,
1227
- p as useServices,
1228
- ae as useStorage,
1229
- rt as withPerformanceMonitoring,
1230
- ge as withProgressiveFeature,
1231
- ue as withServices
1232
- };
1233
- //# sourceMappingURL=core.mjs.map