@rsdoctor/components 0.0.2-beta.0

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 (276) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/assets/connection-point.3b3c78ca.svg +1 -0
  4. package/dist/assets/icon.7509d763.svg +21 -0
  5. package/dist/assets/webpack.98604d64.svg +1 -0
  6. package/dist/components/Alert/change.d.ts +8 -0
  7. package/dist/components/Alert/change.js +94 -0
  8. package/dist/components/Alert/file-relation.d.ts +3 -0
  9. package/dist/components/Alert/file-relation.js +9 -0
  10. package/dist/components/Alert/index.css +29 -0
  11. package/dist/components/Alert/index.d.ts +4 -0
  12. package/dist/components/Alert/index.js +37 -0
  13. package/dist/components/Alert/link.d.ts +3 -0
  14. package/dist/components/Alert/link.js +27 -0
  15. package/dist/components/Alert/package-relation.d.ts +17 -0
  16. package/dist/components/Alert/package-relation.js +206 -0
  17. package/dist/components/Alert/types.d.ts +31 -0
  18. package/dist/components/Alert/types.js +0 -0
  19. package/dist/components/Alert/view.d.ts +4 -0
  20. package/dist/components/Alert/view.js +59 -0
  21. package/dist/components/Alerts/bundle.d.ts +11 -0
  22. package/dist/components/Alerts/bundle.js +47 -0
  23. package/dist/components/Alerts/common.d.ts +15 -0
  24. package/dist/components/Alerts/common.js +106 -0
  25. package/dist/components/Alerts/compile.d.ts +10 -0
  26. package/dist/components/Alerts/compile.js +46 -0
  27. package/dist/components/Alerts/index.d.ts +3 -0
  28. package/dist/components/Alerts/index.js +3 -0
  29. package/dist/components/Alerts/overlay.d.ts +26 -0
  30. package/dist/components/Alerts/overlay.js +154 -0
  31. package/dist/components/Badge/index.d.ts +21 -0
  32. package/dist/components/Badge/index.js +105 -0
  33. package/dist/components/Card/diff.d.ts +23 -0
  34. package/dist/components/Card/diff.js +131 -0
  35. package/dist/components/Card/index.d.ts +7 -0
  36. package/dist/components/Card/index.js +62 -0
  37. package/dist/components/Card/size.d.ts +16 -0
  38. package/dist/components/Card/size.js +71 -0
  39. package/dist/components/Card/statistic.css +16 -0
  40. package/dist/components/Card/statistic.d.ts +9 -0
  41. package/dist/components/Card/statistic.js +34 -0
  42. package/dist/components/Charts/TimelineCharts/index.d.ts +8 -0
  43. package/dist/components/Charts/TimelineCharts/index.js +197 -0
  44. package/dist/components/Charts/bootstrap.d.ts +5 -0
  45. package/dist/components/Charts/bootstrap.js +44 -0
  46. package/dist/components/Charts/common.d.ts +13 -0
  47. package/dist/components/Charts/common.js +56 -0
  48. package/dist/components/Charts/done.d.ts +5 -0
  49. package/dist/components/Charts/done.js +45 -0
  50. package/dist/components/Charts/index.d.ts +10 -0
  51. package/dist/components/Charts/index.js +37 -0
  52. package/dist/components/Charts/loader.css +31 -0
  53. package/dist/components/Charts/loader.d.ts +4 -0
  54. package/dist/components/Charts/loader.js +68 -0
  55. package/dist/components/Charts/minify.d.ts +5 -0
  56. package/dist/components/Charts/minify.js +37 -0
  57. package/dist/components/Charts/tooltips.css +62 -0
  58. package/dist/components/Charts/types.d.ts +61 -0
  59. package/dist/components/Charts/types.js +11 -0
  60. package/dist/components/Charts/utils.d.ts +13 -0
  61. package/dist/components/Charts/utils.js +203 -0
  62. package/dist/components/CodeViewer/config.d.ts +2 -0
  63. package/dist/components/CodeViewer/config.js +18 -0
  64. package/dist/components/CodeViewer/diff.d.ts +11 -0
  65. package/dist/components/CodeViewer/diff.js +53 -0
  66. package/dist/components/CodeViewer/hightlight.d.ts +10 -0
  67. package/dist/components/CodeViewer/hightlight.js +76 -0
  68. package/dist/components/CodeViewer/index.d.ts +4 -0
  69. package/dist/components/CodeViewer/index.js +4 -0
  70. package/dist/components/CodeViewer/viewer.d.ts +13 -0
  71. package/dist/components/CodeViewer/viewer.js +76 -0
  72. package/dist/components/Configuration/index.d.ts +1 -0
  73. package/dist/components/Configuration/index.js +1 -0
  74. package/dist/components/Configuration/webpack.d.ts +13 -0
  75. package/dist/components/Configuration/webpack.js +70 -0
  76. package/dist/components/FileTree/index.css +58 -0
  77. package/dist/components/FileTree/index.d.ts +4 -0
  78. package/dist/components/FileTree/index.js +53 -0
  79. package/dist/components/Form/keyword.d.ts +14 -0
  80. package/dist/components/Form/keyword.js +76 -0
  81. package/dist/components/Keyword/index.d.ts +6 -0
  82. package/dist/components/Keyword/index.js +68 -0
  83. package/dist/components/Layout/builder-select.d.ts +2 -0
  84. package/dist/components/Layout/builder-select.js +50 -0
  85. package/dist/components/Layout/constants.d.ts +1 -0
  86. package/dist/components/Layout/constants.js +4 -0
  87. package/dist/components/Layout/header.css +12 -0
  88. package/dist/components/Layout/header.d.ts +3 -0
  89. package/dist/components/Layout/header.js +87 -0
  90. package/dist/components/Layout/index.d.ts +5 -0
  91. package/dist/components/Layout/index.js +34 -0
  92. package/dist/components/Layout/menus.d.ts +8 -0
  93. package/dist/components/Layout/menus.js +155 -0
  94. package/dist/components/Layout/progress.d.ts +8 -0
  95. package/dist/components/Layout/progress.js +44 -0
  96. package/dist/components/Loader/Analysis/files.d.ts +8 -0
  97. package/dist/components/Loader/Analysis/files.js +187 -0
  98. package/dist/components/Loader/Analysis/index.d.ts +11 -0
  99. package/dist/components/Loader/Analysis/index.js +23 -0
  100. package/dist/components/Loader/executions.d.ts +13 -0
  101. package/dist/components/Loader/executions.js +221 -0
  102. package/dist/components/Manifest/api.d.ts +41 -0
  103. package/dist/components/Manifest/api.js +157 -0
  104. package/dist/components/Manifest/data.d.ts +8 -0
  105. package/dist/components/Manifest/data.js +81 -0
  106. package/dist/components/Manifest/index.d.ts +2 -0
  107. package/dist/components/Manifest/index.js +2 -0
  108. package/dist/components/Opener/code.d.ts +28 -0
  109. package/dist/components/Opener/code.js +69 -0
  110. package/dist/components/Opener/index.d.ts +2 -0
  111. package/dist/components/Opener/index.js +2 -0
  112. package/dist/components/Opener/vscode.d.ts +16 -0
  113. package/dist/components/Opener/vscode.js +57 -0
  114. package/dist/components/Overall/NumberButton.d.ts +14 -0
  115. package/dist/components/Overall/NumberButton.js +29 -0
  116. package/dist/components/Overall/NumberButton.module.js +5 -0
  117. package/dist/components/Overall/NumberButton_module.css +70 -0
  118. package/dist/components/Overall/bundle.d.ts +6 -0
  119. package/dist/components/Overall/bundle.js +167 -0
  120. package/dist/components/Overall/bundle.module.css +0 -0
  121. package/dist/components/Overall/card.module.js +5 -0
  122. package/dist/components/Overall/card_module.css +6 -0
  123. package/dist/components/Overall/compile.d.ts +5 -0
  124. package/dist/components/Overall/compile.js +68 -0
  125. package/dist/components/Overall/compile.module.js +5 -0
  126. package/dist/components/Overall/compile_module.css +4 -0
  127. package/dist/components/Overall/index.d.ts +3 -0
  128. package/dist/components/Overall/index.js +3 -0
  129. package/dist/components/Overall/list.module.js +5 -0
  130. package/dist/components/Overall/list_module.css +7 -0
  131. package/dist/components/Overall/project.d.ts +8 -0
  132. package/dist/components/Overall/project.js +73 -0
  133. package/dist/components/Plugins/webpack.d.ts +18 -0
  134. package/dist/components/Plugins/webpack.js +76 -0
  135. package/dist/components/Resolver/analysis.d.ts +15 -0
  136. package/dist/components/Resolver/analysis.js +160 -0
  137. package/dist/components/Select/index.d.ts +15 -0
  138. package/dist/components/Select/index.js +68 -0
  139. package/dist/components/Status/failed.d.ts +9 -0
  140. package/dist/components/Status/failed.js +33 -0
  141. package/dist/components/Status/index.d.ts +1 -0
  142. package/dist/components/Status/index.js +1 -0
  143. package/dist/components/TextDrawer/duplicate.d.ts +17 -0
  144. package/dist/components/TextDrawer/duplicate.js +107 -0
  145. package/dist/components/TextDrawer/index.d.ts +11 -0
  146. package/dist/components/TextDrawer/index.js +55 -0
  147. package/dist/components/Title/index.d.ts +15 -0
  148. package/dist/components/Title/index.js +10 -0
  149. package/dist/components/index.d.ts +8 -0
  150. package/dist/components/index.js +11 -0
  151. package/dist/components/worker/ecmaversion/client.d.ts +10 -0
  152. package/dist/components/worker/ecmaversion/client.js +61 -0
  153. package/dist/components/worker/ecmaversion/worker.d.ts +1 -0
  154. package/dist/components/worker/ecmaversion/worker.js +13 -0
  155. package/dist/components/worker/jsequal/client.d.ts +11 -0
  156. package/dist/components/worker/jsequal/client.js +39 -0
  157. package/dist/components/worker/jsequal/worker.d.ts +1 -0
  158. package/dist/components/worker/jsequal/worker.js +52 -0
  159. package/dist/config.d.ts +19 -0
  160. package/dist/config.js +39 -0
  161. package/dist/constants.d.ts +48 -0
  162. package/dist/constants.js +71 -0
  163. package/dist/index.d.ts +3 -0
  164. package/dist/index.js +6 -0
  165. package/dist/pages/BundleSize/components/asset.d.ts +26 -0
  166. package/dist/pages/BundleSize/components/asset.js +405 -0
  167. package/dist/pages/BundleSize/components/cards.d.ts +7 -0
  168. package/dist/pages/BundleSize/components/cards.js +154 -0
  169. package/dist/pages/BundleSize/components/editor.d.ts +5 -0
  170. package/dist/pages/BundleSize/components/editor.js +38 -0
  171. package/dist/pages/BundleSize/components/index.css +20 -0
  172. package/dist/pages/BundleSize/components/index.d.ts +16 -0
  173. package/dist/pages/BundleSize/components/index.js +314 -0
  174. package/dist/pages/BundleSize/config.d.ts +7 -0
  175. package/dist/pages/BundleSize/config.js +9 -0
  176. package/dist/pages/BundleSize/constants.d.ts +5 -0
  177. package/dist/pages/BundleSize/constants.js +9 -0
  178. package/dist/pages/BundleSize/index.d.ts +3 -0
  179. package/dist/pages/BundleSize/index.js +11 -0
  180. package/dist/pages/ModuleAnalyze/chunks.d.ts +6 -0
  181. package/dist/pages/ModuleAnalyze/chunks.js +48 -0
  182. package/dist/pages/ModuleAnalyze/components/fileTreeCom.css +88 -0
  183. package/dist/pages/ModuleAnalyze/components/fileTreeCom.d.ts +15 -0
  184. package/dist/pages/ModuleAnalyze/components/fileTreeCom.js +138 -0
  185. package/dist/pages/ModuleAnalyze/constants.d.ts +7 -0
  186. package/dist/pages/ModuleAnalyze/constants.js +14 -0
  187. package/dist/pages/ModuleAnalyze/dependncy.d.ts +9 -0
  188. package/dist/pages/ModuleAnalyze/dependncy.js +31 -0
  189. package/dist/pages/ModuleAnalyze/fileTree.d.ts +9 -0
  190. package/dist/pages/ModuleAnalyze/fileTree.js +125 -0
  191. package/dist/pages/ModuleAnalyze/index.css +10 -0
  192. package/dist/pages/ModuleAnalyze/index.d.ts +8 -0
  193. package/dist/pages/ModuleAnalyze/index.js +64 -0
  194. package/dist/pages/ModuleAnalyze/utils/hooks.d.ts +21 -0
  195. package/dist/pages/ModuleAnalyze/utils/hooks.js +65 -0
  196. package/dist/pages/ModuleAnalyze/utils/index.d.ts +3 -0
  197. package/dist/pages/ModuleAnalyze/utils/index.js +36 -0
  198. package/dist/pages/ModuleResolve/constants.d.ts +3 -0
  199. package/dist/pages/ModuleResolve/constants.js +7 -0
  200. package/dist/pages/ModuleResolve/index.d.ts +3 -0
  201. package/dist/pages/ModuleResolve/index.js +19 -0
  202. package/dist/pages/Overall/constants.d.ts +3 -0
  203. package/dist/pages/Overall/constants.js +7 -0
  204. package/dist/pages/Overall/index.d.ts +9 -0
  205. package/dist/pages/Overall/index.js +28 -0
  206. package/dist/pages/WebpackLoaders/Analysis/constants.d.ts +3 -0
  207. package/dist/pages/WebpackLoaders/Analysis/constants.js +7 -0
  208. package/dist/pages/WebpackLoaders/Analysis/index.d.ts +3 -0
  209. package/dist/pages/WebpackLoaders/Analysis/index.js +19 -0
  210. package/dist/pages/WebpackLoaders/Overall/constants.d.ts +3 -0
  211. package/dist/pages/WebpackLoaders/Overall/constants.js +7 -0
  212. package/dist/pages/WebpackLoaders/Overall/index.d.ts +3 -0
  213. package/dist/pages/WebpackLoaders/Overall/index.js +11 -0
  214. package/dist/pages/WebpackLoaders/constants.d.ts +2 -0
  215. package/dist/pages/WebpackLoaders/constants.js +6 -0
  216. package/dist/pages/WebpackPlugins/constants.d.ts +3 -0
  217. package/dist/pages/WebpackPlugins/constants.js +7 -0
  218. package/dist/pages/WebpackPlugins/index.d.ts +3 -0
  219. package/dist/pages/WebpackPlugins/index.js +79 -0
  220. package/dist/pages/index.d.ts +7 -0
  221. package/dist/pages/index.js +16 -0
  222. package/dist/utils/data/base.d.ts +24 -0
  223. package/dist/utils/data/base.js +70 -0
  224. package/dist/utils/data/index.d.ts +5 -0
  225. package/dist/utils/data/index.js +66 -0
  226. package/dist/utils/data/local.d.ts +14 -0
  227. package/dist/utils/data/local.js +106 -0
  228. package/dist/utils/data/remote.d.ts +10 -0
  229. package/dist/utils/data/remote.js +70 -0
  230. package/dist/utils/file.d.ts +39 -0
  231. package/dist/utils/file.js +154 -0
  232. package/dist/utils/hooks.d.ts +30 -0
  233. package/dist/utils/hooks.js +256 -0
  234. package/dist/utils/i18n/cn.d.ts +3 -0
  235. package/dist/utils/i18n/cn.js +33 -0
  236. package/dist/utils/i18n/en.d.ts +30 -0
  237. package/dist/utils/i18n/en.js +33 -0
  238. package/dist/utils/i18n/index.d.ts +2 -0
  239. package/dist/utils/i18n/index.js +34 -0
  240. package/dist/utils/index.d.ts +16 -0
  241. package/dist/utils/index.js +16 -0
  242. package/dist/utils/loader.d.ts +7 -0
  243. package/dist/utils/loader.js +29 -0
  244. package/dist/utils/locale.d.ts +2 -0
  245. package/dist/utils/locale.js +9 -0
  246. package/dist/utils/manifest.d.ts +27 -0
  247. package/dist/utils/manifest.js +54 -0
  248. package/dist/utils/monaco.d.ts +9 -0
  249. package/dist/utils/monaco.js +48 -0
  250. package/dist/utils/request.d.ts +23 -0
  251. package/dist/utils/request.js +162 -0
  252. package/dist/utils/routes.d.ts +3 -0
  253. package/dist/utils/routes.js +14 -0
  254. package/dist/utils/size.d.ts +2 -0
  255. package/dist/utils/size.js +24 -0
  256. package/dist/utils/socket.d.ts +2 -0
  257. package/dist/utils/socket.js +20 -0
  258. package/dist/utils/storage.d.ts +13 -0
  259. package/dist/utils/storage.js +70 -0
  260. package/dist/utils/string.d.ts +2 -0
  261. package/dist/utils/string.js +14 -0
  262. package/dist/utils/time.d.ts +3 -0
  263. package/dist/utils/time.js +7 -0
  264. package/dist/utils/url.d.ts +6 -0
  265. package/dist/utils/url.js +89 -0
  266. package/dist/utils/worker/index.d.ts +4 -0
  267. package/dist/utils/worker/index.js +4 -0
  268. package/dist/utils/worker/master.d.ts +8 -0
  269. package/dist/utils/worker/master.js +18 -0
  270. package/dist/utils/worker/types.d.ts +9 -0
  271. package/dist/utils/worker/types.js +0 -0
  272. package/dist/utils/worker/utils.d.ts +9 -0
  273. package/dist/utils/worker/utils.js +29 -0
  274. package/dist/utils/worker/worker.d.ts +13 -0
  275. package/dist/utils/worker/worker.js +38 -0
  276. package/package.json +87 -0
