@rsdoctor/components 0.0.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/assets/connection-point.3b3c78ca.svg +1 -0
  4. package/dist/assets/icon.7509d763.svg +21 -0
  5. package/dist/assets/webpack.98604d64.svg +1 -0
  6. package/dist/components/Alert/change.d.ts +8 -0
  7. package/dist/components/Alert/change.js +94 -0
  8. package/dist/components/Alert/file-relation.d.ts +3 -0
  9. package/dist/components/Alert/file-relation.js +9 -0
  10. package/dist/components/Alert/index.css +29 -0
  11. package/dist/components/Alert/index.d.ts +4 -0
  12. package/dist/components/Alert/index.js +37 -0
  13. package/dist/components/Alert/link.d.ts +3 -0
  14. package/dist/components/Alert/link.js +27 -0
  15. package/dist/components/Alert/package-relation.d.ts +17 -0
  16. package/dist/components/Alert/package-relation.js +206 -0
  17. package/dist/components/Alert/types.d.ts +31 -0
  18. package/dist/components/Alert/types.js +0 -0
  19. package/dist/components/Alert/view.d.ts +4 -0
  20. package/dist/components/Alert/view.js +59 -0
  21. package/dist/components/Alerts/bundle.d.ts +11 -0
  22. package/dist/components/Alerts/bundle.js +47 -0
  23. package/dist/components/Alerts/common.d.ts +15 -0
  24. package/dist/components/Alerts/common.js +106 -0
  25. package/dist/components/Alerts/compile.d.ts +10 -0
  26. package/dist/components/Alerts/compile.js +46 -0
  27. package/dist/components/Alerts/index.d.ts +3 -0
  28. package/dist/components/Alerts/index.js +3 -0
  29. package/dist/components/Alerts/overlay.d.ts +26 -0
  30. package/dist/components/Alerts/overlay.js +154 -0
  31. package/dist/components/Badge/index.d.ts +21 -0
  32. package/dist/components/Badge/index.js +105 -0
  33. package/dist/components/Card/diff.d.ts +23 -0
  34. package/dist/components/Card/diff.js +131 -0
  35. package/dist/components/Card/index.d.ts +7 -0
  36. package/dist/components/Card/index.js +62 -0
  37. package/dist/components/Card/size.d.ts +16 -0
  38. package/dist/components/Card/size.js +71 -0
  39. package/dist/components/Card/statistic.css +16 -0
  40. package/dist/components/Card/statistic.d.ts +9 -0
  41. package/dist/components/Card/statistic.js +34 -0
  42. package/dist/components/Charts/TimelineCharts/index.d.ts +8 -0
  43. package/dist/components/Charts/TimelineCharts/index.js +197 -0
  44. package/dist/components/Charts/bootstrap.d.ts +5 -0
  45. package/dist/components/Charts/bootstrap.js +44 -0
  46. package/dist/components/Charts/common.d.ts +13 -0
  47. package/dist/components/Charts/common.js +56 -0
  48. package/dist/components/Charts/done.d.ts +5 -0
  49. package/dist/components/Charts/done.js +45 -0
  50. package/dist/components/Charts/index.d.ts +10 -0
  51. package/dist/components/Charts/index.js +37 -0
  52. package/dist/components/Charts/loader.css +31 -0
  53. package/dist/components/Charts/loader.d.ts +4 -0
  54. package/dist/components/Charts/loader.js +68 -0
  55. package/dist/components/Charts/minify.d.ts +5 -0
  56. package/dist/components/Charts/minify.js +37 -0
  57. package/dist/components/Charts/tooltips.css +62 -0
  58. package/dist/components/Charts/types.d.ts +61 -0
  59. package/dist/components/Charts/types.js +11 -0
  60. package/dist/components/Charts/utils.d.ts +13 -0
  61. package/dist/components/Charts/utils.js +203 -0
  62. package/dist/components/CodeViewer/config.d.ts +2 -0
  63. package/dist/components/CodeViewer/config.js +18 -0
  64. package/dist/components/CodeViewer/diff.d.ts +11 -0
  65. package/dist/components/CodeViewer/diff.js +53 -0
  66. package/dist/components/CodeViewer/hightlight.d.ts +10 -0
  67. package/dist/components/CodeViewer/hightlight.js +76 -0
  68. package/dist/components/CodeViewer/index.d.ts +4 -0
  69. package/dist/components/CodeViewer/index.js +4 -0
  70. package/dist/components/CodeViewer/viewer.d.ts +13 -0
  71. package/dist/components/CodeViewer/viewer.js +76 -0
  72. package/dist/components/Configuration/index.d.ts +1 -0
  73. package/dist/components/Configuration/index.js +1 -0
  74. package/dist/components/Configuration/webpack.d.ts +13 -0
  75. package/dist/components/Configuration/webpack.js +70 -0
  76. package/dist/components/FileTree/index.css +58 -0
  77. package/dist/components/FileTree/index.d.ts +4 -0
  78. package/dist/components/FileTree/index.js +53 -0
  79. package/dist/components/Form/keyword.d.ts +14 -0
  80. package/dist/components/Form/keyword.js +76 -0
  81. package/dist/components/Keyword/index.d.ts +6 -0
  82. package/dist/components/Keyword/index.js +68 -0
  83. package/dist/components/Layout/builder-select.d.ts +2 -0
  84. package/dist/components/Layout/builder-select.js +50 -0
  85. package/dist/components/Layout/constants.d.ts +1 -0
  86. package/dist/components/Layout/constants.js +4 -0
  87. package/dist/components/Layout/header.css +12 -0
  88. package/dist/components/Layout/header.d.ts +3 -0
  89. package/dist/components/Layout/header.js +87 -0
  90. package/dist/components/Layout/index.d.ts +5 -0
  91. package/dist/components/Layout/index.js +34 -0
  92. package/dist/components/Layout/menus.d.ts +8 -0
  93. package/dist/components/Layout/menus.js +155 -0
  94. package/dist/components/Layout/progress.d.ts +8 -0
  95. package/dist/components/Layout/progress.js +44 -0
  96. package/dist/components/Loader/Analysis/files.d.ts +8 -0
  97. package/dist/components/Loader/Analysis/files.js +187 -0
  98. package/dist/components/Loader/Analysis/index.d.ts +11 -0
  99. package/dist/components/Loader/Analysis/index.js +23 -0
  100. package/dist/components/Loader/executions.d.ts +13 -0
  101. package/dist/components/Loader/executions.js +221 -0
  102. package/dist/components/Manifest/api.d.ts +41 -0
  103. package/dist/components/Manifest/api.js +157 -0
  104. package/dist/components/Manifest/data.d.ts +8 -0
  105. package/dist/components/Manifest/data.js +81 -0
  106. package/dist/components/Manifest/index.d.ts +2 -0
  107. package/dist/components/Manifest/index.js +2 -0
  108. package/dist/components/Opener/code.d.ts +28 -0
  109. package/dist/components/Opener/code.js +69 -0
  110. package/dist/components/Opener/index.d.ts +2 -0
  111. package/dist/components/Opener/index.js +2 -0
  112. package/dist/components/Opener/vscode.d.ts +16 -0
  113. package/dist/components/Opener/vscode.js +57 -0
  114. package/dist/components/Overall/NumberButton.d.ts +14 -0
  115. package/dist/components/Overall/NumberButton.js +29 -0
  116. package/dist/components/Overall/NumberButton.module.js +5 -0
  117. package/dist/components/Overall/NumberButton_module.css +70 -0
  118. package/dist/components/Overall/bundle.d.ts +6 -0
  119. package/dist/components/Overall/bundle.js +167 -0
  120. package/dist/components/Overall/bundle.module.css +0 -0
  121. package/dist/components/Overall/card.module.js +5 -0
  122. package/dist/components/Overall/card_module.css +6 -0
  123. package/dist/components/Overall/compile.d.ts +5 -0
  124. package/dist/components/Overall/compile.js +68 -0
  125. package/dist/components/Overall/compile.module.js +5 -0
  126. package/dist/components/Overall/compile_module.css +4 -0
  127. package/dist/components/Overall/index.d.ts +3 -0
  128. package/dist/components/Overall/index.js +3 -0
  129. package/dist/components/Overall/list.module.js +5 -0
  130. package/dist/components/Overall/list_module.css +7 -0
  131. package/dist/components/Overall/project.d.ts +8 -0
  132. package/dist/components/Overall/project.js +73 -0
  133. package/dist/components/Plugins/webpack.d.ts +18 -0
  134. package/dist/components/Plugins/webpack.js +76 -0
  135. package/dist/components/Resolver/analysis.d.ts +15 -0
  136. package/dist/components/Resolver/analysis.js +160 -0
  137. package/dist/components/Select/index.d.ts +15 -0
  138. package/dist/components/Select/index.js +68 -0
  139. package/dist/components/Status/failed.d.ts +9 -0
  140. package/dist/components/Status/failed.js +33 -0
  141. package/dist/components/Status/index.d.ts +1 -0
  142. package/dist/components/Status/index.js +1 -0
  143. package/dist/components/TextDrawer/duplicate.d.ts +17 -0
  144. package/dist/components/TextDrawer/duplicate.js +107 -0
  145. package/dist/components/TextDrawer/index.d.ts +11 -0
  146. package/dist/components/TextDrawer/index.js +55 -0
  147. package/dist/components/Title/index.d.ts +15 -0
  148. package/dist/components/Title/index.js +10 -0
  149. package/dist/components/index.d.ts +8 -0
  150. package/dist/components/index.js +11 -0
  151. package/dist/components/worker/ecmaversion/client.d.ts +10 -0
  152. package/dist/components/worker/ecmaversion/client.js +61 -0
  153. package/dist/components/worker/ecmaversion/worker.d.ts +1 -0
  154. package/dist/components/worker/ecmaversion/worker.js +13 -0
  155. package/dist/components/worker/jsequal/client.d.ts +11 -0
  156. package/dist/components/worker/jsequal/client.js +39 -0
  157. package/dist/components/worker/jsequal/worker.d.ts +1 -0
  158. package/dist/components/worker/jsequal/worker.js +52 -0
  159. package/dist/config.d.ts +19 -0
  160. package/dist/config.js +39 -0
  161. package/dist/constants.d.ts +48 -0
  162. package/dist/constants.js +71 -0
  163. package/dist/index.d.ts +3 -0
  164. package/dist/index.js +6 -0
  165. package/dist/pages/BundleSize/components/asset.d.ts +26 -0
  166. package/dist/pages/BundleSize/components/asset.js +405 -0
  167. package/dist/pages/BundleSize/components/cards.d.ts +7 -0
  168. package/dist/pages/BundleSize/components/cards.js +154 -0
  169. package/dist/pages/BundleSize/components/editor.d.ts +5 -0
  170. package/dist/pages/BundleSize/components/editor.js +38 -0
  171. package/dist/pages/BundleSize/components/index.css +20 -0
  172. package/dist/pages/BundleSize/components/index.d.ts +16 -0
  173. package/dist/pages/BundleSize/components/index.js +314 -0
  174. package/dist/pages/BundleSize/config.d.ts +7 -0
  175. package/dist/pages/BundleSize/config.js +9 -0
  176. package/dist/pages/BundleSize/constants.d.ts +5 -0
  177. package/dist/pages/BundleSize/constants.js +9 -0
  178. package/dist/pages/BundleSize/index.d.ts +3 -0
  179. package/dist/pages/BundleSize/index.js +11 -0
  180. package/dist/pages/ModuleAnalyze/chunks.d.ts +6 -0
  181. package/dist/pages/ModuleAnalyze/chunks.js +48 -0
  182. package/dist/pages/ModuleAnalyze/components/fileTreeCom.css +88 -0
  183. package/dist/pages/ModuleAnalyze/components/fileTreeCom.d.ts +15 -0
  184. package/dist/pages/ModuleAnalyze/components/fileTreeCom.js +138 -0
  185. package/dist/pages/ModuleAnalyze/constants.d.ts +7 -0
  186. package/dist/pages/ModuleAnalyze/constants.js +14 -0
  187. package/dist/pages/ModuleAnalyze/dependncy.d.ts +9 -0
  188. package/dist/pages/ModuleAnalyze/dependncy.js +31 -0
  189. package/dist/pages/ModuleAnalyze/fileTree.d.ts +9 -0
  190. package/dist/pages/ModuleAnalyze/fileTree.js +125 -0
  191. package/dist/pages/ModuleAnalyze/index.css +10 -0
  192. package/dist/pages/ModuleAnalyze/index.d.ts +8 -0
  193. package/dist/pages/ModuleAnalyze/index.js +64 -0
  194. package/dist/pages/ModuleAnalyze/utils/hooks.d.ts +21 -0
  195. package/dist/pages/ModuleAnalyze/utils/hooks.js +65 -0
  196. package/dist/pages/ModuleAnalyze/utils/index.d.ts +3 -0
  197. package/dist/pages/ModuleAnalyze/utils/index.js +36 -0
  198. package/dist/pages/ModuleResolve/constants.d.ts +3 -0
  199. package/dist/pages/ModuleResolve/constants.js +7 -0
  200. package/dist/pages/ModuleResolve/index.d.ts +3 -0
  201. package/dist/pages/ModuleResolve/index.js +19 -0
  202. package/dist/pages/Overall/constants.d.ts +3 -0
  203. package/dist/pages/Overall/constants.js +7 -0
  204. package/dist/pages/Overall/index.d.ts +9 -0
  205. package/dist/pages/Overall/index.js +28 -0
  206. package/dist/pages/WebpackLoaders/Analysis/constants.d.ts +3 -0
  207. package/dist/pages/WebpackLoaders/Analysis/constants.js +7 -0
  208. package/dist/pages/WebpackLoaders/Analysis/index.d.ts +3 -0
  209. package/dist/pages/WebpackLoaders/Analysis/index.js +19 -0
  210. package/dist/pages/WebpackLoaders/Overall/constants.d.ts +3 -0
  211. package/dist/pages/WebpackLoaders/Overall/constants.js +7 -0
  212. package/dist/pages/WebpackLoaders/Overall/index.d.ts +3 -0
  213. package/dist/pages/WebpackLoaders/Overall/index.js +11 -0
  214. package/dist/pages/WebpackLoaders/constants.d.ts +2 -0
  215. package/dist/pages/WebpackLoaders/constants.js +6 -0
  216. package/dist/pages/WebpackPlugins/constants.d.ts +3 -0
  217. package/dist/pages/WebpackPlugins/constants.js +7 -0
  218. package/dist/pages/WebpackPlugins/index.d.ts +3 -0
  219. package/dist/pages/WebpackPlugins/index.js +79 -0
  220. package/dist/pages/index.d.ts +7 -0
  221. package/dist/pages/index.js +16 -0
  222. package/dist/utils/data/base.d.ts +24 -0
  223. package/dist/utils/data/base.js +70 -0
  224. package/dist/utils/data/index.d.ts +5 -0
  225. package/dist/utils/data/index.js +66 -0
  226. package/dist/utils/data/local.d.ts +14 -0
  227. package/dist/utils/data/local.js +106 -0
  228. package/dist/utils/data/remote.d.ts +10 -0
  229. package/dist/utils/data/remote.js +70 -0
  230. package/dist/utils/file.d.ts +39 -0
  231. package/dist/utils/file.js +154 -0
  232. package/dist/utils/hooks.d.ts +30 -0
  233. package/dist/utils/hooks.js +256 -0
  234. package/dist/utils/i18n/cn.d.ts +3 -0
  235. package/dist/utils/i18n/cn.js +33 -0
  236. package/dist/utils/i18n/en.d.ts +30 -0
  237. package/dist/utils/i18n/en.js +33 -0
  238. package/dist/utils/i18n/index.d.ts +2 -0
  239. package/dist/utils/i18n/index.js +34 -0
  240. package/dist/utils/index.d.ts +16 -0
  241. package/dist/utils/index.js +16 -0
  242. package/dist/utils/loader.d.ts +7 -0
  243. package/dist/utils/loader.js +29 -0
  244. package/dist/utils/locale.d.ts +2 -0
  245. package/dist/utils/locale.js +9 -0
  246. package/dist/utils/manifest.d.ts +27 -0
  247. package/dist/utils/manifest.js +54 -0
  248. package/dist/utils/monaco.d.ts +9 -0
  249. package/dist/utils/monaco.js +48 -0
  250. package/dist/utils/request.d.ts +23 -0
  251. package/dist/utils/request.js +162 -0
  252. package/dist/utils/routes.d.ts +3 -0
  253. package/dist/utils/routes.js +14 -0
  254. package/dist/utils/size.d.ts +2 -0
  255. package/dist/utils/size.js +24 -0
  256. package/dist/utils/socket.d.ts +2 -0
  257. package/dist/utils/socket.js +20 -0
  258. package/dist/utils/storage.d.ts +13 -0
  259. package/dist/utils/storage.js +70 -0
  260. package/dist/utils/string.d.ts +2 -0
  261. package/dist/utils/string.js +14 -0
  262. package/dist/utils/time.d.ts +3 -0
  263. package/dist/utils/time.js +7 -0
  264. package/dist/utils/url.d.ts +6 -0
  265. package/dist/utils/url.js +89 -0
  266. package/dist/utils/worker/index.d.ts +4 -0
  267. package/dist/utils/worker/index.js +4 -0
  268. package/dist/utils/worker/master.d.ts +8 -0
  269. package/dist/utils/worker/master.js +18 -0
  270. package/dist/utils/worker/types.d.ts +9 -0
  271. package/dist/utils/worker/types.js +0 -0
  272. package/dist/utils/worker/utils.d.ts +9 -0
  273. package/dist/utils/worker/utils.js +29 -0
  274. package/dist/utils/worker/worker.d.ts +13 -0
  275. package/dist/utils/worker/worker.js +38 -0
  276. package/package.json +87 -0
