nuxt-og-image 2.0.20 → 2.0.22

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 (35) hide show
  1. package/dist/client/200.html +6 -6
  2. package/dist/client/404.html +6 -6
  3. package/dist/client/_nuxt/IconCSS.7dbf5ef2.js +1 -0
  4. package/dist/client/_nuxt/{ImageLoader.61f9175c.js → ImageLoader.7d142ae6.js} +1 -1
  5. package/dist/client/_nuxt/entry.baaec905.js +136 -0
  6. package/dist/client/_nuxt/entry.d5c2937d.css +1 -0
  7. package/dist/client/_nuxt/{error-404.54e2be0d.js → error-404.1e9d5490.js} +1 -1
  8. package/dist/client/_nuxt/error-404.b751fa02.css +1 -0
  9. package/dist/client/_nuxt/{error-500.4af57e17.js → error-500.a2569504.js} +1 -1
  10. package/dist/client/_nuxt/index.3defa0e2.js +1 -0
  11. package/dist/client/_nuxt/{options.bcb5f754.js → options.bfa3a6f5.js} +1 -1
  12. package/dist/client/_nuxt/png.25a0a86a.js +1 -0
  13. package/dist/client/_nuxt/shiki.3055e6bb.js +7 -0
  14. package/dist/client/_nuxt/svg.60dc20c6.js +1 -0
  15. package/dist/client/_nuxt/{vnodes.429b9b53.js → vnodes.8b4e811d.js} +1 -1
  16. package/dist/client/index.html +6 -6
  17. package/dist/client/options/index.html +6 -6
  18. package/dist/client/png/index.html +6 -6
  19. package/dist/client/svg/index.html +6 -6
  20. package/dist/client/vnodes/index.html +6 -6
  21. package/dist/module.d.mts +164 -0
  22. package/dist/module.d.ts +1 -1
  23. package/dist/module.json +1 -1
  24. package/dist/module.mjs +8 -5
  25. package/dist/runtime/composables/defineOgImage.mjs +2 -2
  26. package/dist/types.d.mts +17 -0
  27. package/package.json +7 -7
  28. package/dist/client/_nuxt/IconCSS.f7ecc548.js +0 -1
  29. package/dist/client/_nuxt/entry.37e248c4.js +0 -136
  30. package/dist/client/_nuxt/entry.d467b8d0.css +0 -1
  31. package/dist/client/_nuxt/error-404.888958ab.css +0 -1
  32. package/dist/client/_nuxt/index.de53776f.js +0 -1
  33. package/dist/client/_nuxt/png.db0f6520.js +0 -1
  34. package/dist/client/_nuxt/shiki.b43e6455.js +0 -7
  35. package/dist/client/_nuxt/svg.df957adf.js +0 -1
@@ -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__/client/_nuxt/entry.d467b8d0.css">
6
- <link rel="modulepreload" as="script" crossorigin="" href="/__nuxt_og_image__/client/_nuxt/entry.37e248c4.js">
7
- <link rel="prefetch" as="style" href="/__nuxt_og_image__/client/_nuxt/error-404.888958ab.css">
8
- <link rel="prefetch" as="script" crossorigin="" href="/__nuxt_og_image__/client/_nuxt/error-404.54e2be0d.js">
5
+ <link rel="stylesheet" href="/__nuxt_og_image__/client/_nuxt/entry.d5c2937d.css">
6
+ <link rel="modulepreload" as="script" crossorigin="" href="/__nuxt_og_image__/client/_nuxt/entry.baaec905.js">
7
+ <link rel="prefetch" as="style" href="/__nuxt_og_image__/client/_nuxt/error-404.b751fa02.css">
8
+ <link rel="prefetch" as="script" crossorigin="" href="/__nuxt_og_image__/client/_nuxt/error-404.1e9d5490.js">
9
9
  <link rel="prefetch" as="style" href="/__nuxt_og_image__/client/_nuxt/error-500.69009e70.css">
