@nuxt/cli-nightly 3.30.0-20251027-201254-c23e915 → 3.30.0-20251027-204413-3afd02b
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/dist/dev/index.d.mts +1 -1
- package/dist/dev-lAMCAq4V.mjs +344 -0
- package/dist/index.mjs +3 -3
- package/dist/{info-D9LA_sGO.mjs → info-BcBjPMvL.mjs} +1 -1
- package/package.json +3 -2
- package/dist/dev-DG7T8nNT.mjs +0 -591
package/dist/dev/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HTTPSOptions, ListenOptions, ListenURL, Listener } from "listhen";
|
|
2
2
|
import { IncomingMessage, RequestListener, ServerResponse } from "node:http";
|
|
3
3
|
import EventEmitter from "node:events";
|
|
4
|
-
import { AddressInfo } from "node:net";
|
|
5
4
|
import { DotenvOptions } from "c12";
|
|
6
5
|
import { NuxtConfig } from "@nuxt/schema";
|
|
6
|
+
import { AddressInfo } from "node:net";
|
|
7
7
|
|
|
8
8
|
//#region ../nuxi/src/dev/utils.d.ts
|
|
9
9
|
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { a as legacyRootDirArgs, i as extendsArgs, n as dotEnvArgs, o as logLevelArgs, r as envNameArgs, t as cwdArgs } from "./_shared-C3vB2YLc.mjs";
|
|
2
|
+
import { t as logger } from "./logger-Dk0gkCkX.mjs";
|
|
3
|
+
import { a as parseSocketURL, i as isSocketURL, n as resolveLoadingTemplate, r as renderError, t as initialize } from "./dev-DsH3xiyp.mjs";
|
|
4
|
+
import "./fs-ewAp6tjM.mjs";
|
|
5
|
+
import { t as loadKit } from "./kit-xFxVGu6d.mjs";
|
|
6
|
+
import "./nuxt-Cc9ZTk7m.mjs";
|
|
7
|
+
import { t as overrideEnv } from "./env-Dz4K_NkM.mjs";
|
|
8
|
+
import { n as showVersionsFromConfig } from "./banner-95R8hV4o.mjs";
|
|
9
|
+
import process from "node:process";
|
|
10
|
+
import { defineCommand } from "citty";
|
|
11
|
+
import { isBun, isDeno, isTest } from "std-env";
|
|
12
|
+
import { listen } from "listhen";
|
|
13
|
+
import { isSocketSupported } from "get-port-please";
|
|
14
|
+
import { resolve } from "pathe";
|
|
15
|
+
import { fork } from "node:child_process";
|
|
16
|
+
import { createProxyServer } from "http-proxy-3";
|
|
17
|
+
import { getArgs, parseArgs } from "listhen/cli";
|
|
18
|
+
import { satisfies } from "semver";
|
|
19
|
+
|
|
20
|
+
//#region ../nuxi/src/commands/dev.ts
|
|
21
|
+
const startTime = Date.now();
|
|
22
|
+
const forkSupported = !isTest && (!isBun || isBunForkSupported());
|
|
23
|
+
const listhenArgs = getArgs();
|
|
24
|
+
const command = defineCommand({
|
|
25
|
+
meta: {
|
|
26
|
+
name: "dev",
|
|
27
|
+
description: "Run Nuxt development server"
|
|
28
|
+
},
|
|
29
|
+
args: {
|
|
30
|
+
...cwdArgs,
|
|
31
|
+
...logLevelArgs,
|
|
32
|
+
...dotEnvArgs,
|
|
33
|
+
...legacyRootDirArgs,
|
|
34
|
+
...envNameArgs,
|
|
35
|
+
...extendsArgs,
|
|
36
|
+
clear: {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
description: "Clear console on restart",
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
fork: {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
description: forkSupported ? "Disable forked mode" : "Enable forked mode",
|
|
44
|
+
negativeDescription: "Disable forked mode",
|
|
45
|
+
default: forkSupported,
|
|
46
|
+
alias: ["f"]
|
|
47
|
+
},
|
|
48
|
+
...listhenArgs,
|
|
49
|
+
"port": {
|
|
50
|
+
...listhenArgs.port,
|
|
51
|
+
description: "Port to listen on (default: `NUXT_PORT || NITRO_PORT || PORT || nuxtOptions.devServer.port`)",
|
|
52
|
+
alias: ["p"]
|
|
53
|
+
},
|
|
54
|
+
"open": {
|
|
55
|
+
...listhenArgs.open,
|
|
56
|
+
alias: ["o"],
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
"host": {
|
|
60
|
+
...listhenArgs.host,
|
|
61
|
+
alias: ["h"],
|
|
62
|
+
description: "Host to listen on (default: `NUXT_HOST || NITRO_HOST || HOST || nuxtOptions.devServer?.host`)"
|
|
63
|
+
},
|
|
64
|
+
"clipboard": {
|
|
65
|
+
...listhenArgs.clipboard,
|
|
66
|
+
default: false
|
|
67
|
+
},
|
|
68
|
+
"https.domains": {
|
|
69
|
+
...listhenArgs["https.domains"],
|
|
70
|
+
description: "Comma separated list of domains and IPs, the autogenerated certificate should be valid for (https: true)"
|
|
71
|
+
},
|
|
72
|
+
sslCert: {
|
|
73
|
+
type: "string",
|
|
74
|
+
description: "(DEPRECATED) Use `--https.cert` instead."
|
|
75
|
+
},
|
|
76
|
+
sslKey: {
|
|
77
|
+
type: "string",
|
|
78
|
+
description: "(DEPRECATED) Use `--https.key` instead."
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
async run(ctx) {
|
|
82
|
+
overrideEnv("development");
|
|
83
|
+
const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
|
|
84
|
+
const { loadNuxtConfig } = await loadKit(cwd);
|
|
85
|
+
const nuxtOptions = await loadNuxtConfig({
|
|
86
|
+
cwd,
|
|
87
|
+
dotenv: {
|
|
88
|
+
cwd,
|
|
89
|
+
fileName: ctx.args.dotenv
|
|
90
|
+
},
|
|
91
|
+
envName: ctx.args.envName,
|
|
92
|
+
overrides: {
|
|
93
|
+
dev: true,
|
|
94
|
+
logLevel: ctx.args.logLevel,
|
|
95
|
+
...ctx.args.extends && { extends: ctx.args.extends },
|
|
96
|
+
...ctx.data?.overrides
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
showVersionsFromConfig(cwd, nuxtOptions);
|
|
100
|
+
const listenOptions = resolveListenOptions(nuxtOptions, ctx.args);
|
|
101
|
+
if (!ctx.args.fork) {
|
|
102
|
+
const { listener, close: close$1 } = await initialize({
|
|
103
|
+
cwd,
|
|
104
|
+
args: ctx.args,
|
|
105
|
+
hostname: listenOptions.hostname,
|
|
106
|
+
public: listenOptions.public,
|
|
107
|
+
publicURLs: void 0,
|
|
108
|
+
proxy: { https: listenOptions.https }
|
|
109
|
+
}, { data: ctx.data }, listenOptions);
|
|
110
|
+
return {
|
|
111
|
+
listener,
|
|
112
|
+
async close() {
|
|
113
|
+
await close$1();
|
|
114
|
+
await listener.close();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const devProxy = await createDevProxy(cwd, nuxtOptions, listenOptions);
|
|
119
|
+
const useSocket = (process.env.NUXT_SOCKET ? process.env.NUXT_SOCKET === "1" : void 0) ?? (nuxtOptions._majorVersion === 4 && await isSocketSupported());
|
|
120
|
+
const urls = await devProxy.listener.getURLs();
|
|
121
|
+
const { onRestart, onReady, close } = await initialize({
|
|
122
|
+
cwd,
|
|
123
|
+
args: ctx.args,
|
|
124
|
+
hostname: listenOptions.hostname,
|
|
125
|
+
public: listenOptions.public,
|
|
126
|
+
publicURLs: urls.map((r) => r.url),
|
|
127
|
+
proxy: {
|
|
128
|
+
url: devProxy.listener.url,
|
|
129
|
+
urls,
|
|
130
|
+
https: devProxy.listener.https,
|
|
131
|
+
addr: devProxy.listener.address
|
|
132
|
+
}
|
|
133
|
+
}, {}, useSocket ? void 0 : true);
|
|
134
|
+
onReady((address) => devProxy.setAddress(address));
|
|
135
|
+
const fork$1 = startSubprocess(cwd, ctx.args, ctx.rawArgs, listenOptions);
|
|
136
|
+
onRestart(async (devServer) => {
|
|
137
|
+
const [subprocess] = await Promise.all([fork$1, devServer.close().catch(() => {})]);
|
|
138
|
+
await subprocess.initialize(devProxy, useSocket);
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
listener: devProxy.listener,
|
|
142
|
+
async close() {
|
|
143
|
+
await close();
|
|
144
|
+
(await fork$1).kill(0);
|
|
145
|
+
await devProxy.listener.close();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
var dev_default = command;
|
|
151
|
+
async function createDevProxy(cwd, nuxtOptions, listenOptions) {
|
|
152
|
+
let loadingMessage = "Nuxt dev server is starting...";
|
|
153
|
+
let error;
|
|
154
|
+
let address;
|
|
155
|
+
let loadingTemplate = nuxtOptions.devServer.loadingTemplate;
|
|
156
|
+
const proxy = createProxyServer({});
|
|
157
|
+
proxy.on("proxyReq", (proxyReq, req) => {
|
|
158
|
+
if (!proxyReq.hasHeader("x-forwarded-for")) {
|
|
159
|
+
const address$1 = req.socket.remoteAddress;
|
|
160
|
+
if (address$1) proxyReq.appendHeader("x-forwarded-for", address$1);
|
|
161
|
+
}
|
|
162
|
+
if (!proxyReq.hasHeader("x-forwarded-port")) {
|
|
163
|
+
const localPort = req?.socket?.localPort;
|
|
164
|
+
if (localPort) proxyReq.setHeader("x-forwarded-port", localPort);
|
|
165
|
+
}
|
|
166
|
+
if (!proxyReq.hasHeader("x-forwarded-Proto")) {
|
|
167
|
+
const encrypted = (req?.connection)?.encrypted;
|
|
168
|
+
proxyReq.setHeader("x-forwarded-proto", encrypted ? "https" : "http");
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
const listener = await listen((req, res) => {
|
|
172
|
+
if (error) {
|
|
173
|
+
renderError(req, res, error);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!address) {
|
|
177
|
+
res.statusCode = 503;
|
|
178
|
+
res.setHeader("Content-Type", "text/html");
|
|
179
|
+
res.setHeader("Cache-Control", "no-store");
|
|
180
|
+
if (loadingTemplate) {
|
|
181
|
+
res.end(loadingTemplate({ loading: loadingMessage }));
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
async function resolveLoadingMessage() {
|
|
185
|
+
loadingTemplate = await resolveLoadingTemplate(cwd);
|
|
186
|
+
res.end(loadingTemplate({ loading: loadingMessage }));
|
|
187
|
+
}
|
|
188
|
+
return resolveLoadingMessage();
|
|
189
|
+
}
|
|
190
|
+
const target = isSocketURL(address) ? parseSocketURL(address) : address;
|
|
191
|
+
proxy.web(req, res, { target });
|
|
192
|
+
}, listenOptions);
|
|
193
|
+
listener.server.on("upgrade", (req, socket, head) => {
|
|
194
|
+
if (!address) {
|
|
195
|
+
if (!socket.destroyed) socket.end();
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const target = isSocketURL(address) ? parseSocketURL(address) : address;
|
|
199
|
+
return proxy.ws(req, socket, head, {
|
|
200
|
+
target,
|
|
201
|
+
xfwd: true
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
listener,
|
|
206
|
+
setAddress: (_addr) => {
|
|
207
|
+
address = _addr;
|
|
208
|
+
},
|
|
209
|
+
setLoadingMessage: (_msg) => {
|
|
210
|
+
loadingMessage = _msg;
|
|
211
|
+
},
|
|
212
|
+
setError: (_error) => {
|
|
213
|
+
error = _error;
|
|
214
|
+
},
|
|
215
|
+
clearError() {
|
|
216
|
+
error = void 0;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
async function startSubprocess(cwd, args, rawArgs, listenOptions) {
|
|
221
|
+
let childProc;
|
|
222
|
+
let devProxy;
|
|
223
|
+
let ready;
|
|
224
|
+
const kill = (signal) => {
|
|
225
|
+
if (childProc) {
|
|
226
|
+
childProc.kill(signal === 0 && isDeno ? "SIGTERM" : signal);
|
|
227
|
+
childProc = void 0;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
async function initialize$1(proxy, socket) {
|
|
231
|
+
devProxy = proxy;
|
|
232
|
+
const urls = await devProxy.listener.getURLs();
|
|
233
|
+
await ready;
|
|
234
|
+
childProc.send({
|
|
235
|
+
type: "nuxt:internal:dev:context",
|
|
236
|
+
socket,
|
|
237
|
+
context: {
|
|
238
|
+
cwd,
|
|
239
|
+
args,
|
|
240
|
+
hostname: listenOptions.hostname,
|
|
241
|
+
public: listenOptions.public,
|
|
242
|
+
publicURLs: urls.map((r) => r.url),
|
|
243
|
+
proxy: {
|
|
244
|
+
url: devProxy.listener.url,
|
|
245
|
+
urls,
|
|
246
|
+
https: devProxy.listener.https
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
async function restart() {
|
|
252
|
+
devProxy?.clearError();
|
|
253
|
+
if (!globalThis.__nuxt_cli__) return;
|
|
254
|
+
if (process.platform === "win32") kill("SIGTERM");
|
|
255
|
+
else kill("SIGHUP");
|
|
256
|
+
childProc = fork(globalThis.__nuxt_cli__.devEntry, rawArgs, {
|
|
257
|
+
execArgv: ["--enable-source-maps", process.argv.find((a) => a.includes("--inspect"))].filter(Boolean),
|
|
258
|
+
env: {
|
|
259
|
+
...process.env,
|
|
260
|
+
__NUXT__FORK: "true"
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
childProc.on("close", (errorCode) => {
|
|
264
|
+
if (errorCode) process.exit(errorCode);
|
|
265
|
+
});
|
|
266
|
+
ready = new Promise((resolve$1, reject) => {
|
|
267
|
+
childProc.on("error", reject);
|
|
268
|
+
childProc.on("message", (message) => {
|
|
269
|
+
if (message.type === "nuxt:internal:dev:fork-ready") resolve$1();
|
|
270
|
+
else if (message.type === "nuxt:internal:dev:ready") {
|
|
271
|
+
devProxy.setAddress(message.address);
|
|
272
|
+
if (startTime) logger.debug(`Dev server ready for connections in ${Date.now() - startTime}ms`);
|
|
273
|
+
} else if (message.type === "nuxt:internal:dev:loading") {
|
|
274
|
+
devProxy.setAddress(void 0);
|
|
275
|
+
devProxy.setLoadingMessage(message.message);
|
|
276
|
+
devProxy.clearError();
|
|
277
|
+
} else if (message.type === "nuxt:internal:dev:loading:error") {
|
|
278
|
+
devProxy.setAddress(void 0);
|
|
279
|
+
devProxy.setError(message.error);
|
|
280
|
+
} else if (message.type === "nuxt:internal:dev:restart") restart();
|
|
281
|
+
else if (message.type === "nuxt:internal:dev:rejection") {
|
|
282
|
+
logger.info(`Restarting Nuxt due to error: \`${message.message}\``);
|
|
283
|
+
restart();
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
for (const signal of [
|
|
289
|
+
"exit",
|
|
290
|
+
"SIGTERM",
|
|
291
|
+
"SIGINT",
|
|
292
|
+
"SIGQUIT"
|
|
293
|
+
]) process.once(signal, () => {
|
|
294
|
+
kill(signal === "exit" ? 0 : signal);
|
|
295
|
+
});
|
|
296
|
+
await restart();
|
|
297
|
+
return {
|
|
298
|
+
initialize: initialize$1,
|
|
299
|
+
restart,
|
|
300
|
+
kill
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function resolveListenOptions(nuxtOptions, args) {
|
|
304
|
+
const _port = args.port ?? args.p ?? process.env.NUXT_PORT ?? process.env.NITRO_PORT ?? process.env.PORT ?? nuxtOptions.devServer.port;
|
|
305
|
+
const _hostname = typeof args.host === "string" ? args.host : args.host === true ? "" : process.env.NUXT_HOST ?? process.env.NITRO_HOST ?? process.env.HOST ?? (nuxtOptions.devServer?.host || void 0) ?? void 0;
|
|
306
|
+
const _public = args.public ?? (_hostname && ![
|
|
307
|
+
"localhost",
|
|
308
|
+
"127.0.0.1",
|
|
309
|
+
"::1"
|
|
310
|
+
].includes(_hostname)) ? true : void 0;
|
|
311
|
+
const _httpsCert = args["https.cert"] || args.sslCert || process.env.NUXT_SSL_CERT || process.env.NITRO_SSL_CERT || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "cert" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.cert || "";
|
|
312
|
+
const _httpsKey = args["https.key"] || args.sslKey || process.env.NUXT_SSL_KEY || process.env.NITRO_SSL_KEY || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "key" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.key || "";
|
|
313
|
+
const _httpsPfx = args["https.pfx"] || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "pfx" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.pfx || "";
|
|
314
|
+
const _httpsPassphrase = args["https.passphrase"] || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "passphrase" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.passphrase || "";
|
|
315
|
+
const httpsEnabled = !!(args.https ?? nuxtOptions.devServer.https);
|
|
316
|
+
const _listhenOptions = parseArgs({
|
|
317
|
+
...args,
|
|
318
|
+
"open": args.o || args.open,
|
|
319
|
+
"https": httpsEnabled,
|
|
320
|
+
"https.cert": _httpsCert,
|
|
321
|
+
"https.key": _httpsKey,
|
|
322
|
+
"https.pfx": _httpsPfx,
|
|
323
|
+
"https.passphrase": _httpsPassphrase
|
|
324
|
+
});
|
|
325
|
+
const httpsOptions = httpsEnabled && {
|
|
326
|
+
...nuxtOptions.devServer.https,
|
|
327
|
+
..._listhenOptions.https
|
|
328
|
+
};
|
|
329
|
+
return {
|
|
330
|
+
..._listhenOptions,
|
|
331
|
+
port: _port,
|
|
332
|
+
hostname: _hostname,
|
|
333
|
+
public: _public,
|
|
334
|
+
https: httpsOptions,
|
|
335
|
+
baseURL: nuxtOptions.app.baseURL.startsWith("./") ? nuxtOptions.app.baseURL.slice(1) : nuxtOptions.app.baseURL
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function isBunForkSupported() {
|
|
339
|
+
const bunVersion = globalThis.Bun.version;
|
|
340
|
+
return satisfies(bunVersion, ">=1.2");
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
//#endregion
|
|
344
|
+
export { dev_default as default };
|
package/dist/index.mjs
CHANGED
|
@@ -15,10 +15,10 @@ const commands = {
|
|
|
15
15
|
build: () => import("./build-BebJ09xA.mjs").then(_rDefault),
|
|
16
16
|
cleanup: () => import("./cleanup-8GRakeLu.mjs").then(_rDefault),
|
|
17
17
|
_dev: () => import("./dev-child-CJxOnht6.mjs").then(_rDefault),
|
|
18
|
-
dev: () => import("./dev-
|
|
18
|
+
dev: () => import("./dev-lAMCAq4V.mjs").then(_rDefault),
|
|
19
19
|
devtools: () => import("./devtools-BLGzUSNU.mjs").then(_rDefault),
|
|
20
20
|
generate: () => import("./generate-B328yidV.mjs").then(_rDefault),
|
|
21
|
-
info: () => import("./info-
|
|
21
|
+
info: () => import("./info-BcBjPMvL.mjs").then(_rDefault),
|
|
22
22
|
init: () => import("./init-CvLYtdn1.mjs").then(_rDefault),
|
|
23
23
|
module: () => import("./module-BUBa48Be.mjs").then(_rDefault),
|
|
24
24
|
prepare: () => import("./prepare-B0KOhO-L.mjs").then(_rDefault),
|
|
@@ -63,7 +63,7 @@ async function checkEngines() {
|
|
|
63
63
|
//#endregion
|
|
64
64
|
//#region package.json
|
|
65
65
|
var name = "@nuxt/cli-nightly";
|
|
66
|
-
var version = "3.30.0-20251027-
|
|
66
|
+
var version = "3.30.0-20251027-204413-3afd02b";
|
|
67
67
|
var description = "Nuxt CLI";
|
|
68
68
|
|
|
69
69
|
//#endregion
|
|
@@ -13,7 +13,7 @@ import { detectPackageManager } from "nypm";
|
|
|
13
13
|
import { readPackageJSON } from "pkg-types";
|
|
14
14
|
|
|
15
15
|
//#region ../nuxi/package.json
|
|
16
|
-
var version = "3.30.0-20251027-
|
|
16
|
+
var version = "3.30.0-20251027-204406-3afd02b";
|
|
17
17
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region ../nuxi/src/commands/info.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/cli-nightly",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.30.0-20251027-
|
|
4
|
+
"version": "3.30.0-20251027-204413-3afd02b",
|
|
5
5
|
"description": "Nuxt CLI",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"fuse.js": "^7.1.0",
|
|
44
44
|
"get-port-please": "^3.2.0",
|
|
45
45
|
"giget": "^2.0.0",
|
|
46
|
+
"http-proxy-3": "^1.22.0",
|
|
46
47
|
"jiti": "^2.6.1",
|
|
47
48
|
"listhen": "^1.9.0",
|
|
48
49
|
"nypm": "^0.6.2",
|
|
@@ -57,7 +58,6 @@
|
|
|
57
58
|
"std-env": "^3.10.0",
|
|
58
59
|
"tinyexec": "^1.0.1",
|
|
59
60
|
"ufo": "^1.6.1",
|
|
60
|
-
"undici": "^7.16.0",
|
|
61
61
|
"youch": "^4.1.0-beta.11"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"rollup-plugin-visualizer": "^6.0.5",
|
|
73
73
|
"tsdown": "^0.15.9",
|
|
74
74
|
"typescript": "^5.9.3",
|
|
75
|
+
"undici": "^7.16.0",
|
|
75
76
|
"unplugin-purge-polyfills": "^0.1.0",
|
|
76
77
|
"vitest": "^3.2.4",
|
|
77
78
|
"youch": "^4.1.0-beta.11"
|
package/dist/dev-DG7T8nNT.mjs
DELETED
|
@@ -1,591 +0,0 @@
|
|
|
1
|
-
import { a as legacyRootDirArgs, i as extendsArgs, n as dotEnvArgs, o as logLevelArgs, r as envNameArgs, t as cwdArgs } from "./_shared-C3vB2YLc.mjs";
|
|
2
|
-
import { t as logger } from "./logger-Dk0gkCkX.mjs";
|
|
3
|
-
import { a as parseSocketURL, i as isSocketURL, n as resolveLoadingTemplate, r as renderError, t as initialize } from "./dev-DsH3xiyp.mjs";
|
|
4
|
-
import "./fs-ewAp6tjM.mjs";
|
|
5
|
-
import { t as loadKit } from "./kit-xFxVGu6d.mjs";
|
|
6
|
-
import "./nuxt-Cc9ZTk7m.mjs";
|
|
7
|
-
import { t as overrideEnv } from "./env-Dz4K_NkM.mjs";
|
|
8
|
-
import { n as showVersionsFromConfig } from "./banner-95R8hV4o.mjs";
|
|
9
|
-
import process from "node:process";
|
|
10
|
-
import { defineCommand } from "citty";
|
|
11
|
-
import { isBun, isDeno, isTest, isWindows } from "std-env";
|
|
12
|
-
import { listen } from "listhen";
|
|
13
|
-
import { request } from "node:http";
|
|
14
|
-
import { isSocketSupported } from "get-port-please";
|
|
15
|
-
import { resolve } from "pathe";
|
|
16
|
-
import { NodeRequest } from "srvx/node";
|
|
17
|
-
import { fork } from "node:child_process";
|
|
18
|
-
import { getArgs, parseArgs } from "listhen/cli";
|
|
19
|
-
import { satisfies } from "semver";
|
|
20
|
-
import { Readable } from "node:stream";
|
|
21
|
-
import { pipeline } from "node:stream/promises";
|
|
22
|
-
import { Agent } from "undici";
|
|
23
|
-
import { connect } from "node:net";
|
|
24
|
-
|
|
25
|
-
//#region ../nuxi/src/dev/fetch.ts
|
|
26
|
-
/**
|
|
27
|
-
* Create fetch options for socket-based communication
|
|
28
|
-
* Based on Nitro's fetchSocketOptions implementation
|
|
29
|
-
*/
|
|
30
|
-
function fetchSocketOptions(socketPath) {
|
|
31
|
-
if ("Bun" in globalThis) return { unix: socketPath };
|
|
32
|
-
if ("Deno" in globalThis) return { client: globalThis.Deno.createHttpClient({
|
|
33
|
-
transport: "unix",
|
|
34
|
-
path: socketPath
|
|
35
|
-
}) };
|
|
36
|
-
return { dispatcher: new Agent({ connect: { socketPath } }) };
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* fetch using native Node.js http.request for Windows named pipes
|
|
40
|
-
* this bypasses undici's Web Streams which have buffering issues on Windows
|
|
41
|
-
*/
|
|
42
|
-
function fetchWithNodeHttp(socketPath, url, init) {
|
|
43
|
-
return new Promise((resolve$1, reject) => {
|
|
44
|
-
const headers = {};
|
|
45
|
-
if (init?.headers) if (init.headers instanceof Headers) for (const [key, value] of init.headers.entries()) headers[key] = value;
|
|
46
|
-
else if (Array.isArray(init.headers)) for (const [key, value] of init.headers) headers[key] = value;
|
|
47
|
-
else Object.assign(headers, init.headers);
|
|
48
|
-
const req = request({
|
|
49
|
-
socketPath,
|
|
50
|
-
path: url.pathname + url.search,
|
|
51
|
-
method: init?.method || "GET",
|
|
52
|
-
headers
|
|
53
|
-
}, (res) => {
|
|
54
|
-
const responseHeaders = new Headers();
|
|
55
|
-
for (const [key, value] of Object.entries(res.headers)) if (value !== void 0) if (key.toLowerCase() === "set-cookie") if (Array.isArray(value)) for (const cookie of value) responseHeaders.append("set-cookie", cookie);
|
|
56
|
-
else responseHeaders.append("set-cookie", value);
|
|
57
|
-
else responseHeaders.set(key, Array.isArray(value) ? value.join(", ") : value);
|
|
58
|
-
res.on("error", (err) => {
|
|
59
|
-
if (err && err.message && !err.message.includes("aborted")) reject(err);
|
|
60
|
-
});
|
|
61
|
-
resolve$1({
|
|
62
|
-
status: res.statusCode || 200,
|
|
63
|
-
statusText: res.statusMessage || "OK",
|
|
64
|
-
headers: responseHeaders,
|
|
65
|
-
body: res
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
req.on("error", reject);
|
|
69
|
-
if (init?.body) {
|
|
70
|
-
if (typeof init.body === "string") req.write(init.body);
|
|
71
|
-
else if (init.body instanceof ReadableStream) {
|
|
72
|
-
const reader = init.body.getReader();
|
|
73
|
-
const pump = async () => {
|
|
74
|
-
try {
|
|
75
|
-
while (true) {
|
|
76
|
-
const { done, value } = await reader.read();
|
|
77
|
-
if (done) break;
|
|
78
|
-
req.write(value);
|
|
79
|
-
}
|
|
80
|
-
req.end();
|
|
81
|
-
} catch (err) {
|
|
82
|
-
req.destroy(err);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
pump();
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
req.end();
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Fetch to a specific address (socket or network)
|
|
94
|
-
* Based on Nitro's fetchAddress implementation
|
|
95
|
-
*/
|
|
96
|
-
function fetchAddress(addr, input, inputInit) {
|
|
97
|
-
let url;
|
|
98
|
-
let init;
|
|
99
|
-
if (input instanceof Request) {
|
|
100
|
-
url = new URL(input.url);
|
|
101
|
-
init = {
|
|
102
|
-
method: input.method,
|
|
103
|
-
headers: input.headers,
|
|
104
|
-
body: input.body,
|
|
105
|
-
...inputInit
|
|
106
|
-
};
|
|
107
|
-
} else {
|
|
108
|
-
url = new URL(input);
|
|
109
|
-
init = inputInit;
|
|
110
|
-
}
|
|
111
|
-
init = {
|
|
112
|
-
duplex: "half",
|
|
113
|
-
redirect: "manual",
|
|
114
|
-
...init
|
|
115
|
-
};
|
|
116
|
-
if (addr.socketPath && isWindows) {
|
|
117
|
-
url.protocol = "http:";
|
|
118
|
-
return fetchWithNodeHttp(addr.socketPath, url, init);
|
|
119
|
-
}
|
|
120
|
-
if (addr.socketPath) {
|
|
121
|
-
url.protocol = "http:";
|
|
122
|
-
return fetch(url, {
|
|
123
|
-
...init,
|
|
124
|
-
...fetchSocketOptions(addr.socketPath)
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
const origin = `http://${addr.host}${addr.port ? `:${addr.port}` : ""}`;
|
|
128
|
-
const outURL = new URL(url.pathname + url.search, origin);
|
|
129
|
-
return fetch(outURL, init);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Send Web API Response to Node.js ServerResponse
|
|
133
|
-
*/
|
|
134
|
-
async function sendWebResponse(res, webResponse) {
|
|
135
|
-
res.statusCode = webResponse.status;
|
|
136
|
-
res.statusMessage = webResponse.statusText;
|
|
137
|
-
const setCookies = webResponse.headers.getSetCookie?.();
|
|
138
|
-
if (setCookies && setCookies.length > 0) for (const cookie of setCookies) res.appendHeader("set-cookie", cookie);
|
|
139
|
-
for (const [key, value] of webResponse.headers.entries()) if (key.toLowerCase() !== "set-cookie") res.setHeader(key, value);
|
|
140
|
-
if (webResponse.body) {
|
|
141
|
-
if (webResponse.body instanceof Readable) {
|
|
142
|
-
try {
|
|
143
|
-
await pipeline(webResponse.body, res, { end: true });
|
|
144
|
-
} catch (error) {
|
|
145
|
-
if (!res.writableEnded) res.end();
|
|
146
|
-
throw error;
|
|
147
|
-
}
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const reader = webResponse.body.getReader();
|
|
151
|
-
try {
|
|
152
|
-
while (true) {
|
|
153
|
-
const { done, value } = await reader.read();
|
|
154
|
-
if (done) break;
|
|
155
|
-
if (!res.write(value)) await new Promise((resolve$1) => res.once("drain", resolve$1));
|
|
156
|
-
}
|
|
157
|
-
} catch (error) {
|
|
158
|
-
reader.releaseLock();
|
|
159
|
-
if (!res.writableEnded) res.end();
|
|
160
|
-
throw error;
|
|
161
|
-
} finally {
|
|
162
|
-
reader.releaseLock();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
res.end();
|
|
166
|
-
}
|
|
167
|
-
function createFetchHandler(getAddress, onError, onLoading) {
|
|
168
|
-
return async (req, res) => {
|
|
169
|
-
try {
|
|
170
|
-
const address = getAddress();
|
|
171
|
-
if (!address) {
|
|
172
|
-
await onLoading(req, res);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (req.headers.upgrade?.toLowerCase() === "websocket") {
|
|
176
|
-
res.statusCode = 426;
|
|
177
|
-
res.setHeader("Connection", "close");
|
|
178
|
-
res.end("Upgrade Required");
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
await sendWebResponse(res, await fetchAddress(address, new NodeRequest({
|
|
182
|
-
req,
|
|
183
|
-
res
|
|
184
|
-
})));
|
|
185
|
-
} catch (error) {
|
|
186
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
187
|
-
if (!(errorMessage.toLowerCase().includes("websocket") || errorMessage.toLowerCase().includes("upgrade"))) console.error("Fetch handler error:", error);
|
|
188
|
-
if (!res.headersSent) await onError(req, res);
|
|
189
|
-
else if (!res.writableEnded) res.end();
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
//#endregion
|
|
195
|
-
//#region ../nuxi/src/dev/websocket.ts
|
|
196
|
-
function connectToChildSocket(socketPath, req, clientSocket, head) {
|
|
197
|
-
const childSocket = connect(socketPath);
|
|
198
|
-
let isConnected = false;
|
|
199
|
-
childSocket.on("error", (error) => {
|
|
200
|
-
const errorMessage = error.message || "";
|
|
201
|
-
if (!errorMessage.includes("ECONNRESET") && !errorMessage.includes("EPIPE") && !errorMessage.includes("premature close")) console.error("Child socket connection error:", error);
|
|
202
|
-
if (!clientSocket.destroyed) clientSocket.destroy();
|
|
203
|
-
});
|
|
204
|
-
clientSocket.on("error", (error) => {
|
|
205
|
-
const errorMessage = error.message || "";
|
|
206
|
-
if (!errorMessage.includes("ECONNRESET") && !errorMessage.includes("EPIPE") && !isConnected) console.error("Client socket error:", error);
|
|
207
|
-
if (!childSocket.destroyed) childSocket.destroy();
|
|
208
|
-
});
|
|
209
|
-
childSocket.on("connect", () => {
|
|
210
|
-
isConnected = true;
|
|
211
|
-
const httpRequest = `${`${req.method} ${req.url} HTTP/${req.httpVersion}\r\n`}${Object.entries(req.headers).map(([key, value]) => {
|
|
212
|
-
if (Array.isArray(value)) return value.map((v) => `${key}: ${v}`).join("\r\n");
|
|
213
|
-
return `${key}: ${value}`;
|
|
214
|
-
}).join("\r\n")}\r\n\r\n`;
|
|
215
|
-
childSocket.write(httpRequest);
|
|
216
|
-
if (head && head.length > 0) childSocket.write(head);
|
|
217
|
-
clientSocket.pipe(childSocket);
|
|
218
|
-
childSocket.pipe(clientSocket);
|
|
219
|
-
});
|
|
220
|
-
const cleanup = () => {
|
|
221
|
-
if (!clientSocket.destroyed) clientSocket.destroy();
|
|
222
|
-
if (!childSocket.destroyed) childSocket.destroy();
|
|
223
|
-
};
|
|
224
|
-
clientSocket.on("close", cleanup);
|
|
225
|
-
childSocket.on("close", cleanup);
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Connect to child process via network address for WebSocket upgrades
|
|
229
|
-
* Fallback for non-socket addresses
|
|
230
|
-
*/
|
|
231
|
-
function connectToChildNetwork(host, port, req, clientSocket, head) {
|
|
232
|
-
const childSocket = connect(port, host);
|
|
233
|
-
let isConnected = false;
|
|
234
|
-
childSocket.on("error", (error) => {
|
|
235
|
-
const errorMessage = error.message || "";
|
|
236
|
-
if (!errorMessage.includes("ECONNRESET") && !errorMessage.includes("EPIPE") && !errorMessage.includes("premature close")) console.error("Child network connection error:", error);
|
|
237
|
-
if (!clientSocket.destroyed) clientSocket.destroy();
|
|
238
|
-
});
|
|
239
|
-
clientSocket.on("error", (error) => {
|
|
240
|
-
const errorMessage = error.message || "";
|
|
241
|
-
if (!errorMessage.includes("ECONNRESET") && !errorMessage.includes("EPIPE") && !isConnected) console.error("Client socket error:", error);
|
|
242
|
-
if (!childSocket.destroyed) childSocket.destroy();
|
|
243
|
-
});
|
|
244
|
-
childSocket.on("connect", () => {
|
|
245
|
-
isConnected = true;
|
|
246
|
-
const httpRequest = `${`${req.method} ${req.url} HTTP/${req.httpVersion}\r\n`}${Object.entries(req.headers).map(([key, value]) => {
|
|
247
|
-
if (Array.isArray(value)) return value.map((v) => `${key}: ${v}`).join("\r\n");
|
|
248
|
-
return `${key}: ${value}`;
|
|
249
|
-
}).join("\r\n")}\r\n\r\n`;
|
|
250
|
-
childSocket.write(httpRequest);
|
|
251
|
-
if (head && head.length > 0) childSocket.write(head);
|
|
252
|
-
clientSocket.pipe(childSocket);
|
|
253
|
-
childSocket.pipe(clientSocket);
|
|
254
|
-
});
|
|
255
|
-
const cleanup = () => {
|
|
256
|
-
if (!clientSocket.destroyed) clientSocket.destroy();
|
|
257
|
-
if (!childSocket.destroyed) childSocket.destroy();
|
|
258
|
-
};
|
|
259
|
-
clientSocket.on("close", cleanup);
|
|
260
|
-
childSocket.on("close", cleanup);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region ../nuxi/src/commands/dev.ts
|
|
265
|
-
const startTime = Date.now();
|
|
266
|
-
const forkSupported = !isTest && (!isBun || isBunForkSupported());
|
|
267
|
-
const listhenArgs = getArgs();
|
|
268
|
-
const command = defineCommand({
|
|
269
|
-
meta: {
|
|
270
|
-
name: "dev",
|
|
271
|
-
description: "Run Nuxt development server"
|
|
272
|
-
},
|
|
273
|
-
args: {
|
|
274
|
-
...cwdArgs,
|
|
275
|
-
...logLevelArgs,
|
|
276
|
-
...dotEnvArgs,
|
|
277
|
-
...legacyRootDirArgs,
|
|
278
|
-
...envNameArgs,
|
|
279
|
-
...extendsArgs,
|
|
280
|
-
clear: {
|
|
281
|
-
type: "boolean",
|
|
282
|
-
description: "Clear console on restart",
|
|
283
|
-
default: false
|
|
284
|
-
},
|
|
285
|
-
fork: {
|
|
286
|
-
type: "boolean",
|
|
287
|
-
description: forkSupported ? "Disable forked mode" : "Enable forked mode",
|
|
288
|
-
negativeDescription: "Disable forked mode",
|
|
289
|
-
default: forkSupported,
|
|
290
|
-
alias: ["f"]
|
|
291
|
-
},
|
|
292
|
-
...listhenArgs,
|
|
293
|
-
"port": {
|
|
294
|
-
...listhenArgs.port,
|
|
295
|
-
description: "Port to listen on (default: `NUXT_PORT || NITRO_PORT || PORT || nuxtOptions.devServer.port`)",
|
|
296
|
-
alias: ["p"]
|
|
297
|
-
},
|
|
298
|
-
"open": {
|
|
299
|
-
...listhenArgs.open,
|
|
300
|
-
alias: ["o"],
|
|
301
|
-
default: false
|
|
302
|
-
},
|
|
303
|
-
"host": {
|
|
304
|
-
...listhenArgs.host,
|
|
305
|
-
alias: ["h"],
|
|
306
|
-
description: "Host to listen on (default: `NUXT_HOST || NITRO_HOST || HOST || nuxtOptions.devServer?.host`)"
|
|
307
|
-
},
|
|
308
|
-
"clipboard": {
|
|
309
|
-
...listhenArgs.clipboard,
|
|
310
|
-
default: false
|
|
311
|
-
},
|
|
312
|
-
"https.domains": {
|
|
313
|
-
...listhenArgs["https.domains"],
|
|
314
|
-
description: "Comma separated list of domains and IPs, the autogenerated certificate should be valid for (https: true)"
|
|
315
|
-
},
|
|
316
|
-
sslCert: {
|
|
317
|
-
type: "string",
|
|
318
|
-
description: "(DEPRECATED) Use `--https.cert` instead."
|
|
319
|
-
},
|
|
320
|
-
sslKey: {
|
|
321
|
-
type: "string",
|
|
322
|
-
description: "(DEPRECATED) Use `--https.key` instead."
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
async run(ctx) {
|
|
326
|
-
overrideEnv("development");
|
|
327
|
-
const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
|
|
328
|
-
const { loadNuxtConfig } = await loadKit(cwd);
|
|
329
|
-
const nuxtOptions = await loadNuxtConfig({
|
|
330
|
-
cwd,
|
|
331
|
-
dotenv: {
|
|
332
|
-
cwd,
|
|
333
|
-
fileName: ctx.args.dotenv
|
|
334
|
-
},
|
|
335
|
-
envName: ctx.args.envName,
|
|
336
|
-
overrides: {
|
|
337
|
-
dev: true,
|
|
338
|
-
logLevel: ctx.args.logLevel,
|
|
339
|
-
...ctx.args.extends && { extends: ctx.args.extends },
|
|
340
|
-
...ctx.data?.overrides
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
showVersionsFromConfig(cwd, nuxtOptions);
|
|
344
|
-
const listenOptions = resolveListenOptions(nuxtOptions, ctx.args);
|
|
345
|
-
if (!ctx.args.fork) {
|
|
346
|
-
const { listener, close: close$1 } = await initialize({
|
|
347
|
-
cwd,
|
|
348
|
-
args: ctx.args,
|
|
349
|
-
hostname: listenOptions.hostname,
|
|
350
|
-
public: listenOptions.public,
|
|
351
|
-
publicURLs: void 0,
|
|
352
|
-
proxy: { https: listenOptions.https }
|
|
353
|
-
}, { data: ctx.data }, listenOptions);
|
|
354
|
-
return {
|
|
355
|
-
listener,
|
|
356
|
-
async close() {
|
|
357
|
-
await close$1();
|
|
358
|
-
await listener.close();
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
const devHandler = await createDevHandler(cwd, nuxtOptions, listenOptions);
|
|
363
|
-
const useSocket = (process.env.NUXT_SOCKET ? process.env.NUXT_SOCKET === "1" : void 0) ?? (nuxtOptions._majorVersion === 4 && await isSocketSupported());
|
|
364
|
-
const urls = await devHandler.listener.getURLs();
|
|
365
|
-
const { onRestart, onReady, close } = await initialize({
|
|
366
|
-
cwd,
|
|
367
|
-
args: ctx.args,
|
|
368
|
-
hostname: listenOptions.hostname,
|
|
369
|
-
public: listenOptions.public,
|
|
370
|
-
publicURLs: urls.map((r) => r.url),
|
|
371
|
-
proxy: {
|
|
372
|
-
url: devHandler.listener.url,
|
|
373
|
-
urls,
|
|
374
|
-
https: devHandler.listener.https,
|
|
375
|
-
addr: devHandler.listener.address
|
|
376
|
-
}
|
|
377
|
-
}, {}, useSocket ? void 0 : true);
|
|
378
|
-
onReady((address) => devHandler.setAddress(address));
|
|
379
|
-
const fork$1 = startSubprocess(cwd, ctx.args, ctx.rawArgs, listenOptions);
|
|
380
|
-
onRestart(async (devServer) => {
|
|
381
|
-
const [subprocess] = await Promise.all([fork$1, devServer.close().catch(() => {})]);
|
|
382
|
-
await subprocess.initialize(devHandler, useSocket);
|
|
383
|
-
});
|
|
384
|
-
return {
|
|
385
|
-
listener: devHandler.listener,
|
|
386
|
-
async close() {
|
|
387
|
-
await close();
|
|
388
|
-
(await fork$1).kill(0);
|
|
389
|
-
await devHandler.listener.close();
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
var dev_default = command;
|
|
395
|
-
async function createDevHandler(cwd, nuxtOptions, listenOptions) {
|
|
396
|
-
let loadingMessage = "Nuxt dev server is starting...";
|
|
397
|
-
let error;
|
|
398
|
-
let address;
|
|
399
|
-
let loadingTemplate = nuxtOptions.devServer.loadingTemplate;
|
|
400
|
-
const listener = await listen(createFetchHandler(() => {
|
|
401
|
-
if (!address) return;
|
|
402
|
-
if (isSocketURL(address)) {
|
|
403
|
-
const { socketPath } = parseSocketURL(address);
|
|
404
|
-
return { socketPath };
|
|
405
|
-
}
|
|
406
|
-
try {
|
|
407
|
-
const url = new URL(address);
|
|
408
|
-
return {
|
|
409
|
-
host: url.hostname,
|
|
410
|
-
port: Number.parseInt(url.port) || 80
|
|
411
|
-
};
|
|
412
|
-
} catch {
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
}, async (req, res) => {
|
|
416
|
-
renderError(req, res, error);
|
|
417
|
-
}, async (req, res) => {
|
|
418
|
-
if (res.headersSent) {
|
|
419
|
-
if (!res.writableEnded) res.end();
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
res.statusCode = 503;
|
|
423
|
-
res.setHeader("Content-Type", "text/html");
|
|
424
|
-
res.setHeader("Cache-Control", "no-store");
|
|
425
|
-
if (loadingTemplate) {
|
|
426
|
-
res.end(loadingTemplate({ loading: loadingMessage }));
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
async function resolveLoadingMessage() {
|
|
430
|
-
loadingTemplate = await resolveLoadingTemplate(cwd);
|
|
431
|
-
res.end(loadingTemplate({ loading: loadingMessage }));
|
|
432
|
-
}
|
|
433
|
-
return resolveLoadingMessage();
|
|
434
|
-
}), listenOptions);
|
|
435
|
-
listener.server.on("upgrade", (req, socket, head) => {
|
|
436
|
-
if (!address) {
|
|
437
|
-
if (!socket.destroyed) socket.end();
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
if (isSocketURL(address)) {
|
|
441
|
-
const { socketPath } = parseSocketURL(address);
|
|
442
|
-
connectToChildSocket(socketPath, req, socket, head);
|
|
443
|
-
} else try {
|
|
444
|
-
const url = new URL(address);
|
|
445
|
-
const host = url.hostname;
|
|
446
|
-
connectToChildNetwork(host, Number.parseInt(url.port) || 80, req, socket, head);
|
|
447
|
-
} catch {
|
|
448
|
-
if (!socket.destroyed) socket.end();
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
return {
|
|
452
|
-
listener,
|
|
453
|
-
setAddress: (_addr) => {
|
|
454
|
-
address = _addr;
|
|
455
|
-
},
|
|
456
|
-
setLoadingMessage: (_msg) => {
|
|
457
|
-
loadingMessage = _msg;
|
|
458
|
-
},
|
|
459
|
-
setError: (_error) => {
|
|
460
|
-
error = _error;
|
|
461
|
-
},
|
|
462
|
-
clearError() {
|
|
463
|
-
error = void 0;
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
async function startSubprocess(cwd, args, rawArgs, listenOptions) {
|
|
468
|
-
let childProc;
|
|
469
|
-
let devHandler;
|
|
470
|
-
let ready;
|
|
471
|
-
const kill = (signal) => {
|
|
472
|
-
if (childProc) {
|
|
473
|
-
childProc.kill(signal === 0 && isDeno ? "SIGTERM" : signal);
|
|
474
|
-
childProc = void 0;
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
async function initialize$1(handler, socket) {
|
|
478
|
-
devHandler = handler;
|
|
479
|
-
const urls = await devHandler.listener.getURLs();
|
|
480
|
-
await ready;
|
|
481
|
-
childProc.send({
|
|
482
|
-
type: "nuxt:internal:dev:context",
|
|
483
|
-
socket,
|
|
484
|
-
context: {
|
|
485
|
-
cwd,
|
|
486
|
-
args,
|
|
487
|
-
hostname: listenOptions.hostname,
|
|
488
|
-
public: listenOptions.public,
|
|
489
|
-
publicURLs: urls.map((r) => r.url),
|
|
490
|
-
proxy: {
|
|
491
|
-
url: devHandler.listener.url,
|
|
492
|
-
urls,
|
|
493
|
-
https: devHandler.listener.https
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
async function restart() {
|
|
499
|
-
devHandler?.clearError();
|
|
500
|
-
if (!globalThis.__nuxt_cli__) return;
|
|
501
|
-
if (process.platform === "win32") kill("SIGTERM");
|
|
502
|
-
else kill("SIGHUP");
|
|
503
|
-
childProc = fork(globalThis.__nuxt_cli__.devEntry, rawArgs, {
|
|
504
|
-
execArgv: ["--enable-source-maps", process.argv.find((a) => a.includes("--inspect"))].filter(Boolean),
|
|
505
|
-
env: {
|
|
506
|
-
...process.env,
|
|
507
|
-
__NUXT__FORK: "true"
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
childProc.on("close", (errorCode) => {
|
|
511
|
-
if (errorCode) process.exit(errorCode);
|
|
512
|
-
});
|
|
513
|
-
ready = new Promise((resolve$1, reject) => {
|
|
514
|
-
childProc.on("error", reject);
|
|
515
|
-
childProc.on("message", (message) => {
|
|
516
|
-
if (message.type === "nuxt:internal:dev:fork-ready") resolve$1();
|
|
517
|
-
else if (message.type === "nuxt:internal:dev:ready") {
|
|
518
|
-
devHandler.setAddress(message.address);
|
|
519
|
-
if (startTime) logger.debug(`Dev server ready for connections in ${Date.now() - startTime}ms`);
|
|
520
|
-
} else if (message.type === "nuxt:internal:dev:loading") {
|
|
521
|
-
devHandler.setAddress(void 0);
|
|
522
|
-
devHandler.setLoadingMessage(message.message);
|
|
523
|
-
devHandler.clearError();
|
|
524
|
-
} else if (message.type === "nuxt:internal:dev:loading:error") {
|
|
525
|
-
devHandler.setAddress(void 0);
|
|
526
|
-
devHandler.setError(message.error);
|
|
527
|
-
} else if (message.type === "nuxt:internal:dev:restart") restart();
|
|
528
|
-
else if (message.type === "nuxt:internal:dev:rejection") {
|
|
529
|
-
logger.info(`Restarting Nuxt due to error: \`${message.message}\``);
|
|
530
|
-
restart();
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
for (const signal of [
|
|
536
|
-
"exit",
|
|
537
|
-
"SIGTERM",
|
|
538
|
-
"SIGINT",
|
|
539
|
-
"SIGQUIT"
|
|
540
|
-
]) process.once(signal, () => {
|
|
541
|
-
kill(signal === "exit" ? 0 : signal);
|
|
542
|
-
});
|
|
543
|
-
await restart();
|
|
544
|
-
return {
|
|
545
|
-
initialize: initialize$1,
|
|
546
|
-
restart,
|
|
547
|
-
kill
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
function resolveListenOptions(nuxtOptions, args) {
|
|
551
|
-
const _port = args.port ?? args.p ?? process.env.NUXT_PORT ?? process.env.NITRO_PORT ?? process.env.PORT ?? nuxtOptions.devServer.port;
|
|
552
|
-
const _hostname = typeof args.host === "string" ? args.host : args.host === true ? "" : process.env.NUXT_HOST ?? process.env.NITRO_HOST ?? process.env.HOST ?? (nuxtOptions.devServer?.host || void 0) ?? void 0;
|
|
553
|
-
const _public = args.public ?? (_hostname && ![
|
|
554
|
-
"localhost",
|
|
555
|
-
"127.0.0.1",
|
|
556
|
-
"::1"
|
|
557
|
-
].includes(_hostname)) ? true : void 0;
|
|
558
|
-
const _httpsCert = args["https.cert"] || args.sslCert || process.env.NUXT_SSL_CERT || process.env.NITRO_SSL_CERT || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "cert" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.cert || "";
|
|
559
|
-
const _httpsKey = args["https.key"] || args.sslKey || process.env.NUXT_SSL_KEY || process.env.NITRO_SSL_KEY || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "key" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.key || "";
|
|
560
|
-
const _httpsPfx = args["https.pfx"] || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "pfx" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.pfx || "";
|
|
561
|
-
const _httpsPassphrase = args["https.passphrase"] || typeof nuxtOptions.devServer.https !== "boolean" && nuxtOptions.devServer.https && "passphrase" in nuxtOptions.devServer.https && nuxtOptions.devServer.https.passphrase || "";
|
|
562
|
-
const httpsEnabled = !!(args.https ?? nuxtOptions.devServer.https);
|
|
563
|
-
const _listhenOptions = parseArgs({
|
|
564
|
-
...args,
|
|
565
|
-
"open": args.o || args.open,
|
|
566
|
-
"https": httpsEnabled,
|
|
567
|
-
"https.cert": _httpsCert,
|
|
568
|
-
"https.key": _httpsKey,
|
|
569
|
-
"https.pfx": _httpsPfx,
|
|
570
|
-
"https.passphrase": _httpsPassphrase
|
|
571
|
-
});
|
|
572
|
-
const httpsOptions = httpsEnabled && {
|
|
573
|
-
...nuxtOptions.devServer.https,
|
|
574
|
-
..._listhenOptions.https
|
|
575
|
-
};
|
|
576
|
-
return {
|
|
577
|
-
..._listhenOptions,
|
|
578
|
-
port: _port,
|
|
579
|
-
hostname: _hostname,
|
|
580
|
-
public: _public,
|
|
581
|
-
https: httpsOptions,
|
|
582
|
-
baseURL: nuxtOptions.app.baseURL.startsWith("./") ? nuxtOptions.app.baseURL.slice(1) : nuxtOptions.app.baseURL
|
|
583
|
-
};
|
|
584
|
-
}
|
|
585
|
-
function isBunForkSupported() {
|
|
586
|
-
const bunVersion = globalThis.Bun.version;
|
|
587
|
-
return satisfies(bunVersion, ">=1.2");
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
//#endregion
|
|
591
|
-
export { dev_default as default };
|