@nuxt/kit 3.0.0-rc.9 → 3.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016-present - Nuxt Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,128 @@
1
- # Nuxt Kit
2
1
 
3
- > Toolkit for authoring Nuxt Modules
2
+ [![Nuxt banner](./.github/assets/banner.png)](https://nuxt.com)
3
+
4
+ # 👋 Welcome to Nuxt
5
+
6
+
7
+ Nuxt's goal is to make web development intuitive and performant, with a great developer experience.<br>Learn more in the ['What is Nuxt?'](https://nuxt.com/docs/getting-started/introduction) section of our documentation.
8
+
9
+
10
+ <p>
11
+ <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
12
+ <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
13
+ <a href="./LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
14
+ <a href="https://volta.net/nuxt/nuxt?utm_source=nuxt_readme"><img src="https://user-images.githubusercontent.com/904724/209143798-32345f6c-3cf8-4e06-9659-f4ace4a6acde.svg" alt="Volta board"></a>
15
+ </p>
16
+
17
+ <table>
18
+ <thead>
19
+ <tr>
20
+ <th width="2000" colspan="2">
21
+ </th>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <tr>
26
+ <td width="80" align="center" valign="top">
27
+ <br>
28
+ <a href="https://nuxt.com/docs"><img src="./.github/assets/documentation.png"></a>
29
+ </td>
30
+ <td valign="top">
31
+ <h3>Documentation</h3>
32
+ <p>
33
+ We highly recommend you take a look at <a href="https://nuxt.com">the Nuxt documentation</a> to level up.
34
+ </p>
35
+ </td>
36
+ </tr>
37
+ <tr>
38
+ <td width="80" align="center" valign="top">
39
+ <br>
40
+ <a href="https://nuxt.com/modules"><img src="./.github/assets/modules.png"></a>
41
+ </td>
42
+ <td valign="top">
43
+ <h3>Modules</h3>
44
+ <p>
45
+ Discover our <a href="https://nuxt.com/modules">list of modules</a> to supercharge your Nuxt project. Created by the Nuxt team and community.
46
+ </p>
47
+ </td>
48
+ </tr>
49
+ <tr>
50
+ <td width="80" align="center" valign="top">
51
+ <br>
52
+ <a href="https://nuxt.com/docs/examples/hello-world"><img src="./.github/assets/examples.png"></a>
53
+ </td>
54
+ <td>
55
+ <h3>Examples</h3>
56
+ <p>
57
+ Explore different ways of using Nuxt features and get inspired with <a href="https://nuxt.com/docs/examples/essentials/hello-world">our list of examples</a>.
58
+ </p>
59
+ </td>
60
+ </tr>
61
+ </tbody>
62
+ </table>
63
+
64
+ <table>
65
+ <thead>
66
+ <tr>
67
+ <th width="2000" colspan="2">
68
+ </th>
69
+ </tr>
70
+ </thead>
71
+ <tbody>
72
+ <tr>
73
+ <td width="80" align="center" valign="top">
74
+ <br>
75
+ <a href="https://nuxt.com/docs/community/reporting-bugs"><img src="./.github/assets/reporting-bugs.png"></a>
76
+ </td>
77
+ <td valign="top">
78
+ <h3>Reporting bugs</h3>
79
+ <p>
80
+ Check out the <a href="https://nuxt.com/docs/community/reporting-bugs">Reporting Bugs</a> page.</p>
81
+ </p>
82
+ </td>
83
+ </tr>
84
+ <tr>
85
+ <td width="80" align="center" valign="top">
86
+ <br>
87
+ <a href="https://nuxt.com/docs/community/contribution"><img src="./.github/assets/suggestions.png"></a>
88
+ </td>
89
+ <td valign="top">
90
+ <h3>Suggestions</h3>
91
+ <p>
92
+ Check out the <a href="https://nuxt.com/docs/community/contribution">Contribution</a> page.
93
+ </p>
94
+ </td>
95
+ </tr>
96
+ <tr>
97
+ <td width="80" align="center" valign="top">
98
+ <br>
99
+ <a href="https://nuxt.com/docs/community/getting-help"><img src="./.github/assets/questions.png"></a>
100
+ </td>
101
+ <td valign="top">
102
+ <h3>Questions</h3>
103
+ <p>
104
+ Check out the <a href="https://nuxt.com/docs/community/getting-help">Getting Help</a> page.
105
+ </p>
106
+ </td>
107
+ </tr>
108
+ </tbody>
109
+ </table>
110
+
111
+ ## Local Development
112
+
113
+ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/community/framework-contribution#set-up-your-local-development-environment) to contribute to the framework and documentation.
114
+
115
+ ## Nuxt 2
116
+
117
+ You can find the code for Nuxt 2 on the [`2.x-dev` branch](https://github.com/nuxt/nuxt/tree/2.x-dev) and the documentation at [nuxtjs.org](https://nuxtjs.org).
118
+
119
+ ## Follow us
120
+
121
+ <p valign="center">
122
+ <a href="https://chat.nuxt.dev"><img width="20px" src="./.github/assets/discord.svg" alt="Discord"></a>&nbsp;&nbsp;<a href="https://twitter.nuxt.dev"><img width="20px" src="./.github/assets/twitter.svg" alt="Twitter"></a>&nbsp;&nbsp;<a href="https://github.nuxt.dev"><img width="20px" src="./.github/assets/github.svg" alt="GitHub"></a>
123
+ </p>
124
+
125
+ ## License
126
+
127
+ [MIT](./LICENSE)
4
128
 
5
- Learn more about this package: <https://v3.nuxtjs.org>
package/dist/index.d.ts CHANGED
@@ -1,16 +1,13 @@
1
- import { Nuxt, ModuleContainer, ModuleOptions, ModuleDefinition, NuxtModule, NuxtConfig, NuxtOptions, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate } from '@nuxt/schema';
1
+ import { ModuleOptions, ModuleDefinition, NuxtModule, Nuxt, NuxtConfig, NuxtOptions, SchemaDefinition, ImportPresetWithDeprecation, NuxtCompatibility, NuxtCompatibilityIssues, ComponentsDir, Component, NuxtTemplate, NuxtHooks, NuxtPlugin, NuxtPluginTemplate, ResolvedNuxtTemplate } from '@nuxt/schema';
2
2
  import { LoadConfigOptions } from 'c12';
3
3
  import { Import } from 'unimport';
4
4
  import { Configuration, WebpackPluginInstance } from 'webpack';
5
5
  import { UserConfig, Plugin } from 'vite';
6
- import * as unctx from 'unctx';
7
- import { Middleware } from 'h3';
8
- import { NitroEventHandler, NitroDevEventHandler } from 'nitropack';
6
+ import * as unctx_index from 'unctx/index';
7
+ import { NitroRouteConfig, NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
9
8
  import * as consola from 'consola';
10
9
  import { genSafeVariableName } from 'knitwork';
11
10
 
12
- declare function useModuleContainer(nuxt?: Nuxt): ModuleContainer;
13
-
14
11
  /**
15
12
  * Define a Nuxt module, automatically merging defaults with user provided options, installing
16
13
  * any hooks that are provided, and calling an optional setup function for full control.
@@ -24,6 +21,8 @@ interface LoadNuxtConfigOptions extends LoadConfigOptions<NuxtConfig> {
24
21
  }
25
22
  declare function loadNuxtConfig(opts: LoadNuxtConfigOptions): Promise<NuxtOptions>;
26
23
 
24
+ declare function extendNuxtSchema(def: SchemaDefinition | (() => SchemaDefinition)): void;
25
+
27
26
  interface LoadNuxtOptions extends LoadNuxtConfigOptions {
28
27
  /** Load nuxt with development mode */
29
28
  dev?: boolean;
@@ -38,15 +37,8 @@ declare function loadNuxt(opts: LoadNuxtOptions): Promise<Nuxt>;
38
37
  declare function buildNuxt(nuxt: Nuxt): Promise<any>;
39
38
 
40
39
  declare function addImports(imports: Import | Import[]): void;
41
- /**
42
- * @deprecated Please use `addImports` instead with nuxt>=3.0.0-rc.9
43
- */
44
- declare const addAutoImport: typeof addImports;
45
40
  declare function addImportsDir(dirs: string | string[]): void;
46
- /**
47
- * @deprecated Please use `addImportsDir` instead with nuxt>=3.0.0-rc.9
48
- */
49
- declare const addAutoImportDir: typeof addImportsDir;
41
+ declare function addImportsSources(presets: ImportPresetWithDeprecation | ImportPresetWithDeprecation[]): void;
50
42
 
51
43
  interface ExtendConfigOptions {
52
44
  /**
@@ -75,18 +67,11 @@ interface ExtendConfigOptions {
75
67
  client?: boolean;
76
68
  }
77
69
  interface ExtendWebpackConfigOptions extends ExtendConfigOptions {
78
- /**
79
- * Install plugin on modern build
80
- *
81
- * @default true
82
- * @deprecated Nuxt 2 only
83
- */
84
- modern?: boolean;
85
70
  }
86
71
  interface ExtendViteConfigOptions extends ExtendConfigOptions {
87
72
  }
88
73
  /**
89
- * Extend Webpack config
74
+ * Extend webpack config
90
75
  *
91
76
  * The fallback function might be called multiple times
92
77
  * when applying to both client and server builds.
@@ -97,13 +82,13 @@ declare function extendWebpackConfig(fn: ((config: Configuration) => void), opti
97
82
  */
98
83
  declare function extendViteConfig(fn: ((config: UserConfig) => void), options?: ExtendViteConfigOptions): (() => void) | undefined;
99
84
  /**
100
- * Append Webpack plugin to the config.
85
+ * Append webpack plugin to the config.
101
86
  */
102
- declare function addWebpackPlugin(plugin: WebpackPluginInstance, options?: ExtendWebpackConfigOptions): void;
87
+ declare function addWebpackPlugin(plugin: WebpackPluginInstance | WebpackPluginInstance[], options?: ExtendWebpackConfigOptions): void;
103
88
  /**
104
89
  * Append Vite plugin to the config.
105
90
  */
106
- declare function addVitePlugin(plugin: Plugin, options?: ExtendViteConfigOptions): void;
91
+ declare function addVitePlugin(plugin: Plugin | Plugin[], options?: ExtendViteConfigOptions): void;
107
92
 
108
93
  /**
109
94
  * Check version constraints and return incompatibility issues as an array
@@ -136,7 +121,7 @@ declare function getNuxtVersion(nuxt?: Nuxt | any): any;
136
121
  * Requires Nuxt 2.13+
137
122
  */
138
123
  declare function addComponentsDir(dir: ComponentsDir): Promise<void>;
139
- declare type AddComponentOptions = {
124
+ type AddComponentOptions = {
140
125
  name: string;
141
126
  filePath: string;
142
127
  } & Partial<Exclude<Component, 'shortPath' | 'async' | 'level' | 'import' | 'asyncImport'>>;
@@ -148,7 +133,7 @@ declare type AddComponentOptions = {
148
133
  declare function addComponent(opts: AddComponentOptions): Promise<void>;
149
134
 
150
135
  /** Direct access to the Nuxt context - see https://github.com/unjs/unctx. */
151
- declare const nuxtCtx: unctx.UseContext<Nuxt>;
136
+ declare const nuxtCtx: unctx_index.UseContext<Nuxt>;
152
137
  /**
153
138
  * Get access to Nuxt instance.
154
139
  *
@@ -183,6 +168,15 @@ declare function isIgnored(pathname: string): boolean;
183
168
  declare function addLayout(this: any, template: NuxtTemplate, name?: string): void;
184
169
 
185
170
  declare function extendPages(cb: NuxtHooks['pages:extend']): void;
171
+ interface ExtendRouteRulesOptions {
172
+ /**
173
+ * Override route rule config
174
+ *
175
+ * @default false
176
+ */
177
+ override?: boolean;
178
+ }
179
+ declare function extendRouteRules(route: string, rule: NitroRouteConfig, options?: ExtendRouteRulesOptions): void;
186
180
 
187
181
  /**
188
182
  * Normalize a nuxt plugin object
@@ -247,18 +241,6 @@ declare function resolveFiles(path: string, pattern: string | string[], opts?: {
247
241
  followSymbolicLinks?: boolean;
248
242
  }): Promise<string[]>;
249
243
 
250
- interface LegacyServerMiddleware {
251
- route?: string;
252
- path?: string;
253
- handle?: Middleware | string;
254
- handler: Middleware | string;
255
- }
256
- /**
257
- * Adds a new server middleware to the end of the server middleware array.
258
- *
259
- * @deprecated Use addServerHandler instead
260
- */
261
- declare function addServerMiddleware(middleware: LegacyServerMiddleware): void;
262
244
  /**
263
245
  * Adds a nitro server handler
264
246
  *
@@ -269,6 +251,30 @@ declare function addServerHandler(handler: NitroEventHandler): void;
269
251
  *
270
252
  */
271
253
  declare function addDevServerHandler(handler: NitroDevEventHandler): void;
254
+ /**
255
+ * Adds a Nitro plugin
256
+ */
257
+ declare function addServerPlugin(plugin: string): void;
258
+ /**
259
+ * Adds routes to be prerendered
260
+ */
261
+ declare function addPrerenderRoutes(routes: string | string[]): void;
262
+ /**
263
+ * Access to the Nitro instance
264
+ *
265
+ * **Note:** You can call `useNitro()` only after `ready` hook.
266
+ *
267
+ * **Note:** Changes to the Nitro instance configuration are not applied.
268
+ *
269
+ * @example
270
+ *
271
+ * ```ts
272
+ * nuxt.hook('ready', () => {
273
+ * console.log(useNitro())
274
+ * })
275
+ * ```
276
+ */
277
+ declare function useNitro(): Nitro;
272
278
 
273
279
  /**
274
280
  * Renders given template using lodash template during build into the project buildDir
@@ -278,37 +284,53 @@ declare function addTemplate(_template: NuxtTemplate<any> | string): ResolvedNux
278
284
  * Normalize a nuxt template object
279
285
  */
280
286
  declare function normalizeTemplate(template: NuxtTemplate<any> | string): ResolvedNuxtTemplate<any>;
287
+ /**
288
+ * Trigger rebuilding Nuxt templates
289
+ *
290
+ * You can pass a filter within the options to selectively regenerate a subset of templates.
291
+ */
292
+ declare function updateTemplates(options?: {
293
+ filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
294
+ }): Promise<any>;
281
295
 
282
296
  declare const logger: consola.Consola;
283
297
  declare function useLogger(scope?: string): consola.Consola;
284
298
 
299
+ /** @deprecated Do not use CJS utils */
285
300
  interface ResolveModuleOptions {
286
301
  paths?: string | string[];
287
302
  }
303
+ /** @deprecated Do not use CJS utils */
288
304
  interface RequireModuleOptions extends ResolveModuleOptions {
289
305
  /** Clear the require cache (force fresh require) but only if not within `node_modules` */
290
306
  clearCache?: boolean;
291
307
  /** Automatically de-default the result of requiring the module. */
292
308
  interopDefault?: boolean;
293
309
  }
310
+ /** @deprecated Do not use CJS utils */
294
311
  declare function isNodeModules(id: string): boolean;
312
+ /** @deprecated Do not use CJS utils */
295
313
  declare function clearRequireCache(id: string): void;
314
+ /** @deprecated Do not use CJS utils */
296
315
  declare function scanRequireTree(id: string, files?: Set<string>): Set<string>;
297
- /** Access the require cache by module id. */
316
+ /** @deprecated Do not use CJS utils */
298
317
  declare function getRequireCacheItem(id: string): NodeModule | undefined;
299
318
  /** Resolve the `package.json` file for a given module. */
300
319
  declare function requireModulePkg(id: string, opts?: RequireModuleOptions): any;
301
- /** Resolve the path of a module. */
320
+ /** @deprecated Do not use CJS utils */
302
321
  declare function resolveModule(id: string, opts?: ResolveModuleOptions): string;
303
- /** Try to resolve the path of a module, but don't emit an error if it can't be found. */
322
+ /** @deprecated Do not use CJS utils */
304
323
  declare function tryResolveModule(path: string, opts?: ResolveModuleOptions): string | null;
305
- /** Require a module and return it. */
324
+ /** @deprecated Do not use CJS utils */
306
325
  declare function requireModule(id: string, opts?: RequireModuleOptions): any;
326
+ /** @deprecated Do not use CJS utils */
307
327
  declare function importModule(id: string, opts?: RequireModuleOptions): Promise<any>;
328
+ /** @deprecated Do not use CJS utils */
308
329
  declare function tryImportModule(id: string, opts?: RequireModuleOptions): Promise<any> | undefined;
309
- /** Try to require a module, but don't emit an error if the module can't be required. */
330
+ /** @deprecated Do not use CJS utils */
310
331
  declare function tryRequireModule(id: string, opts?: RequireModuleOptions): any;
311
332
 
333
+ /** @deprecated */
312
334
  declare function compileTemplate(template: NuxtTemplate, ctx: any): Promise<string>;
313
335
  /** @deprecated */
314
336
  declare const templateUtils: {
@@ -319,4 +341,4 @@ declare const templateUtils: {
319
341
  }) => string;
320
342
  };
321
343
 
322
- export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LegacyServerMiddleware, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addLayout, addPlugin, addPluginTemplate, addServerHandler, addServerMiddleware, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendPages, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, getRequireCacheItem, hasNuxtCompatibility, importModule, installModule, isIgnored, isNodeModules, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, requireModulePkg, resolveAlias, resolveFiles, resolveModule, resolvePath, scanRequireTree, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, useLogger, useModuleContainer, useNuxt };
344
+ export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendRouteRulesOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, clearRequireCache, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, getRequireCacheItem, hasNuxtCompatibility, importModule, installModule, isIgnored, isNodeModules, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, requireModulePkg, resolveAlias, resolveFiles, resolveModule, resolvePath, scanRequireTree, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };