@nuxt/kit 3.0.0-rc.12 → 3.0.0-rc.13
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.ts +17 -14
- package/dist/index.mjs +55 -40
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { Import } from 'unimport';
|
|
|
4
4
|
import { Configuration, WebpackPluginInstance } from 'webpack';
|
|
5
5
|
import { UserConfig, Plugin } from 'vite';
|
|
6
6
|
import * as unctx_index from 'unctx/index';
|
|
7
|
-
import { NodeMiddleware } from 'h3';
|
|
8
7
|
import { NitroEventHandler, NitroDevEventHandler, Nitro } from 'nitropack';
|
|
9
8
|
import * as consola from 'consola';
|
|
10
9
|
import { genSafeVariableName } from 'knitwork';
|
|
@@ -248,18 +247,6 @@ declare function resolveFiles(path: string, pattern: string | string[], opts?: {
|
|
|
248
247
|
followSymbolicLinks?: boolean;
|
|
249
248
|
}): Promise<string[]>;
|
|
250
249
|
|
|
251
|
-
interface LegacyServerMiddleware {
|
|
252
|
-
route?: string;
|
|
253
|
-
path?: string;
|
|
254
|
-
handle?: NodeMiddleware | string;
|
|
255
|
-
handler: NodeMiddleware | string;
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Adds a new server middleware to the end of the server middleware array.
|
|
259
|
-
*
|
|
260
|
-
* @deprecated Use addServerHandler instead
|
|
261
|
-
*/
|
|
262
|
-
declare function addServerMiddleware(middleware: LegacyServerMiddleware): void;
|
|
263
250
|
/**
|
|
264
251
|
* Adds a nitro server handler
|
|
265
252
|
*
|
|
@@ -270,6 +257,14 @@ declare function addServerHandler(handler: NitroEventHandler): void;
|
|
|
270
257
|
*
|
|
271
258
|
*/
|
|
272
259
|
declare function addDevServerHandler(handler: NitroDevEventHandler): void;
|
|
260
|
+
/**
|
|
261
|
+
* Adds a Nitro plugin
|
|
262
|
+
*/
|
|
263
|
+
declare function addServerPlugin(plugin: string): void;
|
|
264
|
+
/**
|
|
265
|
+
* Adds routes to be prerendered
|
|
266
|
+
*/
|
|
267
|
+
declare function addPrerenderRoutes(routes: string | string[]): void;
|
|
273
268
|
/**
|
|
274
269
|
* Access to the Nitro instance
|
|
275
270
|
*
|
|
@@ -295,6 +290,14 @@ declare function addTemplate(_template: NuxtTemplate<any> | string): ResolvedNux
|
|
|
295
290
|
* Normalize a nuxt template object
|
|
296
291
|
*/
|
|
297
292
|
declare function normalizeTemplate(template: NuxtTemplate<any> | string): ResolvedNuxtTemplate<any>;
|
|
293
|
+
/**
|
|
294
|
+
* Trigger rebuilding Nuxt templates
|
|
295
|
+
*
|
|
296
|
+
* You can pass a filter within the options to selectively regenerate a subset of templates.
|
|
297
|
+
*/
|
|
298
|
+
declare function updateTemplates(options?: {
|
|
299
|
+
filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
|
|
300
|
+
}): Promise<any>;
|
|
298
301
|
|
|
299
302
|
declare const logger: consola.Consola;
|
|
300
303
|
declare function useLogger(scope?: string): consola.Consola;
|
|
@@ -336,4 +339,4 @@ declare const templateUtils: {
|
|
|
336
339
|
}) => string;
|
|
337
340
|
};
|
|
338
341
|
|
|
339
|
-
export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions,
|
|
342
|
+
export { AddComponentOptions, AddPluginOptions, ExtendConfigOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions, LoadNuxtConfigOptions, LoadNuxtOptions, RequireModuleOptions, ResolveModuleOptions, ResolvePathOptions, Resolver, addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addServerHandler, addServerPlugin, 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, updateTemplates, useLogger, useModuleContainer, useNitro, useNuxt };
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import satisfies from 'semver/functions/satisfies.js';
|
|
|
7
7
|
import consola from 'consola';
|
|
8
8
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
9
9
|
import { globby } from 'globby';
|
|
10
|
-
import {
|
|
10
|
+
import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
|
|
11
11
|
import { interopDefault } from 'mlly';
|
|
12
12
|
import jiti from 'jiti';
|
|
13
13
|
import ignore from 'ignore';
|
|
@@ -95,6 +95,9 @@ function normalizeTemplate(template) {
|
|
|
95
95
|
}
|
|
96
96
|
return template;
|
|
97
97
|
}
|
|
98
|
+
function updateTemplates(options) {
|
|
99
|
+
return useNuxt().hooks.callHook("builder:generateApp", options);
|
|
100
|
+
}
|
|
98
101
|
|
|
99
102
|
async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
100
103
|
const issues = [];
|
|
@@ -188,30 +191,6 @@ function addLayout(template, name) {
|
|
|
188
191
|
});
|
|
189
192
|
}
|
|
190
193
|
|
|
191
|
-
function normalizeHandlerMethod(handler) {
|
|
192
|
-
const [, method = void 0] = handler.handler.match(/\.(get|head|patch|post|put|delete|connect|options|trace)(\.\w+)*$/) || [];
|
|
193
|
-
return {
|
|
194
|
-
method,
|
|
195
|
-
...handler
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function addServerMiddleware(middleware) {
|
|
199
|
-
useNuxt().options.serverMiddleware.push(middleware);
|
|
200
|
-
}
|
|
201
|
-
function addServerHandler(handler) {
|
|
202
|
-
useNuxt().options.serverHandlers.push(normalizeHandlerMethod(handler));
|
|
203
|
-
}
|
|
204
|
-
function addDevServerHandler(handler) {
|
|
205
|
-
useNuxt().options.devServerHandlers.push(handler);
|
|
206
|
-
}
|
|
207
|
-
function useNitro() {
|
|
208
|
-
const nuxt = useNuxt();
|
|
209
|
-
if (!nuxt._nitro) {
|
|
210
|
-
throw new Error("Nitro is not initialized yet. You can call `useNitro()` only after `ready` hook.");
|
|
211
|
-
}
|
|
212
|
-
return nuxt._nitro;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
194
|
const _require = jiti(process.cwd(), { interopDefault: true, esmResolve: true });
|
|
216
195
|
function isNodeModules(id) {
|
|
217
196
|
return /[/\\]node_modules[/\\]/.test(id);
|
|
@@ -331,7 +310,7 @@ async function resolvePath(path, opts = {}) {
|
|
|
331
310
|
if (isAbsolute(path) && existsSync(path) && !await isDirectory(path)) {
|
|
332
311
|
return path;
|
|
333
312
|
}
|
|
334
|
-
const nuxt =
|
|
313
|
+
const nuxt = tryUseNuxt();
|
|
335
314
|
const cwd = opts.cwd || (nuxt ? nuxt.options.rootDir : process.cwd());
|
|
336
315
|
const extensions = opts.extensions || (nuxt ? nuxt.options.extensions : [".ts", ".mjs", ".cjs", ".json"]);
|
|
337
316
|
const modulesDir = nuxt ? nuxt.options.modulesDir : [];
|
|
@@ -381,15 +360,7 @@ function resolveAlias(path, alias) {
|
|
|
381
360
|
if (!alias) {
|
|
382
361
|
alias = tryUseNuxt()?.options.alias || {};
|
|
383
362
|
}
|
|
384
|
-
|
|
385
|
-
if (key === "@" && !path.startsWith("@/")) {
|
|
386
|
-
continue;
|
|
387
|
-
}
|
|
388
|
-
if (path.startsWith(key)) {
|
|
389
|
-
path = alias[key] + path.slice(key.length);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
return path;
|
|
363
|
+
return resolveAlias$1(path, alias);
|
|
393
364
|
}
|
|
394
365
|
function createResolver(base) {
|
|
395
366
|
if (!base) {
|
|
@@ -519,7 +490,8 @@ function useModuleContainer(nuxt = useNuxt()) {
|
|
|
519
490
|
},
|
|
520
491
|
requireModule,
|
|
521
492
|
addModule: requireModule,
|
|
522
|
-
addServerMiddleware
|
|
493
|
+
addServerMiddleware: () => {
|
|
494
|
+
},
|
|
523
495
|
addTemplate(template) {
|
|
524
496
|
if (typeof template === "string") {
|
|
525
497
|
template = { src: template };
|
|
@@ -708,9 +680,10 @@ async function loadNuxtConfig(opts) {
|
|
|
708
680
|
layer.config.rootDir = layer.config.rootDir ?? layer.cwd;
|
|
709
681
|
layer.config.srcDir = resolve(layer.config.rootDir, layer.config.srcDir);
|
|
710
682
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
683
|
+
const _layers = layers.filter((layer) => layer.configFile && !layer.configFile.endsWith(".nuxtrc"));
|
|
684
|
+
nuxtConfig._layers = _layers;
|
|
685
|
+
if (!_layers.length) {
|
|
686
|
+
_layers.push({
|
|
714
687
|
cwd,
|
|
715
688
|
config: {
|
|
716
689
|
rootDir: cwd,
|
|
@@ -901,4 +874,46 @@ function extendPages(cb) {
|
|
|
901
874
|
}
|
|
902
875
|
}
|
|
903
876
|
|
|
904
|
-
|
|
877
|
+
function normalizeHandlerMethod(handler) {
|
|
878
|
+
const [, method = void 0] = handler.handler.match(/\.(get|head|patch|post|put|delete|connect|options|trace)(\.\w+)*$/) || [];
|
|
879
|
+
return {
|
|
880
|
+
method,
|
|
881
|
+
...handler,
|
|
882
|
+
handler: normalize(handler.handler)
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
function addServerHandler(handler) {
|
|
886
|
+
useNuxt().options.serverHandlers.push(normalizeHandlerMethod(handler));
|
|
887
|
+
}
|
|
888
|
+
function addDevServerHandler(handler) {
|
|
889
|
+
useNuxt().options.devServerHandlers.push(handler);
|
|
890
|
+
}
|
|
891
|
+
function addServerPlugin(plugin) {
|
|
892
|
+
const nuxt = useNuxt();
|
|
893
|
+
nuxt.options.nitro.plugins = nuxt.options.nitro.plugins || [];
|
|
894
|
+
nuxt.options.nitro.plugins.push(normalize(plugin));
|
|
895
|
+
}
|
|
896
|
+
function addPrerenderRoutes(routes) {
|
|
897
|
+
const nuxt = useNuxt();
|
|
898
|
+
if (!Array.isArray(routes)) {
|
|
899
|
+
routes = [routes];
|
|
900
|
+
}
|
|
901
|
+
routes = routes.filter(Boolean);
|
|
902
|
+
if (!routes.length) {
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
nuxt.hook("prerender:routes", (ctx) => {
|
|
906
|
+
for (const route of routes) {
|
|
907
|
+
ctx.routes.add(route);
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
function useNitro() {
|
|
912
|
+
const nuxt = useNuxt();
|
|
913
|
+
if (!nuxt._nitro) {
|
|
914
|
+
throw new Error("Nitro is not initialized yet. You can call `useNitro()` only after `ready` hook.");
|
|
915
|
+
}
|
|
916
|
+
return nuxt._nitro;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
export { addAutoImport, addAutoImportDir, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addServerHandler, addServerPlugin, 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, updateTemplates, useLogger, useModuleContainer, useNitro, useNuxt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/kit",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.13",
|
|
4
4
|
"repository": "nuxt/framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nuxt/schema": "3.0.0-rc.
|
|
13
|
+
"@nuxt/schema": "3.0.0-rc.13",
|
|
14
14
|
"c12": "^0.2.13",
|
|
15
15
|
"consola": "^2.15.3",
|
|
16
16
|
"defu": "^6.1.0",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"lodash.template": "^4.5.0",
|
|
23
23
|
"mlly": "^0.5.16",
|
|
24
24
|
"pathe": "^0.3.9",
|
|
25
|
-
"pkg-types": "^0.3.
|
|
25
|
+
"pkg-types": "^0.3.6",
|
|
26
26
|
"scule": "^0.3.2",
|
|
27
27
|
"semver": "^7.3.8",
|
|
28
28
|
"unctx": "^2.0.2",
|
|
29
|
-
"unimport": "^0.
|
|
29
|
+
"unimport": "^0.7.0",
|
|
30
30
|
"untyped": "^0.5.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"unbuild": "latest"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
|
-
"node": "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0"
|
|
38
|
+
"node": "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {}
|
|
41
41
|
}
|