nuxt-og-image 3.0.0-beta.43 → 3.0.0-beta.45

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/dist/client/200.html +5 -5
  2. package/dist/client/404.html +5 -5
  3. package/dist/client/_nuxt/IconCSS.4bbe2613.css +1 -0
  4. package/dist/client/_nuxt/IconCSS.aba927ca.js +1 -0
  5. package/dist/client/_nuxt/builds/latest.json +1 -1
  6. package/dist/client/_nuxt/builds/meta/1157c25b-5f22-479c-8eb1-b4bd8b88c154.json +1 -0
  7. package/dist/client/_nuxt/{entry.47aab0b4.css → entry.33a59bbf.css} +1 -1
  8. package/dist/client/_nuxt/{entry.e02bad90.js → entry.b64dd084.js} +58 -58
  9. package/dist/client/_nuxt/{error-404.3bd94f61.js → error-404.8ae425bf.js} +1 -1
  10. package/dist/client/_nuxt/{error-500.f289d6ba.js → error-500.a5bb9a8b.js} +1 -1
  11. package/dist/client/index.html +5 -5
  12. package/dist/module.d.mts +10 -19
  13. package/dist/module.d.ts +10 -19
  14. package/dist/module.json +1 -1
  15. package/dist/module.mjs +96 -37
  16. package/dist/runtime/components/Templates/Community/Pergel.vue +104 -0
  17. package/dist/runtime/composables/defineOgImage.mjs +2 -3
  18. package/dist/runtime/nuxt/plugins/route-rule-og-image.server.mjs +1 -2
  19. package/dist/runtime/nuxt/utils.d.ts +2 -1
  20. package/dist/runtime/nuxt/utils.mjs +22 -1
  21. package/dist/runtime/server/routes/__og-image__/image.mjs +8 -5
  22. package/dist/runtime/types.d.ts +16 -3
  23. package/package.json +3 -3
  24. package/dist/client/_nuxt/IconCSS.7e8f1f7b.css +0 -1
  25. package/dist/client/_nuxt/IconCSS.b3381402.js +0 -1
  26. package/dist/client/_nuxt/builds/meta/db835b47-d685-41ef-bf6b-0c7f22ed1aff.json +0 -1
  27. package/dist/runtime/core/options/normalise.d.ts +0 -2
  28. package/dist/runtime/core/options/normalise.mjs +0 -27
  29. /package/dist/runtime/core/bindings/resvg/{stackblitz.d.ts → wasm-fs.d.ts} +0 -0
  30. /package/dist/runtime/core/bindings/resvg/{stackblitz.mjs → wasm-fs.mjs} +0 -0
  31. /package/dist/runtime/core/bindings/satori/{stackblitz.d.ts → wasm-fs.d.ts} +0 -0
  32. /package/dist/runtime/core/bindings/satori/{stackblitz.mjs → wasm-fs.mjs} +0 -0
