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,763 @@
1
+ import { s as __toESM } from "../_chunks/DXMHy5ca.mjs";
2
+ import { T as resolve$1, _ as dirname$1, b as join$1, v as extname$1, w as relative$1 } from "../_libs/c12.mjs";
3
+ import { i as unplugin } from "../_libs/unimport.mjs";
4
+ import { t as glob } from "../_libs/tinyglobby.mjs";
5
+ import { u as writeFile$1 } from "../_chunks/B5ooyfLk.mjs";
6
+ import { t as src_default } from "../_libs/mime.mjs";
7
+ import { i as genSafeVariableName, t as genImport } from "../_libs/knitwork.mjs";
8
+ import { t as require_etag } from "../_libs/etag.mjs";
9
+ import { t as replace } from "../_libs/plugin-replace.mjs";
10
+ import { t as rollup } from "../_libs/unwasm.mjs";
11
+ import { dirname } from "node:path";
12
+ import { camelCase } from "scule";
13
+ import { promises } from "node:fs";
14
+ import { withTrailingSlash } from "ufo";
15
+ import { mkdir, readFile, symlink, unlink } from "node:fs/promises";
16
+ import { defu } from "defu";
17
+ import { runtimeDependencies, runtimeDir } from "nitro/runtime/meta";
18
+ import { builtinDrivers, normalizeKey } from "unstorage";
19
+ import { hash } from "ohash";
20
+ import { version } from "nitro/meta";
21
+ import { defineEnv } from "unenv";
22
+ import { connectors } from "db0";
23
+ import { transform } from "esbuild";
24
+ import { rollupNodeFileTrace } from "nf3";
25
+ import { RENDER_CONTEXT_KEYS, compileTemplateToString, hasTemplateSyntax } from "rendu";
26
+
27
+ //#region src/build/plugins/replace.ts
28
+ const NO_REPLACE_RE = /ROLLUP_NO_REPLACE|\\0raw:/;
29
+ function replace$1(options) {
30
+ const _plugin = replace(options);
31
+ return {
32
+ ..._plugin,
33
+ renderChunk(code, chunk, options$1) {
34
+ if (!NO_REPLACE_RE.test(code)) return _plugin.renderChunk.call(this, code, chunk, options$1);
35
+ }
36
+ };
37
+ }
38
+
39
+ //#endregion
40
+ //#region src/build/config.ts
41
+ function baseBuildConfig(nitro) {
42
+ const buildServerDir = join$1(nitro.options.buildDir, "dist/server");
43
+ const presetsDir$1 = resolve$1(runtimeDir, "../presets");
44
+ const extensions = [
45
+ ".ts",
46
+ ".mjs",
47
+ ".js",
48
+ ".json",
49
+ ".node",
50
+ ".tsx",
51
+ ".jsx"
52
+ ];
53
+ const isNodeless = nitro.options.node === false;
54
+ let NODE_ENV = nitro.options.dev ? "development" : "production";
55
+ if (nitro.options.preset === "nitro-prerender") NODE_ENV = "prerender";
56
+ const buildEnvVars = {
57
+ NODE_ENV,
58
+ prerender: nitro.options.preset === "nitro-prerender",
59
+ server: true,
60
+ client: false,
61
+ dev: String(nitro.options.dev),
62
+ DEBUG: nitro.options.dev
63
+ };
64
+ const staticFlags = {
65
+ dev: nitro.options.dev,
66
+ preset: nitro.options.preset,
67
+ prerender: nitro.options.preset === "nitro-prerender",
68
+ server: true,
69
+ client: false,
70
+ nitro: true,
71
+ baseURL: nitro.options.baseURL,
72
+ "versions.nitro": "",
73
+ "versions?.nitro": "",
74
+ _asyncContext: nitro.options.experimental.asyncContext,
75
+ _websocket: nitro.options.experimental.websocket,
76
+ _tasks: nitro.options.experimental.tasks
77
+ };
78
+ const replaceDelimiters = [String.raw`\b`, String.raw`(?![\w.$])`];
79
+ const replacements = {
80
+ "typeof window": "\"undefined\"",
81
+ _import_meta_url_: "import.meta.url",
82
+ "globalThis.process.": "process.",
83
+ "process.env.RUNTIME_CONFIG": () => JSON.stringify(nitro.options.runtimeConfig, null, 2),
84
+ ...Object.fromEntries(Object.entries(buildEnvVars).map(([key, val]) => [`process.env.${key}`, JSON.stringify(val)])),
85
+ ...Object.fromEntries(Object.entries(buildEnvVars).map(([key, val]) => [`import.meta.env.${key}`, JSON.stringify(val)])),
86
+ ...Object.fromEntries(Object.entries(staticFlags).map(([key, val]) => [`process.${key}`, JSON.stringify(val)])),
87
+ ...Object.fromEntries(Object.entries(staticFlags).map(([key, val]) => [`import.meta.${key}`, JSON.stringify(val)])),
88
+ ...nitro.options.replace
89
+ };
90
+ const { env } = defineEnv({
91
+ nodeCompat: isNodeless,
92
+ npmShims: true,
93
+ resolve: true,
94
+ presets: nitro.options.unenv,
95
+ overrides: { alias: nitro.options.alias }
96
+ });
97
+ return {
98
+ buildServerDir,
99
+ presetsDir: presetsDir$1,
100
+ extensions,
101
+ isNodeless,
102
+ buildEnvVars,
103
+ staticFlags,
104
+ replaceDelimiters,
105
+ replacements,
106
+ env,
107
+ aliases: resolveAliases({
108
+ "#internal/nitro": runtimeDir,
109
+ "nitro/runtime": runtimeDir,
110
+ "nitropack/runtime": runtimeDir,
111
+ ...env.alias
112
+ })
113
+ };
114
+ }
115
+ function resolveAliases(_aliases) {
116
+ const aliases = Object.fromEntries(Object.entries(_aliases).sort(([a], [b]) => b.split("/").length - a.split("/").length || b.length - a.length));
117
+ for (const key in aliases) for (const alias in aliases) {
118
+ if (![
119
+ "~",
120
+ "@",
121
+ "#"
122
+ ].includes(alias[0])) continue;
123
+ if (alias === "@" && !aliases[key].startsWith("@/")) continue;
124
+ if (aliases[key].startsWith(alias)) aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
125
+ }
126
+ return aliases;
127
+ }
128
+
129
+ //#endregion
130
+ //#region src/build/plugins/virtual.ts
131
+ const PREFIX = "\0virtual:";
132
+ function virtual(modules, cache = {}) {
133
+ const _modules = /* @__PURE__ */ new Map();
134
+ for (const [id, mod] of Object.entries(modules)) {
135
+ cache[id] = mod;
136
+ _modules.set(id, mod);
137
+ _modules.set(resolve$1(id), mod);
138
+ }
139
+ return {
140
+ name: "virtual",
141
+ resolveId(id, importer) {
142
+ if (id in modules) return PREFIX + id;
143
+ if (importer) {
144
+ const resolved = resolve$1(dirname$1(importer.startsWith(PREFIX) ? importer.slice(9) : importer), id);
145
+ if (_modules.has(resolved)) return PREFIX + resolved;
146
+ }
147
+ return null;
148
+ },
149
+ async load(id) {
150
+ if (!id.startsWith(PREFIX)) return null;
151
+ const idNoPrefix = id.slice(9);
152
+ if (!_modules.has(idNoPrefix)) return null;
153
+ let m = _modules.get(idNoPrefix);
154
+ if (typeof m === "function") m = await m();
155
+ if (!m) return null;
156
+ cache[id.replace(PREFIX, "")] = m;
157
+ return {
158
+ code: m,
159
+ map: null
160
+ };
161
+ }
162
+ };
163
+ }
164
+
165
+ //#endregion
166
+ //#region src/build/plugins/database.ts
167
+ function database(nitro) {
168
+ if (!nitro.options.experimental.database) return virtual({ "#nitro-internal-virtual/database": () => {
169
+ return `export const connectionConfigs = {};`;
170
+ } }, nitro.vfs);
171
+ const dbConfigs = nitro.options.dev && nitro.options.devDatabase || nitro.options.database;
172
+ const connectorsNames = [...new Set(Object.values(dbConfigs || {}).map((config) => config?.connector))].filter(Boolean);
173
+ for (const name of connectorsNames) if (!connectors[name]) throw new Error(`Database connector "${name}" is invalid.`);
174
+ return virtual({ "#nitro-internal-virtual/database": () => {
175
+ return `
176
+ ${connectorsNames.map((name) => `import ${camelCase(name)}Connector from "${connectors[name]}";`).join("\n")}
177
+
178
+ export const connectionConfigs = {
179
+ ${Object.entries(dbConfigs || {}).map(([name, { connector, options }]) => `${name}: {
180
+ connector: ${camelCase(connector)}Connector,
181
+ options: ${JSON.stringify(options)}
182
+ }`).join(",\n")}
183
+ };
184
+ `;
185
+ } }, nitro.vfs);
186
+ }
187
+
188
+ //#endregion
189
+ //#region src/build/plugins/routing.ts
190
+ const RuntimeRouteRules = [
191
+ "headers",
192
+ "redirect",
193
+ "proxy",
194
+ "cache"
195
+ ];
196
+ function routing(nitro) {
197
+ return virtual({
198
+ "#nitro-internal-virtual/routing": () => {
199
+ const allHandlers = uniqueBy([
200
+ ...Object.values(nitro.routing.routes.routes).map((h) => h.data),
201
+ ...Object.values(nitro.routing.routedMiddleware.routes).map((h) => h.data),
202
+ ...nitro.routing.globalMiddleware
203
+ ], "_importHash");
204
+ const h3Imports = [
205
+ allHandlers.some((h) => !h.lazy) && "toEventHandler",
206
+ nitro.options.serverEntry && "toMiddleware",
207
+ allHandlers.some((h) => h.lazy) && "defineLazyEventHandler"
208
+ ].filter(Boolean);
209
+ return `
210
+ import * as __routeRules__ from "nitro/runtime/internal/route-rules";
211
+ ${nitro.options.serverEntry ? `import __serverEntry__ from ${JSON.stringify(nitro.options.serverEntry)};` : ""}
212
+ import {${h3Imports.join(", ")}} from "h3";
213
+
214
+ export const findRouteRules = ${nitro.routing.routeRules.compileToString({
215
+ serialize: serializeRouteRule,
216
+ matchAll: true
217
+ })}
218
+
219
+ ${allHandlers.filter((h) => !h.lazy).map((h) => `import ${h._importHash} from "${h.handler}";`).join("\n")}
220
+
221
+ ${allHandlers.filter((h) => h.lazy).map((h) => `const ${h._importHash} = defineLazyEventHandler(() => import("${h.handler}"));`).join("\n")}
222
+
223
+ export const findRoute = ${nitro.routing.routes.compileToString({ serialize: serializeHandler })}
224
+
225
+ export const findRoutedMiddleware = ${nitro.routing.routedMiddleware.compileToString({
226
+ serialize: serializeHandler,
227
+ matchAll: true
228
+ })};
229
+
230
+ export const globalMiddleware = [
231
+ ${nitro.routing.globalMiddleware.map((h) => h.lazy ? h._importHash : `toEventHandler(${h._importHash})`).join(",")}
232
+ ${nitro.options.serverEntry ? `,toMiddleware(__serverEntry__)` : ""}
233
+ ].filter(Boolean);
234
+ `;
235
+ },
236
+ "#nitro-internal-virtual/routing-meta": () => {
237
+ const routeHandlers = uniqueBy(Object.values(nitro.routing.routes.routes).map((h) => h.data), "_importHash");
238
+ return `
239
+ ${routeHandlers.map((h) => `import ${h._importHash}Meta from "${h.handler}?meta";`).join("\n")}
240
+ export const handlersMeta = [
241
+ ${routeHandlers.map((h) => `{ route: ${JSON.stringify(h.route)}, method: ${JSON.stringify(h.method?.toLowerCase())}, meta: ${h._importHash}Meta }`).join(",\n")}
242
+ ];
243
+ `.trim();
244
+ }
245
+ }, nitro.vfs);
246
+ }
247
+ function uniqueBy(arr, key) {
248
+ return [...new Map(arr.map((item) => [item[key], item])).values()];
249
+ }
250
+ function serializeHandler(h) {
251
+ return `{${[
252
+ `route:${JSON.stringify(h.route)}`,
253
+ h.method && `method:${JSON.stringify(h.method)}`,
254
+ h.meta && `meta:${JSON.stringify(h.meta)}`,
255
+ `handler:${h.lazy ? h._importHash : `toEventHandler(${h._importHash})`}`
256
+ ].filter(Boolean).join(",")}}`;
257
+ }
258
+ function serializeRouteRule(h) {
259
+ return `[${Object.entries(h).filter(([name, options]) => options !== void 0 && name[0] !== "_").map(([name, options]) => {
260
+ return `{${[
261
+ `name:${JSON.stringify(name)}`,
262
+ `route:${JSON.stringify(h._route)}`,
263
+ h._method && `method:${JSON.stringify(h._method)}`,
264
+ RuntimeRouteRules.includes(name) && `handler:__routeRules__.${name}`,
265
+ `options:${JSON.stringify(options)}`
266
+ ].filter(Boolean).join(",")}}`;
267
+ }).join(",")}]`;
268
+ }
269
+
270
+ //#endregion
271
+ //#region src/build/plugins/route-meta.ts
272
+ const virtualPrefix = "\0nitro-handler-meta:";
273
+ const esbuildLoaders = {
274
+ ".ts": "ts",
275
+ ".js": "js",
276
+ ".tsx": "tsx",
277
+ ".jsx": "jsx"
278
+ };
279
+ function routeMeta(nitro) {
280
+ return {
281
+ name: "nitro:route-meta",
282
+ async resolveId(id, importer, resolveOpts) {
283
+ if (id.startsWith("\0")) return;
284
+ if (id.endsWith(`?meta`)) {
285
+ const resolved = await this.resolve(id.replace(`?meta`, ``), importer, resolveOpts);
286
+ if (!resolved) return;
287
+ return virtualPrefix + resolved.id;
288
+ }
289
+ },
290
+ load(id) {
291
+ if (id.startsWith(virtualPrefix)) return readFile(id.slice(20), { encoding: "utf8" });
292
+ },
293
+ async transform(code, id) {
294
+ if (!id.startsWith(virtualPrefix)) return;
295
+ let meta = null;
296
+ try {
297
+ const jsCode = await transform(code, { loader: esbuildLoaders[extname$1(id)] }).then((r) => r.code);
298
+ const ast = this.parse(jsCode);
299
+ for (const node of ast.body) if (node.type === "ExpressionStatement" && node.expression.type === "CallExpression" && node.expression.callee.type === "Identifier" && node.expression.callee.name === "defineRouteMeta" && node.expression.arguments.length === 1) {
300
+ meta = astToObject(node.expression.arguments[0]);
301
+ break;
302
+ }
303
+ } catch (error) {
304
+ nitro.logger.warn(`[handlers-meta] Cannot extra route meta for: ${id}: ${error}`);
305
+ }
306
+ return {
307
+ code: `export default ${JSON.stringify(meta)};`,
308
+ map: null
309
+ };
310
+ }
311
+ };
312
+ }
313
+ function astToObject(node) {
314
+ switch (node.type) {
315
+ case "ObjectExpression": {
316
+ const obj = {};
317
+ for (const prop of node.properties) if (prop.type === "Property") {
318
+ const key = prop.key.name ?? prop.key.value;
319
+ obj[key] = astToObject(prop.value);
320
+ }
321
+ return obj;
322
+ }
323
+ case "ArrayExpression": return node.elements.map((el) => astToObject(el)).filter(Boolean);
324
+ case "Literal": return node.value;
325
+ }
326
+ }
327
+
328
+ //#endregion
329
+ //#region src/build/plugins/server-main.ts
330
+ function serverMain(nitro) {
331
+ return {
332
+ name: "nitro:server-main",
333
+ renderChunk(code, chunk) {
334
+ if (chunk.isEntry) return {
335
+ code: `globalThis.__nitro_main__ = import.meta.url; ${code}`,
336
+ map: null
337
+ };
338
+ }
339
+ };
340
+ }
341
+
342
+ //#endregion
343
+ //#region src/build/plugins/public-assets.ts
344
+ var import_etag$1 = /* @__PURE__ */ __toESM(require_etag(), 1);
345
+ const readAssetHandler = {
346
+ true: "node",
347
+ node: "node",
348
+ false: "null",
349
+ deno: "deno",
350
+ inline: "inline"
351
+ };
352
+ function publicAssets(nitro) {
353
+ return virtual({
354
+ "#nitro-internal-virtual/public-assets-data": async () => {
355
+ const assets = {};
356
+ const files = await glob("**", {
357
+ cwd: nitro.options.output.publicDir,
358
+ absolute: false,
359
+ dot: true
360
+ });
361
+ for (const id of files) {
362
+ let mimeType = src_default.getType(id.replace(/\.(gz|br)$/, "")) || "text/plain";
363
+ if (mimeType.startsWith("text")) mimeType += "; charset=utf-8";
364
+ const fullPath = resolve$1(nitro.options.output.publicDir, id);
365
+ const assetData = await promises.readFile(fullPath);
366
+ const etag = (0, import_etag$1.default)(assetData);
367
+ const stat$1 = await promises.stat(fullPath);
368
+ const assetId = "/" + decodeURIComponent(id);
369
+ let encoding;
370
+ if (id.endsWith(".gz")) encoding = "gzip";
371
+ else if (id.endsWith(".br")) encoding = "br";
372
+ assets[assetId] = {
373
+ type: nitro._prerenderMeta?.[assetId]?.contentType || mimeType,
374
+ encoding,
375
+ etag,
376
+ mtime: stat$1.mtime.toJSON(),
377
+ size: stat$1.size,
378
+ path: relative$1(nitro.options.output.serverDir, fullPath),
379
+ data: nitro.options.serveStatic === "inline" ? assetData.toString("base64") : void 0
380
+ };
381
+ }
382
+ return `export default ${JSON.stringify(assets, null, 2)};`;
383
+ },
384
+ "#nitro-internal-virtual/public-assets-node": () => {
385
+ return `
386
+ import { promises as fsp } from 'node:fs'
387
+ import { fileURLToPath } from 'node:url'
388
+ import { resolve, dirname } from 'node:path'
389
+ import assets from '#nitro-internal-virtual/public-assets-data'
390
+ export function readAsset (id) {
391
+ const serverDir = dirname(fileURLToPath(globalThis.__nitro_main__))
392
+ return fsp.readFile(resolve(serverDir, assets[id].path))
393
+ }`;
394
+ },
395
+ "#nitro-internal-virtual/public-assets-deno": () => {
396
+ return `
397
+ import assets from '#nitro-internal-virtual/public-assets-data'
398
+ export function readAsset (id) {
399
+ // https://deno.com/deploy/docs/serve-static-assets
400
+ const path = '.' + decodeURIComponent(new URL(\`../public\${id}\`, 'file://').pathname)
401
+ return Deno.readFile(path);
402
+ }`;
403
+ },
404
+ "#nitro-internal-virtual/public-assets-null": () => {
405
+ return `
406
+ export function readAsset (id) {
407
+ return Promise.resolve(null);
408
+ }`;
409
+ },
410
+ "#nitro-internal-virtual/public-assets-inline": () => {
411
+ return `
412
+ import assets from '#nitro-internal-virtual/public-assets-data'
413
+ export function readAsset (id) {
414
+ if (!assets[id]) { return undefined }
415
+ if (assets[id]._data) { return assets[id]._data }
416
+ if (!assets[id].data) { return assets[id].data }
417
+ assets[id]._data = Uint8Array.from(atob(assets[id].data), (c) => c.charCodeAt(0))
418
+ return assets[id]._data
419
+ }`;
420
+ },
421
+ "#nitro-internal-virtual/public-assets": () => {
422
+ const publicAssetBases = Object.fromEntries(nitro.options.publicAssets.filter((dir) => !dir.fallthrough && dir.baseURL !== "/").map((dir) => [withTrailingSlash(dir.baseURL), { maxAge: dir.maxAge }]));
423
+ return `
424
+ import assets from '#nitro-internal-virtual/public-assets-data'
425
+ export { readAsset } from "${`#nitro-internal-virtual/public-assets-${readAssetHandler[nitro.options.serveStatic] || "null"}`}"
426
+ export const publicAssetBases = ${JSON.stringify(publicAssetBases)}
427
+
428
+ export function isPublicAssetURL(id = '') {
429
+ if (assets[id]) {
430
+ return true
431
+ }
432
+ for (const base in publicAssetBases) {
433
+ if (id.startsWith(base)) { return true }
434
+ }
435
+ return false
436
+ }
437
+
438
+ export function getPublicAssetMeta(id = '') {
439
+ for (const base in publicAssetBases) {
440
+ if (id.startsWith(base)) { return publicAssetBases[base] }
441
+ }
442
+ return {}
443
+ }
444
+
445
+ export function getAsset (id) {
446
+ return assets[id]
447
+ }
448
+ `;
449
+ }
450
+ }, nitro.vfs);
451
+ }
452
+
453
+ //#endregion
454
+ //#region src/build/plugins/server-assets.ts
455
+ var import_etag = /* @__PURE__ */ __toESM(require_etag(), 1);
456
+ function serverAssets(nitro) {
457
+ if (nitro.options.dev || nitro.options.preset === "nitro-prerender") return virtual({ "#nitro-internal-virtual/server-assets": getAssetsDev(nitro) }, nitro.vfs);
458
+ return virtual({ "#nitro-internal-virtual/server-assets": async () => {
459
+ const assets = {};
460
+ for (const asset of nitro.options.serverAssets) {
461
+ const files = await glob(asset.pattern || "**/*", {
462
+ cwd: asset.dir,
463
+ absolute: false,
464
+ ignore: asset.ignore
465
+ });
466
+ for (const _id of files) {
467
+ const fsPath = resolve$1(asset.dir, _id);
468
+ const id = asset.baseName + "/" + _id;
469
+ assets[id] = {
470
+ fsPath,
471
+ meta: {}
472
+ };
473
+ let type = src_default.getType(id) || "text/plain";
474
+ if (type.startsWith("text")) type += "; charset=utf-8";
475
+ const etag = (0, import_etag.default)(await promises.readFile(fsPath));
476
+ const mtime = await promises.stat(fsPath).then((s) => s.mtime.toJSON());
477
+ assets[id].meta = {
478
+ type,
479
+ etag,
480
+ mtime
481
+ };
482
+ }
483
+ }
484
+ return getAssetProd(assets);
485
+ } }, nitro.vfs);
486
+ }
487
+ function getAssetsDev(nitro) {
488
+ return `
489
+ import { createStorage } from 'unstorage'
490
+ import fsDriver from 'unstorage/drivers/fs'
491
+
492
+ const serverAssets = ${JSON.stringify(nitro.options.serverAssets)}
493
+
494
+ export const assets = createStorage()
495
+
496
+ for (const asset of serverAssets) {
497
+ assets.mount(asset.baseName, fsDriver({ base: asset.dir, ignore: (asset?.ignore || []) }))
498
+ }`;
499
+ }
500
+ function getAssetProd(assets) {
501
+ return `
502
+ const _assets = {\n${Object.entries(assets).map(([id, asset]) => ` [${JSON.stringify(normalizeKey(id))}]: {\n import: () => import(${JSON.stringify("raw:" + asset.fsPath)}).then(r => r.default || r),\n meta: ${JSON.stringify(asset.meta)}\n }`).join(",\n")}\n}
503
+
504
+ const normalizeKey = ${normalizeKey.toString()}
505
+
506
+ export const assets = {
507
+ getKeys() {
508
+ return Promise.resolve(Object.keys(_assets))
509
+ },
510
+ hasItem (id) {
511
+ id = normalizeKey(id)
512
+ return Promise.resolve(id in _assets)
513
+ },
514
+ getItem (id) {
515
+ id = normalizeKey(id)
516
+ return Promise.resolve(_assets[id] ? _assets[id].import() : null)
517
+ },
518
+ getMeta (id) {
519
+ id = normalizeKey(id)
520
+ return Promise.resolve(_assets[id] ? _assets[id].meta : {})
521
+ }
522
+ }
523
+ `;
524
+ }
525
+
526
+ //#endregion
527
+ //#region src/build/plugins/storage.ts
528
+ function storage(nitro) {
529
+ const mounts = [];
530
+ const isDevOrPrerender = nitro.options.dev || nitro.options.preset === "nitro-prerender";
531
+ const storageMounts = isDevOrPrerender ? {
532
+ ...nitro.options.storage,
533
+ ...nitro.options.devStorage
534
+ } : nitro.options.storage;
535
+ for (const path$1 in storageMounts) {
536
+ const mount = storageMounts[path$1];
537
+ mounts.push({
538
+ path: path$1,
539
+ driver: builtinDrivers[mount.driver] || mount.driver,
540
+ opts: mount
541
+ });
542
+ }
543
+ const driverImports = [...new Set(mounts.map((m) => m.driver))];
544
+ const bundledStorageCode = `
545
+ import { prefixStorage } from 'unstorage'
546
+ import overlay from 'unstorage/drivers/overlay'
547
+ import memory from 'unstorage/drivers/memory'
548
+
549
+ const bundledStorage = ${JSON.stringify(nitro.options.bundledStorage)}
550
+ for (const base of bundledStorage) {
551
+ storage.mount(base, overlay({
552
+ layers: [
553
+ memory(),
554
+ // TODO
555
+ // prefixStorage(storage, base),
556
+ prefixStorage(storage, 'assets:nitro:bundled:' + base)
557
+ ]
558
+ }))
559
+ }`;
560
+ return virtual({ "#nitro-internal-virtual/storage": `
561
+ import { createStorage } from 'unstorage'
562
+ import { assets } from '#nitro-internal-virtual/server-assets'
563
+
564
+ ${driverImports.map((i) => genImport(i, genSafeVariableName(i))).join("\n")}
565
+
566
+ export function initStorage() {
567
+ const storage = createStorage({})
568
+ storage.mount('/assets', assets)
569
+ ${mounts.map((m) => `storage.mount('${m.path}', ${genSafeVariableName(m.driver)}(${JSON.stringify(m.opts)}))`).join("\n")}
570
+
571
+ ${!isDevOrPrerender && nitro.options.bundledStorage.length > 0 ? bundledStorageCode : ""}
572
+ return storage
573
+ }
574
+ ` }, nitro.vfs);
575
+ }
576
+
577
+ //#endregion
578
+ //#region src/build/plugins/error-handler.ts
579
+ function errorHandler(nitro) {
580
+ return virtual({ "#nitro-internal-virtual/error-handler": () => {
581
+ const errorHandlers = Array.isArray(nitro.options.errorHandler) ? nitro.options.errorHandler : [nitro.options.errorHandler];
582
+ const builtinHandler = join$1(runtimeDir, `internal/error/${nitro.options.dev ? "dev" : "prod"}`);
583
+ return `
584
+ ${errorHandlers.map((h, i) => `import errorHandler$${i} from "${h}";`).join("\n")}
585
+
586
+ const errorHandlers = [${errorHandlers.map((_, i) => `errorHandler$${i}`).join(", ")}];
587
+
588
+ import { defaultHandler } from "${builtinHandler}";
589
+
590
+ export default async function(error, event) {
591
+ for (const handler of errorHandlers) {
592
+ try {
593
+ const response = await handler(error, event, { defaultHandler });
594
+ if (response) {
595
+ return response;
596
+ }
597
+ } catch(error) {
598
+ // Handler itself thrown, log and continue
599
+ console.error(error);
600
+ }
601
+ }
602
+ // H3 will handle fallback
603
+ }
604
+ `;
605
+ } }, nitro.vfs);
606
+ }
607
+
608
+ //#endregion
609
+ //#region src/build/plugins/renderer-template.ts
610
+ function rendererTemplate(nitro) {
611
+ return virtual({ "#nitro-internal-virtual/renderer-template": async () => {
612
+ if (typeof nitro.options.renderer?.template !== "string") return `export const rendererTemplate = () => '<!-- renderer.template is not set -->'; export const rendererTemplateFile = undefined;`;
613
+ if (nitro.options.dev) return `import { readFile } from 'node:fs/promises';export const rendererTemplate = () => readFile(${JSON.stringify(nitro.options.renderer?.template)}, "utf8"); export const rendererTemplateFile = ${JSON.stringify(nitro.options.renderer?.template)};`;
614
+ else {
615
+ const html = await readFile(nitro.options.renderer?.template, "utf8");
616
+ if (hasTemplateSyntax(html)) return `
617
+ import { renderToResponse } from 'rendu'
618
+ const template = ${compileTemplateToString(html, { contextKeys: [...RENDER_CONTEXT_KEYS] })};
619
+ export const rendererTemplate = (request) => renderToResponse(template, { request })
620
+ `;
621
+ else return `
622
+ import { HTTPResponse } from "h3";
623
+ export const rendererTemplate = () => new HTTPResponse(${JSON.stringify(html)}, { headers: { "content-type": "text/html; charset=utf-8" } });
624
+ `;
625
+ }
626
+ } }, nitro.vfs);
627
+ }
628
+
629
+ //#endregion
630
+ //#region src/build/plugins/feature-flags.ts
631
+ function featureFlags(nitro) {
632
+ return virtual({ "#nitro-internal-virtual/feature-flags": () => {
633
+ const featureFlags$1 = {
634
+ hasRoutes: nitro.routing.routes.hasRoutes(),
635
+ hasRouteRules: nitro.routing.routeRules.hasRoutes(),
636
+ hasRoutedMiddleware: nitro.routing.routedMiddleware.hasRoutes(),
637
+ hasGlobalMiddleware: nitro.routing.globalMiddleware.length > 0 || !!nitro.options.serverEntry,
638
+ hasPlugins: nitro.options.plugins.length > 0,
639
+ hasHooks: nitro.options.features?.runtimeHooks ?? nitro.options.plugins.length > 0
640
+ };
641
+ return Object.entries(featureFlags$1).map(([key, value]) => `export const ${key} = ${Boolean(value)};`).join("\n");
642
+ } }, nitro.vfs);
643
+ }
644
+
645
+ //#endregion
646
+ //#region src/build/plugins/resolve.ts
647
+ const subpathMap = {
648
+ "nitro/h3": "h3",
649
+ "nitro/deps/h3": "h3",
650
+ "nitro/deps/ofetch": "ofetch"
651
+ };
652
+ function nitroResolveIds() {
653
+ return {
654
+ name: "nitro:resolve-ids",
655
+ resolveId: {
656
+ order: "pre",
657
+ handler(id, importer, rOpts) {
658
+ if (importer && importer.startsWith("\0virtual:#nitro-internal-virtual")) return this.resolve(id, runtimeDir, { skipSelf: true });
659
+ const mappedId = subpathMap[id];
660
+ if (mappedId) return this.resolve(mappedId, runtimeDir, { skipSelf: true });
661
+ }
662
+ }
663
+ };
664
+ }
665
+
666
+ //#endregion
667
+ //#region src/build/plugins.ts
668
+ function baseBuildPlugins(nitro, base) {
669
+ const plugins = [];
670
+ if (nitro.options.imports) plugins.push(unplugin.rollup(nitro.options.imports));
671
+ if (nitro.options.experimental.wasm) plugins.push(rollup(nitro.options.wasm || {}));
672
+ plugins.push(serverMain(nitro));
673
+ const nitroPlugins = [...new Set(nitro.options.plugins)];
674
+ plugins.push(virtual({ "#nitro-internal-virtual/plugins": `
675
+ ${nitroPlugins.map((plugin) => `import _${hash(plugin).replace(/-/g, "")} from '${plugin}';`).join("\n")}
676
+
677
+ export const plugins = [
678
+ ${nitroPlugins.map((plugin) => `_${hash(plugin).replace(/-/g, "")}`).join(",\n")}
679
+ ]
680
+ ` }, nitro.vfs));
681
+ plugins.push(featureFlags(nitro));
682
+ plugins.push(nitroResolveIds());
683
+ plugins.push(serverAssets(nitro));
684
+ plugins.push(publicAssets(nitro));
685
+ plugins.push(storage(nitro));
686
+ plugins.push(database(nitro));
687
+ plugins.push(routing(nitro));
688
+ if (nitro.options.experimental.openAPI) plugins.push(routeMeta(nitro));
689
+ plugins.push(errorHandler(nitro));
690
+ plugins.push(virtual({ "#nitro-internal-pollyfills": base.env.polyfill.map((p) => `import '${p}';`).join("\n") || `/* No polyfills */` }, nitro.vfs));
691
+ plugins.push(virtual(nitro.options.virtual, nitro.vfs));
692
+ if (nitro.options.renderer?.template) plugins.push(rendererTemplate(nitro));
693
+ if (!nitro.options.noExternals) plugins.push(rollupNodeFileTrace(defu(nitro.options.externals, {
694
+ outDir: nitro.options.output.serverDir,
695
+ moduleDirectories: nitro.options.nodeModulesDirs,
696
+ external: [...nitro.options.dev ? [nitro.options.buildDir] : [], ...nitro.options.nodeModulesDirs],
697
+ inline: [
698
+ "#",
699
+ "~",
700
+ "@/",
701
+ "~~",
702
+ "@@/",
703
+ "virtual:",
704
+ "nitro/runtime",
705
+ dirname$1(nitro.options.entry),
706
+ ...nitro.options.experimental.wasm ? [(id) => id?.endsWith(".wasm")] : [],
707
+ runtimeDir,
708
+ nitro.options.srcDir,
709
+ ...nitro.options.handlers.map((m) => m.handler).filter((i) => typeof i === "string"),
710
+ ...nitro.options.dev || nitro.options.preset === "nitro-prerender" || nitro.options.experimental.bundleRuntimeDependencies === false ? [] : runtimeDependencies
711
+ ],
712
+ traceOptions: {
713
+ base: "/",
714
+ processCwd: nitro.options.rootDir,
715
+ exportsOnly: true
716
+ },
717
+ traceAlias: {
718
+ "h3-nightly": "h3",
719
+ ...nitro.options.externals?.traceAlias
720
+ },
721
+ exportConditions: nitro.options.exportConditions,
722
+ writePackageJson: true
723
+ })));
724
+ return plugins;
725
+ }
726
+
727
+ //#endregion
728
+ //#region src/presets/_types.gen.ts
729
+ const presetsWithConfig = [
730
+ "awsAmplify",
731
+ "awsLambda",
732
+ "azure",
733
+ "cloudflare",
734
+ "firebase",
735
+ "netlify",
736
+ "vercel"
737
+ ];
738
+
739
+ //#endregion
740
+ //#region src/build/info.ts
741
+ async function writeBuildInfo(nitro) {
742
+ const buildInfoPath = resolve$1(nitro.options.output.dir, "nitro.json");
743
+ const buildInfo = {
744
+ date: (/* @__PURE__ */ new Date()).toJSON(),
745
+ preset: nitro.options.preset,
746
+ framework: nitro.options.framework,
747
+ versions: { nitro: version },
748
+ commands: {
749
+ preview: nitro.options.commands.preview,
750
+ deploy: nitro.options.commands.deploy
751
+ },
752
+ config: { ...Object.fromEntries(presetsWithConfig.map((key) => [key, nitro.options[key]])) }
753
+ };
754
+ await writeFile$1(buildInfoPath, JSON.stringify(buildInfo, null, 2), true);
755
+ const lastBuild = resolve$1(nitro.options.rootDir, "node_modules/.nitro/last-build");
756
+ await mkdir(dirname(lastBuild), { recursive: true });
757
+ await unlink(lastBuild).catch(() => {});
758
+ await symlink(nitro.options.output.dir, lastBuild).catch(console.warn);
759
+ return buildInfo;
760
+ }
761
+
762
+ //#endregion
763
+ export { replace$1 as i, baseBuildPlugins as n, baseBuildConfig as r, writeBuildInfo as t };