@rsdoctor/components 0.0.0-next-20240620044732

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +22 -0
  3. package/dist/assets/connection-point.3b3c78ca.svg +1 -0
  4. package/dist/assets/webpack.98604d64.svg +1 -0
  5. package/dist/components/Alert/change.d.ts +8 -0
  6. package/dist/components/Alert/change.js +93 -0
  7. package/dist/components/Alert/file-relation.d.ts +3 -0
  8. package/dist/components/Alert/file-relation.js +9 -0
  9. package/dist/components/Alert/index.css +32 -0
  10. package/dist/components/Alert/index.d.ts +4 -0
  11. package/dist/components/Alert/index.js +37 -0
  12. package/dist/components/Alert/link.d.ts +3 -0
  13. package/dist/components/Alert/link.js +27 -0
  14. package/dist/components/Alert/package-relation.d.ts +17 -0
  15. package/dist/components/Alert/package-relation.js +281 -0
  16. package/dist/components/Alert/types.d.ts +31 -0
  17. package/dist/components/Alert/types.js +0 -0
  18. package/dist/components/Alert/view.d.ts +4 -0
  19. package/dist/components/Alert/view.js +58 -0
  20. package/dist/components/Alerts/bundle.d.ts +11 -0
  21. package/dist/components/Alerts/bundle.js +61 -0
  22. package/dist/components/Alerts/common.d.ts +15 -0
  23. package/dist/components/Alerts/common.js +112 -0
  24. package/dist/components/Alerts/compile.d.ts +10 -0
  25. package/dist/components/Alerts/compile.js +46 -0
  26. package/dist/components/Alerts/index.d.ts +3 -0
  27. package/dist/components/Alerts/index.js +3 -0
  28. package/dist/components/Alerts/overlay.d.ts +26 -0
  29. package/dist/components/Alerts/overlay.js +154 -0
  30. package/dist/components/Badge/index.d.ts +21 -0
  31. package/dist/components/Badge/index.js +87 -0
  32. package/dist/components/BundleDiff/DiffContainer/assets.d.ts +7 -0
  33. package/dist/components/BundleDiff/DiffContainer/assets.js +507 -0
  34. package/dist/components/BundleDiff/DiffContainer/cards.d.ts +3 -0
  35. package/dist/components/BundleDiff/DiffContainer/cards.js +156 -0
  36. package/dist/components/BundleDiff/DiffContainer/changes.d.ts +15 -0
  37. package/dist/components/BundleDiff/DiffContainer/changes.js +69 -0
  38. package/dist/components/BundleDiff/DiffContainer/constants.d.ts +11 -0
  39. package/dist/components/BundleDiff/DiffContainer/constants.js +17 -0
  40. package/dist/components/BundleDiff/DiffContainer/diff.d.ts +23 -0
  41. package/dist/components/BundleDiff/DiffContainer/diff.js +114 -0
  42. package/dist/components/BundleDiff/DiffContainer/index.d.ts +3 -0
  43. package/dist/components/BundleDiff/DiffContainer/index.js +180 -0
  44. package/dist/components/BundleDiff/DiffContainer/modules.d.ts +8 -0
  45. package/dist/components/BundleDiff/DiffContainer/modules.js +302 -0
  46. package/dist/components/BundleDiff/DiffContainer/overview.d.ts +5 -0
  47. package/dist/components/BundleDiff/DiffContainer/overview.js +178 -0
  48. package/dist/components/BundleDiff/DiffContainer/packages.d.ts +19 -0
  49. package/dist/components/BundleDiff/DiffContainer/packages.js +330 -0
  50. package/dist/components/BundleDiff/DiffContainer/row.d.ts +9 -0
  51. package/dist/components/BundleDiff/DiffContainer/row.js +369 -0
  52. package/dist/components/BundleDiff/DiffContainer/types.d.ts +45 -0
  53. package/dist/components/BundleDiff/DiffContainer/types.js +0 -0
  54. package/dist/components/BundleDiff/DiffContainer/utils.d.ts +2 -0
  55. package/dist/components/BundleDiff/DiffContainer/utils.js +24 -0
  56. package/dist/components/BundleDiff/DiffServerAPIProvider/index.d.ts +4 -0
  57. package/dist/components/BundleDiff/DiffServerAPIProvider/index.js +37 -0
  58. package/dist/components/BundleDiff/constants.d.ts +11 -0
  59. package/dist/components/BundleDiff/constants.js +19 -0
  60. package/dist/components/BundleDiff/index.d.ts +1 -0
  61. package/dist/components/BundleDiff/index.js +1 -0
  62. package/dist/components/Card/diff.d.ts +24 -0
  63. package/dist/components/Card/diff.js +116 -0
  64. package/dist/components/Card/index.d.ts +9 -0
  65. package/dist/components/Card/index.js +50 -0
  66. package/dist/components/Card/size.d.ts +21 -0
  67. package/dist/components/Card/size.js +79 -0
  68. package/dist/components/Card/statistic.css +17 -0
  69. package/dist/components/Card/statistic.d.ts +12 -0
  70. package/dist/components/Card/statistic.js +19 -0
  71. package/dist/components/Charts/TimelineCharts/index.d.ts +8 -0
  72. package/dist/components/Charts/TimelineCharts/index.js +212 -0
  73. package/dist/components/Charts/bootstrap.d.ts +5 -0
  74. package/dist/components/Charts/bootstrap.js +44 -0
  75. package/dist/components/Charts/common.d.ts +13 -0
  76. package/dist/components/Charts/common.js +56 -0
  77. package/dist/components/Charts/constants.d.ts +2 -0
  78. package/dist/components/Charts/constants.js +46 -0
  79. package/dist/components/Charts/done.d.ts +5 -0
  80. package/dist/components/Charts/done.js +45 -0
  81. package/dist/components/Charts/index.d.ts +10 -0
  82. package/dist/components/Charts/index.js +37 -0
  83. package/dist/components/Charts/loader.css +31 -0
  84. package/dist/components/Charts/loader.d.ts +4 -0
  85. package/dist/components/Charts/loader.js +88 -0
  86. package/dist/components/Charts/minify.d.ts +5 -0
  87. package/dist/components/Charts/minify.js +37 -0
  88. package/dist/components/Charts/tooltips.css +62 -0
  89. package/dist/components/Charts/types.d.ts +61 -0
  90. package/dist/components/Charts/types.js +11 -0
  91. package/dist/components/Charts/utils.d.ts +13 -0
  92. package/dist/components/Charts/utils.js +206 -0
  93. package/dist/components/CodeViewer/config.d.ts +2 -0
  94. package/dist/components/CodeViewer/config.js +18 -0
  95. package/dist/components/CodeViewer/diff.d.ts +11 -0
  96. package/dist/components/CodeViewer/diff.js +35 -0
  97. package/dist/components/CodeViewer/hightlight.d.ts +10 -0
  98. package/dist/components/CodeViewer/hightlight.js +76 -0
  99. package/dist/components/CodeViewer/index.d.ts +4 -0
  100. package/dist/components/CodeViewer/index.js +4 -0
  101. package/dist/components/CodeViewer/viewer.d.ts +13 -0
  102. package/dist/components/CodeViewer/viewer.js +60 -0
  103. package/dist/components/Configuration/builder.d.ts +13 -0
  104. package/dist/components/Configuration/builder.js +67 -0
  105. package/dist/components/Configuration/index.d.ts +1 -0
  106. package/dist/components/Configuration/index.js +1 -0
  107. package/dist/components/FileTree/index.css +58 -0
  108. package/dist/components/FileTree/index.d.ts +4 -0
  109. package/dist/components/FileTree/index.js +42 -0
  110. package/dist/components/Form/keyword.d.ts +14 -0
  111. package/dist/components/Form/keyword.js +60 -0
  112. package/dist/components/Keyword/index.d.ts +6 -0
  113. package/dist/components/Keyword/index.js +36 -0
  114. package/dist/components/Layout/builder-select.d.ts +2 -0
  115. package/dist/components/Layout/builder-select.js +50 -0
  116. package/dist/components/Layout/constants.d.ts +1 -0
  117. package/dist/components/Layout/constants.js +4 -0
  118. package/dist/components/Layout/header.css +12 -0
  119. package/dist/components/Layout/header.d.ts +3 -0
  120. package/dist/components/Layout/header.js +86 -0
  121. package/dist/components/Layout/index.d.ts +5 -0
  122. package/dist/components/Layout/index.js +34 -0
  123. package/dist/components/Layout/menus.d.ts +8 -0
  124. package/dist/components/Layout/menus.js +167 -0
  125. package/dist/components/Layout/progress.d.ts +8 -0
  126. package/dist/components/Layout/progress.js +44 -0
  127. package/dist/components/Loader/Analysis/files.d.ts +8 -0
  128. package/dist/components/Loader/Analysis/files.js +193 -0
  129. package/dist/components/Loader/Analysis/index.d.ts +11 -0
  130. package/dist/components/Loader/Analysis/index.js +23 -0
  131. package/dist/components/Loader/executions.d.ts +9 -0
  132. package/dist/components/Loader/executions.js +199 -0
  133. package/dist/components/Manifest/api.d.ts +34 -0
  134. package/dist/components/Manifest/api.js +127 -0
  135. package/dist/components/Manifest/data.d.ts +8 -0
  136. package/dist/components/Manifest/data.js +65 -0
  137. package/dist/components/Manifest/index.d.ts +2 -0
  138. package/dist/components/Manifest/index.js +2 -0
  139. package/dist/components/Opener/code.d.ts +20 -0
  140. package/dist/components/Opener/code.js +78 -0
  141. package/dist/components/Opener/index.d.ts +2 -0
  142. package/dist/components/Opener/index.js +2 -0
  143. package/dist/components/Opener/vscode.d.ts +11 -0
  144. package/dist/components/Opener/vscode.js +42 -0
  145. package/dist/components/Overall/NumberButton.d.ts +8 -0
  146. package/dist/components/Overall/NumberButton.js +29 -0
  147. package/dist/components/Overall/NumberButton.module.js +5 -0
  148. package/dist/components/Overall/NumberButton_module.css +70 -0
  149. package/dist/components/Overall/bundle.d.ts +6 -0
  150. package/dist/components/Overall/bundle.js +167 -0
  151. package/dist/components/Overall/bundle.module.css +0 -0
  152. package/dist/components/Overall/card.module.js +5 -0
  153. package/dist/components/Overall/card_module.css +6 -0
  154. package/dist/components/Overall/compile.d.ts +5 -0
  155. package/dist/components/Overall/compile.js +67 -0
  156. package/dist/components/Overall/compile.module.js +5 -0
  157. package/dist/components/Overall/compile_module.css +4 -0
  158. package/dist/components/Overall/index.d.ts +3 -0
  159. package/dist/components/Overall/index.js +3 -0
  160. package/dist/components/Overall/list.module.js +5 -0
  161. package/dist/components/Overall/list_module.css +7 -0
  162. package/dist/components/Overall/project.d.ts +8 -0
  163. package/dist/components/Overall/project.js +73 -0
  164. package/dist/components/Plugins/webpack.d.ts +18 -0
  165. package/dist/components/Plugins/webpack.js +76 -0
  166. package/dist/components/Resolver/analysis.d.ts +15 -0
  167. package/dist/components/Resolver/analysis.js +144 -0
  168. package/dist/components/Select/index.d.ts +15 -0
  169. package/dist/components/Select/index.js +68 -0
  170. package/dist/components/Status/failed.d.ts +9 -0
  171. package/dist/components/Status/failed.js +33 -0
  172. package/dist/components/Status/index.d.ts +1 -0
  173. package/dist/components/Status/index.js +1 -0
  174. package/dist/components/TextDrawer/duplicate.d.ts +17 -0
  175. package/dist/components/TextDrawer/duplicate.js +69 -0
  176. package/dist/components/TextDrawer/index.d.ts +11 -0
  177. package/dist/components/TextDrawer/index.js +36 -0
  178. package/dist/components/Title/index.d.ts +15 -0
  179. package/dist/components/Title/index.js +10 -0
  180. package/dist/components/index.d.ts +12 -0
  181. package/dist/components/index.js +15 -0
  182. package/dist/components/worker/ecmaversion/client.d.ts +10 -0
  183. package/dist/components/worker/ecmaversion/client.js +60 -0
  184. package/dist/components/worker/ecmaversion/worker.d.ts +1 -0
  185. package/dist/components/worker/ecmaversion/worker.js +13 -0
  186. package/dist/components/worker/jsequal/client.d.ts +11 -0
  187. package/dist/components/worker/jsequal/client.js +38 -0
  188. package/dist/components/worker/jsequal/worker.d.ts +1 -0
  189. package/dist/components/worker/jsequal/worker.js +23 -0
  190. package/dist/config.d.ts +19 -0
  191. package/dist/config.js +25 -0
  192. package/dist/constants.d.ts +50 -0
  193. package/dist/constants.js +75 -0
  194. package/dist/index.d.ts +3 -0
  195. package/dist/index.js +6 -0
  196. package/dist/pages/BundleSize/components/asset.d.ts +26 -0
  197. package/dist/pages/BundleSize/components/asset.js +545 -0
  198. package/dist/pages/BundleSize/components/cards.d.ts +7 -0
  199. package/dist/pages/BundleSize/components/cards.js +143 -0
  200. package/dist/pages/BundleSize/components/editor.d.ts +5 -0
  201. package/dist/pages/BundleSize/components/editor.js +38 -0
  202. package/dist/pages/BundleSize/components/index.css +20 -0
  203. package/dist/pages/BundleSize/components/index.d.ts +16 -0
  204. package/dist/pages/BundleSize/components/index.js +366 -0
  205. package/dist/pages/BundleSize/config.d.ts +7 -0
  206. package/dist/pages/BundleSize/config.js +9 -0
  207. package/dist/pages/BundleSize/constants.d.ts +5 -0
  208. package/dist/pages/BundleSize/constants.js +9 -0
  209. package/dist/pages/BundleSize/index.d.ts +3 -0
  210. package/dist/pages/BundleSize/index.js +11 -0
  211. package/dist/pages/ModuleAnalyze/chunks.d.ts +6 -0
  212. package/dist/pages/ModuleAnalyze/chunks.js +48 -0
  213. package/dist/pages/ModuleAnalyze/components/fileTreeCom.css +97 -0
  214. package/dist/pages/ModuleAnalyze/components/fileTreeCom.d.ts +15 -0
  215. package/dist/pages/ModuleAnalyze/components/fileTreeCom.js +120 -0
  216. package/dist/pages/ModuleAnalyze/constants.d.ts +7 -0
  217. package/dist/pages/ModuleAnalyze/constants.js +14 -0
  218. package/dist/pages/ModuleAnalyze/dependncy.d.ts +9 -0
  219. package/dist/pages/ModuleAnalyze/dependncy.js +31 -0
  220. package/dist/pages/ModuleAnalyze/fileTree.d.ts +9 -0
  221. package/dist/pages/ModuleAnalyze/fileTree.js +125 -0
  222. package/dist/pages/ModuleAnalyze/index.css +10 -0
  223. package/dist/pages/ModuleAnalyze/index.d.ts +8 -0
  224. package/dist/pages/ModuleAnalyze/index.js +64 -0
  225. package/dist/pages/ModuleAnalyze/utils/hooks.d.ts +21 -0
  226. package/dist/pages/ModuleAnalyze/utils/hooks.js +62 -0
  227. package/dist/pages/ModuleAnalyze/utils/index.d.ts +3 -0
  228. package/dist/pages/ModuleAnalyze/utils/index.js +34 -0
  229. package/dist/pages/ModuleResolve/constants.d.ts +3 -0
  230. package/dist/pages/ModuleResolve/constants.js +7 -0
  231. package/dist/pages/ModuleResolve/index.d.ts +3 -0
  232. package/dist/pages/ModuleResolve/index.js +19 -0
  233. package/dist/pages/Overall/constants.d.ts +3 -0
  234. package/dist/pages/Overall/constants.js +7 -0
  235. package/dist/pages/Overall/index.d.ts +9 -0
  236. package/dist/pages/Overall/index.js +39 -0
  237. package/dist/pages/Overall/responsiveGridList.d.ts +6 -0
  238. package/dist/pages/Overall/responsiveGridList.js +28 -0
  239. package/dist/pages/Resources/RuleIndex/constants.d.ts +3 -0
  240. package/dist/pages/Resources/RuleIndex/constants.js +7 -0
  241. package/dist/pages/Resources/RuleIndex/index.d.ts +3 -0
  242. package/dist/pages/Resources/RuleIndex/index.js +53 -0
  243. package/dist/pages/TreeShaking/constants.d.ts +3 -0
  244. package/dist/pages/TreeShaking/constants.js +7 -0
  245. package/dist/pages/TreeShaking/editor.d.ts +12 -0
  246. package/dist/pages/TreeShaking/editor.js +110 -0
  247. package/dist/pages/TreeShaking/index.css +74 -0
  248. package/dist/pages/TreeShaking/index.d.ts +8 -0
  249. package/dist/pages/TreeShaking/index.js +177 -0
  250. package/dist/pages/TreeShaking/open-tag.d.ts +11 -0
  251. package/dist/pages/TreeShaking/open-tag.js +43 -0
  252. package/dist/pages/TreeShaking/space.d.ts +1 -0
  253. package/dist/pages/TreeShaking/space.js +16 -0
  254. package/dist/pages/TreeShaking/table.d.ts +13 -0
  255. package/dist/pages/TreeShaking/table.js +319 -0
  256. package/dist/pages/TreeShaking/types.d.ts +3 -0
  257. package/dist/pages/TreeShaking/types.js +0 -0
  258. package/dist/pages/TreeShaking/utils.d.ts +7 -0
  259. package/dist/pages/TreeShaking/utils.js +147 -0
  260. package/dist/pages/WebpackLoaders/Analysis/constants.d.ts +3 -0
  261. package/dist/pages/WebpackLoaders/Analysis/constants.js +7 -0
  262. package/dist/pages/WebpackLoaders/Analysis/index.d.ts +3 -0
  263. package/dist/pages/WebpackLoaders/Analysis/index.js +19 -0
  264. package/dist/pages/WebpackLoaders/Overall/constants.d.ts +3 -0
  265. package/dist/pages/WebpackLoaders/Overall/constants.js +7 -0
  266. package/dist/pages/WebpackLoaders/Overall/index.d.ts +3 -0
  267. package/dist/pages/WebpackLoaders/Overall/index.js +11 -0
  268. package/dist/pages/WebpackLoaders/constants.d.ts +2 -0
  269. package/dist/pages/WebpackLoaders/constants.js +6 -0
  270. package/dist/pages/WebpackPlugins/constants.d.ts +3 -0
  271. package/dist/pages/WebpackPlugins/constants.js +7 -0
  272. package/dist/pages/WebpackPlugins/index.d.ts +3 -0
  273. package/dist/pages/WebpackPlugins/index.js +79 -0
  274. package/dist/pages/index.d.ts +9 -0
  275. package/dist/pages/index.js +20 -0
  276. package/dist/utils/data/base.d.ts +24 -0
  277. package/dist/utils/data/base.js +48 -0
  278. package/dist/utils/data/index.d.ts +5 -0
  279. package/dist/utils/data/index.js +44 -0
  280. package/dist/utils/data/local.d.ts +14 -0
  281. package/dist/utils/data/local.js +86 -0
  282. package/dist/utils/data/remote.d.ts +10 -0
  283. package/dist/utils/data/remote.js +52 -0
  284. package/dist/utils/file.d.ts +33 -0
  285. package/dist/utils/file.js +154 -0
  286. package/dist/utils/hooks.d.ts +31 -0
  287. package/dist/utils/hooks.js +216 -0
  288. package/dist/utils/i18n/cn.d.ts +3 -0
  289. package/dist/utils/i18n/cn.js +33 -0
  290. package/dist/utils/i18n/en.d.ts +30 -0
  291. package/dist/utils/i18n/en.js +33 -0
  292. package/dist/utils/i18n/index.d.ts +2 -0
  293. package/dist/utils/i18n/index.js +34 -0
  294. package/dist/utils/index.d.ts +16 -0
  295. package/dist/utils/index.js +16 -0
  296. package/dist/utils/loader.d.ts +7 -0
  297. package/dist/utils/loader.js +34 -0
  298. package/dist/utils/locale.d.ts +2 -0
  299. package/dist/utils/locale.js +9 -0
  300. package/dist/utils/manifest.d.ts +27 -0
  301. package/dist/utils/manifest.js +54 -0
  302. package/dist/utils/monaco.d.ts +12 -0
  303. package/dist/utils/monaco.js +71 -0
  304. package/dist/utils/request.d.ts +27 -0
  305. package/dist/utils/request.js +130 -0
  306. package/dist/utils/routes.d.ts +3 -0
  307. package/dist/utils/routes.js +14 -0
  308. package/dist/utils/size.d.ts +2 -0
  309. package/dist/utils/size.js +24 -0
  310. package/dist/utils/socket.d.ts +2 -0
  311. package/dist/utils/socket.js +21 -0
  312. package/dist/utils/storage.d.ts +13 -0
  313. package/dist/utils/storage.js +70 -0
  314. package/dist/utils/string.d.ts +2 -0
  315. package/dist/utils/string.js +14 -0
  316. package/dist/utils/time.d.ts +3 -0
  317. package/dist/utils/time.js +7 -0
  318. package/dist/utils/url.d.ts +7 -0
  319. package/dist/utils/url.js +75 -0
  320. package/dist/utils/worker/index.d.ts +4 -0
  321. package/dist/utils/worker/index.js +4 -0
  322. package/dist/utils/worker/master.d.ts +8 -0
  323. package/dist/utils/worker/master.js +18 -0
  324. package/dist/utils/worker/types.d.ts +9 -0
  325. package/dist/utils/worker/types.js +0 -0
  326. package/dist/utils/worker/utils.d.ts +7 -0
  327. package/dist/utils/worker/utils.js +29 -0
  328. package/dist/utils/worker/worker.d.ts +13 -0
  329. package/dist/utils/worker/worker.js +38 -0
  330. package/package.json +92 -0
