@rsdoctor/components 1.1.3 → 1.1.5

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 (32) hide show
  1. package/dist/components/Charts/TreeMap.d.ts +21 -0
  2. package/dist/components/Charts/TreeMap.js +284 -0
  3. package/dist/components/Charts/TreeMap.js.map +1 -0
  4. package/dist/components/Charts/constants.d.ts +10 -0
  5. package/dist/components/Charts/constants.js +62 -0
  6. package/dist/components/Charts/constants.js.map +1 -1
  7. package/dist/pages/BundleSize/components/asset.js +87 -34
  8. package/dist/pages/BundleSize/components/asset.js.map +1 -1
  9. package/dist/pages/BundleSize/components/index.js +26 -33
  10. package/dist/pages/BundleSize/components/index.js.map +1 -1
  11. package/dist/pages/BundleSize/components/index_module.css +4 -0
  12. package/dist/pages/BundleSize/components/search-modal.d.ts +7 -1
  13. package/dist/pages/BundleSize/components/search-modal.js +61 -30
  14. package/dist/pages/BundleSize/components/search-modal.js.map +1 -1
  15. package/dist/pages/ModuleAnalyze/fileTree.js +3 -3
  16. package/dist/pages/ModuleAnalyze/fileTree.js.map +1 -1
  17. package/dist/pages/ModuleAnalyze/index.d.ts +2 -1
  18. package/dist/pages/ModuleAnalyze/index.js +5 -0
  19. package/dist/pages/ModuleAnalyze/index.js.map +1 -1
  20. package/dist/pages/WebpackLoaders/Analysis/index.js +26 -3
  21. package/dist/pages/WebpackLoaders/Analysis/index.js.map +1 -1
  22. package/dist/pages/WebpackLoaders/Overall/index.js +27 -2
  23. package/dist/pages/WebpackLoaders/Overall/index.js.map +1 -1
  24. package/dist/utils/file.d.ts +13 -1
  25. package/dist/utils/file.js +78 -0
  26. package/dist/utils/file.js.map +1 -1
  27. package/dist/utils/i18n/cn.js +5 -1
  28. package/dist/utils/i18n/cn.js.map +1 -1
  29. package/dist/utils/i18n/en.d.ts +4 -0
  30. package/dist/utils/i18n/en.js +5 -1
  31. package/dist/utils/i18n/en.js.map +1 -1
  32. package/package.json +6 -6
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ export type TreeNode = {
3
+ name: string;
4
+ value?: number;
5
+ children?: TreeNode[];
6
+ path?: string;
7
+ sourceSize?: number;
8
+ bundledSize?: number;
9
+ };
10
+ interface TreeMapProps {
11
+ treeData: TreeNode[];
12
+ valueKey?: 'sourceSize' | 'bundledSize';
13
+ style?: React.CSSProperties;
14
+ onChartClick?: (params: any) => void;
15
+ }
16
+ export declare const TreeMap: React.ForwardRefExoticComponent<TreeMapProps & React.RefAttributes<any>>;
17
+ export declare const AssetTreemapWithFilter: React.FC<{
18
+ treeData: TreeNode[];
19
+ onChartClick?: (params: any) => void;
20
+ }>;
21
+ export {};
@@ -0,0 +1,284 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import React, { useEffect, useState, memo, useMemo } from "react";
3
+ import ReactEChartsCore from "echarts-for-react/lib/core";
4
+ import * as echarts from "echarts/core";
5
+ import { TreemapChart } from "echarts/charts";
6
+ import { TooltipComponent } from "echarts/components";
7
+ import { CanvasRenderer } from "echarts/renderers";
8
+ import { BUNDLE_ANALYZER_COLORS, COLOR_GROUPS } from "./constants";
9
+ import { Checkbox, Card, Typography, Space } from "antd";
10
+ import {
11
+ VerticalAlignBottomOutlined,
12
+ VerticalAlignTopOutlined
13
+ } from "@ant-design/icons";
14
+ import { formatSize, useI18n } from "../../utils";
15
+ import { SearchModal } from "../../pages/BundleSize/components/search-modal";
16
+ function hashString(str) {
17
+ let hash = 5381;
18
+ for (let i = 0; i < str.length; i++) {
19
+ hash = (hash << 5) + hash + str.charCodeAt(i);
20
+ }
21
+ return hash >>> 0;
22
+ }
23
+ function getLevelOption() {
24
+ return [
25
+ {
26
+ itemStyle: {
27
+ color: "white",
28
+ borderColor: "#eee",
29
+ borderWidth: 5,
30
+ gapWidth: 5
31
+ },
32
+ emphasis: {
33
+ itemStyle: {
34
+ borderColor: "#a29f9f"
35
+ }
36
+ }
37
+ },
38
+ {
39
+ colorSaturation: [0.25, 0.5],
40
+ itemStyle: {
41
+ borderWidth: 5,
42
+ gapWidth: 5,
43
+ borderColorSaturation: 0.5,
44
+ borderColor: "#eee"
45
+ }
46
+ }
47
+ ];
48
+ }
49
+ const TreeMapInner = memo(
50
+ ({
51
+ treeData,
52
+ valueKey = "sourceSize",
53
+ style,
54
+ onChartClick,
55
+ forwardedRef
56
+ }) => {
57
+ const [option, setOption] = useState(null);
58
+ const chartRef = React.useRef(null);
59
+ useEffect(() => {
60
+ if (forwardedRef && chartRef.current) {
61
+ if (typeof forwardedRef === "function") {
62
+ forwardedRef(chartRef.current);
63
+ } else {
64
+ forwardedRef.current = chartRef.current;
65
+ }
66
+ }
67
+ }, [forwardedRef, chartRef.current]);
68
+ useEffect(() => {
69
+ echarts.use([TreemapChart, TooltipComponent, CanvasRenderer]);
70
+ }, []);
71
+ useEffect(() => {
72
+ if (!treeData)
73
+ return;
74
+ function convert(node, colorGroup, level = 0) {
75
+ const groupColors = BUNDLE_ANALYZER_COLORS[colorGroup];
76
+ const children = node.children?.map(
77
+ (c, _i) => convert(c, colorGroup, level + 1)
78
+ );
79
+ return {
80
+ id: node.path ? hashString(node.path) : void 0,
81
+ name: node.name,
82
+ value: node[valueKey] ?? node.value ?? 0,
83
+ path: node.path,
84
+ sourceSize: node.sourceSize ?? node.value,
85
+ bundledSize: node.bundledSize,
86
+ children: children && children.length > 0 ? children : void 0,
87
+ itemStyle: {
88
+ borderWidth: 2,
89
+ gapWidth: 2,
90
+ borderColorSaturation: 0.2,
91
+ colorSaturation: 0.2,
92
+ color: groupColors[level % groupColors.length],
93
+ borderColor: groupColors[level % groupColors.length]
94
+ },
95
+ level
96
+ };
97
+ }
98
+ const data = treeData.map((item, index) => {
99
+ const group = COLOR_GROUPS[index % COLOR_GROUPS.length];
100
+ return convert(item, group, 0);
101
+ });
102
+ setOption({
103
+ title: {
104
+ text: "Bundle Tree Map",
105
+ left: "center"
106
+ },
107
+ tooltip: {
108
+ position: "top",
109
+ formatter: function(info) {
110
+ var treePathInfo = info.treePathInfo;
111
+ var treePath = [];
112
+ for (var i = 1; i < treePathInfo.length; i++) {
113
+ treePath.push(treePathInfo[i].name);
114
+ }
115
+ var node = info.data || {};
116
+ var path = node.path || treePath.join("/");
117
+ var sourceSize = node.sourceSize;
118
+ var bundledSize = node.bundledSize;
119
+ return [
120
+ '<div class="tooltip-title">' + echarts.format.encodeHTML(path) + "</div>",
121
+ "<div><b>Source Size:</b> <b>" + (sourceSize !== void 0 ? formatSize(sourceSize) : "-") + "</b></div>",
122
+ "<div><b>Bundled Size:</b> <b>" + (bundledSize !== void 0 ? formatSize(bundledSize) : "-") + "</b></div>"
123
+ ].join("");
124
+ }
125
+ },
126
+ series: [
127
+ {
128
+ name: "Bundle Tree Map",
129
+ id: "bundle-treemap",
130
+ type: "treemap",
131
+ visibleMin: 300,
132
+ left: 10,
133
+ right: 10,
134
+ top: 10,
135
+ bottom: 10,
136
+ label: {
137
+ show: true,
138
+ formatter: "{b}",
139
+ color: "#000"
140
+ },
141
+ upperLabel: {
142
+ show: true,
143
+ height: 30
144
+ },
145
+ levels: getLevelOption(),
146
+ data
147
+ }
148
+ ]
149
+ });
150
+ }, [treeData, valueKey]);
151
+ return option ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
152
+ ReactEChartsCore,
153
+ {
154
+ ref: chartRef,
155
+ option,
156
+ echarts,
157
+ onEvents: onChartClick ? { click: onChartClick } : void 0,
158
+ style: {
159
+ width: "100%",
160
+ minHeight: "500px",
161
+ maxHeight: "1000px",
162
+ border: "5px solid white",
163
+ borderRadius: "10px",
164
+ ...style
165
+ }
166
+ }
167
+ ) }) : null;
168
+ }
169
+ );
170
+ const TreeMap = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(TreeMapInner, { ...props, forwardedRef: ref }));
171
+ const AssetTreemapWithFilter = ({ treeData, onChartClick }) => {
172
+ const assetNames = useMemo(
173
+ () => treeData.map((item) => item.name),
174
+ [treeData]
175
+ );
176
+ const [checkedAssets, setCheckedAssets] = useState(assetNames);
177
+ const [collapsed, setCollapsed] = useState(false);
178
+ const [searchModalOpen, setSearchModalOpen] = useState(false);
179
+ const chartRef = React.useRef(null);
180
+ const { t } = useI18n();
181
+ const filteredTreeData = useMemo(
182
+ () => treeData.filter((item) => checkedAssets.includes(item.name)),
183
+ [treeData, checkedAssets]
184
+ );
185
+ const handleModuleClick = (module) => {
186
+ if (!module?.path)
187
+ return;
188
+ const nodeId = hashString(module.path);
189
+ if (chartRef.current) {
190
+ const echartsInstance = chartRef.current.getEchartsInstance();
191
+ echartsInstance.dispatchAction({
192
+ type: "treemapZoomToNode",
193
+ seriesId: "bundle-treemap",
194
+ targetNodeId: nodeId.toString()
195
+ });
196
+ echartsInstance.dispatchAction({
197
+ type: "highlight",
198
+ seriesId: "bundle-treemap",
199
+ targetNodeId: nodeId.toString()
200
+ });
201
+ }
202
+ setSearchModalOpen(false);
203
+ };
204
+ return /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: /* @__PURE__ */ jsxs(Space, { direction: "vertical", style: { width: "100%" }, children: [
205
+ /* @__PURE__ */ jsx(
206
+ Card,
207
+ {
208
+ title: /* @__PURE__ */ jsxs(Space, { children: [
209
+ /* @__PURE__ */ jsx(Typography.Text, { children: t("Output Assets List") }),
210
+ /* @__PURE__ */ jsx(
211
+ SearchModal,
212
+ {
213
+ onModuleClick: handleModuleClick,
214
+ open: searchModalOpen,
215
+ setOpen: setSearchModalOpen,
216
+ isIcon: true
217
+ }
218
+ )
219
+ ] }),
220
+ extra: /* @__PURE__ */ jsx(
221
+ "span",
222
+ {
223
+ style: { cursor: "pointer", marginLeft: 8 },
224
+ onClick: () => setCollapsed((c) => !c),
225
+ "aria-label": collapsed ? t("Expand") : t("Collapse"),
226
+ children: collapsed ? /* @__PURE__ */ jsx(VerticalAlignBottomOutlined, {}) : /* @__PURE__ */ jsx(VerticalAlignTopOutlined, {})
227
+ }
228
+ ),
229
+ size: "small",
230
+ bodyStyle: {
231
+ overflow: "hidden",
232
+ height: collapsed ? 0 : void 0,
233
+ padding: collapsed ? 0 : void 0,
234
+ transition: "height 0.3s cubic-bezier(.4,0,.2,1), padding 0.3s"
235
+ },
236
+ children: /* @__PURE__ */ jsxs(
237
+ "div",
238
+ {
239
+ style: {
240
+ opacity: collapsed ? 0 : 1,
241
+ transition: "opacity 0.3s",
242
+ gap: 8
243
+ },
244
+ children: [
245
+ /* @__PURE__ */ jsx(
246
+ Checkbox,
247
+ {
248
+ indeterminate: checkedAssets.length > 0 && checkedAssets.length < assetNames.length,
249
+ checked: checkedAssets.length === assetNames.length,
250
+ onChange: (e) => setCheckedAssets(e.target.checked ? assetNames : []),
251
+ style: { marginBottom: 4 },
252
+ children: "ALL / NONE"
253
+ }
254
+ ),
255
+ /* @__PURE__ */ jsx(
256
+ Checkbox.Group,
257
+ {
258
+ options: assetNames,
259
+ value: checkedAssets,
260
+ onChange: setCheckedAssets,
261
+ style: { display: "flex", gap: 8, fontWeight: 500 }
262
+ }
263
+ )
264
+ ]
265
+ }
266
+ )
267
+ }
268
+ ),
269
+ /* @__PURE__ */ jsx("div", { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
270
+ TreeMap,
271
+ {
272
+ ref: chartRef,
273
+ treeData: filteredTreeData,
274
+ onChartClick
275
+ }
276
+ ) })
277
+ ] }) });
278
+ };
279
+ export {
280
+ AssetTreemapWithFilter,
281
+ TreeMap
282
+ };
283
+
284
+ //# sourceMappingURL=TreeMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"mappings":"AAkMU,cAmEE,YAnEF;AAlMV,OAAO,SAAS,WAAW,UAAU,MAAM,eAAe;AAC1D,OAAO,sBAAsB;AAC7B,YAAY,aAAa;AACzB,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB,oBAAoB;AACrD,SAAS,UAAU,MAAM,YAAY,aAAa;AAClD;AAAA,EACE;AAAA,EACA;AAAA,OACK;A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AAC;AAAA,YACrC,cAAY,YAAY,EAAE,QAAQ,IAAI,EAAE,UAAU;AAAA,YAEjD,sBACC,oBAAC,+BAA4B,IAE7B,oBAAC,4BAAyB;AAAA;AAAA,QAE9B;AAAA,QAEF,MAAK;AAAA,QACL,WAAW;AAAA,UACT,UAAU;AAAA,UACV,QAAQ,YAAY,IAAI;AAAA,UACxB,SAAS,YAAY,IAAI;AAAA,UACzB,YAAY;AAAA,QACd;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,SAAS,YAAY,IAAI;AAAA,cACzB,YAAY;AAAA,cACZ,KAAK;AAAA,YACP;AAAA,YAEA;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,eACE,cAAc,SAAS,KACvB,cAAc,SAAS,WAAW;AAAA,kBAEpC,SAAS,cAAc,WAAW,WAAW;AAAA,kBAC7C,UAAU,CAAC,MACT,iBAAiB,EAAE,OAAO,UAAU,aAAa,CAAC,CAAC;AAAA,kBAErD,OAAO,EAAE,cAAc,EAAE;AAAA,kBAExB;AAAA;AAAA,cACH;AAAA,cACA;AAAA,gBAAC,SAAS;AAAA,gBAAT;AAAA,kBACC,SAAS;AAAA,kBACT,OAAO;AAAA,kBACP,UAAU;AAAA,kBACV,OAAO,EAAE,SAAS,QAAQ,KAAK,GAAG,YAAY,IAAI;AAAA;AAAA,cACpD;AAAA;AAAA;AAAA,QACF;AAAA;AAAA,IACF;AAAA,IACA,oBAAC,SAAI,OAAO,EAAE,MAAM,EAAE,GACpB;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,UAAU;AAAA,QACV;AAAA;AAAA,IACF,GACF;AAAA,KACF,GACF;AAEJ","names":[],"ignoreList":[],"sources":["../../../src/components/Charts/TreeMap.tsx"],"sourcesContent":["import React, { useEffect, useState, memo, useMemo } from 'react';\nimport ReactEChartsCore from 'echarts-for-react/lib/core';\nimport * as echarts from 'echarts/core';\nimport { TreemapChart } from 'echarts/charts';\nimport { TooltipComponent } from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { BUNDLE_ANALYZER_COLORS, COLOR_GROUPS } from './constants';\nimport { Checkbox, Card, Typography, Space } from 'antd';\nimport {\n VerticalAlignBottomOutlined,\n VerticalAlignTopOutlined,\n} from '@ant-design/icons';\nimport { formatSize, useI18n } from '../../utils';\nimport { SearchModal } from '../../pages/BundleSize/components/search-modal';\n\n// TreeNode type should match the output of flattenTreemapData\nexport type TreeNode = {\n name: string;\n value?: number;\n children?: TreeNode[];\n path?: string;\n sourceSize?: number;\n bundledSize?: number;\n};\n\ninterface TreeMapProps {\n treeData: TreeNode[];\n valueKey?: 'sourceSize' | 'bundledSize'; // which value to show as area\n style?: React.CSSProperties;\n onChartClick?: (params: any) => void;\n}\n\n// Simple hash function for string (djb2)\nfunction hashString(str: string): number {\n let hash = 5381;\n for (let i = 0; i < str.length; i++) {\n hash = (hash << 5) + hash + str.charCodeAt(i); /* hash * 33 + c */\n }\n return hash >>> 0; // Ensure unsigned\n}\n\nfunction getLevelOption() {\n return [\n {\n itemStyle: {\n color: 'white',\n borderColor: '#eee',\n borderWidth: 5,\n gapWidth: 5,\n },\n emphasis: {\n itemStyle: {\n borderColor: '#a29f9f',\n },\n },\n },\n {\n colorSaturation: [0.25, 0.5],\n itemStyle: {\n borderWidth: 5,\n gapWidth: 5,\n borderColorSaturation: 0.5,\n borderColor: '#eee',\n },\n },\n ];\n}\n\nconst TreeMapInner: React.FC<TreeMapProps & { forwardedRef?: React.Ref<any> }> =\n memo(\n ({\n treeData,\n valueKey = 'sourceSize',\n style,\n onChartClick,\n forwardedRef,\n }) => {\n const [option, setOption] = useState<any>(null);\n const chartRef = React.useRef<any>(null);\n\n // Expose chartRef to parent if forwardedRef is provided\n useEffect(() => {\n if (forwardedRef && chartRef.current) {\n if (typeof forwardedRef === 'function') {\n forwardedRef(chartRef.current);\n } else {\n (forwardedRef as React.MutableRefObject<any>).current =\n chartRef.current;\n }\n }\n }, [forwardedRef, chartRef.current]);\n\n // Register ECharts components\n useEffect(() => {\n echarts.use([TreemapChart, TooltipComponent, CanvasRenderer]);\n }, []);\n\n useEffect(() => {\n if (!treeData) return;\n // Helper to recursively add value field for ECharts\n function convert(\n node: TreeNode,\n colorGroup: keyof typeof BUNDLE_ANALYZER_COLORS,\n level = 0,\n ): any {\n const groupColors = BUNDLE_ANALYZER_COLORS[colorGroup];\n const children = node.children?.map((c, _i) =>\n convert(c, colorGroup, level + 1),\n );\n\n return {\n id: node.path ? hashString(node.path) : undefined,\n name: node.name,\n value: node[valueKey] ?? node.value ?? 0,\n path: node.path,\n sourceSize: node.sourceSize ?? node.value,\n bundledSize: node.bundledSize,\n children: children && children.length > 0 ? children : undefined,\n itemStyle: {\n borderWidth: 2,\n gapWidth: 2,\n borderColorSaturation: 0.2,\n colorSaturation: 0.2,\n color: groupColors[level % groupColors.length],\n borderColor: groupColors[level % groupColors.length],\n },\n level,\n };\n }\n const data = treeData.map((item, index) => {\n const group = COLOR_GROUPS[index % COLOR_GROUPS.length];\n return convert(item, group, 0);\n });\n\n setOption({\n title: {\n text: 'Bundle Tree Map',\n left: 'center',\n },\n tooltip: {\n position: 'top',\n formatter: function (info: any) {\n var treePathInfo = info.treePathInfo;\n var treePath = [];\n for (var i = 1; i < treePathInfo.length; i++) {\n treePath.push(treePathInfo[i].name);\n }\n // Get extra info from node data\n var node = info.data || {};\n var path = node.path || treePath.join('/');\n var sourceSize = node.sourceSize;\n var bundledSize = node.bundledSize;\n return [\n '<div class=\"tooltip-title\">' +\n echarts.format.encodeHTML(path) +\n '</div>',\n '<div><b>Source Size:</b> <b>' +\n (sourceSize !== undefined ? formatSize(sourceSize) : '-') +\n '</b></div>',\n '<div><b>Bundled Size:</b> <b>' +\n (bundledSize !== undefined ? formatSize(bundledSize) : '-') +\n '</b></div>',\n ].join('');\n },\n },\n series: [\n {\n name: 'Bundle Tree Map',\n id: 'bundle-treemap',\n type: 'treemap',\n visibleMin: 300,\n left: 10,\n right: 10,\n top: 10,\n bottom: 10,\n label: {\n show: true,\n formatter: '{b}',\n color: '#000',\n },\n upperLabel: {\n show: true,\n height: 30,\n },\n\n levels: getLevelOption(),\n data: data,\n },\n ],\n });\n }, [treeData, valueKey]);\n\n return option ? (\n <div>\n <ReactEChartsCore\n ref={chartRef}\n option={option}\n echarts={echarts}\n onEvents={onChartClick ? { click: onChartClick } : undefined}\n style={{\n width: '100%',\n minHeight: '500px',\n maxHeight: '1000px',\n border: '5px solid white',\n borderRadius: '10px',\n ...style,\n }}\n />\n </div>\n ) : null;\n },\n );\n\nexport const TreeMap = React.forwardRef<any, TreeMapProps>((props, ref) => (\n <TreeMapInner {...props} forwardedRef={ref} />\n));\n\nexport const AssetTreemapWithFilter: React.FC<{\n treeData: TreeNode[];\n onChartClick?: (params: any) => void;\n}> = ({ treeData, onChartClick }) => {\n const assetNames = useMemo(\n () => treeData.map((item) => item.name),\n [treeData],\n );\n const [checkedAssets, setCheckedAssets] = useState<string[]>(assetNames);\n const [collapsed, setCollapsed] = useState(false);\n const [searchModalOpen, setSearchModalOpen] = useState(false);\n const chartRef = React.useRef<any>(null);\n const { t } = useI18n();\n\n const filteredTreeData = useMemo(\n () => treeData.filter((item) => checkedAssets.includes(item.name)),\n [treeData, checkedAssets],\n );\n\n // Handler for search modal click\n const handleModuleClick = (module: any) => {\n if (!module?.path) return;\n const nodeId = hashString(module.path);\n if (chartRef.current) {\n const echartsInstance = chartRef.current.getEchartsInstance();\n echartsInstance.dispatchAction({\n type: 'treemapZoomToNode',\n seriesId: 'bundle-treemap',\n targetNodeId: nodeId.toString(),\n });\n echartsInstance.dispatchAction({\n type: 'highlight',\n seriesId: 'bundle-treemap',\n targetNodeId: nodeId.toString(),\n });\n }\n setSearchModalOpen(false);\n };\n\n return (\n <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>\n <Space direction=\"vertical\" style={{ width: '100%' }}>\n <Card\n title={\n <Space>\n <Typography.Text>{t('Output Assets List')}</Typography.Text>\n <SearchModal\n onModuleClick={handleModuleClick}\n open={searchModalOpen}\n setOpen={setSearchModalOpen}\n isIcon={true}\n />\n </Space>\n }\n extra={\n <span\n style={{ cursor: 'pointer', marginLeft: 8 }}\n onClick={() => setCollapsed((c) => !c)}\n aria-label={collapsed ? t('Expand') : t('Collapse')}\n >\n {collapsed ? (\n <VerticalAlignBottomOutlined />\n ) : (\n <VerticalAlignTopOutlined />\n )}\n </span>\n }\n size=\"small\"\n bodyStyle={{\n overflow: 'hidden',\n height: collapsed ? 0 : undefined,\n padding: collapsed ? 0 : undefined,\n transition: 'height 0.3s cubic-bezier(.4,0,.2,1), padding 0.3s',\n }}\n >\n <div\n style={{\n opacity: collapsed ? 0 : 1,\n transition: 'opacity 0.3s',\n gap: 8,\n }}\n >\n <Checkbox\n indeterminate={\n checkedAssets.length > 0 &&\n checkedAssets.length < assetNames.length\n }\n checked={checkedAssets.length === assetNames.length}\n onChange={(e) =>\n setCheckedAssets(e.target.checked ? assetNames : [])\n }\n style={{ marginBottom: 4 }}\n >\n {'ALL / NONE'}\n </Checkbox>\n <Checkbox.Group\n options={assetNames}\n value={checkedAssets}\n onChange={setCheckedAssets}\n style={{ display: 'flex', gap: 8, fontWeight: 500 }}\n />\n </div>\n </Card>\n <div style={{ flex: 1 }}>\n <TreeMap\n ref={chartRef}\n treeData={filteredTreeData}\n onChartClick={onChartClick}\n />\n </div>\n </Space>\n </div>\n );\n};\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJtYXBwaW5ncyI6IiIsIm5hbWVzIjpbXSwiaWdub3JlTGlzdCI6W10sInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W119"]}
@@ -7,3 +7,13 @@ export declare enum ChartTypes {
7
7
  Loader = 4,
8
8
  Normal = 5
9
9
  }
