nuxt-og-image 6.7.6 → 6.7.7

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/LICENSE.md +6 -0
  2. package/dist/chunks/decode.mjs +1087 -0
  3. package/dist/chunks/tw4.mjs +1 -1
  4. package/dist/chunks/uno.mjs +2 -2
  5. package/dist/module.d.ts +1 -1
  6. package/dist/module.json +1 -1
  7. package/dist/module.mjs +1 -1
  8. package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.js +5 -6
  9. package/dist/runtime/server/og-image/bindings/font-assets/node.d.ts +1 -1
  10. package/dist/runtime/server/og-image/bindings/font-assets/node.js +2 -3
  11. package/dist/runtime/server/og-image/browser/screenshot.js +2 -1
  12. package/dist/runtime/server/og-image/font-source.d.ts +3 -12
  13. package/dist/runtime/server/og-image/font-source.js +1 -4
  14. package/dist/runtime/server/og-image/fonts.d.ts +0 -7
  15. package/dist/runtime/server/og-image/fonts.js +1 -1
  16. package/dist/runtime/server/og-image/takumi/renderer.js +2 -2
  17. package/dist/runtime/server/routes/resolve.js +2 -1
  18. package/dist/runtime/server/util/fetchLocalAsset.d.ts +1 -1
  19. package/dist/runtime/server/util/fetchLocalAsset.js +2 -1
  20. package/dist/runtime/types.d.ts +1 -1
  21. package/dist/shared/{nuxt-og-image.BIbfn5xQ.mjs → nuxt-og-image.BMHzg1Vz.mjs} +227 -76
  22. package/package.json +21 -22
  23. package/dist/chunks/tw4.cjs +0 -493
  24. package/dist/chunks/uno.cjs +0 -249
  25. package/dist/cli.cjs +0 -1345
  26. package/dist/cli.d.cts +0 -1
  27. package/dist/content.cjs +0 -21
  28. package/dist/content.d.cts +0 -16
  29. package/dist/module.cjs +0 -39
  30. package/dist/module.d.cts +0 -219
  31. package/dist/shared/nuxt-og-image.CMYbz66P.cjs +0 -193
  32. package/dist/shared/nuxt-og-image.CdpC3njh.cjs +0 -5898
