nuxt-og-image 2.0.0-beta.4 → 2.0.0-beta.40

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 (82) hide show
  1. package/README.md +245 -47
  2. package/dist/client/200.html +2 -2
  3. package/dist/client/404.html +2 -2
  4. package/dist/client/_nuxt/IconCSS.1dce7adc.js +1 -0
  5. package/dist/client/_nuxt/IconCSS.f16db5c2.css +1 -0
  6. package/dist/client/_nuxt/ImageLoader.163d23b3.js +1 -0
  7. package/dist/client/_nuxt/ImageLoader.7571516f.css +1 -0
  8. package/dist/client/_nuxt/entry.23646169.js +5 -0
  9. package/dist/client/_nuxt/entry.3d2654cc.css +1 -0
  10. package/dist/client/_nuxt/{error-404.1ff52902.js → error-404.c0f2dfff.js} +1 -1
  11. package/dist/client/_nuxt/{error-500.f7d30da5.js → error-500.6a9dcc3d.js} +1 -1
  12. package/dist/client/_nuxt/{error-component.cf7543e5.js → error-component.0db07bb1.js} +2 -2
  13. package/dist/client/_nuxt/index.403133d8.css +1 -0
  14. package/dist/client/_nuxt/index.531c9ed8.js +1 -0
  15. package/dist/client/_nuxt/{options.56a3e5f9.js → options.fd71c26a.js} +1 -1
  16. package/dist/client/_nuxt/{png.37f3e77b.js → png.5b6830ea.js} +1 -1
  17. package/dist/client/_nuxt/{shiki.3a930bb8.js → shiki.1be71764.js} +1 -1
  18. package/dist/client/_nuxt/{svg.186c6bd1.js → svg.165cf4fc.js} +1 -1
  19. package/dist/client/_nuxt/{vnodes.a799f183.js → vnodes.11ff70a7.js} +1 -1
  20. package/dist/client/index.html +2 -2
  21. package/dist/client/options/index.html +2 -2
  22. package/dist/client/png/index.html +2 -2
  23. package/dist/client/svg/index.html +2 -2
  24. package/dist/client/vnodes/index.html +2 -2
  25. package/dist/module.d.ts +21 -7
  26. package/dist/module.json +1 -1
  27. package/dist/module.mjs +283 -112
  28. package/dist/runtime/browserUtil.d.ts +1 -0
  29. package/dist/runtime/browserUtil.mjs +10 -5
  30. package/dist/runtime/composables/defineOgImage.mjs +15 -12
  31. package/dist/runtime/nitro/middleware/og.png.mjs +51 -7
  32. package/dist/runtime/nitro/middleware/playground.mjs +4 -3
  33. package/dist/runtime/nitro/plugins/prerender.d.ts +3 -0
  34. package/dist/runtime/nitro/plugins/prerender.mjs +26 -0
  35. package/dist/runtime/nitro/providers/browser/lambda.d.ts +1 -1
  36. package/dist/runtime/nitro/providers/browser/lambda.mjs +3 -3
  37. package/dist/runtime/nitro/providers/browser/{node.mjs → playwright.mjs} +0 -9
  38. package/dist/runtime/nitro/providers/browser/universal.d.ts +1 -0
  39. package/dist/runtime/nitro/providers/browser/universal.mjs +33 -0
  40. package/dist/runtime/nitro/providers/png/resvg-node.d.ts +5 -0
  41. package/dist/runtime/nitro/providers/png/resvg-node.mjs +6 -0
  42. package/dist/runtime/nitro/providers/png/resvg-wasm.d.ts +4 -0
  43. package/dist/runtime/nitro/providers/png/resvg-wasm.mjs +11 -0
  44. package/dist/runtime/nitro/providers/png/svg2png.mjs +11 -0
  45. package/dist/runtime/nitro/providers/satori/{webworker.mjs → yoga-wasm.mjs} +4 -5
  46. package/dist/runtime/nitro/renderers/browser.mjs +12 -6
  47. package/dist/runtime/nitro/renderers/satori/index.mjs +20 -14
  48. package/dist/runtime/nitro/renderers/satori/plugins/encoding.mjs +2 -1
  49. package/dist/runtime/nitro/renderers/satori/plugins/imageSrc.mjs +25 -3
  50. package/dist/runtime/nitro/renderers/satori/utils.d.ts +2 -2
  51. package/dist/runtime/nitro/renderers/satori/utils.mjs +25 -12
  52. package/dist/runtime/nitro/routes/debug.d.ts +4 -0
  53. package/dist/runtime/nitro/routes/debug.mjs +9 -0
  54. package/dist/runtime/nitro/routes/html.mjs +52 -14
  55. package/dist/runtime/nitro/routes/options.mjs +18 -15
  56. package/dist/runtime/nitro/routes/svg.mjs +3 -1
  57. package/dist/runtime/nitro/routes/vnode.mjs +3 -1
  58. package/dist/runtime/nitro/util-hostname.d.ts +2 -0
  59. package/dist/runtime/nitro/util-hostname.mjs +15 -0
  60. package/dist/runtime/nitro/utils-pure.d.ts +3 -2
  61. package/dist/runtime/nitro/utils-pure.mjs +9 -8
  62. package/dist/runtime/nitro/utils.d.ts +6 -8
  63. package/dist/runtime/nitro/utils.mjs +50 -47
  64. package/dist/runtime/public-assets/__nuxt_og_image__/browser-provider-not-supported.png +0 -0
  65. package/dist/runtime/public-assets-optional/resvg/resvg.wasm +0 -0
  66. package/dist/types.d.ts +6 -0
  67. package/package.json +32 -22
  68. package/dist/client/_nuxt/IconCSS.a041aca0.js +0 -1
  69. package/dist/client/_nuxt/ImageLoader.9bf39d71.js +0 -1
  70. package/dist/client/_nuxt/entry.74018bda.js +0 -5
  71. package/dist/client/_nuxt/entry.7a8c1ab2.css +0 -1
  72. package/dist/client/_nuxt/index.3f356409.js +0 -1
  73. package/dist/runtime/nitro/providers/svg2png/universal.mjs +0 -9
  74. /package/dist/runtime/nitro/providers/browser/{node.d.ts → playwright.d.ts} +0 -0
  75. /package/dist/runtime/nitro/providers/{svg2png/universal.d.ts → png/svg2png.d.ts} +0 -0
  76. /package/dist/runtime/nitro/providers/satori/{node.d.ts → default.d.ts} +0 -0
  77. /package/dist/runtime/nitro/providers/satori/{node.mjs → default.mjs} +0 -0
  78. /package/dist/runtime/nitro/providers/satori/{webworker.d.ts → yoga-wasm.d.ts} +0 -0
  79. /package/dist/runtime/{public-assets → public-assets-optional/inter-font}/inter-latin-ext-400-normal.woff +0 -0
  80. /package/dist/runtime/{public-assets → public-assets-optional/inter-font}/inter-latin-ext-700-normal.woff +0 -0
  81. /package/dist/runtime/{public-assets → public-assets-optional/svg2png}/svg2png.wasm +0 -0
  82. /package/dist/runtime/{public-assets → public-assets-optional/yoga}/yoga.wasm +0 -0
