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