nuxtseo-shared 0.1.0 → 0.1.2

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.
Files changed (40) hide show
  1. package/dist/content.d.mts +39 -39
  2. package/dist/content.mjs +56 -29
  3. package/dist/devtools.d.mts +10 -10
  4. package/dist/devtools.mjs +37 -43
  5. package/dist/i18n.d.mts +31 -15
  6. package/dist/i18n.mjs +109 -108
  7. package/dist/index.d.mts +3 -7
  8. package/dist/index.mjs +3 -7
  9. package/dist/kit.d.mts +22 -12
  10. package/dist/kit.mjs +79 -73
  11. package/dist/pro.d.mts +7 -7
  12. package/dist/pro.mjs +64 -64
  13. package/dist/runtime/app/composables/rpc.d.mts +16 -0
  14. package/dist/runtime/app/composables/rpc.mjs +28 -0
  15. package/dist/runtime/app/composables/shiki.d.mts +8 -0
  16. package/dist/runtime/app/composables/shiki.mjs +31 -0
  17. package/dist/runtime/app/index.d.mts +2 -0
  18. package/dist/runtime/app/index.mjs +2 -0
  19. package/package.json +29 -44
  20. package/dist/client/composables/rpc.d.mts +0 -21
  21. package/dist/client/composables/rpc.d.ts +0 -21
  22. package/dist/client/composables/rpc.mjs +0 -25
  23. package/dist/client/composables/shiki.d.mts +0 -13
  24. package/dist/client/composables/shiki.d.ts +0 -13
  25. package/dist/client/composables/shiki.mjs +0 -39
  26. package/dist/client/index.d.mts +0 -7
  27. package/dist/client/index.d.ts +0 -7
  28. package/dist/client/index.mjs +0 -6
  29. package/dist/content.d.ts +0 -82
  30. package/dist/devtools.d.ts +0 -14
  31. package/dist/i18n.d.ts +0 -28
  32. package/dist/index.d.ts +0 -7
  33. package/dist/kit.d.ts +0 -32
  34. package/dist/pro.d.ts +0 -18
  35. package/dist/runtime/server/kit.d.mts +0 -7
  36. package/dist/runtime/server/kit.d.ts +0 -7
  37. package/dist/runtime/server/kit.mjs +0 -27
  38. /package/{src/client → dist/runtime/app}/components/NuxtSeoLogo.vue +0 -0
  39. /package/{src/client → dist/runtime/app}/components/OCodeBlock.vue +0 -0
  40. /package/{src/client → dist/runtime/app}/components/OSectionBlock.vue +0 -0
package/dist/kit.d.mts CHANGED
@@ -1,10 +1,11 @@
1
- import { Nuxt } from '@nuxt/schema';
2
- import { Nitro } from 'nitropack';
3
- import { NitroConfig } from 'nitropack/types';
4
- import { NuxtPage, NuxtModule } from 'nuxt/schema';
1
+ import { NuxtModule, NuxtPage } from "nuxt/schema";
2
+ import { Nuxt as Nuxt$1 } from "@nuxt/schema";
3
+ import { Nitro } from "nitropack";
4
+ import { NitroConfig } from "nitropack/types";
5
5
 
6
+ //#region src/kit.d.ts
6
7
  declare function detectTarget(options?: {
7
- static?: boolean;
8
+ static?: boolean;
8
9
  }): string | undefined;
9
10
  declare function resolveNitroPreset(nitroConfig?: NitroConfig): string;
10
11
  /**
@@ -12,21 +13,30 @@ declare function resolveNitroPreset(nitroConfig?: NitroConfig): string;
12
13
  *
13
14
  * These options may not be the resolved options that the module actually uses.
14
15
  */
15
- declare function getNuxtModuleOptions(module: string | NuxtModule, nuxt?: Nuxt): Promise<Record<string, any>>;
16
- declare function isNuxtGenerate(nuxt?: Nuxt): boolean;
16
+ declare function getNuxtModuleOptions(module: string | NuxtModule, nuxt?: Nuxt$1): Promise<Record<string, any>>;
17
+ declare function isNuxtGenerate(nuxt?: Nuxt$1): boolean;
17
18
  /**
18
19
  * Generate TypeScript type augmentations for a Nuxt module.
19
20
  */
