@rsdoctor/core 1.6.1 → 2.0.0-alpha.1

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 (411) hide show
  1. package/dist/build-utils/build/chunks/assetsModules.d.ts +1 -1
  2. package/dist/build-utils/build/chunks/assetsModules.js +1 -1
  3. package/dist/build-utils/build/chunks/index.d.ts +0 -1
  4. package/dist/build-utils/build/chunks/index.js +0 -1
  5. package/dist/build-utils/build/chunks/rspack/transform.d.ts +1 -1
  6. package/dist/build-utils/build/chunks/rspack/transform.js +1 -1
  7. package/dist/build-utils/build/envinfo.d.ts +13 -0
  8. package/dist/build-utils/build/envinfo.js +60 -0
  9. package/dist/build-utils/build/file/cache.d.ts +5 -0
  10. package/dist/build-utils/build/file/cache.js +24 -0
  11. package/dist/build-utils/build/file/index.d.ts +3 -0
  12. package/dist/build-utils/build/file/index.js +5 -0
  13. package/dist/build-utils/build/file/sharding.d.ts +21 -0
  14. package/dist/build-utils/build/file/sharding.js +38 -0
  15. package/dist/build-utils/build/index.d.ts +5 -0
  16. package/dist/build-utils/build/index.js +11 -6
  17. package/dist/build-utils/build/json.d.ts +3 -0
  18. package/dist/build-utils/build/json.js +67 -0
  19. package/dist/build-utils/build/loader/probeLoader.d.ts +2 -2
  20. package/dist/build-utils/build/loader/probeLoader.js +4 -4
  21. package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts +1 -1
  22. package/dist/build-utils/build/loader/probeLoaderPlugin.js +1 -1
  23. package/dist/build-utils/build/module-graph/index.d.ts +0 -3
  24. package/dist/build-utils/build/module-graph/index.js +0 -3
  25. package/dist/build-utils/build/module-graph/parser.d.ts +1 -1
  26. package/dist/build-utils/build/module-graph/parser.js +1 -1
  27. package/dist/build-utils/build/module-graph/rspack/transform.d.ts +1 -1
  28. package/dist/build-utils/build/module-graph/rspack/transform.js +7 -5
  29. package/dist/build-utils/build/module-graph/utils.d.ts +1 -1
  30. package/dist/build-utils/build/module-graph/utils.js +5 -4
  31. package/dist/build-utils/build/process.d.ts +2 -0
  32. package/dist/build-utils/build/process.js +18 -0
  33. package/dist/build-utils/build/server.d.ts +15 -0
  34. package/dist/build-utils/build/server.js +107 -0
  35. package/dist/build-utils/build/utils/loader.d.ts +2 -2
  36. package/dist/build-utils/build/utils/loader.js +10 -19
  37. package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
  38. package/dist/build-utils/build/utils/parseBundle.js +6 -8
  39. package/dist/build-utils/build/utils/plugin.d.ts +1 -1
  40. package/dist/build-utils/build/utils/plugin.js +1 -2
  41. package/dist/build-utils/index.d.ts +10 -0
  42. package/dist/build-utils/index.js +12 -2
  43. package/dist/collection.d.ts +1 -0
  44. package/dist/collection.js +2 -0
  45. package/dist/common/file.d.ts +2 -0
  46. package/dist/common/file.js +8 -0
  47. package/dist/common/global-config.d.ts +21 -0
  48. package/dist/common/global-config.js +33 -0
  49. package/dist/common/index.d.ts +4 -0
  50. package/dist/common/index.js +6 -0
  51. package/dist/common-browser.d.ts +1 -0
  52. package/dist/common-browser.js +2 -0
  53. package/dist/error/error.d.ts +35 -0
  54. package/dist/error/error.js +143 -0
  55. package/dist/error/index.d.ts +2 -0
  56. package/dist/error/index.js +3 -0
  57. package/dist/error/transform.d.ts +3 -0
  58. package/dist/error/transform.js +138 -0
  59. package/dist/error/utils.d.ts +4 -0
  60. package/dist/error/utils.js +23 -0
  61. package/dist/graph/index.d.ts +1 -0
  62. package/dist/graph/index.js +2 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +4 -2
  65. package/dist/inner-plugins/constants.d.ts +1 -1
  66. package/dist/inner-plugins/constants.js +1 -1
  67. package/dist/inner-plugins/loaders/proxy.d.ts +4 -4
  68. package/dist/inner-plugins/plugins/base.d.ts +1 -1
  69. package/dist/inner-plugins/plugins/bundle.d.ts +1 -1
  70. package/dist/inner-plugins/plugins/bundle.js +4 -20
  71. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +6 -8
  72. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +12 -77
  73. package/dist/inner-plugins/plugins/errors.d.ts +3 -3
  74. package/dist/inner-plugins/plugins/errors.js +6 -6
  75. package/dist/inner-plugins/plugins/index.d.ts +0 -1
  76. package/dist/inner-plugins/plugins/index.js +0 -1
  77. package/dist/inner-plugins/plugins/loader.d.ts +1 -1
  78. package/dist/inner-plugins/plugins/loader.js +8 -20
  79. package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
  80. package/dist/inner-plugins/plugins/plugins.js +3 -3
  81. package/dist/inner-plugins/plugins/progress.d.ts +3 -3
  82. package/dist/inner-plugins/plugins/progress.js +16 -18
  83. package/dist/inner-plugins/plugins/resolver.d.ts +2 -3
  84. package/dist/inner-plugins/plugins/resolver.js +2 -2
  85. package/dist/inner-plugins/plugins/rspack.d.ts +8 -3
  86. package/dist/inner-plugins/plugins/rspack.js +18 -4
  87. package/dist/inner-plugins/plugins/rules.d.ts +1 -1
  88. package/dist/inner-plugins/plugins/rules.js +6 -6
  89. package/dist/inner-plugins/plugins/sourcemapTool.d.ts +2 -2
  90. package/dist/inner-plugins/plugins/sourcemapTool.js +2 -2
  91. package/dist/inner-plugins/plugins/summary.d.ts +1 -1
  92. package/dist/inner-plugins/plugins/summary.js +3 -3
  93. package/dist/inner-plugins/utils/config.d.ts +3 -4
  94. package/dist/inner-plugins/utils/config.js +4 -17
  95. package/dist/inner-plugins/utils/loader.d.ts +4 -7
  96. package/dist/inner-plugins/utils/loader.js +10 -36
  97. package/dist/inner-plugins/utils/normalize-config.d.ts +4 -7
  98. package/dist/inner-plugins/utils/openBrowser.d.ts +1 -0
  99. package/dist/inner-plugins/utils/openBrowser.js +55 -0
  100. package/dist/inner-plugins/utils/plugin-common.js +4 -4
  101. package/dist/inner-plugins/utils/plugin.d.ts +1 -1
  102. package/dist/inner-plugins/utils/plugin.js +1 -1
  103. package/dist/inner-plugins/utils/sdk.d.ts +2 -3
  104. package/dist/inner-plugins/utils/sdk.js +2 -2
  105. package/dist/logger.d.ts +9 -0
  106. package/dist/logger.js +51 -0
  107. package/dist/{inner-plugins/constants.d.cts → rspack-plugin/constants.d.ts} +4 -1
  108. package/dist/rspack-plugin/constants.js +23 -0
  109. package/dist/rspack-plugin/index.d.ts +2 -0
  110. package/dist/rspack-plugin/index.js +3 -0
  111. package/dist/rspack-plugin/multiple.d.ts +8 -0
  112. package/dist/rspack-plugin/multiple.js +39 -0
  113. package/dist/rspack-plugin/plugin.d.ts +25 -0
  114. package/dist/rspack-plugin/plugin.js +133 -0
  115. package/dist/rule-utils/document/document.d.ts +16 -0
  116. package/dist/rule-utils/document/document.js +46 -0
  117. package/dist/rule-utils/document/index.d.ts +3 -0
  118. package/dist/rule-utils/document/index.js +4 -0
  119. package/dist/rule-utils/document/server.d.ts +4 -0
  120. package/dist/rule-utils/document/server.js +13 -0
  121. package/dist/rule-utils/document/types.d.ts +31 -0
  122. package/dist/rule-utils/index.d.ts +2 -0
  123. package/dist/rule-utils/index.js +3 -0
  124. package/dist/rule-utils/parser/asserts.d.ts +81 -0
  125. package/dist/rule-utils/parser/asserts.js +105 -0
  126. package/dist/rule-utils/parser/index.d.ts +4 -0
  127. package/dist/rule-utils/parser/index.js +5 -0
  128. package/dist/rule-utils/parser/parser.d.ts +118 -0
  129. package/dist/rule-utils/parser/parser.js +24 -0
  130. package/dist/rule-utils/parser/types.d.ts +30 -0
  131. package/dist/rule-utils/parser/types.js +8 -0
  132. package/dist/rule-utils/parser/utils.d.ts +30 -0
  133. package/dist/rule-utils/parser/utils.js +106 -0
  134. package/dist/rules/linter.d.ts +1 -1
  135. package/dist/rules/linter.js +1 -1
  136. package/dist/rules/rule.d.ts +2 -2
  137. package/dist/rules/rule.js +2 -2
  138. package/dist/rules/rules/cjs-require/index.d.ts +1 -1
  139. package/dist/rules/rules/cjs-require/index.js +3 -3
  140. package/dist/rules/rules/cross-chunks-package/index.d.ts +1 -1
  141. package/dist/rules/rules/cross-chunks-package/index.js +2 -2
  142. package/dist/rules/rules/default-import-check/index.d.ts +1 -1
  143. package/dist/rules/rules/default-import-check/index.js +2 -2
  144. package/dist/rules/rules/default-import-check/utils.d.ts +2 -2
  145. package/dist/rules/rules/default-import-check/utils.js +2 -2
  146. package/dist/rules/rules/duplicate-package/index.d.ts +3 -3
  147. package/dist/rules/rules/duplicate-package/index.js +3 -3
  148. package/dist/rules/rules/duplicate-package/utils.d.ts +1 -1
  149. package/dist/rules/rules/ecma-version-check/index.d.ts +3 -2
  150. package/dist/rules/rules/ecma-version-check/index.js +1 -1
  151. package/dist/rules/rules/ecma-version-check/types.d.ts +1 -2
  152. package/dist/rules/rules/ecma-version-check/utils.d.ts +1 -1
  153. package/dist/rules/rules/esm-resolved-to-cjs/index.d.ts +1 -1
  154. package/dist/rules/rules/esm-resolved-to-cjs/index.js +3 -18
  155. package/dist/rules/rules/index.d.ts +1 -1
  156. package/dist/rules/rules/loader-performance-optimization/index.d.ts +1 -1
  157. package/dist/rules/rules/loader-performance-optimization/index.js +3 -3
  158. package/dist/rules/rules/loader-performance-optimization/types.d.ts +1 -1
  159. package/dist/rules/rules/module-mixed-chunks/index.d.ts +1 -1
  160. package/dist/rules/rules/module-mixed-chunks/index.js +2 -2
  161. package/dist/rules/rules/side-effects-only-imports/index.d.ts +1 -1
  162. package/dist/rules/rules/side-effects-only-imports/index.js +2 -2
  163. package/dist/rules/utils.d.ts +1 -1
  164. package/dist/rules/utils.js +1 -1
  165. package/dist/sdk/index.d.ts +2 -0
  166. package/dist/sdk/index.js +3 -0
  167. package/dist/sdk/multiple/controller.d.ts +12 -0
  168. package/dist/sdk/multiple/controller.js +42 -0
  169. package/dist/sdk/multiple/index.d.ts +2 -0
  170. package/dist/sdk/multiple/index.js +3 -0
  171. package/dist/sdk/multiple/primary.d.ts +32 -0
  172. package/dist/sdk/multiple/primary.js +64 -0
  173. package/dist/sdk/multiple/server.d.ts +7 -0
  174. package/dist/sdk/multiple/server.js +14 -0
  175. package/dist/sdk/sdk/core.d.ts +33 -0
  176. package/dist/sdk/sdk/core.js +163 -0
  177. package/dist/sdk/sdk/index.d.ts +52 -0
  178. package/dist/sdk/sdk/index.js +435 -0
  179. package/dist/sdk/sdk/types.d.ts +26 -0
  180. package/dist/sdk/sdk/types.js +1 -0
  181. package/dist/sdk/server/apis/alerts.d.ts +5 -0
  182. package/dist/sdk/server/apis/alerts.js +30 -0
  183. package/dist/sdk/server/apis/base.d.ts +11 -0
  184. package/dist/sdk/server/apis/base.js +22 -0
  185. package/dist/sdk/server/apis/bundle-diff.d.ts +6 -0
  186. package/dist/sdk/server/apis/bundle-diff.js +51 -0
  187. package/dist/sdk/server/apis/data.d.ts +6 -0
  188. package/dist/sdk/server/apis/data.js +44 -0
  189. package/dist/sdk/server/apis/fs.d.ts +5 -0
  190. package/dist/sdk/server/apis/fs.js +28 -0
  191. package/dist/sdk/server/apis/graph.d.ts +12 -0
  192. package/dist/sdk/server/apis/graph.js +116 -0
  193. package/dist/sdk/server/apis/index.d.ts +10 -0
  194. package/dist/sdk/server/apis/index.js +11 -0
  195. package/dist/sdk/server/apis/loader.d.ts +15 -0
  196. package/dist/sdk/server/apis/loader.js +120 -0
  197. package/dist/sdk/server/apis/plugin.d.ts +6 -0
  198. package/dist/sdk/server/apis/plugin.js +39 -0
  199. package/dist/sdk/server/apis/project.d.ts +8 -0
  200. package/dist/sdk/server/apis/project.js +59 -0
  201. package/dist/sdk/server/apis/renderer.d.ts +6 -0
  202. package/dist/sdk/server/apis/renderer.js +33 -0
  203. package/dist/sdk/server/apis/resolver.d.ts +6 -0
  204. package/dist/sdk/server/apis/resolver.js +38 -0
  205. package/dist/sdk/server/client.d.ts +3 -0
  206. package/dist/sdk/server/client.js +8 -0
  207. package/dist/sdk/server/fakeServer.d.ts +9 -0
  208. package/dist/sdk/server/fakeServer.js +12 -0
  209. package/dist/sdk/server/index.d.ts +44 -0
  210. package/dist/sdk/server/index.js +292 -0
  211. package/dist/sdk/server/json-body.d.ts +6 -0
  212. package/dist/sdk/server/json-body.js +150 -0
  213. package/dist/sdk/server/router.d.ts +24 -0
  214. package/dist/sdk/server/router.js +83 -0
  215. package/dist/sdk/server/security.d.ts +5 -0
  216. package/dist/sdk/server/security.js +47 -0
  217. package/dist/sdk/server/socket/api.d.ts +15 -0
  218. package/dist/sdk/server/socket/api.js +22 -0
  219. package/dist/sdk/server/socket/index.d.ts +48 -0
  220. package/dist/sdk/server/socket/index.js +166 -0
  221. package/dist/sdk/server/utils.d.ts +6 -0
  222. package/dist/sdk/server/utils.js +19 -0
  223. package/dist/sdk/utils/base.d.ts +1 -0
  224. package/dist/sdk/utils/base.js +22 -0
  225. package/dist/sdk/utils/constant.d.ts +1 -0
  226. package/dist/sdk/utils/constant.js +4 -0
  227. package/dist/sdk/utils/index.d.ts +3 -0
  228. package/dist/sdk/utils/index.js +4 -0
  229. package/dist/sdk/utils/openBrowser.d.ts +4 -0
  230. package/dist/sdk/utils/openBrowser.js +53 -0
  231. package/dist/sdk/utils/upload.d.ts +2 -0
  232. package/dist/sdk/utils/upload.js +6 -0
  233. package/dist/sdk.d.ts +1 -0
  234. package/dist/sdk.js +2 -0
  235. package/dist/types/index.d.ts +0 -1
  236. package/dist/types/index.js +0 -1
  237. package/dist/types/loader.d.ts +1 -1
  238. package/dist/types/plugin.d.ts +7 -28
  239. package/dist/types/rules.d.ts +4 -4
  240. package/package.json +123 -55
  241. package/static/openChrome.applescript +95 -0
  242. package/dist/build-utils/build/chunks/assetsModules.cjs +0 -46
  243. package/dist/build-utils/build/chunks/assetsModules.d.cts +0 -17
  244. package/dist/build-utils/build/chunks/chunkTransform.cjs +0 -43
  245. package/dist/build-utils/build/chunks/chunkTransform.d.cts +0 -4
  246. package/dist/build-utils/build/chunks/chunkTransform.d.ts +0 -4
  247. package/dist/build-utils/build/chunks/chunkTransform.js +0 -6
  248. package/dist/build-utils/build/chunks/index.cjs +0 -76
  249. package/dist/build-utils/build/chunks/index.d.cts +0 -3
  250. package/dist/build-utils/build/chunks/rspack/transform.cjs +0 -84
  251. package/dist/build-utils/build/chunks/rspack/transform.d.cts +0 -13
  252. package/dist/build-utils/build/index.cjs +0 -56
  253. package/dist/build-utils/build/index.d.cts +0 -5
  254. package/dist/build-utils/build/loader/index.cjs +0 -69
  255. package/dist/build-utils/build/loader/index.d.cts +0 -2
  256. package/dist/build-utils/build/loader/probeLoader.cjs +0 -93
  257. package/dist/build-utils/build/loader/probeLoader.d.cts +0 -4
  258. package/dist/build-utils/build/loader/probeLoaderPlugin.cjs +0 -69
  259. package/dist/build-utils/build/loader/probeLoaderPlugin.d.cts +0 -5
  260. package/dist/build-utils/build/module-graph/index.cjs +0 -83
  261. package/dist/build-utils/build/module-graph/index.d.cts +0 -4
  262. package/dist/build-utils/build/module-graph/parser.cjs +0 -50
  263. package/dist/build-utils/build/module-graph/parser.d.cts +0 -2
  264. package/dist/build-utils/build/module-graph/rspack/transform.cjs +0 -155
  265. package/dist/build-utils/build/module-graph/rspack/transform.d.cts +0 -26
  266. package/dist/build-utils/build/module-graph/transform.cjs +0 -44
  267. package/dist/build-utils/build/module-graph/transform.d.cts +0 -4
  268. package/dist/build-utils/build/module-graph/transform.d.ts +0 -4
  269. package/dist/build-utils/build/module-graph/transform.js +0 -7
  270. package/dist/build-utils/build/module-graph/treeShaking.cjs +0 -110
  271. package/dist/build-utils/build/module-graph/treeShaking.d.cts +0 -2
  272. package/dist/build-utils/build/module-graph/treeShaking.d.ts +0 -2
  273. package/dist/build-utils/build/module-graph/treeShaking.js +0 -73
  274. package/dist/build-utils/build/module-graph/utils.cjs +0 -99
  275. package/dist/build-utils/build/module-graph/utils.d.cts +0 -3
  276. package/dist/build-utils/build/module-graph/webpack/transform.cjs +0 -174
  277. package/dist/build-utils/build/module-graph/webpack/transform.d.cts +0 -16
  278. package/dist/build-utils/build/module-graph/webpack/transform.d.ts +0 -16
  279. package/dist/build-utils/build/module-graph/webpack/transform.js +0 -124
  280. package/dist/build-utils/build/utils/index.cjs +0 -76
  281. package/dist/build-utils/build/utils/index.d.cts +0 -3
  282. package/dist/build-utils/build/utils/loader.cjs +0 -358
  283. package/dist/build-utils/build/utils/loader.d.cts +0 -20
  284. package/dist/build-utils/build/utils/parseBundle.cjs +0 -287
  285. package/dist/build-utils/build/utils/parseBundle.d.cts +0 -12
  286. package/dist/build-utils/build/utils/plugin.cjs +0 -65
  287. package/dist/build-utils/build/utils/plugin.d.cts +0 -5
  288. package/dist/build-utils/index.cjs +0 -40
  289. package/dist/build-utils/index.d.cts +0 -1
  290. package/dist/index.cjs +0 -85
  291. package/dist/index.d.cts +0 -3
  292. package/dist/inner-plugins/constants.cjs +0 -68
  293. package/dist/inner-plugins/index.cjs +0 -69
  294. package/dist/inner-plugins/index.d.cts +0 -2
  295. package/dist/inner-plugins/loaders/proxy.cjs +0 -108
  296. package/dist/inner-plugins/loaders/proxy.d.cts +0 -7
  297. package/dist/inner-plugins/plugins/base.cjs +0 -57
  298. package/dist/inner-plugins/plugins/base.d.cts +0 -12
  299. package/dist/inner-plugins/plugins/bundle.cjs +0 -116
  300. package/dist/inner-plugins/plugins/bundle.d.cts +0 -15
  301. package/dist/inner-plugins/plugins/bundleTagPlugin.cjs +0 -88
  302. package/dist/inner-plugins/plugins/bundleTagPlugin.d.cts +0 -6
  303. package/dist/inner-plugins/plugins/bundleTagPlugin.d.ts +0 -6
  304. package/dist/inner-plugins/plugins/bundleTagPlugin.js +0 -51
  305. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +0 -182
  306. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +0 -36
  307. package/dist/inner-plugins/plugins/errors.cjs +0 -102
  308. package/dist/inner-plugins/plugins/errors.d.cts +0 -11
  309. package/dist/inner-plugins/plugins/index.cjs +0 -132
  310. package/dist/inner-plugins/plugins/index.d.cts +0 -11
  311. package/dist/inner-plugins/plugins/loader.cjs +0 -169
  312. package/dist/inner-plugins/plugins/loader.d.cts +0 -10
  313. package/dist/inner-plugins/plugins/plugins.cjs +0 -77
  314. package/dist/inner-plugins/plugins/plugins.d.cts +0 -8
  315. package/dist/inner-plugins/plugins/progress.cjs +0 -74
  316. package/dist/inner-plugins/plugins/progress.d.cts +0 -8
  317. package/dist/inner-plugins/plugins/resolver.cjs +0 -94
  318. package/dist/inner-plugins/plugins/resolver.d.cts +0 -13
  319. package/dist/inner-plugins/plugins/rspack.cjs +0 -122
  320. package/dist/inner-plugins/plugins/rspack.d.cts +0 -4
  321. package/dist/inner-plugins/plugins/rules.cjs +0 -101
  322. package/dist/inner-plugins/plugins/rules.d.cts +0 -8
  323. package/dist/inner-plugins/plugins/sourcemapTool.cjs +0 -279
  324. package/dist/inner-plugins/plugins/sourcemapTool.d.cts +0 -52
  325. package/dist/inner-plugins/plugins/summary.cjs +0 -129
  326. package/dist/inner-plugins/plugins/summary.d.cts +0 -14
  327. package/dist/inner-plugins/utils/circleDetect.cjs +0 -53
  328. package/dist/inner-plugins/utils/circleDetect.d.cts +0 -4
  329. package/dist/inner-plugins/utils/config.cjs +0 -207
  330. package/dist/inner-plugins/utils/config.d.cts +0 -5
  331. package/dist/inner-plugins/utils/index.cjs +0 -110
  332. package/dist/inner-plugins/utils/index.d.cts +0 -9
  333. package/dist/inner-plugins/utils/loader.cjs +0 -222
  334. package/dist/inner-plugins/utils/loader.d.cts +0 -13
  335. package/dist/inner-plugins/utils/normalize-config.cjs +0 -126
  336. package/dist/inner-plugins/utils/normalize-config.d.cts +0 -40
  337. package/dist/inner-plugins/utils/plugin-common.cjs +0 -147
  338. package/dist/inner-plugins/utils/plugin-common.d.cts +0 -11
  339. package/dist/inner-plugins/utils/plugin.cjs +0 -110
  340. package/dist/inner-plugins/utils/plugin.d.cts +0 -4
  341. package/dist/inner-plugins/utils/sdk.cjs +0 -59
  342. package/dist/inner-plugins/utils/sdk.d.cts +0 -8
  343. package/dist/rslib-runtime.js +0 -19
  344. package/dist/rules/index.cjs +0 -85
  345. package/dist/rules/index.d.cts +0 -3
  346. package/dist/rules/linter.cjs +0 -76
  347. package/dist/rules/linter.d.cts +0 -9
  348. package/dist/rules/rule.cjs +0 -141
  349. package/dist/rules/rule.d.cts +0 -27
  350. package/dist/rules/rules/cjs-require/index.cjs +0 -87
  351. package/dist/rules/rules/cjs-require/index.d.cts +0 -4
  352. package/dist/rules/rules/cjs-require/types.cjs +0 -18
  353. package/dist/rules/rules/cjs-require/types.d.cts +0 -7
  354. package/dist/rules/rules/cross-chunks-package/index.cjs +0 -78
  355. package/dist/rules/rules/cross-chunks-package/index.d.cts +0 -4
  356. package/dist/rules/rules/cross-chunks-package/types.cjs +0 -18
  357. package/dist/rules/rules/cross-chunks-package/types.d.cts +0 -3
  358. package/dist/rules/rules/cross-chunks-package/utils.cjs +0 -44
  359. package/dist/rules/rules/cross-chunks-package/utils.d.cts +0 -1
  360. package/dist/rules/rules/default-import-check/index.cjs +0 -120
  361. package/dist/rules/rules/default-import-check/index.d.cts +0 -4
  362. package/dist/rules/rules/default-import-check/types.cjs +0 -18
  363. package/dist/rules/rules/default-import-check/types.d.cts +0 -4
  364. package/dist/rules/rules/default-import-check/utils.cjs +0 -101
  365. package/dist/rules/rules/default-import-check/utils.d.cts +0 -10
  366. package/dist/rules/rules/duplicate-package/index.cjs +0 -76
  367. package/dist/rules/rules/duplicate-package/index.d.cts +0 -4
  368. package/dist/rules/rules/duplicate-package/types.cjs +0 -64
  369. package/dist/rules/rules/duplicate-package/types.d.cts +0 -24
  370. package/dist/rules/rules/duplicate-package/utils.cjs +0 -88
  371. package/dist/rules/rules/duplicate-package/utils.d.cts +0 -3
  372. package/dist/rules/rules/ecma-version-check/index.cjs +0 -100
  373. package/dist/rules/rules/ecma-version-check/index.d.cts +0 -4
  374. package/dist/rules/rules/ecma-version-check/types.cjs +0 -18
  375. package/dist/rules/rules/ecma-version-check/types.d.cts +0 -3
  376. package/dist/rules/rules/ecma-version-check/utils.cjs +0 -43
  377. package/dist/rules/rules/ecma-version-check/utils.d.cts +0 -2
  378. package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +0 -256
  379. package/dist/rules/rules/esm-resolved-to-cjs/index.d.cts +0 -4
  380. package/dist/rules/rules/esm-resolved-to-cjs/types.cjs +0 -18
  381. package/dist/rules/rules/esm-resolved-to-cjs/types.d.cts +0 -8
  382. package/dist/rules/rules/index.cjs +0 -59
  383. package/dist/rules/rules/index.d.cts +0 -2
  384. package/dist/rules/rules/loader-performance-optimization/index.cjs +0 -123
  385. package/dist/rules/rules/loader-performance-optimization/index.d.cts +0 -4
  386. package/dist/rules/rules/loader-performance-optimization/types.cjs +0 -18
  387. package/dist/rules/rules/loader-performance-optimization/types.d.cts +0 -22
  388. package/dist/rules/rules/loader-performance-optimization/utils.cjs +0 -47
  389. package/dist/rules/rules/loader-performance-optimization/utils.d.cts +0 -1
  390. package/dist/rules/rules/module-mixed-chunks/index.cjs +0 -89
  391. package/dist/rules/rules/module-mixed-chunks/index.d.cts +0 -4
  392. package/dist/rules/rules/module-mixed-chunks/types.cjs +0 -18
  393. package/dist/rules/rules/module-mixed-chunks/types.d.cts +0 -3
  394. package/dist/rules/rules/side-effects-only-imports/index.cjs +0 -118
  395. package/dist/rules/rules/side-effects-only-imports/index.d.cts +0 -4
  396. package/dist/rules/rules/side-effects-only-imports/types.cjs +0 -18
  397. package/dist/rules/rules/side-effects-only-imports/types.d.cts +0 -9
  398. package/dist/rules/utils.cjs +0 -50
  399. package/dist/rules/utils.d.cts +0 -3
  400. package/dist/types/chunks.cjs +0 -18
  401. package/dist/types/chunks.d.cts +0 -6
  402. package/dist/types/chunks.d.ts +0 -6
  403. package/dist/types/index.cjs +0 -83
  404. package/dist/types/index.d.cts +0 -4
  405. package/dist/types/loader.cjs +0 -18
  406. package/dist/types/loader.d.cts +0 -19
  407. package/dist/types/plugin.cjs +0 -18
  408. package/dist/types/plugin.d.cts +0 -51
  409. package/dist/types/rules.cjs +0 -18
  410. package/dist/types/rules.d.cts +0 -7
  411. /package/dist/{types/chunks.js → rule-utils/document/types.js} +0 -0
