nitro-nightly 4.0.0-20251030-091344-d4418b98 → 4.0.0-20251030-121649-98b56dfe

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 +747 -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 +56 -52
  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
@@ -0,0 +1,1686 @@
1
+ import { T as resolve$2, b as join$1, x as normalize$1, y as isAbsolute$1 } from "./c12.mjs";
2
+ import { r as tokenizer } from "./acorn.mjs";
3
+ import { a as h, o as x } from "./confbox.mjs";
4
+ import { builtinModules, createRequire } from "node:module";
5
+ import path, { dirname, join, win32 } from "node:path";
6
+ import process$1 from "node:process";
7
+ import fs, { promises, realpathSync, statSync } from "node:fs";
8
+ import { joinURL } from "ufo";
9
+ import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
10
+ import assert from "node:assert";
11
+ import v8 from "node:v8";
12
+ import { format, inspect } from "node:util";
13
+ import fsp from "node:fs/promises";
14
+
15
+ //#region node_modules/.pnpm/pkg-types@1.3.1/node_modules/pkg-types/dist/index.mjs
16
+ const defaultFindOptions = {
17
+ startingFrom: ".",
18
+ rootPattern: /^node_modules$/,
19
+ reverse: false,
20
+ test: (filePath) => {
21
+ try {
22
+ if (statSync(filePath).isFile()) return true;
23
+ } catch {}
24
+ }
25
+ };
26
+ async function findFile(filename, _options = {}) {
27
+ const filenames = Array.isArray(filename) ? filename : [filename];
28
+ const options = {
29
+ ...defaultFindOptions,
30
+ ..._options
31
+ };
32
+ const basePath = resolve$2(options.startingFrom);
33
+ const leadingSlash = basePath[0] === "/";
34
+ const segments = basePath.split("/").filter(Boolean);
35
+ if (leadingSlash) segments[0] = "/" + segments[0];
36
+ let root = segments.findIndex((r) => r.match(options.rootPattern));
37
+ if (root === -1) root = 0;
38
+ if (options.reverse) for (let index = root + 1; index <= segments.length; index++) for (const filename2 of filenames) {
39
+ const filePath = join$1(...segments.slice(0, index), filename2);
40
+ if (await options.test(filePath)) return filePath;
41
+ }
42
+ else for (let index = segments.length; index > root; index--) for (const filename2 of filenames) {
43
+ const filePath = join$1(...segments.slice(0, index), filename2);
44
+ if (await options.test(filePath)) return filePath;
45
+ }
46
+ throw new Error(`Cannot find matching ${filename} in ${options.startingFrom} or parent directories`);
47
+ }
48
+ function findNearestFile(filename, _options = {}) {
49
+ return findFile(filename, _options);
50
+ }
51
+ const FileCache = /* @__PURE__ */ new Map();
52
+ async function readPackageJSON(id, options = {}) {
53
+ const resolvedPath = await resolvePackageJSON(id, options);
54
+ const cache$1 = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache;
55
+ if (options.cache && cache$1.has(resolvedPath)) return cache$1.get(resolvedPath);
56
+ const blob = await promises.readFile(resolvedPath, "utf8");
57
+ let parsed;
58
+ try {
59
+ parsed = x(blob);
60
+ } catch {
61
+ parsed = h(blob);
62
+ }
63
+ cache$1.set(resolvedPath, parsed);
64
+ return parsed;
65
+ }
66
+ async function resolvePackageJSON(id = process.cwd(), options = {}) {
67
+ return findNearestFile("package.json", {
68
+ startingFrom: isAbsolute$1(id) ? id : await resolvePath(id, options),
69
+ ...options
70
+ });
71
+ }
72
+
73
+ //#endregion
74
+ //#region node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.mjs
75
+ const BUILTIN_MODULES = new Set(builtinModules);
76
+ function normalizeSlash(path$1) {
77
+ return path$1.replace(/\\/g, "/");
78
+ }
79
+ function matchAll(regex, string, addition) {
80
+ const matches = [];
81
+ for (const match of string.matchAll(regex)) matches.push({
82
+ ...addition,
83
+ ...match.groups,
84
+ code: match[0],
85
+ start: match.index,
86
+ end: (match.index || 0) + match[0].length
87
+ });
88
+ return matches;
89
+ }
90
+ function clearImports(imports) {
91
+ return (imports || "").replace(/\/\/[^\n]*\n|\/\*.*\*\//g, "").replace(/\s+/g, " ");
92
+ }
93
+ function getImportNames(cleanedImports) {
94
+ const topLevelImports = cleanedImports.replace(/{[^}]*}/, "");
95
+ return {
96
+ namespacedImport: topLevelImports.match(/\* as \s*(\S*)/)?.[1],
97
+ defaultImport: topLevelImports.split(",").find((index) => !/[*{}]/.test(index))?.trim() || void 0
98
+ };
99
+ }
100
+ /**
101
+ * @typedef ErrnoExceptionFields
102
+ * @property {number | undefined} [errnode]
103
+ * @property {string | undefined} [code]
104
+ * @property {string | undefined} [path]
105
+ * @property {string | undefined} [syscall]
106
+ * @property {string | undefined} [url]
107
+ *
108
+ * @typedef {Error & ErrnoExceptionFields} ErrnoException
109
+ */
110
+ const own$1 = {}.hasOwnProperty;
111
+ const classRegExp = /^([A-Z][a-z\d]*)+$/;
112
+ const kTypes = new Set([
113
+ "string",
114
+ "function",
115
+ "number",
116
+ "object",
117
+ "Function",
118
+ "Object",
119
+ "boolean",
120
+ "bigint",
121
+ "symbol"
122
+ ]);
123
+ const codes = {};
124
+ /**
125
+ * Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
126
+ * We cannot use Intl.ListFormat because it's not available in
127
+ * --without-intl builds.
128
+ *
129
+ * @param {Array<string>} array
130
+ * An array of strings.
131
+ * @param {string} [type]
132
+ * The list type to be inserted before the last element.
133
+ * @returns {string}
134
+ */
135
+ function formatList(array, type = "and") {
136
+ return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
137
+ }
138
+ /** @type {Map<string, MessageFunction | string>} */
139
+ const messages = /* @__PURE__ */ new Map();
140
+ const nodeInternalPrefix = "__node_internal_";
141
+ /** @type {number} */
142
+ let userStackTraceLimit;
143
+ codes.ERR_INVALID_ARG_TYPE = createError(
144
+ "ERR_INVALID_ARG_TYPE",
145
+ /**
146
+ * @param {string} name
147
+ * @param {Array<string> | string} expected
148
+ * @param {unknown} actual
149
+ */
150
+ (name, expected, actual) => {
151
+ assert(typeof name === "string", "'name' must be a string");
152
+ if (!Array.isArray(expected)) expected = [expected];
153
+ let message = "The ";
154
+ if (name.endsWith(" argument")) message += `${name} `;
155
+ else {
156
+ const type = name.includes(".") ? "property" : "argument";
157
+ message += `"${name}" ${type} `;
158
+ }
159
+ message += "must be ";
160
+ /** @type {Array<string>} */
161
+ const types = [];
162
+ /** @type {Array<string>} */
163
+ const instances = [];
164
+ /** @type {Array<string>} */
165
+ const other = [];
166
+ for (const value of expected) {
167
+ assert(typeof value === "string", "All expected entries have to be of type string");
168
+ if (kTypes.has(value)) types.push(value.toLowerCase());
169
+ else if (classRegExp.exec(value) === null) {
170
+ assert(value !== "object", "The value \"object\" should be written as \"Object\"");
171
+ other.push(value);
172
+ } else instances.push(value);
173
+ }
174
+ if (instances.length > 0) {
175
+ const pos = types.indexOf("object");
176
+ if (pos !== -1) {
177
+ types.slice(pos, 1);
178
+ instances.push("Object");
179
+ }
180
+ }
181
+ if (types.length > 0) {
182
+ message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
183
+ if (instances.length > 0 || other.length > 0) message += " or ";
184
+ }
185
+ if (instances.length > 0) {
186
+ message += `an instance of ${formatList(instances, "or")}`;
187
+ if (other.length > 0) message += " or ";
188
+ }
189
+ if (other.length > 0) if (other.length > 1) message += `one of ${formatList(other, "or")}`;
190
+ else {
191
+ if (other[0].toLowerCase() !== other[0]) message += "an ";
192
+ message += `${other[0]}`;
193
+ }
194
+ message += `. Received ${determineSpecificType(actual)}`;
195
+ return message;
196
+ },
197
+ TypeError
198
+ );
199
+ codes.ERR_INVALID_MODULE_SPECIFIER = createError(
200
+ "ERR_INVALID_MODULE_SPECIFIER",
201
+ /**
202
+ * @param {string} request
203
+ * @param {string} reason
204
+ * @param {string} [base]
205
+ */
206
+ (request, reason, base = void 0) => {
207
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
208
+ },
209
+ TypeError
210
+ );
211
+ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
212
+ "ERR_INVALID_PACKAGE_CONFIG",
213
+ /**
214
+ * @param {string} path
215
+ * @param {string} [base]
216
+ * @param {string} [message]
217
+ */
218
+ (path$1, base, message) => {
219
+ return `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
220
+ },
221
+ Error
222
+ );
223
+ codes.ERR_INVALID_PACKAGE_TARGET = createError(
224
+ "ERR_INVALID_PACKAGE_TARGET",
225
+ /**
226
+ * @param {string} packagePath
227
+ * @param {string} key
228
+ * @param {unknown} target
229
+ * @param {boolean} [isImport=false]
230
+ * @param {string} [base]
231
+ */
232
+ (packagePath, key, target, isImport = false, base = void 0) => {
233
+ const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
234
+ if (key === ".") {
235
+ assert(isImport === false);
236
+ 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 \"./\"" : ""}`;
237
+ }
238
+ return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
239
+ },
240
+ Error
241
+ );
242
+ codes.ERR_MODULE_NOT_FOUND = createError(
243
+ "ERR_MODULE_NOT_FOUND",
244
+ /**
245
+ * @param {string} path
246
+ * @param {string} base
247
+ * @param {boolean} [exactUrl]
248
+ */
249
+ (path$1, base, exactUrl = false) => {
250
+ return `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`;
251
+ },
252
+ Error
253
+ );
254
+ codes.ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
255
+ codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
256
+ "ERR_PACKAGE_IMPORT_NOT_DEFINED",
257
+ /**
258
+ * @param {string} specifier
259
+ * @param {string} packagePath
260
+ * @param {string} base
261
+ */
262
+ (specifier, packagePath, base) => {
263
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
264
+ },
265
+ TypeError
266
+ );
267
+ codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
268
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
269
+ /**
270
+ * @param {string} packagePath
271
+ * @param {string} subpath
272
+ * @param {string} [base]
273
+ */
274
+ (packagePath, subpath, base = void 0) => {
275
+ if (subpath === ".") return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
276
+ return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
277
+ },
278
+ Error
279
+ );
280
+ codes.ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
281
+ codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError("ERR_UNSUPPORTED_RESOLVE_REQUEST", "Failed to resolve module specifier \"%s\" from \"%s\": Invalid relative URL or base scheme is not hierarchical.", TypeError);
282
+ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
283
+ "ERR_UNKNOWN_FILE_EXTENSION",
284
+ /**
285
+ * @param {string} extension
286
+ * @param {string} path
287
+ */
288
+ (extension, path$1) => {
289
+ return `Unknown file extension "${extension}" for ${path$1}`;
290
+ },
291
+ TypeError
292
+ );
293
+ codes.ERR_INVALID_ARG_VALUE = createError(
294
+ "ERR_INVALID_ARG_VALUE",
295
+ /**
296
+ * @param {string} name
297
+ * @param {unknown} value
298
+ * @param {string} [reason='is invalid']
299
+ */
300
+ (name, value, reason = "is invalid") => {
301
+ let inspected = inspect(value);
302
+ if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`;
303
+ return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
304
+ },
305
+ TypeError
306
+ );
307
+ /**
308
+ * Utility function for registering the error codes. Only used here. Exported
309
+ * *only* to allow for testing.
310
+ * @param {string} sym
311
+ * @param {MessageFunction | string} value
312
+ * @param {ErrorConstructor} constructor
313
+ * @returns {new (...parameters: Array<any>) => Error}
314
+ */
315
+ function createError(sym, value, constructor) {
316
+ messages.set(sym, value);
317
+ return makeNodeErrorWithCode(constructor, sym);
318
+ }
319
+ /**
320
+ * @param {ErrorConstructor} Base
321
+ * @param {string} key
322
+ * @returns {ErrorConstructor}
323
+ */
324
+ function makeNodeErrorWithCode(Base, key) {
325
+ return NodeError;
326
+ /**
327
+ * @param {Array<unknown>} parameters
328
+ */
329
+ function NodeError(...parameters) {
330
+ const limit = Error.stackTraceLimit;
331
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
332
+ const error = new Base();
333
+ if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
334
+ const message = getMessage(key, parameters, error);
335
+ Object.defineProperties(error, {
336
+ message: {
337
+ value: message,
338
+ enumerable: false,
339
+ writable: true,
340
+ configurable: true
341
+ },
342
+ toString: {
343
+ value() {
344
+ return `${this.name} [${key}]: ${this.message}`;
345
+ },
346
+ enumerable: false,
347
+ writable: true,
348
+ configurable: true
349
+ }
350
+ });
351
+ captureLargerStackTrace(error);
352
+ error.code = key;
353
+ return error;
354
+ }
355
+ }
356
+ /**
357
+ * @returns {boolean}
358
+ */
359
+ function isErrorStackTraceLimitWritable() {
360
+ try {
361
+ if (v8.startupSnapshot.isBuildingSnapshot()) return false;
362
+ } catch {}
363
+ const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
364
+ if (desc === void 0) return Object.isExtensible(Error);
365
+ return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
366
+ }
367
+ /**
368
+ * This function removes unnecessary frames from Node.js core errors.
369
+ * @template {(...parameters: unknown[]) => unknown} T
370
+ * @param {T} wrappedFunction
371
+ * @returns {T}
372
+ */
373
+ function hideStackFrames(wrappedFunction) {
374
+ const hidden = nodeInternalPrefix + wrappedFunction.name;
375
+ Object.defineProperty(wrappedFunction, "name", { value: hidden });
376
+ return wrappedFunction;
377
+ }
378
+ const captureLargerStackTrace = hideStackFrames(
379
+ /**
380
+ * @param {Error} error
381
+ * @returns {Error}
382
+ */
383
+ function(error) {
384
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
385
+ if (stackTraceLimitIsWritable) {
386
+ userStackTraceLimit = Error.stackTraceLimit;
387
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
388
+ }
389
+ Error.captureStackTrace(error);
390
+ if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
391
+ return error;
392
+ }
393
+ );
394
+ /**
395
+ * @param {string} key
396
+ * @param {Array<unknown>} parameters
397
+ * @param {Error} self
398
+ * @returns {string}
399
+ */
400
+ function getMessage(key, parameters, self) {
401
+ const message = messages.get(key);
402
+ assert(message !== void 0, "expected `message` to be found");
403
+ if (typeof message === "function") {
404
+ assert(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
405
+ return Reflect.apply(message, self, parameters);
406
+ }
407
+ const regex = /%[dfijoOs]/g;
408
+ let expectedLength = 0;
409
+ while (regex.exec(message) !== null) expectedLength++;
410
+ assert(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
411
+ if (parameters.length === 0) return message;
412
+ parameters.unshift(message);
413
+ return Reflect.apply(format, null, parameters);
414
+ }
415
+ /**
416
+ * Determine the specific type of a value for type-mismatch errors.
417
+ * @param {unknown} value
418
+ * @returns {string}
419
+ */
420
+ function determineSpecificType(value) {
421
+ if (value === null || value === void 0) return String(value);
422
+ if (typeof value === "function" && value.name) return `function ${value.name}`;
423
+ if (typeof value === "object") {
424
+ if (value.constructor && value.constructor.name) return `an instance of ${value.constructor.name}`;
425
+ return `${inspect(value, { depth: -1 })}`;
426
+ }
427
+ let inspected = inspect(value, { colors: false });
428
+ if (inspected.length > 28) inspected = `${inspected.slice(0, 25)}...`;
429
+ return `type ${typeof value} (${inspected})`;
430
+ }
431
+ const hasOwnProperty$1 = {}.hasOwnProperty;
432
+ const { ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG$1 } = codes;
433
+ /** @type {Map<string, PackageConfig>} */
434
+ const cache = /* @__PURE__ */ new Map();
435
+ /**
436
+ * @param {string} jsonPath
437
+ * @param {{specifier: URL | string, base?: URL}} options
438
+ * @returns {PackageConfig}
439
+ */
440
+ function read(jsonPath, { base, specifier }) {
441
+ const existing = cache.get(jsonPath);
442
+ if (existing) return existing;
443
+ /** @type {string | undefined} */
444
+ let string;
445
+ try {
446
+ string = fs.readFileSync(path.toNamespacedPath(jsonPath), "utf8");
447
+ } catch (error) {
448
+ const exception = error;
449
+ if (exception.code !== "ENOENT") throw exception;
450
+ }
451
+ /** @type {PackageConfig} */
452
+ const result = {
453
+ exists: false,
454
+ pjsonPath: jsonPath,
455
+ main: void 0,
456
+ name: void 0,
457
+ type: "none",
458
+ exports: void 0,
459
+ imports: void 0
460
+ };
461
+ if (string !== void 0) {
462
+ /** @type {Record<string, unknown>} */
463
+ let parsed;
464
+ try {
465
+ parsed = JSON.parse(string);
466
+ } catch (error_) {
467
+ const cause = error_;
468
+ const error = new ERR_INVALID_PACKAGE_CONFIG$1(jsonPath, (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), cause.message);
469
+ error.cause = cause;
470
+ throw error;
471
+ }
472
+ result.exists = true;
473
+ if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") result.name = parsed.name;
474
+ if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") result.main = parsed.main;
475
+ if (hasOwnProperty$1.call(parsed, "exports")) result.exports = parsed.exports;
476
+ if (hasOwnProperty$1.call(parsed, "imports")) result.imports = parsed.imports;
477
+ if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) result.type = parsed.type;
478
+ }
479
+ cache.set(jsonPath, result);
480
+ return result;
481
+ }
482
+ /**
483
+ * @param {URL | string} resolved
484
+ * @returns {PackageConfig}
485
+ */
486
+ function getPackageScopeConfig(resolved) {
487
+ let packageJSONUrl = new URL("package.json", resolved);
488
+ while (true) {
489
+ if (packageJSONUrl.pathname.endsWith("node_modules/package.json")) break;
490
+ const packageConfig = read(fileURLToPath(packageJSONUrl), { specifier: resolved });
491
+ if (packageConfig.exists) return packageConfig;
492
+ const lastPackageJSONUrl = packageJSONUrl;
493
+ packageJSONUrl = new URL("../package.json", packageJSONUrl);
494
+ if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
495
+ }
496
+ return {
497
+ pjsonPath: fileURLToPath(packageJSONUrl),
498
+ exists: false,
499
+ type: "none"
500
+ };
501
+ }
502
+ /**
503
+ * Returns the package type for a given URL.
504
+ * @param {URL} url - The URL to get the package type for.
505
+ * @returns {PackageType}
506
+ */
507
+ function getPackageType(url) {
508
+ return getPackageScopeConfig(url).type;
509
+ }
510
+ const { ERR_UNKNOWN_FILE_EXTENSION } = codes;
511
+ const hasOwnProperty = {}.hasOwnProperty;
512
+ /** @type {Record<string, string>} */
513
+ const extensionFormatMap = {
514
+ __proto__: null,
515
+ ".cjs": "commonjs",
516
+ ".js": "module",
517
+ ".json": "json",
518
+ ".mjs": "module"
519
+ };
520
+ /**
521
+ * @param {string | null} mime
522
+ * @returns {string | null}
523
+ */
524
+ function mimeToFormat(mime) {
525
+ if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return "module";
526
+ if (mime === "application/json") return "json";
527
+ return null;
528
+ }
529
+ /**
530
+ * @callback ProtocolHandler
531
+ * @param {URL} parsed
532
+ * @param {{parentURL: string, source?: Buffer}} context
533
+ * @param {boolean} ignoreErrors
534
+ * @returns {string | null | void}
535
+ */
536
+ /**
537
+ * @type {Record<string, ProtocolHandler>}
538
+ */
539
+ const protocolHandlers = {
540
+ __proto__: null,
541
+ "data:": getDataProtocolModuleFormat,
542
+ "file:": getFileProtocolModuleFormat,
543
+ "http:": getHttpProtocolModuleFormat,
544
+ "https:": getHttpProtocolModuleFormat,
545
+ "node:"() {
546
+ return "builtin";
547
+ }
548
+ };
549
+ /**
550
+ * @param {URL} parsed
551
+ */
552
+ function getDataProtocolModuleFormat(parsed) {
553
+ const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [
554
+ null,
555
+ null,
556
+ null
557
+ ];
558
+ return mimeToFormat(mime);
559
+ }
560
+ /**
561
+ * Returns the file extension from a URL.
562
+ *
563
+ * Should give similar result to
564
+ * `require('node:path').extname(require('node:url').fileURLToPath(url))`
565
+ * when used with a `file:` URL.
566
+ *
567
+ * @param {URL} url
568
+ * @returns {string}
569
+ */
570
+ function extname$2(url) {
571
+ const pathname = url.pathname;
572
+ let index = pathname.length;
573
+ while (index--) {
574
+ const code = pathname.codePointAt(index);
575
+ if (code === 47) return "";
576
+ if (code === 46) return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
577
+ }
578
+ return "";
579
+ }
580
+ /**
581
+ * @type {ProtocolHandler}
582
+ */
583
+ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
584
+ const value = extname$2(url);
585
+ if (value === ".js") {
586
+ const packageType = getPackageType(url);
587
+ if (packageType !== "none") return packageType;
588
+ return "commonjs";
589
+ }
590
+ if (value === "") {
591
+ const packageType = getPackageType(url);
592
+ if (packageType === "none" || packageType === "commonjs") return "commonjs";
593
+ return "module";
594
+ }
595
+ const format$1 = extensionFormatMap[value];
596
+ if (format$1) return format$1;
597
+ if (ignoreErrors) return;
598
+ throw new ERR_UNKNOWN_FILE_EXTENSION(value, fileURLToPath(url));
599
+ }
600
+ function getHttpProtocolModuleFormat() {}
601
+ /**
602
+ * @param {URL} url
603
+ * @param {{parentURL: string}} context
604
+ * @returns {string | null}
605
+ */
606
+ function defaultGetFormatWithoutErrors(url, context) {
607
+ const protocol = url.protocol;
608
+ if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
609
+ return protocolHandlers[protocol](url, context, true) || null;
610
+ }
611
+ const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
612
+ const { ERR_INVALID_MODULE_SPECIFIER, ERR_INVALID_PACKAGE_CONFIG, ERR_INVALID_PACKAGE_TARGET, ERR_MODULE_NOT_FOUND, ERR_PACKAGE_IMPORT_NOT_DEFINED, ERR_PACKAGE_PATH_NOT_EXPORTED, ERR_UNSUPPORTED_DIR_IMPORT, ERR_UNSUPPORTED_RESOLVE_REQUEST } = codes;
613
+ const own = {}.hasOwnProperty;
614
+ 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;
615
+ 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;
616
+ const invalidPackageNameRegEx = /^\.|%|\\/;
617
+ const patternRegEx = /\*/g;
618
+ const encodedSeparatorRegEx = /%2f|%5c/i;
619
+ /** @type {Set<string>} */
620
+ const emittedPackageWarnings = /* @__PURE__ */ new Set();
621
+ const doubleSlashRegEx = /[/\\]{2}/;
622
+ /**
623
+ *
624
+ * @param {string} target
625
+ * @param {string} request
626
+ * @param {string} match
627
+ * @param {URL} packageJsonUrl
628
+ * @param {boolean} internal
629
+ * @param {URL} base
630
+ * @param {boolean} isTarget
631
+ */
632
+ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
633
+ if (process$1.noDeprecation) return;
634
+ const pjsonPath = fileURLToPath(packageJsonUrl);
635
+ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
636
+ process$1.emitWarning(`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)}` : ""}.`, "DeprecationWarning", "DEP0166");
637
+ }
638
+ /**
639
+ * @param {URL} url
640
+ * @param {URL} packageJsonUrl
641
+ * @param {URL} base
642
+ * @param {string} [main]
643
+ * @returns {void}
644
+ */
645
+ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
646
+ if (process$1.noDeprecation) return;
647
+ if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
648
+ const urlPath = fileURLToPath(url.href);
649
+ const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
650
+ const basePath = fileURLToPath(base);
651
+ if (!main) process$1.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
652
+ else if (path.resolve(packagePath, main) !== urlPath) process$1.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
653
+ }
654
+ /**
655
+ * @param {string} path
656
+ * @returns {Stats | undefined}
657
+ */
658
+ function tryStatSync(path$1) {
659
+ try {
660
+ return statSync(path$1);
661
+ } catch {}
662
+ }
663
+ /**
664
+ * Legacy CommonJS main resolution:
665
+ * 1. let M = pkg_url + (json main field)
666
+ * 2. TRY(M, M.js, M.json, M.node)
667
+ * 3. TRY(M/index.js, M/index.json, M/index.node)
668
+ * 4. TRY(pkg_url/index.js, pkg_url/index.json, pkg_url/index.node)
669
+ * 5. NOT_FOUND
670
+ *
671
+ * @param {URL} url
672
+ * @returns {boolean}
673
+ */
674
+ function fileExists(url) {
675
+ const stats = statSync(url, { throwIfNoEntry: false });
676
+ const isFile = stats ? stats.isFile() : void 0;
677
+ return isFile === null || isFile === void 0 ? false : isFile;
678
+ }
679
+ /**
680
+ * @param {URL} packageJsonUrl
681
+ * @param {PackageConfig} packageConfig
682
+ * @param {URL} base
683
+ * @returns {URL}
684
+ */
685
+ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
686
+ /** @type {URL | undefined} */
687
+ let guess;
688
+ if (packageConfig.main !== void 0) {
689
+ guess = new URL$1(packageConfig.main, packageJsonUrl);
690
+ if (fileExists(guess)) return guess;
691
+ const tries$1 = [
692
+ `./${packageConfig.main}.js`,
693
+ `./${packageConfig.main}.json`,
694
+ `./${packageConfig.main}.node`,
695
+ `./${packageConfig.main}/index.js`,
696
+ `./${packageConfig.main}/index.json`,
697
+ `./${packageConfig.main}/index.node`
698
+ ];
699
+ let i$1 = -1;
700
+ while (++i$1 < tries$1.length) {
701
+ guess = new URL$1(tries$1[i$1], packageJsonUrl);
702
+ if (fileExists(guess)) break;
703
+ guess = void 0;
704
+ }
705
+ if (guess) {
706
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
707
+ return guess;
708
+ }
709
+ }
710
+ const tries = [
711
+ "./index.js",
712
+ "./index.json",
713
+ "./index.node"
714
+ ];
715
+ let i = -1;
716
+ while (++i < tries.length) {
717
+ guess = new URL$1(tries[i], packageJsonUrl);
718
+ if (fileExists(guess)) break;
719
+ guess = void 0;
720
+ }
721
+ if (guess) {
722
+ emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
723
+ return guess;
724
+ }
725
+ throw new ERR_MODULE_NOT_FOUND(fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
726
+ }
727
+ /**
728
+ * @param {URL} resolved
729
+ * @param {URL} base
730
+ * @param {boolean} [preserveSymlinks]
731
+ * @returns {URL}
732
+ */
733
+ function finalizeResolution(resolved, base, preserveSymlinks) {
734
+ if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, "must not include encoded \"/\" or \"\\\" characters", fileURLToPath(base));
735
+ /** @type {string} */
736
+ let filePath;
737
+ try {
738
+ filePath = fileURLToPath(resolved);
739
+ } catch (error) {
740
+ const cause = error;
741
+ Object.defineProperty(cause, "input", { value: String(resolved) });
742
+ Object.defineProperty(cause, "module", { value: String(base) });
743
+ throw cause;
744
+ }
745
+ const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
746
+ if (stats && stats.isDirectory()) {
747
+ const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath(base));
748
+ error.url = String(resolved);
749
+ throw error;
750
+ }
751
+ if (!stats || !stats.isFile()) {
752
+ const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath(base), true);
753
+ error.url = String(resolved);
754
+ throw error;
755
+ }
756
+ {
757
+ const real = realpathSync(filePath);
758
+ const { search, hash } = resolved;
759
+ resolved = pathToFileURL(real + (filePath.endsWith(path.sep) ? "/" : ""));
760
+ resolved.search = search;
761
+ resolved.hash = hash;
762
+ }
763
+ return resolved;
764
+ }
765
+ /**
766
+ * @param {string} specifier
767
+ * @param {URL | undefined} packageJsonUrl
768
+ * @param {URL} base
769
+ * @returns {Error}
770
+ */
771
+ function importNotDefined(specifier, packageJsonUrl, base) {
772
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
773
+ }
774
+ /**
775
+ * @param {string} subpath
776
+ * @param {URL} packageJsonUrl
777
+ * @param {URL} base
778
+ * @returns {Error}
779
+ */
780
+ function exportsNotFound(subpath, packageJsonUrl, base) {
781
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, base && fileURLToPath(base));
782
+ }
783
+ /**
784
+ * @param {string} request
785
+ * @param {string} match
786
+ * @param {URL} packageJsonUrl
787
+ * @param {boolean} internal
788
+ * @param {URL} [base]
789
+ * @returns {never}
790
+ */
791
+ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
792
+ throw new ERR_INVALID_MODULE_SPECIFIER(request, `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJsonUrl)}`, base && fileURLToPath(base));
793
+ }
794
+ /**
795
+ * @param {string} subpath
796
+ * @param {unknown} target
797
+ * @param {URL} packageJsonUrl
798
+ * @param {boolean} internal
799
+ * @param {URL} [base]
800
+ * @returns {Error}
801
+ */
802
+ function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
803
+ target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
804
+ return new ERR_INVALID_PACKAGE_TARGET(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, target, internal, base && fileURLToPath(base));
805
+ }
806
+ /**
807
+ * @param {string} target
808
+ * @param {string} subpath
809
+ * @param {string} match
810
+ * @param {URL} packageJsonUrl
811
+ * @param {URL} base
812
+ * @param {boolean} pattern
813
+ * @param {boolean} internal
814
+ * @param {boolean} isPathMap
815
+ * @param {Set<string> | undefined} conditions
816
+ * @returns {URL}
817
+ */
818
+ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
819
+ if (subpath !== "" && !pattern && target[target.length - 1] !== "/") throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
820
+ if (!target.startsWith("./")) {
821
+ if (internal && !target.startsWith("../") && !target.startsWith("/")) {
822
+ let isURL = false;
823
+ try {
824
+ new URL$1(target);
825
+ isURL = true;
826
+ } catch {}
827
+ if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
828
+ }
829
+ throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
830
+ }
831
+ if (invalidSegmentRegEx.exec(target.slice(2)) !== null) if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
832
+ if (!isPathMap) {
833
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
834
+ emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, true);
835
+ }
836
+ } else throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
837
+ const resolved = new URL$1(target, packageJsonUrl);
838
+ const resolvedPath = resolved.pathname;
839
+ const packagePath = new URL$1(".", packageJsonUrl).pathname;
840
+ if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
841
+ if (subpath === "") return resolved;
842
+ if (invalidSegmentRegEx.exec(subpath) !== null) {
843
+ const request = pattern ? match.replace("*", () => subpath) : match + subpath;
844
+ if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
845
+ if (!isPathMap) emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, false);
846
+ } else throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
847
+ }
848
+ if (pattern) return new URL$1(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
849
+ return new URL$1(subpath, resolved);
850
+ }
851
+ /**
852
+ * @param {string} key
853
+ * @returns {boolean}
854
+ */
855
+ function isArrayIndex(key) {
856
+ const keyNumber = Number(key);
857
+ if (`${keyNumber}` !== key) return false;
858
+ return keyNumber >= 0 && keyNumber < 4294967295;
859
+ }
860
+ /**
861
+ * @param {URL} packageJsonUrl
862
+ * @param {unknown} target
863
+ * @param {string} subpath
864
+ * @param {string} packageSubpath
865
+ * @param {URL} base
866
+ * @param {boolean} pattern
867
+ * @param {boolean} internal
868
+ * @param {boolean} isPathMap
869
+ * @param {Set<string> | undefined} conditions
870
+ * @returns {URL | null}
871
+ */
872
+ function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
873
+ if (typeof target === "string") return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
874
+ if (Array.isArray(target)) {
875
+ /** @type {Array<unknown>} */
876
+ const targetList = target;
877
+ if (targetList.length === 0) return null;
878
+ /** @type {ErrnoException | null | undefined} */
879
+ let lastException;
880
+ let i = -1;
881
+ while (++i < targetList.length) {
882
+ const targetItem = targetList[i];
883
+ /** @type {URL | null} */
884
+ let resolveResult;
885
+ try {
886
+ resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
887
+ } catch (error) {
888
+ const exception = error;
889
+ lastException = exception;
890
+ if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
891
+ throw error;
892
+ }
893
+ if (resolveResult === void 0) continue;
894
+ if (resolveResult === null) {
895
+ lastException = null;
896
+ continue;
897
+ }
898
+ return resolveResult;
899
+ }
900
+ if (lastException === void 0 || lastException === null) return null;
901
+ throw lastException;
902
+ }
903
+ if (typeof target === "object" && target !== null) {
904
+ const keys = Object.getOwnPropertyNames(target);
905
+ let i = -1;
906
+ while (++i < keys.length) {
907
+ const key = keys[i];
908
+ if (isArrayIndex(key)) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), base, "\"exports\" cannot contain numeric property keys.");
909
+ }
910
+ i = -1;
911
+ while (++i < keys.length) {
912
+ const key = keys[i];
913
+ if (key === "default" || conditions && conditions.has(key)) {
914
+ const conditionalTarget = target[key];
915
+ const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
916
+ if (resolveResult === void 0) continue;
917
+ return resolveResult;
918
+ }
919
+ }
920
+ return null;
921
+ }
922
+ if (target === null) return null;
923
+ throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
924
+ }
925
+ /**
926
+ * @param {unknown} exports
927
+ * @param {URL} packageJsonUrl
928
+ * @param {URL} base
929
+ * @returns {boolean}
930
+ */
931
+ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
932
+ if (typeof exports === "string" || Array.isArray(exports)) return true;
933
+ if (typeof exports !== "object" || exports === null) return false;
934
+ const keys = Object.getOwnPropertyNames(exports);
935
+ let isConditionalSugar = false;
936
+ let i = 0;
937
+ let keyIndex = -1;
938
+ while (++keyIndex < keys.length) {
939
+ const key = keys[keyIndex];
940
+ const currentIsConditionalSugar = key === "" || key[0] !== ".";
941
+ if (i++ === 0) isConditionalSugar = currentIsConditionalSugar;
942
+ else if (isConditionalSugar !== currentIsConditionalSugar) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), base, "\"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.");
943
+ }
944
+ return isConditionalSugar;
945
+ }
946
+ /**
947
+ * @param {string} match
948
+ * @param {URL} pjsonUrl
949
+ * @param {URL} base
950
+ */
951
+ function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
952
+ if (process$1.noDeprecation) return;
953
+ const pjsonPath = fileURLToPath(pjsonUrl);
954
+ if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
955
+ emittedPackageWarnings.add(pjsonPath + "|" + match);
956
+ process$1.emitWarning(`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.`, "DeprecationWarning", "DEP0155");
957
+ }
958
+ /**
959
+ * @param {URL} packageJsonUrl
960
+ * @param {string} packageSubpath
961
+ * @param {Record<string, unknown>} packageConfig
962
+ * @param {URL} base
963
+ * @param {Set<string> | undefined} conditions
964
+ * @returns {URL}
965
+ */
966
+ function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
967
+ let exports = packageConfig.exports;
968
+ if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) exports = { ".": exports };
969
+ if (own.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
970
+ const target = exports[packageSubpath];
971
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, false, false, false, conditions);
972
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
973
+ return resolveResult;
974
+ }
975
+ let bestMatch = "";
976
+ let bestMatchSubpath = "";
977
+ const keys = Object.getOwnPropertyNames(exports);
978
+ let i = -1;
979
+ while (++i < keys.length) {
980
+ const key = keys[i];
981
+ const patternIndex = key.indexOf("*");
982
+ if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
983
+ if (packageSubpath.endsWith("/")) emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
984
+ const patternTrailer = key.slice(patternIndex + 1);
985
+ if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
986
+ bestMatch = key;
987
+ bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
988
+ }
989
+ }
990
+ }
991
+ if (bestMatch) {
992
+ const target = exports[bestMatch];
993
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith("/"), conditions);
994
+ if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
995
+ return resolveResult;
996
+ }
997
+ throw exportsNotFound(packageSubpath, packageJsonUrl, base);
998
+ }
999
+ /**
1000
+ * @param {string} a
1001
+ * @param {string} b
1002
+ */
1003
+ function patternKeyCompare(a, b) {
1004
+ const aPatternIndex = a.indexOf("*");
1005
+ const bPatternIndex = b.indexOf("*");
1006
+ const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
1007
+ const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
1008
+ if (baseLengthA > baseLengthB) return -1;
1009
+ if (baseLengthB > baseLengthA) return 1;
1010
+ if (aPatternIndex === -1) return 1;
1011
+ if (bPatternIndex === -1) return -1;
1012
+ if (a.length > b.length) return -1;
1013
+ if (b.length > a.length) return 1;
1014
+ return 0;
1015
+ }
1016
+ /**
1017
+ * @param {string} name
1018
+ * @param {URL} base
1019
+ * @param {Set<string>} [conditions]
1020
+ * @returns {URL}
1021
+ */
1022
+ function packageImportsResolve(name, base, conditions) {
1023
+ if (name === "#" || name.startsWith("#/") || name.endsWith("/")) throw new ERR_INVALID_MODULE_SPECIFIER(name, "is not a valid internal imports specifier name", fileURLToPath(base));
1024
+ /** @type {URL | undefined} */
1025
+ let packageJsonUrl;
1026
+ const packageConfig = getPackageScopeConfig(base);
1027
+ if (packageConfig.exists) {
1028
+ packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
1029
+ const imports = packageConfig.imports;
1030
+ if (imports) if (own.call(imports, name) && !name.includes("*")) {
1031
+ const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, false, true, false, conditions);
1032
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
1033
+ } else {
1034
+ let bestMatch = "";
1035
+ let bestMatchSubpath = "";
1036
+ const keys = Object.getOwnPropertyNames(imports);
1037
+ let i = -1;
1038
+ while (++i < keys.length) {
1039
+ const key = keys[i];
1040
+ const patternIndex = key.indexOf("*");
1041
+ if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
1042
+ const patternTrailer = key.slice(patternIndex + 1);
1043
+ if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
1044
+ bestMatch = key;
1045
+ bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
1046
+ }
1047
+ }
1048
+ }
1049
+ if (bestMatch) {
1050
+ const target = imports[bestMatch];
1051
+ const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
1052
+ if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
1053
+ }
1054
+ }
1055
+ }
1056
+ throw importNotDefined(name, packageJsonUrl, base);
1057
+ }
1058
+ /**
1059
+ * @param {string} specifier
1060
+ * @param {URL} base
1061
+ */
1062
+ function parsePackageName(specifier, base) {
1063
+ let separatorIndex = specifier.indexOf("/");
1064
+ let validPackageName = true;
1065
+ let isScoped = false;
1066
+ if (specifier[0] === "@") {
1067
+ isScoped = true;
1068
+ if (separatorIndex === -1 || specifier.length === 0) validPackageName = false;
1069
+ else separatorIndex = specifier.indexOf("/", separatorIndex + 1);
1070
+ }
1071
+ const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
1072
+ if (invalidPackageNameRegEx.exec(packageName) !== null) validPackageName = false;
1073
+ if (!validPackageName) throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath(base));
1074
+ return {
1075
+ packageName,
1076
+ packageSubpath: "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex)),
1077
+ isScoped
1078
+ };
1079
+ }
1080
+ /**
1081
+ * @param {string} specifier
1082
+ * @param {URL} base
1083
+ * @param {Set<string> | undefined} conditions
1084
+ * @returns {URL}
1085
+ */
1086
+ function packageResolve(specifier, base, conditions) {
1087
+ if (builtinModules.includes(specifier)) return new URL$1("node:" + specifier);
1088
+ const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
1089
+ const packageConfig = getPackageScopeConfig(base);
1090
+ /* c8 ignore next 16 */
1091
+ if (packageConfig.exists) {
1092
+ const packageJsonUrl$1 = pathToFileURL(packageConfig.pjsonPath);
1093
+ if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl$1, packageSubpath, packageConfig, base, conditions);
1094
+ }
1095
+ let packageJsonUrl = new URL$1("./node_modules/" + packageName + "/package.json", base);
1096
+ let packageJsonPath = fileURLToPath(packageJsonUrl);
1097
+ /** @type {string} */
1098
+ let lastPath;
1099
+ do {
1100
+ const stat$1 = tryStatSync(packageJsonPath.slice(0, -13));
1101
+ if (!stat$1 || !stat$1.isDirectory()) {
1102
+ lastPath = packageJsonPath;
1103
+ packageJsonUrl = new URL$1((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
1104
+ packageJsonPath = fileURLToPath(packageJsonUrl);
1105
+ continue;
1106
+ }
1107
+ const packageConfig$1 = read(packageJsonPath, {
1108
+ base,
1109
+ specifier
1110
+ });
1111
+ if (packageConfig$1.exports !== void 0 && packageConfig$1.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig$1, base, conditions);
1112
+ if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig$1, base);
1113
+ return new URL$1(packageSubpath, packageJsonUrl);
1114
+ } while (packageJsonPath.length !== lastPath.length);
1115
+ throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), false);
1116
+ }
1117
+ /**
1118
+ * @param {string} specifier
1119
+ * @returns {boolean}
1120
+ */
1121
+ function isRelativeSpecifier(specifier) {
1122
+ if (specifier[0] === ".") {
1123
+ if (specifier.length === 1 || specifier[1] === "/") return true;
1124
+ if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) return true;
1125
+ }
1126
+ return false;
1127
+ }
1128
+ /**
1129
+ * @param {string} specifier
1130
+ * @returns {boolean}
1131
+ */
1132
+ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
1133
+ if (specifier === "") return false;
1134
+ if (specifier[0] === "/") return true;
1135
+ return isRelativeSpecifier(specifier);
1136
+ }
1137
+ /**
1138
+ * The “Resolver Algorithm Specification” as detailed in the Node docs (which is
1139
+ * sync and slightly lower-level than `resolve`).
1140
+ *
1141
+ * @param {string} specifier
1142
+ * `/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`, etc.
1143
+ * @param {URL} base
1144
+ * Full URL (to a file) that `specifier` is resolved relative from.
1145
+ * @param {Set<string>} [conditions]
1146
+ * Conditions.
1147
+ * @param {boolean} [preserveSymlinks]
1148
+ * Keep symlinks instead of resolving them.
1149
+ * @returns {URL}
1150
+ * A URL object to the found thing.
1151
+ */
1152
+ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1153
+ const protocol = base.protocol;
1154
+ const isRemote = protocol === "data:" || protocol === "http:" || protocol === "https:";
1155
+ /** @type {URL | undefined} */
1156
+ let resolved;
1157
+ if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) try {
1158
+ resolved = new URL$1(specifier, base);
1159
+ } catch (error_) {
1160
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1161
+ error.cause = error_;
1162
+ throw error;
1163
+ }
1164
+ else if (protocol === "file:" && specifier[0] === "#") resolved = packageImportsResolve(specifier, base, conditions);
1165
+ else try {
1166
+ resolved = new URL$1(specifier);
1167
+ } catch (error_) {
1168
+ if (isRemote && !builtinModules.includes(specifier)) {
1169
+ const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1170
+ error.cause = error_;
1171
+ throw error;
1172
+ }
1173
+ resolved = packageResolve(specifier, base, conditions);
1174
+ }
1175
+ assert(resolved !== void 0, "expected to be defined");
1176
+ if (resolved.protocol !== "file:") return resolved;
1177
+ return finalizeResolution(resolved, base);
1178
+ }
1179
+ function fileURLToPath$1(id) {
1180
+ if (typeof id === "string" && !id.startsWith("file://")) return normalizeSlash(id);
1181
+ return normalizeSlash(fileURLToPath(id));
1182
+ }
1183
+ function pathToFileURL$1(id) {
1184
+ return pathToFileURL(fileURLToPath$1(id)).toString();
1185
+ }
1186
+ const INVALID_CHAR_RE = /[\u0000-\u001F"#$&*+,/:;<=>?@[\]^`{|}\u007F]+/g;
1187
+ function sanitizeURIComponent(name = "", replacement = "_") {
1188
+ return name.replace(INVALID_CHAR_RE, replacement).replace(/%../g, replacement);
1189
+ }
1190
+ function sanitizeFilePath(filePath = "") {
1191
+ return filePath.replace(/\?.*$/, "").split(/[/\\]/g).map((p) => sanitizeURIComponent(p)).join("/").replace(/^([A-Za-z])_\//, "$1:/");
1192
+ }
1193
+ function normalizeid(id) {
1194
+ if (typeof id !== "string") id = id.toString();
1195
+ if (/(?:node|data|http|https|file):/.test(id)) return id;
1196
+ if (BUILTIN_MODULES.has(id)) return "node:" + id;
1197
+ return "file://" + encodeURI(normalizeSlash(id));
1198
+ }
1199
+ async function loadURL(url) {
1200
+ return await promises.readFile(fileURLToPath$1(url), "utf8");
1201
+ }
1202
+ const DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
1203
+ const DEFAULT_EXTENSIONS = [
1204
+ ".mjs",
1205
+ ".cjs",
1206
+ ".js",
1207
+ ".json"
1208
+ ];
1209
+ const NOT_FOUND_ERRORS = /* @__PURE__ */ new Set([
1210
+ "ERR_MODULE_NOT_FOUND",
1211
+ "ERR_UNSUPPORTED_DIR_IMPORT",
1212
+ "MODULE_NOT_FOUND",
1213
+ "ERR_PACKAGE_PATH_NOT_EXPORTED"
1214
+ ]);
1215
+ function _tryModuleResolve(id, url, conditions) {
1216
+ try {
1217
+ return moduleResolve(id, url, conditions);
1218
+ } catch (error) {
1219
+ if (!NOT_FOUND_ERRORS.has(error?.code)) throw error;
1220
+ }
1221
+ }
1222
+ function _resolve$1(id, options = {}) {
1223
+ if (typeof id !== "string") if (id instanceof URL) id = fileURLToPath$1(id);
1224
+ else throw new TypeError("input must be a `string` or `URL`");
1225
+ if (/(?:node|data|http|https):/.test(id)) return id;
1226
+ if (BUILTIN_MODULES.has(id)) return "node:" + id;
1227
+ if (id.startsWith("file://")) id = fileURLToPath$1(id);
1228
+ if (isAbsolute$1(id)) try {
1229
+ if (statSync(id).isFile()) return pathToFileURL$1(id);
1230
+ } catch (error) {
1231
+ if (error?.code !== "ENOENT") throw error;
1232
+ }
1233
+ const conditionsSet = options.conditions ? new Set(options.conditions) : DEFAULT_CONDITIONS_SET;
1234
+ const _urls = (Array.isArray(options.url) ? options.url : [options.url]).filter(Boolean).map((url) => new URL(normalizeid(url.toString())));
1235
+ if (_urls.length === 0) _urls.push(new URL(pathToFileURL$1(process.cwd())));
1236
+ const urls = [..._urls];
1237
+ for (const url of _urls) if (url.protocol === "file:") urls.push(new URL("./", url), new URL(joinURL(url.pathname, "_index.js"), url), new URL("node_modules", url));
1238
+ let resolved;
1239
+ for (const url of urls) {
1240
+ resolved = _tryModuleResolve(id, url, conditionsSet);
1241
+ if (resolved) break;
1242
+ for (const prefix of ["", "/index"]) {
1243
+ for (const extension of options.extensions || DEFAULT_EXTENSIONS) {
1244
+ resolved = _tryModuleResolve(joinURL(id, prefix) + extension, url, conditionsSet);
1245
+ if (resolved) break;
1246
+ }
1247
+ if (resolved) break;
1248
+ }
1249
+ if (resolved) break;
1250
+ }
1251
+ if (!resolved) {
1252
+ const error = /* @__PURE__ */ new Error(`Cannot find module ${id} imported from ${urls.join(", ")}`);
1253
+ error.code = "ERR_MODULE_NOT_FOUND";
1254
+ throw error;
1255
+ }
1256
+ return pathToFileURL$1(resolved);
1257
+ }
1258
+ function resolveSync(id, options) {
1259
+ return _resolve$1(id, options);
1260
+ }
1261
+ function resolve$1(id, options) {
1262
+ try {
1263
+ return Promise.resolve(resolveSync(id, options));
1264
+ } catch (error) {
1265
+ return Promise.reject(error);
1266
+ }
1267
+ }
1268
+ function resolvePathSync(id, options) {
1269
+ return fileURLToPath$1(resolveSync(id, options));
1270
+ }
1271
+ function resolvePath(id, options) {
1272
+ try {
1273
+ return Promise.resolve(resolvePathSync(id, options));
1274
+ } catch (error) {
1275
+ return Promise.reject(error);
1276
+ }
1277
+ }
1278
+ const NODE_MODULES_RE = /^(.+\/node_modules\/)([^/@]+|@[^/]+\/[^/]+)(\/?.*?)?$/;
1279
+ function parseNodeModulePath(path$1) {
1280
+ if (!path$1) return {};
1281
+ path$1 = normalize$1(fileURLToPath$1(path$1));
1282
+ const match = NODE_MODULES_RE.exec(path$1);
1283
+ if (!match) return {};
1284
+ const [, dir, name, subpath] = match;
1285
+ return {
1286
+ dir,
1287
+ name,
1288
+ subpath: subpath ? `.${subpath}` : void 0
1289
+ };
1290
+ }
1291
+ async function lookupNodeModuleSubpath(path$1) {
1292
+ path$1 = normalize$1(fileURLToPath$1(path$1));
1293
+ const { name, subpath } = parseNodeModulePath(path$1);
1294
+ if (!name || !subpath) return subpath;
1295
+ const { exports } = await readPackageJSON(path$1).catch(() => {}) || {};
1296
+ if (exports) {
1297
+ const resolvedSubpath = _findSubpath(subpath, exports);
1298
+ if (resolvedSubpath) return resolvedSubpath;
1299
+ }
1300
+ return subpath;
1301
+ }
1302
+ function _findSubpath(subpath, exports) {
1303
+ if (typeof exports === "string") exports = { ".": exports };
1304
+ if (!subpath.startsWith(".")) subpath = subpath.startsWith("/") ? `.${subpath}` : `./${subpath}`;
1305
+ if (subpath in (exports || {})) return subpath;
1306
+ return _flattenExports(exports).find((p) => p.fsPath === subpath)?.subpath;
1307
+ }
1308
+ function _flattenExports(exports = {}, parentSubpath = "./") {
1309
+ return Object.entries(exports).flatMap(([key, value]) => {
1310
+ const [subpath, condition] = key.startsWith(".") ? [key.slice(1), void 0] : ["", key];
1311
+ const _subPath = joinURL(parentSubpath, subpath);
1312
+ if (typeof value === "string") return [{
1313
+ subpath: _subPath,
1314
+ fsPath: value,
1315
+ condition
1316
+ }];
1317
+ else return _flattenExports(value, _subPath);
1318
+ });
1319
+ }
1320
+ const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;|\})import\s*(?:[\s"']*(?<imports>[\p{L}\p{M}\w\t\n\r $*,/{}@.]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][\s;]*/gmu;
1321
+ const EXPORT_DECAL_RE = /\bexport\s+(?<declaration>(?:async function\s*\*?|function\s*\*?|let|const enum|const|enum|var|class))\s+\*?(?<name>[\w$]+)(?<extraNames>.*,\s*[\s\w:[\]{}]*[\w$\]}]+)*/g;
1322
+ const EXPORT_DECAL_TYPE_RE = /\bexport\s+(?<declaration>(?:interface|type|declare (?:async function|function|let|const enum|const|enum|var|class)))\s+(?<name>[\w$]+)/g;
1323
+ const EXPORT_NAMED_RE = /\bexport\s*{(?<exports>[^}]+?)[\s,]*}(?:\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g;
1324
+ const EXPORT_NAMED_TYPE_RE = /\bexport\s+type\s*{(?<exports>[^}]+?)[\s,]*}(?:\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g;
1325
+ const EXPORT_NAMED_DESTRUCT = /\bexport\s+(?:let|var|const)\s+(?:{(?<exports1>[^}]+?)[\s,]*}|\[(?<exports2>[^\]]+?)[\s,]*])\s+=/gm;
1326
+ const EXPORT_STAR_RE = /\bexport\s*\*(?:\s*as\s+(?<name>[\w$]+)\s+)?\s*(?:\s*from\s*["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][^\n;]*)?/g;
1327
+ const EXPORT_DEFAULT_RE = /\bexport\s+default\s+(async function|function|class|true|false|\W|\d)|\bexport\s+default\s+(?<defaultName>.*)/g;
1328
+ const EXPORT_DEFAULT_CLASS_RE = /\bexport\s+default\s+(?<declaration>class)\s+(?<name>[\w$]+)/g;
1329
+ const TYPE_RE = /^\s*?type\s/;
1330
+ function findStaticImports(code) {
1331
+ return _filterStatement(_tryGetLocations(code, "import"), matchAll(ESM_STATIC_IMPORT_RE, code, { type: "static" }));
1332
+ }
1333
+ function parseStaticImport(matched) {
1334
+ const cleanedImports = clearImports(matched.imports);
1335
+ const namedImports = {};
1336
+ const _matches = cleanedImports.match(/{([^}]*)}/)?.[1]?.split(",") || [];
1337
+ for (const namedImport of _matches) {
1338
+ const _match = namedImport.match(/^\s*(\S*) as (\S*)\s*$/);
1339
+ const source = _match?.[1] || namedImport.trim();
1340
+ const importName = _match?.[2] || source;
1341
+ if (source && !TYPE_RE.test(source)) namedImports[source] = importName;
1342
+ }
1343
+ const { namespacedImport, defaultImport } = getImportNames(cleanedImports);
1344
+ return {
1345
+ ...matched,
1346
+ defaultImport,
1347
+ namespacedImport,
1348
+ namedImports
1349
+ };
1350
+ }
1351
+ function findExports(code) {
1352
+ const declaredExports = matchAll(EXPORT_DECAL_RE, code, { type: "declaration" });
1353
+ for (const declaredExport of declaredExports) {
1354
+ if (/^export\s+(?:async\s+)?function/.test(declaredExport.code)) continue;
1355
+ const extraNamesStr = declaredExport.extraNames;
1356
+ if (extraNamesStr) {
1357
+ const extraNames = matchAll(/({.*?})|(\[.*?])|(,\s*(?<name>\w+))/g, extraNamesStr, {}).map((m) => m.name).filter(Boolean);
1358
+ declaredExport.names = [declaredExport.name, ...extraNames];
1359
+ }
1360
+ delete declaredExport.extraNames;
1361
+ }
1362
+ const namedExports = normalizeNamedExports(matchAll(EXPORT_NAMED_RE, code, { type: "named" }));
1363
+ const destructuredExports = matchAll(EXPORT_NAMED_DESTRUCT, code, { type: "named" });
1364
+ for (const namedExport of destructuredExports) {
1365
+ namedExport.exports = namedExport.exports1 || namedExport.exports2;
1366
+ namedExport.names = namedExport.exports.replace(/^\r?\n?/, "").split(/\s*,\s*/g).filter((name) => !TYPE_RE.test(name)).map((name) => name.replace(/^.*?\s*:\s*/, "").replace(/\s*=\s*.*$/, "").trim());
1367
+ }
1368
+ const defaultExport = matchAll(EXPORT_DEFAULT_RE, code, {
1369
+ type: "default",
1370
+ name: "default"
1371
+ });
1372
+ const defaultClassExports = matchAll(EXPORT_DEFAULT_CLASS_RE, code, { type: "declaration" });
1373
+ const starExports = matchAll(EXPORT_STAR_RE, code, { type: "star" });
1374
+ const exports = normalizeExports([
1375
+ ...declaredExports,
1376
+ ...namedExports,
1377
+ ...destructuredExports,
1378
+ ...defaultExport,
1379
+ ...defaultClassExports,
1380
+ ...starExports
1381
+ ]);
1382
+ if (exports.length === 0) return [];
1383
+ const exportLocations = _tryGetLocations(code, "export");
1384
+ if (exportLocations && exportLocations.length === 0) return [];
1385
+ return _filterStatement(exportLocations, exports).filter((exp, index, exports2) => {
1386
+ const nextExport = exports2[index + 1];
1387
+ return !nextExport || exp.type !== nextExport.type || !exp.name || exp.name !== nextExport.name;
1388
+ });
1389
+ }
1390
+ function findTypeExports(code) {
1391
+ const declaredExports = matchAll(EXPORT_DECAL_TYPE_RE, code, { type: "declaration" });
1392
+ const namedExports = normalizeNamedExports(matchAll(EXPORT_NAMED_TYPE_RE, code, { type: "named" }));
1393
+ const exports = normalizeExports([...declaredExports, ...namedExports]);
1394
+ if (exports.length === 0) return [];
1395
+ const exportLocations = _tryGetLocations(code, "export");
1396
+ if (exportLocations && exportLocations.length === 0) return [];
1397
+ return _filterStatement(exportLocations, exports).filter((exp, index, exports2) => {
1398
+ const nextExport = exports2[index + 1];
1399
+ return !nextExport || exp.type !== nextExport.type || !exp.name || exp.name !== nextExport.name;
1400
+ });
1401
+ }
1402
+ function normalizeExports(exports) {
1403
+ for (const exp of exports) {
1404
+ if (!exp.name && exp.names && exp.names.length === 1) exp.name = exp.names[0];
1405
+ if (exp.name === "default" && exp.type !== "default") {
1406
+ exp._type = exp.type;
1407
+ exp.type = "default";
1408
+ }
1409
+ if (!exp.names && exp.name) exp.names = [exp.name];
1410
+ if (exp.type === "declaration" && exp.declaration) exp.declarationType = exp.declaration.replace(/^declare\s*/, "");
1411
+ }
1412
+ return exports;
1413
+ }
1414
+ function normalizeNamedExports(namedExports) {
1415
+ for (const namedExport of namedExports) namedExport.names = namedExport.exports.replace(/^\r?\n?/, "").split(/\s*,\s*/g).filter((name) => !TYPE_RE.test(name)).map((name) => name.replace(/^.*?\sas\s/, "").trim());
1416
+ return namedExports;
1417
+ }
1418
+ async function resolveModuleExportNames(id, options) {
1419
+ const url = await resolvePath(id, options);
1420
+ const exports = findExports(await loadURL(url));
1421
+ const exportNames = new Set(exports.flatMap((exp) => exp.names).filter(Boolean));
1422
+ for (const exp of exports) {
1423
+ if (exp.type !== "star" || !exp.specifier) continue;
1424
+ const subExports = await resolveModuleExportNames(exp.specifier, {
1425
+ ...options,
1426
+ url
1427
+ });
1428
+ for (const subExport of subExports) exportNames.add(subExport);
1429
+ }
1430
+ return [...exportNames];
1431
+ }
1432
+ function _filterStatement(locations, statements) {
1433
+ return statements.filter((exp) => {
1434
+ return !locations || locations.some((location) => {
1435
+ return exp.start <= location.start && exp.end >= location.end;
1436
+ });
1437
+ });
1438
+ }
1439
+ function _tryGetLocations(code, label) {
1440
+ try {
1441
+ return _getLocations(code, label);
1442
+ } catch {}
1443
+ }
1444
+ function _getLocations(code, label) {
1445
+ const tokens = tokenizer(code, {
1446
+ ecmaVersion: "latest",
1447
+ sourceType: "module",
1448
+ allowHashBang: true,
1449
+ allowAwaitOutsideFunction: true,
1450
+ allowImportExportEverywhere: true
1451
+ });
1452
+ const locations = [];
1453
+ for (const token of tokens) if (token.type.label === label) locations.push({
1454
+ start: token.start,
1455
+ end: token.end
1456
+ });
1457
+ return locations;
1458
+ }
1459
+ const ESM_RE = /(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
1460
+ const CJS_RE = /(?:[\s;]|^)(?:module\.exports\b|exports\.\w|require\s*\(|global\.\w)/m;
1461
+ const COMMENT_RE = /\/\*.+?\*\/|\/\/.*(?=[nr])/g;
1462
+ function hasESMSyntax(code, opts = {}) {
1463
+ if (opts.stripComments) code = code.replace(COMMENT_RE, "");
1464
+ return ESM_RE.test(code);
1465
+ }
1466
+ function hasCJSSyntax(code, opts = {}) {
1467
+ if (opts.stripComments) code = code.replace(COMMENT_RE, "");
1468
+ return CJS_RE.test(code);
1469
+ }
1470
+ function detectSyntax(code, opts = {}) {
1471
+ if (opts.stripComments) code = code.replace(COMMENT_RE, "");
1472
+ const hasESM = hasESMSyntax(code, {});
1473
+ const hasCJS = hasCJSSyntax(code, {});
1474
+ return {
1475
+ hasESM,
1476
+ hasCJS,
1477
+ isMixed: hasESM && hasCJS
1478
+ };
1479
+ }
1480
+
1481
+ //#endregion
1482
+ //#region node_modules/.pnpm/quansync@0.2.11/node_modules/quansync/dist/index.mjs
1483
+ const GET_IS_ASYNC = Symbol.for("quansync.getIsAsync");
1484
+ var QuansyncError = class extends Error {
1485
+ constructor(message = "Unexpected promise in sync context") {
1486
+ super(message);
1487
+ this.name = "QuansyncError";
1488
+ }
1489
+ };
1490
+ function isThenable(value) {
1491
+ return value && typeof value === "object" && typeof value.then === "function";
1492
+ }
1493
+ function isQuansyncGenerator(value) {
1494
+ return value && typeof value === "object" && typeof value[Symbol.iterator] === "function" && "__quansync" in value;
1495
+ }
1496
+ function fromObject(options) {
1497
+ const generator = function* (...args) {
1498
+ if (yield GET_IS_ASYNC) return yield options.async.apply(this, args);
1499
+ return options.sync.apply(this, args);
1500
+ };
1501
+ function fn(...args) {
1502
+ const iter = generator.apply(this, args);
1503
+ iter.then = (...thenArgs) => options.async.apply(this, args).then(...thenArgs);
1504
+ iter.__quansync = true;
1505
+ return iter;
1506
+ }
1507
+ fn.sync = options.sync;
1508
+ fn.async = options.async;
1509
+ return fn;
1510
+ }
1511
+ function fromPromise(promise) {
1512
+ return fromObject({
1513
+ async: () => Promise.resolve(promise),
1514
+ sync: () => {
1515
+ if (isThenable(promise)) throw new QuansyncError();
1516
+ return promise;
1517
+ }
1518
+ });
1519
+ }
1520
+ function unwrapYield(value, isAsync) {
1521
+ if (value === GET_IS_ASYNC) return isAsync;
1522
+ if (isQuansyncGenerator(value)) return isAsync ? iterateAsync(value) : iterateSync(value);
1523
+ if (!isAsync && isThenable(value)) throw new QuansyncError();
1524
+ return value;
1525
+ }
1526
+ const DEFAULT_ON_YIELD = (value) => value;
1527
+ function iterateSync(generator, onYield = DEFAULT_ON_YIELD) {
1528
+ let current = generator.next();
1529
+ while (!current.done) try {
1530
+ current = generator.next(unwrapYield(onYield(current.value, false)));
1531
+ } catch (err) {
1532
+ current = generator.throw(err);
1533
+ }
1534
+ return unwrapYield(current.value);
1535
+ }
1536
+ async function iterateAsync(generator, onYield = DEFAULT_ON_YIELD) {
1537
+ let current = generator.next();
1538
+ while (!current.done) try {
1539
+ current = generator.next(await unwrapYield(onYield(current.value, true), true));
1540
+ } catch (err) {
1541
+ current = generator.throw(err);
1542
+ }
1543
+ return current.value;
1544
+ }
1545
+ function fromGeneratorFn(generatorFn, options) {
1546
+ return fromObject({
1547
+ name: generatorFn.name,
1548
+ async(...args) {
1549
+ return iterateAsync(generatorFn.apply(this, args), options?.onYield);
1550
+ },
1551
+ sync(...args) {
1552
+ return iterateSync(generatorFn.apply(this, args), options?.onYield);
1553
+ }
1554
+ });
1555
+ }
1556
+ function quansync$1(input, options) {
1557
+ if (isThenable(input)) return fromPromise(input);
1558
+ if (typeof input === "function") return fromGeneratorFn(input, options);
1559
+ else return fromObject(input);
1560
+ }
1561
+ const getIsAsync = quansync$1({
1562
+ async: () => Promise.resolve(true),
1563
+ sync: () => false
1564
+ });
1565
+
1566
+ //#endregion
1567
+ //#region node_modules/.pnpm/quansync@0.2.11/node_modules/quansync/dist/macro.mjs
1568
+ const quansync = quansync$1;
1569
+
1570
+ //#endregion
1571
+ //#region node_modules/.pnpm/local-pkg@1.1.2/node_modules/local-pkg/dist/index.mjs
1572
+ const toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
1573
+ async function findUp$1(name, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
1574
+ let directory = path.resolve(toPath(cwd) ?? "");
1575
+ const { root } = path.parse(directory);
1576
+ stopAt = path.resolve(directory, toPath(stopAt ?? root));
1577
+ const isAbsoluteName = path.isAbsolute(name);
1578
+ while (directory) {
1579
+ const filePath = isAbsoluteName ? name : path.join(directory, name);
1580
+ try {
1581
+ const stats = await fsp.stat(filePath);
1582
+ if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
1583
+ } catch {}
1584
+ if (directory === stopAt || directory === root) break;
1585
+ directory = path.dirname(directory);
1586
+ }
1587
+ }
1588
+ function findUpSync(name, { cwd = process$1.cwd(), type = "file", stopAt } = {}) {
1589
+ let directory = path.resolve(toPath(cwd) ?? "");
1590
+ const { root } = path.parse(directory);
1591
+ stopAt = path.resolve(directory, toPath(stopAt) ?? root);
1592
+ const isAbsoluteName = path.isAbsolute(name);
1593
+ while (directory) {
1594
+ const filePath = isAbsoluteName ? name : path.join(directory, name);
1595
+ try {
1596
+ const stats = fs.statSync(filePath, { throwIfNoEntry: false });
1597
+ if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
1598
+ } catch {}
1599
+ if (directory === stopAt || directory === root) break;
1600
+ directory = path.dirname(directory);
1601
+ }
1602
+ }
1603
+ function _resolve(path$1, options = {}) {
1604
+ if (options.platform === "auto" || !options.platform) options.platform = process$1.platform === "win32" ? "win32" : "posix";
1605
+ if (process$1.versions.pnp) {
1606
+ const paths = options.paths || [];
1607
+ if (paths.length === 0) paths.push(process$1.cwd());
1608
+ const targetRequire = createRequire(import.meta.url);
1609
+ try {
1610
+ return targetRequire.resolve(path$1, { paths });
1611
+ } catch {}
1612
+ }
1613
+ const modulePath = resolvePathSync(path$1, { url: options.paths });
1614
+ if (options.platform === "win32") return win32.normalize(modulePath);
1615
+ return modulePath;
1616
+ }
1617
+ function resolveModule(name, options = {}) {
1618
+ try {
1619
+ return _resolve(name, options);
1620
+ } catch {
1621
+ return;
1622
+ }
1623
+ }
1624
+ function getPackageJsonPath(name, options = {}) {
1625
+ const entry = resolvePackage(name, options);
1626
+ if (!entry) return;
1627
+ return searchPackageJSON(entry);
1628
+ }
1629
+ const readFile$1 = quansync({
1630
+ async: (id) => fs.promises.readFile(id, "utf8"),
1631
+ sync: (id) => fs.readFileSync(id, "utf8")
1632
+ });
1633
+ const getPackageInfo = quansync(function* (name, options = {}) {
1634
+ const packageJsonPath = getPackageJsonPath(name, options);
1635
+ if (!packageJsonPath) return;
1636
+ const packageJson = JSON.parse(yield readFile$1(packageJsonPath));
1637
+ return {
1638
+ name,
1639
+ version: packageJson.version,
1640
+ rootPath: dirname(packageJsonPath),
1641
+ packageJsonPath,
1642
+ packageJson
1643
+ };
1644
+ });
1645
+ const getPackageInfoSync = getPackageInfo.sync;
1646
+ function resolvePackage(name, options = {}) {
1647
+ try {
1648
+ return _resolve(`${name}/package.json`, options);
1649
+ } catch {}
1650
+ try {
1651
+ return _resolve(name, options);
1652
+ } catch (e) {
1653
+ if (e.code !== "MODULE_NOT_FOUND" && e.code !== "ERR_MODULE_NOT_FOUND") console.error(e);
1654
+ return false;
1655
+ }
1656
+ }
1657
+ function searchPackageJSON(dir) {
1658
+ let packageJsonPath;
1659
+ while (true) {
1660
+ if (!dir) return;
1661
+ const newDir = dirname(dir);
1662
+ if (newDir === dir) return;
1663
+ dir = newDir;
1664
+ packageJsonPath = join(dir, "package.json");
1665
+ if (fs.existsSync(packageJsonPath)) break;
1666
+ }
1667
+ return packageJsonPath;
1668
+ }
1669
+ const findUp = quansync({
1670
+ sync: findUpSync,
1671
+ async: findUp$1
1672
+ });
1673
+ const loadPackageJSON = quansync(function* (cwd = process$1.cwd()) {
1674
+ const path$1 = yield findUp("package.json", { cwd });
1675
+ if (!path$1 || !fs.existsSync(path$1)) return null;
1676
+ return JSON.parse(yield readFile$1(path$1));
1677
+ });
1678
+ const loadPackageJSONSync = loadPackageJSON.sync;
1679
+ const isPackageListed = quansync(function* (name, cwd) {
1680
+ const pkg = (yield loadPackageJSON(cwd)) || {};
1681
+ return name in (pkg.dependencies || {}) || name in (pkg.devDependencies || {});
1682
+ });
1683
+ const isPackageListedSync = isPackageListed.sync;
1684
+
1685
+ //#endregion
1686
+ export { findStaticImports as a, parseNodeModulePath as c, resolveModuleExportNames as d, sanitizeFilePath as f, findExports as i, parseStaticImport as l, detectSyntax as n, findTypeExports as o, fileURLToPath$1 as r, lookupNodeModuleSubpath as s, resolveModule as t, resolve$1 as u };