cf-workers-og 1.0.1 → 2.0.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","sources":["../src/html.ts"],"sourcesContent":["/**\n * cf-workers-og (HTML entry point)\n *\n * Includes HTML string parsing support without legacy constructor behavior.\n */\n\nimport { ImageResponse as CfImageResponse } from \"@cf-wasm/og/workerd\";\nimport type { ReactNode } from \"react\";\nimport { createImageResponseClass } from \"./core/image-response\";\nimport { parseHtml } from \"./html-parser\";\n\nexport { cache } from \"@cf-wasm/og/workerd\";\n\nexport const ImageResponse = createImageResponseClass<ReactNode | string>({\n cfImageResponse: CfImageResponse,\n parseHtml,\n});\n\nexport { parseHtml } from \"./html-parser\";\n\nexport { GoogleFont, CustomFont, loadGoogleFont, createFontConfig } from \"./fonts\";\n\nexport type {\n ImageResponseOptions,\n FontConfig,\n FontWeight,\n FontStyle,\n EmojiType,\n GoogleFontOptions,\n} from \"./types\";\n"],"names":["CfImageResponse"],"mappings":";;;;;AAaO,MAAM,gBAAgB,yBAA6C;AAAA,EACxE,iBAAiBA;AAAAA,EACjB;AACF,CAAC;"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * cf-workers-og (Node.js HTML entry point)
3
+ */
4
+ import type { ReactNode } from "react";
5
+ export { cache } from "@cf-wasm/og/node";
6
+ export declare const ImageResponse: import("./core/image-response").ImageResponseClass<ReactNode>;
7
+ export { parseHtml } from "./html-parser";
8
+ export { GoogleFont, CustomFont, loadGoogleFont, createFontConfig } from "./fonts.node";
9
+ export type { ImageResponseOptions, FontConfig, FontWeight, FontStyle, EmojiType, GoogleFontOptions, } from "./types";
@@ -0,0 +1,19 @@
1
+ import { ImageResponse as ImageResponse$1 } from "@cf-wasm/og/node";
2
+ import { CustomFont, GoogleFont, cache } from "@cf-wasm/og/node";
3
+ import { c as createImageResponseClass } from "./fonts.shared-RU0Lt2Ku.js";
4
+ import { a, l } from "./fonts.shared-RU0Lt2Ku.js";
5
+ import { p as parseHtml } from "./html-parser-DRzlsDtB.js";
6
+ const ImageResponse = createImageResponseClass({
7
+ cfImageResponse: ImageResponse$1,
8
+ parseHtml
9
+ });
10
+ export {
11
+ CustomFont,
12
+ GoogleFont,
13
+ ImageResponse,
14
+ cache,
15
+ a as createFontConfig,
16
+ l as loadGoogleFont,
17
+ parseHtml
18
+ };
19
+ //# sourceMappingURL=html.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.node.js","sources":["../src/html.node.ts"],"sourcesContent":["/**\n * cf-workers-og (Node.js HTML entry point)\n */\n\nimport { ImageResponse as CfImageResponse } from \"@cf-wasm/og/node\";\nimport type { ReactNode } from \"react\";\nimport { createImageResponseClass } from \"./core/image-response\";\nimport { parseHtml } from \"./html-parser\";\n\nexport { cache } from \"@cf-wasm/og/node\";\n\nexport const ImageResponse = createImageResponseClass<ReactNode | string>({\n cfImageResponse: CfImageResponse,\n parseHtml,\n});\n\nexport { parseHtml } from \"./html-parser\";\n\nexport { GoogleFont, CustomFont, loadGoogleFont, createFontConfig } from \"./fonts.node\";\n\nexport type {\n ImageResponseOptions,\n FontConfig,\n FontWeight,\n FontStyle,\n EmojiType,\n GoogleFontOptions,\n} from \"./types\";\n"],"names":["CfImageResponse"],"mappings":";;;;;AAWO,MAAM,gBAAgB,yBAA6C;AAAA,EACxE,iBAAiBA;AAAAA,EACjB;AACF,CAAC;"}
@@ -1,64 +1,3 @@
1
1
  import type { ReactNode } from "react";
2
- import type { ImageResponseOptions } from "./types";
3
2
  export { cache } from "@cf-wasm/og/workerd";
