nuxt-og-image 3.0.0-rc.29 → 3.0.0-rc.30

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 (30) hide show
  1. package/dist/client/200.html +4 -4
  2. package/dist/client/404.html +4 -4
  3. package/dist/client/_nuxt/{IconCSS.e2wv7YPo.js → IconCSS.CZ8ZjA39.js} +1 -1
  4. package/dist/client/_nuxt/builds/latest.json +1 -1
  5. package/dist/client/_nuxt/builds/meta/bb98bdc4-cb43-44eb-b961-cca8b9050d48.json +1 -0
  6. package/dist/client/_nuxt/{entry.-WCPN92k.js → entry.v1zp98GR.js} +51 -51
  7. package/dist/client/_nuxt/{error-404.1yg-jdsN.js → error-404.VV5ycc25.js} +1 -1
  8. package/dist/client/_nuxt/{error-500.2kgN7VKB.js → error-500.VNY3c4OJ.js} +1 -1
  9. package/dist/client/index.html +4 -4
  10. package/dist/module.d.mts +1 -1
  11. package/dist/module.d.ts +1 -1
  12. package/dist/module.json +1 -1
  13. package/dist/module.mjs +46 -47
  14. package/dist/runtime/core/bindings/chromium/chrome-launcher.mjs +9 -0
  15. package/dist/runtime/core/bindings/chromium/on-demand.d.ts +2 -0
  16. package/dist/runtime/core/bindings/chromium/on-demand.mjs +36 -0
  17. package/dist/runtime/core/bindings/chromium/playwright.d.ts +2 -0
  18. package/dist/runtime/core/bindings/chromium/playwright.mjs +6 -0
  19. package/dist/runtime/nuxt/utils.d.ts +2 -1
  20. package/dist/runtime/types.d.ts +2 -2
  21. package/package.json +14 -14
  22. package/dist/client/_nuxt/builds/meta/33bf69ba-5452-4e77-ad39-508d00267652.json +0 -1
  23. package/dist/runtime/core/bindings/chromium/node.mjs +0 -33
  24. /package/dist/runtime/core/bindings/chromium/{node.d.ts → chrome-launcher.d.ts} +0 -0
  25. /package/dist/runtime/{server → nitro}/routes/__og-image__/debug.json.d.ts +0 -0
  26. /package/dist/runtime/{server → nitro}/routes/__og-image__/debug.json.mjs +0 -0
  27. /package/dist/runtime/{server → nitro}/routes/__og-image__/font-[name]-[weight].[extension].d.ts +0 -0
  28. /package/dist/runtime/{server → nitro}/routes/__og-image__/font-[name]-[weight].[extension].mjs +0 -0
  29. /package/dist/runtime/{server → nitro}/routes/__og-image__/image.d.ts +0 -0
  30. /package/dist/runtime/{server → nitro}/routes/__og-image__/image.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 h,f as m}from"./entry.-WCPN92k.js";const x=t=>(h("data-v-05a2b8a3"),t=t(),m(),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=x(()=>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,N)=>{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 h,f as m}from"./entry.v1zp98GR.js";const x=t=>(h("data-v-05a2b8a3"),t=t(),m(),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=x(()=>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,N)=>{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.-WCPN92k.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}'}]}),(b,u)=>(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)])]))}},_=i(x,[["__scopeId","data-v-c967d9a9"]]);export{_ 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.v1zp98GR.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}'}]}),(b,u)=>(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)])]))}},_=i(x,[["__scopeId","data-v-c967d9a9"]]);export{_ as default};
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html><html><head><meta charset="utf-8">
2
2
  <meta name="viewport" content="width=device-width, initial-scale=1">
3
3
  <link rel="stylesheet" href="/__nuxt-og-image/_nuxt/entry.OczI2MjB.css">