20
21
  declare function extendTypes(module: string, template: (options: {
21
- typesPath: string;
22
+ typesPath: string;
22
23
  }) => string | Promise<string>): void;
23
24
  /**
24
25
  * Create a promise that resolves when Nuxt pages are resolved.
25
26
  */
26
- declare function createPagesPromise(nuxt?: Nuxt): Promise<NuxtPage[]>;
27
+ declare function createPagesPromise(nuxt?: Nuxt$1): Promise<NuxtPage[]>;
27
28
  /**
28
29
  * Create a promise that resolves when Nitro is initialized.
29
30
  */
30
- declare function createNitroPromise(nuxt?: Nuxt): Promise<Nitro>;
31
-
32
- export { createNitroPromise, createPagesPromise, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveNitroPreset };
31
+ declare function createNitroPromise(nuxt?: Nuxt$1): Promise<Nitro>;
32
+ interface NuxtContentVersion {
33
+ version: 2 | 3;
34
+ }
35
+ /**
36
+ * Detect which version of @nuxt/content is installed.
37
+ *
38
+ * Returns `false` when @nuxt/content is not installed or the version is unrecognised.
39
+ */
40
+ declare function resolveNuxtContentVersion(): Promise<false | NuxtContentVersion>;
41
+ //#endregion
42
+ export { NuxtContentVersion, createNitroPromise, createPagesPromise, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveNitroPreset, resolveNuxtContentVersion };
package/dist/kit.mjs CHANGED
@@ -1,91 +1,97 @@
1
- import { useNuxt, createResolver, addTemplate, loadNuxtModuleInstance, tryUseNuxt } from '@nuxt/kit';
2
- import { relative } from 'pathe';
3
- import { provider, env } from 'std-env';
4
-
1
+ import { addTemplate, createResolver, hasNuxtModule, hasNuxtModuleCompatibility, loadNuxtModuleInstance, tryUseNuxt, useNuxt } from "@nuxt/kit";
2
+ import { relative } from "pathe";
3
+ import { env, provider } from "std-env";
4
+ //#region src/kit.ts
5
5
  const autodetectableProviders = {
6
- azure_static: "azure",
7
- cloudflare_pages: "cloudflare-pages",
8
- netlify: "netlify",
9
- stormkit: "stormkit",
10
- vercel: "vercel",
11
- cleavr: "cleavr",
12
- stackblitz: "stackblitz"
6
+ azure_static: "azure",
7
+ cloudflare_pages: "cloudflare-pages",
8
+ netlify: "netlify",
9
+ stormkit: "stormkit",
10
+ vercel: "vercel",
11
+ cleavr: "cleavr",
12
+ stackblitz: "stackblitz"
13
13
  };
14
14
  const autodetectableStaticProviders = {
15
- netlify: "netlify-static",
16
- vercel: "vercel-static"
15
+ netlify: "netlify-static",
16
+ vercel: "vercel-static"
17
17
  };
18
18
  function detectTarget(options = {}) {
19
- return options?.static ? autodetectableStaticProviders[provider] : autodetectableProviders[provider];
19
+ return options?.static ? autodetectableStaticProviders[provider] : autodetectableProviders[provider];
20
20
  }
21
21
  function resolveNitroPreset(nitroConfig) {
22
- nitroConfig = nitroConfig || tryUseNuxt()?.options?.nitro;
23
- if (provider === "stackblitz" || provider === "codesandbox")
24
- return provider;
25
- let preset;
26
- if (nitroConfig && nitroConfig?.preset)
27
- preset = nitroConfig.preset;
28
- if (!preset)
29
- preset = env.NITRO_PRESET || env.SERVER_PRESET || detectTarget() || "node-server";
30
- return preset.replace("_", "-");
22
+ nitroConfig = nitroConfig || tryUseNuxt()?.options?.nitro;
23
+ if (provider === "stackblitz" || provider === "codesandbox") return provider;
24
+ let preset;
25
+ if (nitroConfig && nitroConfig?.preset) preset = nitroConfig.preset;
26
+ if (!preset) preset = env.NITRO_PRESET || env.SERVER_PRESET || detectTarget() || "node-server";
27
+ return preset.replace("_", "-");
31
28
  }
