@vlian/framework 1.2.16 → 1.2.19

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 (58) hide show
  1. package/dist/analytics.umd.js +1 -1
  2. package/dist/core/router/RouterManager.cjs +52 -3
  3. package/dist/core/router/RouterManager.cjs.map +1 -1
  4. package/dist/core/router/RouterManager.d.ts +5 -0
  5. package/dist/core/router/RouterManager.js +53 -4
  6. package/dist/core/router/RouterManager.js.map +1 -1
  7. package/dist/core/router/adapter/react-router/ReactRouterAdapter.cjs +1 -1
  8. package/dist/core/router/adapter/react-router/ReactRouterAdapter.cjs.map +1 -1
  9. package/dist/core/router/adapter/react-router/ReactRouterAdapter.js +1 -1
  10. package/dist/core/router/adapter/react-router/ReactRouterAdapter.js.map +1 -1
  11. package/dist/core/router/dev/RouterDevTools.cjs.map +1 -1
  12. package/dist/core/router/dev/RouterDevTools.js.map +1 -1
  13. package/dist/core/router/middleware/RouterMiddlewareManager.cjs +24 -4
  14. package/dist/core/router/middleware/RouterMiddlewareManager.cjs.map +1 -1
  15. package/dist/core/router/middleware/RouterMiddlewareManager.d.ts +1 -0
  16. package/dist/core/router/middleware/RouterMiddlewareManager.js +24 -4
  17. package/dist/core/router/middleware/RouterMiddlewareManager.js.map +1 -1
  18. package/dist/core/router/middleware/types.cjs.map +1 -1
  19. package/dist/core/router/middleware/types.d.ts +1 -1
  20. package/dist/core/router/middleware/types.js.map +1 -1
  21. package/dist/core/router/navigation/RouterNavigation.cjs +69 -14
  22. package/dist/core/router/navigation/RouterNavigation.cjs.map +1 -1
  23. package/dist/core/router/navigation/RouterNavigation.d.ts +3 -0
  24. package/dist/core/router/navigation/RouterNavigation.js +69 -14
  25. package/dist/core/router/navigation/RouterNavigation.js.map +1 -1
  26. package/dist/core/router/performance/RouteCache.cjs +34 -13
  27. package/dist/core/router/performance/RouteCache.cjs.map +1 -1
  28. package/dist/core/router/performance/RouteCache.d.ts +8 -2
  29. package/dist/core/router/performance/RouteCache.js +34 -13
  30. package/dist/core/router/performance/RouteCache.js.map +1 -1
  31. package/dist/core/router/performance/RoutePreloader.cjs +89 -22
  32. package/dist/core/router/performance/RoutePreloader.cjs.map +1 -1
  33. package/dist/core/router/performance/RoutePreloader.d.ts +9 -1
  34. package/dist/core/router/performance/RoutePreloader.js +89 -22
  35. package/dist/core/router/performance/RoutePreloader.js.map +1 -1
  36. package/dist/core/router/types.d.ts +31 -5
  37. package/dist/core/router/types.js.map +1 -1
  38. package/dist/core/router/utils/adapters/react-router/transform.cjs +43 -65
  39. package/dist/core/router/utils/adapters/react-router/transform.cjs.map +1 -1
  40. package/dist/core/router/utils/adapters/react-router/transform.d.ts +1 -1
  41. package/dist/core/router/utils/adapters/react-router/transform.js +43 -60
  42. package/dist/core/router/utils/adapters/react-router/transform.js.map +1 -1
  43. package/dist/core/router/utils/transform.cjs +79 -70
  44. package/dist/core/router/utils/transform.cjs.map +1 -1
  45. package/dist/core/router/utils/transform.d.ts +1 -1
  46. package/dist/core/router/utils/transform.js +80 -71
  47. package/dist/core/router/utils/transform.js.map +1 -1
  48. package/dist/core/router/validation/RouterConfigValidator.d.ts +68 -4
  49. package/dist/core/router/validation/schema.cjs +72 -2
  50. package/dist/core/router/validation/schema.cjs.map +1 -1
  51. package/dist/core/router/validation/schema.d.ts +105 -6
  52. package/dist/core/router/validation/schema.js +72 -2
  53. package/dist/core/router/validation/schema.js.map +1 -1
  54. package/dist/index.umd.js +705 -431
  55. package/dist/index.umd.js.map +1 -1
  56. package/dist/request.umd.js +1 -1
  57. package/dist/state.umd.js +1 -1
  58. package/package.json +1 -1
package/dist/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @vlian/framework v1.2.16
2
+ * @vlian/framework v1.2.19
3
3
  * Secra Framework - 一个现代化的低代码框架
4
4
  * (c) 2026 Secra Framework Contributors
5
5
  * Licensed under Apache-2.0
@@ -15285,7 +15285,7 @@
15285
15285
 
15286
15286
  var distExports = /*@__PURE__*/ requireDist();
15287
15287
 