4
- <link rel="modulepreload" as="script" crossorigin href="/__nuxt-og-image/_nuxt/entry.-WCPN92k.js">
4
+ <link rel="modulepreload" as="script" crossorigin href="/__nuxt-og-image/_nuxt/entry.v1zp98GR.js">
5
5
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/onig.mBJmD8D5.js">
6
6
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/abap.bJqzlTLD.js">
7
7
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/actionscript-3.NUzLYz6e.js">
@@ -219,9 +219,9 @@
219
219
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/vitesse-light.HOMMxGxw.js">
220
220
  <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/vanilla-picker.P0dws0ou.js">
221
221
  <link rel="prefetch" as="style" href="/__nuxt-og-image/_nuxt/error-404.DkXpI38i.css">
222
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/error-404.1yg-jdsN.js">
222
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/error-404.VV5ycc25.js">
223
223
  <link rel="prefetch" as="style" href="/__nuxt-og-image/_nuxt/error-500.SLhS9LVu.css">
224
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/error-500.2kgN7VKB.js">
225
- <script type="module" src="/__nuxt-og-image/_nuxt/entry.-WCPN92k.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"}})();
224
+ <link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/error-500.VNY3c4OJ.js">
225
+ <script type="module" src="/__nuxt-og-image/_nuxt/entry.v1zp98GR.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"}})();
226
226
  </script></head><body><div id="__nuxt"></div><script type="application/json" id="__NUXT_DATA__" data-ssr="false">[{"_errors":1,"serverRendered":2,"data":3,"state":4,"once":5},{},false,{},{},["Set"]]</script>
227
227
  <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-og-image",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
package/dist/module.d.mts CHANGED
@@ -94,7 +94,7 @@ interface FontConfig {
94
94
  }
95
95
  type InputFontConfig = (`${string}:${number}` | string | FontConfig);
