@taicode/common-web 3.7.5 → 3.7.7

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 (272) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +12 -13
  3. package/output/components/alert-dialog.d.ts +0 -20
  4. package/output/components/alert-dialog.d.ts.map +0 -1
  5. package/output/components/alert-dialog.js +0 -65
  6. package/output/components/alert.d.ts +0 -11
  7. package/output/components/alert.d.ts.map +0 -1
  8. package/output/components/alert.js +0 -38
  9. package/output/components/avatar.d.ts +0 -13
  10. package/output/components/avatar.d.ts.map +0 -1
  11. package/output/components/avatar.js +0 -40
  12. package/output/components/badge.d.ts +0 -11
  13. package/output/components/badge.d.ts.map +0 -1
  14. package/output/components/badge.js +0 -39
  15. package/output/components/button.d.ts +0 -12
  16. package/output/components/button.d.ts.map +0 -1
  17. package/output/components/button.js +0 -48
  18. package/output/components/calendar.d.ts +0 -13
  19. package/output/components/calendar.d.ts.map +0 -1
  20. package/output/components/calendar.js +0 -57
  21. package/output/components/card.d.ts +0 -13
  22. package/output/components/card.d.ts.map +0 -1
  23. package/output/components/card.js +0 -43
  24. package/output/components/chart.d.ts +0 -56
  25. package/output/components/chart.d.ts.map +0 -1
  26. package/output/components/chart.js +0 -127
  27. package/output/components/checkbox.d.ts +0 -5
  28. package/output/components/checkbox.d.ts.map +0 -1
  29. package/output/components/checkbox.js +0 -21
  30. package/output/components/command.d.ts +0 -20
  31. package/output/components/command.d.ts.map +0 -1
  32. package/output/components/command.js +0 -55
  33. package/output/components/dialog.d.ts +0 -20
  34. package/output/components/dialog.d.ts.map +0 -1
  35. package/output/components/dialog.js +0 -58
  36. package/output/components/direction.d.ts +0 -9
  37. package/output/components/direction.d.ts.map +0 -1
  38. package/output/components/direction.js +0 -10
  39. package/output/components/drawer.d.ts +0 -14
  40. package/output/components/drawer.d.ts.map +0 -1
  41. package/output/components/drawer.js +0 -56
  42. package/output/components/dropdown-menu.d.ts +0 -29
  43. package/output/components/dropdown-menu.d.ts.map +0 -1
  44. package/output/components/dropdown-menu.js +0 -78
  45. package/output/components/field.d.ts +0 -39
  46. package/output/components/field.d.ts.map +0 -1
  47. package/output/components/field.js +0 -102
  48. package/output/components/footer/index.d.ts +0 -27
  49. package/output/components/footer/index.d.ts.map +0 -1
  50. package/output/components/footer/index.js +0 -17
  51. package/output/components/form.d.ts +0 -26
  52. package/output/components/form.d.ts.map +0 -1
  53. package/output/components/form.js +0 -69
  54. package/output/components/index.d.ts +0 -46
  55. package/output/components/index.d.ts.map +0 -1
  56. package/output/components/index.js +0 -45
  57. package/output/components/input-group.d.ts +0 -17
  58. package/output/components/input-group.d.ts.map +0 -1
  59. package/output/components/input-group.js +0 -75
  60. package/output/components/input.d.ts +0 -4
  61. package/output/components/input.d.ts.map +0 -1
  62. package/output/components/input.js +0 -19
  63. package/output/components/item.d.ts +0 -25
  64. package/output/components/item.d.ts.map +0 -1
  65. package/output/components/item.js +0 -89
  66. package/output/components/json-view/index.d.ts +0 -11
  67. package/output/components/json-view/index.d.ts.map +0 -1
  68. package/output/components/json-view/index.js +0 -52
  69. package/output/components/json-view/lazy/index.d.ts +0 -18
  70. package/output/components/json-view/lazy/index.d.ts.map +0 -1
  71. package/output/components/json-view/lazy/index.js +0 -22
  72. package/output/components/kbd.d.ts +0 -4
  73. package/output/components/kbd.d.ts.map +0 -1
  74. package/output/components/kbd.js +0 -22
  75. package/output/components/label.d.ts +0 -5
  76. package/output/components/label.d.ts.map +0 -1
  77. package/output/components/label.js +0 -20
  78. package/output/components/list-actions/index.d.ts +0 -23
  79. package/output/components/list-actions/index.d.ts.map +0 -1
  80. package/output/components/list-actions/index.js +0 -15
  81. package/output/components/loading-button/index.d.ts +0 -44
  82. package/output/components/loading-button/index.d.ts.map +0 -1
  83. package/output/components/loading-button/index.js +0 -75
  84. package/output/components/loading-button/index.test.d.ts +0 -2
  85. package/output/components/loading-button/index.test.d.ts.map +0 -1
  86. package/output/components/loading-button/index.test.js +0 -203
  87. package/output/components/native-select.d.ts +0 -9
  88. package/output/components/native-select.d.ts.map +0 -1
  89. package/output/components/native-select.js +0 -28
  90. package/output/components/page-back-button/index.d.ts +0 -8
  91. package/output/components/page-back-button/index.d.ts.map +0 -1
  92. package/output/components/page-back-button/index.js +0 -7
  93. package/output/components/page-state.d.ts +0 -19
  94. package/output/components/page-state.d.ts.map +0 -1
  95. package/output/components/page-state.js +0 -13
  96. package/output/components/pagination/index.d.ts +0 -34
  97. package/output/components/pagination/index.d.ts.map +0 -1
  98. package/output/components/pagination/index.js +0 -75
  99. package/output/components/popover.d.ts +0 -11
  100. package/output/components/popover.d.ts.map +0 -1
  101. package/output/components/popover.js +0 -44
  102. package/output/components/progress.d.ts +0 -5
  103. package/output/components/progress.d.ts.map +0 -1
  104. package/output/components/progress.js +0 -21
  105. package/output/components/radio-group.d.ts +0 -6
  106. package/output/components/radio-group.d.ts.map +0 -1
  107. package/output/components/radio-group.js +0 -25
  108. package/output/components/route-pending-indicator/index.d.ts +0 -20
  109. package/output/components/route-pending-indicator/index.d.ts.map +0 -1
  110. package/output/components/route-pending-indicator/index.js +0 -17
  111. package/output/components/scroll-area.d.ts +0 -6
  112. package/output/components/scroll-area.d.ts.map +0 -1
  113. package/output/components/scroll-area.js +0 -24
  114. package/output/components/searchable-select/index.d.ts +0 -41
  115. package/output/components/searchable-select/index.d.ts.map +0 -1
  116. package/output/components/searchable-select/index.js +0 -46
  117. package/output/components/select.d.ts +0 -17
  118. package/output/components/select.d.ts.map +0 -1
  119. package/output/components/select.js +0 -58
  120. package/output/components/separator.d.ts +0 -5
  121. package/output/components/separator.d.ts.map +0 -1
  122. package/output/components/separator.js +0 -20
  123. package/output/components/sheet.d.ts +0 -16
  124. package/output/components/sheet.d.ts.map +0 -1
  125. package/output/components/sheet.js +0 -58
  126. package/output/components/sidebar.d.ts +0 -78
  127. package/output/components/sidebar.d.ts.map +0 -1
  128. package/output/components/sidebar.js +0 -233
  129. package/output/components/size-provider/index.d.ts +0 -2
  130. package/output/components/size-provider/index.d.ts.map +0 -1
  131. package/output/components/size-provider/index.js +0 -1
  132. package/output/components/size-provider/size-provider.d.ts +0 -9
  133. package/output/components/size-provider/size-provider.d.ts.map +0 -1
  134. package/output/components/size-provider/size-provider.js +0 -29
  135. package/output/components/skeleton.d.ts +0 -3
  136. package/output/components/skeleton.d.ts.map +0 -1
  137. package/output/components/skeleton.js +0 -18
  138. package/output/components/sonner.d.ts +0 -8
  139. package/output/components/sonner.d.ts.map +0 -1
  140. package/output/components/sonner.js +0 -34
  141. package/output/components/spinner.d.ts +0 -3
  142. package/output/components/spinner.d.ts.map +0 -1
  143. package/output/components/spinner.js +0 -19
  144. package/output/components/switch.d.ts +0 -8
  145. package/output/components/switch.d.ts.map +0 -1
  146. package/output/components/switch.js +0 -20
  147. package/output/components/table.d.ts +0 -11
  148. package/output/components/table.d.ts.map +0 -1
  149. package/output/components/table.js +0 -47
  150. package/output/components/tabs.d.ts +0 -12
  151. package/output/components/tabs.d.ts.map +0 -1
  152. package/output/components/tabs.js +0 -45
  153. package/output/components/textarea.d.ts +0 -4
  154. package/output/components/textarea.d.ts.map +0 -1
  155. package/output/components/textarea.js +0 -19
  156. package/output/components/theme-switcher.d.ts +0 -6
  157. package/output/components/theme-switcher.d.ts.map +0 -1
  158. package/output/components/theme-switcher.js +0 -19
  159. package/output/components/toaster/index.d.ts +0 -16
  160. package/output/components/toaster/index.d.ts.map +0 -1
  161. package/output/components/toaster/index.js +0 -70
  162. package/output/components/toggle-group.d.ts +0 -12
  163. package/output/components/toggle-group.d.ts.map +0 -1
  164. package/output/components/toggle-group.js +0 -38
  165. package/output/components/toggle.d.ts +0 -10
  166. package/output/components/toggle.d.ts.map +0 -1
  167. package/output/components/toggle.js +0 -38
  168. package/output/components/tooltip.d.ts +0 -8
  169. package/output/components/tooltip.d.ts.map +0 -1
  170. package/output/components/tooltip.js +0 -33
  171. package/output/features/confirm-dialog/index.d.ts +0 -41
  172. package/output/features/confirm-dialog/index.d.ts.map +0 -1
  173. package/output/features/confirm-dialog/index.js +0 -19
  174. package/output/features/input-confirm/index.d.ts +0 -26
  175. package/output/features/input-confirm/index.d.ts.map +0 -1
  176. package/output/features/input-confirm/index.js +0 -59
  177. package/output/features/signin/context.d.ts +0 -14
  178. package/output/features/signin/context.d.ts.map +0 -1
  179. package/output/features/signin/context.js +0 -13
  180. package/output/features/signin/index.d.ts +0 -58
  181. package/output/features/signin/index.d.ts.map +0 -1
  182. package/output/features/signin/index.js +0 -137
  183. package/output/features/signin/service.d.ts +0 -92
  184. package/output/features/signin/service.d.ts.map +0 -1
  185. package/output/features/signin/service.js +0 -519
  186. package/output/features/signin/service.test.d.ts +0 -2
  187. package/output/features/signin/service.test.d.ts.map +0 -1
  188. package/output/features/signin/service.test.js +0 -211
  189. package/output/features/signin/types.d.ts +0 -63
  190. package/output/features/signin/types.d.ts.map +0 -1
  191. package/output/features/signin/types.js +0 -1
  192. package/output/hooks/use-loading/index.d.ts +0 -6
  193. package/output/hooks/use-loading/index.d.ts.map +0 -1
  194. package/output/hooks/use-loading/index.js +0 -14
  195. package/output/hooks/use-loading/index.test.d.ts +0 -2
  196. package/output/hooks/use-loading/index.test.d.ts.map +0 -1
  197. package/output/hooks/use-loading/index.test.js +0 -24
  198. package/output/hooks/use-mobile/index.d.ts +0 -2
  199. package/output/hooks/use-mobile/index.d.ts.map +0 -1
  200. package/output/hooks/use-mobile/index.js +0 -16
  201. package/output/hooks/use-observer/index.d.ts +0 -2
  202. package/output/hooks/use-observer/index.d.ts.map +0 -1
  203. package/output/hooks/use-observer/index.js +0 -1
  204. package/output/hooks/use-observer/use-observer.d.ts +0 -3
  205. package/output/hooks/use-observer/use-observer.d.ts.map +0 -1
  206. package/output/hooks/use-observer/use-observer.js +0 -16
  207. package/output/hooks/use-observer/use-observer.test.d.ts +0 -2
  208. package/output/hooks/use-observer/use-observer.test.d.ts.map +0 -1
  209. package/output/hooks/use-observer/use-observer.test.js +0 -134
  210. package/output/hooks/use-offline/index.d.ts +0 -6
  211. package/output/hooks/use-offline/index.d.ts.map +0 -1
  212. package/output/hooks/use-offline/index.js +0 -19
  213. package/output/layout/app/index.d.ts +0 -34
  214. package/output/layout/app/index.d.ts.map +0 -1
  215. package/output/layout/app/index.js +0 -34
  216. package/output/layout/dashboard/index.d.ts +0 -76
  217. package/output/layout/dashboard/index.d.ts.map +0 -1
  218. package/output/layout/dashboard/index.js +0 -84
  219. package/output/layout/index.d.ts +0 -3
  220. package/output/layout/index.d.ts.map +0 -1
  221. package/output/layout/index.js +0 -2
  222. package/output/services/cache-api/cache-api.d.ts +0 -23
  223. package/output/services/cache-api/cache-api.d.ts.map +0 -1
  224. package/output/services/cache-api/cache-api.js +0 -145
  225. package/output/services/cache-api/cache-api.test.d.ts +0 -2
  226. package/output/services/cache-api/cache-api.test.d.ts.map +0 -1
  227. package/output/services/cache-api/cache-api.test.js +0 -610
  228. package/output/services/cache-api/index.d.ts +0 -2
  229. package/output/services/cache-api/index.d.ts.map +0 -1
  230. package/output/services/cache-api/index.js +0 -1
  231. package/output/services/cached-fetch/index.d.ts +0 -50
  232. package/output/services/cached-fetch/index.d.ts.map +0 -1
  233. package/output/services/cached-fetch/index.js +0 -196
  234. package/output/services/service/index.d.ts +0 -2
  235. package/output/services/service/index.d.ts.map +0 -1
  236. package/output/services/service/index.js +0 -1
  237. package/output/services/service/service.d.ts +0 -135
  238. package/output/services/service/service.d.ts.map +0 -1
  239. package/output/services/service/service.js +0 -276
  240. package/output/services/service/service.test.d.ts +0 -2
  241. package/output/services/service/service.test.d.ts.map +0 -1
  242. package/output/services/service/service.test.js +0 -1399
  243. package/output/services/side-cache/index.d.ts +0 -2
  244. package/output/services/side-cache/index.d.ts.map +0 -1
  245. package/output/services/side-cache/index.js +0 -1
  246. package/output/services/side-cache/side-cache.d.ts +0 -11
  247. package/output/services/side-cache/side-cache.d.ts.map +0 -1
  248. package/output/services/side-cache/side-cache.js +0 -161
  249. package/output/services/side-cache/side-cache.test.d.ts +0 -2
  250. package/output/services/side-cache/side-cache.test.d.ts.map +0 -1
  251. package/output/services/side-cache/side-cache.test.js +0 -271
  252. package/output/utils/avatar/index.d.ts +0 -28
  253. package/output/utils/avatar/index.d.ts.map +0 -1
  254. package/output/utils/avatar/index.js +0 -35
  255. package/output/utils/delay/index.d.ts +0 -2
  256. package/output/utils/delay/index.d.ts.map +0 -1
  257. package/output/utils/delay/index.js +0 -5
  258. package/output/utils/form/index.d.ts +0 -3
  259. package/output/utils/form/index.d.ts.map +0 -1
  260. package/output/utils/form/index.js +0 -1
  261. package/output/utils/merge-class-names/index.d.ts +0 -3
  262. package/output/utils/merge-class-names/index.d.ts.map +0 -1
  263. package/output/utils/merge-class-names/index.js +0 -5
  264. package/output/utils/merge-class-names/index.test.d.ts +0 -2
  265. package/output/utils/merge-class-names/index.test.d.ts.map +0 -1
  266. package/output/utils/merge-class-names/index.test.js +0 -7
  267. package/output/utils/performance/index.d.ts +0 -82
  268. package/output/utils/performance/index.d.ts.map +0 -1
  269. package/output/utils/performance/index.js +0 -129
  270. package/output/utils/redirect/index.d.ts +0 -6
  271. package/output/utils/redirect/index.d.ts.map +0 -1
  272. package/output/utils/redirect/index.js +0 -32
