nitro-nightly 3.0.1-alpha.1 → 3.0.1-alpha.2
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.
- package/README.md +2 -0
- package/dist/_build/common.mjs +24924 -52
- package/dist/_build/rolldown.mjs +29 -63
- package/dist/_build/rollup.mjs +22 -110
- package/dist/_build/vite.build.mjs +3 -43
- package/dist/{_dev.mjs → _chunks/dev.mjs} +45 -43
- package/dist/_chunks/{B-D1JOIz.mjs → nitro.mjs} +144 -308
- package/dist/_chunks/nitro2.mjs +101 -0
- package/dist/_chunks/utils.mjs +254 -0
- package/dist/{_chunks/Bqks5huO.mjs → _common.mjs} +24 -10
- package/dist/_libs/c12+giget+readdirp+chokidar.d.mts +214 -0
- package/dist/_libs/citty.mjs +140 -110
- package/dist/_libs/{plugin-commonjs.mjs → commondir+is-reference.mjs} +59 -250
- package/dist/_libs/compatx.d.mts +47 -0
- package/dist/_libs/confbox.mjs +388 -799
- package/dist/_libs/esbuild.d.mts +20 -0
- package/dist/_libs/estree-walker.mjs +1 -144
- package/dist/_libs/{plugin-node-resolve.mjs → hasown+resolve+deepmerge.mjs} +497 -78
- package/dist/_libs/httpxy.d.mts +79 -0
- package/dist/_libs/httpxy.mjs +6 -1
- package/dist/_libs/magic-string.d.mts +220 -0
- package/dist/_libs/mlly.d.mts +57 -0
- package/dist/_libs/nypm+giget+tinyexec.mjs +3603 -0
- package/dist/_libs/pkg-types.d.mts +23 -0
- package/dist/_libs/plugin-alias.mjs +4 -2
- package/dist/_libs/plugin-inject.mjs +5 -5
- package/dist/_libs/plugin-json.mjs +2 -2
- package/dist/_libs/pluginutils+plugin-commonjs.d.mts +241 -0
- package/dist/_libs/{vite-plugin-fullstack.mjs → pluginutils.mjs} +244 -153
- package/dist/_libs/rc9+c12+dotenv.mjs +972 -0
- package/dist/_libs/{chokidar.mjs → readdirp+chokidar.mjs} +237 -187
- package/dist/_libs/remapping.mjs +1 -1
- package/dist/_libs/{gen-mapping.mjs → resolve-uri+gen-mapping.mjs} +2 -166
- package/dist/_libs/rou3.d.mts +43 -0
- package/dist/_libs/rou3.mjs +9 -6
- package/dist/_libs/std-env.d.mts +4 -0
- package/dist/_libs/tsconfck.mjs +3 -3
- package/dist/_libs/{unimport.mjs → unimport+unplugin.mjs} +226 -1961
- package/dist/_libs/unplugin+unimport.d.mts +426 -0
- package/dist/_libs/unwasm.d.mts +29 -0
- package/dist/_presets.mjs +130 -80
- package/dist/builder.d.mts +4 -4
- package/dist/builder.mjs +6 -30
- package/dist/cli/_chunks/build.mjs +1 -1
- package/dist/cli/_chunks/dev.mjs +5 -11
- package/dist/cli/_chunks/list.mjs +1 -1
- package/dist/cli/_chunks/prepare.mjs +1 -1
- package/dist/cli/_chunks/run.mjs +1 -1
- package/dist/node_modules/@poppinss/colors/build/index.js +130 -160
- package/dist/node_modules/@poppinss/colors/package.json +20 -18
- package/dist/node_modules/@poppinss/exception/build/index.js +36 -55
- package/dist/node_modules/@poppinss/exception/package.json +19 -16
- package/dist/node_modules/@sindresorhus/is/distribution/index.js +46 -5
- package/dist/node_modules/@sindresorhus/is/package.json +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/index.js +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +1 -1
- package/dist/node_modules/@speed-highlight/core/package.json +2 -2
- package/dist/node_modules/hookable/dist/index.mjs +5 -6
- package/dist/node_modules/hookable/package.json +13 -13
- package/dist/node_modules/ufo/dist/index.mjs +16 -9
- package/dist/node_modules/ufo/package.json +15 -14
- package/dist/node_modules/unctx/package.json +16 -16
- package/dist/node_modules/youch/build/{chunk-4XB2BYKC.js → chunk-7QV3D5YX.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-PUHGL6HA.js → chunk-AUGPHE32.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-F4I6KX4R.js → chunk-CM7DWJNZ.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-YYEJ3AGB.js → chunk-EJH674NB.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-EUJBVOYB.js → chunk-OIJ3WD7L.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-HFSXRSKS.js → chunk-P36L72PL.js} +5 -3
- package/dist/node_modules/youch/build/{chunk-4YEN7HVQ.js → chunk-PE3GG3TN.js} +5 -1
- package/dist/node_modules/youch/build/{chunk-PINJDICN.js → chunk-X53OIOJH.js} +2 -4
- package/dist/node_modules/youch/build/index.js +8 -9
- package/dist/node_modules/youch/build/public/error_info/style.css +1 -0
- package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
- package/dist/node_modules/youch/build/public/error_stack/style.css +2 -3
- package/dist/node_modules/youch/package.json +1 -1
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -1
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +5 -6
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +1 -1
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -1
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -1
- package/dist/presets/_nitro/runtime/service-worker.mjs +2 -2
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -1
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +1 -1
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +9 -11
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +1 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +1 -1
- package/dist/presets/azure/runtime/azure-swa.d.mts +1 -1
- package/dist/presets/azure/runtime/azure-swa.mjs +1 -1
- package/dist/presets/bun/runtime/bun.d.mts +1 -1
- package/dist/presets/bun/runtime/bun.mjs +7 -8
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +3 -3
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +19 -17
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +17 -16
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +8 -9
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +12 -18
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -1
- package/dist/presets/deno/runtime/deno-deploy.mjs +4 -5
- package/dist/presets/deno/runtime/deno-server.d.mts +1 -1
- package/dist/presets/deno/runtime/deno-server.mjs +5 -6
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +1 -2
- package/dist/presets/netlify/runtime/netlify-edge.mjs +3 -2
- package/dist/presets/netlify/runtime/netlify.d.mts +3 -2
- package/dist/presets/netlify/runtime/netlify.mjs +3 -1
- package/dist/presets/node/runtime/node-cluster.d.mts +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +5 -6
- package/dist/presets/node/runtime/node-middleware.d.mts +1 -1
- package/dist/presets/node/runtime/node-middleware.mjs +4 -5
- package/dist/presets/node/runtime/node-server.d.mts +1 -1
- package/dist/presets/node/runtime/node-server.mjs +5 -6
- package/dist/presets/standard/runtime/server.d.mts +1 -1
- package/dist/presets/standard/runtime/server.mjs +1 -1
- package/dist/presets/stormkit/runtime/stormkit.d.mts +1 -1
- package/dist/presets/stormkit/runtime/stormkit.mjs +1 -1
- package/dist/presets/vercel/runtime/isr.d.mts +2 -0
- package/dist/presets/vercel/runtime/isr.mjs +19 -0
- package/dist/presets/vercel/runtime/vercel.node.d.mts +1 -1
- package/dist/presets/vercel/runtime/vercel.node.mjs +16 -7
- package/dist/presets/vercel/runtime/vercel.web.d.mts +1 -1
- package/dist/presets/vercel/runtime/vercel.web.mjs +18 -13
- package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -2
- package/dist/presets/winterjs/runtime/winterjs.mjs +1 -1
- package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
- package/dist/presets/zeabur/runtime/zeabur.mjs +1 -1
- package/dist/runtime/app.d.mts +1 -1
- package/dist/runtime/app.mjs +1 -1
- package/dist/runtime/internal/app.d.mts +7 -3
- package/dist/runtime/internal/app.mjs +29 -22
- package/dist/runtime/internal/database.mjs +1 -1
- package/dist/runtime/internal/error/dev.d.mts +0 -1
- package/dist/runtime/internal/error/dev.mjs +1 -1
- package/dist/runtime/internal/route-rules.d.mts +0 -4
- package/dist/runtime/internal/routes/dev-tasks.mjs +1 -1
- package/dist/runtime/internal/routes/openapi.d.mts +0 -1
- package/dist/runtime/internal/routes/openapi.mjs +3 -3
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +1 -1
- package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
- package/dist/runtime/internal/routes/scalar.d.mts +0 -1
- package/dist/runtime/internal/routes/scalar.mjs +4 -4
- package/dist/runtime/internal/routes/swagger.d.mts +0 -1
- package/dist/runtime/internal/routes/swagger.mjs +3 -3
- package/dist/runtime/internal/runtime-config.mjs +8 -8
- package/dist/runtime/internal/static.mjs +1 -1
- package/dist/runtime/internal/storage.mjs +1 -1
- package/dist/runtime/internal/task.mjs +1 -1
- package/dist/runtime/internal/vite/dev-entry.mjs +3 -4
- package/dist/runtime/internal/vite/{dev-worker.mjs → node-runner.mjs} +51 -6
- package/dist/runtime/meta.d.mts +1 -1
- package/dist/runtime/meta.mjs +1 -1
- package/dist/runtime/nitro.d.mts +0 -3
- package/dist/runtime/nitro.mjs +1 -1
- package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
- package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
- package/dist/runtime/virtual/database.d.mts +8 -0
- package/dist/runtime/virtual/database.mjs +2 -0
- package/dist/runtime/virtual/error-handler.d.mts +6 -0
- package/dist/runtime/virtual/error-handler.mjs +9 -0
- package/dist/runtime/virtual/feature-flags.d.mts +7 -0
- package/dist/runtime/virtual/feature-flags.mjs +7 -0
- package/dist/runtime/virtual/plugins.d.mts +3 -0
- package/dist/runtime/virtual/plugins.mjs +2 -0
- package/dist/runtime/virtual/polyfills.d.mts +3 -0
- package/dist/runtime/virtual/polyfills.mjs +2 -0
- package/dist/runtime/virtual/public-assets.d.mts +9 -0
- package/dist/runtime/virtual/public-assets.mjs +8 -0
- package/dist/runtime/virtual/renderer-template.d.mts +4 -0
- package/dist/runtime/virtual/renderer-template.mjs +7 -0
- package/dist/runtime/virtual/routing-meta.d.mts +7 -0
- package/dist/runtime/virtual/routing-meta.mjs +2 -0
- package/dist/runtime/virtual/routing.d.mts +8 -0
- package/dist/runtime/virtual/routing.mjs +11 -0
- package/dist/runtime/virtual/runtime-config.d.mts +3 -0
- package/dist/runtime/virtual/runtime-config.mjs +5 -0
- package/dist/runtime/virtual/server-assets.d.mts +6 -0
- package/dist/runtime/virtual/server-assets.mjs +12 -0
- package/dist/runtime/virtual/storage.d.mts +3 -0
- package/dist/runtime/virtual/storage.mjs +5 -0
- package/dist/runtime/virtual/tasks.d.mts +10 -0
- package/dist/runtime/virtual/tasks.mjs +3 -0
- package/dist/types/index.d.mts +292 -371
- package/dist/types/index.mjs +10 -0
- package/dist/vite.d.mts +7 -12
- package/dist/vite.mjs +734 -41
- package/lib/vite.types.d.mts +26 -0
- package/lib/vite.types.mjs +2 -0
- package/package.json +82 -53
- package/dist/_build/common2.mjs +0 -772
- package/dist/_build/vite.plugin.mjs +0 -768
- package/dist/_chunks/ANM1K1bE.mjs +0 -304
- package/dist/_chunks/BX9-zVkM.mjs +0 -59
- package/dist/_chunks/C7CbzoI1.mjs +0 -39
- package/dist/_libs/acorn.mjs +0 -5034
- package/dist/_libs/c12.mjs +0 -2858
- package/dist/_libs/commondir.mjs +0 -22
- package/dist/_libs/deepmerge.mjs +0 -86
- package/dist/_libs/dot-prop.mjs +0 -138
- package/dist/_libs/duplexer.mjs +0 -71
- package/dist/_libs/etag.mjs +0 -80
- package/dist/_libs/fdir.mjs +0 -514
- package/dist/_libs/function-bind.mjs +0 -63
- package/dist/_libs/giget.mjs +0 -19289
- package/dist/_libs/gzip-size.mjs +0 -21
- package/dist/_libs/hasown.mjs +0 -14
- package/dist/_libs/is-core-module.mjs +0 -220
- package/dist/_libs/is-module.mjs +0 -13
- package/dist/_libs/is-reference.mjs +0 -32
- package/dist/_libs/js-tokens.mjs +0 -382
- package/dist/_libs/knitwork.mjs +0 -124
- package/dist/_libs/local-pkg.mjs +0 -1686
- package/dist/_libs/magic-string.mjs +0 -939
- package/dist/_libs/mime.mjs +0 -1391
- package/dist/_libs/node-fetch-native.mjs +0 -173
- package/dist/_libs/path-parse.mjs +0 -47
- package/dist/_libs/pathe.mjs +0 -41
- package/dist/_libs/picomatch.mjs +0 -1673
- package/dist/_libs/plugin-replace.mjs +0 -104
- package/dist/_libs/pretty-bytes.mjs +0 -116
- package/dist/_libs/std-env.mjs +0 -158
- package/dist/_libs/strip-literal.mjs +0 -51
- package/dist/_libs/tinyglobby.mjs +0 -292
- package/dist/_libs/untyped.mjs +0 -271
- package/dist/_libs/unwasm.mjs +0 -5836
- package/dist/cli/_chunks/detect-acorn.mjs +0 -12
- package/dist/cli/_chunks/dist.mjs +0 -3
- package/dist/cli/_chunks/dist2.mjs +0 -3
- package/dist/cli/_chunks/dist3.mjs +0 -3
- package/dist/cli/_chunks/dist4.mjs +0 -4
- package/dist/cli/_chunks/dist5.mjs +0 -4
- package/dist/cli/_chunks/esm.mjs +0 -3
- package/dist/cli/_chunks/json5.mjs +0 -4
- package/dist/cli/_chunks/jsonc.mjs +0 -4
- package/dist/cli/_chunks/multipart-parser.mjs +0 -6
- package/dist/cli/_chunks/toml.mjs +0 -4
- package/dist/cli/_chunks/yaml.mjs +0 -4
- package/dist/node_modules/kleur/index.js +0 -110
- package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +0 -6
- package/lib/deps/ofetch.mjs +0 -1
- package/lib/deps/ofetch.mts +0 -1
- /package/dist/runtime/{vite-runtime.d.mts → vite.d.mts} +0 -0
- /package/dist/runtime/{vite-runtime.mjs → vite.mjs} +0 -0
- /package/lib/{deps/h3.d.mts → h3.d.mts} +0 -0
- /package/lib/{deps/h3.mjs → h3.mjs} +0 -0
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Layout
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CM7DWJNZ.js";
|
|
4
4
|
import {
|
|
5
5
|
ErrorCause
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-X53OIOJH.js";
|
|
7
7
|
import {
|
|
8
8
|
ErrorInfo
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OIJ3WD7L.js";
|
|
10
10
|
import {
|
|
11
11
|
ErrorMetadata
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-P36L72PL.js";
|
|
13
13
|
import {
|
|
14
14
|
ErrorStack
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EJH674NB.js";
|
|
16
16
|
import {
|
|
17
17
|
ErrorStackSource
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-7QV3D5YX.js";
|
|
19
19
|
import "./chunk-4L7RY2JA.js";
|
|
20
20
|
import {
|
|
21
21
|
Header
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-OSUFJZHZ.js";
|
|
22
|
+
} from "./chunk-AUGPHE32.js";
|
|
24
23
|
import {
|
|
25
24
|
BaseComponent
|
|
26
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-PE3GG3TN.js";
|
|
27
26
|
|
|
28
27
|
// src/youch.ts
|
|
29
28
|
import { parse } from "cookie-es";
|
|
@@ -75,6 +75,7 @@ html.dark {
|
|
|
75
75
|
|
|
76
76
|
.stack-frame-filepath {
|
|
77
77
|
max-width: 100%;
|
|
78
|
+
word-wrap: break-word;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
.stack-frame-location {
|
|
@@ -93,9 +94,7 @@ html.dark {
|
|
|
93
94
|
|
|
94
95
|
.stack-frame-location a {
|
|
95
96
|
text-decoration: none;
|
|
96
|
-
|
|
97
|
-
overflow: hidden;
|
|
98
|
-
text-overflow: ellipsis;
|
|
97
|
+
text-align: left;
|
|
99
98
|
}
|
|
100
99
|
.stack-frame-location span {
|
|
101
100
|
white-space: nowrap;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
export {};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import { Server } from "node:http";
|
|
3
3
|
import { parentPort, threadId } from "node:worker_threads";
|
|
4
4
|
import wsAdapter from "crossws/adapters/node";
|
|
5
5
|
import { toNodeHandler } from "srvx/node";
|
|
6
6
|
import { getSocketAddress, isSocketSupported } from "get-port-please";
|
|
7
7
|
import { useNitroApp, useNitroHooks } from "nitro/app";
|
|
8
|
-
import { startScheduleRunner } from "nitro
|
|
9
|
-
import { trapUnhandledErrors } from "nitro
|
|
10
|
-
import { resolveWebsocketHooks } from "nitro
|
|
11
|
-
import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
|
|
8
|
+
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
9
|
+
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
10
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
12
11
|
// Listen for shutdown signal from runner
|
|
13
12
|
parentPort?.on("message", (msg) => {
|
|
14
13
|
if (msg && msg.event === "shutdown") {
|
|
@@ -25,7 +24,7 @@ listen().catch((error) => {
|
|
|
25
24
|
return shutdown();
|
|
26
25
|
});
|
|
27
26
|
// https://crossws.unjs.io/adapters/node
|
|
28
|
-
if (
|
|
27
|
+
if (import.meta._websocket) {
|
|
29
28
|
const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
|
|
30
29
|
server.on("upgrade", handleUpgrade);
|
|
31
30
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import { useNitroApp } from "nitro/app";
|
|
3
|
-
import { isPublicAssetURL } from "#nitro
|
|
3
|
+
import { isPublicAssetURL } from "#nitro/virtual/public-assets";
|
|
4
4
|
const nitroApp = useNitroApp();
|
|
5
5
|
// @ts-expect-error
|
|
6
6
|
addEventListener("fetch", (event) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
export {};
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import type { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from "aws-lambda";
|
|
2
2
|
import type { ServerRequest } from "srvx";
|
|
3
|
-
// Incoming (AWS => Web)
|
|
4
3
|
export declare function awsRequest(event: APIGatewayProxyEvent | APIGatewayProxyEventV2, context: unknown): ServerRequest;
|
|
5
|
-
// Outgoing (Web => AWS)
|
|
6
4
|
export declare function awsResponseHeaders(response: Response);
|
|
7
|
-
// AWS Lambda proxy integrations requires base64 encoded buffers
|
|
8
|
-
// binaryMediaTypes should be */*
|
|
9
|
-
// see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html
|
|
10
5
|
export declare function awsResponseBody(response: Response): Promise<{
|
|
11
6
|
body: string;
|
|
12
7
|
isBase64Encoded?: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
export declare const handler: unknown;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import { useNitroApp } from "nitro/app";
|
|
3
3
|
import { awsRequest, awsResponseHeaders } from "./_utils.mjs";
|
|
4
4
|
const nitroApp = useNitroApp();
|
|
@@ -10,16 +10,14 @@ export const handler = awslambda.streamifyResponse(async (event, responseStream,
|
|
|
10
10
|
statusCode: response.status,
|
|
11
11
|
...awsResponseHeaders(response)
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
writer.end();
|
|
22
|
-
}
|
|
13
|
+
const body = response.body ?? new ReadableStream({ start(controller) {
|
|
14
|
+
controller.enqueue("");
|
|
15
|
+
controller.close();
|
|
16
|
+
} });
|
|
17
|
+
const writer = awslambda.HttpResponseStream.from(responseStream, httpResponseMetadata);
|
|
18
|
+
const reader = body.getReader();
|
|
19
|
+
await streamToNodeStream(reader, responseStream);
|
|
20
|
+
writer.end();
|
|
23
21
|
});
|
|
24
22
|
async function streamToNodeStream(reader, writer) {
|
|
25
23
|
let readResult = await reader.read();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyResultV2, Context } from "aws-lambda";
|
|
3
3
|
export declare function handler(event: APIGatewayProxyEvent | APIGatewayProxyEventV2, context: Context): Promise<APIGatewayProxyResult | APIGatewayProxyResultV2>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import { serve } from "srvx/bun";
|
|
3
3
|
import wsAdapter from "crossws/adapters/bun";
|
|
4
4
|
import { useNitroApp } from "nitro/app";
|
|
5
|
-
import { startScheduleRunner } from "nitro
|
|
6
|
-
import { trapUnhandledErrors } from "nitro
|
|
7
|
-
import { resolveWebsocketHooks } from "nitro
|
|
8
|
-
import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
|
|
5
|
+
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
6
|
+
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
7
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
9
8
|
const port = Number.parseInt(process.env.NITRO_PORT || process.env.PORT || "") || 3e3;
|
|
10
9
|
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
11
10
|
const cert = process.env.NITRO_SSL_CERT;
|
|
@@ -13,8 +12,8 @@ const key = process.env.NITRO_SSL_KEY;
|
|
|
13
12
|
// const socketPath = process.env.NITRO_UNIX_SOCKET; // TODO
|
|
14
13
|
const nitroApp = useNitroApp();
|
|
15
14
|
let _fetch = nitroApp.fetch;
|
|
16
|
-
const ws =
|
|
17
|
-
if (
|
|
15
|
+
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
16
|
+
if (import.meta._websocket) {
|
|
18
17
|
_fetch = (req) => {
|
|
19
18
|
if (req.headers.get("upgrade") === "websocket") {
|
|
20
19
|
return ws.handleUpgrade(req, req.runtime.bun.server);
|
|
@@ -30,7 +29,7 @@ serve({
|
|
|
30
29
|
key
|
|
31
30
|
} : undefined,
|
|
32
31
|
fetch: _fetch,
|
|
33
|
-
bun: { websocket:
|
|
32
|
+
bun: { websocket: import.meta._websocket ? ws?.websocket : undefined }
|
|
34
33
|
});
|
|
35
34
|
trapUnhandledErrors();
|
|
36
35
|
// Scheduled tasks
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import type * as CF from "@cloudflare/workers-types";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ServerRuntimeContext } from "srvx";
|
|
4
4
|
type MaybePromise<T> = T | Promise<T>;
|
|
5
5
|
export declare function createHandler<Env>(hooks: {
|
|
6
6
|
fetch: (...params: [...Parameters<NonNullable<ExportedHandler<Env>["fetch"]>>, url: URL, cfContextExtras: any]) => MaybePromise<Response | CF.Response | undefined>;
|
|
@@ -12,5 +12,5 @@ export declare function createHandler<Env>(hooks: {
|
|
|
12
12
|
tail(traces, env, context);
|
|
13
13
|
trace(traces, env, context);
|
|
14
14
|
};
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function augmentReq(cfReq: Request | CF.Request, ctx: NonNullable<ServerRuntimeContext["cloudflare"]>);
|
|
16
16
|
export {};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import "#nitro
|
|
2
|
-
import { runCronTasks } from "nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
|
+
import { runCronTasks } from "#nitro/runtime/task";
|
|
3
3
|
import { useNitroApp, useNitroHooks } from "nitro/app";
|
|
4
4
|
export function createHandler(hooks) {
|
|
5
5
|
const nitroApp = useNitroApp();
|
|
6
6
|
const nitroHooks = useNitroHooks();
|
|
7
7
|
return {
|
|
8
8
|
async fetch(request, env, context) {
|
|
9
|
+
globalThis.__env__ = env;
|
|
10
|
+
augmentReq(request, {
|
|
11
|
+
env,
|
|
12
|
+
context
|
|
13
|
+
});
|
|
9
14
|
const ctxExt = {};
|
|
10
15
|
const url = new URL(request.url);
|
|
11
16
|
// Preset-specific logic
|
|
@@ -15,7 +20,7 @@ export function createHandler(hooks) {
|
|
|
15
20
|
return res;
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
|
-
return
|
|
23
|
+
return await nitroApp.fetch(request);
|
|
19
24
|
},
|
|
20
25
|
scheduled(controller, env, context) {
|
|
21
26
|
globalThis.__env__ = env;
|
|
@@ -23,7 +28,7 @@ export function createHandler(hooks) {
|
|
|
23
28
|
controller,
|
|
24
29
|
env,
|
|
25
30
|
context
|
|
26
|
-
}));
|
|
31
|
+
}) || Promise.resolve());
|
|
27
32
|
if (import.meta._tasks) {
|
|
28
33
|
context.waitUntil(runCronTasks(controller.cron, {
|
|
29
34
|
context: { cloudflare: {
|
|
@@ -41,7 +46,7 @@ export function createHandler(hooks) {
|
|
|
41
46
|
event: message,
|
|
42
47
|
env,
|
|
43
48
|
context
|
|
44
|
-
}));
|
|
49
|
+
}) || Promise.resolve());
|
|
45
50
|
},
|
|
46
51
|
queue(batch, env, context) {
|
|
47
52
|
globalThis.__env__ = env;
|
|
@@ -50,7 +55,7 @@ export function createHandler(hooks) {
|
|
|
50
55
|
event: batch,
|
|
51
56
|
env,
|
|
52
57
|
context
|
|
53
|
-
}));
|
|
58
|
+
}) || Promise.resolve());
|
|
54
59
|
},
|
|
55
60
|
tail(traces, env, context) {
|
|
56
61
|
globalThis.__env__ = env;
|
|
@@ -58,7 +63,7 @@ export function createHandler(hooks) {
|
|
|
58
63
|
traces,
|
|
59
64
|
env,
|
|
60
65
|
context
|
|
61
|
-
}));
|
|
66
|
+
}) || Promise.resolve());
|
|
62
67
|
},
|
|
63
68
|
trace(traces, env, context) {
|
|
64
69
|
globalThis.__env__ = env;
|
|
@@ -66,20 +71,17 @@ export function createHandler(hooks) {
|
|
|
66
71
|
traces,
|
|
67
72
|
env,
|
|
68
73
|
context
|
|
69
|
-
}));
|
|
74
|
+
}) || Promise.resolve());
|
|
70
75
|
}
|
|
71
76
|
};
|
|
72
77
|
}
|
|
73
|
-
export
|
|
74
|
-
// Expose latest env to the global context
|
|
75
|
-
globalThis.__env__ = env;
|
|
76
|
-
// srvx compatibility
|
|
78
|
+
export function augmentReq(cfReq, ctx) {
|
|
77
79
|
const req = cfReq;
|
|
80
|
+
req.ip = cfReq.headers.get("cf-connecting-ip") || undefined;
|
|
78
81
|
req.runtime ??= { name: "cloudflare" };
|
|
79
|
-
req.runtime.cloudflare
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
req.runtime.cloudflare = {
|
|
83
|
+
...req.runtime.cloudflare,
|
|
84
|
+
...ctx
|
|
82
85
|
};
|
|
83
|
-
req.waitUntil = context
|
|
84
|
-
return nitroApp.fetch(req);
|
|
86
|
+
req.waitUntil = ctx.context?.waitUntil.bind(ctx.context);
|
|
85
87
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import { DurableObject } from "cloudflare:workers";
|
|
3
3
|
import wsAdapter from "crossws/adapters/cloudflare";
|
|
4
|
-
import { createHandler,
|
|
4
|
+
import { createHandler, augmentReq } from "./_module-handler.mjs";
|
|
5
5
|
import { useNitroApp, useNitroHooks } from "nitro/app";
|
|
6
|
-
import { isPublicAssetURL } from "#nitro
|
|
7
|
-
import { resolveWebsocketHooks } from "nitro
|
|
8
|
-
import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
|
|
6
|
+
import { isPublicAssetURL } from "#nitro/virtual/public-assets";
|
|
7
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
9
8
|
const DURABLE_BINDING = "$DurableObject";
|
|
10
9
|
const DURABLE_INSTANCE = "server";
|
|
11
10
|
const nitroApp = useNitroApp();
|
|
@@ -18,7 +17,7 @@ const getDurableStub = (env) => {
|
|
|
18
17
|
const id = binding.idFromName(DURABLE_INSTANCE);
|
|
19
18
|
return binding.get(id);
|
|
20
19
|
};
|
|
21
|
-
const ws =
|
|
20
|
+
const ws = import.meta._websocket ? wsAdapter({
|
|
22
21
|
resolve: resolveWebsocketHooks,
|
|
23
22
|
instanceName: DURABLE_INSTANCE,
|
|
24
23
|
bindingName: DURABLE_BINDING
|
|
@@ -32,7 +31,7 @@ export default createHandler({ fetch(request, env, context, url, ctxExt) {
|
|
|
32
31
|
ctxExt.durableFetch = (req = request) => getDurableStub(env).fetch(req);
|
|
33
32
|
// Websocket upgrade
|
|
34
33
|
// https://crossws.unjs.io/adapters/cloudflare#durable-objects
|
|
35
|
-
if (
|
|
34
|
+
if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
|
|
36
35
|
return ws.handleUpgrade(request, env, context);
|
|
37
36
|
}
|
|
38
37
|
} });
|
|
@@ -42,29 +41,31 @@ export class $DurableObject extends DurableObject {
|
|
|
42
41
|
state.waitUntil(nitroHooks.callHook("cloudflare:durable:init", this, {
|
|
43
42
|
state,
|
|
44
43
|
env
|
|
45
|
-
}));
|
|
46
|
-
if (
|
|
44
|
+
}) || Promise.resolve());
|
|
45
|
+
if (import.meta._websocket) {
|
|
47
46
|
ws.handleDurableInit(this, state, env);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
fetch(request) {
|
|
51
|
-
|
|
50
|
+
augmentReq(request, {
|
|
51
|
+
env: this.env,
|
|
52
|
+
context: this.ctx
|
|
53
|
+
});
|
|
54
|
+
if (import.meta._websocket && request.headers.get("upgrade") === "websocket") {
|
|
52
55
|
return ws.handleDurableUpgrade(this, request);
|
|
53
56
|
}
|
|
54
|
-
|
|
55
|
-
const url = new URL(request.url);
|
|
56
|
-
return fetchHandler(request, this.env, this.ctx, url, nitroApp, { durable: this });
|
|
57
|
+
return nitroApp.fetch(request);
|
|
57
58
|
}
|
|
58
59
|
alarm() {
|
|
59
|
-
this.ctx.waitUntil(nitroHooks.callHook("cloudflare:durable:alarm", this));
|
|
60
|
+
this.ctx.waitUntil(nitroHooks.callHook("cloudflare:durable:alarm", this) || Promise.resolve());
|
|
60
61
|
}
|
|
61
62
|
async webSocketMessage(client, message) {
|
|
62
|
-
if (
|
|
63
|
+
if (import.meta._websocket) {
|
|
63
64
|
return ws.handleDurableMessage(this, client, message);
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
async webSocketClose(client, code, reason, wasClean) {
|
|
67
|
-
if (
|
|
68
|
+
if (import.meta._websocket) {
|
|
68
69
|
return ws.handleDurableClose(this, client, code, reason, wasClean);
|
|
69
70
|
}
|
|
70
71
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import wsAdapter from "crossws/adapters/cloudflare";
|
|
3
|
-
import { isPublicAssetURL } from "#nitro
|
|
3
|
+
import { isPublicAssetURL } from "#nitro/virtual/public-assets";
|
|
4
4
|
import { createHandler } from "./_module-handler.mjs";
|
|
5
|
-
import { resolveWebsocketHooks } from "nitro
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export default createHandler({ fetch(request, env, context, url) {
|
|
5
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
6
|
+
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
7
|
+
export default createHandler({ fetch(cfRequest, env, context, url) {
|
|
9
8
|
// Static assets fallback (optional binding)
|
|
10
9
|
if (env.ASSETS && isPublicAssetURL(url.pathname)) {
|
|
11
|
-
return env.ASSETS.fetch(
|
|
10
|
+
return env.ASSETS.fetch(cfRequest);
|
|
12
11
|
}
|
|
13
12
|
// Websocket upgrade
|
|
14
13
|
// https://crossws.unjs.io/adapters/cloudflare
|
|
15
|
-
if (
|
|
16
|
-
return ws.handleUpgrade(
|
|
14
|
+
if (import.meta._websocket && cfRequest.headers.get("upgrade") === "websocket") {
|
|
15
|
+
return ws.handleUpgrade(cfRequest, env, context);
|
|
17
16
|
}
|
|
18
17
|
} });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import type { Request as CFRequest, EventContext, ExecutionContext } from "@cloudflare/workers-types";
|
|
3
3
|
/**
|
|
4
4
|
* Reference: https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#parameters
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import wsAdapter from "crossws/adapters/cloudflare";
|
|
3
3
|
import { useNitroApp } from "nitro/app";
|
|
4
|
-
import { isPublicAssetURL } from "#nitro
|
|
5
|
-
import { runCronTasks } from "nitro
|
|
6
|
-
import { resolveWebsocketHooks } from "nitro
|
|
7
|
-
import {
|
|
4
|
+
import { isPublicAssetURL } from "#nitro/virtual/public-assets";
|
|
5
|
+
import { runCronTasks } from "#nitro/runtime/task";
|
|
6
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
7
|
+
import { augmentReq } from "./_module-handler.mjs";
|
|
8
8
|
const nitroApp = useNitroApp();
|
|
9
|
-
const ws =
|
|
9
|
+
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
10
10
|
export default {
|
|
11
11
|
async fetch(cfReq, env, context) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
context,
|
|
17
|
-
env
|
|
18
|
-
};
|
|
19
|
-
req.waitUntil = context.waitUntil.bind(context);
|
|
12
|
+
augmentReq(cfReq, {
|
|
13
|
+
env,
|
|
14
|
+
context
|
|
15
|
+
});
|
|
20
16
|
// Websocket upgrade
|
|
21
17
|
// https://crossws.unjs.io/adapters/cloudflare
|
|
22
|
-
if (
|
|
18
|
+
if (import.meta._websocket && cfReq.headers.get("upgrade") === "websocket") {
|
|
23
19
|
return ws.handleUpgrade(cfReq, env, context);
|
|
24
20
|
}
|
|
25
21
|
const url = new URL(cfReq.url);
|
|
26
22
|
if (env.ASSETS && isPublicAssetURL(url.pathname)) {
|
|
27
23
|
return env.ASSETS.fetch(cfReq);
|
|
28
24
|
}
|
|
29
|
-
|
|
30
|
-
globalThis.__env__ = env;
|
|
31
|
-
return nitroApp.fetch(req);
|
|
25
|
+
return nitroApp.fetch(cfReq);
|
|
32
26
|
},
|
|
33
27
|
scheduled(event, env, context) {
|
|
34
28
|
if (import.meta._tasks) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import wsAdapter from "crossws/adapters/deno";
|
|
3
3
|
import { useNitroApp } from "nitro/app";
|
|
4
|
-
import { resolveWebsocketHooks } from "nitro
|
|
5
|
-
import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
|
|
4
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
6
5
|
const nitroApp = useNitroApp();
|
|
7
|
-
const ws =
|
|
6
|
+
const ws = import.meta._websocket ? wsAdapter({ resolve: resolveWebsocketHooks }) : undefined;
|
|
8
7
|
// TODO: Migrate to srvx to provide request IP
|
|
9
8
|
Deno.serve((denoReq, info) => {
|
|
10
9
|
// srvx compatibility
|
|
@@ -13,7 +12,7 @@ Deno.serve((denoReq, info) => {
|
|
|
13
12
|
req.runtime.deno ??= { info };
|
|
14
13
|
// TODO: Support remoteAddr
|
|
15
14
|
// https://crossws.unjs.io/adapters/deno
|
|
16
|
-
if (
|
|
15
|
+
if (import.meta._websocket && req.headers.get("upgrade") === "websocket") {
|
|
17
16
|
return ws.handleUpgrade(req, info);
|
|
18
17
|
}
|
|
19
18
|
return nitroApp.fetch(req);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import "#nitro
|
|
1
|
+
import "#nitro/virtual/polyfills";
|
|
2
2
|
import { serve } from "srvx/deno";
|
|
3
3
|
import wsAdapter from "crossws/adapters/deno";
|
|
4
4
|
import { useNitroApp } from "nitro/app";
|
|
5
|
-
import { startScheduleRunner } from "nitro
|
|
6
|
-
import { trapUnhandledErrors } from "nitro
|
|
7
|
-
import { resolveWebsocketHooks } from "nitro
|
|
8
|
-
import { hasWebSocket } from "#nitro-internal-virtual/feature-flags";
|
|
5
|
+
import { startScheduleRunner } from "#nitro/runtime/task";
|
|
6
|
+
import { trapUnhandledErrors } from "#nitro/runtime/error/hooks";
|
|
7
|
+
import { resolveWebsocketHooks } from "#nitro/runtime/app";
|
|
9
8
|
const port = Number.parseInt(process.env.NITRO_PORT || process.env.PORT || "") || 3e3;
|
|
10
9
|
const host = process.env.NITRO_HOST || process.env.HOST;
|
|
11
10
|
const cert = process.env.NITRO_SSL_CERT;
|
|
@@ -13,7 +12,7 @@ const key = process.env.NITRO_SSL_KEY;
|
|
|
13
12
|
// const socketPath = process.env.NITRO_UNIX_SOCKET; // TODO
|
|
14
13
|
const nitroApp = useNitroApp();
|
|
15
14
|
let _fetch = nitroApp.fetch;
|
|
16
|
-
if (
|
|
15
|
+
if (import.meta._websocket) {
|
|
17
16
|
const { handleUpgrade } = wsAdapter({ resolve: resolveWebsocketHooks });
|
|
18
17
|
_fetch = (req) => {
|
|
19
18
|
if (req.headers.get("upgrade") === "websocket") {
|