satori 0.0.9 → 0.0.13

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../node_modules/.pnpm/tsup@5.11.13_typescript@4.5.5/node_modules/tsup/assets/esm_shims.js","../../src/yoga-prebuilt.ts","../../src/index.ts","../../src/satori.ts","../../src/yoga.ts","../../src/layout.ts","../../src/utils.ts","../../src/handler/index.ts","../../src/handler/presets.ts","../../src/handler/inheritable.ts","../../src/handler/expand.ts","../../src/text.ts","../../src/builder/text.ts","../../src/builder/transform.ts","../../src/builder/rect.ts","../../src/builder/background-image.ts","../../deps/gradient-parser/index.js","../../src/builder/border-radius.ts","../../src/builder/box-shadow.ts","../../src/builder/image.ts","../../src/font.ts","../../src/builder/svg.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","export { default } from 'yoga-layout-prebuilt'\n","export * from './satori'\nexport { default } from './satori'\n","import type { ReactNode } from 'react'\n\nimport getYoga, { init } from './yoga'\nimport layout from './layout'\nimport FontLoader, { FontOptions } from './font'\nimport svg from './builder/svg'\n\nexport interface SatoriOptions {\n width: number\n height: number\n fonts: FontOptions[]\n embedFont?: boolean\n debug?: boolean\n}\n\nexport { init }\n\nexport default function satori(\n element: ReactNode,\n options: SatoriOptions\n): string {\n const Yoga = getYoga()\n if (!Yoga) throw new Error('Satori is not initialized.')\n\n const font = new FontLoader(options.fonts)\n\n const root = Yoga.Node.create()\n root.setWidth(options.width)\n root.setHeight(options.height)\n root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW)\n root.setFlexWrap(Yoga.WRAP_WRAP)\n root.setAlignContent(Yoga.ALIGN_AUTO)\n root.setAlignItems(Yoga.ALIGN_FLEX_START)\n root.setJustifyContent(Yoga.JUSTIFY_FLEX_START)\n\n const handler = layout(element, {\n id: 1,\n parentStyle: {},\n inheritedStyle: {\n fontSize: 16,\n fontWeight: 'normal',\n fontFamily: 'serif',\n fontStyle: 'normal',\n lineHeight: 1.2,\n color: 'black',\n opacity: 1,\n },\n parent: root,\n font,\n embedFont: options.embedFont,\n debug: options.debug,\n })\n\n handler.next()\n root.calculateLayout(options.width, options.height, Yoga.DIRECTION_LTR)\n\n const content = handler.next([0, 0]).value\n return svg({ width: options.width, height: options.height, content })\n}\n","let Yoga: typeof import('yoga-layout')\n\n// @ts-ignore\nif (WASM) {\n // For WASM build, we don't include the prebuilt version of Yoga but let the\n // user specify the module manually.\n} else {\n const mod = require('./yoga-prebuilt') as any\n if (mod.default) {\n Yoga = mod.default\n } else {\n Yoga = mod\n }\n}\n\nexport function init(yoga: typeof Yoga) {\n Yoga = yoga\n}\n\nexport default function getYoga(): typeof Yoga {\n return Yoga\n}\n","/**\n * This module is used to calculate the layout of the current sub-tree.\n */\n\nimport type { ReactNode } from 'react'\nimport type { YogaNode } from 'yoga-layout'\n\nimport getYoga from './yoga'\nimport { isReactElement, isClass } from './utils'\nimport handler from './handler'\nimport FontLoader from './font'\nimport layoutText from './text'\nimport rect from './builder/rect'\nimport image from './builder/image'\n\nexport interface LayoutContext {\n id: number\n parentStyle: Record<string, number | string>\n inheritedStyle: Record<string, number | string>\n isInheritingTransform?: boolean\n parent: YogaNode\n font: FontLoader\n embedFont: boolean\n debug?: boolean\n}\n\nexport default function* layout(\n element: ReactNode,\n context: LayoutContext\n): Generator<undefined, string, [number, number]> {\n const Yoga = getYoga()\n const { id, inheritedStyle, parent, font, debug, embedFont = true } = context\n\n // 1. Pre-process the node.\n if (element === null || typeof element === 'undefined') {\n yield\n return ''\n }\n\n // Not a normal element.\n if (!isReactElement(element) || typeof element.type === 'function') {\n let iter: ReturnType<typeof layout>\n\n if (!isReactElement(element)) {\n // Process as text node.\n iter = layoutText(String(element), context)\n } else {\n if (isClass(element.type as Function)) {\n throw new Error('Class component is not supported.')\n }\n // If it's a custom component, Satori strictly requires it to be pure,\n // stateless, and not relying on any React APIs such as hooks or suspense.\n // So we can safely evaluate it to render. Otherwise, an error will be\n // thrown by React.\n iter = layout((element.type as Function)(element.props), context)\n }\n\n iter.next()\n const offset = yield\n return iter.next(offset).value\n }\n\n // Process as element.\n const { type, props } = element\n const { style, children } = props\n\n const node = Yoga.Node.create()\n parent.insertChild(node, parent.getChildCount())\n\n const [computedStyle, newInheritableStyle] = handler(\n node,\n type,\n inheritedStyle,\n style,\n props\n )\n // If the element is inheriting the parent `transform`, or applying its own.\n // This affects the coordinate system.\n const isInheritingTransform =\n computedStyle.transform === inheritedStyle.transform\n if (!isInheritingTransform) {\n ;(computedStyle.transform as any).__parent = inheritedStyle.transform\n }\n\n // 2. Do layout recursively for its children.\n const normalizedChildren =\n typeof children === 'undefined' ? [] : [].concat(children)\n const iterators: ReturnType<typeof layout>[] = []\n\n let i = 0\n for (const child of normalizedChildren) {\n const iter = layout(child, {\n id: id * normalizedChildren.length + ++i,\n parentStyle: computedStyle,\n inheritedStyle: newInheritableStyle,\n isInheritingTransform: true,\n parent: node,\n font,\n embedFont,\n debug,\n })\n iter.next()\n iterators.push(iter)\n }\n\n // 3. Post-process the node.\n const [x, y] = yield\n\n if (computedStyle.position === 'absolute') {\n node.calculateLayout()\n }\n\n let { left, top, width, height } = node.getComputedLayout()\n\n // Attach offset to the current node.\n left += x\n top += y\n\n let result = ''\n\n if (type === 'img') {\n result = image(\n {\n id,\n left,\n top,\n width,\n height,\n src: props.src,\n isInheritingTransform,\n debug,\n },\n computedStyle\n )\n } else {\n result = rect(\n { id, left, top, width, height, isInheritingTransform, debug },\n computedStyle\n )\n }\n\n for (const iter of iterators) {\n result += iter.next([left, top]).value\n }\n\n return result\n}\n","import type { ReactNode, ReactElement } from 'react'\n\nexport function isReactElement(node: ReactNode): node is ReactElement {\n const type = typeof node\n if (\n type === 'number' ||\n type === 'bigint' ||\n type === 'string' ||\n type === 'boolean'\n ) {\n return false\n }\n return true\n}\n\nexport function isClass(f: Function) {\n return /^class\\s/.test(Function.prototype.toString.call(f))\n}\n\n// Multiplies two 2d transform matrices.\nexport function multiply(m1: number[], m2: number[]) {\n return [\n m1[0] * m2[0] + m1[2] * m2[1],\n m1[1] * m2[0] + m1[3] * m2[1],\n m1[0] * m2[2] + m1[2] * m2[3],\n m1[1] * m2[2] + m1[3] * m2[3],\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5],\n ]\n}\n\nexport function v(\n field: string | number,\n map: Record<string, any>,\n fallback: any\n) {\n const value = map[field]\n return typeof value === 'undefined' ? fallback : value\n}\n","/**\n * Handler to update the Yoga node properties with the given element type and\n * style. Each supported element has its own preset styles, so this function\n * also returns the inherited style for children of the element.\n */\n\nimport type { YogaNode } from 'yoga-layout'\n\nimport getYoga from '../yoga'\nimport presets from './presets'\nimport inheritable from './inheritable'\nimport expand from './expand'\nimport { v } from '../utils'\n\ntype SatoriElement = keyof typeof presets\n\nexport default function handler(\n node: YogaNode,\n type: SatoriElement | string,\n inheritedStyle: Record<string, string | number>,\n definedStyle: Record<string, string | number>,\n props: Record<string, any>\n): [Record<string, string | number>, Record<string, string | number>] {\n const Yoga = getYoga()\n\n // Extend the default style with defined and inherited styles.\n const style = {\n ...inheritedStyle,\n ...expand(presets[type], inheritedStyle),\n ...expand(definedStyle, inheritedStyle),\n }\n\n if (type === 'img') {\n const width = parseInt(props.width)\n const height = parseInt(props.height)\n const r = height / width\n if (!style.width) style.width = width\n if (!style.height) style.height = r * (style.width as number)\n }\n\n // Set properties for Yoga.\n node.setDisplay(\n v(\n style.display,\n {\n flex: Yoga.DISPLAY_FLEX,\n none: Yoga.DISPLAY_NONE,\n },\n Yoga.DISPLAY_FLEX\n )\n )\n\n // if (style.alignContent) {\n node.setAlignContent(\n v(\n style.alignContent,\n {\n stretch: Yoga.ALIGN_STRETCH,\n center: Yoga.ALIGN_CENTER,\n 'flex-start': Yoga.ALIGN_FLEX_START,\n 'flex-end': Yoga.ALIGN_FLEX_END,\n 'space-between': Yoga.ALIGN_SPACE_BETWEEN,\n 'space-around': Yoga.ALIGN_SPACE_AROUND,\n baseline: Yoga.ALIGN_BASELINE,\n normal: Yoga.ALIGN_AUTO,\n },\n Yoga.ALIGN_AUTO\n )\n )\n // }\n\n node.setAlignItems(\n v(\n style.alignItems,\n {\n stretch: Yoga.ALIGN_STRETCH,\n center: Yoga.ALIGN_CENTER,\n 'flex-start': Yoga.ALIGN_FLEX_START,\n 'flex-end': Yoga.ALIGN_FLEX_END,\n baseline: Yoga.ALIGN_BASELINE,\n normal: Yoga.ALIGN_AUTO,\n },\n Yoga.ALIGN_FLEX_START\n )\n )\n node.setAlignSelf(\n v(\n style.alignSelf,\n {\n stretch: Yoga.ALIGN_STRETCH,\n center: Yoga.ALIGN_CENTER,\n 'flex-start': Yoga.ALIGN_FLEX_START,\n 'flex-end': Yoga.ALIGN_FLEX_END,\n baseline: Yoga.ALIGN_BASELINE,\n normal: Yoga.ALIGN_AUTO,\n },\n Yoga.ALIGN_AUTO\n )\n )\n node.setJustifyContent(\n v(\n style.justifyContent,\n {\n center: Yoga.JUSTIFY_CENTER,\n 'flex-start': Yoga.JUSTIFY_FLEX_START,\n 'flex-end': Yoga.JUSTIFY_FLEX_END,\n 'space-between': Yoga.JUSTIFY_SPACE_BETWEEN,\n 'space-around': Yoga.JUSTIFY_SPACE_AROUND,\n },\n Yoga.JUSTIFY_FLEX_START\n )\n )\n // @TODO: node.setAspectRatio\n\n node.setFlexDirection(\n v(\n style.flexDirection,\n {\n row: Yoga.FLEX_DIRECTION_ROW,\n column: Yoga.FLEX_DIRECTION_COLUMN,\n 'row-reverse': Yoga.FLEX_DIRECTION_ROW_REVERSE,\n 'column-reverse': Yoga.FLEX_DIRECTION_COLUMN_REVERSE,\n },\n Yoga.FLEX_DIRECTION_ROW\n )\n )\n node.setFlexWrap(\n v(\n style.flexWrap,\n {\n wrap: Yoga.WRAP_WRAP,\n nowrap: Yoga.WRAP_NO_WRAP,\n 'wrap-reverse': Yoga.WRAP_WRAP_REVERSE,\n },\n Yoga.WRAP_WRAP\n )\n )\n\n // @TODO: node.setFlex\n\n if (typeof style.flexBasis !== 'undefined') {\n // We can't use `auto` here due to this:\n // https://github.com/facebook/yoga/pull/1112\n // @TODO: We need a fork to add this API.\n node.setFlexBasis(style.flexBasis)\n }\n node.setFlexGrow(\n typeof style.flexGrow === 'undefined' ? 0 : (style.flexGrow as number)\n )\n node.setFlexShrink(\n typeof style.flexShrink === 'undefined' ? 1 : (style.flexShrink as number)\n )\n\n if (typeof style.maxHeight !== 'undefined') {\n node.setMaxHeight(style.maxHeight)\n }\n if (typeof style.maxWidth !== 'undefined') {\n node.setMaxWidth(style.maxWidth)\n }\n if (typeof style.minHeight !== 'undefined') {\n node.setMinHeight(style.minHeight)\n }\n if (typeof style.minWidth !== 'undefined') {\n node.setMinWidth(style.minWidth)\n }\n\n node.setOverflow(\n v(\n style.overflow,\n {\n visible: Yoga.OVERFLOW_VISIBLE,\n hidden: Yoga.OVERFLOW_HIDDEN,\n },\n Yoga.OVERFLOW_VISIBLE\n )\n )\n\n node.setMargin(Yoga.EDGE_TOP, (style.marginTop as number) || 0)\n node.setMargin(Yoga.EDGE_BOTTOM, (style.marginBottom as number) || 0)\n node.setMargin(Yoga.EDGE_LEFT, (style.marginLeft as number) || 0)\n node.setMargin(Yoga.EDGE_RIGHT, (style.marginRight as number) || 0)\n\n // @TODO: Add directional border support.\n node.setBorder(Yoga.EDGE_TOP, (style.borderWidth as number) || 0)\n node.setBorder(Yoga.EDGE_BOTTOM, (style.borderWidth as number) || 0)\n node.setBorder(Yoga.EDGE_LEFT, (style.borderWidth as number) || 0)\n node.setBorder(Yoga.EDGE_RIGHT, (style.borderWidth as number) || 0)\n\n node.setPadding(Yoga.EDGE_TOP, style.paddingTop || 0)\n node.setPadding(Yoga.EDGE_BOTTOM, style.paddingBottom || 0)\n node.setPadding(Yoga.EDGE_LEFT, style.paddingLeft || 0)\n node.setPadding(Yoga.EDGE_RIGHT, style.paddingRight || 0)\n\n node.setPositionType(\n v(\n style.position,\n {\n absolute: Yoga.POSITION_TYPE_ABSOLUTE,\n relative: Yoga.POSITION_TYPE_RELATIVE,\n },\n Yoga.POSITION_TYPE_RELATIVE\n )\n )\n\n if (typeof style.top !== 'undefined') {\n node.setPosition(Yoga.EDGE_TOP, style.top)\n }\n if (typeof style.bottom !== 'undefined') {\n node.setPosition(Yoga.EDGE_BOTTOM, style.bottom)\n }\n if (typeof style.left !== 'undefined') {\n node.setPosition(Yoga.EDGE_LEFT, style.left)\n }\n if (typeof style.right !== 'undefined') {\n node.setPosition(Yoga.EDGE_RIGHT, style.right)\n }\n\n if (typeof style.height !== 'undefined') {\n node.setHeight(style.height)\n } else {\n node.setHeightAuto()\n }\n if (typeof style.width !== 'undefined') {\n node.setWidth(style.width)\n } else {\n node.setWidthAuto()\n }\n\n return [style, inheritable(style)]\n}\n","/**\n * Pre-defined styles for elements. Here we hand pick some from Chromium's\n * default styles:\n * https://chromium.googlesource.com/chromium/blink/+/master/Source/core/css/html.css\n *\n * We try to only include commonly used, styling elements rather than senmantic elements.\n */\n\nexport default {\n // Generic block-level elements\n p: {\n display: 'block',\n marginTop: '1em',\n marginBottom: '1em',\n },\n div: {\n display: 'block',\n },\n blockquote: {\n display: 'block',\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: 40,\n marginRight: 40,\n },\n center: {\n display: 'block',\n textAlign: 'center',\n },\n hr: {\n display: 'block',\n marginTop: '0.5em',\n marginBottom: '0.5em',\n marginLeft: 'auto',\n marginRight: 'auto',\n borderWidth: 1,\n borderStyle: 'inset',\n },\n // Heading elements\n h1: {\n display: 'block',\n fontSize: '2em',\n marginTop: '0.67em',\n marginBottom: '0.67em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n h2: {\n display: 'block',\n fontSize: '1.5em',\n marginTop: '0.83em',\n marginBottom: '0.83em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n h3: {\n display: 'block',\n fontSize: '1.17em',\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n h4: {\n display: 'block',\n marginTop: '1.33em',\n marginBottom: '1.33em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n h5: {\n display: 'block',\n fontSize: '0.83em',\n marginTop: '1.67em',\n marginBottom: '1.67em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n h6: {\n display: 'block',\n fontSize: '0.67em',\n marginTop: '2.33em',\n marginBottom: '2.33em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n // Tables\n // Lists\n // Form elements\n // Inline elements\n u: {\n textDecoration: 'underline',\n },\n strong: {\n fontWeight: 'bold',\n },\n b: {\n fontWeight: 'bold',\n },\n i: {\n fontStyle: 'italic',\n },\n em: {\n fontStyle: 'italic',\n },\n code: {\n fontFamily: 'monospace',\n },\n kbd: {\n fontFamily: 'monospace',\n },\n pre: {\n display: 'block',\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n marginTop: '1em',\n marginBottom: '1em',\n },\n mark: {\n backgroundColor: 'yellow',\n color: 'black',\n },\n big: {\n fontSize: 'larger',\n },\n small: {\n fontSize: 'smaller',\n },\n s: {\n textDecoration: 'line-through',\n },\n}\n","const list = new Set([\n 'color',\n 'font',\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontWeight',\n 'lineHeight',\n 'textAlign',\n 'textTransform',\n 'whiteSpace',\n 'letterSpacing',\n 'transform',\n 'wordBreak',\n\n // Special case: SVG doesn't apply opacity to children elements so we need to\n // make it inheritable here.\n 'opacity',\n])\n\nexport default function inheritable(style: Record<string, any>) {\n const inheritedStyle: Record<string, any> = {}\n for (const prop in style) {\n if (list.has(prop)) {\n inheritedStyle[prop] = style[prop]\n }\n }\n return inheritedStyle\n}\n","/**\n * This module expands the CSS properties to get rid of shorthands, as well as\n * cleaning up some properties.\n */\n\nimport { getPropertyName, getStylesForProperty } from 'css-to-react-native'\nimport CssDimension from 'parse-css-dimension'\nimport { parseElementStyle } from 'css-background-parser'\nimport { multiply } from '../utils'\n\n// https://react-cn.github.io/react/tips/style-props-value-px.html\nconst optOutPx = new Set([\n 'flex',\n 'flexGrow',\n 'flexShrink',\n 'flexBasis',\n 'fontWeight',\n 'lineHeight',\n 'opacity',\n 'scale',\n 'scaleX',\n 'scaleY',\n])\n\nconst baseMatrix = [1, 0, 0, 1, 0, 0]\n\nfunction purify(name: string, value?: string | number) {\n if (typeof value === 'number') {\n if (!optOutPx.has(name)) return value + 'px'\n return String(value)\n }\n // @TODO: For `transform`, we need to convert relative values to absolute\n // values here.\n return value\n}\n\nfunction lengthToNumber(\n length: string | number,\n baseFontSize: number\n): number | undefined {\n if (typeof length === 'number') return length\n\n // Convert em and rem values to number (px), convert rad to deg.\n try {\n const parsed = new CssDimension(length)\n if (parsed.type === 'length') {\n switch (parsed.unit) {\n case 'em':\n return parsed.value * baseFontSize\n case 'rem':\n return parsed.value * 16\n default:\n return parsed.value\n }\n } else if (parsed.type === 'angle') {\n switch (parsed.unit) {\n case 'deg':\n return parsed.value\n case 'rad':\n return (parsed.value * 180) / Math.PI\n default:\n return parsed.value\n }\n }\n } catch (err) {}\n}\n\nexport default function expand(\n style: Record<string, string | number>,\n inheritedStyle: Record<string, string | number>\n): Record<string, string | number> {\n const rules = []\n for (const prop in style) {\n const name = getPropertyName(prop)\n rules.push([name, purify(name, style[prop])])\n }\n const transformedStyle = rules.reduce((accum, rule) => {\n const propertyName = getPropertyName(rule[0])\n const value = rule[1]\n return Object.assign(accum, getStylesForProperty(propertyName, value, true))\n }, {})\n\n // Parse background images.\n if (transformedStyle.backgroundImage) {\n const { backgrounds } = parseElementStyle(transformedStyle)\n transformedStyle.backgroundImage = backgrounds\n }\n\n // Calculate the base font size.\n let baseFontSize: number =\n transformedStyle.fontSize || inheritedStyle.fontSize\n if (typeof baseFontSize === 'string') {\n try {\n const parsed = new CssDimension(baseFontSize)\n switch (parsed.unit) {\n case 'em':\n baseFontSize = parsed.value * (inheritedStyle.fontSize as number)\n break\n case 'rem':\n baseFontSize = parsed.value * 16\n break\n }\n } catch (err) {\n baseFontSize = 16\n }\n }\n transformedStyle.fontSize = baseFontSize\n\n for (const prop in transformedStyle) {\n let value = transformedStyle[prop]\n\n // Convert em and rem values to px (number).\n if (typeof value === 'string') {\n const len = lengthToNumber(value, baseFontSize)\n if (typeof len !== 'undefined') transformedStyle[prop] = len\n value = transformedStyle[prop]\n }\n\n // Inherit the opacity.\n if (prop === 'opacity') {\n value = transformedStyle[prop] =\n value * (inheritedStyle.opacity as number)\n }\n\n // Handle CSS transforms To make it easier, we convert different transform\n // types directly to a matrix and apply it recursively to all its children.\n // @TODO: We need to convert relative values (50%) to absolute values. This\n // is pretty tricky to support as we need an extra pass to handle them after\n // the full layout pass.\n if (prop === 'transform') {\n let matrix = [...baseMatrix]\n const transforms = value as { [type: string]: number | string }[]\n\n // Transforms are applied from right to left.\n for (const transform of transforms) {\n const type = Object.keys(transform)[0]\n const v = transform[type]\n const len = typeof v === 'string' ? lengthToNumber(v, baseFontSize) : v\n\n const transformMatrix = [...baseMatrix]\n switch (type) {\n case 'translateX':\n transformMatrix[4] = len\n break\n case 'translateY':\n transformMatrix[5] = len\n break\n case 'scaleX':\n transformMatrix[0] = len\n break\n case 'scaleY':\n transformMatrix[3] = len\n break\n case 'rotate':\n const rad = (len * Math.PI) / 180\n const c = Math.cos(rad)\n const s = Math.sin(rad)\n transformMatrix[0] = c\n transformMatrix[1] = s\n transformMatrix[2] = -s\n transformMatrix[3] = c\n break\n case 'skewX':\n transformMatrix[2] = Math.tan((len * Math.PI) / 180)\n break\n case 'skewY':\n transformMatrix[1] = Math.tan((len * Math.PI) / 180)\n break\n }\n matrix = multiply(transformMatrix, matrix)\n }\n\n transformedStyle.transform = matrix\n }\n }\n\n return transformedStyle\n}\n","/**\n * This module calculates the layout of a text string. Currently the only\n * supported inline node is text. All other nodes are using block layout.\n */\nimport type { LayoutContext } from './layout'\n\nimport getYoga from './yoga'\nimport { LineBreaker } from 'css-line-break'\nimport text from './builder/text'\nimport { v } from './utils'\n\nexport default function* buildTextNodes(content, context: LayoutContext) {\n const Yoga = getYoga()\n const {\n parentStyle,\n parent,\n font,\n id,\n isInheritingTransform,\n debug,\n embedFont,\n } = context\n\n const breaker = LineBreaker(content, {\n lineBreak: 'strict',\n wordBreak: v(\n parentStyle.wordBreak,\n {\n normal: 'normal',\n 'break-all': 'break-all',\n 'break-word': 'break-word',\n 'keep-all': 'keep-all',\n },\n 'normal'\n ),\n })\n\n const words = []\n for (let br; !(br = breaker.next()).done; ) {\n words.push(br.value.slice())\n }\n\n const nodes = []\n\n // @TODO: Find a better way to avoid overriding the parent node.\n parent.setAlignItems(Yoga.ALIGN_BASELINE)\n if (parentStyle.textAlign === 'left') {\n parent.setJustifyContent(Yoga.JUSTIFY_FLEX_START)\n } else if (parentStyle.textAlign === 'center') {\n parent.setJustifyContent(Yoga.JUSTIFY_CENTER)\n } else if (parentStyle.textAlign === 'right') {\n parent.setJustifyContent(Yoga.JUSTIFY_FLEX_END)\n } else if (parentStyle.textAlign === 'justify') {\n parent.setJustifyContent(Yoga.JUSTIFY_SPACE_BETWEEN)\n }\n\n const resolvedFont = font.getFont(parentStyle as any)\n\n for (const word of words) {\n const node = Yoga.Node.create()\n parent.insertChild(node, parent.getChildCount())\n\n const measured = font.measure(resolvedFont, word, parentStyle as any)\n\n node.setWidth(measured.width)\n node.setHeight(measured.ascent * 1.2)\n node.setMargin(Yoga.EDGE_BOTTOM, measured.descent * 1.2)\n\n nodes.push(node)\n }\n\n const [x, y] = yield\n\n let result = ''\n\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i]\n const word = words[i]\n if (parentStyle.position === 'absolute') {\n node.calculateLayout()\n }\n\n let { left, top, width, height } = node.getComputedLayout()\n\n // Attach offset to the current node.\n left += x\n top += y\n\n let path: string | null = null\n\n if (embedFont) {\n path = font.getSVG(resolvedFont, word, {\n ...parentStyle,\n top,\n left,\n letterSpacing: parentStyle.letterSpacing,\n } as any)\n } else {\n // We need manually add the font ascender height to ensure it starts\n // at the baseline because <text>'s alignment baseline is set to `hanging`\n // by default and supported to change in SVG 1.1.\n top += font.getAscent(resolvedFont, parentStyle as any)\n }\n\n result += text(\n {\n content: word,\n id,\n left,\n top,\n width,\n height,\n isInheritingTransform,\n path,\n debug,\n },\n parentStyle\n )\n }\n\n return result\n}\n","import transform from './transform'\n\nexport default function text(\n {\n content,\n left,\n top,\n width,\n height,\n isInheritingTransform,\n path,\n debug,\n }: {\n content: string\n id: number\n left: number\n top: number\n width: number\n height: number\n isInheritingTransform: boolean\n path: string | null\n debug?: boolean\n },\n style: Record<string, number | string>\n) {\n let matrix = ''\n let opacity = 1\n let extra = ''\n\n if (style.transform) {\n matrix = transform(\n { left, top, width, height },\n style.transform as unknown as number[],\n isInheritingTransform\n )\n }\n\n if (style.opacity) {\n opacity = +style.opacity\n }\n\n if (debug) {\n extra = `<rect x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${\n path === null ? 0.5 : height\n }\" fill=\"transparent\" stroke=\"#575eff\" stroke-width=\"1\" ${\n matrix ? `transform=\"${matrix}\"` : ''\n }></rect>`\n }\n\n // Do not embed the font, use <text> with the raw content instead.\n if (path === null) {\n return `<text x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" fill=\"${\n style.color\n }\" font-weight=\"${style.fontWeight}\" font-style=\"${\n style.fontStyle\n }\" font-size=\"${style.fontSize}\" font-family=\"${style.fontFamily}\" ${\n style.letterSpacing ? `letter-spacing=\"${style.letterSpacing}\"` : ''\n } ${matrix ? `transform=\"${matrix}\"` : ''} ${\n opacity !== 1 ? `opacity=\"${opacity}\"` : ''\n }>${content}</text>${extra}`\n }\n\n return `<path fill=\"${style.color}\" ${\n matrix ? `transform=\"${matrix}\"` : ''\n } ${opacity !== 1 ? `opacity=\"${opacity}\"` : ''} d=\"${path}\"></path>${extra}`\n}\n","import { multiply } from '../utils'\n\nexport default function transform(\n {\n left,\n top,\n width,\n height,\n }: { left: number; top: number; width: number; height: number },\n matrix: number[],\n isInheritingTransform: boolean\n) {\n let result: number[]\n\n // Calculate the transform origin.\n if (isInheritingTransform) {\n result = matrix\n } else {\n // If this element is the transform target, we attach the origin coordinates\n // to this matrix.\n const x = left + width / 2\n const y = top + height / 2\n\n // Due to the different coordinate systems, we need to move the shape to the\n // origin first, then apply the matrix, then move it back.\n result = multiply(\n [1, 0, 0, 1, x, y],\n multiply(matrix, [1, 0, 0, 1, -x, -y])\n )\n\n // And we need to apply its parent transform if it has one.\n if ((matrix as any).__parent) {\n result = multiply((matrix as any).__parent, result)\n }\n\n // Mutate self.\n matrix.splice(0, 6, ...result)\n }\n\n return `matrix(${result.map((v) => v.toFixed(2)).join(',')})`\n}\n","import backgroundImage from './background-image'\nimport radius from './border-radius'\nimport shadow from './box-shadow'\nimport transform from './transform'\n\nexport default function rect(\n {\n id,\n left,\n top,\n width,\n height,\n isInheritingTransform,\n debug,\n }: {\n id: number\n left: number\n top: number\n width: number\n height: number\n isInheritingTransform: boolean\n debug?: boolean\n },\n style: Record<string, number | string>\n) {\n if (style.display === 'none') return ''\n\n let type = 'rect'\n let stroke = 'transparent'\n let strokeWidth = 0\n let matrix = ''\n let defs = ''\n let fills: string[] = []\n let opacity = 1\n let extra = ''\n\n if (style.backgroundColor) {\n fills.push(style.backgroundColor as string)\n }\n\n if (style.borderWidth) {\n strokeWidth = style.borderWidth as number\n stroke = style.borderColor as string\n }\n\n if (style.opacity) {\n opacity = +style.opacity\n }\n\n if (style.transform) {\n matrix = transform(\n { left, top, width, height },\n style.transform as unknown as number[],\n isInheritingTransform\n )\n }\n\n if (style.backgroundImage) {\n const backgrounds = (style.backgroundImage as any)\n .map((background, index) =>\n backgroundImage({ id: id + '_' + index, width, height }, background)\n )\n .filter(Boolean)\n for (const background of backgrounds) {\n defs += background[1]\n fills.push(`url(#${background[0]})`)\n }\n }\n\n const path = radius(\n { left, top, width, height },\n style as Record<string, number>\n )\n if (path) {\n type = 'path'\n }\n\n const filter = shadow({ width, height, id }, style)\n\n if (!fills.length) fills.push('transparent')\n\n if (debug) {\n extra = `<rect x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" fill=\"transparent\" stroke=\"#ff5757\" stroke-width=\"1\" ${\n matrix ? `transform=\"${matrix}\"` : ''\n }></rect>`\n }\n\n return `${defs ? `<defs>${defs}</defs>` : ''}${\n filter ? `${filter}<g filter=\"url(#satori_s-${id})\">` : ''\n }${opacity !== 1 ? `<g opacity=\"${opacity}\">` : ''}${\n // Each background generates a new rectangle.\n fills\n .map((fill, i) => {\n if (fill === 'transparent' && !(i === fills.length - 1 && strokeWidth))\n return ''\n\n return `<${type} x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" fill=\"${fill}\" ${\n i === fills.length - 1 && strokeWidth\n ? `stroke=\"${stroke}\" stroke-width=\"${strokeWidth}\"`\n : ''\n } ${path ? `d=\"${path}\"` : ''} ${\n matrix ? `transform=\"${matrix}\"` : ''\n }></${type}>`\n })\n .join('')\n }${opacity !== 1 ? `</g>` : ''}${filter ? '</g>' : ''}${extra}`\n}\n","import gradient from '../../deps/gradient-parser'\n\ninterface Background {\n attachment: string\n color?: string\n clip: string\n image: string\n origin: string\n position: string\n size: string\n repeat: string\n}\n\nfunction resolveColorFromStop(stop) {\n if (stop.type === 'literal') return stop.value\n if (stop.type === 'hex') return `#${stop.value}`\n if (stop.type === 'rgb') return `rgb(${stop.value.join(',')})`\n if (stop.type === 'rgba') return `rgba(${stop.value.join(',')})`\n return 'transparent'\n}\n\nexport default function backgroundImage(\n { id, width }: { id: string; width: number; height: number },\n { image }: Background\n) {\n if (image.startsWith('linear-gradient(')) {\n const parsed = gradient.parse(image)[0]\n\n // Calculate the direction.\n let x1, y1, x2, y2\n if (parsed.orientation.type === 'directional') {\n ;[x1, y1, x2, y2] = {\n top: [0, 1, 0, 0],\n bottom: [0, 0, 0, 1],\n left: [1, 0, 0, 0],\n right: [0, 0, 1, 0],\n }[parsed.orientation.value]\n } else if (parsed.orientation.type === 'angular') {\n const angle = (+parsed.orientation.value / 180) * Math.PI - Math.PI / 2\n const c = Math.cos(angle)\n const s = Math.sin(angle)\n\n x1 = 0\n y1 = 0\n x2 = c\n y2 = s\n if (x2 < 0) {\n x1 -= x2\n x2 = 0\n }\n if (y2 < 0) {\n y1 -= y2\n y2 = 0\n }\n }\n\n // @TODO\n const totalLength = width\n\n // Resolve the color stops based on the spec:\n // https://drafts.csswg.org/css-images/#color-stop-syntax\n const stops = []\n for (const stop of parsed.colorStops) {\n const color = resolveColorFromStop(stop)\n if (!stops.length) {\n // First stop, ensure it's at the start.\n stops.push({\n offset: 0,\n color,\n })\n\n if (typeof stop.length === 'undefined') continue\n if (stop.length.value === '0') continue\n }\n\n // All offsets are relative values (0-1) in SVG.\n const offset =\n typeof stop.length === 'undefined'\n ? undefined\n : stop.length.type === '%'\n ? stop.length.value / 100\n : stop.length.value / totalLength\n\n stops.push({\n offset,\n color,\n })\n }\n if (!stops.length) {\n stops.push({\n offset: 0,\n color: 'transparent',\n })\n }\n // Last stop, ensure it's at the end.\n const lastStop = stops[stops.length - 1]\n if (lastStop.offset !== 1) {\n if (typeof lastStop.offset === 'undefined') {\n lastStop.offset = 1\n } else {\n stops.push({\n offset: 1,\n color: lastStop.color,\n })\n }\n }\n\n let previousStop = 0\n let nextStop = 1\n // Evenly distribute the missing stop offsets.\n for (let i = 0; i < stops.length; i++) {\n if (typeof stops[i].offset === 'undefined') {\n // Find the next stop that has an offset.\n if (nextStop < i) nextStop = i\n while (typeof stops[nextStop].offset === 'undefined') nextStop++\n\n stops[i].offset =\n ((stops[nextStop].offset - stops[previousStop].offset) /\n (nextStop - previousStop)) *\n (i - previousStop) +\n stops[previousStop].offset\n } else {\n previousStop = i\n }\n }\n\n return [\n `satori_bi${id}`,\n `<linearGradient id=\"satori_bi${id}\" x1=\"${x1}\" y1=\"${y1}\" x2=\"${x2}\" y2=\"${y2}\">${stops\n .map(\n (stop) =>\n `<stop offset=\"${stop.offset * 100}%\" stop-color=\"${stop.color}\"/>`\n )\n .join('')}</linearGradient>`,\n ]\n }\n\n if (image.startsWith('url(')) {\n const src = image.slice(4, -1)\n return [\n `satori_bi${id}`,\n `<pattern id=\"satori_bi${id}\" patternContentUnits=\"objectBoundingBox\" width=\"1\" height=\"1\"><image href=\"${src}\" x=\"0\" y=\"0\" width=\"1\" height=\"1\"/></pattern>`,\n ]\n }\n}\n","// Copyright (c) 2014 Rafael Caricio. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nvar GradientParser = GradientParser || {}\n\nGradientParser.parse = (function () {\n var tokens = {\n linearGradient: /^(\\-(webkit|o|ms|moz)\\-)?(linear\\-gradient)/i,\n repeatingLinearGradient:\n /^(\\-(webkit|o|ms|moz)\\-)?(repeating\\-linear\\-gradient)/i,\n radialGradient: /^(\\-(webkit|o|ms|moz)\\-)?(radial\\-gradient)/i,\n repeatingRadialGradient:\n /^(\\-(webkit|o|ms|moz)\\-)?(repeating\\-radial\\-gradient)/i,\n sideOrCorner:\n /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,\n extentKeywords:\n /^(closest\\-side|closest\\-corner|farthest\\-side|farthest\\-corner|contain|cover)/,\n positionKeywords: /^(left|center|right|top|bottom)/i,\n pixelValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))px/,\n percentageValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))\\%/,\n emValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))em/,\n angleValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))deg/,\n startCall: /^\\(/,\n endCall: /^\\)/,\n comma: /^,/,\n hexColor: /^\\#([0-9a-fA-F]+)/,\n literalColor: /^([a-zA-Z]+)/,\n rgbColor: /^rgb/i,\n rgbaColor: /^rgba/i,\n number: /^(([0-9]*\\.[0-9]+)|([0-9]+\\.?))/,\n }\n\n var input = ''\n\n function error(msg) {\n var err = new Error(input + ': ' + msg)\n err.source = input\n throw err\n }\n\n function getAST() {\n var ast = matchListDefinitions()\n\n if (input.length > 0) {\n error('Invalid input not EOF')\n }\n\n return ast\n }\n\n function matchListDefinitions() {\n return matchListing(matchDefinition)\n }\n\n function matchDefinition() {\n return (\n matchGradient(\n 'linear-gradient',\n tokens.linearGradient,\n matchLinearOrientation\n ) ||\n matchGradient(\n 'repeating-linear-gradient',\n tokens.repeatingLinearGradient,\n matchLinearOrientation\n ) ||\n matchGradient(\n 'radial-gradient',\n tokens.radialGradient,\n matchListRadialOrientations\n ) ||\n matchGradient(\n 'repeating-radial-gradient',\n tokens.repeatingRadialGradient,\n matchListRadialOrientations\n )\n )\n }\n\n function matchGradient(gradientType, pattern, orientationMatcher) {\n return matchCall(pattern, function (captures) {\n var orientation = orientationMatcher()\n if (orientation) {\n if (!scan(tokens.comma)) {\n error('Missing comma before color stops')\n }\n }\n\n return {\n type: gradientType,\n orientation: orientation,\n colorStops: matchListing(matchColorStop),\n }\n })\n }\n\n function matchCall(pattern, callback) {\n var captures = scan(pattern)\n\n if (captures) {\n if (!scan(tokens.startCall)) {\n error('Missing (')\n }\n\n var result = callback(captures)\n\n if (!scan(tokens.endCall)) {\n error('Missing )')\n }\n\n return result\n }\n }\n\n function matchLinearOrientation() {\n return matchSideOrCorner() || matchAngle()\n }\n\n function matchSideOrCorner() {\n return match('directional', tokens.sideOrCorner, 1)\n }\n\n function matchAngle() {\n return match('angular', tokens.angleValue, 1)\n }\n\n function matchListRadialOrientations() {\n var radialOrientations,\n radialOrientation = matchRadialOrientation(),\n lookaheadCache\n\n if (radialOrientation) {\n radialOrientations = []\n radialOrientations.push(radialOrientation)\n\n lookaheadCache = input\n if (scan(tokens.comma)) {\n radialOrientation = matchRadialOrientation()\n if (radialOrientation) {\n radialOrientations.push(radialOrientation)\n } else {\n input = lookaheadCache\n }\n }\n }\n\n return radialOrientations\n }\n\n function matchRadialOrientation() {\n var radialType = matchCircle() || matchEllipse()\n\n if (radialType) {\n radialType.at = matchAtPosition()\n } else {\n var extent = matchExtentKeyword()\n if (extent) {\n radialType = extent\n var positionAt = matchAtPosition()\n if (positionAt) {\n radialType.at = positionAt\n }\n } else {\n var defaultPosition = matchPositioning()\n if (defaultPosition) {\n radialType = {\n type: 'default-radial',\n at: defaultPosition,\n }\n }\n }\n }\n\n return radialType\n }\n\n function matchCircle() {\n var circle = match('shape', /^(circle)/i, 0)\n\n if (circle) {\n circle.style = matchLength() || matchExtentKeyword()\n }\n\n return circle\n }\n\n function matchEllipse() {\n var ellipse = match('shape', /^(ellipse)/i, 0)\n\n if (ellipse) {\n ellipse.style = matchDistance() || matchExtentKeyword()\n }\n\n return ellipse\n }\n\n function matchExtentKeyword() {\n return match('extent-keyword', tokens.extentKeywords, 1)\n }\n\n function matchAtPosition() {\n if (match('position', /^at/, 0)) {\n var positioning = matchPositioning()\n\n if (!positioning) {\n error('Missing positioning value')\n }\n\n return positioning\n }\n }\n\n function matchPositioning() {\n var location = matchCoordinates()\n\n if (location.x || location.y) {\n return {\n type: 'position',\n value: location,\n }\n }\n }\n\n function matchCoordinates() {\n return {\n x: matchDistance(),\n y: matchDistance(),\n }\n }\n\n function matchListing(matcher) {\n var captures = matcher(),\n result = []\n\n if (captures) {\n result.push(captures)\n while (scan(tokens.comma)) {\n captures = matcher()\n if (captures) {\n result.push(captures)\n } else {\n error('One extra comma')\n }\n }\n }\n\n return result\n }\n\n function matchColorStop() {\n var color = matchColor()\n\n if (!color) {\n error('Expected color definition')\n }\n\n color.length = matchDistance()\n return color\n }\n\n function matchColor() {\n return (\n matchHexColor() ||\n matchRGBAColor() ||\n matchRGBColor() ||\n matchLiteralColor()\n )\n }\n\n function matchLiteralColor() {\n return match('literal', tokens.literalColor, 0)\n }\n\n function matchHexColor() {\n return match('hex', tokens.hexColor, 1)\n }\n\n function matchRGBColor() {\n return matchCall(tokens.rgbColor, function () {\n return {\n type: 'rgb',\n value: matchListing(matchNumber),\n }\n })\n }\n\n function matchRGBAColor() {\n return matchCall(tokens.rgbaColor, function () {\n return {\n type: 'rgba',\n value: matchListing(matchNumber),\n }\n })\n }\n\n function matchNumber() {\n return scan(tokens.number)[1]\n }\n\n function matchDistance() {\n return (\n match('%', tokens.percentageValue, 1) ||\n matchPositionKeyword() ||\n matchLength()\n )\n }\n\n function matchPositionKeyword() {\n return match('position-keyword', tokens.positionKeywords, 1)\n }\n\n function matchLength() {\n return match('px', tokens.pixelValue, 1) || match('em', tokens.emValue, 1)\n }\n\n function match(type, pattern, captureIndex) {\n var captures = scan(pattern)\n if (captures) {\n return {\n type: type,\n value: captures[captureIndex],\n }\n }\n }\n\n function scan(regexp) {\n var captures, blankCaptures\n\n blankCaptures = /^[\\n\\r\\t\\s]+/.exec(input)\n if (blankCaptures) {\n consume(blankCaptures[0].length)\n }\n\n captures = regexp.exec(input)\n if (captures) {\n consume(captures[0].length)\n }\n\n return captures\n }\n\n function consume(size) {\n input = input.substr(size)\n }\n\n return function (code) {\n input = code.toString()\n return getAST()\n }\n})()\n\nexport default GradientParser\n","/**\n * CSS border radius to SVG path.\n */\n\nfunction resolveSize(a: number, b: number, limit: number) {\n if (limit < a + b) {\n if (limit / 2 < a && limit / 2 < b) {\n a = b = limit / 2\n } else if (limit / 2 < a) {\n a = limit - b\n } else if (limit / 2 < b) {\n b = limit - a\n }\n }\n return [a, b]\n}\n\nexport default function radius(\n {\n left,\n top,\n width,\n height,\n }: {\n left: number\n top: number\n width: number\n height: number\n },\n style: Record<string, number>\n) {\n let {\n borderTopLeftRadius,\n borderTopRightRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n } = style\n\n borderTopLeftRadius = Math.min(borderTopLeftRadius || 0, width, height)\n borderTopRightRadius = Math.min(borderTopRightRadius || 0, width, height)\n borderBottomLeftRadius = Math.min(borderBottomLeftRadius || 0, width, height)\n borderBottomRightRadius = Math.min(\n borderBottomRightRadius || 0,\n width,\n height\n )\n\n if (\n !borderTopLeftRadius &&\n !borderTopRightRadius &&\n !borderBottomLeftRadius &&\n !borderBottomRightRadius\n ) {\n return ''\n }\n\n // Limit the radius size.\n ;[borderTopLeftRadius, borderTopRightRadius] = resolveSize(\n borderTopLeftRadius,\n borderTopRightRadius,\n width\n )\n ;[borderTopLeftRadius, borderBottomLeftRadius] = resolveSize(\n borderTopLeftRadius,\n borderBottomLeftRadius,\n height\n )\n ;[borderTopRightRadius, borderBottomRightRadius] = resolveSize(\n borderTopRightRadius,\n borderBottomRightRadius,\n height\n )\n ;[borderBottomLeftRadius, borderBottomRightRadius] = resolveSize(\n borderBottomLeftRadius,\n borderBottomRightRadius,\n width\n )\n\n // Generate the path (GitHub Copilot wrote these for me).\n return `M${left + borderTopLeftRadius},${top} h${\n width - borderTopLeftRadius - borderTopRightRadius\n } a${borderTopRightRadius},${borderTopRightRadius} 0 0 1 ${borderTopRightRadius},${borderTopRightRadius} v${\n height - borderTopRightRadius - borderBottomRightRadius\n } a${borderBottomRightRadius},${borderBottomRightRadius} 0 0 1 ${-borderBottomRightRadius},${borderBottomRightRadius} h${\n borderBottomRightRadius + borderBottomLeftRadius - width\n } a${borderBottomLeftRadius},${borderBottomLeftRadius} 0 0 1 ${-borderBottomLeftRadius},${-borderBottomLeftRadius} v${\n borderBottomLeftRadius + borderTopLeftRadius - height\n } a${borderTopLeftRadius},${borderTopLeftRadius} 0 0 1 ${borderTopLeftRadius},${-borderTopLeftRadius}`\n}\n","// @TODO: It seems that SVG filters are pretty expensive for resvg, PNG\n// generation time 10x'd when adding this filter (WASM in browser).\n// https://drafts.fxtf.org/filter-effects/#feGaussianBlurElement\n\nexport default function shadow(\n { id, width, height }: { id: number; width: number; height: number },\n style: Record<string, any>\n) {\n if (\n !style.shadowColor ||\n !style.shadowOffset ||\n typeof style.shadowRadius === 'undefined'\n ) {\n return ''\n }\n\n const left = Math.min(style.shadowOffset.width - style.shadowRadius * 2, 0)\n const right = Math.max(\n style.shadowOffset.width + style.shadowRadius * 2 + width,\n width\n )\n const top = Math.min(style.shadowOffset.height - style.shadowRadius * 2, 0)\n const bottom = Math.max(\n style.shadowOffset.height + style.shadowRadius * 2 + height,\n height\n )\n\n return `<defs><filter id=\"satori_s-${id}\" x=\"${(left / width) * 100}%\" y=\"${\n (top / height) * 100\n }%\" width=\"${((right - left) / width) * 100}%\" height=\"${\n ((bottom - top) / height) * 100\n }%\"><feDropShadow dx=\"${style.shadowOffset.width}\" dy=\"${\n style.shadowOffset.height\n }\" stdDeviation=\"${style.shadowRadius}\" flood-color=\"${\n style.shadowColor\n }\" flood-opacity=\"1\"/></filter></defs>`\n}\n","import radius from './border-radius'\nimport shadow from './box-shadow'\n\nexport default function image(\n {\n id,\n left,\n top,\n width,\n height,\n src,\n debug,\n }: {\n id: number\n left: number\n top: number\n width: number\n height: number\n src: string\n isInheritingTransform: boolean\n debug?: boolean\n },\n style: Record<string, number | string>\n) {\n if (style.display === 'none') return ''\n\n let clip = ''\n let opacity = 1\n\n const preserveAspectRatio =\n style.objectFit === 'contain'\n ? 'xMidYMid'\n : style.objectFit === 'cover'\n ? 'xMidYMid slice'\n : 'none'\n\n const path = radius(\n { left, top, width, height },\n style as Record<string, number>\n )\n\n if (path) {\n clip = `<clipPath id=\"satori_c-${id}\"><path x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" d=\"${path}\"></path></clipPath>`\n }\n\n if (style.opacity) {\n opacity = +style.opacity\n }\n\n const filter = shadow({ width, height, id }, style)\n\n return `${filter}${\n filter ? `<g filter=\"url(#satori_s-${id})\">` : ''\n }${clip}<image href=\"${src}\" x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" preserveAspectRatio=\"${preserveAspectRatio}\" ${\n clip ? `clip-path=\"url(#satori_c-${id})\"` : ''\n } ${opacity !== 1 ? `opacity=\"${opacity}\"` : ''}></image>${\n filter ? '</g>' : ''\n }`\n}\n","/**\n * This class handles everything related to fonts.\n */\n\nimport opentype from 'opentype.js'\n\ntype Weight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900\ntype WeigthName = 'normal' | 'bold'\ntype Style = 'normal' | 'italic'\n\nexport interface FontOptions {\n data: Buffer | ArrayBuffer\n name: string\n weight?: Weight\n style?: Style\n}\n\nexport default class FontLoader {\n defaultFont: opentype.Font\n fonts = new Map<string, [opentype.Font, Weight?, Style?][]>()\n constructor(fontOptions: FontOptions[]) {\n for (const fontOption of fontOptions) {\n const data = fontOption.data\n const font =\n 'buffer' in data\n ? opentype.parse(\n // Buffer to ArrayBuffer.\n data.buffer.slice(\n data.byteOffset,\n data.byteOffset + data.byteLength\n )\n )\n : opentype.parse(data)\n\n // We use the first font as the default font fallback.\n if (!this.defaultFont) this.defaultFont = font\n\n if (!this.fonts.has(fontOption.name)) {\n this.fonts.set(fontOption.name, [])\n }\n this.fonts\n .get(fontOption.name)\n .push([font, fontOption.weight, fontOption.style])\n }\n }\n\n // Get font by name and weight.\n private get({\n name,\n weight,\n style,\n }: {\n name: string\n weight: Weight | WeigthName\n style: Style\n }) {\n if (!this.fonts.has(name)) {\n return this.defaultFont\n }\n\n if (weight === 'normal') weight = 400\n if (weight === 'bold') weight = 700\n\n // Fallback to the closest weight and style according to the strategy here:\n // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#fallback_weights\n const fonts = [...this.fonts.get(name)]\n fonts.sort(([_, weight1, style1], [__, weight2, style2]) => {\n if (weight1 !== weight2) {\n // Put the defined weight first.\n if (!weight1) return 1\n if (!weight2) return -1\n\n // Exact match.\n if (weight1 === weight) return -1\n if (weight2 === weight) return 1\n\n // 400 and 500.\n if (weight === 400 && weight1 === 500) return -1\n if (weight === 500 && weight1 === 400) return -1\n if (weight === 400 && weight2 === 500) return 1\n if (weight === 500 && weight2 === 400) return 1\n\n // Less than 400.\n if (weight < 400) {\n if (weight1 < weight && weight2 < weight) return weight2 - weight1\n if (weight1 < weight) return -1\n if (weight2 < weight) return 1\n return weight1 - weight2\n }\n\n // Greater than 500.\n if (weight < weight1 && weight < weight2) return weight1 - weight2\n if (weight < weight1) return -1\n if (weight < weight2) return 1\n return weight2 - weight1\n }\n\n if (style1 !== style2) {\n // Exact match.\n if (style1 === style) return -1\n if (style2 === style) return 1\n }\n\n return -1\n })\n return fonts[0][0]\n }\n\n public getFont({\n fontFamily,\n fontWeight = 400,\n fontStyle = 'normal',\n }: {\n fontFamily: string\n fontWeight?: Weight | WeigthName\n fontStyle?: Style\n }) {\n return this.get({\n name: fontFamily,\n weight: fontWeight,\n style: fontStyle,\n })\n }\n\n public measure(\n font: opentype.Font,\n content: string,\n {\n fontSize,\n letterSpacing = 0,\n }: {\n fontSize: number\n letterSpacing: number\n }\n ) {\n return {\n width: font.getAdvanceWidth(content, fontSize, {\n letterSpacing: letterSpacing / fontSize,\n }),\n ascent: (font.ascender / font.unitsPerEm) * fontSize,\n descent: -(font.descender / font.unitsPerEm) * fontSize,\n }\n }\n\n public getSVG(\n font: opentype.Font,\n content: string,\n {\n fontSize,\n top,\n left,\n letterSpacing = 0,\n }: {\n fontSize: number\n top: number\n left: number\n letterSpacing: number\n }\n ) {\n // Since we need to pass the baseline position, add the ascender to the top.\n top += (font.ascender / font.unitsPerEm) * fontSize\n\n return font\n .getPath(content, left, top, fontSize, {\n letterSpacing: letterSpacing / fontSize,\n })\n .toPathData(2)\n }\n\n public getAscent(\n font: opentype.Font,\n {\n fontSize,\n }: {\n fontSize: number\n }\n ) {\n return (font.ascender / font.unitsPerEm) * fontSize\n }\n}\n","export default function svg(\n {\n width,\n height,\n content,\n }: {\n width: number\n height: number\n content: string\n },\n style?: Record<string, number | string>\n) {\n return `<svg width=\"${width}\" height=\"${height}\" viewBox=\"0 0 ${width} ${height}\" xmlns=\"http://www.w3.org/2000/svg\">${content}</sv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MF,EACA,CACA,MAAO,eAAe,cAAkB,mBAAwB,KAAS,yCAA8C,UlBK1G,YACb,EACA,EACQ,CACR,GAAM,GAAO,IACb,GAAI,CAAC,EAAM,KAAM,IAAI,OAAM,8BAE3B,GAAM,GAAO,GAAI,GAAW,EAAQ,OAE9B,EAAO,EAAK,KAAK,SACvB,EAAK,SAAS,EAAQ,OACtB,EAAK,UAAU,EAAQ,QACvB,EAAK,iBAAiB,EAAK,oBAC3B,EAAK,YAAY,EAAK,WACtB,EAAK,gBAAgB,EAAK,YAC1B,EAAK,cAAc,EAAK,kBACxB,EAAK,kBAAkB,EAAK,oBAE5B,GAAM,GAAU,EAAO,EAAS,CAC9B,GAAI,EACJ,YAAa,GACb,eAAgB,CACd,SAAU,GACV,WAAY,SACZ,WAAY,QACZ,UAAW,SACX,WAAY,IACZ,MAAO,QACP,QAAS,GAEX,OAAQ,EACR,OACA,UAAW,EAAQ,UACnB,MAAO,EAAQ,QAGjB,EAAQ,OACR,EAAK,gBAAgB,EAAQ,MAAO,EAAQ,OAAQ,EAAK,eAEzD,GAAM,GAAU,EAAQ,KAAK,CAAC,EAAG,IAAI,MACrC,MAAO,IAAI,CAAE,MAAO,EAAQ,MAAO,OAAQ,EAAQ,OAAQ","names":[]}
1
+ {"version":3,"sources":["../../node_modules/.pnpm/tsup@5.11.13_typescript@4.5.5/node_modules/tsup/assets/esm_shims.js","../../src/yoga-prebuilt.ts","../../src/index.ts","../../src/satori.ts","../../src/yoga.ts","../../src/layout.ts","../../src/utils.ts","../../src/handler/index.ts","../../src/handler/presets.ts","../../src/handler/inheritable.ts","../../src/handler/expand.ts","../../src/text.ts","../../src/builder/text.ts","../../src/builder/transform.ts","../../src/builder/shadow.ts","../../src/builder/rect.ts","../../src/builder/background-image.ts","../../deps/gradient-parser/index.js","../../src/builder/border-radius.ts","../../src/builder/image.ts","../../src/font.ts","../../src/builder/svg.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import * as Yoga from 'yoga-layout-prebuilt'\n\nexport default Yoga\n","export * from './satori'\nexport { default } from './satori'\n","import type { ReactNode } from 'react'\n\nimport getYoga, { init } from './yoga'\nimport layout from './layout'\nimport FontLoader, { FontOptions } from './font'\nimport svg from './builder/svg'\n\nexport interface SatoriOptions {\n width: number\n height: number\n fonts: FontOptions[]\n embedFont?: boolean\n debug?: boolean\n graphemeImages?: Record<string, string>\n}\n\nexport { init }\n\nexport default function satori(\n element: ReactNode,\n options: SatoriOptions\n): string {\n const Yoga = getYoga()\n if (!Yoga) throw new Error('Satori is not initialized.')\n\n const font = new FontLoader(options.fonts)\n\n const root = Yoga.Node.create()\n root.setWidth(options.width)\n root.setHeight(options.height)\n root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW)\n root.setFlexWrap(Yoga.WRAP_WRAP)\n root.setAlignContent(Yoga.ALIGN_AUTO)\n root.setAlignItems(Yoga.ALIGN_FLEX_START)\n root.setJustifyContent(Yoga.JUSTIFY_FLEX_START)\n\n const handler = layout(element, {\n id: 1,\n parentStyle: {},\n inheritedStyle: {\n fontSize: 16,\n fontWeight: 'normal',\n fontFamily: 'serif',\n fontStyle: 'normal',\n lineHeight: 1.2,\n color: 'black',\n opacity: 1,\n },\n parent: root,\n font,\n embedFont: options.embedFont,\n debug: options.debug,\n graphemeImages: options.graphemeImages,\n })\n\n handler.next()\n root.calculateLayout(options.width, options.height, Yoga.DIRECTION_LTR)\n\n const content = handler.next([0, 0]).value\n return svg({ width: options.width, height: options.height, content })\n}\n","let Yoga: typeof import('yoga-layout')\n\n// @ts-ignore\nif (WASM) {\n // For WASM build, we don't include the prebuilt version of Yoga but let the\n // user specify the module manually.\n} else {\n const mod = require('./yoga-prebuilt') as any\n if (mod.default) {\n Yoga = mod.default\n } else {\n Yoga = mod\n }\n}\n\nexport function init(yoga: typeof Yoga) {\n Yoga = yoga\n}\n\nexport default function getYoga(): typeof Yoga {\n return Yoga\n}\n","/**\n * This module is used to calculate the layout of the current sub-tree.\n */\n\nimport type { ReactNode } from 'react'\nimport type { YogaNode } from 'yoga-layout'\n\nimport getYoga from './yoga'\nimport { isReactElement, isClass } from './utils'\nimport handler from './handler'\nimport FontLoader from './font'\nimport layoutText from './text'\nimport rect from './builder/rect'\nimport image from './builder/image'\n\nexport interface LayoutContext {\n id: number\n parentStyle: Record<string, number | string>\n inheritedStyle: Record<string, number | string>\n isInheritingTransform?: boolean\n parent: YogaNode\n font: FontLoader\n embedFont: boolean\n debug?: boolean\n graphemeImages?: Record<string, string>\n}\n\nexport default function* layout(\n element: ReactNode,\n context: LayoutContext\n): Generator<undefined, string, [number, number]> {\n const Yoga = getYoga()\n const {\n id,\n inheritedStyle,\n parent,\n font,\n debug,\n embedFont = true,\n graphemeImages,\n } = context\n\n // 1. Pre-process the node.\n if (element === null || typeof element === 'undefined') {\n yield\n return ''\n }\n\n // Not a normal element.\n if (!isReactElement(element) || typeof element.type === 'function') {\n let iter: ReturnType<typeof layout>\n\n if (!isReactElement(element)) {\n // Process as text node.\n iter = layoutText(String(element), context)\n } else {\n if (isClass(element.type as Function)) {\n throw new Error('Class component is not supported.')\n }\n // If it's a custom component, Satori strictly requires it to be pure,\n // stateless, and not relying on any React APIs such as hooks or suspense.\n // So we can safely evaluate it to render. Otherwise, an error will be\n // thrown by React.\n iter = layout((element.type as Function)(element.props), context)\n }\n\n iter.next()\n const offset = yield\n return iter.next(offset).value\n }\n\n // Process as element.\n const { type, props } = element\n const { style, children } = props\n\n const node = Yoga.Node.create()\n parent.insertChild(node, parent.getChildCount())\n\n const [computedStyle, newInheritableStyle] = handler(\n node,\n type,\n inheritedStyle,\n style,\n props\n )\n // If the element is inheriting the parent `transform`, or applying its own.\n // This affects the coordinate system.\n const isInheritingTransform =\n computedStyle.transform === inheritedStyle.transform\n if (!isInheritingTransform) {\n ;(computedStyle.transform as any).__parent = inheritedStyle.transform\n }\n\n // 2. Do layout recursively for its children.\n const normalizedChildren =\n typeof children === 'undefined' ? [] : [].concat(children)\n const iterators: ReturnType<typeof layout>[] = []\n\n let i = 0\n for (const child of normalizedChildren) {\n const iter = layout(child, {\n id: id * normalizedChildren.length + ++i,\n parentStyle: computedStyle,\n inheritedStyle: newInheritableStyle,\n isInheritingTransform: true,\n parent: node,\n font,\n embedFont,\n debug,\n graphemeImages,\n })\n iter.next()\n iterators.push(iter)\n }\n\n // 3. Post-process the node.\n const [x, y] = yield\n\n if (computedStyle.position === 'absolute') {\n node.calculateLayout()\n }\n\n let { left, top, width, height } = node.getComputedLayout()\n\n // Attach offset to the current node.\n left += x\n top += y\n\n let result = ''\n\n if (type === 'img') {\n result = image(\n {\n id,\n left,\n top,\n width,\n height,\n src: props.src,\n isInheritingTransform,\n debug,\n },\n computedStyle\n )\n } else {\n result = rect(\n { id, left, top, width, height, isInheritingTransform, debug },\n computedStyle\n )\n }\n\n for (const iter of iterators) {\n result += iter.next([left, top]).value\n }\n\n return result\n}\n","import type { ReactNode, ReactElement } from 'react'\n\nexport function isReactElement(node: ReactNode): node is ReactElement {\n const type = typeof node\n if (\n type === 'number' ||\n type === 'bigint' ||\n type === 'string' ||\n type === 'boolean'\n ) {\n return false\n }\n return true\n}\n\nexport function isClass(f: Function) {\n return /^class\\s/.test(Function.prototype.toString.call(f))\n}\n\n// Multiplies two 2d transform matrices.\nexport function multiply(m1: number[], m2: number[]) {\n return [\n m1[0] * m2[0] + m1[2] * m2[1],\n m1[1] * m2[0] + m1[3] * m2[1],\n m1[0] * m2[2] + m1[2] * m2[3],\n m1[1] * m2[2] + m1[3] * m2[3],\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5],\n ]\n}\n\nexport function v(\n field: string | number,\n map: Record<string, any>,\n fallback: any\n) {\n const value = map[field]\n return typeof value === 'undefined' ? fallback : value\n}\n","/**\n * Handler to update the Yoga node properties with the given element type and\n * style. Each supported element has its own preset styles, so this function\n * also returns the inherited style for children of the element.\n */\n\nimport type { YogaNode } from 'yoga-layout'\n\nimport getYoga from '../yoga'\nimport presets from './presets'\nimport inheritable from './inheritable'\nimport expand from './expand'\nimport { v } from '../utils'\n\ntype SatoriElement = keyof typeof presets\n\nexport default function handler(\n node: YogaNode,\n type: SatoriElement | string,\n inheritedStyle: Record<string, string | number>,\n definedStyle: Record<string, string | number>,\n props: Record<string, any>\n): [Record<string, string | number>, Record<string, string | number>] {\n const Yoga = getYoga()\n\n // Extend the default style with defined and inherited styles.\n const style = {\n ...inheritedStyle,\n ...expand(presets[type], inheritedStyle),\n ...expand(definedStyle, inheritedStyle),\n }\n\n if (type === 'img') {\n const width = parseInt(props.width)\n const height = parseInt(props.height)\n const r = height / width\n if (!style.width) style.width = width\n if (!style.height) style.height = r * (style.width as number)\n }\n\n // Set properties for Yoga.\n node.setDisplay(\n v(\n style.display,\n {\n flex: Yoga.DISPLAY_FLEX,\n none: Yoga.DISPLAY_NONE,\n },\n Yoga.DISPLAY_FLEX\n )\n )\n\n // if (style.alignContent) {\n node.setAlignContent(\n v(\n style.alignContent,\n {\n stretch: Yoga.ALIGN_STRETCH,\n center: Yoga.ALIGN_CENTER,\n 'flex-start': Yoga.ALIGN_FLEX_START,\n 'flex-end': Yoga.ALIGN_FLEX_END,\n 'space-between': Yoga.ALIGN_SPACE_BETWEEN,\n 'space-around': Yoga.ALIGN_SPACE_AROUND,\n baseline: Yoga.ALIGN_BASELINE,\n normal: Yoga.ALIGN_AUTO,\n },\n Yoga.ALIGN_AUTO\n )\n )\n // }\n\n node.setAlignItems(\n v(\n style.alignItems,\n {\n stretch: Yoga.ALIGN_STRETCH,\n center: Yoga.ALIGN_CENTER,\n 'flex-start': Yoga.ALIGN_FLEX_START,\n 'flex-end': Yoga.ALIGN_FLEX_END,\n baseline: Yoga.ALIGN_BASELINE,\n normal: Yoga.ALIGN_AUTO,\n },\n Yoga.ALIGN_FLEX_START\n )\n )\n node.setAlignSelf(\n v(\n style.alignSelf,\n {\n stretch: Yoga.ALIGN_STRETCH,\n center: Yoga.ALIGN_CENTER,\n 'flex-start': Yoga.ALIGN_FLEX_START,\n 'flex-end': Yoga.ALIGN_FLEX_END,\n baseline: Yoga.ALIGN_BASELINE,\n normal: Yoga.ALIGN_AUTO,\n },\n Yoga.ALIGN_AUTO\n )\n )\n node.setJustifyContent(\n v(\n style.justifyContent,\n {\n center: Yoga.JUSTIFY_CENTER,\n 'flex-start': Yoga.JUSTIFY_FLEX_START,\n 'flex-end': Yoga.JUSTIFY_FLEX_END,\n 'space-between': Yoga.JUSTIFY_SPACE_BETWEEN,\n 'space-around': Yoga.JUSTIFY_SPACE_AROUND,\n },\n Yoga.JUSTIFY_FLEX_START\n )\n )\n // @TODO: node.setAspectRatio\n\n node.setFlexDirection(\n v(\n style.flexDirection,\n {\n row: Yoga.FLEX_DIRECTION_ROW,\n column: Yoga.FLEX_DIRECTION_COLUMN,\n 'row-reverse': Yoga.FLEX_DIRECTION_ROW_REVERSE,\n 'column-reverse': Yoga.FLEX_DIRECTION_COLUMN_REVERSE,\n },\n Yoga.FLEX_DIRECTION_ROW\n )\n )\n node.setFlexWrap(\n v(\n style.flexWrap,\n {\n wrap: Yoga.WRAP_WRAP,\n nowrap: Yoga.WRAP_NO_WRAP,\n 'wrap-reverse': Yoga.WRAP_WRAP_REVERSE,\n },\n Yoga.WRAP_WRAP\n )\n )\n\n // @TODO: node.setFlex\n\n if (typeof style.flexBasis !== 'undefined') {\n // We can't use `auto` here due to this:\n // https://github.com/facebook/yoga/pull/1112\n // @TODO: We need a fork to add this API.\n node.setFlexBasis(style.flexBasis)\n }\n node.setFlexGrow(\n typeof style.flexGrow === 'undefined' ? 0 : (style.flexGrow as number)\n )\n node.setFlexShrink(\n typeof style.flexShrink === 'undefined' ? 1 : (style.flexShrink as number)\n )\n\n if (typeof style.maxHeight !== 'undefined') {\n node.setMaxHeight(style.maxHeight)\n }\n if (typeof style.maxWidth !== 'undefined') {\n node.setMaxWidth(style.maxWidth)\n }\n if (typeof style.minHeight !== 'undefined') {\n node.setMinHeight(style.minHeight)\n }\n if (typeof style.minWidth !== 'undefined') {\n node.setMinWidth(style.minWidth)\n }\n\n node.setOverflow(\n v(\n style.overflow,\n {\n visible: Yoga.OVERFLOW_VISIBLE,\n hidden: Yoga.OVERFLOW_HIDDEN,\n },\n Yoga.OVERFLOW_VISIBLE\n )\n )\n\n node.setMargin(Yoga.EDGE_TOP, (style.marginTop as number) || 0)\n node.setMargin(Yoga.EDGE_BOTTOM, (style.marginBottom as number) || 0)\n node.setMargin(Yoga.EDGE_LEFT, (style.marginLeft as number) || 0)\n node.setMargin(Yoga.EDGE_RIGHT, (style.marginRight as number) || 0)\n\n // @TODO: Add directional border support.\n node.setBorder(Yoga.EDGE_TOP, (style.borderWidth as number) || 0)\n node.setBorder(Yoga.EDGE_BOTTOM, (style.borderWidth as number) || 0)\n node.setBorder(Yoga.EDGE_LEFT, (style.borderWidth as number) || 0)\n node.setBorder(Yoga.EDGE_RIGHT, (style.borderWidth as number) || 0)\n\n node.setPadding(Yoga.EDGE_TOP, style.paddingTop || 0)\n node.setPadding(Yoga.EDGE_BOTTOM, style.paddingBottom || 0)\n node.setPadding(Yoga.EDGE_LEFT, style.paddingLeft || 0)\n node.setPadding(Yoga.EDGE_RIGHT, style.paddingRight || 0)\n\n node.setPositionType(\n v(\n style.position,\n {\n absolute: Yoga.POSITION_TYPE_ABSOLUTE,\n relative: Yoga.POSITION_TYPE_RELATIVE,\n },\n Yoga.POSITION_TYPE_RELATIVE\n )\n )\n\n if (typeof style.top !== 'undefined') {\n node.setPosition(Yoga.EDGE_TOP, style.top)\n }\n if (typeof style.bottom !== 'undefined') {\n node.setPosition(Yoga.EDGE_BOTTOM, style.bottom)\n }\n if (typeof style.left !== 'undefined') {\n node.setPosition(Yoga.EDGE_LEFT, style.left)\n }\n if (typeof style.right !== 'undefined') {\n node.setPosition(Yoga.EDGE_RIGHT, style.right)\n }\n\n if (typeof style.height !== 'undefined') {\n node.setHeight(style.height)\n } else {\n node.setHeightAuto()\n }\n if (typeof style.width !== 'undefined') {\n node.setWidth(style.width)\n } else {\n node.setWidthAuto()\n }\n\n return [style, inheritable(style)]\n}\n","/**\n * Pre-defined styles for elements. Here we hand pick some from Chromium's\n * default styles:\n * https://chromium.googlesource.com/chromium/blink/+/master/Source/core/css/html.css\n *\n * We try to only include commonly used, styling elements rather than senmantic elements.\n */\n\nexport default {\n // Generic block-level elements\n p: {\n display: 'block',\n marginTop: '1em',\n marginBottom: '1em',\n },\n div: {\n display: 'block',\n },\n blockquote: {\n display: 'block',\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: 40,\n marginRight: 40,\n },\n center: {\n display: 'block',\n textAlign: 'center',\n },\n hr: {\n display: 'block',\n marginTop: '0.5em',\n marginBottom: '0.5em',\n marginLeft: 'auto',\n marginRight: 'auto',\n borderWidth: 1,\n borderStyle: 'inset',\n },\n // Heading elements\n h1: {\n display: 'block',\n fontSize: '2em',\n marginTop: '0.67em',\n marginBottom: '0.67em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n h2: {\n display: 'block',\n fontSize: '1.5em',\n marginTop: '0.83em',\n marginBottom: '0.83em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n h3: {\n display: 'block',\n fontSize: '1.17em',\n marginTop: '1em',\n marginBottom: '1em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n h4: {\n display: 'block',\n marginTop: '1.33em',\n marginBottom: '1.33em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n h5: {\n display: 'block',\n fontSize: '0.83em',\n marginTop: '1.67em',\n marginBottom: '1.67em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n h6: {\n display: 'block',\n fontSize: '0.67em',\n marginTop: '2.33em',\n marginBottom: '2.33em',\n marginLeft: 0,\n marginRight: 0,\n fontWeight: 'bold',\n },\n // Tables\n // Lists\n // Form elements\n // Inline elements\n u: {\n textDecoration: 'underline',\n },\n strong: {\n fontWeight: 'bold',\n },\n b: {\n fontWeight: 'bold',\n },\n i: {\n fontStyle: 'italic',\n },\n em: {\n fontStyle: 'italic',\n },\n code: {\n fontFamily: 'monospace',\n },\n kbd: {\n fontFamily: 'monospace',\n },\n pre: {\n display: 'block',\n fontFamily: 'monospace',\n whiteSpace: 'pre',\n marginTop: '1em',\n marginBottom: '1em',\n },\n mark: {\n backgroundColor: 'yellow',\n color: 'black',\n },\n big: {\n fontSize: 'larger',\n },\n small: {\n fontSize: 'smaller',\n },\n s: {\n textDecoration: 'line-through',\n },\n}\n","const list = new Set([\n 'color',\n 'font',\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontWeight',\n 'lineHeight',\n 'textAlign',\n 'textTransform',\n 'whiteSpace',\n 'letterSpacing',\n 'transform',\n 'wordBreak',\n 'textShadowOffset',\n 'textShadowColor',\n 'textShadowRadius',\n\n // Special case: SVG doesn't apply opacity to children elements so we need to\n // make it inheritable here.\n 'opacity',\n])\n\nexport default function inheritable(style: Record<string, any>) {\n const inheritedStyle: Record<string, any> = {}\n for (const prop in style) {\n if (list.has(prop)) {\n inheritedStyle[prop] = style[prop]\n }\n }\n return inheritedStyle\n}\n","/**\n * This module expands the CSS properties to get rid of shorthands, as well as\n * cleaning up some properties.\n */\n\nimport { getPropertyName, getStylesForProperty } from 'css-to-react-native'\nimport CssDimension from 'parse-css-dimension'\nimport { parseElementStyle } from 'css-background-parser'\nimport { multiply } from '../utils'\n\n// https://react-cn.github.io/react/tips/style-props-value-px.html\nconst optOutPx = new Set([\n 'flex',\n 'flexGrow',\n 'flexShrink',\n 'flexBasis',\n 'fontWeight',\n 'lineHeight',\n 'opacity',\n 'scale',\n 'scaleX',\n 'scaleY',\n])\n\nconst baseMatrix = [1, 0, 0, 1, 0, 0]\n\nfunction purify(name: string, value?: string | number) {\n if (typeof value === 'number') {\n if (!optOutPx.has(name)) return value + 'px'\n return String(value)\n }\n // @TODO: For `transform`, we need to convert relative values to absolute\n // values here.\n return value\n}\n\nfunction lengthToNumber(\n length: string | number,\n baseFontSize: number\n): number | undefined {\n if (typeof length === 'number') return length\n\n // Convert em and rem values to number (px), convert rad to deg.\n try {\n const parsed = new CssDimension(length)\n if (parsed.type === 'length') {\n switch (parsed.unit) {\n case 'em':\n return parsed.value * baseFontSize\n case 'rem':\n return parsed.value * 16\n default:\n return parsed.value\n }\n } else if (parsed.type === 'angle') {\n switch (parsed.unit) {\n case 'deg':\n return parsed.value\n case 'rad':\n return (parsed.value * 180) / Math.PI\n default:\n return parsed.value\n }\n }\n } catch (err) {}\n}\n\nexport default function expand(\n style: Record<string, string | number>,\n inheritedStyle: Record<string, string | number>\n): Record<string, string | number> {\n const rules = []\n for (const prop in style) {\n const name = getPropertyName(prop)\n rules.push([name, purify(name, style[prop])])\n }\n const transformedStyle = rules.reduce((accum, rule) => {\n const propertyName = getPropertyName(rule[0])\n const value = rule[1]\n return Object.assign(accum, getStylesForProperty(propertyName, value, true))\n }, {})\n\n // Parse background images.\n if (transformedStyle.backgroundImage) {\n const { backgrounds } = parseElementStyle(transformedStyle)\n transformedStyle.backgroundImage = backgrounds\n }\n\n // Calculate the base font size.\n let baseFontSize: number =\n transformedStyle.fontSize || inheritedStyle.fontSize\n if (typeof baseFontSize === 'string') {\n try {\n const parsed = new CssDimension(baseFontSize)\n switch (parsed.unit) {\n case 'em':\n baseFontSize = parsed.value * (inheritedStyle.fontSize as number)\n break\n case 'rem':\n baseFontSize = parsed.value * 16\n break\n }\n } catch (err) {\n baseFontSize = 16\n }\n }\n if (typeof transformedStyle.fontSize !== 'undefined') {\n transformedStyle.fontSize = baseFontSize\n }\n\n for (const prop in transformedStyle) {\n let value = transformedStyle[prop]\n\n // Convert em and rem values to px (number).\n if (typeof value === 'string') {\n const len = lengthToNumber(value, baseFontSize)\n if (typeof len !== 'undefined') transformedStyle[prop] = len\n value = transformedStyle[prop]\n }\n\n // Inherit the opacity.\n if (prop === 'opacity') {\n value = transformedStyle[prop] =\n value * (inheritedStyle.opacity as number)\n }\n\n // Handle CSS transforms To make it easier, we convert different transform\n // types directly to a matrix and apply it recursively to all its children.\n // @TODO: We need to convert relative values (50%) to absolute values. This\n // is pretty tricky to support as we need an extra pass to handle them after\n // the full layout pass.\n if (prop === 'transform') {\n let matrix = [...baseMatrix]\n const transforms = value as { [type: string]: number | string }[]\n\n // Transforms are applied from right to left.\n for (const transform of transforms) {\n const type = Object.keys(transform)[0]\n const v = transform[type]\n const len = typeof v === 'string' ? lengthToNumber(v, baseFontSize) : v\n\n const transformMatrix = [...baseMatrix]\n switch (type) {\n case 'translateX':\n transformMatrix[4] = len\n break\n case 'translateY':\n transformMatrix[5] = len\n break\n case 'scaleX':\n transformMatrix[0] = len\n break\n case 'scaleY':\n transformMatrix[3] = len\n break\n case 'rotate':\n const rad = (len * Math.PI) / 180\n const c = Math.cos(rad)\n const s = Math.sin(rad)\n transformMatrix[0] = c\n transformMatrix[1] = s\n transformMatrix[2] = -s\n transformMatrix[3] = c\n break\n case 'skewX':\n transformMatrix[2] = Math.tan((len * Math.PI) / 180)\n break\n case 'skewY':\n transformMatrix[1] = Math.tan((len * Math.PI) / 180)\n break\n }\n matrix = multiply(transformMatrix, matrix)\n }\n\n transformedStyle.transform = matrix\n }\n }\n\n return transformedStyle\n}\n","/**\n * This module calculates the layout of a text string. Currently the only\n * supported inline node is text. All other nodes are using block layout.\n */\nimport type { LayoutContext } from './layout'\n\nimport { LineBreaker } from 'css-line-break'\nimport { splitGraphemes } from 'text-segmentation'\n\nimport getYoga from './yoga'\nimport { v } from './utils'\nimport text from './builder/text'\nimport shadow from './builder/shadow'\n\n// @TODO: Support \"lang\" attribute to modify the locale\nconst locale = 'en'\n\nconst INTL_SEGMENTER_SUPPORTED =\n typeof Intl !== 'undefined' && 'Segmenter' in Intl\n\nconst wordSegmenter = INTL_SEGMENTER_SUPPORTED\n ? new (Intl as any).Segmenter(locale, { granularity: 'word' })\n : null\nconst graphemeSegmenter = INTL_SEGMENTER_SUPPORTED\n ? new (Intl as any).Segmenter(locale, {\n granularity: 'grapheme',\n })\n : null\n\n// Implementation modified from\n// https://github.com/niklasvh/html2canvas/blob/6521a487d78172f7179f7c973c1a3af40eb92009/src/css/layout/text.ts\n// https://drafts.csswg.org/css-text/#word-separator\nconst wordSeparators = [\n 0x0020, 0x00a0, 0x1361, 0x10100, 0x10101, 0x1039, 0x1091,\n]\n\nconst breakWords = (str: string): string[] => {\n const breaker = LineBreaker(str, {\n lineBreak: 'strict',\n wordBreak: 'normal',\n })\n\n const words = []\n let bk\n\n while (!(bk = breaker.next()).done) {\n if (bk.value) {\n const value = bk.value.slice()\n const codePoints = [].map.call(value, (char) => char.codePointAt(0))\n let word = ''\n codePoints.forEach((codePoint) => {\n if (!wordSeparators.includes(codePoint)) {\n word += String.fromCodePoint(codePoint)\n } else {\n if (word.length) {\n words.push(word)\n }\n words.push(String.fromCodePoint(codePoint))\n word = ''\n }\n })\n\n if (word.length) {\n words.push(word)\n }\n }\n }\n\n return words\n}\n\nfunction split(content: string, granularity: 'word' | 'grapheme') {\n if (INTL_SEGMENTER_SUPPORTED) {\n return granularity === 'word'\n ? [...wordSegmenter.segment(content)].map((seg) => seg.segment)\n : [...graphemeSegmenter.segment(content)].map((seg) => seg.segment)\n }\n\n if (granularity === 'word') {\n return breakWords(content)\n } else {\n return splitGraphemes(content)\n }\n}\n\nexport default function* buildTextNodes(\n content: string,\n context: LayoutContext\n) {\n const Yoga = getYoga()\n\n const {\n parentStyle,\n parent,\n font,\n id,\n isInheritingTransform,\n debug,\n embedFont,\n graphemeImages,\n } = context\n\n if (parentStyle.textTransform === 'uppercase') {\n content = content.toLocaleUpperCase(locale)\n } else if (parentStyle.textTransform === 'lowercase') {\n content = content.toLocaleLowerCase(locale)\n } else if (parentStyle.textTransform === 'capitalize') {\n content = split(content, 'word')\n // For each word...\n .map((word) => {\n // ...split into graphemes...\n return split(word, 'grapheme')\n .map((grapheme, index) => {\n // ...and make the first grapheme uppercase\n return index === 0 ? grapheme.toLocaleUpperCase(locale) : grapheme\n })\n .join('')\n })\n .join('')\n }\n\n const segmenter = v(\n parentStyle.wordBreak,\n {\n normal: 'word',\n 'break-all': 'grapheme',\n 'break-word': 'grapheme',\n 'keep-all': 'word',\n },\n 'word'\n )\n\n const words = split(content, segmenter)\n\n // Create a container node for this text fragment.\n const textContainer = Yoga.Node.create()\n textContainer.setAlignItems(Yoga.ALIGN_BASELINE)\n if (parentStyle.textAlign === 'left') {\n textContainer.setJustifyContent(Yoga.JUSTIFY_FLEX_START)\n } else if (parentStyle.textAlign === 'center') {\n textContainer.setJustifyContent(Yoga.JUSTIFY_CENTER)\n } else if (parentStyle.textAlign === 'right') {\n textContainer.setJustifyContent(Yoga.JUSTIFY_FLEX_END)\n } else if (parentStyle.textAlign === 'justify') {\n textContainer.setJustifyContent(Yoga.JUSTIFY_SPACE_BETWEEN)\n }\n parent.insertChild(textContainer, parent.getChildCount())\n\n // Get the correct font according to the container style.\n // @TODO: Support font family fallback based on the glyphs of the font.\n const resolvedFont = font.getFont(parentStyle as any)\n const ascent =\n (resolvedFont.ascender / resolvedFont.unitsPerEm) *\n (parentStyle.fontSize as number)\n const descent =\n -(resolvedFont.descender / resolvedFont.unitsPerEm) *\n (parentStyle.fontSize as number)\n const glyphHeight = ascent + descent\n const lineHeight = glyphHeight * 1.2\n\n const { textAlign } = parentStyle\n\n // Compute the layout.\n let lineWidth = []\n let lineSegmentNumber = []\n let wordsInLayout: (null | {\n x: number\n y: number\n width: number\n line: number\n lineIndex: number\n })[] = []\n\n textContainer.setMeasureFunc((width, _widthMode, _height, _heightMode) => {\n let lines = []\n let remainingSpace = ''\n let remainingSpaceWidth = 0\n let currentLine = ''\n let currentWidth = 0\n let maxWidth = 0\n let lineIndex = -1\n\n lineWidth = []\n lineSegmentNumber = [0]\n\n // We naively implement the width calculation without proper kerning.\n // @TODO: Support cases like `white-space: pre` and `pre-wrap`.\n // @TODO: Support different writing modes.\n // @TODO: Support RTL languages.\n for (let i = 0; i < words.length; i++) {\n const word = words[i]\n if ([' ', '\\n', '\\t', ' '].includes(word)) {\n remainingSpace += word\n remainingSpaceWidth = font.measure(\n resolvedFont,\n remainingSpace,\n parentStyle as any\n )\n\n wordsInLayout[i] = null\n } else {\n const w =\n graphemeImages && graphemeImages[word]\n ? (parentStyle.fontSize as number)\n : font.measure(resolvedFont, word, parentStyle as any)\n\n // This is the start of the line, we can ignore all spaces here.\n if (!currentWidth) {\n remainingSpace = ''\n remainingSpaceWidth = 0\n }\n\n const allowedToPutAtBeginning =\n remainingSpaceWidth || ',.!?:-@)>]}%#'.indexOf(word[0]) < 0\n const allowedToJustify = !currentWidth || !!remainingSpaceWidth\n\n if (\n allowedToPutAtBeginning &&\n currentWidth + remainingSpaceWidth + w > width\n ) {\n // Start a new line, spaces can be ignored.\n lineWidth.push(currentWidth)\n lines.push(currentLine)\n currentLine = word\n currentWidth = w\n lineSegmentNumber.push(1)\n lineIndex = -1\n } else {\n // It fits into the current line.\n currentLine += remainingSpace + word\n currentWidth += remainingSpaceWidth + w\n if (allowedToJustify) {\n lineSegmentNumber[lineSegmentNumber.length - 1]++\n }\n }\n\n remainingSpace = ''\n remainingSpaceWidth = 0\n\n if (allowedToJustify) {\n lineIndex++\n }\n\n maxWidth = Math.max(maxWidth, currentWidth)\n wordsInLayout[i] = {\n y: lines.length * lineHeight,\n x: currentWidth - w,\n width: w,\n line: lines.length,\n lineIndex,\n }\n }\n\n // node.setHeight(measured.ascent * 1.2)\n // node.setMargin(Yoga.EDGE_BOTTOM, measured.descent * 1.2)\n }\n if (currentWidth) {\n lines.push(currentLine)\n lineWidth.push(currentWidth)\n }\n\n // If there are multiple lines, we need to stretch it to fit the container.\n if (lines.length > 1) {\n maxWidth = width\n }\n\n // @TODO: Support `line-height`.\n return { width: maxWidth, height: lines.length * lineHeight }\n })\n\n const [x, y] = yield\n\n let result = ''\n\n if (parentStyle.position === 'absolute') {\n textContainer.calculateLayout()\n }\n const {\n left: containerLeft,\n top: containerTop,\n width: containerWidth,\n } = textContainer.getComputedLayout()\n\n // Attach offset to the current node.\n const left = x + containerLeft\n const top = y + containerTop\n\n for (let i = 0; i < words.length; i++) {\n // Skip whitespace.\n if (!wordsInLayout[i]) continue\n\n const word = words[i]\n\n let path: string | null = null\n let image: string | null = null\n\n let topOffset = wordsInLayout[i].y\n let leftOffset = wordsInLayout[i].x\n const width = wordsInLayout[i].width\n const height = lineHeight\n\n // Calculate alignment.\n const remainingWidth = containerWidth - lineWidth[wordsInLayout[i].line]\n if (textAlign === 'right' || textAlign === 'end') {\n leftOffset += remainingWidth\n } else if (textAlign === 'center') {\n leftOffset += remainingWidth / 2\n } else if (textAlign === 'justify') {\n const line = wordsInLayout[i].line\n // Don't justify the last line.\n if (line < lineWidth.length - 1) {\n const segments = lineSegmentNumber[line]\n const gutter = segments > 1 ? remainingWidth / (segments - 1) : 0\n leftOffset += gutter * wordsInLayout[i].lineIndex\n }\n }\n\n if (graphemeImages && graphemeImages[word]) {\n image = graphemeImages[word]\n } else if (embedFont) {\n path = font.getSVG(resolvedFont, word, {\n ...parentStyle,\n left: left + leftOffset,\n top: top + topOffset,\n letterSpacing: parentStyle.letterSpacing,\n } as any)\n } else {\n // We need manually add the font ascender height to ensure it starts\n // at the baseline because <text>'s alignment baseline is set to `hanging`\n // by default and supported to change in SVG 1.1.\n topOffset += ascent\n }\n\n let filter = ''\n if (parentStyle.textShadowOffset) {\n filter = shadow(\n { width, height, id },\n {\n shadowColor: parentStyle.textShadowColor,\n shadowOffset: parentStyle.textShadowOffset,\n shadowRadius: parentStyle.textShadowRadius,\n }\n )\n }\n\n result += text(\n {\n content: word,\n filter,\n id,\n left: left + leftOffset,\n top: top + topOffset,\n width,\n height,\n isInheritingTransform,\n path,\n image,\n debug,\n },\n parentStyle\n )\n }\n\n return result\n}\n","import transform from './transform'\n\nexport default function text(\n {\n id,\n content,\n filter,\n left,\n top,\n width,\n height,\n isInheritingTransform,\n path,\n image,\n debug,\n }: {\n content: string\n filter: string\n id: number\n left: number\n top: number\n width: number\n height: number\n isInheritingTransform: boolean\n path: string | null\n image: string | null\n debug?: boolean\n },\n style: Record<string, number | string>\n) {\n let matrix = ''\n let opacity = 1\n let extra = ''\n\n if (style.transform) {\n matrix = transform(\n { left, top, width, height },\n style.transform as unknown as number[],\n isInheritingTransform\n )\n }\n\n if (style.opacity) {\n opacity = +style.opacity\n }\n\n if (debug) {\n extra = `<rect x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${\n path === null ? 0.5 : height\n }\" fill=\"transparent\" stroke=\"#575eff\" stroke-width=\"1\" ${\n matrix ? `transform=\"${matrix}\"` : ''\n }></rect>`\n }\n\n // This grapheme should be rendered as an image.\n if (image) {\n return `${\n filter ? `${filter}<g filter=\"url(#satori_s-${id})\">` : ''\n }<image href=\"${image}\" x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" ${\n matrix ? `transform=\"${matrix}\"` : ''\n } ${opacity !== 1 ? `opacity=\"${opacity}\"` : ''}></image>${\n filter ? '</g>' : ''\n }${extra}`\n }\n\n // Do not embed the font, use <text> with the raw content instead.\n if (path === null) {\n return `${\n filter ? `${filter}<g filter=\"url(#satori_s-${id})\">` : ''\n }<text x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" fill=\"${\n style.color\n }\" font-weight=\"${style.fontWeight}\" font-style=\"${\n style.fontStyle\n }\" font-size=\"${style.fontSize}\" font-family=\"${style.fontFamily}\" ${\n style.letterSpacing ? `letter-spacing=\"${style.letterSpacing}\"` : ''\n } ${matrix ? `transform=\"${matrix}\"` : ''} ${\n opacity !== 1 ? `opacity=\"${opacity}\"` : ''\n }>${content}</text>${filter ? '</g>' : ''}${extra}`\n }\n\n return `${\n filter ? `${filter}<g filter=\"url(#satori_s-${id})\">` : ''\n }<path fill=\"${style.color}\" ${matrix ? `transform=\"${matrix}\"` : ''} ${\n opacity !== 1 ? `opacity=\"${opacity}\"` : ''\n } d=\"${path}\"></path>${filter ? '</g>' : ''}${extra}`\n}\n","import { multiply } from '../utils'\n\nexport default function transform(\n {\n left,\n top,\n width,\n height,\n }: { left: number; top: number; width: number; height: number },\n matrix: number[],\n isInheritingTransform: boolean\n) {\n let result: number[]\n\n // Calculate the transform origin.\n if (isInheritingTransform) {\n result = matrix\n } else {\n // If this element is the transform target, we attach the origin coordinates\n // to this matrix.\n const x = left + width / 2\n const y = top + height / 2\n\n // Due to the different coordinate systems, we need to move the shape to the\n // origin first, then apply the matrix, then move it back.\n result = multiply(\n [1, 0, 0, 1, x, y],\n multiply(matrix, [1, 0, 0, 1, -x, -y])\n )\n\n // And we need to apply its parent transform if it has one.\n if ((matrix as any).__parent) {\n result = multiply((matrix as any).__parent, result)\n }\n\n // Mutate self.\n matrix.splice(0, 6, ...result)\n }\n\n return `matrix(${result.map((v) => v.toFixed(2)).join(',')})`\n}\n","// @TODO: It seems that SVG filters are pretty expensive for resvg, PNG\n// generation time 10x'd when adding this filter (WASM in browser).\n// https://drafts.fxtf.org/filter-effects/#feGaussianBlurElement\n\nexport default function shadow(\n { id, width, height }: { id: number; width: number; height: number },\n style: Record<string, any>\n) {\n if (\n !style.shadowColor ||\n !style.shadowOffset ||\n typeof style.shadowRadius === 'undefined'\n ) {\n return ''\n }\n\n // Expand the area for the filter to prevent it from cutting off.\n const grow = (style.shadowRadius * style.shadowRadius) / 4\n\n const left = Math.min(style.shadowOffset.width - grow, 0)\n const right = Math.max(style.shadowOffset.width + grow + width, width)\n const top = Math.min(style.shadowOffset.height - grow, 0)\n const bottom = Math.max(style.shadowOffset.height + grow + height, height)\n\n return `<defs><filter id=\"satori_s-${id}\" x=\"${(left / width) * 100}%\" y=\"${\n (top / height) * 100\n }%\" width=\"${((right - left) / width) * 100}%\" height=\"${\n ((bottom - top) / height) * 100\n }%\"><feDropShadow dx=\"${style.shadowOffset.width}\" dy=\"${\n style.shadowOffset.height\n }\" stdDeviation=\"${\n // According to the spec, we use the half of the blur radius as the standard\n // deviation for the filter.\n // > the image that would be generated by applying to the shadow a Gaussian\n // > blur with a standard deviation equal to half the blur radius\n // > https://www.w3.org/TR/css-backgrounds-3/#shadow-blur\n style.shadowRadius / 2\n }\" flood-color=\"${style.shadowColor}\" flood-opacity=\"1\"/></filter></defs>`\n}\n","import backgroundImage from './background-image'\nimport radius from './border-radius'\nimport shadow from './shadow'\nimport transform from './transform'\n\nexport default function rect(\n {\n id,\n left,\n top,\n width,\n height,\n isInheritingTransform,\n debug,\n }: {\n id: number\n left: number\n top: number\n width: number\n height: number\n isInheritingTransform: boolean\n debug?: boolean\n },\n style: Record<string, number | string>\n) {\n if (style.display === 'none') return ''\n\n let type = 'rect'\n let stroke = 'transparent'\n let strokeWidth = 0\n let matrix = ''\n let defs = ''\n let fills: string[] = []\n let opacity = 1\n let extra = ''\n\n if (style.backgroundColor) {\n fills.push(style.backgroundColor as string)\n }\n\n if (style.borderWidth) {\n strokeWidth = style.borderWidth as number\n stroke = style.borderColor as string\n }\n\n if (style.opacity) {\n opacity = +style.opacity\n }\n\n if (style.transform) {\n matrix = transform(\n { left, top, width, height },\n style.transform as unknown as number[],\n isInheritingTransform\n )\n }\n\n if (style.backgroundImage) {\n const backgrounds = (style.backgroundImage as any)\n .map((background, index) =>\n backgroundImage({ id: id + '_' + index, width, height }, background)\n )\n .filter(Boolean)\n for (const background of backgrounds) {\n defs += background[1]\n fills.push(`url(#${background[0]})`)\n }\n }\n\n const path = radius(\n { left, top, width, height },\n style as Record<string, number>\n )\n if (path) {\n type = 'path'\n }\n\n const filter = shadow({ width, height, id }, style)\n\n if (!fills.length) fills.push('transparent')\n\n if (debug) {\n extra = `<rect x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" fill=\"transparent\" stroke=\"#ff5757\" stroke-width=\"1\" ${\n matrix ? `transform=\"${matrix}\"` : ''\n }></rect>`\n }\n\n return `${defs ? `<defs>${defs}</defs>` : ''}${\n filter ? `${filter}<g filter=\"url(#satori_s-${id})\">` : ''\n }${opacity !== 1 ? `<g opacity=\"${opacity}\">` : ''}${\n // Each background generates a new rectangle.\n fills\n .map((fill, i) => {\n if (fill === 'transparent' && !(i === fills.length - 1 && strokeWidth))\n return ''\n\n return `<${type} x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" fill=\"${fill}\" ${\n i === fills.length - 1 && strokeWidth\n ? `stroke=\"${stroke}\" stroke-width=\"${strokeWidth}\"`\n : ''\n } ${path ? `d=\"${path}\"` : ''} ${\n matrix ? `transform=\"${matrix}\"` : ''\n }></${type}>`\n })\n .join('')\n }${opacity !== 1 ? `</g>` : ''}${filter ? '</g>' : ''}${extra}`\n}\n","import gradient from '../../deps/gradient-parser'\n\ninterface Background {\n attachment: string\n color?: string\n clip: string\n image: string\n origin: string\n position: string\n size: string\n repeat: string\n}\n\nfunction resolveColorFromStop(stop) {\n if (stop.type === 'literal') return stop.value\n if (stop.type === 'hex') return `#${stop.value}`\n if (stop.type === 'rgb') return `rgb(${stop.value.join(',')})`\n if (stop.type === 'rgba') return `rgba(${stop.value.join(',')})`\n return 'transparent'\n}\n\nexport default function backgroundImage(\n { id, width }: { id: string; width: number; height: number },\n { image }: Background\n) {\n if (image.startsWith('linear-gradient(')) {\n const parsed = gradient.parse(image)[0]\n\n // Calculate the direction.\n let x1, y1, x2, y2\n if (parsed.orientation.type === 'directional') {\n ;[x1, y1, x2, y2] = {\n top: [0, 1, 0, 0],\n bottom: [0, 0, 0, 1],\n left: [1, 0, 0, 0],\n right: [0, 0, 1, 0],\n }[parsed.orientation.value]\n } else if (parsed.orientation.type === 'angular') {\n const angle = (+parsed.orientation.value / 180) * Math.PI - Math.PI / 2\n const c = Math.cos(angle)\n const s = Math.sin(angle)\n\n x1 = 0\n y1 = 0\n x2 = c\n y2 = s\n if (x2 < 0) {\n x1 -= x2\n x2 = 0\n }\n if (y2 < 0) {\n y1 -= y2\n y2 = 0\n }\n }\n\n // @TODO\n const totalLength = width\n\n // Resolve the color stops based on the spec:\n // https://drafts.csswg.org/css-images/#color-stop-syntax\n const stops = []\n for (const stop of parsed.colorStops) {\n const color = resolveColorFromStop(stop)\n if (!stops.length) {\n // First stop, ensure it's at the start.\n stops.push({\n offset: 0,\n color,\n })\n\n if (typeof stop.length === 'undefined') continue\n if (stop.length.value === '0') continue\n }\n\n // All offsets are relative values (0-1) in SVG.\n const offset =\n typeof stop.length === 'undefined'\n ? undefined\n : stop.length.type === '%'\n ? stop.length.value / 100\n : stop.length.value / totalLength\n\n stops.push({\n offset,\n color,\n })\n }\n if (!stops.length) {\n stops.push({\n offset: 0,\n color: 'transparent',\n })\n }\n // Last stop, ensure it's at the end.\n const lastStop = stops[stops.length - 1]\n if (lastStop.offset !== 1) {\n if (typeof lastStop.offset === 'undefined') {\n lastStop.offset = 1\n } else {\n stops.push({\n offset: 1,\n color: lastStop.color,\n })\n }\n }\n\n let previousStop = 0\n let nextStop = 1\n // Evenly distribute the missing stop offsets.\n for (let i = 0; i < stops.length; i++) {\n if (typeof stops[i].offset === 'undefined') {\n // Find the next stop that has an offset.\n if (nextStop < i) nextStop = i\n while (typeof stops[nextStop].offset === 'undefined') nextStop++\n\n stops[i].offset =\n ((stops[nextStop].offset - stops[previousStop].offset) /\n (nextStop - previousStop)) *\n (i - previousStop) +\n stops[previousStop].offset\n } else {\n previousStop = i\n }\n }\n\n return [\n `satori_bi${id}`,\n `<linearGradient id=\"satori_bi${id}\" x1=\"${x1}\" y1=\"${y1}\" x2=\"${x2}\" y2=\"${y2}\">${stops\n .map(\n (stop) =>\n `<stop offset=\"${stop.offset * 100}%\" stop-color=\"${stop.color}\"/>`\n )\n .join('')}</linearGradient>`,\n ]\n }\n\n if (image.startsWith('url(')) {\n const src = image.slice(4, -1)\n return [\n `satori_bi${id}`,\n `<pattern id=\"satori_bi${id}\" patternContentUnits=\"objectBoundingBox\" width=\"1\" height=\"1\"><image href=\"${src}\" x=\"0\" y=\"0\" width=\"1\" height=\"1\"/></pattern>`,\n ]\n }\n}\n","// Copyright (c) 2014 Rafael Caricio. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nvar GradientParser = GradientParser || {}\n\nGradientParser.parse = (function () {\n var tokens = {\n linearGradient: /^(\\-(webkit|o|ms|moz)\\-)?(linear\\-gradient)/i,\n repeatingLinearGradient:\n /^(\\-(webkit|o|ms|moz)\\-)?(repeating\\-linear\\-gradient)/i,\n radialGradient: /^(\\-(webkit|o|ms|moz)\\-)?(radial\\-gradient)/i,\n repeatingRadialGradient:\n /^(\\-(webkit|o|ms|moz)\\-)?(repeating\\-radial\\-gradient)/i,\n sideOrCorner:\n /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,\n extentKeywords:\n /^(closest\\-side|closest\\-corner|farthest\\-side|farthest\\-corner|contain|cover)/,\n positionKeywords: /^(left|center|right|top|bottom)/i,\n pixelValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))px/,\n percentageValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))\\%/,\n emValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))em/,\n angleValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))deg/,\n startCall: /^\\(/,\n endCall: /^\\)/,\n comma: /^,/,\n hexColor: /^\\#([0-9a-fA-F]+)/,\n literalColor: /^([a-zA-Z]+)/,\n rgbColor: /^rgb/i,\n rgbaColor: /^rgba/i,\n number: /^(([0-9]*\\.[0-9]+)|([0-9]+\\.?))/,\n }\n\n var input = ''\n\n function error(msg) {\n var err = new Error(input + ': ' + msg)\n err.source = input\n throw err\n }\n\n function getAST() {\n var ast = matchListDefinitions()\n\n if (input.length > 0) {\n error('Invalid input not EOF')\n }\n\n return ast\n }\n\n function matchListDefinitions() {\n return matchListing(matchDefinition)\n }\n\n function matchDefinition() {\n return (\n matchGradient(\n 'linear-gradient',\n tokens.linearGradient,\n matchLinearOrientation\n ) ||\n matchGradient(\n 'repeating-linear-gradient',\n tokens.repeatingLinearGradient,\n matchLinearOrientation\n ) ||\n matchGradient(\n 'radial-gradient',\n tokens.radialGradient,\n matchListRadialOrientations\n ) ||\n matchGradient(\n 'repeating-radial-gradient',\n tokens.repeatingRadialGradient,\n matchListRadialOrientations\n )\n )\n }\n\n function matchGradient(gradientType, pattern, orientationMatcher) {\n return matchCall(pattern, function (captures) {\n var orientation = orientationMatcher()\n if (orientation) {\n if (!scan(tokens.comma)) {\n error('Missing comma before color stops')\n }\n }\n\n return {\n type: gradientType,\n orientation: orientation,\n colorStops: matchListing(matchColorStop),\n }\n })\n }\n\n function matchCall(pattern, callback) {\n var captures = scan(pattern)\n\n if (captures) {\n if (!scan(tokens.startCall)) {\n error('Missing (')\n }\n\n var result = callback(captures)\n\n if (!scan(tokens.endCall)) {\n error('Missing )')\n }\n\n return result\n }\n }\n\n function matchLinearOrientation() {\n return matchSideOrCorner() || matchAngle()\n }\n\n function matchSideOrCorner() {\n return match('directional', tokens.sideOrCorner, 1)\n }\n\n function matchAngle() {\n return match('angular', tokens.angleValue, 1)\n }\n\n function matchListRadialOrientations() {\n var radialOrientations,\n radialOrientation = matchRadialOrientation(),\n lookaheadCache\n\n if (radialOrientation) {\n radialOrientations = []\n radialOrientations.push(radialOrientation)\n\n lookaheadCache = input\n if (scan(tokens.comma)) {\n radialOrientation = matchRadialOrientation()\n if (radialOrientation) {\n radialOrientations.push(radialOrientation)\n } else {\n input = lookaheadCache\n }\n }\n }\n\n return radialOrientations\n }\n\n function matchRadialOrientation() {\n var radialType = matchCircle() || matchEllipse()\n\n if (radialType) {\n radialType.at = matchAtPosition()\n } else {\n var extent = matchExtentKeyword()\n if (extent) {\n radialType = extent\n var positionAt = matchAtPosition()\n if (positionAt) {\n radialType.at = positionAt\n }\n } else {\n var defaultPosition = matchPositioning()\n if (defaultPosition) {\n radialType = {\n type: 'default-radial',\n at: defaultPosition,\n }\n }\n }\n }\n\n return radialType\n }\n\n function matchCircle() {\n var circle = match('shape', /^(circle)/i, 0)\n\n if (circle) {\n circle.style = matchLength() || matchExtentKeyword()\n }\n\n return circle\n }\n\n function matchEllipse() {\n var ellipse = match('shape', /^(ellipse)/i, 0)\n\n if (ellipse) {\n ellipse.style = matchDistance() || matchExtentKeyword()\n }\n\n return ellipse\n }\n\n function matchExtentKeyword() {\n return match('extent-keyword', tokens.extentKeywords, 1)\n }\n\n function matchAtPosition() {\n if (match('position', /^at/, 0)) {\n var positioning = matchPositioning()\n\n if (!positioning) {\n error('Missing positioning value')\n }\n\n return positioning\n }\n }\n\n function matchPositioning() {\n var location = matchCoordinates()\n\n if (location.x || location.y) {\n return {\n type: 'position',\n value: location,\n }\n }\n }\n\n function matchCoordinates() {\n return {\n x: matchDistance(),\n y: matchDistance(),\n }\n }\n\n function matchListing(matcher) {\n var captures = matcher(),\n result = []\n\n if (captures) {\n result.push(captures)\n while (scan(tokens.comma)) {\n captures = matcher()\n if (captures) {\n result.push(captures)\n } else {\n error('One extra comma')\n }\n }\n }\n\n return result\n }\n\n function matchColorStop() {\n var color = matchColor()\n\n if (!color) {\n error('Expected color definition')\n }\n\n color.length = matchDistance()\n return color\n }\n\n function matchColor() {\n return (\n matchHexColor() ||\n matchRGBAColor() ||\n matchRGBColor() ||\n matchLiteralColor()\n )\n }\n\n function matchLiteralColor() {\n return match('literal', tokens.literalColor, 0)\n }\n\n function matchHexColor() {\n return match('hex', tokens.hexColor, 1)\n }\n\n function matchRGBColor() {\n return matchCall(tokens.rgbColor, function () {\n return {\n type: 'rgb',\n value: matchListing(matchNumber),\n }\n })\n }\n\n function matchRGBAColor() {\n return matchCall(tokens.rgbaColor, function () {\n return {\n type: 'rgba',\n value: matchListing(matchNumber),\n }\n })\n }\n\n function matchNumber() {\n return scan(tokens.number)[1]\n }\n\n function matchDistance() {\n return (\n match('%', tokens.percentageValue, 1) ||\n matchPositionKeyword() ||\n matchLength()\n )\n }\n\n function matchPositionKeyword() {\n return match('position-keyword', tokens.positionKeywords, 1)\n }\n\n function matchLength() {\n return match('px', tokens.pixelValue, 1) || match('em', tokens.emValue, 1)\n }\n\n function match(type, pattern, captureIndex) {\n var captures = scan(pattern)\n if (captures) {\n return {\n type: type,\n value: captures[captureIndex],\n }\n }\n }\n\n function scan(regexp) {\n var captures, blankCaptures\n\n blankCaptures = /^[\\n\\r\\t\\s]+/.exec(input)\n if (blankCaptures) {\n consume(blankCaptures[0].length)\n }\n\n captures = regexp.exec(input)\n if (captures) {\n consume(captures[0].length)\n }\n\n return captures\n }\n\n function consume(size) {\n input = input.substr(size)\n }\n\n return function (code) {\n input = code.toString()\n return getAST()\n }\n})()\n\nexport default GradientParser\n","/**\n * CSS border radius to SVG path.\n */\n\nfunction resolveSize(a: number, b: number, limit: number) {\n if (limit < a + b) {\n if (limit / 2 < a && limit / 2 < b) {\n a = b = limit / 2\n } else if (limit / 2 < a) {\n a = limit - b\n } else if (limit / 2 < b) {\n b = limit - a\n }\n }\n return [a, b]\n}\n\nexport default function radius(\n {\n left,\n top,\n width,\n height,\n }: {\n left: number\n top: number\n width: number\n height: number\n },\n style: Record<string, number>\n) {\n let {\n borderTopLeftRadius,\n borderTopRightRadius,\n borderBottomLeftRadius,\n borderBottomRightRadius,\n } = style\n\n borderTopLeftRadius = Math.min(borderTopLeftRadius || 0, width, height)\n borderTopRightRadius = Math.min(borderTopRightRadius || 0, width, height)\n borderBottomLeftRadius = Math.min(borderBottomLeftRadius || 0, width, height)\n borderBottomRightRadius = Math.min(\n borderBottomRightRadius || 0,\n width,\n height\n )\n\n if (\n !borderTopLeftRadius &&\n !borderTopRightRadius &&\n !borderBottomLeftRadius &&\n !borderBottomRightRadius\n ) {\n return ''\n }\n\n // Limit the radius size.\n ;[borderTopLeftRadius, borderTopRightRadius] = resolveSize(\n borderTopLeftRadius,\n borderTopRightRadius,\n width\n )\n ;[borderTopLeftRadius, borderBottomLeftRadius] = resolveSize(\n borderTopLeftRadius,\n borderBottomLeftRadius,\n height\n )\n ;[borderTopRightRadius, borderBottomRightRadius] = resolveSize(\n borderTopRightRadius,\n borderBottomRightRadius,\n height\n )\n ;[borderBottomLeftRadius, borderBottomRightRadius] = resolveSize(\n borderBottomLeftRadius,\n borderBottomRightRadius,\n width\n )\n\n // Generate the path (GitHub Copilot wrote these for me).\n return `M${left + borderTopLeftRadius},${top} h${\n width - borderTopLeftRadius - borderTopRightRadius\n } a${borderTopRightRadius},${borderTopRightRadius} 0 0 1 ${borderTopRightRadius},${borderTopRightRadius} v${\n height - borderTopRightRadius - borderBottomRightRadius\n } a${borderBottomRightRadius},${borderBottomRightRadius} 0 0 1 ${-borderBottomRightRadius},${borderBottomRightRadius} h${\n borderBottomRightRadius + borderBottomLeftRadius - width\n } a${borderBottomLeftRadius},${borderBottomLeftRadius} 0 0 1 ${-borderBottomLeftRadius},${-borderBottomLeftRadius} v${\n borderBottomLeftRadius + borderTopLeftRadius - height\n } a${borderTopLeftRadius},${borderTopLeftRadius} 0 0 1 ${borderTopLeftRadius},${-borderTopLeftRadius}`\n}\n","import radius from './border-radius'\nimport shadow from './shadow'\n\nexport default function image(\n {\n id,\n left,\n top,\n width,\n height,\n src,\n debug,\n }: {\n id: number\n left: number\n top: number\n width: number\n height: number\n src: string\n isInheritingTransform: boolean\n debug?: boolean\n },\n style: Record<string, number | string>\n) {\n if (style.display === 'none') return ''\n\n let clip = ''\n let opacity = 1\n\n const preserveAspectRatio =\n style.objectFit === 'contain'\n ? 'xMidYMid'\n : style.objectFit === 'cover'\n ? 'xMidYMid slice'\n : 'none'\n\n const path = radius(\n { left, top, width, height },\n style as Record<string, number>\n )\n\n if (path) {\n clip = `<clipPath id=\"satori_c-${id}\"><path x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" d=\"${path}\"></path></clipPath>`\n }\n\n if (style.opacity) {\n opacity = +style.opacity\n }\n\n const filter = shadow({ width, height, id }, style)\n\n return `${filter}${\n filter ? `<g filter=\"url(#satori_s-${id})\">` : ''\n }${clip}<image href=\"${src}\" x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" preserveAspectRatio=\"${preserveAspectRatio}\" ${\n clip ? `clip-path=\"url(#satori_c-${id})\"` : ''\n } ${opacity !== 1 ? `opacity=\"${opacity}\"` : ''}></image>${\n filter ? '</g>' : ''\n }`\n}\n","/**\n * This class handles everything related to fonts.\n */\n\nimport opentype from 'opentype.js'\n\ntype Weight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900\ntype WeigthName = 'normal' | 'bold'\ntype Style = 'normal' | 'italic'\n\nexport interface FontOptions {\n data: Buffer | ArrayBuffer\n name: string\n weight?: Weight\n style?: Style\n}\n\nexport default class FontLoader {\n defaultFont: opentype.Font\n fonts = new Map<string, [opentype.Font, Weight?, Style?][]>()\n constructor(fontOptions: FontOptions[]) {\n for (const fontOption of fontOptions) {\n const data = fontOption.data\n const font =\n 'buffer' in data\n ? opentype.parse(\n // Buffer to ArrayBuffer.\n data.buffer.slice(\n data.byteOffset,\n data.byteOffset + data.byteLength\n )\n )\n : opentype.parse(data)\n\n // We use the first font as the default font fallback.\n if (!this.defaultFont) this.defaultFont = font\n\n if (!this.fonts.has(fontOption.name)) {\n this.fonts.set(fontOption.name, [])\n }\n this.fonts\n .get(fontOption.name)\n .push([font, fontOption.weight, fontOption.style])\n }\n }\n\n // Get font by name and weight.\n private get({\n name,\n weight,\n style,\n }: {\n name: string\n weight: Weight | WeigthName\n style: Style\n }) {\n if (!this.fonts.has(name)) {\n return this.defaultFont\n }\n\n if (weight === 'normal') weight = 400\n if (weight === 'bold') weight = 700\n\n // Fallback to the closest weight and style according to the strategy here:\n // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#fallback_weights\n const fonts = [...this.fonts.get(name)]\n fonts.sort(([_, weight1, style1], [__, weight2, style2]) => {\n if (weight1 !== weight2) {\n // Put the defined weight first.\n if (!weight1) return 1\n if (!weight2) return -1\n\n // Exact match.\n if (weight1 === weight) return -1\n if (weight2 === weight) return 1\n\n // 400 and 500.\n if (weight === 400 && weight1 === 500) return -1\n if (weight === 500 && weight1 === 400) return -1\n if (weight === 400 && weight2 === 500) return 1\n if (weight === 500 && weight2 === 400) return 1\n\n // Less than 400.\n if (weight < 400) {\n if (weight1 < weight && weight2 < weight) return weight2 - weight1\n if (weight1 < weight) return -1\n if (weight2 < weight) return 1\n return weight1 - weight2\n }\n\n // Greater than 500.\n if (weight < weight1 && weight < weight2) return weight1 - weight2\n if (weight < weight1) return -1\n if (weight < weight2) return 1\n return weight2 - weight1\n }\n\n if (style1 !== style2) {\n // Exact match.\n if (style1 === style) return -1\n if (style2 === style) return 1\n }\n\n return -1\n })\n return fonts[0][0]\n }\n\n public getFont({\n fontFamily,\n fontWeight = 400,\n fontStyle = 'normal',\n }: {\n fontFamily: string\n fontWeight?: Weight | WeigthName\n fontStyle?: Style\n }) {\n return this.get({\n name: fontFamily,\n weight: fontWeight,\n style: fontStyle,\n })\n }\n\n public measure(\n font: opentype.Font,\n content: string,\n {\n fontSize,\n letterSpacing = 0,\n }: {\n fontSize: number\n letterSpacing: number\n }\n ) {\n // console.log(font.charToGlyphIndex('✅') !== 0)\n\n return font.getAdvanceWidth(content, fontSize, {\n letterSpacing: letterSpacing / fontSize,\n })\n }\n\n public getSVG(\n font: opentype.Font,\n content: string,\n {\n fontSize,\n top,\n left,\n letterSpacing = 0,\n }: {\n fontSize: number\n top: number\n left: number\n letterSpacing: number\n }\n ) {\n // Since we need to pass the baseline position, add the ascender to the top.\n top += (font.ascender / font.unitsPerEm) * fontSize\n\n return font\n .getPath(content, left, top, fontSize, {\n letterSpacing: letterSpacing / fontSize,\n })\n .toPathData(2)\n }\n}\n","export default function svg(\n {\n width,\n height,\n content,\n }: {\n width: number\n height: number\n content: string\n },\n style?: Record<string, number | string>\n) {\n return `<svg width=\"${width}\" height=\"${height}\" viewBox=\"0 0 ${width} ${height}\" xmlns=\"http://www.w3.org/2000/svg\">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AAC,EAAG,IAAI,MACrC,MAAO,IAAI,CAAE,MAAO,EAAQ,MAAO,OAAQ,EAAQ,OAAQ","names":[]}
@@ -1,2 +1,3 @@
1
- var xt=Object.defineProperty,$t=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var st=Object.getOwnPropertySymbols;var St=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable;var ft=(t,n,e)=>n in t?xt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,P=(t,n)=>{for(var e in n||(n={}))St.call(n,e)&&ft(t,e,n[e]);if(st)for(var e of st(n))Rt.call(n,e)&&ft(t,e,n[e]);return t},ut=(t,n)=>$t(t,_t(n));var lt;function Tt(t){lt=t}function F(){return lt}function J(t){let n=typeof t;return!(n==="number"||n==="bigint"||n==="string"||n==="boolean")}function ct(t){return/^class\s/.test(Function.prototype.toString.call(t))}function B(t,n){return[t[0]*n[0]+t[2]*n[1],t[1]*n[0]+t[3]*n[1],t[0]*n[2]+t[2]*n[3],t[1]*n[2]+t[3]*n[3],t[0]*n[4]+t[2]*n[5]+t[4],t[1]*n[4]+t[3]*n[5]+t[5]]}function I(t,n,e){let i=n[t];return typeof i=="undefined"?e:i}var mt={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};var Lt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","opacity"]);function j(t){let n={};for(let e in t)Lt.has(e)&&(n[e]=t[e]);return n}import{getPropertyName as dt,getStylesForProperty as It}from"css-to-react-native";import ht from"parse-css-dimension";import{parseElementStyle as At}from"css-background-parser";var Ft=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),pt=[1,0,0,1,0,0];function Ct(t,n){return typeof n=="number"?Ft.has(t)?String(n):n+"px":n}function gt(t,n){if(typeof t=="number")return t;try{let e=new ht(t);if(e.type==="length")switch(e.unit){case"em":return e.value*n;case"rem":return e.value*16;default:return e.value}else if(e.type==="angle")switch(e.unit){case"deg":return e.value;case"rad":return e.value*180/Math.PI;default:return e.value}}catch{}}function U(t,n){let e=[];for(let o in t){let r=dt(o);e.push([r,Ct(r,t[o])])}let i=e.reduce((o,r)=>{let s=dt(r[0]),l=r[1];return Object.assign(o,It(s,l,!0))},{});if(i.backgroundImage){let{backgrounds:o}=At(i);i.backgroundImage=o}let a=i.fontSize||n.fontSize;if(typeof a=="string")try{let o=new ht(a);switch(o.unit){case"em":a=o.value*n.fontSize;break;case"rem":a=o.value*16;break}}catch{a=16}i.fontSize=a;for(let o in i){let r=i[o];if(typeof r=="string"){let s=gt(r,a);typeof s!="undefined"&&(i[o]=s),r=i[o]}if(o==="opacity"&&(r=i[o]=r*n.opacity),o==="transform"){let s=[...pt],l=r;for(let f of l){let d=Object.keys(f)[0],p=f[d],m=typeof p=="string"?gt(p,a):p,u=[...pt];switch(d){case"translateX":u[4]=m;break;case"translateY":u[5]=m;break;case"scaleX":u[0]=m;break;case"scaleY":u[3]=m;break;case"rotate":let h=m*Math.PI/180,S=Math.cos(h),R=Math.sin(h);u[0]=S,u[1]=R,u[2]=-R,u[3]=S;break;case"skewX":u[2]=Math.tan(m*Math.PI/180);break;case"skewY":u[1]=Math.tan(m*Math.PI/180);break}s=B(u,s)}i.transform=s}}return i}function K(t,n,e,i,a){let o=F(),r=P(P(P({},e),U(mt[n],e)),U(i,e));if(n==="img"){let s=parseInt(a.width),f=parseInt(a.height)/s;r.width||(r.width=s),r.height||(r.height=f*r.width)}return t.setDisplay(I(r.display,{flex:o.DISPLAY_FLEX,none:o.DISPLAY_NONE},o.DISPLAY_FLEX)),t.setAlignContent(I(r.alignContent,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,"space-between":o.ALIGN_SPACE_BETWEEN,"space-around":o.ALIGN_SPACE_AROUND,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),t.setAlignItems(I(r.alignItems,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_FLEX_START)),t.setAlignSelf(I(r.alignSelf,{stretch:o.ALIGN_STRETCH,center:o.ALIGN_CENTER,"flex-start":o.ALIGN_FLEX_START,"flex-end":o.ALIGN_FLEX_END,baseline:o.ALIGN_BASELINE,normal:o.ALIGN_AUTO},o.ALIGN_AUTO)),t.setJustifyContent(I(r.justifyContent,{center:o.JUSTIFY_CENTER,"flex-start":o.JUSTIFY_FLEX_START,"flex-end":o.JUSTIFY_FLEX_END,"space-between":o.JUSTIFY_SPACE_BETWEEN,"space-around":o.JUSTIFY_SPACE_AROUND},o.JUSTIFY_FLEX_START)),t.setFlexDirection(I(r.flexDirection,{row:o.FLEX_DIRECTION_ROW,column:o.FLEX_DIRECTION_COLUMN,"row-reverse":o.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":o.FLEX_DIRECTION_COLUMN_REVERSE},o.FLEX_DIRECTION_ROW)),t.setFlexWrap(I(r.flexWrap,{wrap:o.WRAP_WRAP,nowrap:o.WRAP_NO_WRAP,"wrap-reverse":o.WRAP_WRAP_REVERSE},o.WRAP_WRAP)),typeof r.flexBasis!="undefined"&&t.setFlexBasis(r.flexBasis),t.setFlexGrow(typeof r.flexGrow=="undefined"?0:r.flexGrow),t.setFlexShrink(typeof r.flexShrink=="undefined"?1:r.flexShrink),typeof r.maxHeight!="undefined"&&t.setMaxHeight(r.maxHeight),typeof r.maxWidth!="undefined"&&t.setMaxWidth(r.maxWidth),typeof r.minHeight!="undefined"&&t.setMinHeight(r.minHeight),typeof r.minWidth!="undefined"&&t.setMinWidth(r.minWidth),t.setOverflow(I(r.overflow,{visible:o.OVERFLOW_VISIBLE,hidden:o.OVERFLOW_HIDDEN},o.OVERFLOW_VISIBLE)),t.setMargin(o.EDGE_TOP,r.marginTop||0),t.setMargin(o.EDGE_BOTTOM,r.marginBottom||0),t.setMargin(o.EDGE_LEFT,r.marginLeft||0),t.setMargin(o.EDGE_RIGHT,r.marginRight||0),t.setBorder(o.EDGE_TOP,r.borderWidth||0),t.setBorder(o.EDGE_BOTTOM,r.borderWidth||0),t.setBorder(o.EDGE_LEFT,r.borderWidth||0),t.setBorder(o.EDGE_RIGHT,r.borderWidth||0),t.setPadding(o.EDGE_TOP,r.paddingTop||0),t.setPadding(o.EDGE_BOTTOM,r.paddingBottom||0),t.setPadding(o.EDGE_LEFT,r.paddingLeft||0),t.setPadding(o.EDGE_RIGHT,r.paddingRight||0),t.setPositionType(I(r.position,{absolute:o.POSITION_TYPE_ABSOLUTE,relative:o.POSITION_TYPE_RELATIVE},o.POSITION_TYPE_RELATIVE)),typeof r.top!="undefined"&&t.setPosition(o.EDGE_TOP,r.top),typeof r.bottom!="undefined"&&t.setPosition(o.EDGE_BOTTOM,r.bottom),typeof r.left!="undefined"&&t.setPosition(o.EDGE_LEFT,r.left),typeof r.right!="undefined"&&t.setPosition(o.EDGE_RIGHT,r.right),typeof r.height!="undefined"?t.setHeight(r.height):t.setHeightAuto(),typeof r.width!="undefined"?t.setWidth(r.width):t.setWidthAuto(),[r,j(r)]}import{LineBreaker as Nt}from"css-line-break";function D({left:t,top:n,width:e,height:i},a,o){let r;if(o)r=a;else{let s=t+e/2,l=n+i/2;r=B([1,0,0,1,s,l],B(a,[1,0,0,1,-s,-l])),a.__parent&&(r=B(a.__parent,r)),a.splice(0,6,...r)}return`matrix(${r.map(s=>s.toFixed(2)).join(",")})`}function q({content:t,left:n,top:e,width:i,height:a,isInheritingTransform:o,path:r,debug:s},l){let f="",d=1,p="";return l.transform&&(f=D({left:n,top:e,width:i,height:a},l.transform,o)),l.opacity&&(d=+l.opacity),s&&(p=`<rect x="${n}" y="${e}" width="${i}" height="${r===null?.5:a}" fill="transparent" stroke="#575eff" stroke-width="1" ${f?`transform="${f}"`:""}></rect>`),r===null?`<text x="${n}" y="${e}" width="${i}" height="${a}" fill="${l.color}" font-weight="${l.fontWeight}" font-style="${l.fontStyle}" font-size="${l.fontSize}" font-family="${l.fontFamily}" ${l.letterSpacing?`letter-spacing="${l.letterSpacing}"`:""} ${f?`transform="${f}"`:""} ${d!==1?`opacity="${d}"`:""}>${t}</text>${p}`:`<path fill="${l.color}" ${f?`transform="${f}"`:""} ${d!==1?`opacity="${d}"`:""} d="${r}"></path>${p}`}function*Z(t,n){let e=F(),{parentStyle:i,parent:a,font:o,id:r,isInheritingTransform:s,debug:l,embedFont:f}=n,d=Nt(t,{lineBreak:"strict",wordBreak:I(i.wordBreak,{normal:"normal","break-all":"break-all","break-word":"break-word","keep-all":"keep-all"},"normal")}),p=[];for(let E;!(E=d.next()).done;)p.push(E.value.slice());let m=[];a.setAlignItems(e.ALIGN_BASELINE),i.textAlign==="left"?a.setJustifyContent(e.JUSTIFY_FLEX_START):i.textAlign==="center"?a.setJustifyContent(e.JUSTIFY_CENTER):i.textAlign==="right"?a.setJustifyContent(e.JUSTIFY_FLEX_END):i.textAlign==="justify"&&a.setJustifyContent(e.JUSTIFY_SPACE_BETWEEN);let u=o.getFont(i);for(let E of p){let _=e.Node.create();a.insertChild(_,a.getChildCount());let b=o.measure(u,E,i);_.setWidth(b.width),_.setHeight(b.ascent*1.2),_.setMargin(e.EDGE_BOTTOM,b.descent*1.2),m.push(_)}let[h,S]=yield,R="";for(let E=0;E<m.length;E++){let _=m[E],b=p[E];i.position==="absolute"&&_.calculateLayout();let{left:A,top:C,width:N,height:O}=_.getComputedLayout();A+=h,C+=S;let G=null;f?G=o.getSVG(u,b,ut(P({},i),{top:C,left:A,letterSpacing:i.letterSpacing})):C+=o.getAscent(u,i),R+=q({content:b,id:r,left:A,top:C,width:N,height:O,isInheritingTransform:s,path:G,debug:l},i)}return R}var Q=Q||{};Q.parse=function(){var t={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},n="";function e(c){var g=new Error(n+": "+c);throw g.source=n,g}function i(){var c=a();return n.length>0&&e("Invalid input not EOF"),c}function a(){return b(o)}function o(){return r("linear-gradient",t.linearGradient,l)||r("repeating-linear-gradient",t.repeatingLinearGradient,l)||r("radial-gradient",t.radialGradient,p)||r("repeating-radial-gradient",t.repeatingRadialGradient,p)}function r(c,g,y){return s(g,function(v){var at=y();return at&&(k(t.comma)||e("Missing comma before color stops")),{type:c,orientation:at,colorStops:b(A)}})}function s(c,g){var y=k(c);if(y){k(t.startCall)||e("Missing (");var v=g(y);return k(t.endCall)||e("Missing )"),v}}function l(){return f()||d()}function f(){return L("directional",t.sideOrCorner,1)}function d(){return L("angular",t.angleValue,1)}function p(){var c,g=m(),y;return g&&(c=[],c.push(g),y=n,k(t.comma)&&(g=m(),g?c.push(g):n=y)),c}function m(){var c=u()||h();if(c)c.at=R();else{var g=S();if(g){c=g;var y=R();y&&(c.at=y)}else{var v=E();v&&(c={type:"default-radial",at:v})}}return c}function u(){var c=L("shape",/^(circle)/i,0);return c&&(c.style=ot()||S()),c}function h(){var c=L("shape",/^(ellipse)/i,0);return c&&(c.style=T()||S()),c}function S(){return L("extent-keyword",t.extentKeywords,1)}function R(){if(L("position",/^at/,0)){var c=E();return c||e("Missing positioning value"),c}}function E(){var c=_();if(c.x||c.y)return{type:"position",value:c}}function _(){return{x:T(),y:T()}}function b(c){var g=c(),y=[];if(g)for(y.push(g);k(t.comma);)g=c(),g?y.push(g):e("One extra comma");return y}function A(){var c=C();return c||e("Expected color definition"),c.length=T(),c}function C(){return O()||z()||G()||N()}function N(){return L("literal",t.literalColor,0)}function O(){return L("hex",t.hexColor,1)}function G(){return s(t.rgbColor,function(){return{type:"rgb",value:b(W)}})}function z(){return s(t.rgbaColor,function(){return{type:"rgba",value:b(W)}})}function W(){return k(t.number)[1]}function T(){return L("%",t.percentageValue,1)||w()||ot()}function w(){return L("position-keyword",t.positionKeywords,1)}function ot(){return L("px",t.pixelValue,1)||L("em",t.emValue,1)}function L(c,g,y){var v=k(g);if(v)return{type:c,value:v[y]}}function k(c){var g,y;return y=/^[\n\r\t\s]+/.exec(n),y&&it(y[0].length),g=c.exec(n),g&&it(g[0].length),g}function it(c){n=n.substr(c)}return function(c){return n=c.toString(),i()}}();var bt=Q;function Ot(t){return t.type==="literal"?t.value:t.type==="hex"?`#${t.value}`:t.type==="rgb"?`rgb(${t.value.join(",")})`:t.type==="rgba"?`rgba(${t.value.join(",")})`:"transparent"}function tt({id:t,width:n},{image:e}){if(e.startsWith("linear-gradient(")){let i=bt.parse(e)[0],a,o,r,s;if(i.orientation.type==="directional")[a,o,r,s]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[i.orientation.value];else if(i.orientation.type==="angular"){let u=+i.orientation.value/180*Math.PI-Math.PI/2,h=Math.cos(u),S=Math.sin(u);a=0,o=0,r=h,s=S,r<0&&(a-=r,r=0),s<0&&(o-=s,s=0)}let l=n,f=[];for(let u of i.colorStops){let h=Ot(u);if(!f.length&&(f.push({offset:0,color:h}),typeof u.length=="undefined"||u.length.value==="0"))continue;let S=typeof u.length=="undefined"?void 0:u.length.type==="%"?u.length.value/100:u.length.value/l;f.push({offset:S,color:h})}f.length||f.push({offset:0,color:"transparent"});let d=f[f.length-1];d.offset!==1&&(typeof d.offset=="undefined"?d.offset=1:f.push({offset:1,color:d.color}));let p=0,m=1;for(let u=0;u<f.length;u++)if(typeof f[u].offset=="undefined"){for(m<u&&(m=u);typeof f[m].offset=="undefined";)m++;f[u].offset=(f[m].offset-f[p].offset)/(m-p)*(u-p)+f[p].offset}else p=u;return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${a}" y1="${o}" x2="${r}" y2="${s}">${f.map(u=>`<stop offset="${u.offset*100}%" stop-color="${u.color}"/>`).join("")}</linearGradient>`]}if(e.startsWith("url(")){let i=e.slice(4,-1);return[`satori_bi${t}`,`<pattern id="satori_bi${t}" patternContentUnits="objectBoundingBox" width="1" height="1"><image href="${i}" x="0" y="0" width="1" height="1"/></pattern>`]}}function H(t,n,e){return e<t+n&&(e/2<t&&e/2<n?t=n=e/2:e/2<t?t=e-n:e/2<n&&(n=e-t)),[t,n]}function M({left:t,top:n,width:e,height:i},a){let{borderTopLeftRadius:o,borderTopRightRadius:r,borderBottomLeftRadius:s,borderBottomRightRadius:l}=a;return o=Math.min(o||0,e,i),r=Math.min(r||0,e,i),s=Math.min(s||0,e,i),l=Math.min(l||0,e,i),!o&&!r&&!s&&!l?"":([o,r]=H(o,r,e),[o,s]=H(o,s,i),[r,l]=H(r,l,i),[s,l]=H(s,l,e),`M${t+o},${n} h${e-o-r} a${r},${r} 0 0 1 ${r},${r} v${i-r-l} a${l},${l} 0 0 1 ${-l},${l} h${l+s-e} a${s},${s} 0 0 1 ${-s},${-s} v${s+o-i} a${o},${o} 0 0 1 ${o},${-o}`)}function Y({id:t,width:n,height:e},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let a=Math.min(i.shadowOffset.width-i.shadowRadius*2,0),o=Math.max(i.shadowOffset.width+i.shadowRadius*2+n,n),r=Math.min(i.shadowOffset.height-i.shadowRadius*2,0),s=Math.max(i.shadowOffset.height+i.shadowRadius*2+e,e);return`<defs><filter id="satori_s-${t}" x="${a/n*100}%" y="${r/e*100}%" width="${(o-a)/n*100}%" height="${(s-r)/e*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}function et({id:t,left:n,top:e,width:i,height:a,isInheritingTransform:o,debug:r},s){if(s.display==="none")return"";let l="rect",f="transparent",d=0,p="",m="",u=[],h=1,S="";if(s.backgroundColor&&u.push(s.backgroundColor),s.borderWidth&&(d=s.borderWidth,f=s.borderColor),s.opacity&&(h=+s.opacity),s.transform&&(p=D({left:n,top:e,width:i,height:a},s.transform,o)),s.backgroundImage){let _=s.backgroundImage.map((b,A)=>tt({id:t+"_"+A,width:i,height:a},b)).filter(Boolean);for(let b of _)m+=b[1],u.push(`url(#${b[0]})`)}let R=M({left:n,top:e,width:i,height:a},s);R&&(l="path");let E=Y({width:i,height:a,id:t},s);return u.length||u.push("transparent"),r&&(S=`<rect x="${n}" y="${e}" width="${i}" height="${a}" fill="transparent" stroke="#ff5757" stroke-width="1" ${p?`transform="${p}"`:""}></rect>`),`${m?`<defs>${m}</defs>`:""}${E?`${E}<g filter="url(#satori_s-${t})">`:""}${h!==1?`<g opacity="${h}">`:""}${u.map((_,b)=>_==="transparent"&&!(b===u.length-1&&d)?"":`<${l} x="${n}" y="${e}" width="${i}" height="${a}" fill="${_}" ${b===u.length-1&&d?`stroke="${f}" stroke-width="${d}"`:""} ${R?`d="${R}"`:""} ${p?`transform="${p}"`:""}></${l}>`).join("")}${h!==1?"</g>":""}${E?"</g>":""}${S}`}function rt({id:t,left:n,top:e,width:i,height:a,src:o,debug:r},s){if(s.display==="none")return"";let l="",f=1,d=s.objectFit==="contain"?"xMidYMid":s.objectFit==="cover"?"xMidYMid slice":"none",p=M({left:n,top:e,width:i,height:a},s);p&&(l=`<clipPath id="satori_c-${t}"><path x="${n}" y="${e}" width="${i}" height="${a}" d="${p}"></path></clipPath>`),s.opacity&&(f=+s.opacity);let m=Y({width:i,height:a,id:t},s);return`${m}${m?`<g filter="url(#satori_s-${t})">`:""}${l}<image href="${o}" x="${n}" y="${e}" width="${i}" height="${a}" preserveAspectRatio="${d}" ${l?`clip-path="url(#satori_c-${t})"`:""} ${f!==1?`opacity="${f}"`:""}></image>${m?"</g>":""}`}function*X(t,n){let e=F(),{id:i,inheritedStyle:a,parent:o,font:r,debug:s,embedFont:l=!0}=n;if(t===null||typeof t=="undefined")return yield,"";if(!J(t)||typeof t.type=="function"){let T;if(!J(t))T=Z(String(t),n);else{if(ct(t.type))throw new Error("Class component is not supported.");T=X(t.type(t.props),n)}T.next();let w=yield;return T.next(w).value}let{type:f,props:d}=t,{style:p,children:m}=d,u=e.Node.create();o.insertChild(u,o.getChildCount());let[h,S]=K(u,f,a,p,d),R=h.transform===a.transform;R||(h.transform.__parent=a.transform);let E=typeof m=="undefined"?[]:[].concat(m),_=[],b=0;for(let T of E){let w=X(T,{id:i*E.length+ ++b,parentStyle:h,inheritedStyle:S,isInheritingTransform:!0,parent:u,font:r,embedFont:l,debug:s});w.next(),_.push(w)}let[A,C]=yield;h.position==="absolute"&&u.calculateLayout();let{left:N,top:O,width:G,height:z}=u.getComputedLayout();N+=A,O+=C;let W="";f==="img"?W=rt({id:i,left:N,top:O,width:G,height:z,src:d.src,isInheritingTransform:R,debug:s},h):W=et({id:i,left:N,top:O,width:G,height:z,isInheritingTransform:R,debug:s},h);for(let T of _)W+=T.next([N,O]).value;return W}import yt from"opentype.js";var V=class{constructor(n){this.fonts=new Map;for(let e of n){let i=e.data,a="buffer"in i?yt.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):yt.parse(i);this.defaultFont||(this.defaultFont=a),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([a,e.weight,e.style])}}get({name:n,weight:e,style:i}){if(!this.fonts.has(n))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let a=[...this.fonts.get(n)];return a.sort(([o,r,s],[l,f,d])=>{if(r!==f)return r?!f||r===e?-1:f===e?1:e===400&&r===500||e===500&&r===400?-1:e===400&&f===500||e===500&&f===400?1:e<400?r<e&&f<e?f-r:r<e?-1:f<e?1:r-f:e<r&&e<f?r-f:e<r?-1:e<f?1:f-r:1;if(s!==d){if(s===i)return-1;if(d===i)return 1}return-1}),a[0][0]}getFont({fontFamily:n,fontWeight:e=400,fontStyle:i="normal"}){return this.get({name:n,weight:e,style:i})}measure(n,e,{fontSize:i,letterSpacing:a=0}){return{width:n.getAdvanceWidth(e,i,{letterSpacing:a/i}),ascent:n.ascender/n.unitsPerEm*i,descent:-(n.descender/n.unitsPerEm)*i}}getSVG(n,e,{fontSize:i,top:a,left:o,letterSpacing:r=0}){return a+=n.ascender/n.unitsPerEm*i,n.getPath(e,o,a,i,{letterSpacing:r/i}).toPathData(2)}getAscent(n,{fontSize:e}){return n.ascender/n.unitsPerEm*e}};function nt({width:t,height:n,content:e},i){return`<svg width="${t}" height="${n}" viewBox="0 0 ${t} ${n}" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}function Et(t,n){let e=F();if(!e)throw new Error("Satori is not initialized.");let i=new V(n.fonts),a=e.Node.create();a.setWidth(n.width),a.setHeight(n.height),a.setFlexDirection(e.FLEX_DIRECTION_ROW),a.setFlexWrap(e.WRAP_WRAP),a.setAlignContent(e.ALIGN_AUTO),a.setAlignItems(e.ALIGN_FLEX_START),a.setJustifyContent(e.JUSTIFY_FLEX_START);let o=X(t,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:a,font:i,embedFont:n.embedFont,debug:n.debug});o.next(),a.calculateLayout(n.width,n.height,e.DIRECTION_LTR);let r=o.next([0,0]).value;return nt({width:n.width,height:n.height,content:r})}export{Et as default,Tt as init};
1
+ var Ot=Object.defineProperty,Nt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var yt=Object.getOwnPropertySymbols;var kt=Object.prototype.hasOwnProperty,Wt=Object.prototype.propertyIsEnumerable;var xt=(t,o,e)=>o in t?Ot(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,j=(t,o)=>{for(var e in o||(o={}))kt.call(o,e)&&xt(t,e,o[e]);if(yt)for(var e of yt(o))Wt.call(o,e)&&xt(t,e,o[e]);return t},$t=(t,o)=>Nt(t,vt(o));var Et;function Gt(t){Et=t}function P(){return Et}function it(t){let o=typeof t;return!(o==="number"||o==="bigint"||o==="string"||o==="boolean")}function St(t){return/^class\s/.test(Function.prototype.toString.call(t))}function K(t,o){return[t[0]*o[0]+t[2]*o[1],t[1]*o[0]+t[3]*o[1],t[0]*o[2]+t[2]*o[3],t[1]*o[2]+t[3]*o[3],t[0]*o[4]+t[2]*o[5]+t[4],t[1]*o[4]+t[3]*o[5]+t[5]]}function F(t,o,e){let i=o[t];return typeof i=="undefined"?e:i}var _t={p:{display:"block",marginTop:"1em",marginBottom:"1em"},div:{display:"block"},blockquote:{display:"block",marginTop:"1em",marginBottom:"1em",marginLeft:40,marginRight:40},center:{display:"block",textAlign:"center"},hr:{display:"block",marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"auto",marginRight:"auto",borderWidth:1,borderStyle:"inset"},h1:{display:"block",fontSize:"2em",marginTop:"0.67em",marginBottom:"0.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h2:{display:"block",fontSize:"1.5em",marginTop:"0.83em",marginBottom:"0.83em",marginLeft:0,marginRight:0,fontWeight:"bold"},h3:{display:"block",fontSize:"1.17em",marginTop:"1em",marginBottom:"1em",marginLeft:0,marginRight:0,fontWeight:"bold"},h4:{display:"block",marginTop:"1.33em",marginBottom:"1.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},h5:{display:"block",fontSize:"0.83em",marginTop:"1.67em",marginBottom:"1.67em",marginLeft:0,marginRight:0,fontWeight:"bold"},h6:{display:"block",fontSize:"0.67em",marginTop:"2.33em",marginBottom:"2.33em",marginLeft:0,marginRight:0,fontWeight:"bold"},u:{textDecoration:"underline"},strong:{fontWeight:"bold"},b:{fontWeight:"bold"},i:{fontStyle:"italic"},em:{fontStyle:"italic"},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{display:"block",fontFamily:"monospace",whiteSpace:"pre",marginTop:"1em",marginBottom:"1em"},mark:{backgroundColor:"yellow",color:"black"},big:{fontSize:"larger"},small:{fontSize:"smaller"},s:{textDecoration:"line-through"}};var Pt=new Set(["color","font","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","textAlign","textTransform","whiteSpace","letterSpacing","transform","wordBreak","textShadowOffset","textShadowColor","textShadowRadius","opacity"]);function at(t){let o={};for(let e in t)Pt.has(e)&&(o[e]=t[e]);return o}import{getPropertyName as Tt,getStylesForProperty as Bt}from"css-to-react-native";import Lt from"parse-css-dimension";import{parseElementStyle as Mt}from"css-background-parser";var Dt=new Set(["flex","flexGrow","flexShrink","flexBasis","fontWeight","lineHeight","opacity","scale","scaleX","scaleY"]),Rt=[1,0,0,1,0,0];function Yt(t,o){return typeof o=="number"?Dt.has(t)?String(o):o+"px":o}function It(t,o){if(typeof t=="number")return t;try{let e=new Lt(t);if(e.type==="length")switch(e.unit){case"em":return e.value*o;case"rem":return e.value*16;default:return e.value}else if(e.type==="angle")switch(e.unit){case"deg":return e.value;case"rad":return e.value*180/Math.PI;default:return e.value}}catch{}}function rt(t,o){let e=[];for(let n in t){let r=Tt(n);e.push([r,Yt(r,t[n])])}let i=e.reduce((n,r)=>{let a=Tt(r[0]),c=r[1];return Object.assign(n,Bt(a,c,!0))},{});if(i.backgroundImage){let{backgrounds:n}=Mt(i);i.backgroundImage=n}let s=i.fontSize||o.fontSize;if(typeof s=="string")try{let n=new Lt(s);switch(n.unit){case"em":s=n.value*o.fontSize;break;case"rem":s=n.value*16;break}}catch{s=16}typeof i.fontSize!="undefined"&&(i.fontSize=s);for(let n in i){let r=i[n];if(typeof r=="string"){let a=It(r,s);typeof a!="undefined"&&(i[n]=a),r=i[n]}if(n==="opacity"&&(r=i[n]=r*o.opacity),n==="transform"){let a=[...Rt],c=r;for(let u of c){let b=Object.keys(u)[0],d=u[b],m=typeof d=="string"?It(d,s):d,f=[...Rt];switch(b){case"translateX":f[4]=m;break;case"translateY":f[5]=m;break;case"scaleX":f[0]=m;break;case"scaleY":f[3]=m;break;case"rotate":let g=m*Math.PI/180,x=Math.cos(g),I=Math.sin(g);f[0]=x,f[1]=I,f[2]=-I,f[3]=x;break;case"skewX":f[2]=Math.tan(m*Math.PI/180);break;case"skewY":f[1]=Math.tan(m*Math.PI/180);break}a=K(f,a)}i.transform=a}}return i}function st(t,o,e,i,s){let n=P(),r=j(j(j({},e),rt(_t[o],e)),rt(i,e));if(o==="img"){let a=parseInt(s.width),u=parseInt(s.height)/a;r.width||(r.width=a),r.height||(r.height=u*r.width)}return t.setDisplay(F(r.display,{flex:n.DISPLAY_FLEX,none:n.DISPLAY_NONE},n.DISPLAY_FLEX)),t.setAlignContent(F(r.alignContent,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,"space-between":n.ALIGN_SPACE_BETWEEN,"space-around":n.ALIGN_SPACE_AROUND,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_AUTO)),t.setAlignItems(F(r.alignItems,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_FLEX_START)),t.setAlignSelf(F(r.alignSelf,{stretch:n.ALIGN_STRETCH,center:n.ALIGN_CENTER,"flex-start":n.ALIGN_FLEX_START,"flex-end":n.ALIGN_FLEX_END,baseline:n.ALIGN_BASELINE,normal:n.ALIGN_AUTO},n.ALIGN_AUTO)),t.setJustifyContent(F(r.justifyContent,{center:n.JUSTIFY_CENTER,"flex-start":n.JUSTIFY_FLEX_START,"flex-end":n.JUSTIFY_FLEX_END,"space-between":n.JUSTIFY_SPACE_BETWEEN,"space-around":n.JUSTIFY_SPACE_AROUND},n.JUSTIFY_FLEX_START)),t.setFlexDirection(F(r.flexDirection,{row:n.FLEX_DIRECTION_ROW,column:n.FLEX_DIRECTION_COLUMN,"row-reverse":n.FLEX_DIRECTION_ROW_REVERSE,"column-reverse":n.FLEX_DIRECTION_COLUMN_REVERSE},n.FLEX_DIRECTION_ROW)),t.setFlexWrap(F(r.flexWrap,{wrap:n.WRAP_WRAP,nowrap:n.WRAP_NO_WRAP,"wrap-reverse":n.WRAP_WRAP_REVERSE},n.WRAP_WRAP)),typeof r.flexBasis!="undefined"&&t.setFlexBasis(r.flexBasis),t.setFlexGrow(typeof r.flexGrow=="undefined"?0:r.flexGrow),t.setFlexShrink(typeof r.flexShrink=="undefined"?1:r.flexShrink),typeof r.maxHeight!="undefined"&&t.setMaxHeight(r.maxHeight),typeof r.maxWidth!="undefined"&&t.setMaxWidth(r.maxWidth),typeof r.minHeight!="undefined"&&t.setMinHeight(r.minHeight),typeof r.minWidth!="undefined"&&t.setMinWidth(r.minWidth),t.setOverflow(F(r.overflow,{visible:n.OVERFLOW_VISIBLE,hidden:n.OVERFLOW_HIDDEN},n.OVERFLOW_VISIBLE)),t.setMargin(n.EDGE_TOP,r.marginTop||0),t.setMargin(n.EDGE_BOTTOM,r.marginBottom||0),t.setMargin(n.EDGE_LEFT,r.marginLeft||0),t.setMargin(n.EDGE_RIGHT,r.marginRight||0),t.setBorder(n.EDGE_TOP,r.borderWidth||0),t.setBorder(n.EDGE_BOTTOM,r.borderWidth||0),t.setBorder(n.EDGE_LEFT,r.borderWidth||0),t.setBorder(n.EDGE_RIGHT,r.borderWidth||0),t.setPadding(n.EDGE_TOP,r.paddingTop||0),t.setPadding(n.EDGE_BOTTOM,r.paddingBottom||0),t.setPadding(n.EDGE_LEFT,r.paddingLeft||0),t.setPadding(n.EDGE_RIGHT,r.paddingRight||0),t.setPositionType(F(r.position,{absolute:n.POSITION_TYPE_ABSOLUTE,relative:n.POSITION_TYPE_RELATIVE},n.POSITION_TYPE_RELATIVE)),typeof r.top!="undefined"&&t.setPosition(n.EDGE_TOP,r.top),typeof r.bottom!="undefined"&&t.setPosition(n.EDGE_BOTTOM,r.bottom),typeof r.left!="undefined"&&t.setPosition(n.EDGE_LEFT,r.left),typeof r.right!="undefined"&&t.setPosition(n.EDGE_RIGHT,r.right),typeof r.height!="undefined"?t.setHeight(r.height):t.setHeightAuto(),typeof r.width!="undefined"?t.setWidth(r.width):t.setWidthAuto(),[r,at(r)]}import{LineBreaker as zt}from"css-line-break";import{splitGraphemes as Ut}from"text-segmentation";function Z({left:t,top:o,width:e,height:i},s,n){let r;if(n)r=s;else{let a=t+e/2,c=o+i/2;r=K([1,0,0,1,a,c],K(s,[1,0,0,1,-a,-c])),s.__parent&&(r=K(s.__parent,r)),s.splice(0,6,...r)}return`matrix(${r.map(a=>a.toFixed(2)).join(",")})`}function ft({id:t,content:o,filter:e,left:i,top:s,width:n,height:r,isInheritingTransform:a,path:c,image:u,debug:b},d){let m="",f=1,g="";return d.transform&&(m=Z({left:i,top:s,width:n,height:r},d.transform,a)),d.opacity&&(f=+d.opacity),b&&(g=`<rect x="${i}" y="${s}" width="${n}" height="${c===null?.5:r}" fill="transparent" stroke="#575eff" stroke-width="1" ${m?`transform="${m}"`:""}></rect>`),u?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<image href="${u}" x="${i}" y="${s}" width="${n}" height="${r}" ${m?`transform="${m}"`:""} ${f!==1?`opacity="${f}"`:""}></image>${e?"</g>":""}${g}`:c===null?`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<text x="${i}" y="${s}" width="${n}" height="${r}" fill="${d.color}" font-weight="${d.fontWeight}" font-style="${d.fontStyle}" font-size="${d.fontSize}" font-family="${d.fontFamily}" ${d.letterSpacing?`letter-spacing="${d.letterSpacing}"`:""} ${m?`transform="${m}"`:""} ${f!==1?`opacity="${f}"`:""}>${o}</text>${e?"</g>":""}${g}`:`${e?`${e}<g filter="url(#satori_s-${t})">`:""}<path fill="${d.color}" ${m?`transform="${m}"`:""} ${f!==1?`opacity="${f}"`:""} d="${c}"></path>${e?"</g>":""}${g}`}function V({id:t,width:o,height:e},i){if(!i.shadowColor||!i.shadowOffset||typeof i.shadowRadius=="undefined")return"";let s=i.shadowRadius*i.shadowRadius/4,n=Math.min(i.shadowOffset.width-s,0),r=Math.max(i.shadowOffset.width+s+o,o),a=Math.min(i.shadowOffset.height-s,0),c=Math.max(i.shadowOffset.height+s+e,e);return`<defs><filter id="satori_s-${t}" x="${n/o*100}%" y="${a/e*100}%" width="${(r-n)/o*100}%" height="${(c-a)/e*100}%"><feDropShadow dx="${i.shadowOffset.width}" dy="${i.shadowOffset.height}" stdDeviation="${i.shadowRadius/2}" flood-color="${i.shadowColor}" flood-opacity="1"/></filter></defs>`}var Q="en",ut=typeof Intl!="undefined"&&"Segmenter"in Intl,Xt=ut?new Intl.Segmenter(Q,{granularity:"word"}):null,Ht=ut?new Intl.Segmenter(Q,{granularity:"grapheme"}):null,Vt=[32,160,4961,65792,65793,4153,4241],Jt=t=>{let o=zt(t,{lineBreak:"strict",wordBreak:"normal"}),e=[],i;for(;!(i=o.next()).done;)if(i.value){let s=i.value.slice(),n=[].map.call(s,a=>a.codePointAt(0)),r="";n.forEach(a=>{Vt.includes(a)?(r.length&&e.push(r),e.push(String.fromCodePoint(a)),r=""):r+=String.fromCodePoint(a)}),r.length&&e.push(r)}return e};function lt(t,o){return ut?o==="word"?[...Xt.segment(t)].map(e=>e.segment):[...Ht.segment(t)].map(e=>e.segment):o==="word"?Jt(t):Ut(t)}function*ct(t,o){let e=P(),{parentStyle:i,parent:s,font:n,id:r,isInheritingTransform:a,debug:c,embedFont:u,graphemeImages:b}=o;i.textTransform==="uppercase"?t=t.toLocaleUpperCase(Q):i.textTransform==="lowercase"?t=t.toLocaleLowerCase(Q):i.textTransform==="capitalize"&&(t=lt(t,"word").map(y=>lt(y,"grapheme").map((k,l)=>l===0?k.toLocaleUpperCase(Q):k).join("")).join(""));let d=F(i.wordBreak,{normal:"word","break-all":"grapheme","break-word":"grapheme","keep-all":"word"},"word"),m=lt(t,d),f=e.Node.create();f.setAlignItems(e.ALIGN_BASELINE),i.textAlign==="left"?f.setJustifyContent(e.JUSTIFY_FLEX_START):i.textAlign==="center"?f.setJustifyContent(e.JUSTIFY_CENTER):i.textAlign==="right"?f.setJustifyContent(e.JUSTIFY_FLEX_END):i.textAlign==="justify"&&f.setJustifyContent(e.JUSTIFY_SPACE_BETWEEN),s.insertChild(f,s.getChildCount());let g=n.getFont(i),x=g.ascender/g.unitsPerEm*i.fontSize,I=-(g.descender/g.unitsPerEm)*i.fontSize,L=(x+I)*1.2,{textAlign:$}=i,N=[],G=[],w=[];f.setMeasureFunc((y,k,l,p)=>{let h=[],E="",A=0,X="",R=0,H=0,J=-1;N=[],G=[0];for(let D=0;D<m.length;D++){let Y=m[D];if([" ",`
2
+ `," ","\u3000"].includes(Y))E+=Y,A=n.measure(g,E,i),w[D]=null;else{let q=b&&b[Y]?i.fontSize:n.measure(g,Y,i);R||(E="",A=0);let Ft=A||",.!?:-@)>]}%#".indexOf(Y[0])<0,bt=!R||!!A;Ft&&R+A+q>y?(N.push(R),h.push(X),X=Y,R=q,G.push(1),J=-1):(X+=E+Y,R+=A+q,bt&&G[G.length-1]++),E="",A=0,bt&&J++,H=Math.max(H,R),w[D]={y:h.length*L,x:R-q,width:q,line:h.length,lineIndex:J}}}return R&&(h.push(X),N.push(R)),h.length>1&&(H=y),{width:H,height:h.length*L}});let[B,M]=yield,z="";i.position==="absolute"&&f.calculateLayout();let{left:U,top:v,width:C}=f.getComputedLayout(),W=B+U,T=M+v;for(let y=0;y<m.length;y++){if(!w[y])continue;let k=m[y],l=null,p=null,h=w[y].y,E=w[y].x,A=w[y].width,X=L,R=C-N[w[y].line];if($==="right"||$==="end")E+=R;else if($==="center")E+=R/2;else if($==="justify"){let J=w[y].line;if(J<N.length-1){let D=G[J];E+=(D>1?R/(D-1):0)*w[y].lineIndex}}b&&b[k]?p=b[k]:u?l=n.getSVG(g,k,$t(j({},i),{left:W+E,top:T+h,letterSpacing:i.letterSpacing})):h+=x;let H="";i.textShadowOffset&&(H=V({width:A,height:X,id:r},{shadowColor:i.textShadowColor,shadowOffset:i.textShadowOffset,shadowRadius:i.textShadowRadius})),z+=ft({content:k,filter:H,id:r,left:W+E,top:T+h,width:A,height:X,isInheritingTransform:a,path:l,image:p,debug:c},i)}return z}var mt=mt||{};mt.parse=function(){var t={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/},o="";function e(l){var p=new Error(o+": "+l);throw p.source=o,p}function i(){var l=s();return o.length>0&&e("Invalid input not EOF"),l}function s(){return $(n)}function n(){return r("linear-gradient",t.linearGradient,c)||r("repeating-linear-gradient",t.repeatingLinearGradient,c)||r("radial-gradient",t.radialGradient,d)||r("repeating-radial-gradient",t.repeatingRadialGradient,d)}function r(l,p,h){return a(p,function(E){var A=h();return A&&(y(t.comma)||e("Missing comma before color stops")),{type:l,orientation:A,colorStops:$(N)}})}function a(l,p){var h=y(l);if(h){y(t.startCall)||e("Missing (");var E=p(h);return y(t.endCall)||e("Missing )"),E}}function c(){return u()||b()}function u(){return T("directional",t.sideOrCorner,1)}function b(){return T("angular",t.angleValue,1)}function d(){var l,p=m(),h;return p&&(l=[],l.push(p),h=o,y(t.comma)&&(p=m(),p?l.push(p):o=h)),l}function m(){var l=f()||g();if(l)l.at=I();else{var p=x();if(p){l=p;var h=I();h&&(l.at=h)}else{var E=O();E&&(l={type:"default-radial",at:E})}}return l}function f(){var l=T("shape",/^(circle)/i,0);return l&&(l.style=W()||x()),l}function g(){var l=T("shape",/^(ellipse)/i,0);return l&&(l.style=v()||x()),l}function x(){return T("extent-keyword",t.extentKeywords,1)}function I(){if(T("position",/^at/,0)){var l=O();return l||e("Missing positioning value"),l}}function O(){var l=L();if(l.x||l.y)return{type:"position",value:l}}function L(){return{x:v(),y:v()}}function $(l){var p=l(),h=[];if(p)for(h.push(p);y(t.comma);)p=l(),p?h.push(p):e("One extra comma");return h}function N(){var l=G();return l||e("Expected color definition"),l.length=v(),l}function G(){return B()||z()||M()||w()}function w(){return T("literal",t.literalColor,0)}function B(){return T("hex",t.hexColor,1)}function M(){return a(t.rgbColor,function(){return{type:"rgb",value:$(U)}})}function z(){return a(t.rgbaColor,function(){return{type:"rgba",value:$(U)}})}function U(){return y(t.number)[1]}function v(){return T("%",t.percentageValue,1)||C()||W()}function C(){return T("position-keyword",t.positionKeywords,1)}function W(){return T("px",t.pixelValue,1)||T("em",t.emValue,1)}function T(l,p,h){var E=y(p);if(E)return{type:l,value:E[h]}}function y(l){var p,h;return h=/^[\n\r\t\s]+/.exec(o),h&&k(h[0].length),p=l.exec(o),p&&k(p[0].length),p}function k(l){o=o.substr(l)}return function(l){return o=l.toString(),i()}}();var wt=mt;function jt(t){return t.type==="literal"?t.value:t.type==="hex"?`#${t.value}`:t.type==="rgb"?`rgb(${t.value.join(",")})`:t.type==="rgba"?`rgba(${t.value.join(",")})`:"transparent"}function dt({id:t,width:o},{image:e}){if(e.startsWith("linear-gradient(")){let i=wt.parse(e)[0],s,n,r,a;if(i.orientation.type==="directional")[s,n,r,a]={top:[0,1,0,0],bottom:[0,0,0,1],left:[1,0,0,0],right:[0,0,1,0]}[i.orientation.value];else if(i.orientation.type==="angular"){let f=+i.orientation.value/180*Math.PI-Math.PI/2,g=Math.cos(f),x=Math.sin(f);s=0,n=0,r=g,a=x,r<0&&(s-=r,r=0),a<0&&(n-=a,a=0)}let c=o,u=[];for(let f of i.colorStops){let g=jt(f);if(!u.length&&(u.push({offset:0,color:g}),typeof f.length=="undefined"||f.length.value==="0"))continue;let x=typeof f.length=="undefined"?void 0:f.length.type==="%"?f.length.value/100:f.length.value/c;u.push({offset:x,color:g})}u.length||u.push({offset:0,color:"transparent"});let b=u[u.length-1];b.offset!==1&&(typeof b.offset=="undefined"?b.offset=1:u.push({offset:1,color:b.color}));let d=0,m=1;for(let f=0;f<u.length;f++)if(typeof u[f].offset=="undefined"){for(m<f&&(m=f);typeof u[m].offset=="undefined";)m++;u[f].offset=(u[m].offset-u[d].offset)/(m-d)*(f-d)+u[d].offset}else d=f;return[`satori_bi${t}`,`<linearGradient id="satori_bi${t}" x1="${s}" y1="${n}" x2="${r}" y2="${a}">${u.map(f=>`<stop offset="${f.offset*100}%" stop-color="${f.color}"/>`).join("")}</linearGradient>`]}if(e.startsWith("url(")){let i=e.slice(4,-1);return[`satori_bi${t}`,`<pattern id="satori_bi${t}" patternContentUnits="objectBoundingBox" width="1" height="1"><image href="${i}" x="0" y="0" width="1" height="1"/></pattern>`]}}function nt(t,o,e){return e<t+o&&(e/2<t&&e/2<o?t=o=e/2:e/2<t?t=e-o:e/2<o&&(o=e-t)),[t,o]}function tt({left:t,top:o,width:e,height:i},s){let{borderTopLeftRadius:n,borderTopRightRadius:r,borderBottomLeftRadius:a,borderBottomRightRadius:c}=s;return n=Math.min(n||0,e,i),r=Math.min(r||0,e,i),a=Math.min(a||0,e,i),c=Math.min(c||0,e,i),!n&&!r&&!a&&!c?"":([n,r]=nt(n,r,e),[n,a]=nt(n,a,i),[r,c]=nt(r,c,i),[a,c]=nt(a,c,e),`M${t+n},${o} h${e-n-r} a${r},${r} 0 0 1 ${r},${r} v${i-r-c} a${c},${c} 0 0 1 ${-c},${c} h${c+a-e} a${a},${a} 0 0 1 ${-a},${-a} v${a+n-i} a${n},${n} 0 0 1 ${n},${-n}`)}function gt({id:t,left:o,top:e,width:i,height:s,isInheritingTransform:n,debug:r},a){if(a.display==="none")return"";let c="rect",u="transparent",b=0,d="",m="",f=[],g=1,x="";if(a.backgroundColor&&f.push(a.backgroundColor),a.borderWidth&&(b=a.borderWidth,u=a.borderColor),a.opacity&&(g=+a.opacity),a.transform&&(d=Z({left:o,top:e,width:i,height:s},a.transform,n)),a.backgroundImage){let L=a.backgroundImage.map(($,N)=>dt({id:t+"_"+N,width:i,height:s},$)).filter(Boolean);for(let $ of L)m+=$[1],f.push(`url(#${$[0]})`)}let I=tt({left:o,top:e,width:i,height:s},a);I&&(c="path");let O=V({width:i,height:s,id:t},a);return f.length||f.push("transparent"),r&&(x=`<rect x="${o}" y="${e}" width="${i}" height="${s}" fill="transparent" stroke="#ff5757" stroke-width="1" ${d?`transform="${d}"`:""}></rect>`),`${m?`<defs>${m}</defs>`:""}${O?`${O}<g filter="url(#satori_s-${t})">`:""}${g!==1?`<g opacity="${g}">`:""}${f.map((L,$)=>L==="transparent"&&!($===f.length-1&&b)?"":`<${c} x="${o}" y="${e}" width="${i}" height="${s}" fill="${L}" ${$===f.length-1&&b?`stroke="${u}" stroke-width="${b}"`:""} ${I?`d="${I}"`:""} ${d?`transform="${d}"`:""}></${c}>`).join("")}${g!==1?"</g>":""}${O?"</g>":""}${x}`}function pt({id:t,left:o,top:e,width:i,height:s,src:n,debug:r},a){if(a.display==="none")return"";let c="",u=1,b=a.objectFit==="contain"?"xMidYMid":a.objectFit==="cover"?"xMidYMid slice":"none",d=tt({left:o,top:e,width:i,height:s},a);d&&(c=`<clipPath id="satori_c-${t}"><path x="${o}" y="${e}" width="${i}" height="${s}" d="${d}"></path></clipPath>`),a.opacity&&(u=+a.opacity);let m=V({width:i,height:s,id:t},a);return`${m}${m?`<g filter="url(#satori_s-${t})">`:""}${c}<image href="${n}" x="${o}" y="${e}" width="${i}" height="${s}" preserveAspectRatio="${b}" ${c?`clip-path="url(#satori_c-${t})"`:""} ${u!==1?`opacity="${u}"`:""}></image>${m?"</g>":""}`}function*et(t,o){let e=P(),{id:i,inheritedStyle:s,parent:n,font:r,debug:a,embedFont:c=!0,graphemeImages:u}=o;if(t===null||typeof t=="undefined")return yield,"";if(!it(t)||typeof t.type=="function"){let C;if(!it(t))C=ct(String(t),o);else{if(St(t.type))throw new Error("Class component is not supported.");C=et(t.type(t.props),o)}C.next();let W=yield;return C.next(W).value}let{type:b,props:d}=t,{style:m,children:f}=d,g=e.Node.create();n.insertChild(g,n.getChildCount());let[x,I]=st(g,b,s,m,d),O=x.transform===s.transform;O||(x.transform.__parent=s.transform);let L=typeof f=="undefined"?[]:[].concat(f),$=[],N=0;for(let C of L){let W=et(C,{id:i*L.length+ ++N,parentStyle:x,inheritedStyle:I,isInheritingTransform:!0,parent:g,font:r,embedFont:c,debug:a,graphemeImages:u});W.next(),$.push(W)}let[G,w]=yield;x.position==="absolute"&&g.calculateLayout();let{left:B,top:M,width:z,height:U}=g.getComputedLayout();B+=G,M+=w;let v="";b==="img"?v=pt({id:i,left:B,top:M,width:z,height:U,src:d.src,isInheritingTransform:O,debug:a},x):v=gt({id:i,left:B,top:M,width:z,height:U,isInheritingTransform:O,debug:a},x);for(let C of $)v+=C.next([B,M]).value;return v}import At from"opentype.js";var ot=class{constructor(o){this.fonts=new Map;for(let e of o){let i=e.data,s="buffer"in i?At.parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)):At.parse(i);this.defaultFont||(this.defaultFont=s),this.fonts.has(e.name)||this.fonts.set(e.name,[]),this.fonts.get(e.name).push([s,e.weight,e.style])}}get({name:o,weight:e,style:i}){if(!this.fonts.has(o))return this.defaultFont;e==="normal"&&(e=400),e==="bold"&&(e=700);let s=[...this.fonts.get(o)];return s.sort(([n,r,a],[c,u,b])=>{if(r!==u)return r?!u||r===e?-1:u===e?1:e===400&&r===500||e===500&&r===400?-1:e===400&&u===500||e===500&&u===400?1:e<400?r<e&&u<e?u-r:r<e?-1:u<e?1:r-u:e<r&&e<u?r-u:e<r?-1:e<u?1:u-r:1;if(a!==b){if(a===i)return-1;if(b===i)return 1}return-1}),s[0][0]}getFont({fontFamily:o,fontWeight:e=400,fontStyle:i="normal"}){return this.get({name:o,weight:e,style:i})}measure(o,e,{fontSize:i,letterSpacing:s=0}){return o.getAdvanceWidth(e,i,{letterSpacing:s/i})}getSVG(o,e,{fontSize:i,top:s,left:n,letterSpacing:r=0}){return s+=o.ascender/o.unitsPerEm*i,o.getPath(e,n,s,i,{letterSpacing:r/i}).toPathData(2)}};function ht({width:t,height:o,content:e},i){return`<svg width="${t}" height="${o}" viewBox="0 0 ${t} ${o}" xmlns="http://www.w3.org/2000/svg">${e}</svg>`}function Ct(t,o){let e=P();if(!e)throw new Error("Satori is not initialized.");let i=new ot(o.fonts),s=e.Node.create();s.setWidth(o.width),s.setHeight(o.height),s.setFlexDirection(e.FLEX_DIRECTION_ROW),s.setFlexWrap(e.WRAP_WRAP),s.setAlignContent(e.ALIGN_AUTO),s.setAlignItems(e.ALIGN_FLEX_START),s.setJustifyContent(e.JUSTIFY_FLEX_START);let n=et(t,{id:1,parentStyle:{},inheritedStyle:{fontSize:16,fontWeight:"normal",fontFamily:"serif",fontStyle:"normal",lineHeight:1.2,color:"black",opacity:1},parent:s,font:i,embedFont:o.embedFont,debug:o.debug,graphemeImages:o.graphemeImages});n.next(),s.calculateLayout(o.width,o.height,e.DIRECTION_LTR);let r=n.next([0,0]).value;return ht({width:o.width,height:o.height,content:r})}export{Ct as default,Gt as init};
2
3
  //# sourceMappingURL=index.wasm.js.map