satori 0.36.0 → 0.37.1

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
@@ -173,7 +173,7 @@ declare module 'react' {
173
173
 
174
174
  ### CSS
175
175
 
176
- Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Native, and it’s **not** a complete CSS implementation. However, it supports a subset of the spec that covers most common CSS features:
176
+ Satori uses [Taffy](https://github.com/DioxusLabs/taffy) to lay out Flexbox, Grid and block layouts, and it’s **not** a complete CSS implementation. However, it supports a subset of the spec that covers most common CSS features:
177
177
 
178
178
  <table>
179
179
  <thead>
@@ -194,7 +194,7 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
194
194
 
195
195
  <tr>
196
196
  <td colspan="2"><code>display</code></td>
197
- <td><code>flex</code>, <code>block</code>, <code>contents</code>, <code>none</code>, <code>-webkit-box</code>, default to <code>flex</code>. Use <code>flex</code>, <code>contents</code>, or <code>none</code> for <code>div</code> elements with multiple child nodes.</td>
197
+ <td><code>flex</code>, <code>block</code>, <code>grid</code>, <code>contents</code>, <code>none</code>, <code>-webkit-box</code>, default to <code>flex</code>. Use <code>flex</code>, <code>block</code>, <code>grid</code>, <code>contents</code>, or <code>none</code> for <code>div</code> elements with multiple child nodes. Children of <code>block</code> elements are stacked vertically, including text, and margins collapse like in CSS.</td>
198
198
  <td></td>
199
199
  </tr>
200
200
 
@@ -264,11 +264,20 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
264
264
  <tr><td><code>flexGrow</code></td><td>Supported</td><td></td></tr>
265
265
  <tr><td><code>flexShrink</code></td><td>Supported</td><td></td></tr>
266
266
  <tr><td><code>flexBasis</code></td><td>Supported except for <code>auto</code></td><td></td></tr>
267
- <tr><td><code>alignItems</code></td><td><code>stretch</code>, <code>center</code>, <code>flex-start</code>, <code>flex-end</code>, <code>baseline</code>, <code>normal</code>, default to <code>stretch</code></td><td></td></tr>
267
+ <tr><td><code>alignItems</code></td><td><code>stretch</code>, <code>center</code>, <code>start</code>, <code>end</code>, <code>flex-start</code>, <code>flex-end</code>, <code>baseline</code>, <code>normal</code>, default to <code>stretch</code></td><td></td></tr>
268
268
  <tr><td><code>alignContent</code></td><td>Supported</td><td></td></tr>
269
269
  <tr><td><code>alignSelf</code></td><td>Supported</td><td></td></tr>
270
270
  <tr><td><code>justifyContent</code></td><td>Supported</td><td></td></tr>
271
- <tr><td><code>gap</code></td><td>Supported</td><td></td></tr>
271
+ <tr><td><code>gap</code></td><td>Supported, with one or two values. Also <code>rowGap</code> and <code>columnGap</code></td><td></td></tr>
272
+
273
+ <tr><td rowspan="8">Grid</td></tr>
274
+ <tr><td><code>gridTemplateColumns</code>, <code>gridTemplateRows</code></td><td>Lengths, percentages, <code>fr</code>, <code>auto</code>, <code>min-content</code>, <code>max-content</code>, <code>minmax()</code>, <code>fit-content()</code>, <code>repeat()</code> with a count, <code>auto-fill</code> or <code>auto-fit</code>, and line names</td><td></td></tr>
275
+ <tr><td><code>gridTemplateAreas</code></td><td>Supported</td><td></td></tr>
276
+ <tr><td><code>gridAutoColumns</code>, <code>gridAutoRows</code></td><td>Supported</td><td></td></tr>
277
+ <tr><td><code>gridAutoFlow</code></td><td><code>row</code>, <code>column</code> and <code>dense</code>, default to <code>row</code></td><td></td></tr>
278
+ <tr><td><code>gridRow</code>, <code>gridColumn</code>, <code>gridArea</code></td><td>Line numbers, spans, line names and area names. Also the longhands, e.g. <code>gridColumnStart</code></td><td></td></tr>
279
+ <tr><td><code>justifyItems</code>, <code>justifySelf</code></td><td><code>stretch</code>, <code>center</code>, <code>start</code>, <code>end</code>, <code>left</code>, <code>right</code>, <code>baseline</code>, <code>normal</code></td><td></td></tr>
280
+ <tr><td>Shorthands (<code>grid</code>, <code>gridTemplate</code>)</td><td>Not supported</td><td></td></tr>
272
281
 
273
282
  <tr><td rowspan="6">Font</td></tr>
274
283
  <tr><td><code>fontFamily</code></td><td>Supported</td><td></td></tr>
@@ -296,16 +305,17 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
296
305
  <tr><td><code>backgroundImage</code></td><td><code>linear-gradient</code>, <code>repeating-linear-gradient</code>, <code>radial-gradient</code>, <code>repeating-radial-gradient</code>, <code>url</code>, single value</td><td></td></tr>
297
306
  <tr><td><code>backgroundPosition</code></td><td>Support single value</td><td></td></tr>
298
307
  <tr><td><code>backgroundSize</code></td><td>Support <code>cover</code>, <code>contain</code>, <code>auto</code>, and two-value sizes i.e. <code>10px 20%</code></td><td><a href="https://og-playground.vercel.app/?share=ZZXXjqNIFIZfpeWb2RW9Itik3tmRwAQDJgeDNTfkHEwwYdTvvnhGWq003HDOqZ8fDlX11Y9D2Ebx4ePwNcqf35u3t2Fcq_ifHz9e8dtbFudpNn68wRD0_qsy59GY_b8Q-GGZ9u3UREbcxf4u_tK0f_U_4y-_acx8i3dF2Dajnze_jwu1n74EU1_9Efmj_5G_CmDXpH8H_hBjp_fcoVVjhiQ-ban9Ukw7Y-10j3j9ldtnyttvND6LubMHTABVrO4YJypeXGSdBtuwwCRWANMRpy7W49jmUFvuyU0fnmZeduAiZ6ZZaueUXM0V5VDBNs2OtfX6MimW0iTTBD0JeYbFeSOrpLGR5_iMkrHGYSAGEFJl77xRCsjNDC_MmIHV8KDOdsboszJAXchEZifrokEtSyrT5cUkbkifODIuyKC2oblXy8yAqyt-VLcJr8UhYJc2PGoWrW4dppebvMnexThypKZD-IRPx2dFjjnj3eAxqMU1XLTipNKFhrv-1Te3ZWE41aKHtHUogVtC98ZlniyqI9lkcOS5xQnRSlTV0-tKaHckalSGADnQlda0i12YNG7wcO3J-IrGTiWLXtviZ6tc1LDpTrmyhe5uybE1CSYwMHinsikaLkdSepmcxdufvxhlwGcYZFBUF9yqXt9fIT5MC0L3H99JUi4UOqz4PPHkFsq72zM8WjYnYGqRWukUlGh4gcFkBi7zyiOuA0c-D4-VW-zWoSnBLSFHV2qkeLMWcwGd7jWpWVCi5AgElPbN7TB1vJpQbagUW4USzTgmUwZs5ckWiKtbeoovGVYKVZYplg37_NjrsGiWVdUBSYO2HADFotULPEJ1kl-3_QMDRpkEjjNQJkq5rpYMXk6gMN14z9Nh9lIhURHsoqlSm5QUTb2sFTs1ag4JjyqDx8eRoJY24GdbW3E7mrfC2jYpulOIfsX9q8znWkYJIU1Lpl3RHbd1jvHq2hVJ27w8Hu0DQtHereC9qSlsH2pBzdY8HbMclOVBaxkCNQPbCS280YnTjDj1vRVdXk2GTcHUtcLIC2kuZmc-F0CjT5O0bxLguUZX0-46gocAOemyO9ud16EQRYoEzoUHKbUT2c6Z6iVo8ikGz_c28GlfMMZFXId-3ndkk55Y6pEpLu00ERw5DiE5ibPw6Jg0pxiXMCDPY5Xv0ooyy07SOY2ItUJA0GcAc95NKKS17ERr91XBFBjo7kTiSi-nM-MjY9_WyXH_6BRO6OxOPK9k9bA925tNd9HmcmRzKI6YXmAFWWNmoOixTTtukLU1GRFeZIuaqTM24QNH063N0Ubq86kAJkdSfl7B89Dt0_KkVXVtMRYgb4Wsogggys-O-89XYZGtuDtasBrKY6ZmsIg42314VQNix3wBqQC70a0ODgxY3BbqKvgnxsscyioJTTAUoJHSrXUiwWwtLqtAakcVCILGBrn4C1p0-WKUzlCXhIAKTFUJTXzV9zXLWaU56fX5_OfvsDy3VdvvsJyzfIy_vEY_P783376CO8u_fW8O74e2G_O2GQ4fPw4_wX34IHZwH35h_fBxeiVRHEzp4SPxqyF-P8R1W-TW2r3OhHH-me0-yc5rtg7i6PAx9lP8-X4Y_WBXZHFVtXPbV9Hh818">Example</a></td></tr>
299
- <tr><td><code>backgroundClip</code></td><td><code>border-box</code>, <code>text</code></td><td></td></tr>
308
+ <tr><td><code>backgroundClip</code></td><td><code>border-box</code>, <code>padding-box</code>, <code>content-box</code>, <code>text</code>, also as <code>WebkitBackgroundClip</code></td><td></td></tr>
300
309
  <tr><td><code>backgroundRepeat</code></td><td><code>repeat</code>, <code>repeat-x</code>, <code>repeat-y</code>, <code>no-repeat</code>, defaults to <code>repeat</code></td><td></td></tr>
301
310
 
302
- <tr><td rowspan="7"><code>transform</code></td></tr>
311
+ <tr><td rowspan="8"><code>transform</code></td></tr>
303
312
  <tr><td>Translate (<code>translate</code>, <code>translateX</code>, <code>translateY</code>, <code>translateZ</code>, <code>translate3d</code>)</td><td>Supported, with <code>px</code>, <code>em</code>, <code>rem</code>, <code>vw</code> and <code>vh</code> lengths, and percentages of the element's size along X and Y</td><td></td></tr>
304
313
  <tr><td>Rotate (<code>rotate</code>, <code>rotateX</code>, <code>rotateY</code>, <code>rotateZ</code>, <code>rotate3d</code>)</td><td>Supported, with <code>deg</code>, <code>rad</code>, <code>grad</code> and <code>turn</code> angles</td><td></td></tr>
305
314
  <tr><td>Scale (<code>scale</code>, <code>scaleX</code>, <code>scaleY</code>, <code>scaleZ</code>, <code>scale3d</code>)</td><td>Supported, including percentages</td><td></td></tr>
306
315
  <tr><td>Skew (<code>skew</code>, <code>skewX</code>, <code>skewY</code>)</td><td>Supported</td><td></td></tr>
307
316
  <tr><td>Matrix (<code>matrix</code>, <code>matrix3d</code>)</td><td>Supported</td><td></td></tr>
308
317
  <tr><td>Perspective (<code>perspective</code>)</td><td>Approximated, see the notes below</td><td></td></tr>
318
+ <tr><td>The <code>transform</code> attribute of inline <code>&lt;svg&gt;</code></td><td>Transforms the element like the property, which takes precedence</td><td></td></tr>
309
319
 
310
320
  <tr>
311
321
  <td colspan="2"><code>transformOrigin</code></td>
@@ -355,6 +365,18 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
355
365
  <td></td>
356
366
  </tr>
357
367
 
368
+ <tr>
369
+ <td colspan="2"><code>mixBlendMode</code></td>
370
+ <td>All blend modes. Elements blend with what's painted below them in their stacking context</td>
371
+ <td></td>
372
+ </tr>
373
+
374
+ <tr>
375
+ <td colspan="2"><code>isolation</code></td>
376
+ <td><code>auto</code>, <code>isolate</code>, defaults to <code>auto</code></td>
377
+ <td></td>
378
+ </tr>
379
+
358
380
  <tr>
359
381
  <td colspan="2"><code>boxSizing</code></td>
360
382
  <td>Supported</td>
@@ -404,14 +426,26 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
404
426
  <tr><td><code>maskRepeat</code></td><td><code>repeat</code>, <code>repeat-x</code>, <code>repeat-y</code>, <code>no-repeat</code>, defaults to <code>repeat</code></td><td><a href="https://og-playground.vercel.app/?share=nVbpjqNIEn6VkqXVzMg1AhtjQ-3MStwGA-Ywl9U_hssJ5jSHAbf63TdxdfXUzh4_FhllHF8cGZkm4usirKJ48bb4LUrvX8qXl7ab8vj3r19n-uUliVOQdG8vP61Q9G8_vb4LhzTqkr_IorStc3-C0ksejx_SmWbTJg67tCqhLqzyvig_tH6eglLs4qKdVXHZxc2H6tq3XXqZmAoKyzn-v6ovUG6mj_jtBVt_Ejnfs92i6Hdp4IcZaKq-jKCPvsl_jvzOf0sLH8RIXYK_B34bbzevqU0fjQE9CKCi4KOaVsJZAFK0PvMaQ3lwYbPiSNqzgHJV00BFqmk34XaGiEbucHlxslDqMNtRAJpyJkUpM0NTFAcXzqco6ztPUSbggs-8BTgY_AMvwl9UU9Qz_lPvPP0-WaiEz6zinkKoPwLIs9_lkGcATGEO-o6jTUANn3iKeJJ2F-6CJ58PJp8_ICFzA7QeFZqSbqHwBOW1zSeow62UY6HeAxNPzgKZnk18E7jfU2LHzbFMulBY5ZHAgVhYtUGpbGMWTT3HuHuFtZ35wLFRzyRScQ-2EDNEQkuKeaJaDM0GmJSLrNcrzGYQr5uDyFBA20vZ-VqbBuf98BkWRqGZUhXtjeGYEvcIizC5DB9yQU7niRiPpwyXH9QkP8RJdqF9unrEDo56Luig_fXD9yf_3NlVr2GRw3zye5DS01nwtp4j3SNXJ8VU_IH_eD9ygfjifEVTf2-gIVvd5TUO8-CzYC3l8rNWJOo750J-cHBfRKqB6rMf4t2-1mDsPCiN5Bn_uhk15t3umJGT79h9JPCQJ_tP9oSM_YfcP-rGwFrAPViZIUAbiH2v97P-p81BsH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bmAgqnY9pFukjifCFN1mcGPOEFPsIAi-V0rgqfdMZSlIkpEGa4ua3J44SQ4thMqQRr8ujjuxUKgCIq3Iaheg6fbOvF2qN895725IMC-eaTAIA_P77Lx_NvfDbTJw79NvLH3laxn7zK2j8KIUTwM9d9dLMPf71Jcj7-PWla_yyrf0G6n7545P9-3AwTyj1-LJaz8tn90Zcx_48VjRP4tcfSicOsrRTPmXwl6GhvYPlWOQfg4O2V9fnicZ8x0B92OyOLDWIKV2dnbz097B5XMGgMCKICnsK1_MHGk0VczNCzBp-2DG9IDeaKQ4iSwHlJEIsNSrXp49N4Ix9-PjUXGCjiyYcUyb8HhbhfcYpDPmIijDVruPguUYlCjBmho4KMzxUk6Yhpn2-zDDILNeqJ0g_LKDDWDI7v0_dKLMZpJWVyHM45NeqOazgikMfhgJt1KvVzuts66QiOBd5G8D9RuukjgQrFRliCZvOnMvyx0H8ezH_n-P808v_ONQ_Qf_laL99-1L-40v5GwLHXLguXhdVPQ-l7eLt6-I50C7eZpevi_eRd_E2D5GLKA56sHi7-Hkbvy7iorqmp6me5-VueHLQ0Tx5ckUQR4u3runjb6-Lzg8gIonzvBqqJo8W3_4J">Example</a></td></tr>
405
427
 
406
428
  <tr>
407
- <td rowspan="2"><code>WebkitTextStroke</code>
429
+ <td rowspan="2"><code>WebkitTextStroke</code></td>
408
430
  <td><code>WebkitTextStrokeWidth</code></td>
409
- <td>Supported</td>
431
+ <td>Lengths, <code>thin</code>, <code>medium</code> and <code>thick</code>. The shorthand takes the width and color in any order</td>
410
432
  <td></td>
411
433
  </tr>
412
434
  <tr>
413
435
  <td><code>WebkitTextStrokeColor</code></td>
414
- <td>Supported</td>
436
+ <td>Supported, defaults to <code>currentColor</code></td>
437
+ <td></td>
438
+ </tr>
439
+
440
+ <tr>
441
+ <td colspan="2"><code>WebkitTextFillColor</code></td>
442
+ <td>Supported, defaults to <code>currentColor</code></td>
443
+ <td></td>
444
+ </tr>
445
+
446
+ <tr>
447
+ <td colspan="2"><code>paintOrder</code></td>
448
+ <td><code>normal</code>, or <code>fill</code>, <code>stroke</code> and <code>markers</code> in any order. Like browsers, text strokes are painted above the fill by default</td>
415
449
  <td></td>
416
450
  </tr>
417
451
 
@@ -421,7 +455,7 @@ Satori uses the same Flexbox [layout engine](https://yogalayout.com) as React Na
421
455
  Note:
422
456
 
423
457
  1. 3D transforms are drawn like in browsers, with two differences. Elements in a `preserve-3d` context are drawn back to front by the depth of their centers, and elements that intersect aren't cut where they cross. Perspective is approximated: each element is drawn with the affine transform closest to it around its center, which is exact for elements facing the viewer, such as `translateZ()`. `satori/experimental` [draws perspective exactly](#perspective-experimental).
424
- 2. There is no `z-index` support in SVG. Elements that come later in the document will be painted on top.
458
+ 2. Elements are painted in stacking order, see `zIndex`. Unlike browsers, `opacity` applies to each shape of an element instead of the element as a group.
425
459
  3. `calc` isn't supported.
426
460
  4. `currentColor` support is only available for the `color` property.
427
461
  5. CSS variables (custom properties) are supported, including inheritance, fallback values, and nested variables.
@@ -562,23 +596,23 @@ If there is a limitation on dynamically loading WASM (e.g. Cloudflare Workers),
562
596
 
563
597
  #### Standalone Build of Satori
564
598
 
565
- Satori's standalone build doesn't include Yoga's WASM binary by default, and you need to load it manually before using Satori.
599
+ Satori's standalone build doesn't include the WASM binary of its layout engine by default, and you need to load it manually before using Satori.
566
600
 
567
- First, you need to download the `yoga.wasm` binary from [Satori build](https://unpkg.com/satori/) and provide it yourself. Let's use `fetch` to load it directly from the CDN as an example:
601
+ First, you need to download the `layout.wasm` binary from [Satori build](https://unpkg.com/satori/) and provide it yourself. Let's use `fetch` to load it directly from the CDN as an example:
568
602
 
569
603
  ```jsx
570
604
  import satori, { init } from 'satori/standalone'
571
605
 
572
- const res = await fetch('https://unpkg.com/satori/yoga.wasm')
573
- const yogaWasm = await res.arrayBuffer()
606
+ const res = await fetch('https://unpkg.com/satori/layout.wasm')
607
+ const layoutWasm = await res.arrayBuffer()
574
608
 
575
- await init(yogaWasm)
609
+ await init(layoutWasm)
576
610
 
577
611
  // Now you can use satori as usual
578
612
  const svg = await satori(...)
579
613
  ```
580
614
 
581
- Of course, you can also load the `yoga.wasm` file from your local disk via `fs.readFile` in Node.js or other methods.
615
+ Of course, you can also load the `layout.wasm` file from your local disk via `fs.readFile` in Node.js or other methods.
582
616
 
583
617
  ### Font Embedding
584
618
 
@@ -598,7 +632,7 @@ const svg = await satori(
598
632
 
599
633
  ### Pixel Grid Rounding
600
634
 
601
- Set `pointScaleFactor` to control how layout values are rounded to the pixel grid. This parameter is passed directly to [Yoga’s `pointScaleFactor`](https://www.yogalayout.dev/docs/getting-started/configuring-yoga#point-scale-factor) and improves rendering precision on high-DPI displays.
635
+ Set `pointScaleFactor` to control how layout values are rounded to the pixel grid: they are rounded to multiples of `1 / pointScaleFactor` px, or not rounded with `0`. It defaults to `1`, and higher values improve rendering precision on high-DPI displays.
602
636
 
603
637
  ```jsx
604
638
  const svg = await satori(