@vlian/framework 1.2.56 → 1.2.59
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.
- package/README.md +15 -3
- package/dist/analytics/index.cjs +0 -2
- package/dist/analytics/index.js +1 -3
- package/dist/analytics.umd.js +8 -208
- package/dist/components/LocaleSwitch.cjs +0 -2
- package/dist/components/LocaleSwitch.js +1 -103
- package/dist/components/ThemeSwitch.cjs +0 -2
- package/dist/components/ThemeSwitch.js +1 -102
- package/dist/components/index.cjs +0 -2
- package/dist/components/index.js +1 -4
- package/dist/components/persistence.cjs +0 -2
- package/dist/components/persistence.js +1 -39
- package/dist/core/Test.cjs +0 -2
- package/dist/core/Test.js +1 -15
- package/dist/core/app/AppContext.cjs +0 -2
- package/dist/core/app/AppContext.js +1 -339
- package/dist/core/app/AppContext.types.cjs +0 -2
- package/dist/core/app/AppContext.types.js +1 -5
- package/dist/core/app/BasicLayout.cjs +0 -2
- package/dist/core/app/BasicLayout.js +1 -74
- package/dist/core/app/DefaultApp.cjs +0 -2
- package/dist/core/app/DefaultApp.js +1 -143
- package/dist/core/app/index.cjs +0 -2
- package/dist/core/app/index.js +1 -7
- package/dist/core/config/AppConfig.cjs +0 -2
- package/dist/core/config/AppConfig.js +1 -133
- package/dist/core/config/ConfigLoader.cjs +0 -2
- package/dist/core/config/ConfigLoader.js +1 -311
- package/dist/core/config/ConfigValidator.cjs +0 -2
- package/dist/core/config/ConfigValidator.js +2 -121
- package/dist/core/config/index.cjs +0 -2
- package/dist/core/config/index.js +1 -7
- package/dist/core/dev/DevTools.cjs +0 -2
- package/dist/core/dev/DevTools.js +1 -210
- package/dist/core/error/ErrorBoundary.cjs +0 -2
- package/dist/core/error/ErrorBoundary.js +1 -399
- package/dist/core/error/ErrorHandler.cjs +0 -2
- package/dist/core/error/ErrorHandler.js +1 -261
- package/dist/core/error/index.cjs +0 -2
- package/dist/core/error/index.js +1 -6
- package/dist/core/event/AppEventBus.cjs +0 -2
- package/dist/core/event/AppEventBus.js +1 -438
- package/dist/core/event/frameworkEvents.cjs +0 -2
- package/dist/core/event/frameworkEvents.js +1 -135
- package/dist/core/event/hooks.cjs +0 -2
- package/dist/core/event/hooks.js +1 -95
- package/dist/core/event/index.cjs +0 -2
- package/dist/core/event/index.js +1 -10
- package/dist/core/event/types.cjs +0 -2
- package/dist/core/event/types.js +1 -56
- package/dist/core/event/useEventBus.cjs +0 -2
- package/dist/core/event/useEventBus.js +1 -39
- package/dist/core/index.cjs +0 -2
- package/dist/core/index.js +1 -69
- package/dist/core/initialization/InitializationErrorThrower.cjs +0 -2
- package/dist/core/initialization/InitializationErrorThrower.js +1 -30
- package/dist/core/initialization/index.cjs +0 -2
- package/dist/core/initialization/index.js +1 -7
- package/dist/core/initialization/initialization.cjs +0 -2
- package/dist/core/initialization/initialization.js +1 -78
- package/dist/core/initialization/initializationErrorState.cjs +0 -2
- package/dist/core/initialization/initializationErrorState.js +1 -60
- package/dist/core/kernel/defaultAdapters.cjs +0 -2
- package/dist/core/kernel/defaultAdapters.js +1 -176
- package/dist/core/kernel/errors.cjs +0 -2
- package/dist/core/kernel/errors.js +1 -53
- package/dist/core/kernel/index.cjs +0 -2
- package/dist/core/kernel/index.js +1 -4
- package/dist/core/kernel/startKernel.cjs +0 -2
- package/dist/core/kernel/startKernel.js +1 -192
- package/dist/core/kernel/types.cjs +0 -2
- package/dist/core/kernel/types.js +1 -3
- package/dist/core/middleware.cjs +0 -2
- package/dist/core/middleware.js +1 -61
- package/dist/core/plugin/PluginEventBus.cjs +0 -2
- package/dist/core/plugin/PluginEventBus.js +1 -286
- package/dist/core/plugin/PluginSandbox.cjs +0 -2
- package/dist/core/plugin/PluginSandbox.js +1 -125
- package/dist/core/plugin.cjs +0 -2
- package/dist/core/plugin.js +1 -438
- package/dist/core/router/RouterManager.cjs +0 -2
- package/dist/core/router/RouterManager.js +1 -272
- package/dist/core/router/adapter/AdapterManager.cjs +0 -2
- package/dist/core/router/adapter/AdapterManager.js +1 -221
- package/dist/core/router/adapter/index.cjs +0 -2
- package/dist/core/router/adapter/index.js +1 -7
- package/dist/core/router/adapter/react-router/ReactRouterAdapter.cjs +0 -2
- package/dist/core/router/adapter/react-router/ReactRouterAdapter.js +1 -116
- package/dist/core/router/adapter/react-router/index.cjs +0 -2
- package/dist/core/router/adapter/react-router/index.js +1 -5
- package/dist/core/router/adapter/types.cjs +0 -2
- package/dist/core/router/adapter/types.js +1 -7
- package/dist/core/router/dev/RouterDevTools.cjs +0 -2
- package/dist/core/router/dev/RouterDevTools.js +1 -211
- package/dist/core/router/dev/index.cjs +0 -2
- package/dist/core/router/dev/index.js +1 -5
- package/dist/core/router/dynamic/DynamicRouteManager.cjs +0 -2
- package/dist/core/router/dynamic/DynamicRouteManager.js +1 -179
- package/dist/core/router/dynamic/index.cjs +0 -2
- package/dist/core/router/dynamic/index.js +1 -5
- package/dist/core/router/errors/RouterError.cjs +0 -2
- package/dist/core/router/errors/RouterError.js +1 -48
- package/dist/core/router/errors/index.cjs +0 -2
- package/dist/core/router/errors/index.js +1 -5
- package/dist/core/router/index.cjs +0 -2
- package/dist/core/router/index.js +1 -32
- package/dist/core/router/lifecycle/RouterLifecycleManager.cjs +0 -2
- package/dist/core/router/lifecycle/RouterLifecycleManager.js +1 -130
- package/dist/core/router/lifecycle/index.cjs +0 -2
- package/dist/core/router/lifecycle/index.js +1 -5
- package/dist/core/router/middleware/RouterMiddlewareManager.cjs +0 -2
- package/dist/core/router/middleware/RouterMiddlewareManager.js +1 -179
- package/dist/core/router/middleware/auth.cjs +0 -2
- package/dist/core/router/middleware/auth.js +1 -63
- package/dist/core/router/middleware/index.cjs +0 -2
- package/dist/core/router/middleware/index.js +1 -7
- package/dist/core/router/middleware/types.cjs +0 -2
- package/dist/core/router/middleware/types.js +1 -7
- package/dist/core/router/monitoring/RouterMonitoring.cjs +0 -2
- package/dist/core/router/monitoring/RouterMonitoring.js +1 -213
- package/dist/core/router/monitoring/index.cjs +0 -2
- package/dist/core/router/monitoring/index.js +1 -5
- package/dist/core/router/navigation/RouterNavigation.cjs +0 -2
- package/dist/core/router/navigation/RouterNavigation.js +1 -192
- package/dist/core/router/navigation/index.cjs +0 -2
- package/dist/core/router/navigation/index.js +1 -5
- package/dist/core/router/performance/RouteCache.cjs +0 -2
- package/dist/core/router/performance/RouteCache.js +1 -291
- package/dist/core/router/performance/RoutePreloader.cjs +0 -2
- package/dist/core/router/performance/RoutePreloader.js +1 -277
- package/dist/core/router/performance/index.cjs +0 -2
- package/dist/core/router/performance/index.js +1 -6
- package/dist/core/router/plugin/RouterPluginManager.cjs +0 -2
- package/dist/core/router/plugin/RouterPluginManager.js +1 -248
- package/dist/core/router/plugin/index.cjs +0 -2
- package/dist/core/router/plugin/index.js +1 -6
- package/dist/core/router/plugin/types.cjs +0 -2
- package/dist/core/router/plugin/types.js +1 -33
- package/dist/core/router/types.cjs +0 -2
- package/dist/core/router/types.js +1 -5
- package/dist/core/router/utils/adapters/react-router/RouteErrorBoundary.cjs +0 -2
- package/dist/core/router/utils/adapters/react-router/RouteErrorBoundary.js +1 -121
- package/dist/core/router/utils/adapters/react-router/transform.cjs +0 -2
- package/dist/core/router/utils/adapters/react-router/transform.js +1 -242
- package/dist/core/router/utils/transform.cjs +0 -2
- package/dist/core/router/utils/transform.js +1 -791
- package/dist/core/router/validation/RouterConfigValidator.cjs +0 -2
- package/dist/core/router/validation/RouterConfigValidator.js +2 -77
- package/dist/core/router/validation/index.cjs +0 -2
- package/dist/core/router/validation/index.js +1 -6
- package/dist/core/router/validation/schema.cjs +0 -2
- package/dist/core/router/validation/schema.js +1 -151
- package/dist/core/router/version/RouteVersionManager.cjs +0 -2
- package/dist/core/router/version/RouteVersionManager.js +1 -191
- package/dist/core/router/version/index.cjs +0 -2
- package/dist/core/router/version/index.js +1 -5
- package/dist/core/splash/SplashScreen.cjs +0 -2
- package/dist/core/splash/SplashScreen.js +1 -293
- package/dist/core/splash/index.cjs +0 -2
- package/dist/core/splash/index.js +1 -6
- package/dist/core/splash/splashScreenUtils.cjs +0 -2
- package/dist/core/splash/splashScreenUtils.js +1 -30
- package/dist/core/startup/AppInstance.cjs +0 -2
- package/dist/core/startup/AppInstance.js +1 -226
- package/dist/core/startup/environment.cjs +0 -2
- package/dist/core/startup/environment.js +1 -154
- package/dist/core/startup/index.cjs +0 -2
- package/dist/core/startup/index.js +1 -8
- package/dist/core/startup/initializeServices.cjs +0 -2
- package/dist/core/startup/initializeServices.js +1 -188
- package/dist/core/startup/performanceTracker.cjs +0 -2
- package/dist/core/startup/performanceTracker.js +1 -167
- package/dist/core/startup/renderApp.cjs +0 -2
- package/dist/core/startup/renderApp.js +1 -267
- package/dist/core/startup/startApp.cjs +0 -2
- package/dist/core/startup/startApp.js +1 -315
- package/dist/core/types.cjs +0 -2
- package/dist/core/types.js +1 -5
- package/dist/index.cjs +0 -2
- package/dist/index.js +1 -11
- package/dist/index.umd.cjs +0 -2
- package/dist/index.umd.js +362 -13230
- package/dist/kernel/constants.cjs +0 -2
- package/dist/kernel/constants.js +1 -43
- package/dist/kernel/index.cjs +0 -2
- package/dist/kernel/index.js +1 -4
- package/dist/kernel/kernel.cjs +1 -3
- package/dist/kernel/kernel.js +1 -273
- package/dist/kernel/manager/cacheManager.cjs +0 -2
- package/dist/kernel/manager/cacheManager.js +1 -38
- package/dist/kernel/manager/i18n/I18nManager.cjs +0 -2
- package/dist/kernel/manager/i18n/I18nManager.js +1 -83
- package/dist/kernel/manager/i18n/i18n.persistence.cjs +4 -3
- package/dist/kernel/manager/i18n/i18n.persistence.js +1 -38
- package/dist/kernel/manager/i18n/i18n.schema.cjs +0 -2
- package/dist/kernel/manager/i18n/i18n.schema.js +1 -64
- package/dist/kernel/manager/i18n/index.cjs +0 -2
- package/dist/kernel/manager/i18n/index.js +1 -3
- package/dist/kernel/manager/i18nManager.cjs +0 -2
- package/dist/kernel/manager/i18nManager.js +1 -3
- package/dist/kernel/manager/index.cjs +0 -2
- package/dist/kernel/manager/index.js +1 -6
- package/dist/kernel/manager/logger/LoggerManager.cjs +0 -2
- package/dist/kernel/manager/logger/LoggerManager.js +1 -99
- package/dist/kernel/manager/logger/index.cjs +0 -2
- package/dist/kernel/manager/logger/index.js +1 -3
- package/dist/kernel/manager/logger/logger.persistence.cjs +0 -2
- package/dist/kernel/manager/logger/logger.persistence.js +1 -43
- package/dist/kernel/manager/logger/logger.schema.cjs +0 -2
- package/dist/kernel/manager/logger/logger.schema.js +1 -55
- package/dist/kernel/manager/loggerManager.cjs +0 -2
- package/dist/kernel/manager/loggerManager.js +1 -3
- package/dist/kernel/manager/theme/ThemeManager.cjs +0 -2
- package/dist/kernel/manager/theme/ThemeManager.js +1 -76
- package/dist/kernel/manager/theme/index.cjs +0 -2
- package/dist/kernel/manager/theme/index.js +1 -3
- package/dist/kernel/manager/theme/theme.dom.cjs +0 -2
- package/dist/kernel/manager/theme/theme.dom.js +1 -45
- package/dist/kernel/manager/theme/theme.persistence.cjs +0 -2
- package/dist/kernel/manager/theme/theme.persistence.js +1 -38
- package/dist/kernel/manager/theme/theme.schema.cjs +0 -2
- package/dist/kernel/manager/theme/theme.schema.js +1 -97
- package/dist/kernel/manager/themeManager.cjs +0 -2
- package/dist/kernel/manager/themeManager.js +1 -3
- package/dist/kernel/types.cjs +0 -2
- package/dist/kernel/types.js +1 -3
- package/dist/library/index.cjs +0 -2
- package/dist/library/index.js +1 -4
- package/dist/library/locale/index.cjs +0 -2
- package/dist/library/locale/index.js +1 -12
- package/dist/library/locale/langs/en-us/index.cjs +0 -2
- package/dist/library/locale/langs/en-us/index.js +1 -24
- package/dist/library/locale/langs/zh-cn/index.cjs +0 -2
- package/dist/library/locale/langs/zh-cn/index.js +1 -24
- package/dist/library/locale/types.cjs +0 -2
- package/dist/library/locale/types.js +1 -3
- package/dist/library/storage/cache.cjs +0 -2
- package/dist/library/storage/cache.js +1 -237
- package/dist/library/storage/encryption.cjs +0 -2
- package/dist/library/storage/encryption.js +1 -141
- package/dist/library/storage/index.cjs +0 -2
- package/dist/library/storage/index.js +1 -106
- package/dist/state/StateManager.cjs +0 -2
- package/dist/state/StateManager.js +1 -160
- package/dist/state/adapters/AdapterFactory.cjs +0 -2
- package/dist/state/adapters/AdapterFactory.js +1 -85
- package/dist/state/adapters/DefaultAdapter.cjs +0 -2
- package/dist/state/adapters/DefaultAdapter.js +1 -71
- package/dist/state/adapters/ReduxAdapter.cjs +0 -2
- package/dist/state/adapters/ReduxAdapter.js +1 -439
- package/dist/state/adapters/ZustandAdapter.cjs +0 -2
- package/dist/state/adapters/ZustandAdapter.js +1 -70
- package/dist/state/adapters/index.cjs +0 -2
- package/dist/state/adapters/index.js +1 -9
- package/dist/state/adapters/types.cjs +0 -2
- package/dist/state/adapters/types.js +1 -5
- package/dist/state/core/DerivedStateInstance.cjs +0 -2
- package/dist/state/core/DerivedStateInstance.js +1 -173
- package/dist/state/core/StateInstance.cjs +0 -2
- package/dist/state/core/StateInstance.js +1 -168
- package/dist/state/core/StateRegistry.cjs +0 -2
- package/dist/state/core/StateRegistry.js +1 -106
- package/dist/state/core/StateScope.cjs +0 -2
- package/dist/state/core/StateScope.js +1 -133
- package/dist/state/core/index.cjs +0 -2
- package/dist/state/core/index.js +1 -8
- package/dist/state/index.cjs +0 -2
- package/dist/state/index.js +1 -12
- package/dist/state/types.cjs +0 -2
- package/dist/state/types.js +1 -13
- package/dist/state.umd.js +22 -1395
- package/dist/types.cjs +0 -2
- package/dist/types.js +1 -3
- package/dist/utils/analytics.cjs +0 -2
- package/dist/utils/analytics.js +1 -204
- package/dist/utils/configSecurity.cjs +0 -2
- package/dist/utils/configSecurity.js +3 -176
- package/dist/utils/csrf.cjs +0 -2
- package/dist/utils/csrf.js +1 -3
- package/dist/utils/errors/ErrorCodes.cjs +0 -2
- package/dist/utils/errors/ErrorCodes.js +1 -3
- package/dist/utils/errors.cjs +0 -2
- package/dist/utils/errors.js +1 -18
- package/dist/utils/index.cjs +0 -2
- package/dist/utils/index.js +1 -48
- package/dist/utils/logger.cjs +0 -2
- package/dist/utils/logger.js +1 -3
- package/dist/utils/logger.types.cjs +0 -2
- package/dist/utils/logger.types.js +1 -3
- package/dist/utils/monitoring.cjs +0 -2
- package/dist/utils/monitoring.js +1 -3
- package/dist/utils/performance.cjs +0 -2
- package/dist/utils/performance.js +1 -3
- package/dist/utils/resourceLoader.cjs +0 -2
- package/dist/utils/resourceLoader.js +1 -3
- package/dist/utils/runtimeSecurity.cjs +0 -2
- package/dist/utils/runtimeSecurity.js +1 -3
- package/dist/utils/security.cjs +0 -2
- package/dist/utils/security.js +1 -3
- package/dist/utils/traceId.cjs +0 -2
- package/dist/utils/traceId.js +1 -3
- package/dist/utils/validation.cjs +0 -2
- package/dist/utils/validation.js +1 -3
- package/package.json +3 -4
- package/dist/analytics/index.cjs.map +0 -1
- package/dist/analytics/index.js.map +0 -1
- package/dist/analytics.umd.js.map +0 -1
- package/dist/components/LocaleSwitch.cjs.map +0 -1
- package/dist/components/LocaleSwitch.js.map +0 -1
- package/dist/components/ThemeSwitch.cjs.map +0 -1
- package/dist/components/ThemeSwitch.js.map +0 -1
- package/dist/components/index.cjs.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/components/persistence.cjs.map +0 -1
- package/dist/components/persistence.js.map +0 -1
- package/dist/core/Test.cjs.map +0 -1
- package/dist/core/Test.js.map +0 -1
- package/dist/core/app/AppContext.cjs.map +0 -1
- package/dist/core/app/AppContext.js.map +0 -1
- package/dist/core/app/AppContext.types.cjs.map +0 -1
- package/dist/core/app/AppContext.types.js.map +0 -1
- package/dist/core/app/BasicLayout.cjs.map +0 -1
- package/dist/core/app/BasicLayout.js.map +0 -1
- package/dist/core/app/DefaultApp.cjs.map +0 -1
- package/dist/core/app/DefaultApp.js.map +0 -1
- package/dist/core/app/index.cjs.map +0 -1
- package/dist/core/app/index.js.map +0 -1
- package/dist/core/config/AppConfig.cjs.map +0 -1
- package/dist/core/config/AppConfig.js.map +0 -1
- package/dist/core/config/ConfigLoader.cjs.map +0 -1
- package/dist/core/config/ConfigLoader.js.map +0 -1
- package/dist/core/config/ConfigValidator.cjs.map +0 -1
- package/dist/core/config/ConfigValidator.js.map +0 -1
- package/dist/core/config/index.cjs.map +0 -1
- package/dist/core/config/index.js.map +0 -1
- package/dist/core/dev/DevTools.cjs.map +0 -1
- package/dist/core/dev/DevTools.js.map +0 -1
- package/dist/core/error/ErrorBoundary.cjs.map +0 -1
- package/dist/core/error/ErrorBoundary.js.map +0 -1
- package/dist/core/error/ErrorHandler.cjs.map +0 -1
- package/dist/core/error/ErrorHandler.js.map +0 -1
- package/dist/core/error/index.cjs.map +0 -1
- package/dist/core/error/index.js.map +0 -1
- package/dist/core/event/AppEventBus.cjs.map +0 -1
- package/dist/core/event/AppEventBus.js.map +0 -1
- package/dist/core/event/frameworkEvents.cjs.map +0 -1
- package/dist/core/event/frameworkEvents.js.map +0 -1
- package/dist/core/event/hooks.cjs.map +0 -1
- package/dist/core/event/hooks.js.map +0 -1
- package/dist/core/event/index.cjs.map +0 -1
- package/dist/core/event/index.js.map +0 -1
- package/dist/core/event/types.cjs.map +0 -1
- package/dist/core/event/types.js.map +0 -1
- package/dist/core/event/useEventBus.cjs.map +0 -1
- package/dist/core/event/useEventBus.js.map +0 -1
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/initialization/InitializationErrorThrower.cjs.map +0 -1
- package/dist/core/initialization/InitializationErrorThrower.js.map +0 -1
- package/dist/core/initialization/index.cjs.map +0 -1
- package/dist/core/initialization/index.js.map +0 -1
- package/dist/core/initialization/initialization.cjs.map +0 -1
- package/dist/core/initialization/initialization.js.map +0 -1
- package/dist/core/initialization/initializationErrorState.cjs.map +0 -1
- package/dist/core/initialization/initializationErrorState.js.map +0 -1
- package/dist/core/kernel/defaultAdapters.cjs.map +0 -1
- package/dist/core/kernel/defaultAdapters.js.map +0 -1
- package/dist/core/kernel/errors.cjs.map +0 -1
- package/dist/core/kernel/errors.js.map +0 -1
- package/dist/core/kernel/index.cjs.map +0 -1
- package/dist/core/kernel/index.js.map +0 -1
- package/dist/core/kernel/startKernel.cjs.map +0 -1
- package/dist/core/kernel/startKernel.js.map +0 -1
- package/dist/core/kernel/types.cjs.map +0 -1
- package/dist/core/kernel/types.js.map +0 -1
- package/dist/core/middleware.cjs.map +0 -1
- package/dist/core/middleware.js.map +0 -1
- package/dist/core/plugin/PluginEventBus.cjs.map +0 -1
- package/dist/core/plugin/PluginEventBus.js.map +0 -1
- package/dist/core/plugin/PluginSandbox.cjs.map +0 -1
- package/dist/core/plugin/PluginSandbox.js.map +0 -1
- package/dist/core/plugin.cjs.map +0 -1
- package/dist/core/plugin.js.map +0 -1
- package/dist/core/router/RouterManager.cjs.map +0 -1
- package/dist/core/router/RouterManager.js.map +0 -1
- package/dist/core/router/adapter/AdapterManager.cjs.map +0 -1
- package/dist/core/router/adapter/AdapterManager.js.map +0 -1
- package/dist/core/router/adapter/index.cjs.map +0 -1
- package/dist/core/router/adapter/index.js.map +0 -1
- package/dist/core/router/adapter/react-router/ReactRouterAdapter.cjs.map +0 -1
- package/dist/core/router/adapter/react-router/ReactRouterAdapter.js.map +0 -1
- package/dist/core/router/adapter/react-router/index.cjs.map +0 -1
- package/dist/core/router/adapter/react-router/index.js.map +0 -1
- package/dist/core/router/adapter/types.cjs.map +0 -1
- package/dist/core/router/adapter/types.js.map +0 -1
- package/dist/core/router/dev/RouterDevTools.cjs.map +0 -1
- package/dist/core/router/dev/RouterDevTools.js.map +0 -1
- package/dist/core/router/dev/index.cjs.map +0 -1
- package/dist/core/router/dev/index.js.map +0 -1
- package/dist/core/router/dynamic/DynamicRouteManager.cjs.map +0 -1
- package/dist/core/router/dynamic/DynamicRouteManager.js.map +0 -1
- package/dist/core/router/dynamic/index.cjs.map +0 -1
- package/dist/core/router/dynamic/index.js.map +0 -1
- package/dist/core/router/errors/RouterError.cjs.map +0 -1
- package/dist/core/router/errors/RouterError.js.map +0 -1
- package/dist/core/router/errors/index.cjs.map +0 -1
- package/dist/core/router/errors/index.js.map +0 -1
- package/dist/core/router/index.cjs.map +0 -1
- package/dist/core/router/index.js.map +0 -1
- package/dist/core/router/lifecycle/RouterLifecycleManager.cjs.map +0 -1
- package/dist/core/router/lifecycle/RouterLifecycleManager.js.map +0 -1
- package/dist/core/router/lifecycle/index.cjs.map +0 -1
- package/dist/core/router/lifecycle/index.js.map +0 -1
- package/dist/core/router/middleware/RouterMiddlewareManager.cjs.map +0 -1
- package/dist/core/router/middleware/RouterMiddlewareManager.js.map +0 -1
- package/dist/core/router/middleware/auth.cjs.map +0 -1
- package/dist/core/router/middleware/auth.js.map +0 -1
- package/dist/core/router/middleware/index.cjs.map +0 -1
- package/dist/core/router/middleware/index.js.map +0 -1
- package/dist/core/router/middleware/types.cjs.map +0 -1
- package/dist/core/router/middleware/types.js.map +0 -1
- package/dist/core/router/monitoring/RouterMonitoring.cjs.map +0 -1
- package/dist/core/router/monitoring/RouterMonitoring.js.map +0 -1
- package/dist/core/router/monitoring/index.cjs.map +0 -1
- package/dist/core/router/monitoring/index.js.map +0 -1
- package/dist/core/router/navigation/RouterNavigation.cjs.map +0 -1
- package/dist/core/router/navigation/RouterNavigation.js.map +0 -1
- package/dist/core/router/navigation/index.cjs.map +0 -1
- package/dist/core/router/navigation/index.js.map +0 -1
- package/dist/core/router/performance/RouteCache.cjs.map +0 -1
- package/dist/core/router/performance/RouteCache.js.map +0 -1
- package/dist/core/router/performance/RoutePreloader.cjs.map +0 -1
- package/dist/core/router/performance/RoutePreloader.js.map +0 -1
- package/dist/core/router/performance/index.cjs.map +0 -1
- package/dist/core/router/performance/index.js.map +0 -1
- package/dist/core/router/plugin/RouterPluginManager.cjs.map +0 -1
- package/dist/core/router/plugin/RouterPluginManager.js.map +0 -1
- package/dist/core/router/plugin/index.cjs.map +0 -1
- package/dist/core/router/plugin/index.js.map +0 -1
- package/dist/core/router/plugin/types.cjs.map +0 -1
- package/dist/core/router/plugin/types.js.map +0 -1
- package/dist/core/router/types.cjs.map +0 -1
- package/dist/core/router/types.js.map +0 -1
- package/dist/core/router/utils/adapters/react-router/RouteErrorBoundary.cjs.map +0 -1
- package/dist/core/router/utils/adapters/react-router/RouteErrorBoundary.js.map +0 -1
- package/dist/core/router/utils/adapters/react-router/transform.cjs.map +0 -1
- package/dist/core/router/utils/adapters/react-router/transform.js.map +0 -1
- package/dist/core/router/utils/transform.cjs.map +0 -1
- package/dist/core/router/utils/transform.js.map +0 -1
- package/dist/core/router/validation/RouterConfigValidator.cjs.map +0 -1
- package/dist/core/router/validation/RouterConfigValidator.js.map +0 -1
- package/dist/core/router/validation/index.cjs.map +0 -1
- package/dist/core/router/validation/index.js.map +0 -1
- package/dist/core/router/validation/schema.cjs.map +0 -1
- package/dist/core/router/validation/schema.js.map +0 -1
- package/dist/core/router/version/RouteVersionManager.cjs.map +0 -1
- package/dist/core/router/version/RouteVersionManager.js.map +0 -1
- package/dist/core/router/version/index.cjs.map +0 -1
- package/dist/core/router/version/index.js.map +0 -1
- package/dist/core/splash/SplashScreen.cjs.map +0 -1
- package/dist/core/splash/SplashScreen.js.map +0 -1
- package/dist/core/splash/index.cjs.map +0 -1
- package/dist/core/splash/index.js.map +0 -1
- package/dist/core/splash/splashScreenUtils.cjs.map +0 -1
- package/dist/core/splash/splashScreenUtils.js.map +0 -1
- package/dist/core/startup/AppInstance.cjs.map +0 -1
- package/dist/core/startup/AppInstance.js.map +0 -1
- package/dist/core/startup/environment.cjs.map +0 -1
- package/dist/core/startup/environment.js.map +0 -1
- package/dist/core/startup/index.cjs.map +0 -1
- package/dist/core/startup/index.js.map +0 -1
- package/dist/core/startup/initializeServices.cjs.map +0 -1
- package/dist/core/startup/initializeServices.js.map +0 -1
- package/dist/core/startup/performanceTracker.cjs.map +0 -1
- package/dist/core/startup/performanceTracker.js.map +0 -1
- package/dist/core/startup/renderApp.cjs.map +0 -1
- package/dist/core/startup/renderApp.js.map +0 -1
- package/dist/core/startup/startApp.cjs.map +0 -1
- package/dist/core/startup/startApp.js.map +0 -1
- package/dist/core/types.cjs.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.umd.cjs.map +0 -1
- package/dist/index.umd.js.map +0 -1
- package/dist/kernel/constants.cjs.map +0 -1
- package/dist/kernel/constants.js.map +0 -1
- package/dist/kernel/index.cjs.map +0 -1
- package/dist/kernel/index.js.map +0 -1
- package/dist/kernel/kernel.cjs.map +0 -1
- package/dist/kernel/kernel.js.map +0 -1
- package/dist/kernel/manager/cacheManager.cjs.map +0 -1
- package/dist/kernel/manager/cacheManager.js.map +0 -1
- package/dist/kernel/manager/i18n/I18nManager.cjs.map +0 -1
- package/dist/kernel/manager/i18n/I18nManager.js.map +0 -1
- package/dist/kernel/manager/i18n/i18n.persistence.cjs.map +0 -1
- package/dist/kernel/manager/i18n/i18n.persistence.js.map +0 -1
- package/dist/kernel/manager/i18n/i18n.schema.cjs.map +0 -1
- package/dist/kernel/manager/i18n/i18n.schema.js.map +0 -1
- package/dist/kernel/manager/i18n/index.cjs.map +0 -1
- package/dist/kernel/manager/i18n/index.js.map +0 -1
- package/dist/kernel/manager/i18nManager.cjs.map +0 -1
- package/dist/kernel/manager/i18nManager.js.map +0 -1
- package/dist/kernel/manager/index.cjs.map +0 -1
- package/dist/kernel/manager/index.js.map +0 -1
- package/dist/kernel/manager/logger/LoggerManager.cjs.map +0 -1
- package/dist/kernel/manager/logger/LoggerManager.js.map +0 -1
- package/dist/kernel/manager/logger/index.cjs.map +0 -1
- package/dist/kernel/manager/logger/index.js.map +0 -1
- package/dist/kernel/manager/logger/logger.persistence.cjs.map +0 -1
- package/dist/kernel/manager/logger/logger.persistence.js.map +0 -1
- package/dist/kernel/manager/logger/logger.schema.cjs.map +0 -1
- package/dist/kernel/manager/logger/logger.schema.js.map +0 -1
- package/dist/kernel/manager/loggerManager.cjs.map +0 -1
- package/dist/kernel/manager/loggerManager.js.map +0 -1
- package/dist/kernel/manager/persistence.cjs +0 -78
- package/dist/kernel/manager/persistence.cjs.map +0 -1
- package/dist/kernel/manager/persistence.d.ts +0 -3
- package/dist/kernel/manager/persistence.js +0 -60
- package/dist/kernel/manager/persistence.js.map +0 -1
- package/dist/kernel/manager/theme/ThemeManager.cjs.map +0 -1
- package/dist/kernel/manager/theme/ThemeManager.js.map +0 -1
- package/dist/kernel/manager/theme/index.cjs.map +0 -1
- package/dist/kernel/manager/theme/index.js.map +0 -1
- package/dist/kernel/manager/theme/theme.dom.cjs.map +0 -1
- package/dist/kernel/manager/theme/theme.dom.js.map +0 -1
- package/dist/kernel/manager/theme/theme.persistence.cjs.map +0 -1
- package/dist/kernel/manager/theme/theme.persistence.js.map +0 -1
- package/dist/kernel/manager/theme/theme.schema.cjs.map +0 -1
- package/dist/kernel/manager/theme/theme.schema.js.map +0 -1
- package/dist/kernel/manager/themeManager.cjs.map +0 -1
- package/dist/kernel/manager/themeManager.js.map +0 -1
- package/dist/kernel/types.cjs.map +0 -1
- package/dist/kernel/types.js.map +0 -1
- package/dist/library/index.cjs.map +0 -1
- package/dist/library/index.js.map +0 -1
- package/dist/library/locale/index.cjs.map +0 -1
- package/dist/library/locale/index.js.map +0 -1
- package/dist/library/locale/langs/en-us/index.cjs.map +0 -1
- package/dist/library/locale/langs/en-us/index.js.map +0 -1
- package/dist/library/locale/langs/zh-cn/index.cjs.map +0 -1
- package/dist/library/locale/langs/zh-cn/index.js.map +0 -1
- package/dist/library/locale/types.cjs.map +0 -1
- package/dist/library/locale/types.js.map +0 -1
- package/dist/library/storage/cache.cjs.map +0 -1
- package/dist/library/storage/cache.js.map +0 -1
- package/dist/library/storage/encryption.cjs.map +0 -1
- package/dist/library/storage/encryption.js.map +0 -1
- package/dist/library/storage/index.cjs.map +0 -1
- package/dist/library/storage/index.js.map +0 -1
- package/dist/request/adapter/RequestAdapter.d.ts +0 -85
- package/dist/request/adapter/RequestAdapter.js +0 -70
- package/dist/request/adapter/RequestAdapter.js.map +0 -1
- package/dist/request/adapter/axiosAdapter.d.ts +0 -10
- package/dist/request/adapter/axiosAdapter.js +0 -115
- package/dist/request/adapter/axiosAdapter.js.map +0 -1
- package/dist/request/adapter/fetchAdapter.d.ts +0 -10
- package/dist/request/adapter/fetchAdapter.js +0 -126
- package/dist/request/adapter/fetchAdapter.js.map +0 -1
- package/dist/request/adapter/index.d.ts +0 -9
- package/dist/request/adapter/index.js +0 -14
- package/dist/request/adapter/index.js.map +0 -1
- package/dist/request/adapter/kyAdapter.d.ts +0 -10
- package/dist/request/adapter/kyAdapter.js +0 -142
- package/dist/request/adapter/kyAdapter.js.map +0 -1
- package/dist/request/adapter/undiciAdapter.d.ts +0 -10
- package/dist/request/adapter/undiciAdapter.js +0 -164
- package/dist/request/adapter/undiciAdapter.js.map +0 -1
- package/dist/request/adapter.d.ts +0 -1
- package/dist/request/core/RequestClient.d.ts +0 -134
- package/dist/request/core/RequestClient.js +0 -509
- package/dist/request/core/RequestClient.js.map +0 -1
- package/dist/request/core/index.d.ts +0 -5
- package/dist/request/core/index.js +0 -5
- package/dist/request/core/index.js.map +0 -1
- package/dist/request/core.d.ts +0 -1
- package/dist/request/index.d.ts +0 -1
- package/dist/request/index.js +0 -50
- package/dist/request/index.js.map +0 -1
- package/dist/request/plugin/RequestPlugin.d.ts +0 -170
- package/dist/request/plugin/RequestPlugin.js +0 -203
- package/dist/request/plugin/RequestPlugin.js.map +0 -1
- package/dist/request/plugin/cache.d.ts +0 -33
- package/dist/request/plugin/cache.js +0 -264
- package/dist/request/plugin/cache.js.map +0 -1
- package/dist/request/plugin/csrfPlugin.d.ts +0 -21
- package/dist/request/plugin/csrfPlugin.js +0 -44
- package/dist/request/plugin/csrfPlugin.js.map +0 -1
- package/dist/request/plugin/index.d.ts +0 -11
- package/dist/request/plugin/index.js +0 -12
- package/dist/request/plugin/index.js.map +0 -1
- package/dist/request/plugin/monitoring.d.ts +0 -112
- package/dist/request/plugin/monitoring.js +0 -205
- package/dist/request/plugin/monitoring.js.map +0 -1
- package/dist/request/plugin/queue.d.ts +0 -91
- package/dist/request/plugin/queue.js +0 -156
- package/dist/request/plugin/queue.js.map +0 -1
- package/dist/request/plugin/retry.d.ts +0 -34
- package/dist/request/plugin/retry.js +0 -93
- package/dist/request/plugin/retry.js.map +0 -1
- package/dist/request/plugin/validation.d.ts +0 -26
- package/dist/request/plugin/validation.js +0 -116
- package/dist/request/plugin/validation.js.map +0 -1
- package/dist/request/plugin.d.ts +0 -1
- package/dist/request/runtime/RequestContext.d.ts +0 -50
- package/dist/request/runtime/RequestContext.js +0 -86
- package/dist/request/runtime/RequestContext.js.map +0 -1
- package/dist/request/runtime/index.d.ts +0 -4
- package/dist/request/runtime/index.js +0 -5
- package/dist/request/runtime/index.js.map +0 -1
- package/dist/request/runtime.d.ts +0 -1
- package/dist/request/types.d.ts +0 -1
- package/dist/request/types.js +0 -97
- package/dist/request/types.js.map +0 -1
- package/dist/request/utils/RequestQueueManager.d.ts +0 -74
- package/dist/request/utils/RequestQueueManager.js +0 -160
- package/dist/request/utils/RequestQueueManager.js.map +0 -1
- package/dist/request/utils/dependencyCheck.d.ts +0 -63
- package/dist/request/utils/dependencyCheck.js +0 -192
- package/dist/request/utils/dependencyCheck.js.map +0 -1
- package/dist/request/utils/index.d.ts +0 -5
- package/dist/request/utils/index.js +0 -6
- package/dist/request/utils/index.js.map +0 -1
- package/dist/request/utils.d.ts +0 -1
- package/dist/state/StateManager.cjs.map +0 -1
- package/dist/state/StateManager.js.map +0 -1
- package/dist/state/adapters/AdapterFactory.cjs.map +0 -1
- package/dist/state/adapters/AdapterFactory.js.map +0 -1
- package/dist/state/adapters/DefaultAdapter.cjs.map +0 -1
- package/dist/state/adapters/DefaultAdapter.js.map +0 -1
- package/dist/state/adapters/ReduxAdapter.cjs.map +0 -1
- package/dist/state/adapters/ReduxAdapter.js.map +0 -1
- package/dist/state/adapters/ZustandAdapter.cjs.map +0 -1
- package/dist/state/adapters/ZustandAdapter.js.map +0 -1
- package/dist/state/adapters/index.cjs.map +0 -1
- package/dist/state/adapters/index.js.map +0 -1
- package/dist/state/adapters/types.cjs.map +0 -1
- package/dist/state/adapters/types.js.map +0 -1
- package/dist/state/core/DerivedStateInstance.cjs.map +0 -1
- package/dist/state/core/DerivedStateInstance.js.map +0 -1
- package/dist/state/core/StateInstance.cjs.map +0 -1
- package/dist/state/core/StateInstance.js.map +0 -1
- package/dist/state/core/StateRegistry.cjs.map +0 -1
- package/dist/state/core/StateRegistry.js.map +0 -1
- package/dist/state/core/StateScope.cjs.map +0 -1
- package/dist/state/core/StateScope.js.map +0 -1
- package/dist/state/core/index.cjs.map +0 -1
- package/dist/state/core/index.js.map +0 -1
- package/dist/state/index.cjs.map +0 -1
- package/dist/state/index.js.map +0 -1
- package/dist/state/types.cjs.map +0 -1
- package/dist/state/types.js.map +0 -1
- package/dist/state.umd.js.map +0 -1
- package/dist/types.cjs.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/analytics.cjs.map +0 -1
- package/dist/utils/analytics.js.map +0 -1
- package/dist/utils/configSecurity.cjs.map +0 -1
- package/dist/utils/configSecurity.js.map +0 -1
- package/dist/utils/csrf.cjs.map +0 -1
- package/dist/utils/csrf.js.map +0 -1
- package/dist/utils/errors/ErrorCodes.cjs.map +0 -1
- package/dist/utils/errors/ErrorCodes.js.map +0 -1
- package/dist/utils/errors.cjs.map +0 -1
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/logger.cjs.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/logger.types.cjs.map +0 -1
- package/dist/utils/logger.types.js.map +0 -1
- package/dist/utils/monitoring.cjs.map +0 -1
- package/dist/utils/monitoring.js.map +0 -1
- package/dist/utils/performance.cjs.map +0 -1
- package/dist/utils/performance.js.map +0 -1
- package/dist/utils/resourceLoader.cjs.map +0 -1
- package/dist/utils/resourceLoader.js.map +0 -1
- package/dist/utils/runtimeSecurity.cjs.map +0 -1
- package/dist/utils/runtimeSecurity.js.map +0 -1
- package/dist/utils/security.cjs.map +0 -1
- package/dist/utils/security.js.map +0 -1
- package/dist/utils/traceId.cjs.map +0 -1
- package/dist/utils/traceId.js.map +0 -1
- package/dist/utils/validation.cjs.map +0 -1
- package/dist/utils/validation.js.map +0 -1
|
@@ -1,125 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* 插件沙箱
|
|
3
|
-
* 用于插件隔离和权限控制
|
|
4
|
-
*/ function _define_property(obj, key, value) {
|
|
5
|
-
if (key in obj) {
|
|
6
|
-
Object.defineProperty(obj, key, {
|
|
7
|
-
value: value,
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true
|
|
11
|
-
});
|
|
12
|
-
} else {
|
|
13
|
-
obj[key] = value;
|
|
14
|
-
}
|
|
15
|
-
return obj;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 插件权限
|
|
19
|
-
*/ export var PluginPermission = /*#__PURE__*/ function(PluginPermission) {
|
|
20
|
-
/**
|
|
21
|
-
* 访问配置
|
|
22
|
-
*/ PluginPermission["ACCESS_CONFIG"] = "access_config";
|
|
23
|
-
/**
|
|
24
|
-
* 访问状态管理器
|
|
25
|
-
*/ PluginPermission["ACCESS_STATE_MANAGER"] = "access_state_manager";
|
|
26
|
-
/**
|
|
27
|
-
* 访问存储
|
|
28
|
-
*/ PluginPermission["ACCESS_STORAGE"] = "access_storage";
|
|
29
|
-
/**
|
|
30
|
-
* 发布事件
|
|
31
|
-
*/ PluginPermission["EMIT_EVENTS"] = "emit_events";
|
|
32
|
-
/**
|
|
33
|
-
* 订阅事件
|
|
34
|
-
*/ PluginPermission["SUBSCRIBE_EVENTS"] = "subscribe_events";
|
|
35
|
-
return PluginPermission;
|
|
36
|
-
}({});
|
|
37
|
-
/**
|
|
38
|
-
* 插件沙箱
|
|
39
|
-
*/ export class PluginSandbox {
|
|
40
|
-
/**
|
|
41
|
-
* 检查权限
|
|
42
|
-
*
|
|
43
|
-
* @param permission - 权限
|
|
44
|
-
* @returns 是否有权限
|
|
45
|
-
*/ hasPermission(permission) {
|
|
46
|
-
if (!this.config.strictMode) {
|
|
47
|
-
return true; // 非严格模式,允许所有权限
|
|
48
|
-
}
|
|
49
|
-
return this.permissions.has(permission);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* 检查是否可以访问配置键
|
|
53
|
-
*
|
|
54
|
-
* @param key - 配置键
|
|
55
|
-
* @returns 是否可以访问
|
|
56
|
-
*/ canAccessConfig(key) {
|
|
57
|
-
if (!this.hasPermission("access_config")) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
if (this.config.configWhitelist && this.config.configWhitelist.length > 0) {
|
|
61
|
-
return this.config.configWhitelist.includes(key);
|
|
62
|
-
}
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* 检查是否可以访问状态作用域
|
|
67
|
-
*
|
|
68
|
-
* @param scope - 状态作用域
|
|
69
|
-
* @returns 是否可以访问
|
|
70
|
-
*/ canAccessStateScope(scope) {
|
|
71
|
-
if (!this.hasPermission("access_state_manager")) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
if (this.config.stateScopeWhitelist && this.config.stateScopeWhitelist.length > 0) {
|
|
75
|
-
return this.config.stateScopeWhitelist.includes(scope);
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* 过滤配置(根据白名单)
|
|
81
|
-
*
|
|
82
|
-
* @param config - 完整配置
|
|
83
|
-
* @returns 过滤后的配置
|
|
84
|
-
*/ filterConfig(config) {
|
|
85
|
-
if (!this.hasPermission("access_config")) {
|
|
86
|
-
return {};
|
|
87
|
-
}
|
|
88
|
-
if (!this.config.configWhitelist || this.config.configWhitelist.length === 0) {
|
|
89
|
-
return config;
|
|
90
|
-
}
|
|
91
|
-
const filtered = {};
|
|
92
|
-
for (const key of this.config.configWhitelist){
|
|
93
|
-
if (key in config) {
|
|
94
|
-
filtered[key] = config[key];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return filtered;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* 获取沙箱配置
|
|
101
|
-
*/ getConfig() {
|
|
102
|
-
return {
|
|
103
|
-
...this.config
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* 更新权限
|
|
108
|
-
*
|
|
109
|
-
* @param permissions - 权限列表
|
|
110
|
-
*/ updatePermissions(permissions) {
|
|
111
|
-
this.permissions = new Set(permissions);
|
|
112
|
-
this.config.permissions = permissions;
|
|
113
|
-
}
|
|
114
|
-
constructor(config){
|
|
115
|
-
_define_property(this, "config", void 0);
|
|
116
|
-
_define_property(this, "permissions", void 0);
|
|
117
|
-
this.config = {
|
|
118
|
-
strictMode: true,
|
|
119
|
-
...config
|
|
120
|
-
};
|
|
121
|
-
this.permissions = new Set(config.permissions || []);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
//# sourceMappingURL=PluginSandbox.js.map
|
|
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}export var PluginPermission=/*#__PURE__*/function(PluginPermission){PluginPermission["ACCESS_CONFIG"]="access_config";PluginPermission["ACCESS_STATE_MANAGER"]="access_state_manager";PluginPermission["ACCESS_STORAGE"]="access_storage";PluginPermission["EMIT_EVENTS"]="emit_events";PluginPermission["SUBSCRIBE_EVENTS"]="subscribe_events";return PluginPermission}({});export class PluginSandbox{hasPermission(permission){if(!this.config.strictMode){return true}return this.permissions.has(permission)}canAccessConfig(key){if(!this.hasPermission("access_config")){return false}if(this.config.configWhitelist&&this.config.configWhitelist.length>0){return this.config.configWhitelist.includes(key)}return true}canAccessStateScope(scope){if(!this.hasPermission("access_state_manager")){return false}if(this.config.stateScopeWhitelist&&this.config.stateScopeWhitelist.length>0){return this.config.stateScopeWhitelist.includes(scope)}return true}filterConfig(config){if(!this.hasPermission("access_config")){return{}}if(!this.config.configWhitelist||this.config.configWhitelist.length===0){return config}const filtered={};for(const key of this.config.configWhitelist){if(key in config){filtered[key]=config[key]}}return filtered}getConfig(){return{...this.config}}updatePermissions(permissions){this.permissions=new Set(permissions);this.config.permissions=permissions}constructor(config){_define_property(this,"config",void 0);_define_property(this,"permissions",void 0);this.config={strictMode:true,...config};this.permissions=new Set(config.permissions||[])}}
|
package/dist/core/plugin.cjs
CHANGED
package/dist/core/plugin.js
CHANGED
|
@@ -1,438 +1 @@
|
|
|
1
|
-
function _define_property(obj, key,
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
import { PluginSandbox } from "./plugin/PluginSandbox";
|
|
15
|
-
import { pluginEventBus } from "./plugin/PluginEventBus";
|
|
16
|
-
/**
|
|
17
|
-
* 插件管理器
|
|
18
|
-
*
|
|
19
|
-
* 优化:
|
|
20
|
-
* 1. 支持插件依赖管理
|
|
21
|
-
* 2. 支持插件优先级控制
|
|
22
|
-
* 3. 支持插件生命周期管理
|
|
23
|
-
* 4. 支持插件热插拔(动态加载/卸载)
|
|
24
|
-
*/ export class PluginManager {
|
|
25
|
-
/**
|
|
26
|
-
* 注册插件
|
|
27
|
-
*
|
|
28
|
-
* 优化:检查插件依赖是否已注册
|
|
29
|
-
*/ register(plugin) {
|
|
30
|
-
if (this.plugins.has(plugin.name)) {
|
|
31
|
-
console.warn(`插件 ${plugin.name} 已存在,将被覆盖`);
|
|
32
|
-
}
|
|
33
|
-
// 检查依赖是否已注册
|
|
34
|
-
if (plugin.dependencies && plugin.dependencies.length > 0) {
|
|
35
|
-
const missingDeps = plugin.dependencies.filter((dep)=>!this.plugins.has(dep));
|
|
36
|
-
if (missingDeps.length > 0) {
|
|
37
|
-
console.warn(`插件 ${plugin.name} 的依赖未注册: ${missingDeps.join(', ')}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
this.plugins.set(plugin.name, plugin);
|
|
41
|
-
this.pluginStatus.set(plugin.name, 'registered');
|
|
42
|
-
// 创建插件沙箱
|
|
43
|
-
if (plugin.sandbox) {
|
|
44
|
-
const sandbox = new PluginSandbox({
|
|
45
|
-
...plugin.sandbox,
|
|
46
|
-
name: plugin.name
|
|
47
|
-
});
|
|
48
|
-
this.sandboxes.set(plugin.name, sandbox);
|
|
49
|
-
} else {
|
|
50
|
-
// 如果没有配置沙箱,创建默认沙箱(非严格模式)
|
|
51
|
-
const sandbox = new PluginSandbox({
|
|
52
|
-
strictMode: false,
|
|
53
|
-
name: plugin.name
|
|
54
|
-
});
|
|
55
|
-
this.sandboxes.set(plugin.name, sandbox);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* 获取插件加载顺序(考虑依赖和优先级)
|
|
60
|
-
*
|
|
61
|
-
* @returns 插件名称数组,按加载顺序排列
|
|
62
|
-
*/ getLoadOrder() {
|
|
63
|
-
const plugins = Array.from(this.plugins.values());
|
|
64
|
-
// 按优先级排序
|
|
65
|
-
const sortedPlugins = plugins.sort((a, b)=>{
|
|
66
|
-
const priorityA = a.priority ?? 100;
|
|
67
|
-
const priorityB = b.priority ?? 100;
|
|
68
|
-
return priorityA - priorityB;
|
|
69
|
-
});
|
|
70
|
-
// 构建依赖图并拓扑排序
|
|
71
|
-
const visited = new Set();
|
|
72
|
-
const visiting = new Set();
|
|
73
|
-
const result = [];
|
|
74
|
-
const visit = (pluginName)=>{
|
|
75
|
-
if (visiting.has(pluginName)) {
|
|
76
|
-
console.warn(`检测到循环依赖,涉及插件: ${pluginName}`);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (visited.has(pluginName)) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
visiting.add(pluginName);
|
|
83
|
-
const plugin = this.plugins.get(pluginName);
|
|
84
|
-
if (plugin?.dependencies) {
|
|
85
|
-
for (const dep of plugin.dependencies){
|
|
86
|
-
visit(dep);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
visiting.delete(pluginName);
|
|
90
|
-
visited.add(pluginName);
|
|
91
|
-
result.push(pluginName);
|
|
92
|
-
};
|
|
93
|
-
for (const plugin of sortedPlugins){
|
|
94
|
-
visit(plugin.name);
|
|
95
|
-
}
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* 注销插件
|
|
100
|
-
*/ unregister(name) {
|
|
101
|
-
const plugin = this.plugins.get(name);
|
|
102
|
-
if (plugin && plugin.destroy) {
|
|
103
|
-
plugin.destroy();
|
|
104
|
-
}
|
|
105
|
-
this.plugins.delete(name);
|
|
106
|
-
this.sandboxes.delete(name);
|
|
107
|
-
this.pluginStatus.delete(name);
|
|
108
|
-
this.pluginLoaders.delete(name);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* 动态加载插件(热插拔)
|
|
112
|
-
*
|
|
113
|
-
* @param options - 插件加载选项
|
|
114
|
-
* @returns 加载的插件
|
|
115
|
-
*/ async loadPlugin(options) {
|
|
116
|
-
let plugin;
|
|
117
|
-
if (options.url) {
|
|
118
|
-
// 从URL加载插件
|
|
119
|
-
const response = await fetch(options.url);
|
|
120
|
-
if (!response.ok) {
|
|
121
|
-
throw new Error(`无法加载插件: ${options.url} (${response.status})`);
|
|
122
|
-
}
|
|
123
|
-
const pluginModule = await response.json();
|
|
124
|
-
plugin = pluginModule.default || pluginModule;
|
|
125
|
-
} else if (options.modulePath) {
|
|
126
|
-
// 从模块路径动态导入
|
|
127
|
-
const pluginModule = await import(/* @vite-ignore */ options.modulePath);
|
|
128
|
-
plugin = pluginModule.default || pluginModule;
|
|
129
|
-
} else {
|
|
130
|
-
throw new Error('必须提供 url 或 modulePath');
|
|
131
|
-
}
|
|
132
|
-
if (!plugin || !plugin.name) {
|
|
133
|
-
throw new Error('插件格式无效:必须包含 name 属性');
|
|
134
|
-
}
|
|
135
|
-
// 检查插件是否已加载
|
|
136
|
-
if (this.plugins.has(plugin.name)) {
|
|
137
|
-
throw new Error(`插件 ${plugin.name} 已加载`);
|
|
138
|
-
}
|
|
139
|
-
// 设置加载状态
|
|
140
|
-
this.pluginStatus.set(plugin.name, 'loading');
|
|
141
|
-
try {
|
|
142
|
-
// 注册插件
|
|
143
|
-
this.register(plugin);
|
|
144
|
-
// 如果要求立即初始化
|
|
145
|
-
if (options.initialize && options.initContext && options.startOptions) {
|
|
146
|
-
await this.initializePlugin(plugin.name, options.startOptions, options.initContext);
|
|
147
|
-
}
|
|
148
|
-
return plugin;
|
|
149
|
-
} catch (error) {
|
|
150
|
-
this.pluginStatus.delete(plugin.name);
|
|
151
|
-
throw error;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* 初始化单个插件
|
|
156
|
-
*
|
|
157
|
-
* @param name - 插件名称
|
|
158
|
-
* @param options - 启动选项
|
|
159
|
-
* @param context - 初始化上下文
|
|
160
|
-
*/ async initializePlugin(name, options, context) {
|
|
161
|
-
const plugin = this.plugins.get(name);
|
|
162
|
-
if (!plugin) {
|
|
163
|
-
throw new Error(`插件 ${name} 未注册`);
|
|
164
|
-
}
|
|
165
|
-
const status = this.pluginStatus.get(name);
|
|
166
|
-
if (status === 'initialized') {
|
|
167
|
-
return; // 已经初始化
|
|
168
|
-
}
|
|
169
|
-
try {
|
|
170
|
-
const sandbox = this.sandboxes.get(name);
|
|
171
|
-
if (!sandbox) {
|
|
172
|
-
throw new Error(`插件 ${name} 的沙箱未找到`);
|
|
173
|
-
}
|
|
174
|
-
// 执行初始化钩子
|
|
175
|
-
if (plugin.init) {
|
|
176
|
-
const filteredOptions = sandbox.filterConfig(options);
|
|
177
|
-
await plugin.init(filteredOptions, context, sandbox, pluginEventBus);
|
|
178
|
-
}
|
|
179
|
-
this.pluginStatus.set(name, 'initialized');
|
|
180
|
-
} catch (error) {
|
|
181
|
-
console.error(`插件 ${name} 初始化失败:`, error);
|
|
182
|
-
throw error;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* 卸载插件(热插拔)
|
|
187
|
-
*
|
|
188
|
-
* @param name - 插件名称
|
|
189
|
-
* @param force - 是否强制卸载(即使有依赖)
|
|
190
|
-
*/ async unloadPlugin(name, force = false) {
|
|
191
|
-
const plugin = this.plugins.get(name);
|
|
192
|
-
if (!plugin) {
|
|
193
|
-
throw new Error(`插件 ${name} 未加载`);
|
|
194
|
-
}
|
|
195
|
-
// 检查是否有其他插件依赖此插件
|
|
196
|
-
if (!force) {
|
|
197
|
-
const dependents = Array.from(this.plugins.values()).filter((p)=>p.dependencies && p.dependencies.includes(name));
|
|
198
|
-
if (dependents.length > 0) {
|
|
199
|
-
throw new Error(`无法卸载插件 ${name},以下插件依赖它: ${dependents.map((p)=>p.name).join(', ')}`);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
// 执行销毁钩子
|
|
203
|
-
if (plugin.destroy) {
|
|
204
|
-
try {
|
|
205
|
-
await plugin.destroy();
|
|
206
|
-
} catch (error) {
|
|
207
|
-
console.error(`插件 ${name} 的 destroy 钩子执行失败:`, error);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
// 从事件总线移除相关监听器(如果有)
|
|
211
|
-
// 注意:事件总线是全局的,这里只移除插件相关的事件
|
|
212
|
-
// 实际实现可能需要更细粒度的控制
|
|
213
|
-
// 清理插件
|
|
214
|
-
this.unregister(name);
|
|
215
|
-
this.pluginStatus.set(name, 'destroyed');
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* 检查插件是否可以热加载
|
|
219
|
-
*
|
|
220
|
-
* @param plugin - 插件
|
|
221
|
-
* @returns 是否可以热加载
|
|
222
|
-
*/ canHotLoad(plugin) {
|
|
223
|
-
// 检查依赖是否都已加载
|
|
224
|
-
if (plugin.dependencies && plugin.dependencies.length > 0) {
|
|
225
|
-
const missingDeps = plugin.dependencies.filter((dep)=>!this.plugins.has(dep));
|
|
226
|
-
if (missingDeps.length > 0) {
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return true;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* 注册插件加载器(用于延迟加载)
|
|
234
|
-
*
|
|
235
|
-
* @param name - 插件名称
|
|
236
|
-
* @param loader - 加载器函数
|
|
237
|
-
*/ registerLoader(name, loader) {
|
|
238
|
-
this.pluginLoaders.set(name, loader);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* 使用加载器加载插件
|
|
242
|
-
*
|
|
243
|
-
* @param name - 插件名称
|
|
244
|
-
* @param options - 加载选项
|
|
245
|
-
* @returns 加载的插件
|
|
246
|
-
*/ async loadPluginByLoader(name, options) {
|
|
247
|
-
const loader = this.pluginLoaders.get(name);
|
|
248
|
-
if (!loader) {
|
|
249
|
-
throw new Error(`插件 ${name} 的加载器未注册`);
|
|
250
|
-
}
|
|
251
|
-
const plugin = await loader();
|
|
252
|
-
if (!plugin || !plugin.name) {
|
|
253
|
-
throw new Error('插件格式无效:必须包含 name 属性');
|
|
254
|
-
}
|
|
255
|
-
if (plugin.name !== name) {
|
|
256
|
-
throw new Error(`插件名称不匹配: 期望 ${name},实际 ${plugin.name}`);
|
|
257
|
-
}
|
|
258
|
-
// 检查插件是否已加载
|
|
259
|
-
if (this.plugins.has(plugin.name)) {
|
|
260
|
-
return this.plugins.get(plugin.name);
|
|
261
|
-
}
|
|
262
|
-
// 设置加载状态
|
|
263
|
-
this.pluginStatus.set(plugin.name, 'loading');
|
|
264
|
-
try {
|
|
265
|
-
// 注册插件
|
|
266
|
-
this.register(plugin);
|
|
267
|
-
// 如果要求立即初始化
|
|
268
|
-
if (options?.initialize && options.initContext && options.startOptions) {
|
|
269
|
-
await this.initializePlugin(plugin.name, options.startOptions, options.initContext);
|
|
270
|
-
}
|
|
271
|
-
return plugin;
|
|
272
|
-
} catch (error) {
|
|
273
|
-
this.pluginStatus.delete(plugin.name);
|
|
274
|
-
throw error;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* 获取插件
|
|
279
|
-
*/ get(name) {
|
|
280
|
-
return this.plugins.get(name);
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* 获取所有插件
|
|
284
|
-
*/ getAll() {
|
|
285
|
-
return Array.from(this.plugins.values());
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* 执行初始化前钩子
|
|
289
|
-
*
|
|
290
|
-
* 优化:按依赖顺序执行
|
|
291
|
-
*/ async executeBeforeInit(options) {
|
|
292
|
-
const loadOrder = this.getLoadOrder();
|
|
293
|
-
for (const pluginName of loadOrder){
|
|
294
|
-
const plugin = this.plugins.get(pluginName);
|
|
295
|
-
if (!plugin || !plugin.beforeInit) {
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
|
-
try {
|
|
299
|
-
const sandbox = this.sandboxes.get(plugin.name);
|
|
300
|
-
if (!sandbox) {
|
|
301
|
-
console.warn(`插件 ${plugin.name} 的沙箱未找到`);
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
// 根据沙箱配置过滤选项
|
|
305
|
-
const filteredOptions = sandbox.filterConfig(options);
|
|
306
|
-
await plugin.beforeInit(filteredOptions, sandbox, pluginEventBus);
|
|
307
|
-
} catch (error) {
|
|
308
|
-
console.error(`插件 ${plugin.name} 的 beforeInit 钩子执行失败:`, error);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* 执行初始化钩子
|
|
314
|
-
*
|
|
315
|
-
* 优化:按依赖顺序执行,并更新插件状态
|
|
316
|
-
*/ async executeInit(options, context) {
|
|
317
|
-
const loadOrder = this.getLoadOrder();
|
|
318
|
-
for (const pluginName of loadOrder){
|
|
319
|
-
const plugin = this.plugins.get(pluginName);
|
|
320
|
-
if (!plugin || !plugin.init) {
|
|
321
|
-
continue;
|
|
322
|
-
}
|
|
323
|
-
try {
|
|
324
|
-
const sandbox = this.sandboxes.get(plugin.name);
|
|
325
|
-
if (!sandbox) {
|
|
326
|
-
console.warn(`插件 ${plugin.name} 的沙箱未找到`);
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
-
// 根据沙箱配置过滤选项
|
|
330
|
-
const filteredOptions = sandbox.filterConfig(options);
|
|
331
|
-
await plugin.init(filteredOptions, context, sandbox, pluginEventBus);
|
|
332
|
-
this.pluginStatus.set(plugin.name, 'initialized');
|
|
333
|
-
} catch (error) {
|
|
334
|
-
console.error(`插件 ${plugin.name} 的 init 钩子执行失败:`, error);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* 执行初始化后钩子
|
|
340
|
-
*
|
|
341
|
-
* 优化:按依赖顺序执行(逆序,确保依赖插件先执行)
|
|
342
|
-
*/ async executeAfterInit(options, context) {
|
|
343
|
-
const loadOrder = this.getLoadOrder();
|
|
344
|
-
// 逆序执行,确保依赖插件先执行
|
|
345
|
-
const reverseOrder = [
|
|
346
|
-
...loadOrder
|
|
347
|
-
].reverse();
|
|
348
|
-
for (const pluginName of reverseOrder){
|
|
349
|
-
const plugin = this.plugins.get(pluginName);
|
|
350
|
-
if (!plugin || !plugin.afterInit) {
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
try {
|
|
354
|
-
const sandbox = this.sandboxes.get(plugin.name);
|
|
355
|
-
if (!sandbox) {
|
|
356
|
-
console.warn(`插件 ${plugin.name} 的沙箱未找到`);
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
|
-
// 根据沙箱配置过滤选项
|
|
360
|
-
const filteredOptions = sandbox.filterConfig(options);
|
|
361
|
-
await plugin.afterInit(filteredOptions, context, sandbox, pluginEventBus);
|
|
362
|
-
} catch (error) {
|
|
363
|
-
console.error(`插件 ${plugin.name} 的 afterInit 钩子执行失败:`, error);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* 获取插件状态
|
|
369
|
-
*
|
|
370
|
-
* @param name - 插件名称
|
|
371
|
-
* @returns 插件状态
|
|
372
|
-
*/ getPluginStatus(name) {
|
|
373
|
-
return this.pluginStatus.get(name);
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* 检查插件是否已加载
|
|
377
|
-
*
|
|
378
|
-
* @param name - 插件名称
|
|
379
|
-
* @returns 是否已加载
|
|
380
|
-
*/ isLoaded(name) {
|
|
381
|
-
return this.plugins.has(name);
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* 获取已加载的插件列表
|
|
385
|
-
*
|
|
386
|
-
* @returns 插件名称数组
|
|
387
|
-
*/ getLoadedPlugins() {
|
|
388
|
-
return Array.from(this.plugins.keys());
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* 获取所有插件状态
|
|
392
|
-
*
|
|
393
|
-
* @returns 插件状态映射
|
|
394
|
-
*/ getAllPluginStatus() {
|
|
395
|
-
return new Map(this.pluginStatus);
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* 获取插件沙箱
|
|
399
|
-
*
|
|
400
|
-
* @param name - 插件名称
|
|
401
|
-
* @returns 插件沙箱或undefined
|
|
402
|
-
*/ getSandbox(name) {
|
|
403
|
-
return this.sandboxes.get(name);
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* 获取事件总线
|
|
407
|
-
*/ getEventBus() {
|
|
408
|
-
return pluginEventBus;
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* 销毁所有插件
|
|
412
|
-
*/ async destroyAll() {
|
|
413
|
-
for (const plugin of this.plugins.values()){
|
|
414
|
-
if (plugin.destroy) {
|
|
415
|
-
try {
|
|
416
|
-
await plugin.destroy();
|
|
417
|
-
} catch (error) {
|
|
418
|
-
console.error(`插件 ${plugin.name} 的 destroy 钩子执行失败:`, error);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
this.plugins.clear();
|
|
423
|
-
}
|
|
424
|
-
constructor(){
|
|
425
|
-
_define_property(this, "plugins", new Map());
|
|
426
|
-
_define_property(this, "sandboxes", new Map());
|
|
427
|
-
_define_property(this, "pluginStatus", new Map());
|
|
428
|
-
_define_property(this, "pluginLoaders", new Map());
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* 默认插件管理器
|
|
433
|
-
*/ export const pluginManager = new PluginManager();
|
|
434
|
-
// 导出插件相关类型和工具
|
|
435
|
-
export { PluginSandbox, PluginPermission } from "./plugin/PluginSandbox";
|
|
436
|
-
export { PluginEventBus, pluginEventBus } from "./plugin/PluginEventBus";
|
|
437
|
-
|
|
438
|
-
//# sourceMappingURL=plugin.js.map
|
|
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{PluginSandbox}from"./plugin/PluginSandbox";import{pluginEventBus}from"./plugin/PluginEventBus";export class PluginManager{register(plugin){if(this.plugins.has(plugin.name)){console.warn(`插件 ${plugin.name} 已存在,将被覆盖`)}if(plugin.dependencies&&plugin.dependencies.length>0){const missingDeps=plugin.dependencies.filter(dep=>!this.plugins.has(dep));if(missingDeps.length>0){console.warn(`插件 ${plugin.name} 的依赖未注册: ${missingDeps.join(", ")}`)}}this.plugins.set(plugin.name,plugin);this.pluginStatus.set(plugin.name,"registered");if(plugin.sandbox){const sandbox=new PluginSandbox({...plugin.sandbox,name:plugin.name});this.sandboxes.set(plugin.name,sandbox)}else{const sandbox=new PluginSandbox({strictMode:false,name:plugin.name});this.sandboxes.set(plugin.name,sandbox)}}getLoadOrder(){const plugins=Array.from(this.plugins.values());const sortedPlugins=plugins.sort((a,b)=>{const priorityA=a.priority??100;const priorityB=b.priority??100;return priorityA-priorityB});const visited=new Set;const visiting=new Set;const result=[];const visit=pluginName=>{if(visiting.has(pluginName)){console.warn(`检测到循环依赖,涉及插件: ${pluginName}`);return}if(visited.has(pluginName)){return}visiting.add(pluginName);const plugin=this.plugins.get(pluginName);if(plugin?.dependencies){for(const dep of plugin.dependencies){visit(dep)}}visiting.delete(pluginName);visited.add(pluginName);result.push(pluginName)};for(const plugin of sortedPlugins){visit(plugin.name)}return result}unregister(name){const plugin=this.plugins.get(name);if(plugin&&plugin.destroy){plugin.destroy()}this.plugins.delete(name);this.sandboxes.delete(name);this.pluginStatus.delete(name);this.pluginLoaders.delete(name)}async loadPlugin(options){let plugin;if(options.url){const response=await fetch(options.url);if(!response.ok){throw new Error(`无法加载插件: ${options.url} (${response.status})`)}const pluginModule=await response.json();plugin=pluginModule.default||pluginModule}else if(options.modulePath){const pluginModule=await import(options.modulePath);plugin=pluginModule.default||pluginModule}else{throw new Error("必须提供 url 或 modulePath")}if(!plugin||!plugin.name){throw new Error("插件格式无效:必须包含 name 属性")}if(this.plugins.has(plugin.name)){throw new Error(`插件 ${plugin.name} 已加载`)}this.pluginStatus.set(plugin.name,"loading");try{this.register(plugin);if(options.initialize&&options.initContext&&options.startOptions){await this.initializePlugin(plugin.name,options.startOptions,options.initContext)}return plugin}catch(error){this.pluginStatus.delete(plugin.name);throw error}}async initializePlugin(name,options,context){const plugin=this.plugins.get(name);if(!plugin){throw new Error(`插件 ${name} 未注册`)}const status=this.pluginStatus.get(name);if(status==="initialized"){return}try{const sandbox=this.sandboxes.get(name);if(!sandbox){throw new Error(`插件 ${name} 的沙箱未找到`)}if(plugin.init){const filteredOptions=sandbox.filterConfig(options);await plugin.init(filteredOptions,context,sandbox,pluginEventBus)}this.pluginStatus.set(name,"initialized")}catch(error){console.error(`插件 ${name} 初始化失败:`,error);throw error}}async unloadPlugin(name,force=false){const plugin=this.plugins.get(name);if(!plugin){throw new Error(`插件 ${name} 未加载`)}if(!force){const dependents=Array.from(this.plugins.values()).filter(p=>p.dependencies&&p.dependencies.includes(name));if(dependents.length>0){throw new Error(`无法卸载插件 ${name},以下插件依赖它: ${dependents.map(p=>p.name).join(", ")}`)}}if(plugin.destroy){try{await plugin.destroy()}catch(error){console.error(`插件 ${name} 的 destroy 钩子执行失败:`,error)}}this.unregister(name);this.pluginStatus.set(name,"destroyed")}canHotLoad(plugin){if(plugin.dependencies&&plugin.dependencies.length>0){const missingDeps=plugin.dependencies.filter(dep=>!this.plugins.has(dep));if(missingDeps.length>0){return false}}return true}registerLoader(name,loader){this.pluginLoaders.set(name,loader)}async loadPluginByLoader(name,options){const loader=this.pluginLoaders.get(name);if(!loader){throw new Error(`插件 ${name} 的加载器未注册`)}const plugin=await loader();if(!plugin||!plugin.name){throw new Error("插件格式无效:必须包含 name 属性")}if(plugin.name!==name){throw new Error(`插件名称不匹配: 期望 ${name},实际 ${plugin.name}`)}if(this.plugins.has(plugin.name)){return this.plugins.get(plugin.name)}this.pluginStatus.set(plugin.name,"loading");try{this.register(plugin);if(options?.initialize&&options.initContext&&options.startOptions){await this.initializePlugin(plugin.name,options.startOptions,options.initContext)}return plugin}catch(error){this.pluginStatus.delete(plugin.name);throw error}}get(name){return this.plugins.get(name)}getAll(){return Array.from(this.plugins.values())}async executeBeforeInit(options){const loadOrder=this.getLoadOrder();for(const pluginName of loadOrder){const plugin=this.plugins.get(pluginName);if(!plugin||!plugin.beforeInit){continue}try{const sandbox=this.sandboxes.get(plugin.name);if(!sandbox){console.warn(`插件 ${plugin.name} 的沙箱未找到`);continue}const filteredOptions=sandbox.filterConfig(options);await plugin.beforeInit(filteredOptions,sandbox,pluginEventBus)}catch(error){console.error(`插件 ${plugin.name} 的 beforeInit 钩子执行失败:`,error)}}}async executeInit(options,context){const loadOrder=this.getLoadOrder();for(const pluginName of loadOrder){const plugin=this.plugins.get(pluginName);if(!plugin||!plugin.init){continue}try{const sandbox=this.sandboxes.get(plugin.name);if(!sandbox){console.warn(`插件 ${plugin.name} 的沙箱未找到`);continue}const filteredOptions=sandbox.filterConfig(options);await plugin.init(filteredOptions,context,sandbox,pluginEventBus);this.pluginStatus.set(plugin.name,"initialized")}catch(error){console.error(`插件 ${plugin.name} 的 init 钩子执行失败:`,error)}}}async executeAfterInit(options,context){const loadOrder=this.getLoadOrder();const reverseOrder=[...loadOrder].reverse();for(const pluginName of reverseOrder){const plugin=this.plugins.get(pluginName);if(!plugin||!plugin.afterInit){continue}try{const sandbox=this.sandboxes.get(plugin.name);if(!sandbox){console.warn(`插件 ${plugin.name} 的沙箱未找到`);continue}const filteredOptions=sandbox.filterConfig(options);await plugin.afterInit(filteredOptions,context,sandbox,pluginEventBus)}catch(error){console.error(`插件 ${plugin.name} 的 afterInit 钩子执行失败:`,error)}}}getPluginStatus(name){return this.pluginStatus.get(name)}isLoaded(name){return this.plugins.has(name)}getLoadedPlugins(){return Array.from(this.plugins.keys())}getAllPluginStatus(){return new Map(this.pluginStatus)}getSandbox(name){return this.sandboxes.get(name)}getEventBus(){return pluginEventBus}async destroyAll(){for(const plugin of this.plugins.values()){if(plugin.destroy){try{await plugin.destroy()}catch(error){console.error(`插件 ${plugin.name} 的 destroy 钩子执行失败:`,error)}}}this.plugins.clear()}constructor(){_define_property(this,"plugins",new Map);_define_property(this,"sandboxes",new Map);_define_property(this,"pluginStatus",new Map);_define_property(this,"pluginLoaders",new Map)}}export const pluginManager=new PluginManager;export{PluginSandbox,PluginPermission}from"./plugin/PluginSandbox";export{PluginEventBus,pluginEventBus}from"./plugin/PluginEventBus";
|