nuxt-og-image 2.0.0-beta.2 → 2.0.0-beta.22
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 +172 -44
- package/dist/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/IconCSS.779331aa.js +1 -0
- package/dist/client/_nuxt/{ImageLoader.9bf39d71.js → ImageLoader.9ed308b0.js} +1 -1
- package/dist/client/_nuxt/entry.acc10163.css +1 -0
- package/dist/client/_nuxt/entry.e7270163.js +5 -0
- package/dist/client/_nuxt/{error-404.1ff52902.js → error-404.dcc06a80.js} +1 -1
- package/dist/client/_nuxt/{error-500.f7d30da5.js → error-500.fb40d400.js} +1 -1
- package/dist/client/_nuxt/{error-component.cf7543e5.js → error-component.9702a511.js} +2 -2
- package/dist/client/_nuxt/{index.3f356409.js → index.6a247c9d.js} +1 -1
- package/dist/client/_nuxt/{options.56a3e5f9.js → options.481faa9f.js} +1 -1
- package/dist/client/_nuxt/{png.37f3e77b.js → png.7e62d84b.js} +1 -1
- package/dist/client/_nuxt/{shiki.3a930bb8.js → shiki.0c927d45.js} +1 -1
- package/dist/client/_nuxt/{svg.186c6bd1.js → svg.81bf3f5a.js} +1 -1
- package/dist/client/_nuxt/{vnodes.a799f183.js → vnodes.096af306.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 +15 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +239 -117
- package/dist/runtime/browserUtil.d.ts +1 -0
- package/dist/runtime/browserUtil.mjs +10 -5
- package/dist/runtime/composables/defineOgImage.mjs +14 -12
- package/dist/runtime/nitro/middleware/og.png.mjs +50 -7
- 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 +18 -0
- package/dist/runtime/nitro/providers/browser/lambda.d.ts +1 -1
- package/dist/runtime/nitro/providers/browser/lambda.mjs +5 -5
- package/dist/runtime/nitro/providers/browser/{node.mjs → playwright.mjs} +0 -9
- package/dist/runtime/nitro/providers/browser/universal.d.ts +1 -0
- package/dist/runtime/nitro/providers/browser/universal.mjs +33 -0
- package/dist/runtime/nitro/providers/png/resvg.d.ts +4 -0
- package/dist/runtime/nitro/providers/png/resvg.mjs +11 -0
- package/dist/runtime/nitro/providers/png/svg2png.mjs +11 -0
- package/dist/runtime/nitro/providers/satori/{webworker.mjs → yoga-wasm.mjs} +4 -5
- package/dist/runtime/nitro/renderers/browser.mjs +12 -6
- package/dist/runtime/nitro/renderers/satori/index.mjs +3 -3
- 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/debug.d.ts +4 -0
- package/dist/runtime/nitro/routes/debug.mjs +9 -0
- package/dist/runtime/nitro/routes/html.mjs +11 -8
- package/dist/runtime/nitro/routes/options.mjs +9 -6
- 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 +6 -4
- package/dist/runtime/nitro/utils.mjs +44 -33
- package/dist/runtime/public-assets/__nuxt_og_image__/browser-provider-not-supported.png +0 -0
- package/dist/runtime/public-assets-optional/resvg/resvg.wasm +0 -0
- package/package.json +27 -19
- 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
- package/dist/runtime/nitro/providers/svg2png/universal.mjs +0 -9
- /package/dist/runtime/nitro/providers/browser/{node.d.ts → playwright.d.ts} +0 -0
- /package/dist/runtime/nitro/providers/{svg2png/universal.d.ts → png/svg2png.d.ts} +0 -0
- /package/dist/runtime/nitro/providers/satori/{node.d.ts → default.d.ts} +0 -0
- /package/dist/runtime/nitro/providers/satori/{node.mjs → default.mjs} +0 -0
- /package/dist/runtime/nitro/providers/satori/{webworker.d.ts → yoga-wasm.d.ts} +0 -0
- /package/dist/runtime/{public-assets → public-assets-optional/inter-font}/inter-latin-ext-400-normal.woff +0 -0
- /package/dist/runtime/{public-assets → public-assets-optional/inter-font}/inter-latin-ext-700-normal.woff +0 -0
- /package/dist/runtime/{public-assets → public-assets-optional/svg2png}/svg2png.wasm +0 -0
- /package/dist/runtime/{public-assets → public-assets-optional/yoga}/yoga.wasm +0 -0
|
@@ -1,53 +1,75 @@
|
|
|
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 { prefixStorage } from "unstorage";
|
|
6
|
+
import { useHostname } from "./util-hostname.mjs";
|
|
7
|
+
import { useRuntimeConfig, useStorage } from "#imports";
|
|
8
|
+
export * from "./util-hostname.mjs";
|
|
9
|
+
export function wasmLoader(asyncModuleLoad, fallback) {
|
|
6
10
|
let promise;
|
|
7
|
-
let
|
|
11
|
+
let wasm;
|
|
8
12
|
return {
|
|
9
|
-
|
|
10
|
-
if (loaded)
|
|
11
|
-
return true;
|
|
13
|
+
async load(options) {
|
|
12
14
|
if (typeof promise !== "undefined")
|
|
13
15
|
return promise;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
async load() {
|
|
16
|
+
if (wasm)
|
|
17
|
+
return wasm;
|
|
17
18
|
promise = promise || new Promise(async (resolve) => {
|
|
18
|
-
let wasm;
|
|
19
19
|
try {
|
|
20
|
-
wasm = await
|
|
20
|
+
wasm = await asyncModuleLoad;
|
|
21
21
|
if (typeof wasm === "string")
|
|
22
22
|
wasm = void 0;
|
|
23
23
|
} catch (e) {
|
|
24
24
|
}
|
|
25
|
-
if (!wasm)
|
|
26
|
-
wasm = await readPublicAsset(fallback);
|
|
27
25
|
if (!wasm) {
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
wasm = await readPublicAsset(fallback, "base64");
|
|
27
|
+
if (wasm)
|
|
28
|
+
wasm = Buffer.from(wasm, "base64");
|
|
29
|
+
}
|
|
30
|
+
if (!wasm) {
|
|
31
|
+
const url = new URL(options.baseUrl);
|
|
32
|
+
wasm = await (await globalThis.$fetch(fallback, { baseURL: url.origin })).arrayBuffer();
|
|
33
|
+
wasm = Buffer.from(wasm);
|
|
30
34
|
}
|
|
31
|
-
loaded = true;
|
|
32
35
|
resolve(wasm);
|
|
33
36
|
});
|
|
34
37
|
return promise;
|
|
35
38
|
}
|
|
36
39
|
};
|
|
37
40
|
}
|
|
38
|
-
export function fetchOptions(e, path) {
|
|
41
|
+
export async function fetchOptions(e, path) {
|
|
42
|
+
const { runtimeCacheStorage } = useRuntimeConfig()["nuxt-og-image"];
|
|
43
|
+
const cache = runtimeCacheStorage ? prefixStorage(useStorage(), "og-image-cache:options") : false;
|
|
44
|
+
if (cache && await cache.hasItem(path)) {
|
|
45
|
+
const cachedValue = await cache.getItem(path);
|
|
46
|
+
if (cachedValue && cachedValue.expiresAt < Date.now())
|
|
47
|
+
return cachedValue.value;
|
|
48
|
+
else
|
|
49
|
+
await cache.removeItem(path);
|
|
50
|
+
}
|
|
39
51
|
const fetchOptions2 = process.dev || process.env.prerender ? {
|
|
40
52
|
headers: getHeaders(e)
|
|
41
53
|
} : {
|
|
42
54
|
baseURL: useHostname(e)
|
|
43
55
|
};
|
|
44
|
-
|
|
56
|
+
const res = await globalThis.$fetch("/api/og-image-options", {
|
|
45
57
|
query: {
|
|
46
|
-
...getQuery(e),
|
|
47
58
|
path
|
|
48
59
|
},
|
|
49
60
|
...fetchOptions2
|
|
50
61
|
});
|
|
62
|
+
if (cache) {
|
|
63
|
+
await cache.setItem(path, {
|
|
64
|
+
value: res,
|
|
65
|
+
expiresAt: Date.now() + (res.static ? 60 * 60 * 1e3 : 5 * 1e3)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
...res,
|
|
70
|
+
// use query data
|
|
71
|
+
...getQuery(e)
|
|
72
|
+
};
|
|
51
73
|
}
|
|
52
74
|
export function base64ToArrayBuffer(base64) {
|
|
53
75
|
const buffer = Buffer.from(base64, "base64");
|
|
@@ -58,20 +80,9 @@ export function renderIsland(payload) {
|
|
|
58
80
|
query: { props: JSON.stringify(payload) }
|
|
59
81
|
});
|
|
60
82
|
}
|
|
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) => {
|
|
83
|
+
function r(base, key) {
|
|
73
84
|
return join(base, key.replace(/:/g, "/"));
|
|
74
|
-
}
|
|
85
|
+
}
|
|
75
86
|
export async function readPublicAsset(file, encoding) {
|
|
76
87
|
const { assetDirs } = useRuntimeConfig()["nuxt-og-image"];
|
|
77
88
|
for (const assetDir of assetDirs) {
|
|
Binary file
|
|
Binary file
|
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.22",
|
|
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,24 +26,28 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@nuxt/kit": "3.
|
|
29
|
+
"@nuxt/kit": "3.4.2",
|
|
30
|
+
"@resvg/resvg-wasm": "^2.4.1",
|
|
30
31
|
"@types/fs-extra": "^11.0.1",
|
|
31
|
-
"birpc": "^0.2.
|
|
32
|
+
"birpc": "^0.2.11",
|
|
32
33
|
"chalk": "^5.2.0",
|
|
33
|
-
"chrome-launcher": "^0.15.
|
|
34
|
+
"chrome-launcher": "^0.15.2",
|
|
34
35
|
"defu": "^6.1.2",
|
|
35
36
|
"execa": "^7.1.1",
|
|
36
37
|
"fast-glob": "^3.2.12",
|
|
37
38
|
"flatted": "^3.2.7",
|
|
38
39
|
"fs-extra": "^11.1.1",
|
|
40
|
+
"globby": "^13.1.4",
|
|
39
41
|
"launch-editor": "^2.6.0",
|
|
40
|
-
"
|
|
42
|
+
"nypm": "^0.2.0",
|
|
43
|
+
"ofetch": "^1.0.1",
|
|
44
|
+
"ohash": "^1.1.2",
|
|
41
45
|
"pathe": "^1.1.0",
|
|
42
|
-
"playwright-core": "^1.
|
|
43
|
-
"radix3": "^1.0.
|
|
44
|
-
"satori": "0.
|
|
46
|
+
"playwright-core": "^1.33.0",
|
|
47
|
+
"radix3": "^1.0.1",
|
|
48
|
+
"satori": "0.7.2",
|
|
45
49
|
"satori-html": "^0.3.2",
|
|
46
|
-
"sirv": "^2.0.
|
|
50
|
+
"sirv": "^2.0.3",
|
|
47
51
|
"std-env": "^3.3.2",
|
|
48
52
|
"svg2png-wasm": "^1.3.4",
|
|
49
53
|
"tinyws": "^0.1.0",
|
|
@@ -53,18 +57,22 @@
|
|
|
53
57
|
"yoga-wasm-web": "^0.3.3"
|
|
54
58
|
},
|
|
55
59
|
"devDependencies": {
|
|
56
|
-
"@antfu/eslint-config": "^0.
|
|
57
|
-
"@nuxt/devtools-edge": "0.2
|
|
58
|
-
"@nuxt/module-builder": "^0.
|
|
59
|
-
"@nuxt/test-utils": "3.
|
|
60
|
+
"@antfu/eslint-config": "^0.38.5",
|
|
61
|
+
"@nuxt/devtools-edge": "0.4.2-28041905.19fda12",
|
|
62
|
+
"@nuxt/module-builder": "^0.3.0",
|
|
63
|
+
"@nuxt/test-utils": "3.4.2",
|
|
60
64
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|
|
61
65
|
"@types/ws": "^8.5.4",
|
|
62
|
-
"bumpp": "^9.
|
|
63
|
-
"eslint": "8.
|
|
66
|
+
"bumpp": "^9.1.0",
|
|
67
|
+
"eslint": "8.39.0",
|
|
64
68
|
"jest-image-snapshot": "^6.1.0",
|
|
65
|
-
"nuxt": "^3.
|
|
66
|
-
"
|
|
67
|
-
|
|
69
|
+
"nuxt": "^3.4.2",
|
|
70
|
+
"vitest": "^0.30.1"
|
|
71
|
+
},
|
|
72
|
+
"resolutions": {
|
|
73
|
+
"nitropack": "npm:nitropack-edge@2.4.0-28027501.1cf01bf",
|
|
74
|
+
"unstorage": "^1.5.0",
|
|
75
|
+
"unenv": "^1.4.1"
|
|
68
76
|
},
|
|
69
77
|
"scripts": {
|
|
70
78
|
"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};
|