nuxtseo-shared 5.3.2 → 5.3.4

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 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
@@ -3,6 +3,7 @@ import { NuxtSeoModuleDetection } from './kit.mjs';
3
3
  import 'nitropack';
4
4
  import 'nitropack/types';
5
5
  import 'nuxt/schema';
6
+ import '@nuxt/kit';
6
7
 
7
8
  interface ModuleHooks {
8
9
  'nuxt-seo-pro:modules': (modules: NuxtSeoModuleDetection[]) => Promise<void> | void;
package/dist/module.d.ts CHANGED
@@ -3,6 +3,7 @@ import { NuxtSeoModuleDetection } from './kit.js';
3
3
  import 'nitropack';
4
4
  import 'nitropack/types';
5
5
  import 'nuxt/schema';
6
+ import '@nuxt/kit';
6
7
 
7
8
  interface ModuleHooks {
8
9
  'nuxt-seo-pro:modules': (modules: NuxtSeoModuleDetection[]) => Promise<void> | void;
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "5.3.2",
7
+ "version": "5.3.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -0,0 +1,7 @@
1
+ import { H3Event } from 'h3';
2
+ import { NitroRouteRules } from 'nitropack';
3
+
4
+ declare function withoutQuery(path: string): string;
5
+ declare function createNitroRouteRuleMatcher(e?: H3Event): (pathOrUrl: string) => NitroRouteRules;
6
+
7
+ export { createNitroRouteRuleMatcher, withoutQuery };
@@ -0,0 +1,7 @@
1
+ import { H3Event } from 'h3';
2
+ import { NitroRouteRules } from 'nitropack';
3
+
4
+ declare function withoutQuery(path: string): string;
5
+ declare function createNitroRouteRuleMatcher(e?: H3Event): (pathOrUrl: string) => NitroRouteRules;
6
+
7
+ export { createNitroRouteRuleMatcher, withoutQuery };
@@ -0,0 +1,33 @@
1
+ import { defu } from 'defu';
2
+ import { useRuntimeConfig } from 'nitropack/runtime';
3
+ import { toRouteMatcher, createRouter } from 'radix3';
4
+ import { withoutTrailingSlash, parseURL, withoutBase } from 'ufo';
5
+
6
+ function withoutQuery(path) {
7
+ const queryIndex = path.indexOf("?");
8
+ return queryIndex === -1 ? path : path.slice(0, queryIndex);
9
+ }
10
+ let cachedRouteRuleMatcher;
11
+ function createNitroRouteRuleMatcher(e) {
12
+ if (!import.meta.dev && !e && cachedRouteRuleMatcher)
13
+ return cachedRouteRuleMatcher;
14
+ const { nitro, app } = useRuntimeConfig(e);
15
+ const _routeRulesMatcher = toRouteMatcher(
16
+ createRouter({
17
+ routes: Object.fromEntries(
18
+ Object.entries(nitro?.routeRules || {}).map(([path, rules]) => [withoutTrailingSlash(path), rules])
19
+ )
20
+ })
21
+ );
22
+ const matcher = (pathOrUrl) => {
23
+ const path = pathOrUrl[0] === "/" ? pathOrUrl : parseURL(pathOrUrl, app.baseURL).pathname;
24
+ return defu({}, ..._routeRulesMatcher.matchAll(
25
+ withoutBase(withoutTrailingSlash(withoutQuery(path)), app.baseURL)
26
+ ).reverse());
27
+ };
28
+ if (!import.meta.dev && !e)
29
+ cachedRouteRuleMatcher = matcher;
30
+ return matcher;
31
+ }
32
+
33
+ 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?: (string | RegExp)[];
3
- exclude?: (string | RegExp)[];
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?: (string | RegExp)[];
3
- exclude?: (string | RegExp)[];
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.2",
4
+ "version": "5.3.4",
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",
@@ -75,9 +79,9 @@
75
79
  }
76
80
  },
77
81
  "dependencies": {
78
- "@clack/prompts": "^1.6.0",
79
- "@nuxt/devtools-kit": "4.0.0-alpha.3",
80
- "@nuxt/kit": "^4.4.8",
82
+ "@clack/prompts": "^1.7.0",
83
+ "@nuxt/devtools-kit": "4.0.0-alpha.7",
84
+ "@nuxt/kit": "^4.5.0",
81
85
  "birpc": "^4.0.0",
82
86
  "consola": "^3.4.2",
83
87
  "defu": "^6.1.7",
@@ -87,21 +91,22 @@
87
91
  "pkg-types": "^2.3.1",
88
92
  "radix3": "^1.1.2",
89
93
  "sirv": "^3.0.2",
90
- "std-env": "^4.1.0",
94
+ "std-env": "^4.2.0",
91
95
  "ufo": "^1.6.4"
92
96
  },
93
97
  "devDependencies": {
94
- "@arethetypeswrong/cli": "^0.18.4",
98
+ "@arethetypeswrong/cli": "^0.18.5",
95
99
  "@nuxt/module-builder": "^1.0.2",
96
- "@nuxt/schema": "^4.4.8",
97
- "@nuxtjs/i18n": "^10.4.0",
100
+ "@nuxt/schema": "^4.5.0",
101
+ "@nuxtjs/i18n": "^10.4.1",
102
+ "h3": "^1.15.11",
98
103
  "nitropack": "^2.13.4",
99
- "nuxt": "^4.4.8",
100
- "nuxt-site-config": "^4.1.1",
101
- "typescript": "^6.0.3",
102
- "vitest": "^4.1.9",
103
- "vue": "^3.5.39",
104
- "vue-tsc": "^3.3.6"
104
+ "nuxt": "^4.5.0",
105
+ "nuxt-site-config": "^4.1.2",
106
+ "typescript": "6.0.3",
107
+ "vitest": "^4.1.10",
108
+ "vue": "^3.5.40",
109
+ "vue-tsc": "^3.3.7"
105
110
  },
106
111
  "scripts": {
107
112
  "build": "nuxt-module-build build",