nitropack-nightly 2.10.0-28638494.93d002b7 → 3.0.0-beta-28638629.b32e0831-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 (287) hide show
  1. package/README.md +1 -1
  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 -2435
  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 -24
  92. package/dist/presets/azure/runtime/azure-swa.d.ts +0 -5
  93. package/dist/presets/azure/runtime/azure-swa.mjs +0 -30
  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 -102
  108. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.ts +0 -20
  109. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +0 -55
  110. package/dist/presets/cloudflare/runtime/cloudflare-worker.d.ts +0 -1
  111. package/dist/presets/cloudflare/runtime/cloudflare-worker.mjs +0 -63
  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 -148
  120. package/dist/presets/deno/runtime/_deno-env-polyfill.d.ts +0 -0
  121. package/dist/presets/deno/runtime/_deno-env-polyfill.mjs +0 -1
  122. package/dist/presets/deno/runtime/deno-deploy.d.ts +0 -2
  123. package/dist/presets/deno/runtime/deno-deploy.mjs +0 -32
  124. package/dist/presets/deno/runtime/deno-server.d.ts +0 -4
  125. package/dist/presets/deno/runtime/deno-server.mjs +0 -66
  126. package/dist/presets/digitalocean/preset.d.ts +0 -2
  127. package/dist/presets/digitalocean/preset.mjs +0 -11
  128. package/dist/presets/edgio/preset.d.ts +0 -2
  129. package/dist/presets/edgio/preset.mjs +0 -95
  130. package/dist/presets/firebase/preset.d.ts +0 -3
  131. package/dist/presets/firebase/preset.mjs +0 -51
  132. package/dist/presets/firebase/runtime/firebase-gen-1.d.ts +0 -2
  133. package/dist/presets/firebase/runtime/firebase-gen-1.mjs +0 -8
  134. package/dist/presets/firebase/runtime/firebase-gen-2.d.ts +0 -2
  135. package/dist/presets/firebase/runtime/firebase-gen-2.mjs +0 -15
  136. package/dist/presets/firebase/runtime/firebase-gen-default.d.ts +0 -1
  137. package/dist/presets/firebase/runtime/firebase-gen-default.mjs +0 -1
  138. package/dist/presets/firebase/types.d.ts +0 -37
  139. package/dist/presets/firebase/types.mjs +0 -0
  140. package/dist/presets/firebase/utils.d.ts +0 -3
  141. package/dist/presets/firebase/utils.mjs +0 -50
  142. package/dist/presets/flightcontrol/preset.d.ts +0 -2
  143. package/dist/presets/flightcontrol/preset.mjs +0 -11
  144. package/dist/presets/heroku/preset.d.ts +0 -2
  145. package/dist/presets/heroku/preset.mjs +0 -11
  146. package/dist/presets/iis/preset.d.ts +0 -2
  147. package/dist/presets/iis/preset.mjs +0 -32
  148. package/dist/presets/iis/utils.d.ts +0 -3
  149. package/dist/presets/iis/utils.mjs +0 -159
  150. package/dist/presets/koyeb/preset.d.ts +0 -2
  151. package/dist/presets/koyeb/preset.mjs +0 -11
  152. package/dist/presets/netlify/legacy/preset.d.ts +0 -2
  153. package/dist/presets/netlify/legacy/preset.mjs +0 -142
  154. package/dist/presets/netlify/legacy/runtime/_deno-env-polyfill.d.ts +0 -0
  155. package/dist/presets/netlify/legacy/runtime/_deno-env-polyfill.mjs +0 -1
  156. package/dist/presets/netlify/legacy/runtime/netlify-builder.d.ts +0 -3
  157. package/dist/presets/netlify/legacy/runtime/netlify-builder.mjs +0 -5
  158. package/dist/presets/netlify/legacy/runtime/netlify-edge.d.ts +0 -3
  159. package/dist/presets/netlify/legacy/runtime/netlify-edge.mjs +0 -26
  160. package/dist/presets/netlify/legacy/runtime/netlify-lambda.d.ts +0 -4
  161. package/dist/presets/netlify/legacy/runtime/netlify-lambda.mjs +0 -39
  162. package/dist/presets/netlify/legacy/runtime/netlify.d.ts +0 -4
  163. package/dist/presets/netlify/legacy/runtime/netlify.mjs +0 -22
  164. package/dist/presets/netlify/legacy/utils.d.ts +0 -4
  165. package/dist/presets/netlify/legacy/utils.mjs +0 -113
  166. package/dist/presets/netlify/preset.d.ts +0 -3
  167. package/dist/presets/netlify/preset.mjs +0 -127
  168. package/dist/presets/netlify/runtime/_deno-env-polyfill.d.ts +0 -0
  169. package/dist/presets/netlify/runtime/_deno-env-polyfill.mjs +0 -1
  170. package/dist/presets/netlify/runtime/netlify-edge.d.ts +0 -2
  171. package/dist/presets/netlify/runtime/netlify-edge.mjs +0 -25
  172. package/dist/presets/netlify/runtime/netlify.d.ts +0 -4
  173. package/dist/presets/netlify/runtime/netlify.mjs +0 -54
  174. package/dist/presets/netlify/types.d.ts +0 -12
  175. package/dist/presets/netlify/types.mjs +0 -0
  176. package/dist/presets/netlify/utils.d.ts +0 -5
  177. package/dist/presets/netlify/utils.mjs +0 -94
  178. package/dist/presets/node/preset.d.ts +0 -2
  179. package/dist/presets/node/preset.mjs +0 -49
  180. package/dist/presets/node/runtime/cli.d.ts +0 -1
  181. package/dist/presets/node/runtime/cli.mjs +0 -21
  182. package/dist/presets/node/runtime/cluster.d.ts +0 -1
  183. package/dist/presets/node/runtime/cluster.mjs +0 -60
  184. package/dist/presets/node/runtime/node-listener.d.ts +0 -6
  185. package/dist/presets/node/runtime/node-listener.mjs +0 -15
  186. package/dist/presets/node/runtime/node-server.d.ts +0 -3
  187. package/dist/presets/node/runtime/node-server.mjs +0 -44
  188. package/dist/presets/platform.sh/preset.d.ts +0 -2
  189. package/dist/presets/platform.sh/preset.mjs +0 -11
  190. package/dist/presets/render.com/preset.d.ts +0 -2
  191. package/dist/presets/render.com/preset.mjs +0 -11
  192. package/dist/presets/stormkit/preset.d.ts +0 -2
  193. package/dist/presets/stormkit/preset.mjs +0 -15
  194. package/dist/presets/stormkit/runtime/stormkit.d.ts +0 -21
  195. package/dist/presets/stormkit/runtime/stormkit.mjs +0 -32
  196. package/dist/presets/vercel/preset.d.ts +0 -3
  197. package/dist/presets/vercel/preset.mjs +0 -104
  198. package/dist/presets/vercel/runtime/vercel-edge.d.ts +0 -2
  199. package/dist/presets/vercel/runtime/vercel-edge.mjs +0 -22
  200. package/dist/presets/vercel/runtime/vercel.d.ts +0 -4
  201. package/dist/presets/vercel/runtime/vercel.mjs +0 -17
  202. package/dist/presets/vercel/types.d.ts +0 -78
  203. package/dist/presets/vercel/types.mjs +0 -0
  204. package/dist/presets/vercel/utils.d.ts +0 -5
  205. package/dist/presets/vercel/utils.mjs +0 -186
  206. package/dist/presets/winterjs/preset.d.ts +0 -2
  207. package/dist/presets/winterjs/preset.mjs +0 -20
  208. package/dist/presets/winterjs/runtime/winterjs.d.ts +0 -1
  209. package/dist/presets/winterjs/runtime/winterjs.mjs +0 -69
  210. package/dist/presets/zeabur/preset.d.ts +0 -2
  211. package/dist/presets/zeabur/preset.mjs +0 -70
  212. package/dist/presets/zeabur/runtime/zeabur.d.ts +0 -4
  213. package/dist/presets/zeabur/runtime/zeabur.mjs +0 -8
  214. package/dist/runtime/app.d.ts +0 -2
  215. package/dist/runtime/app.mjs +0 -1
  216. package/dist/runtime/cache.d.ts +0 -1
  217. package/dist/runtime/cache.mjs +0 -6
  218. package/dist/runtime/config.d.ts +0 -1
  219. package/dist/runtime/config.mjs +0 -1
  220. package/dist/runtime/context.d.ts +0 -1
  221. package/dist/runtime/context.mjs +0 -1
  222. package/dist/runtime/database.d.ts +0 -1
  223. package/dist/runtime/database.mjs +0 -1
  224. package/dist/runtime/error.d.ts +0 -1
  225. package/dist/runtime/error.mjs +0 -1
  226. package/dist/runtime/internal/app.d.ts +0 -3
  227. package/dist/runtime/internal/app.mjs +0 -152
  228. package/dist/runtime/internal/cache.d.ts +0 -8
  229. package/dist/runtime/internal/cache.mjs +0 -329
  230. package/dist/runtime/internal/client.d.ts +0 -1
  231. package/dist/runtime/internal/client.mjs +0 -4
  232. package/dist/runtime/internal/config.d.ts +0 -6
  233. package/dist/runtime/internal/config.mjs +0 -58
  234. package/dist/runtime/internal/context.d.ts +0 -12
  235. package/dist/runtime/internal/context.mjs +0 -17
  236. package/dist/runtime/internal/database.d.ts +0 -2
  237. package/dist/runtime/internal/database.mjs +0 -14
  238. package/dist/runtime/internal/debug.d.ts +0 -2
  239. package/dist/runtime/internal/debug.mjs +0 -5
  240. package/dist/runtime/internal/error.d.ts +0 -4
  241. package/dist/runtime/internal/error.mjs +0 -71
  242. package/dist/runtime/internal/index.d.ts +0 -6
  243. package/dist/runtime/internal/index.mjs +0 -16
  244. package/dist/runtime/internal/lib/http-graceful-shutdown.d.ts +0 -16
  245. package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +0 -213
  246. package/dist/runtime/internal/meta.d.ts +0 -2
  247. package/dist/runtime/internal/meta.mjs +0 -3
  248. package/dist/runtime/internal/plugin.d.ts +0 -3
  249. package/dist/runtime/internal/plugin.mjs +0 -4
  250. package/dist/runtime/internal/renderer.d.ts +0 -2
  251. package/dist/runtime/internal/renderer.mjs +0 -38
  252. package/dist/runtime/internal/route-rules.d.ts +0 -14
  253. package/dist/runtime/internal/route-rules.mjs +0 -67
  254. package/dist/runtime/internal/routes/openapi.d.ts +0 -3
  255. package/dist/runtime/internal/routes/openapi.mjs +0 -85
  256. package/dist/runtime/internal/routes/scalar.d.ts +0 -2
  257. package/dist/runtime/internal/routes/scalar.mjs +0 -191
  258. package/dist/runtime/internal/routes/swagger.d.ts +0 -2
  259. package/dist/runtime/internal/routes/swagger.mjs +0 -39
  260. package/dist/runtime/internal/shutdown.d.ts +0 -10
  261. package/dist/runtime/internal/shutdown.mjs +0 -34
  262. package/dist/runtime/internal/static.d.ts +0 -2
  263. package/dist/runtime/internal/static.mjs +0 -89
  264. package/dist/runtime/internal/storage.d.ts +0 -2
  265. package/dist/runtime/internal/storage.mjs +0 -5
  266. package/dist/runtime/internal/task.d.ts +0 -17
  267. package/dist/runtime/internal/task.mjs +0 -73
  268. package/dist/runtime/internal/timing.d.ts +0 -2
  269. package/dist/runtime/internal/timing.mjs +0 -29
  270. package/dist/runtime/internal/utils.azure.d.ts +0 -2
  271. package/dist/runtime/internal/utils.azure.mjs +0 -51
  272. package/dist/runtime/internal/utils.d.ts +0 -23
  273. package/dist/runtime/internal/utils.env.d.ts +0 -7
  274. package/dist/runtime/internal/utils.env.mjs +0 -39
  275. package/dist/runtime/internal/utils.lambda.d.ts +0 -12
  276. package/dist/runtime/internal/utils.lambda.mjs +0 -30
  277. package/dist/runtime/internal/utils.mjs +0 -129
  278. package/dist/runtime/plugin.d.ts +0 -1
  279. package/dist/runtime/plugin.mjs +0 -1
  280. package/dist/runtime/storage.d.ts +0 -1
  281. package/dist/runtime/storage.mjs +0 -1
  282. package/dist/runtime/task.d.ts +0 -1
  283. package/dist/runtime/task.mjs +0 -1
  284. package/dist/runtime/utils.d.ts +0 -1
  285. package/dist/runtime/utils.mjs +0 -1
  286. package/dist/shared/nitro.DkCt8MDS.d.mts +0 -588
  287. package/dist/shared/nitro.DkCt8MDS.d.ts +0 -588
