@nuxt/cli-nightly 3.30.0-20251028-094234-3afd02b → 3.30.0-20251030-113745-b8ea409

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 (35) hide show
  1. package/dist/{add-BGMHIn5L.mjs → add-CHVmfYrF.mjs} +1 -1
  2. package/dist/{add-CHYEpn7Y.mjs → add-DAUI-5jB.mjs} +1 -1
  3. package/dist/add-UF9L_ur5.mjs +10 -0
  4. package/dist/{analyze-Coe2kTBZ.mjs → analyze-B7ie7_6H.mjs} +3 -3
  5. package/dist/{banner-95R8hV4o.mjs → banner-CWBLwDiB.mjs} +1 -1
  6. package/dist/build-BEXmJONc.mjs +9 -0
  7. package/dist/{build-DkB8uZtZ.mjs → build-CVr-ruAe.mjs} +4 -4
  8. package/dist/{cleanup-8GRakeLu.mjs → cleanup-X4v95Xqm.mjs} +3 -3
  9. package/dist/dev/index.d.mts +10 -39
  10. package/dist/dev/index.mjs +5 -4
  11. package/dist/{dev-DsH3xiyp.mjs → dev-BYEMtZLe.mjs} +157 -161
  12. package/dist/dev-CD5a8ssT.mjs +8 -0
  13. package/dist/{dev-child-CJxOnht6.mjs → dev-child-Dcs4VQnN.mjs} +1 -1
  14. package/dist/dev-nr2jb3A5.mjs +278 -0
  15. package/dist/{generate-B328yidV.mjs → generate-DZJF1Xf_.mjs} +5 -5
  16. package/dist/index.mjs +16 -16
  17. package/dist/{info-B_wlb5Fu.mjs → info-CAy5OGO8.mjs} +2 -2
  18. package/dist/{init-CvLYtdn1.mjs → init-DxB4kjq8.mjs} +4 -4
  19. package/dist/{module-BUBa48Be.mjs → module-gIxjhGid.mjs} +2 -2
  20. package/dist/{nuxt-Cc9ZTk7m.mjs → nuxt-CfBR40hD.mjs} +1 -1
  21. package/dist/{prepare-xI978yFg.mjs → prepare-DjR-jyiQ.mjs} +2 -2
  22. package/dist/prepare-ZByeo9vQ.mjs +7 -0
  23. package/dist/{preview-BEqrL1ey.mjs → preview-CgpLKg-X.mjs} +1 -1
  24. package/dist/{search-DCyXfxzn.mjs → search-D_JLXbhF.mjs} +1 -1
  25. package/dist/{typecheck-DCWe7Iej.mjs → typecheck-egvrxpjV.mjs} +1 -1
  26. package/dist/{upgrade-BMSFcUWJ.mjs → upgrade-Bsj6DJXO.mjs} +3 -3
  27. package/package.json +2 -3
  28. package/dist/add-qJhPcmZB.mjs +0 -10
  29. package/dist/build-BebJ09xA.mjs +0 -9
  30. package/dist/dev-Bv3ZMKhd.mjs +0 -7
  31. package/dist/dev-lAMCAq4V.mjs +0 -344
  32. package/dist/prepare-B0KOhO-L.mjs +0 -7
  33. /package/dist/{env-Dz4K_NkM.mjs → env-CamzysGq.mjs} +0 -0
  34. /package/dist/{fs-ewAp6tjM.mjs → fs--ofMleGo.mjs} +0 -0
  35. /package/dist/{kit-xFxVGu6d.mjs → kit-f7zsnm10.mjs} +0 -0
