nitro-nightly 4.0.0-20251030-091344-d4418b98 → 4.0.0-20251030-122334-09c1a7a8

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 (334) hide show
  1. package/dist/_build/common.mjs +763 -0
  2. package/dist/_build/rolldown.mjs +216 -0
  3. package/dist/_build/rollup.mjs +359 -0
  4. package/dist/_build/vite.build.mjs +67 -0
  5. package/dist/_build/vite.plugin.mjs +762 -0
  6. package/dist/_chunks/B-7HiF0V.mjs +1303 -0
  7. package/dist/_chunks/B3asVbT4.mjs +151 -0
  8. package/dist/_chunks/B5ooyfLk.mjs +372 -0
  9. package/dist/_chunks/DXMHy5ca.mjs +43 -0
  10. package/dist/_dev.d.mts +12 -0
  11. package/dist/_dev.mjs +675 -0
  12. package/dist/_libs/acorn.mjs +5034 -0
  13. package/dist/_libs/c12.mjs +2798 -0
  14. package/dist/_libs/chokidar.mjs +1560 -0
  15. package/dist/_libs/citty.mjs +333 -0
  16. package/dist/_libs/commondir.mjs +22 -0
  17. package/dist/_libs/compatx.mjs +46 -0
  18. package/dist/_libs/confbox.mjs +2920 -0
  19. package/dist/_libs/debug.mjs +848 -0
  20. package/dist/_libs/deepmerge.mjs +86 -0
  21. package/dist/_libs/depd.mjs +314 -0
  22. package/dist/_libs/dot-prop.mjs +138 -0
  23. package/dist/_libs/duplexer.mjs +71 -0
  24. package/dist/_libs/ee-first.mjs +68 -0
  25. package/dist/_libs/encodeurl.mjs +49 -0
  26. package/dist/_libs/escape-html.mjs +58 -0
  27. package/dist/_libs/escape-string-regexp.mjs +8 -0
  28. package/dist/_libs/estree-walker.mjs +330 -0
  29. package/dist/_libs/etag.mjs +75 -0
  30. package/dist/{_chunks/_deps → _libs}/fdir.mjs +49 -104
  31. package/dist/_libs/fresh.mjs +85 -0
  32. package/dist/_libs/function-bind.mjs +63 -0
  33. package/dist/_libs/gen-mapping.mjs +612 -0
  34. package/dist/_libs/giget.mjs +19076 -0
  35. package/dist/_libs/gzip-size.mjs +21 -0
  36. package/dist/_libs/hasown.mjs +14 -0
  37. package/dist/_libs/http-errors.mjs +436 -0
  38. package/dist/_libs/httpxy.mjs +410 -0
  39. package/dist/_libs/is-core-module.mjs +220 -0
  40. package/dist/_libs/is-module.mjs +13 -0
  41. package/dist/_libs/is-reference.mjs +32 -0
  42. package/dist/{_chunks/_deps → _libs}/js-tokens.mjs +83 -112
  43. package/dist/_libs/klona.mjs +90 -0
  44. package/dist/_libs/knitwork.mjs +124 -0
  45. package/dist/_libs/local-pkg.mjs +1686 -0
  46. package/dist/{_chunks/_deps → _libs}/magic-string.mjs +272 -629
  47. package/dist/_libs/mime-db.mjs +7642 -0
  48. package/dist/_libs/mime-types.mjs +162 -0
  49. package/dist/_libs/mime.mjs +1391 -0
  50. package/dist/_libs/node-fetch-native.mjs +173 -0
  51. package/dist/_libs/on-finished.mjs +170 -0
  52. package/dist/_libs/parseurl.mjs +103 -0
  53. package/dist/_libs/path-parse.mjs +47 -0
  54. package/dist/_libs/pathe.mjs +41 -0
  55. package/dist/_libs/picomatch.mjs +1673 -0
  56. package/dist/_libs/plugin-alias.mjs +64 -0
  57. package/dist/_libs/plugin-commonjs.mjs +1489 -0
  58. package/dist/_libs/plugin-inject.mjs +135 -0
  59. package/dist/_libs/plugin-json.mjs +36 -0
  60. package/dist/_libs/plugin-node-resolve.mjs +1553 -0
  61. package/dist/_libs/plugin-replace.mjs +104 -0
  62. package/dist/_libs/pretty-bytes.mjs +116 -0
  63. package/dist/_libs/range-parser.mjs +102 -0
  64. package/dist/_libs/remapping.mjs +117 -0
  65. package/dist/{_chunks/_deps → _libs}/rou3.mjs +7 -22
  66. package/dist/_libs/send.mjs +857 -0
  67. package/dist/_libs/serve-static.mjs +124 -0
  68. package/dist/_libs/std-env.mjs +158 -0
  69. package/dist/_libs/strip-literal.mjs +51 -0
  70. package/dist/{_chunks/_deps → _libs}/tinyglobby.mjs +32 -33
  71. package/dist/_libs/ultrahtml.mjs +138 -0
  72. package/dist/_libs/unimport.mjs +3520 -0
  73. package/dist/_libs/untyped.mjs +271 -0
  74. package/dist/_libs/unwasm.mjs +5825 -0
  75. package/dist/{_chunks/_deps/@pi0 → _libs}/vite-plugin-fullstack.mjs +28 -42
  76. package/dist/_presets.mjs +1723 -0
  77. package/dist/builder.d.mts +37 -35
  78. package/dist/builder.mjs +45 -117
  79. package/dist/cli/_chunks/build.mjs +43 -0
  80. package/dist/cli/_chunks/common.mjs +15 -0
  81. package/dist/cli/_chunks/detect-acorn.mjs +12 -0
  82. package/dist/cli/_chunks/dev.mjs +79 -0
  83. package/dist/cli/_chunks/dist.mjs +3 -0
  84. package/dist/cli/_chunks/dist2.mjs +4 -0
  85. package/dist/cli/_chunks/esm.mjs +3 -0
  86. package/dist/cli/_chunks/json5.mjs +4 -0
  87. package/dist/cli/_chunks/jsonc.mjs +4 -0
  88. package/dist/cli/_chunks/list.mjs +27 -0
  89. package/dist/cli/_chunks/multipart-parser.mjs +6 -0
  90. package/dist/cli/_chunks/prepare.mjs +19 -0
  91. package/dist/cli/_chunks/run.mjs +55 -0
  92. package/dist/cli/_chunks/task.mjs +16 -0
  93. package/dist/cli/_chunks/toml.mjs +4 -0
  94. package/dist/cli/_chunks/yaml.mjs +4 -0
  95. package/dist/cli/index.d.mts +1 -1
  96. package/dist/cli/index.mjs +19 -18
  97. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
  98. package/dist/presets/_nitro/runtime/nitro-dev.mjs +42 -33
  99. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
  100. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +4 -8
  101. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
  102. package/dist/presets/_nitro/runtime/service-worker.mjs +14 -11
  103. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
  104. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +6 -5
  105. package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
  106. package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
  107. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
  108. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +25 -27
  109. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +7 -7
  110. package/dist/presets/azure/runtime/_utils.mjs +43 -43
  111. package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
  112. package/dist/presets/azure/runtime/azure-swa.mjs +22 -21
  113. package/dist/presets/bun/runtime/bun.d.mts +1 -0
  114. package/dist/presets/bun/runtime/bun.mjs +18 -17
  115. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
  116. package/dist/presets/cloudflare/runtime/_module-handler.mjs +78 -87
  117. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
  118. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +53 -58
  119. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
  120. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +12 -14
  121. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
  122. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +35 -39
  123. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
  124. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +86 -76
  125. package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
  126. package/dist/presets/deno/runtime/deno-deploy.mjs +12 -11
  127. package/dist/presets/deno/runtime/deno-server.d.mts +2 -1
  128. package/dist/presets/deno/runtime/deno-server.mjs +31 -39
  129. package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
  130. package/dist/presets/netlify/runtime/netlify-edge.mjs +14 -11
  131. package/dist/presets/netlify/runtime/netlify.mjs +11 -17
  132. package/dist/presets/node/runtime/node-cluster.mjs +49 -48
  133. package/dist/presets/node/runtime/node-middleware.d.mts +3 -2
  134. package/dist/presets/node/runtime/node-middleware.mjs +7 -6
  135. package/dist/presets/node/runtime/node-server.mjs +33 -23
  136. package/dist/presets/standard/runtime/server.d.mts +1 -3
  137. package/dist/presets/standard/runtime/server.mjs +1 -3
  138. package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
  139. package/dist/presets/stormkit/runtime/stormkit.mjs +20 -20
  140. package/dist/presets/vercel/runtime/vercel.d.mts +3 -3
  141. package/dist/presets/vercel/runtime/vercel.mjs +15 -14
  142. package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
  143. package/dist/presets/winterjs/runtime/winterjs.mjs +72 -68
  144. package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
  145. package/dist/runtime/index.d.mts +12 -1
  146. package/dist/runtime/index.mjs +12 -7
  147. package/dist/runtime/internal/app.mjs +175 -162
  148. package/dist/runtime/internal/cache.d.mts +10 -4
  149. package/dist/runtime/internal/cache.mjs +247 -216
  150. package/dist/runtime/internal/context.d.mts +9 -9
  151. package/dist/runtime/internal/context.mjs +17 -10
  152. package/dist/runtime/internal/database.mjs +8 -10
  153. package/dist/runtime/internal/error/dev.d.mts +5 -4
  154. package/dist/runtime/internal/error/dev.mjs +106 -105
  155. package/dist/runtime/internal/error/prod.d.mts +2 -2
  156. package/dist/runtime/internal/error/prod.mjs +48 -52
  157. package/dist/runtime/internal/error/utils.d.mts +4 -4
  158. package/dist/runtime/internal/error/utils.mjs +1 -1
  159. package/dist/runtime/internal/index.d.mts +2 -0
  160. package/dist/runtime/internal/index.mjs +2 -0
  161. package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +14 -14
  162. package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +248 -209
  163. package/dist/runtime/internal/meta.d.mts +1 -1
  164. package/dist/runtime/internal/meta.mjs +1 -1
  165. package/dist/runtime/internal/plugin.d.mts +2 -2
  166. package/dist/runtime/internal/plugin.mjs +1 -1
  167. package/dist/runtime/internal/renderer.mjs +39 -31
  168. package/dist/runtime/internal/route-rules.d.mts +8 -8
  169. package/dist/runtime/internal/route-rules.mjs +53 -51
  170. package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -30
  171. package/dist/runtime/internal/routes/dev-tasks.mjs +15 -17
  172. package/dist/runtime/internal/routes/openapi.d.mts +1 -0
  173. package/dist/runtime/internal/routes/openapi.mjs +81 -87
  174. package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
  175. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
  176. package/dist/runtime/internal/routes/renderer-template.dev.mjs +10 -17
  177. package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
  178. package/dist/runtime/internal/routes/scalar.d.mts +1 -0
  179. package/dist/runtime/internal/routes/scalar.mjs +22 -23
  180. package/dist/runtime/internal/routes/swagger.d.mts +1 -0
  181. package/dist/runtime/internal/routes/swagger.mjs +9 -11
  182. package/dist/runtime/internal/runtime-config.d.mts +4 -4
  183. package/dist/runtime/internal/runtime-config.mjs +40 -35
  184. package/dist/runtime/internal/shutdown.d.mts +2 -7
  185. package/dist/runtime/internal/shutdown.mjs +30 -29
  186. package/dist/runtime/internal/static.mjs +63 -74
  187. package/dist/runtime/internal/storage.mjs +2 -2
  188. package/dist/runtime/internal/task.d.mts +6 -6
  189. package/dist/runtime/internal/task.mjs +56 -59
  190. package/dist/runtime/internal/utils.d.mts +1 -1
  191. package/dist/runtime/internal/utils.mjs +4 -10
  192. package/dist/types/index.d.mts +2566 -3851
  193. package/dist/types/index.mjs +1 -1
  194. package/dist/vite.d.mts +61 -51
  195. package/dist/vite.mjs +55 -132
  196. package/package.json +10 -10
  197. package/dist/_build/build.mjs +0 -368
  198. package/dist/_build/build2.mjs +0 -556
  199. package/dist/_build/info.mjs +0 -1002
  200. package/dist/_build/prepare.mjs +0 -1511
  201. package/dist/_build/snapshot.mjs +0 -185
  202. package/dist/_build/vite.mjs +0 -959
  203. package/dist/_build/vite2.mjs +0 -149
  204. package/dist/_chunks/_deps/@jridgewell/gen-mapping.mjs +0 -189
  205. package/dist/_chunks/_deps/@jridgewell/remapping.mjs +0 -137
  206. package/dist/_chunks/_deps/@jridgewell/resolve-uri.mjs +0 -231
  207. package/dist/_chunks/_deps/@jridgewell/sourcemap-codec.mjs +0 -173
  208. package/dist/_chunks/_deps/@jridgewell/trace-mapping.mjs +0 -170
  209. package/dist/_chunks/_deps/@rollup/plugin-alias.mjs +0 -89
  210. package/dist/_chunks/_deps/@rollup/plugin-commonjs.mjs +0 -2376
  211. package/dist/_chunks/_deps/@rollup/plugin-inject.mjs +0 -212
  212. package/dist/_chunks/_deps/@rollup/plugin-json.mjs +0 -37
  213. package/dist/_chunks/_deps/@rollup/plugin-node-resolve.mjs +0 -1386
  214. package/dist/_chunks/_deps/@rollup/plugin-replace.mjs +0 -133
  215. package/dist/_chunks/_deps/@rollup/pluginutils.mjs +0 -346
  216. package/dist/_chunks/_deps/acorn.mjs +0 -6225
  217. package/dist/_chunks/_deps/c12.mjs +0 -510
  218. package/dist/_chunks/_deps/chokidar.mjs +0 -1428
  219. package/dist/_chunks/_deps/citty.mjs +0 -460
  220. package/dist/_chunks/_deps/commondir.mjs +0 -77
  221. package/dist/_chunks/_deps/compatx.mjs +0 -76
  222. package/dist/_chunks/_deps/confbox.mjs +0 -300
  223. package/dist/_chunks/_deps/debug.mjs +0 -885
  224. package/dist/_chunks/_deps/deepmerge.mjs +0 -147
  225. package/dist/_chunks/_deps/depd.mjs +0 -550
  226. package/dist/_chunks/_deps/dot-prop.mjs +0 -282
  227. package/dist/_chunks/_deps/dotenv.mjs +0 -555
  228. package/dist/_chunks/_deps/duplexer.mjs +0 -1
  229. package/dist/_chunks/_deps/ee-first.mjs +0 -104
  230. package/dist/_chunks/_deps/encodeurl.mjs +0 -69
  231. package/dist/_chunks/_deps/escape-html.mjs +0 -87
  232. package/dist/_chunks/_deps/escape-string-regexp.mjs +0 -13
  233. package/dist/_chunks/_deps/estree-walker.mjs +0 -433
  234. package/dist/_chunks/_deps/etag.mjs +0 -147
  235. package/dist/_chunks/_deps/exsolve.mjs +0 -1416
  236. package/dist/_chunks/_deps/fresh.mjs +0 -145
  237. package/dist/_chunks/_deps/function-bind.mjs +0 -106
  238. package/dist/_chunks/_deps/giget.mjs +0 -451
  239. package/dist/_chunks/_deps/gzip-size.mjs +0 -19
  240. package/dist/_chunks/_deps/hasown.mjs +0 -19
  241. package/dist/_chunks/_deps/http-errors.mjs +0 -307
  242. package/dist/_chunks/_deps/httpxy.mjs +0 -580
  243. package/dist/_chunks/_deps/inherits.mjs +0 -57
  244. package/dist/_chunks/_deps/is-core-module.mjs +0 -596
  245. package/dist/_chunks/_deps/is-module.mjs +0 -25
  246. package/dist/_chunks/_deps/is-reference.mjs +0 -31
  247. package/dist/_chunks/_deps/klona.mjs +0 -137
  248. package/dist/_chunks/_deps/knitwork.mjs +0 -172
  249. package/dist/_chunks/_deps/local-pkg.mjs +0 -163
  250. package/dist/_chunks/_deps/mime-db.mjs +0 -11685
  251. package/dist/_chunks/_deps/mime-types.mjs +0 -287
  252. package/dist/_chunks/_deps/mime.mjs +0 -1172
  253. package/dist/_chunks/_deps/mlly.mjs +0 -2413
  254. package/dist/_chunks/_deps/ms.mjs +0 -172
  255. package/dist/_chunks/_deps/node-fetch-native.mjs +0 -3
  256. package/dist/_chunks/_deps/nypm.mjs +0 -219
  257. package/dist/_chunks/_deps/on-finished.mjs +0 -246
  258. package/dist/_chunks/_deps/parseurl.mjs +0 -168
  259. package/dist/_chunks/_deps/path-parse.mjs +0 -85
  260. package/dist/_chunks/_deps/pathe.mjs +0 -251
  261. package/dist/_chunks/_deps/perfect-debounce.mjs +0 -88
  262. package/dist/_chunks/_deps/picomatch.mjs +0 -2144
  263. package/dist/_chunks/_deps/pkg-types.mjs +0 -247
  264. package/dist/_chunks/_deps/pretty-bytes.mjs +0 -180
  265. package/dist/_chunks/_deps/quansync.mjs +0 -99
  266. package/dist/_chunks/_deps/range-parser.mjs +0 -171
  267. package/dist/_chunks/_deps/rc9.mjs +0 -219
  268. package/dist/_chunks/_deps/readdirp.mjs +0 -245
  269. package/dist/_chunks/_deps/resolve.mjs +0 -1260
  270. package/dist/_chunks/_deps/send.mjs +0 -1022
  271. package/dist/_chunks/_deps/serve-static.mjs +0 -228
  272. package/dist/_chunks/_deps/setprototypeof.mjs +0 -26
  273. package/dist/_chunks/_deps/statuses.mjs +0 -457
  274. package/dist/_chunks/_deps/std-env.mjs +0 -3
  275. package/dist/_chunks/_deps/strip-literal.mjs +0 -67
  276. package/dist/_chunks/_deps/supports-color.mjs +0 -44
  277. package/dist/_chunks/_deps/tinyexec.mjs +0 -552
  278. package/dist/_chunks/_deps/toidentifier.mjs +0 -41
  279. package/dist/_chunks/_deps/ultrahtml.mjs +0 -3
  280. package/dist/_chunks/_deps/unimport.mjs +0 -2267
  281. package/dist/_chunks/_deps/unplugin-utils.mjs +0 -65
  282. package/dist/_chunks/_deps/unplugin.mjs +0 -1294
  283. package/dist/_chunks/_deps/untyped.mjs +0 -375
  284. package/dist/_chunks/_deps/unwasm.mjs +0 -6959
  285. package/dist/_chunks/_deps/webpack-virtual-modules.mjs +0 -360
  286. package/dist/_chunks/_presets/_all.mjs +0 -59
  287. package/dist/_chunks/_presets/_nitro.mjs +0 -74
  288. package/dist/_chunks/_presets/_resolve.mjs +0 -64
  289. package/dist/_chunks/_presets/_static.mjs +0 -69
  290. package/dist/_chunks/_presets/_types.mjs +0 -3
  291. package/dist/_chunks/_presets/_utils.mjs +0 -31
  292. package/dist/_chunks/_presets/alwaysdata.mjs +0 -17
  293. package/dist/_chunks/_presets/aws-amplify.mjs +0 -111
  294. package/dist/_chunks/_presets/aws-lambda.mjs +0 -23
  295. package/dist/_chunks/_presets/azure.mjs +0 -162
  296. package/dist/_chunks/_presets/bun.mjs +0 -19
  297. package/dist/_chunks/_presets/cleavr.mjs +0 -15
  298. package/dist/_chunks/_presets/cloudflare.mjs +0 -608
  299. package/dist/_chunks/_presets/deno.mjs +0 -196
  300. package/dist/_chunks/_presets/digitalocean.mjs +0 -14
  301. package/dist/_chunks/_presets/firebase.mjs +0 -47
  302. package/dist/_chunks/_presets/flightcontrol.mjs +0 -14
  303. package/dist/_chunks/_presets/genezio.mjs +0 -13
  304. package/dist/_chunks/_presets/heroku.mjs +0 -14
  305. package/dist/_chunks/_presets/iis.mjs +0 -194
  306. package/dist/_chunks/_presets/index.mjs +0 -62
  307. package/dist/_chunks/_presets/koyeb.mjs +0 -14
  308. package/dist/_chunks/_presets/netlify.mjs +0 -241
  309. package/dist/_chunks/_presets/node.mjs +0 -54
  310. package/dist/_chunks/_presets/platform.mjs +0 -14
  311. package/dist/_chunks/_presets/render.mjs +0 -14
  312. package/dist/_chunks/_presets/standard.mjs +0 -23
  313. package/dist/_chunks/_presets/stormkit.mjs +0 -18
  314. package/dist/_chunks/_presets/vercel.mjs +0 -375
  315. package/dist/_chunks/_presets/winterjs.mjs +0 -22
  316. package/dist/_chunks/_presets/zeabur.mjs +0 -69
  317. package/dist/_chunks/_presets/zerops.mjs +0 -27
  318. package/dist/_chunks/app.mjs +0 -600
  319. package/dist/_chunks/builder.mjs +0 -648
  320. package/dist/_chunks/server.mjs +0 -256
  321. package/dist/_cli/build.mjs +0 -49
  322. package/dist/_cli/common.mjs +0 -13
  323. package/dist/_cli/dev.mjs +0 -121
  324. package/dist/_cli/index.mjs +0 -16
  325. package/dist/_cli/list.mjs +0 -33
  326. package/dist/_cli/prepare.mjs +0 -23
  327. package/dist/_cli/run.mjs +0 -59
  328. package/dist/presets/cloudflare/runtime/shims/workers.dev.d.mts +0 -21
  329. package/dist/runtime/internal/empty.d.mts +0 -0
  330. package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
  331. package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
  332. package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
  333. package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
  334. /package/lib/{indexd.mts → index.d.mts} +0 -0
