@nuxt/kit-nightly 4.3.0-29461891.8f4fbecd → 4.3.0-29466366.fa21bb17

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,561 +1,584 @@
1
- import { ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, Nuxt, ModuleMeta, NuxtOptions, SchemaDefinition, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, Component, ComponentsDir, NuxtTemplate, NuxtMiddleware, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate, NuxtServerTemplate, NuxtTypeTemplate } from '@nuxt/schema';
2
- import { LoadConfigOptions } from 'c12';
3
- import { Import, InlinePreset } from 'unimport';
4
- import { WebpackPluginInstance, Configuration } from 'webpack';
5
- import { RspackPluginInstance } from '@rspack/core';
6
- import { Plugin, UserConfig } from 'vite';
7
- import { UseContext } from 'unctx';
8
- import * as NitroV2 from 'nitropack/types';
9
- import * as NitroV3 from 'nitro/types';
10
- import { GlobOptions } from 'tinyglobby';
11
- import { ConsolaInstance, ConsolaOptions } from 'consola';
1
+ import { ConsolaInstance, ConsolaOptions } from "consola";
2
+ import { UseContext } from "unctx";
3
+ import "pkg-types";
4
+ import { GlobOptions } from "tinyglobby";
5
+ import { LoadConfigOptions } from "c12";
6
+ import { Component, ComponentsDir, ModuleDefinition, ModuleMeta, ModuleOptions, Nuxt, NuxtAppConfig, NuxtCompatibility, NuxtCompatibilityIssues, NuxtConfig, NuxtHooks, NuxtMiddleware, NuxtModule, NuxtOptions, NuxtPlugin, NuxtPluginTemplate, NuxtServerTemplate, NuxtTemplate, NuxtTypeTemplate, ResolvedNuxtTemplate, SchemaDefinition } from "@nuxt/schema";
7
+ import { Import, InlinePreset } from "unimport";
8
+ import { Configuration, WebpackPluginInstance } from "webpack";
9
+ import { RspackPluginInstance } from "@rspack/core";
10
+ import { Plugin, UserConfig } from "vite";
11
+ import * as NitroV2 from "nitropack/types";
12
+ import * as NitroV3 from "nitro/types";
12
13
 
14
+ //#region src/module/define.d.ts
13
15
  /**
14
- * Define a Nuxt module, automatically merging defaults with user provided options, installing
15
- * any hooks that are provided, and calling an optional setup function for full control.
16
- */
16
+ * Define a Nuxt module, automatically merging defaults with user provided options, installing
17
+ * any hooks that are provided, and calling an optional setup function for full control.
18
+ */
17
19
  declare function defineNuxtModule<TOptions extends ModuleOptions>(definition: ModuleDefinition<TOptions, Partial<TOptions>, false> | NuxtModule<TOptions, Partial<TOptions>, false>): NuxtModule<TOptions, TOptions, false>;
18
20
  declare function defineNuxtModule<TOptions extends ModuleOptions>(): {
19
- with: <TOptionsDefaults extends Partial<TOptions>>(definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true>) => NuxtModule<TOptions, TOptionsDefaults, true>;
21
+ with: <TOptionsDefaults extends Partial<TOptions>>(definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true>) => NuxtModule<TOptions, TOptionsDefaults, true>;
20
22
  };
21
-
23
+ //#endregion
24
+ //#region src/module/install.d.ts
22
25
  type ModuleToInstall = string | NuxtModule<ModuleOptions, Partial<ModuleOptions>, false>;
23
26
  /**
24
- * Installs a set of modules on a Nuxt instance.
25
- * @internal
26
- */
27
+ * Installs a set of modules on a Nuxt instance.
28
+ * @internal
29
+ */
27
30
  declare function installModules(modulesToInstall: Map<ModuleToInstall, Record<string, any>>, resolvedModulePaths: Set<string>, nuxt?: Nuxt): Promise<void>;
28
31
  /**
29
- * Installs a module on a Nuxt instance.
30
- * @deprecated Use module dependencies.
31
- */
32
- declare function installModule<T extends string | NuxtModule, Config extends Extract<NonNullable<NuxtConfig['modules']>[number], [T, any]>>(moduleToInstall: T, inlineOptions?: [Config] extends [never] ? any : Config[1], nuxt?: Nuxt): Promise<void>;
32
+ * Installs a module on a Nuxt instance.
33
+ * @deprecated Use module dependencies.
34
+ */
35
+ declare function installModule<T extends string | NuxtModule, Config extends Extract<NonNullable<NuxtConfig["modules"]>[number], [T, any]>>(moduleToInstall: T, inlineOptions?: [Config] extends [never] ? any : Config[1], nuxt?: Nuxt): Promise<void>;
33
36
  declare function resolveModuleWithOptions(definition: NuxtModule<any> | string | false | undefined | null | [(NuxtModule | string)?, Record<string, any>?], nuxt: Nuxt): {
34
- resolvedPath?: string;
35
- module: string | NuxtModule<any>;
36
- options: Record<string, any>;
37
+ resolvedPath?: string;
38
+ module: string | NuxtModule<any>;
39
+ options: Record<string, any>;
37
40
  } | undefined;
38
41
  declare function loadNuxtModuleInstance(nuxtModule: string | NuxtModule, nuxt?: Nuxt): Promise<{
39
- nuxtModule: NuxtModule<any>;
40
- buildTimeModuleMeta: ModuleMeta;
41
- resolvedModulePath?: string;
42
+ nuxtModule: NuxtModule<any>;
43
+ buildTimeModuleMeta: ModuleMeta;
44
+ resolvedModulePath?: string;
42
45
  }>;