10
+ export declare const BUNDLE_ANALYZER_COLORS: {
11
+ readonly green: readonly [string, string, string, string, string, string, string];
12
+ readonly blue: readonly [string, string, string, string, string, string, string];
13
+ readonly purple: readonly [string, string, string, string, string, string, string];
14
+ readonly yellow: readonly [string, string, string, string, string, string, string];
15
+ readonly grey: readonly [string, string, string, string, string, string, string];
16
+ };
17
+ type ColorGroup = keyof typeof BUNDLE_ANALYZER_COLORS;
18
+ export declare const COLOR_GROUPS: ColorGroup[];
19
+ export {};
@@ -36,7 +36,69 @@ var ChartTypes = /* @__PURE__ */ ((ChartTypes2) => {
36
36
  ChartTypes2[ChartTypes2["Normal"] = 5] = "Normal";
37
37
  return ChartTypes2;
38
38
  })(ChartTypes || {});
39
+ const BUNDLE_ANALYZER_COLORS = {
40
+ green: [
41
+ hexToRgba("#32b26a", 0.6),
42
+ hexToRgba("#5fcf92", 0.6),
43
+ hexToRgba("#8ee2b6", 0.8),
44
+ hexToRgba("#b7e1cd", 1),
45
+ hexToRgba("#cdeee0", 1),
46
+ hexToRgba("#e0f7ef", 1),
47
+ hexToRgba("#c8e6d6", 1)
48
+ ],
49
+ blue: [
50
+ hexToRgba("#3498f7", 0.6),
51
+ hexToRgba("#5eb3fa", 0.6),
52
+ hexToRgba("#8ccafc", 0.8),
53
+ hexToRgba("#b3d8f8", 1),
54
+ hexToRgba("#cde6fa", 1),
55
+ hexToRgba("#e0f2fd", 1),
56
+ hexToRgba("#c8e0ef", 1)
57
+ ],
58
+ purple: [
59
+ hexToRgba("#a04ddb", 0.6),
60
+ hexToRgba("#b26ef0", 0.6),
61
+ hexToRgba("#c49ff5", 0.8),
62
+ hexToRgba("#d1b3e6", 1),
63
+ hexToRgba("#e0c8f2", 1),
64
+ hexToRgba("#f0e6fa", 1),
65
+ hexToRgba("#d6c8e6", 1)
66
+ ],
67
+ yellow: [
68
+ hexToRgba("#ffe066", 0.6),
69
+ hexToRgba("#ffec80", 0.6),
70
+ hexToRgba("#fff599", 0.8),
71
+ hexToRgba("#fff9c4", 1),
72
+ hexToRgba("#fffbe0", 1),
73
+ hexToRgba("#fffde7", 1),
74
+ hexToRgba("#f5f2c8", 1)
75
+ ],
76
+ grey: [
77
+ hexToRgba("#7a7a7a", 0.7),
78
+ hexToRgba("#969696", 0.7),
79
+ hexToRgba("#b0b0b0", 0.8),
80
+ hexToRgba("#c8c8c8", 1),
81
+ hexToRgba("#dcdcdc", 1),
82
+ hexToRgba("#ededed", 1),
83
+ hexToRgba("#f7f7f7", 1)
84
+ ]
85
+ };
86
+ function hexToRgba(hex, alpha = 1) {
87
+ const r = parseInt(hex.slice(1, 3), 16);
88
+ const g = parseInt(hex.slice(3, 5), 16);
89
+ const b = parseInt(hex.slice(5, 7), 16);
90
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
91
+ }
92
+ const COLOR_GROUPS = [
93
+ "blue",
94
+ "purple",
95
+ "yellow",
96
+ "grey",
97
+ "green"
98
+ ];
39
99
  export {
100
+ BUNDLE_ANALYZER_COLORS,
101
+ COLOR_GROUPS,
40
102
  ChartTypes,
41
103
  PALETTE_COLORS
42
104
  };