4
- /**
5
- * Generate an OG image Response from a React element or HTML string.
6
- *
7
- * This is a wrapper around @cf-wasm/og that provides:
8
- * - Backwards compatibility with workers-og API
9
- * - HTML string parsing support
10
- * - Simplified options interface
11
- *
12
- * @example JSX usage (recommended):
13
- * ```tsx
14
- * import { ImageResponse, cache } from 'cf-workers-og';
15
- *
16
- * export default {
17
- * async fetch(request, env, ctx) {
18
- * cache.setExecutionContext(ctx);
19
- *
20
- * return ImageResponse.create(
21
- * <div style={{ display: 'flex', background: '#000' }}>
22
- * <h1 style={{ color: 'white' }}>Hello World</h1>
23
- * </div>,
24
- * { width: 1200, height: 630 }
25
- * );
26
- * }
27
- * };
28
- * ```
29
- *
30
- * @example HTML string usage:
31
- * ```typescript
32
- * import { ImageResponse, parseHtml } from 'cf-workers-og';
33
- *
34
- * const html = '<div style="display: flex;"><h1>Hello</h1></div>';
35
- * return ImageResponse.create(parseHtml(html), options);
36
- * ```
37
- */
38
- export declare class ImageResponse extends Response {
39
- /**
40
- * Create an OG image Response (async, recommended).
41
- *
42
- * @param element - React element or HTML string to render
43
- * @param options - Image generation options
44
- * @returns Promise<Response> with the generated image
45
- */
46
- static create(element: ReactNode | string, options?: ImageResponseOptions): Promise<Response>;
47
- /**
48
- * Constructor for backwards compatibility with workers-og.
49
- *
50
- * Note: This returns a Promise, not an ImageResponse instance.
51
- * For TypeScript, use `ImageResponse.create()` instead.
52
- *
53
- * @param element - React element or HTML string to render
54
- * @param options - Image generation options
55
- * @returns Response (via Promise trick for constructor)
56
- *
57
- * @example
58
- * ```typescript
59
- * // Works like old workers-og
60
- * return new ImageResponse(element, options);
61
- * ```
62
- */
63
- constructor(element: ReactNode | string, options?: ImageResponseOptions);
64
- }
3
+ export declare const ImageResponse: import("./core/image-response").ImageResponseClass<ReactNode>;
@@ -1,64 +1,3 @@
1
1
  import type { ReactNode } from "react";
2
- import type { ImageResponseOptions } from "./types";
3
2
  export { cache } from "@cf-wasm/og/node";
4
- /**
5
- * Generate an OG image Response from a React element or HTML string.
6
- *
7
- * This is a wrapper around @cf-wasm/og that provides:
8
- * - Backwards compatibility with workers-og API
9
- * - HTML string parsing support
10
- * - Simplified options interface
11
- *
12
- * @example JSX usage (recommended):
13
- * ```tsx
14
- * import { ImageResponse, cache } from 'cf-workers-og';
15
- *
16
- * export default {
17
- * async fetch(request, env, ctx) {
18
- * cache.setExecutionContext(ctx);
19
- *
20
- * return ImageResponse.create(
21
- * <div style={{ display: 'flex', background: '#000' }}>
22
- * <h1 style={{ color: 'white' }}>Hello World</h1>
23
- * </div>,
24
- * { width: 1200, height: 630 }
25
- * );
26
- * }
27
- * };
28
- * ```
29
- *
30
- * @example HTML string usage:
31
- * ```typescript
32
- * import { ImageResponse, parseHtml } from 'cf-workers-og';
33
- *
34
- * const html = '<div style="display: flex;"><h1>Hello</h1></div>';
35
- * return ImageResponse.create(parseHtml(html), options);
36
- * ```
37
- */
38
- export declare class ImageResponse extends Response {
39
- /**
40
- * Create an OG image Response (async, recommended).
41
- *
42
- * @param element - React element or HTML string to render
43
- * @param options - Image generation options
44
- * @returns Promise<Response> with the generated image
45
- */
46
- static create(element: ReactNode | string, options?: ImageResponseOptions): Promise<Response>;
47
- /**
48
- * Constructor for backwards compatibility with workers-og.
49
- *
50
- * Note: This returns a Promise, not an ImageResponse instance.
51
- * For TypeScript, use `ImageResponse.create()` instead.
52
- *
53
- * @param element - React element or HTML string to render
54
- * @param options - Image generation options
55
- * @returns Response (via Promise trick for constructor)
56
- *
57
- * @example
58
- * ```typescript
59
- * // Works like old workers-og
60
- * return new ImageResponse(element, options);
61
- * ```
62
- */
63
- constructor(element: ReactNode | string, options?: ImageResponseOptions);
64
- }
3
+ export declare const ImageResponse: import("./core/image-response").ImageResponseClass<ReactNode>;
package/dist/index.d.ts CHANGED
@@ -28,6 +28,5 @@
28
28
  * @packageDocumentation
29
29
  */
30
30
  export { ImageResponse, cache } from "./image-response";
31
- export { parseHtml } from "./html-parser";
32
31
  export { GoogleFont, CustomFont, loadGoogleFont, createFontConfig } from "./fonts";
33
32
  export type { ImageResponseOptions, FontConfig, FontWeight, FontStyle, EmojiType, GoogleFontOptions, } from "./types";
package/dist/index.js CHANGED
@@ -1,131 +1,16 @@
1
1
  import { ImageResponse as ImageResponse$1 } from "@cf-wasm/og/workerd";
2
2
  import { CustomFont, GoogleFont, cache } from "@cf-wasm/og/workerd";