@@ -1,74 +1,22 @@
1
- import { t as clearBuildDir } from "./fs-ewAp6tjM.mjs";
2
- import { t as loadKit } from "./kit-xFxVGu6d.mjs";
3
- import { a as writeNuxtManifest, i as resolveNuxtManifest, n as loadNuxtManifest } from "./nuxt-Cc9ZTk7m.mjs";
1
+ import { t as loadKit } from "./kit-f7zsnm10.mjs";
2
+ import { n as showVersionsFromConfig } from "./banner-CWBLwDiB.mjs";
3
+ import { t as clearBuildDir } from "./fs--ofMleGo.mjs";
4
+ import { a as writeNuxtManifest, i as resolveNuxtManifest, n as loadNuxtManifest } from "./nuxt-CfBR40hD.mjs";
4
5
  import process from "node:process";
5
6
  import { provider } from "std-env";
6
7
  import { pathToFileURL } from "node:url";
7
8
  import defu, { defu as defu$1 } from "defu";
8
- import { listen } from "listhen";
9
- import { Server } from "node:http";
10
- import { cleanSocket, getSocketAddress } from "get-port-please";
11
9
  import EventEmitter from "node:events";
12
10
  import { existsSync, statSync, watch } from "node:fs";
13
11
  import { mkdir } from "node:fs/promises";
14
12
  import { resolveModulePath } from "exsolve";
15
13
  import { joinURL } from "ufo";
14
+ import { listen } from "listhen";
16
15
  import { resolve } from "pathe";
17
16
  import { debounce } from "perfect-debounce";
18
17
  import { toNodeHandler } from "srvx/node";
19
18
  import { Youch } from "youch";
20
19
 
21
- //#region ../nuxi/src/dev/socket.ts
22
- function formatSocketURL(socketPath, ssl = false) {
23
- return `${ssl ? "https" : "http"}+unix://${process.platform === "win32" ? encodeURIComponent(socketPath) : socketPath.replace(/\//g, "%2F")}`;
24
- }
25
- function isSocketURL(url) {
26
- return url.startsWith("http+unix://") || url.startsWith("https+unix://");
27
- }
28
- function parseSocketURL(url) {
29
- if (!isSocketURL(url)) throw new Error(`Invalid socket URL: ${url}`);
30
- const ssl = url.startsWith("https+unix://");
31
- const path = url.slice(ssl ? 13 : 12);
32
- return {
33
- socketPath: decodeURIComponent(path.replace(/%2F/g, "/")),
34
- protocol: ssl ? "https" : "http"
35
- };
36
- }
37
- async function createSocketListener(handler, proxyAddress) {
38
- const socketPath = getSocketAddress({
39
- name: "nuxt-dev",
40
- random: true
41
- });
42
- const server = new Server(handler);
43
- await cleanSocket(socketPath);
44
- await new Promise((resolve$1) => server.listen({ path: socketPath }, resolve$1));
45
- const url = formatSocketURL(socketPath);
46
- return {
47
- url,
48
- address: {
49
- address: "localhost",
50
- port: 3e3,
51
- ...proxyAddress,
52
- socketPath
53
- },
54
- async close() {
55
- try {
56
- server.removeAllListeners();
57
- await new Promise((resolve$1, reject) => server.close((err) => err ? reject(err) : resolve$1()));
58
- } finally {
59
- await cleanSocket(socketPath);
60
- }
61
- },
62
- getURLs: async () => [{
63
- url,
64
- type: "network"
65
- }],
66
- https: false,
67
- server
68
- };
69
- }
70
-
71
- //#endregion
72
20
  //#region ../../node_modules/.pnpm/h3@1.15.4/node_modules/h3/dist/index.mjs