29
+ /**
30
+ * Get the user provided options for a Nuxt module.
31
+ *
32
+ * These options may not be the resolved options that the module actually uses.
33
+ */
32
34
  async function getNuxtModuleOptions(module, nuxt = useNuxt()) {
33
- const moduleMeta = (typeof module === "string" ? { name: module } : await module.getMeta?.()) || {};
34
- const { nuxtModule } = await loadNuxtModuleInstance(module, nuxt);
35
- let moduleEntry;
36
- for (const m of nuxt.options.modules) {
37
- if (Array.isArray(m) && m.length >= 2) {
38
- const _module = m[0];
39
- const _moduleEntryName = typeof _module === "string" ? _module : (await _module.getMeta?.())?.name || "";
40
- if (_moduleEntryName === moduleMeta.name)
41
- moduleEntry = m;
42
- }
43
- }
44
- let inlineOptions = {};
45
- if (moduleEntry)
46
- inlineOptions = moduleEntry[1];
47
- if (nuxtModule.getOptions)
48
- return nuxtModule.getOptions(inlineOptions, nuxt);
49
- return inlineOptions;
35
+ const moduleMeta = (typeof module === "string" ? { name: module } : await module.getMeta?.()) || {};
36
+ const { nuxtModule } = await loadNuxtModuleInstance(module, nuxt);
37
+ let moduleEntry;
38
+ for (const m of nuxt.options.modules) if (Array.isArray(m) && m.length >= 2) {
39
+ const _module = m[0];
40
+ if ((typeof _module === "string" ? _module : (await _module.getMeta?.())?.name || "") === moduleMeta.name) moduleEntry = m;
41
+ }
42
+ let inlineOptions = {};
43
+ if (moduleEntry) inlineOptions = moduleEntry[1];
44
+ if (nuxtModule.getOptions) return nuxtModule.getOptions(inlineOptions, nuxt);
45
+ return inlineOptions;
50
46
  }
51
47
  function isNuxtGenerate(nuxt = useNuxt()) {
52
- return nuxt.options.nitro.static || nuxt.options._generate || [
53
- "static",
54
- "github-pages"
55
- ].includes(resolveNitroPreset(nuxt.options.nitro));
48
+ return nuxt.options.nitro.static || nuxt.options._generate || ["static", "github-pages"].includes(resolveNitroPreset(nuxt.options.nitro));
56
49
  }
50
+ /**
51
+ * Generate TypeScript type augmentations for a Nuxt module.
52
+ */
57
53
  function extendTypes(module, template) {
58
- const nuxt = useNuxt();
59
- const { resolve } = createResolver(import.meta.url);
60
- addTemplate({
61
- filename: `module/${module}.d.ts`,
62
- getContents: async () => {
63
- const typesPath = relative(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), resolve("runtime/types"));
64
- const s = await template({ typesPath });
65
- return `// Generated by ${module}
66
- ${s}
67
- export {}
68
- `;
69
- }
70
- });
71
- nuxt.hooks.hook("prepare:types", ({ references }) => {
72
- references.push({ path: resolve(nuxt.options.buildDir, `module/${module}.d.ts`) });
73
- });
54
+ const nuxt = useNuxt();
55
+ const { resolve } = createResolver(import.meta.url);
56
+ addTemplate({
57
+ filename: `module/${module}.d.ts`,
58
+ getContents: async () => {
59
+ return `// Generated by ${module}\n${await template({ typesPath: relative(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), resolve("runtime/types")) })}\nexport {}\n`;
60
+ }
61
+ });
62
+ nuxt.hooks.hook("prepare:types", ({ references }) => {
63
+ references.push({ path: resolve(nuxt.options.buildDir, `module/${module}.d.ts`) });
64
+ });
74
65
  }