96
96
  interface RuntimeCompatibilitySchema {
97
- chromium: 'node' | false;
97
+ chromium: 'chrome-launcher' | 'on-demand' | 'playwright' | false;
98
98
  ['css-inline']: 'node' | 'wasm' | 'wasm-fs' | false;
99
99
  resvg: 'node' | 'wasm' | 'wasm-fs' | false;
100
100
  satori: 'node' | 'wasm' | 'wasm-fs' | false;
package/dist/module.d.ts CHANGED
@@ -94,7 +94,7 @@ interface FontConfig {
94
94
  }
95
95
  type InputFontConfig = (`${string}:${number}` | string | FontConfig);
96
96
  interface RuntimeCompatibilitySchema {
97
- chromium: 'node' | false;
97
+ chromium: 'chrome-launcher' | 'on-demand' | 'playwright' | false;
98
98
  ['css-inline']: 'node' | 'wasm' | 'wasm-fs' | false;
99
99
  resvg: 'node' | 'wasm' | 'wasm-fs' | false;
100
100
  satori: 'node' | 'wasm' | 'wasm-fs' | false;
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "ogImage",
8
- "version": "3.0.0-rc.28"
8
+ "version": "3.0.0-rc.29"
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,19 +1,17 @@
1
1
  import * as fs from 'node:fs';
2
2
  import { existsSync } from 'node:fs';
3
- import { useNuxt, addTemplate, loadNuxtModuleInstance, createResolver, resolvePath, defineNuxtModule, useLogger, tryResolveModule, hasNuxtModule, addServerPlugin, addServerHandler, addImports, addComponentsDir, addComponent, addPlugin } from '@nuxt/kit';
3
+ import { useNuxt, addTemplate, loadNuxtModuleInstance, createResolver, resolvePath, tryResolveModule, defineNuxtModule, useLogger, hasNuxtModule, addServerPlugin, addServerHandler, addImports, addComponentsDir, addComponent, addPlugin } from '@nuxt/kit';
4
4
  import { assertSiteConfig, installNuxtSiteConfig } from 'nuxt-site-config-kit';
5
- import { provider, env, isDevelopment, isCI } from 'std-env';
5
+ import { provider, env, isCI, 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 { Launcher } from 'chrome-launcher';
10
9
  import { readPackageJSON } from 'pkg-types';
11
10
  import { ensureDependencyInstalled } from 'nypm';
12
11
  import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
13
12
  import { readFile, writeFile } from 'node:fs/promises';
14
13
  import { createHash } from 'node:crypto';
15
- import { execa } from 'execa';
16
- import terminate from 'terminate';
14
+ import { Launcher } from 'chrome-launcher';
17
15
 
18
16
  const autodetectableProviders = {
19
17
  azure_static: "azure",
@@ -132,6 +130,8 @@ function applyNitroPresetCompatibility(nitroConfig, options) {
132
130
  let binding = options.compatibility?.[key];
133
131
  if (typeof binding === "undefined")
134
132
  binding = compatibility[key];
133
+ if (key === "chromium" && binding === "node")
134
+ binding = "playwright";
135
135
  resolvedCompatibility[key] = binding;
136
136
  return {
137
137
  [`#nuxt-og-image/bindings/${key}`]: binding === false ? "unenv/runtime/mock/empty" : resolve(`./runtime/core/bindings/${key}/${binding}`)
@@ -351,20 +351,19 @@ function sha1(source) {
351
351
  return createHash("sha1").update(source).digest("hex").slice(0, 16);
352
352
  }
353
353
 
354
- async function ensureChromium(logger) {
355
- logger.info("Ensuring Chromium install for og:image generation...");
356
- const installChromeProcess = execa("npx", ["playwright", "install", "chromium"], {
357
- stdio: "inherit"
358
- });
359
- installChromeProcess.stderr?.pipe(process.stderr);
360
- await new Promise((resolve) => {
361
- installChromeProcess.on("exit", (e) => {
362
- if (e !== 0)
363
- logger.error("Failed to install Playwright dependency for og:image generation. Trying anyway...");
364
- resolve(true);
365
- });
366
- });
367
- installChromeProcess.pid && terminate(installChromeProcess.pid);
354
+ const isUndefinedOrTruthy = (v) => typeof v === "undefined" || v !== false;
355
+ function checkLocalChrome() {
356
+ if (isCI)
357
+ return false;
358
+ let hasChromeLocally = false;
359
+ try {
360
+ hasChromeLocally = !!Launcher.getFirstInstallation();
361
+ } catch {
362
+ }
363
+ return hasChromeLocally;
364
+ }
365
+ async function checkPlaywrightDependency() {
366
+ return !!await tryResolveModule("playwright");
368
367
  }
369
368
 
370
369
  function normaliseFontInput(fonts) {
@@ -453,32 +452,32 @@ const module = defineNuxtModule({
453
452
  prerender: { sharp: false }
454
453
  });
455
454
  }
456
- let hasChromeLocally = false;
457
- try {
458
- hasChromeLocally = !!Launcher.getFirstInstallation();
459
- } catch {
460
- }
461
- const isUndefinedOrTruthy = (v) => typeof v === "undefined" || v !== false;
462
- if (isUndefinedOrTruthy(config.compatibility?.prerender?.chromium) && isUndefinedOrTruthy(config.compatibility?.runtime?.chromium)) {
463
- if (isCI)
464
- await ensureChromium(logger);
465
- const hasPlaywrightDependency = !!await tryResolveModule("playwright");
466
- if (hasChromeLocally) {
467
- config.compatibility = defu(config.compatibility, {
468
- runtime: { chromium: false },
469
- dev: { chromium: "node" },
470
- prerender: { chromium: "node" }
471
- });
472
- } else if (hasPlaywrightDependency && targetCompatibility.chromium) {
473
- config.compatibility = defu(config.compatibility, {
474
- runtime: { chromium: "node" },
475
- dev: { chromium: "node" },
476
- prerender: { chromium: "node" }
477
- });
478
- }
479
- } else if (!hasChromeLocally && nuxt.options.dev && config.compatibility?.dev?.chromium === "node") {
480
- await ensureChromium(logger);
455
+ const hasChromeLocally = checkLocalChrome();
456
+ const hasPlaywrightDependency = await checkPlaywrightDependency();
457
+ const chromeCompatibilityFlags = {
458
+ prerender: config.compatibility?.prerender?.chromium,
459
+ dev: config.compatibility?.dev?.chromium,
460
+ runtime: config.compatibility?.runtime?.chromium
461
+ };
462
+ const chromiumBinding = {
463
+ dev: null,
464
+ prerender: null,
465
+ runtime: null
466
+ };
467
+ if (nuxt.options.dev) {
468
+ if (isUndefinedOrTruthy(chromeCompatibilityFlags.dev))
469
+ chromiumBinding.dev = hasChromeLocally ? "chrome-launcher" : hasPlaywrightDependency ? "playwright" : "on-demand";
470
+ } else {
471
+ if (isUndefinedOrTruthy(chromeCompatibilityFlags.prerender))
472
+ chromiumBinding.prerender = hasChromeLocally ? "chrome-launcher" : hasPlaywrightDependency ? "playwright" : "on-demand";
473
+ if (isUndefinedOrTruthy(chromeCompatibilityFlags.runtime))
474
+ chromiumBinding.runtime = hasPlaywrightDependency ? "playwright" : null;
481
475
  }
476
+ config.compatibility = defu(config.compatibility, {
477
+ runtime: { chromium: chromiumBinding.runtime },
478
+ dev: { chromium: chromiumBinding.dev },
479
+ prerender: { chromium: chromiumBinding.prerender }
480
+ });
482
481
  await import('@resvg/resvg-js').catch(() => {
483
482
  logger.warn("ReSVG is missing dependencies for environment. Falling back to WASM version, this may slow down PNG rendering.");
484
483
  config.compatibility = defu(config.compatibility, {
@@ -531,19 +530,19 @@ const module = defineNuxtModule({
531
530
  addServerHandler({
532
531
  lazy: true,
533
532
  route: "/__og-image__/font/**",
534
- handler: resolve("./runtime/server/routes/__og-image__/font-[name]-[weight].[extension]")
533
+ handler: resolve("./runtime/nitro/routes/__og-image__/font-[name]-[weight].[extension]")
535
534
  });
536
535
  if (config.debug || nuxt.options.dev) {
537
536
  addServerHandler({
538
537
  lazy: true,
539
538
  route: "/__og-image__/debug.json",
540
- handler: resolve("./runtime/server/routes/__og-image__/debug.json")
539
+ handler: resolve("./runtime/nitro/routes/__og-image__/debug.json")
541
540
  });
542
541
  }
543
542
  addServerHandler({
544
543
  lazy: true,
545
544
  route: "/__og-image__/image/**",
546
- handler: resolve("./runtime/server/routes/__og-image__/image")
545
+ handler: resolve("./runtime/nitro/routes/__og-image__/image")
547
546
  });
548
547
  nuxt.options.optimization.treeShake.composables.client["nuxt-og-image"] = [];
549
548
  ["defineOgImage", "defineOgImageComponent", "defineOgImageScreenshot"].forEach((name2) => {
@@ -0,0 +1,9 @@
1
+ import playwrightCore from "playwright-core";
2
+ import { Launcher } from "chrome-launcher";
3
+ const chromePath = Launcher.getFirstInstallation();
4
+ export async function createBrowser() {
5
+ return playwrightCore.chromium.launch({
6
+ headless: true,
7
+ executablePath: chromePath
8
+ });
9
+ }
@@ -0,0 +1,2 @@
1
+ import type { Browser } from 'playwright-core';
2
+ export declare function createBrowser(): Promise<Browser | void>;
@@ -0,0 +1,36 @@
1
+ import { execa } from "execa";
2
+ import terminate from "terminate";
3
+ import { createConsola } from "consola";
4
+ import playwrightCore from "playwright-core";
5
+ let installedChromium = false;
6
+ let installChromiumPromise;
7
+ export async function createBrowser() {
8
+ if (installChromiumPromise)
9
+ await installChromiumPromise;
10
+ if (!installedChromium) {
11
+ installChromiumPromise = new Promise((_resolve) => {
12
+ const logger = createConsola().withTag("Nuxt OG Image");
13
+ logger.info("Installing Chromium install for og:image generation...");
14
+ const installChromeProcess = execa("npx", ["playwright", "install", "chromium"], {
15
+ stdio: "inherit"
16
+ });
17
+ installChromeProcess.stderr?.pipe(process.stderr);
18
+ new Promise((resolve) => {
19
+ installChromeProcess.on("exit", (e) => {
20
+ if (e !== 0)
21
+ logger.error("Failed to install Playwright dependency for og:image generation. Trying anyway...");
22
+ resolve(true);
23
+ });
24
+ }).then(() => {
25
+ installChromeProcess.pid && terminate(installChromeProcess.pid);
26
+ logger.info("Installed Chromium install for og:image generation.");
27
+ _resolve();
28
+ });
29
+ }).then(() => {
30
+ installedChromium = true;
31
+ });
32
+ }
33
+ return await playwrightCore.chromium.launch({
34
+ headless: true
35
+ });
36
+ }
@@ -0,0 +1,2 @@
1
+ import type { Browser } from 'playwright-core';
2
+ export declare function createBrowser(): Promise<Browser | void>;
@@ -0,0 +1,6 @@
1
+ import playwright from "playwright";
2
+ export async function createBrowser() {
3
+ return await playwright.chromium.launch({
4
+ headless: true
5
+ });
6
+ }
@@ -1,3 +1,4 @@
1
1
  import type { DefineOgImageInput, OgImageOptions, OgImagePrebuilt } from '../types';
2
- export declare function createOgImageMeta(src: string | null, input: OgImageOptions | OgImagePrebuilt, resolvedOptions: OgImageOptions, ssrContext: Record<string, any>): void;
2
+ import type { NuxtSSRContext } from '#app';
3
+ export declare function createOgImageMeta(src: string | null, input: OgImageOptions | OgImagePrebuilt, resolvedOptions: OgImageOptions, ssrContext: NuxtSSRContext): void;
3
4
  export declare function normaliseOptions(_options: DefineOgImageInput): OgImageOptions | OgImagePrebuilt;
@@ -61,7 +61,7 @@ export interface ScreenshotOptions {
61
61
  }
62
62
  export type OgImagePrebuilt = {
63
63
  url: string;
64
- } & Pick<OgImageOptions, 'width' | 'height' | 'alt'>;
64
+ } & Pick<OgImageOptions, 'width' | 'height' | 'alt' | '_query'>;
65
65
  export type DefineOgImageInput = OgImageOptions | OgImagePrebuilt | false;
66
66
  export interface OgImageOptions<T extends keyof OgImageComponents = 'NuxtSeo'> {
67
67
  /**
@@ -125,7 +125,7 @@ export interface ResolvedFontConfig extends FontConfig {
125
125
  }
126
126
  export type InputFontConfig = (`${string}:${number}` | string | FontConfig);
127
127
  export interface RuntimeCompatibilitySchema {
128
- chromium: 'node' | false;
128
+ chromium: 'chrome-launcher' | 'on-demand' | 'playwright' | false;
129
129
  ['css-inline']: 'node' | 'wasm' | 'wasm-fs' | false;
130
130
  resvg: 'node' | 'wasm' | 'wasm-fs' | false;
131
131
  satori: 'node' | 'wasm' | 'wasm-fs' | false;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "nuxt-og-image",
3
3
  "type": "module",
4
- "version": "3.0.0-rc.29",
5
- "packageManager": "pnpm@8.14.2",
4
+ "version": "3.0.0-rc.30",
5
+ "packageManager": "pnpm@8.14.3",
6
6
  "description": "Enlightened OG Image generation for Nuxt.",
7
7
  "author": {
8
8
  "website": "https://harlanzw.com",
@@ -40,8 +40,8 @@
40
40
  "@nuxt/kit": "^3.9.3",
41
41
  "@resvg/resvg-js": "^2.6.0",
42
42
  "@resvg/resvg-wasm": "^2.6.0",
43
- "@unocss/core": "^0.58.3",
44
- "@unocss/preset-wind": "^0.58.3",
43
+ "@unocss/core": "^0.58.4",
44
+ "@unocss/preset-wind": "^0.58.4",
45
45
  "@vueuse/core": "^10.7.2",
46
46
  "chrome-launcher": "^1.1.0",
47
47
  "defu": "^6.1.4",
@@ -53,7 +53,7 @@
53
53
  "nuxt-icon": "^0.6.8",
54
54
  "nuxt-site-config": "^2.2.8",
55
55
  "nuxt-site-config-kit": "^2.2.8",
56
- "nypm": "^0.3.4",
56
+ "nypm": "^0.3.6",
57
57
  "ofetch": "^1.3.3",
58
58
  "ohash": "^1.1.3",
59
59
  "pathe": "^1.1.2",
@@ -62,13 +62,13 @@
62
62
  "radix3": "^1.1.0",
63
63
  "satori": "0.10.11",
64
64
  "satori-html": "^0.3.2",
65
- "shikiji": "^0.10.0",
65
+ "shikiji": "^0.10.2",
66
66
  "sirv": "^2.0.4",
67
67
  "splitpanes": "^3.1.5",
68
68
  "std-env": "^3.7.0",
69
69
  "terminate": "^2.6.1",
70
70
  "ufo": "^1.3.2",
71
- "vanilla-jsoneditor": "^0.21.3",
71
+ "vanilla-jsoneditor": "^0.21.4",
72
72
  "yoga-wasm-web": "^0.3.3"
73
73
  },
74
74
  "devDependencies": {
@@ -88,11 +88,11 @@
88
88
  "@nuxtjs/color-mode": "^3.3.2",
89
89
  "@nuxtjs/eslint-config-typescript": "^12.1.0",
90
90
  "@nuxtjs/i18n": "8.0.0",
91
- "@nuxtjs/tailwindcss": "^6.11.0",
92
- "@unocss/nuxt": "^0.58.3",
93
- "@unocss/preset-icons": "^0.58.3",
94
- "@unocss/preset-uno": "^0.58.3",
95
- "@unocss/runtime": "^0.58.3",
91
+ "@nuxtjs/tailwindcss": "^6.11.1",
92
+ "@unocss/nuxt": "^0.58.4",
93
+ "@unocss/preset-icons": "^0.58.4",
94
+ "@unocss/preset-uno": "^0.58.4",
95
+ "@unocss/runtime": "^0.58.4",
96
96
  "@vueuse/nuxt": "^10.7.2",
97
97
  "bumpp": "^9.3.0",
98
98
  "eslint": "8.56.0",
@@ -103,8 +103,8 @@
103
103
  "sass": "^1.70.0",
104
104
  "sharp": "^0.33.2",
105
105
  "typescript": "^5.3.3",
106
- "unocss": "^0.58.3",
107
- "vitest": "^1.2.1"
106
+ "unocss": "^0.58.4",
107
+ "vitest": "^1.2.2"
108
108
  },
109
109
  "build": {
110
110
  "externals": [
@@ -1 +0,0 @@
1
- {"id":"33bf69ba-5452-4e77-ad39-508d00267652","timestamp":1705934069704,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}
@@ -1,33 +0,0 @@
1
- import playwrightCore from "playwright-core";
2
- export async function createBrowser() {
3
- if (import.meta.dev || import.meta.env.prerender) {
4
- try {
5
- const { Launcher } = await import(String("chrome-launcher"));
6
- const chromePath = Launcher.getFirstInstallation();
7
- return await playwrightCore.chromium.launch({
8
- headless: true,
9
- executablePath: chromePath
10
- });
11
- } catch (e) {
12
- }
13
- }
14
- try {
15
- return await playwrightCore.chromium.launch({
16
- headless: true
17
- });
18
- } catch (e) {
19
- }
20
- try {
21
- const playwright = await import(String("playwright"));
22
- return await playwright.chromium.launch({
23
- headless: true
24
- });
25
- } catch (e) {
26
- if (import.meta.dev) {
27
- console.warn("Failed to load chromium instance. Ensure you have chrome installed, otherwise add the dependency: `npm add -D playwright`.");
28
- } else {
29
- console.error("Failed to load browser instance. Please open an issue with the exception: https://github.com/nuxt-modules/og-image/issues.");
30
- throw e;
31
- }
32
- }
33
- }