nuxt-og-image 1.3.2 → 1.4.0

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.
Files changed (145) hide show
  1. package/README.md +3 -2
  2. package/dist/client/200.html +2 -2
  3. package/dist/client/404.html +2 -2
  4. package/dist/client/_nuxt/{index.7072fbd5.css → IFrameLoader.7072fbd5.css} +0 -0
  5. package/dist/client/_nuxt/IFrameLoader.d5909035.js +1 -0
  6. package/dist/client/_nuxt/Icon.403b6716.css +1 -0
  7. package/dist/client/_nuxt/Icon.60a95afe.js +1 -0
  8. package/dist/client/_nuxt/Icon.vue.a2ec08e3.js +1 -0
  9. package/dist/client/_nuxt/ImageLoader.a4ce18ac.js +1 -0
  10. package/dist/client/_nuxt/NButton.694cef96.js +1 -0
  11. package/dist/client/_nuxt/NButton.vue.ab05bc78.js +1 -0
  12. package/dist/client/_nuxt/NCard.73524dd1.js +1 -0
  13. package/dist/client/_nuxt/NCheckbox.d5ba4120.js +1 -0
  14. package/dist/client/_nuxt/NDarkToggle.687abd18.js +1 -0
  15. package/dist/client/_nuxt/NDarkToggle.vue.f7f2dd0a.js +1 -0
  16. package/dist/client/_nuxt/NDialog.44534c12.js +7 -0
  17. package/dist/client/_nuxt/NDropdown.29d0f6c4.js +1 -0
  18. package/dist/client/_nuxt/NIcon.af04832c.js +1 -0
  19. package/dist/client/_nuxt/NIcon.vue.4a86e248.js +1 -0
  20. package/dist/client/_nuxt/NLink.7b890d54.js +1 -0
  21. package/dist/client/_nuxt/NLink.vue.1c7b39cf.js +1 -0
  22. package/dist/client/_nuxt/NRadio.1079a996.js +1 -0
  23. package/dist/client/_nuxt/NSwitch.28e8e7c4.js +1 -0
  24. package/dist/client/_nuxt/NTextInput.dd5d77f0.js +1 -0
  25. package/dist/client/_nuxt/NTextInput.vue.9b6f61da.js +1 -0
  26. package/dist/client/_nuxt/NTip.a2522c9e.js +1 -0
  27. package/dist/client/_nuxt/NuxtContentLogo.b33b5adb.js +1 -0
  28. package/dist/client/_nuxt/NuxtExampleLayout.5726c1e7.js +1 -0
  29. package/dist/client/_nuxt/NuxtLogo.c4101b4a.js +1 -0
  30. package/dist/client/_nuxt/UnoIcon.3704f042.js +1 -0
  31. package/dist/client/_nuxt/_plugin-vue_export-helper.c27b6911.js +1 -0
  32. package/dist/client/_nuxt/app.config.d5ed556c.js +1 -0
  33. package/dist/client/_nuxt/client-only.a160727e.js +4 -0
  34. package/dist/client/_nuxt/component.vue3.3c33ad5e.js +1 -0
  35. package/dist/client/_nuxt/components.client.a14db737.js +1 -0
  36. package/dist/client/_nuxt/components.def83447.js +1 -0
  37. package/dist/client/_nuxt/composables.b3b1407e.js +1 -0
  38. package/dist/client/_nuxt/dev-only.3974795b.js +1 -0
  39. package/dist/client/_nuxt/entry.3a708ff1.css +1 -0
  40. package/dist/client/_nuxt/entry.87ffbf0a.js +1 -0
  41. package/dist/client/_nuxt/error-404.1469f10f.css +1 -0
  42. package/dist/client/_nuxt/error-404.6ae4da09.js +1 -0
  43. package/dist/client/_nuxt/error-500.0e359581.js +1 -0
  44. package/dist/client/_nuxt/error-500.92b94fae.css +1 -0
  45. package/dist/client/_nuxt/error-component.e464704a.js +3 -0
  46. package/dist/client/_nuxt/index.0662c04b.js +1 -0
  47. package/dist/client/_nuxt/index.8da3b00c.js +1 -0
  48. package/dist/client/_nuxt/index.f6e5e2e7.js +1 -0
  49. package/dist/client/_nuxt/layout.ac370415.js +1 -0
  50. package/dist/client/_nuxt/logic.439aa142.js +1 -0
  51. package/dist/client/_nuxt/nuxt-error-boundary.550746e3.js +1 -0
  52. package/dist/client/_nuxt/nuxt-link.3b9becb1.js +1 -0
  53. package/dist/client/_nuxt/nuxt-loading-indicator.de8802c9.js +1 -0
  54. package/dist/client/_nuxt/options.582fe505.js +1 -0
  55. package/dist/client/_nuxt/page.b8634cae.js +1 -0
  56. package/dist/client/_nuxt/png.24020c5d.js +1 -0
  57. package/dist/client/_nuxt/runtime-core.esm-bundler.d2479180.js +1 -0
  58. package/dist/client/_nuxt/runtime-dom.esm-bundler.f4f35d78.js +1 -0
  59. package/dist/client/_nuxt/server-placeholder.8ed08e3a.js +1 -0
  60. package/dist/client/_nuxt/{shiki.69102a86.js → shiki.13470033.js} +5 -5
  61. package/dist/client/_nuxt/state.4540d876.js +1 -0
  62. package/dist/client/_nuxt/svg.e70dde70.js +1 -0
  63. package/dist/client/_nuxt/utils.b6c92ff8.js +5 -0
  64. package/dist/client/_nuxt/vnodes.25b95d99.js +1 -0
  65. package/dist/client/_nuxt/welcome.db724adb.css +1 -0
  66. package/dist/client/_nuxt/welcome.dd0c800c.js +1 -0
  67. package/dist/client/index.html +2 -2
  68. package/dist/client/options/index.html +2 -2
  69. package/dist/client/png/index.html +2 -2
  70. package/dist/client/svg/index.html +2 -2
  71. package/dist/client/vnodes/index.html +2 -2
  72. package/dist/module.d.ts +3 -2
  73. package/dist/module.json +1 -1
  74. package/dist/module.mjs +66 -43
  75. package/dist/runtime/components/OgImageBasic.island.vue +1 -1
  76. package/dist/runtime/composables/defineOgImage.mjs +7 -6
  77. package/dist/runtime/nitro/{routes/__og_image__ → middleware}/og.png.d.ts +0 -0
  78. package/dist/runtime/nitro/{routes/__og_image__ → middleware}/og.png.mjs +4 -4
  79. package/dist/runtime/nitro/{routes/__og_image__/index.d.ts → middleware/playground.d.ts} +0 -0
  80. package/dist/runtime/nitro/{routes/__og_image__/index.mjs → middleware/playground.mjs} +4 -4
  81. package/dist/runtime/nitro/providers/browser/lambda.d.ts +1 -0
  82. package/dist/runtime/nitro/{browsers → providers/browser}/lambda.mjs +1 -1
  83. package/dist/runtime/nitro/providers/browser/node.d.ts +1 -0
  84. package/dist/runtime/nitro/{browsers/default.mjs → providers/browser/node.mjs} +1 -1
  85. package/dist/runtime/nitro/providers/satori/node.d.ts +2 -0
  86. package/dist/runtime/nitro/providers/satori/node.mjs +4 -0
  87. package/dist/runtime/nitro/providers/satori/webworker.d.ts +4 -0
  88. package/dist/runtime/nitro/providers/satori/webworker.mjs +11 -0
  89. package/dist/runtime/nitro/providers/svg2png/universal.d.ts +4 -0
  90. package/dist/runtime/nitro/providers/svg2png/universal.mjs +9 -0
  91. package/dist/runtime/nitro/renderers/browser.d.ts +3 -0
  92. package/dist/runtime/nitro/{providers → renderers}/browser.mjs +5 -2
  93. package/dist/runtime/nitro/renderers/satori/index.d.ts +3 -0
  94. package/dist/runtime/nitro/{providers → renderers}/satori/index.mjs +14 -8
  95. package/dist/runtime/nitro/{providers → renderers}/satori/plugins/emojis.d.ts +0 -0
  96. package/dist/runtime/nitro/{providers → renderers}/satori/plugins/emojis.mjs +0 -0
  97. package/dist/runtime/nitro/{providers → renderers}/satori/plugins/flex.d.ts +0 -0
  98. package/dist/runtime/nitro/{providers → renderers}/satori/plugins/flex.mjs +0 -0
  99. package/dist/runtime/nitro/{providers → renderers}/satori/plugins/imageSrc.d.ts +0 -0
  100. package/dist/runtime/nitro/{providers → renderers}/satori/plugins/imageSrc.mjs +2 -1
  101. package/dist/runtime/nitro/{providers → renderers}/satori/plugins/twClasses.d.ts +0 -0
  102. package/dist/runtime/nitro/{providers → renderers}/satori/plugins/twClasses.mjs +0 -0
  103. package/dist/runtime/nitro/{providers → renderers}/satori/utils.d.ts +1 -4
  104. package/dist/runtime/nitro/renderers/satori/utils.mjs +45 -0
  105. package/dist/runtime/nitro/routes/{__og_image__/font.d.ts → font.d.ts} +0 -0
  106. package/dist/runtime/nitro/routes/{__og_image__/font.mjs → font.mjs} +1 -1
  107. package/dist/runtime/nitro/routes/{__og_image__/html.d.ts → html.d.ts} +0 -0
  108. package/dist/runtime/nitro/routes/{__og_image__/html.mjs → html.mjs} +9 -8
  109. package/dist/runtime/nitro/routes/{__og_image__/options.d.ts → options.d.ts} +2 -2
  110. package/dist/runtime/nitro/routes/{__og_image__/options.mjs → options.mjs} +6 -9
  111. package/dist/runtime/nitro/routes/{__og_image__/svg.d.ts → svg.d.ts} +0 -0
  112. package/dist/runtime/nitro/routes/svg.mjs +11 -0
  113. package/dist/runtime/nitro/routes/{__og_image__/vnode.d.ts → vnode.d.ts} +0 -0
  114. package/dist/runtime/nitro/routes/vnode.mjs +11 -0
  115. package/dist/runtime/nitro/utils.d.ts +9 -1
  116. package/dist/runtime/nitro/utils.mjs +75 -10
  117. package/dist/runtime/{public → public-assets}/inter-latin-ext-400-normal.woff +0 -0
  118. package/dist/runtime/{public → public-assets}/inter-latin-ext-700-normal.woff +0 -0
  119. package/dist/runtime/public-assets/svg2png.wasm +0 -0
  120. package/dist/runtime/public-assets/yoga.wasm +0 -0
  121. package/package.json +10 -8
  122. package/dist/client/_nuxt/ImageLoader.be226b50.js +0 -1
  123. package/dist/client/_nuxt/entry.3dc1b14c.js +0 -5
  124. package/dist/client/_nuxt/entry.9f5c391a.css +0 -1
  125. package/dist/client/_nuxt/error-404.68aa58b4.css +0 -1
  126. package/dist/client/_nuxt/error-404.9a311ab2.js +0 -1
  127. package/dist/client/_nuxt/error-500.dc5710d1.css +0 -1
  128. package/dist/client/_nuxt/error-500.f8d3032e.js +0 -1
  129. package/dist/client/_nuxt/error-component.a4dd1ebc.js +0 -3
  130. package/dist/client/_nuxt/index.dea39ba2.js +0 -1
  131. package/dist/client/_nuxt/options.53a4a6ca.js +0 -1
  132. package/dist/client/_nuxt/png.6a754041.js +0 -1
  133. package/dist/client/_nuxt/svg.afcae77d.js +0 -1
  134. package/dist/client/_nuxt/vnodes.dd40690d.js +0 -1
  135. package/dist/runtime/nitro/browsers/default.d.ts +0 -1
  136. package/dist/runtime/nitro/browsers/lambda.d.ts +0 -1
  137. package/dist/runtime/nitro/providers/browser.d.ts +0 -3
  138. package/dist/runtime/nitro/providers/satori/index.d.ts +0 -3
  139. package/dist/runtime/nitro/providers/satori/utils.mjs +0 -69
  140. package/dist/runtime/nitro/resvg/node.d.ts +0 -3
  141. package/dist/runtime/nitro/resvg/node.mjs +0 -6
  142. package/dist/runtime/nitro/resvg/wasm.d.ts +0 -2
  143. package/dist/runtime/nitro/resvg/wasm.mjs +0 -32
  144. package/dist/runtime/nitro/routes/__og_image__/svg.mjs +0 -16
  145. package/dist/runtime/nitro/routes/__og_image__/vnode.mjs +0 -16