@@ -1 +1 @@
1
- {"version":3,"mappings":"AAAO,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,wBAAA;AACA,EAAAA,wBAAA;AACA,EAAAA,wBAAA;AACA,EAAAA,wBAAA;AACA,EAAAA,wBAAA;AACA,EAAAA,wBAAA;AANU,SAAAA;AAAA","names":["ChartTypes"],"ignoreList":[],"sources":["../../../src/components/Charts/constants.ts"],"sourcesContent":["export const PALETTE_COLORS = [\n '#F2793D',\n '#F28B24',\n '#F2A200',\n '#F5CC00',\n '#F5E000',\n '#A3D900',\n '#66CC00',\n '#0AC419',\n '#0AC496',\n '#0AC7D1',\n '#00A8E0',\n '#1471F5',\n '#4060FF',\n '#7559FF',\n '#884DFF',\n '#A526FF',\n '#BA39E5',\n '#C700D9',\n '#D900B5',\n '#E50099',\n '#E52E6B',\n '#F24957',\n '#30B2F2',\n '#00BF70',\n '#5959FF',\n '#9F40FF',\n '#528BFF',\n];\n\nexport enum ChartTypes {\n Bootstrap,\n Compile,\n Done,\n Minify,\n Loader,\n Normal,\n}\n"]}
1
+ {"version":3,"mappings":"AAAO,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,wBAAA;AACA,EAAAA,wBAAA;AACA,EAAAA,wBAAA;AACA,EAAAA,wBAAA;AACA,EAAAA,wBAAA;AACA,EAAAA,wBAAA;AANU,SAAAA;AAAA;AASL,MAAM,yBAAyB;AAAA,EACpC,OAAO;AAAA,IACL,UAAU,WAAW,GAAG;AAAA,IACxB,UAAU,WAAW,GAAG;AAAA,IACxB,UAAU,WAAW,GAAG;AAAA,IACxB,UAAU,WAAW,CAAC;AAAA,IACtB,UAAU,WAAW,CAAC;AAAA,IACtB,UAAU,WAAW,CAAC;AAAA,IACtB,UAAU,WAAW,CAAC;AAAA,EACxB;AAAA,EACA,MAAM;AAAA,IACJ,UAAU,WAAW,GAAG;AAAA,IACxB,UAAU,WAAW,GAAG;AAAA,IACxB,UAAU,WAAW,GAAG;AAAA,IACxB,UAAU,WAAW,CAAC;AAAA,IACtB,UAAU,WA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export const PALETTE_COLORS = [\n '#F2793D',\n '#F28B24',\n '#F2A200',\n '#F5CC00',\n '#F5E000',\n '#A3D900',\n '#66CC00',\n '#0AC419',\n '#0AC496',\n '#0AC7D1',\n '#00A8E0',\n '#1471F5',\n '#4060FF',\n '#7559FF',\n '#884DFF',\n '#A526FF',\n '#BA39E5',\n '#C700D9',\n '#D900B5',\n '#E50099',\n '#E52E6B',\n '#F24957',\n '#30B2F2',\n '#00BF70',\n '#5959FF',\n '#9F40FF',\n '#528BFF',\n];\n\nexport enum ChartTypes {\n Bootstrap,\n Compile,\n Done,\n Minify,\n Loader,\n Normal,\n}\n\nexport const BUNDLE_ANALYZER_COLORS = {\n green: [\n hexToRgba('#32b26a', 0.6),\n hexToRgba('#5fcf92', 0.6),\n hexToRgba('#8ee2b6', 0.8),\n hexToRgba('#b7e1cd', 1),\n hexToRgba('#cdeee0', 1),\n hexToRgba('#e0f7ef', 1),\n hexToRgba('#c8e6d6', 1),\n ],\n blue: [\n hexToRgba('#3498f7', 0.6),\n hexToRgba('#5eb3fa', 0.6),\n hexToRgba('#8ccafc', 0.8),\n hexToRgba('#b3d8f8', 1),\n hexToRgba('#cde6fa', 1),\n hexToRgba('#e0f2fd', 1),\n hexToRgba('#c8e0ef', 1),\n ],\n purple: [\n hexToRgba('#a04ddb', 0.6),\n hexToRgba('#b26ef0', 0.6),\n hexToRgba('#c49ff5', 0.8),\n hexToRgba('#d1b3e6', 1),\n hexToRgba('#e0c8f2', 1),\n hexToRgba('#f0e6fa', 1),\n hexToRgba('#d6c8e6', 1),\n ],\n yellow: [\n hexToRgba('#ffe066', 0.6),\n hexToRgba('#ffec80', 0.6),\n hexToRgba('#fff599', 0.8),\n hexToRgba('#fff9c4', 1),\n hexToRgba('#fffbe0', 1),\n hexToRgba('#fffde7', 1),\n hexToRgba('#f5f2c8', 1),\n ],\n grey: [\n hexToRgba('#7a7a7a', 0.7),\n hexToRgba('#969696', 0.7),\n hexToRgba('#b0b0b0', 0.8),\n hexToRgba('#c8c8c8', 1),\n hexToRgba('#dcdcdc', 1),\n hexToRgba('#ededed', 1),\n hexToRgba('#f7f7f7', 1),\n ],\n} as const;\n\nfunction hexToRgba(hex: string, alpha = 1) {\n const r = parseInt(hex.slice(1, 3), 16);\n const g = parseInt(hex.slice(3, 5), 16);\n const b = parseInt(hex.slice(5, 7), 16);\n return `rgba(${r}, ${g}, ${b}, ${alpha})`;\n}\n\ntype ColorGroup = keyof typeof BUNDLE_ANALYZER_COLORS;\nexport const COLOR_GROUPS: ColorGroup[] = [\n 'blue',\n 'purple',\n 'yellow',\n 'grey',\n 'green',\n];\n"]}
@@ -2,7 +2,6 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import {
3
3
  CodepenCircleOutlined,
4
4
  ColumnHeightOutlined,
5
- DeploymentUnitOutlined,
6
5
  InfoCircleOutlined
7
6
  } from "@ant-design/icons";
