@rsdoctor/components 0.0.0-next-20240620044732

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 (330) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -0
  3. package/dist/assets/connection-point.3b3c78ca.svg +1 -0
  4. package/dist/assets/webpack.98604d64.svg +1 -0
  5. package/dist/components/Alert/change.d.ts +8 -0
  6. package/dist/components/Alert/change.js +93 -0
  7. package/dist/components/Alert/file-relation.d.ts +3 -0
  8. package/dist/components/Alert/file-relation.js +9 -0
  9. package/dist/components/Alert/index.css +32 -0
  10. package/dist/components/Alert/index.d.ts +4 -0
  11. package/dist/components/Alert/index.js +37 -0
  12. package/dist/components/Alert/link.d.ts +3 -0
  13. package/dist/components/Alert/link.js +27 -0
  14. package/dist/components/Alert/package-relation.d.ts +17 -0
  15. package/dist/components/Alert/package-relation.js +281 -0
  16. package/dist/components/Alert/types.d.ts +31 -0
  17. package/dist/components/Alert/types.js +0 -0
  18. package/dist/components/Alert/view.d.ts +4 -0
  19. package/dist/components/Alert/view.js +58 -0
  20. package/dist/components/Alerts/bundle.d.ts +11 -0
  21. package/dist/components/Alerts/bundle.js +61 -0
  22. package/dist/components/Alerts/common.d.ts +15 -0
  23. package/dist/components/Alerts/common.js +112 -0
  24. package/dist/components/Alerts/compile.d.ts +10 -0
  25. package/dist/components/Alerts/compile.js +46 -0
  26. package/dist/components/Alerts/index.d.ts +3 -0
  27. package/dist/components/Alerts/index.js +3 -0
  28. package/dist/components/Alerts/overlay.d.ts +26 -0
  29. package/dist/components/Alerts/overlay.js +154 -0
  30. package/dist/components/Badge/index.d.ts +21 -0
  31. package/dist/components/Badge/index.js +87 -0
  32. package/dist/components/BundleDiff/DiffContainer/assets.d.ts +7 -0
  33. package/dist/components/BundleDiff/DiffContainer/assets.js +507 -0
  34. package/dist/components/BundleDiff/DiffContainer/cards.d.ts +3 -0
  35. package/dist/components/BundleDiff/DiffContainer/cards.js +156 -0
  36. package/dist/components/BundleDiff/DiffContainer/changes.d.ts +15 -0
  37. package/dist/components/BundleDiff/DiffContainer/changes.js +69 -0
  38. package/dist/components/BundleDiff/DiffContainer/constants.d.ts +11 -0
  39. package/dist/components/BundleDiff/DiffContainer/constants.js +17 -0
  40. package/dist/components/BundleDiff/DiffContainer/diff.d.ts +23 -0
  41. package/dist/components/BundleDiff/DiffContainer/diff.js +114 -0
  42. package/dist/components/BundleDiff/DiffContainer/index.d.ts +3 -0
  43. package/dist/components/BundleDiff/DiffContainer/index.js +180 -0
  44. package/dist/components/BundleDiff/DiffContainer/modules.d.ts +8 -0
  45. package/dist/components/BundleDiff/DiffContainer/modules.js +302 -0
  46. package/dist/components/BundleDiff/DiffContainer/overview.d.ts +5 -0
  47. package/dist/components/BundleDiff/DiffContainer/overview.js +178 -0
  48. package/dist/components/BundleDiff/DiffContainer/packages.d.ts +19 -0
  49. package/dist/components/BundleDiff/DiffContainer/packages.js +330 -0
  50. package/dist/components/BundleDiff/DiffContainer/row.d.ts +9 -0
  51. package/dist/components/BundleDiff/DiffContainer/row.js +369 -0
  52. package/dist/components/BundleDiff/DiffContainer/types.d.ts +45 -0
  53. package/dist/components/BundleDiff/DiffContainer/types.js +0 -0
  54. package/dist/components/BundleDiff/DiffContainer/utils.d.ts +2 -0
  55. package/dist/components/BundleDiff/DiffContainer/utils.js +24 -0
  56. package/dist/components/BundleDiff/DiffServerAPIProvider/index.d.ts +4 -0
  57. package/dist/components/BundleDiff/DiffServerAPIProvider/index.js +37 -0
  58. package/dist/components/BundleDiff/constants.d.ts +11 -0
  59. package/dist/components/BundleDiff/constants.js +19 -0
  60. package/dist/components/BundleDiff/index.d.ts +1 -0
  61. package/dist/components/BundleDiff/index.js +1 -0
  62. package/dist/components/Card/diff.d.ts +24 -0
  63. package/dist/components/Card/diff.js +116 -0
  64. package/dist/components/Card/index.d.ts +9 -0
  65. package/dist/components/Card/index.js +50 -0
  66. package/dist/components/Card/size.d.ts +21 -0
  67. package/dist/components/Card/size.js +79 -0
  68. package/dist/components/Card/statistic.css +17 -0
  69. package/dist/components/Card/statistic.d.ts +12 -0
  70. package/dist/components/Card/statistic.js +19 -0
  71. package/dist/components/Charts/TimelineCharts/index.d.ts +8 -0
  72. package/dist/components/Charts/TimelineCharts/index.js +212 -0
  73. package/dist/components/Charts/bootstrap.d.ts +5 -0
  74. package/dist/components/Charts/bootstrap.js +44 -0
  75. package/dist/components/Charts/common.d.ts +13 -0
  76. package/dist/components/Charts/common.js +56 -0
  77. package/dist/components/Charts/constants.d.ts +2 -0
  78. package/dist/components/Charts/constants.js +46 -0
  79. package/dist/components/Charts/done.d.ts +5 -0
  80. package/dist/components/Charts/done.js +45 -0
  81. package/dist/components/Charts/index.d.ts +10 -0
  82. package/dist/components/Charts/index.js +37 -0
  83. package/dist/components/Charts/loader.css +31 -0
  84. package/dist/components/Charts/loader.d.ts +4 -0
  85. package/dist/components/Charts/loader.js +88 -0
  86. package/dist/components/Charts/minify.d.ts +5 -0
  87. package/dist/components/Charts/minify.js +37 -0
  88. package/dist/components/Charts/tooltips.css +62 -0
  89. package/dist/components/Charts/types.d.ts +61 -0
  90. package/dist/components/Charts/types.js +11 -0
  91. package/dist/components/Charts/utils.d.ts +13 -0
  92. package/dist/components/Charts/utils.js +206 -0
  93. package/dist/components/CodeViewer/config.d.ts +2 -0
  94. package/dist/components/CodeViewer/config.js +18 -0
  95. package/dist/components/CodeViewer/diff.d.ts +11 -0
  96. package/dist/components/CodeViewer/diff.js +35 -0
  97. package/dist/components/CodeViewer/hightlight.d.ts +10 -0
  98. package/dist/components/CodeViewer/hightlight.js +76 -0
  99. package/dist/components/CodeViewer/index.d.ts +4 -0
  100. package/dist/components/CodeViewer/index.js +4 -0
  101. package/dist/components/CodeViewer/viewer.d.ts +13 -0
  102. package/dist/components/CodeViewer/viewer.js +60 -0
  103. package/dist/components/Configuration/builder.d.ts +13 -0
  104. package/dist/components/Configuration/builder.js +67 -0
  105. package/dist/components/Configuration/index.d.ts +1 -0
  106. package/dist/components/Configuration/index.js +1 -0
  107. package/dist/components/FileTree/index.css +58 -0
  108. package/dist/components/FileTree/index.d.ts +4 -0
  109. package/dist/components/FileTree/index.js +42 -0
  110. package/dist/components/Form/keyword.d.ts +14 -0
  111. package/dist/components/Form/keyword.js +60 -0
  112. package/dist/components/Keyword/index.d.ts +6 -0
  113. package/dist/components/Keyword/index.js +36 -0
  114. package/dist/components/Layout/builder-select.d.ts +2 -0
  115. package/dist/components/Layout/builder-select.js +50 -0
  116. package/dist/components/Layout/constants.d.ts +1 -0
  117. package/dist/components/Layout/constants.js +4 -0
  118. package/dist/components/Layout/header.css +12 -0
  119. package/dist/components/Layout/header.d.ts +3 -0
  120. package/dist/components/Layout/header.js +86 -0
  121. package/dist/components/Layout/index.d.ts +5 -0
  122. package/dist/components/Layout/index.js +34 -0
  123. package/dist/components/Layout/menus.d.ts +8 -0
  124. package/dist/components/Layout/menus.js +167 -0
  125. package/dist/components/Layout/progress.d.ts +8 -0
  126. package/dist/components/Layout/progress.js +44 -0
  127. package/dist/components/Loader/Analysis/files.d.ts +8 -0
  128. package/dist/components/Loader/Analysis/files.js +193 -0
  129. package/dist/components/Loader/Analysis/index.d.ts +11 -0
  130. package/dist/components/Loader/Analysis/index.js +23 -0
  131. package/dist/components/Loader/executions.d.ts +9 -0
  132. package/dist/components/Loader/executions.js +199 -0
  133. package/dist/components/Manifest/api.d.ts +34 -0
  134. package/dist/components/Manifest/api.js +127 -0
  135. package/dist/components/Manifest/data.d.ts +8 -0
  136. package/dist/components/Manifest/data.js +65 -0
  137. package/dist/components/Manifest/index.d.ts +2 -0
  138. package/dist/components/Manifest/index.js +2 -0
  139. package/dist/components/Opener/code.d.ts +20 -0
  140. package/dist/components/Opener/code.js +78 -0
  141. package/dist/components/Opener/index.d.ts +2 -0
  142. package/dist/components/Opener/index.js +2 -0
  143. package/dist/components/Opener/vscode.d.ts +11 -0
  144. package/dist/components/Opener/vscode.js +42 -0
  145. package/dist/components/Overall/NumberButton.d.ts +8 -0
  146. package/dist/components/Overall/NumberButton.js +29 -0
  147. package/dist/components/Overall/NumberButton.module.js +5 -0
  148. package/dist/components/Overall/NumberButton_module.css +70 -0
  149. package/dist/components/Overall/bundle.d.ts +6 -0
  150. package/dist/components/Overall/bundle.js +167 -0
  151. package/dist/components/Overall/bundle.module.css +0 -0
  152. package/dist/components/Overall/card.module.js +5 -0
  153. package/dist/components/Overall/card_module.css +6 -0
  154. package/dist/components/Overall/compile.d.ts +5 -0
  155. package/dist/components/Overall/compile.js +67 -0
  156. package/dist/components/Overall/compile.module.js +5 -0
  157. package/dist/components/Overall/compile_module.css +4 -0
  158. package/dist/components/Overall/index.d.ts +3 -0
  159. package/dist/components/Overall/index.js +3 -0
  160. package/dist/components/Overall/list.module.js +5 -0
  161. package/dist/components/Overall/list_module.css +7 -0
  162. package/dist/components/Overall/project.d.ts +8 -0
  163. package/dist/components/Overall/project.js +73 -0
  164. package/dist/components/Plugins/webpack.d.ts +18 -0
  165. package/dist/components/Plugins/webpack.js +76 -0
  166. package/dist/components/Resolver/analysis.d.ts +15 -0
  167. package/dist/components/Resolver/analysis.js +144 -0
  168. package/dist/components/Select/index.d.ts +15 -0
  169. package/dist/components/Select/index.js +68 -0
  170. package/dist/components/Status/failed.d.ts +9 -0
  171. package/dist/components/Status/failed.js +33 -0
  172. package/dist/components/Status/index.d.ts +1 -0
  173. package/dist/components/Status/index.js +1 -0
  174. package/dist/components/TextDrawer/duplicate.d.ts +17 -0
  175. package/dist/components/TextDrawer/duplicate.js +69 -0
  176. package/dist/components/TextDrawer/index.d.ts +11 -0
  177. package/dist/components/TextDrawer/index.js +36 -0
  178. package/dist/components/Title/index.d.ts +15 -0
  179. package/dist/components/Title/index.js +10 -0
  180. package/dist/components/index.d.ts +12 -0
  181. package/dist/components/index.js +15 -0
  182. package/dist/components/worker/ecmaversion/client.d.ts +10 -0
  183. package/dist/components/worker/ecmaversion/client.js +60 -0
  184. package/dist/components/worker/ecmaversion/worker.d.ts +1 -0
  185. package/dist/components/worker/ecmaversion/worker.js +13 -0
  186. package/dist/components/worker/jsequal/client.d.ts +11 -0
  187. package/dist/components/worker/jsequal/client.js +38 -0
  188. package/dist/components/worker/jsequal/worker.d.ts +1 -0
  189. package/dist/components/worker/jsequal/worker.js +23 -0
  190. package/dist/config.d.ts +19 -0
  191. package/dist/config.js +25 -0
  192. package/dist/constants.d.ts +50 -0
  193. package/dist/constants.js +75 -0
  194. package/dist/index.d.ts +3 -0
  195. package/dist/index.js +6 -0
  196. package/dist/pages/BundleSize/components/asset.d.ts +26 -0
  197. package/dist/pages/BundleSize/components/asset.js +545 -0
  198. package/dist/pages/BundleSize/components/cards.d.ts +7 -0
  199. package/dist/pages/BundleSize/components/cards.js +143 -0
  200. package/dist/pages/BundleSize/components/editor.d.ts +5 -0
  201. package/dist/pages/BundleSize/components/editor.js +38 -0
  202. package/dist/pages/BundleSize/components/index.css +20 -0
  203. package/dist/pages/BundleSize/components/index.d.ts +16 -0
  204. package/dist/pages/BundleSize/components/index.js +366 -0
  205. package/dist/pages/BundleSize/config.d.ts +7 -0
  206. package/dist/pages/BundleSize/config.js +9 -0
  207. package/dist/pages/BundleSize/constants.d.ts +5 -0
  208. package/dist/pages/BundleSize/constants.js +9 -0
  209. package/dist/pages/BundleSize/index.d.ts +3 -0
  210. package/dist/pages/BundleSize/index.js +11 -0
  211. package/dist/pages/ModuleAnalyze/chunks.d.ts +6 -0
  212. package/dist/pages/ModuleAnalyze/chunks.js +48 -0
  213. package/dist/pages/ModuleAnalyze/components/fileTreeCom.css +97 -0
  214. package/dist/pages/ModuleAnalyze/components/fileTreeCom.d.ts +15 -0
  215. package/dist/pages/ModuleAnalyze/components/fileTreeCom.js +120 -0
  216. package/dist/pages/ModuleAnalyze/constants.d.ts +7 -0
  217. package/dist/pages/ModuleAnalyze/constants.js +14 -0
  218. package/dist/pages/ModuleAnalyze/dependncy.d.ts +9 -0
  219. package/dist/pages/ModuleAnalyze/dependncy.js +31 -0
  220. package/dist/pages/ModuleAnalyze/fileTree.d.ts +9 -0
  221. package/dist/pages/ModuleAnalyze/fileTree.js +125 -0
  222. package/dist/pages/ModuleAnalyze/index.css +10 -0
  223. package/dist/pages/ModuleAnalyze/index.d.ts +8 -0
  224. package/dist/pages/ModuleAnalyze/index.js +64 -0
  225. package/dist/pages/ModuleAnalyze/utils/hooks.d.ts +21 -0
  226. package/dist/pages/ModuleAnalyze/utils/hooks.js +62 -0
  227. package/dist/pages/ModuleAnalyze/utils/index.d.ts +3 -0
  228. package/dist/pages/ModuleAnalyze/utils/index.js +34 -0
  229. package/dist/pages/ModuleResolve/constants.d.ts +3 -0
  230. package/dist/pages/ModuleResolve/constants.js +7 -0
  231. package/dist/pages/ModuleResolve/index.d.ts +3 -0
  232. package/dist/pages/ModuleResolve/index.js +19 -0
  233. package/dist/pages/Overall/constants.d.ts +3 -0
  234. package/dist/pages/Overall/constants.js +7 -0
  235. package/dist/pages/Overall/index.d.ts +9 -0
  236. package/dist/pages/Overall/index.js +39 -0
  237. package/dist/pages/Overall/responsiveGridList.d.ts +6 -0
  238. package/dist/pages/Overall/responsiveGridList.js +28 -0
  239. package/dist/pages/Resources/RuleIndex/constants.d.ts +3 -0
  240. package/dist/pages/Resources/RuleIndex/constants.js +7 -0
  241. package/dist/pages/Resources/RuleIndex/index.d.ts +3 -0
  242. package/dist/pages/Resources/RuleIndex/index.js +53 -0
  243. package/dist/pages/TreeShaking/constants.d.ts +3 -0
  244. package/dist/pages/TreeShaking/constants.js +7 -0
  245. package/dist/pages/TreeShaking/editor.d.ts +12 -0
  246. package/dist/pages/TreeShaking/editor.js +110 -0
  247. package/dist/pages/TreeShaking/index.css +74 -0
  248. package/dist/pages/TreeShaking/index.d.ts +8 -0
  249. package/dist/pages/TreeShaking/index.js +177 -0
  250. package/dist/pages/TreeShaking/open-tag.d.ts +11 -0
  251. package/dist/pages/TreeShaking/open-tag.js +43 -0
  252. package/dist/pages/TreeShaking/space.d.ts +1 -0
  253. package/dist/pages/TreeShaking/space.js +16 -0
  254. package/dist/pages/TreeShaking/table.d.ts +13 -0
  255. package/dist/pages/TreeShaking/table.js +319 -0
  256. package/dist/pages/TreeShaking/types.d.ts +3 -0
  257. package/dist/pages/TreeShaking/types.js +0 -0
  258. package/dist/pages/TreeShaking/utils.d.ts +7 -0
  259. package/dist/pages/TreeShaking/utils.js +147 -0
  260. package/dist/pages/WebpackLoaders/Analysis/constants.d.ts +3 -0
  261. package/dist/pages/WebpackLoaders/Analysis/constants.js +7 -0
  262. package/dist/pages/WebpackLoaders/Analysis/index.d.ts +3 -0
  263. package/dist/pages/WebpackLoaders/Analysis/index.js +19 -0
  264. package/dist/pages/WebpackLoaders/Overall/constants.d.ts +3 -0
  265. package/dist/pages/WebpackLoaders/Overall/constants.js +7 -0
  266. package/dist/pages/WebpackLoaders/Overall/index.d.ts +3 -0
  267. package/dist/pages/WebpackLoaders/Overall/index.js +11 -0
  268. package/dist/pages/WebpackLoaders/constants.d.ts +2 -0
  269. package/dist/pages/WebpackLoaders/constants.js +6 -0
  270. package/dist/pages/WebpackPlugins/constants.d.ts +3 -0
  271. package/dist/pages/WebpackPlugins/constants.js +7 -0
  272. package/dist/pages/WebpackPlugins/index.d.ts +3 -0
  273. package/dist/pages/WebpackPlugins/index.js +79 -0
  274. package/dist/pages/index.d.ts +9 -0
  275. package/dist/pages/index.js +20 -0
  276. package/dist/utils/data/base.d.ts +24 -0
  277. package/dist/utils/data/base.js +48 -0
  278. package/dist/utils/data/index.d.ts +5 -0
  279. package/dist/utils/data/index.js +44 -0
  280. package/dist/utils/data/local.d.ts +14 -0
  281. package/dist/utils/data/local.js +86 -0
  282. package/dist/utils/data/remote.d.ts +10 -0
  283. package/dist/utils/data/remote.js +52 -0
  284. package/dist/utils/file.d.ts +33 -0
  285. package/dist/utils/file.js +154 -0
  286. package/dist/utils/hooks.d.ts +31 -0
  287. package/dist/utils/hooks.js +216 -0
  288. package/dist/utils/i18n/cn.d.ts +3 -0
  289. package/dist/utils/i18n/cn.js +33 -0
  290. package/dist/utils/i18n/en.d.ts +30 -0
  291. package/dist/utils/i18n/en.js +33 -0
  292. package/dist/utils/i18n/index.d.ts +2 -0
  293. package/dist/utils/i18n/index.js +34 -0
  294. package/dist/utils/index.d.ts +16 -0
  295. package/dist/utils/index.js +16 -0
  296. package/dist/utils/loader.d.ts +7 -0
  297. package/dist/utils/loader.js +34 -0
  298. package/dist/utils/locale.d.ts +2 -0
  299. package/dist/utils/locale.js +9 -0
  300. package/dist/utils/manifest.d.ts +27 -0
  301. package/dist/utils/manifest.js +54 -0
  302. package/dist/utils/monaco.d.ts +12 -0
  303. package/dist/utils/monaco.js +71 -0
  304. package/dist/utils/request.d.ts +27 -0
  305. package/dist/utils/request.js +130 -0
  306. package/dist/utils/routes.d.ts +3 -0
  307. package/dist/utils/routes.js +14 -0
  308. package/dist/utils/size.d.ts +2 -0
  309. package/dist/utils/size.js +24 -0
  310. package/dist/utils/socket.d.ts +2 -0
  311. package/dist/utils/socket.js +21 -0
  312. package/dist/utils/storage.d.ts +13 -0
  313. package/dist/utils/storage.js +70 -0
  314. package/dist/utils/string.d.ts +2 -0
  315. package/dist/utils/string.js +14 -0
  316. package/dist/utils/time.d.ts +3 -0
  317. package/dist/utils/time.js +7 -0
  318. package/dist/utils/url.d.ts +7 -0
  319. package/dist/utils/url.js +75 -0
  320. package/dist/utils/worker/index.d.ts +4 -0
  321. package/dist/utils/worker/index.js +4 -0
  322. package/dist/utils/worker/master.d.ts +8 -0
  323. package/dist/utils/worker/master.js +18 -0
  324. package/dist/utils/worker/types.d.ts +9 -0
  325. package/dist/utils/worker/types.js +0 -0
  326. package/dist/utils/worker/utils.d.ts +7 -0
  327. package/dist/utils/worker/utils.js +29 -0
  328. package/dist/utils/worker/worker.d.ts +13 -0
  329. package/dist/utils/worker/worker.js +38 -0
  330. package/package.json +92 -0
