@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,130 @@
1
+ import axios from "axios";
2
+ import { Manifest, SDK } from "@rsdoctor/types";
3
+ import { Manifest as ManifestMethod, Url } from "@rsdoctor/utils/common";
4
+ import { APILoaderMode4Dev } from "../constants";
5
+ import { getManifestUrlFromUrlQuery } from "./url";
6
+ import { getAPILoaderModeFromStorage } from "./storage";
7
+ function random() {
8
+ return `${Date.now()}${Math.floor(Math.random() * 1e4)}`;
9
+ }
10
+ async function fetchShardingFile(url) {
11
+ if (Url.isUrl(url)) {
12
+ return axios.get(url, { timeout: 999999, responseType: "text" }).then((e) => e.data);
13
+ }
14
+ return url;
15
+ }
16
+ async function loadManifestByUrl(url) {
17
+ const json = await fetchJSONByUrl(url);
18
+ const res = await parseManifest(json);
19
+ return res;
20
+ }
21
+ async function fetchJSONByUrl(url) {
22
+ let json = await axios.get(url, { timeout: 3e4 }).then((e) => e.data);
23
+ if (typeof json === "string") {
24
+ json = JSON.parse(json);
25
+ }
26
+ console.log("[json] ", url, json);
27
+ return json;
28
+ }
29
+ function fetchJSONByUrls(urls) {
30
+ return Promise.all(urls.map((url) => fetchJSONByUrl(url)));
31
+ }
32
+ async function parseManifest(json) {
33
+ let transformedData;
34
+ try {
35
+ if (json.cloudData) {
36
+ try {
37
+ transformedData = await ManifestMethod.fetchShardingFiles(
38
+ json.cloudData,
39
+ fetchShardingFile
40
+ );
41
+ } catch (error) {
42
+ console.log("cloudData load error: ", error);
43
+ }
44
+ } else {
45
+ transformedData = await ManifestMethod.fetchShardingFiles(
46
+ json.data,
47
+ fetchShardingFile
48
+ );
49
+ }
50
+ } catch (error) {
51
+ transformedData = await ManifestMethod.fetchShardingFiles(
52
+ json.data,
53
+ fetchShardingFile
54
+ );
55
+ }
56
+ return {
57
+ ...json,
58
+ data: transformedData
59
+ };
60
+ }
61
+ const manifestUrlForDev = "/manifest.json";
62
+ function getManifestUrl() {
63
+ let file;
64
+ if (window[Manifest.RsdoctorManifestClientConstant.WindowPropertyForManifestUrl]) {
65
+ file = window[Manifest.RsdoctorManifestClientConstant.WindowPropertyForManifestUrl];
66
+ } else {
67
+ file = getManifestUrlFromUrlQuery();
68
+ }
69
+ if (!file) {
70
+ if (process.env.NODE_ENV === "development") {
71
+ file = manifestUrlForDev;
72
+ } else {
73
+ file = SDK.ServerAPI.API.Manifest;
74
+ }
75
+ }
76
+ return file;
77
+ }
78
+ const pool = /* @__PURE__ */ new Map();
79
+ async function fetchManifest(url = getManifestUrl()) {
80
+ if (!pool.has(url)) {
81
+ pool.set(
82
+ url,
83
+ fetchJSONByUrl(url).catch((err) => {
84
+ pool.delete(url);
85
+ throw err;
86
+ })
87
+ );
88
+ }
89
+ const res = await pool.get(url);
90
+ return res;
91
+ }
92
+ if (process.env.NODE_ENV === "development") {
93
+ if (getAPILoaderModeFromStorage() === APILoaderMode4Dev.Local) {
94
+ axios.interceptors.request.use((c) => {
95
+ c.withCredentials = false;
96
+ if (c.url?.startsWith("/")) {
97
+ if (c.url === manifestUrlForDev) {
98
+ c.url = SDK.ServerAPI.API.Manifest;
99
+ }
100
+ const url = new URL(location.href);
101
+ url.port = String(process.env.LOCAL_CLI_PORT);
102
+ return {
103
+ ...c,
104
+ url: `${url.origin}${c.url}`
105
+ };
106
+ }
107
+ return c;
108
+ });
109
+ }
110
+ }
111
+ async function postServerAPI(...args) {
112
+ const [api, body] = args;
113
+ const timeout = process.env.NODE_ENV === "development" ? 1e4 : 6e4;
114
+ const { data } = await axios.post(
115
+ `${api}?_t=${random()}`,
116
+ body,
117
+ { timeout }
118
+ );
119
+ return data;
120
+ }
121
+ export {
122
+ fetchJSONByUrl,
123
+ fetchJSONByUrls,
124
+ fetchManifest,
125
+ fetchShardingFile,
126
+ getManifestUrl,
127
+ loadManifestByUrl,
128
+ parseManifest,
129
+ postServerAPI
130
+ };
@@ -0,0 +1,3 @@
1
+ import { Manifest } from '@rsdoctor/types';
2
+ export declare function hasCompile(routes: Manifest.RsdoctorManifestClientRoutes[]): boolean;
3
+ export declare function hasBundle(routes: Manifest.RsdoctorManifestClientRoutes[]): boolean;
@@ -0,0 +1,14 @@
1
+ import { includes } from "lodash-es";
2
+ import { Manifest } from "@rsdoctor/types";
3
+ function hasCompile(routes) {
4
+ const hasCompile2 = includes(routes, Manifest.RsdoctorManifestClientRoutes.WebpackLoaders) || includes(routes, Manifest.RsdoctorManifestClientRoutes.ModuleResolve) || includes(routes, Manifest.RsdoctorManifestClientRoutes.WebpackPlugins);
5
+ return hasCompile2;
6
+ }
7
+ function hasBundle(routes) {
8
+ const hasBundle2 = includes(routes, Manifest.RsdoctorManifestClientRoutes.BundleSize) || includes(routes, Manifest.RsdoctorManifestClientRoutes.ModuleGraph) || includes(routes, Manifest.RsdoctorManifestClientRoutes.TreeShaking);
9
+ return hasBundle2;
10
+ }
11
+ export {
12
+ hasBundle,
13
+ hasCompile
14
+ };
@@ -0,0 +1,2 @@
1
+ export declare function formatSize(bytes: number): string;
2
+ export declare function formatPercent(percent: number): string;
@@ -0,0 +1,24 @@
1
+ function formatSize(bytes) {
2
+ let res;
3
+ if (bytes >= 1073741824) {
4
+ res = `${(bytes / 1073741824).toFixed(2)} GB`;
5
+ } else if (bytes >= 1048576) {
6
+ res = `${(bytes / 1048576).toFixed(2)} MB`;
7
+ } else if (bytes >= 1e3) {
8
+ res = `${(bytes / 1e3).toFixed(2)} KB`;
9
+ } else if (bytes > 1) {
10
+ res = `${bytes} bytes`;
11
+ } else if (bytes === 1) {
12
+ res = `${bytes} byte`;
13
+ } else {
14
+ res = "0 bytes";
15
+ }
16
+ return res;
17
+ }
18
+ function formatPercent(percent) {
19
+ return `${+percent.toFixed(2)}%`;
20
+ }
21
+ export {
22
+ formatPercent,
23
+ formatSize
24
+ };
@@ -0,0 +1,2 @@
1
+ import { Socket } from 'socket.io-client';
2
+ export declare function getSocket(): Socket;
@@ -0,0 +1,21 @@
1
+ import { io } from "socket.io-client";
2
+ const map = /* @__PURE__ */ new Map();
3
+ const socketProtocol = location.protocol.includes("https") ? "wss" : "ws";
4
+ const defaultSocketUrl = process.env.NODE_ENV === "development" ? `${socketProtocol}://${location.hostname}:${process.env.LOCAL_CLI_PORT}` : `${socketProtocol}://${location.host}`;
5
+ function ensureSocket(socketUrl = defaultSocketUrl) {
6
+ if (!map.has(socketUrl)) {
7
+ const socket = io(socketUrl, {});
8
+ socket.on("connect", () => {
9
+ console.log(`Scoket Connect ${socketUrl}`);
10
+ });
11
+ map.set(socketUrl, socket);
12
+ }
13
+ return map.get(socketUrl);
14
+ }
15
+ function getSocket() {
16
+ const socket = ensureSocket(defaultSocketUrl);
17
+ return socket;
18
+ }
19
+ export {
20
+ getSocket
21
+ };
@@ -0,0 +1,13 @@
1
+ import type { Config } from '../config';
2
+ import { APILoaderMode4Dev } from '../constants';
3
+ export declare function getStorage(key: string): string | null;
4
+ export declare function setStorage(key: string, value: string): boolean;
5
+ export declare function getThemeFromStorage(): Config['theme'];
6
+ export declare function setThemeToStorage(theme: Config['theme']): void;
7
+ export declare function getLocaleFromStorage(): Config['locale'];
8
+ export declare function setLocaleToStorage(locale: Config['locale']): void;
9
+ export declare function getViewModeFromStorage(): Config['viewMode'];
10
+ export declare function setViewModeToStorage(viewMode: Config['viewMode']): void;
11
+ export declare function hasViewModeFromStorage(): boolean;
12
+ export declare function setAPILoaderModeToStorage(mode: APILoaderMode4Dev): void;
13
+ export declare function getAPILoaderModeFromStorage(): string;
@@ -0,0 +1,70 @@
1
+ import { APILoaderMode4Dev, Language, Theme, ViewMode } from "../constants";
2
+ var Keys = /* @__PURE__ */ ((Keys2) => {
3
+ Keys2["Namespace"] = "__RSDOCTOR__STORAGE__";
4
+ Keys2["Theme"] = "THEME";
5
+ Keys2["Locale"] = "LOCALE";
6
+ Keys2["ViewMode"] = "VIEWMODE";
7
+ Keys2["APILoaderMode4Dev"] = "APILOADERMODE_DEV";
8
+ return Keys2;
9
+ })(Keys || {});
10
+ function getStorage(key) {
11
+ return window.localStorage.getItem(`${"__RSDOCTOR__STORAGE__" /* Namespace */}${key}`);
12
+ }
13
+ function setStorage(key, value) {
14
+ try {
15
+ window.localStorage.setItem(`${"__RSDOCTOR__STORAGE__" /* Namespace */}${key}`, value);
16
+ return true;
17
+ } catch (error) {
18
+ console.error(error);
19
+ return false;
20
+ }
21
+ }
22
+ function getThemeFromStorage() {
23
+ return getStorage("THEME" /* Theme */) || Theme.Light;
24
+ }
25
+ function setThemeToStorage(theme) {
26
+ setStorage("THEME" /* Theme */, theme);
27
+ }
28
+ function getLocaleFromStorage() {
29
+ return getStorage("LOCALE" /* Locale */) || Language.En;
30
+ }
31
+ function setLocaleToStorage(locale) {
32
+ setStorage("LOCALE" /* Locale */, locale);
33
+ }
34
+ function getViewModeFromStorage() {
35
+ const fallback = { bundleAlerts: ViewMode.List, compileAlerts: ViewMode.List };
36
+ try {
37
+ const str = getStorage("VIEWMODE" /* ViewMode */);
38
+ if (str) {
39
+ return JSON.parse(str) || fallback;
40
+ }
41
+ return fallback;
42
+ } catch (error) {
43
+ return fallback;
44
+ }
45
+ }
46
+ function setViewModeToStorage(viewMode) {
47
+ setStorage("VIEWMODE" /* ViewMode */, JSON.stringify(viewMode));
48
+ }
49
+ function hasViewModeFromStorage() {
50
+ return !!getStorage("VIEWMODE" /* ViewMode */);
51
+ }
52
+ function setAPILoaderModeToStorage(mode) {
53
+ setStorage("APILOADERMODE_DEV" /* APILoaderMode4Dev */, mode);
54
+ }
55
+ function getAPILoaderModeFromStorage() {
56
+ return getStorage("APILOADERMODE_DEV" /* APILoaderMode4Dev */) || APILoaderMode4Dev.Default;
57
+ }
58
+ export {
59
+ getAPILoaderModeFromStorage,
60
+ getLocaleFromStorage,
61
+ getStorage,
62
+ getThemeFromStorage,
63
+ getViewModeFromStorage,
64
+ hasViewModeFromStorage,
65
+ setAPILoaderModeToStorage,
66
+ setLocaleToStorage,
67
+ setStorage,
68
+ setThemeToStorage,
69
+ setViewModeToStorage
70
+ };
@@ -0,0 +1,2 @@
1
+ export declare function ensurePrefix(str: string, prefix: string): string;
2
+ export declare function removePrefix(str: string, prefix: string): string;
@@ -0,0 +1,14 @@
1
+ function ensurePrefix(str, prefix) {
2
+ return str.slice(0, prefix.length) === prefix ? str : `${str}${prefix}`;
3
+ }
4
+ function removePrefix(str, prefix) {
5
+ let res = str;
6
+ while (res.slice(0, prefix.length) === prefix) {
7
+ res = res.slice(prefix.length);
8
+ }
9
+ return res;
10
+ }
11
+ export {
12
+ ensurePrefix,
13
+ removePrefix
14
+ };
@@ -0,0 +1,3 @@
1
+ import { Time } from '@rsdoctor/utils/common';
2
+ declare const toFixedDigits: typeof Time.toFixedDigits, getUnit: typeof Time.getUnit, formatCosts: typeof Time.formatCosts;
3
+ export { toFixedDigits as toFixed, getUnit, formatCosts };
@@ -0,0 +1,7 @@
1
+ import { Time } from "@rsdoctor/utils/common";
2
+ const { toFixedDigits, getUnit, formatCosts } = Time;
3
+ export {
4
+ formatCosts,
5
+ getUnit,
6
+ toFixedDigits as toFixed
7
+ };
@@ -0,0 +1,7 @@
1
+ export declare function isJsDataUrl(path: string): boolean;
2
+ export declare function getManifestUrlFromUrlQuery(): string | void;
3
+ export declare function changeOrigin(origin: string): string;
4
+ export declare function getSharingUrl(manifestCloudUrl: string): string;
5
+ export declare function getDemoUrl(): string | null;
6
+ export declare const getShortPath: (path: string) => string;
7
+ export declare function isDef<E = unknown>(data: E): data is NonNullable<E>;
@@ -0,0 +1,75 @@
1
+ import parse from "url-parse";
2
+ import { Constants, Client } from "@rsdoctor/types";
3
+ import { endsWith } from "lodash-es";
4
+ function setDefaultUrl(url) {
5
+ if (process.env.NODE_ENV !== "development") {
6
+ const uri = parse(Constants.RsdoctorClientUrl, true);
7
+ url.set("origin", uri.origin);
8
+ url.set("protocol", uri.protocol);
9
+ url.set("host", uri.host);
10
+ url.set("pathname", uri.pathname);
11
+ }
12
+ }
13
+ function setUploaderHash(url) {
14
+ if (endsWith(url.hash, Client.RsdoctorClientRoutes.Uploader)) {
15
+ url.set("hash", Client.RsdoctorClientRoutes.Overall);
16
+ }
17
+ }
18
+ function isJsDataUrl(path) {
19
+ return path.startsWith("data:text/javascript;");
20
+ }
21
+ function getManifestUrlFromUrlQuery() {
22
+ const { query } = parse(location.href, true);
23
+ const url = query[Client.RsdoctorClientUrlQuery.ManifestFile];
24
+ if (url) {
25
+ return decodeURIComponent(url);
26
+ }
27
+ }
28
+ function changeOrigin(origin) {
29
+ const url = parse(location.href, true);
30
+ const newUrl = parse(origin, true);
31
+ setUploaderHash(url);
32
+ url.set("origin", origin);
33
+ url.set("protocol", newUrl.protocol);
34
+ url.set("host", newUrl.host);
35
+ url.set("port", newUrl.port);
36
+ return url.toString();
37
+ }
38
+ function getSharingUrl(manifestCloudUrl) {
39
+ const url = parse(location.href, true);
40
+ setDefaultUrl(url);
41
+ setUploaderHash(url);
42
+ url.set("query", {
43
+ ...url.query,
44
+ [Client.RsdoctorClientUrlQuery.ManifestFile]: manifestCloudUrl
45
+ });
46
+ return url.toString();
47
+ }
48
+ function getDemoUrl() {
49
+ if (process.env.OFFICAL_DEMO_MANIFEST_PATH) {
50
+ return getSharingUrl(process.env.OFFICAL_DEMO_MANIFEST_PATH);
51
+ }
52
+ return null;
53
+ }
54
+ const getShortPath = (path) => {
55
+ if (path?.indexOf("node_modules") >= 0) {
56
+ const pathArr = path.split("node_modules");
57
+ return `node_modules${pathArr[pathArr.length - 1]}`;
58
+ }
59
+ if (path?.length) {
60
+ return `${path?.split("/").slice(-4).join("/")}`;
61
+ }
62
+ return path;
63
+ };
64
+ function isDef(data) {
65
+ return data !== void 0 && data !== null;
66
+ }
67
+ export {
68
+ changeOrigin,
69
+ getDemoUrl,
70
+ getManifestUrlFromUrlQuery,
71
+ getSharingUrl,
72
+ getShortPath,
73
+ isDef,
74
+ isJsDataUrl
75
+ };
@@ -0,0 +1,4 @@
1
+ export * from './utils';
2
+ export * from './types';
3
+ export * from './master';
4
+ export * from './worker';
@@ -0,0 +1,4 @@
1
+ export * from "./utils";
2
+ export * from "./types";
3
+ export * from "./master";
4
+ export * from "./worker";
@@ -0,0 +1,8 @@
1
+ import { CreateWorker } from './types';
2
+ import { ChildWorker } from './worker';
3
+ declare class Master {
4
+ private _workerMap;
5
+ detectWorker(create: CreateWorker): ChildWorker;
6
+ }
7
+ export declare const master: Master;
8
+ export {};
@@ -0,0 +1,18 @@
1
+ import { ChildWorker } from "./worker";
2
+ class Master {
3
+ constructor() {
4
+ this._workerMap = /* @__PURE__ */ new WeakMap();
5
+ }
6
+ detectWorker(create) {
7
+ if (this._workerMap.has(create))
8
+ return this._workerMap.get(create);
9
+ const worker = create();
10
+ const child = new ChildWorker(worker);
11
+ this._workerMap.set(create, child);
12
+ return child;
13
+ }
14
+ }
15
+ const master = new Master();
16
+ export {
17
+ master
18
+ };
@@ -0,0 +1,9 @@
1
+ export type CreateWorker = () => Worker;
2
+ export type NativeWorkerMessage<T = unknown> = MessageEvent<WorkerMessage<T>>;
3
+ export type WorkerMessage<T = unknown> = {
4
+ id: number | string;
5
+ data: T;
6
+ };
7
+ export type InternalWorkerEventCallback<T> = (message: WorkerMessage<T>) => unknown;
8
+ export type UserWorkerEventCallback<T = unknown> = (data: T) => unknown;
9
+ export type UserWorkerEventHandler<T = unknown, R = unknown> = (data: T) => R | Promise<R>;
File without changes
@@ -0,0 +1,7 @@
1
+ import { NativeWorkerMessage, UserWorkerEventHandler, WorkerMessage } from './types';
2
+ export declare function sendMessageInClient<T>(msg: WorkerMessage<T>, worker: Worker): void;
3
+ export declare function sendMessageInWorker<T>(receivedMsg: NativeWorkerMessage, response: T): void;
4
+ export declare function handleMessageInWorker<T, R>({ handler, }: {
5
+ workerName: string;
6
+ handler: UserWorkerEventHandler<T, R>;
7
+ }): void;
@@ -0,0 +1,29 @@
1
+ function sendMessageInClient(msg, worker) {
2
+ return worker.postMessage(msg);
3
+ }
4
+ function sendMessageInWorker(receivedMsg, response) {
5
+ const msg = {
6
+ id: receivedMsg.data.id,
7
+ data: response
8
+ };
9
+ return postMessage(msg);
10
+ }
11
+ function handleMessageInWorker({
12
+ handler
13
+ }) {
14
+ onmessage = (e) => {
15
+ const res = handler(e.data.data);
16
+ if (res instanceof Promise) {
17
+ res.then((r) => {
18
+ sendMessageInWorker(e, r);
19
+ });
20
+ } else {
21
+ sendMessageInWorker(e, res);
22
+ }
23
+ };
24
+ }
25
+ export {
26
+ handleMessageInWorker,
27
+ sendMessageInClient,
28
+ sendMessageInWorker
29
+ };
@@ -0,0 +1,13 @@
1
+ import { UserWorkerEventCallback } from './types';
2
+ export declare class ChildWorker {
3
+ protected worker: Worker;
4
+ private timer;
5
+ private callbacks;
6
+ constructor(worker: Worker);
7
+ protected setup(): void;
8
+ protected createEventId(): string;
9
+ emit<T, P = unknown>(data: P, callback: UserWorkerEventCallback<T>): {
10
+ abort: () => boolean;
11
+ };
12
+ dispose(): void;
13
+ }
@@ -0,0 +1,38 @@
1
+ import { sendMessageInClient } from "./utils";
2
+ class ChildWorker {
3
+ constructor(worker) {
4
+ this.worker = worker;
5
+ this.timer = 0;
6
+ this.callbacks = /* @__PURE__ */ new Map();
7
+ this.setup();
8
+ }
9
+ setup() {
10
+ this.worker.onmessage = (msg) => {
11
+ const { data } = msg;
12
+ if (this.callbacks.has(data.id)) {
13
+ const fn = this.callbacks.get(data.id);
14
+ this.callbacks.delete(data.id);
15
+ fn(data.data);
16
+ }
17
+ };
18
+ }
19
+ createEventId() {
20
+ return `${Date.now()}_${++this.timer}`;
21
+ }
22
+ emit(data, callback) {
23
+ const id = this.createEventId();
24
+ const msg = {
25
+ id,
26
+ data
27
+ };
28
+ this.callbacks.set(id, callback);
29
+ sendMessageInClient(msg, this.worker);
30
+ return { abort: () => this.callbacks.delete(id) };
31
+ }
32
+ dispose() {
33
+ this.worker.terminate();
34
+ }
35
+ }
36
+ export {
37
+ ChildWorker
38
+ };
package/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "@rsdoctor/components",
3
+ "version": "0.0.0-next-20240620044732",
4
+ "main": "./dist/index.js",
5
+ "license": "MIT",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/web-infra-dev/rsdoctor",
11
+ "directory": "packages/components"
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./elements": {
22
+ "types": "./dist/components/index.d.ts",
23
+ "default": "./dist/components/index.js"
24
+ },
25
+ "./pages": {
26
+ "types": "./dist/pages/index.d.ts",
27
+ "default": "./dist/pages/index.js"
28
+ },
29
+ "./utils": {
30
+ "types": "./dist/utils/index.d.ts",
31
+ "default": "./dist/utils/index.js"
32
+ },
33
+ "./i18n": {
34
+ "types": "./dist/utils/i18n/index.d.ts",
35
+ "default": "./dist/utils/i18n/index.js"
36
+ },
37
+ "./config": {
38
+ "types": "./dist/config.d.ts",
39
+ "default": "./dist/config.js"
40
+ }
41
+ },
42
+ "eslintIgnore": [
43
+ "node_modules/",
44
+ "dist/"
45
+ ],
46
+ "devDependencies": {
47
+ "@ant-design/icons": "4.8.0",
48
+ "@monaco-editor/react": "4.6.0",
49
+ "@types/lodash-es": "4.17.6",
50
+ "@types/node": "^16",
51
+ "@types/path-browserify": "1.0.1",
52
+ "@types/react": "^18",
53
+ "@types/react-highlight-words": "^0.16.7",
54
+ "@types/url-parse": "1.4.8",
55
+ "ansi-to-react": "6.1.6",
56
+ "antd": "5.15.3",
57
+ "axios": "^1.7.2",
58
+ "dayjs": "1.11.6",
59
+ "echarts": "^5.5.0",
60
+ "echarts-for-react": "^3.0.2",
61
+ "i18next": "22.0.4",
62
+ "lodash-es": "4.17.21",
63
+ "monaco-editor": "0.49.0",
64
+ "path-browserify": "1.0.1",
65
+ "rc-dialog": "9.1.0",
66
+ "rc-tree": "5.7.2",
67
+ "react": "18.2.0",
68
+ "react-highlight-words": "^0.20.0",
69
+ "react-hyper-tree": "0.3.12",
70
+ "react-i18next": "12.0.0",
71
+ "react-json-view": "1.21.3",
72
+ "react-markdown": "^9.0.1",
73
+ "react-router-dom": "6.4.3",
74
+ "socket.io-client": "4.6.1",
75
+ "terser": "^5.26.0",
76
+ "typescript": "^5.2.2",
77
+ "url-parse": "1.5.10",
78
+ "@rsdoctor/graph": "0.0.0-next-20240620044732",
79
+ "@rsdoctor/types": "0.0.0-next-20240620044732",
80
+ "@rsdoctor/utils": "0.0.0-next-20240620044732"
81
+ },
82
+ "publishConfig": {
83
+ "access": "public",
84
+ "registry": "https://registry.npmjs.org/"
85
+ },
86
+ "scripts": {
87
+ "build": "modern build",
88
+ "dev": "npm run start",
89
+ "start": "modern build -w",
90
+ "test": "vitest run"
91
+ }
92
+ }