nuxt-og-image 2.0.0-beta.30 → 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.
Files changed (32) hide show
  1. package/README.md +8 -8
  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.e52725bc.js → ImageLoader.163d23b3.js} +1 -1
  7. package/dist/client/_nuxt/{entry.ec623b49.js → entry.23646169.js} +2 -2
  8. package/dist/client/_nuxt/{entry.0d82ebde.css → entry.3d2654cc.css} +1 -1
  9. package/dist/client/_nuxt/{error-404.1a38651e.js → error-404.c0f2dfff.js} +1 -1
  10. package/dist/client/_nuxt/{error-500.0fdf46db.js → error-500.6a9dcc3d.js} +1 -1
  11. package/dist/client/_nuxt/{error-component.c2f3b155.js → error-component.0db07bb1.js} +2 -2
  12. package/dist/client/_nuxt/{index.4ecbc4d7.js → index.531c9ed8.js} +1 -1
  13. package/dist/client/_nuxt/{options.b6c39737.js → options.fd71c26a.js} +1 -1
  14. package/dist/client/_nuxt/{png.620a2171.js → png.5b6830ea.js} +1 -1
  15. package/dist/client/_nuxt/{shiki.fc3f3455.js → shiki.1be71764.js} +1 -1
  16. package/dist/client/_nuxt/{svg.3ef91b53.js → svg.165cf4fc.js} +1 -1
  17. package/dist/client/_nuxt/{vnodes.83d00cfc.js → vnodes.11ff70a7.js} +1 -1
  18. package/dist/client/index.html +2 -2
  19. package/dist/client/options/index.html +2 -2
  20. package/dist/client/png/index.html +2 -2
  21. package/dist/client/svg/index.html +2 -2
  22. package/dist/client/vnodes/index.html +2 -2
  23. package/dist/module.json +1 -1
  24. package/dist/module.mjs +6 -1
  25. package/dist/runtime/nitro/renderers/satori/index.mjs +6 -3
  26. package/dist/runtime/nitro/renderers/satori/plugins/imageSrc.mjs +1 -3
  27. package/dist/runtime/nitro/routes/options.mjs +2 -3
  28. package/dist/runtime/nitro/utils.mjs +6 -3
  29. package/dist/types.d.ts +6 -0
  30. package/package.json +4 -4
  31. package/dist/client/_nuxt/IconCSS.565f8e72.css +0 -1
  32. package/dist/client/_nuxt/IconCSS.7e52d29b.js +0 -1
@@ -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/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,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-og-image",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.30",
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",
@@ -59,8 +59,8 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@antfu/eslint-config": "^0.38.5",
62
- "@nuxt/devtools-edge": "0.4.5-28047419.153f22c",
63
- "@nuxt/module-builder": "^0.3.0",
62
+ "@nuxt/devtools-edge": "0.4.5-28050619.e64dbcd",
63
+ "@nuxt/module-builder": "^0.3.1",
64
64
  "@nuxt/test-utils": "3.4.3",
65
65
  "@nuxtjs/eslint-config-typescript": "^12.0.0",
66
66
  "@types/ws": "^8.5.4",
@@ -1 +0,0 @@
1
- span[data-v-72c2aaaa]{background-color:currentColor;display:inline-block;-webkit-mask-image:var(--6f0cee94);mask-image:var(--6f0cee94);-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;vertical-align:middle}
@@ -1 +0,0 @@
1
- import{a as p,b as u,e as _,f as t,o as l,h as f,i as m,u as a,j as d}from"./entry.ec623b49.js";const x=p({__name:"IconCSS",props:{name:{type:String,required:!0},size:{type:String,default:""}},setup(c){const s=c;u(e=>({"6f0cee94":a(r)}));const n=_();n?.nuxtIcon?.aliases;const i=t(()=>(n?.nuxtIcon?.aliases||{})[s.name]||s.name),r=t(()=>`url('https://api.iconify.design/${i.value.replace(":","/")}.svg')`),o=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,S)=>(l(),f("span",{style:m({width:a(o),height:a(o)})},null,4))}});const z=d(x,[["__scopeId","data-v-72c2aaaa"]]);export{z as default};