@bleedingdev/modern-js-utils 3.2.0-ultramodern.0

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 (387) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -0
  3. package/dist/cjs/cli/alias.js +82 -0
  4. package/dist/cjs/cli/applyOptionsChain.js +50 -0
  5. package/dist/cjs/cli/commands.js +69 -0
  6. package/dist/cjs/cli/common.js +59 -0
  7. package/dist/cjs/cli/config.js +39 -0
  8. package/dist/cjs/cli/constants.js +136 -0
  9. package/dist/cjs/cli/ensure.js +56 -0
  10. package/dist/cjs/cli/fs.js +46 -0
  11. package/dist/cjs/cli/get/config.js +48 -0
  12. package/dist/cjs/cli/get/data.js +106 -0
  13. package/dist/cjs/cli/get/index.js +112 -0
  14. package/dist/cjs/cli/index.js +212 -0
  15. package/dist/cjs/cli/is/config.js +86 -0
  16. package/dist/cjs/cli/is/env.js +52 -0
  17. package/dist/cjs/cli/is/index.js +79 -0
  18. package/dist/cjs/cli/is/project.js +147 -0
  19. package/dist/cjs/cli/is/type.js +84 -0
  20. package/dist/cjs/cli/logger.js +39 -0
  21. package/dist/cjs/cli/modulePath.js +87 -0
  22. package/dist/cjs/cli/monorepo.js +110 -0
  23. package/dist/cjs/cli/package.js +97 -0
  24. package/dist/cjs/cli/path.js +111 -0
  25. package/dist/cjs/cli/port.js +79 -0
  26. package/dist/cjs/cli/prettyInstructions.js +117 -0
  27. package/dist/cjs/cli/require.js +127 -0
  28. package/dist/cjs/cli/route.js +76 -0
  29. package/dist/cjs/cli/runtimeExports.js +86 -0
  30. package/dist/cjs/cli/tsconfig.js +51 -0
  31. package/dist/cjs/cli/version.js +67 -0
  32. package/dist/cjs/cli/watch.js +87 -0
  33. package/dist/cjs/compiled.js +209 -0
  34. package/dist/cjs/import.js +56 -0
  35. package/dist/cjs/index.js +72 -0
  36. package/dist/cjs/universal/constants.js +84 -0
  37. package/dist/cjs/universal/index.js +36 -0
  38. package/dist/cjs/universal/path.js +36 -0
  39. package/dist/cjs/universal/pluginDagSort.js +75 -0
  40. package/dist/compiled/address/index.js +171 -0
  41. package/dist/compiled/address/lib/address.d.ts +28 -0
  42. package/dist/compiled/address/package.json +1 -0
  43. package/dist/compiled/browserslist/index.d.ts +178 -0
  44. package/dist/compiled/browserslist/index.js +1329 -0
  45. package/dist/compiled/browserslist/license +20 -0
  46. package/dist/compiled/browserslist/package.json +1 -0
  47. package/dist/compiled/chalk/index.d.ts +415 -0
  48. package/dist/compiled/chalk/index.js +2368 -0
  49. package/dist/compiled/chalk/license +9 -0
  50. package/dist/compiled/chalk/package.json +1 -0
  51. package/dist/compiled/chokidar/anymatch/index.d.ts +19 -0
  52. package/dist/compiled/chokidar/fsevents.node +0 -0
  53. package/dist/compiled/chokidar/index.js +4162 -0
  54. package/dist/compiled/chokidar/index.js.LICENSE.txt +41 -0
  55. package/dist/compiled/chokidar/license +21 -0
  56. package/dist/compiled/chokidar/package.json +1 -0
  57. package/dist/compiled/chokidar/types/index.d.ts +188 -0
  58. package/dist/compiled/commander/index.js +1540 -0
  59. package/dist/compiled/commander/index.mjs +2 -0
  60. package/dist/compiled/commander/license +22 -0
  61. package/dist/compiled/commander/package.json +1 -0
  62. package/dist/compiled/commander/typings/index.d.ts +890 -0
  63. package/dist/compiled/debug/index.d.ts +54 -0
  64. package/dist/compiled/debug/index.js +621 -0
  65. package/dist/compiled/debug/license +20 -0
  66. package/dist/compiled/debug/ms/index.d.ts +25 -0
  67. package/dist/compiled/debug/package.json +1 -0
  68. package/dist/compiled/dotenv/index.js +101 -0
  69. package/dist/compiled/dotenv/license +23 -0
  70. package/dist/compiled/dotenv/package.json +1 -0
  71. package/dist/compiled/dotenv/types/index.d.ts +59 -0
  72. package/dist/compiled/dotenv-expand/index.d.ts +15 -0
  73. package/dist/compiled/dotenv-expand/index.js +54 -0
  74. package/dist/compiled/dotenv-expand/license +24 -0
  75. package/dist/compiled/dotenv-expand/package.json +1 -0
  76. package/dist/compiled/execa/index.d.ts +564 -0
  77. package/dist/compiled/execa/index.js +1738 -0
  78. package/dist/compiled/execa/license +9 -0
  79. package/dist/compiled/execa/package.json +1 -0
  80. package/dist/compiled/fast-glob/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
  81. package/dist/compiled/fast-glob/@nodelib/fs.scandir/out/index.d.ts +12 -0
  82. package/dist/compiled/fast-glob/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
  83. package/dist/compiled/fast-glob/@nodelib/fs.scandir/out/settings.d.ts +20 -0
  84. package/dist/compiled/fast-glob/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
  85. package/dist/compiled/fast-glob/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
  86. package/dist/compiled/fast-glob/@nodelib/fs.stat/out/index.d.ts +12 -0
  87. package/dist/compiled/fast-glob/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
  88. package/dist/compiled/fast-glob/@nodelib/fs.stat/out/settings.d.ts +16 -0
  89. package/dist/compiled/fast-glob/@nodelib/fs.stat/out/types/index.d.ts +4 -0
  90. package/dist/compiled/fast-glob/@nodelib/fs.walk/out/index.d.ts +14 -0
  91. package/dist/compiled/fast-glob/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
  92. package/dist/compiled/fast-glob/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
  93. package/dist/compiled/fast-glob/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
  94. package/dist/compiled/fast-glob/@nodelib/fs.walk/out/settings.d.ts +30 -0
  95. package/dist/compiled/fast-glob/@nodelib/fs.walk/out/types/index.d.ts +8 -0
  96. package/dist/compiled/fast-glob/index.js +4665 -0
  97. package/dist/compiled/fast-glob/index.js.LICENSE.txt +38 -0
  98. package/dist/compiled/fast-glob/license +21 -0
  99. package/dist/compiled/fast-glob/out/index.d.ts +27 -0
  100. package/dist/compiled/fast-glob/out/managers/tasks.d.ts +22 -0
  101. package/dist/compiled/fast-glob/out/settings.d.ts +164 -0
  102. package/dist/compiled/fast-glob/out/types/index.d.ts +31 -0
  103. package/dist/compiled/fast-glob/package.json +1 -0
  104. package/dist/compiled/filesize/filesize.d.ts +131 -0
  105. package/dist/compiled/filesize/index.js +198 -0
  106. package/dist/compiled/filesize/index.js.LICENSE.txt +7 -0
  107. package/dist/compiled/filesize/license +28 -0
  108. package/dist/compiled/filesize/package.json +1 -0
  109. package/dist/compiled/fs-extra/index.d.ts +563 -0
  110. package/dist/compiled/fs-extra/index.js +2222 -0
  111. package/dist/compiled/fs-extra/license +15 -0
  112. package/dist/compiled/fs-extra/package.json +1 -0
  113. package/dist/compiled/glob/index.d.ts +91 -0
  114. package/dist/compiled/glob/index.js +2011 -0
  115. package/dist/compiled/glob/license +21 -0
  116. package/dist/compiled/glob/minimatch/index.d.ts +204 -0
  117. package/dist/compiled/glob/package.json +1 -0
  118. package/dist/compiled/globby/index.d.ts +186 -0
  119. package/dist/compiled/globby/index.js +690 -0
  120. package/dist/compiled/globby/license +9 -0
  121. package/dist/compiled/globby/package.json +1 -0
  122. package/dist/compiled/gzip-size/index.d.ts +96 -0
  123. package/dist/compiled/gzip-size/index.js +157 -0
  124. package/dist/compiled/gzip-size/license +9 -0
  125. package/dist/compiled/gzip-size/package.json +1 -0
  126. package/dist/compiled/import-lazy/index.d.ts +26 -0
  127. package/dist/compiled/import-lazy/index.js +45 -0
  128. package/dist/compiled/import-lazy/license +9 -0
  129. package/dist/compiled/import-lazy/package.json +1 -0
  130. package/dist/compiled/inquirer/index.d.ts +997 -0
  131. package/dist/compiled/inquirer/index.js +20167 -0
  132. package/dist/compiled/inquirer/index.js.LICENSE.txt +7 -0
  133. package/dist/compiled/inquirer/lib/objects/choice.d.ts +65 -0
  134. package/dist/compiled/inquirer/lib/objects/choices.d.ts +206 -0
  135. package/dist/compiled/inquirer/lib/objects/separator.d.ts +37 -0
  136. package/dist/compiled/inquirer/lib/ui/baseUI.d.ts +37 -0
  137. package/dist/compiled/inquirer/lib/ui/bottom-bar.d.ts +65 -0
  138. package/dist/compiled/inquirer/lib/ui/prompt.d.ts +104 -0
  139. package/dist/compiled/inquirer/license +22 -0
  140. package/dist/compiled/inquirer/package.json +1 -0
  141. package/dist/compiled/inquirer/through/index.d.ts +25 -0
  142. package/dist/compiled/js-yaml/index.d.ts +154 -0
  143. package/dist/compiled/js-yaml/index.js +2191 -0
  144. package/dist/compiled/js-yaml/index.mjs +2167 -0
  145. package/dist/compiled/js-yaml/index.mjs.LICENSE.txt +1 -0
  146. package/dist/compiled/js-yaml/license +21 -0
  147. package/dist/compiled/js-yaml/package.json +1 -0
  148. package/dist/compiled/json5/index.js +983 -0
  149. package/dist/compiled/json5/lib/index.d.ts +4 -0
  150. package/dist/compiled/json5/lib/parse.d.ts +15 -0
  151. package/dist/compiled/json5/lib/stringify.d.ts +89 -0
  152. package/dist/compiled/json5/package.json +1 -0
  153. package/dist/compiled/lodash/common/array.d.ts +2126 -0
  154. package/dist/compiled/lodash/common/collection.d.ts +1930 -0
  155. package/dist/compiled/lodash/common/common.d.ts +280 -0
  156. package/dist/compiled/lodash/common/date.d.ts +23 -0
  157. package/dist/compiled/lodash/common/function.d.ts +1446 -0
  158. package/dist/compiled/lodash/common/lang.d.ts +1693 -0
  159. package/dist/compiled/lodash/common/math.d.ts +405 -0
  160. package/dist/compiled/lodash/common/number.d.ts +131 -0
  161. package/dist/compiled/lodash/common/object.d.ts +2519 -0
  162. package/dist/compiled/lodash/common/seq.d.ts +210 -0
  163. package/dist/compiled/lodash/common/string.d.ts +788 -0
  164. package/dist/compiled/lodash/common/util.d.ts +1220 -0
  165. package/dist/compiled/lodash/index.d.ts +46 -0
  166. package/dist/compiled/lodash/index.js +1 -0
  167. package/dist/compiled/lodash/index.mjs +1 -0
  168. package/dist/compiled/lodash/license +47 -0
  169. package/dist/compiled/lodash/package.json +1 -0
  170. package/dist/compiled/mime-types/index.d.ts +14 -0
  171. package/dist/compiled/mime-types/index.js +116 -0
  172. package/dist/compiled/mime-types/index.js.LICENSE.txt +13 -0
  173. package/dist/compiled/mime-types/license +23 -0
  174. package/dist/compiled/mime-types/package.json +1 -0
  175. package/dist/compiled/minimist/index.d.ts +95 -0
  176. package/dist/compiled/minimist/index.js +202 -0
  177. package/dist/compiled/minimist/license +18 -0
  178. package/dist/compiled/minimist/package.json +1 -0
  179. package/dist/compiled/nanoid/index.d.ts +91 -0
  180. package/dist/compiled/nanoid/index.js +83 -0
  181. package/dist/compiled/nanoid/index.mjs +69 -0
  182. package/dist/compiled/nanoid/license +20 -0
  183. package/dist/compiled/nanoid/package.json +1 -0
  184. package/dist/compiled/ora/cli-spinners/index.d.ts +125 -0
  185. package/dist/compiled/ora/index.d.ts +277 -0
  186. package/dist/compiled/ora/index.js +3936 -0
  187. package/dist/compiled/ora/index.js.LICENSE.txt +1 -0
  188. package/dist/compiled/ora/license +9 -0
  189. package/dist/compiled/ora/package.json +1 -0
  190. package/dist/compiled/pkg-up/index.d.ts +48 -0
  191. package/dist/compiled/pkg-up/index.js +15 -0
  192. package/dist/compiled/pkg-up/license +9 -0
  193. package/dist/compiled/pkg-up/package.json +1 -0
  194. package/dist/compiled/semver/classes/comparator.d.ts +17 -0
  195. package/dist/compiled/semver/classes/range.d.ts +21 -0
  196. package/dist/compiled/semver/classes/semver.d.ts +62 -0
  197. package/dist/compiled/semver/functions/clean.d.ts +8 -0
  198. package/dist/compiled/semver/functions/cmp.d.ts +16 -0
  199. package/dist/compiled/semver/functions/coerce.d.ts +12 -0
  200. package/dist/compiled/semver/functions/compare-build.d.ts +16 -0
  201. package/dist/compiled/semver/functions/compare-loose.d.ts +5 -0
  202. package/dist/compiled/semver/functions/compare.d.ts +20 -0
  203. package/dist/compiled/semver/functions/diff.d.ts +13 -0
  204. package/dist/compiled/semver/functions/eq.d.ts +9 -0
  205. package/dist/compiled/semver/functions/gt.d.ts +9 -0
  206. package/dist/compiled/semver/functions/gte.d.ts +9 -0
  207. package/dist/compiled/semver/functions/inc.d.ts +15 -0
  208. package/dist/compiled/semver/functions/lt.d.ts +9 -0
  209. package/dist/compiled/semver/functions/lte.d.ts +8 -0
  210. package/dist/compiled/semver/functions/major.d.ts +9 -0
  211. package/dist/compiled/semver/functions/minor.d.ts +9 -0
  212. package/dist/compiled/semver/functions/neq.d.ts +9 -0
  213. package/dist/compiled/semver/functions/parse.d.ts +12 -0
  214. package/dist/compiled/semver/functions/patch.d.ts +9 -0
  215. package/dist/compiled/semver/functions/prerelease.d.ts +12 -0
  216. package/dist/compiled/semver/functions/rcompare.d.ts +15 -0
  217. package/dist/compiled/semver/functions/rsort.d.ts +9 -0
  218. package/dist/compiled/semver/functions/satisfies.d.ts +14 -0
  219. package/dist/compiled/semver/functions/sort.d.ts +9 -0
  220. package/dist/compiled/semver/functions/valid.d.ts +11 -0
  221. package/dist/compiled/semver/index.d.ts +133 -0
  222. package/dist/compiled/semver/index.js +1779 -0
  223. package/dist/compiled/semver/internals/identifiers.d.ts +13 -0
  224. package/dist/compiled/semver/license +15 -0
  225. package/dist/compiled/semver/package.json +1 -0
  226. package/dist/compiled/semver/ranges/gtr.d.ts +14 -0
  227. package/dist/compiled/semver/ranges/intersects.d.ts +13 -0
  228. package/dist/compiled/semver/ranges/ltr.d.ts +14 -0
  229. package/dist/compiled/semver/ranges/max-satisfying.d.ts +14 -0
  230. package/dist/compiled/semver/ranges/min-satisfying.d.ts +14 -0
  231. package/dist/compiled/semver/ranges/min-version.d.ts +10 -0
  232. package/dist/compiled/semver/ranges/outside.d.ts +15 -0
  233. package/dist/compiled/semver/ranges/simplify.d.ts +14 -0
  234. package/dist/compiled/semver/ranges/subset.d.ts +13 -0
  235. package/dist/compiled/semver/ranges/to-comparators.d.ts +9 -0
  236. package/dist/compiled/semver/ranges/valid.d.ts +12 -0
  237. package/dist/compiled/signale/index.d.ts +162 -0
  238. package/dist/compiled/signale/index.js +1704 -0
  239. package/dist/compiled/signale/package.json +1 -0
  240. package/dist/compiled/slash/index.d.ts +25 -0
  241. package/dist/compiled/slash/index.js +32 -0
  242. package/dist/compiled/slash/license +9 -0
  243. package/dist/compiled/slash/package.json +1 -0
  244. package/dist/compiled/strip-ansi/index.d.ts +17 -0
  245. package/dist/compiled/strip-ansi/index.js +34 -0
  246. package/dist/compiled/strip-ansi/license +9 -0
  247. package/dist/compiled/strip-ansi/package.json +1 -0
  248. package/dist/compiled/tsconfig-paths/index.js +629 -0
  249. package/dist/compiled/tsconfig-paths/index.mjs +2 -0
  250. package/dist/compiled/tsconfig-paths/lib/config-loader.d.ts +33 -0
  251. package/dist/compiled/tsconfig-paths/lib/filesystem.d.ts +34 -0
  252. package/dist/compiled/tsconfig-paths/lib/index.d.ts +5 -0
  253. package/dist/compiled/tsconfig-paths/lib/mapping-entry.d.ts +18 -0
  254. package/dist/compiled/tsconfig-paths/lib/match-path-async.d.ts +21 -0
  255. package/dist/compiled/tsconfig-paths/lib/match-path-sync.d.ts +32 -0
  256. package/dist/compiled/tsconfig-paths/lib/register.d.ts +12 -0
  257. package/dist/compiled/tsconfig-paths/lib/try-path.d.ts +15 -0
  258. package/dist/compiled/tsconfig-paths/lib/tsconfig-loader.d.ts +28 -0
  259. package/dist/compiled/tsconfig-paths/license +21 -0
  260. package/dist/compiled/tsconfig-paths/package.json +1 -0
  261. package/dist/compiled/upath/index.js +135 -0
  262. package/dist/compiled/upath/license +22 -0
  263. package/dist/compiled/upath/package.json +1 -0
  264. package/dist/compiled/upath/upath.d.ts +241 -0
  265. package/dist/compiled/url-join/index.d.ts +17 -0
  266. package/dist/compiled/url-join/index.js +61 -0
  267. package/dist/compiled/url-join/license +21 -0
  268. package/dist/compiled/url-join/package.json +1 -0
  269. package/dist/compiled/webpack-chain/index.js +1475 -0
  270. package/dist/compiled/webpack-chain/license +373 -0
  271. package/dist/compiled/webpack-chain/package.json +1 -0
  272. package/dist/compiled/webpack-chain/types/index.d.ts +599 -0
  273. package/dist/esm/cli/alias.mjs +31 -0
  274. package/dist/esm/cli/applyOptionsChain.mjs +16 -0
  275. package/dist/esm/cli/commands.mjs +23 -0
  276. package/dist/esm/cli/common.mjs +9 -0
  277. package/dist/esm/cli/config.mjs +5 -0
  278. package/dist/esm/cli/constants.mjs +30 -0
  279. package/dist/esm/cli/ensure.mjs +9 -0
  280. package/dist/esm/cli/fs.mjs +9 -0
  281. package/dist/esm/cli/get/config.mjs +14 -0
  282. package/dist/esm/cli/get/data.mjs +49 -0
  283. package/dist/esm/cli/get/index.mjs +18 -0
  284. package/dist/esm/cli/index.mjs +23 -0
  285. package/dist/esm/cli/is/config.mjs +37 -0
  286. package/dist/esm/cli/is/env.mjs +6 -0
  287. package/dist/esm/cli/is/index.mjs +4 -0
  288. package/dist/esm/cli/is/project.mjs +75 -0
  289. package/dist/esm/cli/is/type.mjs +26 -0
  290. package/dist/esm/cli/logger.mjs +1 -0
  291. package/dist/esm/cli/modulePath.mjs +33 -0
  292. package/dist/esm/cli/monorepo.mjs +50 -0
  293. package/dist/esm/cli/package.mjs +51 -0
  294. package/dist/esm/cli/path.mjs +35 -0
  295. package/dist/esm/cli/port.mjs +35 -0
  296. package/dist/esm/cli/prettyInstructions.mjs +70 -0
  297. package/dist/esm/cli/require.mjs +79 -0
  298. package/dist/esm/cli/route.mjs +36 -0
  299. package/dist/esm/cli/runtimeExports.mjs +42 -0
  300. package/dist/esm/cli/tsconfig.mjs +7 -0
  301. package/dist/esm/cli/version.mjs +24 -0
  302. package/dist/esm/cli/watch.mjs +40 -0
  303. package/dist/esm/compiled.mjs +45 -0
  304. package/dist/esm/import.mjs +9 -0
  305. package/dist/esm/index.mjs +3 -0
  306. package/dist/esm/rslib-runtime.mjs +12 -0
  307. package/dist/esm/universal/constants.mjs +14 -0
  308. package/dist/esm/universal/index.mjs +1 -0
  309. package/dist/esm/universal/path.mjs +2 -0
  310. package/dist/esm/universal/pluginDagSort.mjs +41 -0
  311. package/dist/esm-node/cli/alias.mjs +32 -0
  312. package/dist/esm-node/cli/applyOptionsChain.mjs +17 -0
  313. package/dist/esm-node/cli/commands.mjs +24 -0
  314. package/dist/esm-node/cli/common.mjs +10 -0
  315. package/dist/esm-node/cli/config.mjs +6 -0
  316. package/dist/esm-node/cli/constants.mjs +31 -0
  317. package/dist/esm-node/cli/ensure.mjs +10 -0
  318. package/dist/esm-node/cli/fs.mjs +10 -0
  319. package/dist/esm-node/cli/get/config.mjs +15 -0
  320. package/dist/esm-node/cli/get/data.mjs +50 -0
  321. package/dist/esm-node/cli/get/index.mjs +19 -0
  322. package/dist/esm-node/cli/index.mjs +24 -0
  323. package/dist/esm-node/cli/is/config.mjs +38 -0
  324. package/dist/esm-node/cli/is/env.mjs +7 -0
  325. package/dist/esm-node/cli/is/index.mjs +5 -0
  326. package/dist/esm-node/cli/is/project.mjs +76 -0
  327. package/dist/esm-node/cli/is/type.mjs +27 -0
  328. package/dist/esm-node/cli/logger.mjs +2 -0
  329. package/dist/esm-node/cli/modulePath.mjs +34 -0
  330. package/dist/esm-node/cli/monorepo.mjs +51 -0
  331. package/dist/esm-node/cli/package.mjs +52 -0
  332. package/dist/esm-node/cli/path.mjs +36 -0
  333. package/dist/esm-node/cli/port.mjs +36 -0
  334. package/dist/esm-node/cli/prettyInstructions.mjs +71 -0
  335. package/dist/esm-node/cli/require.mjs +80 -0
  336. package/dist/esm-node/cli/route.mjs +37 -0
  337. package/dist/esm-node/cli/runtimeExports.mjs +43 -0
  338. package/dist/esm-node/cli/tsconfig.mjs +8 -0
  339. package/dist/esm-node/cli/version.mjs +25 -0
  340. package/dist/esm-node/cli/watch.mjs +41 -0
  341. package/dist/esm-node/compiled.mjs +45 -0
  342. package/dist/esm-node/import.mjs +10 -0
  343. package/dist/esm-node/index.mjs +4 -0
  344. package/dist/esm-node/universal/constants.mjs +15 -0
  345. package/dist/esm-node/universal/index.mjs +2 -0
  346. package/dist/esm-node/universal/path.mjs +3 -0
  347. package/dist/esm-node/universal/pluginDagSort.mjs +42 -0
  348. package/dist/types/cli/alias.d.ts +20 -0
  349. package/dist/types/cli/applyOptionsChain.d.ts +3 -0
  350. package/dist/types/cli/commands.d.ts +8 -0
  351. package/dist/types/cli/common.d.ts +9 -0
  352. package/dist/types/cli/config.d.ts +4 -0
  353. package/dist/types/cli/constants.d.ts +55 -0
  354. package/dist/types/cli/ensure.d.ts +8 -0
  355. package/dist/types/cli/fs.d.ts +7 -0
  356. package/dist/types/cli/get/config.d.ts +1 -0
  357. package/dist/types/cli/get/data.d.ts +6 -0
  358. package/dist/types/cli/get/index.d.ts +11 -0
  359. package/dist/types/cli/index.d.ts +23 -0
  360. package/dist/types/cli/is/config.d.ts +22 -0
  361. package/dist/types/cli/is/env.d.ts +8 -0
  362. package/dist/types/cli/is/index.d.ts +4 -0
  363. package/dist/types/cli/is/project.d.ts +39 -0
  364. package/dist/types/cli/is/type.d.ts +15 -0
  365. package/dist/types/cli/logger.d.ts +1 -0
  366. package/dist/types/cli/modulePath.d.ts +5 -0
  367. package/dist/types/cli/monorepo.d.ts +9 -0
  368. package/dist/types/cli/package.d.ts +5 -0
  369. package/dist/types/cli/path.d.ts +11 -0
  370. package/dist/types/cli/port.d.ts +12 -0
  371. package/dist/types/cli/prettyInstructions.d.ts +9 -0
  372. package/dist/types/cli/require.d.ts +9 -0
  373. package/dist/types/cli/route.d.ts +4 -0
  374. package/dist/types/cli/runtimeExports.d.ts +5 -0
  375. package/dist/types/cli/tsconfig.d.ts +1 -0
  376. package/dist/types/cli/version.d.ts +4 -0
  377. package/dist/types/cli/watch.d.ts +8 -0
  378. package/dist/types/compiled.d.ts +37 -0
  379. package/dist/types/import.d.ts +5 -0
  380. package/dist/types/index.d.ts +3 -0
  381. package/dist/types/universal/constants.d.ts +47 -0
  382. package/dist/types/universal/index.d.ts +1 -0
  383. package/dist/types/universal/path.d.ts +1 -0
  384. package/dist/types/universal/pluginDagSort.d.ts +1 -0
  385. package/package.json +174 -0
  386. package/rslib.config.mts +162 -0
  387. package/rstest.config.mts +8 -0
