nitro-nightly 3.0.0-beta-28969273.f7aa9de6 → 4.0.0-20251010-091516-7cafddba

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 (417) hide show
  1. package/README.md +8 -39
  2. package/dist/_chunks/app.mjs +19797 -0
  3. package/dist/_chunks/build.mjs +84 -0
  4. package/dist/_chunks/build2.mjs +318 -0
  5. package/dist/_chunks/build3.mjs +6452 -0
  6. package/dist/_chunks/detect-acorn.mjs +503 -0
  7. package/dist/_chunks/index.mjs +22242 -0
  8. package/dist/_chunks/index2.mjs +297 -0
  9. package/dist/_chunks/index3.mjs +1058 -0
  10. package/dist/_chunks/index4.mjs +1206 -0
  11. package/dist/_chunks/info.mjs +11157 -0
  12. package/dist/_chunks/json5.mjs +68 -0
  13. package/dist/_chunks/jsonc.mjs +51 -0
  14. package/dist/_chunks/pathe.M-eThtNZ.mjs +204 -0
  15. package/dist/_chunks/plugin.mjs +960 -0
  16. package/dist/_chunks/server.mjs +254 -0
  17. package/dist/_chunks/snapshot.mjs +284 -0
  18. package/dist/_chunks/toml.mjs +259 -0
  19. package/dist/_chunks/yaml.mjs +86 -0
  20. package/dist/cli/build.mjs +10 -3
  21. package/dist/cli/dev.mjs +41 -9
  22. package/dist/cli/index.mjs +460 -1
  23. package/dist/cli/index2.mjs +4 -1
  24. package/dist/cli/list.mjs +10 -4
  25. package/dist/cli/prepare.mjs +6 -3
  26. package/dist/cli/run.mjs +7 -4
  27. package/dist/index.d.mts +52 -0
  28. package/dist/index.mjs +55 -0
  29. package/dist/node_modules/@poppinss/colors/build/index.js +169 -0
  30. package/dist/node_modules/@poppinss/colors/package.json +116 -0
  31. package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
  32. package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
  33. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +717 -0
  34. package/dist/node_modules/@poppinss/dumper/package.json +122 -0
  35. package/dist/node_modules/@poppinss/exception/build/index.js +63 -0
  36. package/dist/node_modules/@poppinss/exception/package.json +106 -0
  37. package/dist/node_modules/@sindresorhus/is/distribution/index.js +1313 -0
  38. package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
  39. package/dist/node_modules/@sindresorhus/is/package.json +81 -0
  40. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
  41. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
  42. package/dist/node_modules/@speed-highlight/core/package.json +90 -0
  43. package/dist/node_modules/cookie/dist/index.js +239 -0
  44. package/dist/node_modules/cookie/package.json +42 -0
  45. package/dist/node_modules/croner/dist/croner.js +1 -0
  46. package/dist/node_modules/croner/package.json +63 -0
  47. package/dist/node_modules/defu/dist/defu.mjs +69 -0
  48. package/dist/node_modules/defu/package.json +43 -0
  49. package/dist/node_modules/destr/dist/index.mjs +72 -0
  50. package/dist/node_modules/destr/package.json +47 -0
  51. package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
  52. package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
  53. package/dist/node_modules/error-stack-parser-es/package.json +83 -0
  54. package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
  55. package/dist/node_modules/get-port-please/package.json +39 -0
  56. package/dist/node_modules/hookable/dist/index.mjs +290 -0
  57. package/dist/node_modules/hookable/package.json +49 -0
  58. package/dist/node_modules/kleur/index.js +110 -0
  59. package/dist/node_modules/kleur/index.mjs +110 -0
  60. package/dist/node_modules/kleur/package.json +51 -0
  61. package/dist/node_modules/klona/dist/index.mjs +81 -0
  62. package/dist/node_modules/klona/full/index.mjs +53 -0
  63. package/dist/node_modules/klona/package.json +74 -0
  64. package/dist/node_modules/scule/dist/index.mjs +80 -0
  65. package/dist/node_modules/scule/package.json +43 -0
  66. package/dist/node_modules/source-map/lib/array-set.js +100 -0
  67. package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
  68. package/dist/node_modules/source-map/lib/base64.js +19 -0
  69. package/dist/node_modules/source-map/lib/binary-search.js +113 -0
  70. package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
  71. package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
  72. package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
  73. package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
  74. package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
  75. package/dist/node_modules/source-map/lib/source-node.js +430 -0
  76. package/dist/node_modules/source-map/lib/url.js +13 -0
  77. package/dist/node_modules/source-map/lib/util.js +444 -0
  78. package/dist/node_modules/source-map/lib/wasm.js +138 -0
  79. package/dist/node_modules/source-map/package.json +79 -0
  80. package/dist/node_modules/source-map/source-map.js +10 -0
  81. package/dist/node_modules/std-env/dist/index.mjs +1 -0
  82. package/dist/node_modules/std-env/package.json +46 -0
  83. package/dist/node_modules/supports-color/index.js +202 -0
  84. package/dist/node_modules/supports-color/package.json +64 -0
  85. package/dist/node_modules/ufo/dist/index.mjs +638 -0
  86. package/dist/node_modules/ufo/package.json +47 -0
  87. package/dist/node_modules/unctx/dist/index.mjs +131 -0
  88. package/dist/node_modules/unctx/package.json +67 -0
  89. package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +42 -0
  90. package/dist/node_modules/youch/build/chunk-4XB2BYKC.js +85 -0
  91. package/dist/node_modules/youch/build/chunk-4YEN7HVQ.js +61 -0
  92. package/dist/node_modules/youch/build/chunk-EUJBVOYB.js +83 -0
  93. package/dist/node_modules/youch/build/chunk-HFSXRSKS.js +85 -0
  94. package/dist/node_modules/youch/build/chunk-JAN2TFI2.js +222 -0
  95. package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +6 -0
  96. package/dist/node_modules/youch/build/chunk-PINJDICN.js +72 -0
  97. package/dist/node_modules/youch/build/chunk-PUHGL6HA.js +41 -0
  98. package/dist/node_modules/youch/build/chunk-VE4LENUR.js +45 -0
  99. package/dist/node_modules/youch/build/index.js +352 -0
  100. package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
  101. package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
  102. package/dist/node_modules/youch/build/public/error_info/style.css +144 -0
  103. package/dist/node_modules/youch/build/public/error_stack/script.js +74 -0
  104. package/dist/node_modules/youch/build/public/error_stack/style.css +220 -0
  105. package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
  106. package/dist/node_modules/youch/build/public/header/script.js +16 -0
  107. package/dist/node_modules/youch/build/public/header/style.css +56 -0
  108. package/dist/node_modules/youch/build/public/layout/script.js +20 -0
  109. package/dist/node_modules/youch/build/public/layout/style.css +431 -0
  110. package/dist/node_modules/youch/package.json +133 -0
  111. package/dist/node_modules/youch-core/build/index.js +316 -0
  112. package/dist/node_modules/youch-core/package.json +124 -0
  113. package/dist/presets/_nitro/runtime/nitro-dev.mjs +48 -73
  114. package/dist/presets/_nitro/runtime/{nitro-prerenderer.d.ts → nitro-prerenderer.d.mts} +1 -1
  115. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +12 -1
  116. package/dist/presets/_nitro/runtime/service-worker.mjs +5 -15
  117. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +2 -2
  118. package/dist/presets/aws-lambda/runtime/_utils.d.mts +18 -0
  119. package/dist/presets/aws-lambda/runtime/_utils.mjs +102 -0
  120. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +3 -0
  121. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +12 -32
  122. package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +3 -0
  123. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +6 -38
  124. package/dist/{runtime/internal/utils.azure.d.ts → presets/azure/runtime/_utils.d.mts} +1 -1
  125. package/dist/{runtime/internal/utils.azure.mjs → presets/azure/runtime/_utils.mjs} +3 -4
  126. package/dist/presets/azure/runtime/azure-swa.mjs +11 -13
  127. package/dist/presets/bun/runtime/bun.mjs +13 -18
  128. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +13 -0
  129. package/dist/presets/cloudflare/runtime/_module-handler.mjs +93 -0
  130. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +19 -0
  131. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +74 -0
  132. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +9 -0
  133. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +13 -97
  134. package/dist/presets/cloudflare/runtime/{cloudflare-pages.d.ts → cloudflare-pages.d.mts} +1 -1
  135. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +19 -27
  136. package/dist/{runtime/internal/timing.d.ts → presets/cloudflare/runtime/plugin.dev.d.mts} +1 -0
  137. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +89 -0
  138. package/dist/presets/deno/runtime/deno-deploy.mjs +11 -25
  139. package/dist/presets/deno/runtime/deno-server.d.mts +6 -0
  140. package/dist/presets/deno/runtime/deno-server.mjs +15 -21
  141. package/dist/presets/netlify/runtime/netlify-edge.d.mts +3 -0
  142. package/dist/presets/netlify/runtime/netlify-edge.mjs +8 -16
  143. package/dist/presets/netlify/runtime/netlify.mjs +16 -45
  144. package/dist/presets/node/runtime/{cluster.mjs → node-cluster.mjs} +1 -3
  145. package/dist/presets/node/runtime/node-middleware.d.mts +4 -0
  146. package/dist/presets/node/runtime/{node-listener.mjs → node-middleware.mjs} +3 -4
  147. package/dist/presets/node/runtime/node-server.mjs +3 -4
  148. package/dist/presets/standard/runtime/server.d.mts +5 -0
  149. package/dist/presets/standard/runtime/server.mjs +6 -0
  150. package/dist/presets/stormkit/runtime/stormkit.mjs +8 -12
  151. package/dist/presets/vercel/runtime/vercel.d.mts +8 -0
  152. package/dist/presets/vercel/runtime/vercel.mjs +11 -11
  153. package/dist/presets/winterjs/runtime/winterjs.mjs +22 -4
  154. package/dist/presets/{node/runtime/node-server.d.ts → zeabur/runtime/zeabur.d.mts} +1 -1
  155. package/dist/presets/zeabur/runtime/zeabur.mjs +2 -6
  156. package/dist/presets.mjs +2460 -0
  157. package/dist/runtime/index.d.mts +11 -0
  158. package/dist/runtime/index.mjs +8 -8
  159. package/dist/runtime/internal/app.d.mts +2 -0
  160. package/dist/runtime/internal/app.mjs +129 -128
  161. package/dist/runtime/internal/cache.d.mts +7 -0
  162. package/dist/runtime/internal/cache.mjs +82 -175
  163. package/dist/runtime/internal/{context.d.ts → context.d.mts} +3 -3
  164. package/dist/runtime/internal/context.mjs +6 -6
  165. package/dist/runtime/internal/error/dev.d.mts +9 -0
  166. package/dist/runtime/internal/error/dev.mjs +122 -0
  167. package/dist/runtime/internal/error/prod.d.mts +8 -0
  168. package/dist/runtime/internal/error/prod.mjs +62 -0
  169. package/dist/runtime/internal/error/utils.d.mts +8 -0
  170. package/dist/runtime/internal/error/utils.mjs +3 -0
  171. package/dist/runtime/internal/index.d.mts +3 -0
  172. package/dist/runtime/internal/index.mjs +1 -14
  173. package/dist/runtime/internal/renderer.d.mts +3 -0
  174. package/dist/runtime/internal/renderer.mjs +29 -33
  175. package/dist/runtime/internal/route-rules.d.mts +8 -0
  176. package/dist/runtime/internal/route-rules.mjs +58 -63
  177. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
  178. package/dist/runtime/internal/routes/dev-tasks.mjs +23 -0
  179. package/dist/runtime/internal/routes/openapi.d.mts +3 -0
  180. package/dist/runtime/internal/routes/openapi.mjs +24 -9
  181. package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
  182. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
  183. package/dist/runtime/internal/routes/renderer-template.dev.mjs +21 -0
  184. package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
  185. package/dist/runtime/internal/routes/scalar.d.mts +3 -0
  186. package/dist/runtime/internal/routes/scalar.mjs +7 -4
  187. package/dist/runtime/internal/routes/swagger.d.mts +3 -0
  188. package/dist/runtime/internal/routes/swagger.mjs +5 -4
  189. package/dist/runtime/internal/{utils.env.d.ts → runtime-config.d.mts} +4 -2
  190. package/dist/runtime/internal/{utils.env.mjs → runtime-config.mjs} +16 -6
  191. package/dist/runtime/internal/static.d.mts +3 -0
  192. package/dist/runtime/internal/static.mjs +24 -36
  193. package/dist/runtime/internal/storage.mjs +2 -1
  194. package/dist/runtime/internal/task.mjs +6 -6
  195. package/dist/runtime/internal/utils.d.mts +1 -0
  196. package/dist/runtime/internal/utils.mjs +1 -116
  197. package/dist/runtime/internal/vite/dev-entry.d.mts +1 -0
  198. package/dist/runtime/internal/vite/dev-entry.mjs +6 -0
  199. package/dist/runtime/internal/vite/dev-worker.mjs +362 -0
  200. package/dist/runtime/internal/vite/prod-setup.d.mts +4 -0
  201. package/dist/runtime/internal/vite/prod-setup.mjs +55 -0
  202. package/dist/runtime/internal/vite/ssr-renderer.d.mts +4 -0
  203. package/dist/runtime/internal/vite/ssr-renderer.mjs +4 -0
  204. package/dist/types/index.d.mts +2688 -138
  205. package/dist/vite.d.mts +59 -0
  206. package/dist/vite.mjs +68 -0
  207. package/lib/config.d.mts +9 -0
  208. package/lib/deps/h3.d.mts +1 -0
  209. package/lib/deps/h3.mjs +1 -0
  210. package/lib/deps/ofetch.mjs +1 -0
  211. package/lib/deps/ofetch.mts +1 -0
  212. package/lib/meta.d.mts +5 -0
  213. package/lib/meta.mjs +21 -0
  214. package/{runtime-meta.d.ts → lib/runtime-meta.d.mts} +1 -0
  215. package/{runtime-meta.mjs → lib/runtime-meta.mjs} +12 -4
  216. package/package.json +142 -160
  217. package/cli.d.ts +0 -1
  218. package/config.d.ts +0 -1
  219. package/core.d.ts +0 -1
  220. package/dist/cli/index.d.ts +0 -1
  221. package/dist/config/index.d.mts +0 -6
  222. package/dist/config/index.d.ts +0 -6
  223. package/dist/core/index.d.mts +0 -30
  224. package/dist/core/index.d.ts +0 -30
  225. package/dist/core/index.mjs +0 -2456
  226. package/dist/kit/index.d.mts +0 -44
  227. package/dist/kit/index.d.ts +0 -44
  228. package/dist/kit/index.mjs +0 -71
  229. package/dist/meta/index.d.mts +0 -3
  230. package/dist/meta/index.d.ts +0 -3
  231. package/dist/meta/index.mjs +0 -3
  232. package/dist/presets/_all.gen.d.ts +0 -2
  233. package/dist/presets/_all.gen.mjs +0 -52
  234. package/dist/presets/_nitro/base-worker.d.ts +0 -2
  235. package/dist/presets/_nitro/base-worker.mjs +0 -25
  236. package/dist/presets/_nitro/nitro-dev.d.ts +0 -2
  237. package/dist/presets/_nitro/nitro-dev.mjs +0 -19
  238. package/dist/presets/_nitro/nitro-prerender.d.ts +0 -2
  239. package/dist/presets/_nitro/nitro-prerender.mjs +0 -17
  240. package/dist/presets/_nitro/preset.d.ts +0 -2
  241. package/dist/presets/_nitro/preset.mjs +0 -5
  242. package/dist/presets/_nitro/service-worker.d.ts +0 -2
  243. package/dist/presets/_nitro/service-worker.mjs +0 -110
  244. package/dist/presets/_resolve.d.ts +0 -8
  245. package/dist/presets/_resolve.mjs +0 -44
  246. package/dist/presets/_static/preset.d.ts +0 -2
  247. package/dist/presets/_static/preset.mjs +0 -69
  248. package/dist/presets/_types.gen.d.ts +0 -16
  249. package/dist/presets/alwaysdata/preset.d.ts +0 -2
  250. package/dist/presets/alwaysdata/preset.mjs +0 -14
  251. package/dist/presets/aws-amplify/preset.d.ts +0 -3
  252. package/dist/presets/aws-amplify/preset.mjs +0 -27
  253. package/dist/presets/aws-amplify/types.d.ts +0 -141
  254. package/dist/presets/aws-amplify/utils.d.ts +0 -2
  255. package/dist/presets/aws-amplify/utils.mjs +0 -82
  256. package/dist/presets/aws-lambda/preset.d.ts +0 -2
  257. package/dist/presets/aws-lambda/preset.mjs +0 -21
  258. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.ts +0 -14
  259. package/dist/presets/aws-lambda/runtime/aws-lambda.d.ts +0 -4
  260. package/dist/presets/azure/preset.d.ts +0 -3
  261. package/dist/presets/azure/preset.mjs +0 -44
  262. package/dist/presets/azure/runtime/azure-functions.mjs +0 -24
  263. package/dist/presets/azure/runtime/azure-swa.d.ts +0 -5
  264. package/dist/presets/azure/types.d.ts +0 -13
  265. package/dist/presets/azure/types.mjs +0 -0
  266. package/dist/presets/azure/utils.d.ts +0 -3
  267. package/dist/presets/azure/utils.mjs +0 -183
  268. package/dist/presets/bun/preset.d.ts +0 -2
  269. package/dist/presets/bun/preset.mjs +0 -17
  270. package/dist/presets/cleavr/preset.d.ts +0 -2
  271. package/dist/presets/cleavr/preset.mjs +0 -12
  272. package/dist/presets/cloudflare/preset.d.ts +0 -3
  273. package/dist/presets/cloudflare/preset.mjs +0 -145
  274. package/dist/presets/cloudflare/runtime/cloudflare-module.d.ts +0 -13
  275. package/dist/presets/cloudflare/runtime/cloudflare-worker.mjs +0 -64
  276. package/dist/presets/cloudflare/types.d.ts +0 -89
  277. package/dist/presets/cloudflare/types.mjs +0 -0
  278. package/dist/presets/cloudflare/types.wrangler.d.ts +0 -974
  279. package/dist/presets/cloudflare/types.wrangler.mjs +0 -0
  280. package/dist/presets/cloudflare/utils.d.ts +0 -3
  281. package/dist/presets/cloudflare/utils.mjs +0 -163
  282. package/dist/presets/deno/preset.d.ts +0 -2
  283. package/dist/presets/deno/preset.mjs +0 -148
  284. package/dist/presets/deno/runtime/_deno-env-polyfill.d.ts +0 -0
  285. package/dist/presets/deno/runtime/_deno-env-polyfill.mjs +0 -1
  286. package/dist/presets/digitalocean/preset.d.ts +0 -2
  287. package/dist/presets/digitalocean/preset.mjs +0 -11
  288. package/dist/presets/edgio/preset.d.ts +0 -2
  289. package/dist/presets/edgio/preset.mjs +0 -95
  290. package/dist/presets/firebase/preset.d.ts +0 -3
  291. package/dist/presets/firebase/preset.mjs +0 -50
  292. package/dist/presets/firebase/runtime/firebase-gen-1.d.ts +0 -2
  293. package/dist/presets/firebase/runtime/firebase-gen-1.mjs +0 -7
  294. package/dist/presets/firebase/runtime/firebase-gen-2.d.ts +0 -2
  295. package/dist/presets/firebase/runtime/firebase-gen-2.mjs +0 -14
  296. package/dist/presets/firebase/runtime/firebase-gen-default.d.ts +0 -1
  297. package/dist/presets/firebase/runtime/firebase-gen-default.mjs +0 -1
  298. package/dist/presets/firebase/types.d.ts +0 -38
  299. package/dist/presets/firebase/types.mjs +0 -0
  300. package/dist/presets/firebase/utils.d.ts +0 -3
  301. package/dist/presets/firebase/utils.mjs +0 -50
  302. package/dist/presets/flightcontrol/preset.d.ts +0 -2
  303. package/dist/presets/flightcontrol/preset.mjs +0 -11
  304. package/dist/presets/heroku/preset.d.ts +0 -2
  305. package/dist/presets/heroku/preset.mjs +0 -11
  306. package/dist/presets/iis/preset.d.ts +0 -2
  307. package/dist/presets/iis/preset.mjs +0 -32
  308. package/dist/presets/iis/utils.d.ts +0 -3
  309. package/dist/presets/iis/utils.mjs +0 -161
  310. package/dist/presets/index.d.mts +0 -1
  311. package/dist/presets/index.d.ts +0 -2
  312. package/dist/presets/index.mjs +0 -1
  313. package/dist/presets/koyeb/preset.d.ts +0 -2
  314. package/dist/presets/koyeb/preset.mjs +0 -11
  315. package/dist/presets/netlify/legacy/preset.d.ts +0 -2
  316. package/dist/presets/netlify/legacy/preset.mjs +0 -143
  317. package/dist/presets/netlify/legacy/runtime/_deno-env-polyfill.d.ts +0 -0
  318. package/dist/presets/netlify/legacy/runtime/_deno-env-polyfill.mjs +0 -1
  319. package/dist/presets/netlify/legacy/runtime/netlify-builder.d.ts +0 -3
  320. package/dist/presets/netlify/legacy/runtime/netlify-builder.mjs +0 -5
  321. package/dist/presets/netlify/legacy/runtime/netlify-edge.d.ts +0 -2
  322. package/dist/presets/netlify/legacy/runtime/netlify-edge.mjs +0 -25
  323. package/dist/presets/netlify/legacy/runtime/netlify-lambda.d.ts +0 -3
  324. package/dist/presets/netlify/legacy/runtime/netlify-lambda.mjs +0 -38
  325. package/dist/presets/netlify/legacy/runtime/netlify.d.ts +0 -4
  326. package/dist/presets/netlify/legacy/runtime/netlify.mjs +0 -22
  327. package/dist/presets/netlify/legacy/utils.d.ts +0 -4
  328. package/dist/presets/netlify/legacy/utils.mjs +0 -113
  329. package/dist/presets/netlify/preset.d.ts +0 -3
  330. package/dist/presets/netlify/preset.mjs +0 -128
  331. package/dist/presets/netlify/runtime/_deno-env-polyfill.d.ts +0 -0
  332. package/dist/presets/netlify/runtime/_deno-env-polyfill.mjs +0 -1
  333. package/dist/presets/netlify/runtime/netlify-edge.d.ts +0 -2
  334. package/dist/presets/netlify/types.d.ts +0 -12
  335. package/dist/presets/netlify/types.mjs +0 -0
  336. package/dist/presets/netlify/utils.d.ts +0 -5
  337. package/dist/presets/netlify/utils.mjs +0 -94
  338. package/dist/presets/node/preset.d.ts +0 -2
  339. package/dist/presets/node/preset.mjs +0 -49
  340. package/dist/presets/node/runtime/cli.d.ts +0 -1
  341. package/dist/presets/node/runtime/cli.mjs +0 -22
  342. package/dist/presets/node/runtime/node-listener.d.ts +0 -6
  343. package/dist/presets/platform.sh/preset.d.ts +0 -2
  344. package/dist/presets/platform.sh/preset.mjs +0 -11
  345. package/dist/presets/render.com/preset.d.ts +0 -2
  346. package/dist/presets/render.com/preset.mjs +0 -11
  347. package/dist/presets/stormkit/preset.d.ts +0 -2
  348. package/dist/presets/stormkit/preset.mjs +0 -15
  349. package/dist/presets/vercel/preset.d.ts +0 -3
  350. package/dist/presets/vercel/preset.mjs +0 -104
  351. package/dist/presets/vercel/runtime/vercel-edge.d.ts +0 -2
  352. package/dist/presets/vercel/runtime/vercel-edge.mjs +0 -22
  353. package/dist/presets/vercel/runtime/vercel.d.ts +0 -4
  354. package/dist/presets/vercel/types.d.ts +0 -78
  355. package/dist/presets/vercel/types.mjs +0 -0
  356. package/dist/presets/vercel/utils.d.ts +0 -5
  357. package/dist/presets/vercel/utils.mjs +0 -186
  358. package/dist/presets/winterjs/preset.d.ts +0 -2
  359. package/dist/presets/winterjs/preset.mjs +0 -20
  360. package/dist/presets/winterjs/runtime/winterjs.d.ts +0 -1
  361. package/dist/presets/zeabur/preset.d.ts +0 -2
  362. package/dist/presets/zeabur/preset.mjs +0 -70
  363. package/dist/presets/zeabur/runtime/zeabur.d.ts +0 -4
  364. package/dist/rollup/index.d.mts +0 -5
  365. package/dist/rollup/index.d.ts +0 -5
  366. package/dist/rollup/index.mjs +0 -1673
  367. package/dist/runtime/index.d.ts +0 -12
  368. package/dist/runtime/internal/app.d.ts +0 -3
  369. package/dist/runtime/internal/cache.d.ts +0 -8
  370. package/dist/runtime/internal/client.mjs +0 -4
  371. package/dist/runtime/internal/config.d.ts +0 -5
  372. package/dist/runtime/internal/config.mjs +0 -45
  373. package/dist/runtime/internal/error.d.ts +0 -4
  374. package/dist/runtime/internal/error.mjs +0 -73
  375. package/dist/runtime/internal/index.d.ts +0 -6
  376. package/dist/runtime/internal/renderer.d.ts +0 -2
  377. package/dist/runtime/internal/route-rules.d.ts +0 -14
  378. package/dist/runtime/internal/routes/openapi.d.ts +0 -3
  379. package/dist/runtime/internal/routes/scalar.d.ts +0 -2
  380. package/dist/runtime/internal/routes/swagger.d.ts +0 -2
  381. package/dist/runtime/internal/static.d.ts +0 -2
  382. package/dist/runtime/internal/timing.mjs +0 -29
  383. package/dist/runtime/internal/utils.d.ts +0 -21
  384. package/dist/runtime/internal/utils.lambda.d.ts +0 -10
  385. package/dist/runtime/internal/utils.lambda.mjs +0 -30
  386. package/dist/shared/nitro.bra5i6ER.d.mts +0 -620
  387. package/dist/shared/nitro.bra5i6ER.d.ts +0 -620
  388. package/dist/types/index.d.ts +0 -260
  389. package/kit.d.ts +0 -1
  390. package/meta.d.ts +0 -1
  391. package/presets.d.ts +0 -1
  392. package/rollup.d.ts +0 -1
  393. package/runtime.d.ts +0 -1
  394. package/types.d.ts +0 -1
  395. /package/dist/presets/_nitro/runtime/{nitro-dev.d.ts → nitro-dev.d.mts} +0 -0
  396. /package/dist/presets/_nitro/runtime/{service-worker.d.ts → service-worker.d.mts} +0 -0
  397. /package/dist/presets/aws-amplify/runtime/{aws-amplify.d.ts → aws-amplify.d.mts} +0 -0
  398. /package/dist/presets/azure/runtime/{azure-functions.d.ts → azure-swa.d.mts} +0 -0
  399. /package/dist/presets/bun/runtime/{bun.d.ts → bun.d.mts} +0 -0
  400. /package/dist/presets/{cloudflare/runtime/cloudflare-worker.d.ts → deno/runtime/deno-deploy.d.mts} +0 -0
  401. /package/dist/presets/netlify/runtime/{netlify.d.ts → netlify.d.mts} +0 -0
  402. /package/dist/presets/node/runtime/{cluster.d.ts → node-cluster.d.mts} +0 -0
  403. /package/dist/presets/{deno/runtime/deno-server.d.ts → node/runtime/node-server.d.mts} +0 -0
  404. /package/dist/presets/stormkit/runtime/{stormkit.d.ts → stormkit.d.mts} +0 -0
  405. /package/dist/presets/{deno/runtime/deno-deploy.d.ts → winterjs/runtime/winterjs.d.mts} +0 -0
  406. /package/dist/runtime/internal/{database.d.ts → database.d.mts} +0 -0
  407. /package/dist/runtime/internal/{debug.d.ts → debug.d.mts} +0 -0
  408. /package/dist/{presets/_types.gen.mjs → runtime/internal/empty.d.mts} +0 -0
  409. /package/dist/{presets/aws-amplify/types.mjs → runtime/internal/empty.mjs} +0 -0
  410. /package/dist/runtime/internal/lib/{http-graceful-shutdown.d.ts → http-graceful-shutdown.d.mts} +0 -0
  411. /package/dist/runtime/internal/{meta.d.ts → meta.d.mts} +0 -0
  412. /package/dist/runtime/internal/{plugin.d.ts → plugin.d.mts} +0 -0
  413. /package/dist/runtime/internal/{shutdown.d.ts → shutdown.d.mts} +0 -0
  414. /package/dist/runtime/internal/{storage.d.ts → storage.d.mts} +0 -0
  415. /package/dist/runtime/internal/{task.d.ts → task.d.mts} +0 -0
  416. /package/dist/runtime/internal/{client.d.ts → vite/dev-worker.d.mts} +0 -0
  417. /package/{dist/config/index.mjs → lib/config.mjs} +0 -0
