nitro 3.0.0 → 3.0.1-alpha.1

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 (293) hide show
  1. package/dist/_build/common.mjs +68 -0
  2. package/dist/_build/common2.mjs +772 -0
  3. package/dist/_build/rolldown.mjs +206 -0
  4. package/dist/_build/rollup.mjs +289 -0
  5. package/dist/_build/vite.build.mjs +56 -0
  6. package/dist/_build/vite.plugin.mjs +768 -0
  7. package/dist/_chunks/ANM1K1bE.mjs +304 -0
  8. package/dist/_chunks/B-D1JOIz.mjs +1355 -0
  9. package/dist/_chunks/BX9-zVkM.mjs +59 -0
  10. package/dist/_chunks/Bqks5huO.mjs +31 -0
  11. package/dist/_chunks/C7CbzoI1.mjs +39 -0
  12. package/dist/_dev.d.mts +12 -0
  13. package/dist/_dev.mjs +705 -0
  14. package/dist/_libs/acorn.mjs +5034 -0
  15. package/dist/_libs/c12.mjs +2858 -0
  16. package/dist/_libs/chokidar.mjs +1561 -0
  17. package/dist/_libs/citty.mjs +333 -0
  18. package/dist/_libs/commondir.mjs +22 -0
  19. package/dist/_libs/compatx.mjs +46 -0
  20. package/dist/_libs/confbox.mjs +2920 -0
  21. package/dist/_libs/deepmerge.mjs +86 -0
  22. package/dist/_libs/dot-prop.mjs +138 -0
  23. package/dist/_libs/duplexer.mjs +71 -0
  24. package/dist/_libs/escape-string-regexp.mjs +8 -0
  25. package/dist/_libs/estree-walker.mjs +330 -0
  26. package/dist/_libs/etag.mjs +80 -0
  27. package/dist/_libs/fdir.mjs +514 -0
  28. package/dist/_libs/function-bind.mjs +63 -0
  29. package/dist/_libs/gen-mapping.mjs +612 -0
  30. package/dist/_libs/giget.mjs +19289 -0
  31. package/dist/_libs/gzip-size.mjs +21 -0
  32. package/dist/_libs/hasown.mjs +14 -0
  33. package/dist/_libs/httpxy.mjs +410 -0
  34. package/dist/_libs/is-core-module.mjs +220 -0
  35. package/dist/_libs/is-module.mjs +13 -0
  36. package/dist/_libs/is-reference.mjs +32 -0
  37. package/dist/_libs/js-tokens.mjs +382 -0
  38. package/dist/_libs/klona.mjs +38 -0
  39. package/dist/_libs/knitwork.mjs +124 -0
  40. package/dist/_libs/local-pkg.mjs +1686 -0
  41. package/dist/_libs/magic-string.mjs +939 -0
  42. package/dist/_libs/mime.mjs +1391 -0
  43. package/dist/_libs/node-fetch-native.mjs +173 -0
  44. package/dist/_libs/path-parse.mjs +47 -0
  45. package/dist/_libs/pathe.mjs +41 -0
  46. package/dist/_libs/picomatch.mjs +1673 -0
  47. package/dist/_libs/plugin-alias.mjs +64 -0
  48. package/dist/_libs/plugin-commonjs.mjs +1491 -0
  49. package/dist/_libs/plugin-inject.mjs +135 -0
  50. package/dist/_libs/plugin-json.mjs +36 -0
  51. package/dist/_libs/plugin-node-resolve.mjs +1553 -0
  52. package/dist/_libs/plugin-replace.mjs +104 -0
  53. package/dist/_libs/pretty-bytes.mjs +116 -0
  54. package/dist/_libs/remapping.mjs +117 -0
  55. package/dist/_libs/rou3.mjs +319 -0
  56. package/dist/_libs/std-env.mjs +158 -0
  57. package/dist/_libs/strip-literal.mjs +51 -0
  58. package/dist/_libs/tinyglobby.mjs +292 -0
  59. package/dist/_libs/tsconfck.mjs +832 -0
  60. package/dist/_libs/ultrahtml.mjs +138 -0
  61. package/dist/_libs/unimport.mjs +3520 -0
  62. package/dist/_libs/untyped.mjs +271 -0
  63. package/dist/_libs/unwasm.mjs +5836 -0
  64. package/dist/_libs/vite-plugin-fullstack.mjs +561 -0
  65. package/dist/_presets.mjs +1752 -0
  66. package/dist/builder.d.mts +63 -0
  67. package/dist/builder.mjs +33 -0
  68. package/dist/cli/_chunks/build.mjs +48 -0
  69. package/dist/cli/_chunks/common.mjs +15 -0
  70. package/dist/cli/_chunks/detect-acorn.mjs +12 -0
  71. package/dist/cli/_chunks/dev.mjs +68 -0
  72. package/dist/cli/_chunks/dist.mjs +3 -0
  73. package/dist/cli/_chunks/dist2.mjs +3 -0
  74. package/dist/cli/_chunks/dist3.mjs +3 -0
  75. package/dist/cli/_chunks/dist4.mjs +4 -0
  76. package/dist/cli/_chunks/dist5.mjs +4 -0
  77. package/dist/cli/_chunks/esm.mjs +3 -0
  78. package/dist/cli/_chunks/json5.mjs +4 -0
  79. package/dist/cli/_chunks/jsonc.mjs +4 -0
  80. package/dist/cli/_chunks/list.mjs +27 -0
  81. package/dist/cli/_chunks/multipart-parser.mjs +6 -0
  82. package/dist/cli/_chunks/prepare.mjs +19 -0
  83. package/dist/cli/_chunks/run.mjs +55 -0
  84. package/dist/cli/_chunks/task.mjs +16 -0
  85. package/dist/cli/_chunks/toml.mjs +4 -0
  86. package/dist/cli/_chunks/yaml.mjs +4 -0
  87. package/dist/cli/index.d.mts +1 -1
  88. package/dist/cli/index.mjs +20 -476
  89. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +1 -1
  90. package/dist/node_modules/@poppinss/dumper/package.json +1 -1
  91. package/dist/node_modules/@sindresorhus/is/distribution/index.js +1 -1
  92. package/dist/node_modules/@sindresorhus/is/package.json +1 -1
  93. package/dist/node_modules/@speed-highlight/core/dist/index.js +2 -2
  94. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -2
  95. package/dist/node_modules/@speed-highlight/core/package.json +7 -3
  96. package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
  97. package/dist/node_modules/cookie-es/package.json +37 -0
  98. package/dist/node_modules/hookable/dist/index.mjs +243 -266
  99. package/dist/node_modules/hookable/package.json +29 -26
  100. package/dist/node_modules/rendu/dist/index.mjs +380 -0
  101. package/dist/node_modules/rendu/package.json +47 -0
  102. package/dist/node_modules/youch/build/{chunk-VE4LENUR.js → chunk-F4I6KX4R.js} +2 -1
  103. package/dist/node_modules/youch/build/{chunk-JAN2TFI2.js → chunk-YYEJ3AGB.js} +4 -1
  104. package/dist/node_modules/youch/build/index.js +16 -8
  105. package/dist/node_modules/youch/build/public/error_stack/script.js +20 -22
  106. package/dist/node_modules/youch/build/public/header/script.js +0 -2
  107. package/dist/node_modules/youch/build/public/layout/script.js +0 -8
  108. package/dist/node_modules/youch/build/public/layout/style.css +4 -0
  109. package/dist/node_modules/youch/package.json +16 -17
  110. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
  111. package/dist/presets/_nitro/runtime/nitro-dev.mjs +48 -42
  112. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
  113. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +10 -14
  114. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
  115. package/dist/presets/_nitro/runtime/service-worker.mjs +15 -12
  116. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
  117. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +7 -6
  118. package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
  119. package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
  120. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
  121. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +26 -28
  122. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +8 -8
  123. package/dist/presets/azure/runtime/_utils.mjs +43 -43
  124. package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
  125. package/dist/presets/azure/runtime/azure-swa.mjs +24 -22
  126. package/dist/presets/bun/runtime/bun.d.mts +2 -0
  127. package/dist/presets/bun/runtime/bun.mjs +34 -21
  128. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
  129. package/dist/presets/cloudflare/runtime/_module-handler.mjs +80 -88
  130. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
  131. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +60 -63
  132. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
  133. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +14 -16
  134. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
  135. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +40 -42
  136. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
  137. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +89 -82
  138. package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
  139. package/dist/presets/deno/runtime/deno-deploy.d.mts +4 -0
  140. package/dist/presets/deno/runtime/deno-deploy.mjs +15 -12
  141. package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
  142. package/dist/presets/deno/runtime/deno-server.mjs +32 -52
  143. package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
  144. package/dist/presets/netlify/runtime/netlify-edge.mjs +15 -12
  145. package/dist/presets/netlify/runtime/netlify.mjs +12 -18
  146. package/dist/presets/node/runtime/node-cluster.d.mts +3 -1
  147. package/dist/presets/node/runtime/node-cluster.mjs +50 -54
  148. package/dist/presets/node/runtime/node-middleware.d.mts +2 -3
  149. package/dist/presets/node/runtime/node-middleware.mjs +9 -8
  150. package/dist/presets/node/runtime/node-server.mjs +37 -34
  151. package/dist/presets/standard/runtime/server.d.mts +1 -3
  152. package/dist/presets/standard/runtime/server.mjs +2 -4
  153. package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
  154. package/dist/presets/stormkit/runtime/stormkit.mjs +21 -21
  155. package/dist/presets/vercel/runtime/vercel.node.d.mts +3 -0
  156. package/dist/presets/vercel/runtime/vercel.node.mjs +15 -0
  157. package/dist/presets/vercel/runtime/{vercel.d.mts → vercel.web.d.mts} +3 -3
  158. package/dist/presets/vercel/runtime/vercel.web.mjs +20 -0
  159. package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
  160. package/dist/presets/winterjs/runtime/winterjs.mjs +73 -69
  161. package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
  162. package/dist/presets/zeabur/runtime/zeabur.mjs +1 -1
  163. package/dist/runtime/app.d.mts +1 -0
  164. package/dist/runtime/app.mjs +1 -0
  165. package/dist/runtime/cache.d.mts +1 -0
  166. package/dist/runtime/cache.mjs +1 -0
  167. package/dist/runtime/config.d.mts +3 -0
  168. package/dist/runtime/config.mjs +4 -0
  169. package/dist/runtime/context.d.mts +1 -0
  170. package/dist/runtime/context.mjs +1 -0
  171. package/dist/runtime/database.d.mts +1 -0
  172. package/dist/runtime/database.mjs +1 -0
  173. package/dist/runtime/internal/app.d.mts +11 -1
  174. package/dist/runtime/internal/app.mjs +188 -140
  175. package/dist/runtime/internal/cache.d.mts +9 -5
  176. package/dist/runtime/internal/cache.mjs +248 -219
  177. package/dist/runtime/internal/context.d.mts +9 -9
  178. package/dist/runtime/internal/context.mjs +17 -10
  179. package/dist/runtime/internal/database.mjs +8 -10
  180. package/dist/runtime/internal/error/dev.d.mts +5 -4
  181. package/dist/runtime/internal/error/dev.mjs +106 -105
  182. package/dist/runtime/internal/error/hooks.d.mts +1 -0
  183. package/dist/runtime/internal/error/hooks.mjs +9 -0
  184. package/dist/runtime/internal/error/prod.d.mts +5 -4
  185. package/dist/runtime/internal/error/prod.mjs +51 -59
  186. package/dist/runtime/internal/error/utils.d.mts +4 -4
  187. package/dist/runtime/internal/error/utils.mjs +1 -1
  188. package/dist/runtime/internal/meta.d.mts +1 -1
  189. package/dist/runtime/internal/meta.mjs +1 -1
  190. package/dist/runtime/internal/plugin.d.mts +2 -2
  191. package/dist/runtime/internal/plugin.mjs +1 -1
  192. package/dist/runtime/internal/route-rules.d.mts +8 -8
  193. package/dist/runtime/internal/route-rules.mjs +54 -52
  194. package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -2
  195. package/dist/runtime/internal/routes/dev-tasks.mjs +16 -18
  196. package/dist/runtime/internal/routes/openapi.d.mts +1 -0
  197. package/dist/runtime/internal/routes/openapi.mjs +81 -87
  198. package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
  199. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
  200. package/dist/runtime/internal/routes/renderer-template.dev.mjs +15 -17
  201. package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
  202. package/dist/runtime/internal/routes/scalar.d.mts +1 -0
  203. package/dist/runtime/internal/routes/scalar.mjs +22 -23
  204. package/dist/runtime/internal/routes/swagger.d.mts +1 -0
  205. package/dist/runtime/internal/routes/swagger.mjs +9 -11
  206. package/dist/runtime/internal/runtime-config.d.mts +4 -4
  207. package/dist/runtime/internal/runtime-config.mjs +40 -35
  208. package/dist/runtime/internal/static.mjs +63 -74
  209. package/dist/runtime/internal/storage.mjs +2 -2
  210. package/dist/runtime/internal/task.d.mts +6 -6
  211. package/dist/runtime/internal/task.mjs +56 -60
  212. package/dist/runtime/internal/vite/dev-entry.mjs +11 -1
  213. package/dist/runtime/internal/vite/dev-worker.mjs +9 -57
  214. package/dist/runtime/internal/vite/ssr-renderer.mjs +3 -1
  215. package/{lib/runtime-meta.d.mts → dist/runtime/meta.d.mts} +1 -1
  216. package/dist/runtime/meta.mjs +26 -0
  217. package/dist/runtime/nitro.d.mts +12 -0
  218. package/dist/runtime/nitro.mjs +32 -0
  219. package/dist/runtime/runtime-config.d.mts +1 -0
  220. package/dist/runtime/runtime-config.mjs +1 -0
  221. package/dist/runtime/storage.d.mts +1 -0
  222. package/dist/runtime/storage.mjs +1 -0
  223. package/dist/runtime/task.d.mts +1 -0
  224. package/dist/runtime/task.mjs +1 -0
  225. package/dist/runtime/vite-runtime.d.mts +8 -0
  226. package/dist/runtime/vite-runtime.mjs +9 -0
  227. package/dist/types/index.d.mts +2625 -2297
  228. package/dist/types/index.mjs +1 -1
  229. package/dist/vite.d.mts +49 -51
  230. package/dist/vite.mjs +44 -68
  231. package/lib/tsconfig.json +27 -0
  232. package/package.json +86 -76
  233. package/dist/_chunks/app.mjs +0 -19797
  234. package/dist/_chunks/build.mjs +0 -84
  235. package/dist/_chunks/build2.mjs +0 -318
  236. package/dist/_chunks/build3.mjs +0 -6452
  237. package/dist/_chunks/detect-acorn.mjs +0 -503
  238. package/dist/_chunks/index.mjs +0 -22242
  239. package/dist/_chunks/index2.mjs +0 -297
  240. package/dist/_chunks/index3.mjs +0 -1058
  241. package/dist/_chunks/index4.mjs +0 -1206
  242. package/dist/_chunks/info.mjs +0 -11157
  243. package/dist/_chunks/json5.mjs +0 -68
  244. package/dist/_chunks/jsonc.mjs +0 -51
  245. package/dist/_chunks/pathe.M-eThtNZ.mjs +0 -204
  246. package/dist/_chunks/plugin.mjs +0 -960
  247. package/dist/_chunks/server.mjs +0 -254
  248. package/dist/_chunks/snapshot.mjs +0 -284
  249. package/dist/_chunks/toml.mjs +0 -259
  250. package/dist/_chunks/yaml.mjs +0 -86
  251. package/dist/cli/build.mjs +0 -54
  252. package/dist/cli/common.mjs +0 -13
  253. package/dist/cli/dev.mjs +0 -95
  254. package/dist/cli/index2.mjs +0 -17
  255. package/dist/cli/list.mjs +0 -34
  256. package/dist/cli/prepare.mjs +0 -24
  257. package/dist/cli/run.mjs +0 -60
  258. package/dist/index.d.mts +0 -52
  259. package/dist/index.mjs +0 -55
  260. package/dist/node_modules/cookie/dist/index.js +0 -239
  261. package/dist/node_modules/cookie/package.json +0 -42
  262. package/dist/node_modules/klona/dist/index.mjs +0 -81
  263. package/dist/node_modules/klona/full/index.mjs +0 -53
  264. package/dist/node_modules/klona/package.json +0 -74
  265. package/dist/node_modules/std-env/dist/index.mjs +0 -1
  266. package/dist/node_modules/std-env/package.json +0 -46
  267. package/dist/presets/vercel/runtime/vercel.mjs +0 -17
  268. package/dist/presets.mjs +0 -2460
  269. package/dist/runtime/index.d.mts +0 -11
  270. package/dist/runtime/index.mjs +0 -17
  271. package/dist/runtime/internal/debug.d.mts +0 -2
  272. package/dist/runtime/internal/debug.mjs +0 -5
  273. package/dist/runtime/internal/empty.d.mts +0 -0
  274. package/dist/runtime/internal/index.d.mts +0 -3
  275. package/dist/runtime/internal/index.mjs +0 -3
  276. package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +0 -16
  277. package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +0 -213
  278. package/dist/runtime/internal/renderer.d.mts +0 -3
  279. package/dist/runtime/internal/renderer.mjs +0 -36
  280. package/dist/runtime/internal/shutdown.d.mts +0 -9
  281. package/dist/runtime/internal/shutdown.mjs +0 -34
  282. package/dist/runtime/internal/utils.d.mts +0 -1
  283. package/dist/runtime/internal/utils.mjs +0 -15
  284. package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
  285. package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
  286. package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
  287. package/dist/runtime/internal/vite/prod-setup.mjs +0 -55
  288. package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
  289. package/lib/config.d.mts +0 -9
  290. package/lib/config.mjs +0 -5
  291. package/lib/meta.d.mts +0 -5
  292. package/lib/meta.mjs +0 -21
  293. package/lib/runtime-meta.mjs +0 -38