43
46
  declare function getDirectory(p: string): string;
44
47
  declare const normalizeModuleTranspilePath: (p: string) => string;
45
-
46
- /**
47
- * Check if a Nuxt module is installed by name.
48
- *
49
- * This will check both the installed modules and the modules to be installed. Note
50
- * that it cannot detect if a module is _going to be_ installed programmatically by another module.
51
- */
48
+ //#endregion
49
+ //#region src/module/compatibility.d.ts
50
+ /**
51
+ * Check if a Nuxt module is installed by name.
52
+ *
53
+ * This will check both the installed modules and the modules to be installed. Note
54
+ * that it cannot detect if a module is _going to be_ installed programmatically by another module.
55
+ */
52
56
  declare function hasNuxtModule(moduleName: string, nuxt?: Nuxt): boolean;
53
57
  /**
54
- * Checks if a Nuxt module is compatible with a given semver version.
55
- */
58
+ * Checks if a Nuxt module is compatible with a given semver version.
59
+ */
56
60
  declare function hasNuxtModuleCompatibility(module: string | NuxtModule, semverVersion: string, nuxt?: Nuxt): Promise<boolean>;
57
61
  /**
58
- * Get the version of a Nuxt module.
59
- *
60
- * Scans installed modules for the version, if it's not found it will attempt to load the module instance and get the version from there.
61
- */
62
+ * Get the version of a Nuxt module.
63
+ *
64
+ * Scans installed modules for the version, if it's not found it will attempt to load the module instance and get the version from there.
65
+ */
62
66
  declare function getNuxtModuleVersion(module: string | NuxtModule, nuxt?: Nuxt | any): Promise<string | false>;
