nitropack-nightly 2.10.0-28638117.48423122 → 3.0.0-beta-28638602.1fe7b893-nitro-nightly-mirror

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 (281) hide show
  1. package/README.md +3 -0
  2. package/cli.d.ts +1 -1
  3. package/config.d.ts +1 -1
  4. package/core.d.ts +1 -1
  5. package/dist/cli/index.d.mts +1 -1
  6. package/dist/cli/index.d.ts +1 -1
  7. package/dist/cli/index.mjs +1 -18
  8. package/dist/config/index.d.mts +1 -6
  9. package/dist/config/index.d.ts +1 -6
  10. package/dist/config/index.mjs +1 -5
  11. package/dist/core/index.d.mts +1 -69
  12. package/dist/core/index.d.ts +1 -69
  13. package/dist/core/index.mjs +1 -2436
  14. package/dist/kit/index.d.mts +1 -44
  15. package/dist/kit/index.d.ts +1 -44
  16. package/dist/kit/index.mjs +1 -71
  17. package/dist/meta/index.d.mts +1 -3
  18. package/dist/meta/index.d.ts +1 -3
  19. package/dist/meta/index.mjs +1 -3
  20. package/dist/presets/index.d.mts +1 -1
  21. package/dist/presets/index.d.ts +1 -2
  22. package/dist/presets/index.mjs +1 -1
  23. package/dist/rollup/index.d.mts +1 -5
  24. package/dist/rollup/index.d.ts +1 -5
  25. package/dist/rollup/index.mjs +1 -2033
  26. package/dist/runtime/index.d.mts +1 -0
  27. package/dist/runtime/index.d.ts +1 -12
  28. package/dist/runtime/index.mjs +1 -17
  29. package/dist/types/index.d.mts +1 -260
  30. package/dist/types/index.d.ts +1 -260
  31. package/dist/types/index.mjs +1 -1
  32. package/kit.d.ts +1 -1
  33. package/meta.d.ts +1 -1
  34. package/package.json +6 -172
  35. package/presets.d.ts +1 -1
  36. package/rollup.d.ts +1 -1
  37. package/runtime-meta.d.ts +1 -4
  38. package/runtime-meta.mjs +1 -30
  39. package/runtime.d.ts +1 -1
  40. package/types.d.ts +1 -1
  41. package/dist/cli/build.mjs +0 -47
  42. package/dist/cli/common.mjs +0 -13
  43. package/dist/cli/dev.mjs +0 -63
  44. package/dist/cli/index2.mjs +0 -14
  45. package/dist/cli/list.mjs +0 -28
  46. package/dist/cli/prepare.mjs +0 -21
  47. package/dist/cli/run.mjs +0 -57
  48. package/dist/presets/_all.gen.d.ts +0 -2
  49. package/dist/presets/_all.gen.mjs +0 -52
  50. package/dist/presets/_nitro/base-worker.d.ts +0 -2
  51. package/dist/presets/_nitro/base-worker.mjs +0 -25
  52. package/dist/presets/_nitro/nitro-dev.d.ts +0 -2
  53. package/dist/presets/_nitro/nitro-dev.mjs +0 -19
  54. package/dist/presets/_nitro/nitro-prerender.d.ts +0 -2
  55. package/dist/presets/_nitro/nitro-prerender.mjs +0 -17
  56. package/dist/presets/_nitro/preset.d.ts +0 -2
  57. package/dist/presets/_nitro/preset.mjs +0 -5
  58. package/dist/presets/_nitro/runtime/nitro-dev.d.ts +0 -1
  59. package/dist/presets/_nitro/runtime/nitro-dev.mjs +0 -86
  60. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.ts +0 -3
  61. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +0 -7
  62. package/dist/presets/_nitro/runtime/service-worker.d.ts +0 -1
  63. package/dist/presets/_nitro/runtime/service-worker.mjs +0 -31
  64. package/dist/presets/_nitro/service-worker.d.ts +0 -2
  65. package/dist/presets/_nitro/service-worker.mjs +0 -110
  66. package/dist/presets/_resolve.d.ts +0 -8
  67. package/dist/presets/_resolve.mjs +0 -44
  68. package/dist/presets/_static/preset.d.ts +0 -2
  69. package/dist/presets/_static/preset.mjs +0 -69
  70. package/dist/presets/_types.gen.d.ts +0 -16
  71. package/dist/presets/_types.gen.mjs +0 -0
  72. package/dist/presets/alwaysdata/preset.d.ts +0 -2
  73. package/dist/presets/alwaysdata/preset.mjs +0 -14
  74. package/dist/presets/aws-amplify/preset.d.ts +0 -3
  75. package/dist/presets/aws-amplify/preset.mjs +0 -27
  76. package/dist/presets/aws-amplify/runtime/aws-amplify.d.ts +0 -1
  77. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +0 -13
  78. package/dist/presets/aws-amplify/types.d.ts +0 -141
  79. package/dist/presets/aws-amplify/types.mjs +0 -0
  80. package/dist/presets/aws-amplify/utils.d.ts +0 -2
  81. package/dist/presets/aws-amplify/utils.mjs +0 -82
  82. package/dist/presets/aws-lambda/preset.d.ts +0 -2
  83. package/dist/presets/aws-lambda/preset.mjs +0 -21
  84. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.ts +0 -15
  85. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +0 -53
  86. package/dist/presets/aws-lambda/runtime/aws-lambda.d.ts +0 -4
  87. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +0 -45
  88. package/dist/presets/azure/preset.d.ts +0 -3
  89. package/dist/presets/azure/preset.mjs +0 -44
  90. package/dist/presets/azure/runtime/azure-functions.d.ts +0 -5
  91. package/dist/presets/azure/runtime/azure-functions.mjs +0 -22
  92. package/dist/presets/azure/runtime/azure-swa.d.ts +0 -5
  93. package/dist/presets/azure/runtime/azure-swa.mjs +0 -28
  94. package/dist/presets/azure/types.d.ts +0 -13
  95. package/dist/presets/azure/types.mjs +0 -0
  96. package/dist/presets/azure/utils.d.ts +0 -3
  97. package/dist/presets/azure/utils.mjs +0 -183
  98. package/dist/presets/bun/preset.d.ts +0 -2
  99. package/dist/presets/bun/preset.mjs +0 -17
  100. package/dist/presets/bun/runtime/bun.d.ts +0 -1
  101. package/dist/presets/bun/runtime/bun.mjs +0 -32
  102. package/dist/presets/cleavr/preset.d.ts +0 -2
  103. package/dist/presets/cleavr/preset.mjs +0 -12
  104. package/dist/presets/cloudflare/preset.d.ts +0 -3
  105. package/dist/presets/cloudflare/preset.mjs +0 -145
  106. package/dist/presets/cloudflare/runtime/cloudflare-module.d.ts +0 -13
  107. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +0 -104
  108. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.ts +0 -20
  109. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +0 -56
  110. package/dist/presets/cloudflare/runtime/cloudflare-worker.d.ts +0 -1
  111. package/dist/presets/cloudflare/runtime/cloudflare-worker.mjs +0 -64
  112. package/dist/presets/cloudflare/types.d.ts +0 -89
  113. package/dist/presets/cloudflare/types.mjs +0 -0
  114. package/dist/presets/cloudflare/types.wrangler.d.ts +0 -974
  115. package/dist/presets/cloudflare/types.wrangler.mjs +0 -0
  116. package/dist/presets/cloudflare/utils.d.ts +0 -3
  117. package/dist/presets/cloudflare/utils.mjs +0 -163
  118. package/dist/presets/deno/preset.d.ts +0 -2
  119. package/dist/presets/deno/preset.mjs +0 -151
  120. package/dist/presets/deno/runtime/deno-deploy.d.ts +0 -1
  121. package/dist/presets/deno/runtime/deno-deploy.mjs +0 -31
  122. package/dist/presets/deno/runtime/deno-server.d.ts +0 -3
  123. package/dist/presets/deno/runtime/deno-server.mjs +0 -65
  124. package/dist/presets/digitalocean/preset.d.ts +0 -2
  125. package/dist/presets/digitalocean/preset.mjs +0 -11
  126. package/dist/presets/edgio/preset.d.ts +0 -2
  127. package/dist/presets/edgio/preset.mjs +0 -95
  128. package/dist/presets/firebase/preset.d.ts +0 -3
  129. package/dist/presets/firebase/preset.mjs +0 -51
  130. package/dist/presets/firebase/runtime/firebase-gen-1.d.ts +0 -2
  131. package/dist/presets/firebase/runtime/firebase-gen-1.mjs +0 -8
  132. package/dist/presets/firebase/runtime/firebase-gen-2.d.ts +0 -2
  133. package/dist/presets/firebase/runtime/firebase-gen-2.mjs +0 -15
  134. package/dist/presets/firebase/runtime/firebase-gen-default.d.ts +0 -1
  135. package/dist/presets/firebase/runtime/firebase-gen-default.mjs +0 -1
  136. package/dist/presets/firebase/types.d.ts +0 -37
  137. package/dist/presets/firebase/types.mjs +0 -0
  138. package/dist/presets/firebase/utils.d.ts +0 -3
  139. package/dist/presets/firebase/utils.mjs +0 -50
  140. package/dist/presets/flightcontrol/preset.d.ts +0 -2
  141. package/dist/presets/flightcontrol/preset.mjs +0 -11
  142. package/dist/presets/heroku/preset.d.ts +0 -2
  143. package/dist/presets/heroku/preset.mjs +0 -11
  144. package/dist/presets/iis/preset.d.ts +0 -2
  145. package/dist/presets/iis/preset.mjs +0 -32
  146. package/dist/presets/iis/utils.d.ts +0 -3
  147. package/dist/presets/iis/utils.mjs +0 -159
  148. package/dist/presets/koyeb/preset.d.ts +0 -2
  149. package/dist/presets/koyeb/preset.mjs +0 -11
  150. package/dist/presets/netlify/legacy/preset.d.ts +0 -2
  151. package/dist/presets/netlify/legacy/preset.mjs +0 -145
  152. package/dist/presets/netlify/legacy/runtime/netlify-builder.d.ts +0 -2
  153. package/dist/presets/netlify/legacy/runtime/netlify-builder.mjs +0 -4
  154. package/dist/presets/netlify/legacy/runtime/netlify-edge.d.ts +0 -2
  155. package/dist/presets/netlify/legacy/runtime/netlify-edge.mjs +0 -25
  156. package/dist/presets/netlify/legacy/runtime/netlify-lambda.d.ts +0 -3
  157. package/dist/presets/netlify/legacy/runtime/netlify-lambda.mjs +0 -38
  158. package/dist/presets/netlify/legacy/runtime/netlify.d.ts +0 -3
  159. package/dist/presets/netlify/legacy/runtime/netlify.mjs +0 -21
  160. package/dist/presets/netlify/legacy/utils.d.ts +0 -4
  161. package/dist/presets/netlify/legacy/utils.mjs +0 -113
  162. package/dist/presets/netlify/preset.d.ts +0 -3
  163. package/dist/presets/netlify/preset.mjs +0 -130
  164. package/dist/presets/netlify/runtime/netlify-edge.d.ts +0 -2
  165. package/dist/presets/netlify/runtime/netlify-edge.mjs +0 -25
  166. package/dist/presets/netlify/runtime/netlify.d.ts +0 -3
  167. package/dist/presets/netlify/runtime/netlify.mjs +0 -53
  168. package/dist/presets/netlify/types.d.ts +0 -12
  169. package/dist/presets/netlify/types.mjs +0 -0
  170. package/dist/presets/netlify/utils.d.ts +0 -5
  171. package/dist/presets/netlify/utils.mjs +0 -94
  172. package/dist/presets/node/preset.d.ts +0 -2
  173. package/dist/presets/node/preset.mjs +0 -49
  174. package/dist/presets/node/runtime/cli.d.ts +0 -1
  175. package/dist/presets/node/runtime/cli.mjs +0 -21
  176. package/dist/presets/node/runtime/cluster.d.ts +0 -1
  177. package/dist/presets/node/runtime/cluster.mjs +0 -58
  178. package/dist/presets/node/runtime/node-listener.d.ts +0 -6
  179. package/dist/presets/node/runtime/node-listener.mjs +0 -13
  180. package/dist/presets/node/runtime/node-server.d.ts +0 -3
  181. package/dist/presets/node/runtime/node-server.mjs +0 -43
  182. package/dist/presets/platform.sh/preset.d.ts +0 -2
  183. package/dist/presets/platform.sh/preset.mjs +0 -11
  184. package/dist/presets/render.com/preset.d.ts +0 -2
  185. package/dist/presets/render.com/preset.mjs +0 -11
  186. package/dist/presets/stormkit/preset.d.ts +0 -2
  187. package/dist/presets/stormkit/preset.mjs +0 -15
  188. package/dist/presets/stormkit/runtime/stormkit.d.ts +0 -21
  189. package/dist/presets/stormkit/runtime/stormkit.mjs +0 -32
  190. package/dist/presets/vercel/preset.d.ts +0 -3
  191. package/dist/presets/vercel/preset.mjs +0 -104
  192. package/dist/presets/vercel/runtime/vercel-edge.d.ts +0 -2
  193. package/dist/presets/vercel/runtime/vercel-edge.mjs +0 -22
  194. package/dist/presets/vercel/runtime/vercel.d.ts +0 -4
  195. package/dist/presets/vercel/runtime/vercel.mjs +0 -17
  196. package/dist/presets/vercel/types.d.ts +0 -78
  197. package/dist/presets/vercel/types.mjs +0 -0
  198. package/dist/presets/vercel/utils.d.ts +0 -5
  199. package/dist/presets/vercel/utils.mjs +0 -186
  200. package/dist/presets/winterjs/preset.d.ts +0 -2
  201. package/dist/presets/winterjs/preset.mjs +0 -20
  202. package/dist/presets/winterjs/runtime/winterjs.d.ts +0 -1
  203. package/dist/presets/winterjs/runtime/winterjs.mjs +0 -69
  204. package/dist/presets/zeabur/preset.d.ts +0 -2
  205. package/dist/presets/zeabur/preset.mjs +0 -70
  206. package/dist/presets/zeabur/runtime/zeabur.d.ts +0 -4
  207. package/dist/presets/zeabur/runtime/zeabur.mjs +0 -8
  208. package/dist/runtime/app.d.ts +0 -2
  209. package/dist/runtime/app.mjs +0 -1
  210. package/dist/runtime/cache.d.ts +0 -1
  211. package/dist/runtime/cache.mjs +0 -6
  212. package/dist/runtime/config.d.ts +0 -1
  213. package/dist/runtime/config.mjs +0 -1
  214. package/dist/runtime/context.d.ts +0 -1
  215. package/dist/runtime/context.mjs +0 -1
  216. package/dist/runtime/database.d.ts +0 -1
  217. package/dist/runtime/database.mjs +0 -1
  218. package/dist/runtime/error.d.ts +0 -1
  219. package/dist/runtime/error.mjs +0 -1
  220. package/dist/runtime/internal/app.d.ts +0 -3
  221. package/dist/runtime/internal/app.mjs +0 -152
  222. package/dist/runtime/internal/cache.d.ts +0 -8
  223. package/dist/runtime/internal/cache.mjs +0 -329
  224. package/dist/runtime/internal/client.d.ts +0 -1
  225. package/dist/runtime/internal/client.mjs +0 -4
  226. package/dist/runtime/internal/config.d.ts +0 -6
  227. package/dist/runtime/internal/config.mjs +0 -58
  228. package/dist/runtime/internal/context.d.ts +0 -12
  229. package/dist/runtime/internal/context.mjs +0 -17
  230. package/dist/runtime/internal/database.d.ts +0 -2
  231. package/dist/runtime/internal/database.mjs +0 -14
  232. package/dist/runtime/internal/debug.d.ts +0 -2
  233. package/dist/runtime/internal/debug.mjs +0 -5
  234. package/dist/runtime/internal/error.d.ts +0 -4
  235. package/dist/runtime/internal/error.mjs +0 -71
  236. package/dist/runtime/internal/lib/http-graceful-shutdown.d.ts +0 -16
  237. package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +0 -213
  238. package/dist/runtime/internal/meta.d.ts +0 -2
  239. package/dist/runtime/internal/meta.mjs +0 -3
  240. package/dist/runtime/internal/plugin.d.ts +0 -3
  241. package/dist/runtime/internal/plugin.mjs +0 -4
  242. package/dist/runtime/internal/polyfill/deno-env.d.ts +0 -0
  243. package/dist/runtime/internal/polyfill/deno-env.mjs +0 -1
  244. package/dist/runtime/internal/renderer.d.ts +0 -2
  245. package/dist/runtime/internal/renderer.mjs +0 -38
  246. package/dist/runtime/internal/route-rules.d.ts +0 -14
  247. package/dist/runtime/internal/route-rules.mjs +0 -67
  248. package/dist/runtime/internal/routes/openapi.d.ts +0 -3
  249. package/dist/runtime/internal/routes/openapi.mjs +0 -85
  250. package/dist/runtime/internal/routes/scalar.d.ts +0 -2
  251. package/dist/runtime/internal/routes/scalar.mjs +0 -191
  252. package/dist/runtime/internal/routes/swagger.d.ts +0 -2
  253. package/dist/runtime/internal/routes/swagger.mjs +0 -39
  254. package/dist/runtime/internal/shutdown.d.ts +0 -10
  255. package/dist/runtime/internal/shutdown.mjs +0 -34
  256. package/dist/runtime/internal/static.d.ts +0 -2
  257. package/dist/runtime/internal/static.mjs +0 -89
  258. package/dist/runtime/internal/storage.d.ts +0 -2
  259. package/dist/runtime/internal/storage.mjs +0 -5
  260. package/dist/runtime/internal/task.d.ts +0 -17
  261. package/dist/runtime/internal/task.mjs +0 -73
  262. package/dist/runtime/internal/timing.d.ts +0 -2
  263. package/dist/runtime/internal/timing.mjs +0 -29
  264. package/dist/runtime/internal/utils.azure.d.ts +0 -2
  265. package/dist/runtime/internal/utils.azure.mjs +0 -51
  266. package/dist/runtime/internal/utils.d.ts +0 -23
  267. package/dist/runtime/internal/utils.env.d.ts +0 -7
  268. package/dist/runtime/internal/utils.env.mjs +0 -39
  269. package/dist/runtime/internal/utils.lambda.d.ts +0 -12
  270. package/dist/runtime/internal/utils.lambda.mjs +0 -30
  271. package/dist/runtime/internal/utils.mjs +0 -129
  272. package/dist/runtime/plugin.d.ts +0 -1
  273. package/dist/runtime/plugin.mjs +0 -1
  274. package/dist/runtime/storage.d.ts +0 -1
  275. package/dist/runtime/storage.mjs +0 -1
  276. package/dist/runtime/task.d.ts +0 -1
  277. package/dist/runtime/task.mjs +0 -1
  278. package/dist/runtime/utils.d.ts +0 -1
  279. package/dist/runtime/utils.mjs +0 -1
  280. package/dist/shared/nitro.DkCt8MDS.d.mts +0 -588
  281. package/dist/shared/nitro.DkCt8MDS.d.ts +0 -588
