nuxt-og-image 2.0.0-beta.31 → 2.0.0-beta.33
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.
- package/README.md +9 -9
- package/dist/module.json +1 -1
- package/dist/runtime/nitro/renderers/satori/index.mjs +9 -6
- package/dist/runtime/nitro/renderers/satori/plugins/imageSrc.mjs +1 -3
- package/dist/runtime/nitro/renderers/satori/utils.d.ts +1 -1
- package/dist/runtime/nitro/renderers/satori/utils.mjs +8 -4
- package/dist/runtime/nitro/routes/options.mjs +2 -3
- package/dist/runtime/nitro/utils.mjs +6 -3
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
Enlightened OG Image generation for Nuxt 3.
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
|
-
<img src="https://repository-images.githubusercontent.com/578125755/
|
|
16
|
+
<img src="https://repository-images.githubusercontent.com/578125755/90f77ca8-95be-4e06-9600-332afe1ba24f">
|
|
17
17
|
|
|
18
18
|
<p align="center">
|
|
19
19
|
<table>
|
|
@@ -50,18 +50,18 @@ Enlightened OG Image generation for Nuxt 3.
|
|
|
50
50
|
|
|
51
51
|
Both Satori and Browser will work in Node based environments. Prerendering is fully supported.
|
|
52
52
|
|
|
53
|
-
When you want to generate dynamic images at runtime there are certain
|
|
53
|
+
When you want to generate dynamic images at runtime there are certain Nitro runtime limitations.
|
|
54
54
|
|
|
55
55
|
| Provider | Satori | Browser |
|
|
56
|
-
|
|
57
|
-
| StackBlitz | ✅
|
|
58
|
-
| Node
|
|
59
|
-
| Vercel | ✅
|
|
60
|
-
| Vercel Edge | ✅
|
|
56
|
+
|------------------------------------|----------------| -- |
|
|
57
|
+
| StackBlitz | ✅ | ❌ |
|
|
58
|
+
| Node | ✅ | ✅ |
|
|
59
|
+
| Vercel | ✅ | ✅ |
|
|
60
|
+
| Vercel Edge | ✅ | ❌ |
|
|
61
61
|
| Cloudflare Workers (requires paid) | ✅ | ❌ |
|
|
62
62
|
| Cloudflare Pages (requires paid) | ✅ | ❌ |
|
|
63
|
-
| Netlify
|
|
64
|
-
| Netlify Edge (TBC) | ❌
|
|
63
|
+
| Netlify | ✅ | ❌ |
|
|
64
|
+
| Netlify Edge (TBC) | ❌ | ❌ |
|
|
65
65
|
|
|
66
66
|
Other providers are yet to be tested. Please create an issue if you have tested one.
|
|
67
67
|
|
package/dist/module.json
CHANGED
|
@@ -10,13 +10,12 @@ import encoding from "./plugins/encoding.mjs";
|
|
|
10
10
|
import loadPngCreator from "#nuxt-og-image/png";
|
|
11
11
|
import loadSatori from "#nuxt-og-image/satori";
|
|
12
12
|
import { useRuntimeConfig } from "#imports";
|
|
13
|
-
import { useNitroApp } from "#internal/nitro";
|
|
14
13
|
const satoriFonts = [];
|
|
15
14
|
let fontLoadPromise = null;
|
|
16
|
-
function loadFonts(fonts) {
|
|
15
|
+
function loadFonts(baseURL, fonts) {
|
|
17
16
|
if (fontLoadPromise)
|
|
18
17
|
return fontLoadPromise;
|
|
19
|
-
return fontLoadPromise = Promise.all(fonts.map((font) => loadFont(font)));
|
|
18
|
+
return fontLoadPromise = Promise.all(fonts.map((font) => loadFont(baseURL, font)));
|
|
20
19
|
}
|
|
21
20
|
export default {
|
|
22
21
|
name: "satori",
|
|
@@ -27,8 +26,12 @@ export default {
|
|
|
27
26
|
},
|
|
28
27
|
createVNode: async function createVNode(baseUrl, options) {
|
|
29
28
|
const url = parseURL(baseUrl);
|
|
30
|
-
const
|
|
31
|
-
|
|
29
|
+
const html = await globalThis.$fetch("/api/og-image-html", {
|
|
30
|
+
params: {
|
|
31
|
+
path: url.pathname,
|
|
32
|
+
options: JSON.stringify(options)
|
|
33
|
+
}
|
|
34
|
+
});
|
|
32
35
|
let body = html.match(/<body[^>]*>([\s\S]*)<\/body>/)?.[1] || "";
|
|
33
36
|
try {
|
|
34
37
|
body = twemoji.parse(body, {
|
|
@@ -52,7 +55,7 @@ export default {
|
|
|
52
55
|
const { fonts, satoriOptions } = useRuntimeConfig()["nuxt-og-image"];
|
|
53
56
|
const vnodes = await this.createVNode(baseUrl, options);
|
|
54
57
|
if (!satoriFonts.length)
|
|
55
|
-
satoriFonts.push(...await loadFonts(fonts));
|
|
58
|
+
satoriFonts.push(...await loadFonts(baseUrl, fonts));
|
|
56
59
|
const satori = await loadSatori();
|
|
57
60
|
return await satori(vnodes, {
|
|
58
61
|
...satoriOptions,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { withBase } from "ufo";
|
|
2
2
|
import { defineSatoriTransformer } from "../utils.mjs";
|
|
3
3
|
import { readPublicAssetBase64 } from "../../../utils.mjs";
|
|
4
|
-
import { useNitroApp } from "#internal/nitro";
|
|
5
4
|
export default defineSatoriTransformer((url) => {
|
|
6
5
|
return {
|
|
7
6
|
filter: (node) => node.type === "img",
|
|
@@ -23,9 +22,8 @@ export default defineSatoriTransformer((url) => {
|
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
if (!updated) {
|
|
26
|
-
const nitroApp = useNitroApp();
|
|
27
25
|
try {
|
|
28
|
-
const response = await
|
|
26
|
+
const response = await globalThis.$fetch.raw(src);
|
|
29
27
|
if (response.status === 200) {
|
|
30
28
|
node.props.src = response.arrayBuffer();
|
|
31
29
|
updated = true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ParsedURL } from 'ufo';
|
|
2
2
|
import type { FontConfig, SatoriTransformer, VNode } from '../../../../types';
|
|
3
|
-
export declare function loadFont(font: FontConfig): Promise<any>;
|
|
3
|
+
export declare function loadFont(baseURL: string, font: FontConfig): Promise<any>;
|
|
4
4
|
export declare function walkSatoriTree(url: ParsedURL, node: VNode, plugins: SatoriTransformer[]): Promise<void>;
|
|
5
5
|
export declare function defineSatoriTransformer(transformer: (url: ParsedURL) => SatoriTransformer): (url: ParsedURL) => SatoriTransformer;
|
|
@@ -2,7 +2,7 @@ import { Buffer } from "node:buffer";
|
|
|
2
2
|
import { base64ToArrayBuffer, readPublicAsset } from "../../utils.mjs";
|
|
3
3
|
import { useStorage } from "#internal/nitro";
|
|
4
4
|
const cachedFonts = {};
|
|
5
|
-
export async function loadFont(font) {
|
|
5
|
+
export async function loadFont(baseURL, font) {
|
|
6
6
|
let fontKey = font;
|
|
7
7
|
if (typeof font === "object")
|
|
8
8
|
fontKey = `${font.name}:${font.weight}`;
|
|
@@ -19,9 +19,13 @@ export async function loadFont(font) {
|
|
|
19
19
|
if (typeof font === "object") {
|
|
20
20
|
data = await readPublicAsset(font.path);
|
|
21
21
|
if (!data) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
try {
|
|
23
|
+
data = await globalThis.$fetch(font.path, {
|
|
24
|
+
responseType: "arrayBuffer",
|
|
25
|
+
baseURL
|
|
26
|
+
});
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
if (!data) {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getQuery } from "h3";
|
|
2
2
|
import { withoutBase } from "ufo";
|
|
3
3
|
import { extractOgImageOptions } from "../utils.mjs";
|
|
4
|
-
import { getRouteRules
|
|
4
|
+
import { getRouteRules } from "#internal/nitro";
|
|
5
5
|
import { useRuntimeConfig } from "#imports";
|
|
6
6
|
export default defineEventHandler(async (e) => {
|
|
7
7
|
const query = getQuery(e);
|
|
8
8
|
const path = withoutBase(query.path || "/", useRuntimeConfig().app.baseURL);
|
|
9
|
-
const nitro = useNitroApp();
|
|
10
9
|
let html;
|
|
11
10
|
try {
|
|
12
|
-
html = await (
|
|
11
|
+
html = await globalThis.$fetch(path);
|
|
13
12
|
} catch (err) {
|
|
14
13
|
throw createError({
|
|
15
14
|
statusCode: 500,
|
|
@@ -4,7 +4,6 @@ import { getQuery } from "h3";
|
|
|
4
4
|
import { join } from "pathe";
|
|
5
5
|
import { prefixStorage } from "unstorage";
|
|
6
6
|
import { useRuntimeConfig, useStorage } from "#imports";
|
|
7
|
-
import { useNitroApp } from "#internal/nitro";
|
|
8
7
|
export * from "./util-hostname.mjs";
|
|
9
8
|
export function wasmLoader(asyncModuleLoad, fallback) {
|
|
10
9
|
let promise;
|
|
@@ -50,8 +49,12 @@ export async function fetchOptions(e, path) {
|
|
|
50
49
|
await cache.removeItem(path);
|
|
51
50
|
}
|
|
52
51
|
if (!options) {
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
options = await globalThis.$fetch("/api/og-image-options", {
|
|
53
|
+
query: {
|
|
54
|
+
path
|
|
55
|
+
},
|
|
56
|
+
responseType: "json"
|
|
57
|
+
});
|
|
55
58
|
if (cache) {
|
|
56
59
|
await cache.setItem(path, {
|
|
57
60
|
value: options,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-og-image",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.33",
|
|
5
5
|
"packageManager": "pnpm@8.1.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@nuxt/kit": "3.4.3",
|
|
29
|
+
"@nuxt/kit": "^3.4.3",
|
|
30
30
|
"@resvg/resvg-wasm": "^2.4.1",
|
|
31
31
|
"@types/fs-extra": "^11.0.1",
|
|
32
32
|
"birpc": "^0.2.11",
|
|
@@ -46,29 +46,29 @@
|
|
|
46
46
|
"pathe": "^1.1.0",
|
|
47
47
|
"playwright-core": "^1.33.0",
|
|
48
48
|
"radix3": "^1.0.1",
|
|
49
|
-
"satori": "0.7.
|
|
49
|
+
"satori": "0.7.4",
|
|
50
50
|
"satori-html": "^0.3.2",
|
|
51
51
|
"sirv": "^2.0.3",
|
|
52
|
-
"std-env": "^3.3.
|
|
52
|
+
"std-env": "^3.3.3",
|
|
53
53
|
"svg2png-wasm": "^1.3.4",
|
|
54
54
|
"tinyws": "^0.1.0",
|
|
55
55
|
"twemoji": "^14.0.2",
|
|
56
|
-
"ufo": "^1.1.
|
|
56
|
+
"ufo": "^1.1.2",
|
|
57
57
|
"ws": "^8.13.0",
|
|
58
58
|
"yoga-wasm-web": "^0.3.3"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@antfu/eslint-config": "^0.38.
|
|
62
|
-
"@nuxt/devtools-edge": "0.4.5-
|
|
61
|
+
"@antfu/eslint-config": "^0.38.6",
|
|
62
|
+
"@nuxt/devtools-edge": "0.4.5-28053684.ddd2e41",
|
|
63
63
|
"@nuxt/module-builder": "^0.3.1",
|
|
64
64
|
"@nuxt/test-utils": "3.4.3",
|
|
65
65
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|
|
66
66
|
"@types/ws": "^8.5.4",
|
|
67
67
|
"bumpp": "^9.1.0",
|
|
68
|
-
"eslint": "8.
|
|
68
|
+
"eslint": "8.40.0",
|
|
69
69
|
"jest-image-snapshot": "^6.1.0",
|
|
70
70
|
"nuxt": "^3.4.3",
|
|
71
|
-
"vitest": "^0.
|
|
71
|
+
"vitest": "^0.31.0"
|
|
72
72
|
},
|
|
73
73
|
"resolutions": {
|
|
74
74
|
"nitropack": "npm:nitropack-edge@2.4.0-28027501.1cf01bf",
|