@@ -0,0 +1,154 @@
1
+ import { get, startsWith } from "lodash-es";
2
+ import { message } from "antd";
3
+ const rootDirname = (file, sep = "/") => {
4
+ const idx = file == null ? void 0 : file.indexOf(sep);
5
+ if (idx === -1) {
6
+ return null;
7
+ }
8
+ if (idx === 0) {
9
+ return sep + (rootDirname(file == null ? void 0 : file.slice(1)) || "");
10
+ }
11
+ return file == null ? void 0 : file.slice(0, idx);
12
+ };
13
+ function mapFileKey(arr, depth = 2, filter = () => true) {
14
+ let d = 0;
15
+ const res = [];
16
+ let parent = arr;
17
+ while (d < depth) {
18
+ parent.filter(filter).forEach((e) => {
19
+ if (!e.isLeaf) {
20
+ res.push(e.key);
21
+ }
22
+ });
23
+ parent = parent.reduce((t, e) => t.concat(e.children || []), []);
24
+ if (!parent.length)
25
+ break;
26
+ d++;
27
+ }
28
+ return res;
29
+ }
30
+ const basenameKey = "__BASENAME__";
31
+ function flattenDirectory(n, parent, sep = "/", inlinedResourcePathKey, dirTitle = (_dir, defaultTitle) => defaultTitle) {
32
+ if (n.isLeaf)
33
+ return;
34
+ if (parent.children && parent.children.length === 1) {
35
+ const defaultTitle = [parent[basenameKey], n[basenameKey]].join(sep);
36
+ parent[inlinedResourcePathKey] = n[inlinedResourcePathKey];
37
+ parent[basenameKey] = defaultTitle;
38
+ parent.key = [parent.key, n.key].join("-");
39
+ parent.children = n.children;
40
+ parent.title = dirTitle(parent, defaultTitle);
41
+ n.children && n.children.forEach((c) => {
42
+ flattenDirectory(c, parent, sep, inlinedResourcePathKey, dirTitle);
43
+ });
44
+ } else {
45
+ n.title = dirTitle(n, n[basenameKey]);
46
+ n.children && n.children.forEach((c) => {
47
+ flattenDirectory(c, n, sep, inlinedResourcePathKey, dirTitle);
48
+ });
49
+ }
50
+ }
51
+ function createFileStructures({
52
+ files,
53
+ sep = "/",
54
+ inlinedResourcePathKey = "__RESOURCEPATH__",
55
+ fileTitle = (_file, basename) => basename,
56
+ dirTitle = (_dir, defaultTitle) => defaultTitle
57
+ }) {
58
+ const sepRegexp = new RegExp(sep);
59
+ const res = files.reduce(
60
+ (t, file) => {
61
+ let dir = rootDirname(file, sep);
62
+ let basename = dir ? file == null ? void 0 : file.slice(dir.length + 1) : file;
63
+ let parent = t;
64
+ while (dir) {
65
+ let exist = parent.children.find((e) => e.title === dir);
66
+ if (!exist) {
67
+ const p = [parent[inlinedResourcePathKey], dir].filter(Boolean).join(sep);
68
+ exist = {
69
+ title: dir,
70
+ // key: [parent.key, parent.children!.length].join('-'),
71
+ key: p,
72
+ children: [],
73
+ [inlinedResourcePathKey]: p,
74
+ [basenameKey]: dir
75
+ };
76
+ parent.children.push(exist);
77
+ }
78
+ parent = exist;
79
+ dir = rootDirname(basename);
80
+ basename = dir ? basename.slice(dir.length).replace(sepRegexp, "") : basename;
81
+ }
82
+ if (parent.children.some((e) => get(e, inlinedResourcePathKey) === file))
83
+ return t;
84
+ parent.children.push({
85
+ title() {
86
+ return fileTitle(file, basename);
87
+ },
88
+ // key: [parent.key, parent.children!.length].join('-'),
89
+ key: file,
90
+ isLeaf: true,
91
+ [inlinedResourcePathKey]: file,
92
+ [basenameKey]: basename
93
+ });
94
+ return t;
95
+ },
96
+ { key: "0", children: [] }
97
+ ).children;
98
+ res.forEach((e) => {
99
+ e.children && e.children.forEach((item) => flattenDirectory(item, e, sep, inlinedResourcePathKey, dirTitle));
100
+ });
101
+ return res;
102
+ }
103
+ function beautifyPath(path, cwd) {
104
+ if (startsWith(path, cwd)) {
105
+ return path.replace(cwd, ".");
106
+ }
107
+ return path;
108
+ }
109
+ function readJSONByFileReader(file) {
110
+ return new Promise((resolve, reject) => {
111
+ const reader = new FileReader();
112
+ reader.onloadend = () => {
113
+ const { result } = reader;
114
+ console.log("reader result: ", result);
115
+ try {
116
+ const json = JSON.parse(result.toString());
117
+ resolve(json);
118
+ } catch (err) {
119
+ message.error("json parse error");
120
+ reject(err);
121
+ }
122
+ };
123
+ reader.onerror = () => {
124
+ const msg = "upload json file error, please try again.";
125
+ message.error(msg);
126
+ reject(new Error(msg));
127
+ };
128
+ reader.readAsText(file.originFileObj || file);
129
+ });
130
+ }
131
+ function beautifyModulePath(modulePath, cwd) {
132
+ const res = beautifyPath(modulePath, cwd);
133
+ const str = "/node_modules/";
134
+ const idx = res.lastIndexOf(str);
135
+ if (idx > -1) {
136
+ return {
137
+ alias: res.slice(idx + str.length),
138
+ inNodeModules: true
139
+ };
140
+ }
141
+ return {
142
+ alias: res,
143
+ inNodeModules: false
144
+ };
145
+ }
146
+ export {
147
+ beautifyModulePath,
148
+ beautifyPath,
149
+ createFileStructures,
150
+ flattenDirectory,
151
+ mapFileKey,
152
+ readJSONByFileReader,
153
+ rootDirname
154
+ };
@@ -0,0 +1,30 @@
1
+ /// <reference types="react" />
2
+ import { Manifest, Rule, SDK } from '@rsdoctor/types';
3
+ import { useTranslation } from 'react-i18next';
4
+ import './i18n';
5
+ export declare const useI18n: typeof useTranslation;
6
+ export declare function useRuleIndexNavigate(code: string, link?: string | undefined): () => void;
7
+ export declare function useUrlQuery(): Record<string, string | undefined>;
8
+ export declare function useLoading(defaultLoading?: boolean): {
9
+ loading: boolean;
10
+ setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
11
+ withLoading(func: (...args: unknown[]) => Promise<unknown> | unknown): Promise<void>;
12
+ };
13
+ export declare function useProjectRootByManifest(manifest: Manifest.DoctorManifest): string;
14
+ export declare function useHashByManifest(manifest: Manifest.DoctorManifest): string;
15
+ export declare function useCloudManifestUrlByManifest(manifest: Manifest.DoctorManifest | Manifest.DoctorManifestWithShardingFiles | void): void;
16
+ export declare function useChunkGraphByManifest(manifest: Manifest.DoctorManifest): SDK.ChunkGraphData;
17
+ export declare function useConfigOutputFileNameByManifest(manifest: Manifest.DoctorManifest): string;
18
+ export declare function useModuleGraphByManifest(manifest: Manifest.DoctorManifest): SDK.ModuleGraphData;
19
+ export declare function useModuleGraph(moduleGraph: SDK.ModuleGraphData): SDK.ModuleGraphData;
20
+ export declare function usePackageGraphByManifest(manifest: Manifest.DoctorManifest): SDK.PackageGraphData;
21
+ export declare function useUniqModulesByManifest(manifest: Manifest.DoctorManifest): SDK.ModuleData[];
22
+ export declare function useUniqModules(modules: SDK.ModuleData[]): SDK.ModuleData[];
23
+ export declare function useErrorsByManifest(manifest: Manifest.DoctorManifest): Rule.RuleStoreData;
24
+ export declare function useBundleAlertsByManifest(manifest: Manifest.DoctorManifest): Rule.RuleStoreDataItem[];
25
+ export declare function useDuplicatePackagesByManifest(manifest: Manifest.DoctorManifest): Rule.PackageRelationDiffRuleStoreData[];
26
+ export declare function useCompileAlertsByErrors(errors: Manifest.DoctorManifestData['errors']): Rule.RuleStoreDataItem[];
27
+ export declare function useBundleAlertsByErrors(errors: Manifest.DoctorManifestData['errors']): Rule.RuleStoreDataItem[];
28
+ export declare function useDuplicatePackagesByErrors(errors: Manifest.DoctorManifestData['errors']): Rule.PackageRelationDiffRuleStoreData[];
29
+ export declare function useWebpackConfigurationByConfigs(configs?: SDK.ConfigData): SDK.WebpackConfigData | null | undefined;
30
+ export declare function useDetectIfCloudIdeEnv(): boolean;
@@ -0,0 +1,256 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ var __async = (__this, __arguments, generator) => {
33
+ return new Promise((resolve, reject) => {
34
+ var fulfilled = (value) => {
35
+ try {
36
+ step(generator.next(value));
37
+ } catch (e) {
38
+ reject(e);
39
+ }
40
+ };
41
+ var rejected = (value) => {
42
+ try {
43
+ step(generator.throw(value));
44
+ } catch (e) {
45
+ reject(e);
46
+ }
47
+ };
48
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
+ step((generator = generator.apply(__this, __arguments)).next());
50
+ });
51
+ };
52
+ import { Algorithm } from "@rsdoctor/utils/common";
53
+ import { Client, Rule } from "@rsdoctor/types";
54
+ import { uniqBy, isArray, defaults } from "lodash-es";
55
+ import { useState } from "react";
56
+ import { useTranslation } from "react-i18next";
57
+ import { useNavigate, useLocation } from "react-router-dom";
58
+ import parse from "url-parse";
59
+ import "./i18n";
60
+ import { setLocaleToStorage } from "./storage";
61
+ const route = Client.DoctorClientRoutes.RuleIndex;
62
+ const useI18n = () => {
63
+ const _a = useTranslation(), { i18n } = _a, rest = __objRest(_a, ["i18n"]);
64
+ return __spreadProps(__spreadValues({}, rest), {
65
+ i18n: __spreadProps(__spreadValues({}, i18n), {
66
+ changeLanguage(lng, callback) {
67
+ return i18n.changeLanguage(lng, (error, t) => {
68
+ if (!error) {
69
+ setLocaleToStorage(lng);
70
+ }
71
+ callback && callback(error, t);
72
+ });
73
+ }
74
+ })
75
+ });
76
+ };
77
+ function useRuleIndexNavigate(code, link) {
78
+ const navigate = useNavigate();
79
+ if (link) {
80
+ return () => window.open(link, "__blank");
81
+ }
82
+ return () => {
83
+ navigate(`${route}?${Rule.DoctorRuleClientConstant.UrlQueryForErrorCode}=${code}`);
84
+ };
85
+ }
86
+ function useUrlQuery() {
87
+ const search = useLocation().search || location.search;
88
+ const { query } = parse(search, true);
89
+ return query;
90
+ }
91
+ function useLoading(defaultLoading = false) {
92
+ const [loading, setLoading] = useState(defaultLoading);
93
+ return {
94
+ loading,
95
+ setLoading,
96
+ withLoading(func) {
97
+ return __async(this, null, function* () {
98
+ try {
99
+ setLoading(true);
100
+ yield func();
101
+ } finally {
102
+ setLoading(false);
103
+ }
104
+ });
105
+ }
106
+ };
107
+ }
108
+ function useProjectRootByManifest(manifest) {
109
+ return manifest.data.root;
110
+ }
111
+ function useHashByManifest(manifest) {
112
+ return manifest.data.hash;
113
+ }
114
+ function useCloudManifestUrlByManifest(manifest) {
115
+ if (!manifest)
116
+ return;
117
+ }
118
+ function ensurePlainObject(value, dfts) {
119
+ if (value && typeof value === "object") {
120
+ if (isArray(value)) {
121
+ return dfts;
122
+ }
123
+ return defaults(value, dfts);
124
+ }
125
+ return dfts;
126
+ }
127
+ function useChunkGraphByManifest(manifest) {
128
+ const prev = manifest.data.chunkGraph;
129
+ if (typeof prev === "string") {
130
+ manifest.data.chunkGraph = JSON.parse(Algorithm.decompressText(prev));
131
+ }
132
+ return ensurePlainObject(manifest.data.chunkGraph, { assets: [], chunks: [], entrypoints: [] });
133
+ }
134
+ function useConfigOutputFileNameByManifest(manifest) {
135
+ var _a, _b, _c, _d, _e, _f, _g, _h;
136
+ if (typeof ((_d = (_c = (_b = (_a = manifest.data.configs) == null ? void 0 : _a[0]) == null ? void 0 : _b.config) == null ? void 0 : _c.output) == null ? void 0 : _d.filename) === "string") {
137
+ return (_h = (_g = (_f = (_e = manifest.data.configs) == null ? void 0 : _e[0]) == null ? void 0 : _f.config) == null ? void 0 : _g.output) == null ? void 0 : _h.filename;
138
+ }
139
+ return "";
140
+ }
141
+ function useModuleGraphByManifest(manifest) {
142
+ const prev = manifest.data.moduleGraph;
143
+ if (typeof prev === "string") {
144
+ manifest.data.moduleGraph = JSON.parse(Algorithm.decompressText(prev));
145
+ }
146
+ return ensurePlainObject(manifest.data.moduleGraph, {
147
+ dependencies: [],
148
+ modules: [],
149
+ moduleGraphModules: [],
150
+ exports: [],
151
+ sideEffects: [],
152
+ variables: []
153
+ });
154
+ }
155
+ function useModuleGraph(moduleGraph) {
156
+ const prev = moduleGraph;
157
+ if (typeof prev === "string") {
158
+ moduleGraph = JSON.parse(Algorithm.decompressText(prev));
159
+ }
160
+ return ensurePlainObject(moduleGraph, {
161
+ dependencies: [],
162
+ modules: [],
163
+ moduleGraphModules: [],
164
+ exports: [],
165
+ sideEffects: [],
166
+ variables: []
167
+ });
168
+ }
169
+ function usePackageGraphByManifest(manifest) {
170
+ const prev = manifest.data.packageGraph;
171
+ if (typeof prev === "string") {
172
+ manifest.data.packageGraph = JSON.parse(Algorithm.decompressText(prev));
173
+ }
174
+ return ensurePlainObject(manifest.data.packageGraph, {
175
+ packages: [],
176
+ dependencies: []
177
+ });
178
+ }
179
+ function useUniqModulesByManifest(manifest) {
180
+ return uniqBy(useModuleGraphByManifest(manifest).modules, (e) => e.path);
181
+ }
182
+ function useUniqModules(modules) {
183
+ return uniqBy(modules, (e) => e.path);
184
+ }
185
+ function useErrorsByManifest(manifest) {
186
+ const prev = manifest.data.errors;
187
+ if (typeof prev === "string") {
188
+ manifest.data.errors = JSON.parse(Algorithm.decompressText(prev));
189
+ }
190
+ return manifest.data.errors || [];
191
+ }
192
+ function useBundleAlertsByManifest(manifest) {
193
+ const errors = useErrorsByManifest(manifest);
194
+ return useBundleAlertsByErrors(errors);
195
+ }
196
+ function useDuplicatePackagesByManifest(manifest) {
197
+ const alerts = useBundleAlertsByManifest(manifest);
198
+ return useDuplicatePackagesByErrors(alerts);
199
+ }
200
+ function useCompileAlertsByErrors(errors) {
201
+ if (isArray(errors)) {
202
+ return errors.filter(
203
+ (e) => e.category === Rule.RuleMessageCategory.Compile && e.code !== Rule.RuleMessageCodeEnumerated.Overlay
204
+ );
205
+ }
206
+ return [];
207
+ }
208
+ function useBundleAlertsByErrors(errors) {
209
+ if (isArray(errors)) {
210
+ return errors.filter(
211
+ (e) => e.category === Rule.RuleMessageCategory.Bundle && e.code !== Rule.RuleMessageCodeEnumerated.Overlay
212
+ );
213
+ }
214
+ return [];
215
+ }
216
+ function useDuplicatePackagesByErrors(errors) {
217
+ return useBundleAlertsByErrors(errors).filter(
218
+ (e) => e.code === Rule.RuleErrorMap.E1001.code
219
+ );
220
+ }
221
+ function useWebpackConfigurationByConfigs(configs = []) {
222
+ if (isArray(configs)) {
223
+ return configs.find((e) => e.name === "webpack");
224
+ }
225
+ return null;
226
+ }
227
+ function useDetectIfCloudIdeEnv() {
228
+ if (window.location.protocol === "https:" && window.location.href.indexOf("ide-proxy") > 0) {
229
+ return true;
230
+ }
231
+ return false;
232
+ }
233
+ export {
234
+ useBundleAlertsByErrors,
235
+ useBundleAlertsByManifest,
236
+ useChunkGraphByManifest,
237
+ useCloudManifestUrlByManifest,
238
+ useCompileAlertsByErrors,
239
+ useConfigOutputFileNameByManifest,
240
+ useDetectIfCloudIdeEnv,
241
+ useDuplicatePackagesByErrors,
242
+ useDuplicatePackagesByManifest,
243
+ useErrorsByManifest,
244
+ useHashByManifest,
245
+ useI18n,
246
+ useLoading,
247
+ useModuleGraph,
248
+ useModuleGraphByManifest,
249
+ usePackageGraphByManifest,
250
+ useProjectRootByManifest,
251
+ useRuleIndexNavigate,
252
+ useUniqModules,
253
+ useUniqModulesByManifest,
254
+ useUrlQuery,
255
+ useWebpackConfigurationByConfigs
256
+ };
@@ -0,0 +1,3 @@
1
+ import en from './en';
2
+ declare const cn: typeof en;
3
+ export default cn;
@@ -0,0 +1,33 @@
1
+ const cn = {
2
+ Overall: "概览",
3
+ "Compile Analysis": "编译分析",
4
+ LoadersAnalysis: "Loaders 分析",
5
+ "Loaders Overall": "Loaders 概览",
6
+ "Loaders Analysis": "Loaders 分析",
7
+ PluginsAnalysis: "Plugins 分析",
8
+ ModuleResolve: "Module Resolve 分析",
9
+ "Bundle Analysis": "产物分析",
10
+ BundleSize: "产物体积分析",
11
+ "Module Graph": "Module Graph",
12
+ TreeShaking: "Tree Shaking",
13
+ "Rule Index": "错误索引信息",
14
+ Resources: "资源",
15
+ "Project Overall": "项目信息概览",
16
+ "Compile Overall": "编译数据概览",
17
+ "Bundle Overall": "产物数据概览",
18
+ "Expand Omitted": " reasons 树会默认折叠中间的第三方引入的模块,点击这个图标可以查看完整树图",
19
+ "Concatenated Tag": "串联模块,hover 上去可以显示聚合成的主模块名称。注:聚合模块 parsed size 为零,有可能是因为被聚合到了主模块中。",
20
+ "the file content not changed after transpiled by this loader": "该文件内容在 loader 处理前后没有发生变化",
21
+ /** Bundle Size */
22
+ "Output Assets List": "产物文件列表",
23
+ "filter the output assets which size is greater than the input value": "筛选大小大于输入值的产物文件",
24
+ "filter the modules which size is greater than the input value": "筛选大小大于输入值的模块",
25
+ "After Compile": "编译后",
26
+ "After Bundle": "打包后",
27
+ CodeModeExplain: "Lite 模式下或纯 stats.json 上传的情况下只有 source code.",
28
+ DuplicatePakCodeExplain: "纯 stats.json 输入的情况下没有代码,可使用 web-doctor 插件参与构建会有对应代码。"
29
+ };
30
+ var cn_default = cn;
31
+ export {
32
+ cn_default as default
33
+ };
@@ -0,0 +1,30 @@
1
+ declare const en: {
2
+ Overall: string;
3
+ 'Compile Analysis': string;
4
+ LoadersAnalysis: string;
5
+ 'Loaders Overall': string;
6
+ 'Loaders Analysis': string;
7
+ PluginsAnalysis: string;
8
+ ModuleResolve: string;
9
+ 'Bundle Analysis': string;
10
+ BundleSize: string;
11
+ 'Module Graph': string;
12
+ TreeShaking: string;
13
+ 'Rule Index': string;
14
+ Resources: string;
15
+ 'Project Overall': string;
16
+ 'Compile Overall': string;
17
+ 'Bundle Overall': string;
18
+ 'Expand Omitted': string;
19
+ 'Concatenated Tag': string;
20
+ 'the file content not changed after transpiled by this loader': string;
21
+ /** Bundle Size */
22
+ 'Output Assets List': string;
23
+ 'filter the output assets which size is greater than the input value': string;
24
+ 'filter the modules which size is greater than the input value': string;
25
+ 'After Compile': string;
26
+ 'After Bundle': string;
27
+ CodeModeExplain: string;
28
+ DuplicatePakCodeExplain: string;
29
+ };
30
+ export default en;
@@ -0,0 +1,33 @@
1
+ const en = {
2
+ Overall: "Overall",
3
+ "Compile Analysis": "Compile Analysis",
4
+ LoadersAnalysis: "Loaders Analysis",
5
+ "Loaders Overall": "Loaders Overall",
6
+ "Loaders Analysis": "Loaders Analysis",
7
+ PluginsAnalysis: "Plugins Analysis",
8
+ ModuleResolve: "Module Resolve",
9
+ "Bundle Analysis": "Bundle Analysis",
10
+ BundleSize: "Bundle Size",
11
+ "Module Graph": "Module Graph",
12
+ TreeShaking: "Tree Shaking",
13
+ "Rule Index": "Rule Index",
14
+ Resources: "Resources",
15
+ "Project Overall": "Project Overall",
16
+ "Compile Overall": "Compile Overall",
17
+ "Bundle Overall": "Bundle Overall",
18
+ "Expand Omitted": "By default, the reasons tree collapses to the middle of the module introduced by a third party. Click on this icon to view the full tree diagram",
19
+ "Concatenated Tag": "Concatenated Module,hover can display the name of the concatenated main module. Note: the parsed size of the concatenated module is zero, possibly because it is aggregated into the main module.",
20
+ "the file content not changed after transpiled by this loader": "the file content not changed after transpiled by this loader",
21
+ /** Bundle Size */
22
+ "Output Assets List": "Output Assets List",
23
+ "filter the output assets which size is greater than the input value": "filter the output assets which size is greater than the input value",
24
+ "filter the modules which size is greater than the input value": "filter the modules which size is greater than the input value",
25
+ "After Compile": "After Compile",
26
+ "After Bundle": "After Bundle",
27
+ CodeModeExplain: "In lite mode or pure stats.json upload, only source code.",
28
+ DuplicatePakCodeExplain: "There is no code, when in the case of pure stats.json."
29
+ };
30
+ var en_default = en;
31
+ export {
32
+ en_default as default
33
+ };
@@ -0,0 +1,2 @@
1
+ import i18n from 'i18next';
2
+ export default i18n;
@@ -0,0 +1,34 @@
1
+ import i18n from "i18next";
2
+ import { initReactI18next } from "react-i18next";
3
+ import en from "./en";
4
+ import cn from "./cn";
5
+ import { getLocaleFromStorage } from "../storage";
6
+ i18n.use(initReactI18next).init({
7
+ lng: getLocaleFromStorage(),
8
+ // we init with resources
9
+ resources: {
10
+ en: {
11
+ translations: en
12
+ },
13
+ cn: {
14
+ translations: cn
15
+ }
16
+ },
17
+ fallbackLng: {
18
+ "zh-CN": ["cn"],
19
+ default: ["en"]
20
+ },
21
+ debug: process.env.NODE_ENV === "development",
22
+ // have a common namespace used around the full app
23
+ ns: ["translations"],
24
+ defaultNS: "translations",
25
+ keySeparator: false,
26
+ // we use content as keys
27
+ interpolation: {
28
+ escapeValue: false
29
+ }
30
+ });
31
+ var i18n_default = i18n;
32
+ export {
33
+ i18n_default as default
34
+ };
@@ -0,0 +1,16 @@
1
+ export * from './data';
2
+ export * from './file';
3
+ export * from './hooks';
4
+ export * from './locale';
5
+ export * from './manifest';
6
+ export * from './monaco';
7
+ export * from './request';
8
+ export * from './routes';
9
+ export * from './size';
10
+ export * from './socket';
11
+ export * from './storage';
12
+ export * from './string';
13
+ export * from './time';
14
+ export * from './url';
15
+ export * from './worker';
16
+ export * from './loader';
@@ -0,0 +1,16 @@
1
+ export * from "./data";
2
+ export * from "./file";
3
+ export * from "./hooks";
4
+ export * from "./locale";
5
+ export * from "./manifest";
6
+ export * from "./monaco";
7
+ export * from "./request";
8
+ export * from "./routes";
9
+ export * from "./size";
10
+ export * from "./socket";
11
+ export * from "./storage";
12
+ export * from "./string";
13
+ export * from "./time";
14
+ export * from "./url";
15
+ export * from "./worker";
16
+ export * from "./loader";
@@ -0,0 +1,7 @@
1
+ import { Loader } from '@rsdoctor/utils/common';
2
+ import { SDK } from '@rsdoctor/types';
3
+ declare const findLoaderTotalTiming: typeof Loader.findLoaderTotalTiming, getLoaderCosts: typeof Loader.getLoaderCosts;
4
+ export { findLoaderTotalTiming, getLoaderCosts };
5
+ export declare function flattenLoaderData(loaderData: SDK.LoaderData): SDK.LoaderTransformData[];
6
+ export declare function filterLoaders(loaderData: SDK.ResourceLoaderData, keyword: string, loaderNames: string[]): SDK.LoaderTransformData[];
7
+ export declare function filterLoader(resourcePath: string, loader: string, keyword: string, loaderNames: string[]): boolean;
@@ -0,0 +1,29 @@
1
+ import { Loader } from "@rsdoctor/utils/common";
2
+ import { flatten, includes } from "lodash-es";
3
+ const { findLoaderTotalTiming, getLoaderCosts } = Loader;
4
+ function flattenLoaderData(loaderData) {
5
+ return flatten(loaderData.map((e) => e.loaders));
6
+ }
7
+ function filterLoaders(loaderData, keyword, loaderNames) {
8
+ return loaderData.loaders.filter((item) => {
9
+ return filterLoader(loaderData.resource.path, item.loader, keyword, loaderNames);
10
+ });
11
+ }
12
+ function filterLoader(resourcePath, loader, keyword, loaderNames) {
13
+ if (keyword) {
14
+ if (resourcePath.indexOf(keyword) === -1)
15
+ return false;
16
+ }
17
+ if (loaderNames && loaderNames.length) {
18
+ if (!includes(loaderNames, loader))
19
+ return false;
20
+ }
21
+ return true;
22
+ }
23
+ export {
24
+ filterLoader,
25
+ filterLoaders,
26
+ findLoaderTotalTiming,
27
+ flattenLoaderData,
28
+ getLoaderCosts
29
+ };
@@ -0,0 +1,2 @@
1
+ import type { Locale } from 'antd/es/locale';
2
+ export declare function getLocale(locale: string): Locale;
@@ -0,0 +1,9 @@
1
+ import cn from "antd/es/locale/zh_CN";
2
+ import en from "antd/es/locale/en_GB";
3
+ function getLocale(locale) {
4
+ const res = locale === "cn" || locale === "zh-CN" ? cn : en;
5
+ return res;
6
+ }
7
+ export {
8
+ getLocale
9
+ };