nuxt-og-image 5.1.7 → 5.1.9

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 (83) hide show
  1. package/dist/client/200.html +1 -15
  2. package/dist/client/404.html +1 -15
  3. package/dist/client/_nuxt/C0O1sPH1.js +4017 -0
  4. package/dist/client/_nuxt/C83k_r4_.js +1 -0
  5. package/dist/client/_nuxt/DAn4LZxu.js +1 -0
  6. package/dist/client/_nuxt/builds/latest.json +1 -1
  7. package/dist/client/_nuxt/builds/meta/9c728642-f464-4f02-9cbc-65fa9d60f818.json +1 -0
  8. package/dist/client/_nuxt/entry.Hpb5KO2G.css +1 -0
  9. package/dist/client/_nuxt/error-404.D1qMyH7R.css +1 -0
  10. package/dist/client/_nuxt/error-500.C-aGJHmP.css +1 -0
  11. package/dist/client/index.html +1 -15
  12. package/dist/content.cjs +7 -5
  13. package/dist/content.d.cts +18 -2
  14. package/dist/content.d.mts +18 -2
  15. package/dist/content.d.ts +18 -2
  16. package/dist/content.mjs +7 -6
  17. package/dist/module.cjs +35 -43
  18. package/dist/module.json +2 -3
  19. package/dist/module.mjs +37 -45
  20. package/dist/runtime/app/components/OgImage/OgImage.js +1 -1
  21. package/dist/runtime/app/components/OgImage/OgImageScreenshot.js +1 -1
  22. package/dist/runtime/app/components/Templates/Community/BrandedLogo.vue.d.ts +1 -4
  23. package/dist/runtime/app/components/Templates/Community/Frame.vue.d.ts +1 -3
  24. package/dist/runtime/app/components/Templates/Community/Nuxt.vue.d.ts +1 -5
  25. package/dist/runtime/app/components/Templates/Community/NuxtSeo.vue +2 -2
  26. package/dist/runtime/app/components/Templates/Community/NuxtSeo.vue.d.ts +1 -4
  27. package/dist/runtime/app/components/Templates/Community/Pergel.vue.d.ts +1 -5
  28. package/dist/runtime/app/components/Templates/Community/SimpleBlog.vue +2 -1
  29. package/dist/runtime/app/components/Templates/Community/SimpleBlog.vue.d.ts +1 -3
  30. package/dist/runtime/app/components/Templates/Community/UnJs.vue +1 -1
  31. package/dist/runtime/app/components/Templates/Community/UnJs.vue.d.ts +1 -8
  32. package/dist/runtime/app/components/Templates/Community/Wave.vue.d.ts +1 -3
  33. package/dist/runtime/app/components/Templates/Community/WithEmoji.vue.d.ts +1 -4
  34. package/dist/runtime/app/composables/defineOgImage.js +11 -23
  35. package/dist/runtime/app/composables/defineOgImageScreenshot.js +2 -1
  36. package/dist/runtime/app/plugins/__zero-runtime/og-image-canonical-urls.server.js +1 -1
  37. package/dist/runtime/app/plugins/__zero-runtime/route-rule-og-image.server.js +1 -1
  38. package/dist/runtime/app/plugins/og-image-canonical-urls.server.js +4 -2
  39. package/dist/runtime/app/plugins/route-rule-og-image.server.js +4 -2
  40. package/dist/runtime/app/utils/plugins.d.ts +3 -3
  41. package/dist/runtime/app/utils/plugins.js +15 -12
  42. package/dist/runtime/app/utils.d.ts +3 -1
  43. package/dist/runtime/app/utils.js +23 -5
  44. package/dist/runtime/server/og-image/bindings/chromium/on-demand.js +8 -3
  45. package/dist/runtime/server/og-image/chromium/screenshot.js +5 -4
  46. package/dist/runtime/server/og-image/context.js +14 -9
  47. package/dist/runtime/server/og-image/satori/font.js +4 -3
  48. package/dist/runtime/server/og-image/satori/plugins/flex.js +1 -1
  49. package/dist/runtime/server/og-image/satori/plugins/imageSrc.js +11 -6
  50. package/dist/runtime/server/og-image/satori/plugins/unocss.js +13 -7
  51. package/dist/runtime/server/og-image/satori/renderer.js +5 -2
  52. package/dist/runtime/server/og-image/satori/transforms/emojis.d.ts +2 -2
  53. package/dist/runtime/server/og-image/satori/transforms/inlineCss.d.ts +1 -1
  54. package/dist/runtime/server/og-image/satori/transforms/inlineCss.js +6 -5
  55. package/dist/runtime/server/og-image/templates/html.js +2 -1
  56. package/dist/runtime/server/plugins/__zero-runtime/nuxt-content-v2.d.ts +1 -1
  57. package/dist/runtime/server/plugins/__zero-runtime/nuxt-content-v2.js +1 -1
  58. package/dist/runtime/server/plugins/nuxt-content-v2.d.ts +1 -1
  59. package/dist/runtime/server/plugins/nuxt-content-v2.js +1 -1
  60. package/dist/runtime/server/plugins/prerender.d.ts +1 -1
  61. package/dist/runtime/server/plugins/prerender.js +3 -3
  62. package/dist/runtime/server/routes/debug.json.js +2 -2
  63. package/dist/runtime/server/util/cache.js +2 -2
  64. package/dist/runtime/server/util/eventHandlers.js +5 -4
  65. package/dist/runtime/server/util/kit.d.ts +2 -2
  66. package/dist/runtime/server/util/kit.js +1 -1
  67. package/dist/runtime/server/util/plugins.js +3 -2
  68. package/dist/runtime/server/utils.d.ts +4 -0
  69. package/dist/runtime/server/utils.js +20 -0
  70. package/dist/runtime/shared.d.ts +13 -4
  71. package/dist/runtime/shared.js +103 -17
  72. package/dist/runtime/types.d.ts +15 -1
  73. package/package.json +38 -31
  74. package/{virtual.d.ts → types/virtual.d.ts} +11 -2
  75. package/dist/client/_nuxt/BuG-6Qss.js +0 -4017
  76. package/dist/client/_nuxt/CN8iCxzm.js +0 -1
  77. package/dist/client/_nuxt/DK6ySO-b.js +0 -1
  78. package/dist/client/_nuxt/builds/meta/a8d773e2-13ae-466e-b246-42e9659ce587.json +0 -1
  79. package/dist/client/_nuxt/entry.BVkKIlAn.css +0 -1
  80. package/dist/client/_nuxt/error-404.CWHu2lpK.css +0 -1
  81. package/dist/client/_nuxt/error-500.xMt3qmEl.css +0 -1
  82. package/dist/runtime/pure.d.ts +0 -9
  83. package/dist/runtime/pure.js +0 -105
