nitro 3.0.1-alpha.2 → 3.0.260311-beta
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/LICENSE +6 -0
- package/README.md +2 -2
- package/dist/THIRD-PARTY-LICENSES.md +1646 -0
- package/dist/_build/common.mjs +6977 -2556
- package/dist/_build/rolldown.mjs +32 -31
- package/dist/_build/rollup.mjs +28 -35
- package/dist/_build/vite.build.mjs +10 -8
- package/dist/_chunks/nitro.mjs +80 -112
- package/dist/_chunks/nitro2.mjs +8 -7
- package/dist/_chunks/nitro3.mjs +129 -0
- package/dist/_chunks/utils.mjs +42 -24
- package/dist/_common.mjs +14 -24
- package/dist/{_chunks/dev.mjs → _dev.mjs} +132 -320
- package/dist/_libs/_.mjs +3 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +3 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +3 -0
- package/dist/_libs/_6.mjs +4 -0
- package/dist/_libs/_7.mjs +5 -0
- package/dist/_libs/c12+rc9.mjs +812 -0
- package/dist/_libs/{c12+giget+readdirp+chokidar.d.mts → c12+readdirp+chokidar.d.mts} +52 -36
- package/dist/_libs/citty.mjs +10 -12
- package/dist/_libs/commondir+is-reference.mjs +60 -49
- package/dist/_libs/compatx.mjs +1 -2
- package/dist/_libs/esbuild.d.mts +1 -1
- package/dist/_libs/escape-string-regexp.mjs +1 -2
- package/dist/_libs/{pluginutils+plugin-commonjs.d.mts → estree+pluginutils.d.mts} +2 -2
- package/dist/_libs/estree-walker.mjs +1 -4
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +146 -169
- package/dist/_libs/httpxy.d.mts +12 -9
- package/dist/_libs/httpxy.mjs +299 -43
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +1 -2
- package/dist/_libs/mlly.d.mts +1 -1
- package/dist/_libs/nypm+tinyexec.mjs +845 -0
- package/dist/_libs/perfect-debounce.mjs +88 -0
- package/dist/_libs/plugin-alias.mjs +2 -4
- package/dist/_libs/plugin-inject.mjs +2 -6
- package/dist/_libs/plugin-json.mjs +2 -4
- package/dist/_libs/pluginutils.mjs +5 -11
- package/dist/_libs/readdirp+chokidar.mjs +187 -192
- package/dist/_libs/remapping.mjs +1 -3
- package/dist/_libs/resolve-uri+gen-mapping.mjs +15 -21
- package/dist/_libs/rou3.d.mts +3 -2
- package/dist/_libs/rou3.mjs +225 -51
- package/dist/_libs/std-env.d.mts +10 -2
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +21 -40
- package/dist/_libs/ultrahtml.mjs +3 -14
- package/dist/_libs/unimport+unplugin.mjs +250 -351
- package/dist/_libs/unplugin+unimport.d.mts +7 -10
- package/dist/_presets.mjs +389 -432
- package/dist/builder.d.mts +5 -4
- package/dist/builder.mjs +12 -6
- package/dist/cli/_chunks/build.mjs +22 -23
- package/dist/cli/_chunks/common.mjs +1 -2
- package/dist/cli/_chunks/deploy.mjs +40 -0
- package/dist/cli/_chunks/dev.mjs +9 -9
- package/dist/cli/_chunks/docs.mjs +30 -0
- package/dist/cli/_chunks/list.mjs +4 -6
- package/dist/cli/_chunks/prepare.mjs +2 -4
- package/dist/cli/_chunks/preview.mjs +51 -0
- package/dist/cli/_chunks/run.mjs +7 -9
- package/dist/cli/_chunks/task.mjs +1 -3
- package/dist/cli/index.mjs +5 -4
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +8 -0
- package/dist/node_modules/@poppinss/dumper/package.json +1 -1
- package/dist/node_modules/croner/dist/croner.js +1 -1
- package/dist/node_modules/croner/package.json +11 -1
- package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
- package/dist/node_modules/youch/build/index.js +204 -351
- package/dist/node_modules/youch/build/public/error_info/script.js +1 -1
- package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
- package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
- package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
- package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
- package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
- package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
- package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
- package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
- package/dist/node_modules/youch/package.json +34 -31
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +9 -56
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +0 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +3 -1
- package/dist/presets/bun/runtime/bun.mjs +4 -3
- package/dist/presets/deno/runtime/deno-server.mjs +4 -3
- package/dist/presets/netlify/runtime/netlify-edge.mjs +0 -1
- package/dist/presets/netlify/runtime/netlify.mjs +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +3 -2
- package/dist/presets/node/runtime/node-server.mjs +3 -2
- package/dist/presets/stormkit/runtime/stormkit.mjs +0 -1
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/vercel.web.mjs +2 -4
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/internal/cache.d.mts +0 -4
- package/dist/runtime/internal/cache.mjs +32 -256
- package/dist/runtime/internal/context.d.mts +3 -1
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +38 -40
- package/dist/runtime/internal/error/hooks.d.mts +1 -1
- package/dist/runtime/internal/error/prod.d.mts +2 -5
- package/dist/runtime/internal/error/prod.mjs +19 -33
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/route-rules.d.mts +9 -4
- package/dist/runtime/internal/route-rules.mjs +9 -1
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -2
- package/dist/runtime/internal/routes/dev-tasks.mjs +6 -2
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +2 -1
- package/dist/runtime/internal/runtime-config.d.mts +1 -1
- package/dist/runtime/internal/static.mjs +5 -4
- package/dist/runtime/internal/task.d.mts +3 -1
- package/dist/runtime/internal/task.mjs +2 -2
- package/dist/runtime/internal/vite/dev-entry.mjs +6 -3
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/meta.mjs +1 -0
- package/dist/runtime/nitro.d.mts +2 -0
- package/dist/runtime/nitro.mjs +2 -0
- package/dist/runtime/virtual/error-handler.mjs +1 -1
- package/dist/runtime/virtual/server-assets.d.mts +2 -1
- package/dist/runtime/vite.d.mts +1 -1
- package/dist/types/index.d.mts +68 -117
- package/dist/types/index.mjs +1 -11
- package/dist/vite.d.mts +3 -3
- package/dist/vite.mjs +236 -233
- package/package.json +83 -68
- package/skills/nitro/SKILL.md +10 -0
- package/skills/nitro/docs/TOC.md +83 -0
- package/skills/nitro/docs/_navigation.json +679 -0
- package/skills/nitro/docs/config/index.md +1147 -0
- package/skills/nitro/docs/deploy/index.md +64 -0
- package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
- package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
- package/skills/nitro/docs/deploy/providers/aws.md +47 -0
- package/skills/nitro/docs/deploy/providers/azure.md +72 -0
- package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
- package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
- package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
- package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
- package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
- package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
- package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
- package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
- package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
- package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
- package/skills/nitro/docs/deploy/providers/iis.md +38 -0
- package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
- package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
- package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
- package/skills/nitro/docs/deploy/providers/render.md +37 -0
- package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
- package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
- package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
- package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
- package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
- package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
- package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
- package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
- package/skills/nitro/docs/docs/assets.md +166 -0
- package/skills/nitro/docs/docs/cache.md +408 -0
- package/skills/nitro/docs/docs/configuration.md +256 -0
- package/skills/nitro/docs/docs/database.md +185 -0
- package/skills/nitro/docs/docs/index.md +56 -0
- package/skills/nitro/docs/docs/lifecycle.md +204 -0
- package/skills/nitro/docs/docs/migration.md +215 -0
- package/skills/nitro/docs/docs/nightly.md +31 -0
- package/skills/nitro/docs/docs/plugins.md +164 -0
- package/skills/nitro/docs/docs/quick-start.md +110 -0
- package/skills/nitro/docs/docs/renderer.md +322 -0
- package/skills/nitro/docs/docs/routing.md +711 -0
- package/skills/nitro/docs/docs/server-entry.md +239 -0
- package/skills/nitro/docs/docs/storage.md +261 -0
- package/skills/nitro/docs/docs/tasks.md +277 -0
- package/skills/nitro/docs/examples/api-routes.md +145 -0
- package/skills/nitro/docs/examples/auto-imports.md +93 -0
- package/skills/nitro/docs/examples/cached-handler.md +81 -0
- package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
- package/skills/nitro/docs/examples/database.md +157 -0
- package/skills/nitro/docs/examples/elysia.md +70 -0
- package/skills/nitro/docs/examples/express.md +78 -0
- package/skills/nitro/docs/examples/fastify.md +79 -0
- package/skills/nitro/docs/examples/hello-world.md +68 -0
- package/skills/nitro/docs/examples/hono.md +74 -0
- package/skills/nitro/docs/examples/import-alias.md +100 -0
- package/skills/nitro/docs/examples/index.md +3 -0
- package/skills/nitro/docs/examples/middleware.md +91 -0
- package/skills/nitro/docs/examples/mono-jsx.md +68 -0
- package/skills/nitro/docs/examples/nano-jsx.md +70 -0
- package/skills/nitro/docs/examples/plugins.md +91 -0
- package/skills/nitro/docs/examples/renderer.md +113 -0
- package/skills/nitro/docs/examples/runtime-config.md +97 -0
- package/skills/nitro/docs/examples/server-fetch.md +87 -0
- package/skills/nitro/docs/examples/shiki.md +198 -0
- package/skills/nitro/docs/examples/virtual-routes.md +74 -0
- package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
- package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
- package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
- package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
- package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
- package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
- package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
- package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
- package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
- package/skills/nitro/docs/examples/vite-trpc.md +335 -0
- package/skills/nitro/docs/examples/websocket.md +282 -0
- package/skills/nitro/docs/index.md +121 -0
- package/dist/_libs/confbox.mjs +0 -2509
- package/dist/_libs/nypm+giget+tinyexec.mjs +0 -3603
- package/dist/_libs/rc9+c12+dotenv.mjs +0 -972
- package/dist/node_modules/hookable/dist/index.mjs +0 -266
- package/dist/node_modules/hookable/package.json +0 -52
- package/dist/node_modules/youch/build/chunk-4L7RY2JA.js +0 -42
- package/dist/node_modules/youch/build/chunk-7QV3D5YX.js +0 -83
- package/dist/node_modules/youch/build/chunk-AUGPHE32.js +0 -39
- package/dist/node_modules/youch/build/chunk-CM7DWJNZ.js +0 -44
- package/dist/node_modules/youch/build/chunk-EJH674NB.js +0 -223
- package/dist/node_modules/youch/build/chunk-OIJ3WD7L.js +0 -81
- package/dist/node_modules/youch/build/chunk-P36L72PL.js +0 -87
- package/dist/node_modules/youch/build/chunk-PE3GG3TN.js +0 -65
- package/dist/node_modules/youch/build/chunk-X53OIOJH.js +0 -70
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +0 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +0 -3
- package/dist/presets/_nitro/runtime/service-worker.d.mts +0 -2
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -8
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +0 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +0 -3
- package/dist/presets/azure/runtime/_utils.d.mts +0 -2
- package/dist/presets/azure/runtime/azure-swa.d.mts +0 -5
- package/dist/presets/bun/runtime/bun.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +0 -16
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +0 -11
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +0 -3
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +0 -20
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +0 -3
- package/dist/presets/deno/runtime/deno-deploy.d.mts +0 -5
- package/dist/presets/deno/runtime/deno-server.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +0 -3
- package/dist/presets/netlify/runtime/netlify.d.mts +0 -4
- package/dist/presets/node/runtime/node-cluster.d.mts +0 -3
- package/dist/presets/node/runtime/node-middleware.d.mts +0 -3
- package/dist/presets/node/runtime/node-server.d.mts +0 -3
- package/dist/presets/standard/runtime/server.d.mts +0 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +0 -21
- package/dist/presets/vercel/runtime/isr.d.mts +0 -2
- package/dist/presets/vercel/runtime/vercel.node.d.mts +0 -3
- package/dist/presets/vercel/runtime/vercel.web.d.mts +0 -8
- package/dist/presets/winterjs/runtime/winterjs.d.mts +0 -2
- package/dist/presets/zeabur/runtime/zeabur.d.mts +0 -3
- package/dist/runtime/internal/vite/node-runner.mjs +0 -359
|
@@ -1,228 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import consola
|
|
6
|
-
import { createReadStream
|
|
7
|
-
import { readFile,
|
|
1
|
+
import { A as src_default, H as v, V as m, ct as join$1, dt as resolve$1, g as writeDevBuildInfo, ot as extname$1 } from "./_build/common.mjs";
|
|
2
|
+
import { n as watch$1 } from "./_libs/readdirp+chokidar.mjs";
|
|
3
|
+
import { t as debounce } from "./_libs/perfect-debounce.mjs";
|
|
4
|
+
import { t as createProxyServer } from "./_libs/httpxy.mjs";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { createReadStream } from "node:fs";
|
|
7
|
+
import { readFile, stat as stat$1 } from "node:fs/promises";
|
|
8
8
|
import { dirname, resolve } from "node:path";
|
|
9
9
|
import { joinURL } from "ufo";
|
|
10
10
|
import { createBrotliCompress, createGzip } from "node:zlib";
|
|
11
|
-
import {
|
|
11
|
+
import { RunnerManager, loadRunner } from "env-runner";
|
|
12
12
|
import { H3, HTTPError, defineHandler, fromNodeHandler, getRequestIP, getRequestURL, serveStatic, toEventHandler } from "h3";
|
|
13
|
-
import { Agent } from "undici";
|
|
14
13
|
import { serve } from "srvx/node";
|
|
15
|
-
import { ErrorParser } from "youch-core";
|
|
16
|
-
import { Youch } from "youch";
|
|
17
|
-
import { SourceMapConsumer } from "source-map";
|
|
18
14
|
import { FastResponse } from "srvx";
|
|
19
|
-
|
|
20
|
-
//#region src/runner/proxy.ts
|
|
21
|
-
function createHTTPProxy(defaults = {}) {
|
|
22
|
-
const proxy = createProxyServer(defaults);
|
|
23
|
-
proxy.on("proxyReq", (proxyReq, req) => {
|
|
24
|
-
if (!proxyReq.hasHeader("x-forwarded-for")) {
|
|
25
|
-
const address = req.socket.remoteAddress;
|
|
26
|
-
if (address) proxyReq.appendHeader("x-forwarded-for", address);
|
|
27
|
-
}
|
|
28
|
-
if (!proxyReq.hasHeader("x-forwarded-port")) {
|
|
29
|
-
if (req?.socket?.localPort) proxyReq.setHeader("x-forwarded-port", req.socket.localPort);
|
|
30
|
-
}
|
|
31
|
-
if (!proxyReq.hasHeader("x-forwarded-Proto")) {
|
|
32
|
-
const encrypted = (req?.connection)?.encrypted;
|
|
33
|
-
proxyReq.setHeader("x-forwarded-proto", encrypted ? "https" : "http");
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
return {
|
|
37
|
-
proxy,
|
|
38
|
-
async handleEvent(event, opts) {
|
|
39
|
-
try {
|
|
40
|
-
return await fromNodeHandler((req, res) => proxy.web(req, res, opts))(event);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
event.res.headers.set("refresh", "3");
|
|
43
|
-
throw new HTTPError({
|
|
44
|
-
status: 503,
|
|
45
|
-
message: "Dev server is unavailable.",
|
|
46
|
-
cause: error
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async function fetchAddress(addr, input, inputInit) {
|
|
53
|
-
let url;
|
|
54
|
-
let init;
|
|
55
|
-
if (input instanceof Request) {
|
|
56
|
-
url = new URL(input.url);
|
|
57
|
-
init = {
|
|
58
|
-
method: input.method,
|
|
59
|
-
headers: input.headers,
|
|
60
|
-
body: input.body,
|
|
61
|
-
...inputInit
|
|
62
|
-
};
|
|
63
|
-
} else {
|
|
64
|
-
url = new URL(input);
|
|
65
|
-
init = inputInit;
|
|
66
|
-
}
|
|
67
|
-
init = {
|
|
68
|
-
duplex: "half",
|
|
69
|
-
redirect: "manual",
|
|
70
|
-
...init
|
|
71
|
-
};
|
|
72
|
-
let res;
|
|
73
|
-
if (addr.socketPath) {
|
|
74
|
-
url.protocol = "http:";
|
|
75
|
-
res = await fetch(url, {
|
|
76
|
-
...init,
|
|
77
|
-
...fetchSocketOptions(addr.socketPath)
|
|
78
|
-
});
|
|
79
|
-
} else {
|
|
80
|
-
const origin = `http://${addr.host}${addr.port ? `:${addr.port}` : ""}`;
|
|
81
|
-
const outURL = new URL(url.pathname + url.search, origin);
|
|
82
|
-
res = await fetch(outURL, init);
|
|
83
|
-
}
|
|
84
|
-
const headers = new Headers(res.headers);
|
|
85
|
-
headers.delete("transfer-encoding");
|
|
86
|
-
return new Response(res.body, {
|
|
87
|
-
status: res.status,
|
|
88
|
-
statusText: res.statusText,
|
|
89
|
-
headers
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
function fetchSocketOptions(socketPath) {
|
|
93
|
-
if ("Bun" in globalThis) return { unix: socketPath };
|
|
94
|
-
if ("Deno" in globalThis) return { client: Deno.createHttpClient({
|
|
95
|
-
transport: "unix",
|
|
96
|
-
path: socketPath
|
|
97
|
-
}) };
|
|
98
|
-
return { dispatcher: new Agent({ connect: { socketPath } }) };
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/runner/node.ts
|
|
103
|
-
var NodeEnvRunner = class {
|
|
104
|
-
closed = false;
|
|
105
|
-
#name;
|
|
106
|
-
#entry;
|
|
107
|
-
#data;
|
|
108
|
-
#hooks;
|
|
109
|
-
#worker;
|
|
110
|
-
#address;
|
|
111
|
-
#proxy;
|
|
112
|
-
#messageListeners;
|
|
113
|
-
constructor(opts) {
|
|
114
|
-
this.#name = opts.name;
|
|
115
|
-
this.#entry = opts.entry;
|
|
116
|
-
this.#data = opts.data;
|
|
117
|
-
this.#hooks = opts.hooks || {};
|
|
118
|
-
this.#proxy = createHTTPProxy();
|
|
119
|
-
this.#messageListeners = /* @__PURE__ */ new Set();
|
|
120
|
-
this.#initWorker();
|
|
121
|
-
}
|
|
122
|
-
get ready() {
|
|
123
|
-
return Boolean(!this.closed && this.#address && this.#proxy && this.#worker);
|
|
124
|
-
}
|
|
125
|
-
async fetch(input, init) {
|
|
126
|
-
for (let i = 0; i < 5 && !(this.#address && this.#proxy); i++) await new Promise((r) => setTimeout(r, 100 * Math.pow(2, i)));
|
|
127
|
-
if (!(this.#address && this.#proxy)) return new Response("Node env runner worker is unavailable", { status: 503 });
|
|
128
|
-
return fetchAddress(this.#address, input, init);
|
|
129
|
-
}
|
|
130
|
-
upgrade(req, socket, head) {
|
|
131
|
-
if (!this.ready) return;
|
|
132
|
-
return this.#proxy.proxy.ws(req, socket, {
|
|
133
|
-
target: this.#address,
|
|
134
|
-
xfwd: true
|
|
135
|
-
}, head).catch((error) => {
|
|
136
|
-
consola$1.error("WebSocket proxy error:", error);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
sendMessage(message) {
|
|
140
|
-
if (!this.#worker) throw new Error("Node env worker should be initialized before sending messages.");
|
|
141
|
-
this.#worker.postMessage(message);
|
|
142
|
-
}
|
|
143
|
-
onMessage(listener) {
|
|
144
|
-
this.#messageListeners.add(listener);
|
|
145
|
-
}
|
|
146
|
-
offMessage(listener) {
|
|
147
|
-
this.#messageListeners.delete(listener);
|
|
148
|
-
}
|
|
149
|
-
async close(cause) {
|
|
150
|
-
if (this.closed) return;
|
|
151
|
-
this.closed = true;
|
|
152
|
-
this.#hooks.onClose?.(this, cause);
|
|
153
|
-
this.#hooks = {};
|
|
154
|
-
const onError = (error) => consola$1.error(error);
|
|
155
|
-
await this.#closeWorker().catch(onError);
|
|
156
|
-
await this.#closeProxy().catch(onError);
|
|
157
|
-
await this.#closeSocket().catch(onError);
|
|
158
|
-
}
|
|
159
|
-
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
160
|
-
const status = this.closed ? "closed" : this.ready ? "ready" : "pending";
|
|
161
|
-
return `NodeEnvRunner#${this.#name}(${status})`;
|
|
162
|
-
}
|
|
163
|
-
#initWorker() {
|
|
164
|
-
if (!existsSync(this.#entry)) {
|
|
165
|
-
this.close(`worker entry not found in "${this.#entry}".`);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const worker = new Worker(this.#entry, {
|
|
169
|
-
env: { ...process.env },
|
|
170
|
-
workerData: {
|
|
171
|
-
name: this.#name,
|
|
172
|
-
...this.#data
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
worker.once("exit", (code) => {
|
|
176
|
-
worker._exitCode = code;
|
|
177
|
-
this.close(`worker exited with code ${code}`);
|
|
178
|
-
});
|
|
179
|
-
worker.once("error", (error) => {
|
|
180
|
-
consola$1.error(`Worker error:`, error);
|
|
181
|
-
this.close(error);
|
|
182
|
-
});
|
|
183
|
-
worker.on("message", (message) => {
|
|
184
|
-
if (message?.address) {
|
|
185
|
-
this.#address = message.address;
|
|
186
|
-
this.#hooks.onReady?.(this, this.#address);
|
|
187
|
-
}
|
|
188
|
-
for (const listener of this.#messageListeners) listener(message);
|
|
189
|
-
});
|
|
190
|
-
this.#worker = worker;
|
|
191
|
-
}
|
|
192
|
-
async #closeProxy() {
|
|
193
|
-
this.#proxy?.proxy?.close(() => {});
|
|
194
|
-
this.#proxy = void 0;
|
|
195
|
-
}
|
|
196
|
-
async #closeSocket() {
|
|
197
|
-
const socketPath = this.#address?.socketPath;
|
|
198
|
-
if (socketPath && socketPath[0] !== "\0" && !socketPath.startsWith(String.raw`\\.\pipe`)) await rm(socketPath).catch(() => {});
|
|
199
|
-
this.#address = void 0;
|
|
200
|
-
}
|
|
201
|
-
async #closeWorker() {
|
|
202
|
-
if (!this.#worker) return;
|
|
203
|
-
this.#worker.postMessage({ event: "shutdown" });
|
|
204
|
-
if (!this.#worker._exitCode && !a && !T) await new Promise((resolve$2) => {
|
|
205
|
-
const gracefulShutdownTimeoutMs = Number.parseInt(process.env.NITRO_SHUTDOWN_TIMEOUT || "", 10) || 5e3;
|
|
206
|
-
const timeout = setTimeout(() => {
|
|
207
|
-
consola$1.warn(`force closing node env runner worker...`);
|
|
208
|
-
resolve$2();
|
|
209
|
-
}, gracefulShutdownTimeoutMs);
|
|
210
|
-
this.#worker?.on("message", (message) => {
|
|
211
|
-
if (message.event === "exit") {
|
|
212
|
-
clearTimeout(timeout);
|
|
213
|
-
resolve$2();
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
this.#worker.removeAllListeners();
|
|
218
|
-
await this.#worker.terminate().catch((error) => {
|
|
219
|
-
consola$1.error(error);
|
|
220
|
-
});
|
|
221
|
-
this.#worker = void 0;
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
//#endregion
|
|
226
15
|
//#region src/dev/vfs.ts
|
|
227
16
|
function createVFSHandler(nitro) {
|
|
228
17
|
return defineHandler(async (event) => {
|
|
@@ -242,9 +31,9 @@ function createVFSHandler(nitro) {
|
|
|
242
31
|
const content = id ? await nitro.vfs.get(id)?.render() : void 0;
|
|
243
32
|
if (isJson) return {
|
|
244
33
|
rootDir: nitro.options.rootDir,
|
|
245
|
-
entries: [...nitro.vfs.keys()].map((id
|
|
246
|
-
id
|
|
247
|
-
path: "/_vfs.json/" + encodeURIComponent(id
|
|
34
|
+
entries: [...nitro.vfs.keys()].map((id) => ({
|
|
35
|
+
id,
|
|
36
|
+
path: "/_vfs.json/" + encodeURIComponent(id)
|
|
248
37
|
})),
|
|
249
38
|
current: id ? {
|
|
250
39
|
id,
|
|
@@ -261,8 +50,8 @@ function createVFSHandler(nitro) {
|
|
|
261
50
|
currentDir = currentDir[segment];
|
|
262
51
|
}
|
|
263
52
|
}
|
|
264
|
-
const generateHTML = (directory, path
|
|
265
|
-
const subpath = [...path
|
|
53
|
+
const generateHTML = (directory, path = []) => Object.entries(directory).map(([fname, value = {}]) => {
|
|
54
|
+
const subpath = [...path, fname];
|
|
266
55
|
const key = subpath.join("/");
|
|
267
56
|
const encodedUrl = encodeURIComponent(key);
|
|
268
57
|
const linkClass = url === `/${encodedUrl}` ? "bg-gray-700 text-white" : "hover:bg-gray-800 text-gray-200";
|
|
@@ -353,22 +142,20 @@ const editorTemplate = (options) => `
|
|
|
353
142
|
}, 0);
|
|
354
143
|
<\/script>
|
|
355
144
|
`;
|
|
356
|
-
|
|
357
145
|
//#endregion
|
|
358
146
|
//#region src/runtime/internal/error/utils.ts
|
|
359
147
|
function defineNitroErrorHandler(handler) {
|
|
360
148
|
return handler;
|
|
361
149
|
}
|
|
362
|
-
|
|
363
150
|
//#endregion
|
|
364
151
|
//#region src/runtime/internal/error/dev.ts
|
|
365
|
-
|
|
152
|
+
const errorHandler = defineNitroErrorHandler(async function defaultNitroErrorHandler(error, event) {
|
|
366
153
|
const res = await defaultHandler(error, event);
|
|
367
154
|
return new FastResponse(typeof res.body === "string" ? res.body : JSON.stringify(res.body, null, 2), res);
|
|
368
155
|
});
|
|
369
156
|
async function defaultHandler(error, event, opts) {
|
|
370
|
-
const
|
|
371
|
-
const status =
|
|
157
|
+
const unhandled = error.unhandled ?? !HTTPError.isError(error);
|
|
158
|
+
const { status = 500, statusText = "" } = unhandled ? {} : error;
|
|
372
159
|
const url = getRequestURL(event, {
|
|
373
160
|
xForwardedHost: true,
|
|
374
161
|
xForwardedProto: true
|
|
@@ -378,58 +165,63 @@ async function defaultHandler(error, event, opts) {
|
|
|
378
165
|
if (/^\/[^/]/.test(baseURL) && !url.pathname.startsWith(baseURL)) return {
|
|
379
166
|
status: 302,
|
|
380
167
|
statusText: "Found",
|
|
381
|
-
headers: { location: `${baseURL}${url.pathname.slice(1)}${url.search}` },
|
|
168
|
+
headers: new Headers({ location: `${baseURL}${url.pathname.slice(1)}${url.search}` }),
|
|
382
169
|
body: `Redirecting...`
|
|
383
170
|
};
|
|
384
171
|
}
|
|
385
|
-
await loadStackTrace(error).catch(consola
|
|
172
|
+
await loadStackTrace(error).catch(consola.error);
|
|
173
|
+
const { Youch } = await import("youch");
|
|
386
174
|
const youch = new Youch();
|
|
387
|
-
if (
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
consola$1.error(`[request error] ${tags} [${event.req.method}] ${url}\n\n`, ansiError);
|
|
175
|
+
if (unhandled && !opts?.silent) {
|
|
176
|
+
const ansiError = (await youch.toANSI(error)).replaceAll(process.cwd(), ".");
|
|
177
|
+
consola.error(`[request error] [${event.req.method}] ${url}\n\n`, ansiError);
|
|
391
178
|
}
|
|
392
179
|
const useJSON = opts?.json ?? !event.req.headers.get("accept")?.includes("text/html");
|
|
393
|
-
const headers = {
|
|
394
|
-
|
|
395
|
-
"
|
|
396
|
-
"
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
} });
|
|
180
|
+
const headers = new Headers(unhandled ? {} : error.headers);
|
|
181
|
+
if (useJSON) {
|
|
182
|
+
headers.set("Content-Type", "application/json; charset=utf-8");
|
|
183
|
+
const jsonBody = typeof error.toJSON === "function" ? error.toJSON() : {
|
|
184
|
+
status,
|
|
185
|
+
statusText,
|
|
186
|
+
message: error.message
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
status,
|
|
190
|
+
statusText,
|
|
191
|
+
headers,
|
|
192
|
+
body: {
|
|
193
|
+
error: true,
|
|
194
|
+
stack: error.stack?.split("\n").map((line) => line.trim()),
|
|
195
|
+
...jsonBody
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
headers.set("Content-Type", "text/html; charset=utf-8");
|
|
414
200
|
return {
|
|
415
201
|
status,
|
|
416
|
-
statusText: error.statusText,
|
|
202
|
+
statusText: unhandled ? "" : error.statusText,
|
|
417
203
|
headers,
|
|
418
|
-
body
|
|
204
|
+
body: await youch.toHTML(error, { request: {
|
|
205
|
+
url: url.href,
|
|
206
|
+
method: event.req.method,
|
|
207
|
+
headers: Object.fromEntries(event.req.headers.entries())
|
|
208
|
+
} })
|
|
419
209
|
};
|
|
420
210
|
}
|
|
421
211
|
async function loadStackTrace(error) {
|
|
422
212
|
if (!(error instanceof Error)) return;
|
|
213
|
+
const { ErrorParser } = await import("youch-core");
|
|
423
214
|
const parsed = await new ErrorParser().defineSourceLoader(sourceLoader).parse(error);
|
|
424
215
|
const stack = error.message + "\n" + parsed.frames.map((frame) => fmtFrame(frame)).join("\n");
|
|
425
216
|
Object.defineProperty(error, "stack", { value: stack });
|
|
426
|
-
if (error.cause) await loadStackTrace(error.cause).catch(consola
|
|
217
|
+
if (error.cause) await loadStackTrace(error.cause).catch(consola.error);
|
|
427
218
|
}
|
|
428
219
|
async function sourceLoader(frame) {
|
|
429
220
|
if (!frame.fileName || frame.fileType !== "fs" || frame.type === "native") return;
|
|
430
221
|
if (frame.type === "app") {
|
|
431
222
|
const rawSourceMap = await readFile(`${frame.fileName}.map`, "utf8").catch(() => {});
|
|
432
223
|
if (rawSourceMap) {
|
|
224
|
+
const { SourceMapConsumer } = await import("source-map");
|
|
433
225
|
const originalPosition = (await new SourceMapConsumer(rawSourceMap)).originalPositionFor({
|
|
434
226
|
line: frame.lineNumber,
|
|
435
227
|
column: frame.columnNumber
|
|
@@ -449,7 +241,6 @@ function fmtFrame(frame) {
|
|
|
449
241
|
const src = `${frame.fileName || ""}:${frame.lineNumber}:${frame.columnNumber})`;
|
|
450
242
|
return frame.functionName ? `at ${frame.functionName} (${src}` : `at ${src}`;
|
|
451
243
|
}
|
|
452
|
-
|
|
453
244
|
//#endregion
|
|
454
245
|
//#region src/dev/app.ts
|
|
455
246
|
var NitroDevApp = class {
|
|
@@ -464,9 +255,9 @@ var NitroDevApp = class {
|
|
|
464
255
|
const app = new H3({
|
|
465
256
|
debug: true,
|
|
466
257
|
onError: async (error, event) => {
|
|
467
|
-
const errorHandler = this.nitro.options.devErrorHandler ||
|
|
258
|
+
const errorHandler$1 = this.nitro.options.devErrorHandler || errorHandler;
|
|
468
259
|
await loadStackTrace(error).catch(() => {});
|
|
469
|
-
return errorHandler(error, event, { defaultHandler });
|
|
260
|
+
return errorHandler$1(error, event, { defaultHandler });
|
|
470
261
|
}
|
|
471
262
|
});
|
|
472
263
|
for (const h of this.nitro.options.devHandlers) {
|
|
@@ -509,11 +300,11 @@ function serveStaticDir(event, opts) {
|
|
|
509
300
|
return serveStatic(event, {
|
|
510
301
|
fallthrough: opts.fallthrough,
|
|
511
302
|
getMeta: async (id) => {
|
|
512
|
-
const path
|
|
513
|
-
if (!path
|
|
514
|
-
const s = await stat$1(path
|
|
303
|
+
const path = r(id);
|
|
304
|
+
if (!path) return;
|
|
305
|
+
const s = await stat$1(path).catch(() => null);
|
|
515
306
|
if (!s?.isFile()) return;
|
|
516
|
-
const ext = extname$1(path
|
|
307
|
+
const ext = extname$1(path);
|
|
517
308
|
return {
|
|
518
309
|
size: s.size,
|
|
519
310
|
mtime: s.mtime,
|
|
@@ -521,9 +312,9 @@ function serveStaticDir(event, opts) {
|
|
|
521
312
|
};
|
|
522
313
|
},
|
|
523
314
|
getContents(id) {
|
|
524
|
-
const path
|
|
525
|
-
if (!path
|
|
526
|
-
const stream = createReadStream(path
|
|
315
|
+
const path = r(id);
|
|
316
|
+
if (!path) return;
|
|
317
|
+
const stream = createReadStream(path);
|
|
527
318
|
const acceptEncoding = event.req.headers.get("accept-encoding") || "";
|
|
528
319
|
if (acceptEncoding.includes("br")) {
|
|
529
320
|
event.res.headers.set("Content-Encoding", "br");
|
|
@@ -540,7 +331,29 @@ function serveStaticDir(event, opts) {
|
|
|
540
331
|
}
|
|
541
332
|
});
|
|
542
333
|
}
|
|
543
|
-
|
|
334
|
+
function createHTTPProxy(defaults = {}) {
|
|
335
|
+
const proxy = createProxyServer({
|
|
336
|
+
xfwd: true,
|
|
337
|
+
...defaults
|
|
338
|
+
});
|
|
339
|
+
return {
|
|
340
|
+
proxy,
|
|
341
|
+
async handleEvent(event, opts) {
|
|
342
|
+
try {
|
|
343
|
+
return await fromNodeHandler((req, res) => {
|
|
344
|
+
return proxy.web(req, res, opts);
|
|
345
|
+
})(event);
|
|
346
|
+
} catch (error) {
|
|
347
|
+
event.res.headers.set("refresh", "3");
|
|
348
|
+
throw new HTTPError({
|
|
349
|
+
status: 503,
|
|
350
|
+
message: "Dev server is unavailable.",
|
|
351
|
+
cause: error
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
544
357
|
//#endregion
|
|
545
358
|
//#region src/dev/server.ts
|
|
546
359
|
function createDevServer(nitro) {
|
|
@@ -551,17 +364,21 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
551
364
|
#workerData = {};
|
|
552
365
|
#listeners = [];
|
|
553
366
|
#watcher;
|
|
554
|
-
#
|
|
367
|
+
#manager;
|
|
555
368
|
#workerIdCtr = 0;
|
|
556
369
|
#workerError;
|
|
370
|
+
#workerRetries = 0;
|
|
557
371
|
#building = true;
|
|
558
372
|
#buildError;
|
|
559
|
-
#
|
|
373
|
+
#reloadPromise;
|
|
560
374
|
constructor(nitro) {
|
|
561
375
|
super(nitro, async (event) => {
|
|
562
|
-
|
|
563
|
-
if (
|
|
564
|
-
return
|
|
376
|
+
if (this.#building) await this.#waitForBuild();
|
|
377
|
+
if (this.#reloadPromise) await this.#reloadPromise;
|
|
378
|
+
if (this.#buildError) return this.#generateError();
|
|
379
|
+
const response = await this.#manager.fetch(event.req);
|
|
380
|
+
if (response.status === 503 && !this.#manager.ready) return this.#generateError();
|
|
381
|
+
return response;
|
|
565
382
|
});
|
|
566
383
|
for (const key of Object.getOwnPropertyNames(NitroDevServer.prototype)) {
|
|
567
384
|
const value = this[key];
|
|
@@ -569,6 +386,20 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
569
386
|
}
|
|
570
387
|
nitro.fetch = this.fetch.bind(this);
|
|
571
388
|
this.#entry = resolve$1(nitro.options.output.dir, nitro.options.output.serverDir, "index.mjs");
|
|
389
|
+
this.#manager = new RunnerManager();
|
|
390
|
+
this.#manager.onReady(async (_runner, addr) => {
|
|
391
|
+
this.#workerRetries = 0;
|
|
392
|
+
writeDevBuildInfo(this.nitro, addr).catch((error) => {
|
|
393
|
+
this.nitro.logger.warn(`Failed to write dev build info: ${error instanceof Error ? error.message : String(error)}`);
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
this.#manager.onClose((_runner, cause) => {
|
|
397
|
+
this.#workerError = cause;
|
|
398
|
+
if (this.#workerRetries++ < 3) {
|
|
399
|
+
this.nitro.logger.info("Restarting dev worker...", cause ? `Cause: ${cause}` : "");
|
|
400
|
+
this.reload();
|
|
401
|
+
} else this.nitro.logger.error("Dev worker failed after 3 retries.", cause ? `Last cause: ${cause}` : "");
|
|
402
|
+
});
|
|
572
403
|
nitro.hooks.hook("close", () => this.close());
|
|
573
404
|
nitro.hooks.hook("dev:start", () => {
|
|
574
405
|
this.#building = true;
|
|
@@ -584,7 +415,6 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
584
415
|
nitro.hooks.hook("dev:error", (cause) => {
|
|
585
416
|
this.#buildError = cause;
|
|
586
417
|
this.#building = false;
|
|
587
|
-
for (const worker of this.#workers) worker.close();
|
|
588
418
|
});
|
|
589
419
|
const devWatch = nitro.options.devServer.watch;
|
|
590
420
|
if (devWatch && devWatch.length > 0) {
|
|
@@ -594,16 +424,15 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
594
424
|
}
|
|
595
425
|
}
|
|
596
426
|
async upgrade(req, socket, head) {
|
|
597
|
-
|
|
598
|
-
if (!worker) throw new HTTPError({
|
|
599
|
-
status: 503,
|
|
600
|
-
statusText: "No worker available."
|
|
601
|
-
});
|
|
602
|
-
if (!worker.upgrade) throw new HTTPError({
|
|
427
|
+
if (!this.#manager.upgrade) throw new HTTPError({
|
|
603
428
|
status: 501,
|
|
604
429
|
statusText: "Worker does not support upgrades."
|
|
605
430
|
});
|
|
606
|
-
return
|
|
431
|
+
return this.#manager.upgrade({ node: {
|
|
432
|
+
req,
|
|
433
|
+
socket,
|
|
434
|
+
head
|
|
435
|
+
} });
|
|
607
436
|
}
|
|
608
437
|
listen(opts) {
|
|
609
438
|
const server = serve({
|
|
@@ -620,58 +449,42 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
620
449
|
Promise.all(this.#listeners.map((l) => l.close())).then(() => {
|
|
621
450
|
this.#listeners = [];
|
|
622
451
|
}),
|
|
623
|
-
|
|
624
|
-
this.#workers = [];
|
|
625
|
-
}),
|
|
452
|
+
this.#manager.close(),
|
|
626
453
|
Promise.resolve(this.#watcher?.close()).then(() => {
|
|
627
454
|
this.#watcher = void 0;
|
|
628
455
|
})
|
|
629
456
|
].map((p) => p.catch((error) => {
|
|
630
|
-
consola
|
|
457
|
+
consola.error(error);
|
|
631
458
|
})));
|
|
632
459
|
}
|
|
633
460
|
reload() {
|
|
634
|
-
|
|
635
|
-
|
|
461
|
+
const nextReload = (this.#reloadPromise ?? Promise.resolve()).catch(() => {}).then(() => this.#reload());
|
|
462
|
+
this.#reloadPromise = nextReload.finally(() => {
|
|
463
|
+
if (this.#reloadPromise === nextReload) this.#reloadPromise = void 0;
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
async #reload() {
|
|
467
|
+
const runner = await loadRunner(this.nitro.options.devServer.runner || process.env.NITRO_DEV_RUNNER || "node-worker", {
|
|
636
468
|
name: `Nitro_${this.#workerIdCtr++}`,
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
onClose: (worker$1, cause) => {
|
|
641
|
-
this.#workerError = cause;
|
|
642
|
-
const index = this.#workers.indexOf(worker$1);
|
|
643
|
-
if (index !== -1) this.#workers.splice(index, 1);
|
|
644
|
-
},
|
|
645
|
-
onReady: async (_worker, addr) => {
|
|
646
|
-
writeDevBuildInfo(this.nitro, addr).catch(() => {});
|
|
647
|
-
}
|
|
469
|
+
data: {
|
|
470
|
+
entry: this.#entry,
|
|
471
|
+
...this.#workerData
|
|
648
472
|
}
|
|
649
473
|
});
|
|
650
|
-
|
|
651
|
-
for (const listener of this.#messageListeners) worker.onMessage(listener);
|
|
652
|
-
this.#workers.unshift(worker);
|
|
653
|
-
}
|
|
474
|
+
await this.#manager.reload(runner);
|
|
654
475
|
}
|
|
655
476
|
sendMessage(message) {
|
|
656
|
-
|
|
477
|
+
this.#manager.sendMessage(message);
|
|
657
478
|
}
|
|
658
479
|
onMessage(listener) {
|
|
659
|
-
this.#
|
|
660
|
-
for (const worker of this.#workers) worker.onMessage(listener);
|
|
480
|
+
this.#manager.onMessage(listener);
|
|
661
481
|
}
|
|
662
482
|
offMessage(listener) {
|
|
663
|
-
this.#
|
|
664
|
-
for (const worker of this.#workers) worker.offMessage(listener);
|
|
483
|
+
this.#manager.offMessage(listener);
|
|
665
484
|
}
|
|
666
|
-
async #
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
while (this.#building || ++retry < maxRetries) {
|
|
670
|
-
if ((this.#workers.length === 0 || this.#buildError) && !this.#building) return;
|
|
671
|
-
const activeWorker = this.#workers.find((w) => w.ready);
|
|
672
|
-
if (activeWorker) return activeWorker;
|
|
673
|
-
await new Promise((resolve$2) => setTimeout(resolve$2, 600));
|
|
674
|
-
}
|
|
485
|
+
async #waitForBuild() {
|
|
486
|
+
const timeout = v || m ? 6e4 : 6e3;
|
|
487
|
+
await this.#manager.waitForReady(timeout);
|
|
675
488
|
}
|
|
676
489
|
#generateError() {
|
|
677
490
|
const error = this.#buildError || this.#workerError;
|
|
@@ -702,6 +515,5 @@ var NitroDevServer = class NitroDevServer extends NitroDevApp {
|
|
|
702
515
|
});
|
|
703
516
|
}
|
|
704
517
|
};
|
|
705
|
-
|
|
706
518
|
//#endregion
|
|
707
|
-
export {
|
|
519
|
+
export { createDevServer as n, NitroDevApp as r, NitroDevServer as t };
|
package/dist/_libs/_.mjs
ADDED