@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,83 @@
1
+ import "node:module";
2
+ const normalizeAPIKey = (key)=>{
3
+ if (key && 'object' == typeof key && 'name' in key) return key.name;
4
+ return key;
5
+ };
6
+ class Router {
7
+ static get(pathname) {
8
+ return (target, propertyKey, descriptor)=>{
9
+ const routes = Router.routes.get;
10
+ const constructor = target.constructor;
11
+ if (!routes.has(constructor)) routes.set(constructor, []);
12
+ routes.get(constructor).push([
13
+ normalizeAPIKey(propertyKey),
14
+ pathname
15
+ ]);
16
+ return descriptor;
17
+ };
18
+ }
19
+ static post(pathname) {
20
+ return (target, propertyKey, descriptor)=>{
21
+ const routes = Router.routes.post;
22
+ const constructor = target.constructor;
23
+ if (!routes.has(constructor)) routes.set(constructor, []);
24
+ routes.get(constructor).push([
25
+ normalizeAPIKey(propertyKey),
26
+ pathname
27
+ ]);
28
+ return descriptor;
29
+ };
30
+ }
31
+ async setup() {
32
+ const { apis, sdk, server } = this.options;
33
+ apis.forEach((API)=>{
34
+ const obj = new API(sdk, server);
35
+ Router.routes.get.get(API)?.forEach(([key, pathname])=>{
36
+ server.get(pathname, this.wrapAPIFunction(obj, key));
37
+ });
38
+ Router.routes.post.get(API)?.forEach(([key, pathname])=>{
39
+ server.post(pathname, this.wrapAPIFunction(obj, key));
40
+ });
41
+ });
42
+ }
43
+ wrapAPIFunction(api, key) {
44
+ const { sdk, server } = this.options;
45
+ return async (req, res)=>{
46
+ const ctx = {
47
+ req,
48
+ res,
49
+ sdk,
50
+ server
51
+ };
52
+ const trap = new Proxy(api, {
53
+ get (target, key, receiver) {
54
+ switch(key){
55
+ case 'ctx':
56
+ return ctx;
57
+ default:
58
+ return Reflect.get(target, key, receiver);
59
+ }
60
+ },
61
+ set (target, key, value, receiver) {
62
+ return Reflect.set(target, key, value, receiver);
63
+ },
64
+ defineProperty (target, p, attrs) {
65
+ return Reflect.defineProperty(target, p, attrs);
66
+ }
67
+ });
68
+ const fn = api[key];
69
+ const result = await fn.call(trap, trap);
70
+ if ('string' == typeof result) return Buffer.from(result, 'utf-8');
71
+ if (result && 'object' == typeof result) return Buffer.from(JSON.stringify(result), 'utf-8');
72
+ return result;
73
+ };
74
+ }
75
+ constructor(options){
76
+ this.options = options;
77
+ }
78
+ }
79
+ Router.routes = {
80
+ get: new Map(),
81
+ post: new Map()
82
+ };
83
+ export { Router };
@@ -0,0 +1,5 @@
1
+ export declare const DEFAULT_ALLOWED_CORS_ORIGINS: RegExp;
2
+ export declare function isAllowedRequestOrigin(origin: string | string[] | undefined): boolean;
3
+ export declare function isAllowedRequestHost(host: string | string[] | undefined): boolean;
4
+ export declare function isAllowedCorsRequest(origin: string | string[] | undefined, host: string | string[] | undefined): boolean;
5
+ export declare function isAllowedOpenInEditorToken(token: string | null, expectedToken: string): boolean;
@@ -0,0 +1,47 @@
1
+ import "node:module";
2
+ import { isIP } from "node:net";
3
+ import { timingSafeEqual } from "node:crypto";
4
+ const DEFAULT_ALLOWED_CORS_ORIGINS = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
5
+ const LOCAL_HOSTNAMES = /^(?:localhost|[^:]+\.localhost)$/;
6
+ function isAllowedRequestOrigin(origin) {
7
+ if (void 0 === origin) return true;
8
+ return 'string' == typeof origin && DEFAULT_ALLOWED_CORS_ORIGINS.test(origin);
9
+ }
10
+ function getHostnameFromOrigin(origin) {
11
+ try {
12
+ const hostname = new URL(origin).hostname.toLowerCase();
13
+ return hostname.startsWith('[') && hostname.endsWith(']') ? hostname.slice(1, -1) : hostname;
14
+ } catch {
15
+ return '';
16
+ }
17
+ }
18
+ function isIpAddress(hostname) {
19
+ return 0 !== isIP(hostname);
20
+ }
21
+ function getHostnameFromHost(host) {
22
+ if (host.startsWith('[')) {
23
+ const endIndex = host.indexOf(']');
24
+ return -1 === endIndex ? '' : host.slice(1, endIndex);
25
+ }
26
+ return host.split(':')[0];
27
+ }
28
+ function isAllowedRequestHost(host) {
29
+ if ('string' != typeof host) return false;
30
+ const hostname = getHostnameFromHost(host).toLowerCase();
31
+ return LOCAL_HOSTNAMES.test(hostname) || isIpAddress(hostname);
32
+ }
33
+ function isAllowedCorsRequest(origin, host) {
34
+ if (void 0 === origin) return true;
35
+ if ('string' != typeof origin || 'string' != typeof host || !isAllowedRequestOrigin(origin)) return false;
36
+ const originHostname = getHostnameFromOrigin(origin);
37
+ const hostHostname = getHostnameFromHost(host).toLowerCase();
38
+ if (originHostname.endsWith('.localhost')) return originHostname === hostHostname;
39
+ return true;
40
+ }
41
+ function isAllowedOpenInEditorToken(token, expectedToken) {
42
+ if ('string' != typeof token || !expectedToken) return false;
43
+ const tokenBuffer = Buffer.from(token);
44
+ const expectedTokenBuffer = Buffer.from(expectedToken);
45
+ return tokenBuffer.length === expectedTokenBuffer.length && timingSafeEqual(tokenBuffer, expectedTokenBuffer);
46
+ }
47
+ export { DEFAULT_ALLOWED_CORS_ORIGINS, isAllowedCorsRequest, isAllowedOpenInEditorToken, isAllowedRequestHost, isAllowedRequestOrigin };
@@ -0,0 +1,15 @@
1
+ import { Data } from '../../../common/index.js';
2
+ import { Manifest, SDK } from '@rsdoctor/shared/types';
3
+ interface SocketAPILoaderOptions {
4
+ sdk: SDK.RsdoctorBuilderSDKInstance;
5
+ }
6
+ export declare class SocketAPILoader implements Manifest.ManifestDataLoader {
7
+ protected options: SocketAPILoaderOptions;
8
+ protected dataLoader: Data.APIDataLoader;
9
+ constructor(options: SocketAPILoaderOptions);
10
+ loadManifest(): Promise<Manifest.RsdoctorManifestWithShardingFiles>;
11
+ loadData<T extends Manifest.RsdoctorManifestMappingKeys>(key: T): Promise<Manifest.InferManifestDataValue<T>>;
12
+ loadData(key: string): Promise<void>;
13
+ get loadAPIData(): <T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, body: SDK.ServerAPI.InferRequestBodyType<T>) => Promise<SDK.ServerAPI.InferResponseType<T>>;
14
+ }
15
+ export {};
@@ -0,0 +1,22 @@
1
+ import "node:module";
2
+ import { Data } from "../../../common/index.js";
3
+ class SocketAPILoader {
4
+ async loadManifest() {
5
+ return this.options.sdk.getManifestData();
6
+ }
7
+ async loadData(key) {
8
+ const data = this.options.sdk.getStoreData();
9
+ const sep = '.';
10
+ let res = data[key];
11
+ if (key.includes(sep)) res = key.split(sep).reduce((t, k)=>t[k], data);
12
+ return res;
13
+ }
14
+ get loadAPIData() {
15
+ return this.dataLoader.loadAPI;
16
+ }
17
+ constructor(options){
18
+ this.options = options;
19
+ this.dataLoader = new Data.APIDataLoader(this);
20
+ }
21
+ }
22
+ export { SocketAPILoader };
@@ -0,0 +1,48 @@
1
+ import { Common, SDK } from '@rsdoctor/shared/types';
2
+ import type { Server } from 'http';
3
+ import WebSocket, { WebSocketServer } from 'ws';
4
+ import { SocketAPILoader } from './api.js';
5
+ interface SocketOptions {
6
+ sdk: SDK.RsdoctorBuilderSDKInstance;
7
+ server: Server;
8
+ port: number;
9
+ token: string;
10
+ }
11
+ type Subscription = {
12
+ api: SDK.ServerAPI.API;
13
+ body: Common.PlainObject | null;
14
+ };
15
+ type SubscriptionRecord = Subscription & {
16
+ count: number;
17
+ };
18
+ type ClientMessage = {
19
+ type?: string;
20
+ id?: string;
21
+ api?: SDK.ServerAPI.API;
22
+ body?: Common.PlainObject | null;
23
+ };
24
+ export declare class Socket {
25
+ protected options: SocketOptions;
26
+ protected server?: WebSocketServer;
27
+ protected clients: Set<WebSocket>;
28
+ protected loader: SocketAPILoader;
29
+ protected map: Map<string, SubscriptionRecord>;
30
+ protected clientSubscriptions: Map<WebSocket, Set<string>>;
31
+ constructor(options: SocketOptions);
32
+ bootstrap(): void;
33
+ attachClient(client: WebSocket): void;
34
+ handleClientMessage(raw: string, client?: WebSocket): Promise<void>;
35
+ protected handleAPIRequestMessage(message: ClientMessage, client?: WebSocket): Promise<void>;
36
+ getSubscriptions(): Subscription[];
37
+ protected saveRequestToMap<T extends SDK.ServerAPI.API>(api: T, body?: SDK.ServerAPI.InferRequestBodyType<T, null> | null, client?: WebSocket): void;
38
+ protected removeRequestFromMap<T extends SDK.ServerAPI.API>(api: T, body?: SDK.ServerAPI.InferRequestBodyType<T, null> | null, client?: WebSocket): void;
39
+ protected removeClientSubscriptions(client: WebSocket): void;
40
+ protected removeSubscriptionKey(key: string): void;
41
+ protected getSubscriptionKey(api: SDK.ServerAPI.API, body: Common.PlainObject | null): string;
42
+ protected getAPIResponse<T extends SDK.ServerAPI.API>(api: T, body: SDK.ServerAPI.InferRequestBodyType<T>): Promise<SDK.ServerAPI.SocketResponseType<SDK.ServerAPI.API>>;
43
+ protected timer: NodeJS.Immediate | undefined;
44
+ broadcast(): Promise<void>;
45
+ sendAPIData<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, payload: SDK.ServerAPI.SocketResponseType<T>): void;
46
+ dispose(): void;
47
+ }
48
+ export {};
@@ -0,0 +1,166 @@
1
+ import "node:module";
2
+ import { SDK } from "@rsdoctor/shared/types";
3
+ import ws, { WebSocketServer } from "ws";
4
+ import { SocketAPILoader } from "./api.js";
5
+ import { isAllowedRequestHost } from "../security.js";
6
+ function isAllowedSocketToken(url, token) {
7
+ if (!url) return false;
8
+ return new URL(url, 'http://localhost').searchParams.get('token') === token;
9
+ }
10
+ class Socket {
11
+ bootstrap() {
12
+ this.server = new WebSocketServer({
13
+ server: this.options.server,
14
+ verifyClient: ({ req })=>{
15
+ const host = req.headers.host || req.headers[':authority'];
16
+ return isAllowedRequestHost(host) && isAllowedSocketToken(req.url, this.options.token);
17
+ }
18
+ });
19
+ this.server.on('connection', (client)=>{
20
+ this.attachClient(client);
21
+ });
22
+ }
23
+ attachClient(client) {
24
+ this.clients.add(client);
25
+ if ('function' == typeof client.on) {
26
+ client.on('message', (message)=>{
27
+ this.handleClientMessage(message.toString(), client);
28
+ });
29
+ client.on('close', ()=>{
30
+ this.clients.delete(client);
31
+ this.removeClientSubscriptions(client);
32
+ });
33
+ }
34
+ }
35
+ async handleClientMessage(raw, client) {
36
+ let message;
37
+ try {
38
+ message = JSON.parse(raw);
39
+ } catch {
40
+ return;
41
+ }
42
+ if (!message.api || !Object.values(SDK.ServerAPI.API).includes(message.api)) return;
43
+ if ('request' === message.type) return void await this.handleAPIRequestMessage(message, client);
44
+ if ('subscribe' === message.type) return void this.saveRequestToMap(message.api, message.body ?? null, client);
45
+ if ('unsubscribe' === message.type) this.removeRequestFromMap(message.api, message.body ?? null, client);
46
+ }
47
+ async handleAPIRequestMessage(message, client) {
48
+ if (!message.id || !client || client.readyState !== ws.OPEN) return;
49
+ try {
50
+ const response = await this.getAPIResponse(message.api, message.body);
51
+ client.send(JSON.stringify({
52
+ type: 'response',
53
+ id: message.id,
54
+ payload: response.res
55
+ }));
56
+ } catch (err) {
57
+ client.send(JSON.stringify({
58
+ type: 'response',
59
+ id: message.id,
60
+ error: err instanceof Error ? err.message : String(err)
61
+ }));
62
+ }
63
+ }
64
+ getSubscriptions() {
65
+ return [
66
+ ...this.map.values()
67
+ ].map(({ api, body })=>({
68
+ api,
69
+ body
70
+ }));
71
+ }
72
+ saveRequestToMap(api, body = null, client) {
73
+ const key = this.getSubscriptionKey(api, body);
74
+ if (client) {
75
+ if (!this.clientSubscriptions.has(client)) this.clientSubscriptions.set(client, new Set());
76
+ const subscriptions = this.clientSubscriptions.get(client);
77
+ if (subscriptions.has(key)) return;
78
+ subscriptions.add(key);
79
+ }
80
+ const record = this.map.get(key);
81
+ if (record) {
82
+ record.count += 1;
83
+ return;
84
+ }
85
+ this.map.set(key, {
86
+ api,
87
+ body,
88
+ count: 1
89
+ });
90
+ }
91
+ removeRequestFromMap(api, body = null, client) {
92
+ const key = this.getSubscriptionKey(api, body);
93
+ if (client) {
94
+ const subscriptions = this.clientSubscriptions.get(client);
95
+ if (!subscriptions?.has(key)) return;
96
+ subscriptions.delete(key);
97
+ if (0 === subscriptions.size) this.clientSubscriptions.delete(client);
98
+ }
99
+ this.removeSubscriptionKey(key);
100
+ }
101
+ removeClientSubscriptions(client) {
102
+ const subscriptions = this.clientSubscriptions.get(client);
103
+ if (!subscriptions) return;
104
+ subscriptions.forEach((key)=>this.removeSubscriptionKey(key));
105
+ this.clientSubscriptions.delete(client);
106
+ }
107
+ removeSubscriptionKey(key) {
108
+ const record = this.map.get(key);
109
+ if (!record) return;
110
+ record.count -= 1;
111
+ if (record.count <= 0) this.map.delete(key);
112
+ }
113
+ getSubscriptionKey(api, body) {
114
+ return `${api}:${JSON.stringify(body ?? null)}`;
115
+ }
116
+ async getAPIResponse(api, body) {
117
+ const data = await this.loader.loadAPIData(api, body);
118
+ const response = {
119
+ req: {
120
+ api,
121
+ body
122
+ },
123
+ res: data
124
+ };
125
+ return response;
126
+ }
127
+ async broadcast() {
128
+ clearImmediate(this.timer);
129
+ this.timer = setImmediate(async ()=>{
130
+ const promises = [];
131
+ this.map.forEach(({ api, body })=>{
132
+ promises.push((async ()=>{
133
+ const res = await this.getAPIResponse(api, body);
134
+ this.sendAPIData(api, res);
135
+ })());
136
+ });
137
+ await Promise.all(promises);
138
+ });
139
+ }
140
+ sendAPIData(api, payload) {
141
+ const message = JSON.stringify({
142
+ api,
143
+ payload
144
+ });
145
+ this.clients.forEach((client)=>{
146
+ if (client.readyState === ws.OPEN) client.send(message);
147
+ });
148
+ }
149
+ dispose() {
150
+ this.clients.forEach((client)=>{
151
+ client.close();
152
+ });
153
+ this.clients.clear();
154
+ this.server?.close();
155
+ }
156
+ constructor(options){
157
+ this.options = options;
158
+ this.clients = new Set();
159
+ this.map = new Map();
160
+ this.clientSubscriptions = new Map();
161
+ this.loader = new SocketAPILoader({
162
+ sdk: options.sdk
163
+ });
164
+ }
165
+ }
166
+ export { Socket };
@@ -0,0 +1,6 @@
1
+ import { SDK } from '@rsdoctor/shared/types';
2
+ export declare function getDataByPagination<T>(data: T[], pagination: SDK.ServerAPI.PaginationRequest): {
3
+ data: T[];
4
+ pagination: SDK.ServerAPI.PaginationResponse;
5
+ };
6
+ export declare function getLocalIpAddress(): string;
@@ -0,0 +1,19 @@
1
+ import "node:module";
2
+ import os from "os";
3
+ function getDataByPagination(data, pagination) {
4
+ const { page = 1, pageSize = 1000 } = pagination;
5
+ return {
6
+ data: data.slice((page - 1) * pageSize, page * pageSize),
7
+ pagination: {
8
+ page,
9
+ pageSize,
10
+ hasNextPage: page <= 0 ? false : page * pageSize < data.length
11
+ }
12
+ };
13
+ }
14
+ function getLocalIpAddress() {
15
+ const interfaces = os.networkInterfaces();
16
+ for (const iface of Object.values(interfaces))for (const alias of iface)if ('IPv4' === alias.family && !alias.internal) return alias.address;
17
+ return '127.0.0.1';
18
+ }
19
+ export { getDataByPagination, getLocalIpAddress };
@@ -0,0 +1 @@
1
+ export declare function findRoot(startDir?: string): string | null;
@@ -0,0 +1,22 @@
1
+ import "node:module";
2
+ import path from "path";
3
+ import fs from "fs";
4
+ function findRoot(startDir = process.cwd()) {
5
+ let dir = startDir;
6
+ let firstPkgDir = null;
7
+ while(dir !== path.parse(dir).root){
8
+ if (fs.existsSync(path.join(dir, 'pnpm-workspace.yaml'))) return dir;
9
+ if (fs.existsSync(path.join(dir, 'yarn.lock'))) return dir;
10
+ if (fs.existsSync(path.join(dir, 'lerna.json'))) return dir;
11
+ const pkgPath = path.join(dir, 'package.json');
12
+ if (fs.existsSync(pkgPath)) {
13
+ if (!firstPkgDir) firstPkgDir = dir;
14
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
15
+ if (pkg.workspaces) return dir;
16
+ }
17
+ dir = path.dirname(dir);
18
+ }
19
+ if (firstPkgDir) return firstPkgDir;
20
+ return null;
21
+ }
22
+ export { findRoot };
@@ -0,0 +1 @@
1
+ export declare const CLOUD_DIR: string;
@@ -0,0 +1,4 @@
1
+ import "node:module";
2
+ import dayjs from "dayjs";
3
+ const CLOUD_DIR = `rsdoctor/manifests/${dayjs().format('YYYYMMDD')}`;
4
+ export { CLOUD_DIR };
@@ -0,0 +1,3 @@
1
+ export * from './constant.js';
2
+ export * from './base.js';
3
+ export * from './upload.js';
@@ -0,0 +1,4 @@
1
+ import "node:module";
2
+ export * from "./constant.js";
3
+ export * from "./base.js";
4
+ export * from "./upload.js";
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Reads the BROWSER environment variable and decides what to do with it.
3
+ */
4
+ export declare function openBrowser(url: string, needEncodeURI?: boolean): Promise<boolean | undefined>;
@@ -0,0 +1,53 @@
1
+ import "node:module";
2
+ import { exec } from "node:child_process";
3
+ import { promisify } from "node:util";
4
+ import { logger } from "../../logger.js";
5
+ import { join } from "node:path";
6
+ const execAsync = promisify(exec);
7
+ const supportedChromiumBrowsers = [
8
+ 'Google Chrome Canary',
9
+ 'Google Chrome Dev',
10
+ 'Google Chrome Beta',
11
+ 'Google Chrome',
12
+ 'Microsoft Edge',
13
+ 'Brave Browser',
14
+ 'Vivaldi',
15
+ 'Chromium'
16
+ ];
17
+ const getTargetBrowser = async ()=>{
18
+ let targetBrowser = process.env.BROWSER;
19
+ if (!targetBrowser || !supportedChromiumBrowsers.includes(targetBrowser)) {
20
+ const { stdout: ps } = await execAsync('ps cax');
21
+ targetBrowser = supportedChromiumBrowsers.find((b)=>ps.includes(b));
22
+ }
23
+ return targetBrowser;
24
+ };
25
+ const openWithDefaultBrowser = async (url)=>{
26
+ try {
27
+ const { default: open } = await import("open");
28
+ await open(url);
29
+ return true;
30
+ } catch (err) {
31
+ logger.error('Failed to open Rsdoctor URL.');
32
+ logger.error(err);
33
+ return false;
34
+ }
35
+ };
36
+ async function openBrowser(url, needEncodeURI = true) {
37
+ const shouldTryOpenChromeWithAppleScript = 'darwin' === process.platform;
38
+ if (shouldTryOpenChromeWithAppleScript) try {
39
+ const targetBrowser = await getTargetBrowser();
40
+ if (targetBrowser) {
41
+ await execAsync(`osascript openChrome.applescript "${needEncodeURI ? encodeURI(url) : url}" "${targetBrowser}"`, {
42
+ cwd: join(__dirname, '../static')
43
+ });
44
+ return true;
45
+ }
46
+ logger.debug('Failed to find the target browser.');
47
+ } catch (err) {
48
+ logger.debug("Failed to open Rsdoctor URL with apple script.");
49
+ logger.debug(err);
50
+ }
51
+ return openWithDefaultBrowser(url);
52
+ }
53
+ export { openBrowser };
@@ -0,0 +1,2 @@
1
+ import { DataWithUrl } from '../sdk/types.js';
2
+ export declare const transformDataUrls: (d: DataWithUrl[]) => Record<string, string[] | string>;
@@ -0,0 +1,6 @@
1
+ import "node:module";
2
+ const transformDataUrls = (d)=>d.reduce((t, item)=>{
3
+ t[item.name] = Array.isArray(item.files) ? item.files.map((e)=>e.path).concat(t[item.name] || []) : item.files;
4
+ return t;
5
+ }, {});
6
+ export { transformDataUrls };
package/dist/sdk.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './sdk/index.js';
package/dist/sdk.js ADDED
@@ -0,0 +1,2 @@
1
+ import "node:module";
2
+ export * from "./sdk/index.js";
@@ -1,4 +1,3 @@
1
- export * from './chunks.js';
2
1
  export * from './rules.js';
