@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,33 @@
1
+ import "node:module";
2
+ import { SDK } from "@rsdoctor/shared/types";
3
+ import node_fs from "node:fs";
4
+ import { createRequire } from "module";
5
+ import { BaseAPI } from "./base.js";
6
+ import { Router } from "../router.js";
7
+ function _ts_decorate(decorators, target, key, desc) {
8
+ var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9
+ if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
10
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12
+ }
13
+ function _ts_metadata(k, v) {
14
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
15
+ }
16
+ const renderer_require = createRequire(import.meta.url);
17
+ class RendererAPI extends BaseAPI {
18
+ async entryHtml() {
19
+ const { server, res } = this.ctx;
20
+ const clientHtmlPath = server.innerClientPath ? server.innerClientPath : renderer_require.resolve('@rsdoctor/client');
21
+ const clientHtml = node_fs.readFileSync(clientHtmlPath, 'utf-8');
22
+ res.setHeader('Content-Type', 'text/html');
23
+ res.setHeader('Cache-Control', 'no-store');
24
+ return clientHtml;
25
+ }
26
+ }
27
+ _ts_decorate([
28
+ Router.get(SDK.ServerAPI.API.EntryHtml),
29
+ _ts_metadata("design:type", Function),
30
+ _ts_metadata("design:paramtypes", []),
31
+ _ts_metadata("design:returntype", Promise)
32
+ ], RendererAPI.prototype, "entryHtml", null);
33
+ export { RendererAPI };
@@ -0,0 +1,6 @@
1
+ import { SDK } from '@rsdoctor/shared/types';
2
+ import { BaseAPI } from './base.js';
3
+ export declare class ResolverAPI extends BaseAPI {
4
+ getResolverFileTree(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetResolverFileTree>>;
5
+ getResolverFileDetails(): Promise<SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetResolverFileDetails>>;
6
+ }
@@ -0,0 +1,38 @@
1
+ import "node:module";
2
+ import { SDK } from "@rsdoctor/shared/types";
3
+ import { BaseAPI } from "./base.js";
4
+ import { Router } from "../router.js";
5
+ function _ts_decorate(decorators, target, key, desc) {
6
+ var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7
+ if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
8
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ }
11
+ function _ts_metadata(k, v) {
12
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
13
+ }
14
+ class ResolverAPI extends BaseAPI {
15
+ async getResolverFileTree() {
16
+ return this.dataLoader.loadAPI(SDK.ServerAPI.API.GetResolverFileTree);
17
+ }
18
+ async getResolverFileDetails() {
19
+ const { req } = this.ctx;
20
+ const { filepath } = req.body;
21
+ return this.dataLoader.loadAPI(SDK.ServerAPI.API.GetResolverFileDetails, {
22
+ filepath
23
+ });
24
+ }
25
+ }
26
+ _ts_decorate([
27
+ Router.post(SDK.ServerAPI.API.GetResolverFileTree),
28
+ _ts_metadata("design:type", Function),
29
+ _ts_metadata("design:paramtypes", []),
30
+ _ts_metadata("design:returntype", Promise)
31
+ ], ResolverAPI.prototype, "getResolverFileTree", null);
32
+ _ts_decorate([
33
+ Router.post(SDK.ServerAPI.API.GetResolverFileDetails),
34
+ _ts_metadata("design:type", Function),
35
+ _ts_metadata("design:paramtypes", []),
36
+ _ts_metadata("design:returntype", Promise)
37
+ ], ResolverAPI.prototype, "getResolverFileDetails", null);
38
+ export { ResolverAPI };
@@ -0,0 +1,3 @@
1
+ export declare const resolveClientHtmlPath: (innerClientPath?: string) => string;
2
+ export declare const resolveClientDistPath: (innerClientPath?: string) => string;
3
+ export declare const resolveClientDiffHtmlPath: (innerClientPath?: string) => string;
@@ -0,0 +1,8 @@
1
+ import "node:module";
2
+ import path from "path";
3
+ import { createRequire } from "module";
4
+ const client_require = createRequire(import.meta.url);
5
+ const resolveClientHtmlPath = (innerClientPath)=>innerClientPath || client_require.resolve('@rsdoctor/client');
6
+ const resolveClientDistPath = (innerClientPath)=>path.dirname(resolveClientHtmlPath(innerClientPath));
7
+ const resolveClientDiffHtmlPath = (innerClientPath)=>path.resolve(resolveClientDistPath(innerClientPath), 'diff.html');
8
+ export { resolveClientDiffHtmlPath, resolveClientDistPath, resolveClientHtmlPath };
@@ -0,0 +1,9 @@
1
+ import { SDK } from '@rsdoctor/shared/types';
2
+ import { RsdoctorServer } from './index.js';
3
+ export declare class RsdoctorFakeServer extends RsdoctorServer {
4
+ protected sdk: SDK.RsdoctorBuilderSDKInstance;
5
+ constructor(sdk: SDK.RsdoctorBuilderSDKInstance, port?: number);
6
+ bootstrap(): Promise<void>;
7
+ openClientPage(): Promise<void>;
8
+ dispose: () => Promise<void>;
9
+ }
@@ -0,0 +1,12 @@
1
+ import "node:module";
2
+ import { Server } from "../../build-utils/index.js";
3
+ import { RsdoctorServer } from "./index.js";
4
+ class RsdoctorFakeServer extends RsdoctorServer {
5
+ async bootstrap() {}
6
+ async openClientPage() {}
7
+ constructor(sdk, port = Server.defaultPort){
8
+ super(sdk, port), this.sdk = sdk, this.dispose = async ()=>{};
9
+ this.sdk = sdk;
10
+ }
11
+ }
12
+ export { RsdoctorFakeServer };
@@ -0,0 +1,44 @@
1
+ import { Common, SDK, Thirdparty, Client } from '@rsdoctor/shared/types';
2
+ export * from './utils.js';
3
+ export type ISocketType = {
4
+ port: number;
5
+ socketUrl: string;
6
+ token: string;
7
+ };
8
+ export type RsdoctorServerOptions = {
9
+ innerClientPath?: string;
10
+ printServerUrl?: boolean;
11
+ cors?: SDK.RsdoctorServerConfig['cors'];
12
+ };
13
+ export declare class RsdoctorServer implements SDK.RsdoctorServerInstance {
14
+ protected sdk: SDK.RsdoctorBuilderSDKInstance;
15
+ private _server;
16
+ port: number;
17
+ private _socket?;
18
+ private disposed;
19
+ private _router;
20
+ private _innerClientPath;
21
+ private _printServerUrl;
22
+ private _cors;
23
+ private _socketToken;
24
+ constructor(sdk: SDK.RsdoctorBuilderSDKInstance, port?: number, config?: RsdoctorServerOptions);
25
+ get app(): SDK.RsdoctorServerInstance['app'];
26
+ get host(): string;
27
+ get origin(): string;
28
+ get socketUrl(): ISocketType;
29
+ get innerClientPath(): string;
30
+ private createInnerServer;
31
+ private resolveCorsOptions;
32
+ bootstrap(): Promise<void>;
33
+ protected wrapNextHandleFunction(method: 'GET' | 'POST', cb: (...args: Parameters<Thirdparty.connect.NextHandleFunction>) => Common.PlainObject | string): Thirdparty.connect.NextHandleFunction;
34
+ proxy(api: SDK.ServerAPI.API, method: 'GET' | 'POST', cb: (...args: Parameters<Thirdparty.connect.NextHandleFunction>) => Common.PlainObject | string): void;
35
+ get: SDK.RsdoctorServerInstance['get'];
36
+ post: SDK.RsdoctorServerInstance['post'];
37
+ getClientUrl(route: Client.RsdoctorClientRoutes, baselineUrl: string, currentUrl: string): string;
38
+ getClientUrl(route?: 'homepage'): string;
39
+ openClientPage(route: Client.RsdoctorClientRoutes, baselineUrl: string, currentUrl: string): Promise<void>;
40
+ openClientPage(route?: 'homepage'): Promise<void>;
41
+ sendAPIDataToClient<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, msg: SDK.ServerAPI.SocketResponseType<T>): void;
42
+ broadcast(): Promise<void>;
43
+ dispose: (exitCode?: number) => Promise<void>;
44
+ }
@@ -0,0 +1,292 @@
1
+ import "node:module";
2
+ import { Client, SDK } from "@rsdoctor/shared/types";
3
+ import { Server } from "../../build-utils/index.js";
4
+ import sirv from "sirv";
5
+ import { Bundle, GlobalConfig } from "../../common/index.js";
6
+ import assert from "assert";
7
+ import cors from "cors";
8
+ import { PassThrough } from "stream";
9
+ import { Socket } from "./socket/index.js";
10
+ import { Router } from "./router.js";
11
+ import * as __rspack_external__apis_index_js_275823d6 from "./apis/index.js";
12
+ import { chalk, logger } from "../../logger.js";
13
+ import { openBrowser } from "../utils/openBrowser.js";
14
+ import path from "path";
15
+ import { createRequire } from "module";
16
+ import { randomBytes } from "crypto";
17
+ import { jsonBodyParser } from "./json-body.js";
18
+ import { DEFAULT_ALLOWED_CORS_ORIGINS, isAllowedCorsRequest, isAllowedOpenInEditorToken, isAllowedRequestHost } from "./security.js";
19
+ export * from "./utils.js";
20
+ const server_require = createRequire(import.meta.url);
21
+ const OPEN_IN_EDITOR_PATH = '/__open-in-editor';
22
+ const LISTEN_RETRY_LIMIT = 10;
23
+ const OPEN_IN_EDITOR_EDITORS = new Set(SDK.OPEN_IN_EDITOR_EDITORS);
24
+ const DEFAULT_JSON_BODY_LIMIT = '10mb';
25
+ const LARGE_JSON_BODY_LIMIT = '500mb';
26
+ const LARGE_JSON_BODY_ROUTES = new Set([
27
+ SDK.ServerAPI.API.ReportLoader,
28
+ SDK.ServerAPI.API.ReportSourceMap
29
+ ]);
30
+ function isAddressInUseError(error) {
31
+ return 'EADDRINUSE' === error.code;
32
+ }
33
+ function isAllowedOpenInEditorEditor(editor) {
34
+ return 'string' == typeof editor && OPEN_IN_EDITOR_EDITORS.has(editor);
35
+ }
36
+ class RsdoctorServer {
37
+ get app() {
38
+ return this._server.app;
39
+ }
40
+ get host() {
41
+ return Server.defaultHost;
42
+ }
43
+ get origin() {
44
+ return `http://${this.host}:${this.port}`;
45
+ }
46
+ get socketUrl() {
47
+ return {
48
+ port: this.port,
49
+ socketUrl: `ws://localhost:${this.port}?token=${this._socketToken}`,
50
+ token: this._socketToken
51
+ };
52
+ }
53
+ get innerClientPath() {
54
+ return this._innerClientPath;
55
+ }
56
+ async createInnerServer() {
57
+ let expectedPort = this.port;
58
+ let lastError;
59
+ for(let retry = 0; retry < LISTEN_RETRY_LIMIT; retry++){
60
+ const port = Server.getPortSync(expectedPort, this.host);
61
+ try {
62
+ return {
63
+ port,
64
+ server: await Server.createServer(port, this.host)
65
+ };
66
+ } catch (error) {
67
+ if (!isAddressInUseError(error)) throw error;
68
+ lastError = error;
69
+ expectedPort = port + 1;
70
+ }
71
+ }
72
+ throw lastError;
73
+ }
74
+ resolveCorsOptions() {
75
+ if (false === this._cors) return false;
76
+ if (true === this._cors) return {};
77
+ if (void 0 === this._cors) return {
78
+ origin: DEFAULT_ALLOWED_CORS_ORIGINS
79
+ };
80
+ return {
81
+ ...this._cors,
82
+ origin: void 0 === this._cors.origin ? DEFAULT_ALLOWED_CORS_ORIGINS : this._cors.origin
83
+ };
84
+ }
85
+ async bootstrap() {
86
+ if (!this.disposed) return;
87
+ const { port, server } = await this.createInnerServer();
88
+ const corsOptions = this.resolveCorsOptions();
89
+ this.port = port;
90
+ this._server = server;
91
+ this._socket = new Socket({
92
+ sdk: this.sdk,
93
+ server: this._server.server,
94
+ port: this.port,
95
+ token: this._socketToken
96
+ });
97
+ await this._socket.bootstrap();
98
+ GlobalConfig.writeMcpPort(this.port, this.sdk.name);
99
+ logger.debug(`Successfully wrote mcp.json for ${chalk.cyan(this.sdk.name)} builder`);
100
+ this.disposed = false;
101
+ this.app.use((req, res, next)=>{
102
+ const host = req.headers.host || req.headers[':authority'];
103
+ if (!isAllowedRequestHost(host)) {
104
+ res.statusCode = 403;
105
+ res.end();
106
+ return;
107
+ }
108
+ next();
109
+ });
110
+ if (false !== corsOptions && corsOptions.origin === DEFAULT_ALLOWED_CORS_ORIGINS) this.app.use((req, res, next)=>{
111
+ const host = req.headers.host || req.headers[':authority'];
112
+ if (!isAllowedCorsRequest(req.headers.origin, host)) {
113
+ res.statusCode = 403;
114
+ res.end();
115
+ return;
116
+ }
117
+ next();
118
+ });
119
+ if (false !== corsOptions) this.app.use(cors(corsOptions));
120
+ this.app.use(jsonBodyParser({
121
+ limit: (req)=>{
122
+ const pathname = new URL(req.url || '/', 'http://localhost').pathname;
123
+ return LARGE_JSON_BODY_ROUTES.has(pathname) ? LARGE_JSON_BODY_LIMIT : DEFAULT_JSON_BODY_LIMIT;
124
+ }
125
+ }));
126
+ await this._router.setup();
127
+ const clientHtmlPath = this._innerClientPath ? this._innerClientPath : server_require.resolve('@rsdoctor/client');
128
+ const clientDistPath = path.resolve(clientHtmlPath, '..');
129
+ this.app.use(sirv(clientDistPath, {
130
+ dev: true
131
+ }));
132
+ this.app.use(OPEN_IN_EDITOR_PATH, (req, res, next)=>{
133
+ if ('GET' !== req.method && 'HEAD' !== req.method) return next();
134
+ const url = new URL(req.url || '', "http://localhost");
135
+ const file = url.searchParams.get('file');
136
+ const editor = url.searchParams.get('editor');
137
+ const token = url.searchParams.get('token');
138
+ if (!isAllowedOpenInEditorToken(token, this._socketToken)) {
139
+ res.statusCode = 403;
140
+ res.end();
141
+ return;
142
+ }
143
+ if (!file) {
144
+ res.statusCode = 400;
145
+ res.end('Missing file parameter');
146
+ return;
147
+ }
148
+ if (!isAllowedOpenInEditorEditor(editor)) {
149
+ res.statusCode = 400;
150
+ res.end('Unsupported editor parameter');
151
+ return;
152
+ }
153
+ try {
154
+ const launch = server_require('launch-editor');
155
+ let responded = false;
156
+ const safeEnd = (code, body)=>{
157
+ if (responded) return;
158
+ responded = true;
159
+ res.statusCode = code;
160
+ res.end(body);
161
+ };
162
+ launch(file, editor, (_fileName, errorMessage)=>{
163
+ if (errorMessage) safeEnd(500, errorMessage);
164
+ });
165
+ setTimeout(()=>{
166
+ safeEnd(200, '');
167
+ }, 200);
168
+ } catch (err) {
169
+ if (!res.writableEnded) {
170
+ res.statusCode = 500;
171
+ res.end(err.message);
172
+ }
173
+ }
174
+ });
175
+ process.once('exit', ()=>this.dispose());
176
+ process.once('SIGINT', ()=>this.dispose(0));
177
+ process.once('SIGTERM', ()=>this.dispose(0));
178
+ process.once('unhandledRejection', (reason)=>{
179
+ console.error('Unhandled promise rejection:', reason);
180
+ this.dispose(1);
181
+ });
182
+ process.once('uncaughtException', (err, origin)=>{
183
+ console.error('Uncaught exception:', err);
184
+ if (origin) console.error('Exception origin:', origin);
185
+ this.dispose(1);
186
+ });
187
+ }
188
+ wrapNextHandleFunction(method, cb) {
189
+ return async (req, res, next)=>{
190
+ const m = req.method?.toUpperCase();
191
+ if (m === method) {
192
+ try {
193
+ const body = await cb(req, res, next);
194
+ res.statusCode = 200;
195
+ if (Buffer.isBuffer(body)) {
196
+ res.setHeader('Content-Length', body.byteLength);
197
+ const ps = new PassThrough();
198
+ ps.write(body);
199
+ ps.end();
200
+ ps.pipe(res);
201
+ } else if (body && 'object' == typeof body) {
202
+ res.writeHead(200, {
203
+ 'Content-Type': 'application/json;utf-8'
204
+ });
205
+ res.write(JSON.stringify(body));
206
+ res.end();
207
+ } else res.writeHead(200).end(body);
208
+ } catch (error) {
209
+ res.statusCode = 500;
210
+ res.end(error.message);
211
+ return next(error);
212
+ }
213
+ return;
214
+ }
215
+ await next();
216
+ };
217
+ }
218
+ proxy(api, method, cb) {
219
+ let idx = this.app.stack.findIndex((e)=>e.route === api);
220
+ if (-1 === idx) idx = this.app.stack.length - 1;
221
+ this.app.stack.splice(idx, 0, {
222
+ route: api,
223
+ handle: this.wrapNextHandleFunction(method, cb)
224
+ });
225
+ }
226
+ getClientUrl(route = 'homepage', ...args) {
227
+ const relativeUrl = SDK.ServerAPI.API.EntryHtml;
228
+ switch(route){
229
+ case Client.RsdoctorClientRoutes.BundleDiff:
230
+ {
231
+ const [baseline, current] = args;
232
+ const qs = Bundle.getBundleDiffPageQueryString([
233
+ baseline,
234
+ current
235
+ ]);
236
+ return `${relativeUrl}${qs}#${Client.RsdoctorClientRoutes.BundleDiff}`;
237
+ }
238
+ default:
239
+ return relativeUrl;
240
+ }
241
+ }
242
+ async openClientPage(...args) {
243
+ const relativeUrl = this.getClientUrl(...args);
244
+ const needEncodeURI = args[0] === Client.RsdoctorClientRoutes.BundleDiff;
245
+ const url = `http://${this.host}:${this.port}${relativeUrl}`;
246
+ const localhostUrl = `http://localhost:${this.port}${relativeUrl}`;
247
+ await openBrowser(localhostUrl, !needEncodeURI);
248
+ if (this._printServerUrl) logger.info(`${chalk.green(`${this.sdk.name} compiler's`)} analyzer running on: ${chalk.cyan(url)}`);
249
+ }
250
+ sendAPIDataToClient(api, msg) {
251
+ this._socket?.sendAPIData(api, msg);
252
+ }
253
+ async broadcast() {
254
+ await this._socket?.broadcast();
255
+ }
256
+ constructor(sdk, port = Server.defaultPort, config){
257
+ this.sdk = sdk;
258
+ this.disposed = true;
259
+ this._socketToken = randomBytes(16).toString('hex');
260
+ this.get = (route, cb)=>{
261
+ const { app } = this;
262
+ app.use(route, this.wrapNextHandleFunction('GET', cb));
263
+ return app;
264
+ };
265
+ this.post = (route, cb)=>{
266
+ const { app } = this;
267
+ app.use(route, this.wrapNextHandleFunction('POST', cb));
268
+ return app;
269
+ };
270
+ this.dispose = async (exitCode)=>{
271
+ if (this.disposed) {
272
+ if (void 0 !== exitCode) process.exit(exitCode);
273
+ return;
274
+ }
275
+ this.disposed = true;
276
+ if (this._server) await this._server.close();
277
+ if (this._socket) this._socket.dispose();
278
+ if (void 0 !== exitCode) process.exit(exitCode);
279
+ };
280
+ assert('number' == typeof port);
281
+ this.port = port;
282
+ this._router = new Router({
283
+ sdk,
284
+ server: this,
285
+ apis: Object.values(__rspack_external__apis_index_js_275823d6)
286
+ });
287
+ this._innerClientPath = config?.innerClientPath || '';
288
+ this._printServerUrl = config?.printServerUrl ?? true;
289
+ this._cors = config?.cors;
290
+ }
291
+ }
292
+ export { RsdoctorServer };
@@ -0,0 +1,6 @@
1
+ import type { Thirdparty } from '@rsdoctor/shared/types';
2
+ interface JsonBodyParserOptions {
3
+ limit?: number | string | ((req: Thirdparty.connect.IncomingMessage) => number | string);
4
+ }
5
+ export declare function jsonBodyParser(options?: JsonBodyParserOptions): Thirdparty.connect.NextHandleFunction;
6
+ export {};
@@ -0,0 +1,150 @@
1
+ import "node:module";
2
+ import raw_body from "raw-body";
3
+ import { createBrotliDecompress, createGunzip, createInflate } from "node:zlib";
4
+ const JSON_CONTENT_TYPE = 'application/json';
5
+ const DEFAULT_CHARSET = 'utf-8';
6
+ function createHttpError(status, message, type) {
7
+ return Object.assign(new Error(message), {
8
+ status,
9
+ statusCode: status,
10
+ type
11
+ });
12
+ }
13
+ function hasBody(req) {
14
+ return void 0 !== req.headers['transfer-encoding'] || !Number.isNaN(Number(req.headers['content-length']));
15
+ }
16
+ function getContentType(req) {
17
+ const contentType = req.headers['content-type'];
18
+ if ('string' != typeof contentType) return;
19
+ return contentType;
20
+ }
21
+ function shouldParse(req) {
22
+ const contentType = getContentType(req);
23
+ if (!contentType) return false;
24
+ return contentType.split(';', 1)[0].trim().toLowerCase() === JSON_CONTENT_TYPE;
25
+ }
26
+ function getCharset(req) {
27
+ const contentType = getContentType(req);
28
+ const match = contentType?.match(/(?:^|;)\s*charset\s*=\s*(?:"([^"]+)"|([^;\s]+))/i);
29
+ return (match?.[1] || match?.[2] || DEFAULT_CHARSET).toLowerCase();
30
+ }
31
+ function getContentStream(req) {
32
+ const contentEncoding = req.headers['content-encoding'];
33
+ const encoding = 'string' == typeof contentEncoding ? contentEncoding.toLowerCase() : 'identity';
34
+ if ('identity' === encoding) return {
35
+ stream: req,
36
+ length: req.headers['content-length']
37
+ };
38
+ let stream;
39
+ switch(encoding){
40
+ case 'gzip':
41
+ stream = createGunzip();
42
+ break;
43
+ case 'deflate':
44
+ stream = createInflate();
45
+ break;
46
+ case 'br':
47
+ stream = createBrotliDecompress();
48
+ break;
49
+ default:
50
+ throw createHttpError(415, `unsupported content encoding "${encoding}"`, 'encoding.unsupported');
51
+ }
52
+ const cleanup = ()=>{
53
+ req.removeListener('aborted', onAborted);
54
+ req.removeListener('close', onClose);
55
+ req.removeListener('error', onError);
56
+ stream.removeListener('close', cleanup);
57
+ };
58
+ const destroy = (error)=>{
59
+ if (!stream.destroyed) stream.destroy(error);
60
+ };
61
+ const onAborted = ()=>{
62
+ destroy(createHttpError(400, 'request aborted', 'request.aborted'));
63
+ };
64
+ const onClose = ()=>{
65
+ if (false === req.complete) onAborted();
66
+ };
67
+ const onError = (error)=>{
68
+ destroy(error);
69
+ };
70
+ req.once('aborted', onAborted);
71
+ req.once('close', onClose);
72
+ req.once('error', onError);
73
+ stream.once('close', cleanup);
74
+ req.pipe(stream);
75
+ return {
76
+ stream,
77
+ cleanup,
78
+ decompressor: stream
79
+ };
80
+ }
81
+ function parseJson(body) {
82
+ if (0 === body.length) return {};
83
+ let value;
84
+ try {
85
+ value = JSON.parse(body);
86
+ } catch (error) {
87
+ throw createHttpError(400, error.message, 'entity.parse.failed');
88
+ }
89
+ if (null === value || 'object' != typeof value) throw createHttpError(400, 'JSON body must be an object or array', 'entity.parse.failed');
90
+ return value;
91
+ }
92
+ function normalizeReadError(error, charset) {
93
+ if (error instanceof Error && 'status' in error && 'number' == typeof error.status) {
94
+ if (charset && 'type' in error && 'encoding.unsupported' === error.type) return createHttpError(415, `unsupported charset "${charset.toUpperCase()}"`, 'charset.unsupported');
95
+ return error;
96
+ }
97
+ return createHttpError(400, error instanceof Error ? error.message : 'failed to read request body', 'request.invalid');
98
+ }
99
+ function jsonBodyParser(options = {}) {
100
+ return (req, _res, next)=>{
101
+ const request = req;
102
+ if (!('body' in request)) request.body = void 0;
103
+ if (!hasBody(req) || !shouldParse(req)) return void next();
104
+ const charset = getCharset(req);
105
+ if (!charset.startsWith('utf-')) {
106
+ req.resume();
107
+ next(createHttpError(415, `unsupported charset "${charset.toUpperCase()}"`, 'charset.unsupported'));
108
+ return;
109
+ }
110
+ let content;
111
+ try {
112
+ content = getContentStream(req);
113
+ } catch (error) {
114
+ req.resume();
115
+ next(normalizeReadError(error));
116
+ return;
117
+ }
118
+ const handleError = (error)=>{
119
+ content.cleanup?.();
120
+ if (content.decompressor) {
121
+ req.unpipe(content.decompressor);
122
+ content.decompressor.destroy();
123
+ }
124
+ req.resume();
125
+ next(normalizeReadError(error, charset));
126
+ };
127
+ let limit;
128
+ try {
129
+ limit = 'function' == typeof options.limit ? options.limit(req) : options.limit;
130
+ } catch (error) {
131
+ handleError(error);
132
+ return;
133
+ }
134
+ raw_body(content.stream, {
135
+ encoding: charset,
136
+ length: content.length,
137
+ limit
138
+ }).then((body)=>{
139
+ try {
140
+ request.body = parseJson(body);
141
+ } catch (error) {
142
+ handleError(error);
143
+ return;
144
+ }
145
+ content.cleanup?.();
146
+ next();
147
+ }, handleError);
148
+ };
149
+ }
150
+ export { jsonBodyParser };
@@ -0,0 +1,24 @@
1
+ import type { ServerResponse } from 'http';
2
+ import { Common, SDK, Thirdparty } from '@rsdoctor/shared/types';
3
+ import { BaseAPI } from './apis/base.js';
4
+ interface RouterOptions {
5
+ apis: Common.Constructor<typeof BaseAPI>[];
6
+ sdk: SDK.RsdoctorBuilderSDKInstance;
7
+ server: SDK.RsdoctorServerInstance;
8
+ }
9
+ export declare class Router {
10
+ protected options: RouterOptions;
11
+ static routes: {
12
+ /**
13
+ * - `key` is the constructor of object which used to match the API class
14
+ */
15
+ get: Map<new (sdk: SDK.RsdoctorSDKInstance, server: SDK.RsdoctorServerInstance) => BaseAPI, [apiKey: PropertyKey, pathname: string][]>;
16
+ post: Map<new (sdk: SDK.RsdoctorSDKInstance, server: SDK.RsdoctorServerInstance) => BaseAPI, [apiKey: PropertyKey, pathname: string][]>;
17
+ };
18
+ static get(pathname: string): MethodDecorator;
19
+ static post(pathname: string): MethodDecorator;
20
+ constructor(options: RouterOptions);
21
+ setup(): Promise<void>;
22
+ wrapAPIFunction<T extends BaseAPI>(api: T, key: PropertyKey): (req: Thirdparty.connect.IncomingMessage, res: ServerResponse) => Promise<unknown>;
23
+ }
24
+ export {};