nitro-nightly 4.0.0-20251010-091516-7cafddba → 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 (252) 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/_libs/fdir.mjs +514 -0
  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/_libs/js-tokens.mjs +382 -0
  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/_libs/magic-string.mjs +939 -0
  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/_libs/rou3.mjs +311 -0
  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/_libs/tinyglobby.mjs +292 -0
  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/_libs/vite-plugin-fullstack.mjs +561 -0
  76. package/dist/_presets.mjs +1723 -0
  77. package/dist/builder.d.mts +54 -0
  78. package/dist/builder.mjs +45 -0
  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 +20 -476
  97. package/dist/node_modules/@speed-highlight/core/dist/index.js +1 -1
  98. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +1 -1
  99. package/dist/node_modules/@speed-highlight/core/package.json +7 -3
  100. package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
  101. package/dist/node_modules/cookie-es/package.json +37 -0
  102. package/dist/node_modules/hookable/dist/index.mjs +243 -266
  103. package/dist/node_modules/hookable/package.json +29 -26
  104. package/dist/node_modules/rendu/dist/index.mjs +380 -0
  105. package/dist/node_modules/rendu/package.json +47 -0
  106. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
  107. package/dist/presets/_nitro/runtime/nitro-dev.mjs +44 -38
  108. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
  109. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +9 -12
  110. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
  111. package/dist/presets/_nitro/runtime/service-worker.mjs +14 -11
  112. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
  113. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +6 -5
  114. package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
  115. package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
  116. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
  117. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +25 -27
  118. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +7 -7
  119. package/dist/presets/azure/runtime/_utils.mjs +43 -43
  120. package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
  121. package/dist/presets/azure/runtime/azure-swa.mjs +22 -21
  122. package/dist/presets/bun/runtime/bun.d.mts +1 -0
  123. package/dist/presets/bun/runtime/bun.mjs +18 -17
  124. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
  125. package/dist/presets/cloudflare/runtime/_module-handler.mjs +79 -87
  126. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
  127. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +55 -61
  128. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
  129. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +12 -14
  130. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
  131. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +35 -39
  132. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
  133. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +89 -82
  134. package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
  135. package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
  136. package/dist/presets/deno/runtime/deno-deploy.mjs +12 -11
  137. package/dist/presets/deno/runtime/deno-server.d.mts +2 -1
  138. package/dist/presets/deno/runtime/deno-server.mjs +31 -39
  139. package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
  140. package/dist/presets/netlify/runtime/netlify-edge.mjs +14 -11
  141. package/dist/presets/netlify/runtime/netlify.mjs +11 -17
  142. package/dist/presets/node/runtime/node-cluster.mjs +49 -48
  143. package/dist/presets/node/runtime/node-middleware.d.mts +3 -2
  144. package/dist/presets/node/runtime/node-middleware.mjs +7 -6
  145. package/dist/presets/node/runtime/node-server.mjs +34 -24
  146. package/dist/presets/standard/runtime/server.d.mts +1 -3
  147. package/dist/presets/standard/runtime/server.mjs +1 -3
  148. package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
  149. package/dist/presets/stormkit/runtime/stormkit.mjs +20 -20
  150. package/dist/presets/vercel/runtime/vercel.d.mts +3 -3
  151. package/dist/presets/vercel/runtime/vercel.mjs +15 -14
  152. package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
  153. package/dist/presets/winterjs/runtime/winterjs.mjs +72 -68
  154. package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
  155. package/dist/runtime/index.d.mts +13 -2
  156. package/dist/runtime/index.mjs +13 -8
  157. package/dist/runtime/internal/app.d.mts +3 -1
  158. package/dist/runtime/internal/app.mjs +179 -140
  159. package/dist/runtime/internal/cache.d.mts +10 -4
  160. package/dist/runtime/internal/cache.mjs +247 -216
  161. package/dist/runtime/internal/context.d.mts +9 -9
  162. package/dist/runtime/internal/context.mjs +17 -10
  163. package/dist/runtime/internal/database.mjs +8 -10
  164. package/dist/runtime/internal/error/dev.d.mts +5 -4
  165. package/dist/runtime/internal/error/dev.mjs +106 -105
  166. package/dist/runtime/internal/error/prod.d.mts +5 -4
  167. package/dist/runtime/internal/error/prod.mjs +51 -59
  168. package/dist/runtime/internal/error/utils.d.mts +4 -4
  169. package/dist/runtime/internal/error/utils.mjs +1 -1
  170. package/dist/runtime/internal/index.d.mts +2 -0
  171. package/dist/runtime/internal/index.mjs +2 -0
  172. package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +14 -14
  173. package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +248 -209
  174. package/dist/runtime/internal/meta.d.mts +1 -1
  175. package/dist/runtime/internal/meta.mjs +1 -1
  176. package/dist/runtime/internal/plugin.d.mts +2 -2
  177. package/dist/runtime/internal/plugin.mjs +1 -1
  178. package/dist/runtime/internal/renderer.mjs +40 -32
  179. package/dist/runtime/internal/route-rules.d.mts +8 -8
  180. package/dist/runtime/internal/route-rules.mjs +53 -51
  181. package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -2
  182. package/dist/runtime/internal/routes/dev-tasks.mjs +15 -17
  183. package/dist/runtime/internal/routes/openapi.d.mts +1 -0
  184. package/dist/runtime/internal/routes/openapi.mjs +81 -87
  185. package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
  186. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
  187. package/dist/runtime/internal/routes/renderer-template.dev.mjs +10 -17
  188. package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
  189. package/dist/runtime/internal/routes/scalar.d.mts +1 -0
  190. package/dist/runtime/internal/routes/scalar.mjs +22 -23
  191. package/dist/runtime/internal/routes/swagger.d.mts +1 -0
  192. package/dist/runtime/internal/routes/swagger.mjs +9 -11
  193. package/dist/runtime/internal/runtime-config.d.mts +4 -4
  194. package/dist/runtime/internal/runtime-config.mjs +40 -35
  195. package/dist/runtime/internal/shutdown.d.mts +2 -8
  196. package/dist/runtime/internal/shutdown.mjs +32 -30
  197. package/dist/runtime/internal/static.mjs +63 -74
  198. package/dist/runtime/internal/storage.mjs +2 -2
  199. package/dist/runtime/internal/task.d.mts +6 -6
  200. package/dist/runtime/internal/task.mjs +56 -60
  201. package/dist/runtime/internal/utils.d.mts +1 -1
  202. package/dist/runtime/internal/utils.mjs +4 -10
  203. package/dist/types/index.d.mts +2594 -2286
  204. package/dist/types/index.mjs +1 -1
  205. package/dist/vite.d.mts +56 -47
  206. package/dist/vite.mjs +55 -68
  207. package/lib/index.d.mts +1 -0
  208. package/lib/index.mjs +1 -0
  209. package/lib/runtime/meta.mjs +35 -0
  210. package/package.json +49 -50
  211. package/dist/_chunks/app.mjs +0 -19797
  212. package/dist/_chunks/build.mjs +0 -84
  213. package/dist/_chunks/build2.mjs +0 -318
  214. package/dist/_chunks/build3.mjs +0 -6452
  215. package/dist/_chunks/detect-acorn.mjs +0 -503
  216. package/dist/_chunks/index.mjs +0 -22242
  217. package/dist/_chunks/index2.mjs +0 -297
  218. package/dist/_chunks/index3.mjs +0 -1058
  219. package/dist/_chunks/index4.mjs +0 -1206
  220. package/dist/_chunks/info.mjs +0 -11157
  221. package/dist/_chunks/json5.mjs +0 -68
  222. package/dist/_chunks/jsonc.mjs +0 -51
  223. package/dist/_chunks/pathe.M-eThtNZ.mjs +0 -204
  224. package/dist/_chunks/plugin.mjs +0 -960
  225. package/dist/_chunks/server.mjs +0 -254
  226. package/dist/_chunks/snapshot.mjs +0 -284
  227. package/dist/_chunks/toml.mjs +0 -259
  228. package/dist/_chunks/yaml.mjs +0 -86
  229. package/dist/cli/build.mjs +0 -54
  230. package/dist/cli/common.mjs +0 -13
  231. package/dist/cli/dev.mjs +0 -95
  232. package/dist/cli/index2.mjs +0 -17
  233. package/dist/cli/list.mjs +0 -34
  234. package/dist/cli/prepare.mjs +0 -24
  235. package/dist/cli/run.mjs +0 -60
  236. package/dist/index.d.mts +0 -52
  237. package/dist/index.mjs +0 -55
  238. package/dist/node_modules/klona/dist/index.mjs +0 -81
  239. package/dist/node_modules/klona/full/index.mjs +0 -53
  240. package/dist/node_modules/klona/package.json +0 -74
  241. package/dist/node_modules/std-env/dist/index.mjs +0 -1
  242. package/dist/node_modules/std-env/package.json +0 -46
  243. package/dist/presets.mjs +0 -2460
  244. package/dist/runtime/internal/debug.d.mts +0 -2
  245. package/dist/runtime/internal/debug.mjs +0 -5
  246. package/dist/runtime/internal/empty.d.mts +0 -0
  247. package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
  248. package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
  249. package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
  250. package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
  251. package/lib/runtime-meta.mjs +0 -38
  252. /package/lib/{runtime-meta.d.mts → runtime/meta.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 };