@vlian/framework 1.2.16 → 1.2.18

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 (55) hide show
  1. package/dist/analytics.umd.js +1 -1
  2. package/dist/core/router/RouterManager.cjs +32 -2
  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 +33 -3
  6. package/dist/core/router/RouterManager.js.map +1 -1
  7. package/dist/core/router/adapter/react-router/ReactRouterAdapter.cjs.map +1 -1
  8. package/dist/core/router/adapter/react-router/ReactRouterAdapter.js.map +1 -1
  9. package/dist/core/router/dev/RouterDevTools.cjs.map +1 -1
  10. package/dist/core/router/dev/RouterDevTools.js.map +1 -1
  11. package/dist/core/router/middleware/RouterMiddlewareManager.cjs +24 -4
  12. package/dist/core/router/middleware/RouterMiddlewareManager.cjs.map +1 -1
  13. package/dist/core/router/middleware/RouterMiddlewareManager.d.ts +1 -0
  14. package/dist/core/router/middleware/RouterMiddlewareManager.js +24 -4
  15. package/dist/core/router/middleware/RouterMiddlewareManager.js.map +1 -1
  16. package/dist/core/router/middleware/types.cjs.map +1 -1
  17. package/dist/core/router/middleware/types.d.ts +1 -1
  18. package/dist/core/router/middleware/types.js.map +1 -1
  19. package/dist/core/router/navigation/RouterNavigation.cjs +69 -14
  20. package/dist/core/router/navigation/RouterNavigation.cjs.map +1 -1
  21. package/dist/core/router/navigation/RouterNavigation.d.ts +3 -0
  22. package/dist/core/router/navigation/RouterNavigation.js +69 -14
  23. package/dist/core/router/navigation/RouterNavigation.js.map +1 -1
  24. package/dist/core/router/performance/RouteCache.cjs +34 -13
  25. package/dist/core/router/performance/RouteCache.cjs.map +1 -1
  26. package/dist/core/router/performance/RouteCache.d.ts +8 -2
  27. package/dist/core/router/performance/RouteCache.js +34 -13
  28. package/dist/core/router/performance/RouteCache.js.map +1 -1
  29. package/dist/core/router/performance/RoutePreloader.cjs +89 -22
  30. package/dist/core/router/performance/RoutePreloader.cjs.map +1 -1
  31. package/dist/core/router/performance/RoutePreloader.d.ts +9 -1
  32. package/dist/core/router/performance/RoutePreloader.js +89 -22
  33. package/dist/core/router/performance/RoutePreloader.js.map +1 -1
  34. package/dist/core/router/types.d.ts +22 -5
  35. package/dist/core/router/types.js.map +1 -1
  36. package/dist/core/router/utils/adapters/react-router/transform.cjs +37 -64
  37. package/dist/core/router/utils/adapters/react-router/transform.cjs.map +1 -1
  38. package/dist/core/router/utils/adapters/react-router/transform.js +37 -59
  39. package/dist/core/router/utils/adapters/react-router/transform.js.map +1 -1
  40. package/dist/core/router/utils/transform.cjs +79 -70
  41. package/dist/core/router/utils/transform.cjs.map +1 -1
  42. package/dist/core/router/utils/transform.d.ts +1 -1
  43. package/dist/core/router/utils/transform.js +80 -71
  44. package/dist/core/router/utils/transform.js.map +1 -1
  45. package/dist/core/router/validation/RouterConfigValidator.d.ts +66 -4
  46. package/dist/core/router/validation/schema.cjs +71 -2
  47. package/dist/core/router/validation/schema.cjs.map +1 -1
  48. package/dist/core/router/validation/schema.d.ts +102 -6
  49. package/dist/core/router/validation/schema.js +71 -2
  50. package/dist/core/router/validation/schema.js.map +1 -1
  51. package/dist/index.umd.js +677 -428
  52. package/dist/index.umd.js.map +1 -1
  53. package/dist/request.umd.js +1 -1
  54. package/dist/state.umd.js +1 -1
  55. 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.18
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,
@@ -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,20 +25934,23 @@
25954
25934
  }
25955
25935
  const reactRoute = {
25956
25936
  children: [],
25957
- HydrateFallback: getLoadingComponent(),
25937
+ hydrateFallbackElement: /*#__PURE__*/ jsxRuntime.jsx(DefaultRouteHydrateFallback, {}),
25958
25938
  id: name,
25959
25939
  handle: getHandle(),
25960
25940
  lazy: async ()=>{
25961
25941
  const ErrorBoundary = await getErrorComponent();
25962
25942
  const config = await getConfig();
25943
+ const LoadingComponent = await getLoadingComponent();
25963
25944
  // 如果配置为空,确保至少返回一个空对象,避免展开 undefined
25964
25945
  if (!config) {
25965
25946
  return {
25966
- ErrorBoundary: ErrorBoundary?.default
25947
+ ErrorBoundary: ErrorBoundary?.default,
25948
+ HydrateFallback: LoadingComponent?.default
25967
25949
  };
25968
25950
  }
25969
25951
  return {
25970
25952
  ErrorBoundary: ErrorBoundary?.default,
25953
+ HydrateFallback: LoadingComponent?.default,
25971
25954
  ...config
25972
25955
  };
25973
25956
  },
@@ -25986,8 +25969,10 @@
25986
25969
  index: true,
25987
25970
  lazy: async ()=>{
25988
25971
  const ErrorBoundary = await getErrorComponent();
25972
+ const LoadingComponent = await getLoadingComponent();
25989
25973
  return {
25990
25974
  ErrorBoundary: ErrorBoundary?.default,
25975
+ HydrateFallback: LoadingComponent?.default,
25991
25976
  ...await getConfig(true)
25992
25977
  };
25993
25978
  }
@@ -26016,8 +26001,10 @@
26016
26001
  index: true,
26017
26002
  lazy: async ()=>{
26018
26003
  const ErrorBoundary = await getErrorComponent();
26004
+ const LoadingComponent = await getLoadingComponent();
26019
26005
  return {
26020
26006
  ErrorBoundary: ErrorBoundary?.default,
26007
+ HydrateFallback: LoadingComponent?.default,
26021
26008
  ...await getConfig(true)
26022
26009
  };
26023
26010
  }
@@ -26051,12 +26038,42 @@
26051
26038
  zod.z.function(),
26052
26039
  zod.z.null()
26053
26040
  ]);