8
7
  import { SDK } from "@rsdoctor/types";
@@ -281,6 +280,63 @@ const ModulesStatistics = ({ modules, chunks, filteredModules }) => {
281
280
  )
282
281
  ] });
283
282
  };
283
+ const ConcatenatedTag = ({ moduleCount }) => {
284
+ return /* @__PURE__ */ jsx(
285
+ Tooltip,
286
+ {
287
+ title: /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
288
+ "This is a concatenated container module that includes ",
289
+ moduleCount,
290
+ " ",
291
+ "modules"
292
+ ] }) }),
293
+ children: /* @__PURE__ */ jsx(Tag, { color: "blue", style: tagStyle, children: "concatenated container" })
294
+ }
295
+ );
296
+ };
297
+ const TotalBundledSizeTag = ({ size }) => {
298
+ return /* @__PURE__ */ jsx(
299
+ Tooltip,
300
+ {
301
+ title: /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsx(Typography.Text, { style: { color: "inherit" }, children: "The total output size of all the files in this folder. If you enabled minification, this value shows the minified size." }) }),
302
+ children: /* @__PURE__ */ jsx(Tag, { style: tagStyle, color: "geekblue", children: `bundled size: ${formatSize(size)}` })
303
+ }
304
+ );
305
+ };
306
+ const BundledSizeTag = ({ size }) => {
307
+ return /* @__PURE__ */ jsx(
308
+ Tooltip,
309
+ {
310
+ title: /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsx(Typography.Text, { style: { color: "inherit" }, children: "The final output size of this file. If you enabled minification, this value shows the minified size." }) }),
311
+ children: /* @__PURE__ */ jsx(Tag, { color: "geekblue", children: `bundled size: ${formatSize(size)}` })
312
+ }
313
+ );
314
+ };
315
+ const TotalSourceSizeTag = ({ size }) => {
316
+ return /* @__PURE__ */ jsx(
317
+ Tooltip,
318
+ {
319
+ title: /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsx(Typography.Text, { style: { color: "inherit" }, children: "The total original size of all the files in this folder, before any transformations and minification." }) }),
320
+ children: /* @__PURE__ */ jsx(
321
+ Tag,
322
+ {
323
+ style: tagStyle,
324
+ color: "cyan",
325
+ children: `source size: ${formatSize(size)}`
326
+ }
327
+ )
328
+ }
329
+ );
330
+ };
331
+ const SourceSizeTag = ({ size }) => {
332
+ return /* @__PURE__ */ jsx(
333
+ Tooltip,
334
+ {
335
+ title: /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsx(Typography.Text, { style: { color: "inherit" }, children: "The original size of this file, before any transformations and minification." }) }),
336
+ children: /* @__PURE__ */ jsx(Tag, { color: "cyan", children: `source size: ${formatSize(size)}` })
337
+ }
338
+ );
339
+ };
284
340
  const AssetDetail = ({
285
341
  asset,
286
342
  chunks: includeChunks,
@@ -318,42 +374,48 @@ const AssetDetail = ({
318
374
  (e) => e !== mod && e.modules && e.modules.indexOf(mod.id) > -1
319
375
  );
320
376
  return /* @__PURE__ */ jsxs("div", { className: styles["bundle-tree"], children: [
321
- /* @__PURE__ */ jsxs("div", { className: styles.box, children: [
322
- /* @__PURE__ */ jsx("div", { className: styles.keywords, children: /* @__PURE__ */ jsx(Keyword, { ellipsis: true, text: basename, keyword: "" }) }),
323
- /* @__PURE__ */ jsx("div", { className: styles.dividerDiv, children: /* @__PURE__ */ jsx(Divider, { className: styles.divider, dashed: true }) })
324
- ] }),
377
+ /* @__PURE__ */ jsx(
378
+ Popover,
379
+ {
380
+ content: `Open the ${basename}’s module reasons tree.`,
381
+ placement: "bottom",
382
+ children: /* @__PURE__ */ jsxs(
383
+ "div",
384
+ {
385
+ className: styles.box,
386
+ onClick: () => {
387
+ setModuleJumpList([mod.id]);
388
+ setShow(true);
389
+ },
390
+ children: [
391
+ /* @__PURE__ */ jsx("div", { className: styles.keywords, children: /* @__PURE__ */ jsx(Keyword, { ellipsis: true, text: basename, keyword: "" }) }),
392
+ /* @__PURE__ */ jsx("div", { className: styles.dividerDiv, children: /* @__PURE__ */ jsx(Divider, { className: styles.divider, dashed: true }) })
393
+ ]
394
+ }
395
+ )
396
+ }
397
+ ),
325
398
  /* @__PURE__ */ jsxs(Space, { children: [
326
399
  parsedSize !== 0 ? /* @__PURE__ */ jsx(
327
400
  Tooltip,
328
401
  {
329
402
  title: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
330
- /* @__PURE__ */ jsx(Tag, { color: "orange", children: `Bundled Size: ${formatSize(parsedSize)}` }),
331
- /* @__PURE__ */ jsx(Tag, { color: "volcano", children: `Source Size: ${formatSize(sourceSize)}` })
403
+ /* @__PURE__ */ jsx(BundledSizeTag, { size: parsedSize }),
404
+ /* @__PURE__ */ jsx(SourceSizeTag, { size: sourceSize })
332
405
  ] }),
333
406
  color: "white",
334
- children: /* @__PURE__ */ jsx(Tag, { color: "purple", style: tagStyle, children: `Bundled Size: ${formatSize(parsedSize)}` })
407
+ children: /* @__PURE__ */ jsx(BundledSizeTag, { size: parsedSize })
335
408
  }
336
409
  ) : sourceSize !== 0 ? (
337
410
  // fallback to display tag for source size
338
- /* @__PURE__ */ jsx(Tag, { color: "geekblue", children: `Source Size: ${formatSize(sourceSize)}` })
339
- ) : null,
340
- isConcatenation ? /* @__PURE__ */ jsx(
341
- Tooltip,
342
- {
343
- title: /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
344
- "this is a concatenated module, it contains",
345
- " ",
346
- mod.modules?.length,
347
- " modules"
348
- ] }) }),
349
- children: /* @__PURE__ */ jsx(Tag, { color: "green", style: tagStyle, children: "concatenated" })
350
- }
411
+ /* @__PURE__ */ jsx(SourceSizeTag, { size: sourceSize })
351
412
  ) : null,
413
+ isConcatenation ? /* @__PURE__ */ jsx(ConcatenatedTag, { moduleCount: mod.modules?.length || 0 }) : null,
352
414
  containedOtherModules && containedOtherModules.length ? /* @__PURE__ */ jsx(
353
415
  Tooltip,
354
416
  {
355
417
  title: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
356
- /* @__PURE__ */ jsx(Typography.Text, { style: { color: "inherit" }, children: "this is a concatenated module, it is be contained in these modules below:" }),
418
+ /* @__PURE__ */ jsx(Typography.Text, { style: { color: "inherit" }, children: "This module is concatenated into another container module:" }),
357
419
  containedOtherModules.map(({ id, path }) => {
358
420
  if (isJsDataUrl(path)) {
359
421
  return /* @__PURE__ */ jsx(
@@ -393,15 +455,6 @@ const AssetDetail = ({
393
455
  children: /* @__PURE__ */ jsx(Tag, { color: "green", children: "concatenated" })
394
456
  }
395
457
  ) : null,
396
- /* @__PURE__ */ jsx(Popover, { content: "Open the Module Graph Box", children: /* @__PURE__ */ jsx(
397
- DeploymentUnitOutlined,
398
- {
399
- onClick: () => {
400
- setModuleJumpList([mod.id]);
401
- setShow(true);
402
- }
403
- }
404
- ) }),
405
458
  /* @__PURE__ */ jsx(ModuleCodeViewer, { data: mod })
406
459
  ] })
407
460
  ] });
@@ -421,9 +474,9 @@ const AssetDetail = ({
421
474
  /* @__PURE__ */ jsx("div", { className: styles.dividerDiv, children: /* @__PURE__ */ jsx(Divider, { className: styles.divider, dashed: true }) })
422
475
  ] }),
423
476
  /* @__PURE__ */ jsx(Space, { children: parsedSize > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
424
- /* @__PURE__ */ jsx(Tag, { style: tagStyle, color: "orange", children: `Bundled: ${formatSize(parsedSize)}` }),
425
- /* @__PURE__ */ jsx(Tag, { style: tagStyle, color: "lime", children: `Source: ${formatSize(sourceSize)}` })
426
- ] }) : /* @__PURE__ */ jsx(Tag, { style: tagStyle, color: "lime", children: `Source: ${formatSize(sourceSize)}` }) })
477
+ /* @__PURE__ */ jsx(TotalBundledSizeTag, { size: parsedSize }),
478
+ /* @__PURE__ */ jsx(TotalSourceSizeTag, { size: sourceSize })
479
+ ] }) : /* @__PURE__ */ jsx(TotalSourceSizeTag, { size: sourceSize }) })
427
480
  ] });
428
481
  }
429
482
  return defaultTitle;