nuxt-og-image 3.0.0-beta.12 → 3.0.0-beta.15
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/dist/client/200.html +5 -5
- package/dist/client/404.html +5 -5
- package/dist/client/_nuxt/{IconCSS.3f011790.js → IconCSS.3a98efc6.js} +1 -1
- package/dist/client/_nuxt/IconCSS.7e8f1f7b.css +1 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/9ab97583-6aef-4d38-9cfe-1a0bb2c6966a.json +1 -0
- package/dist/client/_nuxt/entry.3a009184.css +1 -0
- package/dist/client/_nuxt/entry.95bee607.js +137 -0
- package/dist/client/_nuxt/{error-404.0d8fb510.js → error-404.76a67ecd.js} +1 -1
- package/dist/client/_nuxt/{error-500.cefac4a7.js → error-500.b3ac537c.js} +1 -1
- package/dist/client/index.html +5 -5
- package/dist/module.d.mts +36 -19
- package/dist/module.d.ts +36 -19
- package/dist/module.json +2 -2
- package/dist/module.mjs +54 -41
- package/dist/runtime/cache.d.ts +7 -10
- package/dist/runtime/cache.mjs +38 -26
- package/dist/runtime/components/OgImage/OgImage.d.ts +5 -0
- package/dist/runtime/components/OgImage/{index.mjs → OgImage.mjs} +1 -1
- package/dist/runtime/components/OgImage/OgImageScreenshot.d.ts +5 -0
- package/dist/runtime/components/OgImage/{Screenshot.mjs → OgImageScreenshot.mjs} +1 -1
- package/dist/runtime/components/Templates/Official/SimpleBlog.vue +1 -0
- package/dist/runtime/composables/defineOgImage.d.ts +2 -23
- package/dist/runtime/composables/defineOgImage.mjs +32 -115
- package/dist/runtime/composables/defineOgImageComponent.d.ts +3 -0
- package/dist/runtime/composables/defineOgImageComponent.mjs +8 -0
- package/dist/runtime/composables/defineOgImagePageScreenshot.d.ts +2 -0
- package/dist/runtime/composables/defineOgImagePageScreenshot.mjs +14 -0
- package/dist/runtime/core/bindings/css-inline/node.d.ts +2 -5
- package/dist/runtime/core/bindings/css-inline/node.mjs +2 -10
- package/dist/runtime/core/cache/emojis.d.ts +1 -0
- package/dist/runtime/core/cache/emojis.mjs +5 -0
- package/dist/runtime/core/cache/htmlPayload.d.ts +5 -0
- package/dist/runtime/core/cache/htmlPayload.mjs +6 -0
- package/dist/runtime/core/cache/prerender.d.ts +1 -1
- package/dist/runtime/core/font/fetch.d.ts +2 -3
- package/dist/runtime/core/font/fetch.mjs +10 -4
- package/dist/runtime/core/html/applyEmojis.d.ts +3 -0
- package/dist/runtime/core/html/applyEmojis.mjs +37 -0
- package/dist/runtime/core/html/applyInlineCss.d.ts +3 -0
- package/dist/runtime/core/html/applyInlineCss.mjs +32 -0
- package/dist/runtime/core/html/devIframeTemplate.d.ts +2 -0
- package/dist/runtime/core/html/{fetch.mjs → devIframeTemplate.mjs} +8 -31
- package/dist/runtime/core/html/fetchIsland.d.ts +3 -0
- package/dist/runtime/core/html/fetchIsland.mjs +17 -0
- package/dist/runtime/core/options/fetch.d.ts +1 -1
- package/dist/runtime/core/options/fetch.mjs +10 -5
- package/dist/runtime/core/options/normalise.d.ts +2 -2
- package/dist/runtime/core/renderers/chromium/index.mjs +6 -7
- package/dist/runtime/core/renderers/chromium/screenshot.d.ts +2 -3
- package/dist/runtime/core/renderers/chromium/screenshot.mjs +5 -4
- package/dist/runtime/core/renderers/satori/fonts.d.ts +2 -2
- package/dist/runtime/core/renderers/satori/fonts.mjs +2 -2
- package/dist/runtime/core/renderers/satori/index.d.ts +2 -3
- package/dist/runtime/core/renderers/satori/index.mjs +21 -18
- package/dist/runtime/core/renderers/satori/instances.d.ts +3 -0
- package/dist/runtime/core/renderers/satori/instances.mjs +15 -0
- package/dist/runtime/core/renderers/satori/plugins/emojis.mjs +15 -13
- package/dist/runtime/core/renderers/satori/plugins/imageSrc.mjs +8 -4
- package/dist/runtime/core/renderers/satori/utils.d.ts +2 -3
- package/dist/runtime/core/renderers/satori/vnodes.d.ts +2 -3
- package/dist/runtime/core/renderers/satori/vnodes.mjs +14 -6
- package/dist/runtime/core/utils/resolveRendererContext.d.ts +2 -6
- package/dist/runtime/core/utils/resolveRendererContext.mjs +34 -21
- package/dist/runtime/nitro/plugins/nuxt-content.mjs +2 -2
- package/dist/runtime/nitro/plugins/prerender.mjs +2 -2
- package/dist/runtime/nuxt/plugins/nuxt-content-canonical-urls.mjs +1 -1
- package/dist/runtime/nuxt/plugins/route-rule-og-image.server.mjs +14 -47
- package/dist/runtime/nuxt/utils.d.ts +2 -0
- package/dist/runtime/nuxt/utils.mjs +55 -0
- package/dist/runtime/server/routes/__og-image__/debug.json.d.ts +0 -2
- package/dist/runtime/server/routes/__og-image__/debug.json.mjs +2 -7
- package/dist/runtime/server/routes/__og-image__/image.mjs +86 -0
- package/dist/runtime/types.d.ts +57 -24
- package/dist/runtime/utils.d.ts +3 -0
- package/dist/runtime/utils.mjs +11 -0
- package/package.json +17 -32
- package/virtual.d.ts +49 -0
- package/dist/client/_nuxt/IconCSS.8f429b14.css +0 -1
- package/dist/client/_nuxt/builds/meta/f929037e-e674-4060-8070-9dfb30335a28.json +0 -1
- package/dist/client/_nuxt/entry.434c2c45.css +0 -1
- package/dist/client/_nuxt/entry.6c0001e5.js +0 -137
- package/dist/client/grid.png +0 -0
- package/dist/runtime/components/OgImage/Cached.d.ts +0 -5
- package/dist/runtime/components/OgImage/Cached.mjs +0 -10
- package/dist/runtime/components/OgImage/Dynamic.d.ts +0 -8
- package/dist/runtime/components/OgImage/Dynamic.mjs +0 -10
- package/dist/runtime/components/OgImage/Screenshot.d.ts +0 -6
- package/dist/runtime/components/OgImage/Static.d.ts +0 -8
- package/dist/runtime/components/OgImage/Static.mjs +0 -10
- package/dist/runtime/components/OgImage/WithoutCache.d.ts +0 -5
- package/dist/runtime/components/OgImage/WithoutCache.mjs +0 -10
- package/dist/runtime/components/OgImage/index.d.ts +0 -5
- package/dist/runtime/core/bindings/css-inline/mock.d.ts +0 -5
- package/dist/runtime/core/bindings/css-inline/mock.mjs +0 -3
- package/dist/runtime/core/html/fetch.d.ts +0 -3
- package/dist/runtime/server/routes/__og-image__/image-[path]-og.[extension].mjs +0 -45
- package/dist/runtime/utilts.d.ts +0 -2
- package/dist/runtime/utilts.mjs +0 -8
- /package/dist/runtime/server/routes/__og-image__/{image-[path]-og.[extension].d.ts → image.d.ts} +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.
|
|
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.95bee607.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.
|
|
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.95bee607.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};
|
package/dist/client/index.html
CHANGED
|
@@ -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.
|
|
6
|
-
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-og-image/_nuxt/entry.
|
|
5
|
+
<link rel="stylesheet" href="/__nuxt-og-image/_nuxt/entry.3a009184.css">
|
|
6
|
+
<link rel="modulepreload" as="script" crossorigin href="/__nuxt-og-image/_nuxt/entry.95bee607.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.
|
|
8
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/error-404.76a67ecd.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.
|
|
11
|
-
<script type="module" src="/__nuxt-og-image/_nuxt/entry.
|
|
10
|
+
<link rel="prefetch" as="script" crossorigin href="/__nuxt-og-image/_nuxt/error-500.b3ac537c.js">
|
|
11
|
+
<script type="module" src="/__nuxt-og-image/_nuxt/entry.95bee607.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,10 @@ 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 { OgImageComponents } from '#nuxt-og-image/components';
|
|
5
6
|
import { WasmOptions } from 'nitropack/types';
|
|
6
7
|
|
|
8
|
+
type IconifyEmojiIconSets = 'twemoji' | 'noto' | 'fluent-emoji' | 'fluent-emoji-flat' | 'fluent-emoji-high-contrast' | 'noto-v1' | 'emojione' | 'emojione-monotone' | 'emojione-v1' | 'streamline-emojis' | 'openmoji';
|
|
7
9
|
interface OgImageComponent {
|
|
8
10
|
path?: string;
|
|
9
11
|
pascalName: string;
|
|
@@ -33,27 +35,48 @@ interface ScreenshotOptions {
|
|
|
33
35
|
*/
|
|
34
36
|
delay?: number;
|
|
35
37
|
}
|
|
36
|
-
interface OgImageOptions extends
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
interface OgImageOptions<T extends keyof OgImageComponents = 'Fallback'> {
|
|
39
|
+
/**
|
|
40
|
+
* The width of the screenshot.
|
|
41
|
+
*
|
|
42
|
+
* @default 1200
|
|
43
|
+
*/
|
|
44
|
+
width?: number;
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
46
|
+
* The height of the screenshot.
|
|
47
|
+
*
|
|
48
|
+
* @default 630
|
|
42
49
|
*/
|
|
43
|
-
|
|
50
|
+
height?: number;
|
|
51
|
+
/**
|
|
52
|
+
* The alt text for the image.
|
|
53
|
+
*/
|
|
54
|
+
alt?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Use a prebuilt image instead of generating one.
|
|
57
|
+
*
|
|
58
|
+
* Should be an absolute URL.
|
|
59
|
+
*/
|
|
60
|
+
url?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The name of the component to render.
|
|
63
|
+
*/
|
|
64
|
+
component?: T | string;
|
|
65
|
+
/**
|
|
66
|
+
* Props to pass to the component.
|
|
67
|
+
*/
|
|
68
|
+
props?: OgImageComponents[T] | Record<string, any>;
|
|
69
|
+
renderer?: 'chromium' | 'satori';
|
|
70
|
+
extension?: 'png' | 'jpeg' | 'jpg';
|
|
71
|
+
emojis?: IconifyEmojiIconSets;
|
|
44
72
|
/**
|
|
45
73
|
* Provide a static HTML template to render the OG Image instead of a component.
|
|
46
74
|
*/
|
|
47
75
|
html?: string;
|
|
48
|
-
cache?: boolean;
|
|
49
|
-
cacheKey?: string;
|
|
50
76
|
resvg?: ResvgRenderOptions;
|
|
51
77
|
satori?: SatoriOptions;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
cacheTtl?: number;
|
|
56
|
-
[key: string]: any;
|
|
78
|
+
screenshot?: Partial<ScreenshotOptions>;
|
|
79
|
+
cacheMaxAgeSeconds?: number;
|
|
57
80
|
}
|
|
58
81
|
interface FontConfig {
|
|
59
82
|
name: string;
|
|
@@ -112,12 +135,6 @@ interface ModuleOptions {
|
|
|
112
135
|
* @see https://sharp.pixelplumbing.com/api-constructor
|
|
113
136
|
*/
|
|
114
137
|
sharpOptions?: Partial<SharpOptions>;
|
|
115
|
-
/**
|
|
116
|
-
* Should the playground at <path>/__og_image__ be enabled in development.
|
|
117
|
-
*
|
|
118
|
-
* @default true
|
|
119
|
-
*/
|
|
120
|
-
playground: boolean;
|
|
121
138
|
/**
|
|
122
139
|
* Include Satori runtime.
|
|
123
140
|
*
|
package/dist/module.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ 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 { OgImageComponents } from '#nuxt-og-image/components';
|
|
5
6
|
import { WasmOptions } from 'nitropack/types';
|
|
6
7
|
|
|
8
|
+
type IconifyEmojiIconSets = 'twemoji' | 'noto' | 'fluent-emoji' | 'fluent-emoji-flat' | 'fluent-emoji-high-contrast' | 'noto-v1' | 'emojione' | 'emojione-monotone' | 'emojione-v1' | 'streamline-emojis' | 'openmoji';
|
|
7
9
|
interface OgImageComponent {
|
|
8
10
|
path?: string;
|
|
9
11
|
pascalName: string;
|
|
@@ -33,27 +35,48 @@ interface ScreenshotOptions {
|
|
|
33
35
|
*/
|
|
34
36
|
delay?: number;
|
|
35
37
|
}
|
|
36
|
-
interface OgImageOptions extends
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
interface OgImageOptions<T extends keyof OgImageComponents = 'Fallback'> {
|
|
39
|
+
/**
|
|
40
|
+
* The width of the screenshot.
|
|
41
|
+
*
|
|
42
|
+
* @default 1200
|
|
43
|
+
*/
|
|
44
|
+
width?: number;
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
46
|
+
* The height of the screenshot.
|
|
47
|
+
*
|
|
48
|
+
* @default 630
|
|
42
49
|
*/
|
|
43
|
-
|
|
50
|
+
height?: number;
|
|
51
|
+
/**
|
|
52
|
+
* The alt text for the image.
|
|
53
|
+
*/
|
|
54
|
+
alt?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Use a prebuilt image instead of generating one.
|
|
57
|
+
*
|
|
58
|
+
* Should be an absolute URL.
|
|
59
|
+
*/
|
|
60
|
+
url?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The name of the component to render.
|
|
63
|
+
*/
|
|
64
|
+
component?: T | string;
|
|
65
|
+
/**
|
|
66
|
+
* Props to pass to the component.
|
|
67
|
+
*/
|
|
68
|
+
props?: OgImageComponents[T] | Record<string, any>;
|
|
69
|
+
renderer?: 'chromium' | 'satori';
|
|
70
|
+
extension?: 'png' | 'jpeg' | 'jpg';
|
|
71
|
+
emojis?: IconifyEmojiIconSets;
|
|
44
72
|
/**
|
|
45
73
|
* Provide a static HTML template to render the OG Image instead of a component.
|
|
46
74
|
*/
|
|
47
75
|
html?: string;
|
|
48
|
-
cache?: boolean;
|
|
49
|
-
cacheKey?: string;
|
|
50
76
|
resvg?: ResvgRenderOptions;
|
|
51
77
|
satori?: SatoriOptions;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
cacheTtl?: number;
|
|
56
|
-
[key: string]: any;
|
|
78
|
+
screenshot?: Partial<ScreenshotOptions>;
|
|
79
|
+
cacheMaxAgeSeconds?: number;
|
|
57
80
|
}
|
|
58
81
|
interface FontConfig {
|
|
59
82
|
name: string;
|
|
@@ -112,12 +135,6 @@ interface ModuleOptions {
|
|
|
112
135
|
* @see https://sharp.pixelplumbing.com/api-constructor
|
|
113
136
|
*/
|
|
114
137
|
sharpOptions?: Partial<SharpOptions>;
|
|
115
|
-
/**
|
|
116
|
-
* Should the playground at <path>/__og_image__ be enabled in development.
|
|
117
|
-
*
|
|
118
|
-
* @default true
|
|
119
|
-
*/
|
|
120
|
-
playground: boolean;
|
|
121
138
|
/**
|
|
122
139
|
* Include Satori runtime.
|
|
123
140
|
*
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
|
-
import { useNuxt, createResolver, addTemplate, defineNuxtModule, useLogger, hasNuxtModule, addServerPlugin, addPlugin, addServerHandler, addImports, addComponentsDir, addComponent } from '@nuxt/kit';
|
|
3
|
+
import { useNuxt, createResolver, addTemplate, resolvePath, defineNuxtModule, useLogger, hasNuxtModule, addServerPlugin, addPlugin, addServerHandler, addImports, addComponentsDir, addComponent } from '@nuxt/kit';
|
|
4
4
|
import { installNuxtSiteConfig } from 'nuxt-site-config-kit';
|
|
5
5
|
import { provider, env } from 'std-env';
|
|
6
6
|
import { hash } from 'ohash';
|
|
@@ -8,8 +8,10 @@ import { relative } from 'pathe';
|
|
|
8
8
|
import 'nypm';
|
|
9
9
|
import { defu } from 'defu';
|
|
10
10
|
import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
|
|
11
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
12
|
+
import { createHash } from 'node:crypto';
|
|
11
13
|
|
|
12
|
-
const version = "3.0.0-beta.
|
|
14
|
+
const version = "3.0.0-beta.15";
|
|
13
15
|
|
|
14
16
|
const autodetectableProviders = {
|
|
15
17
|
azure_static: "azure",
|
|
@@ -86,17 +88,14 @@ const RuntimeCompatibility = {
|
|
|
86
88
|
"vercel-edge": {
|
|
87
89
|
bindings: {
|
|
88
90
|
"chromium": false,
|
|
89
|
-
"css-inline":
|
|
91
|
+
"css-inline": false,
|
|
90
92
|
"resvg": "wasm",
|
|
91
93
|
"satori": "node",
|
|
92
|
-
"sharp":
|
|
94
|
+
"sharp": false
|
|
93
95
|
},
|
|
94
|
-
// requires vercel pro
|
|
95
|
-
// TODO support importing
|
|
96
96
|
wasm: {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
97
|
+
// lowers workers kb size
|
|
98
|
+
esmImport: true
|
|
100
99
|
}
|
|
101
100
|
},
|
|
102
101
|
"cloudflare-pages": cloudflare,
|
|
@@ -138,6 +137,7 @@ function applyNitroPresetCompatibility(nitroConfig, options) {
|
|
|
138
137
|
applyBinding("satori"),
|
|
139
138
|
applyBinding("resvg"),
|
|
140
139
|
applyBinding("sharp"),
|
|
140
|
+
applyBinding("css-inline"),
|
|
141
141
|
nitroConfig.alias || {}
|
|
142
142
|
);
|
|
143
143
|
if (Object.values(compatibility.bindings).includes("wasm")) {
|
|
@@ -145,7 +145,7 @@ function applyNitroPresetCompatibility(nitroConfig, options) {
|
|
|
145
145
|
nitroConfig.experimental.wasm = true;
|
|
146
146
|
}
|
|
147
147
|
nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};
|
|
148
|
-
nitroConfig.wasm = defu(compatibility.wasm
|
|
148
|
+
nitroConfig.wasm = defu(compatibility.wasm, nitroConfig.wasm);
|
|
149
149
|
return compatibility;
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -274,13 +274,27 @@ async function setupBuildHandler(config, resolve, nuxt = useNuxt()) {
|
|
|
274
274
|
nitroConfig.alias["utf-8-validate"] = "unenv/runtime/mock/proxy-cjs";
|
|
275
275
|
nitroConfig.alias.queue = "unenv/runtime/mock/proxy-cjs";
|
|
276
276
|
});
|
|
277
|
+
nuxt.hooks.hook("nitro:init", async (nitro) => {
|
|
278
|
+
nitro.hooks.hook("compiled", async (_nitro) => {
|
|
279
|
+
const configuredEntry = nitro.options.rollupConfig?.output.entryFileNames;
|
|
280
|
+
const serverEntry = resolve(_nitro.options.output.serverDir, typeof configuredEntry === "string" ? configuredEntry : "index.mjs");
|
|
281
|
+
const contents = await readFile(serverEntry, "utf-8");
|
|
282
|
+
const wasmSource = await readFile(await resolvePath("@resvg/resvg-wasm/index_bg.wasm"));
|
|
283
|
+
const wasmHash = sha1(wasmSource);
|
|
284
|
+
const postfix = _nitro.options.preset === "vercel-edge" ? "?module" : "";
|
|
285
|
+
await writeFile(serverEntry, contents.replaceAll('"@resvg/resvg-wasm/index_bg.wasm"', `"./wasm/index_bg-${wasmHash}.wasm${postfix}"`), { encoding: "utf-8" });
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function sha1(source) {
|
|
290
|
+
return createHash("sha1").update(source).digest("hex").slice(0, 16);
|
|
277
291
|
}
|
|
278
292
|
|
|
279
293
|
const module = defineNuxtModule({
|
|
280
294
|
meta: {
|
|
281
295
|
name: "nuxt-og-image",
|
|
282
296
|
compatibility: {
|
|
283
|
-
nuxt: "^3.
|
|
297
|
+
nuxt: "^3.8.2",
|
|
284
298
|
bridge: false
|
|
285
299
|
},
|
|
286
300
|
configKey: "ogImage"
|
|
@@ -289,13 +303,13 @@ const module = defineNuxtModule({
|
|
|
289
303
|
return {
|
|
290
304
|
enabled: true,
|
|
291
305
|
defaults: {
|
|
306
|
+
emojis: "noto",
|
|
292
307
|
renderer: "satori",
|
|
293
308
|
component: "Fallback",
|
|
294
309
|
width: 1200,
|
|
295
310
|
height: 600,
|
|
296
|
-
cache: true,
|
|
297
311
|
// default is to cache the image for 1 day (24 hours)
|
|
298
|
-
|
|
312
|
+
cacheMaxAgeSeconds: 60 * 60 * 24 * 3
|
|
299
313
|
},
|
|
300
314
|
componentDirs: ["OgImage", "OgImageTemplate"],
|
|
301
315
|
runtimeSatori: true,
|
|
@@ -320,9 +334,17 @@ const module = defineNuxtModule({
|
|
|
320
334
|
const { resolve } = createResolver(import.meta.url);
|
|
321
335
|
const preset = resolveNitroPreset(nuxt.options.nitro);
|
|
322
336
|
const compatibility = getPresetNitroPresetCompatibility(preset);
|
|
323
|
-
config.defaults.extension
|
|
324
|
-
|
|
337
|
+
const userConfiguredExtension = config.defaults.extension;
|
|
338
|
+
config.defaults.extension = userConfiguredExtension || "jpg";
|
|
339
|
+
if (!compatibility.bindings.sharp && config.defaults.renderer !== "chromium") {
|
|
340
|
+
if (userConfiguredExtension && ["jpeg", "jpg"].includes(userConfiguredExtension))
|
|
341
|
+
logger.warn("The sharp runtime is not available for this target, disabling sharp and using png instead.");
|
|
325
342
|
config.defaults.extension = "png";
|
|
343
|
+
}
|
|
344
|
+
if (config.runtimeBrowser && !compatibility.bindings.chromium) {
|
|
345
|
+
logger.warn("The Chromium runtime is not available for this target, disabling runtimeBrowser.");
|
|
346
|
+
config.runtimeBrowser = false;
|
|
347
|
+
}
|
|
326
348
|
await installNuxtSiteConfig();
|
|
327
349
|
if (hasNuxtModule("@nuxt/content")) {
|
|
328
350
|
addServerPlugin(resolve("./runtime/nitro/plugins/nuxt-content"));
|
|
@@ -346,24 +368,13 @@ const module = defineNuxtModule({
|
|
|
346
368
|
addServerHandler({
|
|
347
369
|
lazy: true,
|
|
348
370
|
route: "/__og-image__/image/**",
|
|
349
|
-
handler: resolve("./runtime/server/routes/__og-image__/image
|
|
371
|
+
handler: resolve("./runtime/server/routes/__og-image__/image")
|
|
350
372
|
});
|
|
351
373
|
nuxt.options.optimization.treeShake.composables.client["nuxt-og-image"] = [];
|
|
352
|
-
[
|
|
353
|
-
// deprecated
|
|
354
|
-
"Dynamic",
|
|
355
|
-
"Static",
|
|
356
|
-
// new
|
|
357
|
-
"index",
|
|
358
|
-
"Cached",
|
|
359
|
-
"Component",
|
|
360
|
-
"WithoutCache",
|
|
361
|
-
"Screenshot"
|
|
362
|
-
].forEach((name) => {
|
|
363
|
-
name = name === "index" ? "defineOgImage" : `defineOgImage${name}`;
|
|
374
|
+
["defineOgImage", "defineOgImageComponent", "defineOgImageScreenshot"].forEach((name) => {
|
|
364
375
|
addImports({
|
|
365
376
|
name,
|
|
366
|
-
from: resolve(
|
|
377
|
+
from: resolve(`./runtime/composables/${name}`)
|
|
367
378
|
});
|
|
368
379
|
nuxt.options.optimization.treeShake.composables.client["nuxt-og-image"].push(name);
|
|
369
380
|
});
|
|
@@ -376,18 +387,12 @@ const module = defineNuxtModule({
|
|
|
376
387
|
island: true
|
|
377
388
|
});
|
|
378
389
|
[
|
|
379
|
-
// deprecated
|
|
380
|
-
"Static",
|
|
381
|
-
"Dynamic",
|
|
382
390
|
// new
|
|
383
|
-
"
|
|
384
|
-
"
|
|
385
|
-
"WithoutCache",
|
|
386
|
-
"Screenshot"
|
|
391
|
+
"OgImage",
|
|
392
|
+
"OgImageScreenshot"
|
|
387
393
|
].forEach((name) => {
|
|
388
394
|
addComponent({
|
|
389
|
-
|
|
390
|
-
name: name === "index" ? "OgImage" : `OgImage${name}`,
|
|
395
|
+
name,
|
|
391
396
|
filePath: resolve(`./runtime/components/OgImage/${name}`)
|
|
392
397
|
});
|
|
393
398
|
});
|
|
@@ -445,12 +450,13 @@ const module = defineNuxtModule({
|
|
|
445
450
|
return `
|
|
446
451
|
declare module 'nitropack' {
|
|
447
452
|
interface NitroRouteRules {
|
|
448
|
-
ogImage?: false | import('${typesPath}').OgImageOptions
|
|
453
|
+
ogImage?: false | import('${typesPath}').OgImageOptions & Record<string, any>
|
|
449
454
|
}
|
|
450
455
|
interface NitroRouteConfig {
|
|
451
|
-
ogImage?: false | import('${typesPath}').OgImageOptions
|
|
456
|
+
ogImage?: false | import('${typesPath}').OgImageOptions & Record<string, any>
|
|
452
457
|
}
|
|
453
458
|
}
|
|
459
|
+
|
|
454
460
|
declare module '#nuxt-og-image/components' {
|
|
455
461
|
export interface OgImageComponents {
|
|
456
462
|
${componentImports}
|
|
@@ -458,6 +464,11 @@ ${componentImports}
|
|
|
458
464
|
}
|
|
459
465
|
`;
|
|
460
466
|
});
|
|
467
|
+
const cacheEnabled = typeof config.runtimeCacheStorage !== "undefined" && config.runtimeCacheStorage !== false;
|
|
468
|
+
const runtimeCacheStorage = typeof config.runtimeCacheStorage === "boolean" ? "default" : config.runtimeCacheStorage.driver;
|
|
469
|
+
let baseCacheKey = runtimeCacheStorage === "default" ? `/cache/nuxt-og-image@${version}` : `/nuxt-og-image@${version}`;
|
|
470
|
+
if (!cacheEnabled)
|
|
471
|
+
baseCacheKey = false;
|
|
461
472
|
nuxt.hooks.hook("modules:done", async () => {
|
|
462
473
|
nuxt.hooks.callHook("og-image:config", config);
|
|
463
474
|
const normalisedFonts = config.fonts.map((f) => {
|
|
@@ -488,8 +499,10 @@ ${componentImports}
|
|
|
488
499
|
runtimeBrowser: config.runtimeBrowser,
|
|
489
500
|
// @ts-expect-error runtime type
|
|
490
501
|
defaults: config.defaults,
|
|
502
|
+
debug: config.debug,
|
|
491
503
|
// avoid adding credentials
|
|
492
|
-
|
|
504
|
+
// @ts-expect-error runtime type
|
|
505
|
+
baseCacheKey,
|
|
493
506
|
// convert the fonts to uniform type to fix ts issue
|
|
494
507
|
fonts: normalisedFonts,
|
|
495
508
|
hasNuxtIcon: hasNuxtModule("nuxt-icon")
|
package/dist/runtime/cache.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
skipRestore?: boolean;
|
|
8
|
-
}): Promise<{
|
|
9
|
-
cachedItem: false | T;
|
|
1
|
+
import type { H3EventOgImageRender } from './core/utils/resolveRendererContext';
|
|
2
|
+
export declare function useOgImageBufferCache(ctx: H3EventOgImageRender, options: {
|
|
3
|
+
baseCacheKey: string | false;
|
|
4
|
+
cacheMaxAgeSeconds?: number;
|
|
5
|
+
}): Promise<void | {
|
|
6
|
+
cachedItem: false | BufferSource;
|
|
10
7
|
enabled: boolean;
|
|
11
|
-
update: (
|
|
8
|
+
update: (image: BufferSource) => Promise<void>;
|
|
12
9
|
}>;
|
package/dist/runtime/cache.mjs
CHANGED
|
@@ -1,45 +1,57 @@
|
|
|
1
1
|
import { prefixStorage } from "unstorage";
|
|
2
|
-
import { getQuery, setHeader } from "h3";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const cache = prefixStorage(useStorage(),
|
|
10
|
-
const key =
|
|
11
|
-
|
|
12
|
-
let xCacheExpires = 0;
|
|
13
|
-
const newExpires = Date.now() + (options.cacheTtl || 0);
|
|
14
|
-
const purge = typeof getQuery(e).purge !== "undefined";
|
|
2
|
+
import { getQuery, handleCacheHeaders, setHeader, setHeaders } from "h3";
|
|
3
|
+
import { withTrailingSlash } from "ufo";
|
|
4
|
+
import { hash } from "ohash";
|
|
5
|
+
import { useStorage } from "#imports";
|
|
6
|
+
export async function useOgImageBufferCache(ctx, options) {
|
|
7
|
+
const maxAge = Number(options.cacheMaxAgeSeconds);
|
|
8
|
+
const enabled = maxAge > 0;
|
|
9
|
+
const cache = prefixStorage(useStorage(), withTrailingSlash(options.baseCacheKey || "/"));
|
|
10
|
+
const key = ctx.key;
|
|
11
|
+
const purge = typeof getQuery(ctx.e).purge !== "undefined";
|
|
15
12
|
let cachedItem = false;
|
|
16
|
-
if (
|
|
17
|
-
const { value, expiresAt } = await cache.getItem(key).catch(() => ({ value: null, expiresAt: Date.now() }));
|
|
13
|
+
if (enabled && await cache.hasItem(key).catch(() => false)) {
|
|
14
|
+
const { value, expiresAt, headers } = await cache.getItem(key).catch(() => ({ value: null, expiresAt: Date.now() }));
|
|
18
15
|
if (purge) {
|
|
19
|
-
xCacheHeader = "PURGE";
|
|
20
|
-
xCacheExpires = newExpires;
|
|
21
16
|
await cache.removeItem(key).catch(() => {
|
|
22
17
|
});
|
|
23
18
|
} else if (expiresAt > Date.now()) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
cachedItem = Buffer.from(value, "base64");
|
|
20
|
+
if (handleCacheHeaders(ctx.e, {
|
|
21
|
+
modifiedTime: new Date(headers["last-modified"]),
|
|
22
|
+
etag: headers.etag,
|
|
23
|
+
maxAge
|
|
24
|
+
}))
|
|
25
|
+
return;
|
|
26
|
+
setHeaders(ctx.e, headers);
|
|
27
27
|
} else {
|
|
28
|
-
xCacheHeader = "MISS";
|
|
29
|
-
xCacheExpires = expiresAt;
|
|
30
28
|
await cache.removeItem(key).catch(() => {
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
if (
|
|
35
|
-
setHeader(e,
|
|
36
|
-
setHeader(e,
|
|
32
|
+
if (!enabled) {
|
|
33
|
+
setHeader(ctx.e, "Cache-Control", "no-cache, no-store, must-revalidate");
|
|
34
|
+
setHeader(ctx.e, "Pragma", "no-cache");
|
|
35
|
+
setHeader(ctx.e, "Expires", "0");
|
|
37
36
|
}
|
|
38
37
|
return {
|
|
39
38
|
enabled,
|
|
40
39
|
cachedItem,
|
|
41
40
|
async update(item) {
|
|
42
|
-
|
|
41
|
+
const value = Buffer.from(item).toString("base64");
|
|
42
|
+
const headers = {
|
|
43
|
+
// avoid multi-tenancy cache issues
|
|
44
|
+
"Vary": "accept-encoding, host",
|
|
45
|
+
"etag": `W/"${hash(value)}"`,
|
|
46
|
+
"last-modified": (/* @__PURE__ */ new Date()).toUTCString(),
|
|
47
|
+
"cache-control": `public, s-maxage=${maxAge}, stale-while-revalidate`
|
|
48
|
+
};
|
|
49
|
+
setHeaders(ctx.e, headers);
|
|
50
|
+
enabled && await cache.setItem(key, {
|
|
51
|
+
value,
|
|
52
|
+
headers,
|
|
53
|
+
expiresAt: Date.now() + maxAge * 1e3
|
|
54
|
+
});
|
|
43
55
|
}
|
|
44
56
|
};
|
|
45
57
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OgImageOptions } from '../../types';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<OgImageOptions<"Fallback">, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<OgImageOptions<"Fallback">>, {
|
|
3
|
+
props?: any;
|
|
4
|
+
}, {}>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OgImagePageScreenshotOptions } from '../../types';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<OgImagePageScreenshotOptions, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<OgImagePageScreenshotOptions>, {
|
|
3
|
+
props?: any;
|
|
4
|
+
}, {}>;
|
|
5
|
+
export default _default;
|
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
import type { OgImageComponents } from '#nuxt-og-image/components';
|
|
4
|
-
export declare function defineOgImageScreenshot(options?: OgImageScreenshotOptions): void;
|
|
5
|
-
/**
|
|
6
|
-
* @param options
|
|
7
|
-
* @deprecated Use `defineOgImage` or `defineOgImageCached` instead
|
|
8
|
-
*/
|
|
9
|
-
export declare function defineOgImageStatic(options?: OgImageOptions): void;
|
|
10
|
-
export declare function defineOgImageCached(options?: OgImageOptions): void;
|
|
11
|
-
export declare function defineOgImageWithoutCache(options?: OgImageOptions): void;
|
|
12
|
-
/**
|
|
13
|
-
* @param options
|
|
14
|
-
* @deprecated Use `defineOgImageWithoutCache` instead
|
|
15
|
-
*/
|
|
16
|
-
export declare function defineOgImageDynamic(options?: OgImageOptions): void;
|
|
17
|
-
type OgImagePrebuilt = {
|
|
18
|
-
url: string;
|
|
19
|
-
} & Pick<OgImageOptions, 'width' | 'height' | 'alt'>;
|
|
20
|
-
type ExtractComponentProps<T extends Component> = T extends new (...args: any) => any ? Omit<InstanceType<T>['$props'], keyof ComponentCustomProps | keyof VNodeProps | keyof AllowedComponentProps> : never;
|
|
21
|
-
export declare function defineOgImageComponent<T extends keyof OgImageComponents>(component: T, props: ExtractComponentProps<OgImageComponents[T]>, options?: OgImageOptions): void;
|
|
22
|
-
export declare function defineOgImage(_options?: OgImagePrebuilt | OgImageOptions): void;
|
|
23
|
-
export {};
|
|
1
|
+
import type { DefineOgImageInput } from '../types';
|
|
2
|
+
export declare function defineOgImage(_options?: DefineOgImageInput): void;
|