package/dist/module.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as fs from 'node:fs';
2
2
  import { existsSync, mkdirSync } from 'node:fs';
3
3
  import { readFile, writeFile } from 'node:fs/promises';
4
- import { resolvePath, useNuxt, addTemplate, updateTemplates, createResolver, loadNuxtModuleInstance, defineNuxtModule, addImports, addBuildPlugin, addServerHandler, hasNuxtModule, hasNuxtModuleCompatibility, addServerPlugin, addComponentsDir, addComponent, addPlugin } from '@nuxt/kit';
4
+ import { resolvePath, useNuxt, addTemplate, updateTemplates, loadNuxtModuleInstance, defineNuxtModule, createResolver, addImports, addBuildPlugin, addServerHandler, hasNuxtModule, hasNuxtModuleCompatibility, addServerPlugin, addComponentsDir, addComponent, addPlugin, addTypeTemplate } from '@nuxt/kit';
5
5
  import { defu } from 'defu';
6
6
  import { installNuxtSiteConfig } from 'nuxt-site-config/kit';
7
7
  import { hash } from 'ohash';
8
- import { dirname, relative as relative$1, isAbsolute, basename } from 'pathe';
8
+ import { dirname, isAbsolute, basename, relative as relative$1 } from 'pathe';
9
9
  import { readPackageJSON } from 'pkg-types';
10
10
  import { isCI, provider, env, isDevelopment } from 'std-env';
11
11
  import { parseURL, parseQuery, withoutLeadingSlash } from 'ufo';
