@vlian/framework 1.2.61 → 1.2.62

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 (260) hide show
  1. package/dist/analytics.umd.js +1 -1
  2. package/dist/components/index.cjs +1 -1
  3. package/dist/components/index.d.ts +0 -4
  4. package/dist/components/index.js +1 -1
  5. package/dist/core-bak/Test.cjs +1 -0
  6. package/dist/core-bak/Test.d.ts +5 -0
  7. package/dist/core-bak/Test.js +1 -0
  8. package/dist/core-bak/app/AppContext.cjs +1 -0
  9. package/dist/core-bak/app/AppContext.d.ts +113 -0
  10. package/dist/core-bak/app/AppContext.js +1 -0
  11. package/dist/core-bak/app/AppContext.types.cjs +1 -0
  12. package/dist/core-bak/app/AppContext.types.d.ts +146 -0
  13. package/dist/core-bak/app/AppContext.types.js +1 -0
  14. package/dist/core-bak/app/BasicLayout.cjs +1 -0
  15. package/dist/core-bak/app/BasicLayout.d.ts +15 -0
  16. package/dist/core-bak/app/BasicLayout.js +1 -0
  17. package/dist/core-bak/app/DefaultApp.cjs +1 -0
  18. package/dist/core-bak/app/DefaultApp.d.ts +10 -0
  19. package/dist/core-bak/app/DefaultApp.js +1 -0
  20. package/dist/core-bak/app/index.cjs +1 -0
  21. package/dist/core-bak/app/index.d.ts +8 -0
  22. package/dist/core-bak/app/index.js +1 -0
  23. package/dist/core-bak/config/AppConfig.cjs +1 -0
  24. package/dist/core-bak/config/AppConfig.d.ts +88 -0
  25. package/dist/core-bak/config/AppConfig.js +1 -0
  26. package/dist/core-bak/config/ConfigLoader.cjs +1 -0
  27. package/dist/core-bak/config/ConfigLoader.d.ts +118 -0
  28. package/dist/core-bak/config/ConfigLoader.js +1 -0
  29. package/dist/core-bak/config/ConfigValidator.cjs +2 -0
  30. package/dist/core-bak/config/ConfigValidator.d.ts +84 -0
  31. package/dist/core-bak/config/ConfigValidator.js +2 -0
  32. package/dist/core-bak/config/index.cjs +1 -0
  33. package/dist/core-bak/config/index.d.ts +6 -0
  34. package/dist/core-bak/config/index.js +1 -0
  35. package/dist/core-bak/dev/DevTools.cjs +1 -0
  36. package/dist/core-bak/dev/DevTools.d.ts +16 -0
  37. package/dist/core-bak/dev/DevTools.js +1 -0
  38. package/dist/core-bak/error/ErrorBoundary.cjs +1 -0
  39. package/dist/core-bak/error/ErrorBoundary.d.ts +121 -0
  40. package/dist/core-bak/error/ErrorBoundary.js +1 -0
  41. package/dist/core-bak/error/ErrorHandler.cjs +1 -0
  42. package/dist/core-bak/error/ErrorHandler.d.ts +171 -0
  43. package/dist/core-bak/error/ErrorHandler.js +1 -0
  44. package/dist/core-bak/error/index.cjs +1 -0
  45. package/dist/core-bak/error/index.d.ts +7 -0
  46. package/dist/core-bak/error/index.js +1 -0
  47. package/dist/core-bak/event/AppEventBus.cjs +1 -0
  48. package/dist/core-bak/event/AppEventBus.d.ts +178 -0
  49. package/dist/core-bak/event/AppEventBus.js +1 -0
  50. package/dist/core-bak/event/frameworkEvents.cjs +1 -0
  51. package/dist/core-bak/event/frameworkEvents.d.ts +69 -0
  52. package/dist/core-bak/event/frameworkEvents.js +1 -0
  53. package/dist/core-bak/event/hooks.cjs +1 -0
  54. package/dist/core-bak/event/hooks.d.ts +57 -0
  55. package/dist/core-bak/event/hooks.js +1 -0
  56. package/dist/core-bak/event/index.cjs +1 -0
  57. package/dist/core-bak/event/index.d.ts +10 -0
  58. package/dist/core-bak/event/index.js +1 -0
  59. package/dist/core-bak/event/types.cjs +1 -0
  60. package/dist/core-bak/event/types.d.ts +269 -0
  61. package/dist/core-bak/event/types.js +1 -0
  62. package/dist/core-bak/event/useEventBus.cjs +1 -0
  63. package/dist/core-bak/event/useEventBus.d.ts +28 -0
  64. package/dist/core-bak/event/useEventBus.js +1 -0
  65. package/dist/core-bak/index.cjs +1 -0
  66. package/dist/core-bak/index.d.ts +54 -0
  67. package/dist/core-bak/index.js +1 -0
  68. package/dist/core-bak/initialization/InitializationErrorThrower.cjs +1 -0
  69. package/dist/core-bak/initialization/InitializationErrorThrower.d.ts +7 -0
  70. package/dist/core-bak/initialization/InitializationErrorThrower.js +1 -0
  71. package/dist/core-bak/initialization/index.cjs +1 -0
  72. package/dist/core-bak/initialization/index.d.ts +7 -0
  73. package/dist/core-bak/initialization/index.js +1 -0
  74. package/dist/core-bak/initialization/initialization.cjs +1 -0
  75. package/dist/core-bak/initialization/initialization.d.ts +69 -0
  76. package/dist/core-bak/initialization/initialization.js +1 -0
  77. package/dist/core-bak/initialization/initializationErrorState.cjs +1 -0
  78. package/dist/core-bak/initialization/initializationErrorState.d.ts +35 -0
  79. package/dist/core-bak/initialization/initializationErrorState.js +1 -0
  80. package/dist/core-bak/kernel/defaultAdapters.cjs +1 -0
  81. package/dist/core-bak/kernel/defaultAdapters.d.ts +2 -0
  82. package/dist/core-bak/kernel/defaultAdapters.js +1 -0
  83. package/dist/core-bak/kernel/errors.cjs +1 -0
  84. package/dist/core-bak/kernel/errors.d.ts +18 -0
  85. package/dist/core-bak/kernel/errors.js +1 -0
  86. package/dist/core-bak/kernel/index.cjs +1 -0
  87. package/dist/core-bak/kernel/index.d.ts +3 -0
  88. package/dist/core-bak/kernel/index.js +1 -0
  89. package/dist/core-bak/kernel/startKernel.cjs +1 -0
  90. package/dist/core-bak/kernel/startKernel.d.ts +2 -0
  91. package/dist/core-bak/kernel/startKernel.js +1 -0
  92. package/dist/core-bak/kernel/types.cjs +1 -0
  93. package/dist/core-bak/kernel/types.d.ts +114 -0
  94. package/dist/core-bak/kernel/types.js +1 -0
  95. package/dist/core-bak/middleware.cjs +1 -0
  96. package/dist/core-bak/middleware.d.ts +36 -0
  97. package/dist/core-bak/middleware.js +1 -0
  98. package/dist/core-bak/plugin/PluginEventBus.cjs +1 -0
  99. package/dist/core-bak/plugin/PluginEventBus.d.ts +169 -0
  100. package/dist/core-bak/plugin/PluginEventBus.js +1 -0
  101. package/dist/core-bak/plugin/PluginSandbox.cjs +1 -0
  102. package/dist/core-bak/plugin/PluginSandbox.d.ts +101 -0
  103. package/dist/core-bak/plugin/PluginSandbox.js +1 -0
  104. package/dist/core-bak/plugin.cjs +1 -0
  105. package/dist/core-bak/plugin.d.ts +224 -0
  106. package/dist/core-bak/plugin.js +1 -0
  107. package/dist/core-bak/router/RouterManager.cjs +1 -0
  108. package/dist/core-bak/router/RouterManager.d.ts +87 -0
  109. package/dist/core-bak/router/RouterManager.js +1 -0
  110. package/dist/core-bak/router/adapter/AdapterManager.cjs +1 -0
  111. package/dist/core-bak/router/adapter/AdapterManager.d.ts +94 -0
  112. package/dist/core-bak/router/adapter/AdapterManager.js +1 -0
  113. package/dist/core-bak/router/adapter/index.cjs +1 -0
  114. package/dist/core-bak/router/adapter/index.d.ts +6 -0
  115. package/dist/core-bak/router/adapter/index.js +1 -0
  116. package/dist/core-bak/router/adapter/react-router/ReactRouterAdapter.cjs +1 -0
  117. package/dist/core-bak/router/adapter/react-router/ReactRouterAdapter.d.ts +43 -0
  118. package/dist/core-bak/router/adapter/react-router/ReactRouterAdapter.js +1 -0
  119. package/dist/core-bak/router/adapter/react-router/index.cjs +1 -0
  120. package/dist/core-bak/router/adapter/react-router/index.d.ts +4 -0
  121. package/dist/core-bak/router/adapter/react-router/index.js +1 -0
  122. package/dist/core-bak/router/adapter/types.cjs +1 -0
  123. package/dist/core-bak/router/adapter/types.d.ts +111 -0
  124. package/dist/core-bak/router/adapter/types.js +1 -0
  125. package/dist/core-bak/router/dev/RouterDevTools.cjs +1 -0
  126. package/dist/core-bak/router/dev/RouterDevTools.d.ts +5 -0
  127. package/dist/core-bak/router/dev/RouterDevTools.js +1 -0
  128. package/dist/core-bak/router/dev/index.cjs +1 -0
  129. package/dist/core-bak/router/dev/index.d.ts +4 -0
  130. package/dist/core-bak/router/dev/index.js +1 -0
  131. package/dist/core-bak/router/dynamic/DynamicRouteManager.cjs +1 -0
  132. package/dist/core-bak/router/dynamic/DynamicRouteManager.d.ts +71 -0
  133. package/dist/core-bak/router/dynamic/DynamicRouteManager.js +1 -0
  134. package/dist/core-bak/router/dynamic/index.cjs +1 -0
  135. package/dist/core-bak/router/dynamic/index.d.ts +4 -0
  136. package/dist/core-bak/router/dynamic/index.js +1 -0
  137. package/dist/core-bak/router/errors/RouterError.cjs +1 -0
  138. package/dist/core-bak/router/errors/RouterError.d.ts +48 -0
  139. package/dist/core-bak/router/errors/RouterError.js +1 -0
  140. package/dist/core-bak/router/errors/index.cjs +1 -0
  141. package/dist/core-bak/router/errors/index.d.ts +4 -0
  142. package/dist/core-bak/router/errors/index.js +1 -0
  143. package/dist/core-bak/router/index.cjs +1 -0
  144. package/dist/core-bak/router/index.d.ts +16 -0
  145. package/dist/core-bak/router/index.js +1 -0
  146. package/dist/core-bak/router/lifecycle/RouterLifecycleManager.cjs +1 -0
  147. package/dist/core-bak/router/lifecycle/RouterLifecycleManager.d.ts +56 -0
  148. package/dist/core-bak/router/lifecycle/RouterLifecycleManager.js +1 -0
  149. package/dist/core-bak/router/lifecycle/index.cjs +1 -0
  150. package/dist/core-bak/router/lifecycle/index.d.ts +4 -0
  151. package/dist/core-bak/router/lifecycle/index.js +1 -0
  152. package/dist/core-bak/router/middleware/RouterMiddlewareManager.cjs +1 -0
  153. package/dist/core-bak/router/middleware/RouterMiddlewareManager.d.ts +61 -0
  154. package/dist/core-bak/router/middleware/RouterMiddlewareManager.js +1 -0
  155. package/dist/core-bak/router/middleware/auth.cjs +1 -0
  156. package/dist/core-bak/router/middleware/auth.d.ts +54 -0
  157. package/dist/core-bak/router/middleware/auth.js +1 -0
  158. package/dist/core-bak/router/middleware/index.cjs +1 -0
  159. package/dist/core-bak/router/middleware/index.d.ts +6 -0
  160. package/dist/core-bak/router/middleware/index.js +1 -0
  161. package/dist/core-bak/router/middleware/types.cjs +1 -0
  162. package/dist/core-bak/router/middleware/types.d.ts +82 -0
  163. package/dist/core-bak/router/middleware/types.js +1 -0
  164. package/dist/core-bak/router/monitoring/RouterMonitoring.cjs +1 -0
  165. package/dist/core-bak/router/monitoring/RouterMonitoring.d.ts +134 -0
  166. package/dist/core-bak/router/monitoring/RouterMonitoring.js +1 -0
  167. package/dist/core-bak/router/monitoring/index.cjs +1 -0
  168. package/dist/core-bak/router/monitoring/index.d.ts +4 -0
  169. package/dist/core-bak/router/monitoring/index.js +1 -0
  170. package/dist/core-bak/router/navigation/RouterNavigation.cjs +1 -0
  171. package/dist/core-bak/router/navigation/RouterNavigation.d.ts +43 -0
  172. package/dist/core-bak/router/navigation/RouterNavigation.js +1 -0
  173. package/dist/core-bak/router/navigation/index.cjs +1 -0
  174. package/dist/core-bak/router/navigation/index.d.ts +4 -0
  175. package/dist/core-bak/router/navigation/index.js +1 -0
  176. package/dist/core-bak/router/performance/RouteCache.cjs +1 -0
  177. package/dist/core-bak/router/performance/RouteCache.d.ts +113 -0
  178. package/dist/core-bak/router/performance/RouteCache.js +1 -0
  179. package/dist/core-bak/router/performance/RoutePreloader.cjs +1 -0
  180. package/dist/core-bak/router/performance/RoutePreloader.d.ts +111 -0
  181. package/dist/core-bak/router/performance/RoutePreloader.js +1 -0
  182. package/dist/core-bak/router/performance/index.cjs +1 -0
  183. package/dist/core-bak/router/performance/index.d.ts +5 -0
  184. package/dist/core-bak/router/performance/index.js +1 -0
  185. package/dist/core-bak/router/plugin/RouterPluginManager.cjs +1 -0
  186. package/dist/core-bak/router/plugin/RouterPluginManager.d.ts +74 -0
  187. package/dist/core-bak/router/plugin/RouterPluginManager.js +1 -0
  188. package/dist/core-bak/router/plugin/index.cjs +1 -0
  189. package/dist/core-bak/router/plugin/index.d.ts +5 -0
  190. package/dist/core-bak/router/plugin/index.js +1 -0
  191. package/dist/core-bak/router/plugin/types.cjs +1 -0
  192. package/dist/core-bak/router/plugin/types.d.ts +153 -0
  193. package/dist/core-bak/router/plugin/types.js +1 -0
  194. package/dist/core-bak/router/types.cjs +1 -0
  195. package/dist/core-bak/router/types.d.ts +464 -0
  196. package/dist/core-bak/router/types.js +1 -0
  197. package/dist/core-bak/router/utils/adapters/react-router/RouteErrorBoundary.cjs +1 -0
  198. package/dist/core-bak/router/utils/adapters/react-router/RouteErrorBoundary.d.ts +2 -0
  199. package/dist/core-bak/router/utils/adapters/react-router/RouteErrorBoundary.js +1 -0
  200. package/dist/core-bak/router/utils/adapters/react-router/transform.cjs +1 -0
  201. package/dist/core-bak/router/utils/adapters/react-router/transform.d.ts +5 -0
  202. package/dist/core-bak/router/utils/adapters/react-router/transform.js +1 -0
  203. package/dist/core-bak/router/utils/transform.cjs +1 -0
  204. package/dist/core-bak/router/utils/transform.d.ts +348 -0
  205. package/dist/core-bak/router/utils/transform.js +1 -0
  206. package/dist/core-bak/router/validation/RouterConfigValidator.cjs +2 -0
  207. package/dist/core-bak/router/validation/RouterConfigValidator.d.ts +121 -0
  208. package/dist/core-bak/router/validation/RouterConfigValidator.js +2 -0
  209. package/dist/core-bak/router/validation/index.cjs +1 -0
  210. package/dist/core-bak/router/validation/index.d.ts +5 -0
  211. package/dist/core-bak/router/validation/index.js +1 -0
  212. package/dist/core-bak/router/validation/schema.cjs +1 -0
  213. package/dist/core-bak/router/validation/schema.d.ts +180 -0
  214. package/dist/core-bak/router/validation/schema.js +1 -0
  215. package/dist/core-bak/router/version/RouteVersionManager.cjs +1 -0
  216. package/dist/core-bak/router/version/RouteVersionManager.d.ts +124 -0
  217. package/dist/core-bak/router/version/RouteVersionManager.js +1 -0
  218. package/dist/core-bak/router/version/index.cjs +1 -0
  219. package/dist/core-bak/router/version/index.d.ts +4 -0
  220. package/dist/core-bak/router/version/index.js +1 -0
  221. package/dist/core-bak/splash/SplashScreen.cjs +1 -0
  222. package/dist/core-bak/splash/SplashScreen.d.ts +14 -0
  223. package/dist/core-bak/splash/SplashScreen.js +1 -0
  224. package/dist/core-bak/splash/index.cjs +1 -0
  225. package/dist/core-bak/splash/index.d.ts +5 -0
  226. package/dist/core-bak/splash/index.js +1 -0
  227. package/dist/core-bak/splash/splashScreenUtils.cjs +1 -0
  228. package/dist/core-bak/splash/splashScreenUtils.d.ts +7 -0
  229. package/dist/core-bak/splash/splashScreenUtils.js +1 -0
  230. package/dist/core-bak/startup/AppInstance.cjs +1 -0
  231. package/dist/core-bak/startup/AppInstance.d.ts +138 -0
  232. package/dist/core-bak/startup/AppInstance.js +1 -0
  233. package/dist/core-bak/startup/environment.cjs +1 -0
  234. package/dist/core-bak/startup/environment.d.ts +87 -0
  235. package/dist/core-bak/startup/environment.js +1 -0
  236. package/dist/core-bak/startup/index.cjs +1 -0
  237. package/dist/core-bak/startup/index.d.ts +7 -0
  238. package/dist/core-bak/startup/index.js +1 -0
  239. package/dist/core-bak/startup/initializeServices.cjs +1 -0
  240. package/dist/core-bak/startup/initializeServices.d.ts +68 -0
  241. package/dist/core-bak/startup/initializeServices.js +1 -0
  242. package/dist/core-bak/startup/performanceTracker.cjs +1 -0
  243. package/dist/core-bak/startup/performanceTracker.d.ts +104 -0
  244. package/dist/core-bak/startup/performanceTracker.js +1 -0
  245. package/dist/core-bak/startup/renderApp.cjs +1 -0
  246. package/dist/core-bak/startup/renderApp.d.ts +70 -0
  247. package/dist/core-bak/startup/renderApp.js +1 -0
  248. package/dist/core-bak/startup/startApp.cjs +1 -0
  249. package/dist/core-bak/startup/startApp.d.ts +14 -0
  250. package/dist/core-bak/startup/startApp.js +1 -0
  251. package/dist/core-bak/types.cjs +1 -0
  252. package/dist/core-bak/types.d.ts +501 -0
  253. package/dist/core-bak/types.js +1 -0
  254. package/dist/index.cjs +1 -1
  255. package/dist/index.d.ts +0 -1
  256. package/dist/index.js +1 -1
  257. package/dist/index.umd.js +31 -246
  258. package/dist/kernel/types.d.ts +46 -3
  259. package/dist/state.umd.js +1 -1
  260. package/package.json +1 -11