3
2
  export * from './loader.js';
4
3
  export * from './plugin.js';
@@ -1,5 +1,4 @@
1
1
  import "node:module";
2
- export * from "./chunks.js";
3
2
  export * from "./rules.js";
4
3
  export * from "./loader.js";
5
4
  export * from "./plugin.js";
@@ -1,4 +1,4 @@
1
- import { Loader } from '@rsdoctor/utils/common';
1
+ import { Loader } from '../common/index.js';
2
2
  export interface ProxyLoaderInternalOptions {
3
3
  cwd: string;
4
4
  /**
@@ -1,6 +1,7 @@
1
- import type { RsdoctorPrimarySDK } from '@rsdoctor/sdk';
2
- import type { Linter, Linter as LinterType, Plugin, SDK } from '@rsdoctor/types';
3
- export interface RsdoctorMultiplePluginOptions<Rules extends LinterType.ExtendRuleData[] = LinterType.ExtendRuleData[]> extends Omit<Plugin.RsdoctorWebpackPluginOptions<Rules>, 'sdkInstance'>, Pick<ConstructorParameters<typeof RsdoctorPrimarySDK>[0], 'stage'> {
1
+ import type { Linter, Linter as LinterType, Plugin, SDK } from '@rsdoctor/shared/types';
2
+ export interface RsdoctorMultiplePluginOptions<Rules extends LinterType.ExtendRuleData[] = LinterType.ExtendRuleData[]> extends Omit<Plugin.RsdoctorRspackPluginOptions<Rules>, 'sdkInstance'>, Pick<{
3
+ stage?: number;
4
+ }, 'stage'> {
4
5
  /**
5
6
  * name of builder
6
7
  */
@@ -24,28 +25,6 @@ export interface RsdoctorPluginInstance<T extends Plugin.BaseCompiler, Rules ext
24
25
  modulesGraph: SDK.ModuleGraphInstance;
25
26
  ensureModulesChunksGraphApplied(compiler: T): void;
26
27
  }
