nuxt-og-image 5.1.4 → 5.1.6

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.
@@ -1,5 +1,6 @@
1
1
  import { fontCache } from "#og-image-cache";
2
2
  import { theme } from "#og-image-virtual/unocss-config.mjs";
3
+ import compatibility from "#og-image/compatibility";
3
4
  import { defu } from "defu";
4
5
  import { sendError } from "h3";
5
6
  import { normaliseFontInput, useOgImageRuntimeConfig } from "../../../shared.js";
@@ -67,9 +68,31 @@ async function createPng(event) {
67
68
  }
68
69
  async function createJpeg(event) {
69
70
  const { sharpOptions } = useOgImageRuntimeConfig();
70
- const png = await createPng(event);
71
- const sharp = await useSharp();
72
- return sharp(png, defu(event.options.sharp, sharpOptions)).jpeg().toBuffer();
71
+ if (compatibility.sharp === false) {
72
+ if (import.meta.dev) {
73
+ throw new Error("Sharp dependency is not accessible. Please check you have it installed and are using a compatible runtime.");
74
+ } else {
75
+ console.error("Sharp dependency is not accessible. Please check you have it installed and are using a compatible runtime. Falling back to png.");
76
+ }
77
+ return createPng(event);
78
+ }
79
+ const svg = await createSvg(event);
80
+ if (!svg) {
81
+ throw new Error("Failed to create SVG for JPEG rendering.");
82
+ }
83
+ const svgBuffer = Buffer.from(svg);
84
+ const sharp = await useSharp().catch(() => {
85
+ if (import.meta.dev) {
86
+ throw new Error("Sharp dependency could not be loaded. Please check you have it installed and are using a compatible runtime.");
87
+ }
88
+ return null;
89
+ });
90
+ if (!sharp) {
91
+ console.error("Sharp dependency is not accessible. Please check you have it installed and are using a compatible runtime. Falling back to png.");
92
+ return createPng(event);
93
+ }
94
+ const options = defu(event.options.sharp, sharpOptions);
95
+ return sharp(svgBuffer, options).jpeg(options).toBuffer();
73
96
  }
