satori 0.25.0 → 0.28.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 CHANGED
@@ -51,6 +51,27 @@ Under the hood, it handles layout calculation, font, typography and more, to gen
51
51
  Satori only accepts JSX elements that are pure and stateless. You can use a subset of HTML
52
52
  elements (see section below), or custom React components, but React APIs such as `useState`, `useEffect`, `dangerouslySetInnerHTML` are not supported.
53
53
 
54
+ #### Experimental: builtin JSX support
55
+
56
+ Satori has an experimental JSX runtime that you can use without having to install React. You can enable it on a per-file basis with [`@jsxImportSource` pragmas](https://www.typescriptlang.org/tsconfig/#jsxImportSource). In the future, it will autocomplete only the subset of HTML elements and CSS properties that Satori supports for better type-safety.
57
+
58
+ ```tsx
59
+ /** @jsxRuntime automatic */
60
+ /** @jsxImportSource satori/jsx */
61
+
62
+ import satori from 'satori';
63
+ import { FC, JSXNode } from 'satori/jsx';
64
+
65
+ const MyComponent: FC<{ children: JSXNode }> = ({ children }) => (
66
+ <div style={{ color: 'black' }}>{children}</div>
67
+ )
68
+
69
+ const svg = await satori(
70
+ <MyComponent>hello, world</MyComponent>,
71
+ options,
72
+ )
73
+ ```
74
+
54
75
  #### Use without JSX
55
76
 
56
77
  If you don't have JSX transpiler enabled, you can simply pass [React-elements-like objects](https://reactjs.org/docs/introducing-jsx.html) that have `type`, `props.children` and `props.style` (and other properties too) directly:
@@ -179,7 +200,7 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
179
200
 
180
201
  <tr><td rowspan="11">Flex</td></tr>
181
202
  <tr><td><code>flexDirection</code></td><td><code>column</code>, <code>row</code>, <code>row-reverse</code>, <code>column-reverse</code>, default to <code>row</code></td><td></td></tr>
182
- <tr><td><code>flexWrap</code></td><td><code>wrap</code>, <code>nowrap</code>, <code>wrap-reverse</code>, default to <code>wrap</code></td><td></td></tr>
203
+ <tr><td><code>flexWrap</code></td><td><code>wrap</code>, <code>nowrap</code>, <code>wrap-reverse</code>, default to <code>nowrap</code></td><td></td></tr>
183
204
  <tr><td><code>flexGrow</code></td><td>Supported</td><td></td></tr>
184
205
  <tr><td><code>flexShrink</code></td><td>Supported</td><td></td></tr>
185
206
  <tr><td><code>flexBasis</code></td><td>Supported except for <code>auto</code></td><td></td></tr>
@@ -351,8 +372,6 @@ Multiple fonts can be passed to Satori and used in `fontFamily`.
351
372
  > [!TIP]
352
373
  > We recommend you define global fonts instead of creating a new object and pass it to satori for better performance, if your fonts do not change. [Read it for more detail](https://github.com/vercel/satori/issues/590)
353
374
 
354
-
355
-
356
375
  #### Emojis
357
376
 
358
377
  To render custom images for specific graphemes, you can use `graphemeImages` option to map the grapheme to an image source: