@rsdoctor/components 1.5.12 → 1.5.14-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 (58) hide show
  1. package/dist/components/Alerts/collapse-cjs-require.d.ts +1 -1
  2. package/dist/components/Alerts/collapse-cross-chunks.d.ts +1 -1
  3. package/dist/components/Alerts/collapse-esm-cjs.d.ts +1 -1
  4. package/dist/components/Alerts/collapse-module-mixed-chunks.d.ts +1 -1
  5. package/dist/components/Alerts/collapse-shared.d.ts +2 -2
  6. package/dist/components/Alerts/collapse-side-effects-only-imports.d.ts +1 -1
  7. package/dist/components/Alerts/collapse.d.ts +1 -1
  8. package/dist/components/Alerts/list.d.ts +1 -1
  9. package/dist/components/FileTree/index.d.ts +1 -1
  10. package/dist/components/Layout/header.d.ts +0 -1
  11. package/dist/components/Layout/header.mjs +14 -53
  12. package/dist/components/Layout/header.mjs.map +1 -1
  13. package/dist/components/Layout/header.module.mjs +15 -0
  14. package/dist/components/Layout/header.module.mjs.map +1 -0
  15. package/dist/components/Layout/header_module.css +88 -0
  16. package/dist/components/Layout/header_module.css.map +1 -0
  17. package/dist/components/Layout/index.mjs +10 -8
  18. package/dist/components/Layout/index.mjs.map +1 -1
  19. package/dist/components/Layout/index.module.mjs +7 -0
  20. package/dist/components/Layout/index.module.mjs.map +1 -0
  21. package/dist/components/Layout/index_module.css +11 -0
  22. package/dist/components/Layout/index_module.css.map +1 -0
  23. package/dist/components/Overall/DataSummary.d.ts +1 -1
  24. package/dist/components/Overall/help-center.d.ts +1 -1
  25. package/dist/components/Overall/overview.d.ts +1 -1
  26. package/dist/components/base/CodeViewer/index.d.ts +1 -1
  27. package/dist/components/base/CodeViewer/useCodeDrawer.d.ts +1 -1
  28. package/dist/components/base/DiffViewer/index.d.ts +1 -1
  29. package/dist/components/base/DiffViewer/useDiffDrawer.d.ts +1 -1
  30. package/dist/pages/BundleSize/components/asset.mjs +392 -323
  31. package/dist/pages/BundleSize/components/asset.mjs.map +1 -1
  32. package/dist/pages/BundleSize/components/asset.module.mjs +16 -0
  33. package/dist/pages/BundleSize/components/asset.module.mjs.map +1 -0
  34. package/dist/pages/BundleSize/components/asset_module.css +111 -0
  35. package/dist/pages/BundleSize/components/asset_module.css.map +1 -0
  36. package/dist/pages/BundleSize/components/index.d.ts +1 -1
  37. package/dist/pages/BundleSize/components/index.mjs +217 -553
  38. package/dist/pages/BundleSize/components/index.mjs.map +1 -1
  39. package/dist/pages/BundleSize/components/index.module.mjs +10 -7
  40. package/dist/pages/BundleSize/components/index.module.mjs.map +1 -1
  41. package/dist/pages/BundleSize/components/index_module.css +47 -59
  42. package/dist/pages/BundleSize/components/index_module.css.map +1 -1
  43. package/dist/pages/BundleSize/components/tree-graph.d.ts +7 -0
  44. package/dist/pages/BundleSize/components/tree-graph.mjs +366 -0
  45. package/dist/pages/BundleSize/components/tree-graph.mjs.map +1 -0
  46. package/dist/pages/BundleSize/index.mjs +1 -11
  47. package/dist/pages/BundleSize/index.mjs.map +1 -1
  48. package/dist/pages/Overall/responsiveLayout.d.ts +1 -1
  49. package/dist/pages/Resources/BundleDiff/DiffContainer/utils.d.ts +1 -1
  50. package/dist/pages/TreeShaking/editor.d.ts +1 -1
  51. package/dist/pages/TreeShaking/space.d.ts +1 -1
  52. package/dist/utils/file.d.ts +1 -1
  53. package/dist/utils/hooks.d.ts +7 -1
  54. package/dist/utils/hooks.mjs +73 -3
  55. package/dist/utils/hooks.mjs.map +1 -1
  56. package/package.json +13 -12
  57. package/dist/components/Layout/header.css +0 -28
  58. package/dist/components/Layout/header.css.map +0 -1
