@rsdoctor/components 1.2.4-beta.0 → 1.2.4-beta.2
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/Layout/header.mjs +1 -1
- package/dist/components/Layout/header.mjs.map +1 -1
- package/dist/pages/Uploader/index.mjs +36 -37
- package/dist/pages/Uploader/index.mjs.map +1 -1
- package/dist/pages/Uploader/utils.d.ts +3 -0
- package/dist/pages/Uploader/utils.mjs +45 -0
- package/dist/pages/Uploader/utils.mjs.map +1 -0
- package/dist/utils/stats.d.ts +2 -2
- package/dist/utils/stats.mjs +3 -3
- package/dist/utils/stats.mjs.map +1 -1
- package/package.json +9 -9
|
@@ -71,7 +71,7 @@ const Header = ({ enableRoutes })=>{
|
|
|
71
71
|
className: "rsdoctor-logo",
|
|
72
72
|
alt: "logo",
|
|
73
73
|
onClick: ()=>{
|
|
74
|
-
navigate(Client.RsdoctorClientRoutes.Home);
|
|
74
|
+
location.hash.includes(Client.RsdoctorClientRoutes.Uploader) && location.pathname.includes('/preview') ? location.href = 'http://rsdoctor.rs' : navigate(Client.RsdoctorClientRoutes.Home);
|
|
75
75
|
}
|
|
76
76
|
}),
|
|
77
77
|
/*#__PURE__*/ jsx(BuilderSelect, {})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components/Layout/header.mjs","sources":["webpack://@rsdoctor/components/./src/components/Layout/header.tsx"],"sourcesContent":["import { TranslationOutlined } from '@ant-design/icons';\nimport { Col, Dropdown, Layout, Row } from 'antd';\nimport React from 'react';\nimport { Language, Size } from '../../constants';\nimport { useI18n, useTheme } from '../../utils';\nimport { OverlayAlertsWithButton } from '../Alerts';\nimport { BuilderSelect } from './builder-select';\nimport { Menus } from './menus';\nimport './header.sass';\nimport { Client } from '@rsdoctor/types';\nimport { useNavigate } from 'react-router-dom';\n\nexport interface HeaderProps {\n enableRoutes?: string[];\n}\n\nexport const Header: React.FC<HeaderProps> = ({ enableRoutes }) => {\n const { i18n } = useI18n();\n\n const navigate = useNavigate();\n const { isLight } = useTheme();\n const iconStyle: React.CSSProperties = {\n display: 'inline-block',\n fontSize: 20,\n textAlign: 'center',\n verticalAlign: 'middle',\n cursor: 'pointer',\n width: 30,\n transition: 'all 0.3s ease',\n };\n const languages = [\n { value: Language.Cn, label: '中文' },\n { value: Language.En, label: 'English' },\n ];\n\n return (\n <Layout.Header\n style={{\n height: Size.NavBarHeight,\n padding: 0,\n paddingLeft: Size.BasePadding,\n paddingRight: Size.BasePadding,\n position: 'fixed',\n zIndex: 999,\n width: '100%',\n backgroundColor: isLight ? '#fff' : '#141414',\n transition: 'none',\n }}\n >\n <Row\n justify=\"space-between\"\n align=\"middle\"\n style={{ height: Size.NavBarHeight }}\n wrap={false}\n >\n <Col\n style={{\n height: Size.NavBarHeight,\n lineHeight: `${Size.NavBarHeight + 2}px`,\n }}\n >\n <div\n style={{\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n height: '100%',\n }}\n >\n <img\n src=\"https://assets.rspack.rs/rsdoctor/rsdoctor-title-logo.png\"\n className=\"rsdoctor-logo\"\n alt=\"logo\"\n onClick={() => {\n navigate(Client.RsdoctorClientRoutes.Home);\n }}\n />\n <BuilderSelect />\n </div>\n </Col>\n <Menus\n key={enableRoutes ? JSON.stringify(enableRoutes) : 'default'}\n style={{ transition: 'none' }}\n />\n\n <Col flex={1}>\n <Row\n align=\"middle\"\n justify=\"end\"\n style={{ height: Size.NavBarHeight }}\n wrap={false}\n gutter={[Size.BasePadding / 3, 0]}\n >\n <Col>\n <OverlayAlertsWithButton />\n </Col>\n\n {/* <Col> TODO: dark mode has some error need fix.\n <Switch\n className=\"header-switch\"\n checkedChildren=\"🌛\"\n unCheckedChildren=\"🌞\"\n checked={isDark}\n onChange={(checked) => {\n setTheme(checked ? Theme.Dark : Theme.Light);\n }}\n style={{ border: `1px solid ${isLight ? '#ddd' : '#fff'}`, background: isLight ? '#eee' : '#141414' }}\n />\n </Col> */}\n <Col>\n <Dropdown\n overlayStyle={{ zIndex: 1000 }}\n menu={{\n items: languages.map((e) => ({\n label: e.label,\n key: e.value,\n onClick() {\n i18n.changeLanguage(e.value);\n },\n })),\n selectedKeys: [i18n.language],\n }}\n >\n <TranslationOutlined\n className=\"header-icon\"\n style={iconStyle}\n />\n </Dropdown>\n </Col>\n </Row>\n </Col>\n </Row>\n </Layout.Header>\n );\n};\n"],"names":["Header","enableRoutes","i18n","useI18n","navigate","useNavigate","isLight","useTheme","iconStyle","languages","Language","Layout","Size","Row","Col","Client","BuilderSelect","Menus","JSON","OverlayAlertsWithButton","Dropdown","e","TranslationOutlined"],"mappings":";;;;;;;;;;;;AAgBO,MAAMA,SAAgC,CAAC,EAAEC,YAAY,EAAE;IAC5D,MAAM,EAAEC,IAAI,EAAE,GAAGC;IAEjB,MAAMC,WAAWC;IACjB,MAAM,EAAEC,OAAO,EAAE,GAAGC;IACpB,MAAMC,YAAiC;QACrC,SAAS;QACT,UAAU;QACV,WAAW;QACX,eAAe;QACf,QAAQ;QACR,OAAO;QACP,YAAY;IACd;IACA,MAAMC,YAAY;QAChB;YAAE,OAAOC,SAAS,EAAE;YAAE,OAAO;QAAK;QAClC;YAAE,OAAOA,SAAS,EAAE;YAAE,OAAO;QAAU;KACxC;IAED,OAAO,WAAP,GACE,IAACC,OAAO,MAAM;QACZ,OAAO;YACL,QAAQC,KAAK,YAAY;YACzB,SAAS;YACT,aAAaA,KAAK,WAAW;YAC7B,cAAcA,KAAK,WAAW;YAC9B,UAAU;YACV,QAAQ;YACR,OAAO;YACP,iBAAiBN,UAAU,SAAS;YACpC,YAAY;QACd;kBAEA,mBAACO,KAAGA;YACF,SAAQ;YACR,OAAM;YACN,OAAO;gBAAE,QAAQD,KAAK,YAAY;YAAC;YACnC,MAAM;;8BAEN,IAACE,KAAGA;oBACF,OAAO;wBACL,QAAQF,KAAK,YAAY;wBACzB,YAAY,GAAGA,KAAK,YAAY,GAAG,EAAE,EAAE,CAAC;oBAC1C;8BAEA,mBAAC;wBACC,OAAO;4BACL,SAAS;4BACT,gBAAgB;4BAChB,YAAY;4BACZ,QAAQ;wBACV;;0CAEA,IAAC;gCACC,KAAI;gCACJ,WAAU;gCACV,KAAI;gCACJ,SAAS;
|
|
1
|
+
{"version":3,"file":"components/Layout/header.mjs","sources":["webpack://@rsdoctor/components/./src/components/Layout/header.tsx"],"sourcesContent":["import { TranslationOutlined } from '@ant-design/icons';\nimport { Col, Dropdown, Layout, Row } from 'antd';\nimport React from 'react';\nimport { Language, Size } from '../../constants';\nimport { useI18n, useTheme } from '../../utils';\nimport { OverlayAlertsWithButton } from '../Alerts';\nimport { BuilderSelect } from './builder-select';\nimport { Menus } from './menus';\nimport './header.sass';\nimport { Client } from '@rsdoctor/types';\nimport { useNavigate } from 'react-router-dom';\n\nexport interface HeaderProps {\n enableRoutes?: string[];\n}\n\nexport const Header: React.FC<HeaderProps> = ({ enableRoutes }) => {\n const { i18n } = useI18n();\n\n const navigate = useNavigate();\n const { isLight } = useTheme();\n const iconStyle: React.CSSProperties = {\n display: 'inline-block',\n fontSize: 20,\n textAlign: 'center',\n verticalAlign: 'middle',\n cursor: 'pointer',\n width: 30,\n transition: 'all 0.3s ease',\n };\n const languages = [\n { value: Language.Cn, label: '中文' },\n { value: Language.En, label: 'English' },\n ];\n\n return (\n <Layout.Header\n style={{\n height: Size.NavBarHeight,\n padding: 0,\n paddingLeft: Size.BasePadding,\n paddingRight: Size.BasePadding,\n position: 'fixed',\n zIndex: 999,\n width: '100%',\n backgroundColor: isLight ? '#fff' : '#141414',\n transition: 'none',\n }}\n >\n <Row\n justify=\"space-between\"\n align=\"middle\"\n style={{ height: Size.NavBarHeight }}\n wrap={false}\n >\n <Col\n style={{\n height: Size.NavBarHeight,\n lineHeight: `${Size.NavBarHeight + 2}px`,\n }}\n >\n <div\n style={{\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n height: '100%',\n }}\n >\n <img\n src=\"https://assets.rspack.rs/rsdoctor/rsdoctor-title-logo.png\"\n className=\"rsdoctor-logo\"\n alt=\"logo\"\n onClick={() => {\n location.hash.includes(Client.RsdoctorClientRoutes.Uploader) &&\n location.pathname.includes('/preview')\n ? (location.href = 'http://rsdoctor.rs')\n : navigate(Client.RsdoctorClientRoutes.Home);\n }}\n />\n <BuilderSelect />\n </div>\n </Col>\n <Menus\n key={enableRoutes ? JSON.stringify(enableRoutes) : 'default'}\n style={{ transition: 'none' }}\n />\n\n <Col flex={1}>\n <Row\n align=\"middle\"\n justify=\"end\"\n style={{ height: Size.NavBarHeight }}\n wrap={false}\n gutter={[Size.BasePadding / 3, 0]}\n >\n <Col>\n <OverlayAlertsWithButton />\n </Col>\n\n {/* <Col> TODO: dark mode has some error need fix.\n <Switch\n className=\"header-switch\"\n checkedChildren=\"🌛\"\n unCheckedChildren=\"🌞\"\n checked={isDark}\n onChange={(checked) => {\n setTheme(checked ? Theme.Dark : Theme.Light);\n }}\n style={{ border: `1px solid ${isLight ? '#ddd' : '#fff'}`, background: isLight ? '#eee' : '#141414' }}\n />\n </Col> */}\n <Col>\n <Dropdown\n overlayStyle={{ zIndex: 1000 }}\n menu={{\n items: languages.map((e) => ({\n label: e.label,\n key: e.value,\n onClick() {\n i18n.changeLanguage(e.value);\n },\n })),\n selectedKeys: [i18n.language],\n }}\n >\n <TranslationOutlined\n className=\"header-icon\"\n style={iconStyle}\n />\n </Dropdown>\n </Col>\n </Row>\n </Col>\n </Row>\n </Layout.Header>\n );\n};\n"],"names":["Header","enableRoutes","i18n","useI18n","navigate","useNavigate","isLight","useTheme","iconStyle","languages","Language","Layout","Size","Row","Col","location","Client","BuilderSelect","Menus","JSON","OverlayAlertsWithButton","Dropdown","e","TranslationOutlined"],"mappings":";;;;;;;;;;;;AAgBO,MAAMA,SAAgC,CAAC,EAAEC,YAAY,EAAE;IAC5D,MAAM,EAAEC,IAAI,EAAE,GAAGC;IAEjB,MAAMC,WAAWC;IACjB,MAAM,EAAEC,OAAO,EAAE,GAAGC;IACpB,MAAMC,YAAiC;QACrC,SAAS;QACT,UAAU;QACV,WAAW;QACX,eAAe;QACf,QAAQ;QACR,OAAO;QACP,YAAY;IACd;IACA,MAAMC,YAAY;QAChB;YAAE,OAAOC,SAAS,EAAE;YAAE,OAAO;QAAK;QAClC;YAAE,OAAOA,SAAS,EAAE;YAAE,OAAO;QAAU;KACxC;IAED,OAAO,WAAP,GACE,IAACC,OAAO,MAAM;QACZ,OAAO;YACL,QAAQC,KAAK,YAAY;YACzB,SAAS;YACT,aAAaA,KAAK,WAAW;YAC7B,cAAcA,KAAK,WAAW;YAC9B,UAAU;YACV,QAAQ;YACR,OAAO;YACP,iBAAiBN,UAAU,SAAS;YACpC,YAAY;QACd;kBAEA,mBAACO,KAAGA;YACF,SAAQ;YACR,OAAM;YACN,OAAO;gBAAE,QAAQD,KAAK,YAAY;YAAC;YACnC,MAAM;;8BAEN,IAACE,KAAGA;oBACF,OAAO;wBACL,QAAQF,KAAK,YAAY;wBACzB,YAAY,GAAGA,KAAK,YAAY,GAAG,EAAE,EAAE,CAAC;oBAC1C;8BAEA,mBAAC;wBACC,OAAO;4BACL,SAAS;4BACT,gBAAgB;4BAChB,YAAY;4BACZ,QAAQ;wBACV;;0CAEA,IAAC;gCACC,KAAI;gCACJ,WAAU;gCACV,KAAI;gCACJ,SAAS;oCACPG,SAAS,IAAI,CAAC,QAAQ,CAACC,OAAO,oBAAoB,CAAC,QAAQ,KAC3DD,SAAS,QAAQ,CAAC,QAAQ,CAAC,cACtBA,SAAS,IAAI,GAAG,uBACjBX,SAASY,OAAO,oBAAoB,CAAC,IAAI;gCAC/C;;0CAEF,IAACC,eAAaA,CAAAA;;;;8BAGlB,IAACC,OAAKA;oBAEJ,OAAO;wBAAE,YAAY;oBAAO;mBADvBjB,eAAekB,KAAK,SAAS,CAAClB,gBAAgB;8BAIrD,IAACa,KAAGA;oBAAC,MAAM;8BACT,mBAACD,KAAGA;wBACF,OAAM;wBACN,SAAQ;wBACR,OAAO;4BAAE,QAAQD,KAAK,YAAY;wBAAC;wBACnC,MAAM;wBACN,QAAQ;4BAACA,KAAK,WAAW,GAAG;4BAAG;yBAAE;;0CAEjC,IAACE,KAAGA;0CACF,kBAACM,yBAAuBA,CAAAA;;0CAe1B,IAACN,KAAGA;0CACF,kBAACO,UAAQA;oCACP,cAAc;wCAAE,QAAQ;oCAAK;oCAC7B,MAAM;wCACJ,OAAOZ,UAAU,GAAG,CAAC,CAACa,IAAO;gDAC3B,OAAOA,EAAE,KAAK;gDACd,KAAKA,EAAE,KAAK;gDACZ;oDACEpB,KAAK,cAAc,CAACoB,EAAE,KAAK;gDAC7B;4CACF;wCACA,cAAc;4CAACpB,KAAK,QAAQ;yCAAC;oCAC/B;8CAEA,kBAACqB,qBAAmBA;wCAClB,WAAU;wCACV,OAAOf;;;;;;;;;;AASzB"}
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { Spin, Upload, message } from "antd";
|
|
4
2
|
import { InboxOutlined } from "@ant-design/icons";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { Spin, Upload, message } from "antd";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { readJSONByFileReader } from "../../utils/index.mjs";
|
|
6
|
+
import { isRspackStats } from "../../utils/stats.mjs";
|
|
7
|
+
import { handleRsdoctorManifest, handleRspackStats } from "./utils.mjs";
|
|
8
8
|
export * from "./constants.mjs";
|
|
9
9
|
const Component = ()=>{
|
|
10
10
|
const [loading, setLoading] = useState(false);
|
|
11
|
+
const handleFileUpload = async (file)=>{
|
|
12
|
+
if (!file) return;
|
|
13
|
+
setLoading(true);
|
|
14
|
+
try {
|
|
15
|
+
const json = await readJSONByFileReader(file);
|
|
16
|
+
if (!json || 'object' != typeof json) throw new Error('Invalid JSON format');
|
|
17
|
+
if (isRspackStats(json)) await handleRspackStats(json);
|
|
18
|
+
else handleRsdoctorManifest(json);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
|
|
21
|
+
message.error(`Upload failed: ${errorMessage}`);
|
|
22
|
+
console.error('Upload error:', err);
|
|
23
|
+
} finally{
|
|
24
|
+
setLoading(false);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
11
27
|
return /*#__PURE__*/ jsx(Spin, {
|
|
12
28
|
spinning: loading,
|
|
13
29
|
tip: "uploading...",
|
|
@@ -16,36 +32,7 @@ const Component = ()=>{
|
|
|
16
32
|
showUploadList: false,
|
|
17
33
|
accept: ".json",
|
|
18
34
|
onChange: ({ file })=>{
|
|
19
|
-
|
|
20
|
-
readJSONByFileReader(file).then(async (json)=>{
|
|
21
|
-
if (json && 'object' == typeof json) try {
|
|
22
|
-
window[Constants.WINDOW_RSDOCTOR_TAG] = json.data;
|
|
23
|
-
window[Constants.WINDOW_RSDOCTOR_TAG].enableRoutes = json.clientRoutes;
|
|
24
|
-
const enableRoutes = json.clientRoutes;
|
|
25
|
-
const baseUrl = `http://${location.host}/#/overall`;
|
|
26
|
-
const queryParams = enableRoutes && enableRoutes.length > 0 ? `?${Client.RsdoctorClientUrlQuery.EnableRoutes}=${encodeURIComponent(JSON.stringify(enableRoutes))}` : '';
|
|
27
|
-
location.href = `${baseUrl}${queryParams}`;
|
|
28
|
-
message.success('JSON data loaded successfully!');
|
|
29
|
-
} catch (err) {
|
|
30
|
-
message.error(`Failed to load JSON data: ${err.message}`);
|
|
31
|
-
console.error('Failed to load JSON data:', err);
|
|
32
|
-
}
|
|
33
|
-
else if (isWebpackStats(json)) {
|
|
34
|
-
const manifestJson = await loadWebpackStats([
|
|
35
|
-
json
|
|
36
|
-
]).then((manifests)=>manifests[0]).catch((err)=>{
|
|
37
|
-
message.error(`load json error: ${err.message}`);
|
|
38
|
-
throw err;
|
|
39
|
-
});
|
|
40
|
-
if (manifestJson) location.href = getSharingUrl((null == manifestJson ? void 0 : manifestJson.cloudManifestUrl) || '');
|
|
41
|
-
else message.error('json is invalid');
|
|
42
|
-
} else {
|
|
43
|
-
message.error('Invalid JSON format');
|
|
44
|
-
console.warn('Invalid JSON format:', json);
|
|
45
|
-
}
|
|
46
|
-
}).finally(()=>{
|
|
47
|
-
setLoading(false);
|
|
48
|
-
});
|
|
35
|
+
handleFileUpload(file);
|
|
49
36
|
},
|
|
50
37
|
style: {
|
|
51
38
|
width: '100%'
|
|
@@ -58,11 +45,23 @@ const Component = ()=>{
|
|
|
58
45
|
}),
|
|
59
46
|
/*#__PURE__*/ jsx("p", {
|
|
60
47
|
className: "ant-upload-text",
|
|
61
|
-
children: "Click or drag
|
|
48
|
+
children: "Click or drag JSON file to this area to upload and analyze your stats.json or rsdoctor's rsdoctor-data.json."
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ jsxs("p", {
|
|
51
|
+
className: "ant-upload-hint",
|
|
52
|
+
children: [
|
|
53
|
+
"The rsdoctor's rsdoctor-data.json is in brief mode, and use the file type: ['json'].",
|
|
54
|
+
/*#__PURE__*/ jsx("a", {
|
|
55
|
+
href: "https://rsdoctor.rs/zh/config/options/output#mode-brief",
|
|
56
|
+
target: "_blank",
|
|
57
|
+
rel: "noopener noreferrer",
|
|
58
|
+
children: "Check the details."
|
|
59
|
+
})
|
|
60
|
+
]
|
|
62
61
|
}),
|
|
63
62
|
/*#__PURE__*/ jsx("p", {
|
|
64
63
|
className: "ant-upload-hint",
|
|
65
|
-
children: "By default, Rsdoctor will emit the
|
|
64
|
+
children: "By default, Rsdoctor will emit the rsdoctor-data.json to the output folder."
|
|
66
65
|
})
|
|
67
66
|
]
|
|
68
67
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages/Uploader/index.mjs","sources":["webpack://@rsdoctor/components/./src/pages/Uploader/index.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"pages/Uploader/index.mjs","sources":["webpack://@rsdoctor/components/./src/pages/Uploader/index.tsx"],"sourcesContent":["import { InboxOutlined } from '@ant-design/icons';\nimport { Common } from '@rsdoctor/types';\nimport { message, Spin, Upload, UploadFile } from 'antd';\nimport React, { useState } from 'react';\nimport { readJSONByFileReader } from '../../utils';\nimport { isRspackStats } from '../../utils/stats';\nimport { handleRspackStats, handleRsdoctorManifest } from './utils';\n\nconst Component: React.FC = () => {\n const [loading, setLoading] = useState(false);\n\n // Main file upload processing function\n const handleFileUpload = async (file: UploadFile) => {\n if (!file) return;\n\n setLoading(true);\n\n try {\n const json = await readJSONByFileReader<Common.PlainObject>(file);\n\n if (!json || typeof json !== 'object') {\n throw new Error('Invalid JSON format');\n }\n\n if (isRspackStats(json)) {\n await handleRspackStats(json);\n } else {\n handleRsdoctorManifest(json);\n }\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : 'Unknown error';\n message.error(`Upload failed: ${errorMessage}`);\n console.error('Upload error:', err);\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <Spin spinning={loading} tip=\"uploading...\">\n <Upload.Dragger\n multiple={false}\n showUploadList={false}\n accept=\".json\"\n onChange={({ file }) => {\n handleFileUpload(file);\n }}\n style={{ width: '100%' }}\n beforeUpload={() => false}\n >\n <p className=\"ant-upload-drag-icon\">\n <InboxOutlined />\n </p>\n <p className=\"ant-upload-text\">\n Click or drag JSON file to this area to upload and analyze your\n stats.json or rsdoctor's rsdoctor-data.json.\n </p>\n <p className=\"ant-upload-hint\">\n The rsdoctor's rsdoctor-data.json is in brief mode, and use the file\n type: ['json'].\n <a\n href=\"https://rsdoctor.rs/zh/config/options/output#mode-brief\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Check the details.\n </a>\n </p>\n <p className=\"ant-upload-hint\">\n By default, Rsdoctor will emit the rsdoctor-data.json to the output\n folder.\n </p>\n </Upload.Dragger>\n </Spin>\n );\n};\n\nexport const Page = Component;\nexport * from './constants';\n"],"names":["Component","loading","setLoading","useState","handleFileUpload","file","json","readJSONByFileReader","Error","isRspackStats","handleRspackStats","handleRsdoctorManifest","err","errorMessage","message","console","Spin","Upload","InboxOutlined","Page"],"mappings":";;;;;;;;AAQA,MAAMA,YAAsB;IAC1B,MAAM,CAACC,SAASC,WAAW,GAAGC,SAAS;IAGvC,MAAMC,mBAAmB,OAAOC;QAC9B,IAAI,CAACA,MAAM;QAEXH,WAAW;QAEX,IAAI;YACF,MAAMI,OAAO,MAAMC,qBAAyCF;YAE5D,IAAI,CAACC,QAAQ,AAAgB,YAAhB,OAAOA,MAClB,MAAM,IAAIE,MAAM;YAGlB,IAAIC,cAAcH,OAChB,MAAMI,kBAAkBJ;iBAExBK,uBAAuBL;QAE3B,EAAE,OAAOM,KAAK;YACZ,MAAMC,eAAeD,eAAeJ,QAAQI,IAAI,OAAO,GAAG;YAC1DE,QAAQ,KAAK,CAAC,CAAC,eAAe,EAAED,cAAc;YAC9CE,QAAQ,KAAK,CAAC,iBAAiBH;QACjC,SAAU;YACRV,WAAW;QACb;IACF;IAEA,OAAO,WAAP,GACE,IAACc,MAAIA;QAAC,UAAUf;QAAS,KAAI;kBAC3B,mBAACgB,OAAO,OAAO;YACb,UAAU;YACV,gBAAgB;YAChB,QAAO;YACP,UAAU,CAAC,EAAEZ,IAAI,EAAE;gBACjBD,iBAAiBC;YACnB;YACA,OAAO;gBAAE,OAAO;YAAO;YACvB,cAAc,IAAM;;8BAEpB,IAAC;oBAAE,WAAU;8BACX,kBAACa,eAAaA,CAAAA;;8BAEhB,IAAC;oBAAE,WAAU;8BAAkB;;8BAI/B,KAAC;oBAAE,WAAU;;wBAAkB;sCAG7B,IAAC;4BACC,MAAK;4BACL,QAAO;4BACP,KAAI;sCACL;;;;8BAIH,IAAC;oBAAE,WAAU;8BAAkB;;;;;AAOvC;AAEO,MAAMC,OAAOnB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Client, Constants, Manifest } from "@rsdoctor/types";
|
|
2
|
+
import { message } from "antd";
|
|
3
|
+
import { loadRspackStats } from "../../utils/stats.mjs";
|
|
4
|
+
const defaultEnableRoutes = [
|
|
5
|
+
Manifest.RsdoctorManifestClientRoutes.Overall,
|
|
6
|
+
Manifest.RsdoctorManifestClientRoutes.BundleSize
|
|
7
|
+
];
|
|
8
|
+
const buildRedirectUrl = (enableRoutes)=>{
|
|
9
|
+
const baseUrl = `http://${location.host}${location.pathname}#/overall`;
|
|
10
|
+
const queryParams = enableRoutes && enableRoutes.length > 0 ? `?${Client.RsdoctorClientUrlQuery.EnableRoutes}=${encodeURIComponent(JSON.stringify(enableRoutes))}` : '';
|
|
11
|
+
return `${baseUrl}${queryParams}`;
|
|
12
|
+
};
|
|
13
|
+
const setWindowDataAndRedirect = (data, enableRoutes)=>{
|
|
14
|
+
window[Constants.WINDOW_RSDOCTOR_TAG] = data;
|
|
15
|
+
window[Constants.WINDOW_RSDOCTOR_TAG].enableRoutes = enableRoutes;
|
|
16
|
+
const redirectUrl = buildRedirectUrl(enableRoutes);
|
|
17
|
+
location.href = redirectUrl;
|
|
18
|
+
message.success('JSON data loaded successfully!');
|
|
19
|
+
};
|
|
20
|
+
const handleRspackStats = async (json)=>{
|
|
21
|
+
try {
|
|
22
|
+
const manifestJson = await loadRspackStats([
|
|
23
|
+
json
|
|
24
|
+
]);
|
|
25
|
+
if (manifestJson && manifestJson[0]) setWindowDataAndRedirect(manifestJson[0].data, defaultEnableRoutes);
|
|
26
|
+
else throw new Error('Invalid manifest data');
|
|
27
|
+
} catch (err) {
|
|
28
|
+
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
|
|
29
|
+
message.error(`Failed to load Rspack stats: ${errorMessage}`);
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const handleRsdoctorManifest = (json)=>{
|
|
34
|
+
try {
|
|
35
|
+
const enableRoutes = json.clientRoutes || defaultEnableRoutes;
|
|
36
|
+
setWindowDataAndRedirect(json.data, enableRoutes);
|
|
37
|
+
} catch (err) {
|
|
38
|
+
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
|
|
39
|
+
message.error(`Failed to load manifest data: ${errorMessage}`);
|
|
40
|
+
console.error('Failed to load manifest data:', err);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export { handleRsdoctorManifest, handleRspackStats };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages/Uploader/utils.mjs","sources":["webpack://@rsdoctor/components/./src/pages/Uploader/utils.ts"],"sourcesContent":["import { Client, Common, Constants, Manifest } from '@rsdoctor/types';\nimport { message } from 'antd';\nimport { loadRspackStats } from '../../utils/stats';\n\n// Default enabled routes\nconst defaultEnableRoutes = [\n Manifest.RsdoctorManifestClientRoutes.Overall,\n Manifest.RsdoctorManifestClientRoutes.BundleSize,\n];\n\n// Build redirect URL\nconst buildRedirectUrl = (enableRoutes: string[]) => {\n const baseUrl = `http://${location.host}${location.pathname}#/overall`;\n const queryParams =\n enableRoutes && enableRoutes.length > 0\n ? `?${Client.RsdoctorClientUrlQuery.EnableRoutes}=${encodeURIComponent(JSON.stringify(enableRoutes))}`\n : '';\n return `${baseUrl}${queryParams}`;\n};\n\n// Set window data and redirect\nconst setWindowDataAndRedirect = (data: any, enableRoutes: string[]) => {\n window[Constants.WINDOW_RSDOCTOR_TAG] = data;\n window[Constants.WINDOW_RSDOCTOR_TAG].enableRoutes = enableRoutes;\n\n const redirectUrl = buildRedirectUrl(enableRoutes);\n location.href = redirectUrl;\n\n message.success('JSON data loaded successfully!');\n};\n\n// Handle Rspack Stats data\nexport const handleRspackStats = async (json: Common.PlainObject) => {\n try {\n const manifestJson = await loadRspackStats([json]);\n if (manifestJson && manifestJson[0]) {\n setWindowDataAndRedirect(manifestJson[0].data, defaultEnableRoutes);\n } else {\n throw new Error('Invalid manifest data');\n }\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : 'Unknown error';\n message.error(`Failed to load Rspack stats: ${errorMessage}`);\n throw err;\n }\n};\n\n// Handle Rsdoctor Manifest data\nexport const handleRsdoctorManifest = (json: Common.PlainObject) => {\n try {\n const enableRoutes = json.clientRoutes || defaultEnableRoutes;\n setWindowDataAndRedirect(json.data, enableRoutes);\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : 'Unknown error';\n message.error(`Failed to load manifest data: ${errorMessage}`);\n console.error('Failed to load manifest data:', err);\n }\n};\n"],"names":["defaultEnableRoutes","Manifest","buildRedirectUrl","enableRoutes","baseUrl","location","queryParams","Client","encodeURIComponent","JSON","setWindowDataAndRedirect","data","window","Constants","redirectUrl","message","handleRspackStats","json","manifestJson","loadRspackStats","Error","err","errorMessage","handleRsdoctorManifest","console"],"mappings":";;;AAKA,MAAMA,sBAAsB;IAC1BC,SAAS,4BAA4B,CAAC,OAAO;IAC7CA,SAAS,4BAA4B,CAAC,UAAU;CACjD;AAGD,MAAMC,mBAAmB,CAACC;IACxB,MAAMC,UAAU,CAAC,OAAO,EAAEC,SAAS,IAAI,GAAGA,SAAS,QAAQ,CAAC,SAAS,CAAC;IACtE,MAAMC,cACJH,gBAAgBA,aAAa,MAAM,GAAG,IAClC,CAAC,CAAC,EAAEI,OAAO,sBAAsB,CAAC,YAAY,CAAC,CAAC,EAAEC,mBAAmBC,KAAK,SAAS,CAACN,gBAAgB,GACpG;IACN,OAAO,GAAGC,UAAUE,aAAa;AACnC;AAGA,MAAMI,2BAA2B,CAACC,MAAWR;IAC3CS,MAAM,CAACC,UAAU,mBAAmB,CAAC,GAAGF;IACxCC,MAAM,CAACC,UAAU,mBAAmB,CAAC,CAAC,YAAY,GAAGV;IAErD,MAAMW,cAAcZ,iBAAiBC;IACrCE,SAAS,IAAI,GAAGS;IAEhBC,QAAQ,OAAO,CAAC;AAClB;AAGO,MAAMC,oBAAoB,OAAOC;IACtC,IAAI;QACF,MAAMC,eAAe,MAAMC,gBAAgB;YAACF;SAAK;QACjD,IAAIC,gBAAgBA,YAAY,CAAC,EAAE,EACjCR,yBAAyBQ,YAAY,CAAC,EAAE,CAAC,IAAI,EAAElB;aAE/C,MAAM,IAAIoB,MAAM;IAEpB,EAAE,OAAOC,KAAK;QACZ,MAAMC,eAAeD,eAAeD,QAAQC,IAAI,OAAO,GAAG;QAC1DN,QAAQ,KAAK,CAAC,CAAC,6BAA6B,EAAEO,cAAc;QAC5D,MAAMD;IACR;AACF;AAGO,MAAME,yBAAyB,CAACN;IACrC,IAAI;QACF,MAAMd,eAAec,KAAK,YAAY,IAAIjB;QAC1CU,yBAAyBO,KAAK,IAAI,EAAEd;IACtC,EAAE,OAAOkB,KAAK;QACZ,MAAMC,eAAeD,eAAeD,QAAQC,IAAI,OAAO,GAAG;QAC1DN,QAAQ,KAAK,CAAC,CAAC,8BAA8B,EAAEO,cAAc;QAC7DE,QAAQ,KAAK,CAAC,iCAAiCH;IACjD;AACF"}
|
package/dist/utils/stats.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Common, Manifest, Plugin } from '@rsdoctor/types';
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
2
|
+
export declare function isRspackStats(json: Common.PlainObject): json is Plugin.StatsCompilation;
|
|
3
|
+
export declare function loadRspackStats(jsons: Plugin.StatsCompilation[]): Promise<Manifest.RsdoctorManifest[]>;
|
package/dist/utils/stats.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SDK } from "@rsdoctor/types";
|
|
2
2
|
import { Chunks, ModuleGraphTrans, PackageGraph } from "@rsdoctor/graph";
|
|
3
3
|
import { isArray } from "lodash-es";
|
|
4
|
-
function
|
|
4
|
+
function isRspackStats(json) {
|
|
5
5
|
return json.hash && isArray(json.assets) && isArray(json.chunks) && isArray(json.modules);
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
7
|
+
async function loadRspackStats(jsons) {
|
|
8
8
|
const res = await Promise.all(jsons.map(async (json)=>{
|
|
9
9
|
const chunkGraph = Chunks.chunkTransform(new Map(), json);
|
|
10
10
|
const moduleGraph = ModuleGraphTrans.getModuleGraphByStats(json, '.', chunkGraph);
|
|
@@ -38,6 +38,6 @@ async function loadWebpackStats(jsons) {
|
|
|
38
38
|
}
|
|
39
39
|
}));
|
|
40
40
|
}
|
|
41
|
-
export {
|
|
41
|
+
export { isRspackStats, loadRspackStats };
|
|
42
42
|
|
|
43
43
|
//# sourceMappingURL=stats.mjs.map
|
package/dist/utils/stats.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils/stats.mjs","sources":["webpack://@rsdoctor/components/./src/utils/stats.ts"],"sourcesContent":["import { Common, Manifest, Plugin, SDK } from '@rsdoctor/types';\nimport { PackageGraph } from '@rsdoctor/graph';\nimport { Chunks, ModuleGraphTrans } from '@rsdoctor/graph';\nimport { isArray } from 'lodash-es';\n\nexport function
|
|
1
|
+
{"version":3,"file":"utils/stats.mjs","sources":["webpack://@rsdoctor/components/./src/utils/stats.ts"],"sourcesContent":["import { Common, Manifest, Plugin, SDK } from '@rsdoctor/types';\nimport { PackageGraph } from '@rsdoctor/graph';\nimport { Chunks, ModuleGraphTrans } from '@rsdoctor/graph';\nimport { isArray } from 'lodash-es';\n\nexport function isRspackStats(\n json: Common.PlainObject,\n): json is Plugin.StatsCompilation {\n return (\n json.hash &&\n isArray(json.assets) &&\n isArray(json.chunks) &&\n isArray(json.modules)\n );\n}\n\nexport async function loadRspackStats(\n jsons: Plugin.StatsCompilation[],\n): Promise<Manifest.RsdoctorManifest[]> {\n const res = await Promise.all(\n jsons.map(async (json) => {\n const chunkGraph = Chunks.chunkTransform(new Map(), json);\n const moduleGraph = ModuleGraphTrans.getModuleGraphByStats(\n json,\n '.',\n chunkGraph,\n );\n await Chunks.getAssetsModulesData(\n moduleGraph,\n chunkGraph,\n json.outputPath || '',\n {},\n undefined,\n );\n const pkgGraph = PackageGraph.fromModuleGraph(moduleGraph, '.');\n\n return {\n hash: json.hash || '',\n moduleGraph: await moduleGraph.toData(),\n chunkGraph: chunkGraph.toData(SDK.ToDataType.Normal),\n packageGraph: pkgGraph.toData(),\n } as Pick<\n SDK.StoreData,\n 'moduleGraph' | 'chunkGraph' | 'hash' | 'packageGraph'\n >;\n }),\n );\n\n return res.map((e) => {\n return {\n client: {\n enableRoutes: [],\n },\n data: {\n pid: 0,\n root: '',\n errors: [],\n configs: [],\n plugin: {},\n summary: {\n costs: [],\n },\n envinfo: {} as SDK.EnvInfo,\n resolver: [],\n loader: [],\n moduleCodeMap: {},\n ...e,\n },\n };\n });\n}\n"],"names":["isRspackStats","json","isArray","loadRspackStats","jsons","res","Promise","chunkGraph","Chunks","Map","moduleGraph","ModuleGraphTrans","undefined","pkgGraph","PackageGraph","SDK","e"],"mappings":";;;AAKO,SAASA,cACdC,IAAwB;IAExB,OACEA,KAAK,IAAI,IACTC,QAAQD,KAAK,MAAM,KACnBC,QAAQD,KAAK,MAAM,KACnBC,QAAQD,KAAK,OAAO;AAExB;AAEO,eAAeE,gBACpBC,KAAgC;IAEhC,MAAMC,MAAM,MAAMC,QAAQ,GAAG,CAC3BF,MAAM,GAAG,CAAC,OAAOH;QACf,MAAMM,aAAaC,OAAO,cAAc,CAAC,IAAIC,OAAOR;QACpD,MAAMS,cAAcC,iBAAiB,qBAAqB,CACxDV,MACA,KACAM;QAEF,MAAMC,OAAO,oBAAoB,CAC/BE,aACAH,YACAN,KAAK,UAAU,IAAI,IACnB,CAAC,GACDW;QAEF,MAAMC,WAAWC,aAAa,eAAe,CAACJ,aAAa;QAE3D,OAAO;YACL,MAAMT,KAAK,IAAI,IAAI;YACnB,aAAa,MAAMS,YAAY,MAAM;YACrC,YAAYH,WAAW,MAAM,CAACQ,IAAI,UAAU,CAAC,MAAM;YACnD,cAAcF,SAAS,MAAM;QAC/B;IAIF;IAGF,OAAOR,IAAI,GAAG,CAAC,CAACW,IACP;YACL,QAAQ;gBACN,cAAc,EAAE;YAClB;YACA,MAAM;gBACJ,KAAK;gBACL,MAAM;gBACN,QAAQ,EAAE;gBACV,SAAS,EAAE;gBACX,QAAQ,CAAC;gBACT,SAAS;oBACP,OAAO,EAAE;gBACX;gBACA,SAAS,CAAC;gBACV,UAAU,EAAE;gBACZ,QAAQ,EAAE;gBACV,eAAe,CAAC;gBAChB,GAAGA,CAAC;YACN;QACF;AAEJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/components",
|
|
3
|
-
"version": "1.2.4-beta.
|
|
3
|
+
"version": "1.2.4-beta.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@rsbuild/plugin-check-syntax": "1.
|
|
42
|
-
"@rsbuild/plugin-react": "^1.
|
|
43
|
-
"@rsbuild/plugin-sass": "^1.
|
|
41
|
+
"@rsbuild/plugin-check-syntax": "1.4.0",
|
|
42
|
+
"@rsbuild/plugin-react": "^1.4.0",
|
|
43
|
+
"@rsbuild/plugin-sass": "^1.4.0",
|
|
44
44
|
"@rsbuild/plugin-svgr": "^1.2.1",
|
|
45
45
|
"@types/lodash-es": "^4.17.12",
|
|
46
46
|
"@types/node": "^22.8.1",
|
|
47
47
|
"@types/path-browserify": "1.0.3",
|
|
48
|
-
"@types/react": "^18.3.
|
|
48
|
+
"@types/react": "^18.3.24",
|
|
49
49
|
"@types/react-highlight-words": "^0.20.0",
|
|
50
50
|
"@types/url-parse": "1.4.11",
|
|
51
51
|
"react": "18.3.1",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"antd": "5.19.1",
|
|
59
59
|
"axios": "^1.12.0",
|
|
60
60
|
"clsx": "^2.1.1",
|
|
61
|
-
"dayjs": "1.11.
|
|
61
|
+
"dayjs": "1.11.18",
|
|
62
62
|
"echarts": "^5.6.0",
|
|
63
63
|
"echarts-for-react": "^3.0.3",
|
|
64
64
|
"i18next": "22.0.4",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"react-router-dom": "6.4.3",
|
|
76
76
|
"socket.io-client": "4.8.1",
|
|
77
77
|
"url-parse": "1.5.10",
|
|
78
|
-
"@rsdoctor/graph": "1.2.4-beta.
|
|
79
|
-
"@rsdoctor/types": "1.2.4-beta.
|
|
80
|
-
"@rsdoctor/utils": "1.2.4-beta.
|
|
78
|
+
"@rsdoctor/graph": "1.2.4-beta.2",
|
|
79
|
+
"@rsdoctor/types": "1.2.4-beta.2",
|
|
80
|
+
"@rsdoctor/utils": "1.2.4-beta.2"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"react": ">=18.3.1",
|