26041
+ const routerOptionsSchema = zod.z.object({
26042
+ basename: zod.z.string().optional(),
26043
+ future: zod.z.record(zod.z.string(), zod.z.union([
26044
+ zod.z.boolean(),
26045
+ zod.z.string(),
26046
+ zod.z.number()
26047
+ ])).optional(),
26048
+ hydrationData: zod.z.unknown().optional(),
26049
+ window: zod.z.unknown().optional(),
26050
+ initialEntries: zod.z.array(zod.z.string()).optional(),
26051
+ initialIndex: zod.z.number().int().nonnegative().optional()
26052
+ }).passthrough();
26053
+ const transformOptionsSchema = zod.z.object({
26054
+ pathValidation: zod.z.object({
26055
+ enablePathValidation: zod.z.boolean().optional(),
26056
+ allowedPathPrefixes: zod.z.array(zod.z.string().min(1)).optional(),
26057
+ maxPathLength: zod.z.number().int().positive().optional(),
26058
+ allowAbsolutePaths: zod.z.boolean().optional()
26059
+ }).optional(),
26060
+ performance: zod.z.object({
26061
+ enableCache: zod.z.boolean().optional(),
26062
+ cacheTTL: zod.z.number().int().positive().optional(),
26063
+ maxCacheSize: zod.z.number().int().positive().optional(),
26064
+ maxRecursionDepth: zod.z.number().int().positive().optional(),
26065
+ enableParallelProcessing: zod.z.boolean().optional(),
26066
+ parallelBatchSize: zod.z.number().int().positive().optional()
26067
+ }).optional(),
26068
+ enableDebugLog: zod.z.boolean().optional()
26069
+ }).passthrough();
26054
26070
  /**
26055
26071
  * RouteConfig Schema
26056
26072
  */ const routeConfigSchema = zod.z.lazy(()=>zod.z.object({
26057
26073
  layout: componentImportSchema.optional().nullable(),
26058
26074
  page: componentImportSchema.optional().nullable(),
26059
26075
  loading: componentImportSchema.optional().nullable(),
26076
+ error: componentImportSchema.optional().nullable(),
26060
26077
  errors: componentImportSchema.optional().nullable(),
26061
26078
  name: zod.z.string().min(1, '路由名称不能为空'),
26062
26079
  path: zod.z.string().optional(),
@@ -26081,12 +26098,51 @@
26081
26098
  'hash',
26082
26099
  'memory'
26083
26100
  ]).optional(),
26084
- options: zod.z.any().optional(),
26101
+ options: routerOptionsSchema.optional(),
26085
26102
  pathResolve: zod.z.object({
26086
26103
  basePath: zod.z.string().optional(),
26087
26104
  pathAliases: zod.z.record(zod.z.string(), zod.z.string()).optional()
26088
26105
  }).optional(),
26089
- transformOptions: zod.z.any().optional()
26106
+ transformOptions: transformOptionsSchema.optional(),
26107
+ preload: zod.z.object({
26108
+ strategy: zod.z.enum([
26109
+ 'none',
26110
+ 'next-level',
26111
+ 'all',
26112
+ 'visible'
26113
+ ]).optional(),
26114
+ delay: zod.z.number().int().positive().optional(),
26115
+ priorityThreshold: zod.z.number().int().nonnegative().optional(),
26116
+ timeout: zod.z.number().int().positive().optional()
26117
+ }).optional()
26118
+ }).superRefine((config, ctx)=>{
26119
+ if (!Array.isArray(config.routes)) {
26120
+ return;
26121
+ }
26122
+ const routeNameMap = new Map();
26123
+ const walk = (routes, parentPath)=>{
26124
+ routes.forEach((route, index)=>{
26125
+ const currentPath = `${parentPath}[${index}]`;
26126
+ const existingPath = routeNameMap.get(route.name);
26127
+ if (existingPath) {
26128
+ ctx.addIssue({
26129
+ code: zod.z.ZodIssueCode.custom,
26130
+ path: [
26131
+ 'routes',
26132
+ index,
26133
+ 'name'
26134
+ ],
26135
+ message: `路由名称重复: "${route.name}",首次定义位置 ${existingPath}`
26136
+ });
26137
+ } else {
26138
+ routeNameMap.set(route.name, currentPath);
26139
+ }
26140
+ if (Array.isArray(route.children) && route.children.length > 0) {
26141
+ walk(route.children, `${currentPath}.children`);
26142
+ }
26143
+ });
26144
+ };
26145
+ walk(config.routes, 'routes');
26090
26146
  });
26091
26147
  /**
26092
26148
  * 验证路由配置
@@ -26106,7 +26162,7 @@
26106
26162
  return routerConfigSchema.safeParse(config);
26107
26163
  }
26108
26164
 
26109
- function _define_property$p(obj, key, value) {
26165
+ function _define_property$q(obj, key, value) {
26110
26166
  if (key in obj) {
26111
26167
  Object.defineProperty(obj, key, {
26112
26168
  value: value,
@@ -26123,7 +26179,7 @@
26123
26179
  * 配置验证错误
26124
26180
  */ class ConfigValidationError extends Error {
26125
26181
  constructor(message, errors){
26126
- super(message), _define_property$p(this, "errors", void 0), this.errors = errors;
26182
+ super(message), _define_property$q(this, "errors", void 0), this.errors = errors;
26127
26183
  this.name = 'ConfigValidationError';
26128
26184
  }
26129
26185
  }
@@ -26292,7 +26348,7 @@
26292
26348
  }
26293
26349
  }
26294
26350
 
