@nuxt/nitro-server-nightly 4.3.0-29461891.8f4fbecd → 4.3.0-29465977.c4f46c64

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/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Nuxt } from '@nuxt/schema';
2
- import { Nitro } from 'nitropack/types';
3
- import { H3Event } from 'h3';
2
+ import { NitroConfig, Nitro, NitroEventHandler, NitroDevEventHandler, NitroRuntimeConfigApp, NitroRuntimeConfig, NitroOptions, NitroRouteConfig } from 'nitropack/types';
3
+ import { H3Event, EventHandler } from 'h3';
4
4
  import { LogObject } from 'consola';
5
5
  import { NuxtRenderHTMLContext, NuxtIslandResponse, NuxtIslandContext } from 'nuxt/app';
6
- import { RuntimeConfig } from 'nuxt/schema';
6
+ import { RuntimeConfig, HookResult, TSReference } from 'nuxt/schema';
7
7
 
8
8
  declare module 'nitropack' {
9
9
  interface NitroRuntimeConfigApp {
@@ -79,6 +79,104 @@ declare module 'nitropack/types' {
79
79
  }) => void | Promise<void>;
80
80
  }
81
81
  }
82
+ declare module '@nuxt/schema' {
83
+ interface NuxtHooks {
84
+ /**
85
+ * Called when the dev middleware is being registered on the Nitro dev server.
86
+ * @param handler the Vite or Webpack event handler
87
+ * @returns Promise
88
+ */
89
+ 'server:devHandler': (handler: EventHandler) => HookResult;
90
+ /**
91
+ * Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
92
+ * @param options Objects containing `references`, `declarations`
93
+ * @returns Promise
94
+ */
95
+ 'nitro:prepare:types': (options: {
96
+ references: TSReference[];
97
+ declarations: string[];
98
+ }) => HookResult;
99
+ /**
100
+ * Called before initializing Nitro, allowing customization of Nitro's configuration.
101
+ * @param nitroConfig The nitro config to be extended
102
+ * @returns Promise
103
+ */
104
+ 'nitro:config': (nitroConfig: NitroConfig) => HookResult;
105
+ /**
106
+ * Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
107
+ * @param nitro The created nitro object
108
+ * @returns Promise
109
+ */
110
+ 'nitro:init': (nitro: Nitro) => HookResult;
111
+ /**
112
+ * Called before building the Nitro instance.
113
+ * @param nitro The created nitro object
114
+ * @returns Promise
115
+ */
116
+ 'nitro:build:before': (nitro: Nitro) => HookResult;
117
+ /**
118
+ * Called after copying public assets. Allows modifying public assets before Nitro server is built.
119
+ * @param nitro The created nitro object
120
+ * @returns Promise
121
+ */
122
+ 'nitro:build:public-assets': (nitro: Nitro) => HookResult;
123
+ }
124
+ interface ConfigSchema {
125
+ /**
126
+ * Configuration for Nitro.
127
+ *
128
+ * @see [Nitro configuration docs](https://nitro.build/config)
129
+ */
130
+ nitro: NitroConfig;
131
+ /**
132
+ * Global route options applied to matching server routes.
133
+ *
134
+ * @experimental This is an experimental feature and API may change in the future.
135
+ *
136
+ * @see [Nitro route rules documentation](https://nitro.build/config#routerules)
137
+ */
138
+ routeRules: NitroConfig['routeRules'];
139
+ /**
140
+ * Nitro server handlers.
141
+ *
142
+ * Each handler accepts the following options:
143
+ * - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of [rou3](https://github.com/h3js/rou3). - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
144
+ *
145
+ * @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
146
+ *
147
+ * @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
148
+ *
149
+ * @example
150
+ * ```js
151
+ * serverHandlers: [
152
+ * { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
153
+ * ]
154
+ * ```
155
+ */
156
+ serverHandlers: NitroEventHandler[];
157
+ /**
158
+ * Nitro development-only server handlers.
159
+ *
160
+ * @see [Nitro server routes documentation](https://nitro.build/guide/routing)
161
+ */
162
+ devServerHandlers: NitroDevEventHandler[];
163
+ }
164
+ interface NuxtConfig {
165
+ nitro?: NitroConfig;
166
+ }
167
+ interface RuntimeConfig {
168
+ app: NitroRuntimeConfigApp;
169
+ /** Only available on the server. */
170
+ nitro?: NitroRuntimeConfig['nitro'];
171
+ }
172
+ interface NuxtDebugOptions {
173
+ /** Debug options for Nitro */
174
+ nitro?: NitroOptions['debug'];
175
+ }
176
+ interface NuxtPage {
177
+ rules?: NitroRouteConfig;
178
+ }
179
+ }
82
180
 