@@ -1,29 +1,56 @@
1
1
  import { withBase } from "ufo";
2
2
  import { renderSSRHead } from "@unhead/ssr";
3
3
  import { createHeadCore } from "@unhead/vue";
4
- import { defineEventHandler, getQuery, sendRedirect } from "h3";
5
- import { fetchOptions, renderIsland, useHostname } from "../utils.mjs";
6
- import { useRuntimeConfig } from "#internal/nitro";
4
+ import { createError, defineEventHandler, getQuery, sendRedirect } from "h3";
5
+ import { hash } from "ohash";
6
+ import { fetchOptions, useHostname } from "../utils.mjs";
7
+ import { useRuntimeConfig } from "#imports";
7
8
  export default defineEventHandler(async (e) => {
8
9
  const { fonts, defaults } = useRuntimeConfig()["nuxt-og-image"];
9
- const path = getQuery(e).path || "/";
10
- const scale = getQuery(e).scale;
11
- const mode = getQuery(e).mode || "light";
10
+ const query = getQuery(e);
11
+ const path = withBase(query.path || "/", useRuntimeConfig().app.baseURL);
12
+ const scale = query.scale;
13
+ const mode = query.mode || "light";
12
14
  let options;
13
- if (getQuery(e).options)
14
- options = JSON.parse(getQuery(e).options);
15
+ if (query.options) {
16
+ try {
17
+ options = JSON.parse(query.options);
18
+ } catch {
19
+ }
20
+ }
15
21
  if (!options)
16
22
  options = await fetchOptions(e, path);
17
- if (options.provider === "browser" && !options.component)
18
- return sendRedirect(e, withBase(path, useHostname(e)));
19
- const island = await renderIsland(options);
23
+ if (options.provider === "browser" && !options.component) {
24
+ const pathWithoutBase = path.replace(new RegExp(`^${useRuntimeConfig().app.baseURL}`), "");
25
+ return sendRedirect(e, withBase(pathWithoutBase, useHostname(e)));
26
+ }
27
+ if (!options.component) {
28
+ throw createError({
29
+ statusCode: 500,
30
+ statusMessage: `Nuxt OG Image trying to render an invalid component. Received options ${JSON.stringify(options)}`
31
+ });
32
+ }
33
+ const hashId = hash([options.component, options]);
34
+ const island = await $fetch(`/__nuxt_island/${options.component}:${hashId}`, {
35
+ params: {
36
+ props: JSON.stringify(options)
37
+ }
38
+ });
20
39
  const head = createHeadCore();
21
40
  head.push(island.head);
41
+ let defaultFontFamily = "sans-serif";
42
+ const firstFont = fonts[0];
43
+ if (firstFont) {
44
+ if (typeof firstFont === "string")
45
+ defaultFontFamily = firstFont.split(":")[0];
46
+ else
47
+ defaultFontFamily = firstFont.name;
48
+ }
22
49
  head.push({
23
50
  style: [
24
51
  {
25
52
  // default font is the first font family
26
- innerHTML: `body { font-family: '${fonts[0].split(":")[0].replace("+", " ")}', sans-serif; }`
53
+ innerHTML: `body { font-family: '${defaultFontFamily.replace("+", " ")}', sans-serif; }`
27
54
  },
28
55
  scale ? {
29
56
  innerHTML: `body {
@@ -43,7 +70,18 @@ img.emoji {
43
70
  vertical-align: -0.1em;
44
71
  }
45
72
  `
46
- } : {}
73
+ } : {},
74
+ ...fonts.filter((font) => typeof font === "object").map((font) => {
75
+ const { name, weight, path: path2 } = font;
76
+ return `
77
+ @font-face {
78
+ font-family: '${name}';
79
+ font-style: normal;
80
+ font-weight: ${weight};
81
+ src: url('${path2}') format('truetype');
82
+ }
83
+ `;
84
+ })
47
85
  ],
48
86
  meta: [
49
87
  {
@@ -70,7 +108,7 @@ img.emoji {
70
108
  rel: "stylesheet"
71
109
  },
72
110
  // have to add each weight as their own stylesheet
73
- ...fonts.map((font) => {
111
+ ...fonts.filter((font) => typeof font === "string").map((font) => {
74
112
  const [name, weight] = font.split(":");
75
113
  return {
76
114
  href: `https://fonts.googleapis.com/css2?family=${name}:wght@${weight}&display=swap`,
@@ -1,17 +1,20 @@
1
- import { createError, defineEventHandler, getHeaders, getQuery } from "h3";
2
- import { extractOgImageOptions, useHostname } from "../utils.mjs";
3
- import { getRouteRules, useRuntimeConfig } from "#internal/nitro";
1
+ import { createError, defineEventHandler, getQuery } from "h3";
2
+ import { withoutBase } from "ufo";
3
+ import { extractOgImageOptions } from "../utils.mjs";
4
+ import { getRouteRules } from "#internal/nitro";
5
+ import { useRuntimeConfig } from "#imports";
4
6
  export default defineEventHandler(async (e) => {
5
7
  const query = getQuery(e);
6
- const path = query.path || "/";
7
- const fetchOptions = process.dev || process.env.prerender ? {
8
- headers: getHeaders(e)
9
- } : {
10
- baseURL: useHostname(e)
11
- };
12
- const html = await globalThis.$fetch(path, {
13
- ...fetchOptions
14
- });
8
+ const path = withoutBase(query.path || "/", useRuntimeConfig().app.baseURL);
9
+ let html;
10
+ try {
11
+ html = await globalThis.$fetch(path);
12
+ } catch (err) {
13
+ throw createError({
14
+ statusCode: 500,
15
+ statusMessage: `Failed to read the path ${path} for og-image extraction. ${err.message}.`
16
+ });
17
+ }
15
18
  const extractedPayload = extractOgImageOptions(html);
16
19
  if (!extractedPayload) {
17
20
  throw createError({
@@ -20,8 +23,10 @@ export default defineEventHandler(async (e) => {
20
23
  });
21
24
  }
22
25
  e.node.req.url = path;
26
+ const oldRouteRules = e.context._nitro.routeRules;
23
27
  e.context._nitro.routeRules = void 0;
24
28
  const routeRules = getRouteRules(e)?.ogImage;
29
+ e.context._nitro.routeRules = oldRouteRules;
25
30
  e.node.req.url = e.path;
26
31
  if (routeRules === false)
27
32
  return false;
@@ -32,8 +37,6 @@ export default defineEventHandler(async (e) => {
32
37
  // use route rules
33
38
  ...routeRules || {},
34
39
  // use provided data
35
- ...extractedPayload,
36
- // use query data
37
- ...query
40
+ ...extractedPayload
38
41
  };
39
42
  });
@@ -2,8 +2,10 @@ import { createError, defineEventHandler, getQuery, setHeader } from "h3";
2
2
  import { withBase } from "ufo";
3
3
  import { fetchOptions, useHostname } from "../utils.mjs";
4
4
  import { useProvider } from "#nuxt-og-image/provider";
5
+ import { useRuntimeConfig } from "#imports";
5
6
  export default defineEventHandler(async (e) => {
6
- const path = getQuery(e).path || "/";
7
+ const query = getQuery(e);
8
+ const path = withBase(query.path || "/", useRuntimeConfig().app.baseURL);
7
9
  const options = await fetchOptions(e, path);
8
10
  setHeader(e, "Content-Type", "image/svg+xml");
9
11
  const provider = await useProvider(options.provider);
@@ -2,8 +2,10 @@ import { createError, defineEventHandler, getQuery, setHeader } from "h3";
2
2
  import { withBase } from "ufo";
3
3
  import { fetchOptions, useHostname } from "../utils.mjs";
4
4
  import { useProvider } from "#nuxt-og-image/provider";
5
+ import { useRuntimeConfig } from "#imports";
5
6
  export default defineEventHandler(async (e) => {
6
- const path = getQuery(e).path || "/";
7
+ const query = getQuery(e);
8
+ const path = withBase(query.path || "/", useRuntimeConfig().app.baseURL);
7
9
  const options = await fetchOptions(e, path);
8
10
  setHeader(e, "Content-Type", "application/json");
9
11
  const provider = await useProvider(options.provider);
@@ -0,0 +1,2 @@
1
+ import type { H3Event } from 'h3';
2
+ export declare function useHostname(e: H3Event): string;
@@ -0,0 +1,15 @@
1
+ import { getRequestHost, getRequestProtocol } from "h3";
2
+ import { withBase } from "ufo";
3
+ import { useRuntimeConfig } from "#imports";
4
+ export function useHostname(e) {
5
+ const base = useRuntimeConfig().app.baseURL;
6
+ let host = getRequestHost(e);
7
+ if (host === "localhost")
8
+ host = process.env.NITRO_HOST || process.env.HOST || host;
9
+ const protocol = getRequestProtocol(e);
10
+ const useHttp = process.dev || host.includes("127.0.0.1") || host.includes("localhost") || protocol === "http";
11
+ let port = host.includes(":") ? host.split(":").pop() : false;
12
+ if ((process.dev || process.env.prerender || host.includes("localhost")) && !port)
13
+ port = process.env.NITRO_PORT || process.env.PORT;
14
+ return withBase(base, `http${useHttp ? "" : "s"}://${host.includes(":") ? host.split(":")[0] : host}${port ? `:${port}` : ""}`);
15
+ }
@@ -1,2 +1,3 @@
1
- export declare function extractOgImageOptions(html: string): false | Record<string, any>;
2
- export declare function stripOgImageOptions(html: string): string;
1
+ import type { OgImageOptions } from '../../types';
2
+ export declare function decodeHtml(html: string): string;
3
+ export declare function extractOgImageOptions(html: string): OgImageOptions | false;
@@ -1,8 +1,12 @@
1
- function decodeHtmlEntities(obj) {
1
+ export function decodeHtml(html) {
2
+ return html.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&cent;/g, "\xA2").replace(/&pound;/g, "\xA3").replace(/&yen;/g, "\xA5").replace(/&euro;/g, "\u20AC").replace(/&copy;/g, "\xA9").replace(/&reg;/g, "\xAE").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&#x27;/g, "'").replace(/&#x2F;/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.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&#x27;/g, "'").replace(/&#x2F;/g, "/");
5
- }
8
+ if (typeof value === "string")
9
+ obj[key] = decodeHtml(value);
6
10
  });
7
11
  return obj;
8
12
  }
@@ -26,10 +30,7 @@ export function extractOgImageOptions(html) {
26
30
  else
27
31
  options.description = html.match(/<meta name="description" content="(.*?)">/)?.[1];
28
32
  }
29
- return decodeHtmlEntities(options);
33
+ return decodeObjectHtmlEntities(options);
30
34
  }
31
35
  return false;
32
36
  }
33
- export function stripOgImageOptions(html) {
34
- return html.replace(/<script id="nuxt-og-image-options" type="application\/json">(.*?)<\/script>/, "");
35
- }
@@ -1,17 +1,15 @@
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 declare function wasmLoader(key: any, fallback: string, baseUrl: string): {
5
- loaded(): boolean | Promise<any>;
6
- load(): Promise<any>;
5
+ export * from './util-hostname';
6
+ export declare function wasmLoader(asyncModuleLoad: Promise<any> | Buffer | string, fallback: string): {
7
+ load(options: {
8
+ baseUrl: string;
9
+ }): Promise<any>;
7
10
  };
8
11
  export declare function fetchOptions(e: H3Event, path: string): Promise<OgImageOptions>;
9
12
  export declare function base64ToArrayBuffer(base64: string): ArrayBuffer;
10
- export declare function renderIsland(payload: OgImageOptions): Promise<{
11
- html: string;
12
- head: any;
13
- }>;
14
- export declare function useHostname(e: H3Event): any;
15
13
  export declare function readPublicAsset(file: string, encoding?: BufferEncoding): Promise<string | Buffer | undefined>;
16
14
  export declare function readPublicAssetBase64(file: string): Promise<string | undefined>;
17
15
  export * from './utils-pure';
@@ -1,77 +1,80 @@
1
1
  import { existsSync, promises as fsp } from "node:fs";
2
- import { getHeaders, getQuery, getRequestHeader } from "h3";
2
+ import { Buffer } from "node:buffer";
3
+ import { getQuery } from "h3";
3
4
  import { join } from "pathe";
4
- import { useRuntimeConfig } from "#internal/nitro";
5
- export function wasmLoader(key, fallback, baseUrl) {
5
+ import { prefixStorage } from "unstorage";
6
+ import { useRuntimeConfig, useStorage } from "#imports";
7
+ export * from "./util-hostname.mjs";
8
+ export function wasmLoader(asyncModuleLoad, fallback) {
6
9
  let promise;
7
- let loaded = false;
10
+ let wasm;
8
11
  return {
9
- loaded() {
10
- if (loaded)
11
- return true;
12
+ async load(options) {
12
13
  if (typeof promise !== "undefined")
13
14
  return promise;
14
- return false;
15
- },
16
- async load() {
15
+ if (wasm)
16
+ return wasm;
17
17
  promise = promise || new Promise(async (resolve) => {
18
- let wasm;
19
18
  try {
20
- wasm = await key;
19
+ wasm = await asyncModuleLoad;
21
20
  if (typeof wasm === "string")
22
21
  wasm = void 0;
23
22
  } catch (e) {
24
23
  }
25
- if (!wasm)
26
- wasm = await readPublicAsset(fallback);
27
24
  if (!wasm) {
28
- const url = new URL(baseUrl);
29
- wasm = await (await fetch(`${url.origin}${fallback}`)).arrayBuffer();
25
+ wasm = await readPublicAsset(fallback, "base64");
26
+ if (wasm)
27
+ wasm = Buffer.from(wasm, "base64");
28
+ }
29
+ if (!wasm) {
30
+ const url = new URL(options.baseUrl);
31
+ wasm = await (await globalThis.$fetch(fallback, { baseURL: url.origin })).arrayBuffer();
32
+ wasm = Buffer.from(wasm);
30
33
  }
31
- loaded = true;
32
34
  resolve(wasm);
33
35
  });
34
36
  return promise;
35
37
  }
36
38
  };
37
39
  }
38
- export function fetchOptions(e, path) {
39
- const fetchOptions2 = process.dev || process.env.prerender ? {
40
- headers: getHeaders(e)
41
- } : {
42
- baseURL: useHostname(e)
40
+ export async function fetchOptions(e, path) {
41
+ const { runtimeCacheStorage } = useRuntimeConfig()["nuxt-og-image"];
42
+ const cache = runtimeCacheStorage || process.env.prerender ? prefixStorage(useStorage(), "og-image-cache:options") : false;
43
+ let options;
44
+ if (cache && await cache.hasItem(path)) {
45
+ const cachedValue = await cache.getItem(path);
46
+ if (cachedValue && cachedValue.value && cachedValue.expiresAt < Date.now())
47
+ options = cachedValue.value;
48
+ else
49
+ await cache.removeItem(path);
50
+ }
51
+ if (!options) {
52
+ options = await globalThis.$fetch("/api/og-image-options", {
53
+ query: {
54
+ path
55
+ },
56
+ responseType: "json"
57
+ });
58
+ if (cache) {
59
+ await cache.setItem(path, {
60
+ value: options,
61
+ expiresAt: Date.now() + (options.static ? 60 * 60 * 1e3 : 5 * 1e3)
62
+ });
63
+ }
64
+ }
65
+ return {
66
+ ...options,
67
+ // use query data
68
+ ...getQuery(e)
43
69
  };
44
- return globalThis.$fetch("/api/og-image-options", {
45
- query: {
46
- ...getQuery(e),
47
- path
48
- },
49
- ...fetchOptions2
50
- });
51
70
  }
52
71
  export function base64ToArrayBuffer(base64) {
53
72
  const buffer = Buffer.from(base64, "base64");
54
73
  return new Uint8Array(buffer).buffer;
55
74
  }
56
- export function renderIsland(payload) {
57
- return globalThis.$fetch(`/__nuxt_island/${payload.component}`, {
58
- query: { props: JSON.stringify(payload) }
59
- });
60
- }
61
- export function useHostname(e) {
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) => {
75
+ function r(base, key) {
73
76
  return join(base, key.replace(/:/g, "/"));
74
- };
77
+ }
75
78
  export async function readPublicAsset(file, encoding) {
76
79
  const { assetDirs } = useRuntimeConfig()["nuxt-og-image"];
77
80
  for (const assetDir of assetDirs) {
package/dist/types.d.ts CHANGED
@@ -7,5 +7,11 @@ declare module '@nuxt/schema' {
7
7
  interface NuxtHooks extends ModuleHooks {}
8
8
  }
9
9
 
10
+ declare module 'nuxt/schema' {
11
+ interface NuxtConfig { ['ogImage']?: Partial<ModuleOptions> }
12
+ interface NuxtOptions { ['ogImage']?: ModuleOptions }
13
+ interface NuxtHooks extends ModuleHooks {}
14
+ }
15
+
10
16
 
11
17
  export { ModuleHooks, ModuleOptions, default } from './module'
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.4",
5
- "packageManager": "pnpm@7.8.0",
4
+ "version": "2.0.0-beta.40",
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,45 +26,55 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@nuxt/kit": "3.3.1",
29
+ "@nuxt/kit": "^3.4.3",
30
+ "@resvg/resvg-js": "^2.4.1",
31
+ "@resvg/resvg-wasm": "^2.4.1",
30
32
  "@types/fs-extra": "^11.0.1",
31
- "birpc": "^0.2.10",
33
+ "birpc": "^0.2.11",
32
34
  "chalk": "^5.2.0",
33
- "chrome-launcher": "^0.15.1",
35
+ "chrome-launcher": "^0.15.2",
34
36
  "defu": "^6.1.2",
35
37
  "execa": "^7.1.1",
36
38
  "fast-glob": "^3.2.12",
37
39
  "flatted": "^3.2.7",
38
40
  "fs-extra": "^11.1.1",
41
+ "globby": "^13.1.4",
39
42
  "launch-editor": "^2.6.0",
40
- "ohash": "^1.0.0",
43
+ "nuxt-icon": "^0.4.0",
44
+ "nypm": "^0.2.0",
45
+ "ofetch": "^1.0.1",
46
+ "ohash": "^1.1.2",
41
47
  "pathe": "^1.1.0",
42
- "playwright-core": "^1.31.2",
43
- "radix3": "^1.0.0",
44
- "satori": "0.4.4",
48
+ "playwright-core": "^1.33.0",
49
+ "radix3": "^1.0.1",
50
+ "satori": "0.7.4",
45
51
  "satori-html": "^0.3.2",
46
- "sirv": "^2.0.2",
47
- "std-env": "^3.3.2",
52
+ "sirv": "^2.0.3",
53
+ "std-env": "^3.3.3",
48
54
  "svg2png-wasm": "^1.3.4",
49
55
  "tinyws": "^0.1.0",
50
56
  "twemoji": "^14.0.2",
51
- "ufo": "^1.1.1",
57
+ "ufo": "^1.1.2",
52
58
  "ws": "^8.13.0",
53
59
  "yoga-wasm-web": "^0.3.3"
54
60
  },
55
61
  "devDependencies": {
56
- "@antfu/eslint-config": "^0.37.0",
57
- "@nuxt/devtools-edge": "0.2.5-27992993.59d3c52",
58
- "@nuxt/module-builder": "^0.2.1",
59
- "@nuxt/test-utils": "3.3.1",
62
+ "@antfu/eslint-config": "^0.38.6",
63
+ "@nuxt/devtools-edge": "0.4.5-28053684.ddd2e41",
64
+ "@nuxt/module-builder": "^0.3.1",
65
+ "@nuxt/test-utils": "3.4.3",
60
66
  "@nuxtjs/eslint-config-typescript": "^12.0.0",
61
67
  "@types/ws": "^8.5.4",
62
- "bumpp": "^9.0.0",
63
- "eslint": "8.36.0",
68
+ "bumpp": "^9.1.0",
69
+ "eslint": "8.40.0",
64
70
  "jest-image-snapshot": "^6.1.0",
65
- "nuxt": "^3.3.1",
66
- "puppeteer": "^19.7.5",
67
- "vitest": "^0.29.7"
71
+ "nuxt": "^3.4.3",
72
+ "vitest": "^0.31.0"
73
+ },
74
+ "resolutions": {
75
+ "nitropack": "npm:nitropack-edge@2.4.0-28027501.1cf01bf",
76
+ "unstorage": "^1.5.0",
77
+ "unenv": "^1.4.1"
68
78
  },
69
79
  "scripts": {
70
80
  "build": "pnpm dev:prepare && pnpm build:module && pnpm build:client",
@@ -75,6 +85,6 @@
75
85
  "dev:build": "nuxi build .playground",
76
86
  "dev:prepare": "nuxt-module-build --stub && nuxi prepare .playground",
77
87
  "release": "bumpp package.json --commit --push --tag",
78
- "test": "pnpm lint"
88
+ "test": "vitest"
79
89
  }
80
90
  }
@@ -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};
@@ -1 +0,0 @@
1
- import{a as m,r as c,m as u,w as r,f as d,s as _,o as f,h as g,i as y,j as v}from"./entry.74018bda.js";const h=m({__name:"ImageLoader",props:{src:String,aspectRatio:Number,description:String},setup(a){const s=a,n=c(),o=c(0);function i(e){const t=n.value,p=Date.now();t.src="",o.value=0,t.style.opacity="0",t.onload=()=>{t.style.opacity="1",o.value=Date.now()-p},t.src=e}u(()=>{r(()=>s.src,e=>{i(e)},{immediate:!0})});const l=d(()=>s.description.replace("%s",o.value.toString()));return r(l,e=>{_.value=e}),(e,t)=>(f(),g("img",{ref_key:"image",ref:n,class:"max-h-full border-1 border-light-500 rounded",style:y({aspectRatio:a.aspectRatio})},null,4))}}),x=v(h,[["__scopeId","data-v-23ec6856"]]);export{x as _};