@nuxt/kit 3.12.3 → 3.13.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/README.md +3 -3
- package/dist/index.d.mts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.mjs +32 -18
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ It provides a number of features that make it easy to build fast, SEO-friendly,
|
|
|
34
34
|
- 🏠 [Local Development](#local-development)
|
|
35
35
|
- ⛰️ [Nuxt 2](#nuxt-2)
|
|
36
36
|
- 🛟 [Professional Support](#professional-support)
|
|
37
|
-
- 🔗 [Follow
|
|
37
|
+
- 🔗 [Follow Us](#follow-us)
|
|
38
38
|
- ⚖️ [License](#license)
|
|
39
39
|
|
|
40
40
|
---
|
|
@@ -106,10 +106,10 @@ Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/
|
|
|
106
106
|
- Technical audit & consulting: [Nuxt Experts](https://nuxt.com/enterprise/support)
|
|
107
107
|
- Custom development & more: [Nuxt Agencies Partners](https://nuxt.com/enterprise/agencies)
|
|
108
108
|
|
|
109
|
-
## <a name="follow-us">🔗 Follow
|
|
109
|
+
## <a name="follow-us">🔗 Follow Us</a>
|
|
110
110
|
|
|
111
111
|
<p valign="center">
|
|
112
|
-
<a href="https://
|
|
112
|
+
<a href="https://go.nuxt.com/discord"><img width="20px" src="https://github.com/nuxt/nuxt/tree/main/.github/assets/discord.svg" alt="Discord"></a> <a href="https://go.nuxt.com/x"><img width="20px" src="https://github.com/nuxt/nuxt/tree/main/.github/assets/twitter.svg" alt="Twitter"></a> <a href="https://go.nuxt.com/github"><img width="20px" src="https://github.com/nuxt/nuxt/tree/main/.github/assets/github.svg" alt="GitHub"></a>
|
|
113
113
|
</p>
|
|
114
114
|
|
|
115
115
|
## <a name="license">⚖️ License</a>
|
package/dist/index.d.mts
CHANGED
|
@@ -13,7 +13,10 @@ import { genSafeVariableName } from 'knitwork';
|
|
|
13
13
|
* Define a Nuxt module, automatically merging defaults with user provided options, installing
|
|
14
14
|
* any hooks that are provided, and calling an optional setup function for full control.
|
|
15
15
|
*/
|
|
16
|
-
declare function defineNuxtModule<
|
|
16
|
+
declare function defineNuxtModule<TOptions extends ModuleOptions>(definition: ModuleDefinition<TOptions, Partial<TOptions>, false> | NuxtModule<TOptions, Partial<TOptions>, false>): NuxtModule<TOptions, TOptions, false>;
|
|
17
|
+
declare function defineNuxtModule<TOptions extends ModuleOptions>(): {
|
|
18
|
+
with: <TOptionsDefaults extends Partial<TOptions>>(definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true>) => NuxtModule<TOptions, TOptionsDefaults, true>;
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
/** Installs a module on a Nuxt instance. */
|
|
19
22
|
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>;
|
|
@@ -148,17 +151,17 @@ declare function assertNuxtCompatibility(constraints: NuxtCompatibility, nuxt?:
|
|
|
148
151
|
*/
|
|
149
152
|
declare function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean>;
|
|
150
153
|
/**
|
|
151
|
-
*
|
|
154
|
+
* @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
|
|
152
155
|
*/
|
|
153
156
|
declare function isNuxt2(nuxt?: Nuxt): boolean;
|
|
154
157
|
/**
|
|
155
|
-
*
|
|
158
|
+
* @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
|
|
156
159
|
*/
|
|
157
160
|
declare function isNuxt3(nuxt?: Nuxt): boolean;
|
|
158
161
|
/**
|
|
159
162
|
* Get nuxt version
|
|
160
163
|
*/
|
|
161
|
-
declare function getNuxtVersion(nuxt?: Nuxt | any):
|
|
164
|
+
declare function getNuxtVersion(nuxt?: Nuxt | any): string;
|
|
162
165
|
|
|
163
166
|
/**
|
|
164
167
|
* Register a directory to be scanned for components and imported only when used.
|
|
@@ -228,6 +231,11 @@ interface AddRouteMiddlewareOptions {
|
|
|
228
231
|
* @default false
|
|
229
232
|
*/
|
|
230
233
|
override?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Prepend middleware to the list
|
|
236
|
+
* @default false
|
|
237
|
+
*/
|
|
238
|
+
prepend?: boolean;
|
|
231
239
|
}
|
|
232
240
|
declare function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void;
|
|
233
241
|
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,10 @@ import { genSafeVariableName } from 'knitwork';
|
|
|
13
13
|
* Define a Nuxt module, automatically merging defaults with user provided options, installing
|
|
14
14
|
* any hooks that are provided, and calling an optional setup function for full control.
|
|
15
15
|
*/
|
|
16
|
-
declare function defineNuxtModule<
|
|
16
|
+
declare function defineNuxtModule<TOptions extends ModuleOptions>(definition: ModuleDefinition<TOptions, Partial<TOptions>, false> | NuxtModule<TOptions, Partial<TOptions>, false>): NuxtModule<TOptions, TOptions, false>;
|
|
17
|
+
declare function defineNuxtModule<TOptions extends ModuleOptions>(): {
|
|
18
|
+
with: <TOptionsDefaults extends Partial<TOptions>>(definition: ModuleDefinition<TOptions, TOptionsDefaults, true> | NuxtModule<TOptions, TOptionsDefaults, true>) => NuxtModule<TOptions, TOptionsDefaults, true>;
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
/** Installs a module on a Nuxt instance. */
|
|
19
22
|
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>;
|
|
@@ -148,17 +151,17 @@ declare function assertNuxtCompatibility(constraints: NuxtCompatibility, nuxt?:
|
|
|
148
151
|
*/
|
|
149
152
|
declare function hasNuxtCompatibility(constraints: NuxtCompatibility, nuxt?: Nuxt): Promise<boolean>;
|
|
150
153
|
/**
|
|
151
|
-
*
|
|
154
|
+
* @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
|
|
152
155
|
*/
|
|
153
156
|
declare function isNuxt2(nuxt?: Nuxt): boolean;
|
|
154
157
|
/**
|
|
155
|
-
*
|
|
158
|
+
* @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
|
|
156
159
|
*/
|
|
157
160
|
declare function isNuxt3(nuxt?: Nuxt): boolean;
|
|
158
161
|
/**
|
|
159
162
|
* Get nuxt version
|
|
160
163
|
*/
|
|
161
|
-
declare function getNuxtVersion(nuxt?: Nuxt | any):
|
|
164
|
+
declare function getNuxtVersion(nuxt?: Nuxt | any): string;
|
|
162
165
|
|
|
163
166
|
/**
|
|
164
167
|
* Register a directory to be scanned for components and imported only when used.
|
|
@@ -228,6 +231,11 @@ interface AddRouteMiddlewareOptions {
|
|
|
228
231
|
* @default false
|
|
229
232
|
*/
|
|
230
233
|
override?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Prepend middleware to the list
|
|
236
|
+
* @default false
|
|
237
|
+
*/
|
|
238
|
+
prepend?: boolean;
|
|
231
239
|
}
|
|
232
240
|
declare function addRouteMiddleware(input: NuxtMiddleware | NuxtMiddleware[], options?: AddRouteMiddlewareOptions): void;
|
|
233
241
|
|
package/dist/index.mjs
CHANGED
|
@@ -109,18 +109,20 @@ async function hasNuxtCompatibility(constraints, nuxt = useNuxt()) {
|
|
|
109
109
|
const issues = await checkNuxtCompatibility(constraints, nuxt);
|
|
110
110
|
return !issues.length;
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function isNuxtMajorVersion(majorVersion, nuxt = useNuxt()) {
|
|
113
113
|
const version = getNuxtVersion(nuxt);
|
|
114
|
-
return version[0] ===
|
|
114
|
+
return version[0] === majorVersion.toString() && version[1] === ".";
|
|
115
|
+
}
|
|
116
|
+
function isNuxt2(nuxt = useNuxt()) {
|
|
117
|
+
return isNuxtMajorVersion(2, nuxt);
|
|
115
118
|
}
|
|
116
119
|
function isNuxt3(nuxt = useNuxt()) {
|
|
117
|
-
|
|
118
|
-
return version[0] === "3" && version[1] === ".";
|
|
120
|
+
return isNuxtMajorVersion(3, nuxt);
|
|
119
121
|
}
|
|
120
122
|
function getNuxtVersion(nuxt = useNuxt()) {
|
|
121
123
|
const rawVersion = nuxt?._version || nuxt?.version || nuxt?.constructor?.version;
|
|
122
|
-
if (
|
|
123
|
-
throw new
|
|
124
|
+
if (typeof rawVersion !== "string") {
|
|
125
|
+
throw new TypeError("Cannot determine nuxt version! Is current instance passed?");
|
|
124
126
|
}
|
|
125
127
|
return rawVersion.replace(/^v/g, "");
|
|
126
128
|
}
|
|
@@ -2081,21 +2083,29 @@ const importName = genSafeVariableName;
|
|
|
2081
2083
|
const templateUtils = { serialize, importName, importSources };
|
|
2082
2084
|
|
|
2083
2085
|
function defineNuxtModule(definition) {
|
|
2086
|
+
if (definition) {
|
|
2087
|
+
return _defineNuxtModule(definition);
|
|
2088
|
+
}
|
|
2089
|
+
return {
|
|
2090
|
+
with: (definition2) => _defineNuxtModule(definition2)
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
function _defineNuxtModule(definition) {
|
|
2094
|
+
var _a;
|
|
2084
2095
|
if (typeof definition === "function") {
|
|
2085
|
-
return
|
|
2096
|
+
return _defineNuxtModule({ setup: definition });
|
|
2086
2097
|
}
|
|
2087
2098
|
const module = defu(definition, { meta: {} });
|
|
2088
|
-
|
|
2089
|
-
module.meta.configKey = module.meta.name;
|
|
2090
|
-
}
|
|
2099
|
+
(_a = module.meta).configKey || (_a.configKey = module.meta.name);
|
|
2091
2100
|
async function getOptions(inlineOptions, nuxt = useNuxt()) {
|
|
2092
|
-
const
|
|
2093
|
-
const
|
|
2094
|
-
|
|
2101
|
+
const nuxtConfigOptionsKey = module.meta.configKey || module.meta.name;
|
|
2102
|
+
const nuxtConfigOptions = nuxtConfigOptionsKey && nuxtConfigOptionsKey in nuxt.options ? nuxt.options[nuxtConfigOptionsKey] : {};
|
|
2103
|
+
const optionsDefaults = module.defaults instanceof Function ? module.defaults(nuxt) : module.defaults ?? {};
|
|
2104
|
+
let options = defu(inlineOptions, nuxtConfigOptions, optionsDefaults);
|
|
2095
2105
|
if (module.schema) {
|
|
2096
|
-
|
|
2106
|
+
options = await applyDefaults(module.schema, options);
|
|
2097
2107
|
}
|
|
2098
|
-
return Promise.resolve(
|
|
2108
|
+
return Promise.resolve(options);
|
|
2099
2109
|
}
|
|
2100
2110
|
async function normalizedModule(inlineOptions, nuxt) {
|
|
2101
2111
|
if (!nuxt) {
|
|
@@ -2209,7 +2219,7 @@ function clearRequireCache(id) {
|
|
|
2209
2219
|
function getRequireCacheItem(id) {
|
|
2210
2220
|
try {
|
|
2211
2221
|
return _require.cache[id];
|
|
2212
|
-
} catch
|
|
2222
|
+
} catch {
|
|
2213
2223
|
}
|
|
2214
2224
|
}
|
|
2215
2225
|
function getNodeModulesPaths(paths) {
|
|
@@ -2490,7 +2500,7 @@ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
|
|
|
2490
2500
|
function getDirectory(p) {
|
|
2491
2501
|
try {
|
|
2492
2502
|
return isAbsolute(p) && lstatSync(p).isFile() ? dirname(p) : p;
|
|
2493
|
-
} catch
|
|
2503
|
+
} catch {
|
|
2494
2504
|
}
|
|
2495
2505
|
return p;
|
|
2496
2506
|
}
|
|
@@ -2569,7 +2579,7 @@ async function getNuxtModuleVersion(module, nuxt = useNuxt()) {
|
|
|
2569
2579
|
return false;
|
|
2570
2580
|
}
|
|
2571
2581
|
|
|
2572
|
-
const layerSchemaKeys = ["future", "srcDir", "rootDir", "dir"];
|
|
2582
|
+
const layerSchemaKeys = ["future", "srcDir", "rootDir", "serverDir", "dir"];
|
|
2573
2583
|
const layerSchema = /* @__PURE__ */ Object.create(null);
|
|
2574
2584
|
for (const key of layerSchemaKeys) {
|
|
2575
2585
|
if (key in NuxtConfigSchema) {
|
|
@@ -3034,6 +3044,8 @@ async function _generateTypes(nuxt) {
|
|
|
3034
3044
|
const relative2 = relativeWithDot(nuxt.options.buildDir, path);
|
|
3035
3045
|
include.add(join(relative2, "runtime"));
|
|
3036
3046
|
exclude.add(join(relative2, "runtime/server"));
|
|
3047
|
+
include.add(join(relative2, "dist/runtime"));
|
|
3048
|
+
exclude.add(join(relative2, "dist/runtime/server"));
|
|
3037
3049
|
}
|
|
3038
3050
|
const isV4 = nuxt.options.future?.compatibilityVersion === 4;
|
|
3039
3051
|
const hasTypescriptVersionWithModulePreserve = await readPackageJSON("typescript", { url: nuxt.options.modulesDir }).then((r) => r?.version && gte(r.version, "5.4.0")).catch(() => isV4);
|
|
@@ -3254,6 +3266,8 @@ function addRouteMiddleware(input, options = {}) {
|
|
|
3254
3266
|
} else {
|
|
3255
3267
|
logger.warn(`'${middleware.name}' middleware already exists at '${foundPath}'. You can set \`override: true\` to replace it.`);
|
|
3256
3268
|
}
|
|
3269
|
+
} else if (options.prepend === true) {
|
|
3270
|
+
app.middleware.unshift({ ...middleware });
|
|
3257
3271
|
} else {
|
|
3258
3272
|
app.middleware.push({ ...middleware });
|
|
3259
3273
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/kit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -29,20 +29,20 @@
|
|
|
29
29
|
"destr": "^2.0.3",
|
|
30
30
|
"globby": "^14.0.2",
|
|
31
31
|
"hash-sum": "^2.0.0",
|
|
32
|
-
"ignore": "^5.3.
|
|
32
|
+
"ignore": "^5.3.2",
|
|
33
33
|
"jiti": "^1.21.6",
|
|
34
34
|
"klona": "^2.0.6",
|
|
35
35
|
"knitwork": "^1.1.0",
|
|
36
36
|
"mlly": "^1.7.1",
|
|
37
37
|
"pathe": "^1.1.2",
|
|
38
|
-
"pkg-types": "^1.1.
|
|
38
|
+
"pkg-types": "^1.1.3",
|
|
39
39
|
"scule": "^1.3.0",
|
|
40
|
-
"semver": "^7.6.
|
|
41
|
-
"ufo": "^1.5.
|
|
40
|
+
"semver": "^7.6.3",
|
|
41
|
+
"ufo": "^1.5.4",
|
|
42
42
|
"unctx": "^2.3.1",
|
|
43
|
-
"unimport": "^3.
|
|
43
|
+
"unimport": "^3.11.0",
|
|
44
44
|
"untyped": "^1.4.2",
|
|
45
|
-
"@nuxt/schema": "3.
|
|
45
|
+
"@nuxt/schema": "3.13.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/hash-sum": "1.0.2",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"lodash-es": "4.17.21",
|
|
52
52
|
"nitropack": "2.9.7",
|
|
53
53
|
"unbuild": "latest",
|
|
54
|
-
"vite": "5.
|
|
55
|
-
"vitest": "
|
|
56
|
-
"webpack": "5.
|
|
54
|
+
"vite": "5.4.2",
|
|
55
|
+
"vitest": "2.0.5",
|
|
56
|
+
"webpack": "5.94.0"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": "^14.18.0 || >=16.10.0"
|