10
- <link rel="prefetch" as="script" crossorigin="" href="/__nuxt_og_image__/client/_nuxt/error-500.4af57e17.js">
11
- <script type="module" src="/__nuxt_og_image__/client/_nuxt/entry.37e248c4.js" crossorigin=""></script><script>"use strict";(()=>{const a=window,e=document.documentElement,m=["dark","light"],c=window.localStorage.getItem("nuxt-color-mode")||"system";let n=c==="system"?f():c;const l=e.getAttribute("data-color-mode-forced");l&&(n=l),i(n),a["__NUXT_COLOR_MODE__"]={preference:c,value:n,getColorScheme:f,addColorScheme:i,removeColorScheme:d};function i(o){const t=""+o+"",s="";e.classList?e.classList.add(t):e.className+=" "+t,s&&e.setAttribute("data-"+s,o)}function d(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 f(){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__/client/_nuxt/error-500.a2569504.js">
11
+ <script type="module" src="/__nuxt_og_image__/client/_nuxt/entry.baaec905.js" crossorigin=""></script><script>"use strict";(()=>{const a=window,e=document.documentElement,m=["dark","light"],c=window.localStorage.getItem("nuxt-color-mode")||"system";let n=c==="system"?f():c;const l=e.getAttribute("data-color-mode-forced");l&&(n=l),i(n),a["__NUXT_COLOR_MODE__"]={preference:c,value:n,getColorScheme:f,addColorScheme:i,removeColorScheme:d};function i(o){const t=""+o+"",s="";e.classList?e.classList.add(t):e.className+=" "+t,s&&e.setAttribute("data-"+s,o)}function d(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 f(){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__/client",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body>
@@ -0,0 +1,164 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { SatoriOptions } from 'satori';
3
+
4
+ interface ScreenshotOptions {
5
+ colorScheme?: 'dark' | 'light';
6
+ selector?: string;
7
+ mask?: string;
8
+ /**
9
+ * The width of the screenshot.
10
+ *
11
+ * @default 1200
12
+ */
13
+ width: number;
14
+ /**
15
+ * The height of the screenshot.
16
+ *
17
+ * @default 630
18
+ */
19
+ height: number;
20
+ /**
21
+ * How long to wait before taking the screenshot. Useful for waiting for animations.
22
+ */
23
+ delay?: number;
24
+ }
25
+ interface OgImageOptions extends Partial<ScreenshotOptions> {
26
+ provider?: 'browser' | 'satori';
27
+ title?: string;
28
+ description?: string;
29
+ component?: string | null;
30
+ alt?: string;
31
+ cache?: boolean;
32
+ cacheKey?: string;
33
+ cacheTtl?: number;
34
+ /**
35
+ * @deprecated Use `cache` instead
36
+ */
37
+ static?: boolean;
38
+ [key: string]: any;
39
+ }
40
+ interface FontConfig {
41
+ name: string;
42
+ weight: number;
43
+ path?: string;
44
+ }
45
+ type InputFontConfig = (`${string}:${number}` | FontConfig);
46
+
47
+ interface RuntimeCompatibilitySchema {
48
+ browser: false | 'playwright' | 'lambda' | 'universal';
49
+ satori: false | 'default' | 'yoga-wasm';
50
+ wasm: 'inline' | 'import' | 'fetch';
51
+ png: 'resvg-wasm' | 'svg2png' | 'resvg-node';
52
+ inlineCss?: 'node' | 'mock';
53
+ node?: boolean;
54
+ wasmImportQuery?: string;
55
+ }
56
+
57
+ interface ModuleOptions {
58
+ /**
59
+ * Whether the og:image images should be generated.
60
+ *
61
+ * @default true
62
+ */
63
+ enabled: boolean;
64
+ /**
65
+ * Default data used within the payload to generate the OG Image.
66
+ *
67
+ * You can use this to change the default template, image sizing and more.
68
+ *
69
+ * @default { component: 'OgImageTemplateFallback', width: 1200, height: 630, cache: true, cacheTtl: 24 * 60 * 60 * 1000 }
70
+ */
71
+ defaults: OgImageOptions;
72
+ /**
73
+ * Fonts to use when rendering the og:image.
74
+ *
75
+ * @example ['Roboto:400,700', { path: 'path/to/font.ttf', weight: 400, name: 'MyFont' }]
76
+ */
77
+ fonts: InputFontConfig[];
78
+ /**
79
+ * Options to pass to satori.
80
+ *
81
+ * @see https://github.com/vercel/satori/blob/main/src/satori.ts#L18
82
+ */
83
+ satoriOptions: Partial<SatoriOptions>;
84
+ /**
85
+ * Should the playground at <path>/__og_image__ be enabled in development.
86
+ *
87
+ * @default true
88
+ */
89
+ playground: boolean;
90
+ /**
91
+ * Include Satori runtime.
92
+ *
93
+ * @default true
94
+ */
95
+ runtimeSatori: boolean;
96
+ /**
97
+ * Include the Browser runtime.
98
+ * This will need to be manually enabled for production environments.
99
+ *
100
+ * @default `process.dev`
101
+ */
102
+ runtimeBrowser: boolean;
103
+ /**
104
+ * Enables debug logs and a debug endpoint.
105
+ *
106
+ * @false false
107
+ */
108
+ debug: boolean;
109
+ /**
110
+ * Modify the cache behavior.
111
+ *
112
+ * Passing a boolean will enable or disable the runtime cache with the default options.
113
+ *
114
+ * Providing a record will allow you to configure the runtime cache fully.
115
+ *
116
+ * @default true
117
+ * @see https://nitro.unjs.io/guide/storage#mountpoints
118
+ * @example { driver: 'redis', host: 'localhost', port: 6379, password: 'password' }
119
+ */
120
+ runtimeCacheStorage: boolean | (Record<string, any> & {
121
+ driver: string;
122
+ });
123
+ /**
124
+ * Extra component directories that should be used to resolve components.
125
+ *
126
+ * @default ['OgImage', 'OgImageTemplate']
127
+ */
128
+ componentDirs: string[];
129
+ /**
130
+ * Manually modify the deployment compatibility.
131
+ *
132
+ * @default { browser: 'playwright', satori: 'default', wasm: 'fetch', png: 'resvg-node' }
133
+ */
134
+ runtimeCompatibility: RuntimeCompatibilitySchema;
135
+ /**
136
+ * The url of your site.
137
+ * Used to generate absolute URLs for the og:image.
138
+ *
139
+ * Note: This is only required when prerendering your site.
140
+ *
141
+ * @deprecated Provide `url` through site config instead: `{ site: { url: <value> }}`.
142
+ * This is powered by the `nuxt-site-config` module.
143
+ * @see https://github.com/harlan-zw/nuxt-site-config
144
+ */
145
+ host?: string;
146
+ /**
147
+ * The url of your site.
148
+ * Used to generate absolute URLs for the og:image.
149
+ *
150
+ * Note: This is only required when prerendering your site.
151
+ *
152
+ * @deprecated Provide `url` through site config instead: `{ site: { url: <value> }}`.
153
+ * This is powered by the `nuxt-site-config` module.
154
+ * @see https://github.com/harlan-zw/nuxt-site-config
155
+ */
156
+ siteUrl?: string;
157
+ }
158
+ interface ModuleHooks {
159
+ 'og-image:config': (config: ModuleOptions) => Promise<void> | void;
160
+ 'og-image:prerenderScreenshots': (queue: OgImageOptions[]) => Promise<void> | void;
161
+ }
162
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
163
+
164
+ export { type ModuleHooks, type ModuleOptions, _default as default };
package/dist/module.d.ts CHANGED
@@ -161,4 +161,4 @@ interface ModuleHooks {
161
161
  }
162
162
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
163
163
 
164
- export { ModuleHooks, ModuleOptions, _default as default };
164
+ export { type ModuleHooks, type ModuleOptions, _default as default };
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "ogImage",
8
- "version": "2.0.20"
8
+ "version": "2.0.22"
9
9
  }
package/dist/module.mjs CHANGED
@@ -20,7 +20,7 @@ import { createBirpcGroup } from 'birpc';
20
20
  import { stringify, parse } from 'flatted';
21
21
  import { addDependency } from 'nypm';
22
22
 
23
- const version = "2.0.20";
23
+ const version = "2.0.22";
24
24
 
25
25
  async function createBrowser() {
26
26
  if (process.dev || process.env.prerender) {
@@ -612,11 +612,14 @@ declare module 'nitropack' {
612
612
  nitroConfig.externals = defu$1(nitroConfig.externals || {}, {
613
613
  inline: [runtimeDir]
614
614
  });
615
- if (config.runtimeBrowser) {
615
+ if (!nitroCompatibility.node) {
616
616
  nitroConfig.alias = nitroConfig.alias || {};
617
- nitroConfig.alias.electron = "unenv/runtime/mock/proxy-cjs";
618
- nitroConfig.alias.bufferutil = "unenv/runtime/mock/proxy-cjs";
619
- nitroConfig.alias["utf-8-validate"] = "unenv/runtime/mock/proxy-cjs";
617
+ if (config.runtimeBrowser) {
618
+ nitroConfig.alias.electron = "unenv/runtime/mock/proxy-cjs";
619
+ nitroConfig.alias.bufferutil = "unenv/runtime/mock/proxy-cjs";
620
+ nitroConfig.alias["utf-8-validate"] = "unenv/runtime/mock/proxy-cjs";
621
+ }
622
+ nitroConfig.alias.queue = "unenv/runtime/mock/proxy-cjs";
620
623
  }
621
624
  if (nitroCompatibility.png === "resvg-wasm")
622
625
  nitroConfig.alias["@resvg/resvg-js"] = "unenv/runtime/mock/proxy-cjs";
@@ -4,7 +4,7 @@ import { normaliseOgImageOptions } from "./util.mjs";
4
4
  import { useRouter, useRuntimeConfig, useServerHead, withSiteUrl } from "#imports";
5
5
  export function defineOgImageScreenshot(options = {}) {
6
6
  const router = useRouter();
7
- const route = router?.currentRoute?.value?.path || "";
7
+ const route = router.currentRoute.value?.path || "";
8
8
  return defineOgImage({
9
9
  alt: `Web page screenshot${route ? ` of ${route}` : ""}.`,
10
10
  provider: "browser",
@@ -41,7 +41,7 @@ export async function defineOgImage(_options = {}) {
41
41
  const { defaults } = useRuntimeConfig()["nuxt-og-image"];
42
42
  const options = normaliseOgImageOptions(_options);
43
43
  const optionsWithDefault = defu(options, defaults);
44
- const src = withSiteUrl(joinURL(useRouter().currentRoute.value.path || "", "/__og_image__/og.png"));
44
+ const src = withSiteUrl(joinURL(useRouter().currentRoute.value?.path || "", "/__og_image__/og.png"));
45
45
  const meta = [
46
46
  { property: "og:image", content: src },
47
47
  { property: "og:image:width", content: optionsWithDefault.width },
@@ -0,0 +1,17 @@
1
+
2
+ import { ModuleOptions, ModuleHooks } from './module'
3
+
4
+ declare module '@nuxt/schema' {
5
+ interface NuxtConfig { ['ogImage']?: Partial<ModuleOptions> }
6
+ interface NuxtOptions { ['ogImage']?: ModuleOptions }
7
+ interface NuxtHooks extends ModuleHooks {}
8
+ }
9
+
10
+ declare module 'nuxt/schema' {
11
+ interface NuxtConfig { ['ogImage']?: Partial<ModuleOptions> }
12
+ interface NuxtOptions { ['ogImage']?: ModuleOptions }
13
+ interface NuxtHooks extends ModuleHooks {}
14
+ }
15
+
16
+
17
+ export { ModuleHooks, ModuleOptions, default } from './module'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-og-image",
3
3
  "type": "module",
4
- "version": "2.0.20",
4
+ "version": "2.0.22",
5
5
  "packageManager": "pnpm@8.7.0",
6
6
  "description": "Enlightened OG Image generation for Nuxt.",
7
7
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "@resvg/resvg-js": "^2.4.1",
32
32
  "@resvg/resvg-wasm": "^2.4.1",
33
33
  "@types/fs-extra": "^11.0.1",
34
- "birpc": "^0.2.13",
34
+ "birpc": "0.2.13",
35
35
  "chalk": "^5.3.0",
36
36
  "chrome-launcher": "^1.0.0",
37
37
  "defu": "^6.1.2",
@@ -45,7 +45,7 @@
45
45
  "launch-editor": "^2.6.0",
46
46
  "nuxt-site-config": "^1.0.11",
47
47
  "nuxt-site-config-kit": "^1.0.11",
48
- "nypm": "^0.3.1",
48
+ "nypm": "^0.3.2",
49
49
  "ofetch": "^1.3.3",
50
50
  "ohash": "^1.1.3",
51
51
  "pathe": "^1.1.1",
@@ -64,10 +64,10 @@
64
64
  },
65
65
  "devDependencies": {
66
66
  "@antfu/eslint-config": "^0.41.0",
67
- "@nuxt/devtools": "0.8.0",
68
- "@nuxt/module-builder": "^0.4.0",
67
+ "@nuxt/devtools": "0.8.2",
68
+ "@nuxt/module-builder": "^0.5.0",
69
69
  "@nuxt/test-utils": "3.7.0",
70
- "@nuxtjs/eslint-config-typescript": "^12.0.0",
70
+ "@nuxtjs/eslint-config-typescript": "^12.1.0",
71
71
  "@types/ws": "^8.5.5",
72
72
  "bumpp": "^9.2.0",
73
73
  "eslint": "8.48.0",
@@ -87,6 +87,6 @@
87
87
  "dev:build": "nuxi build .playground",
88
88
  "dev:prepare": "nuxt-module-build --stub && nuxi prepare .playground",
89
89
  "release": "bumpp package.json --commit --push --tag",
90
- "test": "vitest"
90
+ "test": "vitest build"
91
91
  }
92
92
  }
@@ -1 +0,0 @@
1
- import{g as r,H as p,I as u,n as t,o as l,c as _,s as d,_ as m}from"./entry.37e248c4.js";const f=r({__name:"IconCSS",props:{name:{type:String,required:!0},size:{type:String,default:""}},setup(c){const n=c;p(e=>({f7c88320:i.value}));const s=u(),a=t(()=>((s.nuxtIcon?.aliases||{})[n.name]||n.name).replace(/^i-/,"")),i=t(()=>`url('https://api.iconify.design/${a.value.replace(":","/")}.svg')`),o=t(()=>{if(!n.size&&typeof s.nuxtIcon?.size=="boolean"&&!s.nuxtIcon?.size)return;const e=n.size||s.nuxtIcon?.size||"1em";return String(Number(e))===e?`${e}px`:e});return(e,S)=>(l(),_("span",{style:d({width:o.value,height:o.value})},null,4))}});const x=m(f,[["__scopeId","data-v-4d447e1c"]]);export{x as default};