27
- export interface RsdoctorRspackPluginInstance<Rules extends LinterType.ExtendRuleData[] = []> extends RsdoctorPluginInstance<Plugin.BaseCompilerType<'rspack'>, Rules> {
28
- }
29
- export interface NativePluginConfig {
30
- moduleGraph?: boolean;
31
- chunkGraph?: boolean;
32
- }
33
- export interface RsdoctorRspackPluginExperiments {
34
- /**
35
- * Whether to enable the native plugin to improve the performance.
36
- * @default true
37
- */
38
- enableNativePlugin?: boolean;
39
- }
40
- export interface RsdoctorRspackPluginExperimentsNormalized {
41
- enableNativePlugin?: NativePluginConfig;
42
- }
43
- export interface RsdoctorRspackPluginOptions<Rules extends LinterType.ExtendRuleData[]> extends Plugin.RsdoctorWebpackPluginOptions<Rules> {
44
- /**
45
- * The experiments of the Rsdoctor Rspack plugin.
46
- */
47
- experiments?: RsdoctorRspackPluginExperiments;
48
- }
49
- export type RsdoctorRspackPluginOptionsNormalized<Rules extends Linter.ExtendRuleData[]> = Plugin.RsdoctorPluginOptionsNormalized<Rules> & {
50
- experiments?: RsdoctorRspackPluginExperimentsNormalized;
51
- };
28
+ export type RsdoctorRspackPluginInstance<Rules extends LinterType.ExtendRuleData[] = []> = RsdoctorPluginInstance<Plugin.BaseCompilerType<'rspack'>, Rules>;
29
+ export type RsdoctorRspackPluginOptions<Rules extends LinterType.ExtendRuleData[]> = Plugin.RsdoctorRspackPluginOptions<Rules>;
30
+ export type RsdoctorRspackPluginOptionsNormalized<Rules extends Linter.ExtendRuleData[]> = Plugin.RsdoctorPluginOptionsNormalized<Rules>;
@@ -1,7 +1,7 @@
1
- import { RuleSetRule } from 'webpack';
2
- export interface Rule extends RuleSetRule {
1
+ import type { RuleSetRule } from '@rspack/core';
2
+ export type Rule = RuleSetRule & {
3
3
  /**
4
- * https://webpack.js.org/configuration/module/#ruleloaders
4
+ * The legacy `loaders` field used by rule normalizers.
5
5
  */
6
6
  loaders: RuleSetRule['use'];
7
- }
7
+ };