nuxt-og-image 2.0.0-beta.2 → 2.0.0-beta.21
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 +96 -35
- package/dist/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/IconCSS.ecebf6a5.js +1 -0
- package/dist/client/_nuxt/{ImageLoader.9bf39d71.js → ImageLoader.97400b2b.js} +1 -1
- package/dist/client/_nuxt/entry.7e98a020.css +1 -0
- package/dist/client/_nuxt/entry.c8bf4454.js +5 -0
- package/dist/client/_nuxt/{error-404.1ff52902.js → error-404.7660b68a.js} +1 -1
- package/dist/client/_nuxt/{error-500.f7d30da5.js → error-500.776f22a1.js} +1 -1
- package/dist/client/_nuxt/{error-component.cf7543e5.js → error-component.d4668032.js} +2 -2
- package/dist/client/_nuxt/{index.3f356409.js → index.77081a6c.js} +1 -1
- package/dist/client/_nuxt/{options.56a3e5f9.js → options.b6164a5b.js} +1 -1
- package/dist/client/_nuxt/{png.37f3e77b.js → png.b914f6c4.js} +1 -1
- package/dist/client/_nuxt/{shiki.3a930bb8.js → shiki.ba10b978.js} +1 -1
- package/dist/client/_nuxt/{svg.186c6bd1.js → svg.1e41877e.js} +1 -1
- package/dist/client/_nuxt/{vnodes.a799f183.js → vnodes.a857bced.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/options/index.html +2 -2
- package/dist/client/png/index.html +2 -2
- package/dist/client/svg/index.html +2 -2
- package/dist/client/vnodes/index.html +2 -2
- package/dist/module.d.ts +0 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +72 -60
- package/dist/runtime/browserUtil.d.ts +1 -0
- package/dist/runtime/browserUtil.mjs +7 -4
- package/dist/runtime/composables/defineOgImage.mjs +6 -7
- package/dist/runtime/nitro/middleware/og.png.mjs +17 -2
- package/dist/runtime/nitro/middleware/playground.mjs +4 -3
- package/dist/runtime/nitro/plugins/prerender.d.ts +3 -0
- package/dist/runtime/nitro/plugins/prerender.mjs +20 -0
- package/dist/runtime/nitro/providers/browser/node.mjs +10 -8
- package/dist/runtime/nitro/providers/svg2png/universal.mjs +5 -2
- package/dist/runtime/nitro/renderers/browser.mjs +6 -1
- package/dist/runtime/nitro/renderers/satori/plugins/encoding.mjs +2 -1
- package/dist/runtime/nitro/renderers/satori/utils.mjs +1 -0
- package/dist/runtime/nitro/routes/html.mjs +11 -8
- package/dist/runtime/nitro/routes/options.mjs +6 -3
- package/dist/runtime/nitro/routes/svg.mjs +3 -1
- package/dist/runtime/nitro/routes/vnode.mjs +3 -1
- package/dist/runtime/nitro/util-hostname.d.ts +2 -0
- package/dist/runtime/nitro/util-hostname.mjs +15 -0
- package/dist/runtime/nitro/utils-pure.d.ts +3 -2
- package/dist/runtime/nitro/utils-pure.mjs +16 -13
- package/dist/runtime/nitro/utils.d.ts +3 -2
- package/dist/runtime/nitro/utils.mjs +9 -17
- package/package.json +19 -18
- package/dist/client/_nuxt/IconCSS.a041aca0.js +0 -1
- package/dist/client/_nuxt/entry.74018bda.js +0 -5
- package/dist/client/_nuxt/entry.7a8c1ab2.css +0 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
function
|
|
1
|
+
export function decodeHtml(html) {
|
|
2
|
+
return html.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/¢/g, "\xA2").replace(/£/g, "\xA3").replace(/¥/g, "\xA5").replace(/€/g, "\u20AC").replace(/©/g, "\xA9").replace(/®/g, "\xAE").replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'").replace(///g, "/").replace(/&#([0-9]+);/g, (full, int) => {
|
|
3
|
+
return String.fromCharCode(parseInt(int));
|
|
4
|
+
});
|
|
5
|
+
}
|
|
6
|
+
function decodeObjectHtmlEntities(obj) {
|
|
2
7
|
Object.entries(obj).forEach(([key, value]) => {
|
|
3
|
-
if (typeof value === "string")
|
|
4
|
-
obj[key] = value
|
|
5
|
-
}
|
|
8
|
+
if (typeof value === "string")
|
|
9
|
+
obj[key] = decodeHtml(value);
|
|
6
10
|
});
|
|
7
11
|
return obj;
|
|
8
12
|
}
|
|
@@ -19,15 +23,14 @@ export function extractOgImageOptions(html) {
|
|
|
19
23
|
console.warn("Failed to parse #nuxt-og-image-options", e, options);
|
|
20
24
|
}
|
|
21
25
|
if (options) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
if (!options.description) {
|
|
27
|
+
const description = html.match(/<meta property="og:description" content="(.*?)">/)?.[1];
|
|
28
|
+
if (description)
|
|
29
|
+
options.description = description;
|
|
30
|
+
else
|
|
31
|
+
options.description = html.match(/<meta name="description" content="(.*?)">/)?.[1];
|
|
32
|
+
}
|
|
33
|
+
return decodeObjectHtmlEntities(options);
|
|
28
34
|
}
|
|
29
35
|
return false;
|
|
30
36
|
}
|
|
31
|
-
export function stripOgImageOptions(html) {
|
|
32
|
-
return html.replace(/<script id="nuxt-og-image-options" type="application\/json">(.*?)<\/script>/, "");
|
|
33
|
-
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
2
3
|
import type { H3Event } from 'h3';
|
|
3
4
|
import type { OgImageOptions } from '../../types';
|
|
4
|
-
export
|
|
5
|
+
export * from './util-hostname';
|
|
6
|
+
export declare function wasmLoader(asyncModuleLoad: Promise<any>, fallback: string, baseUrl: string): {
|
|
5
7
|
loaded(): boolean | Promise<any>;
|
|
6
8
|
load(): Promise<any>;
|
|
7
9
|
};
|
|
@@ -11,7 +13,6 @@ export declare function renderIsland(payload: OgImageOptions): Promise<{
|
|
|
11
13
|
html: string;
|
|
12
14
|
head: any;
|
|
13
15
|
}>;
|
|
14
|
-
export declare function useHostname(e: H3Event): any;
|
|
15
16
|
export declare function readPublicAsset(file: string, encoding?: BufferEncoding): Promise<string | Buffer | undefined>;
|
|
16
17
|
export declare function readPublicAssetBase64(file: string): Promise<string | undefined>;
|
|
17
18
|
export * from './utils-pure';
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { existsSync, promises as fsp } from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import { Buffer } from "node:buffer";
|
|
3
|
+
import { getHeaders, getQuery } from "h3";
|
|
3
4
|
import { join } from "pathe";
|
|
4
|
-
import {
|
|
5
|
-
|
|
5
|
+
import { useHostname } from "./util-hostname.mjs";
|
|
6
|
+
import { useRuntimeConfig } from "#imports";
|
|
7
|
+
export * from "./util-hostname.mjs";
|
|
8
|
+
export function wasmLoader(asyncModuleLoad, fallback, baseUrl) {
|
|
6
9
|
let promise;
|
|
7
10
|
let loaded = false;
|
|
8
11
|
return {
|
|
@@ -17,7 +20,7 @@ export function wasmLoader(key, fallback, baseUrl) {
|
|
|
17
20
|
promise = promise || new Promise(async (resolve) => {
|
|
18
21
|
let wasm;
|
|
19
22
|
try {
|
|
20
|
-
wasm = await
|
|
23
|
+
wasm = await asyncModuleLoad;
|
|
21
24
|
if (typeof wasm === "string")
|
|
22
25
|
wasm = void 0;
|
|
23
26
|
} catch (e) {
|
|
@@ -58,20 +61,9 @@ export function renderIsland(payload) {
|
|
|
58
61
|
query: { props: JSON.stringify(payload) }
|
|
59
62
|
});
|
|
60
63
|
}
|
|
61
|
-
|
|
62
|
-
const config = useRuntimeConfig()["nuxt-og-image"];
|
|
63
|
-
if (!process.dev && config.siteUrl)
|
|
64
|
-
return config.siteUrl;
|
|
65
|
-
const host = getRequestHeader(e, "host") || process.env.NITRO_HOST || process.env.HOST || "localhost";
|
|
66
|
-
const protocol = getRequestHeader(e, "x-forwarded-proto") || "http";
|
|
67
|
-
const useHttp = process.env.NODE_ENV === "development" || host.includes("127.0.0.1") || host.includes("localhost") || protocol === "http";
|
|
68
|
-
const port = host.includes(":") ? host.split(":").pop() : process.env.NITRO_PORT || process.env.PORT;
|
|
69
|
-
const base = useRuntimeConfig().app.baseURL;
|
|
70
|
-
return `http${useHttp ? "" : "s"}://${host.includes(":") ? host.split(":")[0] : host}${port ? `:${port}` : ""}${base}`;
|
|
71
|
-
}
|
|
72
|
-
const r = (base, key) => {
|
|
64
|
+
function r(base, key) {
|
|
73
65
|
return join(base, key.replace(/:/g, "/"));
|
|
74
|
-
}
|
|
66
|
+
}
|
|
75
67
|
export async function readPublicAsset(file, encoding) {
|
|
76
68
|
const { assetDirs } = useRuntimeConfig()["nuxt-og-image"];
|
|
77
69
|
for (const assetDir of assetDirs) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-og-image",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
5
|
-
"packageManager": "pnpm@
|
|
4
|
+
"version": "2.0.0-beta.21",
|
|
5
|
+
"packageManager": "pnpm@8.1.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
8
8
|
"homepage": "https://github.com/harlan-zw/nuxt-og-image#readme",
|
|
@@ -26,22 +26,23 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@nuxt/kit": "3.
|
|
29
|
+
"@nuxt/kit": "3.4.2",
|
|
30
30
|
"@types/fs-extra": "^11.0.1",
|
|
31
|
-
"birpc": "^0.2.
|
|
31
|
+
"birpc": "^0.2.11",
|
|
32
32
|
"chalk": "^5.2.0",
|
|
33
|
-
"chrome-launcher": "^0.15.
|
|
33
|
+
"chrome-launcher": "^0.15.2",
|
|
34
34
|
"defu": "^6.1.2",
|
|
35
35
|
"execa": "^7.1.1",
|
|
36
36
|
"fast-glob": "^3.2.12",
|
|
37
37
|
"flatted": "^3.2.7",
|
|
38
38
|
"fs-extra": "^11.1.1",
|
|
39
39
|
"launch-editor": "^2.6.0",
|
|
40
|
-
"
|
|
40
|
+
"ofetch": "^1.0.1",
|
|
41
|
+
"ohash": "^1.1.1",
|
|
41
42
|
"pathe": "^1.1.0",
|
|
42
|
-
"playwright-core": "^1.
|
|
43
|
-
"radix3": "^1.0.
|
|
44
|
-
"satori": "0.4.
|
|
43
|
+
"playwright-core": "^1.32.3",
|
|
44
|
+
"radix3": "^1.0.1",
|
|
45
|
+
"satori": "0.4.14",
|
|
45
46
|
"satori-html": "^0.3.2",
|
|
46
47
|
"sirv": "^2.0.2",
|
|
47
48
|
"std-env": "^3.3.2",
|
|
@@ -53,18 +54,18 @@
|
|
|
53
54
|
"yoga-wasm-web": "^0.3.3"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
|
-
"@antfu/eslint-config": "^0.
|
|
57
|
-
"@nuxt/devtools-edge": "0.
|
|
58
|
-
"@nuxt/module-builder": "^0.
|
|
59
|
-
"@nuxt/test-utils": "3.
|
|
57
|
+
"@antfu/eslint-config": "^0.38.5",
|
|
58
|
+
"@nuxt/devtools-edge": "0.4.1-28031816.5910844",
|
|
59
|
+
"@nuxt/module-builder": "^0.3.0",
|
|
60
|
+
"@nuxt/test-utils": "3.4.2",
|
|
60
61
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|
|
61
62
|
"@types/ws": "^8.5.4",
|
|
62
|
-
"bumpp": "^9.
|
|
63
|
-
"eslint": "8.
|
|
63
|
+
"bumpp": "^9.1.0",
|
|
64
|
+
"eslint": "8.38.0",
|
|
64
65
|
"jest-image-snapshot": "^6.1.0",
|
|
65
|
-
"nuxt": "^3.
|
|
66
|
-
"puppeteer": "^19.
|
|
67
|
-
"vitest": "^0.
|
|
66
|
+
"nuxt": "^3.4.2",
|
|
67
|
+
"puppeteer": "^19.10.1",
|
|
68
|
+
"vitest": "^0.30.1"
|
|
68
69
|
},
|
|
69
70
|
"scripts": {
|
|
70
71
|
"build": "pnpm dev:prepare && pnpm build:module && pnpm build:client",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as p,b as u,e as l,f as t,o as f,h as m,i as _,u as o,j as d}from"./entry.74018bda.js";const x=p({__name:"IconCSS",props:{name:{type:String,required:!0},size:{type:String,default:""}},setup(c){const s=c;u(e=>({"387181c2":o(r)}));const n=l();n?.nuxtIcon?.aliases;const i=t(()=>(n?.nuxtIcon?.aliases||{})[s.name]||s.name),r=t(()=>`url('https://api.iconify.design/${i.value.replace(":","/")}.svg')`),a=t(()=>{if(!s.size&&typeof n.nuxtIcon?.size=="boolean"&&!n.nuxtIcon?.size)return;const e=s.size||n.nuxtIcon?.size||"1em";return String(Number(e))===e?`${e}px`:e});return(e,z)=>(f(),m("span",{style:_({width:o(a),height:o(a)})},null,4))}}),g=d(x,[["__scopeId","data-v-3c47f034"]]);export{g as default};
|