satori 0.24.1 → 0.26.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:
@@ -116,6 +137,12 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
116
137
  </thead>
117
138
  <tbody>
118
139
 
140
+ <tr>
141
+ <td colspan="2"><b>CSS Variables</b></td>
142
+ <td>Supported, including <code>--var-name</code> declaration and <code>var(--var-name)</code> usage with fallback values</td>
143
+ <td><a href="https://og-playground.vercel.app/?share=rVLRTsIwFP2V5hIzTbY4wBjTIC9oos-a8MJLt95tha4lXQfOZf9uOxwRlTeeentO7zntuW0h1RyBwoyL3UoRUtlG4mPb-pqQIIpsgSVGqZbaBJQEnJlNImsMwsOJAkVeWEeM4_hqAPeC2-IXxkW1laxxaCbxY0B9_SQMplZo5TjnU5dqYJkUuXq1WFaeQmXRDNS6rqzImoV2oPL-p3TC0k1udK34wt_c8aMsy46urutNfCIl08kPaPn9lvs47tGuW6m5L3w4x2RIn4VT3DFzfZLPTeBa5i8opQ7JUhvJZ7eu8x-Jv7lqw1TuUr2E-lmJaBKSUTaNx_H4vNqwQgh668dSAW2hHynQBxcNHGYO9M5vOCZ1DjRjssIQsNRr8d5s_Zey-37ndHy4z2WCHKg1NXYhWJa4E4W333tz6L4A">Example</a></td>
144
+ </tr>
145
+
119
146
  <tr>
120
147
  <td colspan="2"><code>display</code></td>
121
148
  <td><code>flex</code>, <code>contents</code>, <code>none</code>, default to <code>flex</code></td>
@@ -304,6 +331,7 @@ Note:
304
331
  2. There is no `z-index` support in SVG. Elements that come later in the document will be painted on top.
305
332
  3. `calc` isn't supported.
306
333
  4. `currentColor` support is only available for the `color` property.
334
+ 5. CSS variables (custom properties) are supported, including inheritance, fallback values, and nested variables.
307
335
 
308
336
  ### Language and Typography
309
337
 
@@ -344,8 +372,6 @@ Multiple fonts can be passed to Satori and used in `fontFamily`.
344
372
  > [!TIP]
345
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)
346
374
 
347
-
348
-
349
375
  #### Emojis
350
376
 
351
377
  To render custom images for specific graphemes, you can use `graphemeImages` option to map the grapheme to an image source: