satori 0.25.0 → 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 +21 -2
- package/dist/jsx/index.cjs +2 -0
- package/dist/jsx/index.cjs.LEGAL.txt +0 -0
- package/dist/jsx/index.cjs.map +1 -0
- package/dist/jsx/index.d.cts +14 -0
- package/dist/jsx/index.d.ts +14 -0
- package/dist/jsx/index.js +2 -0
- package/dist/jsx/index.js.LEGAL.txt +0 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/jsx-runtime.cjs +2 -0
- package/dist/jsx/jsx-runtime.cjs.LEGAL.txt +0 -0
- package/dist/jsx/jsx-runtime.cjs.map +1 -0
- package/dist/jsx/jsx-runtime.d.cts +1 -0
- package/dist/jsx/jsx-runtime.d.ts +1 -0
- package/dist/jsx/jsx-runtime.js +2 -0
- package/dist/jsx/jsx-runtime.js.LEGAL.txt +0 -0
- package/dist/jsx/jsx-runtime.js.map +1 -0
- package/dist/jsx-runtime-d92ed26c.d.ts +1305 -0
- package/package.json +20 -1
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:
|
|
@@ -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:
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var x=(n,e)=>{for(var t in e)o(n,t,{get:e[t],enumerable:!0})},a=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of y(e))!f.call(n,r)&&r!==t&&o(n,r,{get:()=>e[r],enumerable:!(s=p(e,r))||s.enumerable});return n};var u=n=>a(o({},"__esModule",{value:!0}),n);var S={};x(S,{Fragment:()=>l,createElement:()=>c});module.exports=u(S);function i(n,e,t){if("key"in e){let{key:s,...r}=e;t=arguments.length===3?t:s,e=r}return t=t!=null?String(t):null,{type:n,props:e,key:t}}var l=Symbol.for("react.fragment");function c(n,e,...t){if(!e){let m=t.length?{children:t}:{};return i(n,m,null)}let{key:s,...r}=e;return t.length&&(r.children=t),i(n,r,s)}0&&(module.exports={Fragment,createElement});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/jsx/index.ts","../../src/jsx/jsx-runtime.ts"],"sourcesContent":["import { jsx } from './jsx-runtime.js'\nimport type { JSXNode, JSXElement, JSXKey, FC } from './types.js'\n\nexport type * from './types.js'\nexport { Fragment, type JSX } from './jsx-runtime.js'\n\n/**\n * Create a `ReactElement`-like object.\n *\n * @param type - Tag name string or a function component.\n * @param props - Optional props to create the element with.\n * @param children - Zero or more child nodes.\n * @returns A `ReactElement`-like object with properties like `type`, `key`, `props`, and `props.children`.\n */\nexport function createElement<P extends {}>(\n type: string | FC<P>,\n props?: P | null,\n ...children: JSXNode[]\n): JSXElement<P> {\n if (!props) {\n const newProps = children.length ? { children } : {}\n return jsx(type, newProps, null) as JSXElement<P>\n }\n\n // Destructure key from props.\n const { key, ...restProps } = props as {\n key?: JSXKey | undefined | null\n [x: string]: unknown\n }\n // Pass children as props.\n if (children.length) restProps.children = children\n\n return jsx(type, restProps, key) as JSXElement<P>\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n/**\n * @file\n * Minimal JSX runtime for Satori adapted from React v19.1.\n *\n * Use the `@jsxImportSource` pragma directive in files containing JSX for Satori.\n *\n * @see {@link https://github.com/facebook/react/blob/v19.1.0/packages/react/src/jsx/ReactJSXElement.js React JSX runtime implementation}\n * @see {@link https://www.typescriptlang.org/docs/handbook/jsx.html TypeScript: JSX reference}\n * @see {@link https://www.typescriptlang.org/tsconfig/#jsxImportSource TSConfig: using \"jsxImportSource\" or `@jsxImportSource` pragma directive}\n * @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts React typings `@types/react`}\n * @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/jsx-runtime.d.ts React typings for `jsx-runtime`}\n */\nimport type { JSXElement, JSXKey, FC } from './types.js'\nimport type { DefinedIntrinsicElements } from './intrinsic-elements.js'\n\nexport namespace JSX {\n /**\n * **WARNING**: Satori does not support class components.\n * @see {@link https://github.com/vercel/satori?tab=readme-ov-file#jsx Satori JSX documentation}\n */\n export type ElementClass = never\n\n export type ElementType = string | FC<any>\n\n export type Element = JSXElement<any, any>\n\n export interface ElementAttributesProperty {\n props: {}\n }\n\n export interface ElementChildrenAttribute {\n children: {}\n }\n\n // TODO: define IntrinsicElements supported by Satori.\n export interface IntrinsicElements extends DefinedIntrinsicElements {}\n\n export interface IntrinsicAttributes {\n /** **INFO**: Allowed as prop, but will be ignored by Satori. */\n key?: JSXKey | undefined | null\n }\n}\n\nexport function jsx(\n type: string | FC<any>,\n props: Record<string, unknown>,\n key?: JSXKey | undefined | null\n): JSXElement {\n if ('key' in props) {\n // Destructure spread key from props.\n const { key: keyProp, ...restProps } = props\n // Key param takes precedence over spread key prop.\n key = arguments.length === 3 ? key : (keyProp as JSXKey)\n // Shallow copy of props without key.\n props = restProps\n }\n // Coerce key to string if not nullish.\n key = key != null ? String(key) : null\n return { type, props, key }\n}\n\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\n// HACK: Symbol used internally by React.\nexport const Fragment = Symbol.for('react.fragment')\n"],"mappings":"4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,kBAAAC,IAAA,eAAAC,EAAAJ,GC6CO,SAASK,EACdC,EACAC,EACAC,EACY,CACZ,GAAI,QAASD,EAAO,CAElB,GAAM,CAAE,IAAKE,EAAS,GAAGC,CAAU,EAAIH,EAEvCC,EAAM,UAAU,SAAW,EAAIA,EAAOC,EAEtCF,EAAQG,CACV,CAEA,OAAAF,EAAMA,GAAO,KAAO,OAAOA,CAAG,EAAI,KAC3B,CAAE,KAAAF,EAAM,MAAAC,EAAO,IAAAC,CAAI,CAC5B,CAMO,IAAMG,EAAW,OAAO,IAAI,gBAAgB,EDrD5C,SAASC,EACdC,EACAC,KACGC,EACY,CACf,GAAI,CAACD,EAAO,CACV,IAAME,EAAWD,EAAS,OAAS,CAAE,SAAAA,CAAS,EAAI,CAAC,EACnD,OAAOE,EAAIJ,EAAMG,EAAU,IAAI,CACjC,CAGA,GAAM,CAAE,IAAAE,EAAK,GAAGC,CAAU,EAAIL,EAK9B,OAAIC,EAAS,SAAQI,EAAU,SAAWJ,GAEnCE,EAAIJ,EAAMM,EAAWD,CAAG,CACjC","names":["jsx_exports","__export","Fragment","createElement","__toCommonJS","jsx","type","props","key","keyProp","restProps","Fragment","createElement","type","props","children","newProps","jsx","key","restProps"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { F as FC, J as JSXNode, a as JSXElement } from '../jsx-runtime-d92ed26c.js';
|
|
2
|
+
export { C as CSSProperties, b as Fragment, c as JSX, d as JSXKey } from '../jsx-runtime-d92ed26c.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create a `ReactElement`-like object.
|
|
6
|
+
*
|
|
7
|
+
* @param type - Tag name string or a function component.
|
|
8
|
+
* @param props - Optional props to create the element with.
|
|
9
|
+
* @param children - Zero or more child nodes.
|
|
10
|
+
* @returns A `ReactElement`-like object with properties like `type`, `key`, `props`, and `props.children`.
|
|
11
|
+
*/
|
|
12
|
+
declare function createElement<P extends {}>(type: string | FC<P>, props?: P | null, ...children: JSXNode[]): JSXElement<P>;
|
|
13
|
+
|
|
14
|
+
export { FC, JSXElement, JSXNode, createElement };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { F as FC, J as JSXNode, a as JSXElement } from '../jsx-runtime-d92ed26c.js';
|
|
2
|
+
export { C as CSSProperties, b as Fragment, c as JSX, d as JSXKey } from '../jsx-runtime-d92ed26c.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create a `ReactElement`-like object.
|
|
6
|
+
*
|
|
7
|
+
* @param type - Tag name string or a function component.
|
|
8
|
+
* @param props - Optional props to create the element with.
|
|
9
|
+
* @param children - Zero or more child nodes.
|
|
10
|
+
* @returns A `ReactElement`-like object with properties like `type`, `key`, `props`, and `props.children`.
|
|
11
|
+
*/
|
|
12
|
+
declare function createElement<P extends {}>(type: string | FC<P>, props?: P | null, ...children: JSXNode[]): JSXElement<P>;
|
|
13
|
+
|
|
14
|
+
export { FC, JSXElement, JSXNode, createElement };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function o(n,t,e){if("key"in t){let{key:s,...r}=t;e=arguments.length===3?e:s,t=r}return e=e!=null?String(e):null,{type:n,props:t,key:e}}var l=Symbol.for("react.fragment");function y(n,t,...e){if(!t){let i=e.length?{children:e}:{};return o(n,i,null)}let{key:s,...r}=t;return e.length&&(r.children=e),o(n,r,s)}export{l as Fragment,y as createElement};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/jsx/jsx-runtime.ts","../../src/jsx/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n/**\n * @file\n * Minimal JSX runtime for Satori adapted from React v19.1.\n *\n * Use the `@jsxImportSource` pragma directive in files containing JSX for Satori.\n *\n * @see {@link https://github.com/facebook/react/blob/v19.1.0/packages/react/src/jsx/ReactJSXElement.js React JSX runtime implementation}\n * @see {@link https://www.typescriptlang.org/docs/handbook/jsx.html TypeScript: JSX reference}\n * @see {@link https://www.typescriptlang.org/tsconfig/#jsxImportSource TSConfig: using \"jsxImportSource\" or `@jsxImportSource` pragma directive}\n * @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts React typings `@types/react`}\n * @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/jsx-runtime.d.ts React typings for `jsx-runtime`}\n */\nimport type { JSXElement, JSXKey, FC } from './types.js'\nimport type { DefinedIntrinsicElements } from './intrinsic-elements.js'\n\nexport namespace JSX {\n /**\n * **WARNING**: Satori does not support class components.\n * @see {@link https://github.com/vercel/satori?tab=readme-ov-file#jsx Satori JSX documentation}\n */\n export type ElementClass = never\n\n export type ElementType = string | FC<any>\n\n export type Element = JSXElement<any, any>\n\n export interface ElementAttributesProperty {\n props: {}\n }\n\n export interface ElementChildrenAttribute {\n children: {}\n }\n\n // TODO: define IntrinsicElements supported by Satori.\n export interface IntrinsicElements extends DefinedIntrinsicElements {}\n\n export interface IntrinsicAttributes {\n /** **INFO**: Allowed as prop, but will be ignored by Satori. */\n key?: JSXKey | undefined | null\n }\n}\n\nexport function jsx(\n type: string | FC<any>,\n props: Record<string, unknown>,\n key?: JSXKey | undefined | null\n): JSXElement {\n if ('key' in props) {\n // Destructure spread key from props.\n const { key: keyProp, ...restProps } = props\n // Key param takes precedence over spread key prop.\n key = arguments.length === 3 ? key : (keyProp as JSXKey)\n // Shallow copy of props without key.\n props = restProps\n }\n // Coerce key to string if not nullish.\n key = key != null ? String(key) : null\n return { type, props, key }\n}\n\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\n// HACK: Symbol used internally by React.\nexport const Fragment = Symbol.for('react.fragment')\n","import { jsx } from './jsx-runtime.js'\nimport type { JSXNode, JSXElement, JSXKey, FC } from './types.js'\n\nexport type * from './types.js'\nexport { Fragment, type JSX } from './jsx-runtime.js'\n\n/**\n * Create a `ReactElement`-like object.\n *\n * @param type - Tag name string or a function component.\n * @param props - Optional props to create the element with.\n * @param children - Zero or more child nodes.\n * @returns A `ReactElement`-like object with properties like `type`, `key`, `props`, and `props.children`.\n */\nexport function createElement<P extends {}>(\n type: string | FC<P>,\n props?: P | null,\n ...children: JSXNode[]\n): JSXElement<P> {\n if (!props) {\n const newProps = children.length ? { children } : {}\n return jsx(type, newProps, null) as JSXElement<P>\n }\n\n // Destructure key from props.\n const { key, ...restProps } = props as {\n key?: JSXKey | undefined | null\n [x: string]: unknown\n }\n // Pass children as props.\n if (children.length) restProps.children = children\n\n return jsx(type, restProps, key) as JSXElement<P>\n}\n"],"mappings":"AA6CO,SAASA,EACdC,EACAC,EACAC,EACY,CACZ,GAAI,QAASD,EAAO,CAElB,GAAM,CAAE,IAAKE,EAAS,GAAGC,CAAU,EAAIH,EAEvCC,EAAM,UAAU,SAAW,EAAIA,EAAOC,EAEtCF,EAAQG,CACV,CAEA,OAAAF,EAAMA,GAAO,KAAO,OAAOA,CAAG,EAAI,KAC3B,CAAE,KAAAF,EAAM,MAAAC,EAAO,IAAAC,CAAI,CAC5B,CAMO,IAAMG,EAAW,OAAO,IAAI,gBAAgB,ECrD5C,SAASC,EACdC,EACAC,KACGC,EACY,CACf,GAAI,CAACD,EAAO,CACV,IAAME,EAAWD,EAAS,OAAS,CAAE,SAAAA,CAAS,EAAI,CAAC,EACnD,OAAOE,EAAIJ,EAAMG,EAAU,IAAI,CACjC,CAGA,GAAM,CAAE,IAAAE,EAAK,GAAGC,CAAU,EAAIL,EAK9B,OAAIC,EAAS,SAAQI,EAAU,SAAWJ,GAEnCE,EAAIJ,EAAMM,EAAWD,CAAG,CACjC","names":["jsx","type","props","key","keyProp","restProps","Fragment","createElement","type","props","children","newProps","jsx","key","restProps"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var c=(n,e)=>{for(var t in e)s(n,t,{get:e[t],enumerable:!0})},a=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of m(e))!p.call(n,r)&&r!==t&&s(n,r,{get:()=>e[r],enumerable:!(i=l(e,r))||i.enumerable});return n};var x=n=>a(s({},"__esModule",{value:!0}),n);var E={};c(E,{Fragment:()=>u,jsx:()=>o,jsxDEV:()=>f,jsxs:()=>y});module.exports=x(E);function o(n,e,t){if("key"in e){let{key:i,...r}=e;t=arguments.length===3?t:i,e=r}return t=t!=null?String(t):null,{type:n,props:e,key:t}}var y=o,f=o,u=Symbol.for("react.fragment");0&&(module.exports={Fragment,jsx,jsxDEV,jsxs});
|
|
2
|
+
//# sourceMappingURL=jsx-runtime.cjs.map
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/jsx/jsx-runtime.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n/**\n * @file\n * Minimal JSX runtime for Satori adapted from React v19.1.\n *\n * Use the `@jsxImportSource` pragma directive in files containing JSX for Satori.\n *\n * @see {@link https://github.com/facebook/react/blob/v19.1.0/packages/react/src/jsx/ReactJSXElement.js React JSX runtime implementation}\n * @see {@link https://www.typescriptlang.org/docs/handbook/jsx.html TypeScript: JSX reference}\n * @see {@link https://www.typescriptlang.org/tsconfig/#jsxImportSource TSConfig: using \"jsxImportSource\" or `@jsxImportSource` pragma directive}\n * @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts React typings `@types/react`}\n * @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/jsx-runtime.d.ts React typings for `jsx-runtime`}\n */\nimport type { JSXElement, JSXKey, FC } from './types.js'\nimport type { DefinedIntrinsicElements } from './intrinsic-elements.js'\n\nexport namespace JSX {\n /**\n * **WARNING**: Satori does not support class components.\n * @see {@link https://github.com/vercel/satori?tab=readme-ov-file#jsx Satori JSX documentation}\n */\n export type ElementClass = never\n\n export type ElementType = string | FC<any>\n\n export type Element = JSXElement<any, any>\n\n export interface ElementAttributesProperty {\n props: {}\n }\n\n export interface ElementChildrenAttribute {\n children: {}\n }\n\n // TODO: define IntrinsicElements supported by Satori.\n export interface IntrinsicElements extends DefinedIntrinsicElements {}\n\n export interface IntrinsicAttributes {\n /** **INFO**: Allowed as prop, but will be ignored by Satori. */\n key?: JSXKey | undefined | null\n }\n}\n\nexport function jsx(\n type: string | FC<any>,\n props: Record<string, unknown>,\n key?: JSXKey | undefined | null\n): JSXElement {\n if ('key' in props) {\n // Destructure spread key from props.\n const { key: keyProp, ...restProps } = props\n // Key param takes precedence over spread key prop.\n key = arguments.length === 3 ? key : (keyProp as JSXKey)\n // Shallow copy of props without key.\n props = restProps\n }\n // Coerce key to string if not nullish.\n key = key != null ? String(key) : null\n return { type, props, key }\n}\n\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\n// HACK: Symbol used internally by React.\nexport const Fragment = Symbol.for('react.fragment')\n"],"mappings":"4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,QAAAC,EAAA,WAAAC,EAAA,SAAAC,IAAA,eAAAC,EAAAN,GA6CO,SAASG,EACdI,EACAC,EACAC,EACY,CACZ,GAAI,QAASD,EAAO,CAElB,GAAM,CAAE,IAAKE,EAAS,GAAGC,CAAU,EAAIH,EAEvCC,EAAM,UAAU,SAAW,EAAIA,EAAOC,EAEtCF,EAAQG,CACV,CAEA,OAAAF,EAAMA,GAAO,KAAO,OAAOA,CAAG,EAAI,KAC3B,CAAE,KAAAF,EAAM,MAAAC,EAAO,IAAAC,CAAI,CAC5B,CAEO,IAAMJ,EAAOF,EACPC,EAASD,EAGTD,EAAW,OAAO,IAAI,gBAAgB","names":["jsx_runtime_exports","__export","Fragment","jsx","jsxDEV","jsxs","__toCommonJS","type","props","key","keyProp","restProps"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { b as Fragment, c as JSX, j as jsx, f as jsxDEV, e as jsxs } from '../jsx-runtime-d92ed26c.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { b as Fragment, c as JSX, j as jsx, f as jsxDEV, e as jsxs } from '../jsx-runtime-d92ed26c.js';
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/jsx/jsx-runtime.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-empty-interface */\n/**\n * @file\n * Minimal JSX runtime for Satori adapted from React v19.1.\n *\n * Use the `@jsxImportSource` pragma directive in files containing JSX for Satori.\n *\n * @see {@link https://github.com/facebook/react/blob/v19.1.0/packages/react/src/jsx/ReactJSXElement.js React JSX runtime implementation}\n * @see {@link https://www.typescriptlang.org/docs/handbook/jsx.html TypeScript: JSX reference}\n * @see {@link https://www.typescriptlang.org/tsconfig/#jsxImportSource TSConfig: using \"jsxImportSource\" or `@jsxImportSource` pragma directive}\n * @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts React typings `@types/react`}\n * @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/jsx-runtime.d.ts React typings for `jsx-runtime`}\n */\nimport type { JSXElement, JSXKey, FC } from './types.js'\nimport type { DefinedIntrinsicElements } from './intrinsic-elements.js'\n\nexport namespace JSX {\n /**\n * **WARNING**: Satori does not support class components.\n * @see {@link https://github.com/vercel/satori?tab=readme-ov-file#jsx Satori JSX documentation}\n */\n export type ElementClass = never\n\n export type ElementType = string | FC<any>\n\n export type Element = JSXElement<any, any>\n\n export interface ElementAttributesProperty {\n props: {}\n }\n\n export interface ElementChildrenAttribute {\n children: {}\n }\n\n // TODO: define IntrinsicElements supported by Satori.\n export interface IntrinsicElements extends DefinedIntrinsicElements {}\n\n export interface IntrinsicAttributes {\n /** **INFO**: Allowed as prop, but will be ignored by Satori. */\n key?: JSXKey | undefined | null\n }\n}\n\nexport function jsx(\n type: string | FC<any>,\n props: Record<string, unknown>,\n key?: JSXKey | undefined | null\n): JSXElement {\n if ('key' in props) {\n // Destructure spread key from props.\n const { key: keyProp, ...restProps } = props\n // Key param takes precedence over spread key prop.\n key = arguments.length === 3 ? key : (keyProp as JSXKey)\n // Shallow copy of props without key.\n props = restProps\n }\n // Coerce key to string if not nullish.\n key = key != null ? String(key) : null\n return { type, props, key }\n}\n\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\n// HACK: Symbol used internally by React.\nexport const Fragment = Symbol.for('react.fragment')\n"],"mappings":"AA6CO,SAASA,EACdC,EACAC,EACAC,EACY,CACZ,GAAI,QAASD,EAAO,CAElB,GAAM,CAAE,IAAKE,EAAS,GAAGC,CAAU,EAAIH,EAEvCC,EAAM,UAAU,SAAW,EAAIA,EAAOC,EAEtCF,EAAQG,CACV,CAEA,OAAAF,EAAMA,GAAO,KAAO,OAAOA,CAAG,EAAI,KAC3B,CAAE,KAAAF,EAAM,MAAAC,EAAO,IAAAC,CAAI,CAC5B,CAEO,IAAMG,EAAON,EACPO,EAASP,EAGTQ,EAAW,OAAO,IAAI,gBAAgB","names":["jsx","type","props","key","keyProp","restProps","jsxs","jsxDEV","Fragment"]}
|