@@ -129,6 +129,7 @@ const RuntimeCompatibility = {
129
129
  "satori": "node",
130
130
  "sharp": false,
131
131
  "wasm": {
132
+ // @ts-expect-error untyped
132
133
  rollup: {
133
134
  targetEnv: "auto-inline",
134
135
  sync: ["@resvg/resvg-wasm/index_bg.wasm"]
@@ -289,7 +290,7 @@ async function setupBuildHandler(config, resolve, nuxt = useNuxt()) {
289
290
  }
290
291
  async function resolveFilePathSha1(path) {
291
292
  const _path = await resolvePath(path);
292
- return sha1(existsSync(_path) ? await readFile(_path) : path);
293
+ return sha1(existsSync(_path) ? await readFile(_path) : Buffer.from(path));
293
294
  }
294
295
  function sha1(source) {
295
296
  return createHash("sha1").update(source).digest("hex").slice(0, 16);
@@ -333,11 +334,11 @@ function setupDevToolsUI(options, resolve, nuxt = useNuxt()) {
333
334
  const rpc = extendServerRpc("nuxt-og-image", {
334
335
  async ejectCommunityTemplate(path) {
335
336
  const [dirName, componentName] = path.split("/");
336
- const dir = resolve(nuxt.options.rootDir, "components", dirName);
337
+ const dir = resolve(nuxt.options.rootDir, "components", dirName || "");
337
338
  if (!existsSync(dir)) {
338
339
  mkdirSync(dir);
339
340
  }
340
- const newPath = resolve(dir, componentName);
341
+ const newPath = resolve(dir, componentName || "");
341
342
  const templatePath = resolve(`./runtime/app/components/Templates/Community/${componentName}`);
342
343
  const template = (await readFile(templatePath, "utf-8")).replace("{{ title }}", `{{ title }} - Ejected!`);
343
344
  await writeFile(newPath, template, { encoding: "utf-8" });
@@ -487,30 +488,6 @@ async function getNuxtModuleOptions(module, nuxt = useNuxt()) {
487
488
  return nuxtModule.getOptions(inlineOptions, nuxt);
488
489
  return inlineOptions;
489
490
  }
490
- function extendTypes(module, template) {
491
- const nuxt = useNuxt();
492
- const { resolve } = createResolver(import.meta.url);
493
- addTemplate({
494
- filename: `module/${module}.d.ts`,
495
- getContents: async () => {
496
- const typesPath = relative$1(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), resolve("runtime/types"));
497
- const s = await template({ typesPath });
498
- return `// Generated by ${module}
499
- ${s}
500
- export {}
501
- `;
502
- }
503
- });
504
- nuxt.hooks.hook("prepare:types", ({ references }) => {
505
- references.push({ path: resolve(nuxt.options.buildDir, `module/${module}.d.ts`) });
506
- });
507
- nuxt.hooks.hook("nitro:config", (config) => {
508
- config.typescript = config.typescript || {};
509
- config.typescript.tsConfig = config.typescript.tsConfig || {};
510
- config.typescript.tsConfig.include = config.typescript.tsConfig.include || [];
511
- config.typescript.tsConfig.include.push(`./module/${module}.d.ts`);
512
- });
513
- }
514
491
  function isNuxtGenerate(nuxt = useNuxt()) {
515
492
  return nuxt.options._generate || nuxt.options.nitro.static || nuxt.options.nitro.preset === "static";
516
493
  }
@@ -555,8 +532,7 @@ const module = defineNuxtModule({
555
532
  meta: {
556
533
  name: "nuxt-og-image",
557
534
  compatibility: {
558
- nuxt: ">=3.16.0",
559
- bridge: false
535
+ nuxt: ">=3.16.0"
560
536
  },
561
537
  configKey: "ogImage"
562
538
  },
@@ -617,7 +593,7 @@ const module = defineNuxtModule({
617
593
  const basePath = config.zeroRuntime ? "./runtime/server/routes/__zero-runtime" : "./runtime/server/routes";
618
594
  let publicDirAbs = nuxt.options.dir.public;
619
595
  if (!isAbsolute(publicDirAbs)) {
620
- publicDirAbs = publicDirAbs in nuxt.options.alias ? nuxt.options.alias[publicDirAbs] : resolve(nuxt.options.rootDir, publicDirAbs);
596
+ publicDirAbs = (publicDirAbs in nuxt.options.alias ? nuxt.options.alias[publicDirAbs] : resolve(nuxt.options.rootDir, publicDirAbs)) || "";
621
597
  }
622
598
  if (isProviderEnabledForEnv("satori", nuxt, config)) {
623
599
  let attemptSharpUsage = false;
@@ -818,6 +794,8 @@ const module = defineNuxtModule({
818
794
  from: resolve(`./runtime/app/composables/${name}`)
819
795
  });
820
796
  if (!nuxt.options.dev) {
797
+ nuxt.options.optimization.treeShake.composables.client = nuxt.options.optimization.treeShake.composables.client || {};
798
+ nuxt.options.optimization.treeShake.composables.client["nuxt-og-image"] = nuxt.options.optimization.treeShake.composables.client["nuxt-og-image"] || [];
821
799
  nuxt.options.optimization.treeShake.composables.client["nuxt-og-image"].push(name);
822
800
  }
823
801
  });
@@ -879,7 +857,7 @@ const module = defineNuxtModule({
879
857
  hash: hash(componentFile).replaceAll("_", "-"),
880
858
  pascalName: component.pascalName,
881
859
  kebabName: component.kebabName,
882
- path: nuxt.options.dev ? component.filePath : void 0,
860
+ path: component.filePath,
883
861
  category,
884
862
  credits
885
863
  });
@@ -908,17 +886,18 @@ const module = defineNuxtModule({
908
886
  nuxt.options.nitro.virtual["#og-image-virtual/unocss-config.mjs"] = () => {
909
887
  return `export const theme = ${JSON.stringify(unoCssConfig)}`;
910
888
  };
911
- extendTypes("nuxt-og-image", ({ typesPath }) => {
912
- const componentImports = ogImageComponentCtx.components.map((component) => {
913
- const relativeComponentPath = relative$1(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), component.path);
914
- const name = config.componentDirs.sort((a, b) => b.length - a.length).reduce((name2, dir) => {
915
- return name2.replace(new RegExp(`^${dir}`), "");
916
- }, component.pascalName);
917
- return ` '${name}': typeof import('${relativeComponentPath}')['default']`;
918
- }).join("\n");
919
- return `
920
- declare module 'nitropack' {
921
- interface NitroRouteRules {
889
+ addTypeTemplate({
890
+ filename: "module/nuxt-og-image.d.ts",
891
+ getContents: (data) => {
892
+ const typesPath = relative$1(resolve(data.nuxt.options.rootDir, data.nuxt.options.buildDir, "module"), resolve("runtime/types"));
893
+ const componentImports = ogImageComponentCtx.components.map((component) => {
894
+ const relativeComponentPath = relative$1(resolve(nuxt.options.rootDir, nuxt.options.buildDir, "module"), component.path);
895
+ const name = config.componentDirs.sort((a, b) => b.length - a.length).reduce((name2, dir) => {
896
+ return name2.replace(new RegExp(`^${dir}`), "");
897
+ }, component.pascalName);
898
+ return ` '${name}': typeof import('${relativeComponentPath}')['default']`;
899
+ }).join("\n");
900
+ const types = `interface NitroRouteRules {
922
901
  ogImage?: false | import('${typesPath}').OgImageOptions & Record<string, any>
923
902
  }
924
903
  interface NitroRouteConfig {
@@ -927,7 +906,14 @@ declare module 'nitropack' {
927
906
  interface NitroRuntimeHooks {
928
907
  'nuxt-og-image:context': (ctx: import('${typesPath}').OgImageRenderEventContext) => void | Promise<void>
929
908
  'nuxt-og-image:satori:vnodes': (vnodes: import('${typesPath}').VNode, ctx: import('${typesPath}').OgImageRenderEventContext) => void | Promise<void>
930
- }
909
+ }`;
910
+ return `
911
+ declare module 'nitropack' {
912
+ ${types}
913
+ }
914
+
915
+ declare module 'nitropack/types' {
916
+ ${types}
931
917
  }
932
918
 
933
919
  declare module '#og-image/components' {
@@ -938,7 +924,13 @@ ${componentImports}
938
924
  declare module '#og-image/unocss-config' {
939
925
  export type theme = any
940
926
  }
927
+
928
+ export {}
941
929
  `;
930
+ }
931
+ }, {
932
+ nitro: true,
933
+ nuxt: true
942
934
  });
943
935
  const cacheEnabled = typeof config.runtimeCacheStorage !== "undefined" && config.runtimeCacheStorage !== false;
944
936
  const runtimeCacheStorage = typeof config.runtimeCacheStorage === "boolean" ? "default" : config.runtimeCacheStorage.driver;
@@ -1,5 +1,5 @@
1
- import { defineOgImage } from "#imports";
2
1
  import { defineComponent } from "vue";
2
+ import { defineOgImage } from "../../composables/defineOgImage.js";
3
3
  export default defineComponent({
4
4
  name: "OgImage",
5
5
  async setup(_, { attrs }) {
@@ -1,5 +1,5 @@
1
- import { defineOgImageScreenshot } from "#imports";
2
1
  import { defineComponent } from "vue";
2
+ import { defineOgImageScreenshot } from "../../composables/defineOgImageScreenshot.js";
3
3
  export default defineComponent({
4
4
  name: "OgImageScreenshot",
5
5
  async setup(_, { attrs }) {
@@ -5,8 +5,5 @@ type __VLS_Props = {
5
5
  title?: string;
6
6
  logo?: string;
7
7
  };
8
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
9
- title: string;
10
- logo: string;
11
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
9
  export default _default;
@@ -14,7 +14,5 @@ type __VLS_Props = {
14
14
  icon: string;
15
15
  }[];
16
16
  };
17
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
18
- bg: string;
19
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
18
  export default _default;
@@ -3,9 +3,5 @@ type __VLS_Props = {
3
3
  description?: string;
4
4
  headline?: string;
5
5
  };
6
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
7
- title: string;
8
- description: string;
9
- headline: string;
10
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
7
  export default _default;
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
- import { useSiteConfig } from "#imports";
3
- import { useOgImageRuntimeConfig } from "#og-image/shared";
2
+ import { useOgImageRuntimeConfig } from "#og-image/app/utils";
3
+ import { useSiteConfig } from "#site-config/app/composables";
4
4
  import { computed, defineComponent, h, resolveComponent } from "vue";
5
5
  const props = defineProps({
6
6
  colorMode: { type: String, required: false },
@@ -7,8 +7,5 @@ type __VLS_Props = {
7
7
  siteLogo?: string;
8
8
  theme?: string;
9
9
  };
10
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
11
- title: string;
12
- theme: string;
13
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
11
  export default _default;
@@ -3,9 +3,5 @@ type __VLS_Props = {
3
3
  description?: string;
4
4
  headline?: string;
5
5
  };
6
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
7
- title: string;
8
- description: string;
9
- headline: string;
10
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
7
  export default _default;
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
- import { computed, useSiteConfig } from "#imports";
2
+ import { useSiteConfig } from "#site-config/app/composables";
3
3
  import { parseURL } from "ufo";
4
+ import { computed } from "vue";
4
5
  const props = defineProps({
5
6
  title: { type: String, required: false, default: "title" },
6
7
  website: { type: String, required: false }
@@ -2,7 +2,5 @@ type __VLS_Props = {
2
2
  title?: string;
3
3
  website?: string;
4
4
  };
5
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
- title: string;
7
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
6
  export default _default;
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "#imports";
2
+ import { computed } from "vue";
3
3
  const props = defineProps({
4
4
  title: { type: String, required: false, default: "unjs/h3" },
5
5
  description: { type: String, required: false, default: "Minimal H(TTP) framework built for high performance and portability" },
@@ -9,12 +9,5 @@ type __VLS_Props = {
9
9
  stars?: string | number;
10
10
  contributors?: string | number;
11
11
  };
12
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
13
- title: string;
14
- description: string;
15
- emoji: string;
16
- downloads: string | number;
17
- stars: string | number;
18
- contributors: string | number;
19
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
13
  export default _default;
@@ -4,7 +4,5 @@
4
4
  type __VLS_Props = {
5
5
  title?: string;
6
6
  };
7
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
8
- title: string;
9
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
8
  export default _default;
@@ -5,8 +5,5 @@ type __VLS_Props = {
5
5
  emoji?: string;
6
6
  title?: string;
7
7
  };
8
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
9
- title: string;
10
- emoji: string;
11
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
9
  export default _default;
@@ -1,9 +1,7 @@
1
1
  import { appendHeader } from "h3";
2
2
  import { createError, useNuxtApp, useRequestEvent, useRoute, useState } from "nuxt/app";
3
3
  import { ref, toValue } from "vue";
4
- import { createNitroRouteRuleMatcher } from "../../server/util/kit.js";
5
- import { getOgImagePath, useOgImageRuntimeConfig } from "../../shared.js";
6
- import { createOgImageMeta, setHeadOgImagePrebuilt } from "../utils.js";
4
+ import { createOgImageMeta, getOgImagePath, setHeadOgImagePrebuilt, useOgImageRuntimeConfig } from "../utils.js";
7
5
  export function defineOgImage(_options = {}) {
8
6
  const nuxtApp = useNuxtApp();
9
7
  const route = useRoute();
@@ -21,35 +19,25 @@ export function defineOgImage(_options = {}) {
21
19
  if (!import.meta.server) {
22
20
  return;
23
21
  }
24
- const ogImageInstances = nuxtApp.ssrContext._ogImageInstances || [];
25
- const routeRuleMatcher = createNitroRouteRuleMatcher();
26
- const routeRules = routeRuleMatcher(basePath).ogImage;
27
- if (!_options || nuxtApp.ssrContext?.event.context._nitro?.routeRules?.ogImage === false || typeof routeRules !== "undefined" && routeRules === false) {
28
- ogImageInstances.forEach((e) => {
29
- e.dispose();
30
- });
31
- nuxtApp.ssrContext._ogImageInstances = void 0;
32
- return;
33
- }
34
22
  const { defaults } = useOgImageRuntimeConfig();
35
23
  const options = toValue(_options);
36
- for (const key in routeRules) {
37
- if (options[key] === void 0)
38
- options[key] = routeRules[key];
24
+ if (options === false) {
25
+ return;
39
26
  }
27
+ const validOptions = options;
40
28
  for (const key in defaults) {
41
- if (options[key] === void 0)
42
- options[key] = defaults[key];
29
+ if (validOptions[key] === void 0)
30
+ validOptions[key] = defaults[key];
43
31
  }
44
32
  if (route.query)
45
- options._query = route.query;
46
- if (options.url) {
47
- setHeadOgImagePrebuilt(options);
33
+ validOptions._query = route.query;
34
+ if (validOptions.url) {
35
+ setHeadOgImagePrebuilt(validOptions);
48
36
  return;
49
37
  }
50
- const path = getOgImagePath(basePath, options);
38
+ const path = getOgImagePath(basePath, validOptions);
51
39
  if (import.meta.prerender) {
52
40
  appendHeader(useRequestEvent(nuxtApp), "x-nitro-prerender", path);
53
41
  }
54
- createOgImageMeta(path, options, nuxtApp.ssrContext);
42
+ createOgImageMeta(path, validOptions, nuxtApp.ssrContext);
55
43
  }
@@ -1,4 +1,5 @@
1
- import { defineOgImage, useRouter } from "#imports";
1
+ import { useRouter } from "#app";
2
+ import { defineOgImage } from "./defineOgImage.js";
2
3
  export function defineOgImageScreenshot(options = {}) {
3
4
  const router = useRouter();
4
5
  const route = router.currentRoute.value?.path || "/";
@@ -1,4 +1,4 @@
1
- import { defineNuxtPlugin } from "#imports";
1
+ import { defineNuxtPlugin } from "#app";
2
2
  import { ogImageCanonicalUrls as setup } from "../../utils/plugins.js";
3
3
  export default defineNuxtPlugin({
4
4
  setup(nuxtApp) {
@@ -1,4 +1,4 @@
1
- import { defineNuxtPlugin } from "#imports";
1
+ import { defineNuxtPlugin } from "#app";
2
2
  import { routeRuleOgImage as setup } from "../../utils/plugins.js";
3
3
  export default defineNuxtPlugin({
4
4
  setup(nuxtApp) {
@@ -1,5 +1,7 @@
1
- import { defineNuxtPlugin } from "#imports";
1
+ import { defineNuxtPlugin } from "#app";
2
2
  import { ogImageCanonicalUrls as setup } from "../utils/plugins.js";
3
3
  export default defineNuxtPlugin({
4
- setup
4
+ setup(nuxtApp) {
5
+ setup(nuxtApp);
6
+ }
5
7
  });
@@ -1,5 +1,7 @@
1
- import { defineNuxtPlugin } from "#imports";
1
+ import { defineNuxtPlugin } from "#app";
2
2
  import { routeRuleOgImage as setup } from "../utils/plugins.js";
3
3
  export default defineNuxtPlugin({
4
- setup
4
+ setup(nuxtApp) {
5
+ setup(nuxtApp);
6
+ }
5
7
  });
@@ -1,3 +1,3 @@
1
- import type { NuxtApp } from 'nuxt/app';
2
- export declare function ogImageCanonicalUrls(nuxtApp: NuxtApp): void;
3
- export declare function routeRuleOgImage(nuxtApp: NuxtApp): void;
1
+ import type { NuxtSSRContext } from '#app/nuxt';
2
+ export declare function ogImageCanonicalUrls(nuxtApp: NuxtSSRContext['nuxt']): void;
3
+ export declare function routeRuleOgImage(nuxtApp: NuxtSSRContext['nuxt']): void;
@@ -1,4 +1,5 @@
1
- import { useRequestEvent, withSiteUrl } from "#imports";
1
+ import { useRequestEvent } from "#app";
2
+ import { withSiteUrl } from "#site-config/app/composables";
2
3
  import { TemplateParamsPlugin } from "@unhead/vue/plugins";
3
4
  import { defu } from "defu";
4
5
  import { parse, stringify } from "devalue";
@@ -6,13 +7,13 @@ import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
6
7
  import { parseURL, withoutBase } from "ufo";
7
8
  import { toValue } from "vue";
8
9
  import { createOgImageMeta } from "../../app/utils.js";
9
- import { isInternalRoute, separateProps } from "../../pure.js";
10
- import { getOgImagePath } from "../../shared.js";
10
+ import { isInternalRoute, separateProps } from "../../shared.js";
11
+ import { getOgImagePath } from "../utils.js";
11
12
  export function ogImageCanonicalUrls(nuxtApp) {
12
13
  nuxtApp.hooks.hook("app:rendered", async (ctx) => {
13
14
  const { ssrContext } = ctx;
14
15
  const e = useRequestEvent();
15
- const path = parseURL(e.path).pathname;
16
+ const path = parseURL(e?.path || "").pathname;
16
17
  if (isInternalRoute(path))
17
18
  return;
18
19
  ssrContext?.head.use(TemplateParamsPlugin);
@@ -37,20 +38,20 @@ export function ogImageCanonicalUrls(nuxtApp) {
37
38
  }
38
39
  ctx2.tags = ctx2.tags.filter(Boolean);
39
40
  for (const tag of ctx2.tags) {
40
- if (tag.tag === "meta" && (tag.props.property === "og:image" || ["twitter:image:src", "twitter:image"].includes(tag.props.name))) {
41
+ if (tag.tag === "meta" && (tag.props.property === "og:image" || ["twitter:image:src", "twitter:image"].includes(tag.props.name || ""))) {
41
42
  if (!tag.props.content) {
42
43
  tag.props = {};
43
44
  continue;
44
45
  }
45
46
  if (!tag.props.content?.startsWith("https")) {
46
47
  await nuxtApp.runWithContext(() => {
47
- tag.props.content = toValue(withSiteUrl(tag.props.content, {
48
+ tag.props.content = toValue(withSiteUrl(tag.props.content || "", {
48
49
  withBase: true
49
50
  }));
50
51
  });
51
52
  }
52
53
  } else if (overrides && tag.tag === "script" && tag.props.id === "nuxt-og-image-options") {
53
- tag.innerHTML = stringify(defu(overrides, parse(tag.innerHTML)));
54
+ tag.innerHTML = stringify(defu(overrides, parse(tag.innerHTML || "{}")));
54
55
  }
55
56
  }
56
57
  }
@@ -62,15 +63,17 @@ export function routeRuleOgImage(nuxtApp) {
62
63
  nuxtApp.hooks.hook("app:rendered", async (ctx) => {
63
64
  const { ssrContext } = ctx;
64
65
  const e = useRequestEvent();
65
- const path = parseURL(e.path).pathname;
66
+ const path = parseURL(e?.path || "").pathname;
66
67
  if (isInternalRoute(path))
67
68
  return;
68
69
  const _routeRulesMatcher = toRouteMatcher(
69
70
  createRadixRouter({ routes: ssrContext?.runtimeConfig?.nitro?.routeRules })
70
71
  );
71
- let routeRules = defu({}, ..._routeRulesMatcher.matchAll(
72
- withoutBase(path.split("?")[0], ssrContext?.runtimeConfig?.app.baseURL)
73
- ).reverse()).ogImage;
72
+ const matchedRules = _routeRulesMatcher.matchAll(
73
+ withoutBase(path.split("?")?.[0] || "", ssrContext?.runtimeConfig?.app.baseURL || "")
74
+ ).reverse();
75
+ const combinedRules = defu({}, ...matchedRules);
76
+ let routeRules = combinedRules?.ogImage;
74
77
  if (typeof routeRules === "undefined")
75
78
  return;
76
79
  const ogImageInstances = nuxtApp.ssrContext._ogImageInstances || [];
@@ -82,7 +85,7 @@ export function routeRuleOgImage(nuxtApp) {
82
85
  nuxtApp.ssrContext._ogImageInstances = void 0;
83
86
  return;
84
87
  }
85
- routeRules = defu(nuxtApp.ssrContext?.event.context._nitro?.routeRules?.ogImage, routeRules);
88
+ routeRules = defu(nuxtApp.ssrContext?.event?.context._nitro?.routeRules?.ogImage, routeRules);
86
89
  const src = getOgImagePath(ssrContext.url, routeRules);
87
90
  createOgImageMeta(src, routeRules, nuxtApp.ssrContext);
88
91
  });
@@ -1,5 +1,7 @@
1
1
  import type { NuxtSSRContext } from 'nuxt/app';
2
- import type { OgImageOptions, OgImagePrebuilt } from '../types.js';
2
+ import type { OgImageOptions, OgImagePrebuilt, OgImageRuntimeConfig } from '../types.js';
3
3
  export declare function setHeadOgImagePrebuilt(input: OgImagePrebuilt): void;
4
4
  export declare function createOgImageMeta(src: string, input: OgImageOptions | OgImagePrebuilt, ssrContext: NuxtSSRContext): void;
5
5
  export declare function resolveComponentName(component: OgImageOptions['component'], fallback: string): OgImageOptions['component'];
6
+ export declare function getOgImagePath(pagePath: string, _options?: Partial<OgImageOptions>): string;
7
+ export declare function useOgImageRuntimeConfig(): OgImageRuntimeConfig;
@@ -1,10 +1,10 @@
1
+ import { useHead, useRuntimeConfig } from "#app";
1
2
  import { componentNames } from "#build/nuxt-og-image/components.mjs";
2
- import { useHead } from "#imports";
3
3
  import { resolveUnrefHeadInput } from "@unhead/vue";
4
4
  import { defu } from "defu";
5
5
  import { stringify } from "devalue";
6
- import { withQuery } from "ufo";
7
- import { generateMeta, separateProps, useOgImageRuntimeConfig } from "../shared.js";
6
+ import { joinURL, withQuery } from "ufo";
7
+ import { generateMeta, separateProps } from "../shared.js";
8
8
  export function setHeadOgImagePrebuilt(input) {
9
9
  if (import.meta.client) {
10
10
  return;
@@ -33,9 +33,9 @@ export function createOgImageMeta(src, input, ssrContext) {
33
33
  processTemplateParams: true,
34
34
  innerHTML: () => {
35
35
  const payload = resolveUnrefHeadInput(_input);
36
- if (typeof payload.props.title === "undefined")
36
+ if (payload.props && typeof payload.props.title === "undefined")
37
37
  payload.props.title = "%s";
38
- payload.component = resolveComponentName(input.component, defaults.component);
38
+ payload.component = resolveComponentName(input.component, defaults.component || "");
39
39
  delete payload.url;
40
40
  if (payload._query && Object.keys(payload._query).length === 0) {
41
41
  delete payload._query;
@@ -73,3 +73,21 @@ export function resolveComponentName(component, fallback) {
73
73
  }
74
74
  return component;
75
75
  }
76
+ export function getOgImagePath(pagePath, _options) {
77
+ const baseURL = useRuntimeConfig().app.baseURL;
78
+ const extension = _options?.extension || useOgImageRuntimeConfig().defaults.extension;
79
+ const path = joinURL("/", baseURL, `__og-image__/${import.meta.prerender ? "static" : "image"}`, pagePath, `og.${extension}`);
80
+ if (Object.keys(_options?._query || {}).length) {
81
+ return withQuery(path, _options._query);
82
+ }
83
+ return path;
84
+ }
85
+ export function useOgImageRuntimeConfig() {
86
+ const c = useRuntimeConfig();
87
+ return {
88
+ ...c["nuxt-og-image"],
89
+ app: {
90
+ baseURL: c.app.baseURL
91
+ }
92
+ };
93
+ }
@@ -11,14 +11,19 @@ export async function createBrowser() {
11
11
  const logger = createConsola().withTag("Nuxt OG Image");
12
12
  logger.info("Installing Chromium install for og:image generation...");
13
13
  const installChromeProcess = execa("npx", ["playwright", "install", "chromium"], {
14
- stdio: "inherit"
14
+ stdio: "pipe"
15
15
  });
16
- installChromeProcess.stderr?.pipe(process.stderr);
16
+ if (installChromeProcess.stderr) {
17
+ installChromeProcess.stderr.pipe(process.stderr);
18
+ }
19
+ if (installChromeProcess.stdout) {
20
+ installChromeProcess.stdout.pipe(process.stdout);
21
+ }
17
22
  new Promise((resolve) => {
18
23
  installChromeProcess.on("exit", (e) => {
19
24
  if (e !== 0)
20
25
  logger.error("Failed to install Playwright dependency for og:image generation. Trying anyway...");
21
- resolve(true);
26
+ resolve();
22
27
  });
23
28
  }).then(() => {
24
29
  installChromeProcess.kill();
@@ -1,6 +1,7 @@
1
- import { useNitroOrigin } from "#imports";
1
+ import { useNitroOrigin } from "#site-config/server/composables";
2
2
  import { joinURL, withQuery } from "ufo";
3
- import { useOgImageRuntimeConfig } from "../../../shared.js";
3
+ import { toValue } from "vue";
4
+ import { useOgImageRuntimeConfig } from "../../utils.js";
4
5
  export async function createScreenshot({ basePath, e, options, extension }, browser) {
5
6
  const { colorPreference } = useOgImageRuntimeConfig();
6
7
  const path = options.component === "PageScreenshot" ? basePath : joinURL("/__og-image__/image", basePath, `og.html`);
@@ -13,8 +14,8 @@ export async function createScreenshot({ basePath, e, options, extension }, brow
13
14
  options.html = await e.$fetch(path).catch(() => void 0);
14
15
  }
15
16
  await page.setViewportSize({
16
- width: options.width || 1200,
17
- height: options.height || 630
17
+ width: toValue(options.width) || 1200,
18
+ height: toValue(options.height) || 630
18
19
  });
19
20
  if (options.html) {
20
21
  const html = options.html;