@@ -1 +1 @@
1
- import{_ as a,u as n,o as r,c as l,a as e,t as s,b as d,w as c,d as p,e as f,p as x,f as h}from"./entry.e02bad90.js";const m=t=>(x("data-v-05a2b8a3"),t=t(),h(),t),u={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},g=m(()=>e("div",{class:"fixed left-0 right-0 spotlight z-10"},null,-1)),b={class:"max-w-520px text-center z-20"},_=["textContent"],w=["textContent"],y={class:"w-full flex items-center justify-center"},S={__name:"error-404",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:404},statusMessage:{type:String,default:"Not Found"},description:{type:String,default:"Sorry, the page you are looking for could not be found."},backHome:{type:String,default:"Go back home"}},setup(t){const o=t;return n({title:`${o.statusCode} - ${o.statusMessage} | ${o.appName}`,script:[],style:[{children:'*,:before,:after{-webkit-box-sizing:border-box;box-sizing:border-box;border-width:0;border-style:solid;border-color:#e0e0e0}*{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(14, 165, 233, .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000}:root{-moz-tab-size:4;-o-tab-size:4;tab-size:4}a{color:inherit;text-decoration:inherit}body{margin:0;font-family:inherit;line-height:inherit}html{-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";line-height:1.5}h1,p{margin:0}h1{font-size:inherit;font-weight:inherit}'}]}),(k,v)=>{const i=f;return r(),l("div",u,[g,e("div",b,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:s(t.statusCode)},null,8,_),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:s(t.description)},null,8,w),e("div",y,[d(i,{to:"/",class:"gradient-border text-md sm:text-xl py-2 px-4 sm:py-3 sm:px-6 cursor-pointer"},{default:c(()=>[p(s(t.backHome),1)]),_:1})])])])}}},z=a(S,[["__scopeId","data-v-05a2b8a3"]]);export{z as default};
1
+ import{_ as a,u as n,o as r,c as l,a as e,t as s,b as d,w as c,d as p,e as f,p as x,f as h}from"./entry.b64dd084.js";const m=t=>(x("data-v-05a2b8a3"),t=t(),h(),t),u={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},g=m(()=>e("div",{class:"fixed left-0 right-0 spotlight z-10"},null,-1)),b={class:"max-w-520px text-center z-20"},_=["textContent"],w=["textContent"],y={class:"w-full flex items-center justify-center"},S={__name:"error-404",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:404},statusMessage:{type:String,default:"Not Found"},description:{type:String,default:"Sorry, the page you are looking for could not be found."},backHome:{type:String,default:"Go back home"}},setup(t){const o=t;return n({title:`${o.statusCode} - ${o.statusMessage} | ${o.appName}`,script:[],style:[{children:'*,:before,:after{-webkit-box-sizing:border-box;box-sizing:border-box;border-width:0;border-style:solid;border-color:#e0e0e0}*{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(14, 165, 233, .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000}:root{-moz-tab-size:4;-o-tab-size:4;tab-size:4}a{color:inherit;text-decoration:inherit}body{margin:0;font-family:inherit;line-height:inherit}html{-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";line-height:1.5}h1,p{margin:0}h1{font-size:inherit;font-weight:inherit}'}]}),(k,v)=>{const i=f;return r(),l("div",u,[g,e("div",b,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:s(t.statusCode)},null,8,_),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:s(t.description)},null,8,w),e("div",y,[d(i,{to:"/",class:"gradient-border text-md sm:text-xl py-2 px-4 sm:py-3 sm:px-6 cursor-pointer"},{default:c(()=>[p(s(t.backHome),1)]),_:1})])])])}}},z=a(S,[["__scopeId","data-v-05a2b8a3"]]);export{z as default};
@@ -1 +1 @@
1
- import{_ as i,u as a,o as r,c as n,a as e,t as s,p as l,f as d}from"./entry.e02bad90.js";const c=t=>(l("data-v-c967d9a9"),t=t(),d(),t),p={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},h=c(()=>e("div",{class:"fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"},null,-1)),f={class:"max-w-520px text-center"},g=["textContent"],m=["textContent"],x={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Server error"},description:{type:String,default:"This page is temporarily unavailable."}},setup(t){const o=t;return a({title:`${o.statusCode} - ${o.statusMessage} | ${o.appName}`,script:[],style:[{children:'*,:before,:after{-webkit-box-sizing:border-box;box-sizing:border-box;border-width:0;border-style:solid;border-color:#e0e0e0}*{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(14, 165, 233, .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000}:root{-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{margin:0;font-family:inherit;line-height:inherit}html{-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";line-height:1.5}h1,p{margin:0}h1{font-size:inherit;font-weight:inherit}'}]}),(u,b)=>(r(),n("div",p,[h,e("div",f,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:s(t.statusCode)},null,8,g),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:s(t.description)},null,8,m)])]))}},w=i(x,[["__scopeId","data-v-c967d9a9"]]);export{w as default};
1
+ import{_ as i,u as a,o as r,c as n,a as e,t as s,p as l,f as d}from"./entry.b64dd084.js";const c=t=>(l("data-v-c967d9a9"),t=t(),d(),t),p={class:"font-sans antialiased bg-white dark:bg-black text-black dark:text-white grid min-h-screen place-content-center overflow-hidden"},h=c(()=>e("div",{class:"fixed -bottom-1/2 left-0 right-0 h-1/2 spotlight"},null,-1)),f={class:"max-w-520px text-center"},g=["textContent"],m=["textContent"],x={__name:"error-500",props:{appName:{type:String,default:"Nuxt"},version:{type:String,default:""},statusCode:{type:Number,default:500},statusMessage:{type:String,default:"Server error"},description:{type:String,default:"This page is temporarily unavailable."}},setup(t){const o=t;return a({title:`${o.statusCode} - ${o.statusMessage} | ${o.appName}`,script:[],style:[{children:'*,:before,:after{-webkit-box-sizing:border-box;box-sizing:border-box;border-width:0;border-style:solid;border-color:#e0e0e0}*{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(14, 165, 233, .5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000}:root{-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{margin:0;font-family:inherit;line-height:inherit}html{-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";line-height:1.5}h1,p{margin:0}h1{font-size:inherit;font-weight:inherit}'}]}),(u,b)=>(r(),n("div",p,[h,e("div",f,[e("h1",{class:"text-8xl sm:text-10xl font-medium mb-8",textContent:s(t.statusCode)},null,8,g),e("p",{class:"text-xl px-8 sm:px-0 sm:text-4xl font-light mb-16 leading-tight",textContent:s(t.description)},null,8,m)])]))}},w=i(x,[["__scopeId","data-v-c967d9a9"]]);export{w as default};
@@ -2,13 +2,13 @@
2
2
  <html >
3
3
  <head><meta charset="utf-8">
4
4
  <meta name="viewport" content="width=device-width, initial-scale=1">
5
- <link rel="stylesheet" href="/__nuxt-og-image/_nuxt/entry.47aab0b4.css">
6
- <link rel="modulepreload" as="script" crossorigin href="/__nuxt-og-image/_nuxt/entry.e02bad90.js">
5
+ <link rel="stylesheet" href="/__nuxt-og-image/_nuxt/entry.33a59bbf.css">
6
+ <link rel="modulepreload" as="script" crossorigin href="/__nuxt-og-image/_nuxt/entry.b64dd084.js">
7
7
  <link rel="prefetch" as="style" href="/__nuxt-og-image/_nuxt/error-404.b751fa02.css">
8
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/error-404.3bd94f61.js">
8
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/error-404.8ae425bf.js">
9
9
  <link rel="prefetch" as="style" href="/__nuxt-og-image/_nuxt/error-500.69009e70.css">
10
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/error-500.f289d6ba.js">
11
- <script type="module" src="/__nuxt-og-image/_nuxt/entry.e02bad90.js" crossorigin></script><script>"use strict";(()=>{const a=window,e=document.documentElement,m=["dark","light"],c=window&&window.localStorage&&window.localStorage.getItem&&window.localStorage.getItem("nuxt-color-mode")||"system";let n=c==="system"?d():c;const l=e.getAttribute("data-color-mode-forced");l&&(n=l),i(n),a["__NUXT_COLOR_MODE__"]={preference:c,value:n,getColorScheme:d,addColorScheme:i,removeColorScheme:f};function i(o){const t=""+o+"",s="";e.classList?e.classList.add(t):e.className+=" "+t,s&&e.setAttribute("data-"+s,o)}function f(o){const t=""+o+"",s="";e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp(t,"g"),""),s&&e.removeAttribute("data-"+s)}function r(o){return a.matchMedia("(prefers-color-scheme"+o+")")}function d(){if(a.matchMedia&&r("").media!=="not all"){for(const o of m)if(r(":"+o).matches)return o}return"light"}})();
10
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/error-500.a5bb9a8b.js">
11
+ <script type="module" src="/__nuxt-og-image/_nuxt/entry.b64dd084.js" crossorigin></script><script>"use strict";(()=>{const a=window,e=document.documentElement,m=["dark","light"],c=window&&window.localStorage&&window.localStorage.getItem&&window.localStorage.getItem("nuxt-color-mode")||"system";let n=c==="system"?d():c;const l=e.getAttribute("data-color-mode-forced");l&&(n=l),i(n),a["__NUXT_COLOR_MODE__"]={preference:c,value:n,getColorScheme:d,addColorScheme:i,removeColorScheme:f};function i(o){const t=""+o+"",s="";e.classList?e.classList.add(t):e.className+=" "+t,s&&e.setAttribute("data-"+s,o)}function f(o){const t=""+o+"",s="";e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp(t,"g"),""),s&&e.removeAttribute("data-"+s)}function r(o){return a.matchMedia("(prefers-color-scheme"+o+")")}function d(){if(a.matchMedia&&r("").media!=="not all"){for(const o of m)if(r(":"+o).matches)return o}return"light"}})();
12
12
  </script></head>