66
+ /**
67
+ * Create a promise that resolves when Nuxt pages are resolved.
68
+ */
75
69
  function createPagesPromise(nuxt = useNuxt()) {
76
- return new Promise((resolve) => {
77
- nuxt.hooks.hook("modules:done", () => {
78
- if (typeof nuxt.options.pages === "boolean" && nuxt.options.pages === false || typeof nuxt.options.pages === "object" && !nuxt.options.pages.enabled) {
79
- return resolve([]);
80
- }
81
- nuxt.hook("pages:resolved", (pages) => resolve(pages));
82
- });
83
- });
70
+ return new Promise((resolve) => {
71
+ nuxt.hooks.hook("modules:done", () => {
72
+ if (typeof nuxt.options.pages === "boolean" && nuxt.options.pages === false || typeof nuxt.options.pages === "object" && !nuxt.options.pages.enabled) return resolve([]);
73
+ nuxt.hook("pages:resolved", (pages) => resolve(pages));
74
+ });
75
+ });
84
76
  }
77
+ /**
78
+ * Create a promise that resolves when Nitro is initialized.
79
+ */
85
80
  function createNitroPromise(nuxt = useNuxt()) {
86
- return new Promise((resolve) => {
87
- nuxt.hooks.hook("nitro:init", (nitro) => resolve(nitro));
88
- });
81
+ return new Promise((resolve) => {
82
+ nuxt.hooks.hook("nitro:init", (nitro) => resolve(nitro));
83
+ });
89
84
  }
90
-
91
- export { createNitroPromise, createPagesPromise, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveNitroPreset };
85
+ /**
86
+ * Detect which version of @nuxt/content is installed.
87
+ *
88
+ * Returns `false` when @nuxt/content is not installed or the version is unrecognised.
89
+ */
90
+ async function resolveNuxtContentVersion() {
91
+ if (!hasNuxtModule("@nuxt/content")) return false;
92
+ if (await hasNuxtModuleCompatibility("@nuxt/content", "^3")) return { version: 3 };
93
+ if (await hasNuxtModuleCompatibility("@nuxt/content", "^2")) return { version: 2 };
94
+ return false;
95
+ }
96
+ //#endregion
97
+ export { createNitroPromise, createPagesPromise, detectTarget, extendTypes, getNuxtModuleOptions, isNuxtGenerate, resolveNitroPreset, resolveNuxtContentVersion };
package/dist/pro.d.mts CHANGED
@@ -1,8 +1,9 @@
1
+ //#region src/pro.d.ts
1
2
  interface ModuleRegistration {
2
- name: string;
3
- version?: string;
4
- secret?: string;
5
- features?: Record<string, boolean | string | number>;
3
+ name: string;
4
+ version?: string;
5
+ secret?: string;
6
+ features?: Record<string, boolean | string | number>;
6
7
  }
7
8
  /**
8
9
  * Register a Nuxt SEO Pro module for license verification.
@@ -13,6 +14,5 @@ interface ModuleRegistration {
13
14
  */
14
15
  declare function registerNuxtSeoProModule(registration: ModuleRegistration): void;
15
16
  declare function hookNuxtSeoProLicense(): void;
16
-
17
- export { hookNuxtSeoProLicense, registerNuxtSeoProModule };
18
- export type { ModuleRegistration };
17
+ //#endregion
18
+ export { ModuleRegistration, hookNuxtSeoProLicense, registerNuxtSeoProModule };
package/dist/pro.mjs CHANGED
@@ -1,70 +1,70 @@
1
- import * as p from '@clack/prompts';
2
- import { useLogger, useNuxt } from '@nuxt/kit';
3
- import { useSiteConfig } from 'nuxt-site-config/kit';
4
- import { $fetch } from 'ofetch';
5
- import { isTest, isCI } from 'std-env';
6
-
1
+ import { useLogger, useNuxt } from "@nuxt/kit";
2
+ import { isCI, isTest } from "std-env";
3
+ import * as p from "@clack/prompts";
4
+ import { useSiteConfig } from "nuxt-site-config/kit";
5
+ import { $fetch } from "ofetch";
6
+ //#region src/pro.ts
7
7
  const logger = useLogger("nuxt-seo-pro");
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
+ */
8
15
  function registerNuxtSeoProModule(registration) {
9
- const nuxt = useNuxt();
10
- nuxt._nuxtSeoProModules = nuxt._nuxtSeoProModules || [];
11
- nuxt._nuxtSeoProModules.push(registration);
16
+ const nuxt = useNuxt();
17
+ nuxt._nuxtSeoProModules = nuxt._nuxtSeoProModules || [];
18
+ nuxt._nuxtSeoProModules.push(registration);
12
19
  }