package/dist/cli.d.cts DELETED
@@ -1 +0,0 @@
1
-
package/dist/content.cjs DELETED
@@ -1,21 +0,0 @@
1
- 'use strict';
2
-
3
- const content = require('nuxtseo-shared/content');
4
- const zod = require('zod');
5
-
6
- const { defineSchema, asCollection, schema } = content.createContentSchemaFactory({
7
- fieldName: "ogImage",
8
- label: "og-image",
9
- docsUrl: "https://nuxtseo.com/og-image/integrations/content",
10
- buildSchema: (_z) => _z.object({
11
- url: _z.string().optional(),
12
- component: _z.string().optional(),
13
- props: _z.record(_z.string(), _z.any())
14
- }).optional()
15
- }, zod.z);
16
- const ogImageSchema = schema.shape.ogImage;
17
-
18
- exports.asOgImageCollection = asCollection;
19
- exports.defineOgImageSchema = defineSchema;
20
- exports.ogImageSchema = ogImageSchema;
21
- exports.schema = schema;
@@ -1,16 +0,0 @@
1
- import * as nuxtseo_shared_content from 'nuxtseo-shared/content';
2
- import { z } from 'zod';
3
-
4
- declare const defineSchema: (options?: nuxtseo_shared_content.ContentSchemaOptions | undefined) => z.ZodOptional<z.ZodObject<{
5
- url: z.ZodOptional<z.ZodString>;
6
- component: z.ZodOptional<z.ZodString>;
7
- props: z.ZodRecord<z.ZodString, z.ZodAny>;
8
- }, z.core.$strip>>;
9
- declare const asCollection: <T>(collection: any) => T;
10
- declare const schema: z.ZodObject<{
11
- [x: string]: any;
12
- }, z.core.$strip>;
13
-
14
- declare const ogImageSchema: any;
15
-
16
- export { asCollection as asOgImageCollection, defineSchema as defineOgImageSchema, ogImageSchema, schema };
package/dist/module.cjs DELETED
@@ -1,39 +0,0 @@
1
- 'use strict';
2
-
3
- require('node:crypto');
4
- require('node:fs');
5
- require('node:fs/promises');
6
- require('node:url');
7
- require('@nuxt/kit');
8
- require('defu');
9
- require('fnv1a-64');
10
- require('nuxt-site-config/kit');
11
- require('nuxtseo-shared/kit');
12
- require('pathe');
13
- require('pkg-types');
14
- require('std-env');
15
- const module$1 = require('./shared/nuxt-og-image.CdpC3njh.cjs');
16
- require('../dist/runtime/logger.js');
17
- require('oxc-walker');
18
- require('chrome-launcher');
19
- require('nypm');
20
- require('nuxtseo-shared/devtools');
21
- require('unstorage');
22
- require('unstorage/drivers/fs-lite');
23
- require('../dist/runtime/server/og-image/utils/css.js');
24
- require('magic-string');
25
- require('strip-literal');
26
- require('ufo');
27
- require('unplugin');
28
- require('@vue/compiler-sfc');
29
- require('ofetch');
30
- require('ultrahtml');
31
- require('../dist/runtime/server/og-image/core/transforms/emojis/emoji-utils.js');
32
- require('exsolve');
33
- require('./shared/nuxt-og-image.CMYbz66P.cjs');
34
- require('magicast');
35
- require('magicast/helpers');
36
-
37
-
38
-
39
- module.exports = module$1.module;
package/dist/module.d.cts DELETED
@@ -1,219 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { ResvgRenderOptions } from '@resvg/resvg-js';
3
- import { SatoriOptions } from 'satori';
4
- import { SharpOptions } from 'sharp';
5
- import { OgImageComponent, RendererType, OgImageRuntimeConfig, OgImageOptions, CompatibilityFlagEnvOverrides, BrowserConfig } from '../dist/runtime/types.js';
6
- export { OgImageComponent, OgImageOptions, OgImageRenderEventContext, OgImageRuntimeConfig, RuntimeCompatibilitySchema, VNode } from '../dist/runtime/types.js';
7
-
8
- interface ModuleOptions {
9
- /**
10
- * Whether the og:image images should be generated.
11
- *
12
- * @default true
13
- */
14
- enabled: boolean;
15
- /**
16
- * Default data used within the payload to generate the OG Image.
17
- *
18
- * You can use this to change the default template, image sizing and more.
19
- *
20
- * @default { width: 1200, height: 600, extension: 'png', emojis: 'noto', cacheMaxAgeSeconds: 60 * 60 * 24 * 3 }
21
- */
22
- defaults: Omit<OgImageOptions, 'component' | 'renderer' | 'props' | 'url' | 'html' | 'key' | 'cacheKey' | '_query' | '_hash' | 'socialPreview'>;
23
- /**
24
- * Options to pass to satori.
25
- *
26
- * @see https://github.com/vercel/satori/blob/main/src/satori.ts#L18
27
- */
28
- satoriOptions?: Partial<SatoriOptions>;
29
- /**
30
- * Options to pass to resvg.
31
- *
32
- * @see https://github.com/yisibl/resvg-js/blob/main/wasm/index.d.ts#L39
33
- */
34
- resvgOptions?: Partial<ResvgRenderOptions>;
35
- /**
36
- * Options to pass to sharp.
37
- *
38
- * @see https://sharp.pixelplumbing.com/api-constructor
39
- */
40
- sharpOptions?: true | Partial<SharpOptions>;
41
- /**
42
- * Enables debug logs and a debug endpoint.
43
- *
44
- * @false false
45
- */
46
- debug: boolean;
47
- /**
48
- * Configure the runtime cache storage for generated OG images.
49
- * - `true` - Use Nitro's default cache storage (default)
50
- * - `false` - Disable caching
51
- * - `string` - Use a custom storage mount key (e.g., `'redis'`). You must mount the storage yourself via a Nitro plugin.
52
- * - `object` - Provide a driver config that the module will mount for you (build-time only)
53
- *
54
- * @default true
55
- * @see https://nitro.unjs.io/guide/storage#mountpoints
56
- * @example runtimeCacheStorage: 'redis' // Use your own mounted 'redis' storage
57
- * @example runtimeCacheStorage: { driver: 'redis', host: 'localhost', port: 6379 }
58
- */
59
- runtimeCacheStorage: boolean | string | (Record<string, any> & {
60
- driver: string;
61
- });
62
- /**
63
- * Custom version string for cache key namespacing.
64
- *
65
- * By default, the module version is used which invalidates cache on upgrades.
66
- * Set a static value like `'v1'` to persist cache across module updates.
67
- * Set to `false` to disable versioning entirely.
68
- *
69
- * @default module version
70
- * @example cacheVersion: 'v1'
71
- * @example cacheVersion: false
72
- */
73
- cacheVersion?: string | false;
74
- /**
75
- * Extra component directories that should be used to resolve components.
76
- *
77
- * @default ['OgImage', 'OgImageCommunity', 'og-image', 'OgImageTemplate']
78
- */
79
- componentDirs: string[];
80
- /**
81
- * Manually modify the compatibility.
82
- */
83
- compatibility?: CompatibilityFlagEnvOverrides;
84
- /**
85
- * Only allow the prerendering and dev runtimes to generate images.
86
- */
87
- zeroRuntime?: boolean;
88
- /**
89
- * Enable persistent build cache for CI environments.
90
- * Caches rendered images to disk so they persist between CI runs.
91
- *
92
- * @default false
93
- * @example true
94
- * @example { base: '.cache/og-image' }
95
- */
96
- buildCache?: boolean | {
97
- base?: string;
98
- };
99
- /**
100
- * Warn about OG Image components missing renderer suffix in dev mode.
101
- * Set to false to suppress warnings for legacy/test components.
102
- *
103
- * @default true
104
- */
105
- warnMissingSuffix?: boolean;
106
- /**
107
- * @deprecated Runtime always uses Iconify API now. Build-time uses local icons if available.
108
- * Use `defaults.emojis: false` to disable emoji support entirely.
109
- */
110
- emojiStrategy?: 'auto' | 'local' | 'fetch';
111
- /**
112
- * Default cache duration in seconds for generated OG images.
113
- *
114
- * Controls the internal storage TTL, HTTP Cache-Control headers, and the
115
- * auto-configured SWR route rule. Can be overridden per-image via
116
- * `defineOgImage`'s `cacheMaxAgeSeconds` option.
117
- *
118
- * @default 60 * 60 * 24 * 3 (3 days)
119
- */
120
- cacheMaxAgeSeconds?: number;
121
- /**
122
- * Font subsets to download when resolving missing font families via fontless.
123
- *
124
- * Fonts from @nuxt/fonts are always included with all their subsets (devanagari,
125
- * cyrillic, etc.). This option only controls which subsets fontless downloads when
126
- * supplementing missing families for the Satori renderer.
127
- *
128
- * @default ['latin']
129
- * @example ['latin', 'latin-ext', 'devanagari']
130
- */
131
- fontSubsets?: string[];
132
- /**
133
- * Browser renderer configuration.
134
- *
135
- * When using browser-based rendering (screenshots), configure the browser provider.
136
- * For Cloudflare deployments, specify the browser binding name.
137
- *
138
- * @example { provider: 'cloudflare', binding: 'BROWSER' }
139
- */
140
- browser?: BrowserConfig;
141
- /**
142
- * Security limits for image generation. Prevents denial of service via
143
- * oversized dimensions, unbounded DPR, or long-running renders.
144
- */
145
- security?: {
146
- /** Maximum allowed width or height in pixels. @default 2048 */
147
- maxDimension?: number;
148
- /** Maximum device pixel ratio (takumi renderer). @default 2 */
149
- maxDpr?: number;
150
- /** Render timeout in milliseconds. Returns 408 on timeout. @default 15000 */
151
- renderTimeout?: number;
152
- /**
153
- * Per-image fetch timeout in milliseconds.
154
- *
155
- * Applies to remote `<img>` / `background-image` fetches done while resolving templates.
156
- * A stalled resource can otherwise consume the entire `renderTimeout` budget, which
157
- * shows up as near-total request timeouts on edge platforms (e.g. Cloudflare Workers
158
- * when the image URL routes back through the same worker).
159
- *
160
- * @default 3000
161
- */
162
- imageFetchTimeout?: number;
163
- /**
164
- * Maximum allowed length (in characters) for the query string on runtime OG image requests.
165
- * Requests exceeding this limit receive a 400 response.
166
- *
167
- * Set to a number to enable (e.g. `2048`). Leave `null` to disable.
168
- *
169
- * @default null
170
- */
171
- maxQueryParamSize?: number | null;
172
- /**
173
- * Restrict runtime image generation to requests whose Host header matches allowed hosts.
174
- * - `true`: only allow requests whose Host matches the site config URL host
175
- * - `string[]`: allow the site config URL host plus these additional origins
176
- * - `false` (default): no host restriction
177
- *
178
- * Uses h3's `getRequestHost` with `X-Forwarded-Host` support for reverse proxies.
179
- * Prerendering and dev mode are never restricted.
180
- *
181
- * @default false
182
- */
183
- restrictRuntimeImagesToOrigin?: boolean | string[];
184
- /**
185
- * Secret for URL signing. When set, all runtime OG image URLs include a
186
- * keyed hash signature and the handler rejects requests with missing or
187
- * invalid signatures.
188
- *
189
- * Leave unset to auto-generate a per-build secret (signing on by default).
190
- * Set an explicit, stable string for rolling or multi-instance deploys, or
191
- * `false` to disable signing entirely. Generate one with:
192
- * `npx nuxt-og-image generate-secret`
193
- *
194
- * Required (explicitly) when `strict` is enabled.
195
- */
196
- secret?: string | false;
197
- /**
198
- * Enable strict security mode. When enabled:
199
- * - `secret` is required (URL signing)
200
- * - The `html` option is disabled (prevents SSRF via inline HTML injection)
201
- * - `maxQueryParamSize` defaults to `2048`
202
- * - `restrictRuntimeImagesToOrigin` defaults to `true`
203
- *
204
- * @default false
205
- */
206
- strict?: boolean;
207
- };
208
- }
209
- interface ModuleHooks {
210
- 'nuxt-og-image:components': (ctx: {
211
- components: OgImageComponent[];
212
- detectedRenderers: Set<RendererType>;
213
- }) => Promise<void> | void;
214
- 'nuxt-og-image:runtime-config': (config: OgImageRuntimeConfig) => Promise<void> | void;
215
- }
216
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
217
-
218
- export = _default;
219
- export type { ModuleHooks, ModuleOptions };
@@ -1,193 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('node:fs');
4
- const magicast = require('magicast');
5
- const helpers = require('magicast/helpers');
6
- const pathe = require('pathe');
7
- const logger_js = require('../../dist/runtime/logger.js');
8
-
9
- function parseFontString(font) {
10
- const parts = font.split(":");
11
- if (parts.length === 3) {
12
- return {
13
- name: parts[0] || font,
14
- style: parts[1] === "ital" ? "italic" : "normal",
15
- weight: Number.parseInt(parts[2] || "") || 400
16
- };
17
- }
18
- return {
19
- name: parts[0] || font,
20
- weight: Number.parseInt(parts[1] || "") || 400,
21
- style: "normal"
22
- };
23
- }
24
- function groupFontsByFamily(fonts) {
25
- const families = /* @__PURE__ */ new Map();
26
- for (const font of fonts) {
27
- const parsed = parseFontString(font);
28
- const existing = families.get(parsed.name);
29
- if (existing) {
30
- existing.weights.add(parsed.weight);
31
- existing.styles.add(parsed.style);
32
- } else {
33
- families.set(parsed.name, {
34
- weights: /* @__PURE__ */ new Set([parsed.weight]),
35
- styles: /* @__PURE__ */ new Set([parsed.style])
36
- });
37
- }
38
- }
39
- return Array.from(families.entries(), ([name, { weights, styles }]) => ({
40
- name,
41
- weights: [...weights].toSorted((a, b) => a - b),
42
- styles: [...styles]
43
- }));
44
- }
45
- async function migrateFontsConfig(rootDir) {
46
- const configPaths = [
47
- "nuxt.config.ts",
48
- "nuxt.config.js",
49
- "nuxt.config.mjs"
50
- ];
51
- let configPath;
52
- for (const p of configPaths) {
53
- const fullPath = pathe.join(rootDir, p);
54
- if (fs.existsSync(fullPath)) {
55
- configPath = fullPath;
56
- break;
57
- }
58
- }
59
- if (!configPath) {
60
- return { migrated: false, message: "No nuxt.config found" };
61
- }
62
- const mod = await magicast.loadFile(configPath);
63
- const config = mod.exports.default;
64
- if (!config?.ogImage?.fonts) {
65
- return { migrated: false, message: "No ogImage.fonts config found" };
66
- }
67
- const oldFonts = config.ogImage.fonts;
68
- if (!Array.isArray(oldFonts) || oldFonts.length === 0) {
69
- return { migrated: false, message: "ogImage.fonts is empty or invalid" };
70
- }
71
- const groupedFonts = groupFontsByFamily(oldFonts);
72
- if (!config.fonts) {
73
- config.fonts = {};
74
- }
75
- if (!config.fonts.families) {
76
- config.fonts.families = [];
77
- }
78
- const existingFamilies = config.fonts.families;
79
- for (const font of groupedFonts) {
80
- const existing = existingFamilies.find((f) => f.name === font.name);
81
- if (existing) {
82
- const existingWeights = new Set(existing.weights || []);
83
- for (const w of font.weights) {
84
- existingWeights.add(w);
85
- }
86
- existing.weights = [...existingWeights].toSorted((a, b) => a - b);
87
- if (font.styles.includes("italic")) {
88
- const existingStyles = new Set(existing.styles || ["normal"]);
89
- existingStyles.add("italic");
90
- existing.styles = [...existingStyles];
91
- }
92
- existing.global = true;
93
- } else {
94
- const family = {
95
- name: font.name,
96
- weights: font.weights,
97
- global: true
98
- };
99
- if (font.styles.includes("italic")) {
100
- family.styles = font.styles;
101
- }
102
- existingFamilies.push(family);
103
- }
104
- }
105
- helpers.addNuxtModule(mod, "@nuxt/fonts");
106
- delete config.ogImage.fonts;
107
- if (Object.keys(config.ogImage).length === 0) {
108
- delete config.ogImage;
109
- }
110
- await magicast.writeFile(mod, configPath);
111
- const familyNames = groupedFonts.map((f) => f.name).join(", ");
112
- return {
113
- migrated: true,
114
- message: `Migrated fonts (${familyNames}) from ogImage.fonts to @nuxt/fonts`
115
- };
116
- }
117
- async function migrateDefaultsComponent(rootDir) {
118
- const configPaths = [
119
- "nuxt.config.ts",
120
- "nuxt.config.js",
121
- "nuxt.config.mjs"
122
- ];
123
- let configPath;
124
- for (const cp of configPaths) {
125
- const fullPath = pathe.join(rootDir, cp);
126
- if (fs.existsSync(fullPath)) {
127
- configPath = fullPath;
128
- break;
129
- }
130
- }
131
- if (!configPath)
132
- return { migrated: false, componentName: null, message: "No nuxt.config found" };
133
- const mod = await magicast.loadFile(configPath);
134
- const config = mod.exports.default;
135
- if (!config?.ogImage?.defaults?.component)
136
- return { migrated: false, componentName: null, message: "No defaults.component found" };
137
- const componentName = String(config.ogImage.defaults.component);
138
- delete config.ogImage.defaults.component;
139
- if (config.ogImage.defaults && Object.keys(config.ogImage.defaults).length === 0)
140
- delete config.ogImage.defaults;
141
- if (config.ogImage && Object.keys(config.ogImage).length === 0)
142
- delete config.ogImage;
143
- await magicast.writeFile(mod, configPath);
144
- return { migrated: true, componentName, message: `Removed defaults.component: '${componentName}'` };
145
- }
146
- async function promptFontsMigration(rootDir) {
147
- logger_js.logger.info("");
148
- logger_js.logger.info("Detected deprecated ogImage.fonts configuration.");
149
- logger_js.logger.info("");
150
- logger_js.logger.info("Inter fonts now work out of the box without any configuration.");
151
- logger_js.logger.info("For custom fonts, use @nuxt/fonts:");
152
- logger_js.logger.info("");
153
- logger_js.logger.info("Before:");
154
- logger_js.logger.info(" ogImage: {");
155
- logger_js.logger.info(" fonts: ['Inter:400', 'Inter:700']");
156
- logger_js.logger.info(" }");
157
- logger_js.logger.info("");
158
- logger_js.logger.info("After (Inter only): Remove the config entirely \u2014 it works by default.");
159
- logger_js.logger.info("");
160
- logger_js.logger.info("After (custom fonts):");
161
- logger_js.logger.info(" modules: ['@nuxt/fonts', 'nuxt-og-image'],");
162
- logger_js.logger.info(" fonts: {");
163
- logger_js.logger.info(" families: [");
164
- logger_js.logger.info(" { name: 'Roboto', weights: [400, 700], global: true }");
165
- logger_js.logger.info(" ]");
166
- logger_js.logger.info(" }");
167
- logger_js.logger.info("");
168
- const migrate = await logger_js.logger.prompt("Automatically migrate nuxt.config?", {
169
- type: "confirm",
170
- initial: true
171
- });
172
- if (migrate) {
173
- const result = await migrateFontsConfig(rootDir).catch((err) => {
174
- logger_js.logger.error(`Migration failed: ${err.message}`);
175
- return { migrated: false, message: err.message };
176
- });
177
- if (result.migrated) {
178
- logger_js.logger.success(result.message);
179
- logger_js.logger.info("");
180
- logger_js.logger.info("Please install @nuxt/fonts:");
181
- logger_js.logger.info(" npm add @nuxt/fonts");
182
- } else {
183
- logger_js.logger.warn(`Could not migrate: ${result.message}`);
184
- logger_js.logger.info("Please migrate manually.");
185
- }
186
- } else {
187
- logger_js.logger.info("Skipping automatic migration. Please migrate manually.");
188
- }
189
- }
190
-
191
- exports.migrateDefaultsComponent = migrateDefaultsComponent;
192
- exports.migrateFontsConfig = migrateFontsConfig;
193
- exports.promptFontsMigration = promptFontsMigration;