nuxtseo-shared 0.1.9 → 0.3.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/dist/content.d.mts +37 -37
- package/dist/content.d.ts +75 -0
- package/dist/content.mjs +31 -55
- package/dist/devtools.d.mts +10 -10
- package/dist/devtools.d.ts +14 -0
- package/dist/devtools.mjs +43 -37
- package/dist/i18n.d.mts +19 -19
- package/dist/i18n.d.ts +44 -0
- package/dist/i18n.mjs +117 -105
- package/dist/kit.d.mts +29 -14
- package/dist/kit.d.ts +57 -0
- package/dist/kit.mjs +105 -77
- package/dist/module.d.mts +4 -13
- package/dist/module.d.ts +5 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +31 -32
- package/dist/pro.d.mts +2 -16
- package/dist/pro.d.ts +3 -0
- package/dist/pro.mjs +66 -68
- package/dist/runtime/pure.d.ts +0 -0
- package/dist/runtime/pure.js +36 -0
- package/dist/runtime/server/kit.d.ts +0 -0
- package/dist/runtime/server/kit.js +22 -0
- package/dist/telemetry.d.mts +4 -4
- package/dist/telemetry.d.ts +11 -0
- package/dist/telemetry.mjs +58 -45
- package/dist/types.d.mts +7 -0
- package/package.json +25 -21
- package/src/runtime/pure.ts +57 -0
- package/src/runtime/server/kit.ts +26 -0
- package/dist/index.d.mts +0 -3
- package/dist/index.mjs +0 -3
- package/dist/layer-devtools/app.config.ts +0 -27
- package/dist/layer-devtools/assets/css/global.css +0 -593
- package/dist/layer-devtools/components/DevtoolsAlert.vue +0 -101
- package/dist/layer-devtools/components/DevtoolsCopyButton.vue +0 -20
- package/dist/layer-devtools/components/DevtoolsDocs.vue +0 -11
- package/dist/layer-devtools/components/DevtoolsEmptyState.vue +0 -105
- package/dist/layer-devtools/components/DevtoolsError.vue +0 -78
- package/dist/layer-devtools/components/DevtoolsKeyValue.vue +0 -109
- package/dist/layer-devtools/components/DevtoolsLayout.vue +0 -219
- package/dist/layer-devtools/components/DevtoolsLoading.vue +0 -8
- package/dist/layer-devtools/components/DevtoolsMetric.vue +0 -96
- package/dist/layer-devtools/components/DevtoolsPanel.vue +0 -74
- package/dist/layer-devtools/components/DevtoolsProductionError.vue +0 -41
- package/dist/layer-devtools/components/DevtoolsSection.vue +0 -139
- package/dist/layer-devtools/components/DevtoolsSnippet.vue +0 -51
- package/dist/layer-devtools/components/DevtoolsToolbar.vue +0 -42
- package/dist/layer-devtools/components/NuxtSeoLogo.vue +0 -77
- package/dist/layer-devtools/components/OCodeBlock.vue +0 -23
- package/dist/layer-devtools/composables/clipboard.ts +0 -21
- package/dist/layer-devtools/composables/rpc.ts +0 -39
- package/dist/layer-devtools/composables/shiki.ts +0 -46
- package/dist/layer-devtools/composables/state.ts +0 -33
- package/dist/layer-devtools/nuxt.config.ts +0 -26
package/dist/module.mjs
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { defineNuxtModule, useNuxt, createResolver } from '@nuxt/kit';
|
|
2
|
+
import { hookNuxtSeoProLicense } from './pro.mjs';
|
|
3
|
+
import { hookNuxtSeoTelemetry } from './telemetry.mjs';
|
|
4
|
+
import '@clack/prompts';
|
|
5
|
+
import 'nuxt-site-config/kit';
|
|
6
|
+
import 'ofetch';
|
|
7
|
+
import 'std-env';
|
|
8
|
+
import './kit.mjs';
|
|
9
|
+
import 'pathe';
|
|
10
|
+
import 'node:crypto';
|
|
11
|
+
import 'pkg-types';
|
|
12
|
+
|
|
13
|
+
const module$1 = defineNuxtModule({
|
|
14
|
+
meta: {
|
|
15
|
+
name: "nuxtseo-shared",
|
|
16
|
+
configKey: "nuxtSeoShared",
|
|
17
|
+
compatibility: {
|
|
18
|
+
nuxt: ">=3.16.0"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
setup() {
|
|
22
|
+
const nuxt = useNuxt();
|
|
23
|
+
const { resolve } = createResolver(import.meta.url);
|
|
24
|
+
nuxt.options.alias["#nuxtseo-shared"] = resolve("./runtime");
|
|
25
|
+
nuxt.options.nitro.alias = nuxt.options.nitro.alias || {};
|
|
26
|
+
nuxt.options.nitro.alias["#nuxtseo-shared"] = resolve("./runtime");
|
|
27
|
+
hookNuxtSeoProLicense();
|
|
28
|
+
hookNuxtSeoTelemetry();
|
|
29
|
+
}
|
|
15
30
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* Register a Nuxt SEO module with the shared instance.
|
|
19
|
-
* Pro modules are detected by name and trigger license verification at build time.
|
|
20
|
-
*
|
|
21
|
-
* Call this from your module's setup().
|
|
22
|
-
*/
|
|
23
|
-
function registerNuxtSeoModule(registration) {
|
|
24
|
-
const nuxt = useNuxt();
|
|
25
|
-
nuxt._nuxtSeoModules = nuxt._nuxtSeoModules || [];
|
|
26
|
-
nuxt._nuxtSeoModules.push(registration);
|
|
27
|
-
if (PRO_MODULES.has(registration.name)) {
|
|
28
|
-
nuxt._nuxtSeoProModules = nuxt._nuxtSeoProModules || [];
|
|
29
|
-
nuxt._nuxtSeoProModules.push(registration);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { module_default as default, registerNuxtSeoModule };
|
|
31
|
+
|
|
32
|
+
export { module$1 as default };
|
package/dist/pro.d.mts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
//#region src/pro.d.ts
|
|
2
|
-
interface ModuleRegistration {
|
|
3
|
-
name: string;
|
|
4
|
-
version?: string;
|
|
5
|
-
features?: Record<string, boolean | string | number>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Register a Nuxt SEO Pro module for license verification.
|
|
9
|
-
* Uses Nuxt hook so modules don't need to import from each other.
|
|
10
|
-
*
|
|
11
|
-
* Call this in your module setup. Registrations are collected
|
|
12
|
-
* before the single license verification fetch.
|
|
13
|
-
*/
|
|
14
|
-
declare function registerNuxtSeoProModule(registration: ModuleRegistration): void;
|
|
15
1
|
declare function hookNuxtSeoProLicense(): void;
|
|
16
|
-
|
|
17
|
-
export {
|
|
2
|
+
|
|
3
|
+
export { hookNuxtSeoProLicense };
|
package/dist/pro.d.ts
ADDED
package/dist/pro.mjs
CHANGED
|
@@ -1,70 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Register a Nuxt SEO Pro module for license verification.
|
|
10
|
-
* Uses Nuxt hook so modules don't need to import from each other.
|
|
11
|
-
*
|
|
12
|
-
* Call this in your module setup. Registrations are collected
|
|
13
|
-
* before the single license verification fetch.
|
|
14
|
-
*/
|
|
15
|
-
function registerNuxtSeoProModule(registration) {
|
|
16
|
-
const nuxt = useNuxt();
|
|
17
|
-
nuxt._nuxtSeoProModules = nuxt._nuxtSeoProModules || [];
|
|
18
|
-
nuxt._nuxtSeoProModules.push(registration);
|
|
19
|
-
}
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import { useNuxt, useLogger } from '@nuxt/kit';
|
|
3
|
+
import { useSiteConfig } from 'nuxt-site-config/kit';
|
|
4
|
+
import { $fetch } from 'ofetch';
|
|
5
|
+
import { isTest, isCI } from 'std-env';
|
|
6
|
+
import { detectNuxtSeoProModules } from './kit.mjs';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
|
|
20
9
|
function hookNuxtSeoProLicense() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
10
|
+
const nuxt = useNuxt();
|
|
11
|
+
const logger = useLogger("nuxt-seo-pro");
|
|
12
|
+
const isBuild = !nuxt.options.dev && !nuxt.options._prepare;
|
|
13
|
+
if (isBuild && !nuxt._isNuxtSeoProVerifying) {
|
|
14
|
+
const license = nuxt.options.runtimeConfig.seoProKey || process.env.NUXT_SEO_PRO_KEY;
|
|
15
|
+
if (isTest || process.env.VITEST) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!isCI && !license) {
|
|
19
|
+
p.log.warn("\u26A0\uFE0F Building without license in non-CI environment. A license is required for production builds.");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!license) {
|
|
23
|
+
p.log.error("\u{1F510} Nuxt SEO Pro license required");
|
|
24
|
+
p.note("Set NUXT_SEO_PRO_KEY or configure via module options.\n\nhttps://nuxtseo.com/pro/dashboard", "Get your license");
|
|
25
|
+
throw new Error("Missing Nuxt SEO Pro license key.");
|
|
26
|
+
}
|
|
27
|
+
nuxt._isNuxtSeoProVerifying = true;
|
|
28
|
+
nuxt.hooks.hook("build:before", async () => {
|
|
29
|
+
p.intro("Nuxt SEO Pro: License Verification");
|
|
30
|
+
const siteConfig = useSiteConfig();
|
|
31
|
+
const spinner = p.spinner();
|
|
32
|
+
spinner.start("Verifying Nuxt SEO Pro license...");
|
|
33
|
+
const siteUrl = siteConfig.url?.startsWith("http") ? siteConfig.url : void 0;
|
|
34
|
+
const siteName = siteConfig.name || void 0;
|
|
35
|
+
const proModules = detectNuxtSeoProModules(nuxt);
|
|
36
|
+
const modules = proModules.length > 0 ? proModules : void 0;
|
|
37
|
+
const res = await $fetch("https://nuxtseo.com/api/pro/verify", {
|
|
38
|
+
method: "POST",
|
|
39
|
+
body: {
|
|
40
|
+
apiKey: license,
|
|
41
|
+
siteUrl,
|
|
42
|
+
siteName,
|
|
43
|
+
modules
|
|
44
|
+
}
|
|
45
|
+
}).catch((err) => {
|
|
46
|
+
if (err?.response?.status === 401) {
|
|
47
|
+
spinner.error("Invalid API key");
|
|
48
|
+
p.note("Your API key is invalid.\n\nhttps://nuxtseo.com/pro/dashboard", "License Issue");
|
|
49
|
+
throw new Error("Invalid Nuxt SEO Pro API key.");
|
|
50
|
+
}
|
|
51
|
+
if (err?.response?.status === 403) {
|
|
52
|
+
spinner.error("No active subscription");
|
|
53
|
+
p.note("Your subscription has expired or is inactive.\n\nhttps://nuxtseo.com/pro/dashboard", "License Issue");
|
|
54
|
+
throw new Error("No active Nuxt SEO Pro subscription.");
|
|
55
|
+
}
|
|
56
|
+
logger.error(err);
|
|
57
|
+
return null;
|
|
58
|
+
});
|
|
59
|
+
if (!res) {
|
|
60
|
+
spinner.cancel("License verification skipped (network issue)");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
spinner.stop("License verified");
|
|
64
|
+
});
|
|
65
|
+
}
|
|
68
66
|
}
|
|
69
|
-
|
|
70
|
-
export { hookNuxtSeoProLicense
|
|
67
|
+
|
|
68
|
+
export { hookNuxtSeoProLicense };
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createRouter, toRouteMatcher } from "radix3";
|
|
2
|
+
export function createFilter(options = {}) {
|
|
3
|
+
const include = options.include || [];
|
|
4
|
+
const exclude = options.exclude || [];
|
|
5
|
+
if (include.length === 0 && exclude.length === 0)
|
|
6
|
+
return () => true;
|
|
7
|
+
const excludeRegex = exclude.filter((r) => r instanceof RegExp);
|
|
8
|
+
const includeRegex = include.filter((r) => r instanceof RegExp);
|
|
9
|
+
const excludeStrings = exclude.filter((r) => typeof r === "string");
|
|
10
|
+
const includeStrings = include.filter((r) => typeof r === "string");
|
|
11
|
+
const excludeMatcher = excludeStrings.length > 0 ? toRouteMatcher(createRouter({
|
|
12
|
+
routes: Object.fromEntries(excludeStrings.map((r) => [r, true])),
|
|
13
|
+
strictTrailingSlash: false
|
|
14
|
+
})) : null;
|
|
15
|
+
const includeMatcher = includeStrings.length > 0 ? toRouteMatcher(createRouter({
|
|
16
|
+
routes: Object.fromEntries(includeStrings.map((r) => [r, true])),
|
|
17
|
+
strictTrailingSlash: false
|
|
18
|
+
})) : null;
|
|
19
|
+
const excludeExact = new Set(excludeStrings);
|
|
20
|
+
const includeExact = new Set(includeStrings);
|
|
21
|
+
return function(path) {
|
|
22
|
+
if (excludeRegex.some((r) => r.test(path)))
|
|
23
|
+
return false;
|
|
24
|
+
if (excludeExact.has(path))
|
|
25
|
+
return false;
|
|
26
|
+
if (excludeMatcher && excludeMatcher.matchAll(path).length > 0)
|
|
27
|
+
return false;
|
|
28
|
+
if (includeRegex.some((r) => r.test(path)))
|
|
29
|
+
return true;
|
|
30
|
+
if (includeExact.has(path))
|
|
31
|
+
return true;
|
|
32
|
+
if (includeMatcher && includeMatcher.matchAll(path).length > 0)
|
|
33
|
+
return true;
|
|
34
|
+
return include.length === 0;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defu } from "defu";
|
|
2
|
+
import { useRuntimeConfig } from "nitropack/runtime";
|
|
3
|
+
import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
|
|
4
|
+
import { withoutBase, withoutTrailingSlash } from "ufo";
|
|
5
|
+
export function withoutQuery(path) {
|
|
6
|
+
return path.split("?")[0];
|
|
7
|
+
}
|
|
8
|
+
export function createNitroRouteRuleMatcher() {
|
|
9
|
+
const { nitro, app } = useRuntimeConfig();
|
|
10
|
+
const _routeRulesMatcher = toRouteMatcher(
|
|
11
|
+
createRadixRouter({
|
|
12
|
+
routes: Object.fromEntries(
|
|
13
|
+
Object.entries(nitro?.routeRules || {}).map(([path, rules]) => [withoutTrailingSlash(path), rules])
|
|
14
|
+
)
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
return (path) => {
|
|
18
|
+
return defu({}, ..._routeRulesMatcher.matchAll(
|
|
19
|
+
withoutBase(withoutTrailingSlash(withoutQuery(path)), app.baseURL)
|
|
20
|
+
).reverse());
|
|
21
|
+
};
|
|
22
|
+
}
|
package/dist/telemetry.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
//#region src/telemetry.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Hook into build to send telemetry. Call once from the shared module.
|
|
4
|
-
*
|
|
3
|
+
* Auto-detects installed Nuxt SEO modules from `_installedModules`.
|
|
4
|
+
* Modules can optionally report features via the `nuxt-seo:features` hook.
|
|
5
5
|
* Only fires in CI, never in dev/test, fully fire-and-forget.
|
|
6
6
|
*
|
|
7
7
|
* Disable with NUXT_SEO_TELEMETRY_DISABLED=1
|
|
8
8
|
*/
|
|
9
9
|
declare function hookNuxtSeoTelemetry(): void;
|
|
10
|
-
|
|
11
|
-
export { hookNuxtSeoTelemetry };
|
|
10
|
+
|
|
11
|
+
export { hookNuxtSeoTelemetry };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook into build to send telemetry. Call once from the shared module.
|
|
3
|
+
* Auto-detects installed Nuxt SEO modules from `_installedModules`.
|
|
4
|
+
* Modules can optionally report features via the `nuxt-seo:features` hook.
|
|
5
|
+
* Only fires in CI, never in dev/test, fully fire-and-forget.
|
|
6
|
+
*
|
|
7
|
+
* Disable with NUXT_SEO_TELEMETRY_DISABLED=1
|
|
8
|
+
*/
|
|
9
|
+
declare function hookNuxtSeoTelemetry(): void;
|
|
10
|
+
|
|
11
|
+
export { hookNuxtSeoTelemetry };
|
package/dist/telemetry.mjs
CHANGED
|
@@ -1,49 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { $fetch } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { useNuxt } from '@nuxt/kit';
|
|
3
|
+
import { $fetch } from 'ofetch';
|
|
4
|
+
import { detectPackageManager } from 'pkg-types';
|
|
5
|
+
import { isCI, isTest, provider } from 'std-env';
|
|
6
|
+
import { detectNuxtSeoModules } from './kit.mjs';
|
|
7
|
+
import 'pathe';
|
|
8
|
+
|
|
7
9
|
const TELEMETRY_ENDPOINT = "https://nuxtseo.com/api/telemetry/collect";
|
|
8
|
-
/**
|
|
9
|
-
* Hook into build to send telemetry. Call once from the shared module.
|
|
10
|
-
* Reads from the existing _nuxtSeoModules registration list.
|
|
11
|
-
* Only fires in CI, never in dev/test, fully fire-and-forget.
|
|
12
|
-
*
|
|
13
|
-
* Disable with NUXT_SEO_TELEMETRY_DISABLED=1
|
|
14
|
-
*/
|
|
15
10
|
function hookNuxtSeoTelemetry() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
11
|
+
const nuxt = useNuxt();
|
|
12
|
+
if (!isCI || isTest || process.env.VITEST || process.env.NUXT_SEO_TELEMETRY_DISABLED) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (nuxt._isNuxtSeoTelemetryHooked)
|
|
16
|
+
return;
|
|
17
|
+
nuxt._isNuxtSeoTelemetryHooked = true;
|
|
18
|
+
nuxt.hooks.hook("build:done", async () => {
|
|
19
|
+
const modules = detectNuxtSeoModules(nuxt);
|
|
20
|
+
if (modules.length === 0)
|
|
21
|
+
return;
|
|
22
|
+
await nuxt.callHook("nuxt-seo:features", modules);
|
|
23
|
+
const projectHash = createHash("sha256").update(nuxt.options.rootDir).digest("hex").slice(0, 16);
|
|
24
|
+
const config = {};
|
|
25
|
+
for (const mod of modules) {
|
|
26
|
+
if (!mod.features)
|
|
27
|
+
continue;
|
|
28
|
+
const safe = {};
|
|
29
|
+
for (const [k, v] of Object.entries(mod.features)) {
|
|
30
|
+
if (typeof v === "boolean" || typeof v === "number") {
|
|
31
|
+
safe[k] = v;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (Object.keys(safe).length > 0) {
|
|
35
|
+
config[mod.name] = safe;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const payload = {
|
|
39
|
+
projectHash,
|
|
40
|
+
modules: modules.map((m) => m.name),
|
|
41
|
+
moduleVersions: Object.fromEntries(
|
|
42
|
+
modules.filter((m) => m.version).map((m) => [m.name, m.version])
|
|
43
|
+
),
|
|
44
|
+
config: Object.keys(config).length > 0 ? config : void 0,
|
|
45
|
+
nuxtVersion: nuxt._version,
|
|
46
|
+
// eslint-disable-next-line node/prefer-global/process
|
|
47
|
+
nodeVersion: process.version,
|
|
48
|
+
// eslint-disable-next-line node/prefer-global/process
|
|
49
|
+
os: process.platform,
|
|
50
|
+
packageManager: await detectPackageManager(nuxt.options.rootDir).then((r) => r?.name).catch(() => void 0),
|
|
51
|
+
ci: provider || "true"
|
|
52
|
+
};
|
|
53
|
+
$fetch(TELEMETRY_ENDPOINT, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
body: payload,
|
|
56
|
+
timeout: 5e3
|
|
57
|
+
}).catch(() => {
|
|
58
|
+
});
|
|
59
|
+
});
|
|
47
60
|
}
|
|
48
|
-
|
|
61
|
+
|
|
49
62
|
export { hookNuxtSeoTelemetry };
|
package/dist/types.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxtseo-shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "Shared utilities for Nuxt SEO modules.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -11,11 +11,7 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./dist/
|
|
15
|
-
"import": "./dist/index.mjs"
|
|
16
|
-
},
|
|
17
|
-
"./module": {
|
|
18
|
-
"types": "./dist/module.d.mts",
|
|
14
|
+
"types": "./dist/types.d.mts",
|
|
19
15
|
"import": "./dist/module.mjs"
|
|
20
16
|
},
|
|
21
17
|
"./content": {
|
|
@@ -38,14 +34,19 @@
|
|
|
38
34
|
"types": "./dist/pro.d.mts",
|
|
39
35
|
"import": "./dist/pro.mjs"
|
|
40
36
|
},
|
|
41
|
-
"./
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
"./telemetry": {
|
|
38
|
+
"types": "./dist/telemetry.d.mts",
|
|
39
|
+
"import": "./dist/telemetry.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./runtime/pure": "./dist/runtime/pure.js",
|
|
42
|
+
"./runtime/server/kit": "./dist/runtime/server/kit.js",
|
|
43
|
+
"./package.json": "./package.json"
|
|
44
44
|
},
|
|
45
|
-
"main": "./dist/
|
|
46
|
-
"types": "./dist/
|
|
45
|
+
"main": "./dist/module.mjs",
|
|
46
|
+
"types": "./dist/types.d.mts",
|
|
47
47
|
"files": [
|
|
48
|
-
"dist"
|
|
48
|
+
"dist",
|
|
49
|
+
"src/runtime"
|
|
49
50
|
],
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"@nuxt/schema": "^3.16.0 || ^4.0.0",
|
|
@@ -70,25 +71,28 @@
|
|
|
70
71
|
"defu": "^6.1.4",
|
|
71
72
|
"ofetch": "^1.5.1",
|
|
72
73
|
"pathe": "^2.0.3",
|
|
74
|
+
"pkg-types": "^2.3.0",
|
|
73
75
|
"radix3": "^1.1.2",
|
|
74
76
|
"sirv": "^3.0.2",
|
|
75
77
|
"std-env": "^4.0.0",
|
|
76
78
|
"ufo": "^1.6.3"
|
|
77
79
|
},
|
|
78
80
|
"devDependencies": {
|
|
81
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
79
82
|
"@nuxt/schema": "^4.4.2",
|
|
80
83
|
"@nuxtjs/i18n": "^10.2.3",
|
|
81
|
-
"
|
|
82
|
-
"@shikijs/themes": "^4.0.2",
|
|
83
|
-
"@vueuse/core": "^13.9.0",
|
|
84
|
-
"nuxt-site-config": "^4.0.0",
|
|
85
|
-
"obuild": "^0.4.32",
|
|
86
|
-
"shiki": "^4.0.2",
|
|
84
|
+
"nuxt-site-config": "^3.2.21",
|
|
87
85
|
"typescript": "^5.9.3",
|
|
88
|
-
"
|
|
86
|
+
"vitest": "^4.1.0",
|
|
87
|
+
"vue": "^3.5.30",
|
|
88
|
+
"vue-tsc": "^3.2.6"
|
|
89
89
|
},
|
|
90
90
|
"scripts": {
|
|
91
|
-
"build": "
|
|
92
|
-
"
|
|
91
|
+
"build": "nuxt-module-build build",
|
|
92
|
+
"dev:prepare": "nuxt-module-build prepare",
|
|
93
|
+
"stub": "nuxt-module-build build --stub",
|
|
94
|
+
"test": "vitest",
|
|
95
|
+
"test:run": "vitest run",
|
|
96
|
+
"typecheck": "vue-tsc --noEmit"
|
|
93
97
|
}
|
|
94
98
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRouter, toRouteMatcher } from 'radix3'
|
|
2
|
+
|
|
3
|
+
export interface CreateFilterOptions {
|
|
4
|
+
include?: (string | RegExp)[]
|
|
5
|
+
exclude?: (string | RegExp)[]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function createFilter(options: CreateFilterOptions = {}): (path: string) => boolean {
|
|
9
|
+
const include = options.include || []
|
|
10
|
+
const exclude = options.exclude || []
|
|
11
|
+
if (include.length === 0 && exclude.length === 0)
|
|
12
|
+
return () => true
|
|
13
|
+
|
|
14
|
+
// Pre-compute regex and string rules once
|
|
15
|
+
const excludeRegex = exclude.filter(r => r instanceof RegExp) as RegExp[]
|
|
16
|
+
const includeRegex = include.filter(r => r instanceof RegExp) as RegExp[]
|
|
17
|
+
const excludeStrings = exclude.filter(r => typeof r === 'string') as string[]
|
|
18
|
+
const includeStrings = include.filter(r => typeof r === 'string') as string[]
|
|
19
|
+
|
|
20
|
+
// Pre-create routers once (expensive operation)
|
|
21
|
+
const excludeMatcher = excludeStrings.length > 0
|
|
22
|
+
? toRouteMatcher(createRouter({
|
|
23
|
+
routes: Object.fromEntries(excludeStrings.map(r => [r, true])),
|
|
24
|
+
strictTrailingSlash: false,
|
|
25
|
+
}))
|
|
26
|
+
: null
|
|
27
|
+
const includeMatcher = includeStrings.length > 0
|
|
28
|
+
? toRouteMatcher(createRouter({
|
|
29
|
+
routes: Object.fromEntries(includeStrings.map(r => [r, true])),
|
|
30
|
+
strictTrailingSlash: false,
|
|
31
|
+
}))
|
|
32
|
+
: null
|
|
33
|
+
|
|
34
|
+
// Pre-create Sets for O(1) exact match lookups
|
|
35
|
+
const excludeExact = new Set(excludeStrings)
|
|
36
|
+
const includeExact = new Set(includeStrings)
|
|
37
|
+
|
|
38
|
+
return function (path: string): boolean {
|
|
39
|
+
// Check exclude rules first
|
|
40
|
+
if (excludeRegex.some(r => r.test(path)))
|
|
41
|
+
return false
|
|
42
|
+
if (excludeExact.has(path))
|
|
43
|
+
return false
|
|
44
|
+
if (excludeMatcher && excludeMatcher.matchAll(path).length > 0)
|
|
45
|
+
return false
|
|
46
|
+
|
|
47
|
+
// Check include rules
|
|
48
|
+
if (includeRegex.some(r => r.test(path)))
|
|
49
|
+
return true
|
|
50
|
+
if (includeExact.has(path))
|
|
51
|
+
return true
|
|
52
|
+
if (includeMatcher && includeMatcher.matchAll(path).length > 0)
|
|
53
|
+
return true
|
|
54
|
+
|
|
55
|
+
return include.length === 0
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { NitroRouteRules } from 'nitropack'
|
|
2
|
+
import { defu } from 'defu'
|
|
3
|
+
import { useRuntimeConfig } from 'nitropack/runtime'
|
|
4
|
+
import { createRouter as createRadixRouter, toRouteMatcher } from 'radix3'
|
|
5
|
+
import { withoutBase, withoutTrailingSlash } from 'ufo'
|
|
6
|
+
|
|
7
|
+
export function withoutQuery(path: string): string {
|
|
8
|
+
return path.split('?')[0]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createNitroRouteRuleMatcher(): (path: string) => NitroRouteRules {
|
|
12
|
+
const { nitro, app } = useRuntimeConfig()
|
|
13
|
+
const _routeRulesMatcher = toRouteMatcher(
|
|
14
|
+
createRadixRouter({
|
|
15
|
+
routes: Object.fromEntries(
|
|
16
|
+
Object.entries(nitro?.routeRules || {})
|
|
17
|
+
.map(([path, rules]) => [withoutTrailingSlash(path), rules]),
|
|
18
|
+
),
|
|
19
|
+
}),
|
|
20
|
+
)
|
|
21
|
+
return (path: string) => {
|
|
22
|
+
return defu({}, ..._routeRulesMatcher.matchAll(
|
|
23
|
+
withoutBase(withoutTrailingSlash(withoutQuery(path)), app.baseURL),
|
|
24
|
+
).reverse()) as NitroRouteRules
|
|
25
|
+
}
|
|
26
|
+
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { setupDevToolsUI } from "./devtools.mjs";
|
|
2
|
-
import { NuxtContentVersion, createNitroPromise, createPagesPromise, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveNitroPreset, resolveNuxtContentVersion } from "./kit.mjs";
|
|
3
|
-
export { type NuxtContentVersion, createNitroPromise, createPagesPromise, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveNitroPreset, resolveNuxtContentVersion, setupDevToolsUI };
|
package/dist/index.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { setupDevToolsUI } from "./devtools.mjs";
|
|
2
|
-
import { createNitroPromise, createPagesPromise, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveNitroPreset, resolveNuxtContentVersion } from "./kit.mjs";
|
|
3
|
-
export { createNitroPromise, createPagesPromise, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveNitroPreset, resolveNuxtContentVersion, setupDevToolsUI };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export default defineAppConfig({
|
|
2
|
-
ui: {
|
|
3
|
-
colors: {
|
|
4
|
-
primary: 'green',
|
|
5
|
-
neutral: 'neutral',
|
|
6
|
-
},
|
|
7
|
-
button: {
|
|
8
|
-
defaultVariants: {
|
|
9
|
-
color: 'neutral',
|
|
10
|
-
variant: 'ghost',
|
|
11
|
-
size: 'sm',
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
badge: {
|
|
15
|
-
defaultVariants: {
|
|
16
|
-
color: 'neutral',
|
|
17
|
-
variant: 'subtle',
|
|
18
|
-
size: 'xs',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
tooltip: {
|
|
22
|
-
defaultVariants: {
|
|
23
|
-
delayDuration: 0,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
})
|