satori
Version:
Enlightened library to convert HTML and CSS to SVG.
1 lines • 3.18 kB
Source Map (JSON)
{"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"]}