3
- import { p as parseHtml } from "./html-parser-DRzlsDtB.js";
4
- class ImageResponse extends Response {
5
- /**
6
- * Create an OG image Response (async, recommended).
7
- *
8
- * @param element - React element or HTML string to render
9
- * @param options - Image generation options
10
- * @returns Promise<Response> with the generated image
11
- */
12
- static async create(element, options = {}) {
13
- const reactElement = typeof element === "string" ? parseHtml(element) : element;
14
- const {
15
- width = 1200,
16
- height = 630,
17
- format = "png",
18
- fonts,
19
- emoji,
20
- debug = false,
21
- headers = {},
22
- status = 200,
23
- statusText
24
- } = options;
25
- const response = await ImageResponse$1.async(reactElement, {
26
- width,
27
- height,
28
- format,
29
- fonts: fonts ?? [],
30
- emoji
31
- });
32
- const responseHeaders = new Headers(response.headers);
33
- responseHeaders.set(
34
- "Content-Type",
35
- format === "svg" ? "image/svg+xml" : "image/png"
36
- );
37
- responseHeaders.set(
38
- "Cache-Control",
39
- debug ? "no-cache, no-store" : "public, immutable, no-transform, max-age=31536000"
40
- );
41
- for (const [key, value] of Object.entries(headers)) {
42
- responseHeaders.set(key, value);
43
- }
44
- return new Response(response.body, {
45
- headers: responseHeaders,
46
- status,
47
- statusText
48
- });
49
- }
50
- /**
51
- * Constructor for backwards compatibility with workers-og.
52
- *
53
- * Note: This returns a Promise, not an ImageResponse instance.
54
- * For TypeScript, use `ImageResponse.create()` instead.
55
- *
56
- * @param element - React element or HTML string to render
57
- * @param options - Image generation options
58
- * @returns Response (via Promise trick for constructor)
59
- *
60
- * @example
61
- * ```typescript
62
- * // Works like old workers-og
63
- * return new ImageResponse(element, options);
64
- * ```
65
- */
66
- constructor(element, options = {}) {
67
- super(null);
68
- return ImageResponse.create(element, options);
69
- }
70
- }
71
- async function loadGoogleFont(options) {
72
- const { family, weight, text } = options;
73
- const params = {
74
- family: `${encodeURIComponent(family)}${weight ? `:wght@${weight}` : ""}`
75
- };
76
- if (text) {
77
- params.text = text;
78
- } else {
79
- params.subset = "latin";
80
- }
81
- const cssUrl = `https://fonts.googleapis.com/css2?${Object.keys(params).map((key) => `${key}=${params[key]}`).join("&")}`;
82
- const cfCache = typeof caches !== "undefined" ? caches.default : void 0;
83
- let cssResponse;
84
- if (cfCache) {
85
- cssResponse = await cfCache.match(cssUrl);
86
- }
87
- if (!cssResponse) {
88
- cssResponse = await fetch(cssUrl, {
89
- headers: {
90
- // Request TTF format (works better with Satori)
91
- "User-Agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1"
92
- }
93
- });
94
- if (cfCache) {
95
- const cacheResponse = new Response(cssResponse.body, cssResponse);
96
- cacheResponse.headers.set("Cache-Control", "s-maxage=3600");
97
- await cfCache.put(cssUrl, cacheResponse.clone());
98
- cssResponse = cacheResponse;
99
- }
100
- }
101
- const css = await cssResponse.text();
102
- const fontUrlMatch = css.match(
103
- /src: url\(([^)]+)\) format\(['"]?(opentype|truetype)['"]?\)/
104
- );
105
- if (!fontUrlMatch?.[1]) {
106
- throw new Error(
107
- `Could not find font URL for "${family}" (weight: ${weight ?? "default"})`
108
- );
109
- }
110
- const fontUrl = fontUrlMatch[1];
111
- const fontResponse = await fetch(fontUrl);
112
- return fontResponse.arrayBuffer();
113
- }
114
- function createFontConfig(name, data, weight = 400, style = "normal") {
115
- return {
116
- name,
117
- data,
118
- weight,
119
- style
120
- };
121
- }
3
+ import { c as createImageResponseClass } from "./fonts.shared-RU0Lt2Ku.js";
4
+ import { a, l } from "./fonts.shared-RU0Lt2Ku.js";
5
+ const ImageResponse = createImageResponseClass({
6
+ cfImageResponse: ImageResponse$1
7
+ });
122
8
  export {
123
9
  CustomFont,
124
10
  GoogleFont,
125
11
  ImageResponse,
126
12
  cache,
127
- createFontConfig,
128
- loadGoogleFont,
129
- parseHtml
13
+ a as createFontConfig,
14
+ l as loadGoogleFont
130
15
  };
131
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/image-response.ts","../src/fonts.ts"],"sourcesContent":["import { ImageResponse as CfImageResponse } from \"@cf-wasm/og/workerd\";\nimport type { ReactNode } from \"react\";\nimport { parseHtml } from \"./html-parser\";\nimport type { ImageResponseOptions } from \"./types\";\n\n// Re-export cache from @cf-wasm/og for font caching\nexport { cache } from \"@cf-wasm/og/workerd\";\n\n/**\n * Generate an OG image Response from a React element or HTML string.\n *\n * This is a wrapper around @cf-wasm/og that provides:\n * - Backwards compatibility with workers-og API\n * - HTML string parsing support\n * - Simplified options interface\n *\n * @example JSX usage (recommended):\n * ```tsx\n * import { ImageResponse, cache } from 'cf-workers-og';\n *\n * export default {\n * async fetch(request, env, ctx) {\n * cache.setExecutionContext(ctx);\n *\n * return ImageResponse.create(\n * <div style={{ display: 'flex', background: '#000' }}>\n * <h1 style={{ color: 'white' }}>Hello World</h1>\n * </div>,\n * { width: 1200, height: 630 }\n * );\n * }\n * };\n * ```\n *\n * @example HTML string usage:\n * ```typescript\n * import { ImageResponse, parseHtml } from 'cf-workers-og';\n *\n * const html = '<div style=\"display: flex;\"><h1>Hello</h1></div>';\n * return ImageResponse.create(parseHtml(html), options);\n * ```\n */\nexport class ImageResponse extends Response {\n /**\n * Create an OG image Response (async, recommended).\n *\n * @param element - React element or HTML string to render\n * @param options - Image generation options\n * @returns Promise<Response> with the generated image\n */\n static async create(\n element: ReactNode | string,\n options: ImageResponseOptions = {}\n ): Promise<Response> {\n // Parse HTML strings\n const reactElement =\n typeof element === \"string\" ? parseHtml(element) : element;\n\n const {\n width = 1200,\n height = 630,\n format = \"png\",\n fonts,\n emoji,\n debug = false,\n headers = {},\n status = 200,\n statusText,\n } = options;\n\n // Use @cf-wasm/og to generate the image\n // Note: @cf-wasm/og requires fonts to be an array, not undefined\n const response = await CfImageResponse.async(reactElement, {\n width,\n height,\n format,\n fonts: fonts ?? [],\n emoji,\n });\n\n // Build response headers\n const responseHeaders = new Headers(response.headers);\n\n // Set content type\n responseHeaders.set(\n \"Content-Type\",\n format === \"svg\" ? \"image/svg+xml\" : \"image/png\"\n );\n\n // Set cache headers\n responseHeaders.set(\n \"Cache-Control\",\n debug\n ? \"no-cache, no-store\"\n : \"public, immutable, no-transform, max-age=31536000\"\n );\n\n // Apply custom headers\n for (const [key, value] of Object.entries(headers)) {\n responseHeaders.set(key, value);\n }\n\n return new Response(response.body, {\n headers: responseHeaders,\n status,\n statusText,\n });\n }\n\n /**\n * Constructor for backwards compatibility with workers-og.\n *\n * Note: This returns a Promise, not an ImageResponse instance.\n * For TypeScript, use `ImageResponse.create()` instead.\n *\n * @param element - React element or HTML string to render\n * @param options - Image generation options\n * @returns Response (via Promise trick for constructor)\n *\n * @example\n * ```typescript\n * // Works like old workers-og\n * return new ImageResponse(element, options);\n * ```\n */\n constructor(element: ReactNode | string, options: ImageResponseOptions = {}) {\n // Must call super() since we extend Response\n super(null);\n // Return a Promise from the constructor (workers-og pattern)\n // This hack allows `new ImageResponse()` to work like workers-og\n return ImageResponse.create(element, options) as unknown as ImageResponse;\n }\n}\n","import type { FontWeight, GoogleFontOptions } from \"./types\";\n\n// Re-export GoogleFont from @cf-wasm/og for the new API\nexport { GoogleFont, CustomFont } from \"@cf-wasm/og/workerd\";\n\n/**\n * Load a Google Font and return its data as an ArrayBuffer.\n *\n * This is a backwards-compatible function for users migrating from workers-og.\n * For new code, prefer using `GoogleFont` class from `@cf-wasm/og`.\n *\n * @param options - Font loading options\n * @returns Font data as ArrayBuffer\n *\n * @example\n * ```typescript\n * const fontData = await loadGoogleFont({\n * family: 'Inter',\n * weight: 700,\n * });\n *\n * return ImageResponse.create(element, {\n * fonts: [{\n * name: 'Inter',\n * data: fontData,\n * weight: 700,\n * style: 'normal',\n * }],\n * });\n * ```\n *\n * @deprecated Use `GoogleFont` class instead for better caching:\n * ```typescript\n * import { GoogleFont, cache } from 'cf-workers-og';\n * cache.setExecutionContext(ctx);\n * const fonts = [new GoogleFont('Inter', { weight: 700 })];\n * ```\n */\nexport async function loadGoogleFont(\n options: GoogleFontOptions\n): Promise<ArrayBuffer> {\n const { family, weight, text } = options;\n\n // Build Google Fonts CSS URL\n const params: Record<string, string> = {\n family: `${encodeURIComponent(family)}${weight ? `:wght@${weight}` : \"\"}`,\n };\n\n if (text) {\n params.text = text;\n } else {\n params.subset = \"latin\";\n }\n\n const cssUrl = `https://fonts.googleapis.com/css2?${Object.keys(params)\n .map((key) => `${key}=${params[key]}`)\n .join(\"&\")}`;\n\n // Try to use Cloudflare's cache\n const cfCache =\n typeof caches !== \"undefined\"\n ? (caches as unknown as { default: Cache }).default\n : undefined;\n\n let cssResponse: Response | undefined;\n\n if (cfCache) {\n cssResponse = await cfCache.match(cssUrl);\n }\n\n if (!cssResponse) {\n cssResponse = await fetch(cssUrl, {\n headers: {\n // Request TTF format (works better with Satori)\n \"User-Agent\":\n \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1\",\n },\n });\n\n if (cfCache) {\n // Clone and add cache headers\n const cacheResponse = new Response(cssResponse.body, cssResponse);\n cacheResponse.headers.set(\"Cache-Control\", \"s-maxage=3600\");\n await cfCache.put(cssUrl, cacheResponse.clone());\n cssResponse = cacheResponse;\n }\n }\n\n const css = await cssResponse.text();\n\n // Extract font URL from CSS\n const fontUrlMatch = css.match(\n /src: url\\(([^)]+)\\) format\\(['\"]?(opentype|truetype)['\"]?\\)/\n );\n\n if (!fontUrlMatch?.[1]) {\n throw new Error(\n `Could not find font URL for \"${family}\" (weight: ${weight ?? \"default\"})`\n );\n }\n\n const fontUrl = fontUrlMatch[1];\n\n // Fetch the actual font file\n const fontResponse = await fetch(fontUrl);\n return fontResponse.arrayBuffer();\n}\n\n/**\n * Create a font configuration object for ImageResponse.\n *\n * Helper function to build the font config with proper types.\n *\n * @param name - Font family name\n * @param data - Font data as ArrayBuffer\n * @param weight - Font weight (optional, defaults to 400)\n * @param style - Font style (optional, defaults to 'normal')\n */\nexport function createFontConfig(\n name: string,\n data: ArrayBuffer,\n weight: FontWeight = 400,\n style: \"normal\" | \"italic\" = \"normal\"\n) {\n return {\n name,\n data,\n weight,\n style,\n };\n}\n"],"names":["CfImageResponse"],"mappings":"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"}
1
+ {"version":3,"file":"index.js","sources":["../src/image-response.ts"],"sourcesContent":["import { ImageResponse as CfImageResponse } from \"@cf-wasm/og/workerd\";\nimport type { ReactNode } from \"react\";\nimport { createImageResponseClass } from \"./core/image-response\";\n\nexport { cache } from \"@cf-wasm/og/workerd\";\n\nexport const ImageResponse = createImageResponseClass<ReactNode>({\n cfImageResponse: CfImageResponse,\n});\n"],"names":["CfImageResponse"],"mappings":";;;;AAMO,MAAM,gBAAgB,yBAAoC;AAAA,EAC/D,iBAAiBA;AACnB,CAAC;"}
@@ -7,6 +7,5 @@
7
7
  * @packageDocumentation