13
20
  function hookNuxtSeoProLicense() {
14
- const nuxt = useNuxt();
15
- const isBuild = !nuxt.options.dev && !nuxt.options._prepare;
16
- if (isBuild && !nuxt._isNuxtSeoProVerifying) {
17
- const license = nuxt.options.runtimeConfig.seoProKey || process.env.NUXT_SEO_PRO_KEY;
18
- if (isTest || process.env.VITEST) {
19
- return;
20
- }
21
- if (!isCI && !license) {
22
- p.log.warn("\u26A0\uFE0F Building without license in non-CI environment. A license is required for production builds.");
23
- return;
24
- }
25
- if (!license) {
26
- p.log.error("\u{1F510} Nuxt SEO Pro license required");
27
- p.note("Set NUXT_SEO_PRO_KEY or configure via module options.\n\nhttps://nuxtseo.com/pro/dashboard", "Get your license");
28
- throw new Error("Missing Nuxt SEO Pro license key.");
29
- }
30
- nuxt._isNuxtSeoProVerifying = true;
31
- nuxt.hooks.hook("build:before", async () => {
32
- p.intro("Nuxt SEO Pro: License Verification");
33
- const siteConfig = useSiteConfig();
34
- const spinner = p.spinner();
35
- spinner.start("\u{1F511} Verifying Nuxt SEO Pro license...");
36
- const siteUrl = siteConfig.url?.startsWith("http") ? siteConfig.url : void 0;
37
- const siteName = siteConfig.name || void 0;
38
- const modules = nuxt._nuxtSeoProModules?.length > 0 ? nuxt._nuxtSeoProModules : void 0;
39
- const res = await $fetch("https://nuxtseo.com/api/pro/verify", {
40
- method: "POST",
41
- body: {
42
- apiKey: license,
43
- siteUrl,
44
- siteName,
45
- modules
46
- }
47
- }).catch((err) => {
48
- if (err?.response?.status === 401) {
49
- spinner.error("Invalid API key");
50
- p.note("Your API key is invalid.\n\nhttps://nuxtseo.com/pro/dashboard", "License Issue");
51
- throw new Error("Invalid Nuxt SEO Pro API key.");
52
- }
53
- if (err?.response?.status === 403) {
54
- spinner.error("No active subscription");
55
- p.note("Your subscription has expired or is inactive.\n\nhttps://nuxtseo.com/pro/dashboard", "License Issue");
56
- throw new Error("No active Nuxt SEO Pro subscription.");
57
- }
58
- logger.error(err);
59
- return null;
60
- });
61
- if (!res) {
62
- spinner.cancel("License verification skipped (network issue)");
63
- return;
64
- }
65
- spinner.stop("License verified \u2713");
66
- });
67
- }
21
+ const nuxt = useNuxt();
22
+ if (!nuxt.options.dev && !nuxt.options._prepare && !nuxt._isNuxtSeoProVerifying) {
23
+ const license = nuxt.options.runtimeConfig.seoProKey || process.env.NUXT_SEO_PRO_KEY;
24
+ if (isTest || process.env.VITEST) return;
25
+ if (!isCI && !license) {
26
+ p.log.warn("⚠️ Building without license in non-CI environment. A license is required for production builds.");
27
+ return;
28
+ }
29
+ if (!license) {
30
+ p.log.error("🔐 Nuxt SEO Pro license required");
31
+ p.note("Set NUXT_SEO_PRO_KEY or configure via module options.\n\nhttps://nuxtseo.com/pro/dashboard", "Get your license");
32
+ throw new Error("Missing Nuxt SEO Pro license key.");
33
+ }
34
+ nuxt._isNuxtSeoProVerifying = true;
35
+ nuxt.hooks.hook("build:before", async () => {
36
+ p.intro("Nuxt SEO Pro: License Verification");
37
+ const siteConfig = useSiteConfig();
38
+ const spinner = p.spinner();
39
+ spinner.start("🔑 Verifying Nuxt SEO Pro license...");
40
+ if (!await $fetch("https://nuxtseo.com/api/pro/verify", {
41
+ method: "POST",
42
+ body: {
43
+ apiKey: license,
44
+ siteUrl: siteConfig.url?.startsWith("http") ? siteConfig.url : void 0,
45
+ siteName: siteConfig.name || void 0,
46
+ modules: nuxt._nuxtSeoProModules?.length > 0 ? nuxt._nuxtSeoProModules : void 0
47
+ }
48
+ }).catch((err) => {
49
+ if (err?.response?.status === 401) {
50
+ spinner.error("Invalid API key");
51
+ p.note("Your API key is invalid.\n\nhttps://nuxtseo.com/pro/dashboard", "License Issue");
52
+ throw new Error("Invalid Nuxt SEO Pro API key.");
53
+ }
54
+ if (err?.response?.status === 403) {
55
+ spinner.error("No active subscription");
56
+ p.note("Your subscription has expired or is inactive.\n\nhttps://nuxtseo.com/pro/dashboard", "License Issue");
57
+ throw new Error("No active Nuxt SEO Pro subscription.");
58
+ }
59
+ logger.error(err);
60
+ return null;
61
+ })) {
62
+ spinner.cancel("License verification skipped (network issue)");
63
+ return;
64
+ }
65
+ spinner.stop("License verified ✓");
66
+ });
67
+ }
68
68
  }