83
181
  declare function bundle(nuxt: Nuxt & {
84
182
  _nitro?: Nitro;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Nuxt } from '@nuxt/schema';
2
- import { Nitro } from 'nitropack/types';
3
- import { H3Event } from 'h3';
2
+ import { NitroConfig, Nitro, NitroEventHandler, NitroDevEventHandler, NitroRuntimeConfigApp, NitroRuntimeConfig, NitroOptions, NitroRouteConfig } from 'nitropack/types';
3
+ import { H3Event, EventHandler } from 'h3';
4
4
  import { LogObject } from 'consola';
5
5
  import { NuxtRenderHTMLContext, NuxtIslandResponse, NuxtIslandContext } from 'nuxt/app';
6
- import { RuntimeConfig } from 'nuxt/schema';
6
+ import { RuntimeConfig, HookResult, TSReference } from 'nuxt/schema';
7
7
 
8
8
  declare module 'nitropack' {
9
9
  interface NitroRuntimeConfigApp {
@@ -79,6 +79,104 @@ declare module 'nitropack/types' {
79
79
  }) => void | Promise<void>;
80
80
  }
81
81
  }
82
+ declare module '@nuxt/schema' {
83
+ interface NuxtHooks {
84
+ /**
85
+ * Called when the dev middleware is being registered on the Nitro dev server.
86
+ * @param handler the Vite or Webpack event handler
87
+ * @returns Promise
88
+ */
89
+ 'server:devHandler': (handler: EventHandler) => HookResult;
90
+ /**
91
+ * Called before Nitro writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
92
+ * @param options Objects containing `references`, `declarations`
93
+ * @returns Promise
94
+ */
95
+ 'nitro:prepare:types': (options: {
96
+ references: TSReference[];
97
+ declarations: string[];
98
+ }) => HookResult;
99
+ /**
100
+ * Called before initializing Nitro, allowing customization of Nitro's configuration.
101
+ * @param nitroConfig The nitro config to be extended
102
+ * @returns Promise
103
+ */
104
+ 'nitro:config': (nitroConfig: NitroConfig) => HookResult;
105
+ /**
106
+ * Called after Nitro is initialized, which allows registering Nitro hooks and interacting directly with Nitro.
107
+ * @param nitro The created nitro object
108
+ * @returns Promise
109
+ */
110
+ 'nitro:init': (nitro: Nitro) => HookResult;
111
+ /**
112
+ * Called before building the Nitro instance.
113
+ * @param nitro The created nitro object
114
+ * @returns Promise
115
+ */
116
+ 'nitro:build:before': (nitro: Nitro) => HookResult;
117
+ /**
118
+ * Called after copying public assets. Allows modifying public assets before Nitro server is built.
119
+ * @param nitro The created nitro object
120
+ * @returns Promise
121
+ */
122
+ 'nitro:build:public-assets': (nitro: Nitro) => HookResult;
123
+ }
124
+ interface ConfigSchema {
125
+ /**
126
+ * Configuration for Nitro.
127
+ *
128
+ * @see [Nitro configuration docs](https://nitro.build/config)
129
+ */
130
+ nitro: NitroConfig;
131
+ /**
132
+ * Global route options applied to matching server routes.
133
+ *
134
+ * @experimental This is an experimental feature and API may change in the future.
135
+ *
136
+ * @see [Nitro route rules documentation](https://nitro.build/config#routerules)
137
+ */
138
+ routeRules: NitroConfig['routeRules'];
139
+ /**
140
+ * Nitro server handlers.
141
+ *
142
+ * Each handler accepts the following options:
143
+ * - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of [rou3](https://github.com/h3js/rou3). - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
144
+ *
145
+ * @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
146
+ *
147
+ * @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
148
+ *
149
+ * @example
150
+ * ```js
151
+ * serverHandlers: [
152
+ * { route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
153
+ * ]
154
+ * ```
155
+ */
156
+ serverHandlers: NitroEventHandler[];
157
+ /**
158
+ * Nitro development-only server handlers.
159
+ *
160
+ * @see [Nitro server routes documentation](https://nitro.build/guide/routing)
161
+ */
162
+ devServerHandlers: NitroDevEventHandler[];
163
+ }
164
+ interface NuxtConfig {
165
+ nitro?: NitroConfig;
166
+ }
167
+ interface RuntimeConfig {
168
+ app: NitroRuntimeConfigApp;
169
+ /** Only available on the server. */
170
+ nitro?: NitroRuntimeConfig['nitro'];
171
+ }
172
+ interface NuxtDebugOptions {
173
+ /** Debug options for Nitro */
174
+ nitro?: NitroOptions['debug'];
175
+ }
176
+ interface NuxtPage {
177
+ rules?: NitroRouteConfig;
178
+ }
179
+ }
82
180
 