@@ -0,0 +1,163 @@
1
+ import "node:module";
2
+ import { Constants, Manifest } from "@rsdoctor/shared/types";
3
+ import { EnvInfo, File, Json } from "../../build-utils/index.js";
4
+ import node_fs from "node:fs";
5
+ import node_path from "node:path";
6
+ import { createHash, randomUUID } from "node:crypto";
7
+ import node_process from "node:process";
8
+ import { AsyncSeriesHook } from "tapable";
9
+ import { Algorithm, decycle } from "../../common/index.js";
10
+ import { logger } from "../../logger.js";
11
+ import { transformDataUrls } from "../utils/index.js";
12
+ class SDKCore {
13
+ get outputDir() {
14
+ return this._outputDir;
15
+ }
16
+ get name() {
17
+ return this._name;
18
+ }
19
+ async bootstrap() {
20
+ const [cpu, memory, nodeVersion, yarnVersion, npmVersion, pnpmVersion] = await Promise.all([
21
+ EnvInfo.getCPUInfo(),
22
+ EnvInfo.getMemoryInfo(),
23
+ EnvInfo.getNodeVersion(),
24
+ EnvInfo.getYarnVersion(),
25
+ EnvInfo.getNpmVersion(),
26
+ EnvInfo.getPnpmVersion()
27
+ ]);
28
+ this._envinfo = {
29
+ ...this._envinfo,
30
+ cpu,
31
+ memory,
32
+ nodeVersion,
33
+ yarnVersion,
34
+ npmVersion,
35
+ pnpmVersion
36
+ };
37
+ const hash = createHash('md5').update([
38
+ this.name,
39
+ this.root,
40
+ JSON.stringify(this._envinfo),
41
+ Date.now()
42
+ ].join('_')).digest('hex');
43
+ this.setHash(hash);
44
+ }
45
+ async dispose() {}
46
+ setOutputDir(outputDir) {
47
+ this._outputDir = outputDir;
48
+ }
49
+ setName(name) {
50
+ this._name = name;
51
+ }
52
+ setHash(hash) {
53
+ this.hash = hash;
54
+ }
55
+ getHash() {
56
+ return this.hash;
57
+ }
58
+ getClientRoutes() {
59
+ return [
60
+ ...this._clientRoutes
61
+ ];
62
+ }
63
+ addClientRoutes(routes) {
64
+ routes.forEach((route)=>{
65
+ this._clientRoutes.add(route);
66
+ });
67
+ this.onDataReport();
68
+ }
69
+ async writePieces(storeData, _options) {
70
+ const { outputDir } = this;
71
+ const manifest = node_path.resolve(outputDir, Constants.RsdoctorOutputManifest);
72
+ this.diskManifestPath = manifest;
73
+ await File.fse.ensureDir(outputDir);
74
+ const urlsPromiseList = [];
75
+ for (const key of Object.keys(storeData)){
76
+ const data = storeData[key];
77
+ if ('object' != typeof data) {
78
+ urlsPromiseList.push({
79
+ name: key,
80
+ files: data
81
+ });
82
+ continue;
83
+ }
84
+ const jsonStr = await (async ()=>{
85
+ try {
86
+ if ('configs' === key) return JSON.stringify(decycle(data));
87
+ return JSON.stringify(data);
88
+ } catch {
89
+ return Json.stringify(data);
90
+ }
91
+ })();
92
+ if (Array.isArray(jsonStr)) {
93
+ let fileOffset = 0;
94
+ for (const str of jsonStr){
95
+ const result = await this.writeToFolder(str, outputDir, key, fileOffset);
96
+ fileOffset += result.files.length;
97
+ urlsPromiseList.push(result);
98
+ }
99
+ } else urlsPromiseList.push(this.writeToFolder(jsonStr, outputDir, key));
100
+ }
101
+ const dataUrls = await Promise.all(urlsPromiseList);
102
+ logger.debug(`SDKCore.writePieces extraConfig: ${JSON.stringify(this.extraConfig)}`, '[SDKCore.writePieces]');
103
+ this.cloudData = {
104
+ client: {
105
+ enableRoutes: this.getClientRoutes()
106
+ },
107
+ data: transformDataUrls(dataUrls)
108
+ };
109
+ }
110
+ async writeManifest() {
111
+ const { cloudData: data, diskManifestPath } = this;
112
+ const dataStr = JSON.stringify(data, null, 2);
113
+ logger.debug(`SDKCore.writeManifest extraConfig: ${this.extraConfig}`, '[SDKCore.writeManifest]');
114
+ const dir = node_path.dirname(diskManifestPath);
115
+ const base = node_path.basename(diskManifestPath);
116
+ const tmpPath = node_path.join(dir, `${base}.${Date.now()}.${randomUUID()}.tmp`);
117
+ await File.fse.outputFile(tmpPath, dataStr);
118
+ node_fs.renameSync(tmpPath, diskManifestPath);
119
+ return diskManifestPath;
120
+ }
121
+ async saveManifest(data, options) {
122
+ await this.writePieces(data, options);
123
+ const manifestDiskPath = await this.writeManifest();
124
+ await this.hooks.afterSaveManifest.promise({
125
+ manifestWithShardingFiles: this.cloudData,
126
+ manifestDiskPath
127
+ });
128
+ return manifestDiskPath;
129
+ }
130
+ writeToFolder(jsonStr, dir, key, index) {
131
+ const sharding = new File.FileSharding(Algorithm.compressText(jsonStr));
132
+ const folder = node_path.resolve(dir, key);
133
+ const writer = sharding.writeStringToFolder(folder, '', index);
134
+ return writer.then((item)=>{
135
+ const res = {
136
+ name: key,
137
+ files: item.map((el)=>({
138
+ path: node_path.resolve(folder, el.filename),
139
+ basename: el.filename,
140
+ content: el.content
141
+ }))
142
+ };
143
+ return res;
144
+ });
145
+ }
146
+ constructor({ name, root }){
147
+ this.hooks = {
148
+ afterSaveManifest: new AsyncSeriesHook([
149
+ 'result'
150
+ ])
151
+ };
152
+ this._envinfo = {};
153
+ this._clientRoutes = new Set([
154
+ Manifest.RsdoctorManifestClientRoutes.Overall
155
+ ]);
156
+ this.diskManifestPath = '';
157
+ this._name = name;
158
+ this.root = root;
159
+ this.pid = node_process.pid;
160
+ this._outputDir = node_path.join(this.outputDir || this.root, Constants.RsdoctorOutputFolder);
161
+ }
162
+ }
163
+ export { SDKCore };
@@ -0,0 +1,52 @@
1
+ import { Manifest, SDK } from '@rsdoctor/shared/types';
2
+ import { RawSourceMap, SourceMapConsumer } from 'source-map';
3
+ import { RsdoctorServer } from '../server/index.js';
4
+ import { RsdoctorRspackSDKOptions } from './types.js';
5
+ import { SDKCore } from './core.js';
6
+ export * from '../utils/openBrowser.js';
7
+ export * from '../utils/base.js';
8
+ export { resolveClientDiffHtmlPath } from '../server/client.js';
9
+ export declare class RsdoctorSDK<T extends RsdoctorRspackSDKOptions = RsdoctorRspackSDKOptions> extends SDKCore<T> implements SDK.RsdoctorBuilderSDKInstance {
10
+ server: RsdoctorServer;
11
+ extraConfig: SDK.SDKOptionsType | undefined;
12
+ type: SDK.ToDataType;
13
+ root: string;
14
+ private _summary;
15
+ private _configs;
16
+ private _errors;
17
+ private _loader;
18
+ private _loaderStart;
19
+ private _resolver;
20
+ private _plugin;
21
+ private _moduleGraph;
22
+ private _chunkGraph;
23
+ private _rawSourceMapCache;
24
+ private _sourceMap;
25
+ private _packageGraph;
26
+ constructor(options: T);
27
+ bootstrap(): Promise<void>;
28
+ dispose(): Promise<void>;
29
+ applyErrorFix(id: number): Promise<void>;
30
+ clear(): void;
31
+ clearSourceMapCache(): void;
32
+ getSourceMap(file: string): Promise<SourceMapConsumer | undefined>;
33
+ reportSourceMap(data: RawSourceMap): void;
34
+ reportConfiguration(config: SDK.ConfigData[0]): void;
35
+ reportError(errors: Error[]): void;
36
+ reportLoader(data: SDK.LoaderData): void;
37
+ reportLoaderStartOrEnd(data: SDK.ResourceLoaderData): void;
38
+ reportResolver(data: SDK.ResolverData): void;
39
+ reportPlugin(data: SDK.PluginData): void;
40
+ reportModuleGraph(data: SDK.ModuleGraphInstance): void;
41
+ reportPackageGraph(data: SDK.PackageGraphInstance): void;
42
+ reportChunkGraph(data: SDK.ChunkGraphInstance): void;
43
+ reportSummaryData(part: Partial<SDK.SummaryData>): void;
44
+ createPackageGraph(): void;
45
+ writeStore(options?: SDK.WriteStoreOptionsType): Promise<string>;
46
+ getStoreData(): SDK.BuilderStoreData;
47
+ getManifestData(): Manifest.RsdoctorManifestWithShardingFiles;
48
+ getRuleContext(_options: SDK.RuntimeContextOptions): SDK.RuntimeContext;
49
+ onDataReport(): void | Promise<void>;
50
+ addRsdoctorDataToHTML(storeData: SDK.BuilderStoreData, htmlContent: string): string;
51
+ inlineScriptsAndStyles(htmlFilePath: string): string;
52
+ }
@@ -0,0 +1,435 @@
1
+ import "node:module";
2
+ import node_fs from "node:fs";
3
+ import fs_extra from "fs-extra";
4
+ import path_0 from "path";
5
+ import { createRequire } from "module";
6
+ import { DevToolError } from "../../error/index.js";
7
+ import { Constants, SDK } from "@rsdoctor/shared/types";
8
+ import { SourceMapConsumer } from "source-map";
9
+ import { ChunkGraph, ModuleGraph, PackageGraph } from "../../graph/index.js";
10
+ import { logger } from "../../logger.js";
11
+ import { RsdoctorServer } from "../server/index.js";
12
+ import { RsdoctorFakeServer } from "../server/fakeServer.js";
13
+ import { SDKCore } from "./core.js";
14
+ import { Algorithm, Lodash, decycle } from "../../common/index.js";
15
+ import { findRoot } from "../utils/index.js";
16
+ export * from "../utils/openBrowser.js";
17
+ export * from "../utils/base.js";
18
+ const sdk_require = createRequire(import.meta.url);
19
+ class RsdoctorSDK extends SDKCore {
20
+ async bootstrap() {
21
+ logger.debug(`${Date.now()}`, '[RsdoctorSDK][bootstrap start]');
22
+ if (this.server) await this.server.bootstrap();
23
+ await super.bootstrap();
24
+ logger.debug(`${Date.now()} ${this.server.origin}`, '[RsdoctorSDK][bootstrap end]');
25
+ }
26
+ async dispose() {
27
+ logger.debug(`${Date.now()}`, '[RsdoctorSDK][dispose start]');
28
+ if (this.server) await this.server.dispose();
29
+ await super.dispose();
30
+ logger.debug(`${Date.now()}`, '[RsdoctorSDK][dispose end]');
31
+ }
32
+ async applyErrorFix(id) {
33
+ const { _errors: errors } = this;
34
+ const error = errors.find((err)=>err.id === id);
35
+ if (!error || !error.path || !error.fixData || error.fixData.isFixed) return;
36
+ const { path: filePath, fixData } = error;
37
+ const sameFileErrors = errors.filter((item)=>item.path === filePath && item !== error);
38
+ let content = (await node_fs.promises.readFile(filePath, 'utf-8')).toString();
39
+ const startTxt = content.substring(0, fixData.start);
40
+ const endTxt = content.substring(fixData.end, content.length);
41
+ const offset = (fixData.newText ?? '').length - (fixData.end - fixData.start);
42
+ content = startTxt + fixData.newText + endTxt;
43
+ for (const other of sameFileErrors){
44
+ const { fixData: otherFixData } = other;
45
+ if (otherFixData) {
46
+ if (otherFixData.start >= fixData.end) {
47
+ otherFixData.start += offset;
48
+ otherFixData.end += offset;
49
+ }
50
+ }
51
+ }
52
+ await node_fs.promises.writeFile(filePath, content);
53
+ }
54
+ clear() {
55
+ this._errors = [];
56
+ this._loader = [];
57
+ this._resolver = [];
58
+ this._plugin = {};
59
+ this._moduleGraph = new ModuleGraph();
60
+ this._chunkGraph = new ChunkGraph();
61
+ }
62
+ clearSourceMapCache() {
63
+ this._rawSourceMapCache = new Map();
64
+ this._sourceMap = new Map();
65
+ }
66
+ async getSourceMap(file) {
67
+ const { _sourceMap: sourceMap, _rawSourceMapCache: rawMap } = this;
68
+ if (sourceMap.has(file)) return sourceMap.get(file);
69
+ const rawData = rawMap.get(file);
70
+ if (!rawData || rawData.version < 0 || !rawData.sourcesContent?.[0] || !rawData.mappings) return Promise.resolve(void 0);
71
+ try {
72
+ const result = await new SourceMapConsumer(rawData);
73
+ sourceMap.set(file, result);
74
+ return result;
75
+ } catch {
76
+ return Promise.resolve(void 0);
77
+ }
78
+ }
79
+ reportSourceMap(data) {
80
+ this._rawSourceMapCache.set(data.file, data);
81
+ }
82
+ reportConfiguration(config) {
83
+ config.root ??= this.root;
84
+ this._configs.push(config);
85
+ this.onDataReport();
86
+ }
87
+ reportError(errors) {
88
+ errors.forEach((item)=>{
89
+ this._errors.push(DevToolError.from(item, {
90
+ code: this.name
91
+ }));
92
+ });
93
+ this.onDataReport();
94
+ }
95
+ reportLoader(data) {
96
+ data.forEach((item)=>{
97
+ if (this.extraConfig?.mode === SDK.IMode[SDK.IMode.brief]) item.loaders.forEach((_loader)=>{
98
+ _loader.input = void 0;
99
+ _loader.result = void 0;
100
+ });
101
+ let match = this._loader.find((e)=>e.resource.path === item.resource.path);
102
+ if (match) match.loaders.push(...item.loaders);
103
+ else {
104
+ match = item;
105
+ this._loader.push(item);
106
+ }
107
+ match.loaders.sort((a, b)=>{
108
+ if (a.startAt !== b.startAt) return a.startAt - b.startAt;
109
+ if (a.isPitch) {
110
+ if (b.isPitch) return a.loaderIndex - b.loaderIndex;
111
+ return -1;
112
+ }
113
+ if (b.isPitch) return 1;
114
+ return b.loaderIndex - a.loaderIndex;
115
+ });
116
+ });
117
+ this.onDataReport();
118
+ }
119
+ reportLoaderStartOrEnd(data) {
120
+ const _builtinLoader = data.loaders[0];
121
+ if (_builtinLoader.startAt) this._loaderStart.push(data);
122
+ else if (_builtinLoader.endAt) {
123
+ const matchLoaderStart = this._loaderStart.find((e)=>e.resource.path === data.resource.path && e.loaders[0].loader === _builtinLoader.loader);
124
+ if (matchLoaderStart) {
125
+ matchLoaderStart.loaders[0].result = _builtinLoader.result;
126
+ matchLoaderStart.loaders[0].endAt = _builtinLoader.endAt;
127
+ this.reportLoader([
128
+ matchLoaderStart
129
+ ]);
130
+ }
131
+ }
132
+ }
133
+ reportResolver(data) {
134
+ data.forEach((item)=>this._resolver.push(item));
135
+ this.onDataReport();
136
+ }
137
+ reportPlugin(data) {
138
+ Object.keys(data).forEach((hook)=>{
139
+ if (this._plugin[hook]) data[hook].forEach((item)=>{
140
+ this._plugin[hook].push(item || void 0);
141
+ });
142
+ else this._plugin[hook] = data[hook];
143
+ });
144
+ this.onDataReport();
145
+ }
146
+ reportModuleGraph(data) {
147
+ logger.debug(`data size: ${data.size()}`, '[SDK.reportModuleGraph][start]');
148
+ this._moduleGraph.fromInstance(data);
149
+ this.createPackageGraph();
150
+ this.onDataReport();
151
+ logger.debug(`sdk._moduleGraph size: ${this._moduleGraph.size()}`, '[SDK reportModuleGraph][end]');
152
+ }
153
+ reportPackageGraph(data) {
154
+ logger.debug('[SDK.reportPackageGraph][start]');
155
+ if (!this._packageGraph) this._packageGraph = data;
156
+ this.onDataReport();
157
+ logger.debug(`sdk._packageGraph size: ${this._packageGraph.getPackages().length}`, '[SDK reportPackageGraph][end]');
158
+ }
159
+ reportChunkGraph(data) {
160
+ this._chunkGraph.addAsset(...data.getAssets());
161
+ this._chunkGraph.addChunk(...data.getChunks());
162
+ this._chunkGraph.addEntryPoint(...data.getEntryPoints());
163
+ this.onDataReport();
164
+ }
165
+ reportSummaryData(part) {
166
+ const keys = [
167
+ 'costs'
168
+ ];
169
+ for (const key of keys){
170
+ const v = part[key];
171
+ if (v) if ('object' == typeof v) if (Array.isArray(v)) this._summary[key] = [
172
+ ...this._summary[key] || [],
173
+ ...v
174
+ ];
175
+ else this._summary[key] = {
176
+ ...this._summary[key] || {},
177
+ ...v
178
+ };
179
+ else this._summary[key] = v;
180
+ }
181
+ this.onDataReport();
182
+ }
183
+ createPackageGraph() {
184
+ logger.debug(`sdk._moduleGraph size: ${this._moduleGraph.size()}`, '[SDK.createPackageGraph][start]');
185
+ if (!this._packageGraph) {
186
+ const pkgGraph = PackageGraph.fromModuleGraph(this._moduleGraph, this.root, (path)=>{
187
+ try {
188
+ const exists = node_fs.existsSync(path);
189
+ if (exists) {
190
+ const res = fs_extra.readJsonSync(path);
191
+ return res;
192
+ }
193
+ } catch (error) {
194
+ const { message, stack } = error;
195
+ logger.debug(()=>`sdk.createPackageGraph error, path: ${path}, error message: ${stack || message}`, '[SDK.createPackageGraph][error]');
196
+ }
197
+ });
198
+ this._packageGraph = pkgGraph;
199
+ logger.debug(`sdk._packageGraph packages: ${this._packageGraph.getPackages().length}`, '[SDK.createPackageGraph][end]');
200
+ }
201
+ }
202
+ async writeStore(options) {
203
+ logger.debug("sdk.writeStore has run.", '[SDK.writeStore][end]');
204
+ let htmlPath = '';
205
+ if (this.extraConfig?.mode === SDK.IMode[SDK.IMode.brief]) {
206
+ const clientHtmlPath = this.extraConfig.innerClientPath ? this.extraConfig.innerClientPath : sdk_require.resolve('@rsdoctor/client');
207
+ if (this.extraConfig?.brief?.type?.includes('json')) {
208
+ const data = this.getStoreData();
209
+ const clientRoutes = this.getClientRoutes();
210
+ const jsonData = {
211
+ data,
212
+ clientRoutes
213
+ };
214
+ node_fs.mkdirSync(this.outputDir, {
215
+ recursive: true
216
+ });
217
+ node_fs.writeFileSync(path_0.resolve(this.outputDir, this.extraConfig.brief.jsonOptions?.fileName ?? 'rsdoctor-data.json'), JSON.stringify(jsonData));
218
+ }
219
+ if (this.extraConfig.brief?.type?.includes('html')) htmlPath = this.inlineScriptsAndStyles(clientHtmlPath);
220
+ return htmlPath;
221
+ }
222
+ return this.saveManifest(this.getStoreData(), options || {});
223
+ }
224
+ getStoreData() {
225
+ const ctx = this;
226
+ const briefOptions = this.extraConfig?.brief;
227
+ const sections = briefOptions?.jsonOptions?.sections;
228
+ const isJsonType = briefOptions?.type?.includes('json');
229
+ return {
230
+ get hash () {
231
+ return ctx.hash;
232
+ },
233
+ get root () {
234
+ return ctx.root;
235
+ },
236
+ get envinfo () {
237
+ return ctx._envinfo;
238
+ },
239
+ get pid () {
240
+ return ctx.pid;
241
+ },
242
+ get errors () {
243
+ if (isJsonType && sections && !sections.rules) return [];
244
+ return ctx._errors.map((err)=>err.toData());
245
+ },
246
+ get configs () {
247
+ return ctx._configs.slice();
248
+ },
249
+ get summary () {
250
+ return {
251
+ ...ctx._summary
252
+ };
253
+ },
254
+ get resolver () {
255
+ return ctx._resolver.slice();
256
+ },
257
+ get loader () {
258
+ return ctx._loader.slice();
259
+ },
260
+ get moduleGraph () {
261
+ if (isJsonType && sections && !sections.moduleGraph) return {
262
+ dependencies: [],
263
+ modules: [],
264
+ moduleGraphModules: [],
265
+ exports: [],
266
+ sideEffects: [],
267
+ variables: [],
268
+ layers: []
269
+ };
270
+ return ctx._moduleGraph.toData({
271
+ contextPath: ctx._configs?.[0]?.config?.context || '',
272
+ briefOptions
273
+ });
274
+ },
275
+ get chunkGraph () {
276
+ if (isJsonType && sections && !sections.chunkGraph) return {
277
+ assets: [],
278
+ chunks: [],
279
+ entrypoints: []
280
+ };
281
+ return ctx._chunkGraph.toData(ctx.type);
282
+ },
283
+ get moduleCodeMap () {
284
+ if (ctx.extraConfig?.mode === SDK.IMode[SDK.IMode.brief]) return {};
285
+ return ctx._moduleGraph.toCodeData(ctx.type);
286
+ },
287
+ get plugin () {
288
+ return {
289
+ ...ctx._plugin
290
+ };
291
+ },
292
+ get packageGraph () {
293
+ return ctx._packageGraph ? ctx._packageGraph.toData() : {
294
+ packages: [],
295
+ dependencies: []
296
+ };
297
+ },
298
+ get treeShaking () {
299
+ if (ctx.extraConfig?.mode === SDK.IMode[SDK.IMode.brief]) return;
300
+ if (!ctx.extraConfig?.features?.treeShaking) return;
301
+ return ctx._moduleGraph.toTreeShakingData();
302
+ },
303
+ get otherReports () {
304
+ return {
305
+ treemapReportHtml: ''
306
+ };
307
+ }
308
+ };
309
+ }
310
+ getManifestData() {
311
+ const dataValue = this.getStoreData();
312
+ const data = {
313
+ client: {
314
+ enableRoutes: this.getClientRoutes()
315
+ },
316
+ data: Object.keys(dataValue).reduce((t, e)=>{
317
+ const _e = e;
318
+ if (dataValue[_e] && 'object' == typeof dataValue[_e]) t[e] = [
319
+ `${this.server.origin}${SDK.ServerAPI.API.LoadDataByKey}/${e}`
320
+ ];
321
+ else t[e] = dataValue[_e];
322
+ return t;
323
+ }, {}),
324
+ __LOCAL__SERVER__: true,
325
+ __SOCKET__PORT__: this.server.socketUrl.port.toString(),
326
+ __SOCKET__URL__: this.server.socketUrl.socketUrl
327
+ };
328
+ return data;
329
+ }
330
+ getRuleContext(_options) {
331
+ this.createPackageGraph();
332
+ return {
333
+ root: this.root,
334
+ errors: this._errors.slice(),
335
+ configs: this._configs.slice(),
336
+ moduleGraph: this._moduleGraph,
337
+ chunkGraph: this._chunkGraph,
338
+ packageGraph: this._packageGraph,
339
+ loader: this._loader.slice(),
340
+ otherReports: {
341
+ treemapReportHtml: ''
342
+ }
343
+ };
344
+ }
345
+ onDataReport() {
346
+ this.server.broadcast();
347
+ }
348
+ addRsdoctorDataToHTML(storeData, htmlContent) {
349
+ let compressTextScripts = `<script>window.${Constants.WINDOW_RSDOCTOR_TAG}={}</script>`;
350
+ for (const key of Object.keys(storeData)){
351
+ const data = storeData[key];
352
+ const jsonStrFn = ()=>{
353
+ try {
354
+ if ('configs' === key) return JSON.stringify(decycle(data));
355
+ return JSON.stringify(data);
356
+ } catch (error) {
357
+ console.error(error);
358
+ return '';
359
+ }
360
+ };
361
+ const compressText = Algorithm.compressText(jsonStrFn());
362
+ compressTextScripts = `${compressTextScripts} <script>window.${Constants.WINDOW_RSDOCTOR_TAG}.${key}=${JSON.stringify(compressText)}</script>`;
363
+ }
364
+ compressTextScripts = `${compressTextScripts} <script>window.${Constants.WINDOW_RSDOCTOR_TAG}.enableRoutes=${JSON.stringify(this.getClientRoutes())}</script>`;
365
+ htmlContent = htmlContent.replace('<body>', `<body>${compressTextScripts}`);
366
+ return htmlContent;
367
+ }
368
+ inlineScriptsAndStyles(htmlFilePath) {
369
+ function inlineScripts(basePath, scripts) {
370
+ return scripts.map((src)=>{
371
+ const scriptPath = resolveFilePath(basePath, src);
372
+ try {
373
+ const scriptContent = node_fs.readFileSync(scriptPath, 'utf-8');
374
+ return `<script>${scriptContent}</script>`;
375
+ } catch (error) {
376
+ console.error(`Could not read script at ${scriptPath}:`, error);
377
+ return '';
378
+ }
379
+ }).join('');
380
+ }
381
+ function resolveFilePath(basePath, filePath) {
382
+ if (filePath.startsWith('/')) return path_0.resolve(basePath, filePath.slice(1));
383
+ return path_0.resolve(basePath, filePath);
384
+ }
385
+ function inlineCss(basePath, cssFiles) {
386
+ return cssFiles.map((href)=>{
387
+ const cssPath = resolveFilePath(basePath, href);
388
+ try {
389
+ const cssContent = node_fs.readFileSync(cssPath, 'utf-8');
390
+ return `<style>${cssContent}</style>`;
391
+ } catch (error) {
392
+ console.error(`Could not read CSS at ${cssPath}:`, error);
393
+ return '';
394
+ }
395
+ }).join('');
396
+ }
397
+ let htmlContent = node_fs.readFileSync(htmlFilePath, 'utf-8');
398
+ const basePath = path_0.dirname(htmlFilePath);
399
+ const scriptSrcs = Array.from(htmlContent.matchAll(/<script\s+(?:defer="defer"|defer)\s+src=["'](.+?)["']><\/script>/g), (m)=>m[1]);
400
+ const cssHrefs = Array.from(htmlContent.matchAll(/<link\s+href=["'](.+?)["']\s+rel="stylesheet">/g), (m)=>m[1]);
401
+ htmlContent = htmlContent.replace(/<script\s+.*?src=["'].*?["']><\/script>/g, '');
402
+ htmlContent = htmlContent.replace(/<link\s+.*?rel=["']stylesheet["'].*?>/g, '');
403
+ const inlinedScripts = inlineScripts(basePath, scriptSrcs);
404
+ const inlinedCss = inlineCss(basePath, cssHrefs);
405
+ const index = htmlContent.indexOf('</body>');
406
+ htmlContent = htmlContent.slice(0, index) + inlinedCss + inlinedScripts + htmlContent.slice(index);
407
+ htmlContent = this.addRsdoctorDataToHTML(this.getStoreData(), htmlContent);
408
+ const outputFilePath = path_0.resolve(this.outputDir, this.extraConfig?.brief?.htmlOptions?.reportHtmlName || 'rsdoctor-report.html');
409
+ node_fs.mkdirSync(path_0.dirname(outputFilePath), {
410
+ recursive: true
411
+ });
412
+ node_fs.writeFileSync(outputFilePath, htmlContent, {
413
+ encoding: 'utf-8',
414
+ flag: 'w'
415
+ });
416
+ return outputFilePath;
417
+ }
418
+ constructor(options){
419
+ super(options), this._summary = {
420
+ costs: []
421
+ }, this._configs = [], this._errors = [], this._loader = [], this._loaderStart = [], this._resolver = [], this._plugin = {}, this._moduleGraph = new ModuleGraph(), this._chunkGraph = new ChunkGraph(), this._rawSourceMapCache = new Map(), this._sourceMap = new Map();
422
+ const serverConfig = options.config?.server;
423
+ const port = serverConfig?.port ?? options.port;
424
+ this.server = options.config?.noServer ? new RsdoctorFakeServer(this, port) : new RsdoctorServer(this, port, {
425
+ innerClientPath: options.config?.innerClientPath || '',
426
+ printServerUrl: options.config?.printLog?.serverUrls,
427
+ cors: serverConfig?.cors
428
+ });
429
+ this.type = Lodash.isNumber(options.type) ? options.type : SDK.ToDataType.Normal;
430
+ this.extraConfig = options.config;
431
+ this.root = findRoot() ?? '';
432
+ }
433
+ }
434
+ export { resolveClientDiffHtmlPath } from "../server/client.js";
435
+ export { RsdoctorSDK };
@@ -0,0 +1,26 @@
1
+ import { SDK } from '@rsdoctor/shared/types';
2
+ export interface DataWithUrl {
3
+ name: string;
4
+ files: {
5
+ path: string;
6
+ basename: string;
7
+ content: Buffer;
8
+ }[] | string;
9
+ }
10
+ export interface RsdoctorSDKOptions {
11
+ name: string;
12
+ root: string;
13
+ }
14
+ /**
15
+ * sdk options for builder.
16
+ */
17
+ export interface RsdoctorBuilderSDK extends RsdoctorSDKOptions {
18
+ type?: SDK.ToDataType;
19
+ /**
20
+ * port for client server
21
+ */
22
+ port?: number;
23
+ config?: SDK.SDKOptionsType;
24
+ }
25
+ export type RsdoctorRspackSDKOptions = RsdoctorBuilderSDK;
26
+ export type RsdoctorEMOSDKOptions = RsdoctorSDKOptions;
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1,5 @@
1
+ import { SDK } from '@rsdoctor/shared/types';
2
+ import { BaseAPI } from './base.js';
3
+ export declare class AlertsAPI extends BaseAPI {
4
+ getPackageRelationAlertDetails(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetPackageRelationAlertDetails>>;
5
+ }