@@ -0,0 +1,38 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { LoadingOutlined } from "@ant-design/icons";
3
+ import Editor from "@monaco-editor/react";
4
+ import { Card } from "antd";
5
+ import { getOriginalLanguage, getShortPath } from "../../../utils";
6
+ function CodeEditor(props) {
7
+ const { content, path } = props;
8
+ if (!content) {
9
+ return /* @__PURE__ */ jsx("div", { children: "No Code~" });
10
+ }
11
+ return /* @__PURE__ */ jsx(Card, { title: getShortPath(path), className: "bundle-size-editor", style: { height: "90%" }, children: /* @__PURE__ */ jsx(
12
+ Editor,
13
+ {
14
+ theme: "vs-dark",
15
+ language: getOriginalLanguage(path),
16
+ value: content,
17
+ loading: /* @__PURE__ */ jsx(LoadingOutlined, { style: { fontSize: 30, height: "8em" } }),
18
+ options: {
19
+ readOnly: true,
20
+ domReadOnly: true,
21
+ fontSize: 12,
22
+ renderValidationDecorations: "off",
23
+ hideCursorInOverviewRuler: true,
24
+ smoothScrolling: true,
25
+ wordWrap: "bounded",
26
+ colorDecorators: true,
27
+ codeLens: false,
28
+ cursorWidth: 0,
29
+ minimap: {
30
+ enabled: false
31
+ }
32
+ }
33
+ }
34
+ ) });
35
+ }
36
+ export {
37
+ CodeEditor
38
+ };
@@ -0,0 +1,20 @@
1
+ .monaco-hover .markdown-hover.hover-row hr {
2
+ margin: 2px;
3
+ background-color: gray;
4
+ }
5
+ .bundle-size-editor {
6
+ margin-left: 40px;
7
+ flex-grow: 1;
8
+ height: 700px;
9
+ }
10
+ .bundle-size-editor .ant-card-body {
11
+ width: auto;
12
+ height: calc(100% - 48px);
13
+ padding: 0;
14
+ }
15
+ .bundle-size-module-bunton {
16
+ margin-left: 4em;
17
+ }
18
+ .ant-tabs-nav {
19
+ width: 100%;
20
+ }
@@ -0,0 +1,16 @@
1
+ import { Client, SDK } from '@rsdoctor/types';
2
+ import React from 'react';
3
+ import './index.sass';
4
+ interface WebpackModulesOverallProps {
5
+ cwd: string;
6
+ errors: SDK.ErrorsData;
7
+ summary: Client.DoctorClientAssetsSummary;
8
+ entryPoints: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetEntryPoints>;
9
+ }
10
+ export declare const WebpackModulesOverallBase: React.FC<WebpackModulesOverallProps>;
11
+ export declare const WebpackModulesOverall: React.FC<Omit<{
12
+ project: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetProjectInfo>;
13
+ }, "project"> & Partial<{
14
+ body?: any;
15
+ }>>;
16
+ export {};
@@ -0,0 +1,314 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { ColumnHeightOutlined, InfoCircleOutlined, VerticalAlignMiddleOutlined } from "@ant-design/icons";
3
+ import { SDK } from "@rsdoctor/types";
4
+ import {
5
+ Button,
6
+ Card,
7
+ Col,
8
+ Divider,
9
+ Empty,
10
+ InputNumber,
11
+ Radio,
12
+ Row,
13
+ Select,
14
+ Space,
15
+ Tag,
16
+ Tooltip,
17
+ Typography
18
+ } from "antd";
19
+ import { debounce, includes, sumBy } from "lodash-es";
20
+ import React, { useCallback, useMemo, useState } from "react";
21
+ import { ServerAPIProvider, withServerAPI } from "../../../components/Manifest";
22
+ import { Badge as Bdg } from "../../../components/Badge";
23
+ import { FileTree } from "../../../components/FileTree";
24
+ import { KeywordInput } from "../../../components/Form/keyword";
25
+ import { Keyword } from "../../../components/Keyword";
26
+ import { Title } from "../../../components/Title";
27
+ import { Size } from "../../../constants";
28
+ import { createFileStructures, formatSize, useI18n } from "../../../utils";
29
+ import { BundleCards } from "./cards";
30
+ import { CodeViewerWithDrawer } from "../../../components/CodeViewer";
31
+ import { AssetDetail } from "./asset";
32
+ import "./index.css";
33
+ const { Option } = Select;
34
+ const cardBodyHeight = 410;
35
+ const largeCardBodyHeight = 800;
36
+ const WebpackModulesOverallBase = ({
37
+ errors,
38
+ cwd,
39
+ summary,
40
+ entryPoints
41
+ }) => {
42
+ const [selectedEntryPoints, setEntryPoints] = useState([]);
43
+ const [inputModule, setModuleValue] = useState(0);
44
+ const [inputAssetName, setAssetName] = useState("");
45
+ const [inputAssetSize, setAssetSize] = useState(0);
46
+ const [defaultExpandAll, setDefaultExpandAll] = useState(false);
47
+ const [inputModuleUnit, setModuleUnit] = useState("");
48
+ const [inputChunkUnit, setChunkUnit] = useState("");
49
+ const [assetPath, setAssetPath] = useState(null);
50
+ const [fold, setFold] = useState(false);
51
+ const [graphType, setGraphType] = useState("tree");
52
+ const { t } = useI18n();
53
+ const assets = summary.all.total.files;
54
+ const avgAssetSize = summary.all.total.size / assets.length;
55
+ const handleChange = useCallback(
56
+ (type) => (value) => {
57
+ if (type === "module") {
58
+ setModuleUnit(value);
59
+ } else if (type === "chunk") {
60
+ setChunkUnit(value);
61
+ }
62
+ },
63
+ []
64
+ );
65
+ const selectAfter = (type) => /* @__PURE__ */ jsxs(Select, { defaultValue: "kb", onChange: handleChange(type), children: [
66
+ /* @__PURE__ */ jsx(Option, { value: "kb", children: "KB" }),
67
+ /* @__PURE__ */ jsx(Option, { value: "mb", children: "MB" })
68
+ ] });
69
+ const onChangeModule = useCallback(
70
+ debounce((newValue) => {
71
+ const count = inputModuleUnit === "mb" ? newValue * 1024 * 1024 : newValue * 1024;
72
+ setModuleValue(count);
73
+ }, 300),
74
+ []
75
+ );
76
+ const onChangeAsset = useCallback(
77
+ debounce((newValue) => {
78
+ const count = inputChunkUnit === "mb" ? newValue * 1024 * 1024 : newValue * 1024;
79
+ setAssetSize(count);
80
+ }, 300),
81
+ []
82
+ );
83
+ const filteredAssets = useMemo(() => {
84
+ let res = assets.slice();
85
+ if (inputAssetName) {
86
+ res = res.filter((e) => e.path.indexOf(inputAssetName) > -1);
87
+ }
88
+ if (inputAssetSize > 0) {
89
+ res = res.filter((e) => e.size >= inputAssetSize);
90
+ }
91
+ if (selectedEntryPoints.length) {
92
+ res = res.filter((e) => {
93
+ if (selectedEntryPoints.some((ep) => includes(ep.assets, e.path))) {
94
+ return true;
95
+ }
96
+ return false;
97
+ });
98
+ }
99
+ return res.sort((a, b) => {
100
+ const _a = a.path.indexOf("/") > -1 ? 1 : 0;
101
+ const _b = b.path.indexOf("/") > -1 ? 1 : 0;
102
+ return _b - _a;
103
+ });
104
+ }, [assets, selectedEntryPoints, inputAssetName, inputAssetSize]);
105
+ const assetsStructures = useMemo(() => {
106
+ const res = createFileStructures({
107
+ files: filteredAssets.map((e) => e.path).filter(Boolean),
108
+ fileTitle(file, basename) {
109
+ const target = filteredAssets.find((e) => e.path === file);
110
+ const { size, initial, path, content } = target;
111
+ return /* @__PURE__ */ jsxs(
112
+ Space,
113
+ {
114
+ onClick: () => {
115
+ setAssetPath(path);
116
+ },
117
+ children: [
118
+ /* @__PURE__ */ jsx(Keyword, { text: basename, keyword: inputAssetName }),
119
+ /* @__PURE__ */ jsx(Bdg, { label: "size", value: formatSize(size), type: size >= avgAssetSize ? "error" : "default" }),
120
+ initial ? /* @__PURE__ */ jsx(Tag, { color: "cyan", style: { marginRight: 0 }, children: "initial" }) : null,
121
+ /* @__PURE__ */ jsx(
122
+ CodeViewerWithDrawer,
123
+ {
124
+ path,
125
+ content,
126
+ editorConfig: { readOnly: false, domReadOnly: false }
127
+ }
128
+ )
129
+ ]
130
+ }
131
+ );
132
+ }
133
+ });
134
+ return res;
135
+ }, [filteredAssets]);
136
+ const onSearch = (value) => {
137
+ setAssetName(value);
138
+ setDefaultExpandAll(false);
139
+ };
140
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
141
+ /* @__PURE__ */ jsx(BundleCards, { cwd, errors, summary }),
142
+ /* @__PURE__ */ jsxs(
143
+ Radio.Group,
144
+ {
145
+ value: graphType,
146
+ onChange: (e) => setGraphType(e.target.value),
147
+ style: { marginBottom: Size.BasePadding },
148
+ buttonStyle: "solid",
149
+ optionType: "button",
150
+ children: [
151
+ /* @__PURE__ */ jsx(Radio.Button, { value: "tree", children: "Tree Graph" }),
152
+ /* @__PURE__ */ jsx(Radio.Button, { value: "tile", children: "Bundle Analyzer Graph" })
153
+ ]
154
+ }
155
+ ),
156
+ /* @__PURE__ */ jsx(
157
+ Card,
158
+ {
159
+ hidden: graphType === "tree",
160
+ title: /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsx(Title, { text: "From: Webpack Bundle Analyzer" }) }),
161
+ children: /* @__PURE__ */ jsx(ServerAPIProvider, { api: SDK.ServerAPI.API.GetTileReportHtml, body: {}, children: (data) => {
162
+ if (data && graphType === "tile") {
163
+ return /* @__PURE__ */ jsx("iframe", { srcDoc: data, width: "100%", height: largeCardBodyHeight, style: { border: "none" } });
164
+ }
165
+ return /* @__PURE__ */ jsx(Empty, {});
166
+ } })
167
+ }
168
+ ),
169
+ /* @__PURE__ */ jsx(
170
+ Card,
171
+ {
172
+ hidden: graphType === "tile",
173
+ title: /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsx(Title, { text: "Bundle Analysis" }) }),
174
+ extra: fold ? /* @__PURE__ */ jsx(Button, { onClick: () => setFold(false), children: /* @__PURE__ */ jsxs(Typography.Text, { children: [
175
+ "Expand ",
176
+ /* @__PURE__ */ jsx(ColumnHeightOutlined, {})
177
+ ] }) }) : /* @__PURE__ */ jsx(Button, { onClick: () => setFold(true), children: /* @__PURE__ */ jsxs(Typography.Text, { children: [
178
+ "Fold",
179
+ /* @__PURE__ */ jsx(VerticalAlignMiddleOutlined, {})
180
+ ] }) }),
181
+ children: /* @__PURE__ */ jsxs(Row, { align: "middle", gutter: [Size.BasePadding, Size.BasePadding], children: [
182
+ entryPoints && entryPoints.length ? /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(
183
+ Select,
184
+ {
185
+ mode: "multiple",
186
+ value: selectedEntryPoints.map((e) => e.name),
187
+ style: { minWidth: 230, width: "auto", maxWidth: 300 },
188
+ placeholder: "filter assets by entry point",
189
+ onChange: (name) => {
190
+ setEntryPoints(name.map((e) => entryPoints.find((ep) => ep.name === e)).filter(Boolean));
191
+ },
192
+ allowClear: true,
193
+ onClear: () => {
194
+ setEntryPoints([]);
195
+ },
196
+ children: entryPoints.map((e) => {
197
+ return /* @__PURE__ */ jsx(Select.Option, { value: e.name, children: /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsx(Bdg, { label: e.name, value: formatSize(e.size), tooltip: e.name }) }) }, e.name);
198
+ })
199
+ }
200
+ ) }) : null,
201
+ /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(KeywordInput, { placeholder: "search asset by keyword", onChange: onSearch }) }),
202
+ /* @__PURE__ */ jsx(Col, { span: 7, children: /* @__PURE__ */ jsx(
203
+ InputNumber,
204
+ {
205
+ min: 0,
206
+ style: { width: "95%" },
207
+ addonBefore: /* @__PURE__ */ jsxs(Space, { children: [
208
+ /* @__PURE__ */ jsx(Typography.Text, { style: { fontSize: 14, color: "inherit" }, children: "Asset Size" }),
209
+ /* @__PURE__ */ jsx(
210
+ Tooltip,
211
+ {
212
+ title: t("filter the output assets which size is greater than the input value"),
213
+ style: { marginLeft: 3 },
214
+ children: /* @__PURE__ */ jsx(InfoCircleOutlined, { style: { color: "rgba(0,0,0,.45)" } })
215
+ }
216
+ )
217
+ ] }),
218
+ onChange: (value) => onChangeAsset(Number(value)),
219
+ addonAfter: selectAfter("chunk")
220
+ }
221
+ ) }),
222
+ /* @__PURE__ */ jsx(Col, { span: 7, children: /* @__PURE__ */ jsx(
223
+ InputNumber,
224
+ {
225
+ min: 0,
226
+ style: { width: "95%" },
227
+ addonBefore: /* @__PURE__ */ jsxs(Space, { children: [
228
+ /* @__PURE__ */ jsx(Typography.Text, { style: { fontSize: 14, color: "inherit" }, children: "Module Size" }),
229
+ /* @__PURE__ */ jsx(
230
+ Tooltip,
231
+ {
232
+ title: t("filter the modules which size is greater than the input value"),
233
+ style: { marginLeft: 3 },
234
+ children: /* @__PURE__ */ jsx(InfoCircleOutlined, { style: { color: "rgba(0,0,0,.45)" } })
235
+ }
236
+ )
237
+ ] }),
238
+ onChange: (value) => {
239
+ onChangeModule(Number(value));
240
+ },
241
+ addonAfter: selectAfter("module")
242
+ }
243
+ ) }),
244
+ /* @__PURE__ */ jsx(Col, { span: 24, children: filteredAssets.length ? /* @__PURE__ */ jsxs(Row, { gutter: Size.BasePadding, children: [
245
+ /* @__PURE__ */ jsx(Col, { span: 8, children: /* @__PURE__ */ jsx(
246
+ Card,
247
+ {
248
+ title: /* @__PURE__ */ jsxs(Space, { children: [
249
+ /* @__PURE__ */ jsx(Typography.Text, { children: t("Output Assets List") }),
250
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
251
+ /* @__PURE__ */ jsx(
252
+ Tooltip,
253
+ {
254
+ title: `total assets count is ${assets.length}, the filtered assets count is ${filteredAssets.length}`,
255
+ children: /* @__PURE__ */ jsxs(Typography.Text, { type: "secondary", style: { fontSize: 12, fontWeight: 400 }, children: [
256
+ filteredAssets.length,
257
+ " / ",
258
+ assets.length
259
+ ] })
260
+ }
261
+ ),
262
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
263
+ /* @__PURE__ */ jsx(Typography.Text, { type: "secondary", style: { fontSize: 12, fontWeight: 400 }, children: formatSize(sumBy(filteredAssets, (e) => e.size)) })
264
+ ] }),
265
+ size: "small",
266
+ bodyStyle: { overflow: "scroll", height: fold ? cardBodyHeight : largeCardBodyHeight },
267
+ extra: /* @__PURE__ */ jsx(Button, { size: "small", icon: /* @__PURE__ */ jsx(ColumnHeightOutlined, {}), onClick: () => setDefaultExpandAll(true), children: "expand all" }),
268
+ children: /* @__PURE__ */ jsx(
269
+ FileTree,
270
+ {
271
+ treeData: assetsStructures,
272
+ autoExpandParent: true,
273
+ defaultExpandAll: defaultExpandAll || filteredAssets.length <= 20
274
+ },
275
+ `tree_${inputAssetName}_${defaultExpandAll}`
276
+ )
277
+ }
278
+ ) }),
279
+ /* @__PURE__ */ jsx(Col, { span: 16, children: assetPath ? /* @__PURE__ */ jsx(ServerAPIProvider, { api: SDK.ServerAPI.API.GetAssetDetails, body: { assetPath }, children: (details) => /* @__PURE__ */ jsx(
280
+ AssetDetail,
281
+ {
282
+ asset: details.asset,
283
+ chunks: details.chunks,
284
+ modules: details.modules,
285
+ height: fold ? cardBodyHeight : largeCardBodyHeight,
286
+ moduleSizeLimit: inputModule,
287
+ root: cwd
288
+ }
289
+ ) }) : /* @__PURE__ */ jsx(Card, { bodyStyle: { height: fold ? cardBodyHeight + 40 : largeCardBodyHeight }, children: /* @__PURE__ */ jsx(
290
+ Empty,
291
+ {
292
+ description: /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Click the file path on the left to show the modules of the asset" })
293
+ }
294
+ ) }) })
295
+ ] }) : /* @__PURE__ */ jsx(Empty, {}) })
296
+ ] })
297
+ }
298
+ )
299
+ ] });
300
+ };
301
+ const WebpackModulesOverall = withServerAPI({
302
+ api: SDK.ServerAPI.API.GetProjectInfo,
303
+ responsePropName: "project",
304
+ Component: (props) => {
305
+ const { root, errors } = props.project;
306
+ return /* @__PURE__ */ jsx(ServerAPIProvider, { api: SDK.ServerAPI.API.GetAssetsSummary, body: { withFileContent: true }, children: (summary) => {
307
+ return /* @__PURE__ */ jsx(ServerAPIProvider, { api: SDK.ServerAPI.API.GetEntryPoints, children: (entryPoints) => /* @__PURE__ */ jsx(WebpackModulesOverallBase, { cwd: root, errors, summary, entryPoints }) });
308
+ } });
309
+ }
310
+ });
311
+ export {
312
+ WebpackModulesOverall,
313
+ WebpackModulesOverallBase
314
+ };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface config {
3
+ setModuleJumpList(ids: number[]): void;
4
+ moduleJumpList: number[];
5
+ }
6
+ export declare const ModuleGraphListContext: import("react").Context<config>;
7
+ export {};
@@ -0,0 +1,9 @@
1
+ import { createContext } from "react";
2
+ const ModuleGraphListContext = createContext({
3
+ setModuleJumpList(_ids) {
4
+ },
5
+ moduleJumpList: []
6
+ });
7
+ export {
8
+ ModuleGraphListContext
9
+ };
@@ -0,0 +1,5 @@
1
+ import { Client } from '@rsdoctor/types';
2
+ export declare const maxModuleSize = 5000;
3
+ export declare const name = "BundleSize";
4
+ export declare const route = Client.DoctorClientRoutes.BundleSize;
5
+ export type GraphType = 'tile' | 'tree';
@@ -0,0 +1,9 @@
1
+ import { Client } from "@rsdoctor/types";
2
+ const maxModuleSize = 5e3;
3
+ const name = "BundleSize";
4
+ const route = Client.DoctorClientRoutes.BundleSize;
5
+ export {
6
+ maxModuleSize,
7
+ name,
8
+ route
9
+ };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const Page: React.FC;
3
+ export * from './constants';
@@ -0,0 +1,11 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Col, Row } from "antd";
3
+ import { Size } from "../../constants";
4
+ import { WebpackModulesOverall } from "./components";
5
+ const Page = () => {
6
+ return /* @__PURE__ */ jsx(Row, { children: /* @__PURE__ */ jsx(Col, { span: 24, style: { marginBottom: Size.BasePadding }, children: /* @__PURE__ */ jsx(WebpackModulesOverall, {}) }) });
7
+ };
8
+ export * from "./constants";
9
+ export {
10
+ Page
11
+ };
@@ -0,0 +1,6 @@
1
+ import { SDK } from '@rsdoctor/types';
2
+ import React from 'react';
3
+ import './index.sass';
4
+ export declare const ChunksTable: React.FC<{
5
+ chunks: SDK.ChunkData[];
6
+ }>;
@@ -0,0 +1,48 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { Empty, Table, Tag } from "antd";
3
+ import { compact, orderBy } from "lodash-es";
4
+ import { useMemo } from "react";
5
+ import { formatSize } from "../../utils";
6
+ import "./index.css";
7
+ const columns = [
8
+ {
9
+ title: "Chunk Name",
10
+ dataIndex: "name",
11
+ key: "name"
12
+ },
13
+ {
14
+ title: "size | 大小",
15
+ dataIndex: "size",
16
+ key: "size"
17
+ },
18
+ {
19
+ title: "assets | 资源",
20
+ dataIndex: "assets",
21
+ key: "assets"
22
+ },
23
+ {
24
+ title: "Entry or Not | 是否是入口",
25
+ dataIndex: "entry",
26
+ key: "entry"
27
+ }
28
+ ];
29
+ const ChunksTable = ({ chunks }) => {
30
+ const chunksData = useMemo(() => {
31
+ const _chunksData = chunks.map((chunk) => {
32
+ if (!chunk)
33
+ return void 0;
34
+ return {
35
+ key: chunk.id,
36
+ name: /* @__PURE__ */ jsx(Tag, { children: chunk.name }),
37
+ size: /* @__PURE__ */ jsx(Tag, { children: formatSize(chunk.parsedSize) }),
38
+ entry: /* @__PURE__ */ jsx(Tag, { children: chunk.entry ? "是 | Yes" : "否 | No" }),
39
+ assets: chunk.assets.map((asset) => /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(Tag, { children: asset }, asset) }, asset))
40
+ };
41
+ });
42
+ return orderBy(compact(_chunksData), ["size"], ["desc"]);
43
+ }, [chunks]);
44
+ return /* @__PURE__ */ jsx(Fragment, { children: (chunksData == null ? void 0 : chunksData.length) ? /* @__PURE__ */ jsx(Table, { bordered: true, pagination: false, dataSource: chunksData, columns }) : /* @__PURE__ */ jsx(Empty, {}) });
45
+ };
46
+ export {
47
+ ChunksTable
48
+ };
@@ -0,0 +1,88 @@
1
+ .file-tree-com {
2
+ margin: 0;
3
+ }
4
+ .file-tree-com .file-tree-com-treenode {
5
+ margin: 0;
6
+ padding: 0;
7
+ line-height: 24px;
8
+ white-space: nowrap;
9
+ list-style: none;
10
+ outline: 0;
11
+ }
12
+ .file-tree-com .file-tree-com-treenode .file-tree-com-node-content-wrapper {
13
+ position: relative;
14
+ display: inline-block;
15
+ height: 24px;
16
+ margin: 0;
17
+ padding: 0 4px;
18
+ box-sizing: border-box;
19
+ text-decoration: none;
20
+ vertical-align: top;
21
+ cursor: pointer;
22
+ }
23
+ .file-tree-com .file-tree-com-treenode .file-tree-com-arrow-icon {
24
+ transform: rotate(90deg);
25
+ }
26
+ .file-tree-com-child-tree {
27
+ display: none;
28
+ }
29
+ .file-tree-com-child-tree-open {
30
+ display: block;
31
+ }
32
+ .file-tree-com-treenode-disabled > span:not(.file-tree-com-switcher),
33
+ .file-tree-com > a,
34
+ .file-tree-com > a span {
35
+ color: #767676;
36
+ cursor: not-allowed;
37
+ }
38
+ .file-tree-com-treenode-selected {
39
+ background: rgba(5, 145, 255, 0.3);
40
+ border-radius: 4px;
41
+ }
42
+ .file-tree-com-title {
43
+ display: inline-block;
44
+ cursor: pointer;
45
+ }
46
+ .file-tree-com-indent {
47
+ display: inline-block;
48
+ height: 0;
49
+ vertical-align: bottom;
50
+ }
51
+ .file-tree-com-indent-unit {
52
+ display: inline-block;
53
+ width: 14px;
54
+ }
55
+ .file-tree-switcher-arrow {
56
+ transform: rotate(0deg);
57
+ transition: transform 0.3s ease;
58
+ }
59
+ .file-tree-switcher-arrow-expand {
60
+ transform: rotate(90deg);
61
+ }
62
+ .rc-tree.rc-tree-show-line .rc-tree-treenode:not(:last-child) {
63
+ border-left: 1px solid #eee;
64
+ }
65
+ .file-tree-com-titles-box .file-tree-com-titles {
66
+ display: flex;
67
+ flex-direction: column;
68
+ }
69
+ .file-tree-com-titles-box .file-tree-com-titles .file-tree-com-node-title {
70
+ display: flex;
71
+ cursor: pointer;
72
+ }
73
+ .file-tree-com-titles-box .file-tree-com-titles .file-tree-com-node-title img {
74
+ cursor: pointer;
75
+ }
76
+ .file-tree-com-titles-box .file-tree-com-titles .file-tree-com-node-title img-tag {
77
+ cursor: pointer;
78
+ }
79
+ .file-tree-com-titles-box .file-tree-com-titles .file-tree-com-node-title-selected {
80
+ background-color: yellow;
81
+ }
82
+ .file-tree-com-titles-box .file-tree-com-titles .file-tree-com-node-title-tag {
83
+ margin-inline-end: 0;
84
+ }
85
+ .file-tree-com-node-title-code .file-tree-com-titles-box .file-tree-com-titles-tag {
86
+ cursor: pointer;
87
+ padding: 0 2px;
88
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { NewTreeNodeType } from '../utils/hooks';
3
+ import './fileTreeCom.sass';
4
+ type FileTreeProps = {
5
+ treeData: NewTreeNodeType[];
6
+ needCode?: boolean;
7
+ needShowAllTree?: boolean;
8
+ needJumpto?: boolean;
9
+ defaultOpened?: boolean;
10
+ defaultOpenFather?: number;
11
+ cwd: string;
12
+ selectedChunk?: string;
13
+ };
14
+ export declare const FileTree: React.FC<FileTreeProps>;
15
+ export {};