taro-uno-ui 1.0.1 → 1.0.2

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 (414) hide show
  1. package/README.md +67 -30
  2. package/dist/js/{index-CDFsvu80.js → index-QpKiGsEQ.js} +39026 -28023
  3. package/dist/js/index-QpKiGsEQ.js.map +1 -0
  4. package/dist/js/{index-JffnTUrv.js → index-nnTHNhwl.js} +38743 -27720
  5. package/dist/js/index-nnTHNhwl.js.map +1 -0
  6. package/package.json +4 -4
  7. package/dist/js/index-CDFsvu80.js.map +0 -1
  8. package/dist/js/index-DFdcksbe.js +0 -1165
  9. package/dist/js/index-DFdcksbe.js.map +0 -1
  10. package/dist/js/index-DXRIkWX1.js +0 -1148
  11. package/dist/js/index-DXRIkWX1.js.map +0 -1
  12. package/dist/js/index-JffnTUrv.js.map +0 -1
  13. package/dist/utils/http/request.d.ts +0 -280
  14. package/src/app.config.ts +0 -55
  15. package/src/app.scss +0 -508
  16. package/src/app.tsx +0 -44
  17. package/src/components/basic/Button/Button.styles.ts +0 -130
  18. package/src/components/basic/Button/Button.test.tsx +0 -154
  19. package/src/components/basic/Button/Button.tsx +0 -133
  20. package/src/components/basic/Button/Button.types.ts +0 -81
  21. package/src/components/basic/Button/index.tsx +0 -6
  22. package/src/components/basic/Divider/Divider.styles.ts +0 -488
  23. package/src/components/basic/Divider/Divider.test.tsx +0 -551
  24. package/src/components/basic/Divider/Divider.tsx +0 -392
  25. package/src/components/basic/Divider/Divider.types.ts +0 -261
  26. package/src/components/basic/Divider/index.tsx +0 -25
  27. package/src/components/basic/Icon/Icon.data.ts +0 -474
  28. package/src/components/basic/Icon/Icon.styles.ts +0 -359
  29. package/src/components/basic/Icon/Icon.test.tsx +0 -357
  30. package/src/components/basic/Icon/Icon.tsx +0 -167
  31. package/src/components/basic/Icon/Icon.types.ts +0 -210
  32. package/src/components/basic/Icon/IconManager.ts +0 -229
  33. package/src/components/basic/Icon/index.tsx +0 -22
  34. package/src/components/basic/Text/Text.styles.ts +0 -500
  35. package/src/components/basic/Text/Text.test.tsx +0 -299
  36. package/src/components/basic/Text/Text.tsx +0 -340
  37. package/src/components/basic/Text/Text.types.ts +0 -329
  38. package/src/components/basic/Text/index.tsx +0 -27
  39. package/src/components/basic/Typography/Typography.styles.ts +0 -347
  40. package/src/components/basic/Typography/Typography.tsx +0 -207
  41. package/src/components/basic/Typography/Typography.types.ts +0 -296
  42. package/src/components/basic/Typography/index.tsx +0 -14
  43. package/src/components/basic/Video/Video.styles.ts +0 -777
  44. package/src/components/basic/Video/Video.test.tsx +0 -490
  45. package/src/components/basic/Video/Video.tsx +0 -1468
  46. package/src/components/basic/Video/Video.types.ts +0 -500
  47. package/src/components/basic/Video/index.tsx +0 -26
  48. package/src/components/basic/index.tsx +0 -300
  49. package/src/components/common/ErrorBoundary.tsx +0 -87
  50. package/src/components/common/LazyComponent.tsx +0 -247
  51. package/src/components/common/ResponsiveContainer.tsx +0 -93
  52. package/src/components/common/ResponsiveGrid.tsx +0 -183
  53. package/src/components/common/SecurityProvider.tsx +0 -98
  54. package/src/components/common/ThemeProvider.tsx +0 -115
  55. package/src/components/common/VirtualList.tsx +0 -350
  56. package/src/components/common/__tests__/ErrorBoundary.test.tsx +0 -249
  57. package/src/components/common/index.tsx +0 -32
  58. package/src/components/display/Avatar/Avatar.styles.ts +0 -62
  59. package/src/components/display/Avatar/Avatar.test.tsx +0 -390
  60. package/src/components/display/Avatar/Avatar.tsx +0 -66
  61. package/src/components/display/Avatar/Avatar.types.ts +0 -40
  62. package/src/components/display/Avatar/index.ts +0 -3
  63. package/src/components/display/Badge/Badge.tsx +0 -29
  64. package/src/components/display/Badge/Badge.types.ts +0 -29
  65. package/src/components/display/Badge/index.ts +0 -2
  66. package/src/components/display/Calendar/Calendar.styles.ts +0 -255
  67. package/src/components/display/Calendar/Calendar.test.tsx +0 -42
  68. package/src/components/display/Calendar/Calendar.tsx +0 -358
  69. package/src/components/display/Calendar/Calendar.types.ts +0 -91
  70. package/src/components/display/Calendar/index.ts +0 -3
  71. package/src/components/display/Card/Card.styles.ts +0 -89
  72. package/src/components/display/Card/Card.test.tsx +0 -182
  73. package/src/components/display/Card/Card.tsx +0 -135
  74. package/src/components/display/Card/Card.types.ts +0 -55
  75. package/src/components/display/Card/index.ts +0 -3
  76. package/src/components/display/Carousel/Carousel.styles.ts +0 -206
  77. package/src/components/display/Carousel/Carousel.tsx +0 -290
  78. package/src/components/display/Carousel/Carousel.types.ts +0 -57
  79. package/src/components/display/Carousel/index.ts +0 -3
  80. package/src/components/display/List/List.styles.ts +0 -79
  81. package/src/components/display/List/List.tsx +0 -114
  82. package/src/components/display/List/List.types.ts +0 -68
  83. package/src/components/display/List/index.ts +0 -3
  84. package/src/components/display/Rate/Rate.styles.ts +0 -254
  85. package/src/components/display/Rate/Rate.tsx +0 -324
  86. package/src/components/display/Rate/Rate.types.ts +0 -112
  87. package/src/components/display/Rate/index.ts +0 -20
  88. package/src/components/display/Table/Table.styles.ts +0 -269
  89. package/src/components/display/Table/Table.test.tsx +0 -345
  90. package/src/components/display/Table/Table.tsx +0 -426
  91. package/src/components/display/Table/Table.types.ts +0 -256
  92. package/src/components/display/Table/index.tsx +0 -16
  93. package/src/components/display/Tag/Tag.styles.ts +0 -197
  94. package/src/components/display/Tag/Tag.test.tsx +0 -541
  95. package/src/components/display/Tag/Tag.tsx +0 -139
  96. package/src/components/display/Tag/Tag.types.ts +0 -49
  97. package/src/components/display/Tag/index.ts +0 -3
  98. package/src/components/display/Timeline/Timeline.styles.ts +0 -211
  99. package/src/components/display/Timeline/Timeline.tsx +0 -220
  100. package/src/components/display/Timeline/Timeline.types.ts +0 -56
  101. package/src/components/display/Timeline/index.ts +0 -3
  102. package/src/components/display/index.tsx +0 -147
  103. package/src/components/feedback/Loading/Loading.styles.ts +0 -117
  104. package/src/components/feedback/Loading/Loading.test.tsx +0 -534
  105. package/src/components/feedback/Loading/Loading.tsx +0 -132
  106. package/src/components/feedback/Loading/Loading.types.ts +0 -33
  107. package/src/components/feedback/Loading/index.ts +0 -6
  108. package/src/components/feedback/Message/Message.styles.ts +0 -41
  109. package/src/components/feedback/Message/Message.test.tsx +0 -234
  110. package/src/components/feedback/Message/Message.tsx +0 -96
  111. package/src/components/feedback/Message/Message.types.ts +0 -37
  112. package/src/components/feedback/Message/index.ts +0 -6
  113. package/src/components/feedback/Modal/Modal.styles.ts +0 -21
  114. package/src/components/feedback/Modal/Modal.test.tsx +0 -11
  115. package/src/components/feedback/Modal/Modal.tsx +0 -269
  116. package/src/components/feedback/Modal/Modal.types.ts +0 -151
  117. package/src/components/feedback/Modal/index.tsx +0 -11
  118. package/src/components/feedback/Notification/Notification.styles.ts +0 -453
  119. package/src/components/feedback/Notification/Notification.test.tsx +0 -401
  120. package/src/components/feedback/Notification/Notification.tsx +0 -347
  121. package/src/components/feedback/Notification/Notification.types.ts +0 -339
  122. package/src/components/feedback/Notification/NotificationManager.tsx +0 -405
  123. package/src/components/feedback/Notification/index.ts +0 -40
  124. package/src/components/feedback/Notification/index.tsx +0 -154
  125. package/src/components/feedback/Progress/Progress.styles.ts +0 -469
  126. package/src/components/feedback/Progress/Progress.test.simple.tsx +0 -14
  127. package/src/components/feedback/Progress/Progress.test.tsx +0 -312
  128. package/src/components/feedback/Progress/Progress.tsx +0 -488
  129. package/src/components/feedback/Progress/Progress.types.ts +0 -163
  130. package/src/components/feedback/Progress/index.ts +0 -3
  131. package/src/components/feedback/Progress/index.tsx +0 -38
  132. package/src/components/feedback/Progress/utils/animation.ts +0 -193
  133. package/src/components/feedback/Progress/utils/index.ts +0 -26
  134. package/src/components/feedback/Progress/utils/progress-calculator.ts +0 -199
  135. package/src/components/feedback/Result/Result.styles.ts +0 -139
  136. package/src/components/feedback/Result/Result.tsx +0 -221
  137. package/src/components/feedback/Result/Result.types.ts +0 -128
  138. package/src/components/feedback/Result/index.tsx +0 -3
  139. package/src/components/feedback/Toast/Toast.styles.ts +0 -17
  140. package/src/components/feedback/Toast/Toast.test.tsx +0 -10
  141. package/src/components/feedback/Toast/Toast.tsx +0 -384
  142. package/src/components/feedback/Toast/Toast.types.ts +0 -86
  143. package/src/components/feedback/Toast/index.tsx +0 -3
  144. package/src/components/feedback/Tooltip/Tooltip.examples.tsx +0 -435
  145. package/src/components/feedback/Tooltip/Tooltip.styles.ts +0 -340
  146. package/src/components/feedback/Tooltip/Tooltip.test.tsx +0 -446
  147. package/src/components/feedback/Tooltip/Tooltip.tsx +0 -302
  148. package/src/components/feedback/Tooltip/Tooltip.types.ts +0 -166
  149. package/src/components/feedback/Tooltip/index.ts +0 -3
  150. package/src/components/feedback/Tooltip/index.tsx +0 -246
  151. package/src/components/feedback/index.tsx +0 -176
  152. package/src/components/form/Cascader/Cascader.styles.ts +0 -526
  153. package/src/components/form/Cascader/Cascader.test.tsx +0 -77
  154. package/src/components/form/Cascader/Cascader.tsx +0 -581
  155. package/src/components/form/Cascader/Cascader.types.ts +0 -581
  156. package/src/components/form/Cascader/hooks/index.ts +0 -3
  157. package/src/components/form/Cascader/hooks/useCascaderFieldNames.ts +0 -19
  158. package/src/components/form/Cascader/hooks/useCascaderOptions.ts +0 -127
  159. package/src/components/form/Cascader/hooks/useCascaderState.ts +0 -139
  160. package/src/components/form/Cascader/index.ts +0 -25
  161. package/src/components/form/Cascader/utils/formatDisplayValue.ts +0 -19
  162. package/src/components/form/Cascader/utils/index.ts +0 -1
  163. package/src/components/form/Checkbox/Checkbox.styles.ts +0 -607
  164. package/src/components/form/Checkbox/Checkbox.test.tsx +0 -1140
  165. package/src/components/form/Checkbox/Checkbox.tsx +0 -489
  166. package/src/components/form/Checkbox/Checkbox.types.ts +0 -472
  167. package/src/components/form/Checkbox/CheckboxGroup.tsx +0 -444
  168. package/src/components/form/Checkbox/index.tsx +0 -27
  169. package/src/components/form/DatePicker/DatePicker.styles.ts +0 -393
  170. package/src/components/form/DatePicker/DatePicker.test.tsx +0 -407
  171. package/src/components/form/DatePicker/DatePicker.tsx +0 -376
  172. package/src/components/form/DatePicker/DatePicker.types.ts +0 -250
  173. package/src/components/form/DatePicker/index.tsx +0 -15
  174. package/src/components/form/Form/Form.styles.ts +0 -357
  175. package/src/components/form/Form/Form.test.tsx +0 -122
  176. package/src/components/form/Form/Form.tsx +0 -257
  177. package/src/components/form/Form/Form.types.ts +0 -422
  178. package/src/components/form/Form/index.tsx +0 -31
  179. package/src/components/form/Form/useFormLogic.ts +0 -497
  180. package/src/components/form/Input/Input.styles.ts +0 -445
  181. package/src/components/form/Input/Input.test.tsx +0 -494
  182. package/src/components/form/Input/Input.tsx +0 -305
  183. package/src/components/form/Input/Input.types.ts +0 -297
  184. package/src/components/form/Input/index.tsx +0 -26
  185. package/src/components/form/Input/useInputLogic.test.ts +0 -82
  186. package/src/components/form/Input/useInputLogic.ts +0 -260
  187. package/src/components/form/InputNumber/InputNumber.styles.ts +0 -716
  188. package/src/components/form/InputNumber/InputNumber.tsx +0 -402
  189. package/src/components/form/InputNumber/InputNumber.types.ts +0 -336
  190. package/src/components/form/InputNumber/components/InputNumberClearButton.tsx +0 -24
  191. package/src/components/form/InputNumber/components/InputNumberControls.tsx +0 -33
  192. package/src/components/form/InputNumber/components/index.ts +0 -2
  193. package/src/components/form/InputNumber/hooks/index.ts +0 -4
  194. package/src/components/form/InputNumber/hooks/useInputNumberState.ts +0 -313
  195. package/src/components/form/InputNumber/hooks/useInputNumberValidation.ts +0 -148
  196. package/src/components/form/InputNumber/index.ts +0 -25
  197. package/src/components/form/Radio/Radio.styles.ts +0 -451
  198. package/src/components/form/Radio/Radio.test.tsx +0 -547
  199. package/src/components/form/Radio/Radio.tsx +0 -277
  200. package/src/components/form/Radio/Radio.types.ts +0 -414
  201. package/src/components/form/Radio/index.tsx +0 -21
  202. package/src/components/form/Select/Select.styles.ts +0 -518
  203. package/src/components/form/Select/Select.test.tsx +0 -648
  204. package/src/components/form/Select/Select.tsx +0 -474
  205. package/src/components/form/Select/Select.types.ts +0 -429
  206. package/src/components/form/Select/index.tsx +0 -30
  207. package/src/components/form/Slider/Slider.styles.ts +0 -139
  208. package/src/components/form/Slider/Slider.test.tsx +0 -553
  209. package/src/components/form/Slider/Slider.tsx +0 -312
  210. package/src/components/form/Slider/Slider.types.ts +0 -110
  211. package/src/components/form/Slider/index.tsx +0 -3
  212. package/src/components/form/Switch/Switch.styles.ts +0 -534
  213. package/src/components/form/Switch/Switch.test.tsx +0 -345
  214. package/src/components/form/Switch/Switch.tsx +0 -458
  215. package/src/components/form/Switch/Switch.types.ts +0 -386
  216. package/src/components/form/Switch/index.tsx +0 -26
  217. package/src/components/form/Textarea/Textarea.styles.ts +0 -592
  218. package/src/components/form/Textarea/Textarea.test.tsx +0 -1075
  219. package/src/components/form/Textarea/Textarea.tsx +0 -608
  220. package/src/components/form/Textarea/Textarea.types.ts +0 -374
  221. package/src/components/form/Textarea/index.tsx +0 -26
  222. package/src/components/form/TimePicker/TimePicker.styles.ts +0 -434
  223. package/src/components/form/TimePicker/TimePicker.test.tsx +0 -306
  224. package/src/components/form/TimePicker/TimePicker.tsx +0 -250
  225. package/src/components/form/TimePicker/TimePicker.types.ts +0 -385
  226. package/src/components/form/TimePicker/index.ts +0 -21
  227. package/src/components/form/Transfer/Transfer.styles.ts +0 -490
  228. package/src/components/form/Transfer/Transfer.test.tsx +0 -316
  229. package/src/components/form/Transfer/Transfer.tsx +0 -414
  230. package/src/components/form/Transfer/Transfer.types.ts +0 -565
  231. package/src/components/form/Transfer/components/TransferItem.tsx +0 -94
  232. package/src/components/form/Transfer/components/TransferList.tsx +0 -298
  233. package/src/components/form/Transfer/components/TransferOperations.tsx +0 -81
  234. package/src/components/form/Transfer/components/TransferPagination.tsx +0 -139
  235. package/src/components/form/Transfer/components/TransferSearch.tsx +0 -85
  236. package/src/components/form/Transfer/components/index.ts +0 -6
  237. package/src/components/form/Transfer/hooks/index.ts +0 -3
  238. package/src/components/form/Transfer/hooks/useTransferData.ts +0 -202
  239. package/src/components/form/Transfer/hooks/useTransferState.ts +0 -120
  240. package/src/components/form/Transfer/index.ts +0 -27
  241. package/src/components/form/Upload/Upload.styles.ts +0 -145
  242. package/src/components/form/Upload/Upload.test.tsx +0 -10
  243. package/src/components/form/Upload/Upload.tsx +0 -498
  244. package/src/components/form/Upload/Upload.types.ts +0 -200
  245. package/src/components/form/Upload/index.tsx +0 -12
  246. package/src/components/form/index.tsx +0 -152
  247. package/src/components/index.tsx +0 -145
  248. package/src/components/layout/Affix/Affix.styles.ts +0 -42
  249. package/src/components/layout/Affix/Affix.test.tsx +0 -10
  250. package/src/components/layout/Affix/Affix.tsx +0 -83
  251. package/src/components/layout/Affix/Affix.types.ts +0 -29
  252. package/src/components/layout/Affix/index.tsx +0 -3
  253. package/src/components/layout/Col/Col.styles.ts +0 -185
  254. package/src/components/layout/Col/Col.test.tsx +0 -537
  255. package/src/components/layout/Col/Col.tsx +0 -97
  256. package/src/components/layout/Col/Col.types.ts +0 -59
  257. package/src/components/layout/Col/index.tsx +0 -3
  258. package/src/components/layout/Container/Container.styles.ts +0 -163
  259. package/src/components/layout/Container/Container.test.tsx +0 -380
  260. package/src/components/layout/Container/Container.tsx +0 -123
  261. package/src/components/layout/Container/Container.types.ts +0 -63
  262. package/src/components/layout/Container/index.tsx +0 -3
  263. package/src/components/layout/Grid/Grid.styles.ts +0 -183
  264. package/src/components/layout/Grid/Grid.test.tsx +0 -637
  265. package/src/components/layout/Grid/Grid.tsx +0 -123
  266. package/src/components/layout/Grid/Grid.types.ts +0 -78
  267. package/src/components/layout/Grid/index.tsx +0 -3
  268. package/src/components/layout/Layout/Content.tsx +0 -30
  269. package/src/components/layout/Layout/Footer.tsx +0 -30
  270. package/src/components/layout/Layout/Header.tsx +0 -30
  271. package/src/components/layout/Layout/Layout.styles.ts +0 -84
  272. package/src/components/layout/Layout/Layout.test.tsx +0 -10
  273. package/src/components/layout/Layout/Layout.tsx +0 -28
  274. package/src/components/layout/Layout/Layout.types.ts +0 -58
  275. package/src/components/layout/Layout/Sider.tsx +0 -44
  276. package/src/components/layout/Layout/index.tsx +0 -22
  277. package/src/components/layout/Row/Row.styles.ts +0 -159
  278. package/src/components/layout/Row/Row.test.tsx +0 -467
  279. package/src/components/layout/Row/Row.tsx +0 -111
  280. package/src/components/layout/Row/Row.types.ts +0 -60
  281. package/src/components/layout/Row/index.tsx +0 -3
  282. package/src/components/layout/Space/Space.styles.ts +0 -255
  283. package/src/components/layout/Space/Space.test.tsx +0 -682
  284. package/src/components/layout/Space/Space.tsx +0 -203
  285. package/src/components/layout/Space/Space.types.ts +0 -92
  286. package/src/components/layout/Space/index.tsx +0 -12
  287. package/src/components/layout/index.tsx +0 -78
  288. package/src/components/navigation/Menu/Menu.constants.ts +0 -69
  289. package/src/components/navigation/Menu/Menu.stories.tsx +0 -107
  290. package/src/components/navigation/Menu/Menu.styles.ts +0 -767
  291. package/src/components/navigation/Menu/Menu.tsx +0 -352
  292. package/src/components/navigation/Menu/Menu.types.ts +0 -231
  293. package/src/components/navigation/Menu/Menu.utils.ts +0 -187
  294. package/src/components/navigation/Menu/MenuItem.tsx +0 -124
  295. package/src/components/navigation/Menu/SubMenu.tsx +0 -150
  296. package/src/components/navigation/Menu/index.tsx +0 -59
  297. package/src/components/navigation/NavBar/NavBar.styles.ts +0 -129
  298. package/src/components/navigation/NavBar/NavBar.test.tsx +0 -287
  299. package/src/components/navigation/NavBar/NavBar.tsx +0 -228
  300. package/src/components/navigation/NavBar/NavBar.types.ts +0 -54
  301. package/src/components/navigation/NavBar/index.tsx +0 -3
  302. package/src/components/navigation/Pagination/Pagination.styles.ts +0 -187
  303. package/src/components/navigation/Pagination/Pagination.test.tsx +0 -672
  304. package/src/components/navigation/Pagination/Pagination.tsx +0 -395
  305. package/src/components/navigation/Pagination/Pagination.types.ts +0 -87
  306. package/src/components/navigation/Pagination/index.ts +0 -24
  307. package/src/components/navigation/Pagination/index.tsx +0 -9
  308. package/src/components/navigation/Steps/Step.tsx +0 -36
  309. package/src/components/navigation/Steps/Steps.styles.ts +0 -169
  310. package/src/components/navigation/Steps/Steps.test.tsx +0 -14
  311. package/src/components/navigation/Steps/Steps.tsx +0 -112
  312. package/src/components/navigation/Steps/Steps.types.ts +0 -47
  313. package/src/components/navigation/Steps/index.tsx +0 -3
  314. package/src/components/navigation/Tabs/Tabs.styles.ts +0 -199
  315. package/src/components/navigation/Tabs/Tabs.test.tsx +0 -662
  316. package/src/components/navigation/Tabs/Tabs.tsx +0 -253
  317. package/src/components/navigation/Tabs/Tabs.types.ts +0 -115
  318. package/src/components/navigation/Tabs/index.tsx +0 -3
  319. package/src/components/navigation/index.tsx +0 -88
  320. package/src/constants/index.ts +0 -785
  321. package/src/hooks/index.ts +0 -60
  322. package/src/hooks/types.ts +0 -9
  323. package/src/hooks/useAsync.ts +0 -64
  324. package/src/hooks/useClickOutside.ts +0 -52
  325. package/src/hooks/useCounter.ts +0 -87
  326. package/src/hooks/useDebounce.ts +0 -150
  327. package/src/hooks/useDeepCompareEffect.ts +0 -88
  328. package/src/hooks/useEventHandling.ts +0 -444
  329. package/src/hooks/useEventListener.ts +0 -77
  330. package/src/hooks/useLifecycle.ts +0 -399
  331. package/src/hooks/useMediaQuery.ts +0 -75
  332. package/src/hooks/useMutation.ts +0 -233
  333. package/src/hooks/usePerformance.ts +0 -378
  334. package/src/hooks/usePerformanceMonitor.ts +0 -348
  335. package/src/hooks/usePlatform.ts +0 -64
  336. package/src/hooks/usePrevious.ts +0 -25
  337. package/src/hooks/useRequest.test.ts +0 -11
  338. package/src/hooks/useRequest.ts +0 -140
  339. package/src/hooks/useStateManagement.ts +0 -300
  340. package/src/hooks/useStorage.ts +0 -169
  341. package/src/hooks/useStyle.ts +0 -543
  342. package/src/hooks/useTheme.ts +0 -347
  343. package/src/hooks/useToggle.ts +0 -54
  344. package/src/hooks/useVirtualScroll.ts +0 -331
  345. package/src/index.ts +0 -323
  346. package/src/platform/index.ts +0 -1188
  347. package/src/providers/AppProvider.test.tsx +0 -63
  348. package/src/providers/AppProvider.tsx +0 -155
  349. package/src/providers/index.ts +0 -1
  350. package/src/theme/ThemeProvider.tsx +0 -279
  351. package/src/theme/ThemeProvider.types.ts +0 -26
  352. package/src/theme/animations.tsx +0 -660
  353. package/src/theme/defaults.ts +0 -188
  354. package/src/theme/design-system.ts +0 -562
  355. package/src/theme/design-tokens.ts +0 -1122
  356. package/src/theme/generated/dark-theme.scss +0 -120
  357. package/src/theme/generated/tokens.css +0 -441
  358. package/src/theme/generated/tokens.scss +0 -384
  359. package/src/theme/index.ts +0 -99
  360. package/src/theme/responsive.tsx +0 -195
  361. package/src/theme/styles/mixins.scss +0 -612
  362. package/src/theme/styles/variables.scss +0 -295
  363. package/src/theme/styles.ts +0 -403
  364. package/src/theme/tokens/colors.ts +0 -256
  365. package/src/theme/tokens/effects.ts +0 -260
  366. package/src/theme/tokens/index.ts +0 -217
  367. package/src/theme/tokens/spacing.ts +0 -137
  368. package/src/theme/tokens/typography.ts +0 -186
  369. package/src/theme/types.ts +0 -188
  370. package/src/theme/useThemeUtils.ts +0 -313
  371. package/src/theme/utils.ts +0 -501
  372. package/src/theme/variables.ts +0 -602
  373. package/src/types/accessibility.ts +0 -50
  374. package/src/types/button.ts +0 -560
  375. package/src/types/component-props.ts +0 -322
  376. package/src/types/env.d.ts +0 -20
  377. package/src/types/glob.d.ts +0 -4
  378. package/src/types/index.ts +0 -427
  379. package/src/types/modules.d.ts +0 -40
  380. package/src/types/standardized-components.ts +0 -550
  381. package/src/types/taro-adapter.d.ts +0 -174
  382. package/src/types/taro-components.d.ts +0 -73
  383. package/src/types/utils.ts +0 -400
  384. package/src/utils/__tests__/inputValidator.test.ts +0 -338
  385. package/src/utils/__tests__/responsiveUtils.test.ts +0 -311
  386. package/src/utils/__tests__/xssProtection.test.ts +0 -268
  387. package/src/utils/abort-controller.ts +0 -48
  388. package/src/utils/cache.ts +0 -79
  389. package/src/utils/createNamespace.ts +0 -24
  390. package/src/utils/environment.ts +0 -115
  391. package/src/utils/error-handler.ts +0 -88
  392. package/src/utils/errorLogger.ts +0 -193
  393. package/src/utils/formatUtils.ts +0 -412
  394. package/src/utils/http/error-codes.ts +0 -314
  395. package/src/utils/http/http-client.test.ts +0 -63
  396. package/src/utils/http/http-client.ts +0 -161
  397. package/src/utils/http/request-cache.ts +0 -127
  398. package/src/utils/http/request.ts +0 -954
  399. package/src/utils/http/taro-adapter.test.ts +0 -74
  400. package/src/utils/http/taro-adapter.ts +0 -24
  401. package/src/utils/http/types.ts +0 -414
  402. package/src/utils/http/web-adapter.ts +0 -33
  403. package/src/utils/index.ts +0 -112
  404. package/src/utils/inputValidator.ts +0 -264
  405. package/src/utils/performance/performance.ts +0 -839
  406. package/src/utils/responsiveUtils.ts +0 -348
  407. package/src/utils/rtl-support.ts +0 -354
  408. package/src/utils/security/api-security.ts +0 -394
  409. package/src/utils/security/xss-protection.ts +0 -69
  410. package/src/utils/securityHeaders.ts +0 -308
  411. package/src/utils/typeHelpers.ts +0 -16
  412. package/src/utils/types/dataProcessing.ts +0 -544
  413. package/src/utils/types/typeHelpers.ts +0 -197
  414. package/src/utils/xssProtection.ts +0 -468