File without changes
@@ -1,3 +0,0 @@
1
- import type { Nitro } from "nitropack/types";
2
- export declare function writeCFPagesFiles(nitro: Nitro): Promise<void>;
3
- export declare function writeCFPagesStaticFiles(nitro: Nitro): Promise<void>;
@@ -1,163 +0,0 @@
1
- import { existsSync, promises as fsp } from "node:fs";
2
- import { resolve, join } from "pathe";
3
- import {
4
- joinURL,
5
- withLeadingSlash,
6
- withTrailingSlash,
7
- withoutLeadingSlash
8
- } from "ufo";
9
- import { parseTOML, stringifyTOML } from "confbox";
10
- import { globby } from "globby";
11
- import defu from "defu";
12
- import { isCI } from "std-env";
13
- export async function writeCFPagesFiles(nitro) {
14
- await writeCFRoutes(nitro);
15
- await writeCFPagesHeaders(nitro);
16
- await writeCFPagesRedirects(nitro);
17
- await writeCFWrangler(nitro);
18
- }
19
- export async function writeCFPagesStaticFiles(nitro) {
20
- await writeCFPagesHeaders(nitro);
21
- await writeCFPagesRedirects(nitro);
22
- }
23
- async function writeCFRoutes(nitro) {
24
- const _cfPagesConfig = nitro.options.cloudflare?.pages || {};
25
- const routes = {
26
- version: _cfPagesConfig.routes?.version || 1,
27
- include: _cfPagesConfig.routes?.include || ["/*"],
28
- exclude: _cfPagesConfig.routes?.exclude || []
29
- };
30
- const writeRoutes = () => fsp.writeFile(
31
- resolve(nitro.options.output.publicDir, "_routes.json"),
32
- JSON.stringify(routes, void 0, 2)
33
- );
34
- if (_cfPagesConfig.defaultRoutes === false) {
35
- await writeRoutes();
36
- return;
37
- }
38
- const explicitPublicAssets = nitro.options.publicAssets.filter(
39
- (dir, index, array) => {
40
- if (dir.fallthrough || !dir.baseURL) {
41
- return false;
42
- }
43
- const normalizedBase = withoutLeadingSlash(dir.baseURL);
44
- return !array.some(
45
- (otherDir, otherIndex) => otherIndex !== index && normalizedBase.startsWith(
46
- withoutLeadingSlash(withTrailingSlash(otherDir.baseURL))
47
- )
48
- );
49
- }
50
- );
51
- routes.exclude.push(
52
- ...explicitPublicAssets.map((dir) => joinURL(dir.baseURL, "*")).sort(comparePaths)
53
- );
54
- const publicAssetFiles = await globby("**", {
55
- cwd: nitro.options.output.publicDir,
56
- absolute: false,
57
- dot: true,
58
- ignore: [
59
- "_worker.js",
60
- "_worker.js.map",
61
- "nitro.json",
62
- ...routes.exclude.map(
63
- (path) => withoutLeadingSlash(path.replace(/\/\*$/, "/**"))
64
- )
65
- ]
66
- });
67
- routes.exclude.push(
68
- ...publicAssetFiles.map(
69
- (i) => withLeadingSlash(i).replace(/\/index\.html$/, "").replace(/\.html$/, "") || "/"
70
- ).sort(comparePaths)
71
- );
72
- routes.exclude.splice(100 - routes.include.length);
73
- await writeRoutes();
74
- }
75
- function comparePaths(a, b) {
76
- return a.split("/").length - b.split("/").length || a.localeCompare(b);
77
- }
78
- async function writeCFPagesHeaders(nitro) {
79
- const headersPath = join(nitro.options.output.publicDir, "_headers");
80
- const contents = [];
81
- const rules = Object.entries(nitro.options.routeRules).sort(
82
- (a, b) => b[0].split(/\/(?!\*)/).length - a[0].split(/\/(?!\*)/).length
83
- );
84
- for (const [path, routeRules] of rules.filter(
85
- ([_, routeRules2]) => routeRules2.headers
86
- )) {
87
- const headers = [
88
- path.replace("/**", "/*"),
89
- ...Object.entries({ ...routeRules.headers }).map(
90
- ([header, value]) => ` ${header}: ${value}`
91
- )
92
- ].join("\n");
93
- contents.push(headers);
94
- }
95
- if (existsSync(headersPath)) {
96
- const currentHeaders = await fsp.readFile(headersPath, "utf8");
97
- if (/^\/\* /m.test(currentHeaders)) {
98
- nitro.logger.info(
99
- "Not adding Nitro fallback to `_headers` (as an existing fallback was found)."
100
- );
101
- return;
102
- }
103
- nitro.logger.info(
104
- "Adding Nitro fallback to `_headers` to handle all unmatched routes."
105
- );
106
- contents.unshift(currentHeaders);
107
- }
108
- await fsp.writeFile(headersPath, contents.join("\n"));
109
- }
110
- async function writeCFPagesRedirects(nitro) {
111
- const redirectsPath = join(nitro.options.output.publicDir, "_redirects");
112
- const staticFallback = existsSync(
113
- join(nitro.options.output.publicDir, "404.html")
114
- ) ? "/* /404.html 404" : "";
115
- const contents = [staticFallback];
116
- const rules = Object.entries(nitro.options.routeRules).sort(
117
- (a, b) => a[0].split(/\/(?!\*)/).length - b[0].split(/\/(?!\*)/).length
118
- );
119
- for (const [key, routeRules] of rules.filter(
120
- ([_, routeRules2]) => routeRules2.redirect
121
- )) {
122
- const code = routeRules.redirect.statusCode;
123
- contents.unshift(
124
- `${key.replace("/**", "/*")} ${routeRules.redirect.to} ${code}`
125
- );
126
- }
127
- if (existsSync(redirectsPath)) {
128
- const currentRedirects = await fsp.readFile(redirectsPath, "utf8");
129
- if (/^\/\* /m.test(currentRedirects)) {
130
- nitro.logger.info(
131
- "Not adding Nitro fallback to `_redirects` (as an existing fallback was found)."
132
- );
133
- return;
134
- }
135
- nitro.logger.info(
136
- "Adding Nitro fallback to `_redirects` to handle all unmatched routes."
137
- );
138
- contents.unshift(currentRedirects);
139
- }
140
- await fsp.writeFile(redirectsPath, contents.join("\n"));
141
- }
142
- async function writeCFWrangler(nitro) {
143
- const inlineConfig = nitro.options.cloudflare?.wrangler || {};
144
- if (!inlineConfig || Object.keys(inlineConfig).length === 0) {
145
- return;
146
- }
147
- let configFromFile = {};
148
- const configPath = resolve(
149
- nitro.options.rootDir,
150
- inlineConfig.configPath || "wrangler.toml"
151
- );
152
- if (existsSync(configPath)) {
153
- configFromFile = parseTOML(
154
- await fsp.readFile(configPath, "utf8")
155
- );
156
- }
157
- const wranglerConfig = defu(configFromFile, inlineConfig);
158
- const wranglerPath = join(
159
- isCI ? nitro.options.rootDir : nitro.options.buildDir,
160
- "wrangler.toml"
161
- );
162
- await fsp.writeFile(wranglerPath, stringifyTOML(wranglerConfig));
163
- }
@@ -1,2 +0,0 @@
1
- declare const _default: readonly [any, any];
2
- export default _default;
@@ -1,151 +0,0 @@
1
- import { builtinModules } from "node:module";
2
- import { isAbsolute, resolve } from "pathe";
3
- import MagicString from "magic-string";
4
- import { findStaticImports } from "mlly";
5
- import { defineNitroPreset } from "nitropack/kit";
6
- import { writeFile } from "nitropack/kit";
7
- const ImportMetaRe = /import\.meta|globalThis._importMeta_/;
8
- const denoDeploy = defineNitroPreset(
9
- {
10
- entry: "./runtime/deno-deploy",
11
- exportConditions: ["deno"],
12
- node: false,
13
- noExternals: true,
14
- serveStatic: "deno",
15
- commands: {
16
- preview: "",
17
- deploy: "cd ./ && deployctl deploy --project=<project_name> server/index.ts"
18
- },
19
- unenv: {
20
- polyfill: ["nitropack/runtime/internal/polyfill/deno-env"]
21
- },
22
- rollupConfig: {
23
- preserveEntrySignatures: false,
24
- external: (id) => id.startsWith("https://"),
25
- output: {
26
- entryFileNames: "index.ts",
27
- manualChunks: (id) => "index",
28
- format: "esm"
29
- }
30
- }
31
- },
32
- {
33
- name: "deno-deploy",
34
- aliases: ["deno"],
35
- url: import.meta.url
36
- }
37
- );
38
- const denoServer = defineNitroPreset(
39
- {
40
- extends: "node-server",
41
- entry: "./runtime/deno-server",
42
- exportConditions: ["deno"],
43
- commands: {
44
- preview: "deno task --config ./deno.json start"
45
- },
46
- unenv: {
47
- inject: {
48
- global: ["unenv/runtime/polyfill/global-this", "default"],
49
- Buffer: ["node:buffer", "Buffer"],
50
- setTimeout: ["node:timers", "setTimeout"],
51
- clearTimeout: ["node:timers", "clearTimeout"],
52
- setInterval: ["node:timers", "setInterval"],
53
- clearInterval: ["node:timers", "clearInterval"],
54
- setImmediate: ["node:timers", "setImmediate"],
55
- clearImmediate: ["node:timers", "clearImmediate"]
56
- // process: ["node:process", "default"],
57
- }
58
- },
59
- rollupConfig: {
60
- output: {
61
- hoistTransitiveImports: false
62
- },
63
- plugins: [
64
- {
65
- name: "rollup-plugin-node-deno",
66
- resolveId(id) {
67
- id = id.replace("node:", "");
68
- if (builtinModules.includes(id)) {
69
- return {
70
- id: `node:${id}`,
71
- moduleSideEffects: false,
72
- external: true
73
- };
74
- }
75
- if (isHTTPImport(id)) {
76
- return {
77
- id,
78
- external: true
79
- };
80
- }
81
- },
82
- renderChunk(code) {
83
- const s = new MagicString(code);
84
- const imports = findStaticImports(code);
85
- for (const i of imports) {
86
- if (!i.specifier.startsWith(".") && !isAbsolute(i.specifier) && !isHTTPImport(i.specifier) && !i.specifier.startsWith("npm:")) {
87
- const specifier = i.specifier.replace("node:", "");
88
- s.replace(
89
- i.code,
90
- i.code.replace(
91
- new RegExp(`(?<quote>['"])${i.specifier}\\k<quote>`),
92
- JSON.stringify(
93
- builtinModules.includes(specifier) ? "node:" + specifier : "npm:" + specifier
94
- )
95
- )
96
- );
97
- }
98
- }
99
- if (s.hasChanged()) {
100
- return {
101
- code: s.toString(),
102
- map: s.generateMap({ includeContent: true })
103
- };
104
- }
105
- }
106
- },
107
- {
108
- name: "inject-process",
109
- renderChunk: {
110
- order: "post",
111
- handler(code, chunk) {
112
- if (!chunk.isEntry && (!ImportMetaRe.test(code) || code.includes("ROLLUP_NO_REPLACE"))) {
113
- return;
114
- }
115
- const s = new MagicString(code);
116
- s.prepend(
117
- "import __process__ from 'node:process';globalThis.process=globalThis.process||__process__;"
118
- );
119
- return {
120
- code: s.toString(),
121
- map: s.generateMap({ includeContent: true })
122
- };
123
- }
124
- }
125
- }
126
- ]
127
- },
128
- hooks: {
129
- async compiled(nitro) {
130
- const denoJSON = {
131
- tasks: {
132
- start: "deno run --unstable --allow-net --allow-read --allow-write --allow-env ./server/index.mjs"
133
- }
134
- };
135
- await writeFile(
136
- resolve(nitro.options.output.dir, "deno.json"),
137
- JSON.stringify(denoJSON, null, 2)
138
- );
139
- }
140
- }
141
- },
142
- {
143
- name: "deno-server",
144
- url: import.meta.url
145
- }
146
- );
147
- export default [denoDeploy, denoServer];
148
- const HTTP_IMPORT_RE = /^(https?:)?\/\//;
149
- function isHTTPImport(id) {
150
- return HTTP_IMPORT_RE.test(id);
151
- }
@@ -1 +0,0 @@
1
- import "#nitro-internal-pollyfills";
@@ -1,31 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- import { useNitroApp } from "nitropack/runtime";
3
- import wsAdapter from "crossws/adapters/deno";
4
- const nitroApp = useNitroApp();
5
- const ws = import.meta._websocket ? wsAdapter(nitroApp.h3App.websocket) : void 0;
6
- Deno.serve((request, info) => {
7
- if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
8
- return ws.handleUpgrade(request, info);
9
- }
10
- return handleRequest(request, info);
11
- });
12
- async function handleRequest(request, info) {
13
- const url = new URL(request.url);
14
- const headers = new Headers(request.headers);
15
- headers.append("x-forwarded-for", info.remoteAddr.hostname);
16
- if (!headers.has("x-forwarded-proto")) {
17
- headers.set("x-forwarded-proto", "https");
18
- }
19
- let body;
20
- if (request.body) {
21
- body = await request.arrayBuffer();
22
- }
23
- return nitroApp.localFetch(url.pathname + url.search, {
24
- host: url.hostname,
25
- protocol: url.protocol,
26
- headers,
27
- method: request.method,
28
- redirect: request.redirect,
29
- body
30
- });
31
- }
@@ -1,3 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- declare const _default: {};
3
- export default _default;
@@ -1,65 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- import { useNitroApp } from "nitropack/runtime";
3
- import { useRuntimeConfig } from "nitropack/runtime";
4
- import { startScheduleRunner } from "nitropack/runtime/internal/task";
5
- import destr from "destr";
6
- import wsAdapter from "crossws/adapters/deno";
7
- const nitroApp = useNitroApp();
8
- if (Deno.env.get("DEBUG")) {
9
- addEventListener(
10
- "unhandledrejection",
11
- (event) => console.error("[nitro] [dev] [unhandledRejection]", event.reason)
12
- );
13
- addEventListener(
14
- "error",
15
- (event) => console.error("[nitro] [dev] [uncaughtException]", event.error)
16
- );
17
- } else {
18
- addEventListener(
19
- "unhandledrejection",
20
- (err) => console.error("[nitro] [production] [unhandledRejection] " + err)
21
- );
22
- addEventListener(
23
- "error",
24
- (event) => console.error("[nitro] [production] [uncaughtException] " + event.error)
25
- );
26
- }
27
- const serveOptions = {
28
- key: Deno.env.get("NITRO_SSL_KEY"),
29
- cert: Deno.env.get("NITRO_SSL_CERT"),
30
- port: destr(Deno.env.get("NITRO_PORT") || Deno.env.get("PORT")) || 3e3,
31
- hostname: Deno.env.get("NITRO_HOST") || Deno.env.get("HOST"),
32
- onListen: (opts) => {
33
- const baseURL = (useRuntimeConfig().app.baseURL || "").replace(/\/$/, "");
34
- const url = `${opts.hostname}:${opts.port}${baseURL}`;
35
- console.log(`Listening ${url}`);
36
- }
37
- };
38
- if (!serveOptions.key || !serveOptions.cert) {
39
- delete serveOptions.key;
40
- delete serveOptions.cert;
41
- }
42
- Deno.serve(serveOptions, handler);
43
- const ws = import.meta._websocket ? wsAdapter(nitroApp.h3App.websocket) : void 0;
44
- async function handler(request, info) {
45
- if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
46
- return ws.handleUpgrade(request, info);
47
- }
48
- const url = new URL(request.url);
49
- let body;
50
- if (request.body) {
51
- body = await request.arrayBuffer();
52
- }
53
- return nitroApp.localFetch(url.pathname + url.search, {
54
- host: url.hostname,
55
- protocol: url.protocol,
56
- headers: request.headers,
57
- method: request.method,
58
- redirect: request.redirect,
59
- body
60
- });
61
- }
62
- if (import.meta._tasks) {
63
- startScheduleRunner();
64
- }
65
- export default {};
@@ -1,2 +0,0 @@
1
- declare const _default: readonly [any];
2
- export default _default;
@@ -1,11 +0,0 @@
1
- import { defineNitroPreset } from "nitropack/kit";
2
- const digitalOcean = defineNitroPreset(
3
- {
4
- extends: "node-server"
5
- },
6
- {
7
- name: "digital-ocean",
8
- url: import.meta.url
9
- }
10
- );
11
- export default [digitalOcean];
@@ -1,2 +0,0 @@
1
- declare const _default: readonly [any];
2
- export default _default;
@@ -1,95 +0,0 @@
1
- import { promises as fsp } from "node:fs";
2
- import { resolve, dirname } from "pathe";
3
- import { defineNitroPreset } from "nitropack/kit";
4
- const edgio = defineNitroPreset(
5
- {
6
- extends: "node-server",
7
- commands: {
8
- deploy: "cd ./ && npm run deploy",
9
- preview: "cd ./ && npm run preview"
10
- },
11
- hooks: {
12
- async compiled(nitro) {
13
- await writeFile(
14
- resolve(nitro.options.output.dir, "edgio.config.js"),
15
- `module.exports = ${JSON.stringify(
16
- {
17
- connector: "./edgio",
18
- routes: "./routes.js",
19
- backends: {},
20
- includeFiles: {
21
- "server/**": true
22
- }
23
- },
24
- null,
25
- 2
26
- )}`
27
- );
28
- await writeFile(
29
- resolve(nitro.options.output.dir, "routes.js"),
30
- `
31
- import { Router } from '@edgio/core/router'
32
- import { isProductionBuild } from '@edgio/core/environment'
33
-
34
- const router = new Router()
35
-
36
- if (isProductionBuild()) {
37
- router.static('public')
38
- }
39
-
40
- router.fallback(({ renderWithApp }) => { renderWithApp() })
41
-
42
- export default router
43
- `.trim()
44
- );
45
- await writeFile(
46
- resolve(nitro.options.output.dir, "edgio/prod.js"),
47
- `
48
- module.exports = async function entry (port) {
49
- process.env.PORT = process.env.NITRO_PORT = port.toString()
50
- console.log('Starting Edgio server on port', port)
51
- await import('../server/index.mjs')
52
- console.log('Edgio server started')
53
- }
54
- `.trim()
55
- );
56
- await writeFile(
57
- resolve(nitro.options.output.dir, "package.json"),
58
- JSON.stringify(
59
- {
60
- name: "nitropack-edgio-output",
61
- version: "1.0.0",
62
- private: true,
63
- scripts: {
64
- build: "npm i && edgio build",
65
- deploy: "npm i && edgio deploy",
66
- start: "npm i && edgio run --production",
67
- preview: "npm i && edgio build && edgio run --production"
68
- },
69
- devDependencies: {
70
- "@edgio/cli": "^6",
71
- "@edgio/core": "^6"
72
- }
73
- },
74
- null,
75
- 2
76
- )
77
- );
78
- await writeFile(
79
- resolve(nitro.options.output.dir, "package-lock.json"),
80
- ""
81
- );
82
- }
83
- }
84
- },
85
- {
86
- name: "edgio",
87
- aliases: ["layer0"],
88
- url: import.meta.url
89
- }
90
- );
91
- export default [edgio];
92
- async function writeFile(path, contents) {
93
- await fsp.mkdir(dirname(path), { recursive: true });
94
- await fsp.writeFile(path, contents, "utf8");
95
- }
@@ -1,3 +0,0 @@
1
- export type { FirebaseOptions as PresetOptions } from "./types";
2
- declare const _default: readonly [any];
3
- export default _default;
@@ -1,51 +0,0 @@
1
- import { basename } from "pathe";
2
- import { defineNitroPreset } from "nitropack/kit";
3
- import { updatePackageJSON, writeFirebaseConfig } from "./utils.mjs";
4
- const firebase = defineNitroPreset(
5
- {
6
- entry: `./runtime/firebase-gen-{{ firebase.gen }}`,
7
- commands: {
8
- deploy: "npx firebase-tools deploy"
9
- },
10
- firebase: {
11
- // we need this defined here so it's picked up by the template in firebase's entry
12
- gen: Number.parseInt(process.env.NITRO_FIREBASE_GEN || "") || "default"
13
- },
14
- hooks: {
15
- async compiled(nitro) {
16
- await writeFirebaseConfig(nitro);
17
- await updatePackageJSON(nitro);
18
- },
19
- "rollup:before": (nitro, rollupConfig) => {
20
- const _gen = nitro.options.firebase?.gen;
21
- if (!_gen || _gen === "default") {
22
- nitro.logger.warn(
23
- "Neither `firebase.gen` or `NITRO_FIREBASE_GEN` is set. Nitro will default to Cloud Functions 1st generation. It is recommended to set this to the latest generation (currently `2`). Set the version to remove this warning. See https://nitro.unjs.io/deploy/providers/firebase for more information."
24
- );
25
- nitro.options.firebase = { gen: 1 };
26
- }
27
- nitro.options.appConfig.nitro = nitro.options.appConfig.nitro || {};
28
- nitro.options.appConfig.nitro.firebase = nitro.options.firebase;
29
- rollupConfig.plugins.unshift({
30
- name: "nitro:firebase",
31
- transform: (code, id) => {
32
- if (basename(id).startsWith("firebase-gen-")) {
33
- return {
34
- code: code.replace(
35
- /__firebaseServerFunctionName__/g,
36
- nitro.options.firebase?.serverFunctionName || "server"
37
- ),
38
- map: null
39
- };
40
- }
41
- }
42
- });
43
- }
44
- }
45
- },
46
- {
47
- name: "firebase",
48
- url: import.meta.url
49
- }
50
- );
51
- export default [firebase];
@@ -1,2 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- export declare const __firebaseServerFunctionName__: any;
@@ -1,8 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- import { useNitroApp } from "nitropack/runtime";
3
- import { useAppConfig } from "nitropack/runtime";
4
- import functions from "firebase-functions";
5
- import { toNodeListener } from "h3";
6
- const nitroApp = useNitroApp();
7
- const firebaseConfig = useAppConfig().nitro.firebase;
8
- export const __firebaseServerFunctionName__ = functions.region(firebaseConfig.region ?? functions.RESET_VALUE).runWith(firebaseConfig.runtimeOptions ?? functions.RESET_VALUE).https.onRequest(toNodeListener(nitroApp.h3App));
@@ -1,2 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- export declare const __firebaseServerFunctionName__: import("firebase-functions/v2/https").HttpsFunction;
@@ -1,15 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- import { useNitroApp } from "nitropack/runtime";
3
- import { useAppConfig } from "nitropack/runtime";
4
- import { onRequest } from "firebase-functions/v2/https";
5
- import { toNodeListener } from "h3";
6
- const nitroApp = useNitroApp();
7
- const firebaseConfig = useAppConfig().nitro.firebase;
8
- export const __firebaseServerFunctionName__ = onRequest(
9
- {
10
- // Must be set to public to allow all public requests by default
11
- invoker: "public",
12
- ...firebaseConfig.httpsOptions
13
- },
14
- toNodeListener(nitroApp.h3App)
15
- );
@@ -1 +0,0 @@
1
- export { __firebaseServerFunctionName__ } from "./firebase-gen-1";
@@ -1 +0,0 @@
1
- export { __firebaseServerFunctionName__ } from "./firebase-gen-1.mjs";
@@ -1,37 +0,0 @@
1
- import type { HttpsOptions } from "firebase-functions/v2/https";
2
- import type { RuntimeOptions, region } from "firebase-functions";
3
- export type FirebaseOptions = FirebaseOptionsGen1 | FirebaseOptionsGen2;
4
- export interface FirebaseOptionsBase {
5
- gen: 1 | 2;
6
- /**
7
- * Firebase functions node runtime version.
8
- * @see https://cloud.google.com/functions/docs/concepts/nodejs-runtime
9
- */
10
- nodeVersion?: "20" | "18" | "16";
11
- /**
12
- * When deploying multiple apps within the same Firebase project
13
- * you must give your server a unique name in order to avoid overwriting your functions.
14
- *
15
- * @default "server"
16
- */
17
- serverFunctionName?: string;
18
- }
19
- export interface FirebaseOptionsGen1 extends FirebaseOptionsBase {
20
- gen: 1;
21
- /**
22
- * Firebase functions 1st generation region passed to `functions.region()`.
23
- */
24
- region?: Parameters<typeof region>[0];
25
- /**
26
- * Firebase functions 1st generation runtime options passed to `functions.runWith()`.
27
- */
28
- runtimeOptions?: RuntimeOptions;
29
- }
30
- export interface FirebaseOptionsGen2 extends FirebaseOptionsBase {
31
- gen: 2;
32
- /**
33
- * Firebase functions 2nd generation https options passed to `onRequest`.
34
- * @see https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.https.httpsoptions
35
- */
36
- httpsOptions?: HttpsOptions;
37
- }