nuxtseo-shared 5.3.6 → 5.3.8
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/devtools.mjs +4 -1
- package/dist/i18n.mjs +11 -2
- package/dist/kit.d.mts +25 -2
- package/dist/kit.d.ts +25 -2
- package/dist/kit.mjs +152 -2
- package/dist/module.json +2 -2
- package/dist/server.d.mts +18 -4
- package/dist/server.d.ts +18 -4
- package/dist/server.mjs +9 -3
- package/package.json +13 -11
package/dist/devtools.mjs
CHANGED
|
@@ -141,7 +141,10 @@ function toolchainInstalled(rootDir) {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
async function devAddArgs(rootDir) {
|
|
144
|
-
const pm = await detectPackageManager(rootDir).catch(() =>
|
|
144
|
+
const pm = await detectPackageManager(rootDir).catch((error) => {
|
|
145
|
+
console.warn(`[nuxt-seo] could not detect the package manager in "${rootDir}", falling back to npm:`, error);
|
|
146
|
+
return null;
|
|
147
|
+
});
|
|
145
148
|
const name = pm?.name ?? "npm";
|
|
146
149
|
if (name === "npm")
|
|
147
150
|
return { command: "npm", args: ["install", "--save-dev", TOOLCHAIN_PACKAGE] };
|
package/dist/i18n.mjs
CHANGED
|
@@ -112,6 +112,14 @@ function resolveI18nModule() {
|
|
|
112
112
|
isMicro: found === "nuxt-i18n-micro"
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
+
function resolveI18nPages(config, isMicro) {
|
|
116
|
+
const routes = isMicro ? config.globalLocaleRoutes : config.pages;
|
|
117
|
+
if (!routes)
|
|
118
|
+
return void 0;
|
|
119
|
+
return Object.fromEntries(
|
|
120
|
+
Object.entries(routes).filter((entry) => typeof entry[1] === "object" && entry[1] !== null && !Array.isArray(entry[1]))
|
|
121
|
+
);
|
|
122
|
+
}
|
|
115
123
|
async function resolveI18nConfig(logger) {
|
|
116
124
|
const i18n = resolveI18nModule();
|
|
117
125
|
if (!i18n)
|
|
@@ -124,7 +132,8 @@ async function resolveI18nConfig(logger) {
|
|
|
124
132
|
}
|
|
125
133
|
const nuxtI18nConfig = await getNuxtModuleOptions(i18n.module) || {};
|
|
126
134
|
const normalisedLocales = normalizeLocales(nuxtI18nConfig);
|
|
127
|
-
const
|
|
135
|
+
const pages = resolveI18nPages(nuxtI18nConfig, i18n.isMicro);
|
|
136
|
+
const usingI18nPages = Object.keys(pages || {}).length;
|
|
128
137
|
const hasI18nConfigForAlternatives = nuxtI18nConfig.differentDomains || usingI18nPages || nuxtI18nConfig.strategy !== "no_prefix" && nuxtI18nConfig.locales;
|
|
129
138
|
if (!hasI18nConfigForAlternatives)
|
|
130
139
|
return false;
|
|
@@ -133,7 +142,7 @@ async function resolveI18nConfig(logger) {
|
|
|
133
142
|
defaultLocale: nuxtI18nConfig.defaultLocale,
|
|
134
143
|
locales: normalisedLocales,
|
|
135
144
|
strategy: nuxtI18nConfig.strategy,
|
|
136
|
-
pages
|
|
145
|
+
pages
|
|
137
146
|
};
|
|
138
147
|
}
|
|
139
148
|
function mergeOnKey(arr, key) {
|
package/dist/kit.d.mts
CHANGED
|
@@ -4,6 +4,29 @@ import { NitroConfig } from 'nitropack/types';
|
|
|
4
4
|
import { NuxtPage, NuxtModule } from 'nuxt/schema';
|
|
5
5
|
import { useLogger } from '@nuxt/kit';
|
|
6
6
|
|
|
7
|
+
type NitroRuntimeCompatibility = {
|
|
8
|
+
_tag: 'nitro-v2';
|
|
9
|
+
eventContextModule: 'h3';
|
|
10
|
+
eventContextType: 'H3EventContext';
|
|
11
|
+
eventType: `import('h3').H3Event`;
|
|
12
|
+
nitroTypesModule: 'nitropack';
|
|
13
|
+
} | {
|
|
14
|
+
_tag: 'nitro-v3';
|
|
15
|
+
eventContextModule: 'srvx';
|
|
16
|
+
eventContextType: 'ServerRequestContext';
|
|
17
|
+
eventType: `import('nitro/h3').H3Event`;
|
|
18
|
+
nitroTypesModule: 'nitro/types';
|
|
19
|
+
};
|
|
20
|
+
interface NitroTypeAugmentations {
|
|
21
|
+
eventContext?: string;
|
|
22
|
+
nitroInterfaces?: Record<string, string>;
|
|
23
|
+
routeConfig?: string;
|
|
24
|
+
routeRules?: string;
|
|
25
|
+
runtimeHooks?: string;
|
|
26
|
+
}
|
|
27
|
+
declare function renderNitroTypeAugmentations(compatibility: NitroRuntimeCompatibility, augmentations: NitroTypeAugmentations): string;
|
|
28
|
+
declare function setupNitroRuntimeCompatibility(nuxt?: Nuxt): NitroRuntimeCompatibility;
|
|
29
|
+
|
|
7
30
|
interface NuxtSeoModuleDetection {
|
|
8
31
|
name: string;
|
|
9
32
|
version?: string;
|
|
@@ -75,5 +98,5 @@ type UnheadMajor = 2 | 3;
|
|
|
75
98
|
*/
|
|
76
99
|
declare function resolveHostUnheadMajor(rootDir: string): Promise<UnheadMajor>;
|
|
77
100
|
|
|
78
|
-
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, useModuleLogger };
|
|
79
|
-
export type { NuxtContentVersion, NuxtSeoModuleDetection, UnheadMajor };
|
|
101
|
+
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, renderNitroTypeAugmentations, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, setupNitroRuntimeCompatibility, useModuleLogger };
|
|
102
|
+
export type { NitroRuntimeCompatibility, NitroTypeAugmentations, NuxtContentVersion, NuxtSeoModuleDetection, UnheadMajor };
|
package/dist/kit.d.ts
CHANGED
|
@@ -4,6 +4,29 @@ import { NitroConfig } from 'nitropack/types';
|
|
|
4
4
|
import { NuxtPage, NuxtModule } from 'nuxt/schema';
|
|
5
5
|
import { useLogger } from '@nuxt/kit';
|
|
6
6
|
|
|
7
|
+
type NitroRuntimeCompatibility = {
|
|
8
|
+
_tag: 'nitro-v2';
|
|
9
|
+
eventContextModule: 'h3';
|
|
10
|
+
eventContextType: 'H3EventContext';
|
|
11
|
+
eventType: `import('h3').H3Event`;
|
|
12
|
+
nitroTypesModule: 'nitropack';
|
|
13
|
+
} | {
|
|
14
|
+
_tag: 'nitro-v3';
|
|
15
|
+
eventContextModule: 'srvx';
|
|
16
|
+
eventContextType: 'ServerRequestContext';
|
|
17
|
+
eventType: `import('nitro/h3').H3Event`;
|
|
18
|
+
nitroTypesModule: 'nitro/types';
|
|
19
|
+
};
|
|
20
|
+
interface NitroTypeAugmentations {
|
|
21
|
+
eventContext?: string;
|
|
22
|
+
nitroInterfaces?: Record<string, string>;
|
|
23
|
+
routeConfig?: string;
|
|
24
|
+
routeRules?: string;
|
|
25
|
+
runtimeHooks?: string;
|
|
26
|
+
}
|
|
27
|
+
declare function renderNitroTypeAugmentations(compatibility: NitroRuntimeCompatibility, augmentations: NitroTypeAugmentations): string;
|
|
28
|
+
declare function setupNitroRuntimeCompatibility(nuxt?: Nuxt): NitroRuntimeCompatibility;
|
|
29
|
+
|
|
7
30
|
interface NuxtSeoModuleDetection {
|
|
8
31
|
name: string;
|
|
9
32
|
version?: string;
|
|
@@ -75,5 +98,5 @@ type UnheadMajor = 2 | 3;
|
|
|
75
98
|
*/
|
|
76
99
|
declare function resolveHostUnheadMajor(rootDir: string): Promise<UnheadMajor>;
|
|
77
100
|
|
|
78
|
-
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, useModuleLogger };
|
|
79
|
-
export type { NuxtContentVersion, NuxtSeoModuleDetection, UnheadMajor };
|
|
101
|
+
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, renderNitroTypeAugmentations, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, setupNitroRuntimeCompatibility, useModuleLogger };
|
|
102
|
+
export type { NitroRuntimeCompatibility, NitroTypeAugmentations, NuxtContentVersion, NuxtSeoModuleDetection, UnheadMajor };
|
package/dist/kit.mjs
CHANGED
|
@@ -1,9 +1,159 @@
|
|
|
1
1
|
import { pathToFileURL } from 'node:url';
|
|
2
|
-
import { useNuxt, createResolver, addTemplate, loadNuxtModuleInstance, tryUseNuxt, hasNuxtModule, hasNuxtModuleCompatibility, useLogger } from '@nuxt/kit';
|
|
2
|
+
import { getNuxtVersion, addTypeTemplate, useNuxt, createResolver, addTemplate, loadNuxtModuleInstance, tryUseNuxt, hasNuxtModule, hasNuxtModuleCompatibility, useLogger } from '@nuxt/kit';
|
|
3
3
|
import { relative, dirname } from 'pathe';
|
|
4
4
|
import { resolvePackageJSON, readPackageJSON } from 'pkg-types';
|
|
5
5
|
import { provider, env } from 'std-env';
|
|
6
6
|
|
|
7
|
+
const NITRO_RUNTIME_MODULE = "#nuxtseo/nitro";
|
|
8
|
+
const H3_RUNTIME_MODULE = "#nuxtseo/h3";
|
|
9
|
+
const TYPE_TEMPLATE_FILENAME = "types/nuxtseo-nitro.d.ts";
|
|
10
|
+
const legacySetupMarker = Symbol.for("nuxtseo:nitro-runtime-compatibility");
|
|
11
|
+
const typeSetupMarker = Symbol.for("nuxtseo:nitro-runtime-compatibility:request-context-types");
|
|
12
|
+
const runtimeSetupMarker = Symbol.for("nuxtseo:nitro-runtime-compatibility:request-context");
|
|
13
|
+
const nitroV2Compatibility = {
|
|
14
|
+
_tag: "nitro-v2",
|
|
15
|
+
eventContextModule: "h3",
|
|
16
|
+
eventContextType: "H3EventContext",
|
|
17
|
+
eventType: `import('h3').H3Event`,
|
|
18
|
+
nitroTypesModule: "nitropack"
|
|
19
|
+
};
|
|
20
|
+
const nitroV3Compatibility = {
|
|
21
|
+
_tag: "nitro-v3",
|
|
22
|
+
eventContextModule: "srvx",
|
|
23
|
+
eventContextType: "ServerRequestContext",
|
|
24
|
+
eventType: `import('nitro/h3').H3Event`,
|
|
25
|
+
nitroTypesModule: "nitro/types"
|
|
26
|
+
};
|
|
27
|
+
const nitroV2Runtime = `export {
|
|
28
|
+
defineNitroPlugin,
|
|
29
|
+
useNitroApp,
|
|
30
|
+
useEvent,
|
|
31
|
+
useRuntimeConfig,
|
|
32
|
+
defineCachedFunction,
|
|
33
|
+
defineCachedEventHandler,
|
|
34
|
+
useStorage,
|
|
35
|
+
defineTask,
|
|
36
|
+
runTask,
|
|
37
|
+
} from 'nitropack/runtime'
|
|
38
|
+
export function fetchWithEvent(event, request, options) {
|
|
39
|
+
return event.$fetch(request, options)
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
const nitroV2RuntimeTypes = `export {
|
|
43
|
+
defineNitroPlugin,
|
|
44
|
+
useNitroApp,
|
|
45
|
+
useEvent,
|
|
46
|
+
useRuntimeConfig,
|
|
47
|
+
defineCachedFunction,
|
|
48
|
+
defineCachedEventHandler,
|
|
49
|
+
useStorage,
|
|
50
|
+
defineTask,
|
|
51
|
+
runTask,
|
|
52
|
+
} from 'nitropack/runtime'
|
|
53
|
+
export function fetchWithEvent<T>(event: import('h3').H3Event, request: import('ofetch').FetchRequest, options?: import('ofetch').FetchOptions): Promise<T>
|
|
54
|
+
`;
|
|
55
|
+
const nitroV3Runtime = `import { createFetch } from 'ofetch'
|
|
56
|
+
import { fetchWithEvent as fetchRawWithEvent } from 'nitro/h3'
|
|
57
|
+
export { definePlugin as defineNitroPlugin } from 'nitro'
|
|
58
|
+
export { useNitroApp } from 'nitro/app'
|
|
59
|
+
export { useRequest as useEvent } from 'nitro/context'
|
|
60
|
+
import { useRuntimeConfig as _useRuntimeConfig } from 'nitro/runtime-config'
|
|
61
|
+
export function useRuntimeConfig(_event) { return _useRuntimeConfig() }
|
|
62
|
+
export { defineCachedFunction, defineCachedHandler as defineCachedEventHandler } from 'nitro/cache'
|
|
63
|
+
export { useStorage } from 'nitro/storage'
|
|
64
|
+
export { defineTask, runTask } from 'nitro/task'
|
|
65
|
+
export function fetchWithEvent(event, request, options) {
|
|
66
|
+
const localFetch = createFetch({
|
|
67
|
+
fetch: (input, init) => fetchRawWithEvent(event, input, init),
|
|
68
|
+
})
|
|
69
|
+
return localFetch(request, options)
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
const nitroV3RuntimeTypes = `export { definePlugin as defineNitroPlugin } from 'nitro'
|
|
73
|
+
export { useNitroApp } from 'nitro/app'
|
|
74
|
+
export { useRequest as useEvent } from 'nitro/context'
|
|
75
|
+
export function useRuntimeConfig(event?: import('nitro/h3').H3Event): ReturnType<typeof import('nitro/runtime-config').useRuntimeConfig>
|
|
76
|
+
export { defineCachedFunction, defineCachedHandler as defineCachedEventHandler } from 'nitro/cache'
|
|
77
|
+
export { useStorage } from 'nitro/storage'
|
|
78
|
+
export { defineTask, runTask } from 'nitro/task'
|
|
79
|
+
export function fetchWithEvent<T>(event: import('nitro/h3').H3Event, request: import('ofetch').FetchRequest, options?: import('ofetch').FetchOptions): Promise<T>
|
|
80
|
+
`;
|
|
81
|
+
function indent(value, spaces) {
|
|
82
|
+
const padding = " ".repeat(spaces);
|
|
83
|
+
return value.split("\n").map((line) => `${padding}${line}`).join("\n");
|
|
84
|
+
}
|
|
85
|
+
function renderInterface(name, contents) {
|
|
86
|
+
if (!contents?.trim())
|
|
87
|
+
return void 0;
|
|
88
|
+
return ` interface ${name} {
|
|
89
|
+
${indent(contents.trim(), 4)}
|
|
90
|
+
}`;
|
|
91
|
+
}
|
|
92
|
+
function renderRuntimeDeclarations(compatibility) {
|
|
93
|
+
const nitroRuntime = compatibility._tag === "nitro-v3" ? nitroV3RuntimeTypes : nitroV2RuntimeTypes;
|
|
94
|
+
const h3Runtime = compatibility._tag === "nitro-v3" ? `export * from 'nitro/h3'
|
|
95
|
+
` : `export * from 'h3'
|
|
96
|
+
`;
|
|
97
|
+
return `declare module '${NITRO_RUNTIME_MODULE}' {
|
|
98
|
+
${indent(nitroRuntime.trim(), 2)}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
declare module '${H3_RUNTIME_MODULE}' {
|
|
102
|
+
${indent(h3Runtime.trim(), 2)}
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
function applyNitroRuntimeCompatibility(nuxt, compatibility) {
|
|
107
|
+
const nuxtOptions = nuxt.options;
|
|
108
|
+
const nitroOptions = nuxtOptions.nitro ||= {};
|
|
109
|
+
nitroOptions.alias ||= {};
|
|
110
|
+
nitroOptions.virtual ||= {};
|
|
111
|
+
nitroOptions.alias[H3_RUNTIME_MODULE] = compatibility._tag === "nitro-v3" ? "nitro/h3" : "h3";
|
|
112
|
+
nitroOptions.virtual[NITRO_RUNTIME_MODULE] = compatibility._tag === "nitro-v3" ? nitroV3Runtime : nitroV2Runtime;
|
|
113
|
+
}
|
|
114
|
+
function renderNitroTypeAugmentations(compatibility, augmentations) {
|
|
115
|
+
const nitroInterfaces = [
|
|
116
|
+
renderInterface("NitroRouteRules", augmentations.routeRules),
|
|
117
|
+
renderInterface("NitroRouteConfig", augmentations.routeConfig),
|
|
118
|
+
renderInterface("NitroRuntimeHooks", augmentations.runtimeHooks),
|
|
119
|
+
...Object.entries(augmentations.nitroInterfaces || {}).map(([name, contents]) => renderInterface(name, contents))
|
|
120
|
+
].filter((value) => Boolean(value));
|
|
121
|
+
const declarations = [];
|
|
122
|
+
if (nitroInterfaces.length) {
|
|
123
|
+
const nitroTypeModules = compatibility._tag === "nitro-v2" ? ["nitropack", "nitropack/types"] : [compatibility.nitroTypesModule];
|
|
124
|
+
declarations.push(...nitroTypeModules.map((module) => `declare module '${module}' {
|
|
125
|
+
${nitroInterfaces.join("\n")}
|
|
126
|
+
}`));
|
|
127
|
+
}
|
|
128
|
+
if (augmentations.eventContext?.trim()) {
|
|
129
|
+
declarations.push(`declare module '${compatibility.eventContextModule}' {
|
|
130
|
+
${renderInterface(compatibility.eventContextType, augmentations.eventContext)}
|
|
131
|
+
}`);
|
|
132
|
+
}
|
|
133
|
+
return declarations.join("\n\n");
|
|
134
|
+
}
|
|
135
|
+
function setupNitroRuntimeCompatibility(nuxt = useNuxt()) {
|
|
136
|
+
const major = Number.parseInt(getNuxtVersion(nuxt), 10);
|
|
137
|
+
const compatibility = major >= 5 ? nitroV3Compatibility : nitroV2Compatibility;
|
|
138
|
+
applyNitroRuntimeCompatibility(nuxt, compatibility);
|
|
139
|
+
const nuxtWithLegacyMarker = nuxt;
|
|
140
|
+
nuxtWithLegacyMarker[legacySetupMarker] = true;
|
|
141
|
+
const nuxtWithRuntimeMarker = nuxt;
|
|
142
|
+
if (!nuxtWithRuntimeMarker[runtimeSetupMarker]) {
|
|
143
|
+
nuxtWithRuntimeMarker[runtimeSetupMarker] = true;
|
|
144
|
+
nuxt.hooks.hookOnce("modules:done", () => applyNitroRuntimeCompatibility(nuxt, compatibility));
|
|
145
|
+
}
|
|
146
|
+
const nuxtWithTypeMarker = nuxt;
|
|
147
|
+
if (!nuxtWithTypeMarker[typeSetupMarker]) {
|
|
148
|
+
nuxtWithTypeMarker[typeSetupMarker] = true;
|
|
149
|
+
addTypeTemplate({
|
|
150
|
+
filename: TYPE_TEMPLATE_FILENAME,
|
|
151
|
+
getContents: async () => renderRuntimeDeclarations(compatibility)
|
|
152
|
+
}, { nitro: true, nuxt: true });
|
|
153
|
+
}
|
|
154
|
+
return compatibility;
|
|
155
|
+
}
|
|
156
|
+
|
|
7
157
|
function normalizePackageUrl(rootDir) {
|
|
8
158
|
const url = rootDir.startsWith("file:") ? rootDir : pathToFileURL(rootDir.endsWith("/") ? rootDir : `${rootDir}/`).href;
|
|
9
159
|
return url.endsWith("/") ? url : `${url}/`;
|
|
@@ -157,4 +307,4 @@ async function resolveHostUnheadMajor(rootDir) {
|
|
|
157
307
|
return 3;
|
|
158
308
|
}
|
|
159
309
|
|
|
160
|
-
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, useModuleLogger };
|
|
310
|
+
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, renderNitroTypeAugmentations, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, setupNitroRuntimeCompatibility, useModuleLogger };
|
package/dist/module.json
CHANGED
package/dist/server.d.mts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface NitroRouteRulesRuntimeConfig<TRouteRules extends object> {
|
|
2
|
+
app?: {
|
|
3
|
+
baseURL?: string;
|
|
4
|
+
};
|
|
5
|
+
nitro?: {
|
|
6
|
+
routeRules?: Record<string, TRouteRules>;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
3
9
|
declare function withoutQuery(path: string): string;
|
|
4
|
-
declare function createNitroRouteRuleMatcher(runtimeConfig:
|
|
10
|
+
declare function createNitroRouteRuleMatcher<TRouteRules extends object = Record<string, unknown>>(runtimeConfig: NitroRouteRulesRuntimeConfig<object>): (pathOrUrl: string) => TRouteRules;
|
|
11
|
+
declare function normalizeNitroMatchedRouteRules<TMatchedRouteRules extends Record<string, {
|
|
12
|
+
options: unknown;
|
|
13
|
+
}> = Record<string, {
|
|
14
|
+
options: unknown;
|
|
15
|
+
}>>(matchedRouteRules?: TMatchedRouteRules): {
|
|
16
|
+
[Key in keyof TMatchedRouteRules]: TMatchedRouteRules[Key]['options'];
|
|
17
|
+
};
|
|
5
18
|
|
|
6
|
-
export { createNitroRouteRuleMatcher, withoutQuery };
|
|
19
|
+
export { createNitroRouteRuleMatcher, normalizeNitroMatchedRouteRules, withoutQuery };
|
|
20
|
+
export type { NitroRouteRulesRuntimeConfig };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface NitroRouteRulesRuntimeConfig<TRouteRules extends object> {
|
|
2
|
+
app?: {
|
|
3
|
+
baseURL?: string;
|
|
4
|
+
};
|
|
5
|
+
nitro?: {
|
|
6
|
+
routeRules?: Record<string, TRouteRules>;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
3
9
|
declare function withoutQuery(path: string): string;
|
|
4
|
-
declare function createNitroRouteRuleMatcher(runtimeConfig:
|
|
10
|
+
declare function createNitroRouteRuleMatcher<TRouteRules extends object = Record<string, unknown>>(runtimeConfig: NitroRouteRulesRuntimeConfig<object>): (pathOrUrl: string) => TRouteRules;
|
|
11
|
+
declare function normalizeNitroMatchedRouteRules<TMatchedRouteRules extends Record<string, {
|
|
12
|
+
options: unknown;
|
|
13
|
+
}> = Record<string, {
|
|
14
|
+
options: unknown;
|
|
15
|
+
}>>(matchedRouteRules?: TMatchedRouteRules): {
|
|
16
|
+
[Key in keyof TMatchedRouteRules]: TMatchedRouteRules[Key]['options'];
|
|
17
|
+
};
|
|
5
18
|
|
|
6
|
-
export { createNitroRouteRuleMatcher, withoutQuery };
|
|
19
|
+
export { createNitroRouteRuleMatcher, normalizeNitroMatchedRouteRules, withoutQuery };
|
|
20
|
+
export type { NitroRouteRulesRuntimeConfig };
|
package/dist/server.mjs
CHANGED
|
@@ -8,6 +8,7 @@ function withoutQuery(path) {
|
|
|
8
8
|
}
|
|
9
9
|
function createNitroRouteRuleMatcher(runtimeConfig) {
|
|
10
10
|
const { nitro, app } = runtimeConfig;
|
|
11
|
+
const baseURL = app?.baseURL || "/";
|
|
11
12
|
const _routeRulesMatcher = toRouteMatcher(
|
|
12
13
|
createRouter({
|
|
13
14
|
routes: Object.fromEntries(
|
|
@@ -16,11 +17,16 @@ function createNitroRouteRuleMatcher(runtimeConfig) {
|
|
|
16
17
|
})
|
|
17
18
|
);
|
|
18
19
|
return (pathOrUrl) => {
|
|
19
|
-
const path = pathOrUrl[0] === "/" ? pathOrUrl : parseURL(pathOrUrl,
|
|
20
|
+
const path = pathOrUrl[0] === "/" ? pathOrUrl : parseURL(pathOrUrl, baseURL).pathname;
|
|
20
21
|
return defu({}, ..._routeRulesMatcher.matchAll(
|
|
21
|
-
withoutBase(withoutTrailingSlash(withoutQuery(path)),
|
|
22
|
+
withoutBase(withoutTrailingSlash(withoutQuery(path)), baseURL)
|
|
22
23
|
).reverse());
|
|
23
24
|
};
|
|
24
25
|
}
|
|
26
|
+
function normalizeNitroMatchedRouteRules(matchedRouteRules) {
|
|
27
|
+
return Object.fromEntries(
|
|
28
|
+
Object.entries(matchedRouteRules || {}).map(([key, rule]) => [key, rule.options])
|
|
29
|
+
);
|
|
30
|
+
}
|
|
25
31
|
|
|
26
|
-
export { createNitroRouteRuleMatcher, withoutQuery };
|
|
32
|
+
export { createNitroRouteRuleMatcher, normalizeNitroMatchedRouteRules, withoutQuery };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxtseo-shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.3.
|
|
4
|
+
"version": "5.3.8",
|
|
5
5
|
"description": "Shared utilities for Nuxt SEO modules.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"dist"
|
|
65
65
|
],
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@nuxt/schema": "^3.16.0 || ^4.0.0",
|
|
68
|
-
"nuxt": "^3.16.0 || ^4.0.0",
|
|
67
|
+
"@nuxt/schema": "^3.16.0 || ^4.0.0 || ^5.0.0",
|
|
68
|
+
"nuxt": "^3.16.0 || ^4.0.0 || ^5.0.0",
|
|
69
69
|
"nuxt-site-config": "^3.2.0 || ^4.0.0",
|
|
70
70
|
"vue": "^3.5.0",
|
|
71
71
|
"zod": "^3.23.0 || ^4.0.0"
|
|
@@ -81,11 +81,11 @@
|
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@clack/prompts": "^1.7.0",
|
|
83
83
|
"@nuxt/devtools-kit": "4.0.0-alpha.7",
|
|
84
|
-
"@nuxt/kit": "^4.5.
|
|
84
|
+
"@nuxt/kit": "^4.5.1",
|
|
85
85
|
"birpc": "^4.0.0",
|
|
86
86
|
"consola": "^3.4.2",
|
|
87
87
|
"defu": "^6.1.7",
|
|
88
|
-
"nypm": "^0.6.
|
|
88
|
+
"nypm": "^0.6.9",
|
|
89
89
|
"ofetch": "^1.5.1",
|
|
90
90
|
"pathe": "^2.0.3",
|
|
91
91
|
"pkg-types": "^2.3.1",
|
|
@@ -96,24 +96,26 @@
|
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
99
|
-
"@nuxt/module-builder": "^1.0.
|
|
100
|
-
"@nuxt/schema": "^4.5.
|
|
101
|
-
"@
|
|
99
|
+
"@nuxt/module-builder": "^1.0.3",
|
|
100
|
+
"@nuxt/schema": "^4.5.1",
|
|
101
|
+
"@nuxt/test-utils": "^4.1.0",
|
|
102
|
+
"@nuxtjs/i18n": "^10.6.0",
|
|
102
103
|
"h3": "^1.15.11",
|
|
103
104
|
"nitropack": "^2.13.4",
|
|
104
|
-
"nuxt": "^4.5.
|
|
105
|
+
"nuxt": "^4.5.1",
|
|
105
106
|
"nuxt-site-config": "^4.1.2",
|
|
106
107
|
"typescript": "6.0.3",
|
|
107
108
|
"vitest": "^4.1.10",
|
|
108
109
|
"vue": "^3.5.40",
|
|
109
|
-
"vue-tsc": "^3.3.
|
|
110
|
+
"vue-tsc": "^3.3.9"
|
|
110
111
|
},
|
|
111
112
|
"scripts": {
|
|
112
113
|
"build": "nuxt-module-build build",
|
|
113
114
|
"dev:prepare": "nuxt-module-build prepare",
|
|
114
115
|
"stub": "nuxt-module-build build --stub",
|
|
115
116
|
"test": "vitest",
|
|
116
|
-
"test:run": "vitest run",
|
|
117
|
+
"test:run": "vitest run && pnpm test:nuxt5",
|
|
118
|
+
"test:nuxt5": "pnpm --dir test/fixtures/nitro-compat-nuxt5 install --frozen-lockfile && pnpm --dir test/fixtures/nitro-compat-nuxt5 test",
|
|
117
119
|
"test:attw": "attw --pack --profile esm-only",
|
|
118
120
|
"typecheck": "nuxt typecheck ."
|
|
119
121
|
}
|