@@ -0,0 +1,366 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { CodeOutlined, InfoCircleOutlined } from "@ant-design/icons";
3
+ import { SDK } from "@rsdoctor/types";
4
+ import { Card, Col, Divider, Empty, InputNumber, Row, Select, Space, Tooltip, Typography } from "antd";
5
+ import { debounce, sumBy } from "es-toolkit/compat";
6
+ import { memo, useCallback, useEffect, useMemo, useState } from "react";
7
+ import { useCodeDrawer } from "../../../components/base/CodeViewer/useCodeDrawer.mjs";
8
+ import { Badge } from "../../../components/Badge/index.mjs";
9
+ import { FileTree } from "../../../components/FileTree/index.mjs";
10
+ import { KeywordInput } from "../../../components/Form/keyword.mjs";
11
+ import { Keyword } from "../../../components/Keyword/index.mjs";
12
+ import { ServerAPIProvider } from "../../../components/Manifest/index.mjs";
13
+ import { Size } from "../../../constants.mjs";
14
+ import { createFileStructures, formatSize, useI18n } from "../../../utils/index.mjs";
15
+ import { AssetDetail } from "./asset.mjs";
16
+ import index_module from "./index.module.mjs";
17
+ import "./index.css";
18
+ import { SearchModal } from "./search-modal.mjs";
19
+ const { Option: Option } = Select;
20
+ const TreeGraph = /*#__PURE__*/ memo(({ cwd, summary, entryPoints })=>{
21
+ const [selectedEntryPoints, setEntryPoints] = useState([]);
22
+ const [inputModule, setModuleValue] = useState(0);
23
+ const [inputAssetName, setAssetName] = useState('');
24
+ const [inputAssetSize, setAssetSize] = useState(0);
25
+ const [defaultExpandAll, setDefaultExpandAll] = useState(false);
26
+ const [inputModuleUnit, setModuleUnit] = useState('');
27
+ const [inputChunkUnit, setChunkUnit] = useState('');
28
+ const [assetPath, setAssetPath] = useState(null);
29
+ const { showCode, codeDrawerComponent } = useCodeDrawer('Do not have the codes of assets. If you use the lite or brief mode, there will have codes.');
30
+ const { t } = useI18n();
31
+ const assets = summary.all.total.files;
32
+ const handleChange = useCallback((type)=>(value)=>{
33
+ if ('module' === type) setModuleUnit(value);
34
+ else if ('chunk' === type) setChunkUnit(value);
35
+ }, []);
36
+ const selectAfter = (type)=>/*#__PURE__*/ jsxs(Select, {
37
+ defaultValue: "kb",
38
+ onChange: handleChange(type),
39
+ children: [
40
+ /*#__PURE__*/ jsx(Option, {
41
+ value: "kb",
42
+ children: "KB"
43
+ }),
44
+ /*#__PURE__*/ jsx(Option, {
45
+ value: "mb",
46
+ children: "MB"
47
+ })
48
+ ]
49
+ });
50
+ const onChangeModule = useCallback(debounce((newValue)=>{
51
+ const count = 'mb' === inputModuleUnit ? 1024 * newValue * 1024 : 1024 * newValue;
52
+ setModuleValue(count);
53
+ }, 300), []);
54
+ const onChangeAsset = useCallback(debounce((newValue)=>{
55
+ const count = 'mb' === inputChunkUnit ? 1024 * newValue * 1024 : 1024 * newValue;
56
+ setAssetSize(count);
57
+ }, 300), []);
58
+ const filteredAssets = useMemo(()=>{
59
+ let res = assets.slice();
60
+ if (inputAssetName) res = res.filter((e)=>e.path.indexOf(inputAssetName) > -1);
61
+ if (inputAssetSize > 0) res = res.filter((e)=>e.size >= inputAssetSize);
62
+ if (selectedEntryPoints.length) res = res.filter((e)=>{
63
+ if (selectedEntryPoints.some((ep)=>ep.assets.includes(e.path))) return true;
64
+ return false;
65
+ });
66
+ return res.sort((a, b)=>{
67
+ const _a = a.path.indexOf('/') > -1 ? 1 : 0;
68
+ const _b = b.path.indexOf('/') > -1 ? 1 : 0;
69
+ return _b - _a;
70
+ });
71
+ }, [
72
+ assets,
73
+ selectedEntryPoints,
74
+ inputAssetName,
75
+ inputAssetSize
76
+ ]);
77
+ useEffect(()=>{
78
+ function getFileExtension(filePath) {
79
+ const parts = filePath.split('.');
80
+ return parts.length > 1 ? parts.pop() : '';
81
+ }
82
+ summary.all.total.files.forEach((f)=>{
83
+ const ext = getFileExtension(f.path);
84
+ if ('js' === ext) setAssetPath(f.path);
85
+ });
86
+ }, [
87
+ summary.all.total.files
88
+ ]);
89
+ const assetsStructures = useMemo(()=>{
90
+ const res = createFileStructures({
91
+ files: filteredAssets.map((e)=>e.path).filter(Boolean),
92
+ fileTitle (file, basename) {
93
+ const target = filteredAssets.find((e)=>e.path === file);
94
+ const { size, initial, path, content } = target;
95
+ return /*#__PURE__*/ jsxs("div", {
96
+ className: index_module.assetBox,
97
+ onClick: ()=>{
98
+ setAssetPath(path);
99
+ },
100
+ children: [
101
+ /*#__PURE__*/ jsx(Keyword, {
102
+ text: basename,
103
+ keyword: '',
104
+ className: index_module.fileText
105
+ }),
106
+ /*#__PURE__*/ jsxs(Space, {
107
+ size: "small",
108
+ className: index_module.assetsTag,
109
+ children: [
110
+ /*#__PURE__*/ jsx(Divider, {
111
+ type: "vertical"
112
+ }),
113
+ /*#__PURE__*/ jsx(Typography.Text, {
114
+ style: {
115
+ color: '#4FD233'
116
+ },
117
+ children: formatSize(size)
118
+ }),
119
+ /*#__PURE__*/ jsx(Divider, {
120
+ type: "vertical"
121
+ }),
122
+ initial ? /*#__PURE__*/ jsx(Typography.Text, {
123
+ style: {
124
+ color: '#009A9E'
125
+ },
126
+ children: "initial"
127
+ }) : null,
128
+ /*#__PURE__*/ jsx(CodeOutlined, {
129
+ style: {
130
+ fontSize: 14,
131
+ padding: 0
132
+ },
133
+ onClick: ()=>showCode({
134
+ code: content,
135
+ filePath: path
136
+ })
137
+ })
138
+ ]
139
+ })
140
+ ]
141
+ });
142
+ }
143
+ });
144
+ return res;
145
+ }, [
146
+ filteredAssets
147
+ ]);
148
+ const onSearch = (value)=>{
149
+ setAssetName(value);
150
+ setDefaultExpandAll(false);
151
+ };
152
+ return /*#__PURE__*/ jsxs(Fragment, {
153
+ children: [
154
+ /*#__PURE__*/ jsxs("div", {
155
+ className: index_module.treeGraph,
156
+ children: [
157
+ /*#__PURE__*/ jsxs(Row, {
158
+ align: "middle",
159
+ gutter: [
160
+ Size.BasePadding,
161
+ Size.BasePadding
162
+ ],
163
+ children: [
164
+ entryPoints && entryPoints.length ? /*#__PURE__*/ jsx(Col, {
165
+ children: /*#__PURE__*/ jsx(Select, {
166
+ mode: "multiple",
167
+ value: selectedEntryPoints.map((e)=>e.name),
168
+ style: {
169
+ minWidth: 230,
170
+ width: 'auto',
171
+ maxWidth: 300
172
+ },
173
+ placeholder: 'filter assets by entry point',
174
+ onChange: (name)=>{
175
+ setEntryPoints(name.map((e)=>entryPoints.find((ep)=>ep.name === e)).filter(Boolean));
176
+ },
177
+ allowClear: true,
178
+ onClear: ()=>{
179
+ setEntryPoints([]);
180
+ },
181
+ children: entryPoints.map((e)=>/*#__PURE__*/ jsx(Select.Option, {
182
+ value: e.name,
183
+ children: /*#__PURE__*/ jsx(Space, {
184
+ children: /*#__PURE__*/ jsx(Badge, {
185
+ label: e.name,
186
+ value: formatSize(e.size),
187
+ tooltip: e.name
188
+ })
189
+ })
190
+ }, e.name))
191
+ })
192
+ }) : null,
193
+ /*#__PURE__*/ jsx(Col, {
194
+ children: /*#__PURE__*/ jsx(KeywordInput, {
195
+ placeholder: "search asset by keyword",
196
+ onChange: onSearch
197
+ })
198
+ }),
199
+ /*#__PURE__*/ jsx(Col, {
200
+ span: 6,
201
+ children: /*#__PURE__*/ jsx(InputNumber, {
202
+ min: 0,
203
+ style: {
204
+ width: '95%'
205
+ },
206
+ addonBefore: /*#__PURE__*/ jsxs(Space, {
207
+ children: [
208
+ /*#__PURE__*/ jsx(Typography.Text, {
209
+ style: {
210
+ fontSize: 14,
211
+ color: 'inherit'
212
+ },
213
+ children: "Asset Size"
214
+ }),
215
+ /*#__PURE__*/ jsx(Tooltip, {
216
+ title: t('filter the output assets which size is greater than the input value'),
217
+ style: {
218
+ marginLeft: 3
219
+ },
220
+ children: /*#__PURE__*/ jsx(InfoCircleOutlined, {
221
+ style: {
222
+ color: 'rgba(0,0,0,.45)'
223
+ }
224
+ })
225
+ })
226
+ ]
227
+ }),
228
+ onChange: (value)=>onChangeAsset(Number(value)),
229
+ addonAfter: selectAfter('chunk')
230
+ })
231
+ }),
232
+ /*#__PURE__*/ jsx(Col, {
233
+ span: 6,
234
+ children: /*#__PURE__*/ jsx(InputNumber, {
235
+ min: 0,
236
+ style: {
237
+ width: '95%'
238
+ },
239
+ addonBefore: /*#__PURE__*/ jsxs(Space, {
240
+ children: [
241
+ /*#__PURE__*/ jsx(Typography.Text, {
242
+ style: {
243
+ fontSize: 14,
244
+ color: 'inherit'
245
+ },
246
+ children: "Module Size"
247
+ }),
248
+ /*#__PURE__*/ jsx(Tooltip, {
249
+ title: t('filter the modules which size is greater than the input value'),
250
+ style: {
251
+ marginLeft: 3
252
+ },
253
+ children: /*#__PURE__*/ jsx(InfoCircleOutlined, {
254
+ style: {
255
+ color: 'rgba(0,0,0,.45)'
256
+ }
257
+ })
258
+ })
259
+ ]
260
+ }),
261
+ onChange: (value)=>{
262
+ onChangeModule(Number(value));
263
+ },
264
+ addonAfter: selectAfter('module')
265
+ })
266
+ })
267
+ ]
268
+ }),
269
+ /*#__PURE__*/ jsx(Row, {
270
+ children: /*#__PURE__*/ jsx(SearchModal, {})
271
+ }),
272
+ filteredAssets.length ? /*#__PURE__*/ jsxs("div", {
273
+ className: index_module.assetDetailRoot,
274
+ children: [
275
+ /*#__PURE__*/ jsx("div", {
276
+ className: index_module.assetDetailCol,
277
+ children: /*#__PURE__*/ jsx(Card, {
278
+ className: index_module.assetDetailFileTreeRoot,
279
+ classNames: {
280
+ body: index_module.assetDetailFileTreeBody
281
+ },
282
+ title: /*#__PURE__*/ jsxs(Space, {
283
+ children: [
284
+ /*#__PURE__*/ jsx(Typography.Text, {
285
+ children: t('Output Assets List')
286
+ }),
287
+ /*#__PURE__*/ jsx(Divider, {
288
+ type: "vertical"
289
+ }),
290
+ /*#__PURE__*/ jsx(Tooltip, {
291
+ title: `total assets count is ${assets.length}, the filtered assets count is ${filteredAssets.length}`,
292
+ children: /*#__PURE__*/ jsxs(Typography.Text, {
293
+ type: "secondary",
294
+ style: {
295
+ fontSize: 12,
296
+ fontWeight: 400
297
+ },
298
+ children: [
299
+ filteredAssets.length,
300
+ " / ",
301
+ assets.length
302
+ ]
303
+ })
304
+ }),
305
+ /*#__PURE__*/ jsx(Divider, {
306
+ type: "vertical"
307
+ }),
308
+ /*#__PURE__*/ jsx(Typography.Text, {
309
+ type: "secondary",
310
+ style: {
311
+ fontSize: 12,
312
+ fontWeight: 400
313
+ },
314
+ children: formatSize(sumBy(filteredAssets, (e)=>e.size))
315
+ })
316
+ ]
317
+ }),
318
+ size: "small",
319
+ children: /*#__PURE__*/ jsx("div", {
320
+ className: index_module.assetDetailFileTreeViewport,
321
+ children: /*#__PURE__*/ jsx("div", {
322
+ className: index_module.assetDetailFileTreeScrollArea,
323
+ children: /*#__PURE__*/ jsx(FileTree, {
324
+ className: index_module.assets,
325
+ treeData: assetsStructures,
326
+ autoExpandParent: true,
327
+ defaultExpandAll: defaultExpandAll || filteredAssets.length <= 20
328
+ }, `tree_${inputAssetName}_${defaultExpandAll}`)
329
+ })
330
+ })
331
+ })
332
+ }),
333
+ /*#__PURE__*/ jsx("div", {
334
+ className: index_module.assetDetailCol,
335
+ children: assetPath ? /*#__PURE__*/ jsx(ServerAPIProvider, {
336
+ api: SDK.ServerAPI.API.GetAssetDetails,
337
+ body: {
338
+ assetPath
339
+ },
340
+ children: (details)=>/*#__PURE__*/ jsx(AssetDetail, {
341
+ asset: details.asset,
342
+ chunks: details.chunks,
343
+ modules: details.modules,
344
+ moduleSizeLimit: inputModule,
345
+ root: cwd
346
+ })
347
+ }) : /*#__PURE__*/ jsx(Card, {
348
+ children: /*#__PURE__*/ jsx(Empty, {
349
+ description: /*#__PURE__*/ jsx(Typography.Text, {
350
+ strong: true,
351
+ children: "Click the file path on the left to show the modules of the asset"
352
+ })
353
+ })
354
+ })
355
+ })
356
+ ]
357
+ }) : /*#__PURE__*/ jsx(Empty, {})
358
+ ]
359
+ }),
360
+ codeDrawerComponent
361
+ ]
362
+ });
363
+ });
364
+ export { TreeGraph };
365
+
366
+ //# sourceMappingURL=tree-graph.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages/BundleSize/components/tree-graph.mjs","sources":["../../../../src/pages/BundleSize/components/tree-graph.tsx"],"sourcesContent":["import { CodeOutlined, InfoCircleOutlined } from '@ant-design/icons';\nimport { type Client, SDK } from '@rsdoctor/types';\nimport {\n Card,\n Col,\n Divider,\n Empty,\n InputNumber,\n Row,\n Select,\n Space,\n Tooltip,\n Typography,\n} from 'antd';\nimport { debounce, sumBy } from 'es-toolkit/compat';\nimport { memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport { useCodeDrawer } from 'src/components/base/CodeViewer/useCodeDrawer';\nimport { Badge as Bdg } from '../../../components/Badge';\nimport { FileTree } from '../../../components/FileTree';\nimport { KeywordInput } from '../../../components/Form/keyword';\nimport { Keyword } from '../../../components/Keyword';\nimport { ServerAPIProvider } from '../../../components/Manifest';\nimport { Size } from '../../../constants';\nimport { createFileStructures, formatSize, useI18n } from '../../../utils';\nimport { AssetDetail } from './asset';\nimport styles from './index.module.scss';\nimport './index.sass';\nimport { SearchModal } from './search-modal';\nconst { Option } = Select;\n\nexport const TreeGraph = memo(\n ({\n cwd,\n summary,\n entryPoints,\n }: {\n cwd: string;\n summary: Client.RsdoctorClientAssetsSummary;\n entryPoints: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetEntryPoints>;\n }) => {\n const [selectedEntryPoints, setEntryPoints] = useState<\n SDK.EntryPointData[]\n >([]);\n const [inputModule, setModuleValue] = useState(0);\n const [inputAssetName, setAssetName] = useState('');\n const [inputAssetSize, setAssetSize] = useState(0);\n const [defaultExpandAll, setDefaultExpandAll] = useState(false);\n const [inputModuleUnit, setModuleUnit] = useState('');\n const [inputChunkUnit, setChunkUnit] = useState('');\n const [assetPath, setAssetPath] = useState<string | null>(null);\n const { showCode, codeDrawerComponent } = useCodeDrawer(\n 'Do not have the codes of assets. If you use the lite or brief mode, there will have codes.',\n );\n\n const { t } = useI18n();\n\n const assets = summary.all.total.files;\n\n const handleChange = useCallback(\n (type: string) => (value: string) => {\n if (type === 'module') {\n setModuleUnit(value);\n } else if (type === 'chunk') {\n setChunkUnit(value);\n }\n },\n [],\n );\n\n const selectAfter = (type: string) => (\n <Select defaultValue=\"kb\" onChange={handleChange(type)}>\n <Option value=\"kb\">KB</Option>\n <Option value=\"mb\">MB</Option>\n </Select>\n );\n const onChangeModule = useCallback(\n debounce((newValue: number) => {\n const count =\n inputModuleUnit === 'mb' ? newValue * 1024 * 1024 : newValue * 1024;\n setModuleValue(count);\n }, 300),\n [],\n );\n\n const onChangeAsset = useCallback(\n debounce((newValue: number) => {\n const count =\n inputChunkUnit === 'mb' ? newValue * 1024 * 1024 : newValue * 1024;\n setAssetSize(count);\n }, 300),\n [],\n );\n\n const filteredAssets = useMemo(() => {\n let res = assets.slice();\n\n if (inputAssetName) {\n res = res.filter((e) => e.path.indexOf(inputAssetName) > -1);\n }\n\n if (inputAssetSize > 0) {\n res = res.filter((e) => e.size >= inputAssetSize);\n }\n\n if (selectedEntryPoints.length) {\n res = res.filter((e) => {\n if (selectedEntryPoints.some((ep) => ep.assets.includes(e.path))) {\n return true;\n }\n return false;\n });\n }\n\n return res.sort((a, b) => {\n const _a = a.path.indexOf('/') > -1 ? 1 : 0;\n const _b = b.path.indexOf('/') > -1 ? 1 : 0;\n // return _a - _b;\n return _b - _a;\n });\n }, [assets, selectedEntryPoints, inputAssetName, inputAssetSize]);\n\n useEffect(() => {\n function getFileExtension(filePath: string) {\n const parts = filePath.split('.');\n return parts.length > 1 ? parts.pop() : '';\n }\n\n summary.all.total.files.forEach((f) => {\n const ext = getFileExtension(f.path);\n if (ext === 'js') {\n setAssetPath(f.path);\n }\n });\n }, [summary.all.total.files]);\n\n const assetsStructures = useMemo(() => {\n const res = createFileStructures({\n files: filteredAssets.map((e) => e.path).filter(Boolean),\n fileTitle(file, basename) {\n const target = filteredAssets.find((e) => e.path === file)!;\n const { size, initial, path, content } = target;\n\n return (\n <div\n className={styles.assetBox}\n onClick={() => {\n setAssetPath(path);\n }}\n >\n <Keyword\n text={basename}\n keyword={''}\n className={styles.fileText}\n />\n <Space size=\"small\" className={styles.assetsTag}>\n <Divider type=\"vertical\" />\n <Typography.Text style={{ color: '#4FD233' }}>\n {formatSize(size)}\n </Typography.Text>\n <Divider type=\"vertical\" />\n {initial ? (\n <Typography.Text style={{ color: '#009A9E' }}>\n initial\n </Typography.Text>\n ) : null}\n <CodeOutlined\n style={{ fontSize: 14, padding: 0 }}\n onClick={() => showCode({ code: content!, filePath: path })}\n />\n </Space>\n </div>\n );\n },\n });\n return res;\n }, [filteredAssets]);\n\n const onSearch = (value: string) => {\n setAssetName(value);\n setDefaultExpandAll(false);\n };\n return (\n <>\n <div className={styles.treeGraph}>\n <Row align=\"middle\" gutter={[Size.BasePadding, Size.BasePadding]}>\n {entryPoints && entryPoints.length ? (\n <Col>\n <Select\n mode=\"multiple\"\n value={selectedEntryPoints.map((e) => e.name)}\n style={{\n minWidth: 230,\n width: 'auto',\n maxWidth: 300,\n }}\n placeholder={'filter assets by entry point'}\n onChange={(name: string[]) => {\n setEntryPoints(\n name\n .map((e) => entryPoints.find((ep) => ep.name === e)!)\n .filter(Boolean),\n );\n }}\n allowClear\n onClear={() => {\n setEntryPoints([]);\n }}\n >\n {entryPoints.map((e) => {\n return (\n <Select.Option key={e.name} value={e.name}>\n <Space>\n <Bdg\n label={e.name}\n value={formatSize(e.size)}\n tooltip={e.name}\n />\n </Space>\n </Select.Option>\n );\n })}\n </Select>\n </Col>\n ) : null}\n <Col>\n <KeywordInput\n placeholder=\"search asset by keyword\"\n onChange={onSearch}\n />\n </Col>\n <Col span={6}>\n <InputNumber\n min={0}\n style={{ width: '95%' }}\n addonBefore={\n <Space>\n <Typography.Text style={{ fontSize: 14, color: 'inherit' }}>\n Asset Size\n </Typography.Text>\n <Tooltip\n title={t(\n 'filter the output assets which size is greater than the input value',\n )}\n style={{ marginLeft: 3 }}\n >\n <InfoCircleOutlined\n style={{ color: 'rgba(0,0,0,.45)' }}\n />\n </Tooltip>\n </Space>\n }\n onChange={(value) => onChangeAsset(Number(value))}\n addonAfter={selectAfter('chunk')}\n />\n </Col>\n <Col span={6}>\n <InputNumber\n min={0}\n style={{ width: '95%' }}\n addonBefore={\n <Space>\n <Typography.Text style={{ fontSize: 14, color: 'inherit' }}>\n Module Size\n </Typography.Text>\n <Tooltip\n title={t(\n 'filter the modules which size is greater than the input value',\n )}\n style={{ marginLeft: 3 }}\n >\n <InfoCircleOutlined\n style={{ color: 'rgba(0,0,0,.45)' }}\n />\n </Tooltip>\n </Space>\n }\n onChange={(value) => {\n onChangeModule(Number(value));\n }}\n addonAfter={selectAfter('module')}\n />\n </Col>\n </Row>\n <Row>\n <SearchModal />\n </Row>\n {filteredAssets.length ? (\n <div className={styles.assetDetailRoot}>\n <div className={styles.assetDetailCol}>\n <Card\n className={styles.assetDetailFileTreeRoot}\n classNames={{\n body: styles.assetDetailFileTreeBody,\n }}\n title={\n <Space>\n <Typography.Text>\n {t('Output Assets List')}\n </Typography.Text>\n <Divider type=\"vertical\" />\n <Tooltip\n title={`total assets count is ${assets.length}, the filtered assets count is ${filteredAssets.length}`}\n >\n <Typography.Text\n type=\"secondary\"\n style={{\n fontSize: 12,\n fontWeight: 400,\n }}\n >\n {filteredAssets.length} / {assets.length}\n </Typography.Text>\n </Tooltip>\n <Divider type=\"vertical\" />\n <Typography.Text\n type=\"secondary\"\n style={{ fontSize: 12, fontWeight: 400 }}\n >\n {formatSize(sumBy(filteredAssets, (e) => e.size))}\n </Typography.Text>\n </Space>\n }\n size=\"small\"\n >\n <div className={styles.assetDetailFileTreeViewport}>\n <div className={styles.assetDetailFileTreeScrollArea}>\n <FileTree\n className={styles.assets}\n treeData={assetsStructures}\n autoExpandParent\n defaultExpandAll={\n defaultExpandAll || filteredAssets.length <= 20\n }\n key={`tree_${inputAssetName}_${defaultExpandAll}`}\n />\n </div>\n </div>\n </Card>\n </div>\n <div className={styles.assetDetailCol}>\n {assetPath ? (\n <ServerAPIProvider\n api={SDK.ServerAPI.API.GetAssetDetails}\n body={{ assetPath }}\n >\n {(details) => (\n <AssetDetail\n asset={details.asset}\n chunks={details.chunks}\n modules={details.modules}\n moduleSizeLimit={inputModule}\n root={cwd}\n />\n )}\n </ServerAPIProvider>\n ) : (\n <Card>\n <Empty\n description={\n <Typography.Text strong>\n Click the file path on the left to show the modules of\n the asset\n </Typography.Text>\n }\n />\n </Card>\n )}\n </div>\n </div>\n ) : (\n <Empty />\n )}\n </div>\n {codeDrawerComponent}\n </>\n );\n },\n);\n"],"names":["Option","Select","TreeGraph","memo","cwd","summary","entryPoints","selectedEntryPoints","setEntryPoints","useState","inputModule","setModuleValue","inputAssetName","setAssetName","inputAssetSize","setAssetSize","defaultExpandAll","setDefaultExpandAll","inputModuleUnit","setModuleUnit","inputChunkUnit","setChunkUnit","assetPath","setAssetPath","showCode","codeDrawerComponent","useCodeDrawer","t","useI18n","assets","handleChange","useCallback","type","value","selectAfter","onChangeModule","debounce","newValue","count","onChangeAsset","filteredAssets","useMemo","res","e","ep","a","b","_a","_b","useEffect","getFileExtension","filePath","parts","f","ext","assetsStructures","createFileStructures","Boolean","file","basename","target","size","initial","path","content","styles","Keyword","Space","Divider","Typography","formatSize","CodeOutlined","onSearch","Row","Size","Col","name","Bdg","KeywordInput","InputNumber","Tooltip","InfoCircleOutlined","Number","SearchModal","Card","sumBy","FileTree","ServerAPIProvider","SDK","details","AssetDetail","Empty"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAM,EAAEA,QAAAA,MAAM,EAAE,GAAGC;AAEZ,MAAMC,YAAY,WAAHA,GAAGC,KACvB,CAAC,EACCC,GAAG,EACHC,OAAO,EACPC,WAAW,EAKZ;IACC,MAAM,CAACC,qBAAqBC,eAAe,GAAGC,SAE5C,EAAE;IACJ,MAAM,CAACC,aAAaC,eAAe,GAAGF,SAAS;IAC/C,MAAM,CAACG,gBAAgBC,aAAa,GAAGJ,SAAS;IAChD,MAAM,CAACK,gBAAgBC,aAAa,GAAGN,SAAS;IAChD,MAAM,CAACO,kBAAkBC,oBAAoB,GAAGR,SAAS;IACzD,MAAM,CAACS,iBAAiBC,cAAc,GAAGV,SAAS;IAClD,MAAM,CAACW,gBAAgBC,aAAa,GAAGZ,SAAS;IAChD,MAAM,CAACa,WAAWC,aAAa,GAAGd,SAAwB;IAC1D,MAAM,EAAEe,QAAQ,EAAEC,mBAAmB,EAAE,GAAGC,cACxC;IAGF,MAAM,EAAEC,CAAC,EAAE,GAAGC;IAEd,MAAM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,OAAKA,CAAAA;;;YAGTlE;;;AAGP"}
@@ -1,18 +1,8 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { Col, Row } from "antd";
3
2
  import "react";