26295
- function _define_property$o(obj, key, value) {
26351
+ function _define_property$p(obj, key, value) {
26296
26352
  if (key in obj) {
26297
26353
  Object.defineProperty(obj, key, {
26298
26354
  value: value,
@@ -26404,7 +26460,7 @@
26404
26460
  return this.hooks.length;
26405
26461
  }
26406
26462
  constructor(){
26407
- _define_property$o(this, "hooks", []);
26463
+ _define_property$p(this, "hooks", []);
26408
26464
  }
26409
26465
  }
26410
26466
  /**
@@ -26417,7 +26473,7 @@
26417
26473
  return lifecycleManagerInstance;
26418
26474
  }
26419
26475
 
26420
- function _define_property$n(obj, key, value) {
26476
+ function _define_property$o(obj, key, value) {
26421
26477
  if (key in obj) {
26422
26478
  Object.defineProperty(obj, key, {
26423
26479
  value: value,
@@ -26508,16 +26564,35 @@
26508
26564
  for (const middlewareConfig of enabledMiddlewares){
26509
26565
  try {
26510
26566
  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 : {
26567
+ // 如果中间件返回 false,阻止导航
26568
+ if (result === false) {
26569
+ logger.debug(`路由中间件阻止导航: ${middlewareConfig.name || 'anonymous'} -> false`);
26570
+ return {
26515
26571
  allow: false,
26516
26572
  reason: '中间件返回 false'
26517
26573
  };
26518
26574
  }
26575
+ // 如果中间件返回对象且 allow: false,阻止导航
26576
+ if (typeof result === 'object' && result !== null && result.allow === false) {
26577
+ logger.debug(`路由中间件阻止导航: ${middlewareConfig.name || 'anonymous'}`, result);
26578
+ if (result.redirect && !RouterMiddlewareManager.SAFE_REDIRECT_PATH_REGEX.test(result.redirect)) {
26579
+ logger.warn(`路由中间件返回了不安全的重定向地址,已拦截: ${middlewareConfig.name || 'anonymous'} -> ${result.redirect}`);
26580
+ return {
26581
+ allow: false,
26582
+ reason: '中间件返回了不安全的重定向地址'
26583
+ };
26584
+ }
26585
+ return result;
26586
+ }
26519
26587
  // 如果中间件返回字符串,重定向到该路径
26520
26588
  if (typeof result === 'string') {
26589
+ if (!RouterMiddlewareManager.SAFE_REDIRECT_PATH_REGEX.test(result)) {
26590
+ logger.warn(`路由中间件返回了不安全的重定向地址,已拦截: ${middlewareConfig.name || 'anonymous'} -> ${result}`);
26591
+ return {
26592
+ allow: false,
26593
+ reason: '中间件返回了不安全的重定向地址'
26594
+ };
26595
+ }
26521
26596
  logger.debug(`路由中间件重定向: ${middlewareConfig.name || 'anonymous'} -> ${result}`);
26522
26597
  return {
26523
26598
  allow: false,
@@ -26558,9 +26633,10 @@
26558
26633
  return this.middlewares.length;
26559
26634
  }
26560
26635
  constructor(){
26561
- _define_property$n(this, "middlewares", []);
26636
+ _define_property$o(this, "middlewares", []);
26562
26637
  }
26563
26638
  }
26639
+ _define_property$o(RouterMiddlewareManager, "SAFE_REDIRECT_PATH_REGEX", /^(\/|\.\/|\.\.\/|#)/);
26564
26640
  /**
26565
26641
  * 获取路由中间件管理器单例
26566
26642
  */ let middlewareManagerInstance = null;
@@ -26674,7 +26750,7 @@
26674
26750
  return new RouterError(message, code, severity, cause, context);
26675
26751
  }
26676
26752
 
26677
- function _define_property$m(obj, key, value) {
26753
+ function _define_property$n(obj, key, value) {
26678
26754
  if (key in obj) {
26679
26755
  Object.defineProperty(obj, key, {
26680
26756
  value: value,
@@ -26792,8 +26868,11 @@
26792
26868
  /**
26793
26869
  * 启动定期清理
26794
26870
  */ startCleanupInterval() {
26871
+ if (this.cleanupTimer) {
26872
+ clearInterval(this.cleanupTimer);
26873
+ }
26795
26874
  // 每 1 分钟清理一次过期缓存
26796
- setInterval(()=>{
26875
+ this.cleanupTimer = setInterval(()=>{
26797
26876
  this.cleanup();
26798
26877
  }, 60 * 1000);
26799
26878
  }
@@ -26803,15 +26882,18 @@
26803
26882
  const key = this.generateKey(routes);
26804
26883
  const item = this.cache.get(key);
26805
26884
  if (!item) {
26885
+ this.stats.transformMisses++;
26806
26886
  return null;
26807
26887
  }
26808
26888
  if (this.isExpired(item)) {
26809
26889
  this.cache.delete(key);
26890
+ this.stats.transformMisses++;
26810
26891
  return null;
26811
26892
  }
26812
26893
  // 更新访问信息
26813
26894
  item.lastAccessedAt = Date.now();
26814
26895
  item.accessCount++;
26896
+ this.stats.transformHits++;
26815
26897
  return item.value;
26816
26898
  }
26817
26899
  /**
@@ -26841,15 +26923,18 @@
26841
26923
  */ getMatch(path) {
26842
26924
  const item = this.matchCache.get(path);
26843
26925
  if (!item) {
26926
+ this.stats.matchMisses++;
26844
26927
  return undefined;
26845
26928
  }
26846
26929
  if (this.isExpired(item)) {
26847
26930
  this.matchCache.delete(path);
26931
+ this.stats.matchMisses++;
26848
26932
  return undefined;
26849
26933
  }
26850
26934
  // 更新访问信息
26851
26935
  item.lastAccessedAt = Date.now();
26852
26936
  item.accessCount++;
26937
+ this.stats.matchHits++;
26853
26938
  return item.value;
26854
26939
  }
26855
26940
  /**
@@ -26872,23 +26957,28 @@
26872
26957
  */ clear() {
26873
26958
  this.cache.clear();
26874
26959
  this.matchCache.clear();
26960
+ this.stats = {
26961
+ transformHits: 0,
26962
+ transformMisses: 0,
26963
+ matchHits: 0,
26964
+ matchMisses: 0
26965
+ };
26875
26966
  logger.debug('路由缓存已清空');
26876
26967
  }
26877
26968
  /**
26969
+ * 销毁缓存实例并释放资源
26970
+ */ destroy() {
26971
+ this.clear();
26972
+ if (this.cleanupTimer) {
26973
+ clearInterval(this.cleanupTimer);
26974
+ this.cleanupTimer = null;
26975
+ }
26976
+ }
26977
+ /**
26878
26978
  * 获取缓存统计信息
26879
26979
  */ 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
- }
26980
+ const totalHits = this.stats.transformHits + this.stats.matchHits;
26981
+ const totalAccess = totalHits + this.stats.transformMisses + this.stats.matchMisses;
26892
26982
  const hitRate = totalAccess > 0 ? totalHits / totalAccess : 0;
26893
26983
  return {
26894
26984
  transformCacheSize: this.cache.size,
@@ -26898,10 +26988,17 @@
26898
26988
  };
26899
26989
  }
26900
26990
  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);
26991
+ _define_property$n(this, "cache", new Map());
26992
+ _define_property$n(this, "matchCache", new Map());
26993
+ _define_property$n(this, "config", void 0);
26994
+ _define_property$n(this, "persistenceEnabled", false);
26995
+ _define_property$n(this, "cleanupTimer", null);
26996
+ _define_property$n(this, "stats", {
26997
+ transformHits: 0,
26998
+ transformMisses: 0,
26999
+ matchHits: 0,
27000
+ matchMisses: 0
27001
+ });
26905
27002
  this.config = {
26906
27003
  maxSize: config.maxSize ?? 50,
26907
27004
  ttl: config.ttl ?? 5 * 60 * 1000,
@@ -26926,7 +27023,7 @@
26926
27023
  return routeCacheInstance;
26927
27024
  }
26928
27025
 
26929
- function _define_property$l(obj, key, value) {
27026
+ function _define_property$m(obj, key, value) {
26930
27027
  if (key in obj) {
26931
27028
  Object.defineProperty(obj, key, {
26932
27029
  value: value,
@@ -26960,36 +27057,49 @@
26960
27057
  * 路由预加载管理器
26961
27058
  */ class RoutePreloader {
26962
27059
  /**
27060
+ * 更新预加载配置
27061
+ */ updateConfig(config = {}) {
27062
+ this.config = {
27063
+ strategy: config.strategy ?? "none",
27064
+ delay: config.delay ?? 1000,
27065
+ priorityThreshold: config.priorityThreshold ?? 10,
27066
+ timeout: config.timeout ?? 5000
27067
+ };
27068
+ }
27069
+ shouldRegister(priority) {
27070
+ if (this.config.strategy === "none") {
27071
+ return false;
27072
+ }
27073
+ if (this.config.strategy === "visible" && priority > this.config.priorityThreshold) {
27074
+ return false;
27075
+ }
27076
+ return true;
27077
+ }
27078
+ registerTask(key, importFn, routeName, priority) {
27079
+ if (!this.shouldRegister(priority)) {
27080
+ return;
27081
+ }
27082
+ this.tasks.set(key, {
27083
+ importFn,
27084
+ routeName,
27085
+ priority,
27086
+ status: 'pending'
27087
+ });
27088
+ }
27089
+ /**
26963
27090
  * 注册路由用于预加载
26964
27091
  */ registerRoute(route) {
26965
27092
  if (!route.page && !route.layout) {
26966
27093
  return;
26967
27094
  }
26968
27095
  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
27096
  // 注册页面组件
26977
27097
  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
- });
27098
+ this.registerTask(`${route.name}_page`, route.page, route.name, priority);
26984
27099
  }
26985
27100
  // 注册布局组件
26986
27101
  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
- });
27102
+ this.registerTask(`${route.name}_layout`, route.layout, route.name, priority);
26993
27103
  }
26994
27104
  // 递归注册子路由
26995
27105
  if (route.children) {
@@ -26998,8 +27108,43 @@
26998
27108
  }
26999
27109
  /**
27000
27110
  * 注册多个路由
27001
- */ registerRoutes(routes) {
27111
+ */ registerRoutes(routes, resolvers) {
27112
+ const priorityByPath = new Map();
27113
+ const nameByPath = new Map();
27114
+ const collectPriority = (route)=>{
27115
+ const priority = route.handle?.order ?? 999;
27116
+ const routeName = route.name;
27117
+ const record = (value)=>{
27118
+ if (typeof value !== 'string') {
27119
+ return;
27120
+ }
27121
+ if (!priorityByPath.has(value) || (priorityByPath.get(value) ?? 999) > priority) {
27122
+ priorityByPath.set(value, priority);
27123
+ nameByPath.set(value, routeName);
27124
+ }
27125
+ };
27126
+ record(route.page);
27127
+ record(route.layout);
27128
+ record(route.error ?? route.errors);
27129
+ record(route.loading);
27130
+ route.children?.forEach(collectPriority);
27131
+ };
27132
+ routes.forEach(collectPriority);
27002
27133
  routes.forEach((route)=>this.registerRoute(route));
27134
+ if (!resolvers) {
27135
+ return;
27136
+ }
27137
+ const registerResolverMap = (map, type)=>{
27138
+ for (const [path, importFn] of map.entries()){
27139
+ const routeName = nameByPath.get(path) ?? path;
27140
+ const priority = priorityByPath.get(path) ?? 999;
27141
+ this.registerTask(`${routeName}_${type}_${path}`, importFn, routeName, priority);
27142
+ }
27143
+ };
27144
+ registerResolverMap(resolvers.pages, 'page');
27145
+ registerResolverMap(resolvers.layouts, 'layout');
27146
+ registerResolverMap(resolvers.errors, 'error');
27147
+ registerResolverMap(resolvers.loadings, 'loading');
27003
27148
  }
27004
27149
  /**
27005
27150
  * 预加载指定路由
@@ -27018,10 +27163,11 @@
27018
27163
  }
27019
27164
  task.status = 'loading';
27020
27165
  task.startTime = Date.now();
27166
+ let timeoutId = null;
27021
27167
  try {
27022
27168
  // 设置超时
27023
27169
  const timeoutPromise = new Promise((_, reject)=>{
27024
- setTimeout(()=>reject(new Error('预加载超时')), this.config.timeout);
27170
+ timeoutId = setTimeout(()=>reject(new Error('预加载超时')), this.config.timeout);
27025
27171
  });
27026
27172
  // 执行预加载
27027
27173
  await Promise.race([
@@ -27034,6 +27180,10 @@
27034
27180
  } catch (error) {
27035
27181
  task.status = 'failed';
27036
27182
  logger.warn(`路由组件预加载失败: ${task.routeName}`, error);
27183
+ } finally{
27184
+ if (timeoutId) {
27185
+ clearTimeout(timeoutId);
27186
+ }
27037
27187
  }
27038
27188
  }
27039
27189
  /**
@@ -27042,8 +27192,16 @@
27042
27192
  if (this.config.strategy === "none") {
27043
27193
  return;
27044
27194
  }
27195
+ this.stopPreload();
27045
27196
  // 延迟预加载,避免影响初始渲染
27046
27197
  this.preloadTimer = setTimeout(()=>{
27198
+ const browserWindow = typeof window !== 'undefined' ? window : undefined;
27199
+ if (browserWindow?.requestIdleCallback) {
27200
+ this.idleHandle = browserWindow.requestIdleCallback(()=>{
27201
+ this.executePreload();
27202
+ });
27203
+ return;
27204
+ }
27047
27205
  this.executePreload();
27048
27206
  }, this.config.delay);
27049
27207
  }
@@ -27082,10 +27240,15 @@
27082
27240
  /**
27083
27241
  * 停止预加载
27084
27242
  */ stopPreload() {
27243
+ const browserWindow = typeof window !== 'undefined' ? window : undefined;
27085
27244
  if (this.preloadTimer) {
27086
27245
  clearTimeout(this.preloadTimer);
27087
27246
  this.preloadTimer = null;
27088
27247
  }
27248
+ if (this.idleHandle !== null && browserWindow?.cancelIdleCallback) {
27249
+ browserWindow.cancelIdleCallback(this.idleHandle);
27250
+ this.idleHandle = null;
27251
+ }
27089
27252
  }
27090
27253
  /**
27091
27254
  * 清空所有任务
@@ -27110,11 +27273,12 @@
27110
27273
  return stats;
27111
27274
  }
27112
27275
  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);
27276
+ _define_property$m(this, "tasks", new Map());
27277
+ _define_property$m(this, "config", void 0);
27278
+ _define_property$m(this, "preloadTimer", null);
27279
+ _define_property$m(this, "idleHandle", null);
27116
27280
  this.config = {
27117
- strategy: config.strategy ?? "next-level",
27281
+ strategy: config.strategy ?? "none",
27118
27282
  delay: config.delay ?? 1000,
27119
27283
  priorityThreshold: config.priorityThreshold ?? 10,
27120
27284
  timeout: config.timeout ?? 5000
@@ -27163,7 +27327,7 @@
27163
27327
  return PluginLifecycleStage;
27164
27328
  }({});
27165
27329
 
27166
- function _define_property$k(obj, key, value) {
27330
+ function _define_property$l(obj, key, value) {
27167
27331
  if (key in obj) {
27168
27332
  Object.defineProperty(obj, key, {
27169
27333
  value: value,
@@ -27392,7 +27556,7 @@
27392
27556
  return this.plugins.size;
27393
27557
  }
27394
27558
  constructor(){
27395
- _define_property$k(this, "plugins", new Map());
27559
+ _define_property$l(this, "plugins", new Map());
27396
27560
  }
27397
27561
  }
27398
27562
  /**
@@ -27405,7 +27569,7 @@
27405
27569
  return pluginManagerInstance;
27406
27570
  }
27407
27571
 
27408
- function _define_property$j(obj, key, value) {
27572
+ function _define_property$k(obj, key, value) {
27409
27573
  if (key in obj) {
27410
27574
  Object.defineProperty(obj, key, {
27411
27575
  value: value,
@@ -27586,12 +27750,12 @@
27586
27750
  };
27587
27751
  }
27588
27752
  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);
27753
+ _define_property$k(this, "accessRecords", []);
27754
+ _define_property$k(this, "performanceMetrics", new Map());
27755
+ _define_property$k(this, "config", void 0);
27756
+ _define_property$k(this, "monitoringService", getMonitoring());
27757
+ _define_property$k(this, "currentRouteStartTime", 0);
27758
+ _define_property$k(this, "currentRoute", void 0);
27595
27759
  this.config = {
27596
27760
  enabled: config.enabled ?? true,
27597
27761
  trackAccess: config.trackAccess ?? true,
@@ -27612,7 +27776,7 @@
27612
27776
  return routerMonitoringInstance;
27613
27777
  }
27614
27778
 
27615
- function _define_property$i(obj, key, value) {
27779
+ function _define_property$j(obj, key, value) {
27616
27780
  if (key in obj) {
27617
27781
  Object.defineProperty(obj, key, {
27618
27782
  value: value,
@@ -27812,9 +27976,9 @@
27812
27976
  return this.adapters.size;
27813
27977
  }
27814
27978
  constructor(){
27815
- _define_property$i(this, "adapters", new Map());
27816
- _define_property$i(this, "currentAdapter", null);
27817
- _define_property$i(this, "defaultAdapterName", null);
27979
+ _define_property$j(this, "adapters", new Map());
27980
+ _define_property$j(this, "currentAdapter", null);
27981
+ _define_property$j(this, "defaultAdapterName", null);
27818
27982
  }
27819
27983
  }
27820
27984
  /**
@@ -27829,7 +27993,7 @@
27829
27993
 
27830
27994
  /**
27831
27995
  * React Router 适配器实现
27832
- */ function _define_property$h(obj, key, value) {
27996
+ */ function _define_property$i(obj, key, value) {
27833
27997
  if (key in obj) {
27834
27998
  Object.defineProperty(obj, key, {
27835
27999
  value: value,
@@ -27925,9 +28089,9 @@
27925
28089
  logger.debug('React Router 适配器已销毁');
27926
28090
  }
27927
28091
  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);
28092
+ _define_property$i(this, "name", 'react-router');
28093
+ _define_property$i(this, "version", '6.0.0');
28094
+ _define_property$i(this, "router", null);
27931
28095
  }
27932
28096
  }
27933
28097
  /**
@@ -27938,7 +28102,7 @@
27938
28102
  };
27939
28103
  }
27940
28104
 
27941
- function _define_property$g(obj, key, value) {
28105
+ function _define_property$h(obj, key, value) {
27942
28106
  if (key in obj) {
27943
28107
  Object.defineProperty(obj, key, {
27944
28108
  value: value,
@@ -27998,6 +28162,9 @@
27998
28162
  if (!config.routes) {
27999
28163
  throw new RouterError('路由配置不能为空', RouterErrorCode.ROUTER_CONFIG_ERROR);
28000
28164
  }
28165
+ // 更新预加载策略(默认关闭,按需懒加载)
28166
+ this.preloader.updateConfig(config.preload);
28167
+ this.preloader.clear();
28001
28168
  let result;
28002
28169
  const cacheKey = config.routes;
28003
28170
  const cachedResult = this.cache.get(cacheKey);
@@ -28021,10 +28188,11 @@
28021
28188
  const reactRoutes = await transformRoutesToReactRoutes(result.routes, result, config.defaultRouteErrorComponent, config.defaultRouteLoadingComponent);
28022
28189
  // 注册路由到预加载器
28023
28190
  if (result.routes) {
28024
- this.preloader.registerRoutes(result.routes);
28191
+ this.preloader.registerRoutes(result.routes, result);
28025
28192
  // 开始预加载
28026
28193
  this.preloader.startPreload();
28027
28194
  }
28195
+ await this.resolveInitialLazyRoutes(reactRoutes);
28028
28196
  let routerInstance = null;
28029
28197
  if (config.mode === 'browser') {
28030
28198
  routerInstance = reactRouterDom.createBrowserRouter(reactRoutes, config.options);
@@ -28047,14 +28215,40 @@
28047
28215
  routes: result.routes
28048
28216
  });
28049
28217
  // 记录监控:路由初始化完成
28218
+ const initialPath = typeof window !== 'undefined' ? `${window.location.pathname}${window.location.search}${window.location.hash}` : this.router?.state?.location?.pathname ?? '/';
28050
28219
  this.monitoring.trackRouteAccess({
28051
- path: window.location.pathname,
28220
+ path: initialPath,
28052
28221
  meta: {
28053
28222
  name: 'router-init'
28054
28223
  }
28055
28224
  }, undefined, true);
28056
28225
  logger.info('路由管理器初始化完成');
28057
28226
  }
28227
+ /**
28228
+ * 预解析当前 URL 命中的 lazy 路由,避免首屏长时间停留在 hydrate fallback。
28229
+ * 非首屏路由仍保持懒加载,保留代码分割收益。
28230
+ */ async resolveInitialLazyRoutes(routes) {
28231
+ if (typeof window === 'undefined') {
28232
+ return;
28233
+ }
28234
+ const matches = reactRouterDom.matchRoutes(routes, window.location.pathname) ?? [];
28235
+ if (matches.length === 0) {
28236
+ return;
28237
+ }
28238
+ await Promise.all(matches.map(async ({ route })=>{
28239
+ const lazy = route.lazy;
28240
+ if (typeof lazy !== 'function') {
28241
+ return;
28242
+ }
28243
+ try {
28244
+ const resolved = await lazy();
28245
+ Object.assign(route, resolved);
28246
+ delete route.lazy;
28247
+ } catch (error) {
28248
+ logger.warn('首屏路由懒加载预解析失败,回退到 Router 默认懒加载', error);
28249
+ }
28250
+ }));
28251
+ }
28058
28252
  /**
28059
28253
  * 获取路由实例
28060
28254
  *
@@ -28111,25 +28305,25 @@
28111
28305
  /**
28112
28306
  * 路由实例
28113
28307
  * 只能在 initialize 方法中赋值
28114
- */ _define_property$g(this, "router", null);
28308
+ */ _define_property$h(this, "router", null);
28115
28309
  /**
28116
28310
  * 是否已初始化
28117
- */ _define_property$g(this, "initialized", false);
28311
+ */ _define_property$h(this, "initialized", false);
28118
28312
  /**
28119
28313
  * 路由缓存实例
28120
- */ _define_property$g(this, "cache", getRouteCache());
28314
+ */ _define_property$h(this, "cache", getRouteCache());
28121
28315
  /**
28122
28316
  * 路由预加载器实例
28123
- */ _define_property$g(this, "preloader", getRoutePreloader());
28317
+ */ _define_property$h(this, "preloader", getRoutePreloader());
28124
28318
  /**
28125
28319
  * 路由插件管理器实例
28126
- */ _define_property$g(this, "pluginManager", getRouterPluginManager());
28320
+ */ _define_property$h(this, "pluginManager", getRouterPluginManager());
28127
28321
  /**
28128
28322
  * 路由监控服务实例
28129
- */ _define_property$g(this, "monitoring", getRouterMonitoring());
28323
+ */ _define_property$h(this, "monitoring", getRouterMonitoring());
28130
28324
  /**
28131
28325
  * 路由适配器管理器实例
28132
- */ _define_property$g(this, "adapterManager", getAdapterManager());
28326
+ */ _define_property$h(this, "adapterManager", getAdapterManager());
28133
28327
  // 私有构造函数
28134
28328
  // 注册默认的 React Router 适配器
28135
28329
  this.adapterManager.register({
@@ -28139,7 +28333,7 @@
28139
28333
  });
28140
28334
  }
28141
28335
  }
28142
- _define_property$g(RouterManager, "instance", null);
28336
+ _define_property$h(RouterManager, "instance", null);
28143
28337
  /**
28144
28338
  * 获取路由管理器
28145
28339
  */ function getRouterManager() {
@@ -28152,7 +28346,7 @@
28152
28346
  getRouterManager: getRouterManager
28153
28347
  });
28154
28348
 
28155
- function _define_property$f(obj, key, value) {
28349
+ function _define_property$g(obj, key, value) {
28156
28350
  if (key in obj) {
28157
28351
  Object.defineProperty(obj, key, {
28158
28352
  value: value,
@@ -28400,15 +28594,15 @@
28400
28594
  return this.container;
28401
28595
  }
28402
28596
  constructor(){
28403
- _define_property$f(this, "root", null);
28404
- _define_property$f(this, "container", null);
28597
+ _define_property$g(this, "root", null);
28598
+ _define_property$g(this, "container", null);
28405
28599
  }
28406
28600
  }
28407
28601
 
28408
28602
  /**
28409
28603
  * 性能追踪模块
28410
28604
  * 负责收集和上报启动性能指标
28411
- */ function _define_property$e(obj, key, value) {
28605
+ */ function _define_property$f(obj, key, value) {
28412
28606
  if (key in obj) {
28413
28607
  Object.defineProperty(obj, key, {
28414
28608
  value: value,
@@ -28563,9 +28757,9 @@
28563
28757
  return performance.now() - this.startTime;
28564
28758
  }
28565
28759
  constructor(monitoring){
28566
- _define_property$e(this, "monitoring", void 0);
28567
- _define_property$e(this, "metrics", {});
28568
- _define_property$e(this, "startTime", void 0);
28760
+ _define_property$f(this, "monitoring", void 0);
28761
+ _define_property$f(this, "metrics", {});
28762
+ _define_property$f(this, "startTime", void 0);
28569
28763
  this.monitoring = monitoring;
28570
28764
  this.startTime = performance.now();
28571
28765
  }
@@ -28574,7 +28768,7 @@
28574
28768
  /**
28575
28769
  * 应用实例管理模块
28576
28770
  * 支持多实例隔离
28577
- */ function _define_property$d(obj, key, value) {
28771
+ */ function _define_property$e(obj, key, value) {
28578
28772
  if (key in obj) {
28579
28773
  Object.defineProperty(obj, key, {
28580
28774
  value: value,
@@ -28666,25 +28860,25 @@
28666
28860
  constructor(id, options){
28667
28861
  /**
28668
28862
  * 实例ID
28669
- */ _define_property$d(this, "id", void 0);
28863
+ */ _define_property$e(this, "id", void 0);
28670
28864
  /**
28671
28865
  * 应用渲染器
28672
- */ _define_property$d(this, "renderer", void 0);
28866
+ */ _define_property$e(this, "renderer", void 0);
28673
28867
  /**
28674
28868
  * 服务实例
28675
- */ _define_property$d(this, "services", null);
28869
+ */ _define_property$e(this, "services", null);
28676
28870
  /**
28677
28871
  * 性能追踪器
28678
- */ _define_property$d(this, "performanceTracker", null);
28872
+ */ _define_property$e(this, "performanceTracker", null);
28679
28873
  /**
28680
28874
  * 启动配置
28681
- */ _define_property$d(this, "options", void 0);
28875
+ */ _define_property$e(this, "options", void 0);
28682
28876
  /**
28683
28877
  * 是否已初始化
28684
- */ _define_property$d(this, "initialized", false);
28878
+ */ _define_property$e(this, "initialized", false);
28685
28879
  /**
28686
28880
  * 是否已销毁
28687
- */ _define_property$d(this, "destroyed", false);
28881
+ */ _define_property$e(this, "destroyed", false);
28688
28882
  this.id = id;
28689
28883
  this.options = options;
28690
28884
  this.renderer = new AppRenderer();
@@ -28782,19 +28976,19 @@
28782
28976
  this.defaultInstanceId = null;
28783
28977
  }
28784
28978
  constructor(){
28785
- _define_property$d(this, "instances", new Map());
28786
- _define_property$d(this, "defaultInstanceId", null);
28979
+ _define_property$e(this, "instances", new Map());
28980
+ _define_property$e(this, "defaultInstanceId", null);
28787
28981
  // 私有构造函数
28788
28982
  }
28789
28983
  }
28790
- _define_property$d(AppInstanceManager, "instance", null);
28984
+ _define_property$e(AppInstanceManager, "instance", null);
28791
28985
  /**
28792
28986
  * 获取应用实例管理器
28793
28987
  */ function getAppInstanceManager() {
28794
28988
  return AppInstanceManager.getInstance();
28795
28989
  }
28796
28990
 
28797
- function _define_property$c(obj, key, value) {
28991
+ function _define_property$d(obj, key, value) {
28798
28992
  if (key in obj) {
28799
28993
  Object.defineProperty(obj, key, {
28800
28994
  value: value,
@@ -28930,17 +29124,17 @@
28930
29124
  }
28931
29125
  }
28932
29126
  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);
29127
+ _define_property$d(this, "environment", void 0);
29128
+ _define_property$d(this, "isBrowser", void 0);
29129
+ _define_property$d(this, "isSSR", void 0);
29130
+ _define_property$d(this, "isMicroFrontend", void 0);
28937
29131
  this.isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
28938
29132
  this.isSSR = typeof window === 'undefined' && typeof process !== 'undefined';
28939
29133
  this.isMicroFrontend = this.detectMicroFrontend();
28940
29134
  this.environment = this.detectEnvironment();
28941
29135
  }
28942
29136
  }
28943
- _define_property$c(EnvironmentDetector, "instance", null);
29137
+ _define_property$d(EnvironmentDetector, "instance", null);
28944
29138
  /**
28945
29139
  * 获取环境检测器实例
28946
29140
  */ function getEnvironmentDetector() {
@@ -29005,7 +29199,7 @@
29005
29199
  /**
29006
29200
  * 框架生命周期事件集成
29007
29201
  * 自动在框架关键节点触发事件
29008
- */ function _define_property$b(obj, key, value) {
29202
+ */ function _define_property$c(obj, key, value) {
29009
29203
  if (key in obj) {
29010
29204
  Object.defineProperty(obj, key, {
29011
29205
  value: value,
@@ -29130,12 +29324,12 @@
29130
29324
  });
29131
29325
  }
29132
29326
  constructor(eventBus){
29133
- _define_property$b(this, "eventBus", void 0);
29327
+ _define_property$c(this, "eventBus", void 0);
29134
29328
  this.eventBus = eventBus;
29135
29329
  }
29136
29330
  }
29137
29331
 
29138
- function _define_property$a(obj, key, value) {
29332
+ function _define_property$b(obj, key, value) {
29139
29333
  if (key in obj) {
29140
29334
  Object.defineProperty(obj, key, {
29141
29335
  value: value,
@@ -29157,7 +29351,7 @@
29157
29351
  }
29158
29352
  class KernelBootError extends Error {
29159
29353
  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);
29354
+ 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
29355
  this.name = 'KernelBootError';
29162
29356
  this.code = options.code;
29163
29357
  this.phase = options.phase;
@@ -29187,7 +29381,7 @@
29187
29381
  });
29188
29382
  }
29189
29383
 
29190
- function _define_property$9(obj, key, value) {
29384
+ function _define_property$a(obj, key, value) {
29191
29385
  if (key in obj) {
29192
29386
  Object.defineProperty(obj, key, {
29193
29387
  value: value,
@@ -29264,7 +29458,7 @@
29264
29458
  }
29265
29459
  }
29266
29460
  constructor(){
29267
- _define_property$9(this, "instance", null);
29461
+ _define_property$a(this, "instance", null);
29268
29462
  }
29269
29463
  };
29270
29464
  let DefaultEventBusAdapter = class DefaultEventBusAdapter {
@@ -29296,7 +29490,7 @@
29296
29490
  }
29297
29491
  }
29298
29492
  constructor(){
29299
- _define_property$9(this, "bus", null);
29493
+ _define_property$a(this, "bus", null);
29300
29494
  }
29301
29495
  };
29302
29496
  const defaultI18nAdapter = {
@@ -29846,7 +30040,7 @@
29846
30040
  }
29847
30041
  }
29848
30042
 
29849
- function _define_property$8(obj, key, value) {
30043
+ function _define_property$9(obj, key, value) {
29850
30044
  if (key in obj) {
29851
30045
  Object.defineProperty(obj, key, {
29852
30046
  value: value,
@@ -29900,7 +30094,7 @@
29900
30094
  this.listeners.clear();
29901
30095
  }
29902
30096
  constructor(){
29903
- _define_property$8(this, "listeners", new Set());
30097
+ _define_property$9(this, "listeners", new Set());
29904
30098
  }
29905
30099
  };
29906
30100
  /**
@@ -30177,15 +30371,48 @@
30177
30371
  };
30178
30372
  }
30179
30373
 
30374
+ function _define_property$8(obj, key, value) {
30375
+ if (key in obj) {
30376
+ Object.defineProperty(obj, key, {
30377
+ value: value,
30378
+ enumerable: true,
30379
+ configurable: true,
30380
+ writable: true
30381
+ });
30382
+ } else {
30383
+ obj[key] = value;
30384
+ }
30385
+ return obj;
30386
+ }
30180
30387
  /**
30181
30388
  * 路由导航器
30182
30389
  */ class RouterNavigation {
30183
- /**
30184
- * 导航到指定路径
30185
- *
30186
- * @param to - 目标路径或路由名称
30187
- * @param options - 导航选项
30188
- */ static async navigate(to, options) {
30390
+ static buildTargetPath(to, query) {
30391
+ const base = typeof window !== 'undefined' && window.location?.origin ? window.location.origin : 'http://localhost';
30392
+ const url = new URL(to, base);
30393
+ if (query && Object.keys(query).length > 0) {
30394
+ const params = new URLSearchParams(url.search);
30395
+ Object.entries(query).forEach(([key, value])=>{
30396
+ if (value === undefined || value === null) {
30397
+ params.delete(key);
30398
+ return;
30399
+ }
30400
+ params.set(key, String(value));
30401
+ });
30402
+ url.search = params.toString();
30403
+ }
30404
+ return `${url.pathname}${url.search}${url.hash}`;
30405
+ }
30406
+ static async navigateInternal(to, options, depth, visited) {
30407
+ const startTime = performance.now();
30408
+ if (depth > this.MAX_REDIRECTS) {
30409
+ throw new Error(`路由重定向次数超过上限(${this.MAX_REDIRECTS}),可能存在循环重定向`);
30410
+ }
30411
+ const targetPath = this.buildTargetPath(to, options?.query);
30412
+ if (visited.has(targetPath)) {
30413
+ throw new Error(`检测到循环重定向: ${targetPath}`);
30414
+ }
30415
+ visited.add(targetPath);
30189
30416
  const routerManager = await Promise.resolve().then(function () { return RouterManager$1; }).then((m)=>m.getRouterManager());
30190
30417
  const router = routerManager.getRouter();
30191
30418
  if (!router) {
@@ -30195,12 +30422,13 @@
30195
30422
  const currentLocation = this.getCurrentRoute();
30196
30423
  // 构建目标路由位置
30197
30424
  const targetLocation = {
30198
- path: to,
30425
+ path: targetPath,
30199
30426
  query: options?.query
30200
30427
  };
30201
30428
  // 执行生命周期钩子
30202
30429
  const lifecycleManager = getRouterLifecycleManager();
30203
30430
  const beforeEachResult = await lifecycleManager.beforeEach(targetLocation, currentLocation);
30431
+ let finalPath = targetPath;
30204
30432
  // 如果 beforeEach 返回 false,阻止导航
30205
30433
  if (beforeEachResult === false) {
30206
30434
  logger.debug('路由导航被阻止: beforeEach 返回 false');
@@ -30209,14 +30437,14 @@
30209
30437
  // 如果 beforeEach 返回字符串,重定向到该路径
30210
30438
  if (typeof beforeEachResult === 'string') {
30211
30439
  logger.debug(`路由导航重定向: ${beforeEachResult}`);
30212
- to = beforeEachResult;
30440
+ finalPath = this.buildTargetPath(beforeEachResult);
30213
30441
  }
30214
30442
  // 执行中间件
30215
30443
  const middlewareManager = getRouterMiddlewareManager();
30216
30444
  const middlewareContext = {
30217
30445
  to: {
30218
30446
  ...targetLocation,
30219
- path: to
30447
+ path: finalPath
30220
30448
  },
30221
30449
  from: currentLocation,
30222
30450
  options
@@ -30226,8 +30454,10 @@
30226
30454
  if (!middlewareResult.allow) {
30227
30455
  if (middlewareResult.redirect) {
30228
30456
  logger.debug(`路由导航被中间件重定向: ${middlewareResult.redirect}`);
30229
- // 递归调用 navigate 进行重定向
30230
- return this.navigate(middlewareResult.redirect, options);
30457
+ return this.navigateInternal(middlewareResult.redirect, {
30458
+ ...options,
30459
+ query: undefined
30460
+ }, depth + 1, visited);
30231
30461
  }
30232
30462
  logger.debug(`路由导航被中间件阻止: ${middlewareResult.reason || '未知原因'}`);
30233
30463
  return;
@@ -30235,30 +30465,48 @@
30235
30465
  // 执行导航
30236
30466
  try {
30237
30467
  if (options?.replace) {
30238
- router.navigate(to, {
30468
+ router.navigate(finalPath, {
30239
30469
  replace: true,
30240
30470
  state: options.state
30241
30471
  });
30242
30472
  } else {
30243
- router.navigate(to, {
30473
+ router.navigate(finalPath, {
30244
30474
  state: options?.state
30245
30475
  });
30246
30476
  }
30247
30477
  // 执行 afterEach 钩子
30248
30478
  await lifecycleManager.afterEach({
30249
30479
  ...targetLocation,
30250
- path: to
30480
+ path: finalPath
30251
30481
  }, currentLocation);
30482
+ const duration = performance.now() - startTime;
30483
+ routerManager.getMonitoring().trackRoutePerformance(finalPath, {
30484
+ totalTime: duration
30485
+ });
30252
30486
  } catch (error) {
30253
30487
  logger.error('路由导航失败', error);
30254
30488
  throw error;
30255
30489
  }
30256
30490
  }
30257
30491
  /**
30492
+ * 导航到指定路径
30493
+ *
30494
+ * @param to - 目标路径或路由名称
30495
+ * @param options - 导航选项
30496
+ */ static async navigate(to, options) {
30497
+ return this.navigateInternal(to, options, 0, new Set());
30498
+ }
30499
+ /**
30258
30500
  * 获取当前路由信息
30259
30501
  *
30260
30502
  * @returns 当前路由位置信息
30261
30503
  */ static getCurrentRoute() {
30504
+ if (typeof window === 'undefined') {
30505
+ return {
30506
+ path: '/',
30507
+ query: {}
30508
+ };
30509
+ }
30262
30510
  // 从 window.location 获取当前路由信息
30263
30511
  const pathname = window.location.pathname;
30264
30512
  const search = window.location.search;
@@ -30306,6 +30554,7 @@
30306
30554
  });
30307
30555
  }
30308
30556
  }
30557
+ _define_property$8(RouterNavigation, "MAX_REDIRECTS", 10);
30309
30558
 
30310
30559
  function _define_property$7(obj, key, value) {
30311
30560
  if (key in obj) {