63
-
64
- interface LoadNuxtConfigOptions extends Omit<LoadConfigOptions<NuxtConfig>, 'overrides'> {
65
- overrides?: Exclude<LoadConfigOptions<NuxtConfig>['overrides'], Promise<any> | Function>;
67
+ //#endregion
68
+ //#region src/loader/config.d.ts
69
+ interface LoadNuxtConfigOptions extends Omit<LoadConfigOptions<NuxtConfig>, "overrides"> {
70
+ overrides?: Exclude<LoadConfigOptions<NuxtConfig>["overrides"], Promise<any> | Function>;
66
71
  }
67
72
  declare function loadNuxtConfig(opts: LoadNuxtConfigOptions): Promise<NuxtOptions>;
68
-
73
+ //#endregion
74
+ //#region src/loader/schema.d.ts
69
75
  declare function extendNuxtSchema(def: SchemaDefinition | (() => SchemaDefinition)): void;
70
-
76
+ //#endregion
77
+ //#region src/loader/nuxt.d.ts
71
78
  interface LoadNuxtOptions extends LoadNuxtConfigOptions {
72
- /** Load nuxt with development mode */
73
- dev?: boolean;
74
- /** Use lazy initialization of nuxt if set to false */
75
- ready?: boolean;
79
+ /** Load nuxt with development mode */
80
+ dev?: boolean;
81
+ /** Use lazy initialization of nuxt if set to false */
82
+ ready?: boolean;
76
83
  }
77
84
  declare function loadNuxt(opts: LoadNuxtOptions): Promise<Nuxt>;
78
85
  declare function buildNuxt(nuxt: Nuxt): Promise<any>;
79
-
86
+ //#endregion
87
+ //#region src/layers.d.ts
80
88
  interface LayerDirectories {
81
- /** Nuxt rootDir (`/` by default) */
82
- readonly root: string;
83
- /** Nitro source directory (`/server` by default) */
84
- readonly server: string;
85
- /** Local modules directory (`/modules` by default) */
86
- readonly modules: string;
87
- /** Shared directory (`/shared` by default) */
88
- readonly shared: string;
89
- /** Public directory (`/public` by default) */
90
- readonly public: string;
91
- /** Nuxt srcDir (`/app/` by default) */
92
- readonly app: string;
93
- /** Layouts directory (`/app/layouts` by default) */
94
- readonly appLayouts: string;
95
- /** Middleware directory (`/app/middleware` by default) */
96
- readonly appMiddleware: string;
97
- /** Pages directory (`/app/pages` by default) */
98
- readonly appPages: string;
99
- /** Plugins directory (`/app/plugins` by default) */
100
- readonly appPlugins: string;
89
+ /** Nuxt rootDir (`/` by default) */
90
+ readonly root: string;
91
+ /** Nitro source directory (`/server` by default) */
92
+ readonly server: string;
93
+ /** Local modules directory (`/modules` by default) */
94
+ readonly modules: string;
95
+ /** Shared directory (`/shared` by default) */
96
+ readonly shared: string;
97
+ /** Public directory (`/public` by default) */
98
+ readonly public: string;
99
+ /** Nuxt srcDir (`/app/` by default) */
100
+ readonly app: string;
101
+ /** Layouts directory (`/app/layouts` by default) */
102
+ readonly appLayouts: string;
103
+ /** Middleware directory (`/app/middleware` by default) */
104
+ readonly appMiddleware: string;
105
+ /** Pages directory (`/app/pages` by default) */
106
+ readonly appPages: string;
107
+ /** Plugins directory (`/app/plugins` by default) */
108
+ readonly appPlugins: string;
101
109
  }
102
110
  /**
103
- * Get the resolved directory paths for all layers in a Nuxt application.
104
- *
105
- * Returns an array of LayerDirectories objects, ordered by layer priority:
106
- * - The first layer is the user/project layer (highest priority)
107
- * - Earlier layers override later layers in the array
108
- * - Base layers appear last in the array (lowest priority)
109
- *
110
- * @param nuxt - The Nuxt instance to get layers from. Defaults to the current Nuxt context.
111
- * @returns Array of LayerDirectories objects, ordered by priority (user layer first)
112
- */
111
+ * Get the resolved directory paths for all layers in a Nuxt application.
112
+ *
113
+ * Returns an array of LayerDirectories objects, ordered by layer priority:
114
+ * - The first layer is the user/project layer (highest priority)
115
+ * - Earlier layers override later layers in the array
116
+ * - Base layers appear last in the array (lowest priority)
117
+ *
118
+ * @param nuxt - The Nuxt instance to get layers from. Defaults to the current Nuxt context.
119
+ * @returns Array of LayerDirectories objects, ordered by priority (user layer first)
120
+ */
113
121
  declare function getLayerDirectories(nuxt?: Nuxt): LayerDirectories[];
114
-
115
- declare function setGlobalHead(head: NuxtAppConfig['head']): void;
116
-
122
+ //#endregion
123
+ //#region src/head.d.ts
124
+ declare function setGlobalHead(head: NuxtAppConfig["head"]): void;
125
+ //#endregion
126
+ //#region src/imports.d.ts
117
127
  declare function addImports(imports: Import | Import[]): void;
118
128
  declare function addImportsDir(dirs: string | string[], opts?: {
119
- prepend?: boolean;
129
+ prepend?: boolean;
120
130
  }): void;
121
131
  declare function addImportsSources(presets: InlinePreset | InlinePreset[]): void;
122
-
132
+ //#endregion
133
+ //#region src/runtime-config.d.ts
123
134
  /**
124
- * Access 'resolved' Nuxt runtime configuration, with values updated from environment.
125
- *
126
- * This mirrors the runtime behavior of Nitro.
127
- */
135
+ * Access 'resolved' Nuxt runtime configuration, with values updated from environment.
136
+ *
137
+ * This mirrors the runtime behavior of Nitro.
138
+ */
128
139
  declare function useRuntimeConfig(): Record<string, any>;
129
140
  /**
130
- * Update Nuxt runtime configuration.
131
- */
141
+ * Update Nuxt runtime configuration.
142
+ */
132
143
  declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void | Promise<void>;
133
-
144
+ //#endregion
145
+ //#region src/build.d.ts
134
146
  type Arrayable<T> = T | T[];
135
147
  type Thenable<T> = T | Promise<T>;
136
148
  interface ExtendConfigOptions {
137
- /**
138
- * Install plugin on dev
139
- * @default true
140
- */
141
- dev?: boolean;
142
- /**
143
- * Install plugin on build
144
- * @default true
145
- */
146
- build?: boolean;
147
- /**
148
- * Install plugin on server side
149
- * @default true
150
- */
151
- server?: boolean;
152
- /**
153
- * Install plugin on client side
154
- * @default true
155
- */
156
- client?: boolean;
157
- /**
158
- * Prepends the plugin to the array with `unshift()` instead of `push()`.
159
- */
160
- prepend?: boolean;
161
- }
162
- interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
149
+ /**
150
+ * Install plugin on dev
151
+ * @default true
152
+ */
153
+ dev?: boolean;
154
+ /**
155
+ * Install plugin on build
156
+ * @default true
157
+ */
158
+ build?: boolean;
159
+ /**
160
+ * Install plugin on server side
161
+ * @default true
162
+ */
163
+ server?: boolean;
164
+ /**
165
+ * Install plugin on client side
166
+ * @default true
167
+ */
168
+ client?: boolean;
169
+ /**
170
+ * Prepends the plugin to the array with `unshift()` instead of `push()`.
171
+ */
172
+ prepend?: boolean;
163
173
  }
