nuxt-og-image 1.3.2 → 1.4.1
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 +3 -6
- package/dist/client/200.html +2 -2
- package/dist/client/404.html +2 -2
- package/dist/client/_nuxt/{index.7072fbd5.css → IFrameLoader.7072fbd5.css} +0 -0
- package/dist/client/_nuxt/IFrameLoader.9c47f879.js +1 -0
- package/dist/client/_nuxt/Icon.403b6716.css +1 -0
- package/dist/client/_nuxt/Icon.60a95afe.js +1 -0
- package/dist/client/_nuxt/Icon.vue.a2ec08e3.js +1 -0
- package/dist/client/_nuxt/ImageLoader.a49f505c.js +1 -0
- package/dist/client/_nuxt/NButton.0c805413.js +1 -0
- package/dist/client/_nuxt/NButton.vue.c6f50405.js +1 -0
- package/dist/client/_nuxt/NCard.73524dd1.js +1 -0
- package/dist/client/_nuxt/NCheckbox.d5ba4120.js +1 -0
- package/dist/client/_nuxt/NDarkToggle.687abd18.js +1 -0
- package/dist/client/_nuxt/NDarkToggle.vue.f7f2dd0a.js +1 -0
- package/dist/client/_nuxt/NDialog.44534c12.js +7 -0
- package/dist/client/_nuxt/NDropdown.24933a4d.js +1 -0
- package/dist/client/_nuxt/NIcon.af04832c.js +1 -0
- package/dist/client/_nuxt/NIcon.vue.4a86e248.js +1 -0
- package/dist/client/_nuxt/NLink.8cbc1765.js +1 -0
- package/dist/client/_nuxt/NLink.vue.9d5564e9.js +1 -0
- package/dist/client/_nuxt/NRadio.1079a996.js +1 -0
- package/dist/client/_nuxt/NSwitch.28e8e7c4.js +1 -0
- package/dist/client/_nuxt/NTextInput.dd5d77f0.js +1 -0
- package/dist/client/_nuxt/NTextInput.vue.9b6f61da.js +1 -0
- package/dist/client/_nuxt/NTip.a2522c9e.js +1 -0
- package/dist/client/_nuxt/NuxtContentLogo.b33b5adb.js +1 -0
- package/dist/client/_nuxt/NuxtExampleLayout.85a98b42.js +1 -0
- package/dist/client/_nuxt/NuxtLogo.c4101b4a.js +1 -0
- package/dist/client/_nuxt/UnoIcon.3704f042.js +1 -0
- package/dist/client/_nuxt/_plugin-vue_export-helper.c27b6911.js +1 -0
- package/dist/client/_nuxt/app.config.d5ed556c.js +1 -0
- package/dist/client/_nuxt/client-only.a160727e.js +4 -0
- package/dist/client/_nuxt/component.vue3.3c33ad5e.js +1 -0
- package/dist/client/_nuxt/components.client.1798d2db.js +1 -0
- package/dist/client/_nuxt/components.def83447.js +1 -0
- package/dist/client/_nuxt/composables.b3b1407e.js +1 -0
- package/dist/client/_nuxt/dev-only.3974795b.js +1 -0
- package/dist/client/_nuxt/entry.3a708ff1.css +1 -0
- package/dist/client/_nuxt/entry.effa1410.js +1 -0
- package/dist/client/_nuxt/error-404.1469f10f.css +1 -0
- package/dist/client/_nuxt/error-404.6ae4da09.js +1 -0
- package/dist/client/_nuxt/error-500.0e359581.js +1 -0
- package/dist/client/_nuxt/error-500.92b94fae.css +1 -0
- package/dist/client/_nuxt/error-component.287b5382.js +3 -0
- package/dist/client/_nuxt/index.8da3b00c.js +1 -0
- package/dist/client/_nuxt/index.ce5b2578.js +1 -0
- package/dist/client/_nuxt/index.f6e5e2e7.js +1 -0
- package/dist/client/_nuxt/layout.ac370415.js +1 -0
- package/dist/client/_nuxt/logic.a3f9c8c6.js +1 -0
- package/dist/client/_nuxt/nuxt-error-boundary.550746e3.js +1 -0
- package/dist/client/_nuxt/nuxt-link.3b9becb1.js +1 -0
- package/dist/client/_nuxt/nuxt-loading-indicator.de8802c9.js +1 -0
- package/dist/client/_nuxt/options.83d1f896.js +1 -0
- package/dist/client/_nuxt/page.b8634cae.js +1 -0
- package/dist/client/_nuxt/png.8184405c.js +1 -0
- package/dist/client/_nuxt/runtime-core.esm-bundler.d2479180.js +1 -0
- package/dist/client/_nuxt/runtime-dom.esm-bundler.f4f35d78.js +1 -0
- package/dist/client/_nuxt/server-placeholder.8ed08e3a.js +1 -0
- package/dist/client/_nuxt/{shiki.69102a86.js → shiki.13470033.js} +5 -5
- package/dist/client/_nuxt/state.4540d876.js +1 -0
- package/dist/client/_nuxt/svg.6f1b15ad.js +1 -0
- package/dist/client/_nuxt/utils.b6c92ff8.js +5 -0
- package/dist/client/_nuxt/vnodes.fad3909d.js +1 -0
- package/dist/client/_nuxt/welcome.db724adb.css +1 -0
- package/dist/client/_nuxt/welcome.dd0c800c.js +1 -0
- 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 +3 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +66 -43
- package/dist/runtime/components/OgImageBasic.island.vue +1 -1
- package/dist/runtime/composables/defineOgImage.mjs +7 -6
- package/dist/runtime/nitro/{routes/__og_image__ → middleware}/og.png.d.ts +0 -0
- package/dist/runtime/nitro/{routes/__og_image__ → middleware}/og.png.mjs +4 -4
- package/dist/runtime/nitro/{routes/__og_image__/index.d.ts → middleware/playground.d.ts} +0 -0
- package/dist/runtime/nitro/{routes/__og_image__/index.mjs → middleware/playground.mjs} +4 -4
- package/dist/runtime/nitro/providers/browser/lambda.d.ts +1 -0
- package/dist/runtime/nitro/{browsers → providers/browser}/lambda.mjs +1 -1
- package/dist/runtime/nitro/providers/browser/node.d.ts +1 -0
- package/dist/runtime/nitro/{browsers/default.mjs → providers/browser/node.mjs} +1 -1
- package/dist/runtime/nitro/providers/satori/node.d.ts +2 -0
- package/dist/runtime/nitro/providers/satori/node.mjs +4 -0
- package/dist/runtime/nitro/providers/satori/webworker.d.ts +4 -0
- package/dist/runtime/nitro/providers/satori/webworker.mjs +11 -0
- package/dist/runtime/nitro/providers/svg2png/universal.d.ts +4 -0
- package/dist/runtime/nitro/providers/svg2png/universal.mjs +9 -0
- package/dist/runtime/nitro/renderers/browser.d.ts +3 -0
- package/dist/runtime/nitro/{providers → renderers}/browser.mjs +5 -2
- package/dist/runtime/nitro/renderers/satori/index.d.ts +3 -0
- package/dist/runtime/nitro/{providers → renderers}/satori/index.mjs +14 -8
- package/dist/runtime/nitro/{providers → renderers}/satori/plugins/emojis.d.ts +0 -0
- package/dist/runtime/nitro/{providers → renderers}/satori/plugins/emojis.mjs +0 -0
- package/dist/runtime/nitro/{providers → renderers}/satori/plugins/flex.d.ts +0 -0
- package/dist/runtime/nitro/{providers → renderers}/satori/plugins/flex.mjs +0 -0
- package/dist/runtime/nitro/{providers → renderers}/satori/plugins/imageSrc.d.ts +0 -0
- package/dist/runtime/nitro/{providers → renderers}/satori/plugins/imageSrc.mjs +2 -1
- package/dist/runtime/nitro/{providers → renderers}/satori/plugins/twClasses.d.ts +0 -0
- package/dist/runtime/nitro/{providers → renderers}/satori/plugins/twClasses.mjs +0 -0
- package/dist/runtime/nitro/{providers → renderers}/satori/utils.d.ts +1 -4
- package/dist/runtime/nitro/renderers/satori/utils.mjs +45 -0
- package/dist/runtime/nitro/routes/{__og_image__/font.d.ts → font.d.ts} +0 -0
- package/dist/runtime/nitro/routes/{__og_image__/font.mjs → font.mjs} +1 -1
- package/dist/runtime/nitro/routes/{__og_image__/html.d.ts → html.d.ts} +0 -0
- package/dist/runtime/nitro/routes/{__og_image__/html.mjs → html.mjs} +9 -8
- package/dist/runtime/nitro/routes/{__og_image__/options.d.ts → options.d.ts} +2 -2
- package/dist/runtime/nitro/routes/{__og_image__/options.mjs → options.mjs} +6 -9
- package/dist/runtime/nitro/routes/{__og_image__/svg.d.ts → svg.d.ts} +0 -0
- package/dist/runtime/nitro/routes/svg.mjs +11 -0
- package/dist/runtime/nitro/routes/{__og_image__/vnode.d.ts → vnode.d.ts} +0 -0
- package/dist/runtime/nitro/routes/vnode.mjs +11 -0
- package/dist/runtime/nitro/utils.d.ts +9 -1
- package/dist/runtime/nitro/utils.mjs +75 -10
- package/dist/runtime/{public → public-assets}/inter-latin-ext-400-normal.woff +0 -0
- package/dist/runtime/{public → public-assets}/inter-latin-ext-700-normal.woff +0 -0
- package/dist/runtime/public-assets/svg2png.wasm +0 -0
- package/dist/runtime/public-assets/yoga.wasm +0 -0
- package/package.json +10 -8
- package/dist/client/_nuxt/ImageLoader.be226b50.js +0 -1
- package/dist/client/_nuxt/entry.3dc1b14c.js +0 -5
- package/dist/client/_nuxt/entry.9f5c391a.css +0 -1
- package/dist/client/_nuxt/error-404.68aa58b4.css +0 -1
- package/dist/client/_nuxt/error-404.9a311ab2.js +0 -1
- package/dist/client/_nuxt/error-500.dc5710d1.css +0 -1
- package/dist/client/_nuxt/error-500.f8d3032e.js +0 -1
- package/dist/client/_nuxt/error-component.a4dd1ebc.js +0 -3
- package/dist/client/_nuxt/index.dea39ba2.js +0 -1
- package/dist/client/_nuxt/options.53a4a6ca.js +0 -1
- package/dist/client/_nuxt/png.6a754041.js +0 -1
- package/dist/client/_nuxt/svg.afcae77d.js +0 -1
- package/dist/client/_nuxt/vnodes.dd40690d.js +0 -1
- package/dist/runtime/nitro/browsers/default.d.ts +0 -1
- package/dist/runtime/nitro/browsers/lambda.d.ts +0 -1
- package/dist/runtime/nitro/providers/browser.d.ts +0 -3
- package/dist/runtime/nitro/providers/satori/index.d.ts +0 -3
- package/dist/runtime/nitro/providers/satori/utils.mjs +0 -69
- package/dist/runtime/nitro/resvg/node.d.ts +0 -3
- package/dist/runtime/nitro/resvg/node.mjs +0 -6
- package/dist/runtime/nitro/resvg/wasm.d.ts +0 -2
- package/dist/runtime/nitro/resvg/wasm.mjs +0 -32
- package/dist/runtime/nitro/routes/__og_image__/svg.mjs +0 -16
- package/dist/runtime/nitro/routes/__og_image__/vnode.mjs +0 -16
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineEventHandler, getQuery, setHeader } from "h3";
|
|
2
|
+
import { withBase } from "ufo";
|
|
3
|
+
import { fetchOptions, useHostname } from "../utils.mjs";
|
|
4
|
+
import { useProvider } from "#nuxt-og-image/provider";
|
|
5
|
+
export default defineEventHandler(async (e) => {
|
|
6
|
+
const path = getQuery(e).path || "/";
|
|
7
|
+
const options = await fetchOptions(e, path);
|
|
8
|
+
setHeader(e, "Content-Type", "application/json");
|
|
9
|
+
const provider = await useProvider(options.provider);
|
|
10
|
+
return provider.createVNode(withBase(path, useHostname(e)), options);
|
|
11
|
+
});
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { H3Event } from 'h3';
|
|
2
3
|
import type { OgImageOptions } from '../../types';
|
|
3
|
-
export declare function
|
|
4
|
+
export declare function wasmLoader(key: any, fallback: string, baseUrl: string): {
|
|
5
|
+
loaded(): Promise<boolean>;
|
|
6
|
+
load(): Promise<any>;
|
|
7
|
+
};
|
|
8
|
+
export declare function fetchOptions(e: H3Event, path: string): Promise<OgImageOptions>;
|
|
9
|
+
export declare function base64ToArrayBuffer(base64: string): ArrayBuffer;
|
|
4
10
|
export declare function renderIsland(payload: OgImageOptions): Promise<{
|
|
5
11
|
html: string;
|
|
6
12
|
head: any;
|
|
7
13
|
}>;
|
|
8
14
|
export declare function useHostname(e: H3Event): string;
|
|
15
|
+
export declare function readPublicAsset(file: string, encoding?: BufferEncoding): Promise<string | Buffer | undefined>;
|
|
16
|
+
export declare function readPublicAssetBase64(file: string): Promise<string | undefined>;
|
|
@@ -1,17 +1,82 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getRequestHeader } from "h3";
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { existsSync, promises as fsp } from "fs";
|
|
2
|
+
import { getQuery, getRequestHeader } from "h3";
|
|
3
|
+
import { join } from "pathe";
|
|
4
|
+
import { assetDirs } from "#nuxt-og-image/config";
|
|
5
|
+
export function wasmLoader(key, fallback, baseUrl) {
|
|
6
|
+
let promise;
|
|
7
|
+
let loaded = false;
|
|
8
|
+
return {
|
|
9
|
+
async loaded() {
|
|
10
|
+
if (loaded)
|
|
11
|
+
return true;
|
|
12
|
+
if (typeof promise !== "undefined")
|
|
13
|
+
await promise;
|
|
14
|
+
return false;
|
|
15
|
+
},
|
|
16
|
+
async load() {
|
|
17
|
+
promise = promise || new Promise(async (resolve) => {
|
|
18
|
+
let wasm;
|
|
19
|
+
try {
|
|
20
|
+
wasm = await key;
|
|
21
|
+
if (typeof wasm === "string")
|
|
22
|
+
wasm = void 0;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
}
|
|
25
|
+
if (!wasm)
|
|
26
|
+
wasm = await readPublicAsset(fallback);
|
|
27
|
+
if (!wasm) {
|
|
28
|
+
const url = new URL(baseUrl);
|
|
29
|
+
wasm = await (await fetch(`${url.origin}${fallback}`)).arrayBuffer();
|
|
30
|
+
}
|
|
31
|
+
loaded = true;
|
|
32
|
+
resolve(wasm);
|
|
33
|
+
});
|
|
34
|
+
return promise;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function fetchOptions(e, path) {
|
|
39
|
+
return globalThis.$fetch("/api/og-image-options", {
|
|
40
|
+
query: {
|
|
41
|
+
...getQuery(e),
|
|
42
|
+
path
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function base64ToArrayBuffer(base64) {
|
|
47
|
+
const buffer = Buffer.from(base64, "base64");
|
|
48
|
+
return new Uint8Array(buffer).buffer;
|
|
5
49
|
}
|
|
6
50
|
export function renderIsland(payload) {
|
|
7
|
-
return
|
|
8
|
-
props: JSON.stringify(payload)
|
|
9
|
-
})
|
|
51
|
+
return globalThis.$fetch(`/__nuxt_island/${payload.component}`, {
|
|
52
|
+
query: { props: JSON.stringify(payload) }
|
|
53
|
+
});
|
|
10
54
|
}
|
|
11
55
|
export function useHostname(e) {
|
|
12
56
|
const host = getRequestHeader(e, "host") || "localhost:3000";
|
|
13
57
|
const protocol = getRequestHeader(e, "x-forwarded-proto") || "http";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
58
|
+
const useHttp = process.env.NODE_ENV === "development" || host.includes("127.0.0.1") || host.includes("localhost") || protocol === "http";
|
|
59
|
+
return `http${useHttp ? "" : "s"}://${host}`;
|
|
60
|
+
}
|
|
61
|
+
const r = (base, key) => {
|
|
62
|
+
return join(base, key.replace(/:/g, "/"));
|
|
63
|
+
};
|
|
64
|
+
export async function readPublicAsset(file, encoding) {
|
|
65
|
+
for (const assetDir of assetDirs) {
|
|
66
|
+
const path = r(assetDir, file);
|
|
67
|
+
if (existsSync(path))
|
|
68
|
+
return await fsp.readFile(path, { encoding });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export async function readPublicAssetBase64(file) {
|
|
72
|
+
const base64 = await readPublicAsset(file, "base64");
|
|
73
|
+
if (base64) {
|
|
74
|
+
let type = "image/jpeg";
|
|
75
|
+
const ext = file.split(".").pop();
|
|
76
|
+
if (ext === "svg")
|
|
77
|
+
type = "image/svg+xml";
|
|
78
|
+
else if (ext === "png")
|
|
79
|
+
type = "image/png";
|
|
80
|
+
return `data:${type};base64,${base64}`;
|
|
81
|
+
}
|
|
17
82
|
}
|
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-og-image",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.1",
|
|
5
5
|
"packageManager": "pnpm@7.8.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -43,26 +43,28 @@
|
|
|
43
43
|
"pathe": "^1.1.0",
|
|
44
44
|
"playwright-core": "^1.30.0",
|
|
45
45
|
"radix3": "^1.0.0",
|
|
46
|
-
"satori": "^0.1.
|
|
46
|
+
"satori": "^0.1.2",
|
|
47
47
|
"satori-html": "^0.3.2",
|
|
48
48
|
"sirv": "^2.0.2",
|
|
49
49
|
"std-env": "^3.3.1",
|
|
50
|
+
"svg2png-wasm": "^1.3.4",
|
|
50
51
|
"tinyws": "^0.1.0",
|
|
51
52
|
"twemoji": "^14.0.2",
|
|
52
|
-
"ufo": "^1.0.1"
|
|
53
|
+
"ufo": "^1.0.1",
|
|
54
|
+
"yoga-wasm-web": "^0.3.0"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
|
-
"@antfu/eslint-config": "^0.
|
|
56
|
-
"@nuxt/devtools-edge": "0.0.0-
|
|
57
|
+
"@antfu/eslint-config": "^0.35.1",
|
|
58
|
+
"@nuxt/devtools-edge": "0.0.0-27920827.b7cf3cc",
|
|
57
59
|
"@nuxt/module-builder": "^0.2.1",
|
|
58
60
|
"@nuxt/test-utils": "3.1.1",
|
|
59
61
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|
|
60
62
|
"@types/ws": "^8.5.4",
|
|
61
63
|
"bumpp": "^8.2.1",
|
|
62
|
-
"eslint": "8.
|
|
64
|
+
"eslint": "8.33.0",
|
|
63
65
|
"nuxt": "npm:nuxt3@3.1.1-rc.0-27911047.7d812db",
|
|
64
|
-
"puppeteer": "^19.6.
|
|
65
|
-
"vitest": "^0.28.
|
|
66
|
+
"puppeteer": "^19.6.2",
|
|
67
|
+
"vitest": "^0.28.3"
|
|
66
68
|
},
|
|
67
69
|
"scripts": {
|
|
68
70
|
"build": "pnpm dev:prepare && pnpm build:module && pnpm build:client",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as _,r as c,e as m,w as r,h as u,o as d,i as f,j as g,l as y,m as v}from"./entry.3dc1b14c.js";const x=_({__name:"ImageLoader",props:{src:String,aspectRatio:Number,description:String},setup(o){const s=o,n=c(),a=c(0);function i(e){const t=n.value,p=Date.now();t.src="",a.value=0,t.style.opacity="0",t.onload=()=>{t.style.opacity="1",a.value=Date.now()-p},t.src=e}m(()=>{r(()=>s.src,e=>{i(e)},{immediate:!0})});const l=u(()=>s.description.replace("%s",a.value.toString()));return r(l,e=>{y.value=e}),(e,t)=>(d(),f("img",{ref_key:"image",ref:n,class:"max-h-full border-1 border-light-500 rounded",style:g({aspectRatio:o.aspectRatio})},null,4))}});const h=v(x,[["__scopeId","data-v-bfe57a8f"]]);export{h as _};
|