nuxt-og-image 2.0.0-beta.31 → 2.0.0-beta.32

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 CHANGED
@@ -50,18 +50,18 @@ Enlightened OG Image generation for Nuxt 3.
50
50
 
51
51
  Both Satori and Browser will work in Node based environments. Prerendering is fully supported.
52
52
 
53
- When you want to generate dynamic images at runtime there are certain nitro runtime limitations.
53
+ When you want to generate dynamic images at runtime there are certain Nitro runtime limitations.
54
54
 
55
55
  | Provider | Satori | Browser |
56
- |------------------------------------|-----------------| -- |
57
- | StackBlitz | ✅ | ❌ |
58
- | Node | ✅ | ✅ |
59
- | Vercel | ✅ | ✅ |
60
- | Vercel Edge | ✅ | ❌ |
56
+ |------------------------------------|----------------| -- |
57
+ | StackBlitz | ✅ | ❌ |
58
+ | Node | ✅ | ✅ |
59
+ | Vercel | ✅ | ✅ |
60
+ | Vercel Edge | ✅ | ❌ |
61
61
  | Cloudflare Workers (requires paid) | ✅ | ❌ |
62
62
  | Cloudflare Pages (requires paid) | ✅ | ❌ |
63
- | Netlify (TBC) | | ❌ |
64
- | Netlify Edge (TBC) | ❌ | ❌ |
63
+ | Netlify | | ❌ |
64
+ | Netlify Edge (TBC) | ❌ | ❌ |
65
65
 
66
66
  Other providers are yet to be tested. Please create an issue if you have tested one.
67
67
 
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "ogImage",
8
- "version": "2.0.0-beta.31"
8
+ "version": "2.0.0-beta.32"
9
9
  }
@@ -10,7 +10,6 @@ import encoding from "./plugins/encoding.mjs";
10
10
  import loadPngCreator from "#nuxt-og-image/png";
11
11
  import loadSatori from "#nuxt-og-image/satori";
12
12
  import { useRuntimeConfig } from "#imports";
13
- import { useNitroApp } from "#internal/nitro";
14
13
  const satoriFonts = [];
15
14
  let fontLoadPromise = null;
16
15
  function loadFonts(fonts) {
@@ -27,8 +26,12 @@ export default {
27
26
  },
28
27
  createVNode: async function createVNode(baseUrl, options) {
29
28
  const url = parseURL(baseUrl);
30
- const nitroApp = useNitroApp();
31
- const html = await (await nitroApp.localFetch(`/api/og-image-html?path=${url.pathname}&options=${encodeURI(JSON.stringify(options))}`)).text();
29
+ const html = await globalThis.$fetch("/api/og-image-html", {
30
+ params: {
31
+ path: url.pathname,
32
+ options: JSON.stringify(options)
33
+ }
34
+ });
32
35
  let body = html.match(/<body[^>]*>([\s\S]*)<\/body>/)?.[1] || "";
33
36
  try {
34
37
  body = twemoji.parse(body, {
@@ -1,7 +1,6 @@
1
1
  import { withBase } from "ufo";
2
2
  import { defineSatoriTransformer } from "../utils.mjs";
3
3
  import { readPublicAssetBase64 } from "../../../utils.mjs";
4
- import { useNitroApp } from "#internal/nitro";
5
4
  export default defineSatoriTransformer((url) => {
6
5
  return {
7
6
  filter: (node) => node.type === "img",
@@ -23,9 +22,8 @@ export default defineSatoriTransformer((url) => {
23
22
  }
24
23
  }
25
24
  if (!updated) {
26
- const nitroApp = useNitroApp();
27
25
  try {
28
- const response = await nitroApp.localFetch(src);
26
+ const response = await globalThis.$fetch.raw(src);
29
27
  if (response.status === 200) {
30
28
  node.props.src = response.arrayBuffer();
31
29
  updated = true;
@@ -1,15 +1,14 @@
1
1
  import { createError, defineEventHandler, getQuery } from "h3";
2
2
  import { withoutBase } from "ufo";
3
3
  import { extractOgImageOptions } from "../utils.mjs";
4
- import { getRouteRules, useNitroApp } from "#internal/nitro";
4
+ import { getRouteRules } from "#internal/nitro";
5
5
  import { useRuntimeConfig } from "#imports";
6
6
  export default defineEventHandler(async (e) => {
7
7
  const query = getQuery(e);
8
8
  const path = withoutBase(query.path || "/", useRuntimeConfig().app.baseURL);
9
- const nitro = useNitroApp();
10
9
  let html;
11
10
  try {
12
- html = await (await nitro.localFetch(path)).text();
11
+ html = await globalThis.$fetch(path);
13
12
  } catch (err) {
14
13
  throw createError({
15
14
  statusCode: 500,
@@ -4,7 +4,6 @@ import { getQuery } from "h3";
4
4
  import { join } from "pathe";
5
5
  import { prefixStorage } from "unstorage";
6
6
  import { useRuntimeConfig, useStorage } from "#imports";
7
- import { useNitroApp } from "#internal/nitro";
8
7
  export * from "./util-hostname.mjs";
9
8
  export function wasmLoader(asyncModuleLoad, fallback) {
10
9
  let promise;
@@ -50,8 +49,12 @@ export async function fetchOptions(e, path) {
50
49
  await cache.removeItem(path);
51
50
  }
52
51
  if (!options) {
53
- const nitro = useNitroApp();
54
- options = await (await nitro.localFetch(`/api/og-image-options?path=${path}`)).json();
52
+ options = await globalThis.$fetch("/api/og-image-options", {
53
+ query: {
54
+ path
55
+ },
56
+ responseType: "json"
57
+ });
55
58
  if (cache) {
56
59
  await cache.setItem(path, {
57
60
  value: options,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-og-image",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.31",
4
+ "version": "2.0.0-beta.32",
5
5
  "packageManager": "pnpm@8.1.0",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -26,7 +26,7 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@nuxt/kit": "3.4.3",
29
+ "@nuxt/kit": "^3.4.3",
30
30
  "@resvg/resvg-wasm": "^2.4.1",
31
31
  "@types/fs-extra": "^11.0.1",
32
32
  "birpc": "^0.2.11",