@@ -0,0 +1,507 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from "react";
3
+ import {
4
+ Button,
5
+ Col,
6
+ Divider,
7
+ Row,
8
+ Select,
9
+ Space,
10
+ Table,
11
+ Tag,
12
+ Tooltip,
13
+ Typography
14
+ } from "antd";
15
+ import { Graph } from "@rsdoctor/utils/common";
16
+ import { flatten, includes, keys, sumBy, values } from "lodash-es";
17
+ import {
18
+ CheckSquareOutlined,
19
+ InfoCircleOutlined,
20
+ MinusSquareOutlined,
21
+ PlusSquareOutlined,
22
+ SortAscendingOutlined,
23
+ FileSearchOutlined,
24
+ AppstoreAddOutlined
25
+ } from "@ant-design/icons";
26
+ import { Constants, Client } from "@rsdoctor/types";
27
+ import { formatPercent, formatSize } from "@rsdoctor/components/utils";
28
+ import { Percent, SizePercent } from "@rsdoctor/components/elements";
29
+ import { KeywordInput } from "@rsdoctor/components";
30
+ import { ModuleRowForAsset } from "./row";
31
+ import { ViewChanges } from "./changes";
32
+ import { UpdateType, SortType } from "./constants";
33
+ import { formatDiffSize } from "./utils";
34
+ import { Color, Size } from "../../../constants";
35
+ const fileTypes = {
36
+ JS: [Constants.JSExtension],
37
+ CSS: [Constants.CSSExtension],
38
+ HTML: [Constants.HtmlExtension],
39
+ Imgs: Constants.ImgExtensions,
40
+ Fonts: Constants.FontExtensions,
41
+ Media: Constants.MediaExtensions,
42
+ Others: []
43
+ };
44
+ const definedExtensions = flatten(values(fileTypes));
45
+ const Name = ({ data: r }) => {
46
+ const name = /* @__PURE__ */ jsxs(Space, { children: [
47
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: r.alias }),
48
+ /* @__PURE__ */ jsx(
49
+ Tooltip,
50
+ {
51
+ title: /* @__PURE__ */ jsxs(Space, { style: { color: "inherit" }, direction: "vertical", children: [
52
+ r.current ? /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
53
+ "Current realpath: ",
54
+ r.current.path
55
+ ] }) : null,
56
+ r.baseline ? /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
57
+ "Baseline realpath: ",
58
+ r.baseline.path
59
+ ] }) : null
60
+ ] }),
61
+ children: /* @__PURE__ */ jsx(InfoCircleOutlined, {})
62
+ }
63
+ )
64
+ ] });
65
+ if (r.baseline && !r.current) {
66
+ return /* @__PURE__ */ jsxs(Space, { children: [
67
+ /* @__PURE__ */ jsx(MinusSquareOutlined, { style: { color: Color.Red } }),
68
+ name
69
+ ] });
70
+ }
71
+ if (!r.baseline && r.current) {
72
+ return /* @__PURE__ */ jsxs(Space, { children: [
73
+ /* @__PURE__ */ jsx(PlusSquareOutlined, { style: { color: Color.Green } }),
74
+ name
75
+ ] });
76
+ }
77
+ if (r.baseline && r.current) {
78
+ return /* @__PURE__ */ jsxs(Space, { children: [
79
+ /* @__PURE__ */ jsx(CheckSquareOutlined, { style: { color: Color.Yellow } }),
80
+ name
81
+ ] });
82
+ }
83
+ return name;
84
+ };
85
+ const Assets = ({ baseline, current, outputFilename }) => {
86
+ const bOutPutFileName = outputFilename;
87
+ const [keyword, setKeyword] = useState();
88
+ const [selectedFileTypes, setSelectedFileTypes] = useState([]);
89
+ const [selectedUpdateTypes, setSelectedUpdateTypes] = useState(
90
+ []
91
+ );
92
+ const [selectedSortType, setSelectedSortType] = useState(
93
+ SortType.Size
94
+ );
95
+ const [selectedBAsset, setSelectedBAsset] = useState(null);
96
+ const [selectedCAsset, setSelectedCAsset] = useState(null);
97
+ const { assets: bAssets } = baseline.chunkGraph;
98
+ const { assets: cAssets } = current.chunkGraph;
99
+ const dataSource = useMemo(() => {
100
+ const res = {};
101
+ if (selectedBAsset && selectedCAsset) {
102
+ res.choose = {
103
+ alias: `${selectedBAsset}
104
+ ${selectedCAsset}`,
105
+ current: cAssets.find((c) => c.path === selectedCAsset),
106
+ baseline: bAssets.find((b) => b.path === selectedBAsset)
107
+ };
108
+ return values(res);
109
+ }
110
+ bAssets.forEach((asset) => {
111
+ const alias = Graph.formatAssetName(asset.path, bOutPutFileName);
112
+ if (!res[alias]) {
113
+ res[alias] = {
114
+ alias,
115
+ baseline: asset
116
+ };
117
+ } else {
118
+ console.warn("[Baseline Asset Exists]: ", asset, res);
119
+ }
120
+ });
121
+ cAssets.forEach((asset) => {
122
+ const alias = Graph.formatAssetName(asset.path, bOutPutFileName);
123
+ if (!res[alias]) {
124
+ res[alias] = { alias };
125
+ }
126
+ res[alias].current = asset;
127
+ });
128
+ return values(res);
129
+ }, [bAssets, cAssets, selectedBAsset, selectedCAsset]);
130
+ const filteredDataSource = useMemo(() => {
131
+ let list = dataSource.slice();
132
+ if (keyword) {
133
+ list = list.filter((e) => e.alias.indexOf(keyword) > -1);
134
+ }
135
+ if (selectedFileTypes.length) {
136
+ const exts = flatten(
137
+ selectedFileTypes.map((e) => fileTypes[e])
138
+ );
139
+ const hasOthers = selectedFileTypes.indexOf("Others") > -1;
140
+ list = list.filter((e) => {
141
+ const asset = e.baseline || e.current;
142
+ if (Graph.isAssetMatchExtensions(asset, exts)) {
143
+ return true;
144
+ }
145
+ if (hasOthers) {
146
+ return !Graph.isAssetMatchExtensions(asset, definedExtensions);
147
+ }
148
+ return false;
149
+ });
150
+ }
151
+ if (selectedUpdateTypes.length) {
152
+ list = list.filter((e) => {
153
+ if (e.baseline && !e.current) {
154
+ return includes(selectedUpdateTypes, UpdateType.Deleted);
155
+ }
156
+ if (!e.baseline && e.current) {
157
+ return includes(selectedUpdateTypes, UpdateType.New);
158
+ }
159
+ if (e.baseline && e.current) {
160
+ if (e.baseline.size === e.current.size) {
161
+ return includes(selectedUpdateTypes, UpdateType.NotChanged);
162
+ }
163
+ return includes(selectedUpdateTypes, UpdateType.Changed);
164
+ }
165
+ return false;
166
+ });
167
+ }
168
+ if (selectedSortType) {
169
+ if (selectedSortType === SortType.Name) {
170
+ list.sort((a, b) => {
171
+ return a.alias.localeCompare(b.alias);
172
+ });
173
+ } else {
174
+ const { prev, others } = list.reduce(
175
+ (t, c) => {
176
+ if (c.current) {
177
+ if (c.baseline) {
178
+ t.prev.unshift(c);
179
+ } else {
180
+ t.prev.push(c);
181
+ }
182
+ } else {
183
+ t.others.push(c);
184
+ }
185
+ return t;
186
+ },
187
+ {
188
+ prev: [],
189
+ others: []
190
+ }
191
+ );
192
+ list = [
193
+ ...prev.sort((a, b) => {
194
+ if (b.current && a.current) {
195
+ if (selectedSortType === SortType.Delta) {
196
+ const { percent: percentA } = Graph.diffAssetsByExtensions(
197
+ baseline.chunkGraph,
198
+ current.chunkGraph,
199
+ (asset) => Graph.formatAssetName(asset.path, bOutPutFileName) === a.alias
200
+ );
201
+ const { percent: percentB } = Graph.diffAssetsByExtensions(
202
+ baseline.chunkGraph,
203
+ current.chunkGraph,
204
+ (asset) => Graph.formatAssetName(asset.path, bOutPutFileName) === b.alias
205
+ );
206
+ return percentB - percentA;
207
+ }
208
+ return b.current.size - a.current.size;
209
+ }
210
+ return -1;
211
+ }),
212
+ ...others
213
+ ];
214
+ }
215
+ }
216
+ return list;
217
+ }, [
218
+ dataSource,
219
+ keyword,
220
+ selectedFileTypes,
221
+ selectedUpdateTypes,
222
+ selectedSortType
223
+ ]);
224
+ const cSize = useMemo(
225
+ () => sumBy(filteredDataSource, (e) => e.current ? e.current.size : 0) || 0,
226
+ [filteredDataSource]
227
+ );
228
+ const bSize = useMemo(
229
+ () => sumBy(filteredDataSource, (e) => e.baseline ? e.baseline.size : 0) || 0,
230
+ [filteredDataSource]
231
+ );
232
+ return /* @__PURE__ */ jsxs(Row, { gutter: [Size.BasePadding, Size.BasePadding], children: [
233
+ /* @__PURE__ */ jsxs(Col, { span: 24, children: [
234
+ /* @__PURE__ */ jsxs(Space, { wrap: true, children: [
235
+ /* @__PURE__ */ jsx(
236
+ KeywordInput,
237
+ {
238
+ icon: /* @__PURE__ */ jsx(FileSearchOutlined, {}),
239
+ label: "",
240
+ labelStyle: { width: 45 },
241
+ placeholder: "Search by file name",
242
+ onChange: (e) => {
243
+ setKeyword(e);
244
+ }
245
+ }
246
+ ),
247
+ /* @__PURE__ */ jsx(
248
+ Select,
249
+ {
250
+ mode: "multiple",
251
+ placeholder: "Filter by file type",
252
+ style: { width: 250 },
253
+ options: keys(fileTypes).map((e) => ({ label: e, value: e })),
254
+ allowClear: true,
255
+ onChange: (e) => {
256
+ setSelectedFileTypes(e);
257
+ }
258
+ }
259
+ ),
260
+ /* @__PURE__ */ jsx(
261
+ Select,
262
+ {
263
+ mode: "multiple",
264
+ placeholder: "Filter by file changed type",
265
+ style: { width: 200 },
266
+ options: values(UpdateType).map((e) => ({ label: e, value: e })),
267
+ allowClear: true,
268
+ onChange: (e) => {
269
+ setSelectedUpdateTypes(e);
270
+ }
271
+ }
272
+ ),
273
+ /* @__PURE__ */ jsx(
274
+ Select,
275
+ {
276
+ suffixIcon: /* @__PURE__ */ jsx(SortAscendingOutlined, {}),
277
+ options: values(SortType).map((e) => ({ label: e, value: e })),
278
+ value: selectedSortType,
279
+ onChange: (e) => {
280
+ setSelectedSortType(e);
281
+ }
282
+ }
283
+ )
284
+ ] }),
285
+ /* @__PURE__ */ jsxs(Row, { style: { marginTop: 10 }, gutter: [6, 6], children: [
286
+ /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(Button, { children: "Select Baseline Asset and Current Asset to Diff " }) }),
287
+ /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(
288
+ Select,
289
+ {
290
+ allowClear: true,
291
+ placeholder: "select baseline assets",
292
+ showSearch: true,
293
+ style: { width: 300 },
294
+ options: values(baseline.chunkGraph.assets).map((e) => ({
295
+ label: e.path,
296
+ value: e.path
297
+ })),
298
+ onChange: (e) => setSelectedBAsset(e)
299
+ }
300
+ ) }),
301
+ /* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(
302
+ Select,
303
+ {
304
+ allowClear: true,
305
+ placeholder: "select current assets",
306
+ showSearch: true,
307
+ style: { width: 300 },
308
+ options: values(current.chunkGraph.assets).map((e) => ({
309
+ label: e.path,
310
+ value: e.path
311
+ })),
312
+ onChange: (e) => setSelectedCAsset(e)
313
+ }
314
+ ) })
315
+ ] })
316
+ ] }),
317
+ /* @__PURE__ */ jsx(Col, { span: 24, children: /* @__PURE__ */ jsx(
318
+ Table,
319
+ {
320
+ bordered: true,
321
+ sticky: { offsetHeader: 54 },
322
+ pagination: {
323
+ pageSize: 20,
324
+ size: "small"
325
+ },
326
+ dataSource: filteredDataSource,
327
+ rowKey: (e) => e.alias,
328
+ expandable: {
329
+ expandedRowRender: (r) => {
330
+ return /* @__PURE__ */ jsx("div", { style: { margin: Size.BasePadding / 3 }, children: /* @__PURE__ */ jsx(
331
+ ModuleRowForAsset,
332
+ {
333
+ data: r,
334
+ baseline,
335
+ current
336
+ }
337
+ ) });
338
+ },
339
+ columnTitle: /* @__PURE__ */ jsx(
340
+ Tooltip,
341
+ {
342
+ title: "Click to expand row to see the modules which the chunk contains",
343
+ placement: "left",
344
+ children: /* @__PURE__ */ jsx(AppstoreAddOutlined, { style: { cursor: "pointer" } })
345
+ }
346
+ )
347
+ },
348
+ columns: [
349
+ {
350
+ title: /* @__PURE__ */ jsxs(
351
+ Tooltip,
352
+ {
353
+ title: /* @__PURE__ */ jsxs(Space, { direction: "vertical", children: [
354
+ /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
355
+ "filtered assets is ",
356
+ filteredDataSource.length
357
+ ] }),
358
+ /* @__PURE__ */ jsxs(Typography.Text, { style: { color: "inherit" }, children: [
359
+ "total assets is ",
360
+ dataSource.length
361
+ ] })
362
+ ] }),
363
+ children: [
364
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Assets" }),
365
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
366
+ /* @__PURE__ */ jsxs(
367
+ Typography.Text,
368
+ {
369
+ type: "secondary",
370
+ style: { fontSize: 10, fontWeight: 400, marginRight: 4 },
371
+ children: [
372
+ filteredDataSource.length,
373
+ "/",
374
+ dataSource.length
375
+ ]
376
+ }
377
+ ),
378
+ /* @__PURE__ */ jsx(InfoCircleOutlined, {})
379
+ ]
380
+ }
381
+ ),
382
+ render: (_v, r) => /* @__PURE__ */ jsx(Name, { data: r })
383
+ },
384
+ {
385
+ title: () => {
386
+ const cs = formatSize(cSize);
387
+ const diff = Graph.diffSize(bSize, cSize);
388
+ return /* @__PURE__ */ jsxs(
389
+ Tooltip,
390
+ {
391
+ title: `Current size is ${cs}, Delta is ${formatPercent(
392
+ diff.percent
393
+ )}`,
394
+ children: [
395
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Current" }),
396
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
397
+ /* @__PURE__ */ jsxs(
398
+ Typography.Text,
399
+ {
400
+ style: { fontSize: 10, fontWeight: 400, marginRight: 4 },
401
+ children: [
402
+ /* @__PURE__ */ jsx(
403
+ Typography.Text,
404
+ {
405
+ style: { fontSize: "inherit", marginRight: 8 },
406
+ children: cs
407
+ }
408
+ ),
409
+ /* @__PURE__ */ jsx(
410
+ SizePercent,
411
+ {
412
+ fontSize: "inherit",
413
+ baseline: bSize,
414
+ current: cSize
415
+ }
416
+ ),
417
+ formatDiffSize(
418
+ bSize,
419
+ cSize,
420
+ bSize > cSize ? Client.RsdoctorClientDiffState.Down : Client.RsdoctorClientDiffState.Up,
421
+ { fontSize: 10, fontWeight: 400, marginLeft: 4 }
422
+ )
423
+ ]
424
+ }
425
+ ),
426
+ /* @__PURE__ */ jsx(InfoCircleOutlined, {})
427
+ ]
428
+ }
429
+ );
430
+ },
431
+ render: (_v, r) => {
432
+ if (r.current) {
433
+ const { percent, state } = Graph.diffAssetsByExtensions(
434
+ baseline.chunkGraph,
435
+ current.chunkGraph,
436
+ (asset) => Graph.formatAssetName(asset.path, bOutPutFileName) === r.alias
437
+ );
438
+ const isInitial = Graph.isInitialAsset(
439
+ r.current,
440
+ current.chunkGraph.chunks
441
+ );
442
+ return /* @__PURE__ */ jsxs(Space, { children: [
443
+ /* @__PURE__ */ jsx(Typography.Text, { children: formatSize(r.current.size) }),
444
+ /* @__PURE__ */ jsx(Percent, { percent, state }),
445
+ isInitial ? /* @__PURE__ */ jsx(Tag, { color: Color.Blue, children: "initial" }) : null
446
+ ] });
447
+ }
448
+ return "-";
449
+ }
450
+ },
451
+ {
452
+ title: () => {
453
+ const bs = formatSize(bSize);
454
+ return /* @__PURE__ */ jsxs(Tooltip, { title: `Baseline size is ${bs}`, children: [
455
+ /* @__PURE__ */ jsx(Typography.Text, { strong: true, children: "Baseline" }),
456
+ /* @__PURE__ */ jsx(Divider, { type: "vertical" }),
457
+ /* @__PURE__ */ jsx(
458
+ Typography.Text,
459
+ {
460
+ style: { fontSize: 10, fontWeight: 400, marginRight: 4 },
461
+ children: bs
462
+ }
463
+ ),
464
+ /* @__PURE__ */ jsx(InfoCircleOutlined, {})
465
+ ] });
466
+ },
467
+ render: (_v, r) => {
468
+ if (r.baseline) {
469
+ const isInitial = Graph.isInitialAsset(
470
+ r.baseline,
471
+ baseline.chunkGraph.chunks
472
+ );
473
+ return /* @__PURE__ */ jsxs(Space, { children: [
474
+ /* @__PURE__ */ jsx(Typography.Text, { children: formatSize(r.baseline.size) }),
475
+ isInitial ? /* @__PURE__ */ jsx(Tag, { color: Color.Blue, children: "initial" }) : null
476
+ ] });
477
+ }
478
+ return "-";
479
+ }
480
+ },
481
+ {
482
+ title: "Actions",
483
+ key: "actions",
484
+ render: (_v, r) => {
485
+ return /* @__PURE__ */ jsx(
486
+ ViewChanges,
487
+ {
488
+ file: r.alias,
489
+ data: [
490
+ {
491
+ baseline: r.baseline?.content,
492
+ current: r.current?.content,
493
+ group: "assets"
494
+ }
495
+ ]
496
+ }
497
+ );
498
+ }
499
+ }
500
+ ]
501
+ }
502
+ ) })
503
+ ] });
504
+ };
505
+ export {
506
+ Assets
507
+ };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { BundleDiffComponentCardProps } from './types';
3
+ export declare const DiffCards: React.FC<BundleDiffComponentCardProps>;
@@ -0,0 +1,156 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { DuplicatePackageDrawer } from "@rsdoctor/components";
3
+ import { DiffCard, Percent } from "@rsdoctor/components/elements";
4
+ import {
5
+ useDuplicatePackagesByErrors,
6
+ useModuleGraph,
7
+ useUniqModules
8
+ } from "@rsdoctor/components/utils";
9
+ import { Client } from "@rsdoctor/types";
10
+ import { Graph } from "@rsdoctor/utils/common";
11
+ import { Col, Row, Space, Typography } from "antd";
12
+ import { Size } from "../../../constants";
13
+ import { PackagesStatistic, getPackagesTableDataSource } from "./packages";
14
+ const DiffCards = ({
15
+ baseline,
16
+ current,
17
+ assetsDiffResult
18
+ }) => {
19
+ const baselineMod = useUniqModules(baseline.moduleGraph.modules);
20
+ const currentMod = useUniqModules(current.moduleGraph.modules);
21
+ const baselineDup = useDuplicatePackagesByErrors(baseline.errors);
22
+ const currentDup = useDuplicatePackagesByErrors(current.errors);
23
+ const baselineModuleGraph = useModuleGraph(baseline.moduleGraph);
24
+ const currentModuleGraph = useModuleGraph(current.moduleGraph);
25
+ const baselineCwd = baseline.root;
26
+ const currentCwd = current.root;
27
+ const packages = getPackagesTableDataSource({
28
+ baseline: baseline.packageGraph,
29
+ current: current.packageGraph
30
+ });
31
+ const arr = [
32
+ {
33
+ title: ["Bundle Size"],
34
+ value: [assetsDiffResult.all.total]
35
+ },
36
+ {
37
+ title: ["Total JS", "Initial JS"],
38
+ value: [assetsDiffResult.js.total, assetsDiffResult.js.initial]
39
+ },
40
+ {
41
+ title: ["Total CSS", "Initial CSS"],
42
+ value: [assetsDiffResult.css.total, assetsDiffResult.css.initial]
43
+ },
44
+ {
45
+ title: ["Images", "Fonts", "Media"],
46
+ value: [
47
+ assetsDiffResult.imgs.total,
48
+ assetsDiffResult.fonts.total,
49
+ assetsDiffResult.media.total
50
+ ]
51
+ },
52
+ { title: ["HTML"], value: [assetsDiffResult.html.total] },
53
+ { title: ["Others"], value: [assetsDiffResult.others.total] }
54
+ ];
55
+ return /* @__PURE__ */ jsxs(
56
+ Row,
57
+ {
58
+ gutter: [Size.BasePadding, Size.BasePadding],
59
+ wrap: true,
60
+ style: { marginBottom: Size.BasePadding },
61
+ children: [
62
+ arr.map((e) => {
63
+ return /* @__PURE__ */ jsx(Col, { style: { minWidth: 335 }, children: /* @__PURE__ */ jsx(DiffCard, { titles: e.title, datas: e.value, showPercentInTitle: true }) }, e.title.join(","));
64
+ }),
65
+ /* @__PURE__ */ jsx(Col, { style: { minWidth: 335 }, children: /* @__PURE__ */ jsx(
66
+ DiffCard,
67
+ {
68
+ titles: ["Duplicate Packages"],
69
+ datas: [
70
+ {
71
+ size: {
72
+ baseline: baselineDup.length,
73
+ current: currentDup.length
74
+ },
75
+ count: {
76
+ baseline: baselineDup.length,
77
+ current: currentDup.length
78
+ },
79
+ percent: 0,
80
+ state: Client.RsdoctorClientDiffState.Equal
81
+ }
82
+ ],
83
+ formatter: (_v, target) => /* @__PURE__ */ jsx(
84
+ DuplicatePackageDrawer,
85
+ {
86
+ duplicatePackages: target === "baseline" ? baselineDup : currentDup,
87
+ moduleGraph: target === "baseline" ? baselineModuleGraph : currentModuleGraph,
88
+ cwd: target === "baseline" ? baselineCwd : currentCwd,
89
+ buttonProps: { size: "small" },
90
+ moduleCodeMap: target === "baseline" ? baseline.moduleCodeMap : current.moduleCodeMap
91
+ }
92
+ )
93
+ }
94
+ ) }),
95
+ /* @__PURE__ */ jsx(Col, { style: { minWidth: 335 }, children: /* @__PURE__ */ jsx(
96
+ DiffCard,
97
+ {
98
+ titles: ["Modules"],
99
+ datas: [
100
+ {
101
+ size: {
102
+ baseline: baselineMod.length,
103
+ current: currentMod.length
104
+ },
105
+ count: {
106
+ baseline: baselineMod.length,
107
+ current: currentMod.length
108
+ },
109
+ percent: 0,
110
+ state: Client.RsdoctorClientDiffState.Equal
111
+ }
112
+ ],
113
+ formatter: (v, t) => {
114
+ if (t === "baseline")
115
+ return v;
116
+ const diff = Graph.diffSize(baselineMod.length, currentMod.length);
117
+ return /* @__PURE__ */ jsxs(Space, { style: { fontSize: "inherit" }, children: [
118
+ /* @__PURE__ */ jsx(Typography.Text, { style: { fontSize: "inherit" }, children: v }),
119
+ /* @__PURE__ */ jsx(Percent, { ...diff })
120
+ ] });
121
+ }
122
+ }
123
+ ) }),
124
+ /* @__PURE__ */ jsx(Col, { style: { minWidth: 335 }, children: /* @__PURE__ */ jsx(
125
+ DiffCard,
126
+ {
127
+ titles: [
128
+ /* @__PURE__ */ jsxs(Space, { children: [
129
+ /* @__PURE__ */ jsx(Typography.Text, { style: { color: "inherit" }, children: "Packages" }),
130
+ /* @__PURE__ */ jsx(PackagesStatistic, { dataSource: packages })
131
+ ] }, "0")
132
+ ],
133
+ datas: [
134
+ {
135
+ size: {
136
+ baseline: packages.filter((e) => e.baseline).length,
137
+ current: packages.filter((e) => e.current).length
138
+ },
139
+ count: {
140
+ baseline: packages.filter((e) => e.baseline).length,
141
+ current: packages.filter((e) => e.current).length
142
+ },
143
+ percent: 0,
144
+ state: Client.RsdoctorClientDiffState.Equal
145
+ }
146
+ ],
147
+ formatter: (v, t) => t === "baseline" ? v : /* @__PURE__ */ jsx(Space, { children: v })
148
+ }
149
+ ) })
150
+ ]
151
+ }
152
+ );
153
+ };
154
+ export {
155
+ DiffCards
156
+ };
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ interface ViewChangesContentProps {
3
+ file: string;
4
+ data: {
5
+ baseline?: string | void;
6
+ current: string | void;
7
+ baselineTitle?: string;
8
+ currentTitle?: string;
9
+ group: string;
10
+ }[];
11
+ }
12
+ export declare const ViewChanges: React.FC<ViewChangesContentProps & {
13
+ text?: string;
14
+ }>;
15
+ export {};