4
- import { Size } from "../../constants.mjs";
5
3
  import { WebpackModulesOverall } from "./components/index.mjs";
6
4
  export * from "./constants.mjs";
7
- const Page = ()=>/*#__PURE__*/ jsx(Row, {
8
- children: /*#__PURE__*/ jsx(Col, {
9
- span: 24,
10
- style: {
11
- marginBottom: Size.BasePadding
12
- },
13
- children: /*#__PURE__*/ jsx(WebpackModulesOverall, {})
14
- })
15
- });
5
+ const Page = ()=>/*#__PURE__*/ jsx(WebpackModulesOverall, {});
16
6
  export { Page };
17
7
 
18
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pages/BundleSize/index.mjs","sources":["../../../src/pages/BundleSize/index.tsx"],"sourcesContent":["import { Col, Row } from 'antd';\nimport React from 'react';\n\nimport { Size } from '../../constants';\nimport { WebpackModulesOverall } from './components';\n\nexport const Page: React.FC = () => {\n return (\n <Row>\n <Col span={24} style={{ marginBottom: Size.BasePadding }}>\n <WebpackModulesOverall />\n </Col>\n </Row>\n );\n};\n\nexport * from './constants';\n"],"names":["Page","Row","Col","Size","WebpackModulesOverall"],"mappings":";;;;;;AAMO,MAAMA,OAAiB,IACrB,WAAP,GACE,IAACC,KAAGA;kBACF,kBAACC,KAAGA;YAAC,MAAM;YAAI,OAAO;gBAAE,cAAcC,KAAK,WAAW;YAAC;sBACrD,kBAACC,uBAAqBA,CAAAA"}
1
+ {"version":3,"file":"pages/BundleSize/index.mjs","sources":["../../../src/pages/BundleSize/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport { WebpackModulesOverall } from './components';\n\nexport const Page: React.FC = () => {\n return <WebpackModulesOverall />;\n};\n\nexport * from './constants';\n"],"names":["Page","WebpackModulesOverall"],"mappings":";;;;AAIO,MAAMA,OAAiB,IACrB,WAAP,GAAO,IAACC,uBAAqBA,CAAAA"}
@@ -2,5 +2,5 @@ import React from 'react';
2
2
  interface Props {
3
3
  children: React.ReactNode[];
4
4
  }