@@ -0,0 +1,180 @@
1
+ /**
2
+ * 路由配置验证 Schema(使用 Zod)
3
+ */
4
+ import { z } from 'zod';
5
+ /**
6
+ * RouteItemHandle Schema
7
+ */
8
+ export declare const routeItemHandleSchema: z.ZodObject<{
9
+ title: z.ZodString;
10
+ i18nKey: z.ZodOptional<z.ZodString>;
11
+ order: z.ZodNumber;
12
+ icon: z.ZodOptional<z.ZodString>;
13
+ hideInMenu: z.ZodOptional<z.ZodBoolean>;
14
+ hideFooter: z.ZodOptional<z.ZodBoolean>;
15
+ keepAlive: z.ZodOptional<z.ZodBoolean>;
16
+ needLogin: z.ZodOptional<z.ZodBoolean>;
17
+ roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
18
+ name: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$loose>;
20
+ /**
21
+ * ComponentImport Schema
22
+ * 可以是字符串路径或函数
23
+ */
24
+ export declare const componentImportSchema: z.ZodUnion<readonly [z.ZodString, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>, z.ZodNull]>;
25
+ /**
26
+ * RouteConfig Schema
27
+ */
28
+ export declare const routeConfigSchema: z.ZodType<any>;
29
+ /**
30
+ * RouterConfig Schema
31
+ */
32
+ export declare const routerConfigSchema: z.ZodObject<{
33
+ enabled: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"disabled">]>>;
34
+ routes: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>>, z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>]>>;
35
+ mode: z.ZodOptional<z.ZodEnum<{
36
+ hash: "hash";
37
+ browser: "browser";
38
+ memory: "memory";
39
+ }>>;
40
+ options: z.ZodOptional<z.ZodObject<{
41
+ basename: z.ZodOptional<z.ZodString>;
42
+ future: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodNumber]>>>;
43
+ hydrationData: z.ZodOptional<z.ZodUnknown>;
44
+ window: z.ZodOptional<z.ZodUnknown>;
45
+ initialEntries: z.ZodOptional<z.ZodArray<z.ZodString>>;
46
+ initialIndex: z.ZodOptional<z.ZodNumber>;
47
+ }, z.core.$loose>>;
48
+ pathResolve: z.ZodOptional<z.ZodObject<{
49
+ basePath: z.ZodOptional<z.ZodString>;
50
+ pathAliases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
51
+ }, z.core.$strip>>;
52
+ transformOptions: z.ZodOptional<z.ZodObject<{
53
+ pathValidation: z.ZodOptional<z.ZodObject<{
54
+ enablePathValidation: z.ZodOptional<z.ZodBoolean>;
55
+ allowedPathPrefixes: z.ZodOptional<z.ZodArray<z.ZodString>>;
56
+ maxPathLength: z.ZodOptional<z.ZodNumber>;
57
+ allowAbsolutePaths: z.ZodOptional<z.ZodBoolean>;
58
+ }, z.core.$strip>>;
59
+ performance: z.ZodOptional<z.ZodObject<{
60
+ enableCache: z.ZodOptional<z.ZodBoolean>;
61
+ cacheTTL: z.ZodOptional<z.ZodNumber>;
62
+ maxCacheSize: z.ZodOptional<z.ZodNumber>;
63
+ maxRecursionDepth: z.ZodOptional<z.ZodNumber>;
64
+ enableParallelProcessing: z.ZodOptional<z.ZodBoolean>;
65
+ parallelBatchSize: z.ZodOptional<z.ZodNumber>;
66
+ }, z.core.$strip>>;
67
+ enableDebugLog: z.ZodOptional<z.ZodBoolean>;
68
+ }, z.core.$loose>>;
69
+ preload: z.ZodOptional<z.ZodObject<{
70
+ strategy: z.ZodOptional<z.ZodEnum<{
71
+ all: "all";
72
+ none: "none";
73
+ visible: "visible";
74
+ "next-level": "next-level";
75
+ }>>;
76
+ delay: z.ZodOptional<z.ZodNumber>;
77
+ priorityThreshold: z.ZodOptional<z.ZodNumber>;
78
+ timeout: z.ZodOptional<z.ZodNumber>;
79
+ }, z.core.$strip>>;
80
+ enableHydrateFallback: z.ZodOptional<z.ZodBoolean>;
81
+ }, z.core.$strip>;
82
+ /**
83
+ * 验证路由配置
84
+ *
85
+ * @param config - 要验证的路由配置
86
+ * @returns 验证后的路由配置
87
+ * @throws z.ZodError 如果配置验证失败
88
+ */
89
+ export declare function validateRouterConfig(config: unknown): {
90
+ enabled?: boolean | "disabled" | undefined;
91
+ routes?: any[] | z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut> | undefined;
92
+ mode?: "hash" | "browser" | "memory" | undefined;
93
+ options?: {
94
+ [x: string]: unknown;
95
+ basename?: string | undefined;
96
+ future?: Record<string, string | number | boolean> | undefined;
97
+ hydrationData?: unknown;
98
+ window?: unknown;
99
+ initialEntries?: string[] | undefined;
100
+ initialIndex?: number | undefined;
101
+ } | undefined;
102
+ pathResolve?: {
103
+ basePath?: string | undefined;
104
+ pathAliases?: Record<string, string> | undefined;
105
+ } | undefined;
106
+ transformOptions?: {
107
+ [x: string]: unknown;
108
+ pathValidation?: {
109
+ enablePathValidation?: boolean | undefined;
110
+ allowedPathPrefixes?: string[] | undefined;
111
+ maxPathLength?: number | undefined;
112
+ allowAbsolutePaths?: boolean | undefined;
113
+ } | undefined;
114
+ performance?: {
115
+ enableCache?: boolean | undefined;
116
+ cacheTTL?: number | undefined;
117
+ maxCacheSize?: number | undefined;
118
+ maxRecursionDepth?: number | undefined;
119
+ enableParallelProcessing?: boolean | undefined;
120
+ parallelBatchSize?: number | undefined;
121
+ } | undefined;
122
+ enableDebugLog?: boolean | undefined;
123
+ } | undefined;
124
+ preload?: {
125
+ strategy?: "all" | "none" | "visible" | "next-level" | undefined;
126
+ delay?: number | undefined;
127
+ priorityThreshold?: number | undefined;
128
+ timeout?: number | undefined;
129
+ } | undefined;
130
+ enableHydrateFallback?: boolean | undefined;
131
+ };
132
+ /**
133
+ * 安全验证路由配置(不抛出异常)
134
+ *
135
+ * @param config - 要验证的路由配置
136
+ * @returns 验证结果
137
+ */
138
+ export declare function safeValidateRouterConfig(config: unknown): z.ZodSafeParseResult<{
139
+ enabled?: boolean | "disabled" | undefined;
140
+ routes?: any[] | z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut> | undefined;
141
+ mode?: "hash" | "browser" | "memory" | undefined;
142
+ options?: {
143
+ [x: string]: unknown;
144
+ basename?: string | undefined;
145
+ future?: Record<string, string | number | boolean> | undefined;
146
+ hydrationData?: unknown;
147
+ window?: unknown;
148
+ initialEntries?: string[] | undefined;
149
+ initialIndex?: number | undefined;
150
+ } | undefined;
151
+ pathResolve?: {
152
+ basePath?: string | undefined;
153
+ pathAliases?: Record<string, string> | undefined;
154
+ } | undefined;
155
+ transformOptions?: {
156
+ [x: string]: unknown;
157
+ pathValidation?: {
158
+ enablePathValidation?: boolean | undefined;
159
+ allowedPathPrefixes?: string[] | undefined;
160
+ maxPathLength?: number | undefined;
161
+ allowAbsolutePaths?: boolean | undefined;
162
+ } | undefined;
163
+ performance?: {
164
+ enableCache?: boolean | undefined;
165
+ cacheTTL?: number | undefined;
166
+ maxCacheSize?: number | undefined;
167
+ maxRecursionDepth?: number | undefined;
168
+ enableParallelProcessing?: boolean | undefined;
169
+ parallelBatchSize?: number | undefined;
170
+ } | undefined;
171
+ enableDebugLog?: boolean | undefined;
172
+ } | undefined;
173
+ preload?: {
174
+ strategy?: "all" | "none" | "visible" | "next-level" | undefined;
175
+ delay?: number | undefined;
176
+ priorityThreshold?: number | undefined;
177
+ timeout?: number | undefined;
178
+ } | undefined;
179
+ enableHydrateFallback?: boolean | undefined;
180
+ }>;
@@ -0,0 +1 @@
1
+ import{z}from"zod";export const routeItemHandleSchema=z.object({title:z.string().min(1,"路由标题不能为空"),i18nKey:z.string().optional(),order:z.number().int("排序值必须是整数"),icon:z.string().optional(),hideInMenu:z.boolean().optional(),hideFooter:z.boolean().optional(),keepAlive:z.boolean().optional(),needLogin:z.boolean().optional(),roles:z.array(z.string()).optional(),name:z.string().optional()}).passthrough();export const componentImportSchema=z.union([z.string().min(1,"组件路径不能为空"),z.function(),z.null()]);const routerOptionsSchema=z.object({basename:z.string().optional(),future:z.record(z.string(),z.union([z.boolean(),z.string(),z.number()])).optional(),hydrationData:z.unknown().optional(),window:z.unknown().optional(),initialEntries:z.array(z.string()).optional(),initialIndex:z.number().int().nonnegative().optional()}).passthrough();const transformOptionsSchema=z.object({pathValidation:z.object({enablePathValidation:z.boolean().optional(),allowedPathPrefixes:z.array(z.string().min(1)).optional(),maxPathLength:z.number().int().positive().optional(),allowAbsolutePaths:z.boolean().optional()}).optional(),performance:z.object({enableCache:z.boolean().optional(),cacheTTL:z.number().int().positive().optional(),maxCacheSize:z.number().int().positive().optional(),maxRecursionDepth:z.number().int().positive().optional(),enableParallelProcessing:z.boolean().optional(),parallelBatchSize:z.number().int().positive().optional()}).optional(),enableDebugLog:z.boolean().optional()}).passthrough();export const routeConfigSchema=z.lazy(()=>z.object({layout:componentImportSchema.optional().nullable(),page:componentImportSchema.optional().nullable(),loading:componentImportSchema.optional().nullable(),error:componentImportSchema.optional().nullable(),errors:componentImportSchema.optional().nullable(),name:z.string().min(1,"路由名称不能为空"),path:z.string().optional(),isGroup:z.boolean().optional(),enableRedirection:z.boolean().optional(),handle:routeItemHandleSchema,children:z.array(routeConfigSchema).optional()}));export const routerConfigSchema=z.object({enabled:z.union([z.boolean(),z.literal("disabled")]).optional(),routes:z.union([z.array(routeConfigSchema),z.function()]).optional(),mode:z.enum(["browser","hash","memory"]).optional(),options:routerOptionsSchema.optional(),pathResolve:z.object({basePath:z.string().optional(),pathAliases:z.record(z.string(),z.string()).optional()}).optional(),transformOptions:transformOptionsSchema.optional(),preload:z.object({strategy:z.enum(["none","next-level","all","visible"]).optional(),delay:z.number().int().positive().optional(),priorityThreshold:z.number().int().nonnegative().optional(),timeout:z.number().int().positive().optional()}).optional(),enableHydrateFallback:z.boolean().optional()}).superRefine((config,ctx)=>{if(!Array.isArray(config.routes)){return}const routeNameMap=new Map;const walk=(routes,parentPath)=>{routes.forEach((route,index)=>{const currentPath=`${parentPath}[${index}]`;const existingPath=routeNameMap.get(route.name);if(existingPath){ctx.addIssue({code:z.ZodIssueCode.custom,path:["routes",index,"name"],message:`路由名称重复: "${route.name}",首次定义位置 ${existingPath}`})}else{routeNameMap.set(route.name,currentPath)}if(Array.isArray(route.children)&&route.children.length>0){walk(route.children,`${currentPath}.children`)}})};walk(config.routes,"routes")});export function validateRouterConfig(config){return routerConfigSchema.parse(config)}export function safeValidateRouterConfig(config){return routerConfigSchema.safeParse(config)}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get RouteVersionManager(){return RouteVersionManager},get getRouteVersionManager(){return getRouteVersionManager}});const _logger=require("@vlian/logger");const _errors=require("../errors");function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}let RouteVersionManager=class RouteVersionManager{registerVersion(version){if(!/^\d+\.\d+\.\d+/.test(version.version)){throw new Error(`无效的版本号格式: ${version.version}`)}this.versions.set(version.version,{...version,createdAt:version.createdAt||Date.now()});_logger.logger.debug(`路由版本已注册: ${version.version}`)}registerMigration(fromVersion,toVersion,migration){const key=`${fromVersion}->${toVersion}`;this.migrations.set(key,migration);_logger.logger.debug(`路由版本迁移已注册: ${key}`)}checkCompatibility(version){const versionInfo=this.versions.get(version);if(!versionInfo){return false}if(versionInfo.compatible===false){return false}const currentMajor=parseInt(this.config.currentVersion.split(".")[0]);const targetMajor=parseInt(version.split(".")[0]);return currentMajor===targetMajor}async migrate(fromVersion,toVersion,routes){if(fromVersion===toVersion){return routes}const migrationKey=`${fromVersion}->${toVersion}`;const migration=this.migrations.get(migrationKey);if(!migration){return this.migrateStepwise(fromVersion,toVersion,routes)}try{const migratedRoutes=await migration(fromVersion,toVersion,routes);_logger.logger.info(`路由版本迁移完成: ${fromVersion} -> ${toVersion}`);return migratedRoutes}catch(error){_logger.logger.error(`路由版本迁移失败: ${fromVersion} -> ${toVersion}`,error);const errorContext={fromVersion,toVersion};if(error instanceof Error){errorContext.originalError=error}throw new _errors.RouterError(`路由版本迁移失败: ${fromVersion} -> ${toVersion}`,_errors.RouterErrorCode.ROUTE_TRANSFORM_FAILED,undefined,error instanceof Error?error:undefined,errorContext)}}async migrateStepwise(fromVersion,toVersion,routes){const allVersions=Array.from(this.versions.keys()).sort((a,b)=>{const aParts=a.split(".").map(Number);const bParts=b.split(".").map(Number);for(let i=0;i<3;i++){if(aParts[i]!==bParts[i]){return aParts[i]-bParts[i]}}return 0});const fromIndex=allVersions.indexOf(fromVersion);const toIndex=allVersions.indexOf(toVersion);if(fromIndex===-1||toIndex===-1){throw new Error(`无法找到版本迁移路径: ${fromVersion} -> ${toVersion}`)}let currentRoutes=routes;const step=fromIndex<toIndex?1:-1;for(let i=fromIndex;i!==toIndex;i+=step){const currentVersion=allVersions[i];const nextVersion=allVersions[i+step];const migrationKey=`${currentVersion}->${nextVersion}`;const migration=this.migrations.get(migrationKey);if(migration){currentRoutes=await migration(currentVersion,nextVersion,currentRoutes)}else{_logger.logger.warn(`缺少迁移函数: ${migrationKey},跳过迁移`)}}return currentRoutes}getVersion(version){return this.versions.get(version)}getAllVersions(){return Array.from(this.versions.values())}getCurrentVersion(){return this.versions.get(this.config.currentVersion)}async rollback(version,routes){return this.migrate(this.config.currentVersion,version,routes)}constructor(config){_define_property(this,"versions",new Map);_define_property(this,"migrations",new Map);_define_property(this,"config",void 0);this.config={enableVersionCheck:config.enableVersionCheck??true,enableAutoMigration:config.enableAutoMigration??false,currentVersion:config.currentVersion}}};let versionManagerInstance=null;function getRouteVersionManager(config){if(!versionManagerInstance&&config){versionManagerInstance=new RouteVersionManager(config)}if(!versionManagerInstance){throw new Error("路由版本管理器未初始化,请先提供配置")}return versionManagerInstance}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * 路由版本管理器
3
+ * 支持路由版本控制和迁移
4
+ */
5
+ import type { RouteConfig } from '../types';
6
+ /**
7
+ * 路由版本信息
8
+ */
9
+ export interface RouteVersion {
10
+ /**
11
+ * 版本号(语义化版本,如 "1.0.0")
12
+ */
13
+ version: string;
14
+ /**
15
+ * 路由配置
16
+ */
17
+ routes: RouteConfig[];
18
+ /**
19
+ * 创建时间
20
+ */
21
+ createdAt: number;
22
+ /**
23
+ * 描述
24
+ */
25
+ description?: string;
26
+ /**
27
+ * 是否兼容旧版本
28
+ */
29
+ compatible?: boolean;
30
+ }
31
+ /**
32
+ * 版本迁移函数
33
+ */
34
+ export type VersionMigration = (fromVersion: string, toVersion: string, routes: RouteConfig[]) => RouteConfig[] | Promise<RouteConfig[]>;
35
+ /**
36
+ * 路由版本管理器配置
37
+ */
38
+ export interface RouteVersionManagerConfig {
39
+ /**
40
+ * 当前版本
41
+ */
42
+ currentVersion: string;
43
+ /**
44
+ * 是否启用版本检查
45
+ * @default true
46
+ */
47
+ enableVersionCheck?: boolean;
48
+ /**
49
+ * 是否启用自动迁移
50
+ * @default false
51
+ */
52
+ enableAutoMigration?: boolean;
53
+ }
54
+ /**
55
+ * 路由版本管理器
56
+ */
57
+ export declare class RouteVersionManager {
58
+ private versions;
59
+ private migrations;
60
+ private config;
61
+ constructor(config: RouteVersionManagerConfig);
62
+ /**
63
+ * 注册路由版本
64
+ *
65
+ * @param version - 版本信息
66
+ */
67
+ registerVersion(version: RouteVersion): void;
68
+ /**
69
+ * 注册版本迁移函数
70
+ *
71
+ * @param fromVersion - 源版本
72
+ * @param toVersion - 目标版本
73
+ * @param migration - 迁移函数
74
+ */
75
+ registerMigration(fromVersion: string, toVersion: string, migration: VersionMigration): void;
76
+ /**
77
+ * 检查版本兼容性
78
+ *
79
+ * @param version - 要检查的版本
80
+ * @returns 是否兼容
81
+ */
82
+ checkCompatibility(version: string): boolean;
83
+ /**
84
+ * 迁移路由配置
85
+ *
86
+ * @param fromVersion - 源版本
87
+ * @param toVersion - 目标版本
88
+ * @param routes - 路由配置
89
+ * @returns 迁移后的路由配置
90
+ */
91
+ migrate(fromVersion: string, toVersion: string, routes: RouteConfig[]): Promise<RouteConfig[]>;
92
+ /**
93
+ * 逐步迁移(通过中间版本)
94
+ */
95
+ private migrateStepwise;
96
+ /**
97
+ * 获取版本信息
98
+ *
99
+ * @param version - 版本号
100
+ * @returns 版本信息,如果不存在返回 undefined
101
+ */
102
+ getVersion(version: string): RouteVersion | undefined;
103
+ /**
104
+ * 获取所有版本
105
+ *
106
+ * @returns 版本信息数组
107
+ */
108
+ getAllVersions(): RouteVersion[];
109
+ /**
110
+ * 获取当前版本
111
+ *
112
+ * @returns 当前版本信息
113
+ */
114
+ getCurrentVersion(): RouteVersion | undefined;
115
+ /**
116
+ * 回滚到指定版本
117
+ *
118
+ * @param version - 目标版本
119
+ * @param routes - 当前路由配置
120
+ * @returns 回滚后的路由配置
121
+ */
122
+ rollback(version: string, routes: RouteConfig[]): Promise<RouteConfig[]>;
123
+ }
124
+ export declare function getRouteVersionManager(config?: RouteVersionManagerConfig): RouteVersionManager;
@@ -0,0 +1 @@
1
+ function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}import{logger}from"@vlian/logger";import{RouterError,RouterErrorCode}from"../errors";export class RouteVersionManager{registerVersion(version){if(!/^\d+\.\d+\.\d+/.test(version.version)){throw new Error(`无效的版本号格式: ${version.version}`)}this.versions.set(version.version,{...version,createdAt:version.createdAt||Date.now()});logger.debug(`路由版本已注册: ${version.version}`)}registerMigration(fromVersion,toVersion,migration){const key=`${fromVersion}->${toVersion}`;this.migrations.set(key,migration);logger.debug(`路由版本迁移已注册: ${key}`)}checkCompatibility(version){const versionInfo=this.versions.get(version);if(!versionInfo){return false}if(versionInfo.compatible===false){return false}const currentMajor=parseInt(this.config.currentVersion.split(".")[0]);const targetMajor=parseInt(version.split(".")[0]);return currentMajor===targetMajor}async migrate(fromVersion,toVersion,routes){if(fromVersion===toVersion){return routes}const migrationKey=`${fromVersion}->${toVersion}`;const migration=this.migrations.get(migrationKey);if(!migration){return this.migrateStepwise(fromVersion,toVersion,routes)}try{const migratedRoutes=await migration(fromVersion,toVersion,routes);logger.info(`路由版本迁移完成: ${fromVersion} -> ${toVersion}`);return migratedRoutes}catch(error){logger.error(`路由版本迁移失败: ${fromVersion} -> ${toVersion}`,error);const errorContext={fromVersion,toVersion};if(error instanceof Error){errorContext.originalError=error}throw new RouterError(`路由版本迁移失败: ${fromVersion} -> ${toVersion}`,RouterErrorCode.ROUTE_TRANSFORM_FAILED,undefined,error instanceof Error?error:undefined,errorContext)}}async migrateStepwise(fromVersion,toVersion,routes){const allVersions=Array.from(this.versions.keys()).sort((a,b)=>{const aParts=a.split(".").map(Number);const bParts=b.split(".").map(Number);for(let i=0;i<3;i++){if(aParts[i]!==bParts[i]){return aParts[i]-bParts[i]}}return 0});const fromIndex=allVersions.indexOf(fromVersion);const toIndex=allVersions.indexOf(toVersion);if(fromIndex===-1||toIndex===-1){throw new Error(`无法找到版本迁移路径: ${fromVersion} -> ${toVersion}`)}let currentRoutes=routes;const step=fromIndex<toIndex?1:-1;for(let i=fromIndex;i!==toIndex;i+=step){const currentVersion=allVersions[i];const nextVersion=allVersions[i+step];const migrationKey=`${currentVersion}->${nextVersion}`;const migration=this.migrations.get(migrationKey);if(migration){currentRoutes=await migration(currentVersion,nextVersion,currentRoutes)}else{logger.warn(`缺少迁移函数: ${migrationKey},跳过迁移`)}}return currentRoutes}getVersion(version){return this.versions.get(version)}getAllVersions(){return Array.from(this.versions.values())}getCurrentVersion(){return this.versions.get(this.config.currentVersion)}async rollback(version,routes){return this.migrate(this.config.currentVersion,version,routes)}constructor(config){_define_property(this,"versions",new Map);_define_property(this,"migrations",new Map);_define_property(this,"config",void 0);this.config={enableVersionCheck:config.enableVersionCheck??true,enableAutoMigration:config.enableAutoMigration??false,currentVersion:config.currentVersion}}}let versionManagerInstance=null;export function getRouteVersionManager(config){if(!versionManagerInstance&&config){versionManagerInstance=new RouteVersionManager(config)}if(!versionManagerInstance){throw new Error("路由版本管理器未初始化,请先提供配置")}return versionManagerInstance}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});_export_star(require("./RouteVersionManager"),exports);function _export_star(from,to){Object.keys(from).forEach(function(k){if(k!=="default"&&!Object.prototype.hasOwnProperty.call(to,k)){Object.defineProperty(to,k,{enumerable:true,get:function(){return from[k]}})}});return from}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 路由版本管理模块入口
3
+ */
4
+ export * from './RouteVersionManager';
@@ -0,0 +1 @@
1
+ export*from"./RouteVersionManager";
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"SplashScreen",{enumerable:true,get:function(){return SplashScreen}});const _jsxruntime=require("react/jsx-runtime");const _react=/*#__PURE__*/_interop_require_wildcard(require("react"));const _logger=require("@vlian/logger");const _initialization=require("../initialization");function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap;var cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interop_require_wildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj}}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj)}var newObj={__proto__:null};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc)}else{newObj[key]=obj[key]}}}newObj.default=obj;if(cache){cache.set(obj,newObj)}return newObj}const SplashScreen=(0,_react.memo)(({options,onComplete})=>{const[progress,setProgress]=(0,_react.useState)(0);const[currentStep,setCurrentStep]=(0,_react.useState)("准备初始化...");const[isInitializing,setIsInitializing]=(0,_react.useState)(false);const[estimatedTime,setEstimatedTime]=(0,_react.useState)(null);const[isSystemDark,setIsSystemDark]=(0,_react.useState)(()=>{if(typeof window==="undefined"){return false}return window.matchMedia("(prefers-color-scheme: dark)").matches});const hasCompletedRef=(0,_react.useRef)(false);const onCompleteRef=(0,_react.useRef)(onComplete);const optionsRef=(0,_react.useRef)(options);const startTimeRef=(0,_react.useRef)(Date.now());const minDisplayTimeRef=(0,_react.useRef)(options.minSplashScreenTime??500);const progressUpdateTimerRef=(0,_react.useRef)(null);const rafRef=(0,_react.useRef)(null);const lastProgressRef=(0,_react.useRef)(0);const progressHistoryRef=(0,_react.useRef)([]);(0,_react.useEffect)(()=>{onCompleteRef.current=onComplete;optionsRef.current=options;minDisplayTimeRef.current=options.minSplashScreenTime??500},[onComplete,options]);const debouncedProgressUpdate=(0,_react.useCallback)((progressValue,step)=>{if(rafRef.current!==null){cancelAnimationFrame(rafRef.current)}const now=Date.now();progressHistoryRef.current.push({progress:progressValue,time:now});if(progressHistoryRef.current.length>10){progressHistoryRef.current.shift()}if(progressHistoryRef.current.length>=2&&progressValue>0){const history=progressHistoryRef.current;const first=history[0];const last=history[history.length-1];const progressDelta=last.progress-first.progress;const timeDelta=last.time-first.time;if(progressDelta>0&&timeDelta>0){const progressPerMs=progressDelta/timeDelta;const remainingProgress=100-progressValue;const estimatedMs=remainingProgress/progressPerMs;setEstimatedTime(Math.max(0,Math.round(estimatedMs)))}}rafRef.current=requestAnimationFrame(()=>{setProgress(progressValue);if(step){setCurrentStep(step)}lastProgressRef.current=progressValue;rafRef.current=null})},[]);(0,_react.useEffect)(()=>{if(hasCompletedRef.current)return;hasCompletedRef.current=true;startTimeRef.current=Date.now();const performInitialization=async()=>{try{setIsInitializing(true);setProgress(0);setCurrentStep("开始初始化...");_logger.logger.info("启动页开始执行初始化");const context=await (0,_initialization.initialization)(optionsRef.current,(progressValue,step)=>{debouncedProgressUpdate(progressValue,step)});_logger.logger.info("启动页初始化完成",context);const elapsedTime=Date.now()-startTimeRef.current;const dynamicMinTime=elapsedTime<200?Math.min(minDisplayTimeRef.current,300):minDisplayTimeRef.current;const remainingTime=Math.max(0,dynamicMinTime-elapsedTime);if(remainingTime>0){await new Promise(resolve=>setTimeout(resolve,remainingTime))}if(progressUpdateTimerRef.current){clearTimeout(progressUpdateTimerRef.current);progressUpdateTimerRef.current=null}setProgress(100);setCurrentStep("初始化完成");onCompleteRef.current(context)}catch(error){_logger.logger.error("启动页初始化失败:",error);_initialization.initializationErrorState.setError(error);setCurrentStep("初始化失败,请刷新页面重试");onCompleteRef.current({config:{},progress:0,isReady:false,duration:0})}finally{setIsInitializing(false)}};performInitialization();return()=>{if(progressUpdateTimerRef.current){clearTimeout(progressUpdateTimerRef.current)}if(rafRef.current!==null){cancelAnimationFrame(rafRef.current)}}},[debouncedProgressUpdate]);(0,_react.useEffect)(()=>{if(typeof window==="undefined"){return}const mediaQuery=window.matchMedia("(prefers-color-scheme: dark)");const onSystemThemeChange=event=>{setIsSystemDark(event.matches)};setIsSystemDark(mediaQuery.matches);if(typeof mediaQuery.addEventListener==="function"){mediaQuery.addEventListener("change",onSystemThemeChange);return()=>mediaQuery.removeEventListener("change",onSystemThemeChange)}mediaQuery.addListener(onSystemThemeChange);return()=>mediaQuery.removeListener(onSystemThemeChange)},[]);const resolvedMode=_react.default.useMemo(()=>{const mode=optionsRef.current.theme?.mode||"light";if(mode==="system"){return isSystemDark?"dark":"light"}return mode==="dark"?"dark":"light"},[isSystemDark]);const palette=_react.default.useMemo(()=>{if(resolvedMode==="dark"){return{background:"#0b1220",text:"#e2e8f0",subText:"#94a3b8",track:"#1f2937",spinnerTrack:"#334155"}}return{background:"#f5f7fb",text:"#51606f",subText:"#94a3b8",track:"#e9eff5",spinnerTrack:"#d9e2ec"}},[resolvedMode]);const CustomSplashScreen=optionsRef.current.splashScreen;if(CustomSplashScreen){const customProps={progress,currentStep,isInitializing};return(0,_jsxruntime.jsx)(CustomSplashScreen,{...customProps})}return(0,_jsxruntime.jsxs)("div",{role:"status","aria-live":"polite","aria-label":"应用正在加载",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100%",gap:24,background:palette.background,color:palette.text},children:[(0,_jsxruntime.jsx)("div",{"aria-label":"加载中",style:{width:42,height:42,border:`4px solid ${palette.spinnerTrack}`,borderTopColor:"var(--app-primary-color, #2f80ed)",borderRadius:"50%",animation:"secra-spin 1s linear infinite"}}),(0,_jsxruntime.jsxs)("div",{style:{width:"300px"},children:[(0,_jsxruntime.jsx)("div",{"aria-label":`加载进度 ${progress}%`,style:{height:12,background:palette.track,borderRadius:999,overflow:"hidden"},children:(0,_jsxruntime.jsx)("div",{style:{width:`${Math.max(0,Math.min(100,progress))}%`,height:"100%",background:"var(--app-primary-color, #2f80ed)",transition:"width 0.2s ease"}})}),(0,_jsxruntime.jsxs)("div",{style:{marginTop:8,textAlign:"right",fontSize:12,color:palette.text},children:[progress,"%"]})]}),(0,_jsxruntime.jsxs)("div",{role:"status","aria-live":"polite",style:{fontSize:14,color:palette.text,textAlign:"center"},children:[currentStep,estimatedTime!==null&&estimatedTime>0&&(0,_jsxruntime.jsxs)("div",{style:{fontSize:12,color:palette.subText,marginTop:8},children:["预计还需 ",Math.ceil(estimatedTime/1e3)," 秒"]})]}),(0,_jsxruntime.jsx)("style",{children:`@keyframes secra-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }`})]})});SplashScreen.displayName="SplashScreen";
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import type { StartOptions } from '../types';
3
+ import type { InitializationContext } from '../initialization';
4
+ interface SplashScreenProps {
5
+ options: StartOptions;
6
+ onComplete: (context: InitializationContext) => void;
7
+ }
8
+ /**
9
+ * 启动页组件
10
+ *
11
+ * 在启动页中执行初始化,并使用 Ant Design 5 的 Spin 和 Progress 组件展示启动进度
12
+ */
13
+ declare const SplashScreen: React.FC<SplashScreenProps>;
14
+ export { SplashScreen };
@@ -0,0 +1 @@
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React,{useEffect,useState,useRef,memo,useCallback}from"react";import{logger}from"@vlian/logger";import{initialization,initializationErrorState}from"../initialization";const SplashScreen=memo(({options,onComplete})=>{const[progress,setProgress]=useState(0);const[currentStep,setCurrentStep]=useState("准备初始化...");const[isInitializing,setIsInitializing]=useState(false);const[estimatedTime,setEstimatedTime]=useState(null);const[isSystemDark,setIsSystemDark]=useState(()=>{if(typeof window==="undefined"){return false}return window.matchMedia("(prefers-color-scheme: dark)").matches});const hasCompletedRef=useRef(false);const onCompleteRef=useRef(onComplete);const optionsRef=useRef(options);const startTimeRef=useRef(Date.now());const minDisplayTimeRef=useRef(options.minSplashScreenTime??500);const progressUpdateTimerRef=useRef(null);const rafRef=useRef(null);const lastProgressRef=useRef(0);const progressHistoryRef=useRef([]);useEffect(()=>{onCompleteRef.current=onComplete;optionsRef.current=options;minDisplayTimeRef.current=options.minSplashScreenTime??500},[onComplete,options]);const debouncedProgressUpdate=useCallback((progressValue,step)=>{if(rafRef.current!==null){cancelAnimationFrame(rafRef.current)}const now=Date.now();progressHistoryRef.current.push({progress:progressValue,time:now});if(progressHistoryRef.current.length>10){progressHistoryRef.current.shift()}if(progressHistoryRef.current.length>=2&&progressValue>0){const history=progressHistoryRef.current;const first=history[0];const last=history[history.length-1];const progressDelta=last.progress-first.progress;const timeDelta=last.time-first.time;if(progressDelta>0&&timeDelta>0){const progressPerMs=progressDelta/timeDelta;const remainingProgress=100-progressValue;const estimatedMs=remainingProgress/progressPerMs;setEstimatedTime(Math.max(0,Math.round(estimatedMs)))}}rafRef.current=requestAnimationFrame(()=>{setProgress(progressValue);if(step){setCurrentStep(step)}lastProgressRef.current=progressValue;rafRef.current=null})},[]);useEffect(()=>{if(hasCompletedRef.current)return;hasCompletedRef.current=true;startTimeRef.current=Date.now();const performInitialization=async()=>{try{setIsInitializing(true);setProgress(0);setCurrentStep("开始初始化...");logger.info("启动页开始执行初始化");const context=await initialization(optionsRef.current,(progressValue,step)=>{debouncedProgressUpdate(progressValue,step)});logger.info("启动页初始化完成",context);const elapsedTime=Date.now()-startTimeRef.current;const dynamicMinTime=elapsedTime<200?Math.min(minDisplayTimeRef.current,300):minDisplayTimeRef.current;const remainingTime=Math.max(0,dynamicMinTime-elapsedTime);if(remainingTime>0){await new Promise(resolve=>setTimeout(resolve,remainingTime))}if(progressUpdateTimerRef.current){clearTimeout(progressUpdateTimerRef.current);progressUpdateTimerRef.current=null}setProgress(100);setCurrentStep("初始化完成");onCompleteRef.current(context)}catch(error){logger.error("启动页初始化失败:",error);initializationErrorState.setError(error);setCurrentStep("初始化失败,请刷新页面重试");onCompleteRef.current({config:{},progress:0,isReady:false,duration:0})}finally{setIsInitializing(false)}};performInitialization();return()=>{if(progressUpdateTimerRef.current){clearTimeout(progressUpdateTimerRef.current)}if(rafRef.current!==null){cancelAnimationFrame(rafRef.current)}}},[debouncedProgressUpdate]);useEffect(()=>{if(typeof window==="undefined"){return}const mediaQuery=window.matchMedia("(prefers-color-scheme: dark)");const onSystemThemeChange=event=>{setIsSystemDark(event.matches)};setIsSystemDark(mediaQuery.matches);if(typeof mediaQuery.addEventListener==="function"){mediaQuery.addEventListener("change",onSystemThemeChange);return()=>mediaQuery.removeEventListener("change",onSystemThemeChange)}mediaQuery.addListener(onSystemThemeChange);return()=>mediaQuery.removeListener(onSystemThemeChange)},[]);const resolvedMode=React.useMemo(()=>{const mode=optionsRef.current.theme?.mode||"light";if(mode==="system"){return isSystemDark?"dark":"light"}return mode==="dark"?"dark":"light"},[isSystemDark]);const palette=React.useMemo(()=>{if(resolvedMode==="dark"){return{background:"#0b1220",text:"#e2e8f0",subText:"#94a3b8",track:"#1f2937",spinnerTrack:"#334155"}}return{background:"#f5f7fb",text:"#51606f",subText:"#94a3b8",track:"#e9eff5",spinnerTrack:"#d9e2ec"}},[resolvedMode]);const CustomSplashScreen=optionsRef.current.splashScreen;if(CustomSplashScreen){const customProps={progress,currentStep,isInitializing};return _jsx(CustomSplashScreen,{...customProps})}return _jsxs("div",{role:"status","aria-live":"polite","aria-label":"应用正在加载",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",width:"100%",gap:24,background:palette.background,color:palette.text},children:[_jsx("div",{"aria-label":"加载中",style:{width:42,height:42,border:`4px solid ${palette.spinnerTrack}`,borderTopColor:"var(--app-primary-color, #2f80ed)",borderRadius:"50%",animation:"secra-spin 1s linear infinite"}}),_jsxs("div",{style:{width:"300px"},children:[_jsx("div",{"aria-label":`加载进度 ${progress}%`,style:{height:12,background:palette.track,borderRadius:999,overflow:"hidden"},children:_jsx("div",{style:{width:`${Math.max(0,Math.min(100,progress))}%`,height:"100%",background:"var(--app-primary-color, #2f80ed)",transition:"width 0.2s ease"}})}),_jsxs("div",{style:{marginTop:8,textAlign:"right",fontSize:12,color:palette.text},children:[progress,"%"]})]}),_jsxs("div",{role:"status","aria-live":"polite",style:{fontSize:14,color:palette.text,textAlign:"center"},children:[currentStep,estimatedTime!==null&&estimatedTime>0&&_jsxs("div",{style:{fontSize:12,color:palette.subText,marginTop:8},children:["预计还需 ",Math.ceil(estimatedTime/1e3)," 秒"]})]}),_jsx("style",{children:`@keyframes secra-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }`})]})});SplashScreen.displayName="SplashScreen";export{SplashScreen};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get SplashScreen(){return _SplashScreen.SplashScreen},get shouldShowSplashScreen(){return _splashScreenUtils.shouldShowSplashScreen}});const _SplashScreen=require("./SplashScreen");const _splashScreenUtils=require("./splashScreenUtils");
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 启动页模块统一导出
3
+ */
4
+ export { SplashScreen } from './SplashScreen';
5
+ export { shouldShowSplashScreen } from './splashScreenUtils';
@@ -0,0 +1 @@
1
+ export{SplashScreen}from"./SplashScreen";export{shouldShowSplashScreen}from"./splashScreenUtils";
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"shouldShowSplashScreen",{enumerable:true,get:function(){return shouldShowSplashScreen}});function shouldShowSplashScreen(showSplashScreen){if(showSplashScreen==="never"){return false}if(showSplashScreen==="always"){return true}if(showSplashScreen==="first-time-only"){const hasVisited=sessionStorage.getItem("__framework_visited__");if(hasVisited){return false}sessionStorage.setItem("__framework_visited__","true");return true}return true}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 判断是否应该显示启动页
3
+ *
4
+ * @param showSplashScreen - 启动页显示策略
5
+ * @returns boolean
6
+ */
7
+ export declare function shouldShowSplashScreen(showSplashScreen?: 'auto' | 'always' | 'never' | 'first-time-only'): boolean;
@@ -0,0 +1 @@
1
+ export function shouldShowSplashScreen(showSplashScreen){if(showSplashScreen==="never"){return false}if(showSplashScreen==="always"){return true}if(showSplashScreen==="first-time-only"){const hasVisited=sessionStorage.getItem("__framework_visited__");if(hasVisited){return false}sessionStorage.setItem("__framework_visited__","true");return true}return true}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get AppInstance(){return AppInstance},get AppInstanceManager(){return AppInstanceManager},get getAppInstanceManager(){return getAppInstanceManager}});const _renderApp=require("./renderApp");const _performanceTracker=require("./performanceTracker");function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}let AppInstance=class AppInstance{initialize(container,services){if(this.initialized){throw new Error(`应用实例 ${this.id} 已经初始化`)}if(this.destroyed){throw new Error(`应用实例 ${this.id} 已销毁,无法重新初始化`)}this.services=services;this.renderer.initialize(container,this.options.rootOptions);this.performanceTracker=new _performanceTracker.PerformanceTracker(services.monitoring);this.performanceTracker.collectWebVitals();this.initialized=true}getRenderer(){if(!this.initialized){throw new Error(`应用实例 ${this.id} 未初始化`)}return this.renderer}getServices(){if(!this.services){throw new Error(`应用实例 ${this.id} 未初始化`)}return this.services}getPerformanceTracker(){return this.performanceTracker}getEventBus(){if(!this.services){return null}return this.services.eventBus}getOptions(){return this.options}isInitialized(){return this.initialized}isDestroyed(){return this.destroyed}destroy(){if(this.destroyed){return}this.renderer.destroy();this.services=null;this.performanceTracker=null;this.destroyed=true}constructor(id,options){_define_property(this,"id",void 0);_define_property(this,"renderer",void 0);_define_property(this,"services",null);_define_property(this,"performanceTracker",null);_define_property(this,"options",void 0);_define_property(this,"initialized",false);_define_property(this,"destroyed",false);this.id=id;this.options=options;this.renderer=new _renderApp.AppRenderer}};let AppInstanceManager=class AppInstanceManager{static getInstance(){if(!AppInstanceManager.instance){AppInstanceManager.instance=new AppInstanceManager}return AppInstanceManager.instance}createInstance(id,options={}){const instanceId=id||`app-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;if(this.instances.has(instanceId)){throw new Error(`应用实例 ${instanceId} 已存在`)}const instance=new AppInstance(instanceId,options);this.instances.set(instanceId,instance);if(!this.defaultInstanceId){this.defaultInstanceId=instanceId}return instance}getInstance(id){const instanceId=id||this.defaultInstanceId;if(!instanceId){return undefined}return this.instances.get(instanceId)}destroyInstance(id){const instanceId=id||this.defaultInstanceId;if(!instanceId){return}const instance=this.instances.get(instanceId);if(instance){instance.destroy();this.instances.delete(instanceId);if(this.defaultInstanceId===instanceId){const remainingInstances=Array.from(this.instances.keys());this.defaultInstanceId=remainingInstances.length>0?remainingInstances[0]:null}}}getAllInstances(){return Array.from(this.instances.values())}setDefaultInstance(id){if(!this.instances.has(id)){throw new Error(`应用实例 ${id} 不存在`)}this.defaultInstanceId=id}getDefaultInstanceId(){return this.defaultInstanceId}clear(){for(const instance of this.instances.values()){instance.destroy()}this.instances.clear();this.defaultInstanceId=null}constructor(){_define_property(this,"instances",new Map);_define_property(this,"defaultInstanceId",null)}};_define_property(AppInstanceManager,"instance",null);function getAppInstanceManager(){return AppInstanceManager.getInstance()}
@@ -0,0 +1,138 @@
1
+ /**
2
+ * 应用实例管理模块
3
+ * 支持多实例隔离
4
+ */
5
+ import type { Container } from 'react-dom/client';
6
+ import type { StartOptions } from '../types';
7
+ import { AppRenderer } from './renderApp';
8
+ import type { ServicesInitResult } from './initializeServices';
9
+ import { PerformanceTracker } from './performanceTracker';
10
+ /**
11
+ * 应用实例
12
+ */
13
+ export declare class AppInstance {
14
+ /**
15
+ * 实例ID
16
+ */
17
+ readonly id: string;
18
+ /**
19
+ * 应用渲染器
20
+ */
21
+ private renderer;
22
+ /**
23
+ * 服务实例
24
+ */
25
+ private services;
26
+ /**
27
+ * 性能追踪器
28
+ */
29
+ private performanceTracker;
30
+ /**
31
+ * 启动配置
32
+ */
33
+ private options;
34
+ /**
35
+ * 是否已初始化
36
+ */
37
+ private initialized;
38
+ /**
39
+ * 是否已销毁
40
+ */
41
+ private destroyed;
42
+ constructor(id: string, options: StartOptions);
43
+ /**
44
+ * 初始化应用实例
45
+ *
46
+ * @param container - React应用的挂载容器
47
+ * @param services - 服务实例
48
+ */
49
+ initialize(container: Container, services: ServicesInitResult): void;
50
+ /**
51
+ * 获取渲染器
52
+ */
53
+ getRenderer(): AppRenderer;
54
+ /**
55
+ * 获取服务实例
56
+ */
57
+ getServices(): ServicesInitResult;
58
+ /**
59
+ * 获取性能追踪器
60
+ */
61
+ getPerformanceTracker(): PerformanceTracker | null;
62
+ /**
63
+ * 获取事件总线
64
+ */
65
+ getEventBus(): import('../event/AppEventBus').AppEventBus | null;
66
+ /**
67
+ * 获取启动配置
68
+ */
69
+ getOptions(): StartOptions;
70
+ /**
71
+ * 是否已初始化
72
+ */
73
+ isInitialized(): boolean;
74
+ /**
75
+ * 是否已销毁
76
+ */
77
+ isDestroyed(): boolean;
78
+ /**
79
+ * 销毁应用实例
80
+ */
81
+ destroy(): void;
82
+ }
83
+ /**
84
+ * 应用实例管理器
85
+ */
86
+ export declare class AppInstanceManager {
87
+ private static instance;
88
+ private instances;
89
+ private defaultInstanceId;
90
+ private constructor();
91
+ /**
92
+ * 获取单例实例
93
+ */
94
+ static getInstance(): AppInstanceManager;
95
+ /**
96
+ * 创建应用实例
97
+ *
98
+ * @param id - 实例ID,如果不提供则自动生成
99
+ * @param options - 启动配置选项
100
+ * @returns 应用实例
101
+ */
102
+ createInstance(id?: string, options?: StartOptions): AppInstance;
103
+ /**
104
+ * 获取应用实例
105
+ *
106
+ * @param id - 实例ID,如果不提供则返回默认实例
107
+ * @returns 应用实例或undefined
108
+ */
109
+ getInstance(id?: string): AppInstance | undefined;
110
+ /**
111
+ * 销毁应用实例
112
+ *
113
+ * @param id - 实例ID,如果不提供则销毁默认实例
114
+ */
115
+ destroyInstance(id?: string): void;
116
+ /**
117
+ * 获取所有实例
118
+ */
119
+ getAllInstances(): AppInstance[];
120
+ /**
121
+ * 设置默认实例
122
+ *
123
+ * @param id - 实例ID
124
+ */
125
+ setDefaultInstance(id: string): void;
126
+ /**
127
+ * 获取默认实例ID
128
+ */
129
+ getDefaultInstanceId(): string | null;
130
+ /**
131
+ * 清空所有实例
132
+ */
133
+ clear(): void;
134
+ }
135
+ /**
136
+ * 获取应用实例管理器
137
+ */
138
+ export declare function getAppInstanceManager(): AppInstanceManager;
@@ -0,0 +1 @@
1
+ function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}import{AppRenderer}from"./renderApp";import{PerformanceTracker}from"./performanceTracker";export class AppInstance{initialize(container,services){if(this.initialized){throw new Error(`应用实例 ${this.id} 已经初始化`)}if(this.destroyed){throw new Error(`应用实例 ${this.id} 已销毁,无法重新初始化`)}this.services=services;this.renderer.initialize(container,this.options.rootOptions);this.performanceTracker=new PerformanceTracker(services.monitoring);this.performanceTracker.collectWebVitals();this.initialized=true}getRenderer(){if(!this.initialized){throw new Error(`应用实例 ${this.id} 未初始化`)}return this.renderer}getServices(){if(!this.services){throw new Error(`应用实例 ${this.id} 未初始化`)}return this.services}getPerformanceTracker(){return this.performanceTracker}getEventBus(){if(!this.services){return null}return this.services.eventBus}getOptions(){return this.options}isInitialized(){return this.initialized}isDestroyed(){return this.destroyed}destroy(){if(this.destroyed){return}this.renderer.destroy();this.services=null;this.performanceTracker=null;this.destroyed=true}constructor(id,options){_define_property(this,"id",void 0);_define_property(this,"renderer",void 0);_define_property(this,"services",null);_define_property(this,"performanceTracker",null);_define_property(this,"options",void 0);_define_property(this,"initialized",false);_define_property(this,"destroyed",false);this.id=id;this.options=options;this.renderer=new AppRenderer}}export class AppInstanceManager{static getInstance(){if(!AppInstanceManager.instance){AppInstanceManager.instance=new AppInstanceManager}return AppInstanceManager.instance}createInstance(id,options={}){const instanceId=id||`app-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;if(this.instances.has(instanceId)){throw new Error(`应用实例 ${instanceId} 已存在`)}const instance=new AppInstance(instanceId,options);this.instances.set(instanceId,instance);if(!this.defaultInstanceId){this.defaultInstanceId=instanceId}return instance}getInstance(id){const instanceId=id||this.defaultInstanceId;if(!instanceId){return undefined}return this.instances.get(instanceId)}destroyInstance(id){const instanceId=id||this.defaultInstanceId;if(!instanceId){return}const instance=this.instances.get(instanceId);if(instance){instance.destroy();this.instances.delete(instanceId);if(this.defaultInstanceId===instanceId){const remainingInstances=Array.from(this.instances.keys());this.defaultInstanceId=remainingInstances.length>0?remainingInstances[0]:null}}}getAllInstances(){return Array.from(this.instances.values())}setDefaultInstance(id){if(!this.instances.has(id)){throw new Error(`应用实例 ${id} 不存在`)}this.defaultInstanceId=id}getDefaultInstanceId(){return this.defaultInstanceId}clear(){for(const instance of this.instances.values()){instance.destroy()}this.instances.clear();this.defaultInstanceId=null}constructor(){_define_property(this,"instances",new Map);_define_property(this,"defaultInstanceId",null)}}_define_property(AppInstanceManager,"instance",null);export function getAppInstanceManager(){return AppInstanceManager.getInstance()}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get EnvironmentDetector(){return EnvironmentDetector},get RuntimeEnvironment(){return RuntimeEnvironment},get getEnvironmentDetector(){return getEnvironmentDetector}});function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}var RuntimeEnvironment=/*#__PURE__*/function(RuntimeEnvironment){RuntimeEnvironment["BROWSER"]="browser";RuntimeEnvironment["SSR"]="ssr";RuntimeEnvironment["MICRO_FRONTEND"]="micro-frontend";RuntimeEnvironment["NODE"]="node";RuntimeEnvironment["UNKNOWN"]="unknown";return RuntimeEnvironment}({});let EnvironmentDetector=class EnvironmentDetector{static getInstance(){if(!EnvironmentDetector.instance){EnvironmentDetector.instance=new EnvironmentDetector}return EnvironmentDetector.instance}detectMicroFrontend(){if(typeof window==="undefined"){return false}return!!(window.__POWERED_BY_QIANKUN__||window.__MICRO_APP_ENVIRONMENT__||window.singleSpa||window.__SINGLE_SPA__)}detectEnvironment(){if(this.isMicroFrontend){return"micro-frontend"}if(this.isSSR){return"ssr"}if(this.isBrowser){return"browser"}if(typeof process!=="undefined"){return"node"}return"unknown"}getEnvironment(){return this.environment}isBrowserEnvironment(){return this.isBrowser}isSSREnvironment(){return this.isSSR}isMicroFrontendEnvironment(){return this.isMicroFrontend}safeGetElement(selector){if(!this.isBrowser){return null}if(typeof selector==="function"){try{return selector()}catch{return null}}try{if(selector.startsWith("#")){return document.getElementById(selector.slice(1))}return document.querySelector(selector)}catch{return null}}safeExecuteBrowserAPI(fn,fallback){if(!this.isBrowser){return fallback}try{return fn()}catch{return fallback}}constructor(){_define_property(this,"environment",void 0);_define_property(this,"isBrowser",void 0);_define_property(this,"isSSR",void 0);_define_property(this,"isMicroFrontend",void 0);this.isBrowser=typeof window!=="undefined"&&typeof document!=="undefined";this.isSSR=typeof window==="undefined"&&typeof process!=="undefined";this.isMicroFrontend=this.detectMicroFrontend();this.environment=this.detectEnvironment()}};_define_property(EnvironmentDetector,"instance",null);function getEnvironmentDetector(){return EnvironmentDetector.getInstance()}