8
8
  */
9
9
  export { ImageResponse, cache } from "./image-response.node";
10
- export { parseHtml } from "./html-parser";
11
10
  export { GoogleFont, CustomFont, loadGoogleFont, createFontConfig } from "./fonts.node";
12
11
  export type { ImageResponseOptions, FontConfig, FontWeight, FontStyle, EmojiType, GoogleFontOptions, } from "./types";
@@ -1,131 +1,16 @@
1
1
  import { ImageResponse as ImageResponse$1 } from "@cf-wasm/og/node";
2
2
  import { CustomFont, GoogleFont, cache } from "@cf-wasm/og/node";
3
- import { p as parseHtml } from "./html-parser-DRzlsDtB.js";
4
- class ImageResponse extends Response {
5
- /**
6
- * Create an OG image Response (async, recommended).
7
- *
8
- * @param element - React element or HTML string to render
9
- * @param options - Image generation options
10
- * @returns Promise<Response> with the generated image
11
- */
12
- static async create(element, options = {}) {
13
- const reactElement = typeof element === "string" ? parseHtml(element) : element;
14
- const {
15
- width = 1200,
16
- height = 630,
17
- format = "png",
18
- fonts,
19
- emoji,
20
- debug = false,
21
- headers = {},
22
- status = 200,
23
- statusText
24
- } = options;
25
- const response = await ImageResponse$1.async(reactElement, {
26
- width,
27
- height,
28
- format,
29
- fonts: fonts ?? [],
30
- emoji
31
- });
32
- const responseHeaders = new Headers(response.headers);
33
- responseHeaders.set(
34
- "Content-Type",
35
- format === "svg" ? "image/svg+xml" : "image/png"
36
- );
37
- responseHeaders.set(
38
- "Cache-Control",
39
- debug ? "no-cache, no-store" : "public, immutable, no-transform, max-age=31536000"
40
- );
41
- for (const [key, value] of Object.entries(headers)) {
42
- responseHeaders.set(key, value);
43
- }
44
- return new Response(response.body, {
45
- headers: responseHeaders,
46
- status,
47
- statusText
48
- });
49
- }
50
- /**
51
- * Constructor for backwards compatibility with workers-og.
52
- *
53
- * Note: This returns a Promise, not an ImageResponse instance.
54
- * For TypeScript, use `ImageResponse.create()` instead.
55
- *
56
- * @param element - React element or HTML string to render
57
- * @param options - Image generation options
58
- * @returns Response (via Promise trick for constructor)
59
- *
60
- * @example
61
- * ```typescript
62
- * // Works like old workers-og
63
- * return new ImageResponse(element, options);
64
- * ```
65
- */
66
- constructor(element, options = {}) {
67
- super(null);
68
- return ImageResponse.create(element, options);
69
- }
70
- }
71
- async function loadGoogleFont(options) {
72
- const { family, weight, text } = options;
73
- const params = {
74
- family: `${encodeURIComponent(family)}${weight ? `:wght@${weight}` : ""}`
75
- };
76
- if (text) {
77
- params.text = text;
78
- } else {
79
- params.subset = "latin";
80
- }
81
- const cssUrl = `https://fonts.googleapis.com/css2?${Object.keys(params).map((key) => `${key}=${params[key]}`).join("&")}`;
82
- const cfCache = typeof caches !== "undefined" ? caches.default : void 0;
83
- let cssResponse;
84
- if (cfCache) {
85
- cssResponse = await cfCache.match(cssUrl);
86
- }
87
- if (!cssResponse) {
88
- cssResponse = await fetch(cssUrl, {
89
- headers: {
90
- // Request TTF format (works better with Satori)
91
- "User-Agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1"
92
- }
93
- });
94
- if (cfCache) {
95
- const cacheResponse = new Response(cssResponse.body, cssResponse);
96
- cacheResponse.headers.set("Cache-Control", "s-maxage=3600");
97
- await cfCache.put(cssUrl, cacheResponse.clone());
98
- cssResponse = cacheResponse;
99
- }
100
- }
101
- const css = await cssResponse.text();
102
- const fontUrlMatch = css.match(
103
- /src: url\(([^)]+)\) format\(['"]?(opentype|truetype)['"]?\)/
104
- );
105
- if (!fontUrlMatch?.[1]) {
106
- throw new Error(
107
- `Could not find font URL for "${family}" (weight: ${weight ?? "default"})`
108
- );
109
- }
110
- const fontUrl = fontUrlMatch[1];
111
- const fontResponse = await fetch(fontUrl);
112
- return fontResponse.arrayBuffer();
113
- }
114
- function createFontConfig(name, data, weight = 400, style = "normal") {
115
- return {
116
- name,
117
- data,
118
- weight,
119
- style
120
- };
121
- }
3
+ import { c as createImageResponseClass } from "./fonts.shared-RU0Lt2Ku.js";
4
+ import { a, l } from "./fonts.shared-RU0Lt2Ku.js";
5
+ const ImageResponse = createImageResponseClass({
6
+ cfImageResponse: ImageResponse$1
7
+ });
122
8
  export {
123
9
  CustomFont,
124
10
  GoogleFont,
125
11
  ImageResponse,
126
12
  cache,
127
- createFontConfig,
128
- loadGoogleFont,
129
- parseHtml
13
+ a as createFontConfig,
14
+ l as loadGoogleFont
130
15
  };
131
16
  //# sourceMappingURL=index.node.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.node.js","sources":["../src/image-response.node.ts","../src/fonts.node.ts"],"sourcesContent":["import { ImageResponse as CfImageResponse } from \"@cf-wasm/og/node\";\nimport type { ReactNode } from \"react\";\nimport { parseHtml } from \"./html-parser\";\nimport type { ImageResponseOptions } from \"./types\";\n\n// Re-export cache from @cf-wasm/og for font caching\nexport { cache } from \"@cf-wasm/og/node\";\n\n/**\n * Generate an OG image Response from a React element or HTML string.\n *\n * This is a wrapper around @cf-wasm/og that provides:\n * - Backwards compatibility with workers-og API\n * - HTML string parsing support\n * - Simplified options interface\n *\n * @example JSX usage (recommended):\n * ```tsx\n * import { ImageResponse, cache } from 'cf-workers-og';\n *\n * export default {\n * async fetch(request, env, ctx) {\n * cache.setExecutionContext(ctx);\n *\n * return ImageResponse.create(\n * <div style={{ display: 'flex', background: '#000' }}>\n * <h1 style={{ color: 'white' }}>Hello World</h1>\n * </div>,\n * { width: 1200, height: 630 }\n * );\n * }\n * };\n * ```\n *\n * @example HTML string usage:\n * ```typescript\n * import { ImageResponse, parseHtml } from 'cf-workers-og';\n *\n * const html = '<div style=\"display: flex;\"><h1>Hello</h1></div>';\n * return ImageResponse.create(parseHtml(html), options);\n * ```\n */\nexport class ImageResponse extends Response {\n /**\n * Create an OG image Response (async, recommended).\n *\n * @param element - React element or HTML string to render\n * @param options - Image generation options\n * @returns Promise<Response> with the generated image\n */\n static async create(\n element: ReactNode | string,\n options: ImageResponseOptions = {}\n ): Promise<Response> {\n // Parse HTML strings\n const reactElement =\n typeof element === \"string\" ? parseHtml(element) : element;\n\n const {\n width = 1200,\n height = 630,\n format = \"png\",\n fonts,\n emoji,\n debug = false,\n headers = {},\n status = 200,\n statusText,\n } = options;\n\n // Use @cf-wasm/og to generate the image\n // Note: @cf-wasm/og/node requires fonts to be an array, not undefined\n const response = await CfImageResponse.async(reactElement, {\n width,\n height,\n format,\n fonts: fonts ?? [],\n emoji,\n });\n\n // Build response headers\n const responseHeaders = new Headers(response.headers);\n\n // Set content type\n responseHeaders.set(\n \"Content-Type\",\n format === \"svg\" ? \"image/svg+xml\" : \"image/png\"\n );\n\n // Set cache headers\n responseHeaders.set(\n \"Cache-Control\",\n debug\n ? \"no-cache, no-store\"\n : \"public, immutable, no-transform, max-age=31536000\"\n );\n\n // Apply custom headers\n for (const [key, value] of Object.entries(headers)) {\n responseHeaders.set(key, value);\n }\n\n return new Response(response.body, {\n headers: responseHeaders,\n status,\n statusText,\n });\n }\n\n /**\n * Constructor for backwards compatibility with workers-og.\n *\n * Note: This returns a Promise, not an ImageResponse instance.\n * For TypeScript, use `ImageResponse.create()` instead.\n *\n * @param element - React element or HTML string to render\n * @param options - Image generation options\n * @returns Response (via Promise trick for constructor)\n *\n * @example\n * ```typescript\n * // Works like old workers-og\n * return new ImageResponse(element, options);\n * ```\n */\n constructor(element: ReactNode | string, options: ImageResponseOptions = {}) {\n // Must call super() since we extend Response\n super(null);\n // Return a Promise from the constructor (workers-og pattern)\n // This hack allows `new ImageResponse()` to work like workers-og\n return ImageResponse.create(element, options) as unknown as ImageResponse;\n }\n}\n","import type { FontWeight, GoogleFontOptions } from \"./types\";\n\n// Re-export GoogleFont from @cf-wasm/og/node for Node.js environments\nexport { GoogleFont, CustomFont } from \"@cf-wasm/og/node\";\n\n/**\n * Load a Google Font and return its data as an ArrayBuffer.\n *\n * This is a backwards-compatible function for users migrating from workers-og.\n * For new code, prefer using `GoogleFont` class from `@cf-wasm/og`.\n *\n * @param options - Font loading options\n * @returns Font data as ArrayBuffer\n *\n * @example\n * ```typescript\n * const fontData = await loadGoogleFont({\n * family: 'Inter',\n * weight: 700,\n * });\n *\n * return ImageResponse.create(element, {\n * fonts: [{\n * name: 'Inter',\n * data: fontData,\n * weight: 700,\n * style: 'normal',\n * }],\n * });\n * ```\n *\n * @deprecated Use `GoogleFont` class instead for better caching:\n * ```typescript\n * import { GoogleFont, cache } from 'cf-workers-og';\n * cache.setExecutionContext(ctx);\n * const fonts = [new GoogleFont('Inter', { weight: 700 })];\n * ```\n */\nexport async function loadGoogleFont(\n options: GoogleFontOptions\n): Promise<ArrayBuffer> {\n const { family, weight, text } = options;\n\n // Build Google Fonts CSS URL\n const params: Record<string, string> = {\n family: `${encodeURIComponent(family)}${weight ? `:wght@${weight}` : \"\"}`,\n };\n\n if (text) {\n params.text = text;\n } else {\n params.subset = \"latin\";\n }\n\n const cssUrl = `https://fonts.googleapis.com/css2?${Object.keys(params)\n .map((key) => `${key}=${params[key]}`)\n .join(\"&\")}`;\n\n // Try to use Cloudflare's cache\n const cfCache =\n typeof caches !== \"undefined\"\n ? (caches as unknown as { default: Cache }).default\n : undefined;\n\n let cssResponse: Response | undefined;\n\n if (cfCache) {\n cssResponse = await cfCache.match(cssUrl);\n }\n\n if (!cssResponse) {\n cssResponse = await fetch(cssUrl, {\n headers: {\n // Request TTF format (works better with Satori)\n \"User-Agent\":\n \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1\",\n },\n });\n\n if (cfCache) {\n // Clone and add cache headers\n const cacheResponse = new Response(cssResponse.body, cssResponse);\n cacheResponse.headers.set(\"Cache-Control\", \"s-maxage=3600\");\n await cfCache.put(cssUrl, cacheResponse.clone());\n cssResponse = cacheResponse;\n }\n }\n\n const css = await cssResponse.text();\n\n // Extract font URL from CSS\n const fontUrlMatch = css.match(\n /src: url\\(([^)]+)\\) format\\(['\"]?(opentype|truetype)['\"]?\\)/\n );\n\n if (!fontUrlMatch?.[1]) {\n throw new Error(\n `Could not find font URL for \"${family}\" (weight: ${weight ?? \"default\"})`\n );\n }\n\n const fontUrl = fontUrlMatch[1];\n\n // Fetch the actual font file\n const fontResponse = await fetch(fontUrl);\n return fontResponse.arrayBuffer();\n}\n\n/**\n * Create a font configuration object for ImageResponse.\n *\n * Helper function to build the font config with proper types.\n *\n * @param name - Font family name\n * @param data - Font data as ArrayBuffer\n * @param weight - Font weight (optional, defaults to 400)\n * @param style - Font style (optional, defaults to 'normal')\n */\nexport function createFontConfig(\n name: string,\n data: ArrayBuffer,\n weight: FontWeight = 400,\n style: \"normal\" | \"italic\" = \"normal\"\n) {\n return {\n name,\n data,\n weight,\n style,\n };\n}\n"],"names":["CfImageResponse"],"mappings":"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"}
1
+ {"version":3,"file":"index.node.js","sources":["../src/image-response.node.ts"],"sourcesContent":["import { ImageResponse as CfImageResponse } from \"@cf-wasm/og/node\";\nimport type { ReactNode } from \"react\";\nimport { createImageResponseClass } from \"./core/image-response\";\n\nexport { cache } from \"@cf-wasm/og/node\";\n\nexport const ImageResponse = createImageResponseClass<ReactNode>({\n cfImageResponse: CfImageResponse,\n});\n"],"names":["CfImageResponse"],"mappings":";;;;AAMO,MAAM,gBAAgB,yBAAoC;AAAA,EAC/D,iBAAiBA;AACnB,CAAC;"}
package/dist/types.d.ts CHANGED
@@ -11,7 +11,7 @@ export type FontWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
11
11
  */
12
12
  export type FontStyle = "normal" | "italic";
13
13
  /**
14
- * Font configuration for custom fonts
14
+ * Font configuration for manually loaded fonts
15
15
  */
16
16
  export interface FontConfig {
17
17
  name: string;
@@ -19,6 +19,19 @@ export interface FontConfig {
19
19
  weight?: FontWeight;
20
20
  style?: FontStyle;
21
21
  }
22
+ /**
23
+ * Font configuration with async data loading (used by GoogleFont/CustomFont classes)
24
+ */
25
+ export interface AsyncFontConfig {
26
+ name: string;
27
+ data: ArrayBuffer | Promise<ArrayBuffer>;
28
+ weight?: FontWeight;
29
+ style?: FontStyle;
30
+ }
31
+ /**
32
+ * Union type for all supported font configurations
33
+ */
34
+ export type FontInput = FontConfig | AsyncFontConfig;
22
35
  /**
23
36
  * Options for ImageResponse
24
37
  */
@@ -39,9 +52,10 @@ export interface ImageResponseOptions {
39
52
  */
40
53
  format?: "png" | "svg";
41
54
  /**
42
- * Fonts to use for rendering text
55
+ * Fonts to use for rendering text.
56
+ * Accepts FontConfig (manual loading) or GoogleFont/CustomFont classes.
43
57
  */
44
- fonts?: FontConfig[];
58
+ fonts?: FontInput[];
45
59
  /**
46
60
  * Emoji provider for rendering emoji
47
61
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-workers-og",
3
- "version": "1.0.1",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "description": "Generate Open Graph images on Cloudflare Workers with Vite support",
6
6
  "main": "./dist/index.js",
@@ -20,6 +20,58 @@
20
20
  "types": "./dist/index.d.ts",
21
21
  "import": "./dist/index.js"
22
22
  }
23
+ },
24
+ "./node": {
25
+ "types": "./dist/index.node.d.ts",
26
+ "import": "./dist/index.node.js"
27
+ },
28
+ "./workerd": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js"
31
+ },
32
+ "./html": {
33
+ "node": {
34
+ "types": "./dist/html.node.d.ts",
35
+ "import": "./dist/html.node.js"
36
+ },
37
+ "workerd": {
38
+ "types": "./dist/html.d.ts",
39
+ "import": "./dist/html.js"
40
+ },
41
+ "default": {
42
+ "types": "./dist/html.d.ts",
43
+ "import": "./dist/html.js"
44
+ }
45
+ },
46
+ "./node/html": {
47
+ "types": "./dist/html.node.d.ts",
48
+ "import": "./dist/html.node.js"
49
+ },
50
+ "./workerd/html": {
51
+ "types": "./dist/html.d.ts",
52
+ "import": "./dist/html.js"
53
+ },
54
+ "./compat": {
55
+ "node": {
56
+ "types": "./dist/compat.node.d.ts",
57
+ "import": "./dist/compat.node.js"
58
+ },
59
+ "workerd": {
60
+ "types": "./dist/compat.d.ts",
61
+ "import": "./dist/compat.js"
62
+ },
63
+ "default": {
64
+ "types": "./dist/compat.d.ts",
65
+ "import": "./dist/compat.js"
66
+ }
67
+ },
68
+ "./node/compat": {
69
+ "types": "./dist/compat.node.d.ts",
70
+ "import": "./dist/compat.node.js"
71
+ },
72
+ "./workerd/compat": {
73
+ "types": "./dist/compat.d.ts",
74
+ "import": "./dist/compat.js"
23
75
  }
24
76
  },
25
77
  "files": [