@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.
- package/LICENSE +21 -0
- package/README.md +22 -0
- package/dist/assets/connection-point.3b3c78ca.svg +1 -0
- package/dist/assets/webpack.98604d64.svg +1 -0
- package/dist/components/Alert/change.d.ts +8 -0
- package/dist/components/Alert/change.js +93 -0
- package/dist/components/Alert/file-relation.d.ts +3 -0
- package/dist/components/Alert/file-relation.js +9 -0
- package/dist/components/Alert/index.css +32 -0
- package/dist/components/Alert/index.d.ts +4 -0
- package/dist/components/Alert/index.js +37 -0
- package/dist/components/Alert/link.d.ts +3 -0
- package/dist/components/Alert/link.js +27 -0
- package/dist/components/Alert/package-relation.d.ts +17 -0
- package/dist/components/Alert/package-relation.js +281 -0
- package/dist/components/Alert/types.d.ts +31 -0
- package/dist/components/Alert/types.js +0 -0
- package/dist/components/Alert/view.d.ts +4 -0
- package/dist/components/Alert/view.js +58 -0
- package/dist/components/Alerts/bundle.d.ts +11 -0
- package/dist/components/Alerts/bundle.js +61 -0
- package/dist/components/Alerts/common.d.ts +15 -0
- package/dist/components/Alerts/common.js +112 -0
- package/dist/components/Alerts/compile.d.ts +10 -0
- package/dist/components/Alerts/compile.js +46 -0
- package/dist/components/Alerts/index.d.ts +3 -0
- package/dist/components/Alerts/index.js +3 -0
- package/dist/components/Alerts/overlay.d.ts +26 -0
- package/dist/components/Alerts/overlay.js +154 -0
- package/dist/components/Badge/index.d.ts +21 -0
- package/dist/components/Badge/index.js +87 -0
- package/dist/components/BundleDiff/DiffContainer/assets.d.ts +7 -0
- package/dist/components/BundleDiff/DiffContainer/assets.js +507 -0
- package/dist/components/BundleDiff/DiffContainer/cards.d.ts +3 -0
- package/dist/components/BundleDiff/DiffContainer/cards.js +156 -0
- package/dist/components/BundleDiff/DiffContainer/changes.d.ts +15 -0
- package/dist/components/BundleDiff/DiffContainer/changes.js +69 -0
- package/dist/components/BundleDiff/DiffContainer/constants.d.ts +11 -0
- package/dist/components/BundleDiff/DiffContainer/constants.js +17 -0
- package/dist/components/BundleDiff/DiffContainer/diff.d.ts +23 -0
- package/dist/components/BundleDiff/DiffContainer/diff.js +114 -0
- package/dist/components/BundleDiff/DiffContainer/index.d.ts +3 -0
- package/dist/components/BundleDiff/DiffContainer/index.js +180 -0
- package/dist/components/BundleDiff/DiffContainer/modules.d.ts +8 -0
- package/dist/components/BundleDiff/DiffContainer/modules.js +302 -0
- package/dist/components/BundleDiff/DiffContainer/overview.d.ts +5 -0
- package/dist/components/BundleDiff/DiffContainer/overview.js +178 -0
- package/dist/components/BundleDiff/DiffContainer/packages.d.ts +19 -0
- package/dist/components/BundleDiff/DiffContainer/packages.js +330 -0
- package/dist/components/BundleDiff/DiffContainer/row.d.ts +9 -0
- package/dist/components/BundleDiff/DiffContainer/row.js +369 -0
- package/dist/components/BundleDiff/DiffContainer/types.d.ts +45 -0
- package/dist/components/BundleDiff/DiffContainer/types.js +0 -0
- package/dist/components/BundleDiff/DiffContainer/utils.d.ts +2 -0
- package/dist/components/BundleDiff/DiffContainer/utils.js +24 -0
- package/dist/components/BundleDiff/DiffServerAPIProvider/index.d.ts +4 -0
- package/dist/components/BundleDiff/DiffServerAPIProvider/index.js +37 -0
- package/dist/components/BundleDiff/constants.d.ts +11 -0
- package/dist/components/BundleDiff/constants.js +19 -0
- package/dist/components/BundleDiff/index.d.ts +1 -0
- package/dist/components/BundleDiff/index.js +1 -0
- package/dist/components/Card/diff.d.ts +24 -0
- package/dist/components/Card/diff.js +116 -0
- package/dist/components/Card/index.d.ts +9 -0
- package/dist/components/Card/index.js +50 -0
- package/dist/components/Card/size.d.ts +21 -0
- package/dist/components/Card/size.js +79 -0
- package/dist/components/Card/statistic.css +17 -0
- package/dist/components/Card/statistic.d.ts +12 -0
- package/dist/components/Card/statistic.js +19 -0
- package/dist/components/Charts/TimelineCharts/index.d.ts +8 -0
- package/dist/components/Charts/TimelineCharts/index.js +212 -0
- package/dist/components/Charts/bootstrap.d.ts +5 -0
- package/dist/components/Charts/bootstrap.js +44 -0
- package/dist/components/Charts/common.d.ts +13 -0
- package/dist/components/Charts/common.js +56 -0
- package/dist/components/Charts/constants.d.ts +2 -0
- package/dist/components/Charts/constants.js +46 -0
- package/dist/components/Charts/done.d.ts +5 -0
- package/dist/components/Charts/done.js +45 -0
- package/dist/components/Charts/index.d.ts +10 -0
- package/dist/components/Charts/index.js +37 -0
- package/dist/components/Charts/loader.css +31 -0
- package/dist/components/Charts/loader.d.ts +4 -0
- package/dist/components/Charts/loader.js +88 -0
- package/dist/components/Charts/minify.d.ts +5 -0
- package/dist/components/Charts/minify.js +37 -0
- package/dist/components/Charts/tooltips.css +62 -0
- package/dist/components/Charts/types.d.ts +61 -0
- package/dist/components/Charts/types.js +11 -0
- package/dist/components/Charts/utils.d.ts +13 -0
- package/dist/components/Charts/utils.js +206 -0
- package/dist/components/CodeViewer/config.d.ts +2 -0
- package/dist/components/CodeViewer/config.js +18 -0
- package/dist/components/CodeViewer/diff.d.ts +11 -0
- package/dist/components/CodeViewer/diff.js +35 -0
- package/dist/components/CodeViewer/hightlight.d.ts +10 -0
- package/dist/components/CodeViewer/hightlight.js +76 -0
- package/dist/components/CodeViewer/index.d.ts +4 -0
- package/dist/components/CodeViewer/index.js +4 -0
- package/dist/components/CodeViewer/viewer.d.ts +13 -0
- package/dist/components/CodeViewer/viewer.js +60 -0
- package/dist/components/Configuration/builder.d.ts +13 -0
- package/dist/components/Configuration/builder.js +67 -0
- package/dist/components/Configuration/index.d.ts +1 -0
- package/dist/components/Configuration/index.js +1 -0
- package/dist/components/FileTree/index.css +58 -0
- package/dist/components/FileTree/index.d.ts +4 -0
- package/dist/components/FileTree/index.js +42 -0
- package/dist/components/Form/keyword.d.ts +14 -0
- package/dist/components/Form/keyword.js +60 -0
- package/dist/components/Keyword/index.d.ts +6 -0
- package/dist/components/Keyword/index.js +36 -0
- package/dist/components/Layout/builder-select.d.ts +2 -0
- package/dist/components/Layout/builder-select.js +50 -0
- package/dist/components/Layout/constants.d.ts +1 -0
- package/dist/components/Layout/constants.js +4 -0
- package/dist/components/Layout/header.css +12 -0
- package/dist/components/Layout/header.d.ts +3 -0
- package/dist/components/Layout/header.js +86 -0
- package/dist/components/Layout/index.d.ts +5 -0
- package/dist/components/Layout/index.js +34 -0
- package/dist/components/Layout/menus.d.ts +8 -0
- package/dist/components/Layout/menus.js +167 -0
- package/dist/components/Layout/progress.d.ts +8 -0
- package/dist/components/Layout/progress.js +44 -0
- package/dist/components/Loader/Analysis/files.d.ts +8 -0
- package/dist/components/Loader/Analysis/files.js +193 -0
- package/dist/components/Loader/Analysis/index.d.ts +11 -0
- package/dist/components/Loader/Analysis/index.js +23 -0
- package/dist/components/Loader/executions.d.ts +9 -0
- package/dist/components/Loader/executions.js +199 -0
- package/dist/components/Manifest/api.d.ts +34 -0
- package/dist/components/Manifest/api.js +127 -0
- package/dist/components/Manifest/data.d.ts +8 -0
- package/dist/components/Manifest/data.js +65 -0
- package/dist/components/Manifest/index.d.ts +2 -0
- package/dist/components/Manifest/index.js +2 -0
- package/dist/components/Opener/code.d.ts +20 -0
- package/dist/components/Opener/code.js +78 -0
- package/dist/components/Opener/index.d.ts +2 -0
- package/dist/components/Opener/index.js +2 -0
- package/dist/components/Opener/vscode.d.ts +11 -0
- package/dist/components/Opener/vscode.js +42 -0
- package/dist/components/Overall/NumberButton.d.ts +8 -0
- package/dist/components/Overall/NumberButton.js +29 -0
- package/dist/components/Overall/NumberButton.module.js +5 -0
- package/dist/components/Overall/NumberButton_module.css +70 -0
- package/dist/components/Overall/bundle.d.ts +6 -0
- package/dist/components/Overall/bundle.js +167 -0
- package/dist/components/Overall/bundle.module.css +0 -0
- package/dist/components/Overall/card.module.js +5 -0
- package/dist/components/Overall/card_module.css +6 -0
- package/dist/components/Overall/compile.d.ts +5 -0
- package/dist/components/Overall/compile.js +67 -0
- package/dist/components/Overall/compile.module.js +5 -0
- package/dist/components/Overall/compile_module.css +4 -0
- package/dist/components/Overall/index.d.ts +3 -0
- package/dist/components/Overall/index.js +3 -0
- package/dist/components/Overall/list.module.js +5 -0
- package/dist/components/Overall/list_module.css +7 -0
- package/dist/components/Overall/project.d.ts +8 -0
- package/dist/components/Overall/project.js +73 -0
- package/dist/components/Plugins/webpack.d.ts +18 -0
- package/dist/components/Plugins/webpack.js +76 -0
- package/dist/components/Resolver/analysis.d.ts +15 -0
- package/dist/components/Resolver/analysis.js +144 -0
- package/dist/components/Select/index.d.ts +15 -0
- package/dist/components/Select/index.js +68 -0
- package/dist/components/Status/failed.d.ts +9 -0
- package/dist/components/Status/failed.js +33 -0
- package/dist/components/Status/index.d.ts +1 -0
- package/dist/components/Status/index.js +1 -0
- package/dist/components/TextDrawer/duplicate.d.ts +17 -0
- package/dist/components/TextDrawer/duplicate.js +69 -0
- package/dist/components/TextDrawer/index.d.ts +11 -0
- package/dist/components/TextDrawer/index.js +36 -0
- package/dist/components/Title/index.d.ts +15 -0
- package/dist/components/Title/index.js +10 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/index.js +15 -0
- package/dist/components/worker/ecmaversion/client.d.ts +10 -0
- package/dist/components/worker/ecmaversion/client.js +60 -0
- package/dist/components/worker/ecmaversion/worker.d.ts +1 -0
- package/dist/components/worker/ecmaversion/worker.js +13 -0
- package/dist/components/worker/jsequal/client.d.ts +11 -0
- package/dist/components/worker/jsequal/client.js +38 -0
- package/dist/components/worker/jsequal/worker.d.ts +1 -0
- package/dist/components/worker/jsequal/worker.js +23 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +25 -0
- package/dist/constants.d.ts +50 -0
- package/dist/constants.js +75 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/dist/pages/BundleSize/components/asset.d.ts +26 -0
- package/dist/pages/BundleSize/components/asset.js +545 -0
- package/dist/pages/BundleSize/components/cards.d.ts +7 -0
- package/dist/pages/BundleSize/components/cards.js +143 -0
- package/dist/pages/BundleSize/components/editor.d.ts +5 -0
- package/dist/pages/BundleSize/components/editor.js +38 -0
- package/dist/pages/BundleSize/components/index.css +20 -0
- package/dist/pages/BundleSize/components/index.d.ts +16 -0
- package/dist/pages/BundleSize/components/index.js +366 -0
- package/dist/pages/BundleSize/config.d.ts +7 -0
- package/dist/pages/BundleSize/config.js +9 -0
- package/dist/pages/BundleSize/constants.d.ts +5 -0
- package/dist/pages/BundleSize/constants.js +9 -0
- package/dist/pages/BundleSize/index.d.ts +3 -0
- package/dist/pages/BundleSize/index.js +11 -0
- package/dist/pages/ModuleAnalyze/chunks.d.ts +6 -0
- package/dist/pages/ModuleAnalyze/chunks.js +48 -0
- package/dist/pages/ModuleAnalyze/components/fileTreeCom.css +97 -0
- package/dist/pages/ModuleAnalyze/components/fileTreeCom.d.ts +15 -0
- package/dist/pages/ModuleAnalyze/components/fileTreeCom.js +120 -0
- package/dist/pages/ModuleAnalyze/constants.d.ts +7 -0
- package/dist/pages/ModuleAnalyze/constants.js +14 -0
- package/dist/pages/ModuleAnalyze/dependncy.d.ts +9 -0
- package/dist/pages/ModuleAnalyze/dependncy.js +31 -0
- package/dist/pages/ModuleAnalyze/fileTree.d.ts +9 -0
- package/dist/pages/ModuleAnalyze/fileTree.js +125 -0
- package/dist/pages/ModuleAnalyze/index.css +10 -0
- package/dist/pages/ModuleAnalyze/index.d.ts +8 -0
- package/dist/pages/ModuleAnalyze/index.js +64 -0
- package/dist/pages/ModuleAnalyze/utils/hooks.d.ts +21 -0
- package/dist/pages/ModuleAnalyze/utils/hooks.js +62 -0
- package/dist/pages/ModuleAnalyze/utils/index.d.ts +3 -0
- package/dist/pages/ModuleAnalyze/utils/index.js +34 -0
- package/dist/pages/ModuleResolve/constants.d.ts +3 -0
- package/dist/pages/ModuleResolve/constants.js +7 -0
- package/dist/pages/ModuleResolve/index.d.ts +3 -0
- package/dist/pages/ModuleResolve/index.js +19 -0
- package/dist/pages/Overall/constants.d.ts +3 -0
- package/dist/pages/Overall/constants.js +7 -0
- package/dist/pages/Overall/index.d.ts +9 -0
- package/dist/pages/Overall/index.js +39 -0
- package/dist/pages/Overall/responsiveGridList.d.ts +6 -0
- package/dist/pages/Overall/responsiveGridList.js +28 -0
- package/dist/pages/Resources/RuleIndex/constants.d.ts +3 -0
- package/dist/pages/Resources/RuleIndex/constants.js +7 -0
- package/dist/pages/Resources/RuleIndex/index.d.ts +3 -0
- package/dist/pages/Resources/RuleIndex/index.js +53 -0
- package/dist/pages/TreeShaking/constants.d.ts +3 -0
- package/dist/pages/TreeShaking/constants.js +7 -0
- package/dist/pages/TreeShaking/editor.d.ts +12 -0
- package/dist/pages/TreeShaking/editor.js +110 -0
- package/dist/pages/TreeShaking/index.css +74 -0
- package/dist/pages/TreeShaking/index.d.ts +8 -0
- package/dist/pages/TreeShaking/index.js +177 -0
- package/dist/pages/TreeShaking/open-tag.d.ts +11 -0
- package/dist/pages/TreeShaking/open-tag.js +43 -0
- package/dist/pages/TreeShaking/space.d.ts +1 -0
- package/dist/pages/TreeShaking/space.js +16 -0
- package/dist/pages/TreeShaking/table.d.ts +13 -0
- package/dist/pages/TreeShaking/table.js +319 -0
- package/dist/pages/TreeShaking/types.d.ts +3 -0
- package/dist/pages/TreeShaking/types.js +0 -0
- package/dist/pages/TreeShaking/utils.d.ts +7 -0
- package/dist/pages/TreeShaking/utils.js +147 -0
- package/dist/pages/WebpackLoaders/Analysis/constants.d.ts +3 -0
- package/dist/pages/WebpackLoaders/Analysis/constants.js +7 -0
- package/dist/pages/WebpackLoaders/Analysis/index.d.ts +3 -0
- package/dist/pages/WebpackLoaders/Analysis/index.js +19 -0
- package/dist/pages/WebpackLoaders/Overall/constants.d.ts +3 -0
- package/dist/pages/WebpackLoaders/Overall/constants.js +7 -0
- package/dist/pages/WebpackLoaders/Overall/index.d.ts +3 -0
- package/dist/pages/WebpackLoaders/Overall/index.js +11 -0
- package/dist/pages/WebpackLoaders/constants.d.ts +2 -0
- package/dist/pages/WebpackLoaders/constants.js +6 -0
- package/dist/pages/WebpackPlugins/constants.d.ts +3 -0
- package/dist/pages/WebpackPlugins/constants.js +7 -0
- package/dist/pages/WebpackPlugins/index.d.ts +3 -0
- package/dist/pages/WebpackPlugins/index.js +79 -0
- package/dist/pages/index.d.ts +9 -0
- package/dist/pages/index.js +20 -0
- package/dist/utils/data/base.d.ts +24 -0
- package/dist/utils/data/base.js +48 -0
- package/dist/utils/data/index.d.ts +5 -0
- package/dist/utils/data/index.js +44 -0
- package/dist/utils/data/local.d.ts +14 -0
- package/dist/utils/data/local.js +86 -0
- package/dist/utils/data/remote.d.ts +10 -0
- package/dist/utils/data/remote.js +52 -0
- package/dist/utils/file.d.ts +33 -0
- package/dist/utils/file.js +154 -0
- package/dist/utils/hooks.d.ts +31 -0
- package/dist/utils/hooks.js +216 -0
- package/dist/utils/i18n/cn.d.ts +3 -0
- package/dist/utils/i18n/cn.js +33 -0
- package/dist/utils/i18n/en.d.ts +30 -0
- package/dist/utils/i18n/en.js +33 -0
- package/dist/utils/i18n/index.d.ts +2 -0
- package/dist/utils/i18n/index.js +34 -0
- package/dist/utils/index.d.ts +16 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/loader.d.ts +7 -0
- package/dist/utils/loader.js +34 -0
- package/dist/utils/locale.d.ts +2 -0
- package/dist/utils/locale.js +9 -0
- package/dist/utils/manifest.d.ts +27 -0
- package/dist/utils/manifest.js +54 -0
- package/dist/utils/monaco.d.ts +12 -0
- package/dist/utils/monaco.js +71 -0
- package/dist/utils/request.d.ts +27 -0
- package/dist/utils/request.js +130 -0
- package/dist/utils/routes.d.ts +3 -0
- package/dist/utils/routes.js +14 -0
- package/dist/utils/size.d.ts +2 -0
- package/dist/utils/size.js +24 -0
- package/dist/utils/socket.d.ts +2 -0
- package/dist/utils/socket.js +21 -0
- package/dist/utils/storage.d.ts +13 -0
- package/dist/utils/storage.js +70 -0
- package/dist/utils/string.d.ts +2 -0
- package/dist/utils/string.js +14 -0
- package/dist/utils/time.d.ts +3 -0
- package/dist/utils/time.js +7 -0
- package/dist/utils/url.d.ts +7 -0
- package/dist/utils/url.js +75 -0
- package/dist/utils/worker/index.d.ts +4 -0
- package/dist/utils/worker/index.js +4 -0
- package/dist/utils/worker/master.d.ts +8 -0
- package/dist/utils/worker/master.js +18 -0
- package/dist/utils/worker/types.d.ts +9 -0
- package/dist/utils/worker/types.js +0 -0
- package/dist/utils/worker/utils.d.ts +7 -0
- package/dist/utils/worker/utils.js +29 -0
- package/dist/utils/worker/worker.d.ts +13 -0
- package/dist/utils/worker/worker.js +38 -0
- package/package.json +92 -0
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
CodepenCircleOutlined,
|
|
4
|
+
ColumnHeightOutlined,
|
|
5
|
+
DeploymentUnitOutlined,
|
|
6
|
+
InfoCircleOutlined
|
|
7
|
+
} from "@ant-design/icons";
|
|
8
|
+
import Editor from "@monaco-editor/react";
|
|
9
|
+
import { SDK } from "@rsdoctor/types";
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
Card,
|
|
13
|
+
Col,
|
|
14
|
+
Divider,
|
|
15
|
+
Drawer,
|
|
16
|
+
Empty,
|
|
17
|
+
Popover,
|
|
18
|
+
Row,
|
|
19
|
+
Space,
|
|
20
|
+
Tag,
|
|
21
|
+
Tooltip,
|
|
22
|
+
Typography
|
|
23
|
+
} from "antd";
|
|
24
|
+
import { omitBy, sumBy } from "lodash-es";
|
|
25
|
+
import { dirname, relative } from "path";
|
|
26
|
+
import { useEffect, useMemo, useState } from "react";
|
|
27
|
+
import { ServerAPIProvider } from "../../../components/Manifest";
|
|
28
|
+
import { ModuleAnalyzeComponent } from "../../ModuleAnalyze";
|
|
29
|
+
import { Badge as Bdg } from "../../../components/Badge";
|
|
30
|
+
import { FileTree } from "../../../components/FileTree";
|
|
31
|
+
import { KeywordInput } from "../../../components/Form/keyword";
|
|
32
|
+
import { Keyword } from "../../../components/Keyword";
|
|
33
|
+
import { TextDrawer } from "../../../components/TextDrawer";
|
|
34
|
+
import { Size, drawerWidth } from "../../../constants";
|
|
35
|
+
import {
|
|
36
|
+
createFileStructures,
|
|
37
|
+
formatSize,
|
|
38
|
+
getOriginalLanguage,
|
|
39
|
+
isJsDataUrl,
|
|
40
|
+
useI18n
|
|
41
|
+
} from "../../../utils";
|
|
42
|
+
import { ModuleGraphListContext } from "../config";
|
|
43
|
+
let expanedModulesKeys = [];
|
|
44
|
+
const TAB_MAP = {
|
|
45
|
+
source: "source code",
|
|
46
|
+
transformed: "Transformed Code (After compile)",
|
|
47
|
+
parsedSource: "Bundled Code (After bundle and tree-shaking)"
|
|
48
|
+
};
|
|
49
|
+
const tagStyle = {
|
|
50
|
+
margin: "none",
|
|
51
|
+
marginInlineEnd: 0
|
|
52
|
+
};
|
|
53
|
+
const ModuleCodeViewer = ({
|
|
54
|
+
data
|
|
55
|
+
}) => {
|
|
56
|
+
const [tab, setTab] = useState("parsedSource");
|
|
57
|
+
const { t } = useI18n();
|
|
58
|
+
const TAB_LAB_MAP = {
|
|
59
|
+
source: "Source Code",
|
|
60
|
+
transformed: `Transformed Code(${t("After Compile")})`,
|
|
61
|
+
parsedSource: `Bundled Code(${t("After Bundled")})`
|
|
62
|
+
};
|
|
63
|
+
if (!data)
|
|
64
|
+
return null;
|
|
65
|
+
const { path } = data;
|
|
66
|
+
return /* @__PURE__ */ jsx(
|
|
67
|
+
TextDrawer,
|
|
68
|
+
{
|
|
69
|
+
text: "",
|
|
70
|
+
buttonProps: {
|
|
71
|
+
size: "small",
|
|
72
|
+
icon: /* @__PURE__ */ jsx(CodepenCircleOutlined, {}),
|
|
73
|
+
type: "default"
|
|
74
|
+
},
|
|
75
|
+
buttonStyle: { padding: `0 4px` },
|
|
76
|
+
drawerProps: {
|
|
77
|
+
destroyOnClose: true,
|
|
78
|
+
title: `Code of "${path}"`
|
|
79
|
+
},
|
|
80
|
+
children: /* @__PURE__ */ jsx(
|
|
81
|
+
ServerAPIProvider,
|
|
82
|
+
{
|
|
83
|
+
api: SDK.ServerAPI.API.GetModuleCodeByModuleId,
|
|
84
|
+
body: { moduleId: data.id },
|
|
85
|
+
children: (source) => {
|
|
86
|
+
return /* @__PURE__ */ jsx(Fragment, { children: !source["source"] && !source["parsedSource"] && !source["transformed"] ? /* @__PURE__ */ jsx(Empty, { description: "No Code. Rspack builder not support code yet. And if you upload the stats.json to analysis, it's also no code to show." }) : /* @__PURE__ */ jsx(
|
|
87
|
+
Card,
|
|
88
|
+
{
|
|
89
|
+
className: "code-size-card",
|
|
90
|
+
style: { width: "100%" },
|
|
91
|
+
tabList: Object.keys(omitBy(source, (s) => !s)).map((k) => ({ tab: k })).map((e) => ({
|
|
92
|
+
...e,
|
|
93
|
+
tab: TAB_LAB_MAP[e.tab],
|
|
94
|
+
key: e.tab
|
|
95
|
+
})),
|
|
96
|
+
onTabChange: (v) => setTab(v),
|
|
97
|
+
tabBarExtraContent: /* @__PURE__ */ jsx(
|
|
98
|
+
Popover,
|
|
99
|
+
{
|
|
100
|
+
placement: "bottom",
|
|
101
|
+
title: /* @__PURE__ */ jsx(Typography.Title, { level: 5, children: "Explain" }),
|
|
102
|
+
content: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
103
|
+
"div",
|
|
104
|
+
{
|
|
105
|
+
style: {
|
|
106
|
+
display: "flex",
|
|
107
|
+
flexDirection: "column",
|
|
108
|
+
marginBottom: 30
|
|
109
|
+
},
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
112
|
+
/* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Source: " }),
|
|
113
|
+
/* @__PURE__ */ jsx(Typography.Text, { children: TAB_MAP.source })
|
|
114
|
+
] }),
|
|
115
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
116
|
+
/* @__PURE__ */ jsxs(Typography.Text, { strong: true, children: [
|
|
117
|
+
"Transformed:",
|
|
118
|
+
" "
|
|
119
|
+
] }),
|
|
120
|
+
/* @__PURE__ */ jsx(Typography.Text, { children: TAB_MAP.transformed })
|
|
121
|
+
] }),
|
|
122
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
123
|
+
/* @__PURE__ */ jsxs(Typography.Text, { strong: true, children: [
|
|
124
|
+
"Bundled Source:",
|
|
125
|
+
" "
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ jsx(Typography.Text, { children: TAB_MAP.parsedSource })
|
|
128
|
+
] }),
|
|
129
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
130
|
+
/* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "More" }),
|
|
131
|
+
/* @__PURE__ */ jsx(Typography.Text, { children: t("CodeModeExplain") })
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
) }),
|
|
135
|
+
trigger: "hover",
|
|
136
|
+
children: /* @__PURE__ */ jsx("a", { href: "#", children: "Explain" })
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
children: /* @__PURE__ */ jsx(
|
|
140
|
+
Editor,
|
|
141
|
+
{
|
|
142
|
+
theme: "vs-dark",
|
|
143
|
+
language: getOriginalLanguage(path),
|
|
144
|
+
height: window.innerHeight / 1.5,
|
|
145
|
+
value: source[tab],
|
|
146
|
+
options: {
|
|
147
|
+
readOnly: true,
|
|
148
|
+
domReadOnly: true,
|
|
149
|
+
fontSize: 14,
|
|
150
|
+
wordWrap: "bounded",
|
|
151
|
+
minimap: {
|
|
152
|
+
enabled: false
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
) });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
const ModuleGraphViewer = ({ id, show, setShow, cwd }) => {
|
|
166
|
+
if (!id)
|
|
167
|
+
return null;
|
|
168
|
+
return /* @__PURE__ */ jsx(
|
|
169
|
+
Drawer,
|
|
170
|
+
{
|
|
171
|
+
open: show,
|
|
172
|
+
maskClosable: true,
|
|
173
|
+
width: drawerWidth,
|
|
174
|
+
onClose: () => setShow(false),
|
|
175
|
+
children: /* @__PURE__ */ jsx(ServerAPIProvider, { api: SDK.ServerAPI.API.GetAllModuleGraph, body: {}, children: (modules) => /* @__PURE__ */ jsx(ModuleAnalyzeComponent, { cwd, moduleId: id, modules }) })
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
const inlinedResourcePathKey = "__RESOURCEPATH__";
|
|
180
|
+
function getChildrenModule(node) {
|
|
181
|
+
const mods = [];
|
|
182
|
+
node.children && node.children.forEach((n) => {
|
|
183
|
+
if (n.isLeaf) {
|
|
184
|
+
mods.push(n[inlinedResourcePathKey]);
|
|
185
|
+
} else {
|
|
186
|
+
getChildrenModule(n);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
return mods;
|
|
190
|
+
}
|
|
191
|
+
const ModulesStatistics = ({ modules, chunks, filteredModules }) => {
|
|
192
|
+
const { sourceSize, parsedSize, filteredParsedSize, filteredSourceSize } = useMemo(() => {
|
|
193
|
+
return {
|
|
194
|
+
sourceSize: sumBy(modules, (e) => e.size.sourceSize),
|
|
195
|
+
parsedSize: sumBy(modules, (e) => e.size.parsedSize),
|
|
196
|
+
filteredSourceSize: sumBy(filteredModules, (e) => e.size.sourceSize),
|
|
197
|
+
filteredParsedSize: sumBy(filteredModules, (e) => e.size.parsedSize)
|
|
198
|
+
};
|
|
199
|
+
}, [modules, filteredModules]);
|
|
200
|
+
return /* @__PURE__ */ jsxs(Space, { children: [
|
|
201
|
+
/* @__PURE__ */ jsx(
|
|
202
|
+
Tooltip,
|
|
203
|
+
{
|
|
204
|
+
title: `total modules count is ${modules.length}, the filtered modules count is ${filteredModules.length}`,
|
|
205
|
+
children: /* @__PURE__ */ jsxs(Space, { children: [
|
|
206
|
+
/* @__PURE__ */ jsxs(
|
|
207
|
+
Typography.Text,
|
|
208
|
+
{
|
|
209
|
+
type: "secondary",
|
|
210
|
+
style: { fontSize: 12, fontWeight: 400 },
|
|
211
|
+
children: [
|
|
212
|
+
"Modules: ",
|
|
213
|
+
filteredModules.length,
|
|
214
|
+
" / ",
|
|
215
|
+
modules.length
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
/* @__PURE__ */ jsx(InfoCircleOutlined, {})
|
|
220
|
+
] })
|
|
221
|
+
}
|
|
222
|
+
),
|
|
223
|
+
/* @__PURE__ */ jsx(Divider, { type: "vertical" }),
|
|
224
|
+
/* @__PURE__ */ jsx(
|
|
225
|
+
Tooltip,
|
|
226
|
+
{
|
|
227
|
+
title: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
|
|
228
|
+
/* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
|
|
229
|
+
"Total modules bundled size: ",
|
|
230
|
+
formatSize(parsedSize)
|
|
231
|
+
] }),
|
|
232
|
+
/* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
|
|
233
|
+
"Total modules source size: ",
|
|
234
|
+
formatSize(sourceSize)
|
|
235
|
+
] }),
|
|
236
|
+
/* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
|
|
237
|
+
"Filtered modules bundled size: ",
|
|
238
|
+
formatSize(filteredParsedSize)
|
|
239
|
+
] }),
|
|
240
|
+
/* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
|
|
241
|
+
"Filtered modules source size: ",
|
|
242
|
+
formatSize(filteredSourceSize)
|
|
243
|
+
] })
|
|
244
|
+
] }),
|
|
245
|
+
children: /* @__PURE__ */ jsxs(Space, { children: [
|
|
246
|
+
/* @__PURE__ */ jsxs(
|
|
247
|
+
Typography.Text,
|
|
248
|
+
{
|
|
249
|
+
type: "secondary",
|
|
250
|
+
style: { fontSize: 12, fontWeight: 400 },
|
|
251
|
+
children: [
|
|
252
|
+
"Modules Size:",
|
|
253
|
+
" ",
|
|
254
|
+
filteredParsedSize === parsedSize ? formatSize(parsedSize) : `${formatSize(filteredParsedSize)} / ${formatSize(parsedSize)}`
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
/* @__PURE__ */ jsx(InfoCircleOutlined, {})
|
|
259
|
+
] })
|
|
260
|
+
}
|
|
261
|
+
),
|
|
262
|
+
/* @__PURE__ */ jsx(Divider, { type: "vertical" }),
|
|
263
|
+
/* @__PURE__ */ jsx(
|
|
264
|
+
Tooltip,
|
|
265
|
+
{
|
|
266
|
+
title: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
|
|
267
|
+
/* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
|
|
268
|
+
"this asset includes ",
|
|
269
|
+
chunks.length,
|
|
270
|
+
" chunks:",
|
|
271
|
+
" "
|
|
272
|
+
] }),
|
|
273
|
+
chunks.map((e) => /* @__PURE__ */ jsx(Bdg, { label: "chunk", value: e.name }, e.name))
|
|
274
|
+
] }),
|
|
275
|
+
children: /* @__PURE__ */ jsxs(Space, { children: [
|
|
276
|
+
/* @__PURE__ */ jsxs(
|
|
277
|
+
Typography.Text,
|
|
278
|
+
{
|
|
279
|
+
type: "secondary",
|
|
280
|
+
style: { fontSize: 12, fontWeight: 400 },
|
|
281
|
+
children: [
|
|
282
|
+
"Chunks: ",
|
|
283
|
+
chunks.length
|
|
284
|
+
]
|
|
285
|
+
}
|
|
286
|
+
),
|
|
287
|
+
/* @__PURE__ */ jsx(InfoCircleOutlined, {})
|
|
288
|
+
] })
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
] });
|
|
292
|
+
};
|
|
293
|
+
const AssetDetail = ({
|
|
294
|
+
asset,
|
|
295
|
+
chunks: includeChunks,
|
|
296
|
+
modules: includeModules,
|
|
297
|
+
moduleSizeLimit,
|
|
298
|
+
height,
|
|
299
|
+
root
|
|
300
|
+
}) => {
|
|
301
|
+
const [moduleKeyword, setModuleKeyword] = useState("");
|
|
302
|
+
const [defaultExpandAll, setDefaultExpandAll] = useState(false);
|
|
303
|
+
const [moduleJumpList, setModuleJumpList] = useState([]);
|
|
304
|
+
const [show, setShow] = useState(false);
|
|
305
|
+
const filteredModules = useMemo(() => {
|
|
306
|
+
let res = includeModules.slice();
|
|
307
|
+
if (moduleKeyword) {
|
|
308
|
+
const regexp = new RegExp(moduleKeyword, "i");
|
|
309
|
+
res = res.filter((e) => regexp.test(e.path));
|
|
310
|
+
}
|
|
311
|
+
if (moduleSizeLimit) {
|
|
312
|
+
res = res.filter((e) => e.size.parsedSize >= moduleSizeLimit);
|
|
313
|
+
}
|
|
314
|
+
return res;
|
|
315
|
+
}, [includeModules, moduleKeyword, moduleSizeLimit]);
|
|
316
|
+
const fileStructures = useMemo(() => {
|
|
317
|
+
const res = createFileStructures({
|
|
318
|
+
files: filteredModules.map((e) => e.path).filter(Boolean),
|
|
319
|
+
inlinedResourcePathKey,
|
|
320
|
+
fileTitle(file, basename) {
|
|
321
|
+
const mod = filteredModules.find((e) => e.path === file);
|
|
322
|
+
if (!mod)
|
|
323
|
+
return basename;
|
|
324
|
+
const { parsedSize = 0, sourceSize = 0 } = mod.size;
|
|
325
|
+
const isConcatenation = mod.kind === SDK.ModuleKind.Concatenation;
|
|
326
|
+
const containedOtherModules = !isConcatenation && parsedSize === 0 && includeModules.filter(
|
|
327
|
+
(e) => e !== mod && e.modules && e.modules.indexOf(mod.id) > -1
|
|
328
|
+
);
|
|
329
|
+
return /* @__PURE__ */ jsxs(Space, { children: [
|
|
330
|
+
/* @__PURE__ */ jsx(
|
|
331
|
+
Keyword,
|
|
332
|
+
{
|
|
333
|
+
ellipsis: true,
|
|
334
|
+
style: { maxWidth: 500 },
|
|
335
|
+
text: basename,
|
|
336
|
+
keyword: moduleKeyword
|
|
337
|
+
}
|
|
338
|
+
),
|
|
339
|
+
parsedSize !== 0 ? /* @__PURE__ */ jsx(
|
|
340
|
+
Tooltip,
|
|
341
|
+
{
|
|
342
|
+
title: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
|
|
343
|
+
/* @__PURE__ */ jsx(Tag, { color: "orange", children: "Bundled Size:" + formatSize(parsedSize) }),
|
|
344
|
+
/* @__PURE__ */ jsx(Tag, { color: "volcano", children: "Source Size:" + formatSize(sourceSize) })
|
|
345
|
+
] }),
|
|
346
|
+
color: "white",
|
|
347
|
+
children: /* @__PURE__ */ jsx(Tag, { color: "purple", style: tagStyle, children: "Bundled: " + formatSize(parsedSize) })
|
|
348
|
+
}
|
|
349
|
+
) : sourceSize !== 0 ? (
|
|
350
|
+
// fallback to display tag for source size
|
|
351
|
+
/* @__PURE__ */ jsx(Tag, { color: "geekblue", children: "Source Size:" + formatSize(sourceSize) })
|
|
352
|
+
) : null,
|
|
353
|
+
isConcatenation ? /* @__PURE__ */ jsx(
|
|
354
|
+
Tooltip,
|
|
355
|
+
{
|
|
356
|
+
title: /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
|
|
357
|
+
"this is a concatenated module, it contains",
|
|
358
|
+
" ",
|
|
359
|
+
mod.modules?.length,
|
|
360
|
+
" modules"
|
|
361
|
+
] }) }),
|
|
362
|
+
children: /* @__PURE__ */ jsx(Tag, { color: "green", style: tagStyle, children: "concatenated" })
|
|
363
|
+
}
|
|
364
|
+
) : null,
|
|
365
|
+
containedOtherModules && containedOtherModules.length ? /* @__PURE__ */ jsx(
|
|
366
|
+
Tooltip,
|
|
367
|
+
{
|
|
368
|
+
title: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
|
|
369
|
+
/* @__PURE__ */ jsx(Typography.Text, { style: { color: "inherit" }, children: "this is a concatenated module, it is be contained in these modules below:" }),
|
|
370
|
+
containedOtherModules.map(({ id, path }) => {
|
|
371
|
+
if (isJsDataUrl(path)) {
|
|
372
|
+
return /* @__PURE__ */ jsx(
|
|
373
|
+
Typography.Paragraph,
|
|
374
|
+
{
|
|
375
|
+
ellipsis: { rows: 4 },
|
|
376
|
+
style: { color: "inherit", maxWidth: "100%" },
|
|
377
|
+
code: true,
|
|
378
|
+
children: path
|
|
379
|
+
},
|
|
380
|
+
id
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
const p = relative(dirname(mod.path), path);
|
|
384
|
+
if (p.startsWith("javascript;charset=utf-8;base64,")) {
|
|
385
|
+
return /* @__PURE__ */ jsx(
|
|
386
|
+
Typography.Text,
|
|
387
|
+
{
|
|
388
|
+
style: { color: "inherit", maxWidth: "100%" },
|
|
389
|
+
code: true,
|
|
390
|
+
children: p[0] === "." ? p : `./${p}`
|
|
391
|
+
},
|
|
392
|
+
id
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
return /* @__PURE__ */ jsx(
|
|
396
|
+
Typography.Text,
|
|
397
|
+
{
|
|
398
|
+
style: { color: "inherit" },
|
|
399
|
+
code: true,
|
|
400
|
+
children: p[0] === "." ? p : `./${p}`
|
|
401
|
+
},
|
|
402
|
+
id
|
|
403
|
+
);
|
|
404
|
+
})
|
|
405
|
+
] }),
|
|
406
|
+
children: /* @__PURE__ */ jsx(Tag, { color: "green", children: "concatenated" })
|
|
407
|
+
}
|
|
408
|
+
) : null,
|
|
409
|
+
/* @__PURE__ */ jsx(
|
|
410
|
+
Button,
|
|
411
|
+
{
|
|
412
|
+
size: "small",
|
|
413
|
+
icon: /* @__PURE__ */ jsx(DeploymentUnitOutlined, {}),
|
|
414
|
+
onClick: () => {
|
|
415
|
+
setModuleJumpList([mod.id]);
|
|
416
|
+
setShow(true);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
),
|
|
420
|
+
/* @__PURE__ */ jsx(ModuleCodeViewer, { data: mod })
|
|
421
|
+
] });
|
|
422
|
+
},
|
|
423
|
+
dirTitle(dir, defaultTitle) {
|
|
424
|
+
const paths = getChildrenModule(dir);
|
|
425
|
+
if (paths.length) {
|
|
426
|
+
const mods = paths.map(
|
|
427
|
+
(e) => includeModules.find((m) => m.path === e)
|
|
428
|
+
);
|
|
429
|
+
const parsedSize = sumBy(mods, (e) => e.size?.parsedSize || 0);
|
|
430
|
+
return /* @__PURE__ */ jsxs(Space, { children: [
|
|
431
|
+
/* @__PURE__ */ jsx(Typography.Text, { children: defaultTitle }),
|
|
432
|
+
parsedSize > 0 ? /* @__PURE__ */ jsx(Tag, { style: tagStyle, color: "orange", children: "Bundled:" + formatSize(parsedSize) }) : null
|
|
433
|
+
] });
|
|
434
|
+
}
|
|
435
|
+
return defaultTitle;
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
return res;
|
|
439
|
+
}, [filteredModules]);
|
|
440
|
+
const onSearch = (value) => setModuleKeyword(value);
|
|
441
|
+
useEffect(() => {
|
|
442
|
+
setModuleKeyword("");
|
|
443
|
+
setDefaultExpandAll(false);
|
|
444
|
+
}, [asset]);
|
|
445
|
+
useEffect(() => {
|
|
446
|
+
setDefaultExpandAll(false);
|
|
447
|
+
}, [moduleKeyword]);
|
|
448
|
+
return /* @__PURE__ */ jsx(
|
|
449
|
+
ModuleGraphListContext.Provider,
|
|
450
|
+
{
|
|
451
|
+
value: { moduleJumpList, setModuleJumpList },
|
|
452
|
+
children: /* @__PURE__ */ jsxs(
|
|
453
|
+
Card,
|
|
454
|
+
{
|
|
455
|
+
title: `Modules of "${asset.path}"`,
|
|
456
|
+
bodyStyle: { overflow: "scroll", height },
|
|
457
|
+
size: "small",
|
|
458
|
+
children: [
|
|
459
|
+
includeModules.length ? /* @__PURE__ */ jsxs(Row, { children: [
|
|
460
|
+
/* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsx(
|
|
461
|
+
ModulesStatistics,
|
|
462
|
+
{
|
|
463
|
+
modules: includeModules,
|
|
464
|
+
chunks: includeChunks,
|
|
465
|
+
filteredModules
|
|
466
|
+
}
|
|
467
|
+
) }),
|
|
468
|
+
/* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsxs(Space, { children: [
|
|
469
|
+
/* @__PURE__ */ jsx(
|
|
470
|
+
KeywordInput,
|
|
471
|
+
{
|
|
472
|
+
placeholder: "search module by keyword",
|
|
473
|
+
onChange: onSearch
|
|
474
|
+
},
|
|
475
|
+
asset.path
|
|
476
|
+
),
|
|
477
|
+
/* @__PURE__ */ jsx(
|
|
478
|
+
Button,
|
|
479
|
+
{
|
|
480
|
+
onClick: () => setDefaultExpandAll(true),
|
|
481
|
+
size: "small",
|
|
482
|
+
icon: /* @__PURE__ */ jsx(ColumnHeightOutlined, {}),
|
|
483
|
+
children: "expand all"
|
|
484
|
+
}
|
|
485
|
+
)
|
|
486
|
+
] }) }),
|
|
487
|
+
/* @__PURE__ */ jsx(Col, { span: 24, style: { marginTop: Size.BasePadding }, children: filteredModules.length ? /* @__PURE__ */ jsx(
|
|
488
|
+
FileTree,
|
|
489
|
+
{
|
|
490
|
+
onExpand: (expandedKeys) => {
|
|
491
|
+
expanedModulesKeys = expandedKeys;
|
|
492
|
+
},
|
|
493
|
+
treeData: fileStructures,
|
|
494
|
+
autoExpandParent: true,
|
|
495
|
+
defaultExpandParent: true,
|
|
496
|
+
defaultExpandedKeys: expanedModulesKeys?.length ? expanedModulesKeys : fileStructures.length === 1 ? [fileStructures[0].key] : [],
|
|
497
|
+
defaultExpandAll: defaultExpandAll || filteredModules.length <= 20
|
|
498
|
+
},
|
|
499
|
+
`tree_${moduleKeyword}_${defaultExpandAll}_${asset.path}`
|
|
500
|
+
) : /* @__PURE__ */ jsx(
|
|
501
|
+
Empty,
|
|
502
|
+
{
|
|
503
|
+
description: /* @__PURE__ */ jsx(
|
|
504
|
+
Typography.Text,
|
|
505
|
+
{
|
|
506
|
+
strong: true,
|
|
507
|
+
children: `"${moduleKeyword}" can't match any modules`
|
|
508
|
+
}
|
|
509
|
+
)
|
|
510
|
+
}
|
|
511
|
+
) })
|
|
512
|
+
] }) : /* @__PURE__ */ jsx(
|
|
513
|
+
Empty,
|
|
514
|
+
{
|
|
515
|
+
description: /* @__PURE__ */ jsx(
|
|
516
|
+
Typography.Text,
|
|
517
|
+
{
|
|
518
|
+
strong: true,
|
|
519
|
+
children: `"${asset.path}" doesn't have any modules`
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
}
|
|
523
|
+
),
|
|
524
|
+
/* @__PURE__ */ jsx(
|
|
525
|
+
ModuleGraphViewer,
|
|
526
|
+
{
|
|
527
|
+
id: moduleJumpList?.length ? moduleJumpList[moduleJumpList.length - 1] : "",
|
|
528
|
+
show,
|
|
529
|
+
setShow,
|
|
530
|
+
cwd: root
|
|
531
|
+
}
|
|
532
|
+
)
|
|
533
|
+
]
|
|
534
|
+
}
|
|
535
|
+
)
|
|
536
|
+
}
|
|
537
|
+
);
|
|
538
|
+
};
|
|
539
|
+
export {
|
|
540
|
+
AssetDetail,
|
|
541
|
+
ModuleCodeViewer,
|
|
542
|
+
ModuleGraphViewer,
|
|
543
|
+
ModulesStatistics,
|
|
544
|
+
getChildrenModule
|
|
545
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Col, Row, Segmented, theme } from "antd";
|
|
5
|
+
import { useDuplicatePackagesByErrors, useWindowWidth } from "../../../utils";
|
|
6
|
+
import { Size } from "../../../constants";
|
|
7
|
+
import { StatisticCard } from "../../../components/Card/statistic";
|
|
8
|
+
import { DuplicatePackageDrawerWithServer } from "../../../components/TextDrawer";
|
|
9
|
+
import { SizeCard } from "../../../components/Card/size";
|
|
10
|
+
const { useToken } = theme;
|
|
11
|
+
const height = 100;
|
|
12
|
+
const AssetCard = ({ showProgress = false, data, total, tagBgColor }) => {
|
|
13
|
+
const { token } = useToken();
|
|
14
|
+
const _tagBgColor = tagBgColor || token.colorPrimaryBorderHover;
|
|
15
|
+
return /* @__PURE__ */ jsx(SizeCard, { files: data.files, total, showProgress, tagBgColor: _tagBgColor });
|
|
16
|
+
};
|
|
17
|
+
const AssetCardContainer = ({ titles, datas, bgColor }) => {
|
|
18
|
+
const [idx, setIdx] = useState(0);
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
StatisticCard,
|
|
21
|
+
{
|
|
22
|
+
title: titles.length > 1 ? /* @__PURE__ */ jsx(
|
|
23
|
+
Segmented,
|
|
24
|
+
{
|
|
25
|
+
defaultValue: titles[idx],
|
|
26
|
+
options: titles,
|
|
27
|
+
onChange: (e) => {
|
|
28
|
+
setIdx(titles.indexOf(e));
|
|
29
|
+
},
|
|
30
|
+
size: "small",
|
|
31
|
+
style: { transition: "transform 0.3s ease" },
|
|
32
|
+
value: titles[idx] || titles[0]
|
|
33
|
+
}
|
|
34
|
+
) : titles[idx],
|
|
35
|
+
value: datas.map((e, i) => /* @__PURE__ */ createElement(AssetCard, { ...e, key: i, tagBgColor: bgColor?.tagBgColor }))[idx],
|
|
36
|
+
boxProps: {
|
|
37
|
+
style: { background: bgColor?.bgColor }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
const BundleCards = ({ cwd, errors, summary }) => {
|
|
43
|
+
const windowWith = useWindowWidth();
|
|
44
|
+
const duplicatePackages = useDuplicatePackagesByErrors(errors);
|
|
45
|
+
const arr = [
|
|
46
|
+
/* @__PURE__ */ jsx(
|
|
47
|
+
AssetCardContainer,
|
|
48
|
+
{
|
|
49
|
+
titles: ["Total Files"],
|
|
50
|
+
datas: [
|
|
51
|
+
{
|
|
52
|
+
data: summary.all.total,
|
|
53
|
+
total: summary.all.total.size,
|
|
54
|
+
showProgress: true
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ jsx(
|
|
60
|
+
AssetCardContainer,
|
|
61
|
+
{
|
|
62
|
+
titles: ["Total JS", "Initial JS"],
|
|
63
|
+
datas: [
|
|
64
|
+
{
|
|
65
|
+
data: summary.js.total,
|
|
66
|
+
total: summary.all.total.size,
|
|
67
|
+
showProgress: true
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
data: summary.js.initial,
|
|
71
|
+
total: summary.all.total.size,
|
|
72
|
+
showProgress: true
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
AssetCardContainer,
|
|
79
|
+
{
|
|
80
|
+
titles: ["Total CSS", "Initial CSS"],
|
|
81
|
+
datas: [
|
|
82
|
+
{
|
|
83
|
+
data: summary.css.total,
|
|
84
|
+
total: summary.all.total.size,
|
|
85
|
+
showProgress: true
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
data: summary.css.initial,
|
|
89
|
+
total: summary.all.total.size,
|
|
90
|
+
showProgress: true
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
AssetCardContainer,
|
|
97
|
+
{
|
|
98
|
+
titles: ["Images", "Fonts", "Media"],
|
|
99
|
+
datas: [
|
|
100
|
+
{
|
|
101
|
+
data: summary.imgs.total,
|
|
102
|
+
total: summary.all.total.size,
|
|
103
|
+
showProgress: true
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
data: summary.fonts.total,
|
|
107
|
+
total: summary.all.total.size,
|
|
108
|
+
showProgress: true
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
data: summary.media.total,
|
|
112
|
+
total: summary.all.total.size,
|
|
113
|
+
showProgress: true
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsx(
|
|
119
|
+
AssetCardContainer,
|
|
120
|
+
{
|
|
121
|
+
titles: ["HTML Files"],
|
|
122
|
+
datas: [
|
|
123
|
+
{
|
|
124
|
+
data: summary.html.total,
|
|
125
|
+
total: summary.all.total.size,
|
|
126
|
+
showProgress: true
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsx(
|
|
132
|
+
StatisticCard,
|
|
133
|
+
{
|
|
134
|
+
title: "Duplicate Packages",
|
|
135
|
+
value: /* @__PURE__ */ jsx(DuplicatePackageDrawerWithServer, { buttonStyle: { height }, duplicatePackages, cwd })
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
];
|
|
139
|
+
return /* @__PURE__ */ jsx(Row, { gutter: windowWith > 1200 && windowWith < 1400 ? [Size.BasePadding * 2, Size.BasePadding] : [Size.BasePadding, Size.BasePadding], wrap: true, style: { marginBottom: Size.BasePadding }, children: arr.map((e, i) => /* @__PURE__ */ jsx(Col, { span: windowWith > 1500 ? 4 : windowWith > 1200 ? 8 : 8, children: e }, i)) });
|
|
140
|
+
};
|
|
141
|
+
export {
|
|
142
|
+
BundleCards
|
|
143
|
+
};
|