5
- export declare const ResponsiveLayout: ({ children }: Props) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const ResponsiveLayout: ({ children }: Props) => React.JSX.Element;
6
6
  export {};
@@ -1,2 +1,2 @@
1
1
  import { Client } from '@rsdoctor/types';
2
- export declare const formatDiffSize: (bSize: number, cSize: number, state: Client.RsdoctorClientDiffState, propsStyle?: Record<string, string | number>) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const formatDiffSize: (bSize: number, cSize: number, state: Client.RsdoctorClientDiffState, propsStyle?: Record<string, string | number>) => import("react").JSX.Element;
@@ -8,4 +8,4 @@ export interface CodeEditorProps {
8
8
  source: SDK.ModuleSource;
9
9
  toLine?: number;
10
10
  }
11
- export declare function CodeEditor(props: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function CodeEditor(props: CodeEditorProps): import("react").JSX.Element;
@@ -1 +1 @@
1
- export declare function Space(): import("react/jsx-runtime").JSX.Element;
1
+ export declare function Space(): import("react").JSX.Element;
@@ -30,7 +30,7 @@ export declare function beautifyModulePath(modulePath: string, cwd: string): {
30
30
  alias: string;
31
31
  inNodeModules: boolean;
32
32
  };
33
- export declare function getFileIcon(props: TreeNodeProps, addRowIcon?: boolean): import("react/jsx-runtime").JSX.Element;
33
+ export declare function getFileIcon(props: TreeNodeProps, addRowIcon?: boolean): import("react").JSX.Element;
34
34
  type TreeNode = {
35
35
  name: string;
36
36
  value?: number;
@@ -1,4 +1,5 @@
1
1
  import { Manifest, Rule, SDK } from '@rsdoctor/types';
2
+ import { type SetStateAction, type Dispatch } from 'react';
2
3
  import { useTranslation } from 'react-i18next';
3
4
  import './i18n/index.js';
4
5
  export declare const useI18n: typeof useTranslation;
@@ -6,7 +7,7 @@ export declare function useRuleIndexNavigate(code: string, link?: string | undef
6
7
  export declare function useUrlQuery(): Record<string, string | undefined>;
7
8
  export declare function useLoading(defaultLoading?: boolean): {
8
9
  loading: boolean;
9
- setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
10
+ setLoading: Dispatch<SetStateAction<boolean>>;
10
11
  withLoading(func: (...args: unknown[]) => Promise<unknown> | unknown): Promise<void>;
11
12
  };
12
13
  export declare function useProjectRootByManifest(manifest: Manifest.RsdoctorManifest): string;
@@ -28,3 +29,8 @@ export declare function useDuplicatePackagesByErrors(errors: Manifest.RsdoctorMa
28
29
  export declare function useWebpackConfigurationByConfigs(configs?: SDK.ConfigData): SDK.WebpackConfigData | null | undefined;
29
30
  export declare function useDetectIfCloudIdeEnv(): boolean;
30
31
  export declare function useWindowWidth(): number;
32
+ export declare function useElementSize<T extends HTMLElement = HTMLDivElement>(): readonly [import("react").RefObject<T | null>, {
33
+ readonly width: number;
34
+ readonly height: number;
35
+ }];
36
+ export declare function usePersistedState<T>(baseKey: string, initialValue: T | (() => T)): [T, Dispatch<SetStateAction<T>>];
@@ -1,7 +1,7 @@
1
1
  import { Algorithm } from "@rsdoctor/utils/common";
2
2
  import { Client, Rule } from "@rsdoctor/types";
3
- import { defaults, uniqBy } from "es-toolkit/compat";
4
- import { useEffect, useMemo, useState } from "react";
3
+ import { defaults, throttle, uniqBy } from "es-toolkit/compat";
4
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
5
5
  import { useTranslation } from "react-i18next";
6
6
  import { useLocation, useNavigate } from "react-router-dom";
7
7
  import url_parse from "url-parse";
@@ -161,6 +161,76 @@ function useWindowWidth() {
161
161
  }, []);
162
162
  return windowWidth;
163
163
  }
164
- export { useBundleAlertsByErrors, useBundleAlertsByManifest, useChunkGraphByManifest, useCloudManifestUrlByManifest, useCompileAlertsByErrors, useConfigOutputFileNameByManifest, useDetectIfCloudIdeEnv, useDuplicatePackagesByErrors, useDuplicatePackagesByManifest, useErrorsByManifest, useHashByManifest, useI18n, useLoading, useModuleGraph, useModuleGraphByManifest, usePackageGraphByManifest, useProjectRootByManifest, useRuleIndexNavigate, useUniqModules, useUniqModulesByManifest, useUrlQuery, useWebpackConfigurationByConfigs, useWindowWidth };
164
+ function useElementSize() {
165
+ const ref = useRef(null);
166
+ const [width, setWidth_] = useState(0);
167
+ const [height, setHeight_] = useState(0);
168
+ useLayoutEffect(()=>{
169
+ const $el = ref.current;
170
+ if (!$el) return;
171
+ const setWidth = (n)=>setWidth_(Math.ceil(n));
172
+ const setHeight = (n)=>setHeight_(Math.ceil(n));
173
+ const initialRect = $el.getBoundingClientRect();
174
+ setWidth(initialRect.width);
175
+ setHeight(initialRect.height);
176
+ const onResize = throttle((entries)=>{
177
+ const entry = entries[0];
178
+ if (!entry) return;
179
+ const borderBox = entry.borderBoxSize?.[0];
180
+ if (borderBox) {
181
+ setWidth(borderBox.inlineSize);
182
+ setHeight(borderBox.blockSize);
183
+ } else {
184
+ setWidth(entry.contentRect.width);
185
+ setHeight(entry.contentRect.height);
186
+ }
187
+ }, 100);
188
+ const observer = new ResizeObserver(onResize);
189
+ observer.observe($el);
190
+ return ()=>{
191
+ observer.disconnect();
192
+ onResize.cancel();
193
+ };
194
+ }, []);
195
+ return [
196
+ ref,
197
+ {
198
+ width,
199
+ height
200
+ }
201
+ ];
202
+ }
203
+ function usePersistedState(baseKey, initialValue) {
204
+ const NS = 'RSDOC:';
205
+ const key = NS + baseKey;
206
+ const [state, setState] = useState(()=>{
207
+ try {
208
+ const item = window.localStorage.getItem(key);
209
+ if (null !== item) return JSON.parse(item);
210
+ return 'function' == typeof initialValue ? initialValue() : initialValue;
211
+ } catch (error) {
212
+ console.warn(`Error reading localStorage key "${key}":`, error);
213
+ return 'function' == typeof initialValue ? initialValue() : initialValue;
214
+ }
215
+ });
216
+ const setPersistedState = useCallback((value)=>{
217
+ try {
218
+ setState((prevState)=>{
219
+ const nextState = value instanceof Function ? value(prevState) : value;
220
+ window.localStorage.setItem(key, JSON.stringify(nextState));
221
+ return nextState;
222
+ });
223
+ } catch (error) {
224
+ console.warn(`Error setting localStorage key "${key}":`, error);
225
+ }
226
+ }, [
227
+ key
228
+ ]);
229
+ return [
230
+ state,
231
+ setPersistedState
232
+ ];
233
+ }
234
+ export { useBundleAlertsByErrors, useBundleAlertsByManifest, useChunkGraphByManifest, useCloudManifestUrlByManifest, useCompileAlertsByErrors, useConfigOutputFileNameByManifest, useDetectIfCloudIdeEnv, useDuplicatePackagesByErrors, useDuplicatePackagesByManifest, useElementSize, useErrorsByManifest, useHashByManifest, useI18n, useLoading, useModuleGraph, useModuleGraphByManifest, usePackageGraphByManifest, usePersistedState, useProjectRootByManifest, useRuleIndexNavigate, useUniqModules, useUniqModulesByManifest, useUrlQuery, useWebpackConfigurationByConfigs, useWindowWidth };
165
235
 
166
236
  //# sourceMappingURL=hooks.mjs.map