69
-
69
+ //#endregion
70
70
  export { hookNuxtSeoProLicense, registerNuxtSeoProModule };
@@ -0,0 +1,16 @@
1
+ import type { NuxtDevtoolsClient } from "@nuxt/devtools-kit/types";
2
+ import type { $Fetch } from "nitropack/types";
3
+ import type { Ref } from "vue";
4
+ export declare const appFetch: Ref<$Fetch | undefined>;
5
+ export declare const devtools: Ref<NuxtDevtoolsClient | undefined>;
6
+ export declare const colorMode: Ref<"dark" | "light">;
7
+ export interface DevtoolsConnectionOptions {
8
+ onConnected?: (client: any) => void;
9
+ onRouteChange?: (route: any) => void;
10
+ }
11
+ /**
12
+ * Initialize the base devtools connection.
13
+ * Call this in your module's devtools client setup.
14
+ * Returns a cleanup function.
15
+ */
16
+ export declare function useDevtoolsConnection(options?: DevtoolsConnectionOptions): void;
@@ -0,0 +1,28 @@
1
+ import { onDevtoolsClientConnected } from "@nuxt/devtools-kit/iframe-client";
2
+ import { ref, watchEffect } from "vue";
3
+ export const appFetch = ref();
4
+ export const devtools = ref();
5
+ export const colorMode = ref("dark");
6
+ /**
7
+ * Initialize the base devtools connection.
8
+ * Call this in your module's devtools client setup.
9
+ * Returns a cleanup function.
10
+ */
11
+ export function useDevtoolsConnection(options = {}) {
12
+ onDevtoolsClientConnected(async (client) => {
13
+ // @ts-expect-error untyped
14
+ appFetch.value = client.host.app.$fetch;
15
+ watchEffect(() => {
16
+ colorMode.value = client.host.app.colorMode.value;
17
+ });
18
+ devtools.value = client.devtools;
19
+ options.onConnected?.(client);
20
+ if (options.onRouteChange) {
21
+ const $route = client.host.nuxt.vueApp.config.globalProperties?.$route;
22
+ options.onRouteChange($route);
23
+ client.host.nuxt.$router.afterEach((route) => {
24
+ options.onRouteChange(route);
25
+ });
26
+ }
27
+ });
28
+ }
@@ -0,0 +1,8 @@
1
+ import type { HighlighterCore, LanguageRegistration } from "shiki";
2
+ import type { ComputedRef, MaybeRef, Ref } from "vue";
3
+ export declare const shiki: Ref<HighlighterCore | undefined>;
4
+ export interface LoadShikiOptions {
5
+ extraLangs?: (LanguageRegistration | Promise<LanguageRegistration>)[];
6
+ }
7
+ export declare function loadShiki(options?: LoadShikiOptions): Promise<HighlighterCore>;
8
+ export declare function useRenderCodeHighlight(code: MaybeRef<string>, lang: string): ComputedRef<string>;
@@ -0,0 +1,31 @@
1
+ import { createHighlighterCore } from "shiki/core";
2
+ import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
3
+ import { computed, ref, toValue } from "vue";
4
+ import { colorMode } from "./rpc.mjs";
5
+ export const shiki = ref();
6
+ export async function loadShiki(options = {}) {
7
+ const langs = [
8
+ import("@shikijs/langs/xml"),
9
+ import("@shikijs/langs/json"),
10
+ import("@shikijs/langs/js")
11
+ ];
12
+ if (options.extraLangs) {
13
+ langs.push(...options.extraLangs);
14
+ }
15
+ shiki.value = await createHighlighterCore({
16
+ themes: [import("@shikijs/themes/vitesse-light"), import("@shikijs/themes/vitesse-dark")],
17
+ langs,
18
+ engine: createJavaScriptRegexEngine()
19
+ });
20
+ return shiki.value;
21
+ }
22
+ export function useRenderCodeHighlight(code, lang) {
23
+ return computed(() => {
24
+ if (!shiki.value) return "";
25
+ const theme = colorMode.value === "dark" ? "vitesse-dark" : "vitesse-light";
26
+ return shiki.value.codeToHtml(toValue(code) || "", {
27
+ lang,
28
+ theme
29
+ }) || "";
30
+ });
31
+ }
@@ -0,0 +1,2 @@
1
+ export { appFetch, colorMode, devtools } from "./composables/rpc.mjs";
2
+ export { loadShiki, shiki, useRenderCodeHighlight } from "./composables/shiki.mjs";
@@ -0,0 +1,2 @@
1
+ export { appFetch, colorMode, devtools } from "./composables/rpc.mjs";
2
+ export { loadShiki, shiki, useRenderCodeHighlight } from "./composables/shiki.mjs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxtseo-shared",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "description": "Shared utilities for Nuxt SEO modules.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -34,48 +34,35 @@
34
34
  "types": "./dist/pro.d.mts",
