@nuxt/cli-nightly 3.29.4-20251009-171833-0915ec9 → 3.29.4-20251021-190716-bbf70fc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/_shared-C3vB2YLc.mjs +42 -0
  2. package/dist/_utils-DTrPahho.mjs +29 -0
  3. package/dist/add-BGMHIn5L.mjs +333 -0
  4. package/dist/add-CRBwIlDF.mjs +298 -0
  5. package/dist/add-hFFIzkcy.mjs +10 -0
  6. package/dist/analyze-CUKAi_IN.mjs +115 -0
  7. package/dist/banner-CqfM_0Qo.mjs +55 -0
  8. package/dist/build-BSxJLNs_.mjs +78 -0
  9. package/dist/build-KNIBU0AI.mjs +9 -0
  10. package/dist/cleanup-8GRakeLu.mjs +31 -0
  11. package/dist/dev/index.d.mts +87 -83
  12. package/dist/dev/index.mjs +7 -23
  13. package/dist/dev-Bs_0dzlh.mjs +591 -0
  14. package/dist/dev-CnQwDUaD.mjs +7 -0
  15. package/dist/dev-L7lhoThJ.mjs +438 -0
  16. package/dist/dev-child-CSiX6Uyv.mjs +37 -0
  17. package/dist/devtools-BLGzUSNU.mjs +44 -0
  18. package/dist/env-Dz4K_NkM.mjs +12 -0
  19. package/dist/fs-ewAp6tjM.mjs +40 -0
  20. package/dist/generate-CGy3-x2K.mjs +35 -0
  21. package/dist/index.d.mts +9 -18
  22. package/dist/index.mjs +129 -8
  23. package/dist/info-BDdsghj1.mjs +120 -0
  24. package/dist/init-_n9DXzzY.mjs +336 -0
  25. package/dist/kit-xFxVGu6d.mjs +37 -0
  26. package/dist/logger-Dk0gkCkX.mjs +7 -0
  27. package/dist/module-CqBrGD-s.mjs +17 -0
  28. package/dist/nuxt-Cc9ZTk7m.mjs +44 -0
  29. package/dist/packageManagers-DbVB5cXf.mjs +9 -0
  30. package/dist/prepare-B0KOhO-L.mjs +7 -0
  31. package/dist/prepare-xI978yFg.mjs +49 -0
  32. package/dist/preview-C5fNqrC6.mjs +109 -0
  33. package/dist/search-DCyXfxzn.mjs +113 -0
  34. package/dist/test-CBt1emEB.mjs +55 -0
  35. package/dist/typecheck-DCWe7Iej.mjs +102 -0
  36. package/dist/upgrade-BMSFcUWJ.mjs +184 -0
  37. package/dist/versions-CSy_3o_-.mjs +18 -0
  38. package/package.json +13 -13
  39. package/dist/chunks/add.mjs +0 -381
  40. package/dist/chunks/add2.mjs +0 -319
  41. package/dist/chunks/analyze.mjs +0 -139
  42. package/dist/chunks/build.mjs +0 -94
  43. package/dist/chunks/cleanup.mjs +0 -34
  44. package/dist/chunks/dev-child.mjs +0 -38
  45. package/dist/chunks/dev.mjs +0 -709
  46. package/dist/chunks/devtools.mjs +0 -46
  47. package/dist/chunks/generate.mjs +0 -45
  48. package/dist/chunks/index.mjs +0 -507
  49. package/dist/chunks/index2.mjs +0 -15
  50. package/dist/chunks/info.mjs +0 -150
  51. package/dist/chunks/init.mjs +0 -413
  52. package/dist/chunks/prepare.mjs +0 -57
  53. package/dist/chunks/preview.mjs +0 -131
  54. package/dist/chunks/search.mjs +0 -114
  55. package/dist/chunks/test.mjs +0 -62
  56. package/dist/chunks/typecheck.mjs +0 -85
  57. package/dist/chunks/upgrade.mjs +0 -214
  58. package/dist/dev/index.d.ts +0 -94
  59. package/dist/index.d.ts +0 -23
  60. package/dist/shared/cli-nightly.B9AmABr3.mjs +0 -5
  61. package/dist/shared/cli-nightly.BRlCc6aT.mjs +0 -204
  62. package/dist/shared/cli-nightly.BSm0_9Hr.mjs +0 -7
  63. package/dist/shared/cli-nightly.Bu_9IHj2.mjs +0 -51
  64. package/dist/shared/cli-nightly.Cr-OCgdO.mjs +0 -37
  65. package/dist/shared/cli-nightly.DHenkA1C.mjs +0 -14
  66. package/dist/shared/cli-nightly.DPmMxQ6h.mjs +0 -33
  67. package/dist/shared/cli-nightly.DS8guhZv.mjs +0 -52
  68. package/dist/shared/cli-nightly.DkO5RR_e.mjs +0 -14
  69. package/dist/shared/cli-nightly.qKvs7FJ2.mjs +0 -36
@@ -0,0 +1,591 @@
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-L7lhoThJ.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-CqfM_0Qo.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 { fork } from "node:child_process";
17
+ import { getArgs, parseArgs } from "listhen/cli";
18
+ import { satisfies } from "semver";
19
+ import { Readable } from "node:stream";
20
+ import { pipeline } from "node:stream/promises";
21
+ import { NodeRequest } from "srvx/node";
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 };
@@ -0,0 +1,7 @@
1
+ import "./logger-Dk0gkCkX.mjs";
2
+ import { t as initialize } from "./dev-L7lhoThJ.mjs";
3
+ import "./fs-ewAp6tjM.mjs";
4
+ import "./kit-xFxVGu6d.mjs";
5
+ import "./nuxt-Cc9ZTk7m.mjs";
6
+
7
+ export { initialize };