@rsdoctor/components 1.5.13 → 1.5.14
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/dist/components/Charts/TreeMap.mjs +1 -2
- package/dist/components/Charts/TreeMap.mjs.map +1 -1
- package/dist/components/Layout/header.d.ts +0 -1
- package/dist/components/Layout/header.mjs +14 -53
- package/dist/components/Layout/header.mjs.map +1 -1
- package/dist/components/Layout/header.module.mjs +15 -0
- package/dist/components/Layout/header.module.mjs.map +1 -0
- package/dist/components/Layout/header_module.css +88 -0
- package/dist/components/Layout/header_module.css.map +1 -0
- package/dist/components/Layout/index.mjs +10 -8
- package/dist/components/Layout/index.mjs.map +1 -1
- package/dist/components/Layout/index.module.mjs +7 -0
- package/dist/components/Layout/index.module.mjs.map +1 -0
- package/dist/components/Layout/index_module.css +11 -0
- package/dist/components/Layout/index_module.css.map +1 -0
- package/dist/pages/BundleSize/components/asset.mjs +5 -3
- package/dist/pages/BundleSize/components/asset.mjs.map +1 -1
- package/dist/pages/BundleSize/components/asset_module.css +15 -7
- package/dist/pages/BundleSize/components/asset_module.css.map +1 -1
- package/dist/pages/BundleSize/components/index.d.ts +1 -1
- package/dist/pages/BundleSize/components/index.mjs +223 -556
- package/dist/pages/BundleSize/components/index.mjs.map +1 -1
- package/dist/pages/BundleSize/components/index.module.mjs +10 -0
- package/dist/pages/BundleSize/components/index.module.mjs.map +1 -1
- package/dist/pages/BundleSize/components/index_module.css +49 -0
- package/dist/pages/BundleSize/components/index_module.css.map +1 -1
- package/dist/pages/BundleSize/components/tree-graph.d.ts +7 -0
- package/dist/pages/BundleSize/components/tree-graph.mjs +366 -0
- package/dist/pages/BundleSize/components/tree-graph.mjs.map +1 -0
- package/dist/pages/BundleSize/index.mjs +1 -11
- package/dist/pages/BundleSize/index.mjs.map +1 -1
- package/dist/utils/hooks.d.ts +3 -1
- package/dist/utils/hooks.mjs +33 -2
- package/dist/utils/hooks.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/components/Layout/header.css +0 -28
- package/dist/components/Layout/header.css.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages/BundleSize/components/index.mjs","sources":["../../../../src/pages/BundleSize/components/index.tsx"],"sourcesContent":["import {\n CodeOutlined,\n CodepenCircleOutlined,\n DeploymentUnitOutlined,\n InfoCircleOutlined,\n} from '@ant-design/icons';\nimport { Client, SDK } from '@rsdoctor/types';\nimport {\n Button,\n Card,\n Col,\n Divider,\n Empty,\n InputNumber,\n Row,\n Select,\n Space,\n Tag,\n Tooltip,\n Typography,\n Tabs,\n} from 'antd';\nimport { debounce, sumBy } from 'es-toolkit/compat';\nimport React, { 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 { useProjectInfo } from '../../../components/Layout/project-info-context';\nimport {\n createFileStructures,\n flattenTreemapData,\n formatSize,\n useI18n,\n} from '../../../utils';\nimport { AssetDetail } from './asset';\nimport { BundleCards } from './cards';\nimport styles from './index.module.scss';\nimport './index.sass';\nimport { SearchModal } from './search-modal';\nimport {\n AssetTreemapWithFilter,\n TreeNode,\n} from 'src/components/Charts/TreeMap';\nimport { Rspack } from '@rsdoctor/utils/common';\n\nconst { Option } = Select;\n\nconst cardBodyHeight = 600;\n\ninterface WebpackModulesOverallProps {\n cwd: string;\n errors: SDK.ErrorsData;\n summary: Client.RsdoctorClientAssetsSummary;\n entryPoints: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetEntryPoints>;\n}\n\nexport const WebpackModulesOverallBase: React.FC<\n WebpackModulesOverallProps\n> = ({ errors, cwd, summary, entryPoints }) => {\n const [selectedEntryPoints, setEntryPoints] = useState<SDK.EntryPointData[]>(\n [],\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 text={basename} keyword={''} className={styles.fileText} />\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>\n <BundleCards cwd={cwd} errors={errors} summary={summary} />\n <Card styles={{ body: { paddingTop: 0 } }}>\n <Tabs\n size=\"middle\"\n items={[\n {\n key: 'tree',\n label: (\n <Space>\n <Typography.Text>Tree Graph</Typography.Text>\n <Tooltip\n overlayStyle={{ maxWidth: 380 }}\n overlayInnerStyle={{ marginLeft: 16, padding: 10 }}\n color=\"white\"\n title={\n <Space direction=\"vertical\" color=\"white\" size=\"middle\">\n <Row>\n <Col>\n <Tag color=\"cyan\" style={{ margin: 0 }}>\n initial\n </Tag>\n <Typography.Text style={{ marginLeft: 4 }}>\n Identify whether the chunk is an initial chunk.\n </Typography.Text>\n </Col>\n </Row>\n <Row>\n <Col>\n <Tag color=\"green\" style={{ margin: 0 }}>\n concatenated\n </Tag>\n <Typography.Text style={{ marginLeft: 4 }}>\n Identify whether the module is a concatenated\n module\n </Typography.Text>\n <Tooltip\n overlayStyle={{ maxWidth: 408 }}\n placement=\"bottom\"\n color=\"white\"\n title={\n <Space direction=\"vertical\" color=\"white\">\n <Row>\n <Col>\n <Typography.Text strong>\n Concatenated Module\n </Typography.Text>\n <Typography.Text>\n : A performance optimization where\n multiple modules are merged (or\n \"hoisted\") into a single scope instead\n of wrapping each module in separate\n function closures. This reduces the\n bundle size and improves runtime\n performance by minimizing function\n call overhead.\n </Typography.Text>\n </Col>\n </Row>\n </Space>\n }\n >\n <InfoCircleOutlined\n style={{\n color: 'rgba(0,0,0,.45)',\n marginLeft: 4,\n }}\n />\n </Tooltip>\n <Typography.Text>.</Typography.Text>\n </Col>\n </Row>\n <Row>\n <Col>\n <Button\n size=\"small\"\n icon={<CodepenCircleOutlined />}\n />\n <Typography.Text style={{ marginLeft: 4 }}>\n Open the code.\n </Typography.Text>\n </Col>\n </Row>\n <Row>\n <Col>\n <Button\n size=\"small\"\n icon={<DeploymentUnitOutlined />}\n />\n <Typography.Text style={{ marginLeft: 4 }}>\n View the module dependency, that is, module\n reasons in stats.json.\n </Typography.Text>\n </Col>\n </Row>\n <Row>\n <Col>\n <Tag color={'purple'}>{'Bundled: 15.77 KB'}</Tag>\n <Typography.Text>\n The final size of the output files after\n processing, bundling, and optimization. This is\n what is delivered to the browser.\n </Typography.Text>\n </Col>\n </Row>\n <Row>\n <Col>\n <Tag color={'orange'}>{'Source: 60.46 KB'}</Tag>\n <Typography.Text>\n The original size of your source code files\n before any processing or transformations. This\n is the raw size of your code as you wrote it.\n </Typography.Text>\n </Col>\n </Row>\n </Space>\n }\n >\n <InfoCircleOutlined\n style={{ color: 'rgba(0,0,0,.45)' }}\n />\n </Tooltip>\n </Space>\n ),\n children: (\n <Space style={{ display: 'flex' }} direction=\"vertical\">\n <Row\n align=\"middle\"\n gutter={[Size.BasePadding, Size.BasePadding]}\n >\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(\n (e) =>\n entryPoints.find((ep) => ep.name === e)!,\n )\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\n style={{ fontSize: 14, color: 'inherit' }}\n >\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\n style={{ fontSize: 14, color: 'inherit' }}\n >\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 <Row\n align=\"middle\"\n gutter={[Size.BasePadding, Size.BasePadding]}\n >\n <Col span={24}>\n {filteredAssets.length ? (\n <Row gutter={Size.BasePadding}>\n <Col span={6}>\n <Card\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} /{' '}\n {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(\n sumBy(filteredAssets, (e) => e.size),\n )}\n </Typography.Text>\n </Space>\n }\n size=\"small\"\n bodyStyle={{\n overflow: 'scroll',\n height: cardBodyHeight,\n }}\n >\n <FileTree\n className={styles.assets}\n treeData={assetsStructures}\n autoExpandParent\n defaultExpandAll={\n defaultExpandAll ||\n filteredAssets.length <= 20\n }\n key={`tree_${inputAssetName}_${defaultExpandAll}`}\n />\n </Card>\n </Col>\n <Col span={18}>\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 height={cardBodyHeight}\n moduleSizeLimit={inputModule}\n root={cwd}\n />\n )}\n </ServerAPIProvider>\n ) : (\n <Card\n bodyStyle={{\n height: cardBodyHeight,\n }}\n >\n <Empty\n description={\n <Typography.Text strong>\n Click the file path on the left to show\n the modules of the asset\n </Typography.Text>\n }\n />\n </Card>\n )}\n </Col>\n </Row>\n ) : (\n <Empty />\n )}\n </Col>\n </Row>\n </Space>\n ),\n },\n {\n key: 'treemap',\n label: 'Treemap',\n children: (\n <ServerAPIProvider api={SDK.ServerAPI.API.GetProjectInfo}>\n {(data) => {\n const { isRspack, hasSourceMap } =\n Rspack.checkSourceMapSupport(data.configs);\n return (\n <ServerAPIProvider\n api={SDK.ServerAPI.API.GetSummaryBundles}\n >\n {(data) => {\n // Filter assets to only show JS (js, cjs, mjs), .bundle, CSS, and HTML files\n const isTargetFileType = (\n filePath: string,\n ): boolean => {\n const ext =\n filePath.toLowerCase().split('.').pop() || '';\n return (\n ext === 'js' ||\n ext === 'cjs' ||\n ext === 'mjs' ||\n ext === 'bundle' ||\n ext === 'css' ||\n ext === 'html'\n );\n };\n\n const computedTreeData: TreeNode[] = data\n .filter((item) =>\n isTargetFileType(item.asset.path),\n )\n .map((item) => ({\n name: item.asset.path,\n value: item.asset.size,\n children: flattenTreemapData(item.modules)\n .children,\n }));\n return (\n <AssetTreemapWithFilter\n treeData={computedTreeData}\n bundledSize={hasSourceMap || isRspack}\n />\n );\n }}\n </ServerAPIProvider>\n );\n }}\n </ServerAPIProvider>\n ),\n },\n ]}\n defaultActiveKey=\"tree\"\n />\n </Card>\n </div>\n {codeDrawerComponent}\n </>\n );\n};\n\nexport const WebpackModulesOverall: React.FC = () => {\n const { project } = useProjectInfo();\n\n if (!project) {\n return null;\n }\n\n const { root, errors } = project;\n return (\n <ServerAPIProvider\n api={SDK.ServerAPI.API.GetAssetsSummary}\n body={{ withFileContent: true }}\n >\n {(summary) => {\n return (\n <ServerAPIProvider api={SDK.ServerAPI.API.GetEntryPoints}>\n {(entryPoints) => (\n <WebpackModulesOverallBase\n cwd={root}\n errors={errors}\n summary={summary}\n entryPoints={entryPoints}\n />\n )}\n </ServerAPIProvider>\n );\n }}\n </ServerAPIProvider>\n );\n};\n"],"names":["Option","Select","cardBodyHeight","WebpackModulesOverallBase","errors","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","BundleCards","Card","Tabs","Tooltip","Row","Col","Tag","InfoCircleOutlined","Button","CodepenCircleOutlined","DeploymentUnitOutlined","Size","name","Bdg","KeywordInput","InputNumber","Number","SearchModal","sumBy","FileTree","ServerAPIProvider","SDK","details","AssetDetail","Empty","data","isRspack","hasSourceMap","Rspack","isTargetFileType","computedTreeData","item","flattenTreemapData","AssetTreemapWithFilter","WebpackModulesOverall","project","useProjectInfo","root"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAM,EAAEA,QAAAA,MAAM,EAAE,GAAGC;AAEnB,MAAMC,iBAAiB;AAShB,MAAMC,4BAET,CAAC,EAAEC,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAEC,WAAW,EAAE;IACxC,MAAM,CAACC,qBAAqBC,eAAe,GAAGC,SAC5C,EAAE;IAEJ,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,MAAMC,SAASxB,QAAQ,GAAG,CAAC,KAAK,CAAC,KAAK;IAEtC,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A,OACAA,AAAQ,aAARA,OACAA,AAAQ,UAARA,OACAA,AAAQ,WAARA;oDAEJ;oDAEA,MAAMiD,mBAA+BL,KAClC,MAAM,CAAC,CAACM,OACPF,iBAAiBE,KAAK,KAAK,CAAC,IAAI,GAEjC,GAAG,CAAC,CAACA,OAAU;4DACd,MAAMA,KAAK,KAAK,CAAC,IAAI;4DACrB,OAAOA,KAAK,KAAK,CAAC,IAAI;4DACtB,UAAUC,mBAAmBD,KAAK,OAAO,EACtC,QAAQ;wDACb;oDACF,OAAO,WAAP,GACE,IAACE,wBAAsBA;wDACrB,UAAUH;wDACV,aAAaH,gBAAgBD;;gDAGnC;;wCAGN;;gCAGN;6BACD;4BACD,kBAAiB;;;;;YAItB1E;;;AAGP;AAEO,MAAMkF,wBAAkC;IAC7C,MAAM,EAAEC,OAAO,EAAE,GAAGC;IAEpB,IAAI,CAACD,SACH,OAAO;IAGT,MAAM,EAAEE,IAAI,EAAE3G,MAAM,EAAE,GAAGyG;IACzB,OAAO,WAAP,GACE,IAACf,mBAAiBA;QAChB,KAAKC,IAAI,SAAS,CAAC,GAAG,CAAC,gBAAgB;QACvC,MAAM;YAAE,iBAAiB;QAAK;kBAE7B,CAACzF,UACO,WAAP,GACE,IAACwF,mBAAiBA;gBAAC,KAAKC,IAAI,SAAS,CAAC,GAAG,CAAC,cAAc;0BACrD,CAACxF,cAAAA,WAAAA,GACA,IAACJ,2BAAyBA;wBACxB,KAAK4G;wBACL,QAAQ3G;wBACR,SAASE;wBACT,aAAaC;;;;AAQ7B"}
|
|
1
|
+
{"version":3,"file":"pages/BundleSize/components/index.mjs","sources":["../../../../src/pages/BundleSize/components/index.tsx"],"sourcesContent":["import {\n CodepenCircleOutlined,\n DeploymentUnitOutlined,\n InfoCircleOutlined,\n ShrinkOutlined,\n ArrowsAltOutlined,\n} from '@ant-design/icons';\nimport { type Client, SDK } from '@rsdoctor/types';\nimport {\n Button,\n Card,\n Col,\n Row,\n Space,\n Tag,\n Tooltip,\n Typography,\n Tabs,\n} from 'antd';\nimport React, { useId } from 'react';\nimport { ServerAPIProvider } from '../../../components/Manifest';\nimport { useProjectInfo } from '../../../components/Layout/project-info-context';\nimport { flattenTreemapData, usePersistedState } from '../../../utils';\nimport { BundleCards } from './cards';\nimport styles from './index.module.scss';\nimport './index.sass';\nimport {\n AssetTreemapWithFilter,\n TreeNode,\n} from 'src/components/Charts/TreeMap';\nimport { Rspack } from '@rsdoctor/utils/common';\nimport { TreeGraph } from './tree-graph';\n\ninterface WebpackModulesOverallProps {\n cwd: string;\n errors: SDK.ErrorsData;\n summary: Client.RsdoctorClientAssetsSummary;\n entryPoints: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetEntryPoints>;\n}\n\nexport const WebpackModulesOverallBase: React.FC<\n WebpackModulesOverallProps\n> = ({ errors, cwd, summary, entryPoints }) => {\n const [expanded, setExpanded] = usePersistedState(\n 'bundle-size-tabs-card-expanded',\n false,\n );\n const cardDomId = useId();\n const expandActionText = expanded ? 'Shrink card' : 'Expand card';\n return (\n <>\n <React.Activity mode={expanded ? 'hidden' : 'visible'}>\n <BundleCards cwd={cwd} errors={errors} summary={summary} />\n </React.Activity>\n <Card\n className={styles.root}\n classNames={{ body: styles.rootBody }}\n id={cardDomId}\n >\n <Tabs\n size=\"middle\"\n className={styles.tabsRoot}\n tabBarExtraContent={{\n right: (\n <Tooltip\n // the content collapses/expands, but the cursor stays at the same position (outside the button now, cause layout has shifted)\n // antd doesn't know that and keeps the tooltip open, so we need to force rerender it on every state change\n key={String(expanded)}\n title={expandActionText}\n >\n <Button\n // TODO:: does it make sense here? the content basically stays the same and we're actually controlling other elements\n aria-controls={cardDomId}\n aria-expanded={expanded}\n aria-label={expandActionText}\n onClick={() => setExpanded(!expanded)}\n icon={expanded ? <ShrinkOutlined /> : <ArrowsAltOutlined />}\n size=\"small\"\n ></Button>\n </Tooltip>\n ),\n }}\n items={[\n {\n key: 'tree',\n label: (\n <Space>\n <Typography.Text>Tree Graph</Typography.Text>\n <Tooltip\n overlayStyle={{ maxWidth: 380 }}\n overlayInnerStyle={{ marginLeft: 16, padding: 10 }}\n color=\"white\"\n title={\n <Space direction=\"vertical\" color=\"white\" size=\"middle\">\n <Row>\n <Col>\n <Tag color=\"cyan\" style={{ margin: 0 }}>\n initial\n </Tag>\n <Typography.Text style={{ marginLeft: 4 }}>\n Identify whether the chunk is an initial chunk.\n </Typography.Text>\n </Col>\n </Row>\n <Row>\n <Col>\n <Tag color=\"green\" style={{ margin: 0 }}>\n concatenated\n </Tag>\n <Typography.Text style={{ marginLeft: 4 }}>\n Identify whether the module is a concatenated\n module\n </Typography.Text>\n <Tooltip\n overlayStyle={{ maxWidth: 408 }}\n placement=\"bottom\"\n color=\"white\"\n title={\n <Space direction=\"vertical\" color=\"white\">\n <Row>\n <Col>\n <Typography.Text strong>\n Concatenated Module\n </Typography.Text>\n <Typography.Text>\n : A performance optimization where\n multiple modules are merged (or\n \"hoisted\") into a single scope instead\n of wrapping each module in separate\n function closures. This reduces the\n bundle size and improves runtime\n performance by minimizing function call\n overhead.\n </Typography.Text>\n </Col>\n </Row>\n </Space>\n }\n >\n <InfoCircleOutlined\n style={{\n color: 'rgba(0,0,0,.45)',\n marginLeft: 4,\n }}\n />\n </Tooltip>\n <Typography.Text>.</Typography.Text>\n </Col>\n </Row>\n <Row>\n <Col>\n <Button\n size=\"small\"\n icon={<CodepenCircleOutlined />}\n />\n <Typography.Text style={{ marginLeft: 4 }}>\n Open the code.\n </Typography.Text>\n </Col>\n </Row>\n <Row>\n <Col>\n <Button\n size=\"small\"\n icon={<DeploymentUnitOutlined />}\n />\n <Typography.Text style={{ marginLeft: 4 }}>\n View the module dependency, that is, module\n reasons in stats.json.\n </Typography.Text>\n </Col>\n </Row>\n <Row>\n <Col>\n <Tag color={'purple'}>{'Bundled: 15.77 KB'}</Tag>\n <Typography.Text>\n The final size of the output files after\n processing, bundling, and optimization. This is\n what is delivered to the browser.\n </Typography.Text>\n </Col>\n </Row>\n <Row>\n <Col>\n <Tag color={'orange'}>{'Source: 60.46 KB'}</Tag>\n <Typography.Text>\n The original size of your source code files before\n any processing or transformations. This is the raw\n size of your code as you wrote it.\n </Typography.Text>\n </Col>\n </Row>\n </Space>\n }\n >\n <InfoCircleOutlined style={{ color: 'rgba(0,0,0,.45)' }} />\n </Tooltip>\n </Space>\n ),\n children: (\n <TreeGraph\n entryPoints={entryPoints}\n cwd={cwd}\n summary={summary}\n />\n ),\n },\n {\n key: 'treemap',\n label: 'Treemap',\n children: (\n <ServerAPIProvider api={SDK.ServerAPI.API.GetProjectInfo}>\n {(data) => {\n const { isRspack, hasSourceMap } =\n Rspack.checkSourceMapSupport(data.configs);\n return (\n <ServerAPIProvider\n api={SDK.ServerAPI.API.GetSummaryBundles}\n >\n {(data) => {\n // Filter assets to only show JS (js, cjs, mjs), .bundle, CSS, and HTML files\n const isTargetFileType = (\n filePath: string,\n ): boolean => {\n const ext =\n filePath.toLowerCase().split('.').pop() || '';\n return (\n ext === 'js' ||\n ext === 'cjs' ||\n ext === 'mjs' ||\n ext === 'bundle' ||\n ext === 'css' ||\n ext === 'html'\n );\n };\n\n const computedTreeData: TreeNode[] = data\n .filter((item) => isTargetFileType(item.asset.path))\n .map((item) => {\n const moduleTree = flattenTreemapData(\n item.modules,\n );\n const hasModules = item.modules.length > 0;\n return {\n name: item.asset.path,\n sourceSize: hasModules\n ? (moduleTree.sourceSize ?? 0)\n : item.asset.size,\n bundledSize: item.asset.size,\n gzipSize: item.asset.gzipSize ?? 0,\n children: moduleTree.children,\n };\n });\n return (\n <AssetTreemapWithFilter\n treeData={computedTreeData}\n bundledSize={hasSourceMap || isRspack}\n />\n );\n }}\n </ServerAPIProvider>\n );\n }}\n </ServerAPIProvider>\n ),\n },\n ]}\n defaultActiveKey=\"tree\"\n />\n </Card>\n </>\n );\n};\n\nexport const WebpackModulesOverall: React.FC = () => {\n const { project } = useProjectInfo();\n\n if (!project) {\n return null;\n }\n\n const { root, errors } = project;\n return (\n <ServerAPIProvider\n api={SDK.ServerAPI.API.GetAssetsSummary}\n body={{ withFileContent: true }}\n >\n {(summary) => {\n return (\n <ServerAPIProvider api={SDK.ServerAPI.API.GetEntryPoints}>\n {(entryPoints) => (\n <WebpackModulesOverallBase\n cwd={root}\n errors={errors}\n summary={summary}\n entryPoints={entryPoints}\n />\n )}\n </ServerAPIProvider>\n );\n }}\n </ServerAPIProvider>\n );\n};\n"],"names":["WebpackModulesOverallBase","errors","cwd","summary","entryPoints","expanded","setExpanded","usePersistedState","cardDomId","useId","expandActionText","React","BundleCards","Card","styles","Tabs","Tooltip","Button","ShrinkOutlined","ArrowsAltOutlined","String","Space","Typography","Row","Col","Tag","InfoCircleOutlined","CodepenCircleOutlined","DeploymentUnitOutlined","TreeGraph","ServerAPIProvider","SDK","data","isRspack","hasSourceMap","Rspack","isTargetFileType","filePath","ext","computedTreeData","item","moduleTree","flattenTreemapData","hasModules","AssetTreemapWithFilter","WebpackModulesOverall","project","useProjectInfo","root"],"mappings":";;;;;;;;;;;;;;AAwCO,MAAMA,4BAET,CAAC,EAAEC,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAEC,WAAW,EAAE;IACxC,MAAM,CAACC,UAAUC,YAAY,GAAGC,kBAC9B,kCACA;IAEF,MAAMC,YAAYC;IAClB,MAAMC,mBAAmBL,WAAW,gBAAgB;IACpD,OAAO,WAAP,GACE;;0BACE,IAACM,MAAAA,QAAc;gBAAC,MAAMN,WAAW,WAAW;0BAC1C,kBAACO,aAAWA;oBAAC,KAAKV;oBAAK,QAAQD;oBAAQ,SAASE;;;0BAElD,IAACU,MAAIA;gBACH,WAAWC,aAAAA,IAAW;gBACtB,YAAY;oBAAE,MAAMA,aAAAA,QAAe;gBAAC;gBACpC,IAAIN;0BAEJ,kBAACO,MAAIA;oBACH,MAAK;oBACL,WAAWD,aAAAA,QAAe;oBAC1B,oBAAoB;wBAClB,OAAO,WAAP,GACE,IAACE,SAAOA;4BAIN,OAAON;sCAEP,kBAACO,QAAMA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
|
import "./index_module.css";
|
|
2
2
|
const index_module = {
|
|
3
|
+
root: "root-DgXuux",
|
|
4
|
+
rootBody: "rootBody-xGjkG7",
|
|
5
|
+
treeGraph: "treeGraph-LllSyP",
|
|
6
|
+
tabsRoot: "tabsRoot-gPEaze",
|
|
7
|
+
assetDetailCol: "assetDetailCol-jwyTZJ",
|
|
8
|
+
assetDetailFileTreeRoot: "assetDetailFileTreeRoot-RBNnA8",
|
|
9
|
+
assetDetailFileTreeBody: "assetDetailFileTreeBody-kRMd_h",
|
|
10
|
+
assetDetailFileTreeViewport: "assetDetailFileTreeViewport-USNF6e",
|
|
11
|
+
assetDetailRoot: "assetDetailRoot-dgQPS5",
|
|
12
|
+
assetDetailFileTreeScrollArea: "assetDetailFileTreeScrollArea-IqDzT3",
|
|
3
13
|
assets: "assets-ll1P_L",
|
|
4
14
|
assetBox: "assetBox-Y8vGse",
|
|
5
15
|
fileText: "fileText-W0quVZ",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages/BundleSize/components/index.module.mjs","sources":["../../../../src/pages/BundleSize/components/index.module.scss"],"sourcesContent":["// extracted by LIB_CSS_EXTRACT_LOADER\nimport \"./index_module.css\"\nexport default {\"assets\":\"assets-ll1P_L\",\"assetBox\":\"assetBox-Y8vGse\",\"fileText\":\"fileText-W0quVZ\",\"assetsTag\":\"assetsTag-eAVvyj\",\"modal\":\"modal-afyzYa\",\"search-btn\":\"search-btn-To902q\",\"searchBtn\":\"search-btn-To902q\",\"search-modal-list\":\"search-modal-list-G_Uxc8\",\"searchModalList\":\"search-modal-list-G_Uxc8\"};"],"names":[],"mappings":";AAEA,qBAAe;IAAC,QAAS;IAAgB,UAAW;IAAkB,UAAW;IAAkB,WAAY;IAAmB,OAAQ;IAAe,cAAa;IAAoB,WAAY;IAAoB,qBAAoB;IAA2B,iBAAkB;AAA0B"}
|
|
1
|
+
{"version":3,"file":"pages/BundleSize/components/index.module.mjs","sources":["../../../../src/pages/BundleSize/components/index.module.scss"],"sourcesContent":["// extracted by LIB_CSS_EXTRACT_LOADER\nimport \"./index_module.css\"\nexport default {\"root\":\"root-DgXuux\",\"rootBody\":\"rootBody-xGjkG7\",\"treeGraph\":\"treeGraph-LllSyP\",\"tabsRoot\":\"tabsRoot-gPEaze\",\"assetDetailCol\":\"assetDetailCol-jwyTZJ\",\"assetDetailFileTreeRoot\":\"assetDetailFileTreeRoot-RBNnA8\",\"assetDetailFileTreeBody\":\"assetDetailFileTreeBody-kRMd_h\",\"assetDetailFileTreeViewport\":\"assetDetailFileTreeViewport-USNF6e\",\"assetDetailRoot\":\"assetDetailRoot-dgQPS5\",\"assetDetailFileTreeScrollArea\":\"assetDetailFileTreeScrollArea-IqDzT3\",\"assets\":\"assets-ll1P_L\",\"assetBox\":\"assetBox-Y8vGse\",\"fileText\":\"fileText-W0quVZ\",\"assetsTag\":\"assetsTag-eAVvyj\",\"modal\":\"modal-afyzYa\",\"search-btn\":\"search-btn-To902q\",\"searchBtn\":\"search-btn-To902q\",\"search-modal-list\":\"search-modal-list-G_Uxc8\",\"searchModalList\":\"search-modal-list-G_Uxc8\"};"],"names":[],"mappings":";AAEA,qBAAe;IAAC,MAAO;IAAc,UAAW;IAAkB,WAAY;IAAmB,UAAW;IAAkB,gBAAiB;IAAwB,yBAA0B;IAAiC,yBAA0B;IAAiC,6BAA8B;IAAqC,iBAAkB;IAAyB,+BAAgC;IAAuC,QAAS;IAAgB,UAAW;IAAkB,UAAW;IAAkB,WAAY;IAAmB,OAAQ;IAAe,cAAa;IAAoB,WAAY;IAAoB,qBAAoB;IAA2B,iBAAkB;AAA0B"}
|
|
@@ -1,3 +1,52 @@
|
|
|
1
|
+
.root-DgXuux .rootBody-xGjkG7 {
|
|
2
|
+
padding-top: 0;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.root-DgXuux, .rootBody-xGjkG7, .treeGraph-LllSyP, .tabsRoot-gPEaze, .assetDetailCol-jwyTZJ, .assetDetailFileTreeRoot-RBNnA8, .assetDetailFileTreeBody-kRMd_h, .assetDetailFileTreeViewport-USNF6e {
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
flex: 1;
|
|
8
|
+
display: flex;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.tabsRoot-gPEaze .ant-tabs-content-holder {
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
flex: 1;
|
|
14
|
+
display: flex;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tabsRoot-gPEaze .ant-tabs-content {
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
flex: 1;
|
|
20
|
+
display: flex;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tabsRoot-gPEaze .ant-tabs-tabpane-active {
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
flex: 1;
|
|
26
|
+
display: flex;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.treeGraph-LllSyP {
|
|
30
|
+
row-gap: 8px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.assetDetailRoot-dgQPS5 {
|
|
34
|
+
column-gap: var(--spacing-base);
|
|
35
|
+
flex: 1;
|
|
36
|
+
grid-template-columns: 1fr 3fr;
|
|
37
|
+
display: grid;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.assetDetailFileTreeViewport-USNF6e {
|
|
41
|
+
position: relative;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.assetDetailFileTreeScrollArea-IqDzT3 {
|
|
45
|
+
position: absolute;
|
|
46
|
+
inset: 0;
|
|
47
|
+
overflow: auto;
|
|
48
|
+
}
|
|
49
|
+
|
|
1
50
|
.assets-ll1P_L .rc-tree-indent-unit {
|
|
2
51
|
width: 22px;
|
|
3
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://./src/pages/BundleSize/components/index.module.scss"],"names":[],"mappings":"AAAA;EACE,WAAW;AACb;;
|
|
1
|
+
{"version":3,"sources":["webpack://./src/pages/BundleSize/components/index.module.scss"],"names":[],"mappings":"AAAA;EACE,cAAc;AAChB;;AAF8B;EAK5B,sBAAsB;EACtB,OAAO;EACP,aAAa;AACf;;AAR8B;EAW5B,sBAAsB;EACtB,OAAO;EACP,aAAa;AACf;;AAd8B;EAiB5B,sBAAsB;EACtB,OAAO;EACP,aAAa;AACf;;AApB8B;EAuB5B,sBAAsB;EACtB,OAAO;EACP,aAAa;AACf;;AA1ByU;EA6BvU,YAAY;AACd;;AA9BgW;EAiC9V,+BAA+B;EAC/B,OAAO;EACP,8BAA8B;EAC9B,aAAa;AACf;;AArCkc;EAwChc,kBAAkB;AACpB;;AAzCif;EA4C/e,kBAAkB;EAClB,QAAQ;EACR,cAAc;AAChB;;AA/CwjB;EAkDtjB,WAAW;AACb;;AAnDwmB;EAsDtmB,4BAA4B;AAC9B;;AAvDsqB;EA0DpqB,kBAAkB;EAClB,WAAW;AACb;;AA5Dk0B;EA+Dh0B,eAAe;AACjB;;AAhE49B;EAmE19B,cAAc;EACd,iBAAiB;AACnB;;AArEqnC;EAwEnnC,mBAAmB;EACnB,aAAa;AACf;;AA1EuqC;EA6ErqC,iBAAiB;AACnB;;AA9EotC;EAiFltC,YAAY;AACd;;AAlF2uC;EAqFzuC,gBAAgB;AAClB;;AAtFoyC;EAyFlyC,YAAY;EACZ,gBAAgB;AAClB;;AA3Fw2C;EA8Ft2C,WAAW;AACb;;AA/F+3C;EAkG73C,kBAAkB;AACpB;;AAnGk6C;EAsGh6C,WAAW;EACX,UAAU;EACV,sBAAsB;EACtB,qDAAqD;EACrD,mBAAmB;EACnB,kBAAkB;EAClB,WAAW;AACb;;AA7GskD;EAgHpkD,UAAU;AACZ;;AAjH0mD;EAoHxmD,iBAAiB;EACjB,cAAc;AAChB;;AAtHwrD;EAyHtrD,eAAe;EACf,sBAAsB;AACxB","sourcesContent":[".root .rootBody{padding-top:0}.root,.rootBody,.treeGraph,.tabsRoot,.assetDetailCol,.assetDetailFileTreeRoot,.assetDetailFileTreeBody,.assetDetailFileTreeViewport,.tabsRoot :global(.ant-tabs-content-holder),.tabsRoot :global(.ant-tabs-content),.tabsRoot :global(.ant-tabs-tabpane-active){display:flex;flex-direction:column;flex:1}.treeGraph{row-gap:8px}.assetDetailRoot{display:grid;column-gap:var(--spacing-base);grid-template-columns:1fr 3fr;flex:1}.assetDetailFileTreeViewport{position:relative}.assetDetailFileTreeScrollArea{position:absolute;inset:0;overflow:auto}.assets :global .rc-tree-indent-unit{width:22px}.assets :global .rc-tree-treenode{line-height:30px !important}.assets :global .rc-tree-treenode:not(.rc-tree-treenode-switcher-open):not(.rc-tree-treenode-switcher-close) .rc-tree-switcher{position:relative;bottom:4px}.assets :global .rc-tree-treenode:not(.rc-tree-treenode-switcher-open):not(.rc-tree-treenode-switcher-close) .rc-tree-node-content-wrapper{font-size:14px}.assets :global .rc-tree-treenode:not(.rc-tree-treenode-switcher-open):not(.rc-tree-treenode-switcher-close) .file-icon{padding:10px 0 0 0;margin-left:0}.assets .assetBox{display:flex;align-items:center}.assets .assetBox .fileText{margin-right:4px}.assetsTag{height:30px}.assetsTag :global .ant-divider-vertical{margin-inline:0}.modal :global .ant-input-affix-wrapper{padding:4px 5px;width:490px}.search-btn{color:#fff}.search-btn>span{position:relative}.search-btn::before{content:\"\";background:linear-gradient(135deg, #6253e1, #04befe);position:absolute;inset:-1px;opacity:1;transition:all .3s;border-radius:inherit}.search-btn:hover::before{opacity:0}.search-modal-list :global .ant-spin-container{overflow:auto;max-height:30rem}.search-modal-list :global .search-list-item.clickable:hover{background-color:#eee;cursor:pointer}"],"sourceRoot":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Client, SDK } from '@rsdoctor/types';
|
|
2
|
+
import './index.sass';
|
|
3
|
+
export declare const TreeGraph: import("react").MemoExoticComponent<({ cwd, summary, entryPoints, }: {
|
|
4
|
+
cwd: string;
|
|
5
|
+
summary: Client.RsdoctorClientAssetsSummary;
|
|
6
|
+
entryPoints: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetEntryPoints>;
|
|
7
|
+
}) => import("react").JSX.Element>;
|
|
@@ -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
|