@@ -0,0 +1,1752 @@
1
+ import { O as relative$1, _ as h, c as findNearestFile, d as readGitConfig, f as readPackageJSON, h as resolveModulePath, k as resolve$1, s as findFile, w as join$1, x as dirname$1 } from "./_libs/c12.mjs";
2
+ import "./_libs/acorn.mjs";
3
+ import { n as gr, t as Q } from "./_libs/confbox.mjs";
4
+ import { r as fileURLToPath } from "./_libs/local-pkg.mjs";
5
+ import "./_libs/picomatch.mjs";
6
+ import "./_libs/fdir.mjs";
7
+ import { t as glob } from "./_libs/tinyglobby.mjs";
8
+ import { r as resolveCompatibilityDatesFromEnv, t as formatCompatibilityDate } from "./_libs/compatx.mjs";
9
+ import { a as p, r as a, t as K } from "./_libs/std-env.mjs";
10
+ import "./_libs/dot-prop.mjs";
11
+ import { i as writeFile$2 } from "./_chunks/C7CbzoI1.mjs";
12
+ import consola$1 from "consola";
13
+ import { dirname, extname, relative, resolve } from "node:path";
14
+ import { kebabCase } from "scule";
15
+ import { existsSync, promises } from "node:fs";
16
+ import { hasProtocol, joinURL, withLeadingSlash, withTrailingSlash, withoutLeadingSlash } from "ufo";
17
+ import fsp, { readFile, writeFile } from "node:fs/promises";
18
+ import { defu } from "defu";
19
+ import { presetsDir, runtimeDir, version } from "nitro/meta";
20
+ import { colors } from "consola/utils";
21
+
22
+ //#region src/presets/_utils/preset.ts
23
+ function defineNitroPreset(preset, meta) {
24
+ if (typeof preset !== "function" && preset.entry && preset.entry.startsWith(".")) preset.entry = resolve(presetsDir, preset.entry);
25
+ return {
26
+ ...preset,
27
+ _meta: meta
28
+ };
29
+ }
30
+
31
+ //#endregion
32
+ //#region src/presets/_nitro/base-worker.ts
33
+ const baseWorker = defineNitroPreset({
34
+ entry: null,
35
+ node: false,
36
+ minify: true,
37
+ noExternals: true,
38
+ rollupConfig: { output: {
39
+ format: "iife",
40
+ generatedCode: { symbols: true }
41
+ } },
42
+ inlineDynamicImports: true
43
+ }, { name: "base-worker" });
44
+ var base_worker_default = [baseWorker];
45
+
46
+ //#endregion
47
+ //#region src/presets/_nitro/nitro-dev.ts
48
+ const nitroDev = defineNitroPreset({
49
+ entry: "./_nitro/runtime/nitro-dev",
50
+ output: {
51
+ dir: "{{ buildDir }}/dev",
52
+ serverDir: "{{ buildDir }}/dev",
53
+ publicDir: "{{ buildDir }}/dev"
54
+ },
55
+ handlers: [{
56
+ route: "/_nitro/tasks/**",
57
+ lazy: true,
58
+ handler: join$1(runtimeDir, "internal/routes/dev-tasks")
59
+ }],
60
+ externals: { noTrace: true },
61
+ serveStatic: true,
62
+ inlineDynamicImports: true,
63
+ sourcemap: true
64
+ }, {
65
+ name: "nitro-dev",
66
+ dev: true
67
+ });
68
+ var nitro_dev_default = [nitroDev];
69
+
70
+ //#endregion
71
+ //#region src/presets/_nitro/nitro-prerender.ts
72
+ const nitroPrerender = defineNitroPreset({
73
+ entry: "./_nitro/runtime/nitro-prerenderer",
74
+ serveStatic: true,
75
+ output: { serverDir: "{{ buildDir }}/prerender" },
76
+ externals: { noTrace: true }
77
+ }, { name: "nitro-prerender" });
78
+ var nitro_prerender_default = [nitroPrerender];
79
+
80
+ //#endregion
81
+ //#region src/presets/_nitro/preset.ts
82
+ var preset_default = [
83
+ ...base_worker_default,
84
+ ...nitro_dev_default,
85
+ ...nitro_prerender_default
86
+ ];
87
+
88
+ //#endregion
89
+ //#region src/presets/_static/preset.ts
90
+ const _static = defineNitroPreset({
91
+ static: true,
92
+ output: {
93
+ dir: "{{ rootDir }}/.output",
94
+ publicDir: "{{ output.dir }}/public"
95
+ },
96
+ prerender: { crawlLinks: true },
97
+ commands: { preview: "npx serve ./public" }
98
+ }, {
99
+ name: "static",
100
+ static: true
101
+ });
102
+ const githubPages = defineNitroPreset({
103
+ extends: "static",
104
+ commands: { deploy: "npx gh-pages --dotfiles -d ./public" },
105
+ prerender: { routes: ["/", "/404.html"] },
106
+ hooks: { async compiled(nitro) {
107
+ await fsp.writeFile(join$1(nitro.options.output.publicDir, ".nojekyll"), "");
108
+ } }
109
+ }, {
110
+ name: "github-pages",
111
+ static: true
112
+ });
113
+ const gitlabPages = defineNitroPreset({
114
+ extends: "static",
115
+ prerender: { routes: ["/", "/404.html"] }
116
+ }, {
117
+ name: "gitlab-pages",
118
+ static: true
119
+ });
120
+ var preset_default$1 = [
121
+ _static,
122
+ githubPages,
123
+ gitlabPages
124
+ ];
125
+
126
+ //#endregion
127
+ //#region src/presets/alwaysdata/preset.ts
128
+ const alwaysdata = defineNitroPreset({
129
+ extends: "node-server",
130
+ serveStatic: true,
131
+ commands: { deploy: "rsync -rRt --info=progress2 ./ [account]@ssh-[account].alwaysdata.net:www/my-app" }
132
+ }, { name: "alwaysdata" });
133
+ var preset_default$2 = [alwaysdata];
134
+
135
+ //#endregion
136
+ //#region src/presets/aws-amplify/utils.ts
137
+ async function writeAmplifyFiles(nitro) {
138
+ const outDir = nitro.options.output.dir;
139
+ const routes = [];
140
+ let hasWildcardPublicAsset = false;
141
+ if (nitro.options.awsAmplify?.imageOptimization && !nitro.options.static) {
142
+ const { path: path$1, cacheControl } = nitro.options.awsAmplify?.imageOptimization || {};
143
+ if (path$1) routes.push({
144
+ path: path$1,
145
+ target: {
146
+ kind: "ImageOptimization",
147
+ cacheControl
148
+ }
149
+ });
150
+ }
151
+ const computeTarget = nitro.options.static ? { kind: "Static" } : {
152
+ kind: "Compute",
153
+ src: "default"
154
+ };
155
+ for (const publicAsset of nitro.options.publicAssets) {
156
+ if (!publicAsset.baseURL || publicAsset.baseURL === "/") {
157
+ hasWildcardPublicAsset = true;
158
+ continue;
159
+ }
160
+ routes.push({
161
+ path: `${publicAsset.baseURL.replace(/\/$/, "")}/*`,
162
+ target: {
163
+ kind: "Static",
164
+ cacheControl: publicAsset.maxAge > 0 ? `public, max-age=${publicAsset.maxAge}, immutable` : void 0
165
+ },
166
+ fallback: publicAsset.fallthrough ? computeTarget : void 0
167
+ });
168
+ }
169
+ if (hasWildcardPublicAsset && !nitro.options.static) routes.push({
170
+ path: "/*.*",
171
+ target: { kind: "Static" },
172
+ fallback: computeTarget
173
+ });
174
+ routes.push({
175
+ path: "/*",
176
+ target: computeTarget,
177
+ fallback: hasWildcardPublicAsset && nitro.options.awsAmplify?.catchAllStaticFallback ? { kind: "Static" } : void 0
178
+ });
179
+ for (const route of routes) if (route.path !== "/*") route.path = joinURL(nitro.options.baseURL, route.path);
180
+ const deployManifest = {
181
+ version: 1,
182
+ routes,
183
+ imageSettings: nitro.options.awsAmplify?.imageSettings || void 0,
184
+ computeResources: nitro.options.static ? void 0 : [{
185
+ name: "default",
186
+ entrypoint: "server.js",
187
+ runtime: nitro.options.awsAmplify?.runtime || "nodejs20.x"
188
+ }],
189
+ framework: {
190
+ name: nitro.options.framework.name || "nitro",
191
+ version: nitro.options.framework.version || "0.0.0"
192
+ }
193
+ };
194
+ await writeFile(resolve(outDir, "deploy-manifest.json"), JSON.stringify(deployManifest, null, 2));
195
+ if (!nitro.options.static) await writeFile(resolve(outDir, "compute/default/server.js"), `import("./index.mjs")`);
196
+ }
197
+
198
+ //#endregion
199
+ //#region src/presets/aws-amplify/preset.ts
200
+ const awsAmplify = defineNitroPreset({
201
+ entry: "./aws-amplify/runtime/aws-amplify",
202
+ serveStatic: true,
203
+ output: {
204
+ dir: "{{ rootDir }}/.amplify-hosting",
205
+ serverDir: "{{ output.dir }}/compute/default",
206
+ publicDir: "{{ output.dir }}/static{{ baseURL }}"
207
+ },
208
+ commands: { preview: "node ./compute/default/server.js" },
209
+ hooks: { async compiled(nitro) {
210
+ await writeAmplifyFiles(nitro);
211
+ } }
212
+ }, {
213
+ name: "aws-amplify",
214
+ stdName: "aws_amplify"
215
+ });
216
+ var preset_default$3 = [awsAmplify];
217
+
218
+ //#endregion
219
+ //#region src/presets/aws-lambda/preset.ts
220
+ const awsLambda = defineNitroPreset({
221
+ entry: "./aws-lambda/runtime/aws-lambda",
222
+ awsLambda: { streaming: false },
223
+ hooks: { "rollup:before": (nitro, rollupConfig) => {
224
+ if (nitro.options.awsLambda?.streaming) rollupConfig.input += "-streaming";
225
+ } }
226
+ }, { name: "aws-lambda" });
227
+ var preset_default$4 = [awsLambda];
228
+
229
+ //#endregion
230
+ //#region src/presets/_utils/fs.ts
231
+ function prettyPath(p$1, highlight = true) {
232
+ p$1 = relative$1(process.cwd(), p$1);
233
+ return highlight ? colors.cyan(p$1) : p$1;
234
+ }
235
+ async function writeFile$1(file, contents, log = false) {
236
+ await fsp.mkdir(dirname$1(file), { recursive: true });
237
+ await fsp.writeFile(file, contents, typeof contents === "string" ? "utf8" : void 0);
238
+ if (log) consola$1.info("Generated", prettyPath(file));
239
+ }
240
+
241
+ //#endregion
242
+ //#region src/presets/azure/utils.ts
243
+ async function writeSWARoutes(nitro) {
244
+ const host = { version: "2.0" };
245
+ const supportedNodeVersions = new Set(["20", "22"]);
246
+ let nodeVersion = "18";
247
+ try {
248
+ const currentNodeVersion = JSON.parse(await fsp.readFile(join$1(nitro.options.rootDir, "package.json"), "utf8")).engines.node;
249
+ if (supportedNodeVersions.has(currentNodeVersion)) nodeVersion = currentNodeVersion;
250
+ } catch {
251
+ const currentNodeVersion = process.versions.node.slice(0, 2);
252
+ if (supportedNodeVersions.has(currentNodeVersion)) nodeVersion = currentNodeVersion;
253
+ }
254
+ const config = {
255
+ ...nitro.options.azure?.config,
256
+ routes: [],
257
+ platform: {
258
+ apiRuntime: `node:${nodeVersion}`,
259
+ ...nitro.options.azure?.config?.platform
260
+ },
261
+ navigationFallback: {
262
+ rewrite: "/api/server",
263
+ ...nitro.options.azure?.config?.navigationFallback
264
+ }
265
+ };
266
+ const routeFiles = nitro._prerenderedRoutes || [];
267
+ const indexFileExists = routeFiles.some((route) => route.fileName === "/index.html");
268
+ if (!indexFileExists) config.routes.unshift({
269
+ route: "/index.html",
270
+ redirect: "/"
271
+ }, {
272
+ route: "/",
273
+ rewrite: "/api/server"
274
+ });
275
+ const suffix = 11;
276
+ for (const { fileName } of routeFiles) {
277
+ if (!fileName || !fileName.endsWith("/index.html")) continue;
278
+ config.routes.unshift({
279
+ route: fileName.slice(0, -suffix) || "/",
280
+ rewrite: fileName
281
+ });
282
+ }
283
+ for (const { fileName } of routeFiles) {
284
+ if (!fileName || !fileName.endsWith(".html") || fileName.endsWith("index.html")) continue;
285
+ const route = fileName.slice(0, -5);
286
+ const existingRouteIndex = config.routes.findIndex((_route) => _route.route === route);
287
+ if (existingRouteIndex !== -1) config.routes.splice(existingRouteIndex, 1);
288
+ config.routes.unshift({
289
+ route,
290
+ rewrite: fileName
291
+ });
292
+ }
293
+ if (nitro.options.azure?.config && "routes" in nitro.options.azure.config && Array.isArray(nitro.options.azure.config.routes)) for (const customRoute of nitro.options.azure.config.routes.reverse()) {
294
+ const existingRouteMatchIndex = config.routes.findIndex((value) => value.route === customRoute.route);
295
+ if (existingRouteMatchIndex === -1) config.routes.unshift(customRoute);
296
+ else config.routes[existingRouteMatchIndex] = customRoute;
297
+ }
298
+ await writeFile$1(resolve$1(nitro.options.output.serverDir, "function.json"), JSON.stringify({
299
+ entryPoint: "handle",
300
+ bindings: [{
301
+ authLevel: "anonymous",
302
+ type: "httpTrigger",
303
+ direction: "in",
304
+ name: "req",
305
+ route: "{*url}",
306
+ methods: [
307
+ "delete",
308
+ "get",
309
+ "head",
310
+ "options",
311
+ "patch",
312
+ "post",
313
+ "put"
314
+ ]
315
+ }, {
316
+ type: "http",
317
+ direction: "out",
318
+ name: "res"
319
+ }]
320
+ }, null, 2));
321
+ await writeFile$1(resolve$1(nitro.options.output.serverDir, "../host.json"), JSON.stringify(host, null, 2));
322
+ await writeFile$1(resolve$1(nitro.options.output.serverDir, "../package.json"), JSON.stringify({ private: true }));
323
+ await writeFile$1(resolve$1(nitro.options.rootDir, "staticwebapp.config.json"), JSON.stringify(config, null, 2));
324
+ if (!indexFileExists) {
325
+ const relativePrefix = nitro.options.baseURL.split("/").filter(Boolean).map(() => "..").join("/");
326
+ await writeFile$1(resolve$1(nitro.options.output.publicDir, relativePrefix ? `${relativePrefix}/index.html` : "index.html"), "");
327
+ }
328
+ }
329
+
330
+ //#endregion
331
+ //#region src/presets/azure/preset.ts
332
+ const azureSWA = defineNitroPreset({
333
+ entry: "./azure/runtime/azure-swa",
334
+ output: {
335
+ serverDir: "{{ output.dir }}/server/functions",
336
+ publicDir: "{{ output.dir }}/public/{{ baseURL }}"
337
+ },
338
+ commands: { preview: "npx @azure/static-web-apps-cli start ./public --api-location ./server" },
339
+ hooks: { async compiled(ctx) {
340
+ await writeSWARoutes(ctx);
341
+ } }
342
+ }, {
343
+ name: "azure-swa",
344
+ stdName: "azure_static"
345
+ });
346
+ var preset_default$5 = [azureSWA];
347
+
348
+ //#endregion
349
+ //#region src/presets/bun/preset.ts
350
+ const bun = defineNitroPreset({
351
+ entry: "./bun/runtime/bun",
352
+ serveStatic: true,
353
+ exportConditions: [
354
+ "bun",
355
+ "node",
356
+ "import",
357
+ "default"
358
+ ],
359
+ commands: { preview: "bun run ./server/index.mjs" }
360
+ }, { name: "bun" });
361
+ var preset_default$6 = [bun];
362
+
363
+ //#endregion
364
+ //#region src/presets/cleavr/preset.ts
365
+ const cleavr = defineNitroPreset({
366
+ extends: "node-server",
367
+ serveStatic: true
368
+ }, {
369
+ name: "cleavr",
370
+ stdName: "cleavr"
371
+ });
372
+ var preset_default$7 = [cleavr];
373
+
374
+ //#endregion
375
+ //#region src/presets/cloudflare/unenv/node-compat.ts
376
+ const builtnNodeModules$1 = [
377
+ "node:_http_agent",
378
+ "node:_http_client",
379
+ "node:_http_common",
380
+ "node:_http_incoming",
381
+ "node:_http_outgoing",
382
+ "node:_http_server",
383
+ "node:_stream_duplex",
384
+ "node:_stream_passthrough",
385
+ "node:_stream_readable",
386
+ "node:_stream_transform",
387
+ "node:_stream_writable",
388
+ "node:_tls_common",
389
+ "node:_tls_wrap",
390
+ "node:assert",
391
+ "node:assert/strict",
392
+ "node:async_hooks",
393
+ "node:buffer",
394
+ "node:constants",
395
+ "node:crypto",
396
+ "node:diagnostics_channel",
397
+ "node:dns",
398
+ "node:dns/promises",
399
+ "node:events",
400
+ "node:fs",
401
+ "node:fs/promises",
402
+ "node:http",
403
+ "node:http2",
404
+ "node:https",
405
+ "node:module",
406
+ "node:net",
407
+ "node:os",
408
+ "node:path",
409
+ "node:path/posix",
410
+ "node:path/win32",
411
+ "node:process",
412
+ "node:querystring",
413
+ "node:stream",
414
+ "node:stream/consumers",
415
+ "node:stream/promises",
416
+ "node:stream/web",
417
+ "node:string_decoder",
418
+ "node:test",
419
+ "node:timers",
420
+ "node:timers/promises",
421
+ "node:tls",
422
+ "node:url",
423
+ "node:util",
424
+ "node:util/types",
425
+ "node:zlib"
426
+ ];
427
+
428
+ //#endregion
429
+ //#region src/presets/cloudflare/unenv/preset.ts
430
+ const unencCfNodeCompat = {
431
+ meta: { name: "nitro:cloudflare-node-compat" },
432
+ external: builtnNodeModules$1,
433
+ alias: { ...Object.fromEntries(builtnNodeModules$1.flatMap((m) => [[m, m], [m.replace("node:", ""), m]])) },
434
+ inject: {
435
+ global: "unenv/polyfill/globalthis",
436
+ process: "node:process",
437
+ clearImmediate: ["node:timers", "clearImmediate"],
438
+ setImmediate: ["node:timers", "setImmediate"],
439
+ Buffer: ["node:buffer", "Buffer"]
440
+ }
441
+ };
442
+ const unenvCfExternals = {
443
+ meta: { name: "nitro:cloudflare-externals" },
444
+ external: [
445
+ "cloudflare:email",
446
+ "cloudflare:sockets",
447
+ "cloudflare:workers",
448
+ "cloudflare:workflows"
449
+ ]
450
+ };
451
+
452
+ //#endregion
453
+ //#region src/presets/cloudflare/utils.ts
454
+ async function writeCFRoutes(nitro) {
455
+ const _cfPagesConfig = nitro.options.cloudflare?.pages || {};
456
+ const routes = {
457
+ version: _cfPagesConfig.routes?.version || 1,
458
+ include: _cfPagesConfig.routes?.include || ["/*"],
459
+ exclude: _cfPagesConfig.routes?.exclude || []
460
+ };
461
+ const writeRoutes = () => writeFile$1(resolve$1(nitro.options.output.dir, "_routes.json"), JSON.stringify(routes, void 0, 2), true);
462
+ if (_cfPagesConfig.defaultRoutes === false) {
463
+ await writeRoutes();
464
+ return;
465
+ }
466
+ const explicitPublicAssets = nitro.options.publicAssets.filter((dir, index, array) => {
467
+ if (dir.fallthrough || !dir.baseURL) return false;
468
+ const normalizedBase = withoutLeadingSlash(dir.baseURL);
469
+ return !array.some((otherDir, otherIndex) => otherIndex !== index && normalizedBase.startsWith(withoutLeadingSlash(withTrailingSlash(otherDir.baseURL))));
470
+ });
471
+ routes.exclude.push(...explicitPublicAssets.map((asset) => joinURL(nitro.options.baseURL, asset.baseURL || "/", "*")).sort(comparePaths));
472
+ const publicAssetFiles = await glob("**", {
473
+ cwd: nitro.options.output.dir,
474
+ absolute: false,
475
+ dot: true,
476
+ ignore: [
477
+ "_worker.js",
478
+ "_worker.js.map",
479
+ "nitro.json",
480
+ ...routes.exclude.map((path$1) => withoutLeadingSlash(path$1.replace(/\/\*$/, "/**")))
481
+ ]
482
+ });
483
+ routes.exclude.push(...publicAssetFiles.map((i) => withLeadingSlash(i).replace(/\/index\.html$/, "").replace(/\.html$/, "") || "/").sort(comparePaths));
484
+ routes.exclude.splice(100 - routes.include.length);
485
+ await writeRoutes();
486
+ }
487
+ function comparePaths(a$1, b) {
488
+ return a$1.split("/").length - b.split("/").length || a$1.localeCompare(b);
489
+ }
490
+ async function writeCFHeaders(nitro, outdir) {
491
+ const headersPath = join$1(outdir === "public" ? nitro.options.output.publicDir : nitro.options.output.dir, "_headers");
492
+ const contents = [];
493
+ const rules = Object.entries(nitro.options.routeRules).sort((a$1, b) => b[0].split(/\/(?!\*)/).length - a$1[0].split(/\/(?!\*)/).length);
494
+ for (const [path$1, routeRules] of rules.filter(([_, routeRules$1]) => routeRules$1.headers)) {
495
+ const headers = [joinURL(nitro.options.baseURL, path$1.replace("/**", "/*")), ...Object.entries({ ...routeRules.headers }).map(([header, value]) => ` ${header}: ${value}`)].join("\n");
496
+ contents.push(headers);
497
+ }
498
+ if (existsSync(headersPath)) {
499
+ const currentHeaders = await readFile(headersPath, "utf8");
500
+ if (/^\/\* /m.test(currentHeaders)) {
501
+ nitro.logger.info("Not adding Nitro fallback to `_headers` (as an existing fallback was found).");
502
+ return;
503
+ }
504
+ nitro.logger.info("Adding Nitro fallback to `_headers` to handle all unmatched routes.");
505
+ contents.unshift(currentHeaders);
506
+ }
507
+ await writeFile$1(headersPath, contents.join("\n"), true);
508
+ }
509
+ async function writeCFPagesRedirects(nitro) {
510
+ const redirectsPath = join$1(nitro.options.output.dir, "_redirects");
511
+ const contents = [existsSync(join$1(nitro.options.output.publicDir, "404.html")) ? `${joinURL(nitro.options.baseURL, "/*")} ${joinURL(nitro.options.baseURL, "/404.html")} 404` : ""];
512
+ const rules = Object.entries(nitro.options.routeRules).sort((a$1, b) => a$1[0].split(/\/(?!\*)/).length - b[0].split(/\/(?!\*)/).length);
513
+ for (const [key, routeRules] of rules.filter(([_, routeRules$1]) => routeRules$1.redirect)) {
514
+ const code = routeRules.redirect.status;
515
+ const from = joinURL(nitro.options.baseURL, key.replace("/**", "/*"));
516
+ const to = hasProtocol(routeRules.redirect.to, { acceptRelative: true }) ? routeRules.redirect.to : joinURL(nitro.options.baseURL, routeRules.redirect.to);
517
+ contents.unshift(`${from}\t${to}\t${code}`);
518
+ }
519
+ if (existsSync(redirectsPath)) {
520
+ const currentRedirects = await readFile(redirectsPath, "utf8");
521
+ if (/^\/\* /m.test(currentRedirects)) {
522
+ nitro.logger.info("Not adding Nitro fallback to `_redirects` (as an existing fallback was found).");
523
+ return;
524
+ }
525
+ nitro.logger.info("Adding Nitro fallback to `_redirects` to handle all unmatched routes.");
526
+ contents.unshift(currentRedirects);
527
+ }
528
+ await writeFile$1(redirectsPath, contents.join("\n"), true);
529
+ }
530
+ async function enableNodeCompat(nitro) {
531
+ nitro.options.cloudflare ??= {};
532
+ nitro.options.cloudflare.deployConfig ??= true;
533
+ nitro.options.cloudflare.nodeCompat ??= true;
534
+ if (nitro.options.cloudflare.nodeCompat) nitro.options.unenv.push(unencCfNodeCompat);
535
+ }
536
+ const extensionParsers = {
537
+ ".json": h,
538
+ ".jsonc": h,
539
+ ".toml": Q
540
+ };
541
+ async function readWranglerConfig(nitro) {
542
+ const configPath = await findNearestFile([
543
+ "wrangler.json",
544
+ "wrangler.jsonc",
545
+ "wrangler.toml"
546
+ ], { startingFrom: nitro.options.rootDir }).catch(() => void 0);
547
+ if (!configPath) return {};
548
+ const userConfigText = await readFile(configPath, "utf8");
549
+ const parser = extensionParsers[extname(configPath)];
550
+ if (!parser) throw new Error(`Unsupported config file format: ${configPath}`);
551
+ return {
552
+ configPath,
553
+ config: parser(userConfigText)
554
+ };
555
+ }
556
+ async function writeWranglerConfig(nitro, cfTarget) {
557
+ if (!nitro.options.cloudflare?.deployConfig) return;
558
+ const wranglerConfigDir = nitro.options.output.serverDir;
559
+ const wranglerConfigPath = join$1(wranglerConfigDir, "wrangler.json");
560
+ const defaults = {};
561
+ const overrides = {};
562
+ defaults.compatibility_date = nitro.options.compatibilityDate.cloudflare || nitro.options.compatibilityDate.default;
563
+ if (cfTarget === "pages") overrides.pages_build_output_dir = relative(wranglerConfigDir, nitro.options.output.dir);
564
+ else {
565
+ overrides.main = relative(wranglerConfigDir, join$1(nitro.options.output.serverDir, "index.mjs"));
566
+ overrides.assets = {
567
+ binding: "ASSETS",
568
+ directory: relative(wranglerConfigDir, resolve$1(nitro.options.output.publicDir, "..".repeat(nitro.options.baseURL.split("/").filter(Boolean).length)))
569
+ };
570
+ }
571
+ const { config: userConfig = {} } = await readWranglerConfig(nitro);
572
+ const ctxConfig = nitro.options.cloudflare?.wrangler || {};
573
+ for (const key in overrides) if (key in userConfig || key in ctxConfig) nitro.logger.warn(`[cloudflare] Wrangler config \`${key}\`${key in ctxConfig ? "set by config or modules" : ""} is overridden and will be ignored.`);
574
+ const wranglerConfig = defu(overrides, ctxConfig, userConfig, defaults);
575
+ if (!wranglerConfig.name) {
576
+ wranglerConfig.name = await generateWorkerName(nitro);
577
+ nitro.logger.info(`Using auto generated worker name: \`${wranglerConfig.name}\``);
578
+ }
579
+ wranglerConfig.compatibility_flags ??= [];
580
+ if (nitro.options.cloudflare?.nodeCompat && !wranglerConfig.compatibility_flags.includes("nodejs_compat")) wranglerConfig.compatibility_flags.push("nodejs_compat");
581
+ if (cfTarget === "module") {
582
+ if (wranglerConfig.no_bundle === void 0) wranglerConfig.no_bundle = true;
583
+ wranglerConfig.rules ??= [];
584
+ if (!wranglerConfig.rules.some((rule) => rule.type === "ESModule")) wranglerConfig.rules.push({
585
+ type: "ESModule",
586
+ globs: ["**/*.mjs", "**/*.js"]
587
+ });
588
+ }
589
+ await writeFile$1(wranglerConfigPath, JSON.stringify(wranglerConfig, null, 2), true);
590
+ const configPath = join$1(nitro.options.rootDir, ".wrangler/deploy/config.json");
591
+ await writeFile$1(configPath, JSON.stringify({ configPath: relative(dirname(configPath), wranglerConfigPath) }), true);
592
+ }
593
+ async function generateWorkerName(nitro) {
594
+ const gitRepo = (await readGitConfig(nitro.options.rootDir).catch(() => void 0))?.remote?.origin?.url?.replace(/\.git$/, "").match(/[/:]([^/]+\/[^/]+)$/)?.[1];
595
+ const pkgName = (await readPackageJSON(nitro.options.rootDir).catch(() => void 0))?.name;
596
+ const subpath = relative(nitro.options.workspaceDir, nitro.options.rootDir);
597
+ return `${gitRepo || pkgName}/${subpath}`.toLowerCase().replace(/[^a-zA-Z0-9-]/g, "-").replace(/-$/, "");
598
+ }
599
+
600
+ //#endregion
601
+ //#region src/presets/cloudflare/dev.ts
602
+ async function cloudflareDevModule(nitro) {
603
+ if (!nitro.options.dev) return;
604
+ nitro.options.unenv.push({
605
+ meta: { name: "nitro:cloudflare-dev" },
606
+ alias: { "cloudflare:workers": resolve(presetsDir, "cloudflare/runtime/shims/workers.dev.mjs") }
607
+ });
608
+ if (!await resolveModulePath("wrangler", {
609
+ from: nitro.options.nodeModulesDirs,
610
+ try: true
611
+ })) {
612
+ nitro.logger.warn("Wrangler is not installed. Please install it using `npx nypm i wrangler` to enable dev emulation.");
613
+ return;
614
+ }
615
+ const config = {
616
+ ...nitro.options.cloudflareDev,
617
+ ...nitro.options.cloudflare?.dev
618
+ };
619
+ let configPath = config.configPath;
620
+ if (!configPath) configPath = await findFile([
621
+ "wrangler.json",
622
+ "wrangler.jsonc",
623
+ "wrangler.toml"
624
+ ], { startingFrom: nitro.options.rootDir }).catch(() => void 0);
625
+ const persistDir = resolve(nitro.options.rootDir, config.persistDir || ".wrangler/state/v3");
626
+ const gitIgnorePath = await findFile(".gitignore", { startingFrom: nitro.options.rootDir }).catch(() => void 0);
627
+ if (gitIgnorePath && persistDir === ".wrangler/state/v3") {
628
+ const gitIgnore = await promises.readFile(gitIgnorePath, "utf8");
629
+ if (!gitIgnore.includes(".wrangler/state/v3")) await promises.writeFile(gitIgnorePath, gitIgnore + "\n.wrangler/state/v3\n").catch(() => {});
630
+ }
631
+ nitro.options.runtimeConfig.wrangler = {
632
+ ...nitro.options.runtimeConfig.wrangler,
633
+ configPath,
634
+ persistDir,
635
+ environment: config.environment
636
+ };
637
+ nitro.options.externals.inline = nitro.options.externals.inline || [];
638
+ nitro.options.externals.inline.push(fileURLToPath(new URL("runtime/", import.meta.url)));
639
+ nitro.options.plugins = nitro.options.plugins || [];
640
+ nitro.options.plugins.unshift(resolveModulePath("./cloudflare/runtime/plugin.dev", {
641
+ from: presetsDir,
642
+ extensions: [".mjs", ".ts"]
643
+ }));
644
+ }
645
+
646
+ //#endregion
647
+ //#region src/presets/cloudflare/preset.ts
648
+ const cloudflarePages = defineNitroPreset({
649
+ extends: "base-worker",
650
+ entry: "./cloudflare/runtime/cloudflare-pages",
651
+ exportConditions: ["workerd"],
652
+ minify: false,
653
+ commands: {
654
+ preview: "npx wrangler --cwd ./ pages dev",
655
+ deploy: "npx wrangler --cwd ./ pages deploy"
656
+ },
657
+ output: {
658
+ dir: "{{ rootDir }}/dist",
659
+ publicDir: "{{ output.dir }}/{{ baseURL }}",
660
+ serverDir: "{{ output.dir }}/_worker.js"
661
+ },
662
+ alias: { _mime: "mime/index.js" },
663
+ wasm: {
664
+ lazy: false,
665
+ esmImport: true
666
+ },
667
+ rollupConfig: { output: {
668
+ entryFileNames: "index.js",
669
+ format: "esm",
670
+ inlineDynamicImports: false
671
+ } },
672
+ hooks: {
673
+ "build:before": async (nitro) => {
674
+ nitro.options.unenv.push(unenvCfExternals);
675
+ await enableNodeCompat(nitro);
676
+ },
677
+ async compiled(nitro) {
678
+ await writeWranglerConfig(nitro, "pages");
679
+ await writeCFRoutes(nitro);
680
+ await writeCFHeaders(nitro, "output");
681
+ await writeCFPagesRedirects(nitro);
682
+ }
683
+ }
684
+ }, {
685
+ name: "cloudflare-pages",
686
+ stdName: "cloudflare_pages"
687
+ });
688
+ const cloudflarePagesStatic = defineNitroPreset({
689
+ extends: "static",
690
+ output: {
691
+ dir: "{{ rootDir }}/dist",
692
+ publicDir: "{{ output.dir }}/{{ baseURL }}"
693
+ },
694
+ commands: {
695
+ preview: "npx wrangler --cwd ./ pages dev",
696
+ deploy: "npx wrangler --cwd ./ pages deploy"
697
+ },
698
+ hooks: { async compiled(nitro) {
699
+ await writeCFHeaders(nitro, "output");
700
+ await writeCFPagesRedirects(nitro);
701
+ } }
702
+ }, {
703
+ name: "cloudflare-pages-static",
704
+ stdName: "cloudflare_pages",
705
+ static: true
706
+ });
707
+ const cloudflareDev = defineNitroPreset({
708
+ extends: "nitro-dev",
709
+ modules: [cloudflareDevModule]
710
+ }, {
711
+ name: "cloudflare-dev",
712
+ aliases: [
713
+ "cloudflare-module",
714
+ "cloudflare-durable",
715
+ "cloudflare-pages"
716
+ ],
717
+ compatibilityDate: "2025-07-13",
718
+ dev: true
719
+ });
720
+ const cloudflareModule = defineNitroPreset({
721
+ extends: "base-worker",
722
+ entry: "./cloudflare/runtime/cloudflare-module",
723
+ output: { publicDir: "{{ output.dir }}/public/{{ baseURL }}" },
724
+ exportConditions: ["workerd"],
725
+ minify: false,
726
+ commands: {
727
+ preview: "npx wrangler --cwd ./ dev",
728
+ deploy: "npx wrangler --cwd ./ deploy"
729
+ },
730
+ rollupConfig: { output: {
731
+ format: "esm",
732
+ exports: "named",
733
+ inlineDynamicImports: false
734
+ } },
735
+ wasm: {
736
+ lazy: false,
737
+ esmImport: true
738
+ },
739
+ hooks: {
740
+ "build:before": async (nitro) => {
741
+ nitro.options.unenv.push(unenvCfExternals);
742
+ await enableNodeCompat(nitro);
743
+ },
744
+ async compiled(nitro) {
745
+ await writeWranglerConfig(nitro, "module");
746
+ await writeCFHeaders(nitro, "public");
747
+ await writeFile$1(resolve$1(nitro.options.output.dir, "package.json"), JSON.stringify({
748
+ private: true,
749
+ main: "./server/index.mjs"
750
+ }, null, 2));
751
+ await writeFile$1(resolve$1(nitro.options.output.dir, "package-lock.json"), JSON.stringify({ lockfileVersion: 1 }, null, 2));
752
+ }
753
+ }
754
+ }, {
755
+ name: "cloudflare-module",
756
+ stdName: "cloudflare_workers"
757
+ });
758
+ const cloudflareDurable = defineNitroPreset({
759
+ extends: "cloudflare-module",
760
+ entry: "./cloudflare/runtime/cloudflare-durable"
761
+ }, { name: "cloudflare-durable" });
762
+ var preset_default$8 = [
763
+ cloudflarePages,
764
+ cloudflarePagesStatic,
765
+ cloudflareModule,
766
+ cloudflareDurable,
767
+ cloudflareDev
768
+ ];
769
+
770
+ //#endregion
771
+ //#region src/presets/deno/unenv/node-compat.ts
772
+ const builtnNodeModules = [
773
+ "node:_http_agent",
774
+ "node:_http_common",
775
+ "node:_http_outgoing",
776
+ "node:_http_server",
777
+ "node:_stream_duplex",
778
+ "node:_stream_passthrough",
779
+ "node:_stream_readable",
780
+ "node:_stream_transform",
781
+ "node:_stream_writable",
782
+ "node:_tls_common",
783
+ "node:_tls_wrap",
784
+ "node:assert",
785
+ "node:assert/strict",
786
+ "node:async_hooks",
787
+ "node:buffer",
788
+ "node:child_process",
789
+ "node:cluster",
790
+ "node:console",
791
+ "node:constants",
792
+ "node:crypto",
793
+ "node:dgram",
794
+ "node:diagnostics_channel",
795
+ "node:dns",
796
+ "node:dns/promises",
797
+ "node:domain",
798
+ "node:events",
799
+ "node:fs",
800
+ "node:fs/promises",
801
+ "node:http",
802
+ "node:http2",
803
+ "node:https",
804
+ "node:inspector",
805
+ "node:inspector/promises",
806
+ "node:module",
807
+ "node:net",
808
+ "node:os",
809
+ "node:path",
810
+ "node:path/posix",
811
+ "node:path/win32",
812
+ "node:perf_hooks",
813
+ "node:process",
814
+ "node:punycode",
815
+ "node:querystring",
816
+ "node:readline",
817
+ "node:readline/promises",
818
+ "node:repl",
819
+ "node:sqlite",
820
+ "node:stream",
821
+ "node:stream/consumers",
822
+ "node:stream/promises",
823
+ "node:stream/web",
824
+ "node:string_decoder",
825
+ "node:sys",
826
+ "node:test",
827
+ "node:timers",
828
+ "node:timers/promises",
829
+ "node:tls",
830
+ "node:trace_events",
831
+ "node:tty",
832
+ "node:url",
833
+ "node:util",
834
+ "node:util/types",
835
+ "node:v8",
836
+ "node:vm",
837
+ "node:wasi",
838
+ "node:worker_threads",
839
+ "node:zlib"
840
+ ];
841
+
842
+ //#endregion
843
+ //#region src/presets/deno/unenv/preset.ts
844
+ const unenvDeno = {
845
+ meta: { name: "nitro:deno" },
846
+ external: builtnNodeModules.map((m) => `node:${m}`),
847
+ alias: { ...Object.fromEntries(builtnNodeModules.flatMap((m) => [[m, m], [m.replace("node:", ""), m]])) },
848
+ inject: {
849
+ global: "unenv/polyfill/globalthis",
850
+ process: "node:process",
851
+ clearImmediate: ["node:timers", "clearImmediate"],
852
+ setImmediate: ["node:timers", "setImmediate"],
853
+ Buffer: ["node:buffer", "Buffer"]
854
+ }
855
+ };
856
+
857
+ //#endregion
858
+ //#region src/presets/deno/preset.ts
859
+ const denoDeploy = defineNitroPreset({
860
+ entry: "./deno/runtime/deno-deploy",
861
+ exportConditions: ["deno"],
862
+ node: false,
863
+ noExternals: true,
864
+ serveStatic: "deno",
865
+ commands: {
866
+ preview: "",
867
+ deploy: "cd ./ && deployctl deploy --project=<project_name> server/index.ts"
868
+ },
869
+ unenv: unenvDeno,
870
+ rollupConfig: {
871
+ preserveEntrySignatures: false,
872
+ external: (id) => id.startsWith("https://") || id.startsWith("node:"),
873
+ output: {
874
+ entryFileNames: "index.ts",
875
+ manualChunks: (id) => "index",
876
+ format: "esm"
877
+ }
878
+ }
879
+ }, { name: "deno-deploy" });
880
+ const denoServer = defineNitroPreset({
881
+ entry: "./deno/runtime/deno-server",
882
+ serveStatic: true,
883
+ exportConditions: ["deno"],
884
+ commands: { preview: "deno -A ./server/index.mjs" },
885
+ rollupConfig: {
886
+ external: (id) => id.startsWith("https://"),
887
+ output: { hoistTransitiveImports: false }
888
+ },
889
+ hooks: { async compiled(nitro) {
890
+ await writeFile$1(resolve$1(nitro.options.output.dir, "deno.json"), JSON.stringify({ tasks: { start: "deno run -A ./server/index.mjs" } }, null, 2));
891
+ } }
892
+ }, {
893
+ aliases: ["deno"],
894
+ name: "deno-server"
895
+ });
896
+ var preset_default$9 = [denoDeploy, denoServer];
897
+
898
+ //#endregion
899
+ //#region src/presets/digitalocean/preset.ts
900
+ const digitalOcean = defineNitroPreset({
901
+ extends: "node-server",
902
+ serveStatic: true
903
+ }, { name: "digital-ocean" });
904
+ var preset_default$10 = [digitalOcean];
905
+
906
+ //#endregion
907
+ //#region src/presets/firebase/preset.ts
908
+ const firebaseAppHosting = defineNitroPreset({
909
+ extends: "node-server",
910
+ serveStatic: true,
911
+ hooks: { async compiled(nitro) {
912
+ const serverEntry = join$1(nitro.options.output.serverDir, "index.mjs");
913
+ await writeFile$1(join$1(nitro.options.rootDir, ".apphosting/bundle.yaml"), gr({
914
+ version: "v1",
915
+ runConfig: {
916
+ runCommand: `node ${relative$1(nitro.options.rootDir, serverEntry)}`,
917
+ ...nitro.options.firebase?.appHosting
918
+ },
919
+ metadata: {
920
+ framework: nitro.options.framework.name || "nitro",
921
+ frameworkVersion: nitro.options.framework.version || "2.x",
922
+ adapterPackageName: "nitro",
923
+ adapterVersion: version
924
+ },
925
+ outputFiles: { serverApp: { include: [relative$1(nitro.options.rootDir, nitro.options.output.dir)] } }
926
+ }), true);
927
+ } }
928
+ }, {
929
+ name: "firebase-app-hosting",
930
+ stdName: "firebase_app_hosting"
931
+ });
932
+ var preset_default$11 = [firebaseAppHosting];
933
+
934
+ //#endregion
935
+ //#region src/presets/flightcontrol/preset.ts
936
+ const flightControl = defineNitroPreset({
937
+ extends: "node-server",
938
+ serveStatic: true
939
+ }, { name: "flight-control" });
940
+ var preset_default$12 = [flightControl];
941
+
942
+ //#endregion
943
+ //#region src/presets/genezio/preset.ts
944
+ const genezio = defineNitroPreset({ extends: "aws_lambda" }, { name: "genezio" });
945
+ var preset_default$13 = [genezio];
946
+
947
+ //#endregion
948
+ //#region src/presets/heroku/preset.ts
949
+ const heroku = defineNitroPreset({
950
+ extends: "node-server",
951
+ serveStatic: true
952
+ }, { name: "heroku" });
953
+ var preset_default$14 = [heroku];
954
+
955
+ //#endregion
956
+ //#region src/presets/iis/utils.ts
957
+ async function writeIISFiles(nitro) {
958
+ await writeFile$1(resolve$1(nitro.options.output.dir, "web.config"), await iisXmlTemplate(nitro));
959
+ }
960
+ async function writeIISNodeFiles(nitro) {
961
+ await writeFile$1(resolve$1(nitro.options.output.dir, "web.config"), await iisnodeXmlTemplate(nitro));
962
+ await writeFile$1(resolve$1(nitro.options.output.dir, "index.js"), `
963
+ if (process.env.PORT.startsWith('\\\\')) {
964
+ process.env.NITRO_UNIX_SOCKET = process.env.PORT
965
+ delete process.env.PORT
966
+ }
967
+ import('./server/index.mjs');
968
+ `);
969
+ }
970
+ async function iisnodeXmlTemplate(nitro) {
971
+ const path$1 = resolve$1(nitro.options.rootDir, "web.config");
972
+ const originalString = `<?xml version="1.0" encoding="utf-8"?>
973
+ <!--
974
+ This configuration file is required if iisnode is used to run node processes behind
975
+ IIS or IIS Express. For more information, visit:
976
+ https://github.com/Azure/iisnode/blob/master/src/samples/configuration/web.config
977
+ -->
978
+ <configuration>
979
+ <system.webServer>
980
+ <!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
981
+ <webSocket enabled="false" />
982
+ <handlers>
983
+ <!-- Indicates that the index.js file is a Node.js site to be handled by the iisnode module -->
984
+ <add name="iisnode" path="index.js" verb="*" modules="iisnode" />
985
+ </handlers>
986
+ <rewrite>
987
+ <rules>
988
+ <!-- Do not interfere with requests for node-inspector debugging -->
989
+ <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
990
+ <match url="^index.js/debug[/]?" />
991
+ </rule>
992
+
993
+ <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
994
+ <rule name="StaticContent">
995
+ <action type="Rewrite" url="public{PATH_INFO}" />
996
+ </rule>
997
+
998
+ <!-- All other URLs are mapped to the Node.js site entrypoint -->
999
+ <rule name="DynamicContent">
1000
+ <conditions>
1001
+ <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" />
1002
+ </conditions>
1003
+ <action type="Rewrite" url="index.js" />
1004
+ </rule>
1005
+ </rules>
1006
+ </rewrite>
1007
+
1008
+ <!-- 'bin' directory has no special meaning in Node.js and apps can be placed in it -->
1009
+ <security>
1010
+ <requestFiltering>
1011
+ <hiddenSegments>
1012
+ <remove segment="bin" />
1013
+ </hiddenSegments>
1014
+ <requestLimits maxAllowedContentLength="4294967295" />
1015
+ </requestFiltering>
1016
+ </security>
1017
+
1018
+ <!-- Make sure error responses are left untouched -->
1019
+ <httpErrors existingResponse="PassThrough" />
1020
+
1021
+ <!--
1022
+ You can control how Node is hosted within IIS using the following options:
1023
+ * watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
1024
+ * node_env: will be propagated to node as NODE_ENV environment variable
1025
+ * debuggingEnabled - controls whether the built-in debugger is enabled
1026
+ See https://github.com/Azure/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
1027
+ -->
1028
+ <iisnode
1029
+ watchedFiles="index.js"
1030
+ node_env="production"
1031
+ debuggingEnabled="false"
1032
+ loggingEnabled="false"
1033
+ />
1034
+ </system.webServer>
1035
+ </configuration>
1036
+ `;
1037
+ if (existsSync(path$1)) {
1038
+ const fileString = await readFile(path$1, "utf8");
1039
+ const originalWebConfig = await parseXmlDoc(originalString);
1040
+ const fileWebConfig = await parseXmlDoc(fileString);
1041
+ if (nitro.options.iis?.mergeConfig && !nitro.options.iis.overrideConfig) return buildNewXmlDoc(defu(fileWebConfig, originalWebConfig));
1042
+ if (nitro.options.iis?.overrideConfig) return buildNewXmlDoc({ ...fileWebConfig });
1043
+ }
1044
+ return originalString;
1045
+ }
1046
+ async function iisXmlTemplate(nitro) {
1047
+ const path$1 = resolve$1(nitro.options.rootDir, "web.config");
1048
+ const originalString = `<?xml version="1.0" encoding="UTF-8"?>
1049
+ <configuration>
1050
+ <system.webServer>
1051
+ <handlers>
1052
+ <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
1053
+ </handlers>
1054
+ <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\\logs\\node.log" startupTimeLimit="20" processPath="C:\\Program Files\\nodejs\\node.exe" arguments=".\\server\\index.mjs">
1055
+ <environmentVariables>
1056
+ <environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
1057
+ <environmentVariable name="NODE_ENV" value="Production" />
1058
+ </environmentVariables>
1059
+ </httpPlatform>
1060
+ </system.webServer>
1061
+ </configuration>
1062
+ `;
1063
+ if (existsSync(path$1)) {
1064
+ const fileString = await readFile(path$1, "utf8");
1065
+ const originalWebConfig = await parseXmlDoc(originalString);
1066
+ const fileWebConfig = await parseXmlDoc(fileString);
1067
+ if (nitro.options.iis?.mergeConfig && !nitro.options.iis.overrideConfig) return buildNewXmlDoc(defu(fileWebConfig, originalWebConfig));
1068
+ if (nitro.options.iis?.overrideConfig) return buildNewXmlDoc({ ...fileWebConfig });
1069
+ }
1070
+ return originalString;
1071
+ }
1072
+ async function parseXmlDoc(xml) {
1073
+ const { Parser } = await import("xml2js");
1074
+ if (xml === void 0 || !xml) return {};
1075
+ const parser = new Parser({ explicitArray: false });
1076
+ let parsedRecord = {};
1077
+ parser.parseString(xml, (_, r) => {
1078
+ parsedRecord = r;
1079
+ });
1080
+ return parsedRecord;
1081
+ }
1082
+ async function buildNewXmlDoc(xmlObj) {
1083
+ const { Builder } = await import("xml2js");
1084
+ return new Builder().buildObject({ ...xmlObj });
1085
+ }
1086
+
1087
+ //#endregion
1088
+ //#region src/presets/iis/preset.ts
1089
+ const iisHandler = defineNitroPreset({
1090
+ extends: "node-server",
1091
+ serveStatic: true,
1092
+ hooks: { async compiled(nitro) {
1093
+ await writeIISFiles(nitro);
1094
+ } }
1095
+ }, { name: "iis-handler" });
1096
+ const iisNode = defineNitroPreset({
1097
+ extends: "node-server",
1098
+ serveStatic: true,
1099
+ hooks: { async compiled(nitro) {
1100
+ await writeIISNodeFiles(nitro);
1101
+ } }
1102
+ }, { name: "iis-node" });
1103
+ var preset_default$15 = [iisHandler, iisNode];
1104
+
1105
+ //#endregion
1106
+ //#region src/presets/koyeb/preset.ts
1107
+ const koyeb = defineNitroPreset({
1108
+ extends: "node-server",
1109
+ serveStatic: true
1110
+ }, { name: "koyeb" });
1111
+ var preset_default$16 = [koyeb];
1112
+
1113
+ //#endregion
1114
+ //#region src/presets/netlify/utils.ts
1115
+ async function writeRedirects(nitro) {
1116
+ const redirectsPath = join$1(nitro.options.output.publicDir, "_redirects");
1117
+ let contents = "";
1118
+ if (nitro.options.static) {
1119
+ const staticFallback = existsSync(join$1(nitro.options.output.publicDir, "404.html")) ? "/* /404.html 404" : "";
1120
+ contents += staticFallback;
1121
+ }
1122
+ const rules = Object.entries(nitro.options.routeRules).sort((a$1, b) => a$1[0].split(/\/(?!\*)/).length - b[0].split(/\/(?!\*)/).length);
1123
+ for (const [key, routeRules] of rules.filter(([_, routeRules$1]) => routeRules$1.redirect)) {
1124
+ let code = routeRules.redirect.status;
1125
+ if (code === 307) code = 302;
1126
+ if (code === 308) code = 301;
1127
+ contents = `${key.replace("/**", "/*")}\t${routeRules.redirect.to.replace("/**", "/:splat")}\t${code}\n` + contents;
1128
+ }
1129
+ if (existsSync(redirectsPath)) {
1130
+ const currentRedirects = await promises.readFile(redirectsPath, "utf8");
1131
+ if (/^\/\* /m.test(currentRedirects)) {
1132
+ nitro.logger.info("Not adding Nitro fallback to `_redirects` (as an existing fallback was found).");
1133
+ return;
1134
+ }
1135
+ nitro.logger.info("Adding Nitro fallback to `_redirects` to handle all unmatched routes.");
1136
+ contents = currentRedirects + "\n" + contents;
1137
+ }
1138
+ await promises.writeFile(redirectsPath, contents);
1139
+ }
1140
+ async function writeHeaders(nitro) {
1141
+ const headersPath = join$1(nitro.options.output.publicDir, "_headers");
1142
+ let contents = "";
1143
+ const rules = Object.entries(nitro.options.routeRules).sort((a$1, b) => b[0].split(/\/(?!\*)/).length - a$1[0].split(/\/(?!\*)/).length);
1144
+ for (const [path$1, routeRules] of rules.filter(([_, routeRules$1]) => routeRules$1.headers)) {
1145
+ const headers = [path$1.replace("/**", "/*"), ...Object.entries({ ...routeRules.headers }).map(([header, value]) => ` ${header}: ${value}`)].join("\n");
1146
+ contents += headers + "\n";
1147
+ }
1148
+ if (existsSync(headersPath)) {
1149
+ const currentHeaders = await promises.readFile(headersPath, "utf8");
1150
+ if (/^\/\* /m.test(currentHeaders)) {
1151
+ nitro.logger.info("Not adding Nitro fallback to `_headers` (as an existing fallback was found).");
1152
+ return;
1153
+ }
1154
+ nitro.logger.info("Adding Nitro fallback to `_headers` to handle all unmatched routes.");
1155
+ contents = currentHeaders + "\n" + contents;
1156
+ }
1157
+ await promises.writeFile(headersPath, contents);
1158
+ }
1159
+ function getStaticPaths(publicAssets, baseURL) {
1160
+ return ["/.netlify/*", ...publicAssets.filter((a$1) => a$1.fallthrough !== true && a$1.baseURL && a$1.baseURL !== "/").map((a$1) => joinURL(baseURL, a$1.baseURL, "*"))];
1161
+ }
1162
+ function generateNetlifyFunction(nitro) {
1163
+ return `
1164
+ export { default } from "./main.mjs";
1165
+ export const config = {
1166
+ name: "server handler",
1167
+ generator: "${getGeneratorString(nitro)}",
1168
+ path: "/*",
1169
+ nodeBundler: "none",
1170
+ includedFiles: ["**"],
1171
+ excludedPath: ${JSON.stringify(getStaticPaths(nitro.options.publicAssets, nitro.options.baseURL))},
1172
+ preferStatic: true,
1173
+ };
1174
+ `.trim();
1175
+ }
1176
+ function getGeneratorString(nitro) {
1177
+ return `${nitro.options.framework.name}@${nitro.options.framework.version}`;
1178
+ }
1179
+
1180
+ //#endregion
1181
+ //#region src/presets/netlify/preset.ts
1182
+ const netlify = defineNitroPreset({
1183
+ entry: "./netlify/runtime/netlify",
1184
+ output: {
1185
+ dir: "{{ rootDir }}/.netlify/functions-internal",
1186
+ publicDir: "{{ rootDir }}/dist/{{ baseURL }}"
1187
+ },
1188
+ prerender: { autoSubfolderIndex: false },
1189
+ rollupConfig: { output: { entryFileNames: "main.mjs" } },
1190
+ hooks: { async compiled(nitro) {
1191
+ await writeHeaders(nitro);
1192
+ await writeRedirects(nitro);
1193
+ await promises.writeFile(join$1(nitro.options.output.dir, "server", "server.mjs"), generateNetlifyFunction(nitro));
1194
+ if (nitro.options.netlify) {
1195
+ const configPath = join$1(nitro.options.output.dir, "../deploy/v1/config.json");
1196
+ await promises.mkdir(dirname$1(configPath), { recursive: true });
1197
+ await promises.writeFile(configPath, JSON.stringify(nitro.options.netlify), "utf8");
1198
+ }
1199
+ } }
1200
+ }, {
1201
+ name: "netlify",
1202
+ stdName: "netlify"
1203
+ });
1204
+ const netlifyEdge = defineNitroPreset({
1205
+ extends: "base-worker",
1206
+ entry: "./netlify/runtime/netlify-edge",
1207
+ exportConditions: ["netlify"],
1208
+ output: {
1209
+ serverDir: "{{ rootDir }}/.netlify/edge-functions/server",
1210
+ publicDir: "{{ rootDir }}/dist/{{ baseURL }}"
1211
+ },
1212
+ prerender: { autoSubfolderIndex: false },
1213
+ rollupConfig: { output: {
1214
+ entryFileNames: "server.js",
1215
+ format: "esm"
1216
+ } },
1217
+ unenv: unenvDeno,
1218
+ hooks: { async compiled(nitro) {
1219
+ await writeHeaders(nitro);
1220
+ await writeRedirects(nitro);
1221
+ const manifest = {
1222
+ version: 1,
1223
+ functions: [{
1224
+ path: "/*",
1225
+ excludedPath: getStaticPaths(nitro.options.publicAssets, nitro.options.baseURL),
1226
+ name: "edge server handler",
1227
+ function: "server",
1228
+ generator: getGeneratorString(nitro)
1229
+ }]
1230
+ };
1231
+ const manifestPath = join$1(nitro.options.rootDir, ".netlify/edge-functions/manifest.json");
1232
+ await promises.mkdir(dirname$1(manifestPath), { recursive: true });
1233
+ await promises.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
1234
+ } }
1235
+ }, { name: "netlify-edge" });
1236
+ const netlifyStatic = defineNitroPreset({
1237
+ extends: "static",
1238
+ output: {
1239
+ dir: "{{ rootDir }}/dist",
1240
+ publicDir: "{{ rootDir }}/dist/{{ baseURL }}"
1241
+ },
1242
+ prerender: { autoSubfolderIndex: false },
1243
+ commands: { preview: "npx serve ./" },
1244
+ hooks: { async compiled(nitro) {
1245
+ await writeHeaders(nitro);
1246
+ await writeRedirects(nitro);
1247
+ } }
1248
+ }, {
1249
+ name: "netlify-static",
1250
+ stdName: "netlify",
1251
+ static: true
1252
+ });
1253
+ var preset_default$17 = [
1254
+ netlify,
1255
+ netlifyEdge,
1256
+ netlifyStatic
1257
+ ];
1258
+
1259
+ //#endregion
1260
+ //#region src/presets/node/cluster.ts
1261
+ const nodeCluster = defineNitroPreset({
1262
+ extends: "node-server",
1263
+ serveStatic: true,
1264
+ entry: "./node/runtime/node-cluster",
1265
+ rollupConfig: { output: { entryFileNames: "worker.mjs" } },
1266
+ hooks: { async compiled(nitro) {
1267
+ await writeFile$2(resolve$1(nitro.options.output.serverDir, "index.mjs"), nodeClusterEntry());
1268
+ } }
1269
+ }, { name: "node-cluster" });
1270
+ function nodeClusterEntry() {
1271
+ return `
1272
+ import cluster from "node:cluster";
1273
+ import os from "node:os";
1274
+
1275
+ if (cluster.isPrimary) {
1276
+ const numberOfWorkers =
1277
+ Number.parseInt(process.env.NITRO_CLUSTER_WORKERS || "") ||
1278
+ (os.cpus().length > 0 ? os.cpus().length : 1);
1279
+ for (let i = 0; i < numberOfWorkers; i++) {
1280
+ cluster.fork({
1281
+ WORKER_ID: i + 1,
1282
+ });
1283
+ }
1284
+ } else {
1285
+ import("./worker.mjs").catch((error) => {
1286
+ console.error(error);
1287
+ process.exit(1);
1288
+ });
1289
+ }
1290
+ `;
1291
+ }
1292
+
1293
+ //#endregion
1294
+ //#region src/presets/node/preset.ts
1295
+ const nodeServer = defineNitroPreset({
1296
+ entry: "./node/runtime/node-server",
1297
+ serveStatic: true,
1298
+ commands: { preview: "node ./server/index.mjs" }
1299
+ }, {
1300
+ name: "node-server",
1301
+ aliases: ["node"]
1302
+ });
1303
+ const nodeMiddleware = defineNitroPreset({ entry: "./node/runtime/node-middleware" }, { name: "node-middleware" });
1304
+ var preset_default$18 = [
1305
+ nodeServer,
1306
+ nodeCluster,
1307
+ nodeMiddleware
1308
+ ];
1309
+
1310
+ //#endregion
1311
+ //#region src/presets/platform.sh/preset.ts
1312
+ const platformSh = defineNitroPreset({
1313
+ extends: "node-server",
1314
+ serveStatic: true
1315
+ }, { name: "platform-sh" });
1316
+ var preset_default$19 = [platformSh];
1317
+
1318
+ //#endregion
1319
+ //#region src/presets/render.com/preset.ts
1320
+ const renderCom = defineNitroPreset({
1321
+ extends: "node-server",
1322
+ serveStatic: true
1323
+ }, { name: "render-com" });
1324
+ var preset_default$20 = [renderCom];
1325
+
1326
+ //#endregion
1327
+ //#region src/presets/standard/preset.ts
1328
+ const standard = defineNitroPreset({
1329
+ entry: "./standard/runtime/server",
1330
+ serveStatic: false,
1331
+ exportConditions: ["import", "default"],
1332
+ output: { publicDir: "{{ output.dir }}/public/{{ baseURL }}" },
1333
+ commands: { preview: "npx srvx --prod ./" },
1334
+ alias: {
1335
+ srvx: "srvx/generic",
1336
+ "srvx/bun": "srvx/bun",
1337
+ "srvx/deno": "srvx/deno",
1338
+ "srvx/node": "srvx/node",
1339
+ "srvx/generic": "srvx/generic"
1340
+ }
1341
+ }, { name: "standard" });
1342
+ var preset_default$21 = [standard];
1343
+
1344
+ //#endregion
1345
+ //#region src/presets/stormkit/preset.ts
1346
+ const stormkit = defineNitroPreset({
1347
+ entry: "./stormkit/runtime/stormkit",
1348
+ output: {
1349
+ dir: "{{ rootDir }}/.stormkit",
1350
+ publicDir: "{{ rootDir }}/.stormkit/public/{{ baseURL }}"
1351
+ }
1352
+ }, {
1353
+ name: "stormkit",
1354
+ stdName: "stormkit"
1355
+ });
1356
+ var preset_default$22 = [stormkit];
1357
+
1358
+ //#endregion
1359
+ //#region src/presets/vercel/utils.ts
1360
+ const SUPPORTED_NODE_VERSIONS = [20, 22];
1361
+ const FALLBACK_ROUTE = "/__server";
1362
+ const ISR_SUFFIX = "-isr";
1363
+ const SAFE_FS_CHAR_RE = /[^a-zA-Z0-9_.[\]/]/g;
1364
+ function getSystemNodeVersion() {
1365
+ const systemNodeVersion = Number.parseInt(process.versions.node.split(".")[0]);
1366
+ return Number.isNaN(systemNodeVersion) ? 22 : systemNodeVersion;
1367
+ }
1368
+ async function generateFunctionFiles(nitro) {
1369
+ const o11Routes = getObservabilityRoutes(nitro);
1370
+ const buildConfigPath = resolve$1(nitro.options.output.dir, "config.json");
1371
+ const buildConfig = generateBuildConfig(nitro, o11Routes);
1372
+ await writeFile$1(buildConfigPath, JSON.stringify(buildConfig, null, 2));
1373
+ const functionConfigPath = resolve$1(nitro.options.output.serverDir, ".vc-config.json");
1374
+ const functionConfig = {
1375
+ handler: "index.mjs",
1376
+ launcherType: "Nodejs",
1377
+ shouldAddHelpers: false,
1378
+ supportsResponseStreaming: true,
1379
+ ...nitro.options.vercel?.functions
1380
+ };
1381
+ await writeFile$1(functionConfigPath, JSON.stringify(functionConfig, null, 2));
1382
+ for (const [key, value] of Object.entries(nitro.options.routeRules)) {
1383
+ if (!value.isr) continue;
1384
+ const funcPrefix = resolve$1(nitro.options.output.serverDir, "..", normalizeRouteDest(key) + ISR_SUFFIX);
1385
+ await fsp.mkdir(dirname$1(funcPrefix), { recursive: true });
1386
+ await fsp.symlink("./" + relative$1(dirname$1(funcPrefix), nitro.options.output.serverDir), funcPrefix + ".func", "junction");
1387
+ await writePrerenderConfig(funcPrefix + ".prerender-config.json", value.isr, nitro.options.vercel?.config?.bypassToken);
1388
+ }
1389
+ if (o11Routes.length === 0) return;
1390
+ const _getRouteRules = (path$1) => defu({}, ...nitro.routing.routeRules.matchAll("", path$1).reverse());
1391
+ for (const route of o11Routes) {
1392
+ if (_getRouteRules(route.src).isr) continue;
1393
+ const funcPrefix = resolve$1(nitro.options.output.serverDir, "..", route.dest);
1394
+ await fsp.mkdir(dirname$1(funcPrefix), { recursive: true });
1395
+ await fsp.symlink("./" + relative$1(dirname$1(funcPrefix), nitro.options.output.serverDir), funcPrefix + ".func", "junction");
1396
+ }
1397
+ }
1398
+ async function generateStaticFiles(nitro) {
1399
+ const buildConfigPath = resolve$1(nitro.options.output.dir, "config.json");
1400
+ const buildConfig = generateBuildConfig(nitro);
1401
+ await writeFile$1(buildConfigPath, JSON.stringify(buildConfig, null, 2));
1402
+ }
1403
+ function generateBuildConfig(nitro, o11Routes) {
1404
+ const rules = Object.entries(nitro.options.routeRules).sort((a$1, b) => b[0].split(/\/(?!\*)/).length - a$1[0].split(/\/(?!\*)/).length);
1405
+ const config = defu(nitro.options.vercel?.config, {
1406
+ version: 3,
1407
+ overrides: { ...Object.fromEntries((nitro._prerenderedRoutes?.filter((r) => r.fileName !== r.route) || []).map(({ route, fileName }) => [withoutLeadingSlash(fileName), { path: route.replace(/^\//, "") }])) },
1408
+ routes: [
1409
+ ...rules.filter(([_, routeRules]) => routeRules.redirect || routeRules.headers).map(([path$1, routeRules]) => {
1410
+ let route = { src: path$1.replace("/**", "/(.*)") };
1411
+ if (routeRules.redirect) route = defu(route, {
1412
+ status: routeRules.redirect.status,
1413
+ headers: { Location: routeRules.redirect.to.replace("/**", "/$1") }
1414
+ });
1415
+ if (routeRules.headers) route = defu(route, { headers: routeRules.headers });
1416
+ return route;
1417
+ }),
1418
+ ...nitro.options.publicAssets.filter((asset) => !asset.fallthrough).map((asset) => joinURL(nitro.options.baseURL, asset.baseURL || "/")).map((baseURL) => ({
1419
+ src: baseURL + "(.*)",
1420
+ headers: { "cache-control": "public,max-age=31536000,immutable" },
1421
+ continue: true
1422
+ })),
1423
+ { handle: "filesystem" }
1424
+ ]
1425
+ });
1426
+ if (nitro.options.static) return config;
1427
+ config.routes.push(...nitro.options.routeRules["/"]?.isr ? [{
1428
+ src: "(?<url>/)",
1429
+ dest: `/index${ISR_SUFFIX}?url=$url`
1430
+ }] : [], ...rules.filter(([key, value]) => value.isr !== void 0 && key !== "/").map(([key, value]) => {
1431
+ const src = key.replace(/^(.*)\/\*\*/, "(?<url>$1/.*)");
1432
+ if (value.isr === false) return {
1433
+ src,
1434
+ dest: FALLBACK_ROUTE
1435
+ };
1436
+ return {
1437
+ src,
1438
+ dest: withLeadingSlash(normalizeRouteDest(key) + ISR_SUFFIX + "?url=$url")
1439
+ };
1440
+ }), ...(o11Routes || []).map((route) => ({
1441
+ src: joinURL(nitro.options.baseURL, route.src),
1442
+ dest: withLeadingSlash(route.dest)
1443
+ })), ...nitro.options.routeRules["/**"]?.isr ? [] : [{
1444
+ src: "/(.*)",
1445
+ dest: FALLBACK_ROUTE
1446
+ }]);
1447
+ return config;
1448
+ }
1449
+ function deprecateSWR(nitro) {
1450
+ if (nitro.options.future.nativeSWR) return;
1451
+ let hasLegacyOptions = false;
1452
+ for (const [_key, value] of Object.entries(nitro.options.routeRules)) {
1453
+ if (_hasProp(value, "isr")) continue;
1454
+ if (value.cache === false) value.isr = false;
1455
+ if (_hasProp(value, "static")) {
1456
+ value.isr = !value.static;
1457
+ hasLegacyOptions = true;
1458
+ }
1459
+ if (value.cache && _hasProp(value.cache, "swr")) {
1460
+ value.isr = value.cache.swr;
1461
+ hasLegacyOptions = true;
1462
+ }
1463
+ }
1464
+ if (hasLegacyOptions && !a) nitro.logger.warn("Nitro now uses `isr` option to configure ISR behavior on Vercel. Backwards-compatible support for `static` and `swr` options within the Vercel Build Options API will be removed in the future versions. Set `future.nativeSWR: true` nitro config disable this warning.");
1465
+ }
1466
+ async function resolveVercelRuntime(nitro) {
1467
+ let runtime = nitro.options.vercel?.functions?.runtime;
1468
+ if (runtime) return runtime;
1469
+ if ((await readVercelConfig(nitro.options.rootDir)).bunVersion || "Bun" in globalThis) runtime = "bun1.x";
1470
+ else {
1471
+ const systemNodeVersion = getSystemNodeVersion();
1472
+ runtime = `nodejs${SUPPORTED_NODE_VERSIONS.find((version$1) => version$1 >= systemNodeVersion) ?? SUPPORTED_NODE_VERSIONS.at(-1)}.x`;
1473
+ }
1474
+ nitro.options.vercel ??= {};
1475
+ nitro.options.vercel.functions ??= {};
1476
+ nitro.options.vercel.functions.runtime = runtime;
1477
+ return runtime;
1478
+ }
1479
+ async function readVercelConfig(rootDir) {
1480
+ const vercelConfigPath = resolve$1(rootDir, "vercel.json");
1481
+ return await fsp.readFile(vercelConfigPath).then((config) => JSON.parse(config.toString())).catch(() => ({}));
1482
+ }
1483
+ function _hasProp(obj, prop) {
1484
+ return obj && typeof obj === "object" && prop in obj;
1485
+ }
1486
+ function getObservabilityRoutes(nitro) {
1487
+ if ((nitro.options.compatibilityDate.vercel || nitro.options.compatibilityDate.default) < "2025-07-15") return [];
1488
+ const routePatterns = [...new Set([...nitro.options.ssrRoutes || [], ...[...nitro.scannedHandlers, ...nitro.options.handlers].filter((h$1) => !h$1.middleware && h$1.route).map((h$1) => h$1.route)])];
1489
+ const staticRoutes = [];
1490
+ const dynamicRoutes = [];
1491
+ const catchAllRoutes = [];
1492
+ for (const route of routePatterns) if (route.includes("**")) catchAllRoutes.push(route);
1493
+ else if (route.includes(":") || route.includes("*")) dynamicRoutes.push(route);
1494
+ else staticRoutes.push(route);
1495
+ return [
1496
+ ...normalizeRoutes(staticRoutes),
1497
+ ...normalizeRoutes(dynamicRoutes),
1498
+ ...normalizeRoutes(catchAllRoutes)
1499
+ ];
1500
+ }
1501
+ function normalizeRoutes(routes) {
1502
+ return routes.sort((a$1, b) => b.localeCompare(a$1)).map((route) => ({
1503
+ src: normalizeRouteSrc(route),
1504
+ dest: normalizeRouteDest(route)
1505
+ }));
1506
+ }
1507
+ function normalizeRouteSrc(route) {
1508
+ let idCtr = 0;
1509
+ return route.split("/").map((segment) => {
1510
+ if (segment.startsWith("**")) return segment === "**" ? "(?:.*)" : `?(?<${namedGroup(segment.slice(3))}>.+)`;
1511
+ if (segment === "*") return `(?<_${idCtr++}>[^/]*)`;
1512
+ if (segment.includes(":")) return segment.replace(/:(\w+)/g, (_, id) => `(?<${namedGroup(id)}>[^/]+)`).replace(/\./g, String.raw`\.`);
1513
+ return segment;
1514
+ }).join("/");
1515
+ }
1516
+ function namedGroup(input = "") {
1517
+ if (/\d/.test(input[0])) input = `_${input}`;
1518
+ return input.replace(/[^a-zA-Z0-9_]/g, "") || "_";
1519
+ }
1520
+ function normalizeRouteDest(route) {
1521
+ return route.split("/").slice(1).map((segment) => {
1522
+ if (segment.startsWith("**")) return `[...${segment.replace(/[*:]/g, "")}]`;
1523
+ if (segment === "*") return "[-]";
1524
+ if (segment.startsWith(":")) return `[${segment.slice(1)}]`;
1525
+ if (segment.includes(":")) return `[${segment.replace(/:/g, "_")}]`;
1526
+ return segment;
1527
+ }).map((segment) => segment.replace(SAFE_FS_CHAR_RE, "-")).join("/") || "index";
1528
+ }
1529
+ async function writePrerenderConfig(filename, isrConfig, bypassToken) {
1530
+ if (typeof isrConfig === "number") isrConfig = { expiration: isrConfig };
1531
+ else if (isrConfig === true) isrConfig = { expiration: false };
1532
+ else isrConfig = { ...isrConfig };
1533
+ const prerenderConfig = {
1534
+ expiration: isrConfig.expiration ?? false,
1535
+ bypassToken,
1536
+ ...isrConfig
1537
+ };
1538
+ await writeFile$1(filename, JSON.stringify(prerenderConfig, null, 2));
1539
+ }
1540
+
1541
+ //#endregion
1542
+ //#region src/presets/vercel/preset.ts
1543
+ const vercel = defineNitroPreset({
1544
+ entry: "./vercel/runtime/vercel.{format}",
1545
+ output: {
1546
+ dir: "{{ rootDir }}/.vercel/output",
1547
+ serverDir: "{{ output.dir }}/functions/__server.func",
1548
+ publicDir: "{{ output.dir }}/static/{{ baseURL }}"
1549
+ },
1550
+ commands: {
1551
+ preview: "",
1552
+ deploy: "npx vercel deploy --prebuilt"
1553
+ },
1554
+ hooks: {
1555
+ "build:before": async (nitro) => {
1556
+ const logger = nitro.logger.withTag("vercel");
1557
+ const runtime = await resolveVercelRuntime(nitro);
1558
+ if (runtime.startsWith("bun") && !nitro.options.exportConditions.includes("bun")) nitro.options.exportConditions.push("bun");
1559
+ logger.info(`Using \`${runtime}\` runtime.`);
1560
+ let serverFormat = nitro.options.vercel?.entryFormat;
1561
+ if (!serverFormat) serverFormat = nitro.routing.routes.routes.flatMap((r) => r.data).some((h$1) => h$1.format === "node") ? "node" : "web";
1562
+ logger.info(`Using \`${serverFormat}\` entry format.`);
1563
+ nitro.options.entry = nitro.options.entry.replace("{format}", serverFormat);
1564
+ },
1565
+ "rollup:before": (nitro) => {
1566
+ deprecateSWR(nitro);
1567
+ },
1568
+ async compiled(nitro) {
1569
+ await generateFunctionFiles(nitro);
1570
+ }
1571
+ }
1572
+ }, {
1573
+ name: "vercel",
1574
+ stdName: "vercel"
1575
+ });
1576
+ const vercelStatic = defineNitroPreset({
1577
+ extends: "static",
1578
+ output: {
1579
+ dir: "{{ rootDir }}/.vercel/output",
1580
+ publicDir: "{{ output.dir }}/static/{{ baseURL }}"
1581
+ },
1582
+ commands: { preview: "npx serve ./static" },
1583
+ hooks: {
1584
+ "rollup:before": (nitro) => {
1585
+ deprecateSWR(nitro);
1586
+ },
1587
+ async compiled(nitro) {
1588
+ await generateStaticFiles(nitro);
1589
+ }
1590
+ }
1591
+ }, {
1592
+ name: "vercel-static",
1593
+ stdName: "vercel",
1594
+ static: true
1595
+ });
1596
+ var preset_default$23 = [vercel, vercelStatic];
1597
+
1598
+ //#endregion
1599
+ //#region src/presets/winterjs/preset.ts
1600
+ const winterjs = defineNitroPreset({
1601
+ extends: "base-worker",
1602
+ entry: "./winterjs/runtime/winterjs",
1603
+ minify: false,
1604
+ serveStatic: "inline",
1605
+ wasm: { lazy: true },
1606
+ commands: { preview: "wasmer run wasmer/winterjs --forward-host-env --net --mapdir app:./ app/server/index.mjs" }
1607
+ }, { name: "winterjs" });
1608
+ var preset_default$24 = [winterjs];
1609
+
1610
+ //#endregion
1611
+ //#region src/presets/zeabur/preset.ts
1612
+ const zeabur = defineNitroPreset({
1613
+ entry: "./zeabur/runtime/zeabur",
1614
+ output: {
1615
+ dir: "{{ rootDir }}/.zeabur/output",
1616
+ serverDir: "{{ output.dir }}/functions/__nitro.func",
1617
+ publicDir: "{{ output.dir }}/static"
1618
+ },
1619
+ hooks: { async compiled(nitro) {
1620
+ await writeFile$1(resolve$1(nitro.options.output.dir, "config.json"), JSON.stringify({
1621
+ containerized: false,
1622
+ routes: [{
1623
+ src: ".*",
1624
+ dest: "/__nitro"
1625
+ }]
1626
+ }, null, 2));
1627
+ for (const [key, value] of Object.entries(nitro.options.routeRules)) {
1628
+ if (!value.isr) continue;
1629
+ const funcPrefix = resolve$1(nitro.options.output.serverDir, ".." + key);
1630
+ await fsp.mkdir(dirname$1(funcPrefix), { recursive: true });
1631
+ await fsp.symlink("./" + relative$1(dirname$1(funcPrefix), nitro.options.output.serverDir), funcPrefix + ".func", "junction");
1632
+ await writeFile$1(funcPrefix + ".prerender-config.json", JSON.stringify({ type: "Prerender" }));
1633
+ }
1634
+ } }
1635
+ }, {
1636
+ name: "zeabur",
1637
+ stdName: "zeabur"
1638
+ });
1639
+ const zeaburStatic = defineNitroPreset({
1640
+ extends: "static",
1641
+ output: {
1642
+ dir: "{{ rootDir }}/.zeabur/output",
1643
+ publicDir: "{{ output.dir }}/static"
1644
+ },
1645
+ commands: { preview: "npx serve ./static" }
1646
+ }, {
1647
+ name: "zeabur-static",
1648
+ static: true
1649
+ });
1650
+ var preset_default$25 = [zeabur, zeaburStatic];
1651
+
1652
+ //#endregion
1653
+ //#region src/presets/zerops/preset.ts
1654
+ const zerops = defineNitroPreset({
1655
+ extends: "node-server",
1656
+ serveStatic: true
1657
+ }, { name: "zerops" });
1658
+ const zeropsStatic = defineNitroPreset({
1659
+ extends: "static",
1660
+ output: {
1661
+ dir: "{{ rootDir }}/.zerops/output",
1662
+ publicDir: "{{ output.dir }}/static"
1663
+ }
1664
+ }, {
1665
+ name: "zerops-static",
1666
+ static: true
1667
+ });
1668
+ var preset_default$26 = [zerops, zeropsStatic];
1669
+
1670
+ //#endregion
1671
+ //#region src/presets/_all.gen.ts
1672
+ var _all_gen_default = [
1673
+ ...preset_default,
1674
+ ...preset_default$1,
1675
+ ...preset_default$2,
1676
+ ...preset_default$3,
1677
+ ...preset_default$4,
1678
+ ...preset_default$5,
1679
+ ...preset_default$6,
1680
+ ...preset_default$7,
1681
+ ...preset_default$8,
1682
+ ...preset_default$9,
1683
+ ...preset_default$10,
1684
+ ...preset_default$11,
1685
+ ...preset_default$12,
1686
+ ...preset_default$13,
1687
+ ...preset_default$14,
1688
+ ...preset_default$15,
1689
+ ...preset_default$16,
1690
+ ...preset_default$17,
1691
+ ...preset_default$18,
1692
+ ...preset_default$19,
1693
+ ...preset_default$20,
1694
+ ...preset_default$21,
1695
+ ...preset_default$22,
1696
+ ...preset_default$23,
1697
+ ...preset_default$24,
1698
+ ...preset_default$25,
1699
+ ...preset_default$26
1700
+ ];
1701
+
1702
+ //#endregion
1703
+ //#region src/presets/_resolve.ts
1704
+ const _stdProviderMap = {
1705
+ aws_amplify: "aws",
1706
+ azure_static: "azure",
1707
+ cloudflare_pages: "cloudflare"
1708
+ };
1709
+ async function resolvePreset(name, opts = {}) {
1710
+ if (name === ".") return;
1711
+ const _name = kebabCase(name) || p;
1712
+ const _compatDates = opts.compatibilityDate ? resolveCompatibilityDatesFromEnv(opts.compatibilityDate) : false;
1713
+ const matches = _all_gen_default.filter((preset$1) => {
1714
+ if (![
1715
+ preset$1._meta.name,
1716
+ preset$1._meta.stdName,
1717
+ ...preset$1._meta.aliases || []
1718
+ ].filter(Boolean).includes(_name)) return false;
1719
+ if (opts.dev && !preset$1._meta.dev || !opts.dev && preset$1._meta.dev) return false;
1720
+ if (_compatDates) {
1721
+ const _date = _compatDates[_stdProviderMap[preset$1._meta.stdName]] || _compatDates[preset$1._meta.stdName] || _compatDates[preset$1._meta.name] || _compatDates.default;
1722
+ if (_date && preset$1._meta.compatibilityDate && new Date(preset$1._meta.compatibilityDate) > new Date(_date)) return false;
1723
+ }
1724
+ return true;
1725
+ }).sort((a$1, b) => {
1726
+ const aDate = new Date(a$1._meta.compatibilityDate || 0);
1727
+ return new Date(b._meta.compatibilityDate || 0) > aDate ? 1 : -1;
1728
+ });
1729
+ const preset = matches.find((p$1) => (p$1._meta.static || false) === (opts?.static || false)) || matches[0];
1730
+ if (typeof preset === "function") return preset();
1731
+ if (!name && !preset) {
1732
+ if (opts?.static) return resolvePreset("static", opts);
1733
+ return resolvePreset({
1734
+ deno: "deno",
1735
+ bun: "bun"
1736
+ }[K] || "node", opts);
1737
+ }
1738
+ if (name && !preset) {
1739
+ const options = _all_gen_default.filter((p$1) => p$1._meta.name === name || p$1._meta.stdName === name || p$1._meta.aliases?.includes(name)).sort((a$1, b) => (a$1._meta.compatibilityDate || 0) > (b._meta.compatibilityDate || 0) ? 1 : -1);
1740
+ if (options.length > 0) {
1741
+ let msg = `Preset "${name}" cannot be resolved with current compatibilityDate: ${formatCompatibilityDate(_compatDates || "")}.\n\n`;
1742
+ for (const option of options) msg += `\n- ${option._meta.name} (requires compatibilityDate >= ${option._meta.compatibilityDate})`;
1743
+ const err = new Error(msg);
1744
+ Error.captureStackTrace?.(err, resolvePreset);
1745
+ throw err;
1746
+ }
1747
+ }
1748
+ return preset;
1749
+ }
1750
+
1751
+ //#endregion
1752
+ export { resolvePreset };