nuxtseo-shared 5.3.3 → 5.3.6
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/kit.d.mts +5 -1
- package/dist/kit.d.ts +5 -1
- package/dist/kit.mjs +7 -2
- package/dist/module.d.mts +1 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.json +1 -1
- package/dist/server.d.mts +6 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.mjs +26 -0
- package/dist/utils.d.mts +19 -4
- package/dist/utils.d.ts +19 -4
- package/dist/utils.mjs +46 -3
- package/package.json +7 -2
package/dist/kit.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import { Nuxt } from '@nuxt/schema';
|
|
|
2
2
|
import { Nitro } from 'nitropack';
|
|
3
3
|
import { NitroConfig } from 'nitropack/types';
|
|
4
4
|
import { NuxtPage, NuxtModule } from 'nuxt/schema';
|
|
5
|
+
import { useLogger } from '@nuxt/kit';
|
|
5
6
|
|
|
6
7
|
interface NuxtSeoModuleDetection {
|
|
7
8
|
name: string;
|
|
@@ -14,6 +15,9 @@ interface NuxtSeoModuleDetection {
|
|
|
14
15
|
* No self-registration needed; modules are discovered automatically.
|
|
15
16
|
*/
|
|
16
17
|
declare function detectNuxtSeoModules(nuxt?: Nuxt): NuxtSeoModuleDetection[];
|
|
18
|
+
declare function useModuleLogger(name: string, options: {
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
}, nuxt?: Nuxt): ReturnType<typeof useLogger>;
|
|
17
21
|
declare function detectTarget(options?: {
|
|
18
22
|
static?: boolean;
|
|
19
23
|
}): string | undefined;
|
|
@@ -71,5 +75,5 @@ type UnheadMajor = 2 | 3;
|
|
|
71
75
|
*/
|
|
72
76
|
declare function resolveHostUnheadMajor(rootDir: string): Promise<UnheadMajor>;
|
|
73
77
|
|
|
74
|
-
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor };
|
|
78
|
+
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, useModuleLogger };
|
|
75
79
|
export type { NuxtContentVersion, NuxtSeoModuleDetection, UnheadMajor };
|
package/dist/kit.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Nuxt } from '@nuxt/schema';
|
|
|
2
2
|
import { Nitro } from 'nitropack';
|
|
3
3
|
import { NitroConfig } from 'nitropack/types';
|
|
4
4
|
import { NuxtPage, NuxtModule } from 'nuxt/schema';
|
|
5
|
+
import { useLogger } from '@nuxt/kit';
|
|
5
6
|
|
|
6
7
|
interface NuxtSeoModuleDetection {
|
|
7
8
|
name: string;
|
|
@@ -14,6 +15,9 @@ interface NuxtSeoModuleDetection {
|
|
|
14
15
|
* No self-registration needed; modules are discovered automatically.
|
|
15
16
|
*/
|
|
16
17
|
declare function detectNuxtSeoModules(nuxt?: Nuxt): NuxtSeoModuleDetection[];
|
|
18
|
+
declare function useModuleLogger(name: string, options: {
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
}, nuxt?: Nuxt): ReturnType<typeof useLogger>;
|
|
17
21
|
declare function detectTarget(options?: {
|
|
18
22
|
static?: boolean;
|
|
19
23
|
}): string | undefined;
|
|
@@ -71,5 +75,5 @@ type UnheadMajor = 2 | 3;
|
|
|
71
75
|
*/
|
|
72
76
|
declare function resolveHostUnheadMajor(rootDir: string): Promise<UnheadMajor>;
|
|
73
77
|
|
|
74
|
-
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor };
|
|
78
|
+
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, useModuleLogger };
|
|
75
79
|
export type { NuxtContentVersion, NuxtSeoModuleDetection, UnheadMajor };
|
package/dist/kit.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pathToFileURL } from 'node:url';
|
|
2
|
-
import { useNuxt, createResolver, addTemplate, loadNuxtModuleInstance, tryUseNuxt, hasNuxtModule, hasNuxtModuleCompatibility } from '@nuxt/kit';
|
|
2
|
+
import { 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';
|
|
@@ -26,6 +26,11 @@ function detectNuxtSeoModules(nuxt = useNuxt()) {
|
|
|
26
26
|
entryPath: m.entryPath
|
|
27
27
|
}));
|
|
28
28
|
}
|
|
29
|
+
function useModuleLogger(name, options, nuxt = useNuxt()) {
|
|
30
|
+
const logger = useLogger(name);
|
|
31
|
+
logger.level = options.debug || nuxt.options.debug ? 4 : 3;
|
|
32
|
+
return logger;
|
|
33
|
+
}
|
|
29
34
|
const autodetectableProviders = {
|
|
30
35
|
azure_static: "azure",
|
|
31
36
|
cloudflare_pages: "cloudflare-pages",
|
|
@@ -152,4 +157,4 @@ async function resolveHostUnheadMajor(rootDir) {
|
|
|
152
157
|
return 3;
|
|
153
158
|
}
|
|
154
159
|
|
|
155
|
-
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor };
|
|
160
|
+
export { createNitroPromise, createPagesPromise, detectNuxtSeoModules, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveHostUnheadMajor, resolveNitroPreset, resolveNuxtContentVersion, resolvePackageMajor, useModuleLogger };
|
package/dist/module.d.mts
CHANGED
package/dist/module.d.ts
CHANGED
package/dist/module.json
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NitroRuntimeConfig, NitroRouteRules } from 'nitropack';
|
|
2
|
+
|
|
3
|
+
declare function withoutQuery(path: string): string;
|
|
4
|
+
declare function createNitroRouteRuleMatcher(runtimeConfig: NitroRuntimeConfig): (pathOrUrl: string) => NitroRouteRules;
|
|
5
|
+
|
|
6
|
+
export { createNitroRouteRuleMatcher, withoutQuery };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { NitroRuntimeConfig, NitroRouteRules } from 'nitropack';
|
|
2
|
+
|
|
3
|
+
declare function withoutQuery(path: string): string;
|
|
4
|
+
declare function createNitroRouteRuleMatcher(runtimeConfig: NitroRuntimeConfig): (pathOrUrl: string) => NitroRouteRules;
|
|
5
|
+
|
|
6
|
+
export { createNitroRouteRuleMatcher, withoutQuery };
|
package/dist/server.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defu } from 'defu';
|
|
2
|
+
import { toRouteMatcher, createRouter } from 'radix3';
|
|
3
|
+
import { withoutTrailingSlash, parseURL, withoutBase } from 'ufo';
|
|
4
|
+
|
|
5
|
+
function withoutQuery(path) {
|
|
6
|
+
const queryIndex = path.indexOf("?");
|
|
7
|
+
return queryIndex === -1 ? path : path.slice(0, queryIndex);
|
|
8
|
+
}
|
|
9
|
+
function createNitroRouteRuleMatcher(runtimeConfig) {
|
|
10
|
+
const { nitro, app } = runtimeConfig;
|
|
11
|
+
const _routeRulesMatcher = toRouteMatcher(
|
|
12
|
+
createRouter({
|
|
13
|
+
routes: Object.fromEntries(
|
|
14
|
+
Object.entries(nitro?.routeRules || {}).map(([path, rules]) => [withoutTrailingSlash(path), rules])
|
|
15
|
+
)
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
return (pathOrUrl) => {
|
|
19
|
+
const path = pathOrUrl[0] === "/" ? pathOrUrl : parseURL(pathOrUrl, app.baseURL).pathname;
|
|
20
|
+
return defu({}, ..._routeRulesMatcher.matchAll(
|
|
21
|
+
withoutBase(withoutTrailingSlash(withoutQuery(path)), app.baseURL)
|
|
22
|
+
).reverse());
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { createNitroRouteRuleMatcher, withoutQuery };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import { ConsolaInstance } from 'consola';
|
|
2
|
+
|
|
3
|
+
interface SerializedRegExp {
|
|
4
|
+
regex: string;
|
|
5
|
+
}
|
|
6
|
+
interface SourceFlagsRegExp {
|
|
7
|
+
source: string;
|
|
8
|
+
flags?: string;
|
|
9
|
+
}
|
|
10
|
+
type FilterEntry = string | RegExp;
|
|
11
|
+
type SerializedFilterEntry = string | SerializedRegExp | SourceFlagsRegExp;
|
|
12
|
+
type FilterEntryInput = FilterEntry | SerializedRegExp | SourceFlagsRegExp;
|
|
13
|
+
declare function serializeFilters(filters: unknown[], tag?: string): SerializedFilterEntry[];
|
|
14
|
+
declare function deserializeFilters(filters: FilterEntryInput[]): FilterEntry[];
|
|
1
15
|
interface CreateFilterOptions {
|
|
2
|
-
include?:
|
|
3
|
-
exclude?:
|
|
16
|
+
include?: FilterEntryInput[];
|
|
17
|
+
exclude?: FilterEntryInput[];
|
|
4
18
|
}
|
|
5
19
|
declare function createFilter(options?: CreateFilterOptions): (path: string) => boolean;
|
|
6
20
|
declare function withoutQuery(path: string): string;
|
|
21
|
+
declare function createModuleLogger(tag: string, debug?: boolean): ConsolaInstance;
|
|
7
22
|
|
|
8
|
-
export { createFilter, withoutQuery };
|
|
9
|
-
export type { CreateFilterOptions };
|
|
23
|
+
export { createFilter, createModuleLogger, deserializeFilters, serializeFilters, withoutQuery };
|
|
24
|
+
export type { CreateFilterOptions, FilterEntry, FilterEntryInput, SerializedFilterEntry, SerializedRegExp, SourceFlagsRegExp };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import { ConsolaInstance } from 'consola';
|
|
2
|
+
|
|
3
|
+
interface SerializedRegExp {
|
|
4
|
+
regex: string;
|
|
5
|
+
}
|
|
6
|
+
interface SourceFlagsRegExp {
|
|
7
|
+
source: string;
|
|
8
|
+
flags?: string;
|
|
9
|
+
}
|
|
10
|
+
type FilterEntry = string | RegExp;
|
|
11
|
+
type SerializedFilterEntry = string | SerializedRegExp | SourceFlagsRegExp;
|
|
12
|
+
type FilterEntryInput = FilterEntry | SerializedRegExp | SourceFlagsRegExp;
|
|
13
|
+
declare function serializeFilters(filters: unknown[], tag?: string): SerializedFilterEntry[];
|
|
14
|
+
declare function deserializeFilters(filters: FilterEntryInput[]): FilterEntry[];
|
|
1
15
|
interface CreateFilterOptions {
|
|
2
|
-
include?:
|
|
3
|
-
exclude?:
|
|
16
|
+
include?: FilterEntryInput[];
|
|
17
|
+
exclude?: FilterEntryInput[];
|
|
4
18
|
}
|
|
5
19
|
declare function createFilter(options?: CreateFilterOptions): (path: string) => boolean;
|
|
6
20
|
declare function withoutQuery(path: string): string;
|
|
21
|
+
declare function createModuleLogger(tag: string, debug?: boolean): ConsolaInstance;
|
|
7
22
|
|
|
8
|
-
export { createFilter, withoutQuery };
|
|
9
|
-
export type { CreateFilterOptions };
|
|
23
|
+
export { createFilter, createModuleLogger, deserializeFilters, serializeFilters, withoutQuery };
|
|
24
|
+
export type { CreateFilterOptions, FilterEntry, FilterEntryInput, SerializedFilterEntry, SerializedRegExp, SourceFlagsRegExp };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,8 +1,48 @@
|
|
|
1
|
+
import { createConsola } from 'consola';
|
|
1
2
|
import { toRouteMatcher, createRouter } from 'radix3';
|
|
2
3
|
|
|
4
|
+
function parseSerializedRegExp(value) {
|
|
5
|
+
const lastSlash = value.lastIndexOf("/");
|
|
6
|
+
return new RegExp(value.slice(1, lastSlash), value.slice(lastSlash + 1));
|
|
7
|
+
}
|
|
8
|
+
function serializeFilters(filters, tag) {
|
|
9
|
+
const prefix = tag ? `[${tag}] ` : "";
|
|
10
|
+
const result = [];
|
|
11
|
+
for (const filter of filters) {
|
|
12
|
+
if (filter instanceof RegExp) {
|
|
13
|
+
result.push({ regex: filter.toString() });
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (typeof filter === "string") {
|
|
17
|
+
result.push(filter);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (filter && typeof filter === "object" && typeof filter.regex === "string") {
|
|
21
|
+
result.push(filter);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (filter && typeof filter === "object" && typeof filter.source === "string") {
|
|
25
|
+
result.push(filter);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
console.warn(`${prefix}You have provided an invalid filter: ${filter}, ignoring.`);
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
function deserializeFilters(filters) {
|
|
33
|
+
return filters.map((filter) => {
|
|
34
|
+
if (filter instanceof RegExp || typeof filter === "string")
|
|
35
|
+
return filter;
|
|
36
|
+
if (typeof filter.regex === "string")
|
|
37
|
+
return parseSerializedRegExp(filter.regex);
|
|
38
|
+
if (typeof filter.source === "string")
|
|
39
|
+
return new RegExp(filter.source, filter.flags || "");
|
|
40
|
+
return filter;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
3
43
|
function createFilter(options = {}) {
|
|
4
|
-
const include = options.include || [];
|
|
5
|
-
const exclude = options.exclude || [];
|
|
44
|
+
const include = deserializeFilters(options.include || []);
|
|
45
|
+
const exclude = deserializeFilters(options.exclude || []);
|
|
6
46
|
if (include.length === 0 && exclude.length === 0)
|
|
7
47
|
return () => true;
|
|
8
48
|
const excludeRegex = exclude.filter((r) => r instanceof RegExp);
|
|
@@ -38,5 +78,8 @@ function createFilter(options = {}) {
|
|
|
38
78
|
function withoutQuery(path) {
|
|
39
79
|
return path.split("?")[0];
|
|
40
80
|
}
|
|
81
|
+
function createModuleLogger(tag, debug) {
|
|
82
|
+
return createConsola({ level: debug ? 4 : 3, defaults: { tag } });
|
|
83
|
+
}
|
|
41
84
|
|
|
42
|
-
export { createFilter, withoutQuery };
|
|
85
|
+
export { createFilter, createModuleLogger, deserializeFilters, serializeFilters, 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.6",
|
|
5
5
|
"description": "Shared utilities for Nuxt SEO modules.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
"types": "./dist/const.d.mts",
|
|
53
53
|
"default": "./dist/const.mjs"
|
|
54
54
|
},
|
|
55
|
+
"./server": {
|
|
56
|
+
"types": "./dist/server.d.mts",
|
|
57
|
+
"default": "./dist/server.mjs"
|
|
58
|
+
},
|
|
55
59
|
"./package.json": "./package.json"
|
|
56
60
|
},
|
|
57
61
|
"main": "./dist/module.mjs",
|
|
@@ -95,9 +99,10 @@
|
|
|
95
99
|
"@nuxt/module-builder": "^1.0.2",
|
|
96
100
|
"@nuxt/schema": "^4.5.0",
|
|
97
101
|
"@nuxtjs/i18n": "^10.4.1",
|
|
102
|
+
"h3": "^1.15.11",
|
|
98
103
|
"nitropack": "^2.13.4",
|
|
99
104
|
"nuxt": "^4.5.0",
|
|
100
|
-
"nuxt-site-config": "^4.1.
|
|
105
|
+
"nuxt-site-config": "^4.1.2",
|
|
101
106
|
"typescript": "6.0.3",
|
|
102
107
|
"vitest": "^4.1.10",
|
|
103
108
|
"vue": "^3.5.40",
|