73
21
  function hasProp(obj, prop) {
74
22
  try {
@@ -337,6 +285,8 @@ async function renderError(req, res, error) {
337
285
  const youch = new Youch();
338
286
  res.statusCode = 500;
339
287
  res.setHeader("Content-Type", "text/html");
288
+ res.setHeader("Cache-Control", "no-store");
289
+ res.setHeader("Refresh", "3");
340
290
  const html = await youch.toHTML(error, { request: {
341
291
  url: req.url,
342
292
  method: req.method,
@@ -363,14 +313,15 @@ var FileChangeTracker = class {
363
313
  }
364
314
  };
365
315
  var NuxtDevServer = class extends EventEmitter {
366
- _handler;
367
- _distWatcher;
368
- _configWatcher;
369
- _currentNuxt;
370
- _loadingMessage;
371
- _loadingError;
372
- _fileChangeTracker = new FileChangeTracker();
373
- cwd;
316
+ #handler;
317
+ #distWatcher;
318
+ #configWatcher;
319
+ #currentNuxt;
320
+ #loadingMessage;
321
+ #loadingError;
322
+ #fileChangeTracker = new FileChangeTracker();
323
+ #cwd;
324
+ #websocketConnections = /* @__PURE__ */ new Set();
374
325
  loadDebounced;
375
326
  handler;
376
327
  listener;
@@ -385,66 +336,58 @@ var NuxtDevServer = class extends EventEmitter {
385
336
  this.once("ready", () => {
386
337
  _initResolve();
387
338
  });
388
- this.cwd = options.cwd;
339
+ this.#cwd = options.cwd;
389
340
  this.handler = async (req, res) => {
390
- if (this._loadingError) {
391
- this._renderError(req, res);
341
+ if (this.#loadingError) {
342
+ renderError(req, res, this.#loadingError);
392
343
  return;
393
344
  }
394
345
  await _initPromise;
395
- if (this._handler) this._handler(req, res);
396
- else this._renderLoadingScreen(req, res);
346
+ if (this.#handler) this.#handler(req, res);
347
+ else this.#renderLoadingScreen(req, res);
397
348
  };
398
- this.listener = void 0;
399
349
  }
400
- _renderError(req, res) {
401
- renderError(req, res, this._loadingError);
402
- }
403
- async _renderLoadingScreen(req, res) {
350
+ async #renderLoadingScreen(req, res) {
404
351
  if (res.headersSent) {
405
352
  if (!res.writableEnded) res.end();
406
353
  return;
407
354
  }
408
355
  res.statusCode = 503;
409
356
  res.setHeader("Content-Type", "text/html");
410
- const loadingTemplate = this.options.loadingTemplate || this._currentNuxt?.options.devServer.loadingTemplate || await resolveLoadingTemplate(this.cwd);
411
- res.end(loadingTemplate({ loading: this._loadingMessage || "Loading..." }));
357
+ const loadingTemplate = this.options.loadingTemplate || this.#currentNuxt?.options.devServer.loadingTemplate || await resolveLoadingTemplate(this.#cwd);
358
+ res.end(loadingTemplate({ loading: this.#loadingMessage || "Loading..." }));
412
359
  }
413
360
  async init() {
414
- await this.load();
415
- this._watchConfig();
361
+ this.#loadingMessage = `Starting Nuxt...`;
362
+ this.#handler = void 0;
363
+ this.emit("loading", this.#loadingMessage);
364
+ await this.#loadNuxtInstance();
365
+ if (this.options.showBanner) showVersionsFromConfig(this.options.cwd, this.#currentNuxt.options);
366
+ await this.#createListener();
367
+ await this.#initializeNuxt(false);
368
+ this.#watchConfig();
416
369
  }
417
370
  closeWatchers() {
418
- this._distWatcher?.close();
419
- this._configWatcher?.();
371
+ this.#distWatcher?.close();
372
+ this.#configWatcher?.();
420
373
  }
421
374
  async load(reload, reason) {
422
375
  try {
423
376
  this.closeWatchers();
424
- await this._load(reload, reason);
425
- this._watchConfig();
426
- this._loadingError = void 0;
377
+ await this.#load(reload, reason);
378
+ this.#loadingError = void 0;
427
379
  } catch (error) {
428
380
  console.error(`Cannot ${reload ? "restart" : "start"} nuxt: `, error);
429
- this._handler = void 0;
430
- this._loadingError = error;
431
- this._loadingMessage = "Error while loading Nuxt. Please check console and fix errors.";
381
+ this.#handler = void 0;
382
+ this.#loadingError = error;
383
+ this.#loadingMessage = "Error while loading Nuxt. Please check console and fix errors.";
432
384
  this.emit("loading:error", error);
433
385
  }
386
+ this.#watchConfig();
434
387
  }
435
- async close() {
436
- if (this._currentNuxt) await this._currentNuxt.close();
437
- }
438
- async _load(reload, reason) {
439
- const action = reload ? "Restarting" : "Starting";
440
- this._loadingMessage = `${reason ? `${reason}. ` : ""}${action} Nuxt...`;
441
- this._handler = void 0;
442
- this.emit("loading", this._loadingMessage);
443
- if (reload) console.info(this._loadingMessage);
444
- await this.close();
388
+ async #loadNuxtInstance(urls) {
445
389
  const kit = await loadKit(this.options.cwd);
446
- const devServerDefaults = resolveDevServerDefaults({}, await this.listener.getURLs().then((r) => r.map((r$1) => r$1.url)));
447
- this._currentNuxt = await kit.loadNuxt({
390
+ const loadOptions = {
448
391
  cwd: this.options.cwd,
449
392
  dev: true,
450
393
  ready: false,
@@ -453,7 +396,6 @@ var NuxtDevServer = class extends EventEmitter {
453
396
  cwd: this.options.cwd,
454
397
  fileName: this.options.dotenv.fileName
455
398
  },
456
- defaults: defu(this.options.defaults, devServerDefaults),
457
399
  overrides: {
458
400
  logLevel: this.options.logLevel,
459
401
  ...this.options.overrides,
@@ -462,8 +404,55 @@ var NuxtDevServer = class extends EventEmitter {
462
404
  ...this.options.overrides.vite
463
405
  }
464
406
  }
465
- });
466
- if (!process.env.NUXI_DISABLE_VITE_HMR) this._currentNuxt.hooks.hook("vite:extend", ({ config }) => {
407
+ };
408
+ if (urls) {
409
+ const overrides = this.options.listenOverrides || {};
410
+ const hostname = overrides.hostname ?? overrides.host;
411
+ const https = overrides.https;
412
+ loadOptions.defaults = resolveDevServerDefaults({
413
+ hostname,
414
+ https
415
+ }, urls);
416
+ }
417
+ this.#currentNuxt = await kit.loadNuxt(loadOptions);
418
+ }
419
+ async #createListener() {
420
+ if (!this.#currentNuxt) throw new Error("Nuxt must be loaded before creating listener");
421
+ const listenOptions = this.#resolveListenOptions();
422
+ this.listener = await listen(this.handler, listenOptions);
423
+ if (listenOptions.public) {
424
+ this.#currentNuxt.options.devServer.cors = { origin: "*" };
425
+ if (this.#currentNuxt.options.vite?.server) this.#currentNuxt.options.vite.server.allowedHosts = true;
426
+ return;
427
+ }
428
+ const urls = await this.listener.getURLs().then((r) => r.map((r$1) => r$1.url));
429
+ if (urls && urls.length > 0) this.#currentNuxt.options.vite = defu(this.#currentNuxt.options.vite, { server: { allowedHosts: urls.map((u) => new URL(u).hostname) } });
430
+ }
431
+ #resolveListenOptions() {
432
+ if (!this.#currentNuxt) throw new Error("Nuxt must be loaded before resolving listen options");
433
+ const nuxtConfig = this.#currentNuxt.options;
434
+ const overrides = this.options.listenOverrides || {};
435
+ const port = overrides.port ?? nuxtConfig.devServer?.port;
436
+ const hostname = overrides.hostname ?? overrides.host ?? nuxtConfig.devServer?.host;
437
+ const isPublic = provider === "codesandbox" || (overrides.public ?? (isPublicHostname(hostname) ? true : void 0));
438
+ const httpsFromConfig = typeof nuxtConfig.devServer?.https !== "boolean" && nuxtConfig.devServer?.https ? nuxtConfig.devServer.https : {};
439
+ const httpsOptions = !!(overrides.https ?? nuxtConfig.devServer?.https) && {
440
+ ...httpsFromConfig,
441
+ ...typeof overrides.https === "object" ? overrides.https : {}
442
+ };
443
+ const baseURL = nuxtConfig.app?.baseURL?.startsWith?.("./") ? nuxtConfig.app.baseURL.slice(1) : nuxtConfig.app?.baseURL;
444
+ return {
445
+ ...overrides,
446
+ port,
447
+ hostname,
448
+ public: isPublic,
449
+ https: httpsOptions || void 0,
450
+ baseURL
451
+ };
452
+ }
453
+ async #initializeNuxt(reload) {
454
+ if (!this.#currentNuxt) throw new Error("Nuxt must be loaded before configuration");
455
+ if (!process.env.NUXI_DISABLE_VITE_HMR) this.#currentNuxt.hooks.hook("vite:extend", ({ config }) => {
467
456
  if (config.server) config.server.hmr = {
468
457
  protocol: void 0,
469
458
  ...config.server.hmr,
@@ -472,20 +461,21 @@ var NuxtDevServer = class extends EventEmitter {
472
461
  server: this.listener.server
473
462
  };
474
463
  });
475
- this._currentNuxt.hooks.hookOnce("close", () => {
464
+ this.#currentNuxt.hooks.hookOnce("close", () => {
465
+ this.#closeWebSocketConnections();
476
466
  this.listener.server.removeAllListeners("upgrade");
477
467
  });
478
468
  if (!reload) {
479
- const previousManifest = await loadNuxtManifest(this._currentNuxt.options.buildDir);
480
- const newManifest = resolveNuxtManifest(this._currentNuxt);
481
- const promise = writeNuxtManifest(this._currentNuxt, newManifest);
482
- this._currentNuxt.hooks.hookOnce("ready", async () => {
469
+ const previousManifest = await loadNuxtManifest(this.#currentNuxt.options.buildDir);
470
+ const newManifest = resolveNuxtManifest(this.#currentNuxt);
471
+ const promise = writeNuxtManifest(this.#currentNuxt, newManifest);
472
+ this.#currentNuxt.hooks.hookOnce("ready", async () => {
483
473
  await promise;
484
474
  });
485
- if (previousManifest && newManifest && previousManifest._hash !== newManifest._hash) await clearBuildDir(this._currentNuxt.options.buildDir);
475
+ if (previousManifest && newManifest && previousManifest._hash !== newManifest._hash) await clearBuildDir(this.#currentNuxt.options.buildDir);
486
476
  }
487
- await this._currentNuxt.ready();
488
- const unsub = this._currentNuxt.hooks.hook("restart", async (options) => {
477
+ await this.#currentNuxt.ready();
478
+ const unsub = this.#currentNuxt.hooks.hook("restart", async (options) => {
489
479
  unsub();
490
480
  if (options?.hard) {
491
481
  this.emit("restart");
@@ -493,35 +483,59 @@ var NuxtDevServer = class extends EventEmitter {
493
483
  }
494
484
  await this.load(true);
495
485
  });
496
- if (this._currentNuxt.server && "upgrade" in this._currentNuxt.server) this.listener.server.on("upgrade", (req, socket, head) => {
497
- const nuxt = this._currentNuxt;
486
+ if (this.#currentNuxt.server && "upgrade" in this.#currentNuxt.server) this.listener.server.on("upgrade", (req, socket, head) => {
487
+ const nuxt = this.#currentNuxt;
498
488
  if (!nuxt || !nuxt.server) return;
499
489
  const viteHmrPath = joinURL(nuxt.options.app.baseURL.startsWith("./") ? nuxt.options.app.baseURL.slice(1) : nuxt.options.app.baseURL, nuxt.options.app.buildAssetsDir);
500
490
  if (req.url?.startsWith(viteHmrPath)) return;
501
491
  nuxt.server.upgrade(req, socket, head);
492
+ this.#websocketConnections.add(socket);
493
+ socket.on("close", () => {
494
+ this.#websocketConnections.delete(socket);
495
+ });
502
496
  });
503
- await this._currentNuxt.hooks.callHook("listen", this.listener.server, this.listener);
497
+ await this.#currentNuxt.hooks.callHook("listen", this.listener.server, this.listener);
504
498
  const addr = this.listener.address;
505
- this._currentNuxt.options.devServer.host = addr.address;
506
- this._currentNuxt.options.devServer.port = addr.port;
507
- this._currentNuxt.options.devServer.url = getAddressURL(addr, !!this.listener.https);
508
- this._currentNuxt.options.devServer.https = this.options.devContext.proxy?.https;
499
+ this.#currentNuxt.options.devServer.host = addr.address;
500
+ this.#currentNuxt.options.devServer.port = addr.port;
501
+ this.#currentNuxt.options.devServer.url = getAddressURL(addr, !!this.listener.https);
502
+ this.#currentNuxt.options.devServer.https = this.listener.https;
509
503
  if (this.listener.https && !process.env.NODE_TLS_REJECT_UNAUTHORIZED) console.warn("You might need `NODE_TLS_REJECT_UNAUTHORIZED=0` environment variable to make https work.");
510
- await Promise.all([kit.writeTypes(this._currentNuxt).catch(console.error), kit.buildNuxt(this._currentNuxt)]);
511
- if (!this._currentNuxt.server) throw new Error("Nitro server has not been initialized.");
512
- const distDir = resolve(this._currentNuxt.options.buildDir, "dist");
504
+ const kit = await loadKit(this.options.cwd);
505
+ await Promise.all([kit.writeTypes(this.#currentNuxt).catch(console.error), kit.buildNuxt(this.#currentNuxt)]);
506
+ if (!this.#currentNuxt.server) throw new Error("Nitro server has not been initialized.");
507
+ const distDir = resolve(this.#currentNuxt.options.buildDir, "dist");
513
508
  await mkdir(distDir, { recursive: true });
514
- this._distWatcher = watch(distDir);
515
- this._distWatcher.on("change", (_event, file) => {
516
- if (!this._fileChangeTracker.shouldEmitChange(resolve(distDir, file || ""))) return;
509
+ this.#distWatcher = watch(distDir);
510
+ this.#distWatcher.on("change", (_event, file) => {
511
+ if (!this.#fileChangeTracker.shouldEmitChange(resolve(distDir, file || ""))) return;
517
512
  this.loadDebounced(true, ".nuxt/dist directory has been removed");
518
513
  });
519
- if ("fetch" in this._currentNuxt.server) this._handler = toNodeHandler(this._currentNuxt.server.fetch);
520
- else this._handler = toNodeListener(this._currentNuxt.server.app);
521
- this.emit("ready", "socketPath" in addr ? formatSocketURL(addr.socketPath, !!this.listener.https) : `http://127.0.0.1:${addr.port}`);
514
+ if ("fetch" in this.#currentNuxt.server) this.#handler = toNodeHandler(this.#currentNuxt.server.fetch);
515
+ else this.#handler = toNodeListener(this.#currentNuxt.server.app);
516
+ const proto = this.listener.https ? "https" : "http";
517
+ this.emit("ready", `${proto}://127.0.0.1:${addr.port}`);
522
518
  }
523
- _watchConfig() {
524
- this._configWatcher = createConfigWatcher(this.cwd, this.options.dotenv.fileName, () => this.emit("restart"), (file) => this.loadDebounced(true, `${file} updated`));
519
+ async close() {
520
+ if (this.#currentNuxt) await this.#currentNuxt.close();
521
+ }
522
+ #closeWebSocketConnections() {
523
+ for (const socket of this.#websocketConnections) socket.destroy();
524
+ this.#websocketConnections.clear();
525
+ }
526
+ async #load(reload, reason) {
527
+ const action = reload ? "Restarting" : "Starting";
528
+ this.#loadingMessage = `${reason ? `${reason}. ` : ""}${action} Nuxt...`;
529
+ this.#handler = void 0;
530
+ this.emit("loading", this.#loadingMessage);
531
+ if (reload) console.info(this.#loadingMessage);
532
+ await this.close();
533
+ const urls = await this.listener.getURLs().then((r) => r.map((r$1) => r$1.url));
534
+ await this.#loadNuxtInstance(urls);
535
+ await this.#initializeNuxt(!!reload);
536
+ }
537
+ #watchConfig() {
538
+ this.#configWatcher = createConfigWatcher(this.#cwd, this.options.dotenv.fileName, () => this.emit("restart"), (file) => this.loadDebounced(true, `${file} updated`));
525
539
  }
526
540
  };
527
541
  function getAddressURL(addr, https) {
@@ -531,16 +545,9 @@ function getAddressURL(addr, https) {
531
545
  const port = addr.port || 3e3;
532
546
  return `${proto}://${host}:${port}/`;
533
547
  }
534
- function resolveDevServerOverrides(listenOptions) {
535
- if (listenOptions.public || provider === "codesandbox") return {
536
- devServer: { cors: { origin: "*" } },
537
- vite: { server: { allowedHosts: true } }
538
- };
539
- return {};
540
- }
541
548
  function resolveDevServerDefaults(listenOptions, urls = []) {
542
549
  const defaultConfig = {};
543
- if (urls) defaultConfig.vite = { server: { allowedHosts: urls.filter((u) => !isSocketURL(u)).map((u) => new URL(u).hostname) } };
550
+ if (urls && urls.length > 0) defaultConfig.vite = { server: { allowedHosts: urls.map((u) => new URL(u).hostname) } };
544
551
  if (listenOptions.hostname) {
545
552
  defaultConfig.devServer = { cors: { origin: [`${listenOptions.https ? "https" : "http"}://${listenOptions.hostname}`, ...urls] } };
546
553
  defaultConfig.vite = defu(defaultConfig.vite, { server: { allowedHosts: [listenOptions.hostname] } });
@@ -579,6 +586,13 @@ async function resolveLoadingTemplate(cwd) {
579
586
  try: true
580
587
  }) || cwd })).href)).loading || ((params) => `<h2>${params.loading}</h2>`);
581
588
  }
589
+ function isPublicHostname(hostname) {
590
+ return !!hostname && ![
591
+ "localhost",
592
+ "127.0.0.1",
593
+ "::1"
594
+ ].includes(hostname);
595
+ }
582
596
 
583
597
  //#endregion
584
598
  //#region ../nuxi/src/dev/index.ts
@@ -595,7 +609,7 @@ var IPC = class {
595
609
  process.exit();
596
610
  });
597
611
  process.on("message", (message) => {
598
- if (message.type === "nuxt:internal:dev:context") initialize(message.context, {}, message.socket ? void 0 : true);
612
+ if (message.type === "nuxt:internal:dev:context") initialize(message.context, { listenOverrides: message.listenOverrides });
599
613
  });
600
614
  this.send({ type: "nuxt:internal:dev:fork-ready" });
601
615
  }
@@ -604,16 +618,10 @@ var IPC = class {
604
618
  }
605
619
  };
606
620
  const ipc = new IPC();
607
- async function initialize(devContext, ctx = {}, _listenOptions) {
608
- const devServerOverrides = resolveDevServerOverrides({ public: devContext.public });
609
- const devServerDefaults = resolveDevServerDefaults({
610
- hostname: devContext.hostname,
611
- https: devContext.proxy?.https
612
- }, devContext.publicURLs);
621
+ async function initialize(devContext, ctx = {}) {
613
622
  const devServer = new NuxtDevServer({
614
623
  cwd: devContext.cwd,
615
- overrides: defu(ctx.data?.overrides, { extends: devContext.args.extends }, devServerOverrides),
616
- defaults: devServerDefaults,
624
+ overrides: defu(ctx.data?.overrides, { extends: devContext.args.extends }),
617
625
  logLevel: devContext.args.logLevel,
618
626
  clear: devContext.args.clear,
619
627
  dotenv: {
@@ -621,21 +629,9 @@ async function initialize(devContext, ctx = {}, _listenOptions) {
621
629
  fileName: devContext.args.dotenv
622
630
  },
623
631
  envName: devContext.args.envName,
624
- devContext: { proxy: devContext.proxy }
632
+ showBanner: ctx.showBanner !== false && !ipc.enabled,
633
+ listenOverrides: ctx.listenOverrides
625
634
  });
626
- const listenOptions = _listenOptions === true || process.env._PORT ? {
627
- port: process.env._PORT ?? 0,
628
- hostname: "127.0.0.1",
629
- showURL: false
630
- } : _listenOptions;
631
- devServer.listener = listenOptions ? await listen(devServer.handler, listenOptions) : await createSocketListener(devServer.handler, devContext.proxy?.addr);
632
- if (process.env.DEBUG) console.debug(`Using ${listenOptions ? "network" : "socket"} listener for Nuxt dev server.`);
633
- devServer.listener._url = devServer.listener.url;
634
- if (devContext.proxy?.url) devServer.listener.url = devContext.proxy.url;
635
- if (devContext.proxy?.urls) {
636
- const _getURLs = devServer.listener.getURLs.bind(devServer.listener);
637
- devServer.listener.getURLs = async () => Array.from(new Set([...devContext.proxy?.urls || [], ...await _getURLs()]));
638
- }
639
635
  let address;
640
636
  if (ipc.enabled) {
641
637
  devServer.on("loading:error", (_error) => {
@@ -673,7 +669,7 @@ async function initialize(devContext, ctx = {}, _listenOptions) {
673
669
  listener: devServer.listener,
674
670
  close: async () => {
675
671
  devServer.closeWatchers();
676
- await devServer.close();
672
+ await Promise.all([devServer.listener.close(), devServer.close()]);
677
673
  },
678
674
  onReady: (callback) => {
679
675
  if (address) callback(address);
@@ -695,4 +691,4 @@ async function initialize(devContext, ctx = {}, _listenOptions) {
695
691
  }
696
692
 
697
693
  //#endregion
698
- export { parseSocketURL as a, isSocketURL as i, resolveLoadingTemplate as n, renderError as r, initialize as t };
694
+ export { initialize as t };
@@ -0,0 +1,8 @@
1
+ import "./logger-Dk0gkCkX.mjs";
2
+ import { t as initialize } from "./dev-BYEMtZLe.mjs";
3
+ import "./kit-f7zsnm10.mjs";
4
+ import "./banner-CWBLwDiB.mjs";
5
+ import "./fs--ofMleGo.mjs";
6
+ import "./nuxt-CfBR40hD.mjs";
7
+
8
+ export { initialize };
@@ -25,7 +25,7 @@ var dev_child_default = defineCommand({
25
25
  async run(ctx) {
26
26
  if (!process.send && !isTest) console.warn("`nuxi _dev` is an internal command and should not be used directly. Please use `nuxi dev` instead.");
27
27
  const cwd = resolve(ctx.args.cwd || ctx.args.rootDir);
28
- const { initialize } = await import("./dev-Bv3ZMKhd.mjs");
28
+ const { initialize } = await import("./dev-CD5a8ssT.mjs");
29
29
  await initialize({
30
30
  cwd,
31
31
  args: ctx.args