nuxtseo-shared 0.7.0 → 0.8.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.
@@ -70,7 +70,7 @@ interface DefineContentSchemaConfig<TSchema = any, TDefineOptions extends Conten
70
70
  declare function createContentSchemaFactory<TSchema, TDefineOptions extends ContentSchemaOptions = ContentSchemaOptions>(config: DefineContentSchemaConfig<TSchema, TDefineOptions>, defaultZ: Zod): {
71
71
  defineSchema: (options?: TDefineOptions) => TSchema;
72
72
  asCollection: <T>(collection: any) => T;
73
- schema: z.ZodObject<z.ZodRawShape, "strip", z.ZodTypeAny, {
73
+ schema: z.ZodObject<any, "strip", z.ZodTypeAny, {
74
74
  [x: string]: any;
75
75
  }, {
76
76
  [x: string]: any;
package/dist/content.d.ts CHANGED
@@ -70,7 +70,7 @@ interface DefineContentSchemaConfig<TSchema = any, TDefineOptions extends Conten
70
70
  declare function createContentSchemaFactory<TSchema, TDefineOptions extends ContentSchemaOptions = ContentSchemaOptions>(config: DefineContentSchemaConfig<TSchema, TDefineOptions>, defaultZ: Zod): {
71
71
  defineSchema: (options?: TDefineOptions) => TSchema;
72
72
  asCollection: <T>(collection: any) => T;
73
- schema: z.ZodObject<z.ZodRawShape, "strip", z.ZodTypeAny, {
73
+ schema: z.ZodObject<any, "strip", z.ZodTypeAny, {
74
74
  [x: string]: any;
75
75
  }, {
76
76
  [x: string]: any;
@@ -10,8 +10,14 @@ interface DevToolsUIConfig {
10
10
  icon: string;
11
11
  devPort?: number;
12
12
  }
13
+ interface SeoModuleInfo {
14
+ name: string;
15
+ title: string;
16
+ icon: string;
17
+ route: string;
18
+ }
13
19
  declare function setupDevToolsUI(config: DevToolsUIConfig, resolve: Resolver['resolve'], nuxt?: Nuxt): void;
14
20
  declare function setupDevToolsRpc<ServerFunctions extends object, ClientFunctions extends object>(namespace: string, serverFunctions: ServerFunctions, nuxt?: Nuxt): Promise<BirpcGroup<ClientFunctions, ServerFunctions>>;
15
21
 
16
22
  export { setupDevToolsRpc, setupDevToolsUI };
17
- export type { DevToolsUIConfig };
23
+ export type { DevToolsUIConfig, SeoModuleInfo };
@@ -10,8 +10,14 @@ interface DevToolsUIConfig {
10
10
  icon: string;
11
11
  devPort?: number;
12
12
  }
13
+ interface SeoModuleInfo {
14
+ name: string;
15
+ title: string;
16
+ icon: string;
17
+ route: string;
18
+ }
13
19
  declare function setupDevToolsUI(config: DevToolsUIConfig, resolve: Resolver['resolve'], nuxt?: Nuxt): void;
14
20
  declare function setupDevToolsRpc<ServerFunctions extends object, ClientFunctions extends object>(namespace: string, serverFunctions: ServerFunctions, nuxt?: Nuxt): Promise<BirpcGroup<ClientFunctions, ServerFunctions>>;
15
21
 
16
22
  export { setupDevToolsRpc, setupDevToolsUI };
17
- export type { DevToolsUIConfig };
23
+ export type { DevToolsUIConfig, SeoModuleInfo };
package/dist/devtools.mjs CHANGED
@@ -6,6 +6,18 @@ import sirv from 'sirv';
6
6
  function setupDevToolsUI(config, resolve, nuxt = useNuxt()) {
7
7
  const { route, name, title, icon, devPort = 3030 } = config;
8
8
  const clientPath = resolve("./devtools");
9
+ const modules = nuxt._seoDevtoolsModules ??= [];
10
+ modules.push({ name, title, icon, route });
11
+ if (!nuxt._seoDevtoolsRpcRegistered) {
12
+ nuxt._seoDevtoolsRpcRegistered = true;
13
+ onDevToolsInitialized(() => {
14
+ extendServerRpc("nuxt-seo-modules", {
15
+ getInstalledSeoModules() {
16
+ return nuxt._seoDevtoolsModules || [];
17
+ }
18
+ }, nuxt);
19
+ }, nuxt);
20
+ }
9
21
  const isProductionBuild = existsSync(clientPath) && readdirSync(clientPath).length > 0;
10
22
  if (isProductionBuild) {
11
23
  nuxt.hook("vite:serverCreated", (server) => {
package/dist/kit.mjs CHANGED
@@ -74,10 +74,11 @@ async function getNuxtModuleOptions(module, nuxt = useNuxt()) {
74
74
  return inlineOptions;
75
75
  }
76
76
  function isNuxtGenerate(nuxt = useNuxt()) {
77
- return nuxt.options.nitro.static || nuxt.options._generate || [
77
+ const nitroOptions = nuxt.options.nitro;
78
+ return nitroOptions?.static || nuxt.options._generate || [
78
79
  "static",
79
80
  "github-pages"
80
- ].includes(resolveNitroPreset(nuxt.options.nitro));
81
+ ].includes(resolveNitroPreset(nitroOptions));
81
82
  }
82
83
  function extendTypes(module, template) {
83
84
  const nuxt = useNuxt();
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "0.6.1",
7
+ "version": "0.8.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,14 +1,11 @@
1
1
  import { defineNuxtModule } from '@nuxt/kit';
2
2
  import { hookNuxtSeoProLicense } from './pro.mjs';
3
- import { hookNuxtSeoTelemetry } from './telemetry.mjs';
4
3
  import '@clack/prompts';
5
4
  import 'nuxt-site-config/kit';
6
5
  import 'ofetch';
7
6
  import 'std-env';
8
7
  import './kit.mjs';
9
8
  import 'pathe';
10
- import 'node:crypto';
11
- import 'pkg-types';
12
9
 
13
10
  const module$1 = defineNuxtModule({
14
11
  meta: {
@@ -20,7 +17,6 @@ const module$1 = defineNuxtModule({
20
17
  },
21
18
  setup() {
22
19
  hookNuxtSeoProLicense();
23
- hookNuxtSeoTelemetry();
24
20
  }
25
21
  });
26
22
 
package/dist/pro.mjs CHANGED
@@ -33,6 +33,7 @@ function hookNuxtSeoProLicense() {
33
33
  const siteUrl = siteConfig.url?.startsWith("http") ? siteConfig.url : void 0;
34
34
  const siteName = siteConfig.name || void 0;
35
35
  const proModules = detectNuxtSeoProModules(nuxt);
36
+ await nuxt.hooks.callHook("nuxt-seo-pro:modules", proModules);
36
37
  const modules = proModules.length > 0 ? proModules : void 0;
37
38
  const res = await $fetch("https://nuxtseo.com/api/pro/verify", {
38
39
  method: "POST",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxtseo-shared",
3
3
  "type": "module",
4
- "version": "0.7.0",
4
+ "version": "0.8.0",
5
5
  "description": "Shared utilities for Nuxt SEO modules.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -34,10 +34,6 @@
34
34
  "types": "./dist/pro.d.mts",
35
35
  "import": "./dist/pro.mjs"
36
36
  },
37
- "./telemetry": {
38
- "types": "./dist/telemetry.d.mts",
39
- "import": "./dist/telemetry.mjs"
40
- },
41
37
  "./utils": {
42
38
  "types": "./dist/utils.d.mts",
43
39
  "import": "./dist/utils.mjs"
@@ -83,10 +79,10 @@
83
79
  "@nuxt/module-builder": "^1.0.2",
84
80
  "@nuxt/schema": "^4.4.2",
85
81
  "@nuxtjs/i18n": "^10.2.4",
86
- "nuxt-site-config": "^4.0.0",
82
+ "nuxt-site-config": "^4.0.6",
87
83
  "typescript": "^6.0.2",
88
84
  "vitest": "^4.1.1",
89
- "vue": "^3.5.30",
85
+ "vue": "^3.5.31",
90
86
  "vue-tsc": "^3.2.6"
91
87
  },
92
88
  "scripts": {
@@ -1,11 +0,0 @@
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 };
@@ -1,11 +0,0 @@
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 };
@@ -1,62 +0,0 @@
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
-
9
- const TELEMETRY_ENDPOINT = "https://nuxtseo.com/api/telemetry/collect";
10
- function hookNuxtSeoTelemetry() {
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
- });
60
- }
61
-
62
- export { hookNuxtSeoTelemetry };