@@ -1,86 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- import { useNitroApp } from "nitropack/runtime";
3
- import { trapUnhandledNodeErrors } from "nitropack/runtime/internal";
4
- import { runTask } from "nitropack/runtime";
5
- import { startScheduleRunner } from "nitropack/runtime/internal";
6
- import { tasks, scheduledTasks } from "#nitro-internal-virtual/tasks";
7
- import { Server } from "node:http";
8
- import { tmpdir } from "node:os";
9
- import { join } from "node:path";
10
- import { mkdirSync } from "node:fs";
11
- import { threadId, parentPort } from "node:worker_threads";
12
- import { isWindows, provider } from "std-env";
13
- import {
14
- defineEventHandler,
15
- getQuery,
16
- getRouterParam,
17
- toNodeListener,
18
- readBody
19
- } from "h3";
20
- import wsAdapter from "crossws/adapters/node";
21
- const nitroApp = useNitroApp();
22
- const server = new Server(toNodeListener(nitroApp.h3App));
23
- if (import.meta._websocket) {
24
- const { handleUpgrade } = wsAdapter(nitroApp.h3App.websocket);
25
- server.on("upgrade", handleUpgrade);
26
- }
27
- function getAddress() {
28
- if (provider === "stackblitz" || process.env.NITRO_NO_UNIX_SOCKET || process.versions.bun) {
29
- return 0;
30
- }
31
- const socketName = `worker-${process.pid}-${threadId}.sock`;
32
- if (isWindows) {
33
- return join(String.raw`\\.\pipe\nitro`, socketName);
34
- } else {
35
- const socketDir = join(tmpdir(), "nitro");
36
- mkdirSync(socketDir, { recursive: true });
37
- return join(socketDir, socketName);
38
- }
39
- }
40
- const listenAddress = getAddress();
41
- const listener = server.listen(listenAddress, () => {
42
- const _address = server.address();
43
- parentPort?.postMessage({
44
- event: "listen",
45
- address: typeof _address === "string" ? { socketPath: _address } : { host: "localhost", port: _address?.port }
46
- });
47
- });
48
- nitroApp.router.get(
49
- "/_nitro/tasks",
50
- defineEventHandler(async (event) => {
51
- const _tasks = await Promise.all(
52
- Object.entries(tasks).map(async ([name, task]) => {
53
- const _task = await task.resolve?.();
54
- return [name, { description: _task?.meta?.description }];
55
- })
56
- );
57
- return {
58
- tasks: Object.fromEntries(_tasks),
59
- scheduledTasks
60
- };
61
- })
62
- );
63
- nitroApp.router.use(
64
- "/_nitro/tasks/:name",
65
- defineEventHandler(async (event) => {
66
- const name = getRouterParam(event, "name");
67
- const payload = {
68
- ...getQuery(event),
69
- ...await readBody(event).then((r) => r?.payload).catch(() => ({}))
70
- };
71
- return await runTask(name, { payload });
72
- })
73
- );
74
- trapUnhandledNodeErrors();
75
- async function onShutdown(signal) {
76
- await nitroApp.hooks.callHook("close");
77
- }
78
- parentPort?.on("message", async (msg) => {
79
- if (msg && msg.event === "shutdown") {
80
- await onShutdown();
81
- parentPort?.postMessage({ event: "exit" });
82
- }
83
- });
84
- if (import.meta._tasks) {
85
- startScheduleRunner();
86
- }
@@ -1,3 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- export declare const localFetch: any;
3
- export declare const closePrerenderer: () => any;
@@ -1,7 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- import { useNitroApp } from "nitropack/runtime";
3
- import { trapUnhandledNodeErrors } from "nitropack/runtime/internal";
4
- const nitroApp = useNitroApp();
5
- export const localFetch = nitroApp.localFetch;
6
- export const closePrerenderer = () => nitroApp.hooks.callHook("close");
7
- trapUnhandledNodeErrors();
@@ -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 { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
4
- const nitroApp = useNitroApp();
5
- addEventListener("fetch", (event) => {
6
- const url = new URL(event.request.url);
7
- if (isPublicAssetURL(url.pathname) || url.pathname.includes("/_server/")) {
8
- return;
9
- }
10
- event.respondWith(handleEvent(url, event));
11
- });
12
- async function handleEvent(url, event) {
13
- let body;
14
- if (event.request.body) {
15
- body = await event.request.arrayBuffer();
16
- }
17
- return nitroApp.localFetch(url.pathname + url.search, {
18
- host: url.hostname,
19
- protocol: url.protocol,
20
- headers: event.request.headers,
21
- method: event.request.method,
22
- redirect: event.request.redirect,
23
- body
24
- });
25
- }
26
- self.addEventListener("install", () => {
27
- self.skipWaiting();
28
- });
29
- self.addEventListener("activate", (event) => {
30
- event.waitUntil(self.clients.claim());
31
- });
@@ -1,2 +0,0 @@
1
- declare const _default: readonly [any];
2
- export default _default;
@@ -1,110 +0,0 @@
1
- import { existsSync, promises as fsp } from "node:fs";
2
- import { resolve } from "pathe";
3
- import { joinURL } from "ufo";
4
- import { defineNitroPreset } from "nitropack/kit";
5
- const serviceWorker = defineNitroPreset(
6
- () => {
7
- return {
8
- extends: "base-worker",
9
- entry: "./runtime/service-worker",
10
- output: {
11
- serverDir: "{{ output.dir }}/public/server"
12
- },
13
- commands: {
14
- preview: "npx serve ./public"
15
- },
16
- hooks: {
17
- "prerender:generate"(route, nitro) {
18
- const script = scriptTemplate(nitro.options.baseURL);
19
- route.contents = (route.contents || "").replace(
20
- "</head>",
21
- `${script}
22
- </head>`
23
- );
24
- },
25
- async compiled(nitro) {
26
- await fsp.writeFile(
27
- resolve(nitro.options.output.publicDir, "sw.js"),
28
- `self.importScripts('${joinURL(
29
- nitro.options.baseURL,
30
- "server/index.mjs"
31
- )}');`,
32
- "utf8"
33
- );
34
- const html = htmlTemplate(nitro.options.baseURL);
35
- if (!existsSync(resolve(nitro.options.output.publicDir, "index.html"))) {
36
- await fsp.writeFile(
37
- resolve(nitro.options.output.publicDir, "index.html"),
38
- html,
39
- "utf8"
40
- );
41
- }
42
- if (!existsSync(resolve(nitro.options.output.publicDir, "200.html"))) {
43
- await fsp.writeFile(
44
- resolve(nitro.options.output.publicDir, "200.html"),
45
- html,
46
- "utf8"
47
- );
48
- }
49
- if (!existsSync(resolve(nitro.options.output.publicDir, "404.html"))) {
50
- await fsp.writeFile(
51
- resolve(nitro.options.output.publicDir, "404.html"),
52
- html,
53
- "utf8"
54
- );
55
- }
56
- }
57
- }
58
- };
59
- },
60
- {
61
- name: "service-worker",
62
- url: import.meta.url
63
- }
64
- );
65
- export default [serviceWorker];
66
- function htmlTemplate(baseURL = "/") {
67
- return (
68
- /* html */
69
- `<!DOCTYPE html>
70
- <html>
71
- <head>
72
- <meta charset="utf-8">
73
- <link rel="prefetch" href="${joinURL(baseURL, "sw.js")}">
74
- <link rel="prefetch" href="${joinURL(baseURL, "server/index.mjs")}">
75
- ${scriptTemplate(baseURL)}
76
- </head>
77
- <body>
78
- Initializing nitro service worker...
79
- </body>
80
- </html>`
81
- );
82
- }
83
- function scriptTemplate(baseURL = "/") {
84
- return (
85
- /* js */
86
- `
87
- <script>
88
- async function register () {
89
- const registration = await navigator.serviceWorker.register('${joinURL(
90
- baseURL,
91
- "sw.js"
92
- )}')
93
- await navigator.serviceWorker.ready
94
- registration.active.addEventListener('statechange', (event) => {
95
- if (event.target.state === 'activated') {
96
- window.location.reload()
97
- }
98
- })
99
- }
100
- if ('serviceWorker' in navigator) {
101
- if (location.hostname !== 'localhost' && location.protocol === 'http:') {
102
- location.replace(location.href.replace('http://', 'https://'))
103
- } else {
104
- register()
105
- }
106
- }
107
- <\/script>
108
- `
109
- );
110
- }
@@ -1,8 +0,0 @@
1
- import type { NitroPreset, NitroPresetMeta } from "nitropack/types";
2
- import { type CompatibilityDateSpec } from "compatx";
3
- export declare function resolvePreset(name: string, opts: {
4
- static?: boolean;
5
- compatibilityDate?: CompatibilityDateSpec;
6
- }): Promise<(NitroPreset & {
7
- _meta?: NitroPresetMeta;
8
- }) | undefined>;
@@ -1,44 +0,0 @@
1
- import { kebabCase } from "scule";
2
- import { provider } from "std-env";
3
- import allPresets from "./_all.gen.mjs";
4
- import {
5
- resolveCompatibilityDatesFromEnv
6
- } from "compatx";
7
- const _stdProviderMap = {
8
- aws_amplify: "aws",
9
- azure_static: "azure",
10
- cloudflare_pages: "cloudflare"
11
- };
12
- export async function resolvePreset(name, opts) {
13
- const _name = kebabCase(name) || provider;
14
- const _compatDates = resolveCompatibilityDatesFromEnv(opts.compatibilityDate);
15
- const matches = allPresets.filter((preset2) => {
16
- const names = [
17
- preset2._meta.name,
18
- preset2._meta.stdName,
19
- ...preset2._meta.aliases || []
20
- ].filter(Boolean);
21
- if (!names.includes(_name)) {
22
- return false;
23
- }
24
- const _date = _compatDates[_stdProviderMap[preset2._meta.stdName]] || _compatDates[preset2._meta.stdName] || _compatDates[preset2._meta.name] || _compatDates.default;
25
- if (_date && preset2._meta.compatibilityDate && new Date(preset2._meta.compatibilityDate) > new Date(_date)) {
26
- return false;
27
- }
28
- return true;
29
- }).sort((a, b) => {
30
- const aDate = new Date(a._meta.compatibilityDate || 0);
31
- const bDate = new Date(b._meta.compatibilityDate || 0);
32
- return bDate > aDate ? 1 : -1;
33
- });
34
- const preset = matches.find(
35
- (p) => (p._meta.static || false) === (opts?.static || false)
36
- ) || matches[0];
37
- if (typeof preset === "function") {
38
- return preset();
39
- }
40
- if (!name && !preset) {
41
- return opts?.static ? resolvePreset("static", opts) : resolvePreset("node-server", opts);
42
- }
43
- return preset;
44
- }
@@ -1,2 +0,0 @@
1
- declare const _default: readonly [any, any, any];
2
- export default _default;
@@ -1,69 +0,0 @@
1
- import { defineNitroPreset } from "nitropack/kit";
2
- import fsp from "node:fs/promises";
3
- import { join } from "pathe";
4
- const _static = defineNitroPreset(
5
- {
6
- static: true,
7
- output: {
8
- dir: "{{ rootDir }}/.output",
9
- publicDir: "{{ output.dir }}/public"
10
- },
11
- prerender: {
12
- crawlLinks: true
13
- },
14
- commands: {
15
- preview: "npx serve ./public"
16
- }
17
- },
18
- {
19
- name: "static",
20
- static: true,
21
- url: import.meta.url
22
- }
23
- );
24
- const githubPages = defineNitroPreset(
25
- {
26
- extends: "static",
27
- commands: {
28
- deploy: "npx gh-pages --dotfiles -d ./public"
29
- },
30
- prerender: {
31
- routes: [
32
- "/",
33
- // https://docs.github.com/en/pages/getting-started-with-github-pages/creating-a-custom-404-page-for-your-github-pages-site
34
- "/404.html"
35
- ]
36
- },
37
- hooks: {
38
- async compiled(nitro) {
39
- await fsp.writeFile(
40
- join(nitro.options.output.publicDir, ".nojekyll"),
41
- ""
42
- );
43
- }
44
- }
45
- },
46
- {
47
- name: "github-pages",
48
- static: true,
49
- url: import.meta.url
50
- }
51
- );
52
- const gitlabPages = defineNitroPreset(
53
- {
54
- extends: "static",
55
- prerender: {
56
- routes: [
57
- "/",
58
- // https://docs.gitlab.com/ee/user/project/pages/introduction.html#custom-error-codes-pages
59
- "/404.html"
60
- ]
61
- }
62
- },
63
- {
64
- name: "gitlab-pages",
65
- static: true,
66
- url: import.meta.url
67
- }
68
- );
69
- export default [_static, githubPages, gitlabPages];
@@ -1,16 +0,0 @@
1
- import { PresetOptions as AwsAmplifyOptions } from "./aws-amplify/preset";
2
- import { PresetOptions as AzureOptions } from "./azure/preset";
3
- import { PresetOptions as CloudflareOptions } from "./cloudflare/preset";
4
- import { PresetOptions as FirebaseOptions } from "./firebase/preset";
5
- import { PresetOptions as NetlifyOptions } from "./netlify/preset";
6
- import { PresetOptions as VercelOptions } from "./vercel/preset";
7
- export interface PresetOptions {
8
- awsAmplify: AwsAmplifyOptions;
9
- azure: AzureOptions;
10
- cloudflare: CloudflareOptions;
11
- firebase: FirebaseOptions;
12
- netlify: NetlifyOptions;
13
- vercel: VercelOptions;
14
- }
15
- export type PresetName = "alwaysdata" | "aws-amplify" | "aws-lambda" | "aws-lambda-streaming" | "azure" | "azure-functions" | "azure-swa" | "base-worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-module" | "cloudflare-pages" | "cloudflare-pages-static" | "cloudflare-worker" | "deno" | "deno-deploy" | "deno-server" | "digital-ocean" | "edgio" | "firebase" | "flight-control" | "github-pages" | "gitlab-pages" | "heroku" | "iis" | "iis-handler" | "iis-node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlify-edge" | "netlify-legacy" | "netlify-static" | "nitro-dev" | "nitro-prerender" | "node" | "node-cluster" | "node-listener" | "node-server" | "platform-sh" | "render-com" | "service-worker" | "static" | "stormkit" | "vercel" | "vercel-edge" | "vercel-static" | "winterjs" | "zeabur" | "zeabur-static";
16
- export type PresetNameInput = "alwaysdata" | "aws-amplify" | "awsAmplify" | "aws_amplify" | "aws-lambda" | "awsLambda" | "aws_lambda" | "aws-lambda-streaming" | "awsLambdaStreaming" | "aws_lambda_streaming" | "azure" | "azure-functions" | "azureFunctions" | "azure_functions" | "azure-swa" | "azureSwa" | "azure_swa" | "base-worker" | "baseWorker" | "base_worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-module" | "cloudflareModule" | "cloudflare_module" | "cloudflare-pages" | "cloudflarePages" | "cloudflare_pages" | "cloudflare-pages-static" | "cloudflarePagesStatic" | "cloudflare_pages_static" | "cloudflare-worker" | "cloudflareWorker" | "cloudflare_worker" | "deno" | "deno-deploy" | "denoDeploy" | "deno_deploy" | "deno-server" | "denoServer" | "deno_server" | "digital-ocean" | "digitalOcean" | "digital_ocean" | "edgio" | "firebase" | "flight-control" | "flightControl" | "flight_control" | "github-pages" | "githubPages" | "github_pages" | "gitlab-pages" | "gitlabPages" | "gitlab_pages" | "heroku" | "iis" | "iis-handler" | "iisHandler" | "iis_handler" | "iis-node" | "iisNode" | "iis_node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlifyBuilder" | "netlify_builder" | "netlify-edge" | "netlifyEdge" | "netlify_edge" | "netlify-legacy" | "netlifyLegacy" | "netlify_legacy" | "netlify-static" | "netlifyStatic" | "netlify_static" | "nitro-dev" | "nitroDev" | "nitro_dev" | "nitro-prerender" | "nitroPrerender" | "nitro_prerender" | "node" | "node-cluster" | "nodeCluster" | "node_cluster" | "node-listener" | "nodeListener" | "node_listener" | "node-server" | "nodeServer" | "node_server" | "platform-sh" | "platformSh" | "platform_sh" | "render-com" | "renderCom" | "render_com" | "service-worker" | "serviceWorker" | "service_worker" | "static" | "stormkit" | "vercel" | "vercel-edge" | "vercelEdge" | "vercel_edge" | "vercel-static" | "vercelStatic" | "vercel_static" | "winterjs" | "zeabur" | "zeabur-static" | "zeaburStatic" | "zeabur_static" | (string & {});
File without changes
@@ -1,2 +0,0 @@
1
- declare const _default: readonly [any];
2
- export default _default;
@@ -1,14 +0,0 @@
1
- import { defineNitroPreset } from "nitropack/kit";
2
- const alwaysdata = defineNitroPreset(
3
- {
4
- extends: "node-server",
5
- commands: {
6
- deploy: "rsync -rRt --info=progress2 ./ [account]@ssh-[account].alwaysdata.net:www/my-app"
7
- }
8
- },
9
- {
10
- name: "alwaysdata",
11
- url: import.meta.url
12
- }
13
- );
14
- export default [alwaysdata];
@@ -1,3 +0,0 @@
1
- export type { AWSAmplifyOptions as PresetOptions } from "./types";
2
- declare const _default: readonly [any];
3
- export default _default;
@@ -1,27 +0,0 @@
1
- import { defineNitroPreset } from "nitropack/kit";
2
- import { writeAmplifyFiles } from "./utils.mjs";
3
- const awsAmplify = defineNitroPreset(
4
- {
5
- extends: "node-server",
6
- entry: "./runtime/aws-amplify",
7
- output: {
8
- dir: "{{ rootDir }}/.amplify-hosting",
9
- serverDir: "{{ output.dir }}/compute/default",
10
- publicDir: "{{ output.dir }}/static{{ baseURL }}"
11
- },
12
- commands: {
13
- preview: "node ./compute/default/server.js"
14
- },
15
- hooks: {
16
- async compiled(nitro) {
17
- await writeAmplifyFiles(nitro);
18
- }
19
- }
20
- },
21
- {
22
- name: "aws-amplify",
23
- stdName: "aws_amplify",
24
- url: import.meta.url
25
- }
26
- );
27
- export default [awsAmplify];
@@ -1 +0,0 @@
1
- import "#nitro-internal-pollyfills";
@@ -1,13 +0,0 @@
1
- import "#nitro-internal-pollyfills";
2
- import { useNitroApp } from "nitropack/runtime";
3
- import { Server } from "node:http";
4
- import { toNodeListener } from "h3";
5
- const nitroApp = useNitroApp();
6
- const server = new Server(toNodeListener(nitroApp.h3App));
7
- server.listen(3e3, (err) => {
8
- if (err) {
9
- console.error(err);
10
- } else {
11
- console.log(`Listening on http://localhost:3000 (AWS Amplify Hosting)`);
12
- }
13
- });
@@ -1,141 +0,0 @@
1
- export interface AmplifyComputeConfig {
2
- /**
3
- * The name property dictates the name of the provisioned compute resource. It is also the name
4
- * of the sub-directory in the `compute` folder in the deployment bundle.
5
- */
6
- name: string;
7
- /**
8
- * The runtime property dictates the runtime of the provisioned compute resource.
9
- * Values are subset of https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
10
- */
11
- runtime: "nodejs16.x" | "nodejs18.x";
12
- /**
13
- * Specifies the starting file from which code will run for the given compute resource.
14
- * The specified file should exist inside the given sub-directory that represents a compute resource.
15
- *
16
- * @example `"entrypoint.js"`
17
- */
18
- entrypoint: string;
19
- }
20
- export type AmplifyRouteTarget = {
21
- kind: "Static";
22
- cacheControl?: string;
23
- } | {
24
- kind: "ImageOptimization";
25
- cacheControl?: string;
26
- } | {
27
- kind: "Compute";
28
- /**
29
- * A string that indicates the name of the sub-directory in the given deployment bundle that
30
- * contains the primitive's executable code. Valid and required only for the Compute primitive.
31
- * The value here should point to one of the compute resources present in the given
32
- * deployment bundle. The only supported value for this field is default.
33
- */
34
- src: string;
35
- };
36
- export type AmplifyRoute = {
37
- /**
38
- * The path defines a glob pattern that matches incoming request paths (excluding querystring).
39
- * The first match in a given list of rules determines which routing rule is applied to the incoming request.
40
- * Only the following wildcard characters are supported as far as pattern matching is concerned: `*` (matches 0 or more characters)
41
- *
42
- * _Note_: The "/*" pattern is called a catch-all pattern and will match all incoming requests.
43
- * It is special because fallback routing is only supported for catch-all routes.
44
- *
45
- */
46
- path: string;
47
- /**
48
- * An object that dictates the target to route the matched request to.
49
- */
50
- target: AmplifyRouteTarget;
51
- /** An object that dictates the target to fallback to if the original target returns a 404. */
52
- fallback?: AmplifyRouteTarget;
53
- };
54
- export type AmplifyImageSettings = {
55
- /** Array of supported image widths */
56
- sizes: number[];
57
- /**
58
- * Array of allowed external domains that can use Image Optimization.
59
- * Leave empty for only allowing the deployment domain to use Image Optimization.
60
- */
61
- domains: string[];
62
- /**
63
- * Array of allowed external patterns that can use Image Optimization.
64
- * Similar to `domains` but provides more control with RegExp.
65
- */
66
- remotePatterns: {
67
- /** The protocol of the allowed remote pattern. Can be `http` or `https`. */
68
- protocol?: "http" | "https";
69
- /**
70
- * The hostname of the allowed remote pattern.
71
- * Can be literal or wildcard. Single `*` matches a single subdomain.
72
- * Double `**` matches any number of subdomains.
73
- * We will disallow blanket wildcards of `**` with nothing else.
74
- */
75
- hostname: string;
76
- /** The port of the allowed remote pattern. */
77
- port?: string;
78
- /** The pathname of the allowed remote pattern. */
79
- pathname?: string;
80
- }[];
81
- /** Array of allowed output image formats. */
82
- formats: ("image/avif" | "image/webp" | "image/gif" | "image/png" | "image/jpeg")[];
83
- /** Cache duration (in seconds) for the optimized images. */
84
- minimumCacheTTL: number;
85
- /** Allow SVG input image URLs. This is disabled by default for security purposes. */
86
- dangerouslyAllowSVG: boolean;
87
- };
88
- export interface AmplifyDeployManifest {
89
- /** The `version` property dictates the version of the Deployment Specification that has been implemented */
90
- version: 1;
91
- /**
92
- * The routes property allows framework authors to leverage the routing rules primitive.
93
- * Routing rules provide a mechanism by which incoming request paths can be routed to a specific target
94
- * in the deployment bundle. Routing rules only dictate the destination of an incoming request and they are
95
- * applied after rewrite/redirect rules have already transformed the request.
96
- *
97
- * Limits for routing rules:
98
- * - A limit of 25 rules will be enforced on the routes array
99
- */
100
- routes?: AmplifyRoute[];
101
- /**
102
- * The imageSettings property allows framework authors to customize the behavior of the image optimization primitive,
103
- * which provides on-demand optimization of images at runtime.
104
- */
105
- imageSettings?: AmplifyImageSettings;
106
- /**
107
- * Metadata about the provisioned compute resource(s). Each item in the array is an object that contains metadata
108
- * about that compute resource.
109
- *
110
- * For example, given the following directory structure:
111
- * ```
112
- * .amplify
113
- * └── compute
114
- * └── default
115
- * └── index.js
116
- * ```
117
- * The `computeResources` property would look like:
118
- * ```
119
- * [
120
- * {
121
- * name: 'default',
122
- * runtime: 'nodejs16.x',
123
- * entrypoint: 'index.js',
124
- * }
125
- * ]
126
- * ```
127
- */
128
- computeResources?: AmplifyComputeConfig[];
129
- framework: {
130
- name: string;
131
- version: string;
132
- };
133
- }
134
- export interface AWSAmplifyOptions {
135
- catchAllStaticFallback?: boolean;
136
- imageOptimization?: {
137
- path?: string;
138
- cacheControl?: string;
139
- };
140
- imageSettings?: AmplifyImageSettings;
141
- }
File without changes
@@ -1,2 +0,0 @@
1
- import type { Nitro } from "nitropack/types";
2
- export declare function writeAmplifyFiles(nitro: Nitro): Promise<void>;