@@ -1 +0,0 @@
1
- import{a as v,r as _,b as x,e as S,w as u,f as b,h as R,o as g,i as y,j as k,k as H,l as $,m as D,p as h,q as F,u as p,s as I,t as L,v as W,x as B,y as C}from"./entry.3dc1b14c.js";const M=v({__name:"IFrameLoader",props:{src:String,aspectRatio:Number,description:String},setup(r){const t=r,s=_(t.src),a=_(),o=_(0),c=x(()=>{let e=a.value;e||(e=document.querySelector("#iframe-loader"));const l=Date.now();e.src="";const n=e.offsetHeight,d=e.offsetWidth,m=n>630?1:n/630,f=d>1200?1:d/1200,w=f>m?m:f;o.value=0,e.style.opacity="0",e.onload=()=>{e.style.opacity="1",o.value=Date.now()-l},e.src=`${s.value}&scale=${w}`},200);S(()=>{u(()=>t.src,e=>{s.value=e,c()},{immediate:!0}),u(()=>H.value,()=>{c()})}),b({bodyAttrs:{onresize:()=>{c()}}});const i=R(()=>t.description.replace("%s",o.value.toString()));return u(i,e=>{$.value=e}),(e,l)=>(g(),y("iframe",{id:"iframe-loader",ref_key:"iframe",ref:a,class:"max-h-full",style:k({aspectRatio:r.aspectRatio}),width:"1200",height:"630"},null,4))}});const T=D(M,[["__scopeId","data-v-7b5ca4c2"]]),q={class:"flex h-full w-full"},A=v({__name:"index",async setup(r){let t,s;const a=([t,s]=h(()=>I.useServerConfig()),t=await t,s(),t),o=a.value?.height||630,i=(a.value?.width||1200)/o;return[t,s]=h(()=>L()),t=await t,s(),(e,l)=>{const n=T;return g(),y("div",q,[F(n,{src:`${p(W)}/__og_image__/html?timestamp=${p(B)}`,"aspect-ratio":i,description:"[HTML] Generated in %sms.",class:"max-h-full",onRefresh:p(C)},null,8,["src","onRefresh"])])}}});export{A as default};
@@ -1 +0,0 @@
1
- import{a as i,p as a,o as r,i as h,u as s,t as p}from"./entry.3dc1b14c.js";import{h as l}from"./shiki.69102a86.js";const c=["innerHTML"],g=i({__name:"options",async setup(_){let t,e;const o=([t,e]=a(()=>p()),t=await t,e(),t);return(n,f)=>(r(),h("pre",{"of-auto":"","h-full":"","text-sm":"",style:{"white-space":"break-spaces"},innerHTML:("highlight"in n?n.highlight:s(l))(JSON.stringify(s(o),null,2),"json")},null,8,c))}});export{g as default};
@@ -1 +0,0 @@
1
- import{_ as i}from"./ImageLoader.be226b50.js";import{a as _,p as a,o as p,c as m,u as o,s as u,t as g,v as h,x as f}from"./entry.3dc1b14c.js";const C=_({__name:"png",async setup(l){let t,e;const s=([t,e]=a(()=>u.useServerConfig()),t=await t,e(),t),n=s.value?.height||630,c=(s.value?.width||1200)/n;return[t,e]=a(()=>g()),t=await t,e(),(w,v)=>{const r=i;return p(),m(r,{src:`${o(h)}/__og_image__/og.png?timestamp=${o(f)}`,"aspect-ratio":c,description:"[PNG] Generated in %sms using Satori & Resvg."},null,8,["src"])}}});export{C as default};
@@ -1 +0,0 @@
1
- import{_ as i}from"./ImageLoader.be226b50.js";import{a as _,p as a,o as p,c as m,u as o,s as u,t as h,v as f,x as g}from"./entry.3dc1b14c.js";const C=_({__name:"svg",async setup(l){let t,e;const s=([t,e]=a(()=>u.useServerConfig()),t=await t,e(),t),n=s.value?.height||630,c=(s.value?.width||1200)/n;return[t,e]=a(()=>h()),t=await t,e(),(v,w)=>{const r=i;return p(),m(r,{src:`${o(f)}/__og_image__/svg?timestamp=${o(g)}`,"aspect-ratio":c,description:"[SVG] Generated in %sms using Satori."},null,8,["src"])}}});export{C as default};
@@ -1 +0,0 @@
1
- import{a,p as i,o as r,i as h,u as n,A as l}from"./entry.3dc1b14c.js";import{h as c}from"./shiki.69102a86.js";const p=["innerHTML"],g=a({__name:"vnodes",async setup(_){let e,t;const o=([e,t]=i(()=>l()),e=await e,t(),e);return(s,f)=>(r(),h("pre",{"of-auto":"","h-full":"","text-sm":"",style:{"white-space":"break-spaces"},innerHTML:("highlight"in s?s.highlight:n(c))(JSON.stringify(n(o),null,2),"json")},null,8,p))}});export{g as default};
@@ -1 +0,0 @@
1
- export declare function createBrowser(): Promise<any>;
@@ -1 +0,0 @@
1
- export declare function createBrowser(): Promise<import("puppeteer-core").Browser>;
@@ -1,3 +0,0 @@
1
- import type { Provider } from '../../../types';
2
- declare const _default: Provider;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { Provider } from '../../../../types';
2
- declare const _default: Provider;
3
- export default _default;
@@ -1,69 +0,0 @@
1
- import { existsSync, promises as fsp } from "fs";
2
- import { join } from "pathe";
3
- import { useStorage } from "#internal/nitro";
4
- import { publicDirs } from "#nuxt-og-image/config";
5
- const cachedFonts = {};
6
- const r = (base, key) => {
7
- return join(base, key.replace(/:/g, "/"));
8
- };
9
- export async function readPublicAsset(file, encoding) {
10
- for (const d of publicDirs) {
11
- const path = r(d, file);
12
- if (existsSync(path))
13
- return await fsp.readFile(path, { encoding });
14
- }
15
- }
16
- export async function readPublicAssetBase64(file) {
17
- const base64 = await readPublicAsset(file, "base64");
18
- if (base64) {
19
- let type = "image/jpeg";
20
- const ext = file.split(".").pop();
21
- if (ext === "svg")
22
- type = "image/svg+xml";
23
- else if (ext === "png")
24
- type = "image/png";
25
- return `data:${type};base64,${base64}`;
26
- }
27
- }
28
- export async function loadFont(url, font) {
29
- if (cachedFonts[font])
30
- return cachedFonts[font];
31
- const [name, weight] = font.split(":");
32
- if (name === "Inter" && ["400", "700"].includes(weight)) {
33
- const data2 = await readPublicAsset(`/inter-latin-ext-${weight}-normal.woff`);
34
- if (data2) {
35
- return cachedFonts[font] = { name, weight: weight === "400" ? "500" : weight, data: data2, style: "normal" };
36
- }
37
- }
38
- const fontUrl = await $fetch("/api/og-image-font", {
39
- query: { name, weight }
40
- });
41
- let data;
42
- const storageKey = `nuxt-og-image:font:${font}`;
43
- const hasStoredFont = await useStorage().hasItem(storageKey);
44
- if (!hasStoredFont) {
45
- data = await $fetch(fontUrl, {
46
- responseType: "arrayBuffer"
47
- });
48
- await useStorage().setItem(storageKey, data);
49
- } else {
50
- data = await useStorage().getItem(storageKey);
51
- }
52
- return cachedFonts[font] = { name, weight, data, style: "normal" };
53
- }
54
- export async function walkSatoriTree(url, node, plugins) {
55
- if (!node.props?.children)
56
- return;
57
- for (const child of node.props.children || []) {
58
- if (child) {
59
- for (const plugin of plugins) {
60
- if (plugin.filter(child))
61
- await plugin.transform(child);
62
- }
63
- await walkSatoriTree(url, child, plugins);
64
- }
65
- }
66
- }
67
- export function defineSatoriTransformer(transformer) {
68
- return transformer;
69
- }
@@ -1,3 +0,0 @@
1
- /// <reference types="node" />
2
- import type { ResvgRenderOptions } from '@resvg/resvg-js';
3
- export default function (svg: string, options: ResvgRenderOptions): Promise<Buffer>;
@@ -1,6 +0,0 @@
1
- import { Resvg } from "@resvg/resvg-js";
2
- export default async function(svg, options) {
3
- const resvg = new Resvg(svg, options);
4
- const pngData = resvg.render();
5
- return pngData.asPng();
6
- }
@@ -1,2 +0,0 @@
1
- import type { ResvgRenderOptions } from '@resvg/resvg-wasm';
2
- export default function (svg: string, options: ResvgRenderOptions): Promise<Uint8Array>;
@@ -1,32 +0,0 @@
1
- import { Resvg, initWasm } from "@resvg/resvg-wasm";
2
- import { resolvePath } from "mlly";
3
- import { dirname, join } from "pathe";
4
- import { $fetch } from "ofetch";
5
- let initialisedWasm = false;
6
- async function useResvgWasm() {
7
- let wasm = null;
8
- if (initialisedWasm)
9
- return;
10
- try {
11
- const path = join(
12
- dirname(await resolvePath("@resvg/resvg-wasm")),
13
- "index_bg.wasm"
14
- );
15
- const fs = await import("node:fs/promises");
16
- wasm = await fs.readFile(path);
17
- } catch (e) {
18
- wasm = await $fetch("https://unpkg.com/@resvg/resvg-wasm/index_bg.wasm", {
19
- responseType: "arrayBuffer"
20
- });
21
- }
22
- if (wasm) {
23
- await initWasm(wasm);
24
- initialisedWasm = true;
25
- }
26
- }
27
- export default async function(svg, options) {
28
- await useResvgWasm();
29
- const resvg = new Resvg(svg, options);
30
- const pngData = resvg.render();
31
- return pngData.asPng();
32
- }
@@ -1,16 +0,0 @@
1
- import { defineEventHandler, setHeader } from "h3";
2
- import { joinURL, parseURL, withBase, withoutTrailingSlash } 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 = parseURL(e.path).pathname;
7
- if (!path.endsWith("__og_image__/svg"))
8
- return;
9
- const basePath = withoutTrailingSlash(
10
- path.replace("__og_image__/svg", "")
11
- );
12
- const options = await fetchOptions(basePath);
13
- setHeader(e, "Content-Type", "image/svg+xml");
14
- const provider = await useProvider(options.provider);
15
- return provider.createSvg(withBase(joinURL(basePath, "/__og_image__/html"), useHostname(e)), options);
16
- });
@@ -1,16 +0,0 @@
1
- import { defineEventHandler, setHeader } from "h3";
2
- import { joinURL, parseURL, withBase, withoutTrailingSlash } 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 = parseURL(e.path).pathname;
7
- if (!path.endsWith("__og_image__/vnode"))
8
- return;
9
- const basePath = withoutTrailingSlash(
10
- path.replace("__og_image__/vnode", "")
11
- );
12
- const options = await fetchOptions(basePath);
13
- setHeader(e, "Content-Type", "application/json");
14
- const provider = await useProvider(options.provider);
15
- return provider.createVNode(withBase(joinURL(basePath, "/__og_image__/html"), useHostname(e)), options);
16
- });