@@ -0,0 +1,38 @@
1
+ import "node:module";
2
+ import { MAIN_ENTRY_NAME } from "../constants.mjs";
3
+ import { isEmpty } from "./type.mjs";
4
+ const isSSR = (config)=>{
5
+ const { server } = config;
6
+ if (server?.ssr) return true;
7
+ if (server?.ssrByEntries && !isEmpty(server.ssrByEntries)) {
8
+ for (const name of Object.keys(server.ssrByEntries))if (server.ssrByEntries[name]) return true;
9
+ }
10
+ return false;
11
+ };
12
+ const isUseSSRBundle = (config)=>{
13
+ const { output } = config;
14
+ if (output?.ssg || output?.ssgByEntries && Object.keys(output?.ssgByEntries).length > 0) return true;
15
+ return isSSR(config);
16
+ };
17
+ const isUseRsc = (config)=>config?.server?.rsc;
18
+ const isServiceWorker = (config)=>{
19
+ const { output, deploy } = config;
20
+ if (deploy?.worker?.ssr && (output?.ssg || isSSR(config))) return true;
21
+ return false;
22
+ };
23
+ const isSSGEntry = (config, entryName, entrypoints)=>{
24
+ const { output, source } = config;
25
+ const single = isSingleEntry(entrypoints, source?.mainEntryName);
26
+ if (single) {
27
+ const byEntries = output?.ssgByEntries;
28
+ return Boolean(output?.ssg) || byEntries && !isEmpty(byEntries);
29
+ }
30
+ const byEntries = output?.ssgByEntries;
31
+ if (!byEntries || isEmpty(byEntries)) return false;
32
+ return Boolean(byEntries[entryName]);
33
+ };
34
+ const isSingleEntry = (entrypoints, mainEntryName = MAIN_ENTRY_NAME)=>{
35
+ const firstEntry = entrypoints[0];
36
+ return 1 === entrypoints.length && firstEntry?.entryName === mainEntryName;
37
+ };
38
+ export { isSSGEntry, isSSR, isServiceWorker, isSingleEntry, isUseRsc, isUseSSRBundle };
@@ -0,0 +1,7 @@
1
+ import "node:module";
2
+ const getNodeEnv = ()=>process.env.NODE_ENV || 'development';
3
+ const isDev = ()=>'development' === getNodeEnv();
4
+ const isProd = ()=>'production' === getNodeEnv();
5
+ const isTest = ()=>'test' === getNodeEnv();
6
+ const isBrowser = ()=>"u" > typeof window;
7
+ export { getNodeEnv, isBrowser, isDev, isProd, isTest };
@@ -0,0 +1,5 @@
1
+ import "node:module";
2
+ export * from "./config.mjs";
3
+ export * from "./env.mjs";
4
+ export * from "./project.mjs";
5
+ export * from "./type.mjs";
@@ -0,0 +1,76 @@
1
+ import "node:module";
2
+ import path from "path";
3
+ import pkg_up from "../../../compiled/pkg-up/index.js";
4
+ import { fs, minimist, semver } from "../../compiled.mjs";
5
+ import { getArgv } from "../commands.mjs";
6
+ import { createDebugger } from "../common.mjs";
7
+ import { ensureArray } from "../ensure.mjs";
8
+ import { tryResolve } from "../require.mjs";
9
+ const debug = createDebugger('judge-depExists');
10
+ const isDepExists = (appDirectory, name)=>{
11
+ const pkgPath = path.resolve(appDirectory, './package.json');
12
+ if (!fs.existsSync(pkgPath)) {
13
+ debug("can't find package.json under: %s", appDirectory);
14
+ return false;
15
+ }
16
+ const json = fs.readJSONSync(pkgPath);
17
+ const { dependencies = {}, devDependencies = {} } = json;
18
+ return dependencies.hasOwnProperty(name) || devDependencies.hasOwnProperty(name);
19
+ };
20
+ const isPackageInstalled = (name, resolvePaths)=>{
21
+ try {
22
+ tryResolve(name, ...ensureArray(resolvePaths));
23
+ return true;
24
+ } catch (err) {
25
+ return false;
26
+ }
27
+ };
28
+ const isApiOnly = async (appDirectory, entryDir, apiDir)=>{
29
+ const existApi = await fs.pathExists(apiDir ?? path.join(appDirectory, 'api'));
30
+ const existSrc = await fs.pathExists(path.join(appDirectory, entryDir ?? 'src'));
31
+ const options = minimist(getArgv());
32
+ if (options['api-only']) return true;
33
+ return existApi && !existSrc;
34
+ };
35
+ const isWebOnly = async ()=>{
36
+ const options = minimist(getArgv());
37
+ return Boolean(options['web-only']);
38
+ };
39
+ const isVersionBeyond17 = (version)=>semver.gte(semver.minVersion(version), '17.0.0');
40
+ const getReactVersion = (cwd)=>{
41
+ const pkgPath = pkg_up.sync({
42
+ cwd
43
+ });
44
+ if (!pkgPath) return false;
45
+ const pkgInfo = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
46
+ const deps = {
47
+ ...pkgInfo.devDependencies,
48
+ ...pkgInfo.dependencies
49
+ };
50
+ if ('string' != typeof deps.react) return false;
51
+ try {
52
+ const reactPath = tryResolve('react/package.json', cwd);
53
+ const reactVersion = JSON.parse(fs.readFileSync(reactPath, 'utf8')).version;
54
+ return reactVersion;
55
+ } catch (error) {
56
+ console.error('Failed to resolve React version:', error);
57
+ return false;
58
+ }
59
+ };
60
+ const isBeyondReact17 = (cwd)=>{
61
+ const reactVersion = getReactVersion(cwd);
62
+ if (!reactVersion) return false;
63
+ return isVersionBeyond17(reactVersion);
64
+ };
65
+ const isSupportAutomaticJsx = (cwd)=>{
66
+ const reactVersion = getReactVersion(cwd);
67
+ if (!reactVersion) return false;
68
+ return semver.satisfies(semver.minVersion(reactVersion), '>=16.14.0');
69
+ };
70
+ const isReact18 = (cwd = process.cwd())=>{
71
+ const reactVersion = getReactVersion(cwd);
72
+ if (!reactVersion) return false;
73
+ return semver.gte(semver.minVersion(reactVersion), '18.0.0');
74
+ };
75
+ const isTypescript = (root)=>fs.existsSync(path.resolve(root, './tsconfig.json'));
76
+ export { getReactVersion, isApiOnly, isBeyondReact17, isDepExists, isPackageInstalled, isReact18, isSupportAutomaticJsx, isTypescript, isVersionBeyond17, isWebOnly };
@@ -0,0 +1,27 @@
1
+ import "node:module";
2
+ function isString(str) {
3
+ return 'string' == typeof str;
4
+ }
5
+ function isUndefined(obj) {
6
+ return void 0 === obj;
7
+ }
8
+ function isArray(obj) {
9
+ return Array.isArray(obj);
10
+ }
11
+ function isFunction(func) {
12
+ return 'function' == typeof func;
13
+ }
14
+ function isObject(obj) {
15
+ return null !== obj && 'object' == typeof obj;
16
+ }
17
+ function isPlainObject(obj) {
18
+ return isObject(obj) && '[object Object]' === Object.prototype.toString.call(obj);
19
+ }
20
+ function isPromise(obj) {
21
+ return Boolean(obj) && ('object' == typeof obj || 'function' == typeof obj) && 'function' == typeof obj.then;
22
+ }
23
+ function isRegExp(obj) {
24
+ return '[object RegExp]' === Object.prototype.toString.call(obj);
25
+ }
26
+ const isEmpty = (o)=>0 === Object.entries(o).length && o.constructor === Object;
27
+ export { isArray, isEmpty, isFunction, isObject, isPlainObject, isPromise, isRegExp, isString, isUndefined };
@@ -0,0 +1,2 @@
1
+ import "node:module";
2
+ export { createLogger, logger } from "rslog";
@@ -0,0 +1,34 @@
1
+ import "node:module";
2
+ import node_fs from "node:fs";
3
+ import node_path from "node:path";
4
+ const SOURCE_EXTENSIONS = [
5
+ '.ts',
6
+ '.js'
7
+ ];
8
+ const JS_LIKE_EXTENSION_RE = /\.(?:c|m)?js$/;
9
+ const isFile = (filepath)=>node_fs.existsSync(filepath) && node_fs.statSync(filepath).isFile();
10
+ const findSourceEntry = (resolvedPath)=>{
11
+ const ext = node_path.extname(resolvedPath);
12
+ if (ext) {
13
+ if (isFile(resolvedPath)) return resolvedPath;
14
+ if (JS_LIKE_EXTENSION_RE.test(resolvedPath)) {
15
+ const tsPath = `${resolvedPath.slice(0, -ext.length)}.ts`;
16
+ if (isFile(tsPath)) return tsPath;
17
+ }
18
+ return;
19
+ }
20
+ for (const candidateExt of SOURCE_EXTENSIONS){
21
+ const filePath = `${resolvedPath}${candidateExt}`;
22
+ if (isFile(filePath)) return filePath;
23
+ }
24
+ for (const candidateExt of SOURCE_EXTENSIONS){
25
+ const indexPath = node_path.join(resolvedPath, `index${candidateExt}`);
26
+ if (isFile(indexPath)) return indexPath;
27
+ }
28
+ };
29
+ const findMatchedSourcePath = (matchPath, specifier)=>{
30
+ let matchedPath = matchPath(specifier, void 0, void 0, SOURCE_EXTENSIONS);
31
+ if (!matchedPath && JS_LIKE_EXTENSION_RE.test(specifier)) matchedPath = matchPath(specifier.replace(JS_LIKE_EXTENSION_RE, ''), void 0, void 0, SOURCE_EXTENSIONS);
32
+ return matchedPath;
33
+ };
34
+ export { JS_LIKE_EXTENSION_RE, SOURCE_EXTENSIONS, findMatchedSourcePath, findSourceEntry };
@@ -0,0 +1,51 @@
1
+ import "node:module";
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { glob, yaml } from "../compiled.mjs";
5
+ const PACKAGE_MAX_DEPTH = 5;
6
+ const WORKSPACE_FILES = {
7
+ YARN: 'package.json',
8
+ PNPM: 'pnpm-workspace.yaml',
9
+ LERNA: 'lerna.json'
10
+ };
11
+ const isLerna = (root)=>fs.existsSync(path.join(root, WORKSPACE_FILES.LERNA));
12
+ const isYarnWorkspaces = (root)=>{
13
+ const pkg = path.join(root, WORKSPACE_FILES.YARN);
14
+ if (!fs.existsSync(pkg)) return false;
15
+ const json = JSON.parse(fs.readFileSync(pkg, 'utf8'));
16
+ return Boolean(json.workspaces?.packages);
17
+ };
18
+ const isPnpmWorkspaces = (root)=>fs.existsSync(path.join(root, WORKSPACE_FILES.PNPM));
19
+ const isMonorepo = (root)=>isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
20
+ const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH)=>{
21
+ let inMonorepo = false;
22
+ let monorepoRoot = appDirectory;
23
+ for(let depth = 0; depth < maxDepth; depth++){
24
+ if (isMonorepo(appDirectory)) {
25
+ inMonorepo = true;
26
+ break;
27
+ }
28
+ monorepoRoot = path.dirname(appDirectory);
29
+ }
30
+ return inMonorepo ? monorepoRoot : void 0;
31
+ };
32
+ const getMonorepoPackages = (root)=>{
33
+ let packages = [];
34
+ if (isYarnWorkspaces(root)) {
35
+ const json = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
36
+ ({ packages } = json.workspaces);
37
+ } else if (isLerna(root)) {
38
+ const json = JSON.parse(fs.readFileSync(path.resolve(root, 'lerna.json'), 'utf8'));
39
+ ({ packages } = json);
40
+ } else ({ packages } = yaml.load(fs.readFileSync(path.join(root, WORKSPACE_FILES.PNPM), 'utf8')));
41
+ if (packages) return packages.map((name)=>glob.sync(path.join(root, `${name}/`), {
42
+ ignore: [
43
+ '**/node_modules/**'
44
+ ]
45
+ })).reduce((acc, val)=>acc.concat(val), []).filter((filepath)=>fs.existsSync(path.resolve(filepath, 'package.json'))).map((filepath)=>({
46
+ path: filepath,
47
+ name: JSON.parse(fs.readFileSync(path.resolve(filepath, 'package.json'), 'utf8')).name
48
+ }));
49
+ return [];
50
+ };
51
+ export { findMonorepoRoot, getMonorepoPackages, isLerna, isMonorepo, isPnpmWorkspaces, isYarnWorkspaces };
@@ -0,0 +1,52 @@
1
+ import "node:module";
2
+ import { execa } from "../compiled.mjs";
3
+ async function getPnpmVersion() {
4
+ const { stdout } = await execa('pnpm', [
5
+ '--version'
6
+ ]);
7
+ return stdout;
8
+ }
9
+ async function canUseNpm() {
10
+ try {
11
+ await execa('npm', [
12
+ '--version'
13
+ ], {
14
+ env: process.env
15
+ });
16
+ return true;
17
+ } catch (e) {
18
+ return false;
19
+ }
20
+ }
21
+ async function canUseYarn() {
22
+ try {
23
+ await execa('yarn', [
24
+ '--version'
25
+ ], {
26
+ env: process.env
27
+ });
28
+ return true;
29
+ } catch (e) {
30
+ return false;
31
+ }
32
+ }
33
+ async function canUsePnpm() {
34
+ try {
35
+ await execa('pnpm', [
36
+ '--version'
37
+ ], {
38
+ env: process.env
39
+ });
40
+ return true;
41
+ } catch (e) {
42
+ return false;
43
+ }
44
+ }
45
+ function removeModuleSyncFromExports(exports) {
46
+ if ('object' != typeof exports || null === exports) return exports;
47
+ if (Array.isArray(exports)) return exports.map(removeModuleSyncFromExports);
48
+ const result = {};
49
+ for (const [key, value] of Object.entries(exports))if ('module-sync' !== key) result[key] = removeModuleSyncFromExports(value);
50
+ return result;
51
+ }
52
+ export { canUseNpm, canUsePnpm, canUseYarn, getPnpmVersion, removeModuleSyncFromExports };
@@ -0,0 +1,36 @@
1
+ import "node:module";
2
+ import fs from "fs";
3
+ import os from "os";
4
+ import path from "path";
5
+ import { nanoid, upath } from "../compiled.mjs";
6
+ const isPathString = (test)=>path.posix.basename(test) !== test || path.win32.basename(test) !== test;
7
+ const isRelativePath = (test)=>/^\.\.?($|[\\/])/.test(test);
8
+ const normalizeOutputPath = (s)=>s.replace(/\\/g, '\\\\');
9
+ const normalizeToPosixPath = (p)=>upath.normalizeSafe(path.normalize(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`);
10
+ const getTemplatePath = (prefix)=>{
11
+ const tmpRoot = fs.realpathSync(os.tmpdir());
12
+ const parts = [
13
+ tmpRoot
14
+ ];
15
+ prefix && parts.push(prefix);
16
+ parts.push(nanoid());
17
+ return path.resolve(...parts);
18
+ };
19
+ function getRealTemporaryDirectory() {
20
+ let ret = null;
21
+ try {
22
+ ret = os.tmpdir();
23
+ ret = fs.realpathSync(ret);
24
+ } catch {}
25
+ return ret;
26
+ }
27
+ function splitPathString(str) {
28
+ return str.split(/[\\/]/);
29
+ }
30
+ const removeLeadingSlash = (s)=>s.replace(/^\/+/, '');
31
+ const removeTailSlash = (s)=>s.replace(/\/+$/, '');
32
+ const removeSlash = (s)=>removeLeadingSlash(removeTailSlash(s));
33
+ function formatImportPath(str) {
34
+ return str.replace(/\\/g, '/');
35
+ }
36
+ export { formatImportPath, getRealTemporaryDirectory, getTemplatePath, isPathString, isRelativePath, normalizeOutputPath, normalizeToPosixPath, removeLeadingSlash, removeSlash, removeTailSlash, splitPathString };
@@ -0,0 +1,36 @@
1
+ import "node:module";
2
+ import net from "net";
3
+ import { chalk } from "../compiled.mjs";
4
+ import { logger } from "./logger.mjs";
5
+ const getPort = async (expectPort, { tryLimits = 20, strictPort = false, slient = false } = {})=>{
6
+ let port = expectPort;
7
+ if ('string' == typeof port) port = parseInt(port, 10);
8
+ if (strictPort) tryLimits = 1;
9
+ const original = port;
10
+ let found = false;
11
+ let attempts = 0;
12
+ while(!found && attempts <= tryLimits)try {
13
+ await new Promise((resolve, reject)=>{
14
+ const server = net.createServer();
15
+ server.unref();
16
+ server.on('error', reject);
17
+ server.listen({
18
+ port,
19
+ host: '0.0.0.0'
20
+ }, ()=>{
21
+ found = true;
22
+ server.close(resolve);
23
+ });
24
+ });
25
+ } catch (e) {
26
+ if ('EADDRINUSE' !== e.code) throw e;
27
+ port++;
28
+ attempts++;
29
+ }
30
+ if (port !== original) {
31
+ if (strictPort) throw new Error(`Port "${original}" is occupied, please choose another one.`);
32
+ else if (!slient) logger.info(`Port ${original} is in use. ${chalk.yellow(`using port ${port}.`)}`);
33
+ }
34
+ return port;
35
+ };
36
+ export { getPort };
@@ -0,0 +1,71 @@
1
+ import "node:module";
2
+ import { isIPv6 } from "net";
3
+ import os from "os";
4
+ import { chalk } from "../compiled.mjs";
5
+ import { DEFAULT_DEV_HOST } from "./constants.mjs";
6
+ import { isDev, isSingleEntry } from "./is/index.mjs";
7
+ const normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1');
8
+ const getIpv4Interfaces = ()=>{
9
+ const interfaces = os.networkInterfaces();
10
+ const ipv4Interfaces = [];
11
+ Object.keys(interfaces).forEach((key)=>{
12
+ interfaces[key].forEach((detail)=>{
13
+ const familyV4Value = 'string' == typeof detail.family ? 'IPv4' : 4;
14
+ if (detail.family === familyV4Value) ipv4Interfaces.push(detail);
15
+ });
16
+ });
17
+ return ipv4Interfaces;
18
+ };
19
+ const getHostInUrl = (host)=>{
20
+ if (isIPv6(host)) return '::' === host ? '[::1]' : `[${host}]`;
21
+ return host;
22
+ };
23
+ const getAddressUrls = (protocol = 'http', port, host)=>{
24
+ const LOCAL_LABEL = 'Local: ';
25
+ const NETWORK_LABEL = 'Network: ';
26
+ const isLocalhost = (url)=>url?.includes('localhost');
27
+ if (host && host !== DEFAULT_DEV_HOST) return [
28
+ {
29
+ label: isLocalhost(host) ? LOCAL_LABEL : NETWORK_LABEL,
30
+ url: `${protocol}://${getHostInUrl(host)}:${port}`
31
+ }
32
+ ];
33
+ const ipv4Interfaces = getIpv4Interfaces();
34
+ return ipv4Interfaces.reduce((memo, detail)=>{
35
+ if (isLocalhost(detail.address) || detail.internal) memo.push({
36
+ label: LOCAL_LABEL,
37
+ url: `${protocol}://localhost:${port}`
38
+ });
39
+ else memo.push({
40
+ label: NETWORK_LABEL,
41
+ url: `${protocol}://${detail.address}:${port}`
42
+ });
43
+ return memo;
44
+ }, []);
45
+ };
46
+ const prettyInstructions = (appContext, config)=>{
47
+ const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
48
+ const isHttps = isDev() && (config?.dev?.https || config?.tools?.devServer?.https);
49
+ const urls = getAddressUrls(isHttps ? 'https' : 'http', port, config.dev?.host);
50
+ const routes = apiOnly ? serverRoutes : serverRoutes.filter((route)=>route.entryName);
51
+ let message = '\n';
52
+ if (isSingleEntry(entrypoints, config.source?.mainEntryName) || apiOnly) {
53
+ const defaultRoutePath = routes[0]?.urlPath ?? '';
54
+ message += urls.map(({ label, url })=>` ${chalk.bold(`> ${label.padEnd(10)}`)}${chalk.cyanBright(normalizeUrl(`${url}/${defaultRoutePath}`))}\n`).join('');
55
+ } else {
56
+ const maxNameLength = Math.max(...routes.map((r)=>r.entryName.length));
57
+ urls.forEach(({ label, url })=>{
58
+ message += ` ${chalk.bold(`> ${label}`)}${0 === routes.length ? chalk.cyanBright(url) : ''}\n`;
59
+ routes.forEach(({ entryName, urlPath, isSSR })=>{
60
+ if (!checkedEntries.includes(entryName)) return;
61
+ message += ` ${chalk.yellowBright(isSSR ? 'λ' : '○')} ${chalk.yellowBright(entryName.padEnd(maxNameLength + 8))}${chalk.cyanBright(normalizeUrl(`${url}/${urlPath}`))}\n`;
62
+ });
63
+ });
64
+ message += '\n';
65
+ message += chalk.cyanBright(' λ (Server) server-side renders at runtime\n');
66
+ message += chalk.cyanBright(' ○ (Static) client-side renders as static HTML\n');
67
+ }
68
+ if (config.dev?.cliShortcuts) message += ` ${chalk.dim('> press')} ${chalk.bold('h + enter')} ${chalk.dim('to show shortcuts')}\n`;
69
+ return message;
70
+ };
71
+ export { getAddressUrls, prettyInstructions };
@@ -0,0 +1,80 @@
1
+ import "node:module";
2
+ import { readFile } from "node:fs/promises";
3
+ import { isAbsolute } from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+ import { moduleResolve } from "import-meta-resolve";
6
+ import { findExists } from "./fs.mjs";
7
+ async function importPath(path) {
8
+ const modulePath = isAbsolute(path) ? pathToFileURL(path).href : path;
9
+ if ('development' !== process.env.NODE_ENV) return await import(modulePath);
10
+ {
11
+ const timestamp = Date.now();
12
+ return await import(`${modulePath}?t=${timestamp}`);
13
+ }
14
+ }
15
+ async function compatibleRequireESM(path, interop = true) {
16
+ if (path.endsWith('.json')) return JSON.parse(await readFile(path, 'utf8'));
17
+ const requiredModule = await importPath(path);
18
+ return interop ? requiredModule.default : requiredModule;
19
+ }
20
+ async function compatibleRequire(path, interop = true) {
21
+ return await compatibleRequireESM(path, interop);
22
+ }
23
+ async function loadFromProject(moduleName, appDir) {
24
+ let requiredModule;
25
+ const paths = [
26
+ appDir,
27
+ process.cwd()
28
+ ];
29
+ try {
30
+ const modulePath = tryResolve(moduleName, ...paths);
31
+ {
32
+ const moduleUrl = pathToFileURL(modulePath).href;
33
+ requiredModule = await import(moduleUrl);
34
+ }
35
+ return requiredModule.default || requiredModule;
36
+ } catch (error) {
37
+ if ('MODULE_NOT_FOUND' === error.code) throw new Error(`Cannot find module ${moduleName}.`);
38
+ throw error;
39
+ }
40
+ }
41
+ const dynamicImport = new Function('modulePath', 'return import(modulePath)');
42
+ const requireExistModule = async (filename, opt)=>{
43
+ const final = {
44
+ extensions: [
45
+ '.ts',
46
+ '.js'
47
+ ],
48
+ interop: true,
49
+ ...opt
50
+ };
51
+ const exist = findExists(final.extensions.map((ext)=>`${filename}${ext}`));
52
+ if (!exist) return null;
53
+ return compatibleRequire(exist, final.interop);
54
+ };
55
+ const cleanRequireCache = (filelist)=>{};
56
+ const tryResolveESM = (name, ...resolvePath)=>{
57
+ const conditions = new Set([
58
+ 'node',
59
+ 'import',
60
+ 'module',
61
+ 'default'
62
+ ]);
63
+ for (const p of resolvePath)try {
64
+ return moduleResolve(name, pathToFileURL(`${p}/`), conditions, false).pathname.replace(/^\/(\w):/, '$1:');
65
+ } catch (err) {}
66
+ const err = new Error(`Can not find module ${name}.`);
67
+ err.code = 'MODULE_NOT_FOUND';
68
+ throw err;
69
+ };
70
+ const tryResolve = (name, ...resolvePath)=>{
71
+ let filePath = '';
72
+ try {
73
+ filePath = tryResolveESM(name, ...resolvePath);
74
+ } catch (err) {
75
+ if ('MODULE_NOT_FOUND' === err.code) throw new Error(`Can not find module ${name}.`);
76
+ throw err;
77
+ }
78
+ return filePath;
79
+ };
80
+ export { cleanRequireCache, compatibleRequire, dynamicImport, loadFromProject, requireExistModule, tryResolve };
@@ -0,0 +1,37 @@
1
+ import "node:module";
2
+ import { lodash } from "../compiled.mjs";
3
+ const { cloneDeep: cloneDeep } = lodash;
4
+ function filterRoutesForServer(routes) {
5
+ const clonedRoutes = cloneDeep(routes);
6
+ const newRoutes = clonedRoutes.map((route)=>{
7
+ if ('nested' !== route.type) return route;
8
+ if (route.children && route.children.length > 0) route.children = filterRoutesForServer(route.children);
9
+ if (route.inValidSSRRoute) return null;
10
+ return route;
11
+ }).filter((route)=>null !== route);
12
+ return newRoutes;
13
+ }
14
+ function filterRoutesLoader(routes) {
15
+ const clonedRoutes = cloneDeep(routes);
16
+ const newRoutes = clonedRoutes.map((route)=>{
17
+ if ('nested' !== route.type) return route;
18
+ if (route.children && route.children.length > 0) route.children = filterRoutesLoader(route.children);
19
+ if (route.inValidSSRRoute) {
20
+ delete route.loader;
21
+ delete route.data;
22
+ delete route.action;
23
+ }
24
+ return route;
25
+ }).filter((route)=>null !== route);
26
+ return newRoutes;
27
+ }
28
+ function markRoutes(routes, routeIds) {
29
+ return routes.map((route)=>{
30
+ if ('nested' !== route.type) return route;
31
+ if (route.children && route.children.length > 0) route.children = markRoutes(route.children, routeIds);
32
+ if (route.children && route.children.length > 0) route.inValidSSRRoute = route.children.every((child)=>child.inValidSSRRoute ?? false);
33
+ else if (route.id) route.inValidSSRRoute = !routeIds.includes(route.id);
34
+ return route;
35
+ });
36
+ }
37
+ export { filterRoutesForServer, filterRoutesLoader, markRoutes };
@@ -0,0 +1,43 @@
1
+ import "node:module";
2
+ import path from "path";
3
+ import { fs } from "../compiled.mjs";
4
+ import { normalizeOutputPath } from "./path.mjs";
5
+ const memo = (fn)=>{
6
+ const cache = new Map();
7
+ return (...params)=>{
8
+ const stringifiedParams = JSON.stringify(params);
9
+ const cachedResult = cache.get(stringifiedParams);
10
+ if (cachedResult) return cachedResult;
11
+ const res = fn(...params);
12
+ cache.set(stringifiedParams, res);
13
+ return res;
14
+ };
15
+ };
16
+ const ensureRuntimeExportsFile = (filepath)=>{
17
+ fs.ensureDirSync(path.dirname(filepath));
18
+ if (!fs.existsSync(filepath)) fs.writeFileSync(filepath, 'export {};\n');
19
+ };
20
+ const formatRuntimeExports = (exportsList)=>{
21
+ if (0 === exportsList.length) return 'export {};\n';
22
+ return `${exportsList.join('\n')}\n`;
23
+ };
24
+ const flushRuntimeExports = (filepath, exportsSet)=>{
25
+ fs.writeFileSync(filepath, formatRuntimeExports(Array.from(exportsSet)));
26
+ };
27
+ const createRuntimeExportsUtils = memo((internalDirectory, filename)=>{
28
+ const filepath = path.resolve(internalDirectory, `${filename}.ts`);
29
+ const exportsSet = new Set();
30
+ ensureRuntimeExportsFile(filepath);
31
+ return {
32
+ addExport (exportStatement) {
33
+ const normalized = exportStatement?.trim();
34
+ if (!normalized) return;
35
+ exportsSet.add(normalized);
36
+ flushRuntimeExports(filepath, exportsSet);
37
+ },
38
+ getPath () {
39
+ return normalizeOutputPath(filepath);
40
+ }
41
+ };
42
+ });
43
+ export { createRuntimeExportsUtils };
@@ -0,0 +1,8 @@
1
+ import "node:module";
2
+ import path from "path";
3
+ import { TS_CONFIG_FILENAME } from "./constants.mjs";
4
+ const resolveServerTsconfig = (appDirectory, configuredPath)=>{
5
+ if (configuredPath) return path.isAbsolute(configuredPath) ? configuredPath : path.resolve(appDirectory, configuredPath);
6
+ return path.resolve(appDirectory, TS_CONFIG_FILENAME);
7
+ };
8
+ export { resolveServerTsconfig };
@@ -0,0 +1,25 @@
1
+ import "node:module";
2
+ const parseNodeVersion = ()=>{
3
+ const [major = 0, minor = 0] = process.versions.node.split('.').map(Number);
4
+ return {
5
+ major,
6
+ minor
7
+ };
8
+ };
9
+ function isVersionAtLeast1819() {
10
+ const { major, minor } = parseNodeVersion();
11
+ return major > 18 || 18 === major && minor >= 19;
12
+ }
13
+ function isVersionAtLeast18() {
14
+ const { major } = parseNodeVersion();
15
+ return major >= 18;
16
+ }
17
+ function isVersionAtLeast22() {
18
+ const { major } = parseNodeVersion();
19
+ return major >= 22;
20
+ }
21
+ function isVersionAtLeast20() {
22
+ const { major } = parseNodeVersion();
23
+ return major >= 20;
24
+ }
25
+ export { isVersionAtLeast18, isVersionAtLeast1819, isVersionAtLeast20, isVersionAtLeast22 };