35
35
  "import": "./dist/pro.mjs"
36
36
  },
37
- "./runtime/server/kit": {
38
- "types": "./dist/runtime/server/kit.d.mts",
39
- "import": "./dist/runtime/server/kit.mjs"
37
+ "./runtime/app": {
38
+ "types": "./dist/runtime/app/index.d.mts",
39
+ "import": "./dist/runtime/app/index.mjs"
40
40
  },
41
- "./client": {
42
- "types": "./dist/client/index.d.mts",
43
- "import": "./dist/client/index.mjs"
41
+ "./runtime/app/composables/rpc": {
42
+ "types": "./dist/runtime/app/composables/rpc.d.mts",
43
+ "import": "./dist/runtime/app/composables/rpc.mjs"
44
44
  },
45
- "./client/composables/rpc": {
46
- "types": "./dist/client/composables/rpc.d.mts",
47
- "import": "./dist/client/composables/rpc.mjs"
45
+ "./runtime/app/composables/shiki": {
46
+ "types": "./dist/runtime/app/composables/shiki.d.mts",
47
+ "import": "./dist/runtime/app/composables/shiki.mjs"
48
48
  },
49
- "./client/composables/shiki": {
50
- "types": "./dist/client/composables/shiki.d.mts",
51
- "import": "./dist/client/composables/shiki.mjs"
52
- },
53
- "./client/components/OCodeBlock": "./src/client/components/OCodeBlock.vue",
54
- "./client/components/OSectionBlock": "./src/client/components/OSectionBlock.vue",
55
- "./client/components/NuxtSeoLogo": "./src/client/components/NuxtSeoLogo.vue"
49
+ "./runtime/app/components/OCodeBlock": "./dist/runtime/app/components/OCodeBlock.vue",
50
+ "./runtime/app/components/OSectionBlock": "./dist/runtime/app/components/OSectionBlock.vue",
51
+ "./runtime/app/components/NuxtSeoLogo": "./dist/runtime/app/components/NuxtSeoLogo.vue"
56
52
  },
57
53
  "main": "./dist/index.mjs",
58
54
  "types": "./dist/index.d.mts",
59
55
  "files": [
60
- "dist",
61
- "src/client/components"
56
+ "dist"
62
57
  ],
63
58
  "peerDependencies": {
64
59
  "@nuxt/schema": "^3.16.0 || ^4.0.0",
65
- "h3": "^1.15.0",
66
- "nitropack": "^2.12.0",
67
60
  "nuxt": "^3.16.0 || ^4.0.0",
68
61
  "nuxt-site-config": "^3.2.0",
69
62
  "vue": "^3.5.0",
70
63
  "zod": "^3.23.0"
71
64
  },
72
65
  "peerDependenciesMeta": {
73
- "h3": {
74
- "optional": true
75
- },
76
- "nitropack": {
77
- "optional": true
78
- },
79
66
  "nuxt-site-config": {
80
67
  "optional": true
81
68
  },
@@ -84,34 +71,32 @@
84
71
  }
85
72
  },
86
73
  "dependencies": {
87
- "@clack/prompts": "^0.10.0",
88
- "@nuxt/devtools-kit": "^2.3.0",
74
+ "@clack/prompts": "^1.1.0",
75
+ "@nuxt/devtools-kit": "^3.2.4",
89
76
  "@nuxt/kit": "^4.4.2",
90
77
  "consola": "^3.4.2",
91
78
  "defu": "^6.1.4",
92
- "ofetch": "^1.4.1",
79
+ "ofetch": "^1.5.1",
93
80
  "pathe": "^2.0.3",
94
81
  "radix3": "^1.1.2",
95
- "sirv": "^3.0.1",
96
- "std-env": "^3.9.0",
97
- "ufo": "^1.6.1"
82
+ "sirv": "^3.0.2",
83
+ "std-env": "^4.0.0",
84
+ "ufo": "^1.6.3"
98
85
  },
99
86
  "devDependencies": {
100
87
  "@nuxt/schema": "^4.4.2",
101
88
  "@nuxtjs/i18n": "^10.2.3",
102
- "@shikijs/langs": "^3.0.0",
103
- "@shikijs/themes": "^3.0.0",
104
- "@vueuse/core": "^13.0.0",
105
- "h3": "^1.15.0",
106
- "nitropack": "^2.13.1",
107
- "nuxt-site-config": "^3.2.21",
108
- "shiki": "^3.0.0",
89
+ "@shikijs/langs": "^4.0.2",
90
+ "@shikijs/themes": "^4.0.2",
91
+ "@vueuse/core": "^14.2.1",
92
+ "nuxt-site-config": "^4.0.0",
93
+ "obuild": "^0.4.32",
94
+ "shiki": "^4.0.2",
109
95
  "typescript": "^5.9.3",
110
- "unbuild": "^3.5.0",
111
- "vue": "^3.5.0"
96
+ "vue": "^3.5.30"
112
97
  },
113
98
  "scripts": {
114
- "build": "unbuild",
115
- "stub": "unbuild --stub"
99
+ "build": "obuild",
100
+ "stub": "obuild --stub"
116
101
  }
117
102
  }
@@ -1,21 +0,0 @@
1
- import * as vue from 'vue';
2
- import * as nitropack from 'nitropack';
3
- import { NuxtDevtoolsClient } from '@nuxt/devtools-kit/types';
4
- import { $Fetch } from 'nitropack/types';
5
-
6
- declare const appFetch: vue.Ref<$Fetch<unknown, nitropack.NitroFetchRequest> | undefined, $Fetch<unknown, nitropack.NitroFetchRequest> | undefined>;
7
- declare const devtools: vue.Ref<NuxtDevtoolsClient | undefined, NuxtDevtoolsClient | undefined>;
8
- declare const colorMode: vue.Ref<"dark" | "light", "dark" | "light">;
9
- interface DevtoolsConnectionOptions {
10
- onConnected?: (client: any) => void;
11
- onRouteChange?: (route: any) => void;
12
- }
13
- /**
14
- * Initialize the base devtools connection.
15
- * Call this in your module's devtools client setup.
16
- * Returns a cleanup function.
17
- */
18
- declare function useDevtoolsConnection(options?: DevtoolsConnectionOptions): void;
19
-
20
- export { appFetch, colorMode, devtools, useDevtoolsConnection };
21
- export type { DevtoolsConnectionOptions };