@@ -0,0 +1,1058 @@
1
+ import { i as createNitro, k as addRoute, l as scanUnprefixedPublicAssets, m as compressPublicAssets, n as mime, w as writeFile, o as findAllRoutes, q as createRouter, t as genObjectKey, u as resolveNitroPath, v as toExports, r as resolveModulePath, x as parseNodeModulePath, y as lookupNodeModuleSubpath, z as isDirectory } from './index.mjs';
2
+ import { pathToFileURL } from 'node:url';
3
+ import { colors } from 'consola/utils';
4
+ import { defu } from 'defu';
5
+ import { parseURL, withTrailingSlash, withBase, joinURL, withoutBase } from 'ufo';
6
+ import { a as relative, r as resolve, j as join, c as normalizeWindowsPath, i as isAbsolute, d as dirname } from './pathe.M-eThtNZ.mjs';
7
+ import './server.mjs';
8
+ import { existsSync, promises } from 'node:fs';
9
+ import { runtimeDir } from 'nitro/runtime/meta';
10
+ import 'scule';
11
+
12
+ async function build(nitro) {
13
+ switch (nitro.options.builder) {
14
+ case "rollup": {
15
+ const { rollupBuild } = await import('./build3.mjs');
16
+ return rollupBuild(nitro);
17
+ }
18
+ case "rolldown": {
19
+ const { rolldownBuild } = await import('./build2.mjs');
20
+ return rolldownBuild(nitro);
21
+ }
22
+ case "vite": {
23
+ const { viteBuild } = await import('./build.mjs');
24
+ return viteBuild(nitro);
25
+ }
26
+ default: {
27
+ throw new Error(`Unknown builder: ${nitro.options.builder}`);
28
+ }
29
+ }
30
+ }
31
+
32
+ async function runParallel(inputs, cb, opts) {
33
+ const tasks = /* @__PURE__ */ new Set();
34
+ function queueNext() {
35
+ const route = inputs.values().next().value;
36
+ if (!route) {
37
+ return;
38
+ }
39
+ inputs.delete(route);
40
+ const task = (opts.interval ? new Promise((resolve) => setTimeout(resolve, opts.interval)) : Promise.resolve()).then(() => cb(route)).catch((error) => {
41
+ console.error(error);
42
+ });
43
+ tasks.add(task);
44
+ return task.then(() => {
45
+ tasks.delete(task);
46
+ if (inputs.size > 0) {
47
+ return refillQueue();
48
+ }
49
+ });
50
+ }
51
+ function refillQueue() {
52
+ const workers = Math.min(opts.concurrency - tasks.size, inputs.size);
53
+ return Promise.all(Array.from({ length: workers }, () => queueNext()));
54
+ }
55
+ await refillQueue();
56
+ }
57
+
58
+ var D=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),x=new Set(["script","style"]),o=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm,b=/[\@\.a-z0-9_\:\-]/i;function I(e){let t={};if(e){let i="none",r,n="",a,l;for(let c=0;c<e.length;c++){let d=e[c];i==="none"?b.test(d)?(r&&(t[r]=n,r=void 0,n=""),a=c,i="key"):d==="="&&r&&(i="value"):i==="key"?b.test(d)||(r=e.substring(a,c),d==="="?i="value":i="none"):d===l&&c>0&&e[c-1]!=="\\"?l&&(n=e.substring(a,c),l=void 0,i="none"):(d==='"'||d==="'")&&!l&&(a=c+1,l=d);}i==="key"&&a!=null&&a<e.length&&(r=e.substring(a,e.length)),r&&(t[r]=n);}return t}function P(e){let t=typeof e=="string"?e:e.value,i,r,n,a,l,c,d,m,s,u=[];o.lastIndex=0,r=i={type:0,children:[]};let g=0;function h(){a=t.substring(g,o.lastIndex-n[0].length),a&&r.children.push({type:2,value:a,parent:r});}for(;n=o.exec(t);){if(c=n[5]||n[8],d=n[6]||n[9],m=n[7]||n[10],x.has(r.name)&&n[2]!==r.name){l=o.lastIndex-n[0].length,r.children.length>0&&(r.children[0].value+=n[0]);continue}else if(c==="<!--"){if(l=o.lastIndex-n[0].length,x.has(r.name))continue;s={type:3,value:d,parent:r,loc:[{start:l,end:l+c.length},{start:o.lastIndex-m.length,end:o.lastIndex}]},u.push(s),s.parent.children.push(s);}else if(c==="<!")l=o.lastIndex-n[0].length,s={type:4,value:d,parent:r,loc:[{start:l,end:l+c.length},{start:o.lastIndex-m.length,end:o.lastIndex}]},u.push(s),s.parent.children.push(s);else if(n[1]!=="/")if(h(),x.has(r.name)){g=o.lastIndex,h();continue}else s={type:1,name:n[2]+"",attributes:I(n[3]),parent:r,children:[],loc:[{start:o.lastIndex-n[0].length,end:o.lastIndex}]},u.push(s),s.parent.children.push(s),n[4]&&n[4].indexOf("/")>-1||D.has(s.name)?(s.loc[1]=s.loc[0],s.isSelfClosingTag=true):r=s;else h(),n[2]+""===r.name?(s=r,r=s.parent,s.loc.push({start:o.lastIndex-n[0].length,end:o.lastIndex}),a=t.substring(s.loc[0].end,s.loc[1].start),s.children.length===0&&s.children.push({type:2,value:a,parent:r})):n[2]+""===u[u.length-1].name&&u[u.length-1].isSelfClosingTag===true&&(s=u[u.length-1],s.loc.push({start:o.lastIndex-n[0].length,end:o.lastIndex}));g=o.lastIndex;}return a=t.slice(g),r.children.push({type:2,value:a,parent:r}),i}var T=class{constructor(t){this.callback=t;}async visit(t,i,r){if(await this.callback(t,i,r),Array.isArray(t.children)){let n=[];for(let a=0;a<t.children.length;a++){let l=t.children[a];n.push(this.visit(l,t,a));}await Promise.all(n);}}};function z(e,t){return new T(t).visit(e)}
59
+
60
+ const allowedExtensions = /* @__PURE__ */ new Set(["", ".json"]);
61
+ const linkParents$1 = /* @__PURE__ */ new Map();
62
+ const HTML_ENTITIES = {
63
+ "&lt;": "<",
64
+ "&gt;": ">",
65
+ "&amp;": "&",
66
+ "&apos;": "'",
67
+ "&quot;": '"'
68
+ };
69
+ function escapeHtml(text) {
70
+ return text.replace(
71
+ /&(lt|gt|amp|apos|quot);/g,
72
+ (ch) => HTML_ENTITIES[ch] || ch
73
+ );
74
+ }
75
+ async function extractLinks(html, from, res, crawlLinks) {
76
+ const links = [];
77
+ const _links = [];
78
+ if (crawlLinks) {
79
+ await z(P(html), (node) => {
80
+ if (!node.attributes?.href) {
81
+ return;
82
+ }
83
+ const link = escapeHtml(node.attributes.href);
84
+ if (!decodeURIComponent(link).startsWith("#") && allowedExtensions.has(getExtension(link))) {
85
+ _links.push(link);
86
+ }
87
+ });
88
+ }
89
+ const header = res.headers.get("x-nitro-prerender") || "";
90
+ _links.push(...header.split(",").map((i) => decodeURIComponent(i.trim())));
91
+ for (const link of _links.filter(Boolean)) {
92
+ const _link = parseURL(link);
93
+ if (_link.protocol || _link.host) {
94
+ continue;
95
+ }
96
+ if (!_link.pathname.startsWith("/")) {
97
+ const fromURL = new URL(from, "http://localhost");
98
+ _link.pathname = new URL(_link.pathname, fromURL).pathname;
99
+ }
100
+ links.push(_link.pathname + _link.search);
101
+ }
102
+ for (const link of links) {
103
+ const _parents = linkParents$1.get(link);
104
+ if (_parents) {
105
+ _parents.add(from);
106
+ } else {
107
+ linkParents$1.set(link, /* @__PURE__ */ new Set([from]));
108
+ }
109
+ }
110
+ return links;
111
+ }
112
+ const EXT_REGEX = /\.[\da-z]+$/;
113
+ function getExtension(link) {
114
+ const pathname = parseURL(link).pathname;
115
+ return (pathname.match(EXT_REGEX) || [])[0] || "";
116
+ }
117
+ function formatPrerenderRoute(route) {
118
+ let str = ` \u251C\u2500 ${route.route} (${route.generateTimeMS}ms)`;
119
+ if (route.error) {
120
+ const parents = linkParents$1.get(route.route);
121
+ const errorColor = colors[route.error.status === 404 ? "yellow" : "red"];
122
+ const errorLead = parents?.size ? "\u251C\u2500\u2500" : "\u2514\u2500\u2500";
123
+ str += `
124
+ \u2502 ${errorLead} ${errorColor(route.error.message)}`;
125
+ if (parents?.size) {
126
+ str += `
127
+ ${[...parents.values()].map((link) => ` \u2502 \u2514\u2500\u2500 Linked from ${link}`).join("\n")}`;
128
+ }
129
+ }
130
+ if (route.skip) {
131
+ str += colors.gray(" (skipped)");
132
+ }
133
+ return colors.gray(str);
134
+ }
135
+ function matchesIgnorePattern(path, pattern) {
136
+ if (typeof pattern === "string") {
137
+ return path.startsWith(pattern);
138
+ }
139
+ if (typeof pattern === "function") {
140
+ return pattern(path) === true;
141
+ }
142
+ if (pattern instanceof RegExp) {
143
+ return pattern.test(path);
144
+ }
145
+ return false;
146
+ }
147
+
148
+ const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
149
+ const linkParents = /* @__PURE__ */ new Map();
150
+ async function prerender(nitro) {
151
+ if (nitro.options.noPublicDir) {
152
+ nitro.logger.warn(
153
+ "Skipping prerender since `noPublicDir` option is enabled."
154
+ );
155
+ return;
156
+ }
157
+ if (nitro.options.builder === "vite") {
158
+ nitro.logger.warn(
159
+ "Skipping prerender since not supported with vite builder yet..."
160
+ );
161
+ return;
162
+ }
163
+ const routes = new Set(nitro.options.prerender.routes);
164
+ const prerenderRulePaths = Object.entries(nitro.options.routeRules).filter(([path2, options]) => options.prerender && !path2.includes("*")).map((e) => e[0]);
165
+ for (const route of prerenderRulePaths) {
166
+ routes.add(route);
167
+ }
168
+ await nitro.hooks.callHook("prerender:routes", routes);
169
+ if (routes.size === 0) {
170
+ if (nitro.options.prerender.crawlLinks) {
171
+ routes.add("/");
172
+ } else {
173
+ return;
174
+ }
175
+ }
176
+ nitro.logger.info("Initializing prerenderer");
177
+ nitro._prerenderedRoutes = [];
178
+ nitro._prerenderMeta = nitro._prerenderMeta || {};
179
+ const prerendererConfig = {
180
+ ...nitro.options._config,
181
+ static: false,
182
+ rootDir: nitro.options.rootDir,
183
+ logLevel: 0,
184
+ preset: "nitro-prerender"
185
+ };
186
+ await nitro.hooks.callHook("prerender:config", prerendererConfig);
187
+ const nitroRenderer = await createNitro(prerendererConfig);
188
+ const prerenderStartTime = Date.now();
189
+ await nitro.hooks.callHook("prerender:init", nitroRenderer);
190
+ let path = relative(nitro.options.output.dir, nitro.options.output.publicDir);
191
+ if (!path.startsWith(".")) {
192
+ path = `./${path}`;
193
+ }
194
+ nitroRenderer.options.commands.preview = `npx serve ${path}`;
195
+ nitroRenderer.options.output.dir = nitro.options.output.dir;
196
+ await build(nitroRenderer);
197
+ const serverFilename = typeof nitroRenderer.options.rollupConfig?.output?.entryFileNames === "string" ? nitroRenderer.options.rollupConfig.output.entryFileNames : "index.mjs";
198
+ const serverEntrypoint = resolve(
199
+ nitroRenderer.options.output.serverDir,
200
+ serverFilename
201
+ );
202
+ const { closePrerenderer, appFetch } = await import(pathToFileURL(serverEntrypoint).href);
203
+ const routeRules = createRouter();
204
+ for (const [route, rules] of Object.entries(nitro.options.routeRules)) {
205
+ addRoute(routeRules, void 0, route, rules);
206
+ }
207
+ const _getRouteRules = (path2) => defu(
208
+ {},
209
+ ...findAllRoutes(routeRules, void 0, path2).map((r) => r.data).reverse()
210
+ );
211
+ const generatedRoutes = /* @__PURE__ */ new Set();
212
+ const failedRoutes = /* @__PURE__ */ new Set();
213
+ const skippedRoutes = /* @__PURE__ */ new Set();
214
+ const displayedLengthWarns = /* @__PURE__ */ new Set();
215
+ const publicAssetBases = nitro.options.publicAssets.filter(
216
+ (a) => !!a.baseURL && a.baseURL !== "/" && !a.fallthrough
217
+ ).map((a) => withTrailingSlash(a.baseURL));
218
+ const scannedPublicAssets = nitro.options.prerender.ignoreUnprefixedPublicAssets ? new Set(await scanUnprefixedPublicAssets(nitro)) : /* @__PURE__ */ new Set();
219
+ const canPrerender = (route = "/") => {
220
+ if (generatedRoutes.has(route) || skippedRoutes.has(route)) {
221
+ return false;
222
+ }
223
+ for (const pattern of nitro.options.prerender.ignore) {
224
+ if (matchesIgnorePattern(route, pattern)) {
225
+ return false;
226
+ }
227
+ }
228
+ if (publicAssetBases.some((base) => route.startsWith(base))) {
229
+ return false;
230
+ }
231
+ if (scannedPublicAssets.has(route)) {
232
+ return false;
233
+ }
234
+ if (_getRouteRules(route).prerender === false) {
235
+ return false;
236
+ }
237
+ return true;
238
+ };
239
+ const canWriteToDisk = (route) => {
240
+ if (route.route.includes("?")) {
241
+ return false;
242
+ }
243
+ const FS_MAX_SEGMENT = 255;
244
+ const FS_MAX_PATH = 1024;
245
+ const FS_MAX_PATH_PUBLIC_HTML = FS_MAX_PATH - (nitro.options.output.publicDir.length + 10);
246
+ if ((route.route.length >= FS_MAX_PATH_PUBLIC_HTML || route.route.split("/").some((s) => s.length > FS_MAX_SEGMENT)) && !displayedLengthWarns.has(route)) {
247
+ displayedLengthWarns.add(route);
248
+ const _route = route.route.slice(0, 60) + "...";
249
+ if (route.route.length >= FS_MAX_PATH_PUBLIC_HTML) {
250
+ nitro.logger.warn(
251
+ `Prerendering long route "${_route}" (${route.route.length}) can cause filesystem issues since it exceeds ${FS_MAX_PATH_PUBLIC_HTML}-character limit when writing to \`${nitro.options.output.publicDir}\`.`
252
+ );
253
+ } else {
254
+ nitro.logger.warn(
255
+ `Skipping prerender of the route "${_route}" since it exceeds the ${FS_MAX_SEGMENT}-character limit in one of the path segments and can cause filesystem issues.`
256
+ );
257
+ return false;
258
+ }
259
+ }
260
+ return true;
261
+ };
262
+ const generateRoute = async (route) => {
263
+ const start = Date.now();
264
+ route = decodeURI(route);
265
+ if (!canPrerender(route)) {
266
+ skippedRoutes.add(route);
267
+ return;
268
+ }
269
+ generatedRoutes.add(route);
270
+ const _route = { route };
271
+ const encodedRoute = encodeURI(route);
272
+ const res = await appFetch(withBase(encodedRoute, nitro.options.baseURL), {
273
+ headers: [["x-nitro-prerender", encodedRoute]]
274
+ // TODO
275
+ // retry: nitro.options.prerender.retry,
276
+ // retryDelay: nitro.options.prerender.retryDelay,
277
+ });
278
+ let dataBuff = Buffer.from(await res.arrayBuffer());
279
+ Object.defineProperty(_route, "contents", {
280
+ get: () => {
281
+ return dataBuff ? dataBuff.toString("utf8") : void 0;
282
+ },
283
+ set(value) {
284
+ if (dataBuff) {
285
+ dataBuff = Buffer.from(value);
286
+ }
287
+ }
288
+ });
289
+ Object.defineProperty(_route, "data", {
290
+ get: () => {
291
+ return dataBuff ? dataBuff.buffer : void 0;
292
+ },
293
+ set(value) {
294
+ if (dataBuff) {
295
+ dataBuff = Buffer.from(value);
296
+ }
297
+ }
298
+ });
299
+ const redirectCodes = [301, 302, 303, 304, 307, 308];
300
+ if (![200, ...redirectCodes].includes(res.status)) {
301
+ _route.error = new Error(`[${res.status}] ${res.statusText}`);
302
+ _route.error.status = res.status;
303
+ _route.error.statusText = res.statusText;
304
+ }
305
+ _route.generateTimeMS = Date.now() - start;
306
+ const contentType = res.headers.get("content-type") || "";
307
+ const isImplicitHTML = !route.endsWith(".html") && contentType.includes("html") && !JsonSigRx.test(dataBuff.subarray(0, 32).toString("utf8"));
308
+ const routeWithIndex = route.endsWith("/") ? route + "index" : route;
309
+ const htmlPath = route.endsWith("/") || nitro.options.prerender.autoSubfolderIndex ? joinURL(route, "index.html") : route + ".html";
310
+ _route.fileName = withoutBase(
311
+ isImplicitHTML ? htmlPath : routeWithIndex,
312
+ nitro.options.baseURL
313
+ );
314
+ const inferredContentType = mime.getType(_route.fileName) || "text/plain";
315
+ _route.contentType = contentType || inferredContentType;
316
+ await nitro.hooks.callHook("prerender:generate", _route, nitro);
317
+ if (_route.contentType !== inferredContentType) {
318
+ nitro._prerenderMeta[_route.fileName] ||= {};
319
+ nitro._prerenderMeta[_route.fileName].contentType = _route.contentType;
320
+ }
321
+ if (_route.error) {
322
+ failedRoutes.add(_route);
323
+ }
324
+ if (_route.skip || _route.error) {
325
+ await nitro.hooks.callHook("prerender:route", _route);
326
+ nitro.logger.log(formatPrerenderRoute(_route));
327
+ dataBuff = void 0;
328
+ return _route;
329
+ }
330
+ if (canWriteToDisk(_route)) {
331
+ const filePath = join(nitro.options.output.publicDir, _route.fileName);
332
+ await writeFile(filePath, dataBuff);
333
+ nitro._prerenderedRoutes.push(_route);
334
+ } else {
335
+ _route.skip = true;
336
+ }
337
+ if (!_route.error && (isImplicitHTML || route.endsWith(".html"))) {
338
+ const extractedLinks = await extractLinks(
339
+ dataBuff.toString("utf8"),
340
+ route,
341
+ res,
342
+ nitro.options.prerender.crawlLinks
343
+ );
344
+ for (const _link of extractedLinks) {
345
+ if (canPrerender(_link)) {
346
+ routes.add(_link);
347
+ }
348
+ }
349
+ }
350
+ await nitro.hooks.callHook("prerender:route", _route);
351
+ nitro.logger.log(formatPrerenderRoute(_route));
352
+ dataBuff = void 0;
353
+ return _route;
354
+ };
355
+ nitro.logger.info(
356
+ nitro.options.prerender.crawlLinks ? `Prerendering ${routes.size} initial routes with crawler` : `Prerendering ${routes.size} routes`
357
+ );
358
+ await runParallel(routes, generateRoute, {
359
+ concurrency: nitro.options.prerender.concurrency,
360
+ interval: nitro.options.prerender.interval
361
+ });
362
+ await closePrerenderer();
363
+ await nitro.hooks.callHook("prerender:done", {
364
+ prerenderedRoutes: nitro._prerenderedRoutes,
365
+ failedRoutes: [...failedRoutes]
366
+ });
367
+ if (nitro.options.prerender.failOnError && failedRoutes.size > 0) {
368
+ nitro.logger.log("\nErrors prerendering:");
369
+ for (const route of failedRoutes) {
370
+ const parents = linkParents.get(route.route);
371
+ parents?.size ? `
372
+ ${[...parents.values()].map((link) => colors.gray(` \u2502 \u2514\u2500\u2500 Linked from ${link}`)).join("\n")}` : "";
373
+ nitro.logger.log(formatPrerenderRoute(route));
374
+ }
375
+ nitro.logger.log("");
376
+ throw new Error("Exiting due to prerender errors.");
377
+ }
378
+ const prerenderTimeInMs = Date.now() - prerenderStartTime;
379
+ nitro.logger.info(
380
+ `Prerendered ${nitro._prerenderedRoutes.length} routes in ${prerenderTimeInMs / 1e3} seconds`
381
+ );
382
+ if (nitro.options.compressPublicAssets) {
383
+ await compressPublicAssets(nitro);
384
+ }
385
+ }
386
+
387
+ const pathSeparators = /* @__PURE__ */ new Set(["/", "\\", void 0]);
388
+ const normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
389
+ function normalizeAliases(_aliases) {
390
+ if (_aliases[normalizedAliasSymbol]) {
391
+ return _aliases;
392
+ }
393
+ const aliases = Object.fromEntries(
394
+ Object.entries(_aliases).sort(([a], [b]) => _compareAliases(a, b))
395
+ );
396
+ for (const key in aliases) {
397
+ for (const alias in aliases) {
398
+ if (alias === key || key.startsWith(alias)) {
399
+ continue;
400
+ }
401
+ if (aliases[key]?.startsWith(alias) && pathSeparators.has(aliases[key][alias.length])) {
402
+ aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
403
+ }
404
+ }
405
+ }
406
+ Object.defineProperty(aliases, normalizedAliasSymbol, {
407
+ value: true,
408
+ enumerable: false
409
+ });
410
+ return aliases;
411
+ }
412
+ function resolveAlias(path, aliases) {
413
+ const _path = normalizeWindowsPath(path);
414
+ aliases = normalizeAliases(aliases);
415
+ for (const [alias, to] of Object.entries(aliases)) {
416
+ if (!_path.startsWith(alias)) {
417
+ continue;
418
+ }
419
+ const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
420
+ if (hasTrailingSlash(_path[_alias.length])) {
421
+ return join(to, _path.slice(alias.length));
422
+ }
423
+ }
424
+ return _path;
425
+ }
426
+ function _compareAliases(a, b) {
427
+ return b.split("/").length - a.split("/").length;
428
+ }
429
+ function hasTrailingSlash(path = "/") {
430
+ const lastChar = path[path.length - 1];
431
+ return lastChar === "/" || lastChar === "\\";
432
+ }
433
+
434
+ function getType(val) {
435
+ const type = typeof val;
436
+ if (type === "undefined" || val === null) {
437
+ return void 0;
438
+ }
439
+ if (Array.isArray(val)) {
440
+ return "array";
441
+ }
442
+ return type;
443
+ }
444
+ function isObject(val) {
445
+ return val !== null && !Array.isArray(val) && typeof val === "object";
446
+ }
447
+ function nonEmpty(arr) {
448
+ return arr.filter(Boolean);
449
+ }
450
+ function unique(arr) {
451
+ return [...new Set(arr)];
452
+ }
453
+ function joinPath(a, b = "", sep = ".") {
454
+ return a ? a + sep + b : b;
455
+ }
456
+ function setValue(obj, path, val) {
457
+ const keys = path.split(".");
458
+ const _key = keys.pop();
459
+ for (const key of keys) {
460
+ if (!obj || typeof obj !== "object") {
461
+ return;
462
+ }
463
+ if (!(key in obj)) {
464
+ obj[key] = {};
465
+ }
466
+ obj = obj[key];
467
+ }
468
+ if (_key) {
469
+ if (!obj || typeof obj !== "object") {
470
+ return;
471
+ }
472
+ obj[_key] = val;
473
+ }
474
+ }
475
+ function getValue(obj, path) {
476
+ for (const key of path.split(".")) {
477
+ if (!obj || typeof obj !== "object" || !(key in obj)) {
478
+ return;
479
+ }
480
+ obj = obj[key];
481
+ }
482
+ return obj;
483
+ }
484
+ function normalizeTypes(val) {
485
+ const arr = unique(val.filter(Boolean));
486
+ if (arr.length === 0 || arr.includes("any")) {
487
+ return;
488
+ }
489
+ return arr.length > 1 ? arr : arr[0];
490
+ }
491
+
492
+ async function resolveSchema(obj, defaults, options = {}) {
493
+ const schema = await _resolveSchema(obj, "", {
494
+ root: obj,
495
+ defaults,
496
+ resolveCache: {},
497
+ ignoreDefaults: !!options.ignoreDefaults
498
+ });
499
+ return schema;
500
+ }
501
+ async function _resolveSchema(input, id, ctx) {
502
+ if (id in ctx.resolveCache) {
503
+ return ctx.resolveCache[id];
504
+ }
505
+ const schemaId = "#" + id.replace(/\./g, "/");
506
+ if (!isObject(input)) {
507
+ const safeInput = Array.isArray(input) ? [...input] : input;
508
+ const schema2 = {
509
+ type: getType(input),
510
+ id: schemaId,
511
+ default: ctx.ignoreDefaults ? void 0 : safeInput
512
+ };
513
+ normalizeSchema(schema2, { ignoreDefaults: ctx.ignoreDefaults });
514
+ ctx.resolveCache[id] = schema2;
515
+ if (ctx.defaults && getValue(ctx.defaults, id) === void 0) {
516
+ setValue(ctx.defaults, id, schema2.default);
517
+ }
518
+ return schema2;
519
+ }
520
+ const node = { ...input };
521
+ const schema = ctx.resolveCache[id] = {
522
+ ...node.$schema,
523
+ id: schemaId
524
+ };
525
+ for (const key in node) {
526
+ if (key === "$resolve" || key === "$schema" || key === "$default") {
527
+ continue;
528
+ }
529
+ schema.properties = schema.properties || {};
530
+ if (!schema.properties[key]) {
531
+ const child = schema.properties[key] = await _resolveSchema(
532
+ node[key],
533
+ joinPath(id, key),
534
+ ctx
535
+ );
536
+ if (Array.isArray(child.tags) && child.tags.includes("@required")) {
537
+ schema.required = schema.required || [];
538
+ if (!schema.required.includes(key)) {
539
+ schema.required.push(key);
540
+ }
541
+ }
542
+ }
543
+ }
544
+ if (!ctx.ignoreDefaults) {
545
+ if (ctx.defaults) {
546
+ schema.default = getValue(ctx.defaults, id);
547
+ }
548
+ if (schema.default === void 0 && "$default" in node) {
549
+ schema.default = node.$default;
550
+ }
551
+ if (typeof node.$resolve === "function") {
552
+ schema.default = await node.$resolve(schema.default, async (key) => {
553
+ return (await _resolveSchema(getValue(ctx.root, key), key, ctx)).default;
554
+ });
555
+ }
556
+ }
557
+ if (ctx.defaults) {
558
+ setValue(ctx.defaults, id, schema.default);
559
+ }
560
+ if (!schema.type) {
561
+ schema.type = getType(schema.default) || (schema.properties ? "object" : "any");
562
+ }
563
+ normalizeSchema(schema, { ignoreDefaults: ctx.ignoreDefaults });
564
+ if (ctx.defaults && getValue(ctx.defaults, id) === void 0) {
565
+ setValue(ctx.defaults, id, schema.default);
566
+ }
567
+ return schema;
568
+ }
569
+ function normalizeSchema(schema, options) {
570
+ if (schema.type === "array" && !("items" in schema)) {
571
+ schema.items = {
572
+ type: nonEmpty(unique(schema.default.map((i) => getType(i))))
573
+ };
574
+ if (schema.items.type) {
575
+ if (schema.items.type.length === 0) {
576
+ schema.items.type = "any";
577
+ } else if (schema.items.type.length === 1) {
578
+ schema.items.type = schema.items.type[0];
579
+ }
580
+ }
581
+ }
582
+ if (!options.ignoreDefaults && schema.default === void 0 && ("properties" in schema || schema.type === "object" || schema.type === "any")) {
583
+ const propsWithDefaults = Object.entries(schema.properties || {}).filter(([, prop]) => "default" in prop).map(([key, value]) => [key, value.default]);
584
+ schema.default = Object.fromEntries(propsWithDefaults);
585
+ }
586
+ }
587
+
588
+ const GenerateTypesDefaults = {
589
+ interfaceName: "Untyped",
590
+ addExport: true,
591
+ addDefaults: true,
592
+ allowExtraKeys: void 0,
593
+ partial: false,
594
+ indentation: 0
595
+ };
596
+ const TYPE_MAP = {
597
+ array: "any[]",
598
+ bigint: "bigint",
599
+ boolean: "boolean",
600
+ number: "number",
601
+ object: "",
602
+ // Will be precisely defined
603
+ any: "any",
604
+ string: "string",
605
+ symbol: "Symbol",
606
+ function: "Function"
607
+ };
608
+ const SCHEMA_KEYS = /* @__PURE__ */ new Set([
609
+ "items",
610
+ "default",
611
+ "resolve",
612
+ "properties",
613
+ "title",
614
+ "description",
615
+ "$schema",
616
+ "type",
617
+ "tsType",
618
+ "markdownType",
619
+ "tags",
620
+ "args",
621
+ "id",
622
+ "returns"
623
+ ]);
624
+ const DECLARATION_RE = /typeof import\(["'](?<source>[^)]+)["']\)(\.(?<type>\w+)|\[["'](?<type1>\w+)["']])/g;
625
+ function extractTypeImports(declarations) {
626
+ const typeImports = {};
627
+ const aliases = /* @__PURE__ */ new Set();
628
+ const imports = [];
629
+ for (const match of declarations.matchAll(DECLARATION_RE)) {
630
+ const { source, type1, type = type1 } = match.groups || {};
631
+ typeImports[source] = typeImports[source] || /* @__PURE__ */ new Set();
632
+ typeImports[source].add(type);
633
+ }
634
+ for (const source in typeImports) {
635
+ const sourceImports = [];
636
+ for (const type of typeImports[source]) {
637
+ let count = 0;
638
+ let alias = type;
639
+ while (aliases.has(alias)) {
640
+ alias = `${type}${count++}`;
641
+ }
642
+ aliases.add(alias);
643
+ sourceImports.push(alias === type ? type : `${type} as ${alias}`);
644
+ declarations = declarations.replace(
645
+ new RegExp(
646
+ `typeof import\\(['"]${source}['"]\\)(\\.${type}|\\[['"]${type}['"]\\])`,
647
+ "g"
648
+ ),
649
+ alias
650
+ );
651
+ }
652
+ imports.push(
653
+ `import type { ${sourceImports.join(", ")} } from '${source}'`
654
+ );
655
+ }
656
+ return [...imports, declarations].join("\n");
657
+ }
658
+ function generateTypes(schema, opts = {}) {
659
+ opts = { ...GenerateTypesDefaults, ...opts };
660
+ const baseIden = " ".repeat(opts.indentation || 0);
661
+ const interfaceCode = `interface ${opts.interfaceName} {
662
+ ` + _genTypes(schema, baseIden + " ", opts).map((l) => l.trim().length > 0 ? l : "").join("\n") + `
663
+ ${baseIden}}`;
664
+ if (!opts.addExport) {
665
+ return baseIden + interfaceCode;
666
+ }
667
+ return extractTypeImports(baseIden + `export ${interfaceCode}`);
668
+ }
669
+ function _genTypes(schema, spaces, opts) {
670
+ const buff = [];
671
+ if (!schema) {
672
+ return buff;
673
+ }
674
+ for (const key in schema.properties) {
675
+ const val = schema.properties[key];
676
+ buff.push(...generateJSDoc(val, opts));
677
+ if (val.tsType) {
678
+ buff.push(
679
+ `${genObjectKey(key)}${isRequired(schema, key, opts) ? "" : "?"}: ${val.tsType},
680
+ `
681
+ );
682
+ } else if (val.type === "object") {
683
+ buff.push(
684
+ `${genObjectKey(key)}${isRequired(schema, key, opts) ? "" : "?"}: {`,
685
+ ..._genTypes(val, spaces, opts),
686
+ "},\n"
687
+ );
688
+ } else {
689
+ let type;
690
+ if (val.type === "array") {
691
+ type = `Array<${getTsType(val.items || [], opts)}>`;
692
+ } else if (val.type === "function") {
693
+ type = genFunctionType(val, opts);
694
+ } else {
695
+ type = getTsType(val, opts);
696
+ }
697
+ buff.push(
698
+ `${genObjectKey(key)}${isRequired(schema, key, opts) ? "" : "?"}: ${type},
699
+ `
700
+ );
701
+ }
702
+ }
703
+ if (buff.length > 0) {
704
+ const last = buff.pop() || "";
705
+ buff.push(last.slice(0, Math.max(0, last.length - 1)));
706
+ }
707
+ if (opts.allowExtraKeys === true || buff.length === 0 && opts.allowExtraKeys !== false) {
708
+ buff.push("[key: string]: any");
709
+ }
710
+ return buff.flatMap((l) => l.split("\n")).map((l) => spaces + l);
711
+ }
712
+ function getTsType(type, opts) {
713
+ if (Array.isArray(type)) {
714
+ return [normalizeTypes(type.map((t) => getTsType(t, opts)))].flat().join("|") || "any";
715
+ }
716
+ if (!type) {
717
+ return "any";
718
+ }
719
+ if (type.tsType) {
720
+ return type.tsType;
721
+ }
722
+ if (!type.type) {
723
+ return "any";
724
+ }
725
+ if (Array.isArray(type.type)) {
726
+ return type.type.map((t) => {
727
+ if (t === "object" && type.type.length > 1) {
728
+ return `{
729
+ ` + _genTypes(type, " ", opts).join("\n") + `
730
+ }`;
731
+ }
732
+ return TYPE_MAP[t];
733
+ }).join("|");
734
+ }
735
+ if (type.type === "array") {
736
+ return `Array<${getTsType(type.items || [], opts)}>`;
737
+ }
738
+ if (type.type === "object") {
739
+ return `{
740
+ ` + _genTypes(type, " ", opts).join("\n") + `
741
+ }`;
742
+ }
743
+ return TYPE_MAP[type.type] || type.type;
744
+ }
745
+ function genFunctionType(schema, opts) {
746
+ return `(${genFunctionArgs(schema.args, opts)}) => ${getTsType(
747
+ schema.returns || [],
748
+ opts
749
+ )}`;
750
+ }
751
+ function genFunctionArgs(args, opts) {
752
+ return args?.map((arg) => {
753
+ let argStr = arg.name;
754
+ if (arg.optional || arg.default) {
755
+ argStr += "?";
756
+ }
757
+ if (arg.type || arg.tsType) {
758
+ argStr += `: ${getTsType(arg, opts)}`;
759
+ }
760
+ return argStr;
761
+ }).join(", ") || "";
762
+ }
763
+ function generateJSDoc(schema, opts) {
764
+ opts.defaultDescription = opts.defaultDescription || opts.defaultDescrption;
765
+ let buff = [];
766
+ if (schema.title) {
767
+ buff.push(schema.title, "");
768
+ }
769
+ if (schema.description) {
770
+ buff.push(schema.description, "");
771
+ } else if (opts.defaultDescription && schema.type !== "object") {
772
+ buff.push(opts.defaultDescription, "");
773
+ }
774
+ if (opts.addDefaults && schema.type !== "object" && schema.type !== "any" && !(Array.isArray(schema.default) && schema.default.length === 0)) {
775
+ const stringified = JSON.stringify(schema.default);
776
+ if (stringified) {
777
+ buff.push(`@default ${stringified.replace(/\*\//g, String.raw`*\/`)}`);
778
+ }
779
+ }
780
+ for (const key in schema) {
781
+ if (!SCHEMA_KEYS.has(key)) {
782
+ buff.push("", `@${key} ${schema[key]}`);
783
+ }
784
+ }
785
+ if (Array.isArray(schema.tags)) {
786
+ for (const tag of schema.tags) {
787
+ if (tag !== "@untyped") {
788
+ buff.push("", tag);
789
+ }
790
+ }
791
+ }
792
+ buff = buff.flatMap((i) => i.split("\n"));
793
+ if (buff.length > 0) {
794
+ return buff.length === 1 ? ["/** " + buff[0] + " */"] : ["/**", ...buff.map((i) => ` * ${i}`), "*/"];
795
+ }
796
+ return [];
797
+ }
798
+ function isRequired(schema, key, opts) {
799
+ if (Array.isArray(schema.required) && schema.required.includes(key)) {
800
+ return true;
801
+ }
802
+ return !opts.partial;
803
+ }
804
+
805
+ async function writeTypes(nitro) {
806
+ const types = {
807
+ routes: {}
808
+ };
809
+ const typesDir = resolve(nitro.options.buildDir, "types");
810
+ const middleware = [...nitro.scannedHandlers, ...nitro.options.handlers];
811
+ for (const mw of middleware) {
812
+ if (typeof mw.handler !== "string" || !mw.route) {
813
+ continue;
814
+ }
815
+ const relativePath = relative(
816
+ typesDir,
817
+ resolveNitroPath(mw.handler, nitro.options)
818
+ ).replace(/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/, "");
819
+ const method = mw.method || "default";
820
+ types.routes[mw.route] ??= {};
821
+ types.routes[mw.route][method] ??= [];
822
+ types.routes[mw.route][method].push(
823
+ `Simplify<Serialize<Awaited<ReturnType<typeof import('${relativePath}').default>>>>`
824
+ );
825
+ }
826
+ let autoImportedTypes = [];
827
+ let autoImportExports = "";
828
+ if (nitro.unimport) {
829
+ await nitro.unimport.init();
830
+ const allImports = await nitro.unimport.getImports();
831
+ autoImportExports = toExports(allImports).replace(
832
+ /#internal\/nitro/g,
833
+ relative(typesDir, runtimeDir)
834
+ );
835
+ const resolvedImportPathMap = /* @__PURE__ */ new Map();
836
+ for (const i of allImports) {
837
+ if (resolvedImportPathMap.has(i.from)) {
838
+ continue;
839
+ }
840
+ let path = resolveAlias(i.from, nitro.options.alias);
841
+ if (!isAbsolute(path)) {
842
+ const resolvedPath = resolveModulePath(i.from, {
843
+ try: true,
844
+ from: nitro.options.nodeModulesDirs,
845
+ conditions: ["type", "node", "import"],
846
+ suffixes: ["", "/index"],
847
+ extensions: [".mjs", ".cjs", ".js", ".mts", ".cts", ".ts"]
848
+ });
849
+ if (resolvedPath) {
850
+ const { dir, name } = parseNodeModulePath(resolvedPath);
851
+ if (!dir || !name) {
852
+ path = resolvedPath;
853
+ } else {
854
+ const subpath = await lookupNodeModuleSubpath(resolvedPath);
855
+ path = join(dir, name, subpath || "");
856
+ }
857
+ }
858
+ }
859
+ if (existsSync(path) && !await isDirectory(path)) {
860
+ path = path.replace(/\.[a-z]+$/, "");
861
+ }
862
+ if (isAbsolute(path)) {
863
+ path = relative(typesDir, path);
864
+ }
865
+ resolvedImportPathMap.set(i.from, path);
866
+ }
867
+ autoImportedTypes = [
868
+ nitro.options.imports && nitro.options.imports.autoImport !== false ? (await nitro.unimport.generateTypeDeclarations({
869
+ exportHelper: false,
870
+ resolvePath: (i) => resolvedImportPathMap.get(i.from) ?? i.from
871
+ })).trim() : ""
872
+ ];
873
+ }
874
+ const generateRoutes = () => [
875
+ "// Generated by nitro",
876
+ 'import type { Serialize, Simplify } from "nitro/types";',
877
+ 'declare module "nitro/types" {',
878
+ " type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T",
879
+ " interface InternalApi {",
880
+ ...Object.entries(types.routes).map(
881
+ ([path, methods]) => [
882
+ ` '${path}': {`,
883
+ ...Object.entries(methods).map(
884
+ ([method, types2]) => ` '${method}': ${types2.join(" | ")}`
885
+ ),
886
+ " }"
887
+ ].join("\n")
888
+ ),
889
+ " }",
890
+ "}",
891
+ // Makes this a module for augmentation purposes
892
+ "export {}"
893
+ ];
894
+ const config = [
895
+ "// Generated by nitro",
896
+ /* ts */
897
+ `declare module "nitro/types" {`,
898
+ nitro.options.typescript.generateRuntimeConfigTypes ? generateTypes(
899
+ await resolveSchema(
900
+ Object.fromEntries(
901
+ Object.entries(nitro.options.runtimeConfig).filter(
902
+ ([key]) => !["app", "nitro"].includes(key)
903
+ )
904
+ )
905
+ ),
906
+ {
907
+ interfaceName: "NitroRuntimeConfig",
908
+ addExport: false,
909
+ addDefaults: false,
910
+ allowExtraKeys: false,
911
+ indentation: 2
912
+ }
913
+ ) : "",
914
+ `}`,
915
+ // Makes this a module for augmentation purposes
916
+ "export {}"
917
+ ];
918
+ const declarations = [
919
+ // local nitropack augmentations
920
+ '/// <reference path="./nitro-routes.d.ts" />',
921
+ '/// <reference path="./nitro-config.d.ts" />',
922
+ // global server auto-imports
923
+ '/// <reference path="./nitro-imports.d.ts" />'
924
+ ];
925
+ const buildFiles = [];
926
+ buildFiles.push({
927
+ path: join(typesDir, "nitro-routes.d.ts"),
928
+ contents: () => generateRoutes().join("\n")
929
+ });
930
+ buildFiles.push({
931
+ path: join(typesDir, "nitro-config.d.ts"),
932
+ contents: config.join("\n")
933
+ });
934
+ buildFiles.push({
935
+ path: join(typesDir, "nitro-imports.d.ts"),
936
+ contents: [...autoImportedTypes, autoImportExports || "export {}"].join(
937
+ "\n"
938
+ )
939
+ });
940
+ buildFiles.push({
941
+ path: join(typesDir, "nitro.d.ts"),
942
+ contents: declarations.join("\n")
943
+ });
944
+ if (nitro.options.typescript.generateTsConfig) {
945
+ const tsConfigPath = resolve(
946
+ nitro.options.buildDir,
947
+ nitro.options.typescript.tsconfigPath
948
+ );
949
+ const tsconfigDir = dirname(tsConfigPath);
950
+ const tsConfig = defu(nitro.options.typescript.tsConfig, {
951
+ compilerOptions: {
952
+ /* Base options: */
953
+ esModuleInterop: true,
954
+ allowSyntheticDefaultImports: true,
955
+ skipLibCheck: true,
956
+ target: "ESNext",
957
+ allowJs: true,
958
+ resolveJsonModule: true,
959
+ moduleDetection: "force",
960
+ isolatedModules: true,
961
+ verbatimModuleSyntax: true,
962
+ allowImportingTsExtensions: true,
963
+ /* Strictness */
964
+ strict: nitro.options.typescript.strict,
965
+ noUncheckedIndexedAccess: true,
966
+ noImplicitOverride: true,
967
+ forceConsistentCasingInFileNames: true,
968
+ /* If NOT transpiling with TypeScript: */
969
+ module: "Preserve",
970
+ jsx: "preserve",
971
+ jsxFactory: "h",
972
+ jsxFragmentFactory: "Fragment",
973
+ paths: {
974
+ "#imports": [
975
+ relativeWithDot(tsconfigDir, join(typesDir, "nitro-imports"))
976
+ ],
977
+ ...nitro.options.typescript.internalPaths ? {
978
+ "nitro/runtime": [
979
+ relativeWithDot(tsconfigDir, join(runtimeDir, "index"))
980
+ ],
981
+ "#internal/nitro": [
982
+ relativeWithDot(tsconfigDir, join(runtimeDir, "index"))
983
+ ],
984
+ "nitro/runtime/*": [
985
+ relativeWithDot(tsconfigDir, join(runtimeDir, "*"))
986
+ ],
987
+ "#internal/nitro/*": [
988
+ relativeWithDot(tsconfigDir, join(runtimeDir, "*"))
989
+ ]
990
+ } : {}
991
+ }
992
+ },
993
+ include: [
994
+ relativeWithDot(tsconfigDir, join(typesDir, "nitro.d.ts")).replace(
995
+ /^(?=[^.])/,
996
+ "./"
997
+ ),
998
+ join(relativeWithDot(tsconfigDir, nitro.options.rootDir), "**/*"),
999
+ ...nitro.options.srcDir === nitro.options.rootDir ? [] : [join(relativeWithDot(tsconfigDir, nitro.options.srcDir), "**/*")]
1000
+ ]
1001
+ });
1002
+ for (const alias in tsConfig.compilerOptions.paths) {
1003
+ const paths = await Promise.all(
1004
+ tsConfig.compilerOptions.paths[alias].map(async (path) => {
1005
+ if (!isAbsolute(path)) {
1006
+ return path;
1007
+ }
1008
+ const stats = await promises.stat(path).catch(
1009
+ () => null
1010
+ /* file does not exist */
1011
+ );
1012
+ return relativeWithDot(
1013
+ tsconfigDir,
1014
+ stats?.isFile() ? path.replace(/(?<=\w)\.\w+$/g, "") : path
1015
+ );
1016
+ })
1017
+ );
1018
+ tsConfig.compilerOptions.paths[alias] = [...new Set(paths)];
1019
+ }
1020
+ tsConfig.include = [
1021
+ ...new Set(
1022
+ tsConfig.include.map(
1023
+ (p) => isAbsolute(p) ? relativeWithDot(tsconfigDir, p) : p
1024
+ )
1025
+ )
1026
+ ];
1027
+ if (tsConfig.exclude) {
1028
+ tsConfig.exclude = [
1029
+ ...new Set(
1030
+ tsConfig.exclude.map(
1031
+ (p) => isAbsolute(p) ? relativeWithDot(tsconfigDir, p) : p
1032
+ )
1033
+ )
1034
+ ];
1035
+ }
1036
+ types.tsConfig = tsConfig;
1037
+ buildFiles.push({
1038
+ path: tsConfigPath,
1039
+ contents: () => JSON.stringify(tsConfig, null, 2)
1040
+ });
1041
+ }
1042
+ await nitro.hooks.callHook("types:extend", types);
1043
+ await Promise.all(
1044
+ buildFiles.map(async (file) => {
1045
+ await writeFile(
1046
+ resolve(nitro.options.buildDir, file.path),
1047
+ typeof file.contents === "string" ? file.contents : file.contents()
1048
+ );
1049
+ })
1050
+ );
1051
+ }
1052
+ const RELATIVE_RE = /^\.{1,2}\//;
1053
+ function relativeWithDot(from, to) {
1054
+ const rel = relative(from, to);
1055
+ return RELATIVE_RE.test(rel) ? rel : "./" + rel;
1056
+ }
1057
+
1058
+ export { build as b, prerender as p, runParallel as r, writeTypes as w };