@@ -1,314 +0,0 @@
1
- /**
2
- * 统一错误码规范
3
- * 提供完整的错误码定义和错误信息映射
4
- */
5
-
6
- /** 错误码类型 */
7
- export enum ErrorCode {
8
- // 网络错误
9
- NETWORK_ERROR = 'NETWORK_ERROR',
10
- TIMEOUT_ERROR = 'TIMEOUT_ERROR',
11
- CANCEL_ERROR = 'CANCEL_ERROR',
12
- INVALID_URL = 'INVALID_URL',
13
- INSECURE_URL = 'INSECURE_URL',
14
-
15
- // HTTP状态码错误
16
- HTTP_400 = 'HTTP_400',
17
- HTTP_401 = 'HTTP_401',
18
- HTTP_403 = 'HTTP_403',
19
- HTTP_404 = 'HTTP_404',
20
- HTTP_405 = 'HTTP_405',
21
- HTTP_408 = 'HTTP_408',
22
- HTTP_409 = 'HTTP_409',
23
- HTTP_410 = 'HTTP_410',
24
- HTTP_422 = 'HTTP_422',
25
- HTTP_429 = 'HTTP_429',
26
- HTTP_500 = 'HTTP_500',
27
- HTTP_501 = 'HTTP_501',
28
- HTTP_502 = 'HTTP_502',
29
- HTTP_503 = 'HTTP_503',
30
- HTTP_504 = 'HTTP_504',
31
- HTTP_505 = 'HTTP_505',
32
-
33
- // 业务逻辑错误
34
- BUSINESS_ERROR = 'BUSINESS_ERROR',
35
- INVALID_PARAMS = 'INVALID_PARAMS',
36
- INVALID_REQUEST = 'INVALID_REQUEST',
37
- DATA_NOT_FOUND = 'DATA_NOT_FOUND',
38
- DATA_CONFLICT = 'DATA_CONFLICT',
39
- PERMISSION_DENIED = 'PERMISSION_DENIED',
40
- USER_NOT_LOGGED_IN = 'USER_NOT_LOGGED_IN',
41
- USER_SESSION_EXPIRED = 'USER_SESSION_EXPIRED',
42
- USER_TOKEN_INVALID = 'USER_TOKEN_INVALID',
43
- INSUFFICIENT_BALANCE = 'INSUFFICIENT_BALANCE',
44
-
45
- // 系统错误
46
- SYSTEM_ERROR = 'SYSTEM_ERROR',
47
- SERVICE_UNAVAILABLE = 'SERVICE_UNAVAILABLE',
48
- DATABASE_ERROR = 'DATABASE_ERROR',
49
- CACHE_ERROR = 'CACHE_ERROR',
50
-
51
- // 安全错误
52
- SECURITY_ERROR = 'SECURITY_ERROR',
53
- XSS_ATTACK = 'XSS_ATTACK',
54
- CSRF_ATTACK = 'CSRF_ATTACK',
55
- SQL_INJECTION = 'SQL_INJECTION',
56
- INVALID_SIGNATURE = 'INVALID_SIGNATURE',
57
- INVALID_CREDENTIALS = 'INVALID_CREDENTIALS',
58
-
59
- // 其他错误
60
- UNKNOWN_ERROR = 'UNKNOWN_ERROR',
61
- UNEXPECTED_ERROR = 'UNEXPECTED_ERROR',
62
- NOT_SUPPORTED = 'NOT_SUPPORTED',
63
- FEATURE_DISABLED = 'FEATURE_DISABLED',
64
- }
65
-
66
- /** 错误信息映射 */
67
- export const ERROR_MESSAGES: Record<ErrorCode, string> = {
68
- // 网络错误
69
- [ErrorCode.NETWORK_ERROR]: '网络连接失败,请检查您的网络设置',
70
- [ErrorCode.TIMEOUT_ERROR]: '请求超时,请稍后重试',
71
- [ErrorCode.CANCEL_ERROR]: '请求已取消',
72
- [ErrorCode.INVALID_URL]: '无效的请求地址',
73
- [ErrorCode.INSECURE_URL]: '不安全的请求地址',
74
-
75
- // HTTP状态码错误
76
- [ErrorCode.HTTP_400]: '请求参数错误',
77
- [ErrorCode.HTTP_401]: '未授权访问',
78
- [ErrorCode.HTTP_403]: '禁止访问',
79
- [ErrorCode.HTTP_404]: '请求的资源不存在',
80
- [ErrorCode.HTTP_405]: '不支持的请求方法',
81
- [ErrorCode.HTTP_408]: '请求超时',
82
- [ErrorCode.HTTP_409]: '请求冲突',
83
- [ErrorCode.HTTP_410]: '请求的资源已永久删除',
84
- [ErrorCode.HTTP_422]: '请求参数验证失败',
85
- [ErrorCode.HTTP_429]: '请求过于频繁,请稍后重试',
86
- [ErrorCode.HTTP_500]: '服务器内部错误',
87
- [ErrorCode.HTTP_501]: '服务器不支持该请求方法',
88
- [ErrorCode.HTTP_502]: '网关错误',
89
- [ErrorCode.HTTP_503]: '服务暂时不可用',
90
- [ErrorCode.HTTP_504]: '网关超时',
91
- [ErrorCode.HTTP_505]: 'HTTP版本不支持',
92
-
93
- // 业务逻辑错误
94
- [ErrorCode.BUSINESS_ERROR]: '业务逻辑错误',
95
- [ErrorCode.INVALID_PARAMS]: '无效的请求参数',
96
- [ErrorCode.INVALID_REQUEST]: '无效的请求',
97
- [ErrorCode.DATA_NOT_FOUND]: '请求的数据不存在',
98
- [ErrorCode.DATA_CONFLICT]: '数据冲突',
99
- [ErrorCode.PERMISSION_DENIED]: '没有操作权限',
100
- [ErrorCode.USER_NOT_LOGGED_IN]: '用户未登录',
101
- [ErrorCode.USER_SESSION_EXPIRED]: '用户会话已过期',
102
- [ErrorCode.USER_TOKEN_INVALID]: '无效的用户令牌',
103
- [ErrorCode.INSUFFICIENT_BALANCE]: '余额不足',
104
-
105
- // 系统错误
106
- [ErrorCode.SYSTEM_ERROR]: '系统错误',
107
- [ErrorCode.SERVICE_UNAVAILABLE]: '服务不可用',
108
- [ErrorCode.DATABASE_ERROR]: '数据库错误',
109
- [ErrorCode.CACHE_ERROR]: '缓存错误',
110
-
111
- // 安全错误
112
- [ErrorCode.SECURITY_ERROR]: '安全错误',
113
- [ErrorCode.XSS_ATTACK]: 'XSS攻击检测',
114
- [ErrorCode.CSRF_ATTACK]: 'CSRF攻击检测',
115
- [ErrorCode.SQL_INJECTION]: 'SQL注入攻击检测',
116
- [ErrorCode.INVALID_SIGNATURE]: '无效的签名',
117
- [ErrorCode.INVALID_CREDENTIALS]: '无效的凭证',
118
-
119
- // 其他错误
120
- [ErrorCode.UNKNOWN_ERROR]: '未知错误',
121
- [ErrorCode.UNEXPECTED_ERROR]: '意外错误',
122
- [ErrorCode.NOT_SUPPORTED]: '不支持的功能',
123
- [ErrorCode.FEATURE_DISABLED]: '功能已禁用',
124
- };
125
-
126
- /** 错误严重程度 */
127
- export enum ErrorSeverity {
128
- LOW = 'LOW',
129
- MEDIUM = 'MEDIUM',
130
- HIGH = 'HIGH',
131
- CRITICAL = 'CRITICAL',
132
- }
133
-
134
- /** 错误严重程度映射 */
135
- export const ERROR_SEVERITY: Record<ErrorCode, ErrorSeverity> = {
136
- // 网络错误
137
- [ErrorCode.NETWORK_ERROR]: ErrorSeverity.MEDIUM,
138
- [ErrorCode.TIMEOUT_ERROR]: ErrorSeverity.MEDIUM,
139
- [ErrorCode.CANCEL_ERROR]: ErrorSeverity.LOW,
140
- [ErrorCode.INVALID_URL]: ErrorSeverity.HIGH,
141
- [ErrorCode.INSECURE_URL]: ErrorSeverity.CRITICAL,
142
-
143
- // HTTP状态码错误
144
- [ErrorCode.HTTP_400]: ErrorSeverity.MEDIUM,
145
- [ErrorCode.HTTP_401]: ErrorSeverity.HIGH,
146
- [ErrorCode.HTTP_403]: ErrorSeverity.HIGH,
147
- [ErrorCode.HTTP_404]: ErrorSeverity.MEDIUM,
148
- [ErrorCode.HTTP_405]: ErrorSeverity.HIGH,
149
- [ErrorCode.HTTP_408]: ErrorSeverity.MEDIUM,
150
- [ErrorCode.HTTP_409]: ErrorSeverity.MEDIUM,
151
- [ErrorCode.HTTP_410]: ErrorSeverity.MEDIUM,
152
- [ErrorCode.HTTP_422]: ErrorSeverity.MEDIUM,
153
- [ErrorCode.HTTP_429]: ErrorSeverity.MEDIUM,
154
- [ErrorCode.HTTP_500]: ErrorSeverity.CRITICAL,
155
- [ErrorCode.HTTP_501]: ErrorSeverity.CRITICAL,
156
- [ErrorCode.HTTP_502]: ErrorSeverity.CRITICAL,
157
- [ErrorCode.HTTP_503]: ErrorSeverity.CRITICAL,
158
- [ErrorCode.HTTP_504]: ErrorSeverity.CRITICAL,
159
- [ErrorCode.HTTP_505]: ErrorSeverity.CRITICAL,
160
-
161
- // 业务逻辑错误
162
- [ErrorCode.BUSINESS_ERROR]: ErrorSeverity.MEDIUM,
163
- [ErrorCode.INVALID_PARAMS]: ErrorSeverity.MEDIUM,
164
- [ErrorCode.INVALID_REQUEST]: ErrorSeverity.MEDIUM,
165
- [ErrorCode.DATA_NOT_FOUND]: ErrorSeverity.MEDIUM,
166
- [ErrorCode.DATA_CONFLICT]: ErrorSeverity.MEDIUM,
167
- [ErrorCode.PERMISSION_DENIED]: ErrorSeverity.HIGH,
168
- [ErrorCode.USER_NOT_LOGGED_IN]: ErrorSeverity.HIGH,
169
- [ErrorCode.USER_SESSION_EXPIRED]: ErrorSeverity.HIGH,
170
- [ErrorCode.USER_TOKEN_INVALID]: ErrorSeverity.HIGH,
171
- [ErrorCode.INSUFFICIENT_BALANCE]: ErrorSeverity.MEDIUM,
172
-
173
- // 系统错误
174
- [ErrorCode.SYSTEM_ERROR]: ErrorSeverity.CRITICAL,
175
- [ErrorCode.SERVICE_UNAVAILABLE]: ErrorSeverity.CRITICAL,
176
- [ErrorCode.DATABASE_ERROR]: ErrorSeverity.CRITICAL,
177
- [ErrorCode.CACHE_ERROR]: ErrorSeverity.HIGH,
178
-
179
- // 安全错误
180
- [ErrorCode.SECURITY_ERROR]: ErrorSeverity.CRITICAL,
181
- [ErrorCode.XSS_ATTACK]: ErrorSeverity.CRITICAL,
182
- [ErrorCode.CSRF_ATTACK]: ErrorSeverity.CRITICAL,
183
- [ErrorCode.SQL_INJECTION]: ErrorSeverity.CRITICAL,
184
- [ErrorCode.INVALID_SIGNATURE]: ErrorSeverity.HIGH,
185
- [ErrorCode.INVALID_CREDENTIALS]: ErrorSeverity.HIGH,
186
-
187
- // 其他错误
188
- [ErrorCode.UNKNOWN_ERROR]: ErrorSeverity.MEDIUM,
189
- [ErrorCode.UNEXPECTED_ERROR]: ErrorSeverity.CRITICAL,
190
- [ErrorCode.NOT_SUPPORTED]: ErrorSeverity.LOW,
191
- [ErrorCode.FEATURE_DISABLED]: ErrorSeverity.LOW,
192
- };
193
-
194
- /** 错误码工具函数 */
195
- export const ErrorCodeUtils = {
196
- /**
197
- * 根据HTTP状态码获取对应的错误码
198
- */
199
- fromHttpStatus(statusCode: number): ErrorCode {
200
- switch (statusCode) {
201
- case 400:
202
- return ErrorCode.HTTP_400;
203
- case 401:
204
- return ErrorCode.HTTP_401;
205
- case 403:
206
- return ErrorCode.HTTP_403;
207
- case 404:
208
- return ErrorCode.HTTP_404;
209
- case 405:
210
- return ErrorCode.HTTP_405;
211
- case 408:
212
- return ErrorCode.HTTP_408;
213
- case 409:
214
- return ErrorCode.HTTP_409;
215
- case 410:
216
- return ErrorCode.HTTP_410;
217
- case 422:
218
- return ErrorCode.HTTP_422;
219
- case 429:
220
- return ErrorCode.HTTP_429;
221
- case 500:
222
- return ErrorCode.HTTP_500;
223
- case 501:
224
- return ErrorCode.HTTP_501;
225
- case 502:
226
- return ErrorCode.HTTP_502;
227
- case 503:
228
- return ErrorCode.HTTP_503;
229
- case 504:
230
- return ErrorCode.HTTP_504;
231
- case 505:
232
- return ErrorCode.HTTP_505;
233
- default:
234
- return ErrorCode.UNKNOWN_ERROR;
235
- }
236
- },
237
-
238
- /**
239
- * 获取错误信息
240
- */
241
- getErrorMessage(code: ErrorCode, customMessage?: string): string {
242
- return customMessage || ERROR_MESSAGES[code] || ERROR_MESSAGES[ErrorCode.UNKNOWN_ERROR];
243
- },
244
-
245
- /**
246
- * 获取错误严重程度
247
- */
248
- getSeverity(code: ErrorCode): ErrorSeverity {
249
- return ERROR_SEVERITY[code] || ErrorSeverity.MEDIUM;
250
- },
251
-
252
- /**
253
- * 检查错误是否为网络错误
254
- */
255
- isNetworkError(code: ErrorCode): boolean {
256
- return [
257
- ErrorCode.NETWORK_ERROR,
258
- ErrorCode.TIMEOUT_ERROR,
259
- ErrorCode.CANCEL_ERROR,
260
- ErrorCode.INVALID_URL,
261
- ErrorCode.INSECURE_URL,
262
- ].includes(code);
263
- },
264
-
265
- /**
266
- * 检查错误是否为认证错误
267
- */
268
- isAuthError(code: ErrorCode): boolean {
269
- return [
270
- ErrorCode.HTTP_401,
271
- ErrorCode.HTTP_403,
272
- ErrorCode.PERMISSION_DENIED,
273
- ErrorCode.USER_NOT_LOGGED_IN,
274
- ErrorCode.USER_SESSION_EXPIRED,
275
- ErrorCode.USER_TOKEN_INVALID,
276
- ErrorCode.INVALID_CREDENTIALS,
277
- ].includes(code);
278
- },
279
-
280
- /**
281
- * 检查错误是否为系统错误
282
- */
283
- isSystemError(code: ErrorCode): boolean {
284
- return [
285
- ErrorCode.SYSTEM_ERROR,
286
- ErrorCode.SERVICE_UNAVAILABLE,
287
- ErrorCode.DATABASE_ERROR,
288
- ErrorCode.CACHE_ERROR,
289
- ErrorCode.UNEXPECTED_ERROR,
290
- ].includes(code);
291
- },
292
-
293
- /**
294
- * 检查错误是否为业务错误
295
- */
296
- isBusinessError(code: ErrorCode): boolean {
297
- return [
298
- ErrorCode.BUSINESS_ERROR,
299
- ErrorCode.INVALID_PARAMS,
300
- ErrorCode.INVALID_REQUEST,
301
- ErrorCode.DATA_NOT_FOUND,
302
- ErrorCode.DATA_CONFLICT,
303
- ErrorCode.INSUFFICIENT_BALANCE,
304
- ].includes(code);
305
- },
306
- };
307
-
308
- export default {
309
- ErrorCode,
310
- ERROR_MESSAGES,
311
- ErrorSeverity,
312
- ERROR_SEVERITY,
313
- ErrorCodeUtils,
314
- };
@@ -1,63 +0,0 @@
1
- import { describe, expect, it, vi, beforeEach } from 'vitest';
2
- import { HttpClient } from './http-client';
3
- import { IRequestAdapter, RequestConfig, ResponseData } from './types';
4
-
5
- // 模拟 localStorage
6
- const mockLocalStorage = {
7
- storage: {} as Record<string, string>,
8
- getItem: vi.fn((key: string) => mockLocalStorage.storage[key] || null),
9
- setItem: vi.fn((key: string, value: string) => {
10
- mockLocalStorage.storage[key] = value;
11
- }),
12
- removeItem: vi.fn((key: string) => {
13
- delete mockLocalStorage.storage[key];
14
- }),
15
- clear: vi.fn(() => {
16
- mockLocalStorage.storage = {};
17
- })
18
- };
19
-
20
- globalThis.localStorage = mockLocalStorage as any;
21
-
22
- describe('HttpClient', () => {
23
- beforeEach(() => {
24
- // 重置模拟
25
- vi.clearAllMocks();
26
- mockLocalStorage.storage = {};
27
- });
28
-
29
- it('builds GET request and parses json', async () => {
30
- // 模拟 fetch
31
- const mockFetch = vi.spyOn(global, 'fetch' as any).mockResolvedValue({
32
- ok: true,
33
- status: 200,
34
- headers: new Headers({ 'content-type': 'application/json' }),
35
- json: async () => ({ ok: true }),
36
- text: async () => ''
37
- } as any);
38
-
39
- // 创建简单的适配器来避免安全功能
40
- const simpleAdapter: IRequestAdapter = {
41
- async request<T = any>(config: RequestConfig): Promise<ResponseData<T>> {
42
- const response = await fetch(config.url, {
43
- method: config.method,
44
- headers: config.headers,
45
- body: config.method !== 'GET' ? JSON.stringify(config.data) : undefined
46
- });
47
-
48
- const data = await response.json();
49
-
50
- return {
51
- data,
52
- statusCode: response.status,
53
- header: Object.fromEntries(response.headers)
54
- };
55
- }
56
- };
57
-
58
- const client = new HttpClient({ baseUrl: 'https://example.com', adapter: simpleAdapter });
59
- const res = await client.get('/api/test', { params: { q: 'x' } });
60
- expect(res).toEqual({ ok: true });
61
- mockFetch.mockRestore();
62
- });
63
- });
@@ -1,161 +0,0 @@
1
- import { createApiInterceptor, buildSecureHeaders, isSecureUrl, secureRetry } from '@/utils/security/api-security';
2
- import { ErrorHandlingManager } from '@/utils/error-handler';
3
- import { IRequestAdapter, RequestConfig as AdapterRequestConfig } from './types';
4
- import { WebAdapter } from './web-adapter';
5
- import { TaroAdapter } from './taro-adapter';
6
-
7
- export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
8
-
9
- export interface RequestOptions {
10
- method?: HttpMethod;
11
- headers?: Record<string, string>;
12
- params?: Record<string, any>;
13
- data?: any;
14
- timeout?: number;
15
- retries?: number;
16
- retryDelay?: number;
17
- baseUrl?: string;
18
- }
19
-
20
- export interface HttpClientConfig {
21
- baseUrl?: string;
22
- headers?: Record<string, string>;
23
- adapter?: IRequestAdapter;
24
- }
25
-
26
- interface RequestConfig {
27
- method: HttpMethod;
28
- url: string;
29
- headers: Record<string, string>;
30
- data?: any;
31
- }
32
-
33
- interface ResponseData {
34
- status: number;
35
- ok: boolean;
36
- headers: Headers | Record<string, string>;
37
- data: any;
38
- }
39
-
40
- type RequestInterceptor = (_config: RequestConfig) => RequestConfig;
41
- type ResponseInterceptor = (_response: ResponseData) => ResponseData;
42
-
43
- export class HttpClient {
44
- private baseUrl: string;
45
- private defaultHeaders: Record<string, string>;
46
- private errorManager = ErrorHandlingManager.getInstance();
47
- private security = createApiInterceptor();
48
- private requestInterceptors: RequestInterceptor[] = [];
49
- private responseInterceptors: ResponseInterceptor[] = [];
50
- private adapter: IRequestAdapter;
51
-
52
- constructor(config: HttpClientConfig = {}) {
53
- this.baseUrl = config.baseUrl || '';
54
- this.defaultHeaders = config.headers || {};
55
- this.adapter = config.adapter || this.getDefaultAdapter();
56
- }
57
-
58
- private getDefaultAdapter(): IRequestAdapter {
59
- if (process.env['TARO_ENV'] === 'h5') {
60
- return new WebAdapter();
61
- }
62
- return new TaroAdapter();
63
- }
64
-
65
- addRequestInterceptor(interceptor: RequestInterceptor) {
66
- this.requestInterceptors.push(interceptor);
67
- }
68
-
69
- addResponseInterceptor(interceptor: ResponseInterceptor) {
70
- this.responseInterceptors.push(interceptor);
71
- }
72
-
73
- async request<T>(url: string, options: RequestOptions = {}): Promise<T> {
74
- const method = (options.method || 'GET').toUpperCase() as HttpMethod;
75
- const base = options.baseUrl ?? this.baseUrl;
76
- const fullUrl = this.buildUrl(base, url, options.params);
77
- if (!isSecureUrl(fullUrl)) {
78
- throw this.errorManager.createAuthorizationError('insecure_url');
79
- }
80
-
81
- const headers = {
82
- ...this.defaultHeaders,
83
- ...(options.headers || {}),
84
- ...buildSecureHeaders(method, fullUrl, options.data),
85
- };
86
-
87
- let config: RequestConfig = { method, url: fullUrl, headers, data: options.data };
88
- config = this.security.request.execute(config);
89
- for (const it of this.requestInterceptors) config = it(config);
90
-
91
- const doRequest = async () => {
92
- const adapterConfig: AdapterRequestConfig = {
93
- url: config.url,
94
- method: config.method,
95
- headers: config.headers,
96
- data: config.data,
97
- timeout: options.timeout,
98
- };
99
-
100
- const resp = await this.adapter.request(adapterConfig);
101
-
102
- const wrapped: ResponseData = {
103
- status: resp.statusCode,
104
- ok: resp.statusCode >= 200 && resp.statusCode < 300,
105
- headers: resp.header,
106
- data: resp.data,
107
- };
108
-
109
- let processed = this.security.response.execute(wrapped);
110
- for (const it of this.responseInterceptors) processed = it(processed);
111
-
112
- if (!processed.ok) {
113
- const err = new Error(`HTTP ${processed.status}`);
114
- this.errorManager.handleError(err);
115
- throw err;
116
- }
117
- return processed.data as T;
118
- };
119
-
120
- const retries = options.retries ?? (method === 'GET' ? 3 : 0);
121
- const retryDelay = options.retryDelay ?? 500;
122
- return await secureRetry(doRequest, retries, retryDelay);
123
- }
124
-
125
- get<T>(url: string, options: Omit<RequestOptions, 'method' | 'data'> = {}): Promise<T> {
126
- return this.request<T>(url, { ...options, method: 'GET' });
127
- }
128
-
129
- post<T>(url: string, data?: any, options: Omit<RequestOptions, 'method' | 'data'> = {}): Promise<T> {
130
- return this.request<T>(url, { ...options, method: 'POST', data });
131
- }
132
-
133
- put<T>(url: string, data?: any, options: Omit<RequestOptions, 'method' | 'data'> = {}): Promise<T> {
134
- return this.request<T>(url, { ...options, method: 'PUT', data });
135
- }
136
-
137
- patch<T>(url: string, data?: any, options: Omit<RequestOptions, 'method' | 'data'> = {}): Promise<T> {
138
- return this.request<T>(url, { ...options, method: 'PATCH', data });
139
- }
140
-
141
- delete<T>(url: string, options: Omit<RequestOptions, 'method' | 'data'> = {}): Promise<T> {
142
- return this.request<T>(url, { ...options, method: 'DELETE' });
143
- }
144
-
145
- private buildUrl(base: string, url: string, params?: Record<string, any>): string {
146
- const root = base ? base.replace(/\/$/, '') : '';
147
- const path = url.startsWith('http') ? url : `${root}${url.startsWith('/') ? url : `/${url}`}`;
148
- if (!params || Object.keys(params).length === 0) return path;
149
- const usp = new URLSearchParams();
150
- Object.entries(params).forEach(([k, v]) => {
151
- if (v === undefined || v === null) return;
152
- if (Array.isArray(v)) v.forEach((x) => usp.append(k, String(x)));
153
- else usp.append(k, String(v));
154
- });
155
- const sep = path.includes('?') ? '&' : '?';
156
- return `${path}${sep}${usp.toString()}`;
157
- }
158
- }
159
-
160
- export const httpClient = new HttpClient();
161
- export default HttpClient;
@@ -1,127 +0,0 @@
1
- /**
2
- * Request Cache Manager
3
- * Provides intelligent request caching and deduplication
4
- */
5
-
6
- export interface CacheConfig {
7
- /** Cache time to live in milliseconds */
8
- ttl?: number;
9
- /** Cache key generator function */
10
- keyGenerator?: (url: string, params?: any) => string;
11
- /** Whether to enable cache */
12
- enabled?: boolean;
13
- }
14
-
15
- export interface CachedResponse<T> {
16
- data: T;
17
- timestamp: number;
18
- ttl: number;
19
- }
20
-
21
- export class RequestCache {
22
- private cache = new Map<string, CachedResponse<any>>();
23
- private pendingRequests = new Map<string, Promise<any>>();
24
-
25
- /**
26
- * Generate cache key from request config
27
- */
28
- generateKey(url: string, params?: any): string {
29
- const paramStr = params ? JSON.stringify(params) : '';
30
- return `${url}:${paramStr}`;
31
- }
32
-
33
- /**
34
- * Get cached response if valid
35
- */
36
- get<T>(key: string): T | null {
37
- const cached = this.cache.get(key);
38
- if (!cached) return null;
39
-
40
- const now = Date.now();
41
- if (now - cached.timestamp > cached.ttl) {
42
- this.cache.delete(key);
43
- return null;
44
- }
45
-
46
- return cached.data as T;
47
- }
48
-
49
- /**
50
- * Set cache entry
51
- */
52
- set<T>(key: string, data: T, ttl: number = 5 * 60 * 1000): void {
53
- this.cache.set(key, {
54
- data,
55
- timestamp: Date.now(),
56
- ttl,
57
- });
58
- }
59
-
60
- /**
61
- * Check if request is already in flight
62
- */
63
- hasPendingRequest(key: string): boolean {
64
- return this.pendingRequests.has(key);
65
- }
66
-
67
- /**
68
- * Get pending request promise
69
- */
70
- getPendingRequest<T>(key: string): Promise<T> | undefined {
71
- return this.pendingRequests.get(key);
72
- }
73
-
74
- /**
75
- * Set pending request
76
- */
77
- setPendingRequest<T>(key: string, promise: Promise<T>): void {
78
- this.pendingRequests.set(key, promise);
79
-
80
- // Clean up after promise settles
81
- promise
82
- .finally(() => {
83
- this.pendingRequests.delete(key);
84
- })
85
- .catch(() => {
86
- // Ignore errors - they'll be handled by the caller
87
- });
88
- }
89
-
90
- /**
91
- * Clear specific cache entry
92
- */
93
- clear(key: string): void {
94
- this.cache.delete(key);
95
- }
96
-
97
- /**
98
- * Clear all cache
99
- */
100
- clearAll(): void {
101
- this.cache.clear();
102
- }
103
-
104
- /**
105
- * Clear expired entries
106
- */
107
- clearExpired(): void {
108
- const now = Date.now();
109
- for (const [key, cached] of this.cache.entries()) {
110
- if (now - cached.timestamp > cached.ttl) {
111
- this.cache.delete(key);
112
- }
113
- }
114
- }
115
-
116
- /**
117
- * Get cache statistics
118
- */
119
- getStats() {
120
- return {
121
- size: this.cache.size,
122
- pending: this.pendingRequests.size,
123
- };
124
- }
125
- }
126
-
127
- export const globalRequestCache = new RequestCache();