15288
- function _define_property$R(obj, key, value) {
15288
+ function _define_property$S(obj, key, value) {
15289
15289
  if (key in obj) {
15290
15290
  Object.defineProperty(obj, key, {
15291
15291
  value: value,
@@ -15508,11 +15508,11 @@
15508
15508
  // 注意:存储缓存的清理由存储系统自己处理(通过过期时间)
15509
15509
  }
15510
15510
  constructor(storage, config = {}){
15511
- _define_property$R(this, "memoryCache", new Map());
15512
- _define_property$R(this, "storage", void 0);
15513
- _define_property$R(this, "config", void 0);
15514
- _define_property$R(this, "head", null);
15515
- _define_property$R(this, "tail", null);
15511
+ _define_property$S(this, "memoryCache", new Map());
15512
+ _define_property$S(this, "storage", void 0);
15513
+ _define_property$S(this, "config", void 0);
15514
+ _define_property$S(this, "head", null);
15515
+ _define_property$S(this, "tail", null);
15516
15516
  this.storage = storage;
15517
15517
  this.config = {
15518
15518
  defaultTTL: config.defaultTTL ?? 24 * 60 * 60 * 1000,
@@ -16981,7 +16981,7 @@
16981
16981
  return baseMessage;
16982
16982
  }
16983
16983
 
16984
- function _define_property$Q(obj, key, value) {
16984
+ function _define_property$R(obj, key, value) {
16985
16985
  if (key in obj) {
16986
16986
  Object.defineProperty(obj, key, {
16987
16987
  value: value,
@@ -17065,17 +17065,17 @@
17065
17065
  constructor(message, type = "UNKNOWN", severity = "MEDIUM", options){
17066
17066
  super(message), /**
17067
17067
  * 错误类型
17068
- */ _define_property$Q(this, "type", void 0), /**
17068
+ */ _define_property$R(this, "type", void 0), /**
17069
17069
  * 错误严重程度
17070
- */ _define_property$Q(this, "severity", void 0), /**
17070
+ */ _define_property$R(this, "severity", void 0), /**
17071
17071
  * 错误代码
17072
- */ _define_property$Q(this, "code", void 0), /**
17072
+ */ _define_property$R(this, "code", void 0), /**
17073
17073
  * 原始错误
17074
- */ _define_property$Q(this, "originalError", void 0), /**
17074
+ */ _define_property$R(this, "originalError", void 0), /**
17075
17075
  * 错误上下文
17076
- */ _define_property$Q(this, "context", void 0), /**
17076
+ */ _define_property$R(this, "context", void 0), /**
17077
17077
  * 是否可恢复
17078
- */ _define_property$Q(this, "recoverable", void 0);
17078
+ */ _define_property$R(this, "recoverable", void 0);
17079
17079
  this.name = 'FrameworkError';
17080
17080
  this.type = type;
17081
17081
  this.severity = severity;
@@ -17641,7 +17641,7 @@
17641
17641
  }
17642
17642
  }
17643
17643
 
17644
- function _define_property$P(obj, key, value) {
17644
+ function _define_property$Q(obj, key, value) {
17645
17645
  if (key in obj) {
17646
17646
  Object.defineProperty(obj, key, {
17647
17647
  value: value,
@@ -17730,16 +17730,16 @@
17730
17730
  /**
17731
17731
  * 私有构造函数,防止外部直接实例化
17732
17732
  */ constructor(){
17733
- _define_property$P(this, "_local", void 0);
17734
- _define_property$P(this, "_session", void 0);
17735
- _define_property$P(this, "_indexedDB", void 0);
17736
- _define_property$P(this, "_localCache", void 0);
17737
- _define_property$P(this, "_sessionCache", void 0);
17738
- _define_property$P(this, "cacheEnabled", false);
17733
+ _define_property$Q(this, "_local", void 0);
17734
+ _define_property$Q(this, "_session", void 0);
17735
+ _define_property$Q(this, "_indexedDB", void 0);
17736
+ _define_property$Q(this, "_localCache", void 0);
17737
+ _define_property$Q(this, "_sessionCache", void 0);
17738
+ _define_property$Q(this, "cacheEnabled", false);
17739
17739
  // 私有构造函数
17740
17740
  }
17741
17741
  };
17742
- _define_property$P(Storage, "instance", null);
17742
+ _define_property$Q(Storage, "instance", null);
17743
17743
  const storage = Storage.getInstance();
17744
17744
 
17745
17745
  /**
@@ -17753,7 +17753,7 @@
17753
17753
  return LogLevel;
17754
17754
  }({});
17755
17755
 
17756
- function _define_property$O(obj, key, value) {
17756
+ function _define_property$P(obj, key, value) {
17757
17757
  if (key in obj) {
17758
17758
  Object.defineProperty(obj, key, {
17759
17759
  value: value,
@@ -17818,12 +17818,12 @@
17818
17818
  }
17819
17819
  }
17820
17820
  constructor(prefix = ''){
17821
- _define_property$O(this, "counter", 0);
17822
- _define_property$O(this, "prefix", void 0);
17821
+ _define_property$P(this, "counter", 0);
17822
+ _define_property$P(this, "prefix", void 0);
17823
17823
  this.prefix = prefix;
17824
17824
  }
17825
17825
  }
17826
- _define_property$O(TraceIdGenerator, "instance", null);
17826
+ _define_property$P(TraceIdGenerator, "instance", null);
17827
17827
  /**
17828
17828
  * 全局追踪 ID 生成器实例
17829
17829
  */ let globalTraceIdGenerator = null;
@@ -17870,7 +17870,7 @@
17870
17870
  currentTraceId = null;
17871
17871
  }
17872
17872
 
17873
- function _define_property$N(obj, key, value) {
17873
+ function _define_property$O(obj, key, value) {
17874
17874
  if (key in obj) {
17875
17875
  Object.defineProperty(obj, key, {
17876
17876
  value: value,
@@ -18203,16 +18203,16 @@
18203
18203
  this.log(LogLevel.ERROR, ...args);
18204
18204
  }
18205
18205
  constructor(options = {}){
18206
- _define_property$N(this, "level", void 0);
18207
- _define_property$N(this, "enableColors", void 0);
18208
- _define_property$N(this, "showTimestamp", void 0);
18209
- _define_property$N(this, "showLevel", void 0);
18210
- _define_property$N(this, "prefix", void 0);
18211
- _define_property$N(this, "enableSanitization", void 0);
18212
- _define_property$N(this, "isProduction", void 0);
18213
- _define_property$N(this, "format", void 0);
18214
- _define_property$N(this, "context", {});
18215
- _define_property$N(this, "logHandlers", []);
18206
+ _define_property$O(this, "level", void 0);
18207
+ _define_property$O(this, "enableColors", void 0);
18208
+ _define_property$O(this, "showTimestamp", void 0);
18209
+ _define_property$O(this, "showLevel", void 0);
18210
+ _define_property$O(this, "prefix", void 0);
18211
+ _define_property$O(this, "enableSanitization", void 0);
18212
+ _define_property$O(this, "isProduction", void 0);
18213
+ _define_property$O(this, "format", void 0);
18214
+ _define_property$O(this, "context", {});
18215
+ _define_property$O(this, "logHandlers", []);
18216
18216
  this.level = options.level ?? LogLevel.INFO;
18217
18217
  this.enableColors = options.enableColors ?? true;
18218
18218
  this.showTimestamp = options.showTimestamp ?? true;
@@ -18412,7 +18412,7 @@
18412
18412
  * 提供 CSRF Token 的生成、存储和验证功能
18413
18413
  */ /**
18414
18414
  * CSRF Token 存储接口
18415
- */ function _define_property$M(obj, key, value) {
18415
+ */ function _define_property$N(obj, key, value) {
18416
18416
  if (key in obj) {
18417
18417
  Object.defineProperty(obj, key, {
18418
18418
  value: value,
@@ -18455,7 +18455,7 @@
18455
18455
  document.cookie = `${this.cookieName}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`;
18456
18456
  }
18457
18457
  constructor(cookieName = 'csrf-token'){
18458
- _define_property$M(this, "cookieName", void 0);
18458
+ _define_property$N(this, "cookieName", void 0);
18459
18459
  this.cookieName = cookieName;
18460
18460
  }
18461
18461
  };
@@ -18472,7 +18472,7 @@
18472
18472
  this.token = null;
18473
18473
  }
18474
18474
  constructor(){
18475
- _define_property$M(this, "token", null);
18475
+ _define_property$N(this, "token", null);
18476
18476
  }
18477
18477
  };
18478
18478
  /**
@@ -18523,11 +18523,11 @@
18523
18523
  return this.headerName;
18524
18524
  }
18525
18525
  constructor(config){
18526
- _define_property$M(this, "storage", void 0);
18527
- _define_property$M(this, "headerName", void 0);
18528
- _define_property$M(this, "cookieName", void 0);
18529
- _define_property$M(this, "getTokenFn", void 0);
18530
- _define_property$M(this, "validateTokenFn", void 0);
18526
+ _define_property$N(this, "storage", void 0);
18527
+ _define_property$N(this, "headerName", void 0);
18528
+ _define_property$N(this, "cookieName", void 0);
18529
+ _define_property$N(this, "getTokenFn", void 0);
18530
+ _define_property$N(this, "validateTokenFn", void 0);
18531
18531
  this.headerName = config?.headerName ?? 'X-CSRF-Token';
18532
18532
  this.cookieName = config?.cookieName ?? 'csrf-token';
18533
18533
  this.storage = config?.storage ?? (typeof document !== 'undefined' ? new CookieTokenStorage(this.cookieName) : new MemoryTokenStorage());
@@ -18557,7 +18557,7 @@
18557
18557
  initCSRFManager: initCSRFManager
18558
18558
  });
18559
18559
 
18560
- function _define_property$L(obj, key, value) {
18560
+ function _define_property$M(obj, key, value) {
18561
18561
  if (key in obj) {
18562
18562
  Object.defineProperty(obj, key, {
18563
18563
  value: value,
@@ -18847,12 +18847,12 @@
18847
18847
  this.config.onReport(metricsToReport);
18848
18848
  }
18849
18849
  constructor(config = {}){
18850
- _define_property$L(this, "config", void 0);
18851
- _define_property$L(this, "metrics", {});
18852
- _define_property$L(this, "observers", []);
18853
- _define_property$L(this, "aggregatedMetrics", {});
18854
- _define_property$L(this, "aggregationTimer", void 0);
18855
- _define_property$L(this, "autoReportTimer", void 0);
18850
+ _define_property$M(this, "config", void 0);
18851
+ _define_property$M(this, "metrics", {});
18852
+ _define_property$M(this, "observers", []);
18853
+ _define_property$M(this, "aggregatedMetrics", {});
18854
+ _define_property$M(this, "aggregationTimer", void 0);
18855
+ _define_property$M(this, "autoReportTimer", void 0);
18856
18856
  this.config = {
18857
18857
  collectWebVitals: config.collectWebVitals ?? true,
18858
18858
  onReport: config.onReport ?? (()=>{}),
@@ -18912,7 +18912,7 @@
18912
18912
  return result;
18913
18913
  }
18914
18914
 
18915
- function _define_property$K(obj, key, value) {
18915
+ function _define_property$L(obj, key, value) {
18916
18916
  if (key in obj) {
18917
18917
  Object.defineProperty(obj, key, {
18918
18918
  value: value,
@@ -19158,14 +19158,14 @@
19158
19158
  });
19159
19159
  }
19160
19160
  constructor(errorConfig = {}){
19161
- _define_property$K(this, "errorConfig", void 0);
19162
- _define_property$K(this, "errorHandlers", []);
19163
- _define_property$K(this, "performanceMetrics", {});
19164
- _define_property$K(this, "unhandledRejectionHandler", void 0);
19165
- _define_property$K(this, "errorHandler", void 0);
19166
- _define_property$K(this, "errorRecords", []);
19167
- _define_property$K(this, "errorAggregations", new Map());
19168
- _define_property$K(this, "aggregationTimer", void 0);
19161
+ _define_property$L(this, "errorConfig", void 0);
19162
+ _define_property$L(this, "errorHandlers", []);
19163
+ _define_property$L(this, "performanceMetrics", {});
19164
+ _define_property$L(this, "unhandledRejectionHandler", void 0);
19165
+ _define_property$L(this, "errorHandler", void 0);
19166
+ _define_property$L(this, "errorRecords", []);
19167
+ _define_property$L(this, "errorAggregations", new Map());
19168
+ _define_property$L(this, "aggregationTimer", void 0);
19169
19169
  this.errorConfig = {
19170
19170
  autoCapture: errorConfig.autoCapture ?? true,
19171
19171
  onError: errorConfig.onError ?? (()=>{}),
@@ -19206,7 +19206,7 @@
19206
19206
 
19207
19207
  /**
19208
19208
  * 资源类型
19209
- */ function _define_property$J(obj, key, value) {
19209
+ */ function _define_property$K(obj, key, value) {
19210
19210
  if (key in obj) {
19211
19211
  Object.defineProperty(obj, key, {
19212
19212
  value: value,
@@ -19484,9 +19484,9 @@
19484
19484
  return this.loadedResources.has(url);
19485
19485
  }
19486
19486
  constructor(){
19487
- _define_property$J(this, "loadedResources", new Set());
19488
- _define_property$J(this, "loadingResources", new Map());
19489
- _define_property$J(this, "maxConcurrentLoads", 6); // 最大并发加载数(默认值)
19487
+ _define_property$K(this, "loadedResources", new Set());
19488
+ _define_property$K(this, "loadingResources", new Map());
19489
+ _define_property$K(this, "maxConcurrentLoads", 6); // 最大并发加载数(默认值)
19490
19490
  }
19491
19491
  }
19492
19492
  /**
@@ -19811,7 +19811,7 @@
19811
19811
  RuntimeSecurity: RuntimeSecurity
19812
19812
  });
19813
19813
 
19814
- function _define_property$I(obj, key, value) {
19814
+ function _define_property$J(obj, key, value) {
19815
19815
  if (key in obj) {
19816
19816
  Object.defineProperty(obj, key, {
19817
19817
  value: value,
@@ -19975,9 +19975,9 @@
19975
19975
  this.flush();
19976
19976
  }
19977
19977
  constructor(config = {}){
19978
- _define_property$I(this, "config", void 0);
19979
- _define_property$I(this, "eventQueue", []);
19980
- _define_property$I(this, "batchTimer", null);
19978
+ _define_property$J(this, "config", void 0);
19979
+ _define_property$J(this, "eventQueue", []);
19980
+ _define_property$J(this, "batchTimer", null);
19981
19981
  this.config = {
19982
19982
  enabled: config.enabled ?? true,
19983
19983
  sampleRate: config.sampleRate ?? 1.0,
@@ -20045,7 +20045,7 @@
20045
20045
  /**
20046
20046
  * 插件沙箱
20047
20047
  * 用于插件隔离和权限控制
20048
- */ function _define_property$H(obj, key, value) {
20048
+ */ function _define_property$I(obj, key, value) {
20049
20049
  if (key in obj) {
20050
20050
  Object.defineProperty(obj, key, {
20051
20051
  value: value,
@@ -20136,8 +20136,8 @@
20136
20136
  this.config.permissions = permissions;
20137
20137
  }
20138
20138
  constructor(config){
20139
- _define_property$H(this, "config", void 0);
20140
- _define_property$H(this, "permissions", void 0);
20139
+ _define_property$I(this, "config", void 0);
20140
+ _define_property$I(this, "permissions", void 0);
20141
20141
  this.config = {
20142
20142
  strictMode: true,
20143
20143
  ...config
@@ -20151,7 +20151,7 @@
20151
20151
  * 用于插件间通信
20152
20152
  */ /**
20153
20153
  * 事件监听器类型
20154
- */ function _define_property$G(obj, key, value) {
20154
+ */ function _define_property$H(obj, key, value) {
20155
20155
  if (key in obj) {
20156
20156
  Object.defineProperty(obj, key, {
20157
20157
  value: value,
@@ -20411,10 +20411,10 @@
20411
20411
  };
20412
20412
  }
20413
20413
  constructor(config = {}){
20414
- _define_property$G(this, "listeners", new Map());
20415
- _define_property$G(this, "eventHistory", []);
20416
- _define_property$G(this, "config", void 0);
20417
- _define_property$G(this, "eventCounter", 0);
20414
+ _define_property$H(this, "listeners", new Map());
20415
+ _define_property$H(this, "eventHistory", []);
20416
+ _define_property$H(this, "config", void 0);
20417
+ _define_property$H(this, "eventCounter", 0);
20418
20418
  this.config = {
20419
20419
  enableTracking: config.enableTracking ?? false,
20420
20420
  maxHistorySize: config.maxHistorySize ?? 100,
@@ -20431,7 +20431,7 @@
20431
20431
  enableValidation: false
20432
20432
  });
20433
20433
 
20434
- function _define_property$F(obj, key, value) {
20434
+ function _define_property$G(obj, key, value) {
20435
20435
  if (key in obj) {
20436
20436
  Object.defineProperty(obj, key, {
20437
20437
  value: value,
@@ -20853,10 +20853,10 @@
20853
20853
  this.plugins.clear();
20854
20854
  }
20855
20855
  constructor(){
20856
- _define_property$F(this, "plugins", new Map());
20857
- _define_property$F(this, "sandboxes", new Map());
20858
- _define_property$F(this, "pluginStatus", new Map());
20859
- _define_property$F(this, "pluginLoaders", new Map());
20856
+ _define_property$G(this, "plugins", new Map());
20857
+ _define_property$G(this, "sandboxes", new Map());
20858
+ _define_property$G(this, "pluginStatus", new Map());
20859
+ _define_property$G(this, "pluginLoaders", new Map());
20860
20860
  }
20861
20861
  };
20862
20862
  /**
@@ -21080,7 +21080,7 @@
21080
21080
  }
21081
21081
  }
21082
21082
 
21083
- function _define_property$E(obj, key, value) {
21083
+ function _define_property$F(obj, key, value) {
21084
21084
  if (key in obj) {
21085
21085
  Object.defineProperty(obj, key, {
21086
21086
  value: value,
@@ -21130,8 +21130,8 @@
21130
21130
  return this.error !== null;
21131
21131
  }
21132
21132
  constructor(){
21133
- _define_property$E(this, "error", null);
21134
- _define_property$E(this, "listeners", new Set());
21133
+ _define_property$F(this, "error", null);
21134
+ _define_property$F(this, "listeners", new Set());
21135
21135
  }
21136
21136
  };
21137
21137
  /**
@@ -21481,7 +21481,7 @@
21481
21481
  return true;
21482
21482
  }
21483
21483
 
21484
- function _define_property$D(obj, key, value) {
21484
+ function _define_property$E(obj, key, value) {
21485
21485
  if (key in obj) {
21486
21486
  Object.defineProperty(obj, key, {
21487
21487
  value: value,
@@ -21534,7 +21534,7 @@
21534
21534
  return this.middlewares.length;
21535
21535
  }
21536
21536
  constructor(){
21537
- _define_property$D(this, "middlewares", []);
21537
+ _define_property$E(this, "middlewares", []);
21538
21538
  }
21539
21539
  }
21540
21540
  /**
@@ -21543,7 +21543,7 @@
21543
21543
 
21544
21544
  /**
21545
21545
  * 状态实例核心实现
21546
- */ function _define_property$C(obj, key, value) {
21546
+ */ function _define_property$D(obj, key, value) {
21547
21547
  if (key in obj) {
21548
21548
  Object.defineProperty(obj, key, {
21549
21549
  value: value,
@@ -21675,25 +21675,25 @@
21675
21675
  */ constructor(initialValue, options = {}){
21676
21676
  /**
21677
21677
  * 状态实例标识符
21678
- */ _define_property$C(this, "id", void 0);
21678
+ */ _define_property$D(this, "id", void 0);
21679
21679
  /**
21680
21680
  * 状态作用域
21681
- */ _define_property$C(this, "scope", void 0);
21681
+ */ _define_property$D(this, "scope", void 0);
21682
21682
  /**
21683
21683
  * 当前状态值
21684
- */ _define_property$C(this, "value", void 0);
21684
+ */ _define_property$D(this, "value", void 0);
21685
21685
  /**
21686
21686
  * 订阅者集合
21687
- */ _define_property$C(this, "subscribers", new Set());
21687
+ */ _define_property$D(this, "subscribers", new Set());
21688
21688
  /**
21689
21689
  * 是否已销毁
21690
- */ _define_property$C(this, "destroyed", false);
21690
+ */ _define_property$D(this, "destroyed", false);
21691
21691
  /**
21692
21692
  * 开发模式标志
21693
- */ _define_property$C(this, "devMode", void 0);
21693
+ */ _define_property$D(this, "devMode", void 0);
21694
21694
  /**
21695
21695
  * 中间件函数数组
21696
- */ _define_property$C(this, "middleware", void 0);
21696
+ */ _define_property$D(this, "middleware", void 0);
21697
21697
  this.value = initialValue;
21698
21698
  this.id = options.id ?? Symbol('StateInstance');
21699
21699
  this.scope = options.scope;
@@ -21710,7 +21710,7 @@
21710
21710
 
21711
21711
  /**
21712
21712
  * 状态作用域管理
21713
- */ function _define_property$B(obj, key, value) {
21713
+ */ function _define_property$C(obj, key, value) {
21714
21714
  if (key in obj) {
21715
21715
  Object.defineProperty(obj, key, {
21716
21716
  value: value,
@@ -21833,16 +21833,16 @@
21833
21833
  constructor(){
21834
21834
  /**
21835
21835
  * 作用域到状态实例的映射
21836
- */ _define_property$B(this, "scopeMap", new Map());
21836
+ */ _define_property$C(this, "scopeMap", new Map());
21837
21837
  /**
21838
21838
  * 状态实例到作用域的映射(用于快速查找)
21839
- */ _define_property$B(this, "instanceToScopeMap", new Map());
21839
+ */ _define_property$C(this, "instanceToScopeMap", new Map());
21840
21840
  }
21841
21841
  }
21842
21842
 
21843
21843
  /**
21844
21844
  * 状态注册表实现
21845
- */ function _define_property$A(obj, key, value) {
21845
+ */ function _define_property$B(obj, key, value) {
21846
21846
  if (key in obj) {
21847
21847
  Object.defineProperty(obj, key, {
21848
21848
  value: value,
@@ -21936,17 +21936,17 @@
21936
21936
  */ constructor(){
21937
21937
  /**
21938
21938
  * 状态实例映射表(ID -> Instance)
21939
- */ _define_property$A(this, "instances", new Map());
21939
+ */ _define_property$B(this, "instances", new Map());
21940
21940
  /**
21941
21941
  * 作用域管理器
21942
- */ _define_property$A(this, "scopeManager", void 0);
21942
+ */ _define_property$B(this, "scopeManager", void 0);
21943
21943
  this.scopeManager = new StateScopeManager();
21944
21944
  }
21945
21945
  }
21946
21946
 
21947
21947
  /**
21948
21948
  * 派生状态实例实现
21949
- */ function _define_property$z(obj, key, value) {
21949
+ */ function _define_property$A(obj, key, value) {
21950
21950
  if (key in obj) {
21951
21951
  Object.defineProperty(obj, key, {
21952
21952
  value: value,
@@ -22084,28 +22084,28 @@
22084
22084
  */ constructor(config, options = {}){
22085
22085
  /**
22086
22086
  * 状态实例标识符
22087
- */ _define_property$z(this, "id", void 0);
22087
+ */ _define_property$A(this, "id", void 0);
22088
22088
  /**
22089
22089
  * 状态作用域
22090
- */ _define_property$z(this, "scope", void 0);
22090
+ */ _define_property$A(this, "scope", void 0);
22091
22091
  /**
22092
22092
  * 派生状态配置
22093
- */ _define_property$z(this, "config", void 0);
22093
+ */ _define_property$A(this, "config", void 0);
22094
22094
  /**
22095
22095
  * 当前派生值
22096
- */ _define_property$z(this, "value", void 0);
22096
+ */ _define_property$A(this, "value", void 0);
22097
22097
  /**
22098
22098
  * 订阅者集合
22099
- */ _define_property$z(this, "subscribers", new Set());
22099
+ */ _define_property$A(this, "subscribers", new Set());
22100
22100
  /**
22101
22101
  * 依赖状态的取消订阅函数数组
22102
- */ _define_property$z(this, "dependencyUnsubscribes", []);
22102
+ */ _define_property$A(this, "dependencyUnsubscribes", []);
22103
22103
  /**
22104
22104
  * 是否已销毁
22105
- */ _define_property$z(this, "destroyed", false);
22105
+ */ _define_property$A(this, "destroyed", false);
22106
22106
  /**
22107
22107
  * 是否正在重新计算
22108
- */ _define_property$z(this, "recomputing", false);
22108
+ */ _define_property$A(this, "recomputing", false);
22109
22109
  this.config = config;
22110
22110
  this.id = options.id ?? Symbol('DerivedStateInstance');
22111
22111
  this.scope = options.scope;
@@ -22121,7 +22121,7 @@
22121
22121
  *
22122
22122
  * 这是 Secra Framework 内置的默认状态适配器实现
22123
22123
  * 不依赖任何外部状态管理库,提供基础的状态管理能力
22124
- */ function _define_property$y(obj, key, value) {
22124
+ */ function _define_property$z(obj, key, value) {
22125
22125
  if (key in obj) {
22126
22126
  Object.defineProperty(obj, key, {
22127
22127
  value: value,
@@ -22175,19 +22175,19 @@
22175
22175
  constructor(){
22176
22176
  /**
22177
22177
  * 适配器名称
22178
- */ _define_property$y(this, "name", 'DefaultAdapter');
22178
+ */ _define_property$z(this, "name", 'DefaultAdapter');
22179
22179
  /**
22180
22180
  * 是否已销毁
22181
- */ _define_property$y(this, "destroyed", false);
22181
+ */ _define_property$z(this, "destroyed", false);
22182
22182
  /**
22183
22183
  * 创建的状态实例集合(用于销毁时清理)
22184
- */ _define_property$y(this, "instances", new Set());
22184
+ */ _define_property$z(this, "instances", new Set());
22185
22185
  }
22186
22186
  }
22187
22187
 
22188
22188
  /**
22189
22189
  * 状态适配器工厂
22190
- */ function _define_property$x(obj, key, value) {
22190
+ */ function _define_property$y(obj, key, value) {
22191
22191
  if (key in obj) {
22192
22192
  Object.defineProperty(obj, key, {
22193
22193
  value: value,
@@ -22263,10 +22263,10 @@
22263
22263
  }
22264
22264
  /**
22265
22265
  * 默认适配器实例
22266
- */ _define_property$x(AdapterFactory, "defaultAdapter", null);
22266
+ */ _define_property$y(AdapterFactory, "defaultAdapter", null);
22267
22267
  /**
22268
22268
  * 自定义适配器映射
22269
- */ _define_property$x(AdapterFactory, "customAdapters", new Map());
22269
+ */ _define_property$y(AdapterFactory, "customAdapters", new Map());
22270
22270
 
22271
22271
  /**
22272
22272
  * Redux Toolkit 适配器
@@ -22289,7 +22289,7 @@
22289
22289
  * state.set(1);
22290
22290
  * console.log(state.get()); // 1
22291
22291
  * ```
22292
- */ function _define_property$w(obj, key, value) {
22292
+ */ function _define_property$x(obj, key, value) {
22293
22293
  if (key in obj) {
22294
22294
  Object.defineProperty(obj, key, {
22295
22295
  value: value,
@@ -22447,37 +22447,37 @@
22447
22447
  */ constructor(store, sliceName, actions, initialValue, options = {}){
22448
22448
  /**
22449
22449
  * 状态实例标识符
22450
- */ _define_property$w(this, "id", void 0);
22450
+ */ _define_property$x(this, "id", void 0);
22451
22451
  /**
22452
22452
  * 状态作用域
22453
- */ _define_property$w(this, "scope", void 0);
22453
+ */ _define_property$x(this, "scope", void 0);
22454
22454
  /**
22455
22455
  * Redux store 引用
22456
- */ _define_property$w(this, "store", void 0);
22456
+ */ _define_property$x(this, "store", void 0);
22457
22457
  /**
22458
22458
  * Redux slice 名称(在 store 中的路径)
22459
- */ _define_property$w(this, "sliceName", void 0);
22459
+ */ _define_property$x(this, "sliceName", void 0);
22460
22460
  /**
22461
22461
  * Redux slice actions
22462
- */ _define_property$w(this, "actions", void 0);
22462
+ */ _define_property$x(this, "actions", void 0);
22463
22463
  /**
22464
22464
  * 订阅者集合
22465
- */ _define_property$w(this, "subscribers", new Set());
22465
+ */ _define_property$x(this, "subscribers", new Set());
22466
22466
  /**
22467
22467
  * Redux store 订阅取消函数
22468
- */ _define_property$w(this, "unsubscribeStore", void 0);
22468
+ */ _define_property$x(this, "unsubscribeStore", void 0);
22469
22469
  /**
22470
22470
  * 是否已销毁
22471
- */ _define_property$w(this, "destroyed", false);
22471
+ */ _define_property$x(this, "destroyed", false);
22472
22472
  /**
22473
22473
  * 开发模式标志
22474
- */ _define_property$w(this, "devMode", void 0);
22474
+ */ _define_property$x(this, "devMode", void 0);
22475
22475
  /**
22476
22476
  * 中间件函数数组
22477
- */ _define_property$w(this, "middleware", void 0);
22477
+ */ _define_property$x(this, "middleware", void 0);
22478
22478
  /**
22479
22479
  * 上一次的状态值(用于订阅通知)
22480
- */ _define_property$w(this, "previousValue", void 0);
22480
+ */ _define_property$x(this, "previousValue", void 0);
22481
22481
  this.store = store;
22482
22482
  this.sliceName = sliceName;
22483
22483
  this.actions = actions;
@@ -22529,10 +22529,10 @@
22529
22529
  */ constructor(){
22530
22530
  /**
22531
22531
  * 当前 reducer 映射
22532
- */ _define_property$w(this, "reducers", new Map());
22532
+ */ _define_property$x(this, "reducers", new Map());
22533
22533
  /**
22534
22534
  * 根 reducer 函数
22535
- */ _define_property$w(this, "rootReducer", void 0);
22535
+ */ _define_property$x(this, "rootReducer", void 0);
22536
22536
  this.rootReducer = (state, action)=>{
22537
22537
  const stateRecord = state ?? {};
22538
22538
  const newState = {
@@ -22676,28 +22676,28 @@
22676
22676
  */ constructor(options){
22677
22677
  /**
22678
22678
  * 适配器名称
22679
- */ _define_property$w(this, "name", 'ReduxAdapter');
22679
+ */ _define_property$x(this, "name", 'ReduxAdapter');
22680
22680
  /**
22681
22681
  * 是否已销毁
22682
- */ _define_property$w(this, "destroyed", false);
22682
+ */ _define_property$x(this, "destroyed", false);
22683
22683
  /**
22684
22684
  * 创建的状态实例集合
22685
- */ _define_property$w(this, "instances", new Set());
22685
+ */ _define_property$x(this, "instances", new Set());
22686
22686
  /**
22687
22687
  * Redux store 实例
22688
- */ _define_property$w(this, "store", null);
22688
+ */ _define_property$x(this, "store", null);
22689
22689
  /**
22690
22690
  * Redux slice 名称计数器(用于生成唯一的 slice 名称)
22691
- */ _define_property$w(this, "sliceCounter", 0);
22691
+ */ _define_property$x(this, "sliceCounter", 0);
22692
22692
  /**
22693
22693
  * Redux slice 名称到状态实例的映射
22694
- */ _define_property$w(this, "sliceToInstance", new Map());
22694
+ */ _define_property$x(this, "sliceToInstance", new Map());
22695
22695
  /**
22696
22696
  * 动态 reducer 管理器
22697
- */ _define_property$w(this, "reducerManager", void 0);
22697
+ */ _define_property$x(this, "reducerManager", void 0);
22698
22698
  /**
22699
22699
  * 是否启用开发模式
22700
- */ _define_property$w(this, "devMode", void 0);
22700
+ */ _define_property$x(this, "devMode", void 0);
22701
22701
  this.devMode = options?.devMode ?? false;
22702
22702
  this.reducerManager = new DynamicReducerManager();
22703
22703
  this.store = options?.store ?? null;
@@ -22712,7 +22712,7 @@
22712
22712
  * 这是一个适配器接口示例,展示如何将 Zustand 集成到 Secra 状态管理器
22713
22713
  *
22714
22714
  * ⚠️ 注意:这是一个占位实现,实际使用时需要安装 zustand 依赖
22715
- */ function _define_property$v(obj, key, value) {
22715
+ */ function _define_property$w(obj, key, value) {
22716
22716
  if (key in obj) {
22717
22717
  Object.defineProperty(obj, key, {
22718
22718
  value: value,
@@ -22765,13 +22765,13 @@
22765
22765
  constructor(){
22766
22766
  /**
22767
22767
  * 适配器名称
22768
- */ _define_property$v(this, "name", 'ZustandAdapter');
22768
+ */ _define_property$w(this, "name", 'ZustandAdapter');
22769
22769
  /**
22770
22770
  * 是否已销毁
22771
- */ _define_property$v(this, "destroyed", false);
22771
+ */ _define_property$w(this, "destroyed", false);
22772
22772
  /**
22773
22773
  * 创建的状态实例集合
22774
- */ _define_property$v(this, "instances", new Set());
22774
+ */ _define_property$w(this, "instances", new Set());
22775
22775
  }
22776
22776
  }
22777
22777
 
@@ -22779,7 +22779,7 @@
22779
22779
  * 状态管理器主类
22780
22780
  *
22781
22781
  * 这是状态管理器的核心入口,提供统一的状态管理 API
22782
- */ function _define_property$u(obj, key, value) {
22782
+ */ function _define_property$v(obj, key, value) {
22783
22783
  if (key in obj) {
22784
22784
  Object.defineProperty(obj, key, {
22785
22785
  value: value,
@@ -22904,19 +22904,19 @@
22904
22904
  */ constructor(options = {}){
22905
22905
  /**
22906
22906
  * 默认适配器
22907
- */ _define_property$u(this, "adapter", void 0);
22907
+ */ _define_property$v(this, "adapter", void 0);
22908
22908
  /**
22909
22909
  * 状态注册表(如果启用)
22910
- */ _define_property$u(this, "registry", void 0);
22910
+ */ _define_property$v(this, "registry", void 0);
22911
22911
  /**
22912
22912
  * 默认作用域
22913
- */ _define_property$u(this, "defaultScope", void 0);
22913
+ */ _define_property$v(this, "defaultScope", void 0);
22914
22914
  /**
22915
22915
  * 是否启用开发模式
22916
- */ _define_property$u(this, "devMode", void 0);
22916
+ */ _define_property$v(this, "devMode", void 0);
22917
22917
  /**
22918
22918
  * 是否已销毁
22919
- */ _define_property$u(this, "destroyed", false);
22919
+ */ _define_property$v(this, "destroyed", false);
22920
22920
  this.adapter = options.defaultAdapter ?? AdapterFactory.getDefaultAdapter();
22921
22921
  this.defaultScope = options.defaultScope;
22922
22922
  this.devMode = options.devMode ?? false;
@@ -22931,7 +22931,7 @@
22931
22931
  }
22932
22932
  }
22933
22933
 
22934
- function _define_property$t(obj, key, value) {
22934
+ function _define_property$u(obj, key, value) {
22935
22935
  if (key in obj) {
22936
22936
  Object.defineProperty(obj, key, {
22937
22937
  value: value,
@@ -23331,25 +23331,25 @@
23331
23331
  /**
23332
23332
  * 事件监听器映射表
23333
23333
  * 使用 Map + Set 结构提高性能
23334
- */ _define_property$t(this, "listeners", new Map());
23334
+ */ _define_property$u(this, "listeners", new Map());
23335
23335
  /**
23336
23336
  * 事件历史记录
23337
- */ _define_property$t(this, "eventHistory", []);
23337
+ */ _define_property$u(this, "eventHistory", []);
23338
23338
  /**
23339
23339
  * 事件中间件列表
23340
- */ _define_property$t(this, "middlewares", []);
23340
+ */ _define_property$u(this, "middlewares", []);
23341
23341
  /**
23342
23342
  * 事件统计信息
23343
- */ _define_property$t(this, "stats", new Map());
23343
+ */ _define_property$u(this, "stats", new Map());
23344
23344
  /**
23345
23345
  * 配置
23346
- */ _define_property$t(this, "config", void 0);
23346
+ */ _define_property$u(this, "config", void 0);
23347
23347
  /**
23348
23348
  * 事件计数器(用于生成唯一事件ID)
23349
- */ _define_property$t(this, "eventCounter", 0);
23349
+ */ _define_property$u(this, "eventCounter", 0);
23350
23350
  /**
23351
23351
  * 监听器ID计数器
23352
- */ _define_property$t(this, "listenerIdCounter", 0);
23352
+ */ _define_property$u(this, "listenerIdCounter", 0);
23353
23353
  this.config = {
23354
23354
  enableTracking: config.enableTracking ?? process.env.NODE_ENV === 'development',
23355
23355
  maxHistorySize: config.maxHistorySize ?? 100,
@@ -23542,7 +23542,7 @@
23542
23542
  };
23543
23543
  }
23544
23544
 
23545
- function _define_property$s(obj, key, value) {
23545
+ function _define_property$t(obj, key, value) {
23546
23546
  if (key in obj) {
23547
23547
  Object.defineProperty(obj, key, {
23548
23548
  value: value,
@@ -23660,7 +23660,7 @@
23660
23660
  /**
23661
23661
  * 私有构造函数,防止外部直接实例化
23662
23662
  */ constructor(){
23663
- _define_property$s(this, "_config", void 0);
23663
+ _define_property$t(this, "_config", void 0);
23664
23664
  this._config = {
23665
23665
  theme: {
23666
23666
  mode: 'light'
@@ -23669,7 +23669,7 @@
23669
23669
  };
23670
23670
  }
23671
23671
  };
23672
- _define_property$s(AppConfigManager, "instance", null);
23672
+ _define_property$t(AppConfigManager, "instance", null);
23673
23673
  /**
23674
23674
  * 应用配置单例实例
23675
23675
  */ const appConfig = AppConfigManager.getInstance();
@@ -24275,7 +24275,7 @@
24275
24275
  return r.length !== t.length || r.some((e, o) => !Object.is(e, t[o]));
24276
24276
  }
24277
24277
 
24278
- function _define_property$r(obj, key, value) {
24278
+ function _define_property$s(obj, key, value) {
24279
24279
  if (key in obj) {
24280
24280
  Object.defineProperty(obj, key, {
24281
24281
  value: value,
@@ -24474,8 +24474,8 @@
24474
24474
  return new ErrorHandler(config);
24475
24475
  }
24476
24476
  constructor(config = {}){
24477
- _define_property$r(this, "config", void 0);
24478
- _define_property$r(this, "monitoring", void 0);
24477
+ _define_property$s(this, "config", void 0);
24478
+ _define_property$s(this, "monitoring", void 0);
24479
24479
  this.monitoring = config.monitoring;
24480
24480
  this.config = {
24481
24481
  defaultStrategies: config.defaultStrategies ?? [
@@ -24892,7 +24892,7 @@
24892
24892
  };
24893
24893
  }
24894
24894
 
24895
- function _define_property$q(obj, key, value) {
24895
+ function _define_property$r(obj, key, value) {
24896
24896
  if (key in obj) {
24897
24897
  Object.defineProperty(obj, key, {
24898
24898
  value: value,
@@ -24951,8 +24951,8 @@
24951
24951
  }
24952
24952
  }
24953
24953
  constructor(maxSize = 50){
24954
- _define_property$q(this, "cache", new Map());
24955
- _define_property$q(this, "maxSize", void 0);
24954
+ _define_property$r(this, "cache", new Map());
24955
+ _define_property$r(this, "maxSize", void 0);
24956
24956
  this.maxSize = maxSize;
24957
24957
  }
24958
24958
  };
@@ -24964,7 +24964,12 @@
24964
24964
  */ const DEFAULT_OPTIONS = {
24965
24965
  pathValidation: {
24966
24966
  enablePathValidation: true,
24967
- allowedPathPrefixes: [],
24967
+ // 默认仅允许常见本地模块路径,生产环境建议进一步收紧。
24968
+ allowedPathPrefixes: [
24969
+ '@/',
24970
+ './',
24971
+ '../'
24972
+ ],
24968
24973
  maxPathLength: 500,
24969
24974
  allowAbsolutePaths: false
24970
24975
  },
@@ -25026,62 +25031,62 @@
25026
25031
  */ function simpleHash(str) {
25027
25032
  return optimizedHash(str);
25028
25033
  }
25029
- /**
25030
- * 配置序列化缓存(避免重复序列化)
25031
- */ const configStringCache = new Map();
25034
+ function serializeComponentRef(value) {
25035
+ if (typeof value === 'string') {
25036
+ return {
25037
+ str: value
25038
+ };
25039
+ }
25040
+ if (typeof value === 'function') {
25041
+ // 函数引用无法稳定序列化源码,使用名称和长度参与哈希,避免同名不同体完全碰撞。
25042
+ const fnText = String(value);
25043
+ return {
25044
+ fn: `${value.name || 'anonymous'}:${fnText.length}`
25045
+ };
25046
+ }
25047
+ return {};
25048
+ }
25049
+ function serializeRouteConfig(route) {
25050
+ const page = serializeComponentRef(route.page);
25051
+ const layout = serializeComponentRef(route.layout);
25052
+ const routeError = serializeComponentRef(route.error ?? route.errors);
25053
+ const loading = serializeComponentRef(route.loading);
25054
+ return {
25055
+ name: route.name,
25056
+ path: route.path,
25057
+ page: page.str,
25058
+ pageFn: page.fn,
25059
+ layout: layout.str,
25060
+ layoutFn: layout.fn,
25061
+ error: routeError.str,
25062
+ errorFn: routeError.fn,
25063
+ loading: loading.str,
25064
+ loadingFn: loading.fn,
25065
+ isGroup: route.isGroup,
25066
+ enableRedirection: route.enableRedirection,
25067
+ handle: route.handle ? {
25068
+ title: route.handle.title,
25069
+ order: route.handle.order,
25070
+ needLogin: route.handle.needLogin,
25071
+ roles: Array.isArray(route.handle.roles) ? [
25072
+ ...route.handle.roles
25073
+ ] : undefined
25074
+ } : undefined,
25075
+ children: route.children?.map((child)=>serializeRouteConfig(child))
25076
+ };
25077
+ }
25032
25078
  /**
25033
25079
  * 生成配置哈希(用于缓存键)
25034
25080
  * 优化:缓存序列化结果,避免重复序列化
25035
25081
  */ function generateConfigHash(routes) {
25036
25082
  try {
25037
- // 快速检查:如果路由数量为 0,直接返回
25038
25083
  if (routes.length === 0) {
25039
25084
  return 'empty';
25040
25085
  }
25041
- // 使用路由数量作为快速键的一部分
25042
- const quickKey = `${routes.length}_${routes[0]?.name || ''}_${routes[routes.length - 1]?.name || ''}`;
25043
- // 检查序列化缓存
25044
- if (configStringCache.has(quickKey)) {
25045
- const cachedStr = configStringCache.get(quickKey);
25046
- // 验证缓存是否仍然有效(简单检查)
25047
- const currentStr = JSON.stringify(routes, null, 0).substring(0, 100);
25048
- if (cachedStr.startsWith(currentStr.substring(0, 50))) {
25049
- return simpleHash(cachedStr);
25050
- }
25051
- }
25052
- // 使用 JSON.stringify 生成配置的字符串表示
25053
- // 只包含影响转换结果的字段
25054
- const configStr = JSON.stringify(routes, (key, value)=>{
25055
- // 只序列化相关字段
25056
- if ([
25057
- 'name',
25058
- 'path',
25059
- 'page',
25060
- 'layout',
25061
- 'errors',
25062
- 'loading',
25063
- 'isGroup',
25064
- 'enableRedirection',
25065
- 'children'
25066
- ].includes(key)) {
25067
- return value;
25068
- }
25069
- if (key === 'handle' && value && typeof value === 'object') {
25070
- // 只序列化 handle 的基本字段
25071
- return {
25072
- title: value.title,
25073
- order: value.order
25074
- };
25075
- }
25076
- return undefined;
25077
- });
25078
- // 缓存序列化结果(限制缓存大小)
25079
- if (configStringCache.size < 20) {
25080
- configStringCache.set(quickKey, configStr);
25081
- }
25086
+ const serializedRoutes = routes.map((route)=>serializeRouteConfig(route));
25087
+ const configStr = JSON.stringify(serializedRoutes);
25082
25088
  return simpleHash(configStr);
25083
25089
  } catch {
25084
- // 如果序列化失败,返回空字符串(不使用缓存)
25085
25090
  return '';
25086
25091
  }
25087
25092
  }
@@ -25094,6 +25099,7 @@
25094
25099
  const ABSOLUTE_PATH_REGEX = /^\/|^[A-Za-z]:\\/;
25095
25100
  const CONTROL_CHAR_REGEX = /[\x00-\x1f\x7f]/;
25096
25101
  const NULL_BYTE_REGEX = /%00|\\0|\x00/;
25102
+ const URL_SCHEME_REGEX = /^[A-Za-z][A-Za-z0-9+.-]*:/;
25097
25103
  // 保留供未来使用(命令注入检测)
25098
25104
  // const COMMAND_INJECTION_REGEX = /[;|&$`]/;
25099
25105
  // const ALLOWED_CHARS_REGEX = /^[a-zA-Z0-9\/\-_.@]+$/;
@@ -25151,6 +25157,13 @@
25151
25157
  // : '路径验证失败',
25152
25158
  // };
25153
25159
  // }
25160
+ // 禁止 URL scheme 导入(如 http:, https:, data:, javascript:)
25161
+ if (URL_SCHEME_REGEX.test(path)) {
25162
+ return {
25163
+ valid: false,
25164
+ error: process.env.NODE_ENV === 'development' ? '不允许使用带协议的路径' : '路径验证失败'
25165
+ };
25166
+ }
25154
25167
  // 检查绝对路径(使用预编译正则)
25155
25168
  if (!config.allowAbsolutePaths && ABSOLUTE_PATH_REGEX.test(path)) {
25156
25169
  return {
@@ -25158,6 +25171,13 @@
25158
25171
  error: process.env.NODE_ENV === 'development' ? '不允许使用绝对路径' : '路径验证失败'
25159
25172
  };
25160
25173
  }
25174
+ // 默认仅允许相对路径和别名路径,避免把第三方包名作为动态入口。
25175
+ if (!path.startsWith('@/') && !path.startsWith('./') && !path.startsWith('../')) {
25176
+ return {
25177
+ valid: false,
25178
+ error: process.env.NODE_ENV === 'development' ? '仅允许使用 @/、./、../ 开头的模块路径' : '路径验证失败'
25179
+ };
25180
+ }
25161
25181
  // 检查路径前缀白名单(优化:使用 Set 提高查找速度)
25162
25182
  if (config.allowedPathPrefixes.length > 0) {
25163
25183
  const prefixSet = new Set(config.allowedPathPrefixes);
@@ -25326,8 +25346,8 @@
25326
25346
  }
25327
25347
  }
25328
25348
  constructor(){
25329
- _define_property$q(this, "pool", []);
25330
- _define_property$q(this, "maxPoolSize", 100);
25349
+ _define_property$r(this, "pool", []);
25350
+ _define_property$r(this, "maxPoolSize", 100);
25331
25351
  }
25332
25352
  };
25333
25353
  const stackNodePool = new StackNodePool();
@@ -25379,9 +25399,10 @@
25379
25399
  map: result.layouts
25380
25400
  });
25381
25401
  }
25382
- if (route.errors && typeof route.errors === 'string') {
25402
+ const routeError = route.error ?? route.errors;
25403
+ if (routeError && typeof routeError === 'string') {
25383
25404
  pathsToProcess.push({
25384
- path: route.errors,
25405
+ path: routeError,
25385
25406
  map: result.errors
25386
25407
  });
25387
25408
  }
@@ -25426,7 +25447,7 @@
25426
25447
  // 提取组件路径到 Map 中(同时进行验证)
25427
25448
  extractAndValidatePath(route.page, result.pages, config, options);
25428
25449
  extractAndValidatePath(route.layout, result.layouts, config, options);
25429
- extractAndValidatePath(route.errors, result.errors, config, options);
25450
+ extractAndValidatePath(route.error ?? route.errors, result.errors, config, options);
25430
25451
  extractAndValidatePath(route.loading, result.loadings, config, options);
25431
25452
  // 处理子路由
25432
25453
  if (route.children && Array.isArray(route.children) && route.children.length > 0) {
@@ -25459,7 +25480,7 @@
25459
25480
  *
25460
25481
  * @param routes - 路由配置列表,可以是:
25461
25482
  * - 路由配置数组(RouteConfig[])
25462
- * - 返回路由配置数组的异步函数(() => Promise<RouteConfig[]>)
25483
+ * - 返回路由配置数组的函数(支持同步或异步:() => RouteConfig[] | Promise<RouteConfig[]>)
25463
25484
  * 支持异步函数是为了支持动态加载路由配置(如从服务器获取)
25464
25485
  * @param options - 转换配置选项
25465
25486
  * @returns 包含以下内容的结果对象:
@@ -25610,26 +25631,14 @@
25610
25631
  if (mergedOptions.performance.enableCache && transformCache) {
25611
25632
  const configHash = generateConfigHash(routesArray);
25612
25633
  if (configHash) {
25613
- // 使用结构化克隆(如果可用)或浅拷贝 + 深拷贝 routes
25614
- let cachedResult;
25615
- if (typeof structuredClone !== 'undefined') {
25616
- // 使用结构化克隆(更快且更安全)
25617
- cachedResult = structuredClone(result);
25618
- // Map 需要手动克隆(structuredClone 可能不支持 Map
25619
- cachedResult.pages = new Map(result.pages);
25620
- cachedResult.layouts = new Map(result.layouts);
25621
- cachedResult.errors = new Map(result.errors);
25622
- cachedResult.loadings = new Map(result.loadings);
25623
- } else {
25624
- // 回退到手动深拷贝
25625
- cachedResult = {
25626
- pages: new Map(result.pages),
25627
- layouts: new Map(result.layouts),
25628
- errors: new Map(result.errors),
25629
- loadings: new Map(result.loadings),
25630
- routes: JSON.parse(JSON.stringify(result.routes))
25631
- };
25632
- }
25634
+ // 注意:Map 中包含函数值,structuredClone 会失败;统一使用手动克隆。
25635
+ const cachedResult = {
25636
+ pages: new Map(result.pages),
25637
+ layouts: new Map(result.layouts),
25638
+ errors: new Map(result.errors),
25639
+ loadings: new Map(result.loadings),
25640
+ routes: JSON.parse(JSON.stringify(result.routes))
25641
+ };
25633
25642
  transformCache.set(configHash, {
25634
25643
  result: cachedResult,
25635
25644
  timestamp: Date.now(),
@@ -25784,7 +25793,7 @@
25784
25793
  });
25785
25794
  };
25786
25795
 
25787
- function DefaultRouteLoading() {
25796
+ function DefaultRouteHydrateFallback() {
25788
25797
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
25789
25798
  style: {
25790
25799
  padding: 16,
@@ -25794,7 +25803,7 @@
25794
25803
  children: "Loading..."
25795
25804
  });
25796
25805
  }
25797
- const transformRoutesToReactRoutes = async (routes, transformResult, defaultRouteErrorComponent, defaultRouteLoadingComponent)=>{
25806
+ const transformRoutesToReactRoutes = async (routes, transformResult, defaultRouteErrorComponent, defaultRouteLoadingComponent, enableHydrateFallback = false)=>{
25798
25807
  /**
25799
25808
  * 批量处理路由
25800
25809
  * @param routes 路由组
@@ -25805,18 +25814,19 @@
25805
25814
  * 处理单个路由
25806
25815
  * @param route 路由
25807
25816
  */ function transformRouteToReactRoute(route) {
25808
- const { isGroup = false, enableRedirection = false, name, path, handle, children, page, layout, loading, errors } = route;
25817
+ const { isGroup = false, enableRedirection = false, name, path, handle, children, page, layout, error, errors, loading } = route;
25818
+ const routeError = error ?? errors;
25809
25819
  // 获取错误组件
25810
25820
  async function getErrorComponent() {
25811
- // 如果 errors 是函数,直接使用
25812
- if (typeof errors === 'function') {
25813
- return errors();
25821
+ // 如果 error/errors 是函数,直接使用
25822
+ if (typeof routeError === 'function') {
25823
+ return routeError();
25814
25824
  }
25815
25825
  const errorsMap = transformResult.errors;
25816
- // 判断 errors 是否为 string 且不是空字符串
25817
- if (typeof errors === 'string' && errors !== '') {
25818
- // 使用 errors 作为 key 获取 transformResult.errors 的值
25819
- const errorResolver = errorsMap.get(errors);
25826
+ // 判断 error/errors 是否为 string 且不是空字符串
25827
+ if (typeof routeError === 'string' && routeError !== '') {
25828
+ // 使用 routeError 作为 key 获取 transformResult.errors 的值
25829
+ const errorResolver = errorsMap.get(routeError);
25820
25830
  // 如果获取不到,返回 null
25821
25831
  if (!errorResolver) {
25822
25832
  return null;
@@ -25841,52 +25851,6 @@
25841
25851
  default: RouteErrorBoundary
25842
25852
  };
25843
25853
  }
25844
- // 获取默认加载组件(配置的或内置的 Spin)
25845
- function getDefaultLoadingComponent() {
25846
- if (defaultRouteLoadingComponent) {
25847
- // 如果配置了默认加载组件,使用 React.lazy 包装
25848
- // 使用懒加载是因为用户可能希望自定义组件支持代码分割
25849
- return /*#__PURE__*/ React.lazy(()=>defaultRouteLoadingComponent().then((module)=>({
25850
- default: module.default || module
25851
- })));
25852
- }
25853
- // 如果没有配置默认加载组件,使用框架内置 Loading 组件
25854
- // 直接导入而非懒加载,因为:
25855
- // 1. 内置 Loading 组件无外部依赖
25856
- // 2. 加载组件需要快速显示,直接导入速度更快
25857
- // 3. 作为基础设施组件,应该保证可用性
25858
- return DefaultRouteLoading;
25859
- }
25860
- // 获取加载组件
25861
- function getLoadingComponent() {
25862
- // 如果 loading 是函数,直接使用 React.lazy 包装
25863
- if (typeof loading === 'function') {
25864
- return /*#__PURE__*/ React.lazy(()=>loading().then((module)=>({
25865
- default: module.default || module
25866
- })));
25867
- }
25868
- const loadingsMap = transformResult.loadings;
25869
- // 判断 loading 是否为 string 且不是空字符串
25870
- if (typeof loading === 'string' && loading !== '') {
25871
- // 使用 loading 作为 key 获取 transformResult.loadings 的值
25872
- const loadingResolver = loadingsMap.get(loading);
25873
- // 如果获取不到,使用默认加载组件
25874
- if (!loadingResolver) {
25875
- return getDefaultLoadingComponent();
25876
- }
25877
- // 如果获取到,使用 React.lazy 包装动态导入函数
25878
- // loadingResolver 是一个返回 Promise 的函数,Promise resolve 后的值是组件模块
25879
- if (typeof loadingResolver === 'function') {
25880
- return /*#__PURE__*/ React.lazy(()=>loadingResolver().then((module)=>({
25881
- default: module.default || module
25882
- })));
25883
- }
25884
- // 如果 loadingResolver 不是函数,使用默认加载组件
25885
- return getDefaultLoadingComponent();
25886
- }
25887
- // 如果 loading 为空,使用默认加载组件
25888
- return getDefaultLoadingComponent();
25889
- }
25890
25854
  // 获取转换配置
25891
25855
  function convertConfig(m) {
25892
25856
  if (!m) {
@@ -25895,7 +25859,7 @@
25895
25859
  const { action, loader, shouldRevalidate, default: Component } = m;
25896
25860
  // 如果 Component 不存在,记录警告
25897
25861
  if (!Component) {
25898
- console.warn(`路由组件未找到 default 导出: ${name}`, m);
25862
+ logger.warn(`路由组件未找到 default 导出: ${name}`, m);
25899
25863
  }
25900
25864
  return {
25901
25865
  action,
@@ -25904,6 +25868,22 @@
25904
25868
  Component
25905
25869
  };
25906
25870
  }
25871
+ // 获取加载组件
25872
+ async function getLoadingComponent() {
25873
+ if (typeof loading === 'function') {
25874
+ return loading();
25875
+ }
25876
+ if (typeof loading === 'string' && loading !== '') {
25877
+ const loadingResolver = transformResult.loadings.get(loading);
25878
+ if (typeof loadingResolver === 'function') {
25879
+ return loadingResolver();
25880
+ }
25881
+ }
25882
+ if (defaultRouteLoadingComponent) {
25883
+ return defaultRouteLoadingComponent();
25884
+ }
25885
+ return null;
25886
+ }
25907
25887
  // 获取配置
25908
25888
  async function getConfig(index = false) {
25909
25889
  // 如果有layout和不是index,返回布局配置
@@ -25954,25 +25934,31 @@
25954
25934
  }
25955
25935
  const reactRoute = {
25956
25936
  children: [],
25957
- HydrateFallback: getLoadingComponent(),
25958
25937
  id: name,
25959
25938
  handle: getHandle(),
25960
25939
  lazy: async ()=>{
25961
25940
  const ErrorBoundary = await getErrorComponent();
25962
25941
  const config = await getConfig();
25942
+ const LoadingComponent = await getLoadingComponent();
25943
+ const HydrateFallback = LoadingComponent?.default ?? DefaultRouteHydrateFallback;
25963
25944
  // 如果配置为空,确保至少返回一个空对象,避免展开 undefined
25964
25945
  if (!config) {
25965
25946
  return {
25966
- ErrorBoundary: ErrorBoundary?.default
25947
+ ErrorBoundary: ErrorBoundary?.default,
25948
+ HydrateFallback
25967
25949
  };
25968
25950
  }
25969
25951
  return {
25970
25952
  ErrorBoundary: ErrorBoundary?.default,
25953
+ HydrateFallback,
25971
25954
  ...config
25972
25955
  };
25973
25956
  },
25974
25957
  path
25975
25958
  };
25959
+ if (enableHydrateFallback) {
25960
+ reactRoute.hydrateFallbackElement = /*#__PURE__*/ jsxRuntime.jsx(DefaultRouteHydrateFallback, {});
25961
+ }
25976
25962
  // 处理子路由
25977
25963
  if (children?.length) {
25978
25964
  reactRoute.children = children.flatMap((child)=>transformRouteToReactRoute(child)).sort((a, b)=>{
@@ -25986,8 +25972,11 @@
25986
25972
  index: true,
25987
25973
  lazy: async ()=>{
25988
25974
  const ErrorBoundary = await getErrorComponent();
25975
+ const LoadingComponent = await getLoadingComponent();
25976
+ const HydrateFallback = LoadingComponent?.default ?? DefaultRouteHydrateFallback;
25989
25977
  return {
25990
25978
  ErrorBoundary: ErrorBoundary?.default,
25979
+ HydrateFallback,
25991
25980
  ...await getConfig(true)
25992
25981
  };
25993
25982
  }
@@ -26016,8 +26005,11 @@
26016
26005
  index: true,
26017
26006
  lazy: async ()=>{
26018
26007
  const ErrorBoundary = await getErrorComponent();
26008
+ const LoadingComponent = await getLoadingComponent();
26009
+ const HydrateFallback = LoadingComponent?.default ?? DefaultRouteHydrateFallback;
26019
26010
  return {
26020
26011
  ErrorBoundary: ErrorBoundary?.default,
26012
+ HydrateFallback,
26021
26013
  ...await getConfig(true)
26022
26014
  };
26023
26015
  }
@@ -26051,12 +26043,42 @@
26051
26043
  zod.z.function(),
26052
26044
  zod.z.null()
26053
26045
  ]);
26046
+ const routerOptionsSchema = zod.z.object({
26047
+ basename: zod.z.string().optional(),
26048
+ future: zod.z.record(zod.z.string(), zod.z.union([
26049
+ zod.z.boolean(),
26050
+ zod.z.string(),
26051
+ zod.z.number()
26052
+ ])).optional(),
26053
+ hydrationData: zod.z.unknown().optional(),
26054
+ window: zod.z.unknown().optional(),
26055
+ initialEntries: zod.z.array(zod.z.string()).optional(),
26056
+ initialIndex: zod.z.number().int().nonnegative().optional()
26057
+ }).passthrough();
26058
+ const transformOptionsSchema = zod.z.object({
26059
+ pathValidation: zod.z.object({
26060
+ enablePathValidation: zod.z.boolean().optional(),
26061
+ allowedPathPrefixes: zod.z.array(zod.z.string().min(1)).optional(),
26062
+ maxPathLength: zod.z.number().int().positive().optional(),
26063
+ allowAbsolutePaths: zod.z.boolean().optional()
26064
+ }).optional(),
26065
+ performance: zod.z.object({
26066
+ enableCache: zod.z.boolean().optional(),
26067
+ cacheTTL: zod.z.number().int().positive().optional(),
26068
+ maxCacheSize: zod.z.number().int().positive().optional(),
26069
+ maxRecursionDepth: zod.z.number().int().positive().optional(),
26070
+ enableParallelProcessing: zod.z.boolean().optional(),
26071
+ parallelBatchSize: zod.z.number().int().positive().optional()
26072
+ }).optional(),
26073
+ enableDebugLog: zod.z.boolean().optional()
26074
+ }).passthrough();
26054
26075
  /**
26055
26076
  * RouteConfig Schema
26056
26077
  */ const routeConfigSchema = zod.z.lazy(()=>zod.z.object({
26057
26078
  layout: componentImportSchema.optional().nullable(),
26058
26079
  page: componentImportSchema.optional().nullable(),
26059
26080
  loading: componentImportSchema.optional().nullable(),
26081
+ error: componentImportSchema.optional().nullable(),
26060
26082
  errors: componentImportSchema.optional().nullable(),
26061
26083
  name: zod.z.string().min(1, '路由名称不能为空'),
26062
26084
  path: zod.z.string().optional(),
@@ -26081,12 +26103,52 @@
26081
26103
  'hash',
26082
26104
  'memory'
26083
26105
  ]).optional(),
26084
- options: zod.z.any().optional(),
26106
+ options: routerOptionsSchema.optional(),
26085
26107
  pathResolve: zod.z.object({
26086
26108
  basePath: zod.z.string().optional(),
26087
26109
  pathAliases: zod.z.record(zod.z.string(), zod.z.string()).optional()
26088
26110
  }).optional(),
26089
- transformOptions: zod.z.any().optional()
26111
+ transformOptions: transformOptionsSchema.optional(),
26112
+ preload: zod.z.object({
26113
+ strategy: zod.z.enum([
26114
+ 'none',
26115
+ 'next-level',
26116
+ 'all',
26117
+ 'visible'
26118
+ ]).optional(),
26119
+ delay: zod.z.number().int().positive().optional(),
26120
+ priorityThreshold: zod.z.number().int().nonnegative().optional(),
26121
+ timeout: zod.z.number().int().positive().optional()
26122
+ }).optional(),
26123
+ enableHydrateFallback: zod.z.boolean().optional()
26124
+ }).superRefine((config, ctx)=>{
26125
+ if (!Array.isArray(config.routes)) {
26126
+ return;
26127
+ }
26128
+ const routeNameMap = new Map();
26129
+ const walk = (routes, parentPath)=>{
26130
+ routes.forEach((route, index)=>{
26131
+ const currentPath = `${parentPath}[${index}]`;
26132
+ const existingPath = routeNameMap.get(route.name);
26133
+ if (existingPath) {
26134
+ ctx.addIssue({
26135
+ code: zod.z.ZodIssueCode.custom,
26136
+ path: [
26137
+ 'routes',
26138
+ index,
26139
+ 'name'
26140
+ ],
26141
+ message: `路由名称重复: "${route.name}",首次定义位置 ${existingPath}`
26142
+ });
26143
+ } else {
26144
+ routeNameMap.set(route.name, currentPath);
26145
+ }
26146
+ if (Array.isArray(route.children) && route.children.length > 0) {
26147
+ walk(route.children, `${currentPath}.children`);
26148
+ }
26149
+ });
26150
+ };
26151
+ walk(config.routes, 'routes');
26090
26152
  });
26091
26153
  /**
26092
26154
  * 验证路由配置
@@ -26106,7 +26168,7 @@
26106
26168
  return routerConfigSchema.safeParse(config);
26107
26169
  }
26108
26170
 
26109
- function _define_property$p(obj, key, value) {
26171
+ function _define_property$q(obj, key, value) {
26110
26172
  if (key in obj) {
26111
26173
  Object.defineProperty(obj, key, {
26112
26174
  value: value,
@@ -26123,7 +26185,7 @@
26123
26185
  * 配置验证错误
26124
26186
  */ class ConfigValidationError extends Error {
26125
26187
  constructor(message, errors){
26126
- super(message), _define_property$p(this, "errors", void 0), this.errors = errors;
26188
+ super(message), _define_property$q(this, "errors", void 0), this.errors = errors;
26127
26189
  this.name = 'ConfigValidationError';
26128
26190
  }
26129
26191
  }
@@ -26292,7 +26354,7 @@
26292
26354
  }
26293
26355
  }
26294
26356
 
26295
- function _define_property$o(obj, key, value) {
26357
+ function _define_property$p(obj, key, value) {
26296
26358
  if (key in obj) {
26297
26359
  Object.defineProperty(obj, key, {
26298
26360
  value: value,
@@ -26404,7 +26466,7 @@
26404
26466
  return this.hooks.length;
26405
26467
  }
26406
26468
  constructor(){
26407
- _define_property$o(this, "hooks", []);
26469
+ _define_property$p(this, "hooks", []);
26408
26470
  }
26409
26471
  }
26410
26472
  /**
@@ -26417,7 +26479,7 @@
26417
26479
  return lifecycleManagerInstance;
26418
26480
  }
26419
26481
 
26420
- function _define_property$n(obj, key, value) {
26482
+ function _define_property$o(obj, key, value) {
26421
26483
  if (key in obj) {
26422
26484
  Object.defineProperty(obj, key, {
26423
26485
  value: value,
@@ -26508,16 +26570,35 @@
26508
26570
  for (const middlewareConfig of enabledMiddlewares){
26509
26571
  try {
26510
26572
  const result = await middlewareConfig.middleware(context);
26511
- // 如果中间件返回 false 或包含 allow: false,阻止导航
26512
- if (typeof result === 'object' && result.allow === false) {
26513
- logger.debug(`路由中间件阻止导航: ${middlewareConfig.name || 'anonymous'}`, result);
26514
- return typeof result === 'object' ? result : {
26573
+ // 如果中间件返回 false,阻止导航
26574
+ if (result === false) {
26575
+ logger.debug(`路由中间件阻止导航: ${middlewareConfig.name || 'anonymous'} -> false`);
26576
+ return {
26515
26577
  allow: false,
26516
26578
  reason: '中间件返回 false'
26517
26579
  };
26518
26580
  }
26581
+ // 如果中间件返回对象且 allow: false,阻止导航
26582
+ if (typeof result === 'object' && result !== null && result.allow === false) {
26583
+ logger.debug(`路由中间件阻止导航: ${middlewareConfig.name || 'anonymous'}`, result);
26584
+ if (result.redirect && !RouterMiddlewareManager.SAFE_REDIRECT_PATH_REGEX.test(result.redirect)) {
26585
+ logger.warn(`路由中间件返回了不安全的重定向地址,已拦截: ${middlewareConfig.name || 'anonymous'} -> ${result.redirect}`);
26586
+ return {
26587
+ allow: false,
26588
+ reason: '中间件返回了不安全的重定向地址'
26589
+ };
26590
+ }
26591
+ return result;
26592
+ }
26519
26593
  // 如果中间件返回字符串,重定向到该路径
26520
26594
  if (typeof result === 'string') {
26595
+ if (!RouterMiddlewareManager.SAFE_REDIRECT_PATH_REGEX.test(result)) {
26596
+ logger.warn(`路由中间件返回了不安全的重定向地址,已拦截: ${middlewareConfig.name || 'anonymous'} -> ${result}`);
26597
+ return {
26598
+ allow: false,
26599
+ reason: '中间件返回了不安全的重定向地址'
26600
+ };
26601
+ }
26521
26602
  logger.debug(`路由中间件重定向: ${middlewareConfig.name || 'anonymous'} -> ${result}`);
26522
26603
  return {
26523
26604
  allow: false,
@@ -26558,9 +26639,10 @@
26558
26639
  return this.middlewares.length;
26559
26640
  }
26560
26641
  constructor(){
26561
- _define_property$n(this, "middlewares", []);
26642
+ _define_property$o(this, "middlewares", []);
26562
26643
  }
26563
26644
  }
26645
+ _define_property$o(RouterMiddlewareManager, "SAFE_REDIRECT_PATH_REGEX", /^(\/|\.\/|\.\.\/|#)/);
26564
26646
  /**
26565
26647
  * 获取路由中间件管理器单例
26566
26648
  */ let middlewareManagerInstance = null;
@@ -26674,7 +26756,7 @@
26674
26756
  return new RouterError(message, code, severity, cause, context);
26675
26757
  }
26676
26758
 
26677
- function _define_property$m(obj, key, value) {
26759
+ function _define_property$n(obj, key, value) {
26678
26760
  if (key in obj) {
26679
26761
  Object.defineProperty(obj, key, {
26680
26762
  value: value,
@@ -26792,8 +26874,11 @@
26792
26874
  /**
26793
26875
  * 启动定期清理
26794
26876
  */ startCleanupInterval() {
26877
+ if (this.cleanupTimer) {
26878
+ clearInterval(this.cleanupTimer);
26879
+ }
26795
26880
  // 每 1 分钟清理一次过期缓存
26796
- setInterval(()=>{
26881
+ this.cleanupTimer = setInterval(()=>{
26797
26882
  this.cleanup();
26798
26883
  }, 60 * 1000);
26799
26884
  }
@@ -26803,15 +26888,18 @@
26803
26888
  const key = this.generateKey(routes);
26804
26889
  const item = this.cache.get(key);
26805
26890
  if (!item) {
26891
+ this.stats.transformMisses++;
26806
26892
  return null;
26807
26893
  }
26808
26894
  if (this.isExpired(item)) {
26809
26895
  this.cache.delete(key);
26896
+ this.stats.transformMisses++;
26810
26897
  return null;
26811
26898
  }
26812
26899
  // 更新访问信息
26813
26900
  item.lastAccessedAt = Date.now();
26814
26901
  item.accessCount++;
26902
+ this.stats.transformHits++;
26815
26903
  return item.value;
26816
26904
  }
26817
26905
  /**
@@ -26841,15 +26929,18 @@
26841
26929
  */ getMatch(path) {
26842
26930
  const item = this.matchCache.get(path);
26843
26931
  if (!item) {
26932
+ this.stats.matchMisses++;
26844
26933
  return undefined;
26845
26934
  }
26846
26935
  if (this.isExpired(item)) {
26847
26936
  this.matchCache.delete(path);
26937
+ this.stats.matchMisses++;
26848
26938
  return undefined;
26849
26939
  }
26850
26940
  // 更新访问信息
26851
26941
  item.lastAccessedAt = Date.now();
26852
26942
  item.accessCount++;
26943
+ this.stats.matchHits++;
26853
26944
  return item.value;
26854
26945
  }
26855
26946
  /**
@@ -26872,23 +26963,28 @@
26872
26963
  */ clear() {
26873
26964
  this.cache.clear();
26874
26965
  this.matchCache.clear();
26966
+ this.stats = {
26967
+ transformHits: 0,
26968
+ transformMisses: 0,
26969
+ matchHits: 0,
26970
+ matchMisses: 0
26971
+ };
26875
26972
  logger.debug('路由缓存已清空');
26876
26973
  }
26877
26974
  /**
26975
+ * 销毁缓存实例并释放资源
26976
+ */ destroy() {
26977
+ this.clear();
26978
+ if (this.cleanupTimer) {
26979
+ clearInterval(this.cleanupTimer);
26980
+ this.cleanupTimer = null;
26981
+ }
26982
+ }
26983
+ /**
26878
26984
  * 获取缓存统计信息
26879
26985
  */ getStats() {
26880
- let totalHits = 0;
26881
- let totalAccess = 0;
26882
- // 统计转换结果缓存
26883
- for (const item of this.cache.values()){
26884
- totalHits += item.accessCount;
26885
- totalAccess += item.accessCount;
26886
- }
26887
- // 统计匹配结果缓存
26888
- for (const item of this.matchCache.values()){
26889
- totalHits += item.accessCount;
26890
- totalAccess += item.accessCount;
26891
- }
26986
+ const totalHits = this.stats.transformHits + this.stats.matchHits;
26987
+ const totalAccess = totalHits + this.stats.transformMisses + this.stats.matchMisses;
26892
26988
  const hitRate = totalAccess > 0 ? totalHits / totalAccess : 0;
26893
26989
  return {
26894
26990
  transformCacheSize: this.cache.size,
@@ -26898,10 +26994,17 @@
26898
26994
  };
26899
26995
  }
26900
26996
  constructor(config = {}){
26901
- _define_property$m(this, "cache", new Map());
26902
- _define_property$m(this, "matchCache", new Map());
26903
- _define_property$m(this, "config", void 0);
26904
- _define_property$m(this, "persistenceEnabled", false);
26997
+ _define_property$n(this, "cache", new Map());
26998
+ _define_property$n(this, "matchCache", new Map());
26999
+ _define_property$n(this, "config", void 0);
27000
+ _define_property$n(this, "persistenceEnabled", false);
27001
+ _define_property$n(this, "cleanupTimer", null);
27002
+ _define_property$n(this, "stats", {
27003
+ transformHits: 0,
27004
+ transformMisses: 0,
27005
+ matchHits: 0,
27006
+ matchMisses: 0
27007
+ });
26905
27008
  this.config = {
26906
27009
  maxSize: config.maxSize ?? 50,
26907
27010
  ttl: config.ttl ?? 5 * 60 * 1000,
@@ -26926,7 +27029,7 @@
26926
27029
  return routeCacheInstance;
26927
27030
  }
26928
27031
 
26929
- function _define_property$l(obj, key, value) {
27032
+ function _define_property$m(obj, key, value) {
26930
27033
  if (key in obj) {
26931
27034
  Object.defineProperty(obj, key, {
26932
27035
  value: value,
@@ -26960,36 +27063,49 @@
26960
27063
  * 路由预加载管理器
26961
27064
  */ class RoutePreloader {
26962
27065
  /**
27066
+ * 更新预加载配置
27067
+ */ updateConfig(config = {}) {
27068
+ this.config = {
27069
+ strategy: config.strategy ?? "none",
27070
+ delay: config.delay ?? 1000,
27071
+ priorityThreshold: config.priorityThreshold ?? 10,
27072
+ timeout: config.timeout ?? 5000
27073
+ };
27074
+ }
27075
+ shouldRegister(priority) {
27076
+ if (this.config.strategy === "none") {
27077
+ return false;
27078
+ }
27079
+ if (this.config.strategy === "visible" && priority > this.config.priorityThreshold) {
27080
+ return false;
27081
+ }
27082
+ return true;
27083
+ }
27084
+ registerTask(key, importFn, routeName, priority) {
27085
+ if (!this.shouldRegister(priority)) {
27086
+ return;
27087
+ }
27088
+ this.tasks.set(key, {
27089
+ importFn,
27090
+ routeName,
27091
+ priority,
27092
+ status: 'pending'
27093
+ });
27094
+ }
27095
+ /**
26963
27096
  * 注册路由用于预加载
26964
27097
  */ registerRoute(route) {
26965
27098
  if (!route.page && !route.layout) {
26966
27099
  return;
26967
27100
  }
26968
27101
  const priority = route.handle?.order ?? 999;
26969
- // 根据策略决定是否注册
26970
- if (this.config.strategy === "none") {
26971
- return;
26972
- }
26973
- if (this.config.strategy === "visible" && priority > this.config.priorityThreshold) {
26974
- return;
26975
- }
26976
27102
  // 注册页面组件
26977
27103
  if (route.page && typeof route.page === 'function') {
26978
- this.tasks.set(`${route.name}_page`, {
26979
- importFn: route.page,
26980
- routeName: route.name,
26981
- priority,
26982
- status: 'pending'
26983
- });
27104
+ this.registerTask(`${route.name}_page`, route.page, route.name, priority);
26984
27105
  }
26985
27106
  // 注册布局组件
26986
27107
  if (route.layout && typeof route.layout === 'function') {
26987
- this.tasks.set(`${route.name}_layout`, {
26988
- importFn: route.layout,
26989
- routeName: route.name,
26990
- priority,
26991
- status: 'pending'
26992
- });
27108
+ this.registerTask(`${route.name}_layout`, route.layout, route.name, priority);
26993
27109
  }
26994
27110
  // 递归注册子路由
26995
27111
  if (route.children) {
@@ -26998,8 +27114,43 @@
26998
27114
  }
26999
27115
  /**
27000
27116
  * 注册多个路由
27001
- */ registerRoutes(routes) {
27117
+ */ registerRoutes(routes, resolvers) {
27118
+ const priorityByPath = new Map();
27119
+ const nameByPath = new Map();
27120
+ const collectPriority = (route)=>{
27121
+ const priority = route.handle?.order ?? 999;
27122
+ const routeName = route.name;
27123
+ const record = (value)=>{
27124
+ if (typeof value !== 'string') {
27125
+ return;
27126
+ }
27127
+ if (!priorityByPath.has(value) || (priorityByPath.get(value) ?? 999) > priority) {
27128
+ priorityByPath.set(value, priority);
27129
+ nameByPath.set(value, routeName);
27130
+ }
27131
+ };
27132
+ record(route.page);
27133
+ record(route.layout);
27134
+ record(route.error ?? route.errors);
27135
+ record(route.loading);
27136
+ route.children?.forEach(collectPriority);
27137
+ };
27138
+ routes.forEach(collectPriority);
27002
27139
  routes.forEach((route)=>this.registerRoute(route));
27140
+ if (!resolvers) {
27141
+ return;
27142
+ }
27143
+ const registerResolverMap = (map, type)=>{
27144
+ for (const [path, importFn] of map.entries()){
27145
+ const routeName = nameByPath.get(path) ?? path;
27146
+ const priority = priorityByPath.get(path) ?? 999;
27147
+ this.registerTask(`${routeName}_${type}_${path}`, importFn, routeName, priority);
27148
+ }
27149
+ };
27150
+ registerResolverMap(resolvers.pages, 'page');
27151
+ registerResolverMap(resolvers.layouts, 'layout');
27152
+ registerResolverMap(resolvers.errors, 'error');
27153
+ registerResolverMap(resolvers.loadings, 'loading');
27003
27154
  }
27004
27155
  /**
27005
27156
  * 预加载指定路由
@@ -27018,10 +27169,11 @@
27018
27169
  }
27019
27170
  task.status = 'loading';
27020
27171
  task.startTime = Date.now();
27172
+ let timeoutId = null;
27021
27173
  try {
27022
27174
  // 设置超时
27023
27175
  const timeoutPromise = new Promise((_, reject)=>{
27024
- setTimeout(()=>reject(new Error('预加载超时')), this.config.timeout);
27176
+ timeoutId = setTimeout(()=>reject(new Error('预加载超时')), this.config.timeout);
27025
27177
  });
27026
27178
  // 执行预加载
27027
27179
  await Promise.race([
@@ -27034,6 +27186,10 @@
27034
27186
  } catch (error) {
27035
27187
  task.status = 'failed';
27036
27188
  logger.warn(`路由组件预加载失败: ${task.routeName}`, error);
27189
+ } finally{
27190
+ if (timeoutId) {
27191
+ clearTimeout(timeoutId);
27192
+ }
27037
27193
  }
27038
27194
  }
27039
27195
  /**
@@ -27042,8 +27198,16 @@
27042
27198
  if (this.config.strategy === "none") {
27043
27199
  return;
27044
27200
  }
27201
+ this.stopPreload();
27045
27202
  // 延迟预加载,避免影响初始渲染
27046
27203
  this.preloadTimer = setTimeout(()=>{
27204
+ const browserWindow = typeof window !== 'undefined' ? window : undefined;
27205
+ if (browserWindow?.requestIdleCallback) {
27206
+ this.idleHandle = browserWindow.requestIdleCallback(()=>{
27207
+ this.executePreload();
27208
+ });
27209
+ return;
27210
+ }
27047
27211
  this.executePreload();
27048
27212
  }, this.config.delay);
27049
27213
  }
@@ -27082,10 +27246,15 @@
27082
27246
  /**
27083
27247
  * 停止预加载
27084
27248
  */ stopPreload() {
27249
+ const browserWindow = typeof window !== 'undefined' ? window : undefined;
27085
27250
  if (this.preloadTimer) {
27086
27251
  clearTimeout(this.preloadTimer);
27087
27252
  this.preloadTimer = null;
27088
27253
  }
27254
+ if (this.idleHandle !== null && browserWindow?.cancelIdleCallback) {
27255
+ browserWindow.cancelIdleCallback(this.idleHandle);
27256
+ this.idleHandle = null;
27257
+ }
27089
27258
  }
27090
27259
  /**
27091
27260
  * 清空所有任务
@@ -27110,11 +27279,12 @@
27110
27279
  return stats;
27111
27280
  }
27112
27281
  constructor(config = {}){
27113
- _define_property$l(this, "tasks", new Map());
27114
- _define_property$l(this, "config", void 0);
27115
- _define_property$l(this, "preloadTimer", null);
27282
+ _define_property$m(this, "tasks", new Map());
27283
+ _define_property$m(this, "config", void 0);
27284
+ _define_property$m(this, "preloadTimer", null);
27285
+ _define_property$m(this, "idleHandle", null);
27116
27286
  this.config = {
27117
- strategy: config.strategy ?? "next-level",
27287
+ strategy: config.strategy ?? "none",
27118
27288
  delay: config.delay ?? 1000,
27119
27289
  priorityThreshold: config.priorityThreshold ?? 10,
27120
27290
  timeout: config.timeout ?? 5000
@@ -27163,7 +27333,7 @@
27163
27333
  return PluginLifecycleStage;
27164
27334
  }({});
27165
27335
 
27166
- function _define_property$k(obj, key, value) {
27336
+ function _define_property$l(obj, key, value) {
27167
27337
  if (key in obj) {
27168
27338
  Object.defineProperty(obj, key, {
27169
27339
  value: value,
@@ -27392,7 +27562,7 @@
27392
27562
  return this.plugins.size;
27393
27563
  }
27394
27564
  constructor(){
27395
- _define_property$k(this, "plugins", new Map());
27565
+ _define_property$l(this, "plugins", new Map());
27396
27566
  }
27397
27567
  }
27398
27568
  /**
@@ -27405,7 +27575,7 @@
27405
27575
  return pluginManagerInstance;
27406
27576
  }
27407
27577
 
27408
- function _define_property$j(obj, key, value) {
27578
+ function _define_property$k(obj, key, value) {
27409
27579
  if (key in obj) {
27410
27580
  Object.defineProperty(obj, key, {
27411
27581
  value: value,
@@ -27586,12 +27756,12 @@
27586
27756
  };
27587
27757
  }
27588
27758
  constructor(config = {}){
27589
- _define_property$j(this, "accessRecords", []);
27590
- _define_property$j(this, "performanceMetrics", new Map());
27591
- _define_property$j(this, "config", void 0);
27592
- _define_property$j(this, "monitoringService", getMonitoring());
27593
- _define_property$j(this, "currentRouteStartTime", 0);
27594
- _define_property$j(this, "currentRoute", void 0);
27759
+ _define_property$k(this, "accessRecords", []);
27760
+ _define_property$k(this, "performanceMetrics", new Map());
27761
+ _define_property$k(this, "config", void 0);
27762
+ _define_property$k(this, "monitoringService", getMonitoring());
27763
+ _define_property$k(this, "currentRouteStartTime", 0);
27764
+ _define_property$k(this, "currentRoute", void 0);
27595
27765
  this.config = {
27596
27766
  enabled: config.enabled ?? true,
27597
27767
  trackAccess: config.trackAccess ?? true,
@@ -27612,7 +27782,7 @@
27612
27782
  return routerMonitoringInstance;
27613
27783
  }
27614
27784
 
27615
- function _define_property$i(obj, key, value) {
27785
+ function _define_property$j(obj, key, value) {
27616
27786
  if (key in obj) {
27617
27787
  Object.defineProperty(obj, key, {
27618
27788
  value: value,
@@ -27812,9 +27982,9 @@
27812
27982
  return this.adapters.size;
27813
27983
  }
27814
27984
  constructor(){
27815
- _define_property$i(this, "adapters", new Map());
27816
- _define_property$i(this, "currentAdapter", null);
27817
- _define_property$i(this, "defaultAdapterName", null);
27985
+ _define_property$j(this, "adapters", new Map());
27986
+ _define_property$j(this, "currentAdapter", null);
27987
+ _define_property$j(this, "defaultAdapterName", null);
27818
27988
  }
27819
27989
  }
27820
27990
  /**
@@ -27829,7 +27999,7 @@
27829
27999
 
27830
28000
  /**
27831
28001
  * React Router 适配器实现
27832
- */ function _define_property$h(obj, key, value) {
28002
+ */ function _define_property$i(obj, key, value) {
27833
28003
  if (key in obj) {
27834
28004
  Object.defineProperty(obj, key, {
27835
28005
  value: value,
@@ -27850,7 +28020,7 @@
27850
28020
  */ async initialize(config) {
27851
28021
  // 转换路由配置
27852
28022
  const transformResult = await transformRoutes(config.routes);
27853
- const reactRoutes = await transformRoutesToReactRoutes(transformResult.routes, transformResult, config.defaultRouteErrorComponent, config.defaultRouteLoadingComponent);
28023
+ const reactRoutes = await transformRoutesToReactRoutes(transformResult.routes, transformResult, config.defaultRouteErrorComponent, config.defaultRouteLoadingComponent, Boolean(config.options?.hydrationData));
27854
28024
  // 创建路由实例
27855
28025
  const mode = config.mode || 'browser';
27856
28026
  if (mode === 'browser') {
@@ -27925,9 +28095,9 @@
27925
28095
  logger.debug('React Router 适配器已销毁');
27926
28096
  }
27927
28097
  constructor(){
27928
- _define_property$h(this, "name", 'react-router');
27929
- _define_property$h(this, "version", '6.0.0');
27930
- _define_property$h(this, "router", null);
28098
+ _define_property$i(this, "name", 'react-router');
28099
+ _define_property$i(this, "version", '6.0.0');
28100
+ _define_property$i(this, "router", null);
27931
28101
  }
27932
28102
  }
27933
28103
  /**
@@ -27938,7 +28108,7 @@
27938
28108
  };
27939
28109
  }
27940
28110
 
27941
- function _define_property$g(obj, key, value) {
28111
+ function _define_property$h(obj, key, value) {
27942
28112
  if (key in obj) {
27943
28113
  Object.defineProperty(obj, key, {
27944
28114
  value: value,
@@ -27998,6 +28168,9 @@
27998
28168
  if (!config.routes) {
27999
28169
  throw new RouterError('路由配置不能为空', RouterErrorCode.ROUTER_CONFIG_ERROR);
28000
28170
  }
28171
+ // 更新预加载策略(默认关闭,按需懒加载)
28172
+ this.preloader.updateConfig(config.preload);
28173
+ this.preloader.clear();
28001
28174
  let result;
28002
28175
  const cacheKey = config.routes;
28003
28176
  const cachedResult = this.cache.get(cacheKey);
@@ -28018,13 +28191,15 @@
28018
28191
  // 缓存转换结果
28019
28192
  this.cache.set(cacheKey, result);
28020
28193
  }
28021
- const reactRoutes = await transformRoutesToReactRoutes(result.routes, result, config.defaultRouteErrorComponent, config.defaultRouteLoadingComponent);
28194
+ const enableHydrateFallback = config.enableHydrateFallback ?? Boolean(config.options?.hydrationData);
28195
+ const reactRoutes = await transformRoutesToReactRoutes(result.routes, result, config.defaultRouteErrorComponent, config.defaultRouteLoadingComponent, enableHydrateFallback);
28022
28196
  // 注册路由到预加载器
28023
28197
  if (result.routes) {
28024
- this.preloader.registerRoutes(result.routes);
28198
+ this.preloader.registerRoutes(result.routes, result);
28025
28199
  // 开始预加载
28026
28200
  this.preloader.startPreload();
28027
28201
  }
28202
+ await this.resolveInitialLazyRoutes(reactRoutes, !enableHydrateFallback);
28028
28203
  let routerInstance = null;
28029
28204
  if (config.mode === 'browser') {
28030
28205
  routerInstance = reactRouterDom.createBrowserRouter(reactRoutes, config.options);
@@ -28047,14 +28222,58 @@
28047
28222
  routes: result.routes
28048
28223
  });
28049
28224
  // 记录监控:路由初始化完成
28225
+ const initialPath = typeof window !== 'undefined' ? `${window.location.pathname}${window.location.search}${window.location.hash}` : this.router?.state?.location?.pathname ?? '/';
28050
28226
  this.monitoring.trackRouteAccess({
28051
- path: window.location.pathname,
28227
+ path: initialPath,
28052
28228
  meta: {
28053
28229
  name: 'router-init'
28054
28230
  }
28055
28231
  }, undefined, true);
28056
28232
  logger.info('路由管理器初始化完成');
28057
28233
  }
28234
+ /**
28235
+ * 预解析 lazy 路由,避免首屏或重定向链路长时间停留在 hydrate fallback。
28236
+ * resolveAll=true 时会在初始化阶段解析全部 lazy 路由。
28237
+ */ async resolveInitialLazyRoutes(routes, resolveAll = false) {
28238
+ if (typeof window === 'undefined') {
28239
+ return;
28240
+ }
28241
+ let targetRoutes = [];
28242
+ if (resolveAll) {
28243
+ const stack = [
28244
+ ...routes
28245
+ ];
28246
+ while(stack.length > 0){
28247
+ const current = stack.shift();
28248
+ if (!current) {
28249
+ continue;
28250
+ }
28251
+ targetRoutes.push(current);
28252
+ if (current.children && current.children.length > 0) {
28253
+ stack.push(...current.children);
28254
+ }
28255
+ }
28256
+ } else {
28257
+ const matches = reactRouterDom.matchRoutes(routes, window.location.pathname) ?? [];
28258
+ if (matches.length === 0) {
28259
+ return;
28260
+ }
28261
+ targetRoutes = matches.map((match)=>match.route);
28262
+ }
28263
+ await Promise.all(targetRoutes.map(async (route)=>{
28264
+ const lazy = route.lazy;
28265
+ if (typeof lazy !== 'function') {
28266
+ return;
28267
+ }
28268
+ try {
28269
+ const resolved = await lazy();
28270
+ Object.assign(route, resolved);
28271
+ delete route.lazy;
28272
+ } catch (error) {
28273
+ logger.warn('首屏路由懒加载预解析失败,回退到 Router 默认懒加载', error);
28274
+ }
28275
+ }));
28276
+ }
28058
28277
  /**
28059
28278
  * 获取路由实例
28060
28279
  *
@@ -28111,25 +28330,25 @@
28111
28330
  /**
28112
28331
  * 路由实例
28113
28332
  * 只能在 initialize 方法中赋值
28114
- */ _define_property$g(this, "router", null);
28333
+ */ _define_property$h(this, "router", null);
28115
28334
  /**
28116
28335
  * 是否已初始化
28117
- */ _define_property$g(this, "initialized", false);
28336
+ */ _define_property$h(this, "initialized", false);
28118
28337
  /**
28119
28338
  * 路由缓存实例
28120
- */ _define_property$g(this, "cache", getRouteCache());
28339
+ */ _define_property$h(this, "cache", getRouteCache());
28121
28340
  /**
28122
28341
  * 路由预加载器实例
28123
- */ _define_property$g(this, "preloader", getRoutePreloader());
28342
+ */ _define_property$h(this, "preloader", getRoutePreloader());
28124
28343
  /**
28125
28344
  * 路由插件管理器实例
28126
- */ _define_property$g(this, "pluginManager", getRouterPluginManager());
28345
+ */ _define_property$h(this, "pluginManager", getRouterPluginManager());
28127
28346
  /**
28128
28347
  * 路由监控服务实例
28129
- */ _define_property$g(this, "monitoring", getRouterMonitoring());
28348
+ */ _define_property$h(this, "monitoring", getRouterMonitoring());
28130
28349
  /**
28131
28350
  * 路由适配器管理器实例
28132
- */ _define_property$g(this, "adapterManager", getAdapterManager());
28351
+ */ _define_property$h(this, "adapterManager", getAdapterManager());
28133
28352
  // 私有构造函数
28134
28353
  // 注册默认的 React Router 适配器
28135
28354
  this.adapterManager.register({
@@ -28139,7 +28358,7 @@
28139
28358
  });
28140
28359
  }
28141
28360
  }
28142
- _define_property$g(RouterManager, "instance", null);
28361
+ _define_property$h(RouterManager, "instance", null);
28143
28362
  /**
28144
28363
  * 获取路由管理器
28145
28364
  */ function getRouterManager() {
@@ -28152,7 +28371,7 @@
28152
28371
  getRouterManager: getRouterManager
28153
28372
  });
28154
28373
 
28155
- function _define_property$f(obj, key, value) {
28374
+ function _define_property$g(obj, key, value) {
28156
28375
  if (key in obj) {
28157
28376
  Object.defineProperty(obj, key, {
28158
28377
  value: value,
@@ -28400,15 +28619,15 @@
28400
28619
  return this.container;
28401
28620
  }
28402
28621
  constructor(){
28403
- _define_property$f(this, "root", null);
28404
- _define_property$f(this, "container", null);
28622
+ _define_property$g(this, "root", null);
28623
+ _define_property$g(this, "container", null);
28405
28624
  }
28406
28625
  }
28407
28626
 
28408
28627
  /**
28409
28628
  * 性能追踪模块
28410
28629
  * 负责收集和上报启动性能指标
28411
- */ function _define_property$e(obj, key, value) {
28630
+ */ function _define_property$f(obj, key, value) {
28412
28631
  if (key in obj) {
28413
28632
  Object.defineProperty(obj, key, {
28414
28633
  value: value,
@@ -28563,9 +28782,9 @@
28563
28782
  return performance.now() - this.startTime;
28564
28783
  }
28565
28784
  constructor(monitoring){
28566
- _define_property$e(this, "monitoring", void 0);
28567
- _define_property$e(this, "metrics", {});
28568
- _define_property$e(this, "startTime", void 0);
28785
+ _define_property$f(this, "monitoring", void 0);
28786
+ _define_property$f(this, "metrics", {});
28787
+ _define_property$f(this, "startTime", void 0);
28569
28788
  this.monitoring = monitoring;
28570
28789
  this.startTime = performance.now();
28571
28790
  }
@@ -28574,7 +28793,7 @@
28574
28793
  /**
28575
28794
  * 应用实例管理模块
28576
28795
  * 支持多实例隔离
28577
- */ function _define_property$d(obj, key, value) {
28796
+ */ function _define_property$e(obj, key, value) {
28578
28797
  if (key in obj) {
28579
28798
  Object.defineProperty(obj, key, {
28580
28799
  value: value,
@@ -28666,25 +28885,25 @@
28666
28885
  constructor(id, options){
28667
28886
  /**
28668
28887
  * 实例ID
28669
- */ _define_property$d(this, "id", void 0);
28888
+ */ _define_property$e(this, "id", void 0);
28670
28889
  /**
28671
28890
  * 应用渲染器
28672
- */ _define_property$d(this, "renderer", void 0);
28891
+ */ _define_property$e(this, "renderer", void 0);
28673
28892
  /**
28674
28893
  * 服务实例
28675
- */ _define_property$d(this, "services", null);
28894
+ */ _define_property$e(this, "services", null);
28676
28895
  /**
28677
28896
  * 性能追踪器
28678
- */ _define_property$d(this, "performanceTracker", null);
28897
+ */ _define_property$e(this, "performanceTracker", null);
28679
28898
  /**
28680
28899
  * 启动配置
28681
- */ _define_property$d(this, "options", void 0);
28900
+ */ _define_property$e(this, "options", void 0);
28682
28901
  /**
28683
28902
  * 是否已初始化
28684
- */ _define_property$d(this, "initialized", false);
28903
+ */ _define_property$e(this, "initialized", false);
28685
28904
  /**
28686
28905
  * 是否已销毁
28687
- */ _define_property$d(this, "destroyed", false);
28906
+ */ _define_property$e(this, "destroyed", false);
28688
28907
  this.id = id;
28689
28908
  this.options = options;
28690
28909
  this.renderer = new AppRenderer();
@@ -28782,19 +29001,19 @@
28782
29001
  this.defaultInstanceId = null;
28783
29002
  }
28784
29003
  constructor(){
28785
- _define_property$d(this, "instances", new Map());
28786
- _define_property$d(this, "defaultInstanceId", null);
29004
+ _define_property$e(this, "instances", new Map());
29005
+ _define_property$e(this, "defaultInstanceId", null);
28787
29006
  // 私有构造函数
28788
29007
  }
28789
29008
  }
28790
- _define_property$d(AppInstanceManager, "instance", null);
29009
+ _define_property$e(AppInstanceManager, "instance", null);
28791
29010
  /**
28792
29011
  * 获取应用实例管理器
28793
29012
  */ function getAppInstanceManager() {
28794
29013
  return AppInstanceManager.getInstance();
28795
29014
  }
28796
29015
 
28797
- function _define_property$c(obj, key, value) {
29016
+ function _define_property$d(obj, key, value) {
28798
29017
  if (key in obj) {
28799
29018
  Object.defineProperty(obj, key, {
28800
29019
  value: value,
@@ -28930,17 +29149,17 @@
28930
29149
  }
28931
29150
  }
28932
29151
  constructor(){
28933
- _define_property$c(this, "environment", void 0);
28934
- _define_property$c(this, "isBrowser", void 0);
28935
- _define_property$c(this, "isSSR", void 0);
28936
- _define_property$c(this, "isMicroFrontend", void 0);
29152
+ _define_property$d(this, "environment", void 0);
29153
+ _define_property$d(this, "isBrowser", void 0);
29154
+ _define_property$d(this, "isSSR", void 0);
29155
+ _define_property$d(this, "isMicroFrontend", void 0);
28937
29156
  this.isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
28938
29157
  this.isSSR = typeof window === 'undefined' && typeof process !== 'undefined';
28939
29158
  this.isMicroFrontend = this.detectMicroFrontend();
28940
29159
  this.environment = this.detectEnvironment();
28941
29160
  }
28942
29161
  }
28943
- _define_property$c(EnvironmentDetector, "instance", null);
29162
+ _define_property$d(EnvironmentDetector, "instance", null);
28944
29163
  /**
28945
29164
  * 获取环境检测器实例
28946
29165
  */ function getEnvironmentDetector() {
@@ -29005,7 +29224,7 @@
29005
29224
  /**
29006
29225
  * 框架生命周期事件集成
29007
29226
  * 自动在框架关键节点触发事件
29008
- */ function _define_property$b(obj, key, value) {
29227
+ */ function _define_property$c(obj, key, value) {
29009
29228
  if (key in obj) {
29010
29229
  Object.defineProperty(obj, key, {
29011
29230
  value: value,
@@ -29130,12 +29349,12 @@
29130
29349
  });
29131
29350
  }
29132
29351
  constructor(eventBus){
29133
- _define_property$b(this, "eventBus", void 0);
29352
+ _define_property$c(this, "eventBus", void 0);
29134
29353
  this.eventBus = eventBus;
29135
29354
  }
29136
29355
  }
29137
29356
 
29138
- function _define_property$a(obj, key, value) {
29357
+ function _define_property$b(obj, key, value) {
29139
29358
  if (key in obj) {
29140
29359
  Object.defineProperty(obj, key, {
29141
29360
  value: value,
@@ -29157,7 +29376,7 @@
29157
29376
  }
29158
29377
  class KernelBootError extends Error {
29159
29378
  constructor(message, options){
29160
- super(message), _define_property$a(this, "code", void 0), _define_property$a(this, "phase", void 0), _define_property$a(this, "severity", void 0), _define_property$a(this, "retryable", void 0), _define_property$a(this, "traceId", void 0), _define_property$a(this, "cause", void 0);
29379
+ super(message), _define_property$b(this, "code", void 0), _define_property$b(this, "phase", void 0), _define_property$b(this, "severity", void 0), _define_property$b(this, "retryable", void 0), _define_property$b(this, "traceId", void 0), _define_property$b(this, "cause", void 0);
29161
29380
  this.name = 'KernelBootError';
29162
29381
  this.code = options.code;
29163
29382
  this.phase = options.phase;
@@ -29187,7 +29406,7 @@
29187
29406
  });
29188
29407
  }
29189
29408
 
29190
- function _define_property$9(obj, key, value) {
29409
+ function _define_property$a(obj, key, value) {
29191
29410
  if (key in obj) {
29192
29411
  Object.defineProperty(obj, key, {
29193
29412
  value: value,
@@ -29264,7 +29483,7 @@
29264
29483
  }
29265
29484
  }
29266
29485
  constructor(){
29267
- _define_property$9(this, "instance", null);
29486
+ _define_property$a(this, "instance", null);
29268
29487
  }
29269
29488
  };
29270
29489
  let DefaultEventBusAdapter = class DefaultEventBusAdapter {
@@ -29296,7 +29515,7 @@
29296
29515
  }
29297
29516
  }
29298
29517
  constructor(){
29299
- _define_property$9(this, "bus", null);
29518
+ _define_property$a(this, "bus", null);
29300
29519
  }
29301
29520
  };
29302
29521
  const defaultI18nAdapter = {
@@ -29846,7 +30065,7 @@
29846
30065
  }
29847
30066
  }
29848
30067
 
29849
- function _define_property$8(obj, key, value) {
30068
+ function _define_property$9(obj, key, value) {
29850
30069
  if (key in obj) {
29851
30070
  Object.defineProperty(obj, key, {
29852
30071
  value: value,
@@ -29900,7 +30119,7 @@
29900
30119
  this.listeners.clear();
29901
30120
  }
29902
30121
  constructor(){
29903
- _define_property$8(this, "listeners", new Set());
30122
+ _define_property$9(this, "listeners", new Set());
29904
30123
  }
29905
30124
  };
29906
30125
  /**
@@ -30177,15 +30396,48 @@
30177
30396
  };
30178
30397
  }
30179
30398
 
30399
+ function _define_property$8(obj, key, value) {
30400
+ if (key in obj) {
30401
+ Object.defineProperty(obj, key, {
30402
+ value: value,
30403
+ enumerable: true,
30404
+ configurable: true,
30405
+ writable: true
30406
+ });
30407
+ } else {
30408
+ obj[key] = value;
30409
+ }
30410
+ return obj;
30411
+ }
30180
30412
  /**
30181
30413
  * 路由导航器
30182
30414
  */ class RouterNavigation {
30183
- /**
30184
- * 导航到指定路径
30185
- *
30186
- * @param to - 目标路径或路由名称
30187
- * @param options - 导航选项
30188
- */ static async navigate(to, options) {
30415
+ static buildTargetPath(to, query) {
30416
+ const base = typeof window !== 'undefined' && window.location?.origin ? window.location.origin : 'http://localhost';
30417
+ const url = new URL(to, base);
30418
+ if (query && Object.keys(query).length > 0) {
30419
+ const params = new URLSearchParams(url.search);
30420
+ Object.entries(query).forEach(([key, value])=>{
30421
+ if (value === undefined || value === null) {
30422
+ params.delete(key);
30423
+ return;
30424
+ }
30425
+ params.set(key, String(value));
30426
+ });
30427
+ url.search = params.toString();
30428
+ }
30429
+ return `${url.pathname}${url.search}${url.hash}`;
30430
+ }
30431
+ static async navigateInternal(to, options, depth, visited) {
30432
+ const startTime = performance.now();
30433
+ if (depth > this.MAX_REDIRECTS) {
30434
+ throw new Error(`路由重定向次数超过上限(${this.MAX_REDIRECTS}),可能存在循环重定向`);
30435
+ }
30436
+ const targetPath = this.buildTargetPath(to, options?.query);
30437
+ if (visited.has(targetPath)) {
30438
+ throw new Error(`检测到循环重定向: ${targetPath}`);
30439
+ }
30440
+ visited.add(targetPath);
30189
30441
  const routerManager = await Promise.resolve().then(function () { return RouterManager$1; }).then((m)=>m.getRouterManager());
30190
30442
  const router = routerManager.getRouter();
30191
30443
  if (!router) {
@@ -30195,12 +30447,13 @@
30195
30447
  const currentLocation = this.getCurrentRoute();
30196
30448
  // 构建目标路由位置
30197
30449
  const targetLocation = {
30198
- path: to,
30450
+ path: targetPath,
30199
30451
  query: options?.query
30200
30452
  };
30201
30453
  // 执行生命周期钩子
30202
30454
  const lifecycleManager = getRouterLifecycleManager();
30203
30455
  const beforeEachResult = await lifecycleManager.beforeEach(targetLocation, currentLocation);
30456
+ let finalPath = targetPath;
30204
30457
  // 如果 beforeEach 返回 false,阻止导航
30205
30458
  if (beforeEachResult === false) {
30206
30459
  logger.debug('路由导航被阻止: beforeEach 返回 false');
@@ -30209,14 +30462,14 @@
30209
30462
  // 如果 beforeEach 返回字符串,重定向到该路径
30210
30463
  if (typeof beforeEachResult === 'string') {
30211
30464
  logger.debug(`路由导航重定向: ${beforeEachResult}`);
30212
- to = beforeEachResult;
30465
+ finalPath = this.buildTargetPath(beforeEachResult);
30213
30466
  }
30214
30467
  // 执行中间件
30215
30468
  const middlewareManager = getRouterMiddlewareManager();
30216
30469
  const middlewareContext = {
30217
30470
  to: {
30218
30471
  ...targetLocation,
30219
- path: to
30472
+ path: finalPath
30220
30473
  },
30221
30474
  from: currentLocation,
30222
30475
  options
@@ -30226,8 +30479,10 @@
30226
30479
  if (!middlewareResult.allow) {
30227
30480
  if (middlewareResult.redirect) {
30228
30481
  logger.debug(`路由导航被中间件重定向: ${middlewareResult.redirect}`);
30229
- // 递归调用 navigate 进行重定向
30230
- return this.navigate(middlewareResult.redirect, options);
30482
+ return this.navigateInternal(middlewareResult.redirect, {
30483
+ ...options,
30484
+ query: undefined
30485
+ }, depth + 1, visited);
30231
30486
  }
30232
30487
  logger.debug(`路由导航被中间件阻止: ${middlewareResult.reason || '未知原因'}`);
30233
30488
  return;
@@ -30235,30 +30490,48 @@
30235
30490
  // 执行导航
30236
30491
  try {
30237
30492
  if (options?.replace) {
30238
- router.navigate(to, {
30493
+ router.navigate(finalPath, {
30239
30494
  replace: true,
30240
30495
  state: options.state
30241
30496
  });
30242
30497
  } else {
30243
- router.navigate(to, {
30498
+ router.navigate(finalPath, {
30244
30499
  state: options?.state
30245
30500
  });
30246
30501
  }
30247
30502
  // 执行 afterEach 钩子
30248
30503
  await lifecycleManager.afterEach({
30249
30504
  ...targetLocation,
30250
- path: to
30505
+ path: finalPath
30251
30506
  }, currentLocation);
30507
+ const duration = performance.now() - startTime;
30508
+ routerManager.getMonitoring().trackRoutePerformance(finalPath, {
30509
+ totalTime: duration
30510
+ });
30252
30511
  } catch (error) {
30253
30512
  logger.error('路由导航失败', error);
30254
30513
  throw error;
30255
30514
  }
30256
30515
  }
30257
30516
  /**
30517
+ * 导航到指定路径
30518
+ *
30519
+ * @param to - 目标路径或路由名称
30520
+ * @param options - 导航选项
30521
+ */ static async navigate(to, options) {
30522
+ return this.navigateInternal(to, options, 0, new Set());
30523
+ }
30524
+ /**
30258
30525
  * 获取当前路由信息
30259
30526
  *
30260
30527
  * @returns 当前路由位置信息
30261
30528
  */ static getCurrentRoute() {
30529
+ if (typeof window === 'undefined') {
30530
+ return {
30531
+ path: '/',
30532
+ query: {}
30533
+ };
30534
+ }
30262
30535
  // 从 window.location 获取当前路由信息
30263
30536
  const pathname = window.location.pathname;
30264
30537
  const search = window.location.search;
@@ -30306,6 +30579,7 @@
30306
30579
  });
30307
30580
  }
30308
30581
  }
30582
+ _define_property$8(RouterNavigation, "MAX_REDIRECTS", 10);
30309
30583
 
30310
30584
  function _define_property$7(obj, key, value) {
30311
30585
  if (key in obj) {