@@ -1,82 +0,0 @@
1
- import { type Metric } from 'web-vitals';
2
- /**
3
- * 性能指标类型
4
- */
5
- export interface PerformanceMetrics {
6
- cls?: Metric;
7
- fcp?: Metric;
8
- inp?: Metric;
9
- lcp?: Metric;
10
- ttfb?: Metric;
11
- }
12
- /**
13
- * 性能监控配置
14
- */
15
- export interface PerformanceMonitorConfig {
16
- /**
17
- * 是否启用性能监控
18
- */
19
- enabled: boolean;
20
- /**
21
- * 是否在控制台输出日志
22
- */
23
- logToConsole: boolean;
24
- /**
25
- * 性能指标上报回调
26
- */
27
- onMetric?: (metric: Metric) => void;
28
- /**
29
- * 错误追踪回调
30
- */
31
- onError?: (error: Error) => void;
32
- }
33
- /**
34
- * 性能监控器类
35
- */
36
- export declare class PerformanceMonitor {
37
- private config;
38
- private metrics;
39
- private isInitialized;
40
- constructor(config?: Partial<PerformanceMonitorConfig>);
41
- /**
42
- * 初始化性能监控
43
- */
44
- init(): void;
45
- /**
46
- * 处理性能指标
47
- */
48
- private handleMetric;
49
- /**
50
- * 输出性能指标到控制台
51
- */
52
- private logMetric;
53
- /**
54
- * 设置错误追踪
55
- */
56
- private setupErrorTracking;
57
- /**
58
- * 处理错误
59
- */
60
- private handleError;
61
- /**
62
- * 获取当前收集的所有性能指标
63
- */
64
- getMetrics(): PerformanceMetrics;
65
- /**
66
- * 手动记录自定义性能指标
67
- */
68
- recordCustomMetric(name: string, value: number, metadata?: Record<string, unknown>): void;
69
- /**
70
- * 手动报告错误
71
- */
72
- reportError(error: Error | string): void;
73
- }
74
- /**
75
- * 获取性能监控器单例
76
- */
77
- export declare function getPerformanceMonitor(config?: Partial<PerformanceMonitorConfig>): PerformanceMonitor;
78
- /**
79
- * 初始化性能监控(便捷函数)
80
- */
81
- export declare function initPerformanceMonitoring(config?: Partial<PerformanceMonitorConfig>): void;
82
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/utils/performance/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,MAAM,EAAE,MAAM,YAAY,CAAA;AAE5E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,YAAY,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACjC;AAUD;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,aAAa,CAAQ;gBAEjB,MAAM,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC;IAItD;;OAEG;IACH,IAAI,IAAI,IAAI;IAsBZ;;OAEG;IACH,OAAO,CAAC,YAAY;IAYpB;;OAEG;IACH,OAAO,CAAC,SAAS;IAWjB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAU1B;;OAEG;IACH,OAAO,CAAC,WAAW;IAUnB;;OAEG;IACH,UAAU,IAAI,kBAAkB;IAIhC;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAkBzF;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI;CAIzC;AAKD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,GAAG,kBAAkB,CAKpG;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,GAAG,IAAI,CAG1F"}
@@ -1,129 +0,0 @@
1
- import { onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';
2
- /**
3
- * 默认配置
4
- */
5
- const defaultConfig = {
6
- enabled: true,
7
- logToConsole: true,
8
- };
9
- /**
10
- * 性能监控器类
11
- */
12
- export class PerformanceMonitor {
13
- constructor(config) {
14
- this.metrics = {};
15
- this.isInitialized = false;
16
- this.config = Object.assign(Object.assign({}, defaultConfig), config);
17
- }
18
- /**
19
- * 初始化性能监控
20
- */
21
- init() {
22
- if (this.isInitialized || !this.config.enabled) {
23
- return;
24
- }
25
- this.isInitialized = true;
26
- // 注册 Core Web Vitals 监听器
27
- onCLS(this.handleMetric.bind(this));
28
- onFCP(this.handleMetric.bind(this));
29
- onINP(this.handleMetric.bind(this));
30
- onLCP(this.handleMetric.bind(this));
31
- onTTFB(this.handleMetric.bind(this));
32
- // 注册全局错误监听器
33
- this.setupErrorTracking();
34
- if (this.config.logToConsole) {
35
- console.log('[PerformanceMonitor] 性能监控已初始化');
36
- }
37
- }
38
- /**
39
- * 处理性能指标
40
- */
41
- handleMetric(metric) {
42
- this.metrics[metric.name.toLowerCase()] = metric;
43
- if (this.config.logToConsole) {
44
- this.logMetric(metric);
45
- }
46
- if (this.config.onMetric) {
47
- this.config.onMetric(metric);
48
- }
49
- }
50
- /**
51
- * 输出性能指标到控制台
52
- */
53
- logMetric(metric) {
54
- const { name, value, rating } = metric;
55
- const color = rating === 'good' ? '#22c55e' : rating === 'needs-improvement' ? '#eab308' : '#ef4444';
56
- console.log(`%c[Performance] ${name}: ${value.toFixed(2)} (${rating})`, `color: ${color}; font-weight: bold;`);
57
- }
58
- /**
59
- * 设置错误追踪
60
- */
61
- setupErrorTracking() {
62
- window.addEventListener('error', (event) => {
63
- this.handleError(event.error || new Error(event.message));
64
- });
65
- window.addEventListener('unhandledrejection', (event) => {
66
- this.handleError(new Error(`Unhandled Promise Rejection: ${event.reason}`));
67
- });
68
- }
69
- /**
70
- * 处理错误
71
- */
72
- handleError(error) {
73
- if (this.config.logToConsole) {
74
- console.error('[PerformanceMonitor] 捕获到错误:', error);
75
- }
76
- if (this.config.onError) {
77
- this.config.onError(error);
78
- }
79
- }
80
- /**
81
- * 获取当前收集的所有性能指标
82
- */
83
- getMetrics() {
84
- return Object.assign({}, this.metrics);
85
- }
86
- /**
87
- * 手动记录自定义性能指标
88
- */
89
- recordCustomMetric(name, value, metadata) {
90
- const customMetric = {
91
- name,
92
- value,
93
- rating: value < 100 ? 'good' : value < 300 ? 'needs-improvement' : 'poor',
94
- delta: value,
95
- entries: [],
96
- id: `custom-${Date.now()}`,
97
- navigationType: 'navigate',
98
- };
99
- this.handleMetric(customMetric);
100
- if (this.config.logToConsole && metadata) {
101
- console.log('[PerformanceMonitor] 自定义指标元数据:', metadata);
102
- }
103
- }
104
- /**
105
- * 手动报告错误
106
- */
107
- reportError(error) {
108
- const errorObj = typeof error === 'string' ? new Error(error) : error;
109
- this.handleError(errorObj);
110
- }
111
- }
112
- // 创建单例实例
113
- let monitorInstance = null;
114
- /**
115
- * 获取性能监控器单例
116
- */
117
- export function getPerformanceMonitor(config) {
118
- if (!monitorInstance) {
119
- monitorInstance = new PerformanceMonitor(config);
120
- }
121
- return monitorInstance;
122
- }
123
- /**
124
- * 初始化性能监控(便捷函数)
125
- */
126
- export function initPerformanceMonitoring(config) {
127
- const monitor = getPerformanceMonitor(config);
128
- monitor.init();
129
- }
@@ -1,6 +0,0 @@
1
- interface ResolvedRedirect {
2
- target: string;
3
- }
4
- export declare function resolveSafeRedirect(redirect: string | undefined, locale: string): ResolvedRedirect | null;
5
- export {};
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/utils/redirect/index.ts"],"names":[],"mappings":"AAEA,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAA;CACf;AAgBD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAwBzG"}
@@ -1,32 +0,0 @@
1
- const LOCALE_SEGMENT_REGEX = /^\/(zh-CN|en-US)(\/|$)/;
2
- function withLocalePrefix(pathname, locale) {
3
- const normalizedPathname = pathname.startsWith('/') ? pathname : `/${pathname}`;
4
- if (LOCALE_SEGMENT_REGEX.test(normalizedPathname)) {
5
- return normalizedPathname;
6
- }
7
- if (normalizedPathname === '/') {
8
- return `/${locale}`;
9
- }
10
- return `/${locale}${normalizedPathname}`;
11
- }
12
- export function resolveSafeRedirect(redirect, locale) {
13
- if (!(redirect === null || redirect === void 0 ? void 0 : redirect.trim())) {
14
- return null;
15
- }
16
- try {
17
- const url = new URL(redirect, window.location.origin);
18
- if (!['http:', 'https:'].includes(url.protocol)) {
19
- return null;
20
- }
21
- if (url.origin !== window.location.origin) {
22
- return null;
23
- }
24
- const pathname = withLocalePrefix(url.pathname, locale);
25
- return {
26
- target: `${pathname}${url.search}${url.hash}`,
27
- };
28
- }
29
- catch (_a) {
30
- return null;
31
- }
32
- }