@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,20 @@
1
+ import * as Overall from "./Overall";
2
+ import * as BundleSize from "./BundleSize";
3
+ import * as ModuleAnalyze from "./ModuleAnalyze";
4
+ import * as LoaderTimeline from "./WebpackLoaders/Overall";
5
+ import * as LoaderFiles from "./WebpackLoaders/Analysis";
6
+ import * as PluginsAnalyze from "./WebpackPlugins";
7
+ import * as ModuleResolve from "./ModuleResolve";
8
+ import * as RuleIndex from "./Resources/RuleIndex";
9
+ import * as TreeShaking from "./TreeShaking";
10
+ export {
11
+ BundleSize,
12
+ LoaderFiles,
13
+ LoaderTimeline,
14
+ ModuleAnalyze,
15
+ ModuleResolve,
16
+ Overall,
17
+ PluginsAnalyze,
18
+ RuleIndex,
19
+ TreeShaking
20
+ };
@@ -0,0 +1,24 @@
1
+ import { Common, Manifest, SDK } from '@rsdoctor/types';
2
+ import { Data } from '@rsdoctor/utils/common';
3
+ export declare abstract class BaseDataLoader implements Manifest.ManifestDataLoader {
4
+ protected manifest: Manifest.RsdoctorManifestWithShardingFiles;
5
+ protected pool: Map<string, Promise<unknown>>;
6
+ protected loader: Data.APIDataLoader;
7
+ protected disposed: boolean;
8
+ protected shardingDataMap: Map<keyof Manifest.RsdoctorManifestData, Promise<any>>;
9
+ constructor(manifest: Manifest.RsdoctorManifestWithShardingFiles);
10
+ protected get<T extends keyof Manifest.RsdoctorManifestWithShardingFiles>(key: T): void | Manifest.RsdoctorManifestWithShardingFiles[T];
11
+ protected getData<T extends keyof Manifest.RsdoctorManifestData>(key: T, scope?: 'data' | 'cloudData'): void | Manifest.RsdoctorManifestWithShardingFiles['data'][T];
12
+ protected getKeys(key: string): string[];
13
+ protected joinKeys(keys: string[]): string;
14
+ dispose(): void;
15
+ limit<T>(key: string, fn: Common.Function<unknown[], Promise<T>>): Promise<T>;
16
+ log(...args: unknown[]): void;
17
+ loadManifest(): Promise<Manifest.RsdoctorManifestWithShardingFiles>;
18
+ abstract loadData<T extends string, P>(key: T): Promise<void | P>;
19
+ abstract loadData<T extends Manifest.RsdoctorManifestMappingKeys>(key: T): Promise<void | Manifest.InferManifestDataValue<T>>;
20
+ abstract isLocal(): boolean;
21
+ abstract loadAPI<T extends SDK.ServerAPI.API, B extends SDK.ServerAPI.InferRequestBodyType<T> = SDK.ServerAPI.InferRequestBodyType<T>, R extends SDK.ServerAPI.InferResponseType<T> = SDK.ServerAPI.InferResponseType<T>>(...args: B extends void ? [api: T] : [api: T, body: B]): Promise<R>;
22
+ abstract onDataUpdate<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, fn: (response: SDK.ServerAPI.SocketResponseType<T>) => void): void;
23
+ abstract removeOnDataUpdate<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, fn: (response: SDK.ServerAPI.SocketResponseType<T>) => void): void;
24
+ }
@@ -0,0 +1,48 @@
1
+ import { Data } from "@rsdoctor/utils/common";
2
+ class BaseDataLoader {
3
+ constructor(manifest) {
4
+ this.manifest = manifest;
5
+ this.pool = /* @__PURE__ */ new Map();
6
+ this.disposed = false;
7
+ this.shardingDataMap = /* @__PURE__ */ new Map();
8
+ this.loader = new Data.APIDataLoader(this);
9
+ console.log("[DataLoader] isLocal: ", this.isLocal());
10
+ }
11
+ get(key) {
12
+ if (!this.manifest)
13
+ return;
14
+ return this.manifest[key];
15
+ }
16
+ getData(key, scope = "data") {
17
+ const data = this.get(scope);
18
+ if (!data)
19
+ return;
20
+ return data[key];
21
+ }
22
+ getKeys(key) {
23
+ return key.split(".");
24
+ }
25
+ joinKeys(keys) {
26
+ return keys.join(".");
27
+ }
28
+ dispose() {
29
+ this.disposed = true;
30
+ }
31
+ limit(key, fn) {
32
+ if (this.pool.has(key)) {
33
+ return this.pool.get(key);
34
+ }
35
+ const res = fn().finally(() => this.pool.delete(key));
36
+ this.pool.set(key, res);
37
+ return res;
38
+ }
39
+ log(...args) {
40
+ console.log(`[${this.constructor.name}]`, ...args);
41
+ }
42
+ async loadManifest() {
43
+ return this.manifest;
44
+ }
45
+ }
46
+ export {
47
+ BaseDataLoader
48
+ };
@@ -0,0 +1,5 @@
1
+ import { Manifest } from '@rsdoctor/types';
2
+ import { BaseDataLoader } from './base';
3
+ export declare function useDataLoader(manifest: Manifest.RsdoctorManifestWithShardingFiles | void): {
4
+ loader: void | BaseDataLoader;
5
+ };
@@ -0,0 +1,44 @@
1
+ import { useEffect, useState } from "react";
2
+ import { LocalServerDataLoader } from "./local";
3
+ import { RemoteDataLoader } from "./remote";
4
+ import { getAPILoaderModeFromStorage } from "../storage";
5
+ import { APILoaderMode4Dev } from "../../constants";
6
+ const loaderTask = /* @__PURE__ */ new WeakMap();
7
+ async function createDataLoader(manifest) {
8
+ try {
9
+ if (process.env.NODE_ENV === "development") {
10
+ const mode = getAPILoaderModeFromStorage();
11
+ if (mode === APILoaderMode4Dev.Local)
12
+ return new LocalServerDataLoader(manifest);
13
+ if (mode === APILoaderMode4Dev.Remote)
14
+ return new RemoteDataLoader(manifest);
15
+ }
16
+ if (manifest.__LOCAL__SERVER__) {
17
+ return new LocalServerDataLoader(manifest);
18
+ }
19
+ } catch (error) {
20
+ console.log("[DataLoader] fallback to RemoteDataLoader");
21
+ }
22
+ return new RemoteDataLoader(manifest);
23
+ }
24
+ function useDataLoader(manifest) {
25
+ const [loader, setLoader] = useState(void 0);
26
+ useEffect(() => {
27
+ if (!manifest)
28
+ return;
29
+ if (!loaderTask.has(manifest)) {
30
+ const promise = createDataLoader(manifest);
31
+ loaderTask.set(manifest, promise);
32
+ }
33
+ const task = loaderTask.get(manifest);
34
+ task.then((loader2) => {
35
+ setLoader(loader2);
36
+ });
37
+ }, [manifest]);
38
+ return {
39
+ loader
40
+ };
41
+ }
42
+ export {
43
+ useDataLoader
44
+ };
@@ -0,0 +1,14 @@
1
+ import { Common, Manifest, SDK } from '@rsdoctor/types';
2
+ import { BaseDataLoader } from './base';
3
+ export declare class LocalServerDataLoader extends BaseDataLoader {
4
+ protected events: Map<SDK.ServerAPI.API | SDK.ServerAPI.APIExtends, Set<Common.Function>>;
5
+ isLocal(): boolean;
6
+ loadData<T extends keyof Manifest.RsdoctorManifestData>(key: T): Promise<void | Manifest.RsdoctorManifestData[T]>;
7
+ loadAPI<T extends SDK.ServerAPI.API, B extends SDK.ServerAPI.InferRequestBodyType<T> = SDK.ServerAPI.InferRequestBodyType<T>, R extends SDK.ServerAPI.InferResponseType<T> = SDK.ServerAPI.InferResponseType<T>>(...args: B extends void ? [api: T] : [api: T, body: B]): Promise<R>;
8
+ dispose(): void;
9
+ /**
10
+ * add event listener when received data from server.
11
+ */
12
+ onDataUpdate<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, fn: (response: SDK.ServerAPI.SocketResponseType<T>) => void): void;
13
+ removeOnDataUpdate<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, fn: (response: SDK.ServerAPI.SocketResponseType<T>) => void): void;
14
+ }
@@ -0,0 +1,86 @@
1
+ import { Manifest as ManifestShared } from "@rsdoctor/utils/common";
2
+ import { SDK } from "@rsdoctor/types";
3
+ import { get } from "lodash-es";
4
+ import { BaseDataLoader } from "./base";
5
+ import { getSocket } from "../socket";
6
+ class LocalServerDataLoader extends BaseDataLoader {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.events = /* @__PURE__ */ new Map();
10
+ }
11
+ isLocal() {
12
+ return true;
13
+ }
14
+ async loadData(key) {
15
+ return this.limit(key, async () => {
16
+ const [scope, ...rest] = this.getKeys(key);
17
+ const data = this.getData(scope);
18
+ if (!data)
19
+ return;
20
+ let res = data;
21
+ if (ManifestShared.isShardingData(res)) {
22
+ if (!this.shardingDataMap.has(key)) {
23
+ const task = new Promise((resolve) => {
24
+ getSocket().emit(
25
+ SDK.ServerAPI.API.LoadDataByKey,
26
+ { key },
27
+ (res2) => {
28
+ resolve(res2.res);
29
+ }
30
+ );
31
+ });
32
+ this.shardingDataMap.set(key, task);
33
+ }
34
+ res = await this.shardingDataMap.get(key);
35
+ this.shardingDataMap.delete(key);
36
+ return res;
37
+ }
38
+ return rest.length > 0 ? get(res, this.joinKeys(rest)) : res;
39
+ });
40
+ }
41
+ async loadAPI(...args) {
42
+ const [api, body] = args;
43
+ const key = body ? `${api}_${JSON.stringify(body)}` : `${api}`;
44
+ return this.limit(key, async () => {
45
+ return new Promise((resolve) => {
46
+ getSocket().emit(
47
+ api,
48
+ body,
49
+ (res) => {
50
+ resolve(res.res);
51
+ }
52
+ );
53
+ });
54
+ });
55
+ }
56
+ dispose() {
57
+ super.dispose();
58
+ this.events.forEach((evs, api) => {
59
+ evs.forEach((ev) => {
60
+ this.removeOnDataUpdate(api, ev);
61
+ });
62
+ evs.clear();
63
+ });
64
+ this.events.clear();
65
+ }
66
+ /**
67
+ * add event listener when received data from server.
68
+ */
69
+ onDataUpdate(api, fn) {
70
+ if (!this.events.has(api)) {
71
+ this.events.set(api, /* @__PURE__ */ new Set());
72
+ }
73
+ if (this.events.get(api).has(fn)) {
74
+ return;
75
+ }
76
+ this.events.get(api).add(fn);
77
+ getSocket().on(api, fn);
78
+ }
79
+ removeOnDataUpdate(api, fn) {
80
+ getSocket().off(api, fn);
81
+ this.events.get(api).delete(fn);
82
+ }
83
+ }
84
+ export {
85
+ LocalServerDataLoader
86
+ };
@@ -0,0 +1,10 @@
1
+ import { Manifest, SDK } from '@rsdoctor/types';
2
+ import { BaseDataLoader } from './base';
3
+ export declare class RemoteDataLoader extends BaseDataLoader {
4
+ isLocal(): boolean;
5
+ loadData<T extends Manifest.RsdoctorManifestMappingKeys>(key: T): Promise<Manifest.InferManifestDataValue<T>>;
6
+ loadAPI<T extends SDK.ServerAPI.API, B extends SDK.ServerAPI.InferRequestBodyType<T> = SDK.ServerAPI.InferRequestBodyType<T>, R extends SDK.ServerAPI.InferResponseType<T> = SDK.ServerAPI.InferResponseType<T>>(...args: B extends void ? [api: T] : [api: T, body: B]): Promise<R>;
7
+ dispose(): void;
8
+ onDataUpdate(): void;
9
+ removeOnDataUpdate(): void;
10
+ }
@@ -0,0 +1,52 @@
1
+ import { Manifest as ManifestShared } from "@rsdoctor/utils/common";
2
+ import { get } from "lodash-es";
3
+ import { BaseDataLoader } from "./base";
4
+ import { fetchShardingFile } from "../request";
5
+ class RemoteDataLoader extends BaseDataLoader {
6
+ isLocal() {
7
+ return false;
8
+ }
9
+ async loadData(key) {
10
+ return this.limit(key, async () => {
11
+ const [scope, ...rest] = this.getKeys(key);
12
+ const data = this.getData(
13
+ scope,
14
+ "cloudData"
15
+ );
16
+ if (!data)
17
+ return;
18
+ let res = data;
19
+ if (ManifestShared.isShardingData(res)) {
20
+ if (!this.shardingDataMap.has(scope)) {
21
+ const task = ManifestShared.fetchShardingData(
22
+ res,
23
+ fetchShardingFile
24
+ ).catch((err) => {
25
+ this.log(`loadData error: `, res, key);
26
+ throw err;
27
+ });
28
+ this.shardingDataMap.set(scope, task);
29
+ }
30
+ res = await this.shardingDataMap.get(scope);
31
+ }
32
+ return rest.length > 0 ? get(res, this.joinKeys(rest)) : res;
33
+ });
34
+ }
35
+ async loadAPI(...args) {
36
+ const [api, body] = args;
37
+ const key = body ? `${api}_${JSON.stringify(body)}` : `${api}`;
38
+ return this.limit(key, async () => {
39
+ return this.loader.loadAPI(...args);
40
+ });
41
+ }
42
+ dispose() {
43
+ super.dispose();
44
+ }
45
+ onDataUpdate() {
46
+ }
47
+ removeOnDataUpdate() {
48
+ }
49
+ }
50
+ export {
51
+ RemoteDataLoader
52
+ };
@@ -0,0 +1,33 @@
1
+ /// <reference types="react" />
2
+ import { Common } from '@rsdoctor/types';
3
+ import { UploadFile } from 'antd';
4
+ import { FieldDataNode } from 'rc-tree';
5
+ export type DataNode = FieldDataNode<{
6
+ key: string | number;
7
+ title?: React.ReactNode | ((data: DataNode) => React.ReactNode);
8
+ }> & {
9
+ __BASENAME__?: any;
10
+ __RESOURCEPATH__?: any;
11
+ children?: DataNode[];
12
+ };
13
+ export declare const rootDirname: (file: string, sep?: string) => string | null;
14
+ export declare function mapFileKey(arr: DataNode[], depth?: number, filter?: (node: DataNode) => boolean): DataNode['key'][];
15
+ export declare function flattenDirectory(n: DataNode, parent: DataNode, sep: string | undefined, inlinedResourcePathKey: keyof DataNode, dirTitle?: (_dir: DataNode, defaultTitle: string) => JSX.Element | string): void;
16
+ export declare function createFileStructures({ files, sep, inlinedResourcePathKey, fileTitle, dirTitle, }: {
17
+ files: string[];
18
+ cwd?: string;
19
+ sep?: string;
20
+ inlinedResourcePathKey?: keyof DataNode;
21
+ dirTitle?(dir: DataNode, defaultTitle: string): JSX.Element | string;
22
+ fileTitle?(file: string, basename: string): JSX.Element | string;
23
+ }): DataNode[];
24
+ export declare function beautifyPath(path: string, cwd: string): string;
25
+ export declare function readJSONByFileReader<T extends Common.PlainObject>(file: UploadFile): Promise<T>;
26
+ export declare function readJSONByFileReader<T extends Common.PlainObject>(file: Blob): Promise<T>;
27
+ /**
28
+ * beautify module path, will replace cwd & last 'node_modules'
29
+ */
30
+ export declare function beautifyModulePath(modulePath: string, cwd: string): {
31
+ alias: string;
32
+ inNodeModules: boolean;
33
+ };
@@ -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?.indexOf(sep);
5
+ if (idx === -1) {
6
+ return null;
7
+ }
8
+ if (idx === 0) {
9
+ return sep + (rootDirname(file?.slice(1)) || "");
10
+ }
11
+ return 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?.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,31 @@
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.RsdoctorManifest): string;
14
+ export declare function useHashByManifest(manifest: Manifest.RsdoctorManifest): string;
15
+ export declare function useCloudManifestUrlByManifest(manifest: Manifest.RsdoctorManifest | Manifest.RsdoctorManifestWithShardingFiles | void): void;
16
+ export declare function useChunkGraphByManifest(manifest: Manifest.RsdoctorManifest): SDK.ChunkGraphData;
17
+ export declare function useConfigOutputFileNameByManifest(manifest: Manifest.RsdoctorManifest): string;
18
+ export declare function useModuleGraphByManifest(manifest: Manifest.RsdoctorManifest): SDK.ModuleGraphData;
19
+ export declare function useModuleGraph(moduleGraph: SDK.ModuleGraphData): SDK.ModuleGraphData;
20
+ export declare function usePackageGraphByManifest(manifest: Manifest.RsdoctorManifest): SDK.PackageGraphData;
21
+ export declare function useUniqModulesByManifest(manifest: Manifest.RsdoctorManifest): SDK.ModuleData[];
22
+ export declare function useUniqModules(modules: SDK.ModuleData[]): SDK.ModuleData[];
23
+ export declare function useErrorsByManifest(manifest: Manifest.RsdoctorManifest): Rule.RuleStoreData;
24
+ export declare function useBundleAlertsByManifest(manifest: Manifest.RsdoctorManifest): Rule.RuleStoreDataItem[];
25
+ export declare function useDuplicatePackagesByManifest(manifest: Manifest.RsdoctorManifest): Rule.PackageRelationDiffRuleStoreData[];
26
+ export declare function useCompileAlertsByErrors(errors: Manifest.RsdoctorManifestData['errors']): Rule.RuleStoreDataItem[];
27
+ export declare function useBundleAlertsByErrors(errors: Manifest.RsdoctorManifestData['errors']): Rule.RuleStoreDataItem[];
28
+ export declare function useDuplicatePackagesByErrors(errors: Manifest.RsdoctorManifestData['errors']): Rule.PackageRelationDiffRuleStoreData[];
29
+ export declare function useWebpackConfigurationByConfigs(configs?: SDK.ConfigData): SDK.WebpackConfigData | null | undefined;
30
+ export declare function useDetectIfCloudIdeEnv(): boolean;
31
+ export declare function useWindowWidth(): number;