83
181
  declare function bundle(nuxt: Nuxt & {
84
182
  _nitro?: Nitro;
package/dist/index.mjs CHANGED
@@ -11,7 +11,7 @@ import { readPackageJSON } from 'pkg-types';
11
11
  import { withTrailingSlash, joinURL } from 'ufo';
12
12
  import { hash } from 'ohash';
13
13
  import { createNitro, scanHandlers, writeTypes, copyPublicAssets, prepare, build, prerender, createDevServer } from 'nitropack';
14
- import { getLayerDirectories, getDirectory, resolveNuxtModule, addTemplate, resolveAlias, addPlugin, resolveIgnorePatterns, createIsIgnored, addVitePlugin, logger, findPath } from '@nuxt/kit';
14
+ import { getLayerDirectories, getDirectory, resolveNuxtModule, addTemplate, resolveAlias, addPlugin, resolveIgnorePatterns, createIsIgnored, logger, addVitePlugin, findPath } from '@nuxt/kit';
15
15
  import escapeRE from 'escape-string-regexp';
16
16
  import { defu } from 'defu';
17
17
  import { dynamicEventHandler, defineEventHandler } from 'h3';
@@ -19,7 +19,7 @@ import { isWindows } from 'std-env';
19
19
  import { ImpoundPlugin } from 'impound';
20
20
  import { resolveModulePath } from 'exsolve';
21
21
 
22
- const version = "4.3.0-29461891.8f4fbecd";
22
+ const version = "4.3.0-29465977.c4f46c64";
23
23
  const nitroBuilder = {
24
24
  version: version};
25
25
 
@@ -271,7 +271,7 @@ async function bundle(nuxt) {
271
271
  name: "nuxt",
272
272
  version: nuxtVersion || nitroBuilder.version
273
273
  },
274
- imports: {
274
+ imports: nuxt.options.experimental.nitroAutoImports === false ? false : {
275
275
  autoImport: nuxt.options.imports.autoImport,
276
276
  dirs: [...sharedDirs],
277
277
  imports: [
@@ -437,7 +437,7 @@ async function bundle(nuxt) {
437
437
  },
438
438
  logLevel: logLevelMapReverse[nuxt.options.logLevel]
439
439
  });
440
- if (nuxt.options.experimental.serverAppConfig && nitroConfig.imports) {
440
+ if (nuxt.options.experimental.serverAppConfig === true && nitroConfig.imports) {
441
441
  nitroConfig.imports.imports ||= [];
442
442
  nitroConfig.imports.imports.push({
443
443
  name: "useAppConfig",
@@ -660,6 +660,20 @@ async function bundle(nuxt) {
660
660
  ignored: [isIgnored]
661
661
  }
662
662
  };
663
+ nuxt.options.typescript.hoist.push(
664
+ // Nitro auto-imported/augmented dependencies
665
+ "nitro/types",
666
+ "nitro/runtime",
667
+ // TODO: remove in v5
668
+ "nitropack/types",
669
+ "nitropack/runtime",
670
+ "nitropack",
671
+ "defu",
672
+ "h3",
673
+ "consola",
674
+ "ofetch",
675
+ "crossws"
676
+ );
663
677
  await nuxt.callHook("nitro:config", nitroConfig);
664
678
  if (nitroConfig.static && nuxt.options.dev) {
665
679
  nitroConfig.routeRules ||= {};
@@ -693,6 +707,17 @@ async function bundle(nuxt) {
693
707
  compatibilityDate: nuxt.options.compatibilityDate,
694
708
  dotenv: nuxt.options._loadOptions?.dotenv
695
709
  });
710
+ if (nuxt.options.experimental.serverAppConfig === false && nitro.options.imports) {
711
+ nitro.options.imports.presets ||= [];
712
+ nitro.options.imports.presets = nitro.options.imports.presets.map((preset) => typeof preset === "string" || !("imports" in preset) ? preset : {
713
+ ...preset,
714
+ imports: preset.imports.filter((i) => i !== "useAppConfig")
715
+ });
716
+ }
717
+ if (nitro.options.static && nuxt.options.experimental.payloadExtraction === void 0) {
718
+ logger.warn("Using experimental payload extraction for full-static output. You can opt-out by setting `experimental.payloadExtraction` to `false`.");
719
+ nuxt.options.experimental.payloadExtraction = true;
720
+ }
696
721
  const spaLoadingTemplateFilePath = await spaLoadingTemplatePath(nuxt);
697
722
  nuxt.hook("builder:watch", async (_event, relativePath) => {
698
723
  const path = resolve(nuxt.options.srcDir, relativePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/nitro-server-nightly",
3
- "version": "4.3.0-29461891.8f4fbecd",
3
+ "version": "4.3.0-29465977.c4f46c64",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@nuxt/devalue": "^2.0.2",
22
- "@nuxt/kit": "npm:@nuxt/kit-nightly@4.3.0-29461891.8f4fbecd",
22
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@4.3.0-29465977.c4f46c64",
23
23
  "@unhead/vue": "^2.1.1",
24
24
  "@vue/shared": "^3.5.26",
25
25
  "consola": "^3.4.2",
@@ -47,11 +47,11 @@
47
47
  "vue-devtools-stub": "^0.1.0"
48
48
  },
49
49
  "peerDependencies": {
50
- "nuxt": "npm:nuxt-nightly@4.3.0-29461891.8f4fbecd"
50
+ "nuxt": "npm:nuxt-nightly@4.3.0-29465977.c4f46c64"
51
51
  },
52
52
  "devDependencies": {
53
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.3.0-29461891.8f4fbecd",
54
- "nuxt": "npm:nuxt-nightly@4.3.0-29461891.8f4fbecd",
53
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.3.0-29465977.c4f46c64",
54
+ "nuxt": "npm:nuxt-nightly@4.3.0-29465977.c4f46c64",
55
55
  "unbuild": "3.6.1",
56
56
  "vitest": "3.2.4"
57
57
  },