13
13
  <body ><div id="__nuxt"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"_errors":1,"serverRendered":2,"data":3,"state":4},{},false,{},{}]</script>
14
14
  <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-og-image",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body>
package/dist/module.d.mts CHANGED
@@ -2,8 +2,8 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { SatoriOptions } from 'satori';
3
3
  import { ResvgRenderOptions } from '@resvg/resvg-js';
4
4
  import { SharpOptions } from 'sharp';
5
+ import { WasmOptions } from 'nitropack';
5
6
  import { OgImageComponents } from '#nuxt-og-image/components';
6
- import { WasmOptions } from 'nitropack/types';
7
7
 
8
8
  type IconifyEmojiIconSets = 'twemoji' | 'noto' | 'fluent-emoji' | 'fluent-emoji-flat' | 'fluent-emoji-high-contrast' | 'noto-v1' | 'emojione' | 'emojione-monotone' | 'emojione-v1' | 'streamline-emojis' | 'openmoji';
9
9
  interface OgImageComponent {
@@ -86,17 +86,21 @@ interface FontConfig {
86
86
  key?: string;
87
87
  }
88
88
  type InputFontConfig = (`${string}:${number}` | FontConfig);
89
-
90
89
  interface RuntimeCompatibilitySchema {
91
90
  bindings: {
92
91
  chromium: 'node' | false;
93
92
  ['css-inline']: 'node' | false;
94
- resvg: 'node' | 'wasm' | 'stackblitz' | false;
95
- satori: 'node' | 'wasm' | 'stackblitz' | false;
93
+ resvg: 'node' | 'wasm' | 'wasm-fs' | false;
94
+ satori: 'node' | 'wasm' | 'wasm-fs' | false;
96
95
  sharp: 'node' | false;
97
96
  };
98
97
  wasm?: WasmOptions;
99
98
  }
99
+ interface CompatibilityConfig {
100
+ dev?: Partial<RuntimeCompatibilitySchema>;
101
+ runtime?: Partial<RuntimeCompatibilitySchema>;
102
+ prerender?: Partial<RuntimeCompatibilitySchema>;
103
+ }
100
104
 
101
105
  interface ModuleOptions {
102
106
  /**
@@ -137,19 +141,6 @@ interface ModuleOptions {
137
141
  * @see https://sharp.pixelplumbing.com/api-constructor
138
142
  */
139
143
  sharpOptions?: Partial<SharpOptions>;
140
- /**
141
- * Include Satori runtime.
142
- *
143
- * @default true
144
- */
145
- runtimeSatori: boolean;
146
- /**
147
- * Include the Browser runtime.
148
- * This will need to be manually enabled for production environments.
149
- *
150
- * @default `process.dev`
151
- */
152
- runtimeChromium: boolean;
153
144
  /**
154
145
  * Enables debug logs and a debug endpoint.
155
146
  *
@@ -177,9 +168,9 @@ interface ModuleOptions {
177
168
  */
178
169
  componentDirs: string[];
179
170
  /**
180
- * Manually modify the deployment compatibility.
171
+ * Manually modify the compatibility.
181
172
  */
182
- runtimeCompatibility?: RuntimeCompatibilitySchema;
173
+ compatibility?: CompatibilityConfig;
183
174
  }
184
175
  interface ModuleHooks {
185
176
  'nuxt-og-image:components': (ctx: {
package/dist/module.d.ts CHANGED
@@ -2,8 +2,8 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { SatoriOptions } from 'satori';
3
3
  import { ResvgRenderOptions } from '@resvg/resvg-js';
4
4
  import { SharpOptions } from 'sharp';
5
+ import { WasmOptions } from 'nitropack';
5
6
  import { OgImageComponents } from '#nuxt-og-image/components';
6
- import { WasmOptions } from 'nitropack/types';
7
7
 
8
8
  type IconifyEmojiIconSets = 'twemoji' | 'noto' | 'fluent-emoji' | 'fluent-emoji-flat' | 'fluent-emoji-high-contrast' | 'noto-v1' | 'emojione' | 'emojione-monotone' | 'emojione-v1' | 'streamline-emojis' | 'openmoji';
9
9
  interface OgImageComponent {
@@ -86,17 +86,21 @@ interface FontConfig {
86
86
  key?: string;
87
87
  }
88
88
  type InputFontConfig = (`${string}:${number}` | FontConfig);
89
-
90
89
  interface RuntimeCompatibilitySchema {
91
90
  bindings: {
92
91
  chromium: 'node' | false;
93
92
  ['css-inline']: 'node' | false;
94
- resvg: 'node' | 'wasm' | 'stackblitz' | false;
95
- satori: 'node' | 'wasm' | 'stackblitz' | false;
93
+ resvg: 'node' | 'wasm' | 'wasm-fs' | false;
94
+ satori: 'node' | 'wasm' | 'wasm-fs' | false;
96
95
  sharp: 'node' | false;
97
96
  };
98
97
  wasm?: WasmOptions;
99
98
  }
99
+ interface CompatibilityConfig {
100
+ dev?: Partial<RuntimeCompatibilitySchema>;
101
+ runtime?: Partial<RuntimeCompatibilitySchema>;
102
+ prerender?: Partial<RuntimeCompatibilitySchema>;
103
+ }
100
104
 
101
105
  interface ModuleOptions {
102
106
  /**
@@ -137,19 +141,6 @@ interface ModuleOptions {
137
141
  * @see https://sharp.pixelplumbing.com/api-constructor
138
142
  */
139
143
  sharpOptions?: Partial<SharpOptions>;
140
- /**
141
- * Include Satori runtime.
142
- *
143
- * @default true
144
- */
145
- runtimeSatori: boolean;
146
- /**
147
- * Include the Browser runtime.
148
- * This will need to be manually enabled for production environments.
149
- *
150
- * @default `process.dev`
151
- */
152
- runtimeChromium: boolean;
153
144
  /**
154
145
  * Enables debug logs and a debug endpoint.
155
146
  *
@@ -177,9 +168,9 @@ interface ModuleOptions {
177
168
  */
178
169
  componentDirs: string[];
179
170
  /**
180
- * Manually modify the deployment compatibility.
171
+ * Manually modify the compatibility.
181
172
  */
182
- runtimeCompatibility?: RuntimeCompatibilitySchema;
173
+ compatibility?: CompatibilityConfig;
183
174
  }
184
175
  interface ModuleHooks {
185
176
  'nuxt-og-image:components': (ctx: {
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "ogImage",
8
- "version": "3.0.0-beta.43"
8
+ "version": "3.0.0-beta.45"
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,17 +1,20 @@
1
1
  import * as fs from 'node:fs';
2
2
  import { existsSync } from 'node:fs';
3
- import { loadNuxtModuleInstance, useNuxt, createResolver, addTemplate, resolvePath, defineNuxtModule, useLogger, hasNuxtModule, addServerPlugin, addServerHandler, addImports, addComponentsDir, addComponent, addPlugin } from '@nuxt/kit';
3
+ import { useNuxt, addTemplate, loadNuxtModuleInstance, createResolver, resolvePath, defineNuxtModule, useLogger, tryResolveModule, hasNuxtModule, addServerPlugin, addServerHandler, addImports, addComponentsDir, addComponent, addPlugin } from '@nuxt/kit';
4
4
  import { assertSiteConfig, installNuxtSiteConfig } from 'nuxt-site-config-kit';
5
5
  import { provider, env, isDevelopment } from 'std-env';
6
6
  import { hash } from 'ohash';
7
7
  import { relative, dirname } from 'pathe';
8
8
  import { defu } from 'defu';
9
- import 'nypm';
9
+ import { Launcher } from 'chrome-launcher';
10
+ import { addDependency } from 'nypm';
10
11
  import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
11
12
  import { readFile, writeFile } from 'node:fs/promises';
12
13
  import { createHash } from 'node:crypto';
14
+ import { execa } from 'execa';
15
+ import terminate from 'terminate';
13
16
 
14
- const version = "3.0.0-beta.43";
17
+ const version = "3.0.0-beta.45";
15
18
 
16
19
  const autodetectableProviders = {
17
20
  azure_static: "azure",
@@ -54,7 +57,8 @@ const awsLambda = {
54
57
  "css-inline": "node",
55
58
  "resvg": "node",
56
59
  "satori": "node",
57
- "sharp": "node"
60
+ "sharp": false
61
+ // 0.33.x has issues
58
62
  }
59
63
  };
60
64
  const RuntimeCompatibility = {
@@ -65,13 +69,13 @@ const RuntimeCompatibility = {
65
69
  bindings: {
66
70
  "chromium": false,
67
71
  "css-inline": false,
68
- "resvg": "stackblitz",
69
- "satori": "stackblitz",
72
+ "resvg": "wasm-fs",
73
+ "satori": "wasm-fs",
70
74
  "sharp": false
71
75
  }
72
76
  },
73
77
  "aws-lambda": awsLambda,
74
- "netlify": awsLambda,
78
+ "netlify": defu({ bindings: { sharp: false } }, awsLambda),
75
79
  "netlify-edge": {
76
80
  bindings: {
77
81
  "chromium": false,
@@ -125,11 +129,11 @@ function getPresetNitroPresetCompatibility(target) {
125
129
  return compatibility;
126
130
  }
127
131
  function applyNitroPresetCompatibility(nitroConfig, options) {
128
- let compatibility = options?.compatibility;
129
132
  const target = resolveNitroPreset(nitroConfig);
130
- if (!compatibility)
131
- compatibility = getPresetNitroPresetCompatibility(target);
132
- const resolve = options.resolve;
133
+ const compatibility = defu(options.compatibility, getPresetNitroPresetCompatibility(target));
134
+ const { resolve } = options;
135
+ nitroConfig.alias["#nuxt-og-image/renderers/satori"] = compatibility.bindings.satori ? resolve("./runtime/core/renderers/satori") : "unenv/runtime/mock/empty";
136
+ nitroConfig.alias["#nuxt-og-image/renderers/chromium"] = compatibility.bindings.chromium ? resolve("./runtime/core/renderers/chromium") : "unenv/runtime/mock/empty";
133
137
  function applyBinding(key) {
134
138
  const binding = compatibility.bindings[key];
135
139
  if (binding === false)
@@ -150,8 +154,21 @@ function applyNitroPresetCompatibility(nitroConfig, options) {
150
154
  }
151
155
  nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};
152
156
  nitroConfig.wasm = defu(compatibility.wasm, nitroConfig.wasm);
157
+ nitroConfig.virtual["#nuxt-og-image/compatibility"] = () => `export default ${JSON.stringify(compatibility)}`;
158
+ addTemplate({
159
+ filename: "nuxt-og-image/compatibility.mjs",
160
+ getContents() {
161
+ return `export default ${JSON.stringify(compatibility)}`;
162
+ },
163
+ options: { mode: "server" }
164
+ });
153
165
  return compatibility;
154
166
  }
167
+ function ensureDependencies(dep, nuxt = useNuxt()) {
168
+ return Promise.all(dep.map((d) => {
169
+ return addDependency(d, { cwd: nuxt.options.rootDir, dev: true });
170
+ }));
171
+ }
155
172
 
156
173
  async function getNuxtModuleOptions(module, nuxt = useNuxt()) {
157
174
  const moduleMeta = (typeof module === "string" ? { name: module } : await module.getMeta?.()) || {};
@@ -253,16 +270,12 @@ function setupDevToolsUI(options, resolve, nuxt = useNuxt()) {
253
270
 
254
271
  function setupDevHandler(options, resolve, nuxt = useNuxt()) {
255
272
  nuxt.hooks.hook("nitro:config", async (nitroConfig) => {
256
- nitroConfig.alias["#nuxt-og-image/renderers/satori"] = options.runtimeSatori ? resolve("./runtime/core/renderers/satori") : "unenv/runtime/mock/empty";
257
- nitroConfig.alias["#nuxt-og-image/renderers/chromium"] = options.runtimeChromium ? resolve("./runtime/core/renderers/chromium") : "unenv/runtime/mock/empty";
258
- applyNitroPresetCompatibility(nitroConfig, { resolve, compatibility: options.runtimeCompatibility });
273
+ applyNitroPresetCompatibility(nitroConfig, { compatibility: options.compatibility?.dev, resolve });
259
274
  });
260
275
  }
261
276
 
262
277
  function setupGenerateHandler(options, resolve, nuxt = useNuxt()) {
263
278
  nuxt.hooks.hook("nitro:config", async (nitroConfig) => {
264
- nitroConfig.alias["#nuxt-og-image/renderers/satori"] = "unenv/runtime/mock/empty";
265
- nitroConfig.alias["#nuxt-og-image/renderers/chromium"] = "unenv/runtime/mock/empty";
266
279
  applyNitroPresetCompatibility(nitroConfig, {
267
280
  compatibility: {
268
281
  bindings: {
@@ -286,9 +299,7 @@ function setupGenerateHandler(options, resolve, nuxt = useNuxt()) {
286
299
  function setupPrerenderHandler(options, resolve, nuxt = useNuxt()) {
287
300
  nuxt.hooks.hook("nitro:init", async (nitro) => {
288
301
  nitro.hooks.hook("prerender:config", async (nitroConfig) => {
289
- nitroConfig.alias["#nuxt-og-image/renderers/satori"] = resolve("./runtime/core/renderers/satori");
290
- nitroConfig.alias["#nuxt-og-image/renderers/chromium"] = resolve("./runtime/core/renderers/chromium");
291
- applyNitroPresetCompatibility(nitroConfig, { resolve });
302
+ applyNitroPresetCompatibility(nitroConfig, { compatibility: options.compatibility.prerender, resolve });
292
303
  nitroConfig.wasm = nitroConfig.wasm || {};
293
304
  nitroConfig.wasm.esmImport = false;
294
305
  const prerenderingPages = (nuxt.options.nitro.prerender?.routes || []).some((r) => r && (!r.includes(".") || r.includes("*")));
@@ -306,9 +317,7 @@ async function setupBuildHandler(config, resolve, nuxt = useNuxt()) {
306
317
  if (typeof config.runtimeCacheStorage === "object")
307
318
  nuxt.options.nitro.storage["og-image"] = config.runtimeCacheStorage;
308
319
  nuxt.hooks.hook("nitro:config", async (nitroConfig) => {
309
- nitroConfig.alias["#nuxt-og-image/renderers/satori"] = config.runtimeSatori ? resolve("./runtime/core/renderers/satori") : "unenv/runtime/mock/empty";
310
- nitroConfig.alias["#nuxt-og-image/renderers/chromium"] = config.runtimeChromium ? resolve("./runtime/core/renderers/chromium") : "unenv/runtime/mock/empty";
311
- applyNitroPresetCompatibility(nitroConfig, { resolve, compatibility: config.runtimeCompatibility });
320
+ applyNitroPresetCompatibility(nitroConfig, { compatibility: config.compatibility?.runtime, resolve });
312
321
  nitroConfig.alias.electron = "unenv/runtime/mock/proxy-cjs";
313
322
  nitroConfig.alias.bufferutil = "unenv/runtime/mock/proxy-cjs";
314
323
  nitroConfig.alias["utf-8-validate"] = "unenv/runtime/mock/proxy-cjs";
@@ -337,6 +346,22 @@ function sha1(source) {
337
346
  return createHash("sha1").update(source).digest("hex").slice(0, 16);
338
347
  }
339
348
 
349
+ async function ensureChromium(logger) {
350
+ logger.info("Ensuring Chromium install for og:image generation...");
351
+ const installChromeProcess = execa("npx", ["playwright", "install", "chromium"], {
352
+ stdio: "inherit"
353
+ });
354
+ installChromeProcess.stderr?.pipe(process.stderr);
355
+ await new Promise((resolve) => {
356
+ installChromeProcess.on("exit", (e) => {
357
+ if (e !== 0)
358
+ logger.error("Failed to install Playwright dependency for og:image generation. Trying anyway...");
359
+ resolve(true);
360
+ });
361
+ });
362
+ installChromeProcess.pid && terminate(installChromeProcess.pid);
363
+ }
364
+
340
365
  const module = defineNuxtModule({
341
366
  meta: {
342
367
  name: "nuxt-og-image",
@@ -346,7 +371,7 @@ const module = defineNuxtModule({
346
371
  },
347
372
  configKey: "ogImage"
348
373
  },
349
- defaults(nuxt) {
374
+ defaults() {
350
375
  return {
351
376
  enabled: true,
352
377
  defaults: {
@@ -361,8 +386,6 @@ const module = defineNuxtModule({
361
386
  componentDirs: ["OgImage", "OgImageTemplate"],
362
387
  fonts: [],
363
388
  runtimeCacheStorage: true,
364
- runtimeSatori: true,
365
- runtimeChromium: nuxt.options.dev,
366
389
  debug: isDevelopment
367
390
  };
368
391
  },
@@ -379,17 +402,55 @@ const module = defineNuxtModule({
379
402
  }
380
403
  const { resolve } = createResolver(import.meta.url);
381
404
  const preset = resolveNitroPreset(nuxt.options.nitro);
382
- const compatibility = getPresetNitroPresetCompatibility(preset);
405
+ const targetCompatibility = getPresetNitroPresetCompatibility(preset);
406
+ const hasSharpDependency = !!await tryResolveModule("sharp");
383
407
  const userConfiguredExtension = config.defaults.extension;
384
- config.defaults.extension = userConfiguredExtension || "png";
385
- if (!compatibility.bindings.sharp && config.defaults.renderer !== "chromium") {
386
- if (userConfiguredExtension && ["jpeg", "jpg"].includes(userConfiguredExtension))
387
- logger.warn("The sharp runtime is not available for this target, disabling sharp and using png instead.");
388
- config.defaults.extension = "png";
408
+ const hasConfiguredJpegs = userConfiguredExtension && ["jpeg", "jpg"].includes(userConfiguredExtension);
409
+ config.defaults.extension = userConfiguredExtension || (hasSharpDependency && targetCompatibility.bindings.sharp ? "jpg" : "png");
410
+ if (hasConfiguredJpegs && config.defaults.renderer !== "chromium") {
411
+ if (hasSharpDependency && !targetCompatibility.bindings.sharp) {
412
+ logger.warn(`Rendering JPEGs requires sharp which does not work with ${preset}. Images will be rendered as PNG at runtime.`);
413
+ config.compatibility = defu({
414
+ runtime: {
415
+ sharp: false
416
+ }
417
+ }, config.compatibility);
418
+ } else if (!hasSharpDependency) {
419
+ logger.warn("You have enabled `JPEG` images. These require the `sharp` dependency which is missing, installing it for you.");
420
+ await ensureDependencies(["sharp"]);
421
+ logger.warn("Support for `sharp` is limited so check the compatibility guide.");
422
+ }
423
+ } else if (!hasSharpDependency) {
424
+ config.compatibility = defu({
425
+ runtime: { sharp: false },
426
+ dev: { sharp: false },
427
+ prerender: { sharp: false }
428
+ }, config.compatibility);
389
429
  }
390
- if (config.runtimeChromium && !compatibility.bindings.chromium) {
391
- logger.warn("The Chromium runtime is not available for this target, disabling runtimeChromium.");
392
- config.runtimeChromium = false;
430
+ const hasChromeLocally = !!Launcher.getFirstInstallation();
431
+ const hasPlaywrightDependency = !!await tryResolveModule("playwright");
432
+ if (!hasChromeLocally && !hasPlaywrightDependency) {
433
+ if (nuxt.options._generate)
434
+ await ensureChromium(logger);
435
+ else if (nuxt.options.build)
436
+ logger.info("You are missing a chromium install. You will not be able to prerender images using the chromium render.");
437
+ config.compatibility = defu({
438
+ runtime: { chromium: false },
439
+ dev: { chromium: false },
440
+ prerender: { chromium: false }
441
+ }, config.compatibility);
442
+ } else if (hasChromeLocally) {
443
+ config.compatibility = defu({
444
+ runtime: { chromium: false },
445
+ dev: { chromium: true },
446
+ prerender: { chromium: true }
447
+ }, config.compatibility);
448
+ } else if (hasPlaywrightDependency && targetCompatibility.bindings.chromium) {
449
+ config.compatibility = defu({
450
+ runtime: { chromium: true },
451
+ dev: { chromium: true },
452
+ prerender: { chromium: true }
453
+ }, config.compatibility);
393
454
  }
394
455
  await installNuxtSiteConfig();
395
456
  if (hasNuxtModule("@nuxt/content"))
@@ -495,7 +556,7 @@ const module = defineNuxtModule({
495
556
  nuxt.hooks.hook("nuxt-og-image:components", ogImageComponentCtx);
496
557
  });
497
558
  addTemplate({
498
- filename: "og-image-component-names.mjs",
559
+ filename: "nuxt-og-image/components.mjs",
499
560
  getContents() {
500
561
  return `export const componentNames = ${JSON.stringify(ogImageComponentCtx.components)}`;
501
562
  },
@@ -574,8 +635,6 @@ ${componentImports}
574
635
  satoriOptions: config.satoriOptions || {},
575
636
  resvgOptions: config.resvgOptions || {},
576
637
  sharpOptions: config.sharpOptions || {},
577
- runtimeSatori: config.runtimeSatori,
578
- runtimeChromium: config.runtimeChromium,
579
638
  defaults: config.defaults,
580
639
  debug: config.debug,
581
640
  // avoid adding credentials
@@ -0,0 +1,104 @@
1
+ <script lang="ts" setup>
2
+ /**
3
+ * @credits Pergel <https://nuxtlabs.com/>
4
+ * @see https://github.com/nuxt/nuxt.com/blob/main/components/OgImage/OgImageDocs.vue
5
+ */
6
+ import { computed } from 'vue'
7
+
8
+ const props = withDefaults(defineProps<{ title?: string, description?: string, headline?: string }>(), {
9
+ title: 'title',
10
+ description: 'description',
11
+ headline: 'headline',
12
+ })
13
+
14
+ const title = computed(() => props.title.slice(0, 60))
15
+ </script>
16
+
17
+ <template>
18
+ <div class="w-full h-full flex flex-col justify-center bg-[#212121]">
19
+ <svg class="absolute top-0 right-0" width="1200" height="675" viewBox="0 0 1200 675" fill="none" xmlns="http://www.w3.org/2000/svg">
20
+ <g style="mix-blend-mode:overlay" opacity="0.7" filter="url(#filter0_f_448_25)">
21
+ <circle cx="901.5" cy="45.5" r="199.5" fill="#FFA7A7" />
22
+ <circle cx="600.5" cy="216.5" r="199.5" fill="#FFCC49" />
23
+ <circle cx="179.5" cy="317.5" r="199.5" fill="#FFA149" />
24
+ </g>
25
+ <defs>
26
+ <filter id="filter0_f_448_25" x="-240" y="-374" width="1561" height="1111" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
27
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
28
+ <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
29
+ <feGaussianBlur stdDeviation="110" result="effect1_foregroundBlur_448_25" />
30
+ </filter>
31
+ </defs>
32
+ </svg>
33
+
34
+ <div class="w-[600px] pl-[100px]">
35
+ <p v-if="headline" class="uppercase text-[24px] text-[#FEC476] mb-4 font-semibold">
36
+ Oku - Pergel
37
+ </p>
38
+ <h1 class="w-[600px] m-0 text-[75px] font-semibold mb-4 text-white flex items-center">
39
+ <span>{{ title }}</span>
40
+ </h1>
41
+ <p class="text-[32px] text-[#E4E4E7] leading-tight">
42
+ {{ description.slice(0, 200) }}
43
+ </p>
44
+ </div>
45
+
46
+ <svg class="absolute top-[250px] right-[190px]" width="241" height="184" viewBox="0 0 241 184" fill="none" xmlns="http://www.w3.org/2000/svg">
47
+ <g filter="url(#filter0_ddd_563_6)">
48
+ <path d="M204.852 126.822C204.852 127.098 204.677 128.114 202.583 129.748C200.551 131.335 197.276 133.034 192.613 134.687C183.325 137.979 169.872 140.62 153.875 142.19C137.92 143.755 120.334 144.166 103.363 143.367C86.3776 142.566 70.8801 140.594 58.8213 137.738C52.7901 136.31 47.8449 134.713 44.0617 133.037C40.1988 131.325 37.891 129.679 36.7621 128.335C36.2309 127.702 36.0703 127.267 36.0227 127.035C35.9829 126.842 35.9842 126.629 36.1192 126.305C36.459 125.488 37.6413 124.038 40.7165 122.28C46.7614 118.823 57.5073 115.641 71.9244 113.359C86.2251 111.096 103.109 109.879 120.426 109.879" stroke="url(#paint0_angular_563_6)" stroke-width="8" />
49
+ </g>
50
+ <g clip-path="url(#clip0_563_6)">
51
+ <g filter="url(#filter1_i_563_6)">
52
+ <path d="M211.514 112.29L209.41 124.066L200.573 115.781L182.897 61.0337C186.772 60.5223 190.442 59.2291 193.777 57.2455L211.514 112.29ZM196.523 35.7822C195.733 40.2018 193.22 44.1268 189.537 46.6936C185.853 49.2604 181.301 50.2588 176.881 49.4691L174.437 49.0324L131.693 103.474L120.534 108.187L122.638 96.4106L165.598 41.721C160.708 33.7969 163.149 23.3421 171.139 18.407C174.615 16.2766 178.781 15.416 182.836 16.1405L184.821 5.03095C186.294 5.29416 187.603 6.13183 188.458 7.35968C189.314 8.58752 189.647 10.105 189.383 11.5782L188.212 18.1328C194.461 21.6568 197.783 28.7276 196.523 35.7822ZM185.413 33.7973C185.677 32.3241 185.344 30.8066 184.488 29.5788C183.633 28.3509 182.324 27.5133 180.851 27.25C179.378 26.9868 177.861 27.3196 176.633 28.1752C175.405 29.0308 174.567 30.3391 174.304 31.8123C174.041 33.2856 174.374 34.803 175.229 36.0308C176.085 37.2587 177.393 38.0964 178.866 38.3596C180.339 38.6228 181.857 38.29 183.085 37.4344C184.313 36.5788 185.15 35.2705 185.413 33.7973Z" fill="url(#paint1_diamond_563_6)" />
53
+ </g>
54
+ </g>
55
+ <defs>
56
+ <filter id="filter0_ddd_563_6" x="-3.8147e-05" y="77.8786" width="240.852" height="105.886" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
57
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
58
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" />
59
+ <feOffset dy="3.62319" />
60
+ <feGaussianBlur stdDeviation="7.24638" />
61
+ <feComposite in2="hardAlpha" operator="out" />
62
+ <feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 0.667391 0 0 0 0 0.3625 0 0 0 0.75 0" />
63
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_563_6" />
64
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" />
65
+ <feOffset dy="4" />
66
+ <feGaussianBlur stdDeviation="16" />
67
+ <feComposite in2="hardAlpha" operator="out" />
68
+ <feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 0.854792 0 0 0 0 0.4875 0 0 0 0.25 0" />
69
+ <feBlend mode="normal" in2="effect1_dropShadow_563_6" result="effect2_dropShadow_563_6" />
70
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" />
71
+ <feOffset dy="4" />
72
+ <feGaussianBlur stdDeviation="2" />
73
+ <feComposite in2="hardAlpha" operator="out" />
74
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0" />
75
+ <feBlend mode="normal" in2="effect2_dropShadow_563_6" result="effect3_dropShadow_563_6" />
76
+ <feBlend mode="normal" in="SourceGraphic" in2="effect3_dropShadow_563_6" result="shape" />
77
+ </filter>
78
+ <filter id="filter1_i_563_6" x="120.534" y="5.03094" width="94.9804" height="123.035" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
79
+ <feFlood flood-opacity="0" result="BackgroundImageFix" />
80
+ <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
81
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" />
82
+ <feOffset dx="7" dy="5" />
83
+ <feGaussianBlur stdDeviation="2" />
84
+ <feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1" />
85
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0" />
86
+ <feBlend mode="normal" in2="shape" result="effect1_innerShadow_563_6" />
87
+ </filter>
88
+ <radialGradient id="paint0_angular_563_6" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(120.426 126.822) rotate(90) scale(20.943 88.4261)">
89
+ <stop offset="0.0677083" stop-color="#FFE092" />
90
+ <stop offset="0.333333" stop-color="#FFD792" />
91
+ <stop offset="0.666667" stop-color="#FFD192" />
92
+ <stop offset="1" stop-color="#FFAC5F" />
93
+ </radialGradient>
94
+ <radialGradient id="paint1_diamond_563_6" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(303.899 145.741) rotate(-155.036) scale(253.361 239.508)">
95
+ <stop offset="0.333674" stop-color="#FEC479" />
96
+ <stop offset="1" stop-color="white" stop-opacity="0" />
97
+ </radialGradient>
98
+ <clipPath id="clip0_563_6">
99
+ <rect width="135.426" height="135.426" fill="white" transform="translate(96.5743)" />
100
+ </clipPath>
101
+ </defs>
102
+ </svg>
103
+ </div>
104
+ </template>
@@ -3,8 +3,7 @@ import { appendHeader } from "h3";
3
3
  import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
4
4
  import { withoutBase } from "ufo";
5
5
  import { getOgImagePath, separateProps, useOgImageRuntimeConfig } from "../utils.mjs";
6
- import { normaliseOptions } from "../core/options/normalise.mjs";
7
- import { createOgImageMeta } from "../nuxt/utils.mjs";
6
+ import { createOgImageMeta, normaliseOptions } from "../nuxt/utils.mjs";
8
7
  import { useNuxtApp, useRequestEvent, useRouter, useRuntimeConfig } from "#imports";
9
8
  export function defineOgImage(_options = {}) {
10
9
  if (!import.meta.server)
@@ -29,7 +28,7 @@ export function defineOgImage(_options = {}) {
29
28
  ..._options
30
29
  });
31
30
  const { defaults } = useOgImageRuntimeConfig();
32
- const resolvedOptions = normaliseOptions(defu(separateProps(options), separateProps(routeRules), defaults));
31
+ const resolvedOptions = normaliseOptions(defu(separateProps(_options), separateProps(routeRules), defaults));
33
32
  if (_options.url) {
34
33
  createOgImageMeta(null, options, resolvedOptions, nuxtApp.ssrContext);
35
34
  } else {
@@ -1,9 +1,8 @@
1
1
  import { defu } from "defu";
2
2
  import { parseURL, withoutBase } from "ufo";
3
3
  import { createRouter as createRadixRouter, toRouteMatcher } from "radix3";
4
- import { normaliseOptions } from "../../core/options/normalise.mjs";
5
4
  import { getOgImagePath, isInternalRoute, useOgImageRuntimeConfig } from "../../utils.mjs";
6
- import { createOgImageMeta } from "../utils.mjs";
5
+ import { createOgImageMeta, normaliseOptions } from "../utils.mjs";
7
6
  import { defineNuxtPlugin, useRequestEvent } from "#imports";
8
7
  export default defineNuxtPlugin((nuxtApp) => {
9
8
  nuxtApp.hooks.hook("app:rendered", async (ctx) => {
@@ -1,2 +1,3 @@
1
- import type { OgImageOptions, OgImagePrebuilt } from '../types';
1
+ import type { DefineOgImageInput, OgImageOptions, OgImagePrebuilt } from '../types';
2
2
  export declare function createOgImageMeta(src: string | null, input: OgImageOptions | OgImagePrebuilt, resolvedOptions: OgImageOptions, ssrContext: Record<string, any>): void;
3
+ export declare function normaliseOptions(_options: DefineOgImageInput): OgImageOptions | OgImagePrebuilt;
@@ -1,6 +1,8 @@
1
1
  import { defu } from "defu";
2
2
  import { separateProps } from "../utils.mjs";
3
- import { useServerHead } from "#imports";
3
+ import { unref, useServerHead } from "#imports";
4
+ import { componentNames } from "#build/nuxt-og-image/components.mjs";
5
+ import compatibility from "#build/nuxt-og-image/compatibility.mjs";
4
6
  export function createOgImageMeta(src, input, resolvedOptions, ssrContext) {
5
7
  const _input = separateProps(defu(input, ssrContext._ogImagePayload));
6
8
  const url = src || input.url || resolvedOptions.url;
@@ -51,3 +53,22 @@ export function createOgImageMeta(src, input, resolvedOptions, ssrContext) {
51
53
  ssrContext._ogImagePayload = _input;
52
54
  ssrContext._ogImageInstances.push(instance);
53
55
  }
56
+ export function normaliseOptions(_options) {
57
+ const options = { ...unref(_options) };
58
+ if (!options)
59
+ return options;
60
+ if (options.component && componentNames) {
61
+ const originalName = options.component;
62
+ for (const component of componentNames) {
63
+ if (component.pascalName.endsWith(originalName) || component.kebabName.endsWith(originalName)) {
64
+ options.component = component.pascalName;
65
+ break;
66
+ }
67
+ }
68
+ }
69
+ if (["jpeg", "jpg"].includes(options.extension || "") && !compatibility.bindings.sharp)
70
+ options.extension = "png";
71
+ if (options.renderer === "chromium" && !compatibility.bindings.chromium)
72
+ options.renderer = "satori";
73
+ return options;
74
+ }