@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,216 @@
1
+ import { Algorithm } from "@rsdoctor/utils/common";
2
+ import { Client, Rule } from "@rsdoctor/types";
3
+ import { uniqBy, isArray, defaults } from "lodash-es";
4
+ import { useEffect, useState } from "react";
5
+ import { useTranslation } from "react-i18next";
6
+ import { useNavigate, useLocation } from "react-router-dom";
7
+ import parse from "url-parse";
8
+ import "./i18n";
9
+ import { setLocaleToStorage } from "./storage";
10
+ const route = Client.RsdoctorClientRoutes.RuleIndex;
11
+ const useI18n = () => {
12
+ const { i18n, ...rest } = useTranslation();
13
+ return {
14
+ ...rest,
15
+ i18n: {
16
+ ...i18n,
17
+ changeLanguage(lng, callback) {
18
+ return i18n.changeLanguage(lng, (error, t) => {
19
+ if (!error) {
20
+ setLocaleToStorage(lng);
21
+ }
22
+ callback && callback(error, t);
23
+ });
24
+ }
25
+ }
26
+ };
27
+ };
28
+ function useRuleIndexNavigate(code, link) {
29
+ const navigate = useNavigate();
30
+ if (link) {
31
+ return () => window.open(link, "__blank");
32
+ }
33
+ return () => {
34
+ navigate(`${route}?${Rule.RsdoctorRuleClientConstant.UrlQueryForErrorCode}=${code}`);
35
+ };
36
+ }
37
+ function useUrlQuery() {
38
+ const search = useLocation().search || location.search;
39
+ const { query } = parse(search, true);
40
+ return query;
41
+ }
42
+ function useLoading(defaultLoading = false) {
43
+ const [loading, setLoading] = useState(defaultLoading);
44
+ return {
45
+ loading,
46
+ setLoading,
47
+ async withLoading(func) {
48
+ try {
49
+ setLoading(true);
50
+ await func();
51
+ } finally {
52
+ setLoading(false);
53
+ }
54
+ }
55
+ };
56
+ }
57
+ function useProjectRootByManifest(manifest) {
58
+ return manifest.data.root;
59
+ }
60
+ function useHashByManifest(manifest) {
61
+ return manifest.data.hash;
62
+ }
63
+ function useCloudManifestUrlByManifest(manifest) {
64
+ if (!manifest)
65
+ return;
66
+ }
67
+ function ensurePlainObject(value, dfts) {
68
+ if (value && typeof value === "object") {
69
+ if (isArray(value)) {
70
+ return dfts;
71
+ }
72
+ return defaults(value, dfts);
73
+ }
74
+ return dfts;
75
+ }
76
+ function useChunkGraphByManifest(manifest) {
77
+ const prev = manifest.data.chunkGraph;
78
+ if (typeof prev === "string") {
79
+ manifest.data.chunkGraph = JSON.parse(Algorithm.decompressText(prev));
80
+ }
81
+ return ensurePlainObject(manifest.data.chunkGraph, { assets: [], chunks: [], entrypoints: [] });
82
+ }
83
+ function useConfigOutputFileNameByManifest(manifest) {
84
+ if (typeof manifest.data.configs?.[0]?.config?.output?.filename === "string") {
85
+ return manifest.data.configs?.[0]?.config?.output?.filename;
86
+ }
87
+ return "";
88
+ }
89
+ function useModuleGraphByManifest(manifest) {
90
+ const prev = manifest.data.moduleGraph;
91
+ if (typeof prev === "string") {
92
+ manifest.data.moduleGraph = JSON.parse(Algorithm.decompressText(prev));
93
+ }
94
+ return ensurePlainObject(manifest.data.moduleGraph, {
95
+ dependencies: [],
96
+ modules: [],
97
+ moduleGraphModules: [],
98
+ exports: [],
99
+ sideEffects: [],
100
+ variables: []
101
+ });
102
+ }
103
+ function useModuleGraph(moduleGraph) {
104
+ const prev = moduleGraph;
105
+ if (typeof prev === "string") {
106
+ moduleGraph = JSON.parse(Algorithm.decompressText(prev));
107
+ }
108
+ return ensurePlainObject(moduleGraph, {
109
+ dependencies: [],
110
+ modules: [],
111
+ moduleGraphModules: [],
112
+ exports: [],
113
+ sideEffects: [],
114
+ variables: []
115
+ });
116
+ }
117
+ function usePackageGraphByManifest(manifest) {
118
+ const prev = manifest.data.packageGraph;
119
+ if (typeof prev === "string") {
120
+ manifest.data.packageGraph = JSON.parse(Algorithm.decompressText(prev));
121
+ }
122
+ return ensurePlainObject(manifest.data.packageGraph, {
123
+ packages: [],
124
+ dependencies: []
125
+ });
126
+ }
127
+ function useUniqModulesByManifest(manifest) {
128
+ return uniqBy(useModuleGraphByManifest(manifest).modules, (e) => e.path);
129
+ }
130
+ function useUniqModules(modules) {
131
+ return uniqBy(modules, (e) => e.path);
132
+ }
133
+ function useErrorsByManifest(manifest) {
134
+ const prev = manifest.data.errors;
135
+ if (typeof prev === "string") {
136
+ manifest.data.errors = JSON.parse(Algorithm.decompressText(prev));
137
+ }
138
+ return manifest.data.errors || [];
139
+ }
140
+ function useBundleAlertsByManifest(manifest) {
141
+ const errors = useErrorsByManifest(manifest);
142
+ return useBundleAlertsByErrors(errors);
143
+ }
144
+ function useDuplicatePackagesByManifest(manifest) {
145
+ const alerts = useBundleAlertsByManifest(manifest);
146
+ return useDuplicatePackagesByErrors(alerts);
147
+ }
148
+ function useCompileAlertsByErrors(errors) {
149
+ if (isArray(errors)) {
150
+ return errors.filter(
151
+ (e) => e.category === Rule.RuleMessageCategory.Compile && e.code !== Rule.RuleMessageCodeEnumerated.Overlay
152
+ );
153
+ }
154
+ return [];
155
+ }
156
+ function useBundleAlertsByErrors(errors) {
157
+ if (isArray(errors)) {
158
+ return errors.filter(
159
+ (e) => e.category === Rule.RuleMessageCategory.Bundle && e.code !== Rule.RuleMessageCodeEnumerated.Overlay
160
+ );
161
+ }
162
+ return [];
163
+ }
164
+ function useDuplicatePackagesByErrors(errors) {
165
+ return useBundleAlertsByErrors(errors).filter(
166
+ (e) => e.code === Rule.RuleErrorMap.E1001.code
167
+ );
168
+ }
169
+ function useWebpackConfigurationByConfigs(configs = []) {
170
+ if (isArray(configs)) {
171
+ return configs.find((e) => e.name === "webpack" || e.name === "rspack");
172
+ }
173
+ return null;
174
+ }
175
+ function useDetectIfCloudIdeEnv() {
176
+ if (window.location.protocol === "https:" && window.location.href.indexOf("ide-proxy") > 0) {
177
+ return true;
178
+ }
179
+ return false;
180
+ }
181
+ function useWindowWidth() {
182
+ const [windowWidth, setWindowWidth] = useState(window.innerWidth);
183
+ useEffect(() => {
184
+ const handleResize = () => setWindowWidth(window.innerWidth);
185
+ window.addEventListener("resize", handleResize);
186
+ return () => {
187
+ window.removeEventListener("resize", handleResize);
188
+ };
189
+ }, []);
190
+ return windowWidth;
191
+ }
192
+ export {
193
+ useBundleAlertsByErrors,
194
+ useBundleAlertsByManifest,
195
+ useChunkGraphByManifest,
196
+ useCloudManifestUrlByManifest,
197
+ useCompileAlertsByErrors,
198
+ useConfigOutputFileNameByManifest,
199
+ useDetectIfCloudIdeEnv,
200
+ useDuplicatePackagesByErrors,
201
+ useDuplicatePackagesByManifest,
202
+ useErrorsByManifest,
203
+ useHashByManifest,
204
+ useI18n,
205
+ useLoading,
206
+ useModuleGraph,
207
+ useModuleGraphByManifest,
208
+ usePackageGraphByManifest,
209
+ useProjectRootByManifest,
210
+ useRuleIndexNavigate,
211
+ useUniqModules,
212
+ useUniqModulesByManifest,
213
+ useUrlQuery,
214
+ useWebpackConfigurationByConfigs,
215
+ useWindowWidth
216
+ };
@@ -0,0 +1,3 @@
1
+ import en from './en';
2
+ declare const cn: typeof en;
3
+ export default cn;
@@ -0,0 +1,33 @@
1
+ const cn = {
2
+ Overall: "概览",
3
+ "Compile Analysis": "编译分析",
4
+ LoadersAnalysis: "Loaders 分析",
5
+ "Loaders Timeline": "Loaders 概览",
6
+ "Loaders Analysis": "Loaders 分析",
7
+ PluginsAnalysis: "Plugins 分析",
8
+ ModuleResolve: "Module Resolve 分析",
9
+ "Bundle Analysis": "产物分析",
10
+ BundleSize: "产物体积分析",
11
+ "Module Graph": "Module Graph",
12
+ TreeShaking: "Tree Shaking",
13
+ "Rule Index": "错误索引信息",
14
+ Resources: "资源",
15
+ "Project Overall": "项目信息概览",
16
+ "Compile Overall": "编译数据概览",
17
+ "Bundle Overall": "产物数据概览",
18
+ "Expand Omitted": " reasons 树会默认折叠中间的第三方引入的模块,点击这个图标可以查看完整树图",
19
+ "Concatenated Tag": "串联模块,hover 上去可以显示聚合成的主模块名称。注:聚合模块 bundled size 为零,有可能是因为被聚合到了主模块中。",
20
+ "the file content not changed after transpiled by this loader": "该文件内容在 loader 处理前后没有发生变化",
21
+ /** Bundle Size */
22
+ "Output Assets List": "产物文件列表",
23
+ "filter the output assets which size is greater than the input value": "筛选大小大于输入值的产物文件",
24
+ "filter the modules which size is greater than the input value": "筛选大小大于输入值的模块",
25
+ "After Compile": "编译后",
26
+ "After Bundle": "打包后",
27
+ CodeModeExplain: "Lite 模式下或纯 stats.json 上传的情况下只有 source code.",
28
+ DuplicatePakCodeExplain: "纯 stats.json 输入的情况下没有代码,可使用 web-doctor 插件参与构建会有对应代码。"
29
+ };
30
+ var cn_default = cn;
31
+ export {
32
+ cn_default as default
33
+ };
@@ -0,0 +1,30 @@
1
+ declare const en: {
2
+ Overall: string;
3
+ 'Compile Analysis': string;
4
+ LoadersAnalysis: string;
5
+ 'Loaders Timeline': string;
6
+ 'Loaders Analysis': string;
7
+ PluginsAnalysis: string;
8
+ ModuleResolve: string;
9
+ 'Bundle Analysis': string;
10
+ BundleSize: string;
11
+ 'Module Graph': string;
12
+ TreeShaking: string;
13
+ 'Rule Index': string;
14
+ Resources: string;
15
+ 'Project Overall': string;
16
+ 'Compile Overall': string;
17
+ 'Bundle Overall': string;
18
+ 'Expand Omitted': string;
19
+ 'Concatenated Tag': string;
20
+ 'the file content not changed after transpiled by this loader': string;
21
+ /** Bundle Size */
22
+ 'Output Assets List': string;
23
+ 'filter the output assets which size is greater than the input value': string;
24
+ 'filter the modules which size is greater than the input value': string;
25
+ 'After Compile': string;
26
+ 'After Bundle': string;
27
+ CodeModeExplain: string;
28
+ DuplicatePakCodeExplain: string;
29
+ };
30
+ export default en;
@@ -0,0 +1,33 @@
1
+ const en = {
2
+ Overall: "Overall",
3
+ "Compile Analysis": "Compile Analysis",
4
+ LoadersAnalysis: "Loaders Analysis",
5
+ "Loaders Timeline": "Loaders Timeline",
6
+ "Loaders Analysis": "Loaders Analysis",
7
+ PluginsAnalysis: "Plugins Analysis",
8
+ ModuleResolve: "Module Resolve",
9
+ "Bundle Analysis": "Bundle Analysis",
10
+ BundleSize: "Bundle Size",
11
+ "Module Graph": "Module Graph",
12
+ TreeShaking: "Tree Shaking",
13
+ "Rule Index": "Rule Index",
14
+ Resources: "Resources",
15
+ "Project Overall": "Project Overall",
16
+ "Compile Overall": "Compile Overall",
17
+ "Bundle Overall": "Bundle Overall",
18
+ "Expand Omitted": "By default, the reasons tree collapses to the middle of the module introduced by a third party. Click on this icon to view the full tree diagram",
19
+ "Concatenated Tag": "Concatenated Module,hover can display the name of the concatenated main module. Note: the bundled size of the concatenated module is zero, possibly because it is aggregated into the main module.",
20
+ "the file content not changed after transpiled by this loader": "the file content not changed after transpiled by this loader",
21
+ /** Bundle Size */
22
+ "Output Assets List": "Output Assets List",
23
+ "filter the output assets which size is greater than the input value": "filter the output assets which size is greater than the input value",
24
+ "filter the modules which size is greater than the input value": "filter the modules which size is greater than the input value",
25
+ "After Compile": "After Compile",
26
+ "After Bundle": "After Bundle",
27
+ CodeModeExplain: "In lite mode or pure stats.json upload, only source code.",
28
+ DuplicatePakCodeExplain: "There is no code, when in the case of pure stats.json."
29
+ };
30
+ var en_default = en;
31
+ export {
32
+ en_default as default
33
+ };
@@ -0,0 +1,2 @@
1
+ import i18n from 'i18next';
2
+ export default i18n;
@@ -0,0 +1,34 @@
1
+ import i18n from "i18next";
2
+ import { initReactI18next } from "react-i18next";
3
+ import en from "./en";
4
+ import cn from "./cn";
5
+ import { getLocaleFromStorage } from "../storage";
6
+ i18n.use(initReactI18next).init({
7
+ lng: getLocaleFromStorage(),
8
+ // we init with resources
9
+ resources: {
10
+ en: {
11
+ translations: en
12
+ },
13
+ cn: {
14
+ translations: cn
15
+ }
16
+ },
17
+ fallbackLng: {
18
+ "zh-CN": ["cn"],
19
+ default: ["en"]
20
+ },
21
+ debug: process.env.NODE_ENV === "development",
22
+ // have a common namespace used around the full app
23
+ ns: ["translations"],
24
+ defaultNS: "translations",
25
+ keySeparator: false,
26
+ // we use content as keys
27
+ interpolation: {
28
+ escapeValue: false
29
+ }
30
+ });
31
+ var i18n_default = i18n;
32
+ export {
33
+ i18n_default as default
34
+ };
@@ -0,0 +1,16 @@
1
+ export * from './data';
2
+ export * from './file';
3
+ export * from './hooks';
4
+ export * from './locale';
5
+ export * from './manifest';
6
+ export * from './monaco';
7
+ export * from './request';
8
+ export * from './routes';
9
+ export * from './size';
10
+ export * from './socket';
11
+ export * from './storage';
12
+ export * from './string';
13
+ export * from './time';
14
+ export * from './url';
15
+ export * from './worker';
16
+ export * from './loader';
@@ -0,0 +1,16 @@
1
+ export * from "./data";
2
+ export * from "./file";
3
+ export * from "./hooks";
4
+ export * from "./locale";
5
+ export * from "./manifest";
6
+ export * from "./monaco";
7
+ export * from "./request";
8
+ export * from "./routes";
9
+ export * from "./size";
10
+ export * from "./socket";
11
+ export * from "./storage";
12
+ export * from "./string";
13
+ export * from "./time";
14
+ export * from "./url";
15
+ export * from "./worker";
16
+ export * from "./loader";
@@ -0,0 +1,7 @@
1
+ import { Loader } from '@rsdoctor/utils/common';
2
+ import { SDK } from '@rsdoctor/types';
3
+ declare const findLoaderTotalTiming: typeof Loader.findLoaderTotalTiming, getLoaderCosts: typeof Loader.getLoaderCosts;
4
+ export { findLoaderTotalTiming, getLoaderCosts };
5
+ export declare function flattenLoaderData(loaderData: SDK.LoaderData): SDK.LoaderTransformData[];
6
+ export declare function filterLoaders(loaderData: SDK.ResourceLoaderData, keyword: string, loaderNames: string[]): SDK.LoaderTransformData[];
7
+ export declare function filterLoader(resourcePath: string, loader: string, keyword: string, loaderNames: string[]): boolean;
@@ -0,0 +1,34 @@
1
+ import { Loader } from "@rsdoctor/utils/common";
2
+ import { flatten, includes } from "lodash-es";
3
+ const { findLoaderTotalTiming, getLoaderCosts } = Loader;
4
+ function flattenLoaderData(loaderData) {
5
+ return flatten(loaderData.map((e) => e.loaders));
6
+ }
7
+ function filterLoaders(loaderData, keyword, loaderNames) {
8
+ return loaderData.loaders.filter((item) => {
9
+ return filterLoader(
10
+ loaderData.resource.path,
11
+ item.loader,
12
+ keyword,
13
+ loaderNames
14
+ );
15
+ });
16
+ }
17
+ function filterLoader(resourcePath, loader, keyword, loaderNames) {
18
+ if (keyword) {
19
+ if (resourcePath.indexOf(keyword) === -1)
20
+ return false;
21
+ }
22
+ if (loaderNames?.length) {
23
+ if (!includes(loaderNames, loader))
24
+ return false;
25
+ }
26
+ return true;
27
+ }
28
+ export {
29
+ filterLoader,
30
+ filterLoaders,
31
+ findLoaderTotalTiming,
32
+ flattenLoaderData,
33
+ getLoaderCosts
34
+ };
@@ -0,0 +1,2 @@
1
+ import type { Locale } from 'antd/es/locale';
2
+ export declare function getLocale(locale: string): Locale;
@@ -0,0 +1,9 @@
1
+ import cn from "antd/es/locale/zh_CN";
2
+ import en from "antd/es/locale/en_GB";
3
+ function getLocale(locale) {
4
+ const res = locale === "cn" || locale === "zh-CN" ? cn : en;
5
+ return res;
6
+ }
7
+ export {
8
+ getLocale
9
+ };
@@ -0,0 +1,27 @@
1
+ import { ModuleGraph } from '@rsdoctor/graph';
2
+ import { Manifest, SDK } from '@rsdoctor/types';
3
+ import { Theme, ViewMode } from '../constants';
4
+ export declare function useManifestJson(): Manifest.RsdoctorManifest;
5
+ export declare function useLocale(): import("../constants").Language;
6
+ export declare function useTheme(): {
7
+ theme: Theme;
8
+ setTheme: (theme: Theme) => void;
9
+ isDark: boolean;
10
+ isLight: boolean;
11
+ };
12
+ export declare function useViewMode(): {
13
+ viewMode: {
14
+ bundleAlerts: ViewMode;
15
+ compileAlerts: ViewMode;
16
+ };
17
+ setViewMode: (mode: Partial<{
18
+ bundleAlerts: ViewMode;
19
+ compileAlerts: ViewMode;
20
+ }>, saveStorage?: boolean | undefined) => void;
21
+ setCompileAlertsViewMode(mode: ViewMode): void;
22
+ setBundleAlertsViewMode(mode: ViewMode): void;
23
+ isCompileList: boolean;
24
+ isBundleList: boolean;
25
+ };
26
+ export declare function useManifest(url: string): Manifest.RsdoctorManifestWithShardingFiles | undefined;
27
+ export declare function useModuleGraphInstanceByModuleGraph(moduleGraph: SDK.ModuleGraphData): ModuleGraph;
@@ -0,0 +1,54 @@
1
+ import { useContext, useEffect, useMemo, useState } from "react";
2
+ import { ModuleGraph } from "@rsdoctor/graph";
3
+ import { ConfigContext } from "../config";
4
+ import { Theme, ViewMode } from "../constants";
5
+ import { fetchManifest } from "./request";
6
+ function useManifestJson() {
7
+ const { json } = useContext(ConfigContext);
8
+ return json;
9
+ }
10
+ function useLocale() {
11
+ const ctx = useContext(ConfigContext);
12
+ return ctx.locale;
13
+ }
14
+ function useTheme() {
15
+ const { theme, setTheme } = useContext(ConfigContext);
16
+ const isDark = theme === Theme.Dark;
17
+ return { theme, setTheme, isDark, isLight: !isDark };
18
+ }
19
+ function useViewMode() {
20
+ const { viewMode, setViewMode } = useContext(ConfigContext);
21
+ const { bundleAlerts, compileAlerts } = viewMode;
22
+ return {
23
+ viewMode,
24
+ setViewMode,
25
+ setCompileAlertsViewMode(mode) {
26
+ setViewMode({ compileAlerts: mode });
27
+ },
28
+ setBundleAlertsViewMode(mode) {
29
+ setViewMode({ bundleAlerts: mode });
30
+ },
31
+ isCompileList: compileAlerts === ViewMode.List,
32
+ isBundleList: bundleAlerts === ViewMode.List
33
+ };
34
+ }
35
+ function useManifest(url) {
36
+ const [manifest, setManifest] = useState();
37
+ useEffect(() => {
38
+ fetchManifest(url).then((res) => {
39
+ setManifest(res);
40
+ });
41
+ }, []);
42
+ return manifest;
43
+ }
44
+ function useModuleGraphInstanceByModuleGraph(moduleGraph) {
45
+ return useMemo(() => ModuleGraph.fromData(moduleGraph), [moduleGraph]);
46
+ }
47
+ export {
48
+ useLocale,
49
+ useManifest,
50
+ useManifestJson,
51
+ useModuleGraphInstanceByModuleGraph,
52
+ useTheme,
53
+ useViewMode
54
+ };
@@ -0,0 +1,12 @@
1
+ import type { SDK } from '@rsdoctor/types';
2
+ import type { Range as RangeClass } from 'monaco-editor';
3
+ export declare function getOriginalLanguage(filepath: string): string;
4
+ export declare function getModifiedLanguage(filepath: string): string;
5
+ export declare function getRevealPositionForViewer(startLineNumber: number, startColumn: number): {
6
+ lineNumber: number;
7
+ column: number;
8
+ };
9
+ export declare function getSelectionRange(source: SDK.SourceRange, Range: typeof RangeClass): RangeClass;
10
+ export declare function useMonacoEditor(): {
11
+ initMonaco: (monacoRef: any) => Promise<void>;
12
+ };
@@ -0,0 +1,71 @@
1
+ import { extname } from "path";
2
+ import { loader } from "@monaco-editor/react";
3
+ import { isJsDataUrl } from "./url";
4
+ const monacoLoader = loader.init();
5
+ function getOriginalLanguage(filepath) {
6
+ if (isJsDataUrl(filepath)) {
7
+ return "javascript";
8
+ }
9
+ const ext = extname(filepath).slice(1);
10
+ switch (ext) {
11
+ case "js":
12
+ case "jsx":
13
+ return "javascript";
14
+ case "ts":
15
+ case "tsx":
16
+ return "typescript";
17
+ default:
18
+ return ext;
19
+ }
20
+ }
21
+ function getModifiedLanguage(filepath) {
22
+ const ext = extname(filepath).slice(1);
23
+ switch (ext) {
24
+ case "js":
25
+ case "jsx":
26
+ case "ts":
27
+ case "tsx":
28
+ return "javascript";
29
+ default:
30
+ return ext;
31
+ }
32
+ }
33
+ function getRevealPositionForViewer(startLineNumber, startColumn) {
34
+ return {
35
+ lineNumber: Math.floor(startLineNumber / 1.2) || 1,
36
+ column: Math.floor(startColumn / 1.5) || 1
37
+ };
38
+ }
39
+ function getSelectionRange(source, Range) {
40
+ const { start, end } = source;
41
+ const { line = 1, column = 0 } = start;
42
+ return new Range(line, column + 1, end?.line ?? line, (end?.column ?? 9999) + 1);
43
+ }
44
+ const initMonaco = (monacoRef) => {
45
+ return new Promise((resolve, reject) => {
46
+ if (monacoRef.value) {
47
+ resolve();
48
+ return;
49
+ }
50
+ monacoLoader.then((monacoInstance) => {
51
+ monacoRef.value = monacoInstance;
52
+ }).catch((error) => {
53
+ if (error?.type !== "cancelation") {
54
+ console.error("Monaco initialization error:", error);
55
+ reject();
56
+ }
57
+ });
58
+ });
59
+ };
60
+ function useMonacoEditor() {
61
+ return {
62
+ initMonaco
63
+ };
64
+ }
65
+ export {
66
+ getModifiedLanguage,
67
+ getOriginalLanguage,
68
+ getRevealPositionForViewer,
69
+ getSelectionRange,
70
+ useMonacoEditor
71
+ };
@@ -0,0 +1,27 @@
1
+ import { Manifest, SDK } from '@rsdoctor/types';
2
+ export declare function fetchShardingFile(url: string): Promise<string>;
3
+ export declare function loadManifestByUrl(url: string): Promise<{
4
+ data: Manifest.RsdoctorManifestData;
5
+ cloudData?: Record<keyof Manifest.RsdoctorManifestData, string | string[]> | undefined;
6
+ __LOCAL__SERVER__?: boolean | undefined;
7
+ __SOCKET__URL__?: string | undefined;
8
+ client: Manifest.RsdoctorManifestClient;
9
+ cloudManifestUrl?: string | undefined;
10
+ name?: string | undefined;
11
+ series?: Manifest.RsdoctorManifestSeriesData[] | undefined;
12
+ }>;
13
+ export declare function fetchJSONByUrl(url: string): Promise<Manifest.RsdoctorManifestWithShardingFiles>;
14
+ export declare function fetchJSONByUrls(urls: string[]): Promise<Manifest.RsdoctorManifestWithShardingFiles[]>;
15
+ export declare function parseManifest(json: Manifest.RsdoctorManifestWithShardingFiles): Promise<{
16
+ data: Manifest.RsdoctorManifestData;
17
+ cloudData?: Record<keyof Manifest.RsdoctorManifestData, string | string[]> | undefined;
18
+ __LOCAL__SERVER__?: boolean | undefined;
19
+ __SOCKET__URL__?: string | undefined;
20
+ client: Manifest.RsdoctorManifestClient;
21
+ cloudManifestUrl?: string | undefined;
22
+ name?: string | undefined;
23
+ series?: Manifest.RsdoctorManifestSeriesData[] | undefined;
24
+ }>;
25
+ export declare function getManifestUrl(): string;
26
+ export declare function fetchManifest(url?: string): Promise<Manifest.RsdoctorManifestWithShardingFiles>;
27
+ export declare function postServerAPI<T extends SDK.ServerAPI.API, B extends SDK.ServerAPI.InferRequestBodyType<T> = SDK.ServerAPI.InferRequestBodyType<T>, R extends SDK.ServerAPI.InferResponseType<T> = SDK.ServerAPI.InferResponseType<T>>(...args: B extends void ? [api: T] : [api: T, body: B]): Promise<R>;