@@ -0,0 +1,193 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import React, { useCallback, useMemo, useRef, useState } from "react";
3
+ import { endsWith, get, sumBy } from "lodash-es";
4
+ import { Card, Col, Descriptions, Divider, Drawer, Row, Space, Table, Tooltip, Typography } from "antd";
5
+ import { CloseCircleOutlined } from "@ant-design/icons";
6
+ import { Constants, SDK } from "@rsdoctor/types";
7
+ import { ServerAPIProvider } from "../../Manifest";
8
+ import { drawerWidth, Size } from "../../../constants";
9
+ import { createFileStructures, formatCosts, mapFileKey, filterLoader, useMonacoEditor } from "../../../utils";
10
+ import { LoaderExecutions } from "../executions";
11
+ import { FileTree } from "../../FileTree";
12
+ import { Keyword } from "../../Keyword";
13
+ import { ECMAVersionDetectTag } from "../../worker/ecmaversion/client";
14
+ const LoaderFiles = (props) => {
15
+ const { cwd, filetree } = props;
16
+ const [drawerVisible, setDrawerVisible] = useState(false);
17
+ const [resourcePath, setResourcePath] = useState("");
18
+ const [loaderIndex, setLoaderIndex] = useState(0);
19
+ const [selectedNode, setSelectedNode] = useState(null);
20
+ const monacoRef = useRef(null);
21
+ const { initMonaco } = useMonacoEditor();
22
+ const init = useCallback(async () => {
23
+ await initMonaco(monacoRef);
24
+ }, []);
25
+ const maxHeight = 700;
26
+ const filteredFiles = useMemo(
27
+ () => filetree.filter((e) => e.loaders.some((l) => filterLoader(e.path, l.loader, props.filename, props.loaders))),
28
+ [props.filename, props.loaders]
29
+ );
30
+ const inlinedResourcePathKey = "__RESOURCEPATH__";
31
+ const files = useMemo(() => {
32
+ return createFileStructures({
33
+ files: filteredFiles.map((e) => e.path),
34
+ cwd,
35
+ fileTitle(file, basename) {
36
+ const { loaders } = filetree.find((e) => e.path === file);
37
+ return /* @__PURE__ */ jsxs(
38
+ Space,
39
+ {
40
+ style: { wordBreak: "break-all" },
41
+ onClick: () => {
42
+ setLoaderIndex(0);
43
+ setResourcePath(file);
44
+ setDrawerVisible(true);
45
+ },
46
+ children: [
47
+ /* @__PURE__ */ jsx(Keyword, { text: basename, keyword: props.filename }),
48
+ endsWith(file, Constants.JSExtension) ? /* @__PURE__ */ jsx(
49
+ ServerAPIProvider,
50
+ {
51
+ api: SDK.ServerAPI.API.GetLoaderFileFirstInput,
52
+ body: { file },
53
+ fallbackComponent: () => null,
54
+ children: (res) => /* @__PURE__ */ jsx(ECMAVersionDetectTag, { code: res })
55
+ }
56
+ ) : null,
57
+ loaders.map((e, i) => {
58
+ const isError = e.errors && e.errors.length;
59
+ const key = `${file}_${e.loader}_${i}`;
60
+ return /* @__PURE__ */ jsx(Tooltip, { title: e.path, children: /* @__PURE__ */ jsxs(
61
+ Typography.Text,
62
+ {
63
+ code: true,
64
+ style: { color: isError ? "#f50" : "inherit" },
65
+ onClick: (ev) => {
66
+ ev.stopPropagation();
67
+ setResourcePath(file);
68
+ setLoaderIndex(i);
69
+ setDrawerVisible(true);
70
+ },
71
+ children: [
72
+ /* @__PURE__ */ jsx(Typography.Text, { style: { maxWidth: 135, color: "inherit" }, ellipsis: true, children: e.loader }),
73
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
74
+ isError ? /* @__PURE__ */ jsx(CloseCircleOutlined, {}) : /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: formatCosts(e.costs) })
75
+ ]
76
+ }
77
+ ) }, key);
78
+ })
79
+ ]
80
+ }
81
+ );
82
+ },
83
+ dirTitle(_dir, defaultTitle) {
84
+ return /* @__PURE__ */ jsx(Keyword, { text: defaultTitle, keyword: props.filename });
85
+ }
86
+ });
87
+ }, [filteredFiles]);
88
+ return /* @__PURE__ */ jsxs(Row, { style: { width: "100%" }, gutter: Size.BasePadding, children: [
89
+ /* @__PURE__ */ jsx(Col, { span: 14, children: /* @__PURE__ */ jsxs(
90
+ Card,
91
+ {
92
+ title: /* @__PURE__ */ jsxs(Typography.Text, { strong: true, children: [
93
+ "Total Files: ",
94
+ filteredFiles.length
95
+ ] }),
96
+ bodyStyle: { overflow: "scroll", maxHeight },
97
+ children: [
98
+ /* @__PURE__ */ jsx(
99
+ FileTree,
100
+ {
101
+ defaultExpandedKeys: mapFileKey(files, filteredFiles.length >= 100 ? 3 : 4, (node) => {
102
+ const resourcePath2 = get(node, inlinedResourcePathKey);
103
+ const isNodeModules = resourcePath2.indexOf("/node_modules/") > -1;
104
+ return !isNodeModules;
105
+ }),
106
+ treeData: files,
107
+ onSelect: (_e, info) => {
108
+ init();
109
+ if (!info.node.isLeaf) {
110
+ setSelectedNode(info.node);
111
+ }
112
+ },
113
+ selectedKeys: selectedNode ? [selectedNode.key] : void 0,
114
+ expandAction: "click"
115
+ },
116
+ `${props.loaders.join("|")}_${props.filename}`
117
+ ),
118
+ /* @__PURE__ */ jsx(
119
+ Drawer,
120
+ {
121
+ open: drawerVisible,
122
+ onClose: () => setDrawerVisible(false),
123
+ maskClosable: true,
124
+ width: drawerWidth,
125
+ zIndex: 999,
126
+ bodyStyle: { padding: 0 },
127
+ children: drawerVisible ? /* @__PURE__ */ jsx(ServerAPIProvider, { api: SDK.ServerAPI.API.GetLoaderFileDetails, body: { path: resourcePath }, children: (data) => /* @__PURE__ */ jsx(LoaderExecutions, { data, cwd, index: loaderIndex }) }) : null
128
+ }
129
+ )
130
+ ]
131
+ }
132
+ ) }),
133
+ selectedNode ? /* @__PURE__ */ jsx(Col, { span: 10, children: /* @__PURE__ */ jsx(
134
+ Card,
135
+ {
136
+ title: /* @__PURE__ */ jsx(
137
+ Tooltip,
138
+ {
139
+ title: React.cloneElement(selectedNode.title, { style: { color: "#fff" } }),
140
+ children: /* @__PURE__ */ jsxs(Typography.Text, { children: [
141
+ 'Statistics of "',
142
+ selectedNode.title,
143
+ '"'
144
+ ] })
145
+ }
146
+ ),
147
+ children: /* @__PURE__ */ jsx(
148
+ ServerAPIProvider,
149
+ {
150
+ api: SDK.ServerAPI.API.GetLoaderFolderStatistics,
151
+ body: { folder: selectedNode[inlinedResourcePathKey] },
152
+ children: (tableData) => /* @__PURE__ */ jsx(
153
+ Table,
154
+ {
155
+ style: { width: "100%", maxHeight, overflowY: "scroll", wordBreak: "break-all" },
156
+ pagination: false,
157
+ bordered: true,
158
+ rowKey: (e) => e.loader,
159
+ columns: [
160
+ {
161
+ title: "Loader Name",
162
+ dataIndex: "loader"
163
+ },
164
+ {
165
+ title: "Files",
166
+ dataIndex: "files"
167
+ },
168
+ {
169
+ title: "Total Duration",
170
+ dataIndex: "costs",
171
+ render: (v) => /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: formatCosts(v) }),
172
+ sorter: (a, b) => a.costs - b.costs,
173
+ defaultSortOrder: "descend",
174
+ sortDirections: ["descend", "ascend"]
175
+ }
176
+ ],
177
+ dataSource: tableData,
178
+ footer: () => /* @__PURE__ */ jsxs(Descriptions, { title: "Total", bordered: true, layout: "vertical", size: "small", children: [
179
+ /* @__PURE__ */ jsx(Descriptions.Item, { label: "loaders", children: tableData.length }),
180
+ /* @__PURE__ */ jsx(Descriptions.Item, { label: "files", children: sumBy(tableData, (e) => e.files) }),
181
+ /* @__PURE__ */ jsx(Descriptions.Item, { label: "duration", children: /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: formatCosts(sumBy(tableData, (e) => e.costs)) }) })
182
+ ] })
183
+ }
184
+ )
185
+ }
186
+ )
187
+ }
188
+ ) }) : null
189
+ ] });
190
+ };
191
+ export {
192
+ LoaderFiles
193
+ };
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ export declare const LoaderAnalysisBase: React.FC<{
3
+ cwd: string;
4
+ }>;
5
+ export declare const LoaderAnalysis: React.FC<Omit<{
6
+ cwd: string;
7
+ }, "cwd"> & Partial<{
8
+ body: {
9
+ key: import("@rsdoctor/types/dist/manifest").RsdoctorManifestMappingKeys;
10
+ };
11
+ }>>;
@@ -0,0 +1,23 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { SDK } from "@rsdoctor/types";
4
+ import { ServerAPIProvider, withServerAPI } from "../../Manifest";
5
+ import { LoaderFiles } from "./files";
6
+ import { LoaderCommonSelect } from "../../Select";
7
+ const LoaderAnalysisBase = ({ cwd }) => {
8
+ const [store, setStore] = useState({ filename: "", loaders: [] });
9
+ return /* @__PURE__ */ jsxs("div", { children: [
10
+ /* @__PURE__ */ jsx(ServerAPIProvider, { api: SDK.ServerAPI.API.GetLoaderNames, children: (loaderNames) => /* @__PURE__ */ jsx(LoaderCommonSelect, { onChange: (e) => setStore(e), loaderNames }) }),
11
+ /* @__PURE__ */ jsx(ServerAPIProvider, { api: SDK.ServerAPI.API.GetLoaderFileTree, children: (filetree) => /* @__PURE__ */ jsx(LoaderFiles, { filename: store.filename, filetree, loaders: store.loaders, cwd }) })
12
+ ] });
13
+ };
14
+ const LoaderAnalysis = withServerAPI({
15
+ api: SDK.ServerAPI.API.LoadDataByKey,
16
+ body: { key: "root" },
17
+ responsePropName: "cwd",
18
+ Component: LoaderAnalysisBase
19
+ });
20
+ export {
21
+ LoaderAnalysis,
22
+ LoaderAnalysisBase
23
+ };
@@ -0,0 +1,9 @@
1
+ import { SDK } from '@rsdoctor/types';
2
+ import { PropsWithChildren } from 'react';
3
+ interface LoaderExecutionsProps {
4
+ cwd: string;
5
+ data: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetLoaderFileDetails>;
6
+ index?: number;
7
+ }
8
+ export declare const LoaderExecutions: ({ data, cwd, index }: PropsWithChildren<LoaderExecutionsProps>) => JSX.Element;
9
+ export {};
@@ -0,0 +1,199 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { ClockCircleOutlined } from "@ant-design/icons";
3
+ import Editor from "@monaco-editor/react";
4
+ import { Constants } from "@rsdoctor/types";
5
+ import { Badge, Button, Col, Divider, Empty, Row, Space, Tag, Timeline, Tooltip, Typography } from "antd";
6
+ import dayjs from "dayjs";
7
+ import { endsWith } from "lodash-es";
8
+ import { useState } from "react";
9
+ import { Size } from "../../constants";
10
+ import { beautifyPath, formatCosts, getModifiedLanguage, useTheme } from "../../utils";
11
+ import { Card } from "../Card";
12
+ import { DiffViewer } from "../CodeViewer";
13
+ import { CodeOpener } from "../Opener";
14
+ import { Title } from "../Title";
15
+ import { JSIsEqualTag } from "../worker/jsequal/client";
16
+ const LoaderInfoItem = ({
17
+ label,
18
+ value,
19
+ ellipsis = false,
20
+ ...textProps
21
+ }) => {
22
+ return /* @__PURE__ */ jsxs(Row, { children: [
23
+ /* @__PURE__ */ jsx(Col, { span: 6, children: /* @__PURE__ */ jsxs(Space, { children: [
24
+ /* @__PURE__ */ jsx(Badge, { status: "processing" }),
25
+ /* @__PURE__ */ jsx("div", { style: { width: 180 }, children: /* @__PURE__ */ jsx(Typography.Text, { strong: true, code: true, children: label }) }),
26
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" })
27
+ ] }) }),
28
+ /* @__PURE__ */ jsx(Col, { span: 18, children: /* @__PURE__ */ jsx(Typography.Paragraph, { ellipsis, strong: true, ...textProps, children: value }) })
29
+ ] });
30
+ };
31
+ const LoaderExecutions = ({ data, cwd, index }) => {
32
+ const { loaders, resource } = data;
33
+ const [currentIndex, setCurrentIndex] = useState(index || 0);
34
+ const { theme } = useTheme();
35
+ const isLight = theme === "light";
36
+ const loader = loaders[currentIndex];
37
+ const before = loader.input || "";
38
+ const leftSpan = 5;
39
+ const hasError = loader.errors && loader.errors.length;
40
+ return /* @__PURE__ */ jsxs(Row, { style: { height: "100%" }, children: [
41
+ /* @__PURE__ */ jsx(
42
+ Col,
43
+ {
44
+ span: leftSpan,
45
+ style: { borderRight: isLight ? `1px solid #f0f0f0` : void 0, padding: Size.BasePadding },
46
+ children: /* @__PURE__ */ jsxs(Space, { direction: "vertical", style: { width: "100%" }, children: [
47
+ /* @__PURE__ */ jsx(Title, { text: "Executions" }),
48
+ /* @__PURE__ */ jsx(Timeline, { mode: "left", style: { marginTop: Size.BasePadding }, children: loaders.map((e, i, arr) => {
49
+ const { loader: loader2, isPitch } = e;
50
+ return /* @__PURE__ */ jsxs(
51
+ Timeline.Item,
52
+ {
53
+ dot: isPitch ? /* @__PURE__ */ jsx(Tag, { style: { marginLeft: 1, fontWeight: 500 }, children: "pitch" }) : /* @__PURE__ */ jsx(ClockCircleOutlined, {}),
54
+ style: { paddingBottom: 10, textAlign: "center" },
55
+ children: [
56
+ /* @__PURE__ */ jsx(Row, { align: "middle", justify: "space-between", gutter: [0, 10], children: /* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsx(Tooltip, { title: loader2, trigger: "hover", children: /* @__PURE__ */ jsx(
57
+ Button,
58
+ {
59
+ type: i === currentIndex ? "primary" : "default",
60
+ block: true,
61
+ onClick: () => {
62
+ setCurrentIndex(i);
63
+ },
64
+ style: { textAlign: "left" },
65
+ children: /* @__PURE__ */ jsxs(Typography.Text, { ellipsis: true, style: { color: "inherit" }, children: [
66
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, style: { color: "inherit" }, children: formatCosts(e.costs) }),
67
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
68
+ loader2
69
+ ] })
70
+ }
71
+ ) }) }) }),
72
+ i === arr.length - 1 ? null : /* @__PURE__ */ jsx("div", { style: { paddingTop: 10 }, children: /* @__PURE__ */ jsx(Typography.Text, { children: "⬇️" }) })
73
+ ]
74
+ },
75
+ i
76
+ );
77
+ }) })
78
+ ] })
79
+ }
80
+ ),
81
+ /* @__PURE__ */ jsxs(Col, { span: 24 - leftSpan, style: { height: "100%" }, children: [
82
+ /* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsxs(
83
+ Card,
84
+ {
85
+ title: "Loader Details",
86
+ style: { border: "none" },
87
+ collapsable: true,
88
+ defaultCollapsed: true,
89
+ extra: /* @__PURE__ */ jsx(Tag, { icon: /* @__PURE__ */ jsx(ClockCircleOutlined, {}), color: "default", children: dayjs(loader.startAt).format("YYYY-MM-DD HH:mm:ss") }),
90
+ children: [
91
+ loader.isPitch ? /* @__PURE__ */ jsx(Typography.Text, { code: true, children: "pitch" }) : null,
92
+ loader.isPitch || hasError || !endsWith(resource.path, Constants.JSExtension) ? null : /* @__PURE__ */ jsx(JSIsEqualTag, { input: before, output: loader.result || "" }),
93
+ /* @__PURE__ */ jsxs(Space, { direction: "vertical", style: { padding: Size.BasePadding, wordBreak: "break-all" }, children: [
94
+ /* @__PURE__ */ jsx(LoaderInfoItem, { label: "file path", value: beautifyPath(resource.path, cwd), code: true }),
95
+ /* @__PURE__ */ jsx(
96
+ LoaderInfoItem,
97
+ {
98
+ label: "resource path",
99
+ value: /* @__PURE__ */ jsx(CodeOpener, { cwd, url: resource.path, loc: "", disabled: true })
100
+ }
101
+ ),
102
+ /* @__PURE__ */ jsx(LoaderInfoItem, { label: "resource query", value: resource.queryRaw || "-" }),
103
+ /* @__PURE__ */ jsx(LoaderInfoItem, { label: "duration", value: formatCosts(loader.costs), mark: true }),
104
+ /* @__PURE__ */ jsx(LoaderInfoItem, { label: "loader name", value: loader.loader, code: true }),
105
+ /* @__PURE__ */ jsx(LoaderInfoItem, { label: "loader index", value: `${loader.loaderIndex}` }),
106
+ /* @__PURE__ */ jsx(LoaderInfoItem, { label: "loader path", value: /* @__PURE__ */ jsx(CodeOpener, { cwd, url: loader.path, loc: "", disabled: true }) }),
107
+ /* @__PURE__ */ jsx(
108
+ LoaderInfoItem,
109
+ {
110
+ label: "options",
111
+ value: JSON.stringify(loader.options || "-"),
112
+ copyable: true,
113
+ ellipsis: {
114
+ rows: 2,
115
+ expandable: true,
116
+ symbol: "more"
117
+ }
118
+ }
119
+ )
120
+ ] })
121
+ ]
122
+ }
123
+ ) }),
124
+ hasError ? /* @__PURE__ */ jsxs(Col, { span: 24, style: { height: "53%", minHeight: 400 }, children: [
125
+ /* @__PURE__ */ jsx(
126
+ "div",
127
+ {
128
+ style: {
129
+ padding: Size.BasePadding,
130
+ borderTop: `1px solid ${isLight ? "#f0f0f0" : "rgba(253, 253, 253, 0.12)"}`,
131
+ borderBottom: `1px solid ${isLight ? "#f0f0f0" : "rgba(253, 253, 253, 0.12)"}`
132
+ },
133
+ children: /* @__PURE__ */ jsx(Title, { text: `the error stack of [${loader.loader}] ${loader.isPitch ? "pitch" : ""}` })
134
+ }
135
+ ),
136
+ /* @__PURE__ */ jsx("div", { style: { height: "90%" }, children: /* @__PURE__ */ jsx(
137
+ Editor,
138
+ {
139
+ theme: "vs-dark",
140
+ options: {
141
+ readOnly: true,
142
+ domReadOnly: true,
143
+ fontSize: 14,
144
+ minimap: { enabled: false },
145
+ lineNumbers: "off"
146
+ },
147
+ value: loader.errors[0].message,
148
+ language: "javascript"
149
+ }
150
+ ) })
151
+ ] }) : /* @__PURE__ */ jsxs(Col, { span: 24, style: { height: "53%", minHeight: 400 }, children: [
152
+ /* @__PURE__ */ jsx(
153
+ "div",
154
+ {
155
+ style: {
156
+ padding: Size.BasePadding,
157
+ borderTop: `1px solid ${isLight ? "#f0f0f0" : "rgba(253, 253, 253, 0.12)"}`,
158
+ borderBottom: `1px solid ${isLight ? "#f0f0f0" : "rgba(253, 253, 253, 0.12)"}`
159
+ },
160
+ children: /* @__PURE__ */ jsx(Title, { text: `the result of [${loader.loader}] ${loader.isPitch ? "pitch" : ""}` })
161
+ }
162
+ ),
163
+ loader.isPitch ? loader.result ? /* @__PURE__ */ jsx("div", { style: { height: "90%" }, children: /* @__PURE__ */ jsx(
164
+ Editor,
165
+ {
166
+ theme: "vs-dark",
167
+ options: {
168
+ readOnly: true,
169
+ domReadOnly: true,
170
+ fontSize: 14,
171
+ formatOnType: true,
172
+ formatOnPaste: true
173
+ },
174
+ value: loader.result,
175
+ language: getModifiedLanguage(resource.path)
176
+ }
177
+ ) }) : /* @__PURE__ */ jsx(Empty, {}) : /* @__PURE__ */ jsxs("div", { style: { height: "90%" }, children: [
178
+ /* @__PURE__ */ jsxs(Row, { children: [
179
+ /* @__PURE__ */ jsx(Col, { span: 12, style: { padding: `${Size.BasePadding / 2}px ${Size.BasePadding}px` }, children: /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Input" }) }),
180
+ /* @__PURE__ */ jsx(
181
+ Col,
182
+ {
183
+ span: 12,
184
+ style: {
185
+ padding: `${Size.BasePadding / 2}px ${Size.BasePadding}px`
186
+ },
187
+ children: /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Output" })
188
+ }
189
+ )
190
+ ] }),
191
+ /* @__PURE__ */ jsx("div", { style: { height: "86%" }, children: /* @__PURE__ */ jsx(DiffViewer, { filepath: resource.path, before, after: loader.result || "" }) })
192
+ ] })
193
+ ] })
194
+ ] })
195
+ ] });
196
+ };
197
+ export {
198
+ LoaderExecutions
199
+ };
@@ -0,0 +1,34 @@
1
+ import { Manifest, SDK } from '@rsdoctor/types';
2
+ import React from 'react';
3
+ export type InferServerAPIBody<T> = SDK.ServerAPI.InferRequestBodyType<T> extends void ? {
4
+ body?: any;
5
+ } : {
6
+ body: SDK.ServerAPI.InferRequestBodyType<T>;
7
+ };
8
+ type ServerAPIProviderProps<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends> = {
9
+ manifestLoader?: () => Promise<Manifest.RsdoctorManifestWithShardingFiles>;
10
+ api: T;
11
+ children: (response: SDK.ServerAPI.InferResponseType<T>) => JSX.Element;
12
+ fallbackComponent?: React.FC;
13
+ showSkeleton?: boolean;
14
+ } & InferServerAPIBody<T>;
15
+ /**
16
+ * this component will request server api to the sdk of Rsdoctor in local development.
17
+ * otherwise it will fallback to load full manifest for the data.
18
+ *
19
+ * @example usage
20
+ * <ServerAPIProvider {...props}>
21
+ * {(response) => {
22
+ * <Component {...}></Component>
23
+ * }}
24
+ * </ServerAPIProvider>
25
+ */
26
+ export declare const ServerAPIProvider: <T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(props: ServerAPIProviderProps<T>) => JSX.Element | null;
27
+ export declare function withServerAPI<T, P extends keyof T, A extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>({ Component, api, responsePropName, body: bodyInRoot, fallbackComponent, showSkeleton, }: {
28
+ Component: React.FC<T>;
29
+ api: A;
30
+ responsePropName: P;
31
+ fallbackComponent?: React.FC;
32
+ showSkeleton?: boolean;
33
+ } & Partial<Partial<InferServerAPIBody<A>>>): React.FC<Omit<T, P> & Partial<InferServerAPIBody<A>>>;
34
+ export {};
@@ -0,0 +1,127 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { SDK } from "@rsdoctor/types";
3
+ import { Skeleton, Spin } from "antd";
4
+ import { useCallback, useEffect, useState } from "react";
5
+ import { includes, isEqual, isNil, values } from "lodash-es";
6
+ import { fetchManifest, useDataLoader } from "../../utils";
7
+ import { ComponentState } from "../../constants";
8
+ import { FailedStatus } from "../Status";
9
+ const ServerAPIProvider = (props) => {
10
+ const {
11
+ manifestLoader = fetchManifest,
12
+ api,
13
+ children,
14
+ // default value of "body" must be "null" to avoid the response type not match when the socket received message.
15
+ body = null,
16
+ showSkeleton = true,
17
+ fallbackComponent
18
+ } = props;
19
+ let promise = manifestLoader();
20
+ const [manifest, setManifest] = useState();
21
+ const [state, setState] = useState(ComponentState.Pending);
22
+ const [res, setRes] = useState({});
23
+ const { loader } = useDataLoader(manifest);
24
+ function init(loader2) {
25
+ ensureManifest(promise).then(() => {
26
+ executeLoader(loader2);
27
+ });
28
+ }
29
+ const update = useCallback(
30
+ ({ req, res: response }) => {
31
+ if (req.api === api) {
32
+ if (isEqual(req.body, body) || isNil(req.body) && isNil(body)) {
33
+ if (!isEqual(res, response)) {
34
+ setRes(response);
35
+ }
36
+ }
37
+ }
38
+ setState(ComponentState.Success);
39
+ },
40
+ [res, api, body]
41
+ );
42
+ useEffect(() => {
43
+ init(loader);
44
+ }, [loader, api, body]);
45
+ useEffect(() => {
46
+ if (!loader)
47
+ return;
48
+ loader.onDataUpdate(api, update);
49
+ return () => {
50
+ loader.removeOnDataUpdate(api, update);
51
+ };
52
+ }, [loader, api, body]);
53
+ function ensureManifest(pro) {
54
+ return pro.then((manifest2) => {
55
+ setManifest(manifest2);
56
+ }).catch((err) => {
57
+ setState(ComponentState.Fail);
58
+ throw err;
59
+ });
60
+ }
61
+ function executeLoader(loader2) {
62
+ if (!loader2)
63
+ return;
64
+ const exts = values(SDK.ServerAPI.APIExtends);
65
+ if (includes(exts, api)) {
66
+ setState(ComponentState.Success);
67
+ return;
68
+ }
69
+ loader2.loadAPI(api, body).then((e) => {
70
+ if (isNil(e)) {
71
+ return;
72
+ }
73
+ setRes(e);
74
+ setState(ComponentState.Success);
75
+ }).catch((err) => {
76
+ console.error(err);
77
+ setState(ComponentState.Fail);
78
+ });
79
+ }
80
+ if (state === ComponentState.Pending) {
81
+ return showSkeleton ? /* @__PURE__ */ jsx(Skeleton, { active: true }) : null;
82
+ }
83
+ if (state === ComponentState.Fail) {
84
+ if (fallbackComponent)
85
+ return fallbackComponent;
86
+ return /* @__PURE__ */ jsx(
87
+ FailedStatus,
88
+ {
89
+ retry: () => {
90
+ setState(ComponentState.Pending);
91
+ promise = manifestLoader();
92
+ init();
93
+ }
94
+ }
95
+ );
96
+ }
97
+ if (state === ComponentState.Updating) {
98
+ return /* @__PURE__ */ jsx(Spin, { spinning: true, children: children(res) });
99
+ }
100
+ return children(res);
101
+ };
102
+ function withServerAPI({
103
+ Component,
104
+ api,
105
+ responsePropName,
106
+ body: bodyInRoot,
107
+ fallbackComponent,
108
+ showSkeleton
109
+ }) {
110
+ return function _(props) {
111
+ const { body = bodyInRoot, ...rest } = props;
112
+ return (
113
+ // @ts-ignore
114
+ /* @__PURE__ */ jsx(ServerAPIProvider, { api, body, showSkeleton, fallbackComponent, children: (res) => {
115
+ const _props = {
116
+ ...rest,
117
+ [responsePropName]: res
118
+ };
119
+ return /* @__PURE__ */ jsx(Component, { ..._props });
120
+ } })
121
+ );
122
+ };
123
+ }
124
+ export {
125
+ ServerAPIProvider,
126
+ withServerAPI
127
+ };
@@ -0,0 +1,8 @@
1
+ import { Manifest } from '@rsdoctor/types';
2
+ import React from 'react';
3
+ type ExtractAlias<T> = T extends [property: string, alias: infer P][] ? `${P extends string ? P : never}` : never;
4
+ /**
5
+ * @deprecated
6
+ */
7
+ export declare function ConnectManifestData<Props extends object, Keys extends [property: `${Manifest.RsdoctorManifestMappingKeys}`, alias: keyof Props][] | [property: string, alias: keyof Props][]>(manifestLoader: () => Promise<Manifest.RsdoctorManifestWithShardingFiles>, keys: Keys, Component: React.FC<Props>): React.FC<Omit<Props, ExtractAlias<Keys>>>;
8
+ export {};
@@ -0,0 +1,65 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Skeleton } from "antd";
3
+ import { useEffect, useState } from "react";
4
+ import { useDataLoader } from "../../utils";
5
+ import { PageState } from "../../constants";
6
+ import { FailedStatus } from "../Status";
7
+ function ConnectManifestData(manifestLoader, keys, Component) {
8
+ const promise = manifestLoader();
9
+ return function _() {
10
+ const [manifest, setManifest] = useState();
11
+ const [state, setState] = useState(PageState.Pending);
12
+ const [props, setProps] = useState({});
13
+ const { loader } = useDataLoader(manifest);
14
+ useEffect(() => {
15
+ ensureManifest(promise).then(() => {
16
+ executeLoader(loader);
17
+ });
18
+ }, [loader]);
19
+ function ensureManifest(pro) {
20
+ return pro.then((manifest2) => {
21
+ setManifest(manifest2);
22
+ }).catch(() => {
23
+ setState(PageState.Fail);
24
+ });
25
+ }
26
+ function executeLoader(loader2) {
27
+ if (!loader2)
28
+ return;
29
+ Promise.all(keys.map(([key]) => loader2.loadData(key))).then((e) => {
30
+ const p = e.reduce((t, val, i) => {
31
+ const [_key, alias] = keys[i];
32
+ t[alias] = val;
33
+ return t;
34
+ }, {});
35
+ setProps(p);
36
+ setState(PageState.Success);
37
+ }).catch((err) => {
38
+ console.error(err);
39
+ setState(PageState.Fail);
40
+ });
41
+ }
42
+ if (state === PageState.Pending) {
43
+ return /* @__PURE__ */ jsx(Skeleton, { active: true });
44
+ }
45
+ if (state === PageState.Fail) {
46
+ return /* @__PURE__ */ jsx(
47
+ FailedStatus,
48
+ {
49
+ retry: () => {
50
+ setState(PageState.Pending);
51
+ promise.then(() => {
52
+ executeLoader(loader);
53
+ }).catch(() => {
54
+ ensureManifest(manifestLoader());
55
+ });
56
+ }
57
+ }
58
+ );
59
+ }
60
+ return /* @__PURE__ */ jsx(Component, { ...props });
61
+ };
62
+ }
63
+ export {
64
+ ConnectManifestData
65
+ };
@@ -0,0 +1,2 @@
1
+ export * from './data';
2
+ export * from './api';