nuxt-og-image 5.1.4 → 5.1.5

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.
@@ -6,6 +6,7 @@ import { normaliseFontInput, useOgImageRuntimeConfig } from "../../../shared.js"
6
6
  import { loadFont } from "./font.js";
7
7
  import { useResvg, useSatori, useSharp } from "./instances.js";
8
8
  import { createVNodes } from "./vnodes.js";
9
+ import compatibility from "#og-image/compatibility";
9
10
  const fontPromises = {};
10
11
  async function resolveFonts(event) {
11
12
  const { fonts } = useOgImageRuntimeConfig();
@@ -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.5",
5
5
  "description": "Enlightened OG Image generation for Nuxt.",
6
6
  "author": {
7
7
  "website": "https://harlanzw.com",
@@ -49,15 +49,15 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@nuxt/devtools-kit": "^2.4.1",
52
- "@nuxt/kit": "^3.17.3",
52
+ "@nuxt/kit": "^3.17.4",
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,18 +69,18 @@
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.2",
84
84
  "@css-inline/css-inline": "^0.14.3",
85
85
  "@headlessui/vue": "^1.7.23",
86
86
  "@iconify-json/carbon": "^1.2.8",
@@ -88,33 +88,33 @@
88
88
  "@iconify-json/noto": "^1.2.3",
89
89
  "@iconify-json/ri": "^1.2.5",
90
90
  "@iconify-json/tabler": "^1.2.18",
91
- "@img/sharp-linux-x64": "^0.34.1",
91
+ "@img/sharp-linux-x64": "^0.34.2",
92
92
  "@nuxt/content": "^3.5.1",
93
93
  "@nuxt/devtools": "^2.4.1",
94
94
  "@nuxt/devtools-ui-kit": "^2.4.1",
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.4",
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.0",
118
118
  "vue-tsc": "^2.2.10"
119
119
  },
120
120
  "scripts": {
@@ -1 +0,0 @@
1
- {"id":"dev","timestamp":1747715432208,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -1 +0,0 @@
1
- {"id":"e8cf65e2-e6ce-426c-84bd-d6a74b10ae7a","timestamp":1747715432026,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -1 +0,0 @@
1
- .spotlight[data-v-614499fb]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);bottom:-30vh;filter:blur(20vh);height:40vh}.gradient-border[data-v-614499fb]{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:.5rem;position:relative}@media (prefers-color-scheme:light){.gradient-border[data-v-614499fb]{background-color:#ffffff4d}.gradient-border[data-v-614499fb]:before{background:linear-gradient(90deg,#e2e2e2,#e2e2e2 25%,#00dc82,#36e4da 75%,#0047e1)}}@media (prefers-color-scheme:dark){.gradient-border[data-v-614499fb]{background-color:#1414144d}.gradient-border[data-v-614499fb]:before{background:linear-gradient(90deg,#303030,#303030 25%,#00dc82,#36e4da 75%,#0047e1)}}.gradient-border[data-v-614499fb]:before{background-size:400% auto;border-radius:.5rem;bottom:0;content:"";left:0;-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;opacity:.5;padding:2px;position:absolute;right:0;top:0;transition:background-position .3s ease-in-out,opacity .2s ease-in-out;width:100%}.gradient-border[data-v-614499fb]:hover:before{background-position:-50% 0;opacity:1}.fixed[data-v-614499fb]{position:fixed}.left-0[data-v-614499fb]{left:0}.right-0[data-v-614499fb]{right:0}.z-10[data-v-614499fb]{z-index:10}.z-20[data-v-614499fb]{z-index:20}.grid[data-v-614499fb]{display:grid}.mb-16[data-v-614499fb]{margin-bottom:4rem}.mb-8[data-v-614499fb]{margin-bottom:2rem}.max-w-520px[data-v-614499fb]{max-width:520px}.min-h-screen[data-v-614499fb]{min-height:100vh}.w-full[data-v-614499fb]{width:100%}.flex[data-v-614499fb]{display:flex}.cursor-pointer[data-v-614499fb]{cursor:pointer}.place-content-center[data-v-614499fb]{place-content:center}.items-center[data-v-614499fb]{align-items:center}.justify-center[data-v-614499fb]{justify-content:center}.overflow-hidden[data-v-614499fb]{overflow:hidden}.bg-white[data-v-614499fb]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-4[data-v-614499fb]{padding-left:1rem;padding-right:1rem}.px-8[data-v-614499fb]{padding-left:2rem;padding-right:2rem}.py-2[data-v-614499fb]{padding-bottom:.5rem;padding-top:.5rem}.text-center[data-v-614499fb]{text-align:center}.text-8xl[data-v-614499fb]{font-size:6rem;line-height:1}.text-xl[data-v-614499fb]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-614499fb]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-614499fb]{font-weight:300}.font-medium[data-v-614499fb]{font-weight:500}.leading-tight[data-v-614499fb]{line-height:1.25}.font-sans[data-v-614499fb]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.antialiased[data-v-614499fb]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-614499fb]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-614499fb]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-614499fb]{padding-left:0;padding-right:0}.sm\:px-6[data-v-614499fb]{padding-left:1.5rem;padding-right:1.5rem}.sm\:py-3[data-v-614499fb]{padding-bottom:.75rem;padding-top:.75rem}.sm\:text-4xl[data-v-614499fb]{font-size:2.25rem;line-height:2.5rem}.sm\:text-xl[data-v-614499fb]{font-size:1.25rem;line-height:1.75rem}}
@@ -1 +0,0 @@
1
- .spotlight[data-v-232a872a]{background:linear-gradient(45deg,#00dc82,#36e4da 50%,#0047e1);filter:blur(20vh)}.fixed[data-v-232a872a]{position:fixed}.-bottom-1\/2[data-v-232a872a]{bottom:-50%}.left-0[data-v-232a872a]{left:0}.right-0[data-v-232a872a]{right:0}.grid[data-v-232a872a]{display:grid}.mb-16[data-v-232a872a]{margin-bottom:4rem}.mb-8[data-v-232a872a]{margin-bottom:2rem}.h-1\/2[data-v-232a872a]{height:50%}.max-w-520px[data-v-232a872a]{max-width:520px}.min-h-screen[data-v-232a872a]{min-height:100vh}.place-content-center[data-v-232a872a]{place-content:center}.overflow-hidden[data-v-232a872a]{overflow:hidden}.bg-white[data-v-232a872a]{--un-bg-opacity:1;background-color:rgb(255 255 255/var(--un-bg-opacity))}.px-8[data-v-232a872a]{padding-left:2rem;padding-right:2rem}.text-center[data-v-232a872a]{text-align:center}.text-8xl[data-v-232a872a]{font-size:6rem;line-height:1}.text-xl[data-v-232a872a]{font-size:1.25rem;line-height:1.75rem}.text-black[data-v-232a872a]{--un-text-opacity:1;color:rgb(0 0 0/var(--un-text-opacity))}.font-light[data-v-232a872a]{font-weight:300}.font-medium[data-v-232a872a]{font-weight:500}.leading-tight[data-v-232a872a]{line-height:1.25}.font-sans[data-v-232a872a]{font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}.antialiased[data-v-232a872a]{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (prefers-color-scheme:dark){.dark\:bg-black[data-v-232a872a]{--un-bg-opacity:1;background-color:rgb(0 0 0/var(--un-bg-opacity))}.dark\:text-white[data-v-232a872a]{--un-text-opacity:1;color:rgb(255 255 255/var(--un-text-opacity))}}@media (min-width:640px){.sm\:px-0[data-v-232a872a]{padding-left:0;padding-right:0}.sm\:text-4xl[data-v-232a872a]{font-size:2.25rem;line-height:2.5rem}}
@@ -1,24 +0,0 @@
1
- /**
2
- * Emoji Unicode to name mapping utilities
3
- *
4
- * This file provides utilities for converting Unicode emoji characters to their
5
- * corresponding Iconify icon names, using a more efficient approach than a large
6
- * hardcoded mapping.
7
- */
8
- export declare const EMOJI_PREFIXES: Record<string, string[]>;
9
- export declare const KNOWN_EMOJI_NAMES: Record<string, string>;
10
- /**
11
- * Gets possible Iconify icon names for a given Unicode emoji
12
- *
13
- * @param codePoint The Unicode code point as a hex string (e.g., "1f44b" for 👋)
14
- * @param emojiSet The emoji set to use (e.g., "noto")
15
- * @returns An array of possible icon names to try
16
- */
17
- export declare function getEmojiIconNames(codePoint: string, emojiSet: string): string[];
18
- /**
19
- * Gets the code point for a Unicode emoji character
20
- *
21
- * @param emoji The emoji character (e.g., "👋")
22
- * @returns Hex code point (e.g., "1f44b")
23
- */
24
- export declare function getEmojiCodePoint(emoji: string): string;
@@ -1,76 +0,0 @@
1
- export const EMOJI_PREFIXES = {
2
- // Most emoji sets use kebab-case naming
3
- "default": ["emoji-", ""],
4
- // Some sets may have specific prefixes
5
- "noto": ["", "emoji-"],
6
- "twemoji": ["", "emoji-"],
7
- "fluent-emoji": ["", "emoji-"],
8
- "fluent-emoji-flat": ["", "emoji-"],
9
- "fluent-emoji-high-contrast": ["", "emoji-"],
10
- "openmoji": ["", "emoji-"],
11
- "emojione": ["", "emoji-"]
12
- };
13
- export const KNOWN_EMOJI_NAMES = {
14
- "1f44b": "waving-hand",
15
- "1f600": "grinning-face",
16
- "1f604": "grinning-face-with-smiling-eyes",
17
- "1f60d": "smiling-face-with-heart-eyes",
18
- "1f618": "face-blowing-a-kiss",
19
- "1f44d": "thumbs-up",
20
- "1f44e": "thumbs-down",
21
- "1f389": "party-popper",
22
- "1f680": "rocket",
23
- "1f4a5": "collision",
24
- "1f525": "fire",
25
- "1f381": "wrapped-gift",
26
- "1f602": "face-with-tears-of-joy",
27
- "1f970": "smiling-face-with-hearts",
28
- "1f60a": "smiling-face-with-smiling-eyes",
29
- "1f973": "partying-face",
30
- "2764": "red-heart",
31
- "1f49b": "yellow-heart",
32
- "1f499": "blue-heart",
33
- "1f49a": "green-heart",
34
- "1f49c": "purple-heart",
35
- "1f496": "sparkling-heart",
36
- "1f495": "two-hearts",
37
- "1f4af": "hundred-points",
38
- "1f4aa": "flexed-biceps",
39
- "1f44f": "clapping-hands",
40
- "1f64f": "folded-hands",
41
- "1f64c": "raising-hands",
42
- "1f9d0": "face-with-monocle",
43
- "1f914": "thinking-face",
44
- "1f605": "grinning-face-with-sweat",
45
- "1f643": "upside-down-face",
46
- "1f609": "winking-face",
47
- "1f60e": "smiling-face-with-sunglasses",
48
- "1f385": "santa-claus",
49
- "1f384": "christmas-tree",
50
- "1f334": "palm-tree",
51
- "1f419": "octopus",
52
- "1f98b": "butterfly",
53
- "1f41d": "honeybee",
54
- "1f436": "dog-face",
55
- "1f431": "cat-face",
56
- "1f427": "penguin",
57
- "1f98a": "fox",
58
- "1f438": "frog"
59
- };
60
- export function getEmojiIconNames(codePoint, emojiSet) {
61
- const prefixes = EMOJI_PREFIXES[emojiSet] || EMOJI_PREFIXES.default;
62
- if (KNOWN_EMOJI_NAMES[codePoint]) {
63
- return prefixes.map((prefix) => `${prefix}${KNOWN_EMOJI_NAMES[codePoint]}`);
64
- }
65
- return [
66
- // Try direct code point (e.g., "1f44b")
67
- codePoint,
68
- // Try with u prefix (e.g., "u1f44b")
69
- `u${codePoint}`,
70
- // Try with emoji- prefix (e.g., "emoji-u1f44b")
71
- ...prefixes.map((prefix) => `${prefix}u${codePoint}`)
72
- ];
73
- }
74
- export function getEmojiCodePoint(emoji) {
75
- return emoji.codePointAt(0).toString(16);
76
- }