74
97
  const SatoriRenderer = {
75
98
  name: "satori",
@@ -4,8 +4,8 @@ import { useCssInline } from "../instances.js";
4
4
  export async function applyInlineCss(ctx, island) {
5
5
  const { e } = ctx;
6
6
  let html = island.html;
7
- let css = island.head.style.map((s) => s.innerHTML).filter(Boolean).join("\n");
8
- const componentInlineStyles = island.head.link.filter((l) => l.href.startsWith("/_nuxt/components") && l.href.replaceAll("/", "").includes(ctx.options.component));
7
+ let css = island.head.style?.map((s) => s.innerHTML).filter(Boolean).join("\n") || "";
8
+ const componentInlineStyles = island.head.link?.filter((l) => l.href.startsWith("/_nuxt/components") && l.href.replaceAll("/", "").includes(ctx.options.component)) || [];
9
9
  if (!import.meta.prerender && !componentInlineStyles.length) {
10
10
  return false;
11
11
  }
@@ -7,7 +7,7 @@ import type { NitroOptions } from 'nitropack';
7
7
  import type { NitroApp } from 'nitropack/types';
8
8
  import type { SatoriOptions } from 'satori';
9
9
  import type { html } from 'satori-html';
10
- import type { SharpOptions } from 'sharp';
10
+ import type { JpegOptions, SharpOptions } from 'sharp';
11
11
  import type { Ref } from 'vue';
12
12
  export interface OgImageRenderEventContext {
13
13
  unocss: UnoGenerator;
@@ -116,7 +116,7 @@ export interface OgImageOptions<T extends keyof OgImageComponents = 'NuxtSeo'> {
116
116
  resvg?: ResvgRenderOptions;
117
117
  satori?: SatoriOptions;
118
118
  screenshot?: Partial<ScreenshotOptions>;
119
- sharp?: SharpOptions;
119
+ sharp?: SharpOptions & JpegOptions;
120
120
  fonts?: InputFontConfig[];
121
121
  cacheMaxAgeSeconds?: number;
122
122
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-og-image",
3
3
  "type": "module",
4
- "version": "5.1.4",
4
+ "version": "5.1.6",
5
5
  "description": "Enlightened OG Image generation for Nuxt.",
6
6
  "author": {
7
7
  "website": "https://harlanzw.com",
@@ -48,16 +48,16 @@
48
48
  "unstorage": "^1.15.0"
49
49
  },
50
50
  "dependencies": {
51
- "@nuxt/devtools-kit": "^2.4.1",
52
- "@nuxt/kit": "^3.17.3",
51
+ "@nuxt/devtools-kit": "^2.5.0",
52
+ "@nuxt/kit": "^3.17.5",
53
53
  "@resvg/resvg-js": "^2.6.2",
54
54
  "@resvg/resvg-wasm": "^2.6.2",
55
- "@unocss/core": "^66.1.2",
56
- "@unocss/preset-wind3": "^66.1.2",
55
+ "@unocss/core": "^66.1.3",
56
+ "@unocss/preset-wind3": "^66.1.3",
57
57
  "chrome-launcher": "^1.2.0",
58
58
  "consola": "^3.4.2",
59
59
  "defu": "^6.1.4",
60
- "execa": "^9.5.3",
60
+ "execa": "^9.6.0",
61
61
  "image-size": "^2.0.2",
62
62
  "magic-string": "^0.30.17",
63
63
  "mocked-exports": "^0.1.1",
@@ -69,52 +69,52 @@
69
69
  "pkg-types": "^2.1.0",
70
70
  "playwright-core": "^1.52.0",
71
71
  "radix3": "^1.1.2",
72
- "satori": "^0.13.1",
72
+ "satori": "^0.13.2",
73
73
  "satori-html": "^0.3.2",
74
74
  "sirv": "^3.0.1",
75
75
  "std-env": "^3.9.0",
76
76
  "strip-literal": "^3.0.0",
77
77
  "ufo": "^1.6.1",
78
- "unplugin": "^2.3.4",
78
+ "unplugin": "^2.3.5",
79
79
  "unwasm": "^0.3.9",
80
80
  "yoga-wasm-web": "^0.3.3"
81
81
  },
82
82
  "devDependencies": {
83
- "@antfu/eslint-config": "^4.13.1",
83
+ "@antfu/eslint-config": "^4.13.3",
84
84
  "@css-inline/css-inline": "^0.14.3",
85
85
  "@headlessui/vue": "^1.7.23",
86
- "@iconify-json/carbon": "^1.2.8",
86
+ "@iconify-json/carbon": "^1.2.9",
87
87
  "@iconify-json/logos": "^1.2.4",
88
88
  "@iconify-json/noto": "^1.2.3",
89
89
  "@iconify-json/ri": "^1.2.5",
90
- "@iconify-json/tabler": "^1.2.18",
91
- "@img/sharp-linux-x64": "^0.34.1",
90
+ "@iconify-json/tabler": "^1.2.19",
91
+ "@img/sharp-linux-x64": "^0.34.2",
92
92
  "@nuxt/content": "^3.5.1",
93
- "@nuxt/devtools": "^2.4.1",
94
- "@nuxt/devtools-ui-kit": "^2.4.1",
93
+ "@nuxt/devtools": "^2.5.0",
94
+ "@nuxt/devtools-ui-kit": "^2.5.0",
95
95
  "@nuxt/icon": "^1.13.0",
96
96
  "@nuxt/image": "^1.10.0",
97
97
  "@nuxt/module-builder": "^1.0.1",
98
- "@nuxt/test-utils": "^3.19.0",
99
- "@nuxt/ui": "^3.1.2",
98
+ "@nuxt/test-utils": "^3.19.1",
99
+ "@nuxt/ui": "^3.1.3",
100
100
  "@nuxtjs/color-mode": "^3.5.2",
101
101
  "@nuxtjs/eslint-config-typescript": "^12.1.0",
102
- "@nuxtjs/i18n": "^9.5.4",
102
+ "@nuxtjs/i18n": "^9.5.5",
103
103
  "@nuxtjs/tailwindcss": "^6.14.0",
104
- "@unocss/nuxt": "^66.1.2",
105
- "@unocss/preset-icons": "^66.1.2",
106
- "@unocss/runtime": "^66.1.2",
107
- "@vueuse/nuxt": "^13.2.0",
104
+ "@unocss/nuxt": "^66.1.3",
105
+ "@unocss/preset-icons": "^66.1.3",
106
+ "@unocss/runtime": "^66.1.3",
107
+ "@vueuse/nuxt": "^13.3.0",
108
108
  "bumpp": "^10.1.1",
109
- "eslint": "9.25.1",
110
- "jest-image-snapshot": "^6.5.0",
111
- "nuxt": "^3.17.3",
109
+ "eslint": "9.28.0",
110
+ "jest-image-snapshot": "^6.5.1",
111
+ "nuxt": "^3.17.5",
112
112
  "playwright": "^1.52.0",
113
- "sass": "^1.89.0",
114
- "sharp": "^0.34.1",
113
+ "sass": "^1.89.1",
114
+ "sharp": "^0.34.2",
115
115
  "typescript": "^5.8.3",
116
- "unocss": "^66.1.2",
117
- "vitest": "^3.1.3",
116
+ "unocss": "^66.1.3",
117
+ "vitest": "^3.2.1",
118
118
  "vue-tsc": "^2.2.10"
119
119
  },
120
120
  "scripts": {