takumi-js 2.13.7 → 2.14.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.
- package/README.md +13 -11
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
# takumi-js
|
|
5
5
|
|
|
6
|
-
**
|
|
6
|
+
**Generate Open Graph images from JSX, HTML, and CSS without a headless browser.**
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Create social cards, banners, PNG, JPEG, WebP, SVG, and animations. The package provides an `ImageResponse` API compatible with `next/og`.
|
|
9
9
|
|
|
10
10
|
[Documentation](https://takumi.kane.tw/docs/) · [Playground](https://takumi.kane.tw/playground)
|
|
11
11
|
|
|
@@ -21,12 +21,14 @@ npm install takumi-js
|
|
|
21
21
|
|
|
22
22
|
## Quick start
|
|
23
23
|
|
|
24
|
+
Save this example as `image.tsx` and run it with `bun image.tsx`. In Node.js, compile JSX before running it.
|
|
25
|
+
|
|
24
26
|
```tsx
|
|
25
27
|
import { render } from "takumi-js";
|
|
26
28
|
import { writeFile } from "node:fs/promises";
|
|
27
29
|
|
|
28
30
|
const image = await render(
|
|
29
|
-
<div tw="w-full h-full flex items-center justify-center bg-
|
|
31
|
+
<div tw="w-full h-full flex items-center justify-center bg-linear-to-b from-blue-100 to-red-50">
|
|
30
32
|
<h1 tw="text-6xl font-bold">Hello from Takumi</h1>
|
|
31
33
|
</div>,
|
|
32
34
|
{ width: 1200, height: 630 },
|
|
@@ -35,13 +37,13 @@ const image = await render(
|
|
|
35
37
|
await writeFile("./output.png", image);
|
|
36
38
|
```
|
|
37
39
|
|
|
38
|
-
##
|
|
40
|
+
## Migrate from another renderer
|
|
39
41
|
|
|
40
|
-
| You are using | What changes
|
|
41
|
-
| :------------------------ |
|
|
42
|
-
| `satori` | Replace `satori()` with `renderSvg()`, or call `render()` for encoded image bytes. [Compare the renderers](https://takumi.kane.tw/docs/comparison-to-satori).
|
|
43
|
-
| `next/og` | Swap the `ImageResponse` import.
|
|
44
|
-
| Puppeteer for screenshots | Pass a JSX or HTML tree to `render()`. Scripts do not run, and Takumi supports less CSS than Chrome.
|
|
42
|
+
| You are using | What changes |
|
|
43
|
+
| :------------------------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
44
|
+
| `satori` | Replace `satori()` with `renderSvg()`, or call `render()` for encoded image bytes. [Compare the renderers](https://takumi.kane.tw/docs/comparison-to-satori). |
|
|
45
|
+
| `next/og` | Swap the `ImageResponse` import. Keep explicit Flexbox styles and compare the rendered output. [Read the migration guide](https://takumi.kane.tw/docs/comparison-to-satori#migrate-from-nextog). |
|
|
46
|
+
| Puppeteer for screenshots | Pass a JSX or HTML tree to `render()`. Scripts do not run, and Takumi supports less CSS than Chrome. |
|
|
45
47
|
|
|
46
48
|
## Runtime detection
|
|
47
49
|
|
|
@@ -61,7 +63,7 @@ import { ImageResponse } from "takumi-js/response";
|
|
|
61
63
|
|
|
62
64
|
export function GET() {
|
|
63
65
|
return new ImageResponse(
|
|
64
|
-
<div tw="w-full h-full flex items-center justify-center bg-
|
|
66
|
+
<div tw="w-full h-full flex items-center justify-center bg-linear-to-b from-blue-100 to-red-50">
|
|
65
67
|
<h1 tw="text-6xl font-bold">Hello from Takumi</h1>
|
|
66
68
|
</div>,
|
|
67
69
|
{ width: 1200, height: 630 },
|
|
@@ -76,7 +78,7 @@ import { renderSvg } from "takumi-js";
|
|
|
76
78
|
import { writeFile } from "node:fs/promises";
|
|
77
79
|
|
|
78
80
|
const svg = await renderSvg(
|
|
79
|
-
<div tw="w-full h-full flex items-center justify-center bg-
|
|
81
|
+
<div tw="w-full h-full flex items-center justify-center bg-linear-to-b from-blue-100 to-red-50">
|
|
80
82
|
<h1 tw="text-6xl font-bold">Hello from Takumi</h1>
|
|
81
83
|
</div>,
|
|
82
84
|
{ width: 1200, height: 630 },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "takumi-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "Render OG images from JSX, HTML, and CSS. No headless browser.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animated-webp",
|
|
@@ -238,15 +238,15 @@
|
|
|
238
238
|
"publish-lint": "attw --pack . && publint --strict ."
|
|
239
239
|
},
|
|
240
240
|
"dependencies": {
|
|
241
|
-
"@takumi-rs/core": "2.
|
|
242
|
-
"@takumi-rs/helpers": "2.
|
|
243
|
-
"@takumi-rs/wasm": "2.
|
|
241
|
+
"@takumi-rs/core": "2.14.0",
|
|
242
|
+
"@takumi-rs/helpers": "2.14.0",
|
|
243
|
+
"@takumi-rs/wasm": "2.14.0"
|
|
244
244
|
},
|
|
245
245
|
"devDependencies": {
|
|
246
|
-
"@types/bun": "^1.4.
|
|
246
|
+
"@types/bun": "^1.4.1",
|
|
247
247
|
"@types/react": "19.2.18",
|
|
248
248
|
"react": "^19.2.8",
|
|
249
|
-
"tsdown": "0.
|
|
249
|
+
"tsdown": "0.23.0",
|
|
250
250
|
"unrun": "^0.3.1"
|
|
251
251
|
},
|
|
252
252
|
"engines": {
|