@@ -1,1416 +0,0 @@
1
- import fs, { lstatSync, realpathSync, statSync } from 'node:fs';
2
- import { fileURLToPath, pathToFileURL, URL as URL$1 } from 'node:url';
3
- import path, { isAbsolute } from 'node:path';
4
- import assert from 'node:assert';
5
- import process$1 from 'node:process';
6
- import v8 from 'node:v8';
7
- import { format, inspect } from 'node:util';
8
-
9
- const nodeBuiltins = [
10
- "_http_agent",
11
- "_http_client",
12
- "_http_common",
13
- "_http_incoming",
14
- "_http_outgoing",
15
- "_http_server",
16
- "_stream_duplex",
17
- "_stream_passthrough",
18
- "_stream_readable",
19
- "_stream_transform",
20
- "_stream_wrap",
21
- "_stream_writable",
22
- "_tls_common",
23
- "_tls_wrap",
24
- "assert",
25
- "assert/strict",
26
- "async_hooks",
27
- "buffer",
28
- "child_process",
29
- "cluster",
30
- "console",
31
- "constants",
32
- "crypto",
33
- "dgram",
34
- "diagnostics_channel",
35
- "dns",
36
- "dns/promises",
37
- "domain",
38
- "events",
39
- "fs",
40
- "fs/promises",
41
- "http",
42
- "http2",
43
- "https",
44
- "inspector",
45
- "inspector/promises",
46
- "module",
47
- "net",
48
- "os",
49
- "path",
50
- "path/posix",
51
- "path/win32",
52
- "perf_hooks",
53
- "process",
54
- "punycode",
55
- "querystring",
56
- "readline",
57
- "readline/promises",
58
- "repl",
59
- "stream",
60
- "stream/consumers",
61
- "stream/promises",
62
- "stream/web",
63
- "string_decoder",
64
- "sys",
65
- "timers",
66
- "timers/promises",
67
- "tls",
68
- "trace_events",
69
- "tty",
70
- "url",
71
- "util",
72
- "util/types",
73
- "v8",
74
- "vm",
75
- "wasi",
76
- "worker_threads",
77
- "zlib"
78
- ];
79
-
80
- const own$1 = {}.hasOwnProperty;
81
- const classRegExp = /^([A-Z][a-z\d]*)+$/;
82
- const kTypes = /* @__PURE__ */ new Set([
83
- "string",
84
- "function",
85
- "number",
86
- "object",
87
- // Accept 'Function' and 'Object' as alternative to the lower cased version.
88
- "Function",
89
- "Object",
90
- "boolean",
91
- "bigint",
92
- "symbol"
93
- ]);
94
- const messages = /* @__PURE__ */ new Map();
95
- const nodeInternalPrefix = "__node_internal_";
96
- let userStackTraceLimit;
97
- function formatList(array, type = "and") {
98
- return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array.at(-1)}`;
99
- }
100
- function createError(sym, value, constructor) {
101
- messages.set(sym, value);
102
- return makeNodeErrorWithCode(constructor, sym);
103
- }
104
- function makeNodeErrorWithCode(Base, key) {
105
- return function NodeError(...parameters) {
106
- const limit = Error.stackTraceLimit;
107
- if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
108
- const error = new Base();
109
- if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
110
- const message = getMessage(key, parameters, error);
111
- Object.defineProperties(error, {
112
- // Note: no need to implement `kIsNodeError` symbol, would be hard,
113
- // probably.
114
- message: {
115
- value: message,
116
- enumerable: false,
117
- writable: true,
118
- configurable: true
119
- },
120
- toString: {
121
- /** @this {Error} */
122
- value() {
123
- return `${this.name} [${key}]: ${this.message}`;
124
- },
125
- enumerable: false,
126
- writable: true,
127
- configurable: true
128
- }
129
- });
130
- captureLargerStackTrace(error);
131
- error.code = key;
132
- return error;
133
- };
134
- }
135
- function isErrorStackTraceLimitWritable() {
136
- try {
137
- if (v8.startupSnapshot.isBuildingSnapshot()) {
138
- return false;
139
- }
140
- } catch {
141
- }
142
- const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
143
- if (desc === void 0) {
144
- return Object.isExtensible(Error);
145
- }
146
- return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
147
- }
148
- function hideStackFrames(wrappedFunction) {
149
- const hidden = nodeInternalPrefix + wrappedFunction.name;
150
- Object.defineProperty(wrappedFunction, "name", { value: hidden });
151
- return wrappedFunction;
152
- }
153
- const captureLargerStackTrace = hideStackFrames(function(error) {
154
- const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
155
- if (stackTraceLimitIsWritable) {
156
- userStackTraceLimit = Error.stackTraceLimit;
157
- Error.stackTraceLimit = Number.POSITIVE_INFINITY;
158
- }
159
- Error.captureStackTrace(error);
160
- if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
161
- return error;
162
- });
163
- function getMessage(key, parameters, self) {
164
- const message = messages.get(key);
165
- assert(message !== void 0, "expected `message` to be found");
166
- if (typeof message === "function") {
167
- assert(
168
- message.length <= parameters.length,
169
- // Default options do not count.
170
- `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
171
- );
172
- return Reflect.apply(message, self, parameters);
173
- }
174
- const regex = /%[dfijoOs]/g;
175
- let expectedLength = 0;
176
- while (regex.exec(message) !== null) expectedLength++;
177
- assert(
178
- expectedLength === parameters.length,
179
- `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
180
- );
181
- if (parameters.length === 0) return message;
182
- parameters.unshift(message);
183
- return Reflect.apply(format, null, parameters);
184
- }
185
- function determineSpecificType(value) {
186
- if (value === null || value === void 0) {
187
- return String(value);
188
- }
189
- if (typeof value === "function" && value.name) {
190
- return `function ${value.name}`;
191
- }
192
- if (typeof value === "object") {
193
- if (value.constructor && value.constructor.name) {
194
- return `an instance of ${value.constructor.name}`;
195
- }
196
- return `${inspect(value, { depth: -1 })}`;
197
- }
198
- let inspected = inspect(value, { colors: false });
199
- if (inspected.length > 28) {
200
- inspected = `${inspected.slice(0, 25)}...`;
201
- }
202
- return `type ${typeof value} (${inspected})`;
203
- }
204
- createError(
205
- "ERR_INVALID_ARG_TYPE",
206
- (name, expected, actual) => {
207
- assert(typeof name === "string", "'name' must be a string");
208
- if (!Array.isArray(expected)) {
209
- expected = [expected];
210
- }
211
- let message = "The ";
212
- if (name.endsWith(" argument")) {
213
- message += `${name} `;
214
- } else {
215
- const type = name.includes(".") ? "property" : "argument";
216
- message += `"${name}" ${type} `;
217
- }
218
- message += "must be ";
219
- const types = [];
220
- const instances = [];
221
- const other = [];
222
- for (const value of expected) {
223
- assert(
224
- typeof value === "string",
225
- "All expected entries have to be of type string"
226
- );
227
- if (kTypes.has(value)) {
228
- types.push(value.toLowerCase());
229
- } else if (classRegExp.exec(value) === null) {
230
- assert(
231
- value !== "object",
232
- 'The value "object" should be written as "Object"'
233
- );
234
- other.push(value);
235
- } else {
236
- instances.push(value);
237
- }
238
- }
239
- if (instances.length > 0) {
240
- const pos = types.indexOf("object");
241
- if (pos !== -1) {
242
- types.slice(pos, 1);
243
- instances.push("Object");
244
- }
245
- }
246
- if (types.length > 0) {
247
- message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
248
- types,
249
- "or"
250
- )}`;
251
- if (instances.length > 0 || other.length > 0) message += " or ";
252
- }
253
- if (instances.length > 0) {
254
- message += `an instance of ${formatList(instances, "or")}`;
255
- if (other.length > 0) message += " or ";
256
- }
257
- if (other.length > 0) {
258
- if (other.length > 1) {
259
- message += `one of ${formatList(other, "or")}`;
260
- } else {
261
- if (other[0]?.toLowerCase() !== other[0]) message += "an ";
262
- message += `${other[0]}`;
263
- }
264
- }
265
- message += `. Received ${determineSpecificType(actual)}`;
266
- return message;
267
- },
268
- TypeError
269
- );
270
- const ERR_INVALID_MODULE_SPECIFIER = createError(
271
- "ERR_INVALID_MODULE_SPECIFIER",
272
- /**
273
- * @param {string} request
274
- * @param {string} reason
275
- * @param {string} [base]
276
- */
277
- (request, reason, base) => {
278
- return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
279
- },
280
- TypeError
281
- );
282
- const ERR_INVALID_PACKAGE_CONFIG = createError(
283
- "ERR_INVALID_PACKAGE_CONFIG",
284
- (path, base, message) => {
285
- return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
286
- },
287
- Error
288
- );
289
- const ERR_INVALID_PACKAGE_TARGET = createError(
290
- "ERR_INVALID_PACKAGE_TARGET",
291
- (packagePath, key, target, isImport = false, base) => {
292
- const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
293
- if (key === ".") {
294
- assert(isImport === false);
295
- return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
296
- }
297
- return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
298
- target
299
- )} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
300
- },
301
- Error
302
- );
303
- const ERR_MODULE_NOT_FOUND = createError(
304
- "ERR_MODULE_NOT_FOUND",
305
- (path, base, exactUrl = false) => {
306
- return `Cannot find ${exactUrl ? "module" : "package"} '${path}' imported from ${base}`;
307
- },
308
- Error
309
- );
310
- createError(
311
- "ERR_NETWORK_IMPORT_DISALLOWED",
312
- "import of '%s' by %s is not supported: %s",
313
- Error
314
- );
315
- const ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
316
- "ERR_PACKAGE_IMPORT_NOT_DEFINED",
317
- (specifier, packagePath, base) => {
318
- return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
319
- },
320
- TypeError
321
- );
322
- const ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
323
- "ERR_PACKAGE_PATH_NOT_EXPORTED",
324
- /**
325
- * @param {string} packagePath
326
- * @param {string} subpath
327
- * @param {string} [base]
328
- */
329
- (packagePath, subpath, base) => {
330
- if (subpath === ".")
331
- return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
332
- return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
333
- },
334
- Error
335
- );
336
- const ERR_UNSUPPORTED_DIR_IMPORT = createError(
337
- "ERR_UNSUPPORTED_DIR_IMPORT",
338
- "Directory import '%s' is not supported resolving ES modules imported from %s",
339
- Error
340
- );
341
- const ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
342
- "ERR_UNSUPPORTED_RESOLVE_REQUEST",
343
- 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
344
- TypeError
345
- );
346
- const ERR_UNKNOWN_FILE_EXTENSION = createError(
347
- "ERR_UNKNOWN_FILE_EXTENSION",
348
- (extension, path) => {
349
- return `Unknown file extension "${extension}" for ${path}`;
350
- },
351
- TypeError
352
- );
353
- createError(
354
- "ERR_INVALID_ARG_VALUE",
355
- (name, value, reason = "is invalid") => {
356
- let inspected = inspect(value);
357
- if (inspected.length > 128) {
358
- inspected = `${inspected.slice(0, 128)}...`;
359
- }
360
- const type = name.includes(".") ? "property" : "argument";
361
- return `The ${type} '${name}' ${reason}. Received ${inspected}`;
362
- },
363
- TypeError
364
- // Note: extra classes have been shaken out.
365
- // , RangeError
366
- );
367
-
368
- const hasOwnProperty$1 = {}.hasOwnProperty;
369
- const cache = /* @__PURE__ */ new Map();
370
- function read(jsonPath, { base, specifier }) {
371
- const existing = cache.get(jsonPath);
372
- if (existing) {
373
- return existing;
374
- }
375
- let string;
376
- try {
377
- string = fs.readFileSync(path.toNamespacedPath(jsonPath), "utf8");
378
- } catch (error) {
379
- const exception = error;
380
- if (exception.code !== "ENOENT") {
381
- throw exception;
382
- }
383
- }
384
- const result = {
385
- exists: false,
386
- pjsonPath: jsonPath,
387
- main: void 0,
388
- name: void 0,
389
- type: "none",
390
- // Ignore unknown types for forwards compatibility
391
- exports: void 0,
392
- imports: void 0
393
- };
394
- if (string !== void 0) {
395
- let parsed;
396
- try {
397
- parsed = JSON.parse(string);
398
- } catch (error_) {
399
- const error = new ERR_INVALID_PACKAGE_CONFIG(
400
- jsonPath,
401
- (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier),
402
- error_.message
403
- );
404
- error.cause = error_;
405
- throw error;
406
- }
407
- result.exists = true;
408
- if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") {
409
- result.name = parsed.name;
410
- }
411
- if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") {
412
- result.main = parsed.main;
413
- }
414
- if (hasOwnProperty$1.call(parsed, "exports")) {
415
- result.exports = parsed.exports;
416
- }
417
- if (hasOwnProperty$1.call(parsed, "imports")) {
418
- result.imports = parsed.imports;
419
- }
420
- if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) {
421
- result.type = parsed.type;
422
- }
423
- }
424
- cache.set(jsonPath, result);
425
- return result;
426
- }
427
- function getPackageScopeConfig(resolved) {
428
- let packageJSONUrl = new URL("package.json", resolved);
429
- while (true) {
430
- const packageJSONPath2 = packageJSONUrl.pathname;
431
- if (packageJSONPath2.endsWith("node_modules/package.json")) {
432
- break;
433
- }
434
- const packageConfig = read(fileURLToPath(packageJSONUrl), {
435
- specifier: resolved
436
- });
437
- if (packageConfig.exists) {
438
- return packageConfig;
439
- }
440
- const lastPackageJSONUrl = packageJSONUrl;
441
- packageJSONUrl = new URL("../package.json", packageJSONUrl);
442
- if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
443
- break;
444
- }
445
- }
446
- const packageJSONPath = fileURLToPath(packageJSONUrl);
447
- return {
448
- pjsonPath: packageJSONPath,
449
- exists: false,
450
- type: "none"
451
- };
452
- }
453
-
454
- const hasOwnProperty = {}.hasOwnProperty;
455
- const extensionFormatMap = {
456
- __proto__: null,
457
- ".json": "json",
458
- ".cjs": "commonjs",
459
- ".cts": "commonjs",
460
- ".js": "module",
461
- ".ts": "module",
462
- ".mts": "module",
463
- ".mjs": "module"
464
- };
465
- const protocolHandlers = {
466
- __proto__: null,
467
- "data:": getDataProtocolModuleFormat,
468
- "file:": getFileProtocolModuleFormat,
469
- "node:": () => "builtin"
470
- };
471
- function mimeToFormat(mime) {
472
- if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime))
473
- return "module";
474
- if (mime === "application/json") return "json";
475
- return null;
476
- }
477
- function getDataProtocolModuleFormat(parsed) {
478
- const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
479
- parsed.pathname
480
- ) || [null, null, null];
481
- return mimeToFormat(mime);
482
- }
483
- function extname(url) {
484
- const pathname = url.pathname;
485
- let index = pathname.length;
486
- while (index--) {
487
- const code = pathname.codePointAt(index);
488
- if (code === 47) {
489
- return "";
490
- }
491
- if (code === 46) {
492
- return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
493
- }
494
- }
495
- return "";
496
- }
497
- function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
498
- const ext = extname(url);
499
- if (ext === ".js") {
500
- const { type: packageType } = getPackageScopeConfig(url);
501
- if (packageType !== "none") {
502
- return packageType;
503
- }
504
- return "commonjs";
505
- }
506
- if (ext === "") {
507
- const { type: packageType } = getPackageScopeConfig(url);
508
- if (packageType === "none" || packageType === "commonjs") {
509
- return "commonjs";
510
- }
511
- return "module";
512
- }
513
- const format = extensionFormatMap[ext];
514
- if (format) return format;
515
- if (ignoreErrors) {
516
- return void 0;
517
- }
518
- const filepath = fileURLToPath(url);
519
- throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath);
520
- }
521
- function defaultGetFormatWithoutErrors(url, context) {
522
- const protocol = url.protocol;
523
- if (!hasOwnProperty.call(protocolHandlers, protocol)) {
524
- return null;
525
- }
526
- return protocolHandlers[protocol](url, context, true) || null;
527
- }
528
-
529
- const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
530
- const own = {}.hasOwnProperty;
531
- const invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
532
- const deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
533
- const invalidPackageNameRegEx = /^\.|%|\\/;
534
- const patternRegEx = /\*/g;
535
- const encodedSeparatorRegEx = /%2f|%5c/i;
536
- const emittedPackageWarnings = /* @__PURE__ */ new Set();
537
- const doubleSlashRegEx = /[/\\]{2}/;
538
- function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
539
- if (process$1.noDeprecation) {
540
- return;
541
- }
542
- const pjsonPath = fileURLToPath(packageJsonUrl);
543
- const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
544
- process$1.emitWarning(
545
- `Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}.`,
546
- "DeprecationWarning",
547
- "DEP0166"
548
- );
549
- }
550
- function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
551
- if (process$1.noDeprecation) {
552
- return;
553
- }
554
- const format = defaultGetFormatWithoutErrors(url, { parentURL: base.href });
555
- if (format !== "module") return;
556
- const urlPath = fileURLToPath(url.href);
557
- const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
558
- const basePath = fileURLToPath(base);
559
- if (!main) {
560
- process$1.emitWarning(
561
- `No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(
562
- packagePath.length
563
- )}", imported from ${basePath}.
564
- Default "index" lookups for the main are deprecated for ES modules.`,
565
- "DeprecationWarning",
566
- "DEP0151"
567
- );
568
- } else if (path.resolve(packagePath, main) !== urlPath) {
569
- process$1.emitWarning(
570
- `Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(
571
- packagePath.length
572
- )}", imported from ${basePath}.
573
- Automatic extension resolution of the "main" field is deprecated for ES modules.`,
574
- "DeprecationWarning",
575
- "DEP0151"
576
- );
577
- }
578
- }
579
- function tryStatSync(path2) {
580
- try {
581
- return statSync(path2);
582
- } catch {
583
- }
584
- }
585
- function fileExists(url) {
586
- const stats = statSync(url, { throwIfNoEntry: false });
587
- const isFile = stats ? stats.isFile() : void 0;
588
- return isFile === null || isFile === void 0 ? false : isFile;
589
- }
590
- function legacyMainResolve(packageJsonUrl, packageConfig, base) {
591
- let guess;
592
- if (packageConfig.main !== void 0) {
593
- guess = new URL$1(packageConfig.main, packageJsonUrl);
594
- if (fileExists(guess)) return guess;
595
- const tries2 = [
596
- `./${packageConfig.main}.js`,
597
- `./${packageConfig.main}.json`,
598
- `./${packageConfig.main}.node`,
599
- `./${packageConfig.main}/index.js`,
600
- `./${packageConfig.main}/index.json`,
601
- `./${packageConfig.main}/index.node`
602
- ];
603
- let i2 = -1;
604
- while (++i2 < tries2.length) {
605
- guess = new URL$1(tries2[i2], packageJsonUrl);
606
- if (fileExists(guess)) break;
607
- guess = void 0;
608
- }
609
- if (guess) {
610
- emitLegacyIndexDeprecation(
611
- guess,
612
- packageJsonUrl,
613
- base,
614
- packageConfig.main
615
- );
616
- return guess;
617
- }
618
- }
619
- const tries = ["./index.js", "./index.json", "./index.node"];
620
- let i = -1;
621
- while (++i < tries.length) {
622
- guess = new URL$1(tries[i], packageJsonUrl);
623
- if (fileExists(guess)) break;
624
- guess = void 0;
625
- }
626
- if (guess) {
627
- emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
628
- return guess;
629
- }
630
- throw new ERR_MODULE_NOT_FOUND(
631
- fileURLToPath(new URL$1(".", packageJsonUrl)),
632
- fileURLToPath(base)
633
- );
634
- }
635
- function finalizeResolution(resolved, base, preserveSymlinks) {
636
- if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
637
- throw new ERR_INVALID_MODULE_SPECIFIER(
638
- resolved.pathname,
639
- String.raw`must not include encoded "/" or "\" characters`,
640
- fileURLToPath(base)
641
- );
642
- }
643
- let filePath;
644
- try {
645
- filePath = fileURLToPath(resolved);
646
- } catch (error) {
647
- Object.defineProperty(error, "input", { value: String(resolved) });
648
- Object.defineProperty(error, "module", { value: String(base) });
649
- throw error;
650
- }
651
- const stats = tryStatSync(
652
- filePath.endsWith("/") ? filePath.slice(-1) : filePath
653
- );
654
- if (stats && stats.isDirectory()) {
655
- const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath(base));
656
- error.url = String(resolved);
657
- throw error;
658
- }
659
- if (!stats || !stats.isFile()) {
660
- const error = new ERR_MODULE_NOT_FOUND(
661
- filePath || resolved.pathname,
662
- base && fileURLToPath(base),
663
- true
664
- );
665
- error.url = String(resolved);
666
- throw error;
667
- }
668
- {
669
- const real = realpathSync(filePath);
670
- const { search, hash } = resolved;
671
- resolved = pathToFileURL(real + (filePath.endsWith(path.sep) ? "/" : ""));
672
- resolved.search = search;
673
- resolved.hash = hash;
674
- }
675
- return resolved;
676
- }
677
- function importNotDefined(specifier, packageJsonUrl, base) {
678
- return new ERR_PACKAGE_IMPORT_NOT_DEFINED(
679
- specifier,
680
- packageJsonUrl && fileURLToPath(new URL$1(".", packageJsonUrl)),
681
- fileURLToPath(base)
682
- );
683
- }
684
- function exportsNotFound(subpath, packageJsonUrl, base) {
685
- return new ERR_PACKAGE_PATH_NOT_EXPORTED(
686
- fileURLToPath(new URL$1(".", packageJsonUrl)),
687
- subpath,
688
- base && fileURLToPath(base)
689
- );
690
- }
691
- function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
692
- const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJsonUrl)}`;
693
- throw new ERR_INVALID_MODULE_SPECIFIER(
694
- request,
695
- reason,
696
- base && fileURLToPath(base)
697
- );
698
- }
699
- function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
700
- target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
701
- return new ERR_INVALID_PACKAGE_TARGET(
702
- fileURLToPath(new URL$1(".", packageJsonUrl)),
703
- subpath,
704
- target,
705
- internal,
706
- base && fileURLToPath(base)
707
- );
708
- }
709
- function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
710
- if (subpath !== "" && !pattern && target.at(-1) !== "/")
711
- throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
712
- if (!target.startsWith("./")) {
713
- if (internal && !target.startsWith("../") && !target.startsWith("/")) {
714
- let isURL = false;
715
- try {
716
- new URL$1(target);
717
- isURL = true;
718
- } catch {
719
- }
720
- if (!isURL) {
721
- const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(
722
- patternRegEx,
723
- target,
724
- () => subpath
725
- ) : target + subpath;
726
- return packageResolve(exportTarget, packageJsonUrl, conditions);
727
- }
728
- }
729
- throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
730
- }
731
- if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
732
- if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
733
- if (!isPathMap) {
734
- const request = pattern ? match.replace("*", () => subpath) : match + subpath;
735
- const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
736
- patternRegEx,
737
- target,
738
- () => subpath
739
- ) : target;
740
- emitInvalidSegmentDeprecation(
741
- resolvedTarget,
742
- request,
743
- match,
744
- packageJsonUrl,
745
- internal,
746
- base,
747
- true
748
- );
749
- }
750
- } else {
751
- throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
752
- }
753
- }
754
- const resolved = new URL$1(target, packageJsonUrl);
755
- const resolvedPath = resolved.pathname;
756
- const packagePath = new URL$1(".", packageJsonUrl).pathname;
757
- if (!resolvedPath.startsWith(packagePath))
758
- throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
759
- if (subpath === "") return resolved;
760
- if (invalidSegmentRegEx.exec(subpath) !== null) {
761
- const request = pattern ? match.replace("*", () => subpath) : match + subpath;
762
- if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
763
- if (!isPathMap) {
764
- const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
765
- patternRegEx,
766
- target,
767
- () => subpath
768
- ) : target;
769
- emitInvalidSegmentDeprecation(
770
- resolvedTarget,
771
- request,
772
- match,
773
- packageJsonUrl,
774
- internal,
775
- base,
776
- false
777
- );
778
- }
779
- } else {
780
- throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
781
- }
782
- }
783
- if (pattern) {
784
- return new URL$1(
785
- RegExpPrototypeSymbolReplace.call(
786
- patternRegEx,
787
- resolved.href,
788
- () => subpath
789
- )
790
- );
791
- }
792
- return new URL$1(subpath, resolved);
793
- }
794
- function isArrayIndex(key) {
795
- const keyNumber = Number(key);
796
- if (`${keyNumber}` !== key) return false;
797
- return keyNumber >= 0 && keyNumber < 4294967295;
798
- }
799
- function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
800
- if (typeof target === "string") {
801
- return resolvePackageTargetString(
802
- target,
803
- subpath,
804
- packageSubpath,
805
- packageJsonUrl,
806
- base,
807
- pattern,
808
- internal,
809
- isPathMap,
810
- conditions
811
- );
812
- }
813
- if (Array.isArray(target)) {
814
- const targetList = target;
815
- if (targetList.length === 0) return null;
816
- let lastException;
817
- let i = -1;
818
- while (++i < targetList.length) {
819
- const targetItem = targetList[i];
820
- let resolveResult;
821
- try {
822
- resolveResult = resolvePackageTarget(
823
- packageJsonUrl,
824
- targetItem,
825
- subpath,
826
- packageSubpath,
827
- base,
828
- pattern,
829
- internal,
830
- isPathMap,
831
- conditions
832
- );
833
- } catch (error) {
834
- const exception = error;
835
- lastException = exception;
836
- if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
837
- throw error;
838
- }
839
- if (resolveResult === void 0) continue;
840
- if (resolveResult === null) {
841
- lastException = null;
842
- continue;
843
- }
844
- return resolveResult;
845
- }
846
- if (lastException === void 0 || lastException === null) {
847
- return null;
848
- }
849
- throw lastException;
850
- }
851
- if (typeof target === "object" && target !== null) {
852
- const keys = Object.getOwnPropertyNames(target);
853
- let i = -1;
854
- while (++i < keys.length) {
855
- const key = keys[i];
856
- if (isArrayIndex(key)) {
857
- throw new ERR_INVALID_PACKAGE_CONFIG(
858
- fileURLToPath(packageJsonUrl),
859
- fileURLToPath(base),
860
- '"exports" cannot contain numeric property keys.'
861
- );
862
- }
863
- }
864
- i = -1;
865
- while (++i < keys.length) {
866
- const key = keys[i];
867
- if (key === "default" || conditions && conditions.has(key)) {
868
- const conditionalTarget = target[key];
869
- const resolveResult = resolvePackageTarget(
870
- packageJsonUrl,
871
- conditionalTarget,
872
- subpath,
873
- packageSubpath,
874
- base,
875
- pattern,
876
- internal,
877
- isPathMap,
878
- conditions
879
- );
880
- if (resolveResult === void 0) continue;
881
- return resolveResult;
882
- }
883
- }
884
- return null;
885
- }
886
- if (target === null) {
887
- return null;
888
- }
889
- throw invalidPackageTarget(
890
- packageSubpath,
891
- target,
892
- packageJsonUrl,
893
- internal,
894
- base
895
- );
896
- }
897
- function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
898
- if (typeof exports === "string" || Array.isArray(exports)) return true;
899
- if (typeof exports !== "object" || exports === null) return false;
900
- const keys = Object.getOwnPropertyNames(exports);
901
- let isConditionalSugar = false;
902
- let i = 0;
903
- let keyIndex = -1;
904
- while (++keyIndex < keys.length) {
905
- const key = keys[keyIndex];
906
- const currentIsConditionalSugar = key === "" || key[0] !== ".";
907
- if (i++ === 0) {
908
- isConditionalSugar = currentIsConditionalSugar;
909
- } else if (isConditionalSugar !== currentIsConditionalSugar) {
910
- throw new ERR_INVALID_PACKAGE_CONFIG(
911
- fileURLToPath(packageJsonUrl),
912
- fileURLToPath(base),
913
- `"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`
914
- );
915
- }
916
- }
917
- return isConditionalSugar;
918
- }
919
- function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
920
- if (process$1.noDeprecation) {
921
- return;
922
- }
923
- const pjsonPath = fileURLToPath(pjsonUrl);
924
- if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
925
- emittedPackageWarnings.add(pjsonPath + "|" + match);
926
- process$1.emitWarning(
927
- `Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`,
928
- "DeprecationWarning",
929
- "DEP0155"
930
- );
931
- }
932
- function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
933
- let exports = packageConfig.exports;
934
- if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) {
935
- exports = { ".": exports };
936
- }
937
- if (own.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
938
- const target = exports[packageSubpath];
939
- const resolveResult = resolvePackageTarget(
940
- packageJsonUrl,
941
- target,
942
- "",
943
- packageSubpath,
944
- base,
945
- false,
946
- false,
947
- false,
948
- conditions
949
- );
950
- if (resolveResult === null || resolveResult === void 0) {
951
- throw exportsNotFound(packageSubpath, packageJsonUrl, base);
952
- }
953
- return resolveResult;
954
- }
955
- let bestMatch = "";
956
- let bestMatchSubpath = "";
957
- const keys = Object.getOwnPropertyNames(exports);
958
- let i = -1;
959
- while (++i < keys.length) {
960
- const key = keys[i];
961
- const patternIndex = key.indexOf("*");
962
- if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
963
- if (packageSubpath.endsWith("/")) {
964
- emitTrailingSlashPatternDeprecation(
965
- packageSubpath,
966
- packageJsonUrl,
967
- base
968
- );
969
- }
970
- const patternTrailer = key.slice(patternIndex + 1);
971
- if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
972
- bestMatch = key;
973
- bestMatchSubpath = packageSubpath.slice(
974
- patternIndex,
975
- packageSubpath.length - patternTrailer.length
976
- );
977
- }
978
- }
979
- }
980
- if (bestMatch) {
981
- const target = exports[bestMatch];
982
- const resolveResult = resolvePackageTarget(
983
- packageJsonUrl,
984
- target,
985
- bestMatchSubpath,
986
- bestMatch,
987
- base,
988
- true,
989
- false,
990
- packageSubpath.endsWith("/"),
991
- conditions
992
- );
993
- if (resolveResult === null || resolveResult === void 0) {
994
- throw exportsNotFound(packageSubpath, packageJsonUrl, base);
995
- }
996
- return resolveResult;
997
- }
998
- throw exportsNotFound(packageSubpath, packageJsonUrl, base);
999
- }
1000
- function patternKeyCompare(a, b) {
1001
- const aPatternIndex = a.indexOf("*");
1002
- const bPatternIndex = b.indexOf("*");
1003
- const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
1004
- const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
1005
- if (baseLengthA > baseLengthB) return -1;
1006
- if (baseLengthB > baseLengthA) return 1;
1007
- if (aPatternIndex === -1) return 1;
1008
- if (bPatternIndex === -1) return -1;
1009
- if (a.length > b.length) return -1;
1010
- if (b.length > a.length) return 1;
1011
- return 0;
1012
- }
1013
- function packageImportsResolve(name, base, conditions) {
1014
- if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
1015
- const reason = "is not a valid internal imports specifier name";
1016
- throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath(base));
1017
- }
1018
- let packageJsonUrl;
1019
- const packageConfig = getPackageScopeConfig(base);
1020
- if (packageConfig.exists) {
1021
- packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
1022
- const imports = packageConfig.imports;
1023
- if (imports) {
1024
- if (own.call(imports, name) && !name.includes("*")) {
1025
- const resolveResult = resolvePackageTarget(
1026
- packageJsonUrl,
1027
- imports[name],
1028
- "",
1029
- name,
1030
- base,
1031
- false,
1032
- true,
1033
- false,
1034
- conditions
1035
- );
1036
- if (resolveResult !== null && resolveResult !== void 0) {
1037
- return resolveResult;
1038
- }
1039
- } else {
1040
- let bestMatch = "";
1041
- let bestMatchSubpath = "";
1042
- const keys = Object.getOwnPropertyNames(imports);
1043
- let i = -1;
1044
- while (++i < keys.length) {
1045
- const key = keys[i];
1046
- const patternIndex = key.indexOf("*");
1047
- if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
1048
- const patternTrailer = key.slice(patternIndex + 1);
1049
- if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
1050
- bestMatch = key;
1051
- bestMatchSubpath = name.slice(
1052
- patternIndex,
1053
- name.length - patternTrailer.length
1054
- );
1055
- }
1056
- }
1057
- }
1058
- if (bestMatch) {
1059
- const target = imports[bestMatch];
1060
- const resolveResult = resolvePackageTarget(
1061
- packageJsonUrl,
1062
- target,
1063
- bestMatchSubpath,
1064
- bestMatch,
1065
- base,
1066
- true,
1067
- true,
1068
- false,
1069
- conditions
1070
- );
1071
- if (resolveResult !== null && resolveResult !== void 0) {
1072
- return resolveResult;
1073
- }
1074
- }
1075
- }
1076
- }
1077
- }
1078
- throw importNotDefined(name, packageJsonUrl, base);
1079
- }
1080
- function parsePackageName(specifier, base) {
1081
- let separatorIndex = specifier.indexOf("/");
1082
- let validPackageName = true;
1083
- let isScoped = false;
1084
- if (specifier[0] === "@") {
1085
- isScoped = true;
1086
- if (separatorIndex === -1 || specifier.length === 0) {
1087
- validPackageName = false;
1088
- } else {
1089
- separatorIndex = specifier.indexOf("/", separatorIndex + 1);
1090
- }
1091
- }
1092
- const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
1093
- if (invalidPackageNameRegEx.exec(packageName) !== null) {
1094
- validPackageName = false;
1095
- }
1096
- if (!validPackageName) {
1097
- throw new ERR_INVALID_MODULE_SPECIFIER(
1098
- specifier,
1099
- "is not a valid package name",
1100
- fileURLToPath(base)
1101
- );
1102
- }
1103
- const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
1104
- return { packageName, packageSubpath, isScoped };
1105
- }
1106
- function packageResolve(specifier, base, conditions) {
1107
- if (nodeBuiltins.includes(specifier)) {
1108
- return new URL$1("node:" + specifier);
1109
- }
1110
- const { packageName, packageSubpath, isScoped } = parsePackageName(
1111
- specifier,
1112
- base
1113
- );
1114
- const packageConfig = getPackageScopeConfig(base);
1115
- if (packageConfig.exists && packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) {
1116
- const packageJsonUrl2 = pathToFileURL(packageConfig.pjsonPath);
1117
- return packageExportsResolve(
1118
- packageJsonUrl2,
1119
- packageSubpath,
1120
- packageConfig,
1121
- base,
1122
- conditions
1123
- );
1124
- }
1125
- let packageJsonUrl = new URL$1(
1126
- "./node_modules/" + packageName + "/package.json",
1127
- base
1128
- );
1129
- let packageJsonPath = fileURLToPath(packageJsonUrl);
1130
- let lastPath;
1131
- do {
1132
- const stat = tryStatSync(packageJsonPath.slice(0, -13));
1133
- if (!stat || !stat.isDirectory()) {
1134
- lastPath = packageJsonPath;
1135
- packageJsonUrl = new URL$1(
1136
- (isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json",
1137
- packageJsonUrl
1138
- );
1139
- packageJsonPath = fileURLToPath(packageJsonUrl);
1140
- continue;
1141
- }
1142
- const packageConfig2 = read(packageJsonPath, { base, specifier });
1143
- if (packageConfig2.exports !== void 0 && packageConfig2.exports !== null) {
1144
- return packageExportsResolve(
1145
- packageJsonUrl,
1146
- packageSubpath,
1147
- packageConfig2,
1148
- base,
1149
- conditions
1150
- );
1151
- }
1152
- if (packageSubpath === ".") {
1153
- return legacyMainResolve(packageJsonUrl, packageConfig2, base);
1154
- }
1155
- return new URL$1(packageSubpath, packageJsonUrl);
1156
- } while (packageJsonPath.length !== lastPath.length);
1157
- throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), false);
1158
- }
1159
- function isRelativeSpecifier(specifier) {
1160
- if (specifier[0] === ".") {
1161
- if (specifier.length === 1 || specifier[1] === "/") return true;
1162
- if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) {
1163
- return true;
1164
- }
1165
- }
1166
- return false;
1167
- }
1168
- function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
1169
- if (specifier === "") return false;
1170
- if (specifier[0] === "/") return true;
1171
- return isRelativeSpecifier(specifier);
1172
- }
1173
- function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1174
- const protocol = base.protocol;
1175
- const isData = protocol === "data:";
1176
- let resolved;
1177
- if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
1178
- try {
1179
- resolved = new URL$1(specifier, base);
1180
- } catch (error_) {
1181
- const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1182
- error.cause = error_;
1183
- throw error;
1184
- }
1185
- } else if (protocol === "file:" && specifier[0] === "#") {
1186
- resolved = packageImportsResolve(specifier, base, conditions);
1187
- } else {
1188
- try {
1189
- resolved = new URL$1(specifier);
1190
- } catch (error_) {
1191
- if (isData && !nodeBuiltins.includes(specifier)) {
1192
- const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1193
- error.cause = error_;
1194
- throw error;
1195
- }
1196
- resolved = packageResolve(specifier, base, conditions);
1197
- }
1198
- }
1199
- assert(resolved !== void 0, "expected to be defined");
1200
- if (resolved.protocol !== "file:") {
1201
- return resolved;
1202
- }
1203
- return finalizeResolution(resolved, base);
1204
- }
1205
-
1206
- const DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
1207
- const isWindows = /* @__PURE__ */ (() => process.platform === "win32")();
1208
- const NOT_FOUND_ERRORS = /* @__PURE__ */ new Set([
1209
- "ERR_MODULE_NOT_FOUND",
1210
- "ERR_UNSUPPORTED_DIR_IMPORT",
1211
- "MODULE_NOT_FOUND",
1212
- "ERR_PACKAGE_PATH_NOT_EXPORTED",
1213
- "ERR_PACKAGE_IMPORT_NOT_DEFINED"
1214
- ]);
1215
- const globalCache = /* @__PURE__ */ (() => (
1216
- // eslint-disable-next-line unicorn/no-unreadable-iife
1217
- globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map()
1218
- ))();
1219
- function resolveModuleURL(input, options) {
1220
- const parsedInput = _parseInput(input);
1221
- if ("external" in parsedInput) {
1222
- return parsedInput.external;
1223
- }
1224
- const specifier = parsedInput.specifier;
1225
- let url = parsedInput.url;
1226
- let absolutePath = parsedInput.absolutePath;
1227
- let cacheKey;
1228
- let cacheObj;
1229
- if (options?.cache !== false) {
1230
- cacheKey = _cacheKey(absolutePath || specifier, options);
1231
- cacheObj = options?.cache && typeof options?.cache === "object" ? options.cache : globalCache;
1232
- }
1233
- if (cacheObj) {
1234
- const cached = cacheObj.get(cacheKey);
1235
- if (typeof cached === "string") {
1236
- return cached;
1237
- }
1238
- if (cached instanceof Error) {
1239
- if (options?.try) {
1240
- return void 0;
1241
- }
1242
- throw cached;
1243
- }
1244
- }
1245
- if (absolutePath) {
1246
- try {
1247
- const stat = lstatSync(absolutePath);
1248
- if (stat.isSymbolicLink()) {
1249
- absolutePath = realpathSync(absolutePath);
1250
- url = pathToFileURL(absolutePath);
1251
- }
1252
- if (stat.isFile()) {
1253
- if (cacheObj) {
1254
- cacheObj.set(cacheKey, url.href);
1255
- }
1256
- return url.href;
1257
- }
1258
- } catch (error) {
1259
- if (error?.code !== "ENOENT") {
1260
- if (cacheObj) {
1261
- cacheObj.set(cacheKey, error);
1262
- }
1263
- throw error;
1264
- }
1265
- }
1266
- }
1267
- const conditionsSet = options?.conditions ? new Set(options.conditions) : DEFAULT_CONDITIONS_SET;
1268
- const target = specifier || url.href;
1269
- const bases = _normalizeBases(options?.from);
1270
- const suffixes = options?.suffixes || [""];
1271
- const extensions = options?.extensions ? ["", ...options.extensions] : [""];
1272
- let resolved;
1273
- for (const base of bases) {
1274
- for (const suffix of suffixes) {
1275
- let name = _join(target, suffix);
1276
- if (name === ".") {
1277
- name += "/.";
1278
- }
1279
- for (const extension of extensions) {
1280
- resolved = _tryModuleResolve(name + extension, base, conditionsSet);
1281
- if (resolved) {
1282
- break;
1283
- }
1284
- }
1285
- if (resolved) {
1286
- break;
1287
- }
1288
- }
1289
- if (resolved) {
1290
- break;
1291
- }
1292
- }
1293
- if (!resolved) {
1294
- const error = new Error(
1295
- `Cannot resolve module "${input}" (from: ${bases.map((u) => _fmtPath(u)).join(", ")})`
1296
- );
1297
- error.code = "ERR_MODULE_NOT_FOUND";
1298
- if (cacheObj) {
1299
- cacheObj.set(cacheKey, error);
1300
- }
1301
- if (options?.try) {
1302
- return void 0;
1303
- }
1304
- throw error;
1305
- }
1306
- if (cacheObj) {
1307
- cacheObj.set(cacheKey, resolved.href);
1308
- }
1309
- return resolved.href;
1310
- }
1311
- function resolveModulePath(id, options) {
1312
- const resolved = resolveModuleURL(id, options);
1313
- if (!resolved) {
1314
- return void 0;
1315
- }
1316
- if (!resolved.startsWith("file://") && options?.try) {
1317
- return void 0;
1318
- }
1319
- const absolutePath = fileURLToPath(resolved);
1320
- return isWindows ? _normalizeWinPath(absolutePath) : absolutePath;
1321
- }
1322
- function _tryModuleResolve(specifier, base, conditions) {
1323
- try {
1324
- return moduleResolve(specifier, base, conditions);
1325
- } catch (error) {
1326
- if (!NOT_FOUND_ERRORS.has(error?.code)) {
1327
- throw error;
1328
- }
1329
- }
1330
- }
1331
- function _normalizeBases(inputs) {
1332
- const urls = (Array.isArray(inputs) ? inputs : [inputs]).flatMap(
1333
- (input) => _normalizeBase(input)
1334
- );
1335
- if (urls.length === 0) {
1336
- return [pathToFileURL("./")];
1337
- }
1338
- return urls;
1339
- }
1340
- function _normalizeBase(input) {
1341
- if (!input) {
1342
- return [];
1343
- }
1344
- if (_isURL(input)) {
1345
- return [input];
1346
- }
1347
- if (typeof input !== "string") {
1348
- return [];
1349
- }
1350
- if (/^(?:node|data|http|https|file):/.test(input)) {
1351
- return new URL(input);
1352
- }
1353
- try {
1354
- if (input.endsWith("/") || statSync(input).isDirectory()) {
1355
- return pathToFileURL(input + "/");
1356
- }
1357
- return pathToFileURL(input);
1358
- } catch {
1359
- return [pathToFileURL(input + "/"), pathToFileURL(input)];
1360
- }
1361
- }
1362
- function _fmtPath(input) {
1363
- try {
1364
- return fileURLToPath(input);
1365
- } catch {
1366
- return input;
1367
- }
1368
- }
1369
- function _cacheKey(id, opts) {
1370
- return JSON.stringify([
1371
- id,
1372
- (opts?.conditions || ["node", "import"]).sort(),
1373
- opts?.extensions,
1374
- opts?.from,
1375
- opts?.suffixes
1376
- ]);
1377
- }
1378
- function _join(a, b) {
1379
- if (!a || !b || b === "/") {
1380
- return a;
1381
- }
1382
- return (a.endsWith("/") ? a : a + "/") + (b.startsWith("/") ? b.slice(1) : b);
1383
- }
1384
- function _normalizeWinPath(path) {
1385
- return path.replace(/\\/g, "/").replace(/^[a-z]:\//, (r) => r.toUpperCase());
1386
- }
1387
- function _isURL(input) {
1388
- return input instanceof URL || input?.constructor?.name === "URL";
1389
- }
1390
- function _parseInput(input) {
1391
- if (typeof input === "string") {
1392
- if (input.startsWith("file:")) {
1393
- const url = new URL(input);
1394
- return { url, absolutePath: fileURLToPath(url) };
1395
- }
1396
- if (isAbsolute(input)) {
1397
- return { url: pathToFileURL(input), absolutePath: input };
1398
- }
1399
- if (/^(?:node|data|http|https):/.test(input)) {
1400
- return { external: input };
1401
- }
1402
- if (nodeBuiltins.includes(input) && !input.includes(":")) {
1403
- return { external: `node:${input}` };
1404
- }
1405
- return { specifier: input };
1406
- }
1407
- if (_isURL(input)) {
1408
- if (input.protocol === "file:") {
1409
- return { url: input, absolutePath: fileURLToPath(input) };
1410
- }
1411
- return { external: input.href };
1412
- }
1413
- throw new TypeError("id must be a `string` or `URL`");
1414
- }
1415
-
1416
- export { resolveModulePath as r };