164
- interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, 'server' | 'client'> {
165
- /**
166
- * Extend server Vite configuration
167
- * @default true
168
- * @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
169
- * Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
170
- * You can likely use a Vite plugin to achieve the same result.
171
- */
172
- server?: boolean;
173
- /**
174
- * Extend client Vite configuration
175
- * @default true
176
- * @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
177
- * Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
178
- * You can likely use a Vite plugin to achieve the same result.
179
- */
180
- client?: boolean;
174
+ interface ExtendWebpackConfigOptions extends ExtendConfigOptions {}
175
+ interface ExtendViteConfigOptions extends Omit<ExtendConfigOptions, "server" | "client"> {
176
+ /**
177
+ * Extend server Vite configuration
178
+ * @default true
179
+ * @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
180
+ * Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
181
+ * You can likely use a Vite plugin to achieve the same result.
182
+ */
183
+ server?: boolean;
184
+ /**
185
+ * Extend client Vite configuration
186
+ * @default true
187
+ * @deprecated calling \`extendViteConfig\` with only server/client environment is deprecated.
188
+ * Nuxt 5+ uses the Vite Environment API which shares a configuration between environments.
189
+ * You can likely use a Vite plugin to achieve the same result.
190
+ */
191
+ client?: boolean;
181
192
  }
182
193
  type ExtendWebpacklikeConfig = (fn: (config: Configuration) => void, options?: ExtendWebpackConfigOptions) => void;
183
194
  /**
184
- * Extend webpack config
185
- *
186
- * The fallback function might be called multiple times
187
- * when applying to both client and server builds.
188
- */
195
+ * Extend webpack config
196
+ *
197
+ * The fallback function might be called multiple times
198
+ * when applying to both client and server builds.
199
+ */
189
200
  declare const extendWebpackConfig: ExtendWebpacklikeConfig;
190
201
  /**
191
- * Extend rspack config
192
- *
193
- * The fallback function might be called multiple times
194
- * when applying to both client and server builds.
195
- */
202
+ * Extend rspack config
203
+ *
204
+ * The fallback function might be called multiple times
205
+ * when applying to both client and server builds.
206
+ */
196
207
  declare const extendRspackConfig: ExtendWebpacklikeConfig;
197
208
  /**
198
- * Extend Vite config
199
- */
209
+ * Extend Vite config
210
+ */
200
211
  declare function extendViteConfig(fn: ((config: UserConfig) => Thenable<void>), options?: ExtendViteConfigOptions): (() => void) | undefined;
201
212
  /**
202
- * Append webpack plugin to the config.
203
- */
213
+ * Append webpack plugin to the config.
214
+ */
204
215
  declare function addWebpackPlugin(pluginOrGetter: Arrayable<WebpackPluginInstance> | (() => Thenable<Arrayable<WebpackPluginInstance>>), options?: ExtendWebpackConfigOptions): void;
205
216
  /**
206
- * Append rspack plugin to the config.
207
- */
217
+ * Append rspack plugin to the config.
218
+ */
208
219
  declare function addRspackPlugin(pluginOrGetter: Arrayable<RspackPluginInstance> | (() => Thenable<Arrayable<RspackPluginInstance>>), options?: ExtendWebpackConfigOptions): void;
209
220
  /**
210
- * Append Vite plugin to the config.
211
- */
221
+ * Append Vite plugin to the config.
222
+ */
212
223
  declare function addVitePlugin(pluginOrGetter: Arrayable<Plugin> | (() => Thenable<Arrayable<Plugin>>), options?: ExtendConfigOptions): void;
213
224
  interface AddBuildPluginFactory {
214
- vite?: () => Thenable<Arrayable<Plugin>>;
215
- webpack?: () => Thenable<Arrayable<WebpackPluginInstance>>;
216
- rspack?: () => Thenable<Arrayable<RspackPluginInstance>>;
225
+ vite?: () => Thenable<Arrayable<Plugin>>;
226
+ webpack?: () => Thenable<Arrayable<WebpackPluginInstance>>;
227
+ rspack?: () => Thenable<Arrayable<RspackPluginInstance>>;
217
228
  }
218
229
  declare function addBuildPlugin(pluginFactory: AddBuildPluginFactory, options?: ExtendConfigOptions): void;
219
-
230
+ //#endregion
231
+ //#region src/compatibility.d.ts
220
232
  declare function normalizeSemanticVersion(version: string): string;
221
233
  /**
222
- * Check version constraints and return incompatibility issues as an array
223
- */
234
+ * Check version constraints and return incompatibility issues as an array
235
+ */
224
236
  declare function checkNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<NuxtCompatibilityIssues>;
225
237
  /**
226
- * Check version constraints and throw a detailed error if has any, otherwise returns true
227
- */
238
+ * Check version constraints and throw a detailed error if has any, otherwise returns true
239
+ */
228
240
  declare function assertNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<true>;
229
241
  /**
230
- * Check version constraints and return true if passed, otherwise returns false
231
- */
242
+ * Check version constraints and return true if passed, otherwise returns false
243
+ */
232
244
  declare function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean>;
233
245
  type NuxtMajorVersion = 2 | 3 | 4;
234
246
  /**
235
- * Check if current Nuxt instance is of specified major version
236
- */
247
+ * Check if current Nuxt instance is of specified major version
248
+ */
237
249
  declare function isNuxtMajorVersion(majorVersion: NuxtMajorVersion, nuxt?: Nuxt): boolean;
238
250
  /**
239
- * @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
240
- */
251
+ * @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
252
+ */
241
253
  declare function isNuxt2(nuxt?: Nuxt): boolean;
242
254
  /**
243
- * @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
244
- */
255
+ * @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
256
+ */
245
257
  declare function isNuxt3(nuxt?: Nuxt): boolean;
246
258
  /**
247
- * Get nuxt version
248
- */
259
+ * Get nuxt version
260
+ */
249
261
  declare function getNuxtVersion(nuxt?: Nuxt | any): string;
250
-
262
+ //#endregion
263
+ //#region src/components.d.ts
251
264
  /**
252
- * Register a directory to be scanned for components and imported only when used.
253
- */
265
+ * Register a directory to be scanned for components and imported only when used.
266
+ */
254
267
  declare function addComponentsDir(dir: ComponentsDir, opts?: {
255
- prepend?: boolean;
268
+ prepend?: boolean;
256
269
  }): void;
257
270
  type AddComponentOptions = {
258
- name: string;
259
- filePath: string;
260
- } & Partial<Exclude<Component, 'shortPath' | 'async' | 'level' | 'import' | 'asyncImport'>>;
261
- /**
262
- * This utility takes a file path or npm package that is scanned for named exports, which are get added automatically
263
- */
264
- declare function addComponentExports(opts: Omit<AddComponentOptions, 'name'> & {
265
- prefix?: string;
271
+ name: string;
272
+ filePath: string;
273
+ } & Partial<Exclude<Component, "shortPath" | "async" | "level" | "import" | "asyncImport">>;
274
+ /**
275
+ * This utility takes a file path or npm package that is scanned for named exports, which are get added automatically
276
+ */
277
+ declare function addComponentExports(opts: Omit<AddComponentOptions, "name"> & {
278
+ prefix?: string;
266
279
  }): void;
267
280
  /**
268
- * Register a component by its name and filePath.
269
- */
281
+ * Register a component by its name and filePath.
282
+ */
270
283
  declare function addComponent(opts: AddComponentOptions): void;
271
-
284
+ //#endregion
285
+ //#region src/context.d.ts
272
286
  /**
273
- * Direct access to the Nuxt global context - see https://github.com/unjs/unctx.
274
- * @deprecated Use `getNuxtCtx` instead
275
- */
287
+ * Direct access to the Nuxt global context - see https://github.com/unjs/unctx.
288
+ * @deprecated Use `getNuxtCtx` instead
289
+ */
276
290
  declare const nuxtCtx: UseContext<Nuxt>;
277
291
  /** Direct access to the Nuxt context with asyncLocalStorage - see https://github.com/unjs/unctx. */
278
292
  declare const getNuxtCtx: () => Nuxt | null;
279
293
  /**
280
- * Get access to Nuxt instance.
281
- *
282
- * Throws an error if Nuxt instance is unavailable.
283
- * @example
284
- * ```js
285
- * const nuxt = useNuxt()
286
- * ```
287
- */
294
+ * Get access to Nuxt instance.
295
+ *
296
+ * Throws an error if Nuxt instance is unavailable.
297
+ * @example
298
+ * ```js
299
+ * const nuxt = useNuxt()
300
+ * ```
301
+ */
288
302
  declare function useNuxt(): Nuxt;
289
303
  /**
290
- * Get access to Nuxt instance.
291
- *
292
- * Returns null if Nuxt instance is unavailable.
293
- * @example
294
- * ```js
295
- * const nuxt = tryUseNuxt()
296
- * if (nuxt) {
297
- * // Do something
298
- * }
299
- * ```
300
- */
304
+ * Get access to Nuxt instance.
305
+ *
306
+ * Returns null if Nuxt instance is unavailable.
307
+ * @example
308
+ * ```js
309
+ * const nuxt = tryUseNuxt()
310
+ * if (nuxt) {
311
+ * // Do something
312
+ * }
313
+ * ```
314
+ */
301
315
  declare function tryUseNuxt(): Nuxt | null;
302
316
  declare function runWithNuxtContext<T extends (...args: any[]) => any>(nuxt: Nuxt, fn: T): ReturnType<T>;
303
-
317
+ //#endregion
318
+ //#region src/ignore.d.ts
304
319
  declare function createIsIgnored(nuxt?: Nuxt | null | undefined): (pathname: string, stats?: unknown) => boolean;
305
320
  /**
306
- * Return a filter function to filter an array of paths
307
- */
321
+ * Return a filter function to filter an array of paths
322
+ */
308
323
  declare function isIgnored(pathname: string, _stats?: unknown, nuxt?: Nuxt | null | undefined): boolean;
309
324
  declare function resolveIgnorePatterns(relativePath?: string): string[];
310
-
325
+ //#endregion
326
+ //#region src/layout.d.ts
311
327
  declare function addLayout(template: NuxtTemplate | string, name?: string): void;
312
-
313
- type isNitroV2 = 'options' extends keyof NitroV2.Nitro ? '___INVALID' extends keyof NitroV2.Nitro ? false : true : false;
328
+ //#endregion
329
+ //#region src/nitro-types.d.ts
330
+ type isNitroV2 = "options" extends keyof NitroV2.Nitro ? "___INVALID" extends keyof NitroV2.Nitro ? false : true : false;
314
331
  type Nitro = isNitroV2 extends true ? NitroV2.Nitro : NitroV3.Nitro;
315
332
  type NitroDevEventHandler = isNitroV2 extends true ? NitroV2.NitroDevEventHandler : NitroV3.NitroDevEventHandler;
316
333
  type NitroEventHandler = isNitroV2 extends true ? NitroV2.NitroEventHandler : NitroV3.NitroEventHandler;
317
334
  type NitroRouteConfig = isNitroV2 extends true ? NitroV2.NitroRouteConfig : NitroV3.NitroRouteConfig;
318
-
319
- declare function extendPages(cb: NuxtHooks['pages:extend']): void;
335
+ //#endregion
336
+ //#region src/pages.d.ts
337
+ declare function extendPages(cb: NuxtHooks["pages:extend"]): void;
320
338
  interface ExtendRouteRulesOptions {
321
- /**
322
- * Override route rule config
323
- * @default false
324
- */
325
- override?: boolean;
339
+ /**
340
+ * Override route rule config
341
+ * @default false
342
+ */
343
+ override?: boolean;
326
344
  }
327
345
  declare function extendRouteRules(route: string, rule: NitroRouteConfig, options?: ExtendRouteRulesOptions): void;
328
346
  interface AddRouteMiddlewareOptions {
329
- /**
330
- * Override existing middleware with the same name, if it exists
331
- * @default false
332
- */
333
- override?: boolean;
334
- /**
335
- * Prepend middleware to the list
336
- * @default false
337
- */
338
- prepend?: boolean;
347
+ /**
348
+ * Override existing middleware with the same name, if it exists
349
+ * @default false
350
+ */
351
+ override?: boolean;
352
+ /**
353
+ * Prepend middleware to the list
354
+ * @default false
355
+ */
356
+ prepend?: boolean;
339
357
  }
340
358
  declare function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void;
341
-
359
+ //#endregion
360
+ //#region src/plugin.d.ts
342
361
  declare function normalizePlugin(plugin: NuxtPlugin | string): NuxtPlugin;
343
362
  /**
344
- * Registers a nuxt plugin and to the plugins array.
345
- *
346
- * Note: You can use mode or .client and .server modifiers with fileName option
347
- * to use plugin only in client or server side.
348
- *
349
- * Note: By default plugin is prepended to the plugins array. You can use second argument to append (push) instead.
350
- * @example
351
- * ```js
352
- * import { createResolver } from '@nuxt/kit'
353
- * const resolver = createResolver(import.meta.url)
354
- *
355
- * addPlugin({
356
- * src: resolver.resolve('templates/foo.js'),
357
- * filename: 'foo.server.js' // [optional] only include in server bundle
358
- * })
359
- * ```
360
- */
363
+ * Registers a nuxt plugin and to the plugins array.
364
+ *
365
+ * Note: You can use mode or .client and .server modifiers with fileName option
366
+ * to use plugin only in client or server side.
367
+ *
368
+ * Note: By default plugin is prepended to the plugins array. You can use second argument to append (push) instead.
369
+ * @example
370
+ * ```js
371
+ * import { createResolver } from '@nuxt/kit'
372
+ * const resolver = createResolver(import.meta.url)
373
+ *
374
+ * addPlugin({
375
+ * src: resolver.resolve('templates/foo.js'),
376
+ * filename: 'foo.server.js' // [optional] only include in server bundle
377
+ * })
378
+ * ```
379
+ */
361
380
  interface AddPluginOptions {
362
- append?: boolean;
381
+ append?: boolean;
363
382
  }
364
383
  declare function addPlugin(_plugin: NuxtPlugin | string, opts?: AddPluginOptions): NuxtPlugin;
365
384
  /**
366
- * Adds a template and registers as a nuxt plugin.
367
- */
385
+ * Adds a template and registers as a nuxt plugin.
386
+ */
368
387
  declare function addPluginTemplate(plugin: NuxtPluginTemplate | string, opts?: AddPluginOptions): NuxtPlugin;
369
-
388
+ //#endregion
389
+ //#region src/resolve.d.ts
370
390
  interface ResolvePathOptions {
371
- /** Base for resolving paths from. Default is Nuxt rootDir. */
372
- cwd?: string;
373
- /** An object of aliases. Default is Nuxt configured aliases. */
374
- alias?: Record<string, string>;
375
- /**
376
- * The file extensions to try.
377
- * Default is Nuxt configured extensions.
378
- *
379
- * Isn't considered when `type` is set to `'dir'`.
380
- */
381
- extensions?: string[];
382
- /**
383
- * Whether to resolve files that exist in the Nuxt VFS (for example, as a Nuxt template).
384
- * @default false
385
- */
386
- virtual?: boolean;
387
- /**
388
- * Whether to fallback to the original path if the resolved path does not exist instead of returning the normalized input path.
389
- * @default false
390
- */
391
- fallbackToOriginal?: boolean;
392
- /**
393
- * The type of the path to be resolved.
394
- * @default 'file'
395
- */
396
- type?: PathType;
391
+ /** Base for resolving paths from. Default is Nuxt rootDir. */
392
+ cwd?: string;
393
+ /** An object of aliases. Default is Nuxt configured aliases. */
394
+ alias?: Record<string, string>;
395
+ /**
396
+ * The file extensions to try.
397
+ * Default is Nuxt configured extensions.
398
+ *
399
+ * Isn't considered when `type` is set to `'dir'`.
400
+ */
401
+ extensions?: string[];
402
+ /**
403
+ * Whether to resolve files that exist in the Nuxt VFS (for example, as a Nuxt template).
404
+ * @default false
405
+ */
406
+ virtual?: boolean;
407
+ /**
408
+ * Whether to fallback to the original path if the resolved path does not exist instead of returning the normalized input path.
409
+ * @default false
410
+ */
411
+ fallbackToOriginal?: boolean;
412
+ /**
413
+ * The type of the path to be resolved.
414
+ * @default 'file'
415
+ */
416
+ type?: PathType;
397
417
  }
398
418
  /**
399
- * Resolve the full path to a file or a directory (based on the provided type), respecting Nuxt alias and extensions options.
400
- *
401
- * If a path cannot be resolved, normalized input will be returned unless the `fallbackToOriginal` option is set to `true`,
402
- * in which case the original input path will be returned.
403
- */
419
+ * Resolve the full path to a file or a directory (based on the provided type), respecting Nuxt alias and extensions options.
420
+ *
421
+ * If a path cannot be resolved, normalized input will be returned unless the `fallbackToOriginal` option is set to `true`,
422
+ * in which case the original input path will be returned.
423
+ */
404
424
  declare function resolvePath(path: string, opts?: ResolvePathOptions): Promise<string>;
405
425
  /**
406
- * Try to resolve first existing file in paths
407
- */
426
+ * Try to resolve first existing file in paths
427
+ */
408
428
  declare function findPath(paths: string | string[], opts?: ResolvePathOptions, pathType?: PathType): Promise<string | null>;
409
429
  /**
410
- * Resolve path aliases respecting Nuxt alias options
411
- */
430
+ * Resolve path aliases respecting Nuxt alias options
431
+ */
412
432
  declare function resolveAlias(path: string, alias?: Record<string, string>): string;
413
433
  interface Resolver {
414
- resolve(...path: string[]): string;
415
- resolvePath(path: string, opts?: ResolvePathOptions): Promise<string>;
434
+ resolve(...path: string[]): string;
435
+ resolvePath(path: string, opts?: ResolvePathOptions): Promise<string>;
416
436
  }
417
437
  /**
418
- * Create a relative resolver
419
- */
438
+ * Create a relative resolver
439
+ */
420
440
  declare function createResolver(base: string | URL): Resolver;
421
441
  declare function resolveNuxtModule(base: string, paths: string[]): Promise<string[]>;
422
- type PathType = 'file' | 'dir';
423
- /**
424
- * Resolve absolute file paths in the provided directory with respect to `.nuxtignore` and return them sorted.
425
- * @param path path to the directory to resolve files in
426
- * @param pattern glob pattern or an array of glob patterns to match files
427
- * @param opts options for globbing
428
- * @param opts.followSymbolicLinks whether to follow symbolic links, default is `true`
429
- * @param opts.ignore additional glob patterns to ignore
430
- * @returns sorted array of absolute file paths
431
- */
442
+ type PathType = "file" | "dir";
443
+ /**
444
+ * Resolve absolute file paths in the provided directory with respect to `.nuxtignore` and return them sorted.
445
+ * @param path path to the directory to resolve files in
446
+ * @param pattern glob pattern or an array of glob patterns to match files
447
+ * @param opts options for globbing
448
+ * @param opts.followSymbolicLinks whether to follow symbolic links, default is `true`
449
+ * @param opts.ignore additional glob patterns to ignore
450
+ * @returns sorted array of absolute file paths
451
+ */
432
452
  declare function resolveFiles(path: string, pattern: string | string[], opts?: {
433
- followSymbolicLinks?: boolean;
434
- ignore?: GlobOptions['ignore'];
453
+ followSymbolicLinks?: boolean;
454
+ ignore?: GlobOptions["ignore"];
435
455
  }): Promise<string[]>;
436
-
456
+ //#endregion
457
+ //#region src/nitro.d.ts
437
458
  /**
438
- * Adds a nitro server handler
439
- *
440
- */
459
+ * Adds a nitro server handler
460
+ *
461
+ */
441
462
  declare function addServerHandler(handler: NitroEventHandler): void;
442
463
  /**
443
- * Adds a nitro server handler for development-only
444
- *
445
- */
464
+ * Adds a nitro server handler for development-only
465
+ *
466
+ */
446
467
  declare function addDevServerHandler(handler: NitroDevEventHandler): void;
447
468
  /**
448
- * Adds a Nitro plugin
449
- */
469
+ * Adds a Nitro plugin
470
+ */
450
471
  declare function addServerPlugin(plugin: string): void;
451
472
  /**
452
- * Adds routes to be prerendered
453
- */
473
+ * Adds routes to be prerendered
474
+ */
454
475
  declare function addPrerenderRoutes(routes: string | string[]): void;
455
476
  /**
456
- * Access to the Nitro instance
457
- *
458
- * **Note:** You can call `useNitro()` only after `ready` hook.
459
- *
460
- * **Note:** Changes to the Nitro instance configuration are not applied.
461
- * @example
462
- *
463
- * ```ts
464
- * nuxt.hook('ready', () => {
465
- * console.log(useNitro())
466
- * })
467
- * ```
468
- */
477
+ * Access to the Nitro instance
478
+ *
479
+ * **Note:** You can call `useNitro()` only after `ready` hook.
480
+ *
481
+ * **Note:** Changes to the Nitro instance configuration are not applied.
482
+ * @example
483
+ *
484
+ * ```ts
485
+ * nuxt.hook('ready', () => {
486
+ * console.log(useNitro())
487
+ * })
488
+ * ```
489
+ */
469
490
  declare function useNitro(): Nitro;
470
491
  /**
471
- * Add server imports to be auto-imported by Nitro
472
- */
492
+ * Add server imports to be auto-imported by Nitro
493
+ */
473
494
  declare function addServerImports(imports: Import | Import[]): void;
474
495
  /**
475
- * Add directories to be scanned for auto-imports by Nitro
476
- */
496
+ * Add directories to be scanned for auto-imports by Nitro
497
+ */
477
498
  declare function addServerImportsDir(dirs: string | string[], opts?: {
478
- prepend?: boolean;
499
+ prepend?: boolean;
479
500
  }): void;
480
501
  /**
481
- * Add directories to be scanned by Nitro. It will check for subdirectories,
482
- * which will be registered just like the `~/server` folder is.
483
- */
502
+ * Add directories to be scanned by Nitro. It will check for subdirectories,
503
+ * which will be registered just like the `~/server` folder is.
504
+ */
484
505
  declare function addServerScanDir(dirs: string | string[], opts?: {
485
- prepend?: boolean;
506
+ prepend?: boolean;
486
507
  }): void;
487
-
508
+ //#endregion
509
+ //#region src/template.d.ts
488
510
  /**
489
- * Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
490
- */
511
+ * Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
512
+ */
491
513
  declare function addTemplate<T>(_template: NuxtTemplate<T> | string): ResolvedNuxtTemplate<T>;
492
514
  /**
493
- * Adds a virtual file that can be used within the Nuxt Nitro server build.
494
- */
515
+ * Adds a virtual file that can be used within the Nuxt Nitro server build.
516
+ */
495
517
  declare function addServerTemplate(template: NuxtServerTemplate): NuxtServerTemplate;
496
518
  /**
497
- * Renders given types during build to disk in the project `buildDir`
498
- * and register them as types.
499
- *
500
- * You can pass a second context object to specify in which context the type should be added.
501
- *
502
- * If no context object is passed, then it will only be added to the nuxt context.
503
- */
519
+ * Renders given types during build to disk in the project `buildDir`
520
+ * and register them as types.
521
+ *
522
+ * You can pass a second context object to specify in which context the type should be added.
523
+ *
524
+ * If no context object is passed, then it will only be added to the nuxt context.
525
+ */
504
526
  declare function addTypeTemplate<T>(_template: NuxtTypeTemplate<T>, context?: {
505
- nitro?: boolean;
506
- nuxt?: boolean;
507
- node?: boolean;
508
- shared?: boolean;
527
+ nitro?: boolean;
528
+ nuxt?: boolean;
529
+ node?: boolean;
530
+ shared?: boolean;
509
531
  }): ResolvedNuxtTemplate<T>;
510
532
  /**
511
- * Normalize a nuxt template object
512
- */
533
+ * Normalize a nuxt template object
534
+ */
513
535
  declare function normalizeTemplate<T>(template: NuxtTemplate<T> | string, buildDir?: string): ResolvedNuxtTemplate<T>;
514
536
  /**
515
- * Trigger rebuilding Nuxt templates
516
- *
517
- * You can pass a filter within the options to selectively regenerate a subset of templates.
518
- */
537
+ * Trigger rebuilding Nuxt templates
538
+ *
539
+ * You can pass a filter within the options to selectively regenerate a subset of templates.
540
+ */
519
541
  declare function updateTemplates(options?: {
520
- filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
542
+ filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
521
543
  }): Promise<void>;
522
544
  declare function writeTypes(nuxt: Nuxt): Promise<void>;
523
-
545
+ //#endregion
546
+ //#region src/logger.d.ts
524
547
  declare const logger: ConsolaInstance;
525
548
  declare function useLogger(tag?: string, options?: Partial<ConsolaOptions>): ConsolaInstance;
526
-
549
+ //#endregion
550
+ //#region src/internal/esm.d.ts
527
551
  interface ResolveModuleOptions {
528
- /** @deprecated use `url` with URLs pointing at a file - never a directory */
529
- paths?: string | string[];
530
- url?: URL | URL[];
531
- /** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
532
- extensions?: string[];
552
+ /** @deprecated use `url` with URLs pointing at a file - never a directory */
553
+ paths?: string | string[];
554
+ url?: URL | URL[];
555
+ /** @default ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'] */
556
+ extensions?: string[];
533
557
  }
534
558
  declare function directoryToURL(dir: string): URL;
535
559
  /**
536
- * Resolve a module from a given root path using an algorithm patterned on
537
- * the upcoming `import.meta.resolve`. It returns a file URL
538
- *
539
- * @internal
540
- */
560
+ * Resolve a module from a given root path using an algorithm patterned on
561
+ * the upcoming `import.meta.resolve`. It returns a file URL
562
+ *
563
+ * @internal
564
+ */
541
565
  declare function tryResolveModule(id: string, url: URL | URL[]): Promise<string | undefined>;
542
566
  /** @deprecated pass URLs pointing at files */
543
567
  declare function tryResolveModule(id: string, url: string | string[]): Promise<string | undefined>;
544
568
  declare function resolveModule(id: string, options?: ResolveModuleOptions): string;
545
569
  interface ImportModuleOptions extends ResolveModuleOptions {
546
- /** Automatically de-default the result of requiring the module. */
547
- interopDefault?: boolean;
570
+ /** Automatically de-default the result of requiring the module. */
571
+ interopDefault?: boolean;
548
572
  }
549
573
  declare function importModule<T = unknown>(id: string, opts?: ImportModuleOptions): Promise<T>;
550
574
  declare function tryImportModule<T = unknown>(id: string, opts?: ImportModuleOptions): Promise<T | undefined> | undefined;
551
575
  /**
552
- * @deprecated Please use `importModule` instead.
553
- */
576
+ * @deprecated Please use `importModule` instead.
577
+ */
554
578
  declare function requireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T;
555
579
  /**
556
- * @deprecated Please use `tryImportModule` instead.
557
- */
580
+ * @deprecated Please use `tryImportModule` instead.
581
+ */
558
582
  declare function tryRequireModule<T = unknown>(id: string, opts?: ImportModuleOptions): T | undefined;
559
-
560
- export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
561
- export type { AddComponentOptions, AddPluginOptions, AddRouteMiddlewareOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, ImportModuleOptions, LayerDirectories, LoadNuxtConfigOptions, LoadNuxtOptions, NuxtMajorVersion, ResolveModuleOptions, ResolvePathOptions, Resolver };
583
+ //#endregion
584
+ export { type AddComponentOptions, type AddPluginOptions, type AddRouteMiddlewareOptions, type ExtendConfigOptions, type ExtendRouteRulesOptions, type ExtendViteConfigOptions, type ExtendWebpackConfigOptions, type ImportModuleOptions, type LayerDirectories, type LoadNuxtConfigOptions, type LoadNuxtOptions, type NuxtMajorVersion, type ResolveModuleOptions, type ResolvePathOptions, type Resolver, addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getLayerDirectories, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, installModules, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveModuleWithOptions, resolveNuxtModule, resolvePath, runWithNuxtContext, setGlobalHead, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };