@pairdraw/design-jsx 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","names":["compact","uniq","namesOnInstance","React","React.createElement","React.createElement"],"sources":["../../src/mini-react.ts","../../src/overrides/effects.ts","../../src/overrides/state.ts","../../src/props-overrides.ts","../../src/order.ts","../../src/overrides/vector.ts","../../src/scalar-bindings.ts","../../src/renderer.ts","../../src/transform.ts","../../src/render.ts","../../src/fields.ts"],"sourcesContent":["export type ComponentType = (props: Record<string, unknown>) => ReactNode\n\nexport type ReactElement = {\n type: string | ComponentType\n props: Record<string, unknown> & { children?: ReactNode[] }\n}\n\nexport type ReactNode = ReactElement | string | number | null | undefined | ReactNode[]\n\nexport function createElement(\n type: string | ComponentType,\n props: Record<string, unknown> | null,\n ...children: ReactNode[]\n): ReactElement {\n const flatChildren = children.flat()\n return {\n type,\n props: {\n ...props,\n children: flatChildren.length > 0 ? flatChildren : undefined\n }\n }\n}\n","import * as v from 'valibot'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { colorSchema } from '@pairdraw/scene-graph/color'\nimport { TRANSPARENT } from '@pairdraw/scene-graph/constants'\nimport { parseCSSShadows } from '@pairdraw/scene-graph/css'\nimport { normalizeEffects } from '@pairdraw/scene-graph/effects'\nimport { finiteNumberSchema, type Vector } from '@pairdraw/scene-graph/primitives'\nimport { shaderUniformValueSchema } from '@pairdraw/scene-graph/shaders'\n\nimport { BLEND_MODE, enumProp } from '../enums'\nimport { parseScriptInput } from '../schema'\n\nconst offsetSchema = v.object({\n x: v.optional(finiteNumberSchema),\n y: v.optional(finiteNumberSchema)\n})\n\nconst effectFields = {\n radius: finiteNumberSchema,\n offset: v.optional(offsetSchema),\n spread: v.optional(finiteNumberSchema, 0),\n visible: v.optional(v.boolean(), true),\n blendMode: v.optional(enumProp(BLEND_MODE)),\n showShadowBehindNode: v.optional(v.boolean())\n}\n\nconst SHADOW_TYPES = ['DROP_SHADOW', 'INNER_SHADOW'] as const\nconst BLUR_TYPES = ['LAYER_BLUR', 'BACKGROUND_BLUR', 'FOREGROUND_BLUR'] as const\n\nfunction shadowEffectSchema(type: (typeof SHADOW_TYPES)[number]) {\n return v.object({\n type: v.literal(type),\n color: colorSchema,\n ...effectFields\n })\n}\n\nfunction blurEffectSchema(type: (typeof BLUR_TYPES)[number]) {\n return v.object({\n type: v.literal(type),\n color: v.optional(colorSchema),\n ...effectFields\n })\n}\n\nconst shaderEffectSchema = v.object({\n type: v.literal('SHADER'),\n source: v.pipe(v.string(), v.minLength(1)),\n uniforms: v.optional(v.record(v.string(), shaderUniformValueSchema)),\n uniformBindings: v.optional(v.record(v.string(), v.string())),\n visible: v.optional(v.boolean(), true),\n blendMode: v.optional(enumProp(BLEND_MODE))\n})\n\nconst effectSchema = v.variant('type', [\n shadowEffectSchema('DROP_SHADOW'),\n shadowEffectSchema('INNER_SHADOW'),\n blurEffectSchema('LAYER_BLUR'),\n blurEffectSchema('BACKGROUND_BLUR'),\n blurEffectSchema('FOREGROUND_BLUR'),\n shaderEffectSchema\n])\n\nconst effectsSchema = v.array(effectSchema)\n\ntype ParsedEffect = v.InferOutput<typeof effectSchema>\ntype NormalizableEffect = Parameters<typeof normalizeEffects>[0][number]\ntype StoredShadow = Exclude<NormalizableEffect, { type: 'SHADER' }>\n\n/** Drop an omitted offset so `normalizeEffects` can apply the shadow or blur default. */\nfunction forNormalize(effect: ParsedEffect): NormalizableEffect {\n if (effect.type === 'SHADER') {\n const shader: Extract<NormalizableEffect, { type: 'SHADER' }> = {\n type: 'SHADER',\n source: effect.source,\n visible: effect.visible\n }\n if (effect.uniforms !== undefined) shader.uniforms = effect.uniforms\n if (effect.uniformBindings !== undefined) shader.uniformBindings = effect.uniformBindings\n if (effect.blendMode !== undefined) shader.blendMode = effect.blendMode\n return shader\n }\n const shadow: StoredShadow = {\n type: effect.type,\n color: effect.color ?? { ...TRANSPARENT },\n radius: effect.radius,\n spread: effect.spread,\n visible: effect.visible\n }\n if (effect.offset !== undefined) {\n const offset: Partial<Vector> = {}\n if (effect.offset.x !== undefined) offset.x = effect.offset.x\n if (effect.offset.y !== undefined) offset.y = effect.offset.y\n shadow.offset = offset\n }\n if (effect.blendMode !== undefined) shadow.blendMode = effect.blendMode\n if (effect.showShadowBehindNode !== undefined) {\n shadow.showShadowBehindNode = effect.showShadowBehindNode\n }\n return shadow\n}\n\n/** `effects` takes structured effects; `shadow` appends its shadows and `blur` a layer blur. */\nexport function applyEffectOverrides(props: Record<string, unknown>, o: Partial<SceneNode>): void {\n if (Array.isArray(props.effects) && props.effects.length > 0) {\n const effects = parseScriptInput('effects', effectsSchema, props.effects).map(forNormalize)\n o.effects = normalizeEffects(effects)\n }\n\n // A CSS shadow list, as `box-shadow` takes it.\n const shadows = typeof props.shadow === 'string' ? parseCSSShadows(props.shadow) : []\n if (shadows.length > 0) o.effects = [...(o.effects ?? []), ...shadows]\n\n if (typeof props.blur === 'number') {\n o.effects = [\n ...(o.effects ?? []),\n {\n type: 'LAYER_BLUR',\n radius: props.blur,\n visible: true,\n color: { ...TRANSPARENT },\n offset: { x: 0, y: 0 },\n spread: 0\n }\n ]\n }\n}\n","import { CONSTRAINT, MASK_TYPE } from '#design-jsx/enums'\n\nimport type { ConstraintType, SceneNode } from '@pairdraw/scene-graph'\n\nfunction constraintValue(value: unknown): ConstraintType | undefined {\n return CONSTRAINT.parse(value)\n}\n\n/** The `constraints` prop, shaped like Figma's `constraints` object. */\ninterface ConstraintsValue {\n horizontal?: unknown\n vertical?: unknown\n}\n\nfunction isConstraintsValue(value: unknown): value is ConstraintsValue {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction applyConstraints(value: unknown, o: Partial<SceneNode>): void {\n if (!isConstraintsValue(value)) return\n const h = constraintValue(value.horizontal)\n const v = constraintValue(value.vertical)\n if (h) o.horizontalConstraint = h\n if (v) o.verticalConstraint = v\n}\n\nfunction sizeLimit(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined\n}\n\n/**\n * Visibility, locking, mask, constraint, and size-limit props. Constraints follow Figma's\n * `constraints` object with its values in lowercase, as `blendMode` is.\n */\nexport function applyStateOverrides(props: Record<string, unknown>, o: Partial<SceneNode>): void {\n if (typeof props.visible === 'boolean') o.visible = props.visible\n if (typeof props.locked === 'boolean') o.locked = props.locked\n applyConstraints(props.constraints, o)\n\n const minWidth = sizeLimit(props.minW)\n const maxWidth = sizeLimit(props.maxW)\n const minHeight = sizeLimit(props.minH)\n const maxHeight = sizeLimit(props.maxH)\n if (minWidth !== undefined) o.minWidth = minWidth\n if (maxWidth !== undefined) o.maxWidth = maxWidth\n if (minHeight !== undefined) o.minHeight = minHeight\n if (maxHeight !== undefined) o.maxHeight = maxHeight\n\n // `mask` alone masks by alpha; an unknown mask type leaves the layer as it was.\n const maskType = props.mask === true ? 'ALPHA' : MASK_TYPE.parse(props.mask)\n if (maskType) {\n o.isMask = true\n o.maskType = maskType\n }\n}\n","import type { Fill, SceneNode, ArcData, NodeType } from '@pairdraw/scene-graph'\nimport { colorToFill, tryParseColor } from '@pairdraw/scene-graph/color'\nimport { parseCSSGridTracks, parseCSSNumber } from '@pairdraw/scene-graph/css'\nimport {\n autoLayoutSizingFields,\n fillSizingFields,\n parseAutoLayoutDirection,\n parseCounterAxisAlign,\n parsePrimaryAxisAlign\n} from '@pairdraw/scene-graph/layout'\nimport type { Color, JSONObject } from '@pairdraw/scene-graph/primitives'\nimport { withShaderPaints, type ShaderPaint } from '@pairdraw/scene-graph/shaders'\n\nimport { DESIGN_JSX_STYLE_KEYS, designJSXProp } from './definitions'\nimport {\n BLEND_MODE,\n TEXT_ALIGN,\n TEXT_ALIGN_VERTICAL,\n TEXT_AUTO_RESIZE,\n TEXT_CASE,\n TEXT_DECORATION,\n TEXT_DIRECTION\n} from './enums'\nimport { applyEffectOverrides } from './overrides/effects'\nimport { fillFromValue, isColor, isFillValue } from './overrides/fills'\nimport { applyStateOverrides } from './overrides/state'\nimport { applyStrokeOverrides } from './overrides/strokes'\nimport { applyTextDetailOverrides, AUTO, textLengthProp } from './overrides/text'\nimport { isShaderFill } from './paints'\nimport { readLayerProps, type LayerProps } from './schema'\n\nconst WEIGHT_MAP: Record<string, number> = {\n normal: 400,\n medium: 500,\n bold: 700\n}\n\nfunction parseDirection(value: unknown): SceneNode['textDirection'] | undefined {\n if (typeof value !== 'string') return undefined\n return TEXT_DIRECTION.parse(value) ?? 'AUTO'\n}\n\nfunction numberFromPx(value: unknown): number | undefined {\n if (typeof value === 'number') return value\n return typeof value === 'string' ? (parseCSSNumber(value) ?? undefined) : undefined\n}\n\n/** `props` with the sizes and styles its `style` object gives, where the props leave them unset. */\nexport function normalizeStyleProps(props: Record<string, unknown>): Record<string, unknown> {\n const style = props.style\n if (style === null || typeof style !== 'object' || Array.isArray(style)) return props\n\n const source = style as JSONObject\n const normalized = { ...props }\n for (const [name, keys] of Object.entries(DESIGN_JSX_STYLE_KEYS)) {\n if (designJSXProp(normalized, name) !== undefined) continue\n const found = keys.find(({ key }) => source[key] !== undefined)\n if (found) normalized[name] = found.px ? numberFromPx(source[found.key]) : source[found.key]\n }\n return normalized\n}\n\nexport function applySizeOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n parentLayout: SceneNode['layoutMode']\n): { w: unknown; h: unknown } {\n const w = designJSXProp(props, 'w')\n const h = designJSXProp(props, 'h')\n if (typeof w === 'number') o.width = w\n if (typeof h === 'number') o.height = h\n\n if (w === 'fill') Object.assign(o, fillSizingFields(parentLayout, 'HORIZONTAL'))\n if (h === 'fill') Object.assign(o, fillSizingFields(parentLayout, 'VERTICAL'))\n\n if (props.x !== undefined) o.x = props.x as number\n if (props.y !== undefined) o.y = props.y as number\n if (props.top !== undefined) o.y = props.top as number\n if (props.left !== undefined) o.x = props.left as number\n\n if (props.position === 'absolute') o.layoutPositioning = 'ABSOLUTE'\n const hasExplicitPosition =\n props.x !== undefined ||\n props.y !== undefined ||\n props.top !== undefined ||\n props.left !== undefined\n if (hasExplicitPosition && parentLayout !== 'NONE') {\n o.layoutPositioning = 'ABSOLUTE'\n }\n\n return { w, h }\n}\n\n/**\n * Sets the layer's fills, moving each shader paint's preset into the layer's plugin data,\n * where a shader paint keeps it.\n */\nfunction setFills(values: (string | Color | Fill)[], o: Partial<SceneNode>): void {\n const shaders: ShaderPaint[] = []\n // A colour string no parser reads would otherwise become black, opposite to leaving it out.\n const usable = values.filter(\n (value) => typeof value !== 'string' || tryParseColor(value) !== null\n )\n const fills = usable.map((value) => {\n const fill = fillFromValue(value)\n if (!isShaderFill(fill)) return fill\n const { shader, ...paint } = fill\n if (paint.imageHash) shaders.push(shader)\n return paint\n })\n if (fills.length === 0) return\n o.fills = fills\n if (shaders.length > 0)\n o.pluginData = withShaderPaints({ pluginData: o.pluginData ?? [] }, fills, shaders)\n}\n\nfunction applyFillOverride(props: Record<string, unknown>, o: Partial<SceneNode>): void {\n // `fills={[]}` paints nothing, which a text, painted black by default, has to say.\n if (Array.isArray(props.fills) && props.fills.length === 0) {\n o.fills = []\n return\n }\n if (Array.isArray(props.fills)) {\n setFills(props.fills.filter(isFillValue), o)\n return\n }\n\n const bg = designJSXProp(props, 'bg')\n if (isFillValue(bg)) setFills([bg], o)\n}\n\nfunction applyCornerOverrides(props: LayerProps, o: Partial<SceneNode>): void {\n const rounded = props.rounded ?? props.cornerRadius ?? props.borderRadius\n if (rounded !== undefined) o.cornerRadius = rounded\n\n if (\n props.roundedTL !== undefined ||\n props.roundedTR !== undefined ||\n props.roundedBL !== undefined ||\n props.roundedBR !== undefined\n ) {\n o.independentCorners = true\n if (props.roundedTL !== undefined) o.topLeftRadius = props.roundedTL\n if (props.roundedTR !== undefined) o.topRightRadius = props.roundedTR\n if (props.roundedBL !== undefined) o.bottomLeftRadius = props.roundedBL\n if (props.roundedBR !== undefined) o.bottomRightRadius = props.roundedBR\n }\n\n if (props.cornerSmoothing !== undefined) o.cornerSmoothing = props.cornerSmoothing\n}\n\nfunction applyVisualOverrides(props: LayerProps, o: Partial<SceneNode>): void {\n applyFillOverride(props, o)\n applyStrokeOverrides(props, o)\n applyCornerOverrides(props, o)\n\n if (props.opacity !== undefined) o.opacity = props.opacity\n applyTransformOverrides(props, o)\n const blendMode = BLEND_MODE.parse(props.blendMode)\n if (blendMode) o.blendMode = blendMode\n if (props.overflow === 'hidden') o.clipsContent = true\n}\n\nfunction applyTransformOverrides(props: LayerProps, o: Partial<SceneNode>): void {\n const rotation = props.rotate ?? props.rotation\n if (rotation !== undefined) o.rotation = rotation\n if (props.flipX !== undefined) o.flipX = props.flipX === true\n if (props.flipY !== undefined) o.flipY = props.flipY === true\n}\n\nfunction applyPaddingOverrides(props: Record<string, unknown>, o: Partial<SceneNode>): void {\n const p = designJSXProp(props, 'p')\n if (typeof p === 'number') {\n o.paddingTop = p\n o.paddingRight = p\n o.paddingBottom = p\n o.paddingLeft = p\n }\n const px = props.px as number | undefined\n const py = props.py as number | undefined\n if (px !== undefined) {\n o.paddingLeft = px\n o.paddingRight = px\n }\n if (py !== undefined) {\n o.paddingTop = py\n o.paddingBottom = py\n }\n if (props.pt !== undefined) o.paddingTop = props.pt as number\n if (props.pr !== undefined) o.paddingRight = props.pr as number\n if (props.pb !== undefined) o.paddingBottom = props.pb as number\n if (props.pl !== undefined) o.paddingLeft = props.pl as number\n}\n\nconst PADDING_KEYS = ['p', 'padding', 'px', 'py', 'pt', 'pr', 'pb', 'pl'] as const\nconst AUTO_LAYOUT_TRIGGER_KEYS = [\n ...PADDING_KEYS,\n 'justify',\n 'justifyContent',\n 'items',\n 'align',\n 'alignItems'\n] as const\n\nfunction hasAutoLayoutTriggerProps(props: Record<string, unknown>): boolean {\n return AUTO_LAYOUT_TRIGGER_KEYS.some((k) => props[k] !== undefined)\n}\n\nfunction applyGridOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n w: unknown,\n h: unknown\n): void {\n o.layoutMode = 'GRID'\n\n if (typeof w === 'number') o.width = w\n if (typeof h === 'number') o.height = h\n\n if (typeof props.columns === 'string') {\n o.gridTemplateColumns = parseCSSGridTracks(props.columns)\n } else if (typeof props.columns === 'number') {\n o.gridTemplateColumns = Array.from({ length: props.columns }, () => ({\n sizing: 'FR' as const,\n value: 1\n }))\n }\n\n if (typeof props.rows === 'string') {\n o.gridTemplateRows = parseCSSGridTracks(props.rows)\n } else if (typeof props.rows === 'number') {\n o.gridTemplateRows = Array.from({ length: props.rows }, () => ({\n sizing: 'FR' as const,\n value: 1\n }))\n }\n\n if (typeof props.columnGap === 'number') o.gridColumnGap = props.columnGap\n if (typeof props.rowGap === 'number') o.gridRowGap = props.rowGap\n if (typeof props.gap === 'number') {\n o.gridColumnGap = props.gap\n o.gridRowGap = props.gap\n }\n\n if (props.rows === undefined && typeof h !== 'number') {\n o.height = 0\n }\n}\n\nfunction applyGridChildOverrides(props: Record<string, unknown>, o: Partial<SceneNode>): void {\n const col = designJSXProp(props, 'colStart')\n const row = designJSXProp(props, 'rowStart')\n const colSpan = designJSXProp(props, 'colSpan')\n const rowSpan = designJSXProp(props, 'rowSpan')\n\n // A span without a start is CSS `grid-column: span N`, which holds while auto placement picks\n // the column; requiring a start here dropped `colSpan` alone.\n if (col === undefined && row === undefined && colSpan === undefined && rowSpan === undefined)\n return\n o.gridPosition = {\n column: (col as number | undefined) ?? 0,\n row: (row as number | undefined) ?? 0,\n columnSpan: (colSpan as number | undefined) ?? 1,\n rowSpan: (rowSpan as number | undefined) ?? 1\n }\n}\n\nfunction applyAutoLayoutSizing(\n o: Partial<SceneNode>,\n props: Record<string, unknown>,\n w: unknown,\n h: unknown\n): void {\n const flex = typeof props.flex === 'string' ? props.flex : 'col'\n o.layoutMode = parseAutoLayoutDirection(flex) ?? 'HORIZONTAL'\n const own = (dim: unknown) => (typeof dim === 'number' ? 'FIXED' : 'HUG')\n Object.assign(o, autoLayoutSizingFields(o.layoutMode, own(w), own(h)))\n}\n\nfunction applyLayoutAlignmentOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode>\n): void {\n const justify = designJSXProp(props, 'justify')\n if (typeof justify === 'string' && justify) {\n o.primaryAxisAlign = parsePrimaryAxisAlign(justify) ?? 'MIN'\n }\n const items = designJSXProp(props, 'items')\n if (typeof items === 'string' && items) {\n o.counterAxisAlign = parseCounterAxisAlign(items) ?? 'MIN'\n }\n}\n\nfunction shouldEnableAutoLayout(props: Record<string, unknown>, isText: boolean): boolean {\n if (props.flex !== undefined) return true\n if (!isText && hasAutoLayoutTriggerProps(props)) return true\n return false\n}\n\nfunction applyLayoutOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n w: unknown,\n h: unknown,\n isText: boolean,\n parentLayout: SceneNode['layoutMode']\n): void {\n if (props.grid) {\n applyGridOverrides(props, o, w, h)\n applyPaddingOverrides(props, o)\n if (props.grow !== undefined) o.layoutGrow = props.grow as number\n return\n }\n\n if (parentLayout === 'GRID') {\n applyGridChildOverrides(props, o)\n }\n\n if (shouldEnableAutoLayout(props, isText)) {\n applyAutoLayoutSizing(o, props, w, h)\n }\n\n o.layoutDirection =\n parseDirection(props.flow ?? (!isText ? props.dir : undefined)) ?? o.layoutDirection\n\n if (props.gap !== undefined) o.itemSpacing = props.gap as number\n\n if (props.wrap) {\n o.layoutWrap = 'WRAP'\n if (props.rowGap !== undefined) o.counterAxisSpacing = props.rowGap as number\n }\n\n applyLayoutAlignmentOverrides(props, o)\n\n applyPaddingOverrides(props, o)\n\n if (props.grow !== undefined) o.layoutGrow = props.grow as number\n}\n\nfunction applyTextStyleOverrides(props: LayerProps, o: Partial<SceneNode>): void {\n const fontSize = designJSXProp(props, 'size')\n if (typeof fontSize === 'number') o.fontSize = fontSize\n\n const fontFamily = designJSXProp(props, 'font')\n if (typeof fontFamily === 'string') o.fontFamily = fontFamily\n\n const weight = designJSXProp(props, 'weight')\n if (typeof props.italic === 'boolean') o.italic = props.italic\n\n if (typeof weight === 'number') {\n o.fontWeight = weight\n } else if (typeof weight === 'string') {\n o.fontWeight = WEIGHT_MAP[weight] ?? 400\n }\n\n if (typeof props.color === 'string' || isColor(props.color)) {\n o.fills = [colorToFill(props.color)]\n }\n\n // A value it cannot read is left out, so the text keeps its own.\n const lineHeight = props.lineHeight === AUTO ? null : textLengthProp(props.lineHeight)\n if (lineHeight !== undefined) o.lineHeight = lineHeight\n const letterSpacing = textLengthProp(props.letterSpacing)\n if (letterSpacing) o.letterSpacing = letterSpacing\n const textDecoration = TEXT_DECORATION.parse(props.textDecoration)\n if (textDecoration) o.textDecoration = textDecoration\n applyTextDetailOverrides(props, o)\n const textCase = TEXT_CASE.parse(props.textCase)\n if (textCase) o.textCase = textCase\n if (props.maxLines !== undefined) {\n o.maxLines = props.maxLines\n o.textTruncation = 'ENDING'\n }\n if (props.truncate) {\n o.textTruncation = 'ENDING'\n }\n\n applyTextAlignmentOverrides(props, o)\n}\n\nfunction applyTextAlignmentOverrides(props: Record<string, unknown>, o: Partial<SceneNode>): void {\n const textAlign = designJSXProp(props, 'textAlign')\n if (typeof textAlign === 'string') {\n o.textAlignHorizontal = TEXT_ALIGN.parse(textAlign) ?? 'LEFT'\n }\n\n const textAlignVertical = designJSXProp(props, 'textAlignVertical')\n if (typeof textAlignVertical === 'string') {\n o.textAlignVertical = TEXT_ALIGN_VERTICAL.parse(textAlignVertical) ?? 'TOP'\n }\n}\n\nfunction applyTextAutoResize(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n parentLayout: SceneNode['layoutMode']\n): void {\n const w = designJSXProp(props, 'w')\n const hasExplicitWidth = w !== undefined\n const grow = typeof props.grow === 'number' ? props.grow : undefined\n const fillsParent = w === 'fill' || (grow !== undefined && grow > 0)\n const isInsideAutoLayout = parentLayout !== 'NONE'\n\n // DO NOT CHANGE these defaults without testing headless layout (no CanvasKit).\n // WIDTH_AND_HEIGHT relies on MeasureFunc — without it, text keeps the 100×100\n // default SceneNode size and blows up every HUG container. layout.ts has a\n // fallback estimator, but changing this logic can silently break all JSX rendering.\n if (props.textAutoResize) {\n o.textAutoResize = TEXT_AUTO_RESIZE.parse(props.textAutoResize) ?? 'NONE'\n } else if (hasExplicitWidth || (isInsideAutoLayout && fillsParent)) {\n o.textAutoResize = 'HEIGHT'\n } else {\n o.textAutoResize = 'WIDTH_AND_HEIGHT'\n }\n}\n\nfunction applyTextOverrides(\n props: LayerProps,\n o: Partial<SceneNode>,\n parentLayout: SceneNode['layoutMode']\n): void {\n applyTextStyleOverrides(props, o)\n // Without `dir` the node keeps the style's own direction, which is auto by default; writing an\n // undefined override would erase it and stop Arabic text from being detected as RTL.\n const direction = parseDirection(props.dir)\n if (direction) o.textDirection = direction\n applyTextAutoResize(props, o, parentLayout)\n}\n\nconst FULL_TURN_DEGREES = 360\n\nfunction numberProp(value: unknown): number | undefined {\n return typeof value === 'number' ? value : undefined\n}\n\n/**\n * An `<Ellipse>`'s arc from its props: angles in degrees, clockwise from three o'clock, as the\n * canvas draws arcs, and the hole as a share of the ellipse. Null when none is set.\n */\nfunction arcOverride(props: Record<string, unknown>): ArcData | null {\n const start = numberProp(props.startAngle)\n const end = numberProp(props.endAngle)\n const innerRadius = numberProp(props.innerRadius)\n if (start === undefined && end === undefined && innerRadius === undefined) return null\n const startDegrees = start ?? 0\n return {\n startingAngle: (startDegrees * Math.PI) / 180,\n endingAngle: ((end ?? startDegrees + FULL_TURN_DEGREES) * Math.PI) / 180,\n innerRadius: innerRadius ?? 0\n }\n}\n\n/** The fields a shape element's own props set, by the layer it makes. */\nexport function shapeOverrides(\n nodeType: NodeType,\n props: Record<string, unknown>\n): Partial<SceneNode> {\n const o: Partial<SceneNode> = {}\n if (nodeType === 'STAR' || nodeType === 'POLYGON') {\n const points = numberProp(props.pointCount) ?? numberProp(props.points)\n if (points !== undefined) o.pointCount = points\n }\n if (nodeType === 'STAR') {\n const innerRadius = numberProp(props.innerRadius)\n if (innerRadius !== undefined) o.starInnerRadius = innerRadius\n }\n if (nodeType === 'ELLIPSE') {\n const arc = arcOverride(props)\n if (arc) o.arcData = arc\n }\n return o\n}\n\nexport function propsToOverrides(\n props: Record<string, unknown>,\n isText: boolean,\n parentLayout: SceneNode['layoutMode']\n): Partial<SceneNode> {\n // Layer props are read once, after `style` gives the ones the props leave unset.\n const layer = readLayerProps(normalizeStyleProps(props))\n const o: Partial<SceneNode> = {}\n\n if (layer.name) o.name = layer.name\n\n const { w, h } = applySizeOverrides(layer, o, parentLayout)\n applyVisualOverrides(layer, o)\n applyLayoutOverrides(layer, o, w, h, isText, parentLayout)\n if (isText) applyTextOverrides(layer, o, parentLayout)\n applyEffectOverrides(layer, o)\n applyStateOverrides(layer, o)\n\n return o\n}\n","import { compact, isPlainObject, isString, pull, range, uniq } from 'es-toolkit'\n\nimport { namesComponent, rekaRole } from './behaviours'\nimport { isComponentProperty } from './component-properties'\nimport { DESIGN_JSX_SUPPORTED_PROPERTIES } from './definitions'\nimport { elementNodeType } from './elements'\nimport { isLayerRef, type LayerRef } from './refs'\nimport { isTreeNode, type TreeNode } from './tree'\n\n/** A component as an element names it: by name, or by the `ref()` that marks it. */\ntype ComponentKey = string | LayerRef\n\n/**\n * The components an element and its descendants define and name. `mayName` holds the text values\n * property props give, an exposed nested instance's included: a swap takes one as a component's\n * name, other properties as plain text, and which is which is known only once the component\n * renders.\n */\ninterface ComponentUse {\n defines: ComponentKey[]\n names: ComponentKey[]\n mayName: string[]\n}\n\n/** Whether an element defines a component: a component, a set, or a Reka root naming none. */\nfunction definesComponent(node: TreeNode): boolean {\n const nodeType = elementNodeType(node.type)\n if (nodeType === 'COMPONENT' || nodeType === 'COMPONENT_SET') return true\n return rekaRole(node.type)?.role === 'root' && !namesComponent(node.props)\n}\n\n/** What the element itself defines or names, without its descendants. */\nfunction ownUse(node: TreeNode): ComponentUse {\n const { props } = node\n if (definesComponent(node)) {\n const name = isString(props.name) ? props.name : ''\n return { defines: compact([name, isLayerRef(props.ref) && props.ref]), names: [], mayName: [] }\n }\n const of = props.component ?? props.componentId ?? props.of\n const component = isComponentProperty(of) ? of.defaultValue : of\n const assigned = [\n ...Object.entries(props)\n .filter(([key]) => !DESIGN_JSX_SUPPORTED_PROPERTIES.has(key))\n .map(([, value]) => value),\n ...(isPlainObject(props.properties) ? Object.values(props.properties) : [])\n ]\n // An exposed nested instance's values, as in `Action={{ Icon: 'Arrow' }}`.\n const nested = assigned.filter(isPlainObject).flatMap((values) => Object.values(values))\n return {\n defines: [],\n names: [\n ...(isString(component) || isLayerRef(component) ? [component] : []),\n ...assigned.filter(isLayerRef)\n ],\n mayName: [...assigned, ...nested].filter(isString)\n }\n}\n\n/** Reads each element's components once, for every level an order is asked at. */\nexport class RenderOrder {\n private readonly uses = new WeakMap<TreeNode, ComponentUse>()\n\n private use(node: TreeNode): ComponentUse {\n const known = this.uses.get(node)\n if (known) return known\n const parts = [\n ownUse(node),\n ...node.children.filter(isTreeNode).map((child) => this.use(child))\n ]\n const use = {\n defines: uniq(parts.flatMap((part) => part.defines)),\n names: uniq(parts.flatMap((part) => part.names)),\n mayName: uniq(parts.flatMap((part) => part.mayName))\n }\n this.uses.set(node, use)\n return use\n }\n\n /**\n * The indices of `siblings` in render order: those that define a component before those that\n * name it, otherwise as written. When none is ready, what text values may name gives way\n * first, so a text that matches a component's name never holds back a real reference; only\n * components that do name each other keep the written order.\n */\n of(siblings: readonly TreeNode[]): number[] {\n const uses = siblings.map((sibling) => this.use(sibling))\n if (uses.every((use) => use.defines.length === 0)) return range(siblings.length)\n\n const owners = new Map<ComponentKey, number[]>()\n uses.forEach((use, index) => {\n for (const key of use.defines) owners.set(key, [...(owners.get(key) ?? []), index])\n })\n const siblingsDefining = (keys: ComponentKey[], index: number) =>\n uniq(keys.flatMap((key) => owners.get(key) ?? [])).filter((owner) => owner !== index)\n const needs = uses.map((use, index) => siblingsDefining(use.names, index))\n const mayNeed = uses.map((use, index) => siblingsDefining(use.mayName, index))\n\n const order: number[] = []\n const pending = range(siblings.length)\n const rendered = (indices: number[]) => indices.every((index) => order.includes(index))\n while (pending.length > 0) {\n const next =\n pending.find((index) => rendered(needs[index]) && rendered(mayNeed[index])) ??\n pending.find((index) => rendered(needs[index])) ??\n pending[0]\n order.push(next)\n pull(pending, [next])\n }\n return order\n }\n}\n","import * as v from 'valibot'\n\nimport type { SceneGraph, SceneNode, VectorNetwork } from '@pairdraw/scene-graph'\nimport { parsePluginVectorPath, parseSVGPathData } from '@pairdraw/scene-graph/parse-path'\nimport type { Rect } from '@pairdraw/scene-graph/primitives'\nimport { mergeVectorNetworks, transformVectorNetwork } from '@pairdraw/scene-graph/vector-network'\n\nimport { designJSXProp } from '../definitions'\nimport { normalizeStyleProps } from '../props-overrides'\nimport { parseScriptInput } from '../schema'\n\nconst FILL_RULES = { nonzero: 'NONZERO', evenodd: 'EVENODD' } as const\n\nconst vectorPropsSchema = v.pipe(\n v.object({\n d: v.optional(v.pipe(v.string(), v.trim(), v.nonEmpty())),\n fillRule: v.optional(v.picklist(['nonzero', 'evenodd'])),\n paths: v.optional(\n v.array(\n v.object({\n windingRule: v.picklist(['NONZERO', 'EVENODD', 'NONE']),\n data: v.string()\n })\n )\n )\n }),\n v.check((props) => !(props.d && props.paths), 'Expected `d` or `paths`, not both')\n)\n\nfunction parsedNetwork(result: ReturnType<typeof parseSVGPathData>, which: string): VectorNetwork {\n if (!result.ok) throw new Error(`Invalid <Vector> ${which}: ${result.error}`)\n return result.network\n}\n\n/**\n * The vector network a `<Vector>`'s `d` or `paths` draws, in the coordinates they are written\n * in, or null when it has neither. `d` reads as SVG does, its open subpaths filled only when\n * `fillsOpenSubpaths`; `paths` as Figma's `vectorPaths`.\n */\nfunction vectorNetworkProp(\n props: Record<string, unknown>,\n fillsOpenSubpaths: boolean\n): VectorNetwork | null {\n const parsed = parseScriptInput('Invalid <Vector> props', vectorPropsSchema, props)\n if (parsed.d) {\n const windingRule = FILL_RULES[parsed.fillRule ?? 'nonzero']\n return parsedNetwork(\n parseSVGPathData(parsed.d, windingRule, { includeOpenRegions: fillsOpenSubpaths }),\n '`d`'\n )\n }\n if (!parsed.paths) return null\n return mergeVectorNetworks(\n parsed.paths.map(({ windingRule, data }, index) =>\n parsedNetwork(parsePluginVectorPath(data, windingRule), `paths[${index}]`)\n )\n )\n}\n\n/** The size a `<Vector>` is given, on the axes its props size. */\ninterface VectorSize {\n width?: number\n height?: number\n}\n\n/**\n * The size of `node` on the axes `props` set, by `w`/`width` and `h`/`height`, however they set\n * them: a number, a variable, or a layout value. The layer already holds what they resolve to.\n */\nfunction vectorSize(props: Record<string, unknown>, node: SceneNode): VectorSize {\n const sized = normalizeStyleProps(props)\n return {\n width: designJSXProp(sized, 'w') === undefined ? undefined : node.width,\n height: designJSXProp(sized, 'h') === undefined ? undefined : node.height\n }\n}\n\n/**\n * The fields that place a vector network in its layer. On an axis the author sized, the path is\n * drawn in the layer's own box as written, as an SVG icon is in its view box. On an axis left\n * unsized, the layer takes the network's extent and moves to where it starts, as Figma's\n * `vectorPaths` setter does.\n */\nfunction vectorGeometry(\n network: VectorNetwork,\n bounds: Rect,\n size: VectorSize,\n position: Pick<SceneNode, 'x' | 'y'>\n): Partial<SceneNode> {\n const dx = size.width === undefined ? bounds.x : 0\n const dy = size.height === undefined ? bounds.y : 0\n return {\n x: position.x + dx,\n y: position.y + dy,\n width: size.width ?? bounds.width,\n height: size.height ?? bounds.height,\n vectorNetwork: transformVectorNetwork([1, 0, -dx, 0, 1, -dy, 0, 0, 1], network)\n }\n}\n\n/**\n * A `<Vector>`'s `d` or `paths` as its vector network, the layer sized to it. `vectorBounds`\n * measures the network, curves included, which the engine provides.\n */\nexport function placeVectorPaths(\n graph: SceneGraph,\n node: SceneNode,\n props: Record<string, unknown>,\n vectorBounds: (network: VectorNetwork) => Rect\n): void {\n if (node.type !== 'VECTOR') return\n // A filled vector strokes its regions, which close, so an open subpath becomes one only when\n // nothing strokes it, as SVG import decides.\n const fillsOpenSubpaths =\n node.fills.some((fill) => fill.visible) && !node.strokes.some((stroke) => stroke.visible)\n const network = vectorNetworkProp(props, fillsOpenSubpaths)\n if (!network) return\n graph.updateNode(\n node.id,\n vectorGeometry(network, vectorBounds(network), vectorSize(props, node), node)\n )\n}\n","import type { SceneGraph, VariableLiteral } from '@pairdraw/scene-graph'\n\nimport { isVariable } from './variables'\nimport { requireVariableId } from './variables/graph'\nimport { scalarProps } from './variables/props'\n\n/** Resolve numeric props before sizing inference; retain real graph bindings afterward. */\nexport function prepareScalarBindings(\n graph: SceneGraph,\n props: Record<string, unknown>,\n bindings: Record<string, string>,\n isText: boolean,\n resolve: (variableId: string) => VariableLiteral | undefined\n): void {\n const entries = scalarProps({ text: isText, grid: !!props.grid, wrap: !!props.wrap })\n const scalarBindings = new Map<string, string>()\n for (const { prop: key, fields } of entries) {\n const value = props[key]\n if (value === undefined) continue\n // A literal longhand must also override a bound shorthand on that edge.\n for (const field of fields) scalarBindings.delete(field)\n if (!isVariable(value)) continue\n\n const variable = graph.variables.get(requireVariableId(graph, value))\n if (variable?.type !== 'FLOAT') {\n throw new Error(`Expected a FLOAT variable for ${key}: ${value.name}`)\n }\n const resolved = resolve(variable.id)\n if (typeof resolved !== 'number' || !Number.isFinite(resolved)) {\n throw new TypeError(`Cannot resolve numeric variable for ${key}: ${value.name}`)\n }\n props[key] = resolved\n for (const field of fields) scalarBindings.set(field, variable.id)\n }\n Object.assign(bindings, Object.fromEntries(scalarBindings))\n}\n","import { omitBy } from 'es-toolkit/object'\n\nimport type { NodeType, SceneGraph, SceneNode, VariableModeMap } from '@pairdraw/scene-graph'\nimport { parseColor } from '@pairdraw/scene-graph/color'\nimport { setInstanceOverride } from '@pairdraw/scene-graph/instances/overrides'\nimport { textLayerName } from '@pairdraw/scene-graph/node-defaults'\n\nimport type { RekaScope } from './behaviours'\nimport { renderRekaNode } from './behaviours/render'\nimport {\n assignComponentProperties,\n assignNamedProperties,\n bindProperties,\n componentPropNames as namesOnInstance,\n exposeInstance,\n inferComponentSetProperties\n} from './component-properties'\nimport { CONNECTOR_ELEMENT, resolveConnectorEnds } from './connectors'\nimport { elementNodeType, elementOwnLayer, type OwnLayerRenderer } from './elements'\nimport { RenderOrder } from './order'\nimport { placeVectorPaths } from './overrides/vector'\nimport { applySizeOverrides, propsToOverrides, shapeOverrides } from './props-overrides'\nimport { isLayerRef, LayerRefs } from './refs'\nimport { prepareScalarBindings } from './scalar-bindings'\nimport { readElementProps } from './schema'\nimport type { DesignJSXServices } from './services'\nimport { isTextContent, TEXT_CONTENT_NAMES, textContentFields } from './text-content'\nimport { FRAGMENT, isTreeNode } from './tree'\nimport type { TreeNode } from './tree'\nimport type { RenderOptions } from './types'\nimport { isVariable } from './variables'\nimport {\n applyVariableDefinitions,\n bindVariableProp,\n requireVariableId,\n resolveForLayer,\n variableModes,\n type LayerContext\n} from './variables/graph'\nimport { paintProps } from './variables/props'\n\nexport interface RenderResult {\n id: string\n name: string\n type: NodeType\n childIds: string[]\n warnings?: string[]\n}\n\n/** The nodes a tree renders as: a fragment's children, or the tree itself. */\nfunction treeRoots(tree: TreeNode): TreeNode[] {\n return tree.type === FRAGMENT ? tree.children.filter(isTreeNode) : [tree]\n}\n\n/** Render every root of `tree` into the parent and lay out once. */\nexport async function renderRoots<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n options: RenderOptions = {}\n): Promise<RenderResult[]> {\n const roots = treeRoots(tree)\n if (roots.length === 0) throw new Error('JSX must return a Figma element (Frame, Text, etc)')\n const parentId = options.parentId ?? graph.getPages()[0].id\n applyVariableDefinitions(graph, tree)\n\n const originalChildCount = graph.getChildren(parentId).length\n // Render roots that define a component before roots that name it, so an `<Instance of={card}>`\n // written before its `<Component ref={card}>` still finds the component (RenderOrder).\n const order = new RenderOrder()\n const nodes: SceneNode[] = []\n const connectors: Array<{ node: SceneNode; tree: TreeNode }> = []\n const refs = new LayerRefs()\n const onNode = (element: TreeNode, node: SceneNode) => {\n if (element.type === CONNECTOR_ELEMENT) connectors.push({ node, tree: element })\n else refs.mark(element.props.ref, node)\n options.onNode?.(element, node)\n }\n for (const index of order.of(roots)) {\n const node = await renderNode(services, graph, roots[index], parentId, onNode, undefined, refs)\n const { x, y } = options.positions?.[index] ?? options\n if (x !== undefined) graph.updateNode(node.id, { x })\n if (y !== undefined) graph.updateNode(node.id, { y })\n nodes[index] = node\n }\n // Keep the written layer order even though components rendered first.\n nodes.forEach((node, index) => graph.insertChildAt(node.id, parentId, originalChildCount + index))\n\n const rootIds = nodes.map((node) => node.id)\n const warnings = [...refs.warnings, ...resolveConnectorEnds(graph, rootIds, connectors, refs)]\n if (!options.deferLayout) services.layout(graph, rootIds)\n\n return nodes.map((node) => ({\n id: node.id,\n name: node.name,\n type: node.type,\n childIds: node.childIds,\n ...(warnings.length > 0 && { warnings })\n }))\n}\n\n/** Render `tree` and return its first root; a fragment's other roots are rendered too. */\nexport async function renderTree<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n options: RenderOptions = {}\n): Promise<RenderResult> {\n const [first] = await renderRoots(services, graph, tree, options)\n return first\n}\n\ninterface PreparedProps {\n props: Record<string, unknown>\n bindings: Record<string, string>\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction preparePropsForRender(\n graph: SceneGraph,\n source: Record<string, unknown>,\n isText: boolean,\n layer: LayerContext\n): PreparedProps {\n const props = { ...source }\n const bindings: Record<string, string> = {}\n\n if (Array.isArray(props.fills)) {\n props.fills = props.fills.map((value: unknown, index) => {\n const fill = { value }\n bindVariableProp(graph, fill, bindings, 'value', `fills/${index}/color`, layer)\n return fill.value\n })\n }\n\n for (const { prop, fields } of paintProps({ text: isText })) {\n bindVariableProp(graph, props, bindings, prop, fields[0], layer)\n }\n\n if (isObjectRecord(props.style)) {\n const style = { ...props.style }\n for (const key of ['background', 'backgroundColor']) {\n bindVariableProp(graph, style, bindings, key, 'fills/0/color', layer)\n }\n if (isText) bindVariableProp(graph, style, bindings, 'color', 'fills/0/color', layer)\n bindVariableProp(graph, style, bindings, 'borderColor', 'strokes/0/color', layer)\n props.style = style\n }\n\n prepareScalarBindings(graph, props, bindings, isText, (variableId) =>\n resolveForLayer(graph, variableId, layer.parentId, layer.modes)\n )\n\n if (isObjectRecord(props.bind)) {\n for (const [field, value] of Object.entries(props.bind)) {\n if (isVariable(value)) {\n bindings[field] = requireVariableId(graph, value)\n } else if (typeof value === 'string') {\n bindings[field] = value\n }\n }\n }\n\n return { props, bindings }\n}\n\n/**\n * An element that draws its own layer. Its props are resolved as any layer's are, so a\n * `designVar()` binds, and its layer props become fields as any layer's do; the element reads the\n * rest itself.\n */\nfunction renderOwnLayerElement(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n element: OwnLayerRenderer\n): SceneNode {\n const modes = variableModes(graph, tree.props.mode)\n const { props, bindings } = preparePropsForRender(graph, tree.props, false, { parentId, modes })\n const parentLayout = graph.getNode(parentId)?.layoutMode ?? 'NONE'\n const layer = omitBy(\n {\n ...propsToOverrides(readElementProps(element.layer, props), false, parentLayout),\n ...(modes && { variableModes: modes })\n },\n (value) => value === undefined\n )\n const node = element.render(graph, { ...tree, props }, parentId, layer)\n for (const [field, variableId] of Object.entries(bindings)) {\n graph.bindVariable(element.bindingTarget?.(graph, node, field) ?? node.id, field, variableId)\n }\n return node\n}\n\nfunction applyBindings(graph: SceneGraph, nodeId: string, bindings: Record<string, string>): void {\n for (const [field, variableId] of Object.entries(bindings)) {\n graph.bindVariable(nodeId, field, variableId)\n }\n}\n\nfunction applyIconSize(\n props: Record<string, unknown>,\n overrides: Partial<SceneNode>,\n parentLayout: SceneNode['layoutMode'],\n size: number\n): void {\n const { w, h } = applySizeOverrides(props, overrides, parentLayout)\n if (typeof w !== 'number') overrides.width = size\n if (typeof h !== 'number') overrides.height = size\n}\n\nasync function renderIconNode<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string\n): Promise<SceneNode> {\n const props = tree.props\n const iconName = props.name as string | undefined\n if (!iconName) throw new Error('<Icon> requires a name prop (e.g. name=\"lucide:heart\")')\n\n const size = (props.size as number | undefined) ?? 24\n const artwork = await services.icon(iconName, size)\n if (!artwork) throw new Error(`Icon \"${iconName}\" not found`)\n return placeArtwork(services, graph, artwork, props, size, parentId)\n}\n\nfunction placeArtwork<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n artwork: Artwork,\n props: Record<string, unknown>,\n size: number,\n parentId: string\n): SceneNode {\n const parentLayout = graph.getNode(parentId)?.layoutMode ?? 'NONE'\n const overrides: Partial<SceneNode> = {}\n if (typeof props.label === 'string' && props.label) overrides.name = props.label\n applyIconSize(props, overrides, parentLayout, size)\n const modes = variableModes(graph, props.mode)\n if (modes) overrides.variableModes = modes\n const variableId = isVariable(props.color) ? requireVariableId(graph, props.color) : undefined\n const resolved = variableId && resolveForLayer(graph, variableId, parentId, modes)\n if (isVariable(props.color) && typeof resolved !== 'object')\n throw new Error(`Cannot resolve color variable ${props.color.name} for color`)\n const color =\n typeof resolved === 'object'\n ? resolved\n : parseColor(typeof props.color === 'string' ? props.color : '#000000')\n const node = services.createArtwork(graph, artwork, { parentId, size, color, overrides })\n if (variableId) bindSolidPaints(graph, node, variableId)\n return node\n}\n\n/** Bind every solid paint of an artwork's paths, so it follows the variable it was drawn in. */\nfunction bindSolidPaints(graph: SceneGraph, node: SceneNode, variableId: string): void {\n for (const field of ['fills', 'strokes'] as const) {\n node[field].forEach((paint, index) => {\n if (paint.type === 'SOLID') graph.bindVariable(node.id, `${field}/${index}/color`, variableId)\n })\n }\n for (const child of graph.getChildren(node.id)) bindSolidPaints(graph, child, variableId)\n}\n\n/**\n * Render an inline <svg> element into vector nodes through the same artwork path as\n * icons. The body may be string children or a `body` prop; parsed shape children work too.\n */\nfunction renderSVGNode<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string\n): SceneNode {\n const props = tree.props\n const explicitW = typeof props.w === 'number' ? props.w : 0\n const explicitH = typeof props.h === 'number' ? props.h : 0\n const size =\n explicitW > 0 || explicitH > 0\n ? Math.max(explicitW, explicitH)\n : ((props.size as number | undefined) ?? 24)\n const body =\n (typeof props.body === 'string' && props.body) ||\n tree.children.filter((c): c is string => typeof c === 'string').join('')\n const artwork = services.svg({ body, elements: tree.children.filter(isTreeNode), props }, size)\n if (!artwork) {\n throw new Error('<svg> requires SVG markup, a body prop, or supported SVG shape children')\n }\n return placeArtwork(services, graph, artwork, props, size, parentId)\n}\n\n/** Every component or set the reference names: one by ID, or each one sharing the name. */\nfunction componentsNamed(graph: SceneGraph, ref: string): SceneNode[] {\n const byId = graph.getNode(ref)\n if (byId?.type === 'COMPONENT' || byId?.type === 'COMPONENT_SET') return [byId]\n const components: SceneNode[] = []\n const sets: SceneNode[] = []\n for (const node of graph.getAllNodes()) {\n if (node.name !== ref) continue\n if (node.type === 'COMPONENT') components.push(node)\n else if (node.type === 'COMPONENT_SET') sets.push(node)\n }\n return [...components, ...sets]\n}\n\n/** Whether `props` selects a variant of `set`, naming one of its variant properties. */\nfunction selectsVariant(set: SceneNode, props: Record<string, unknown>): boolean {\n return Object.keys(props).some((key) =>\n set.componentPropertyDefinitions.some(\n (definition) => definition.type === 'VARIANT' && definition.name === key\n )\n )\n}\n\n/**\n * The component or component set an element names. A name several of them share uses the set when\n * the props select one of its variants, and the first otherwise; the warning from\n * `componentReferenceWarnings` says so and how to pick one by ID.\n */\nfunction namedComponent(\n graph: SceneGraph,\n props: Record<string, unknown>,\n refs?: LayerRefs\n): SceneNode | undefined {\n const ref = props.component ?? props.componentId ?? props.of\n if (isLayerRef(ref)) {\n const marked = graph.getNode(refs?.layerOf(ref) ?? '')\n return marked?.type === 'COMPONENT' || marked?.type === 'COMPONENT_SET' ? marked : undefined\n }\n if (typeof ref !== 'string') return undefined\n\n const matches = componentsNamed(graph, ref)\n if (matches.length <= 1) return matches[0]\n return (\n matches.find((node) => node.type === 'COMPONENT_SET' && selectsVariant(node, props)) ??\n matches[0]\n )\n}\n\n/** A name several components or sets share, naming each candidate by its ID. */\nexport function componentReferenceWarnings(\n graph: SceneGraph,\n props: Record<string, unknown>\n): string[] {\n const ref = props.component ?? props.componentId ?? props.of\n if (typeof ref !== 'string') return []\n const matches = componentsNamed(graph, ref)\n if (matches.length < 2) return []\n const chosen = namedComponent(graph, props)\n const choices = matches\n .map((node) => `${node.id} (${node.type === 'COMPONENT_SET' ? 'component set' : 'component'})`)\n .join(', ')\n const joined = chosen?.type === 'COMPONENT_SET' ? 'the component set' : 'the first'\n return [\n `<Instance> of \"${ref}\" names ${matches.length} components and joins ${joined}; name the one you mean by its ID: ${choices}.`\n ]\n}\n\nfunction findVariantInSet(\n graph: SceneGraph,\n componentSet: SceneNode,\n props: Record<string, unknown>\n) {\n const requested = Object.fromEntries(\n Object.entries(props)\n .filter(([key]) =>\n componentSet.componentPropertyDefinitions.some(\n (definition) => definition.type === 'VARIANT' && definition.name === key\n )\n )\n .map(([key, value]) => [key, String(value)])\n )\n const variants = graph.getChildren(componentSet.id).filter((node) => node.type === 'COMPONENT')\n return (\n variants.find((variant) =>\n Object.entries(requested).every(\n ([key, value]) => variant.componentPropertyValues[key] === value\n )\n ) ?? variants[0]\n )\n}\n\nfunction resolveComponent(\n graph: SceneGraph,\n props: Record<string, unknown>,\n refs?: LayerRefs\n): SceneNode | undefined {\n const named = namedComponent(graph, props, refs)\n return named?.type === 'COMPONENT_SET' ? findVariantInSet(graph, named, props) : named\n}\n\n/**\n * The names an element sets on its component by prop: properties such as `State` or `Title`, and\n * exposed instances.\n */\nexport function componentPropNames(graph: SceneGraph, props: Record<string, unknown>): string[] {\n const component = resolveComponent(graph, props)\n return component ? namesOnInstance(graph, component) : []\n}\n\nasync function renderInstanceNode(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n refs?: LayerRefs\n): Promise<SceneNode> {\n const parent = graph.getNode(parentId)\n const parentLayout = parent?.layoutMode ?? 'NONE'\n const modes = variableModes(graph, tree.props.mode)\n const bound = bindProperties(\n graph,\n tree.props,\n 'INSTANCE',\n parentId,\n componentIdNamed(graph, refs)\n )\n const { props, bindings } = preparePropsForRender(graph, bound.props, false, { parentId, modes })\n const component = resolveComponent(graph, props, refs)\n if (!component) {\n const ref = props.component ?? props.componentId ?? props.of\n if (isLayerRef(ref)) throw new Error('<Instance> ref() marks no component rendered before it')\n const label = typeof ref === 'string' || typeof ref === 'number' ? String(ref) : ''\n throw new Error(`<Instance> component not found: ${label}`)\n }\n const overrides: Partial<SceneNode> = {\n ...propsToOverrides(props, false, parentLayout),\n ...layerMetadata(modes, bound.references)\n }\n // Instances inherit their container layout, but explicitly authored dimensions\n // must also replace the inherited sizing mode on that axis.\n const layout = overrides.layoutMode ?? component.layoutMode\n if (layout !== 'NONE') {\n const axes =\n layout === 'HORIZONTAL'\n ? (['primaryAxisSizing', 'counterAxisSizing'] as const)\n : (['counterAxisSizing', 'primaryAxisSizing'] as const)\n for (const [dimension, field] of [\n ['w', axes[0]],\n ['h', axes[1]]\n ] as const) {\n const value = props[dimension]\n if (typeof value === 'number') overrides[field] = 'FIXED'\n else if (value === 'hug' || value === 'fill') overrides[field] = 'HUG'\n }\n }\n const instance =\n graph.createInstance(component.id, parentId, overrides) ?? graph.createNode('FRAME', parentId)\n try {\n for (const [field, value] of Object.entries(overrides)) {\n setInstanceOverride(instance.instanceOverrides, instance.id, instance.id, field, value)\n }\n graph.updateNode(instance.id, { instanceOverrides: instance.instanceOverrides })\n applyBindings(graph, instance.id, bindings)\n applyInstanceOverrides(graph, instance, tree.props.overrides)\n assignNamedProperties(graph, instance, props, componentIdNamed(graph, refs))\n assignComponentProperties(graph, instance, props.properties, componentIdNamed(graph, refs))\n if (props.exposed === true) exposeInstance(graph, instance)\n return instance\n } catch (error) {\n graph.deleteNode(instance.id)\n throw error\n }\n}\n\n/**\n * Apply child overrides to a freshly created instance. Keys are\n * `childName:prop` (e.g. 'label:text', 'icon:fills'); the child is resolved by\n * name among the instance's descendants, and the value is applied to both the\n * child node and the instance's overrides record so component sync keeps it.\n */\nfunction applyInstanceOverrides(\n graph: SceneGraph,\n instance: SceneNode,\n overridesProp: unknown\n): void {\n if (!overridesProp || typeof overridesProp !== 'object') return\n if (Array.isArray(overridesProp)) return\n const entries = Object.entries(overridesProp)\n if (entries.length === 0) return\n\n const descendants: SceneNode[] = []\n const walk = (id: string) => {\n const node = graph.getNode(id)\n if (!node) return\n descendants.push(node)\n for (const cid of node.childIds) walk(cid)\n }\n walk(instance.id)\n\n let mutated = false\n for (const [key, value] of entries) {\n const sep = key.indexOf(':')\n if (sep === -1) continue\n const childName = key.slice(0, sep)\n const prop = key.slice(sep + 1)\n const child = descendants.find((n) => n.name === childName)\n if (!child || !(prop in child)) continue\n graph.updateNode(child.id, { [prop]: value })\n setInstanceOverride(instance.instanceOverrides, instance.id, child.id, prop, value)\n mutated = true\n }\n if (mutated) {\n graph.updateNode(instance.id, { instanceOverrides: instance.instanceOverrides })\n }\n}\n\nasync function renderArtworkNode<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string\n): Promise<SceneNode> {\n const bound = bindProperties(graph, tree.props, 'VECTOR', parentId, componentIdNamed(graph))\n const artwork = { ...tree, props: bound.props }\n const node =\n tree.type === 'icon'\n ? await renderIconNode(services, graph, artwork, parentId)\n : renderSVGNode(services, graph, artwork, parentId)\n const metadata: Partial<SceneNode> = layerMetadata(undefined, bound.references)\n if (typeof bound.props.visible === 'boolean') metadata.visible = bound.props.visible\n if (Object.keys(metadata).length > 0) graph.updateNode(node.id, metadata)\n return node\n}\n\n/** The modes a layer pins and the component properties its fields are bound to. */\nfunction layerMetadata(\n modes: VariableModeMap | undefined,\n references: SceneNode['componentPropertyReferences']\n): Partial<SceneNode> {\n return {\n ...(modes && { variableModes: modes }),\n ...(references.length > 0 && { componentPropertyReferences: references })\n }\n}\n\n/** The component a swap property's default names, by ID or name, as `<Instance of>` finds it. */\nfunction componentIdNamed(graph: SceneGraph, refs?: LayerRefs) {\n return (name: string) => resolveComponent(graph, { of: name }, refs)?.id\n}\n\nexport interface ElementOverrides {\n overrides: Partial<SceneNode>\n /** Variable IDs by bound field, such as `fills/0/color`. */\n bindings: Record<string, string>\n}\n\n/** The fields and variable bindings an element's props set on a `nodeType` node under `parentId`. */\nexport function elementOverrides(\n graph: SceneGraph,\n nodeType: NodeType,\n tree: TreeNode,\n parentId: string\n): ElementOverrides {\n const parentLayout = graph.getNode(parentId)?.layoutMode ?? 'NONE'\n const isText = nodeType === 'TEXT'\n const modes = variableModes(graph, tree.props.mode)\n const bound = bindProperties(graph, tree.props, nodeType, parentId, componentIdNamed(graph))\n const layer = { parentId, modes }\n const { props, bindings } = preparePropsForRender(graph, bound.props, isText, layer)\n const overrides = {\n ...propsToOverrides(props, isText, parentLayout),\n ...shapeOverrides(nodeType, props),\n ...layerMetadata(modes, bound.references)\n }\n\n if (isText) {\n // A span's variables give their values; characters keep no bindings of their own.\n const spanOverrides = (spanProps: Record<string, unknown>) =>\n propsToOverrides(preparePropsForRender(graph, spanProps, true, layer).props, true, 'NONE')\n Object.assign(overrides, textContentFields(tree, props, overrides, spanOverrides))\n // As Figma does, a text layer follows its characters until a name is given, and keeps a given\n // name through later edits.\n if (overrides.name) overrides.autoRename = false\n else if (overrides.text !== undefined) overrides.name = textLayerName('TEXT', overrides.text)\n }\n return { overrides, bindings }\n}\n\nasync function renderNode<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n onNode?: RenderOptions['onNode'],\n scope?: RekaScope,\n refs?: LayerRefs\n): Promise<SceneNode> {\n const node = await renderNodeContent(services, graph, tree, parentId, onNode, scope, refs)\n onNode?.(tree, node)\n return node\n}\n\n/**\n * The elements rendered their own way rather than as the layer their definition names, or null\n * for any other element.\n */\nfunction renderOwnElement<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n refs?: LayerRefs\n): Promise<SceneNode> | null {\n switch (tree.type) {\n case 'icon':\n case 'svg':\n return renderArtworkNode(services, graph, tree, parentId)\n case 'instance':\n return renderInstanceNode(graph, tree, parentId, refs)\n default: {\n const element = elementOwnLayer(tree.type)\n return element ? Promise.resolve(renderOwnLayerElement(graph, tree, parentId, element)) : null\n }\n }\n}\n\nasync function renderNodeContent<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n onNode?: RenderOptions['onNode'],\n scope?: RekaScope,\n refs?: LayerRefs\n): Promise<SceneNode> {\n const own = renderOwnElement(services, graph, tree, parentId, refs)\n if (own) return own\n const reka = await renderRekaNode(graph, tree, parentId, scope, {\n render: (child, childParentId, childScope) =>\n renderNode(services, graph, child, childParentId, onNode, childScope, refs),\n create: (nodeType, element, elementParentId) => {\n const { overrides, bindings } = elementOverrides(graph, nodeType, element, elementParentId)\n const created = graph.createNode(nodeType, elementParentId, overrides)\n applyBindings(graph, created.id, bindings)\n placeVectorPaths(graph, created, element.props, (network) => services.vectorBounds(network))\n return created\n },\n instance: (element, elementParentId) =>\n renderInstanceNode(graph, element, elementParentId, refs),\n finishSet: (setId) => inferComponentSetProperties(graph, setId)\n })\n if (reka) return reka\n\n if (isTextContent(tree))\n throw new Error(`<${TEXT_CONTENT_NAMES[tree.type]}> must be inside <Text>`)\n const nodeType = elementNodeType(tree.type)\n if (!nodeType) throw new Error(`Unknown element: <${tree.type}>`)\n\n const { overrides, bindings } = elementOverrides(graph, nodeType, tree, parentId)\n const node = graph.createNode(nodeType, parentId, overrides)\n applyBindings(graph, node.id, bindings)\n placeVectorPaths(graph, node, tree.props, (network) => services.vectorBounds(network))\n\n for (const child of tree.children) {\n if (typeof child === 'string' || (node.type === 'TEXT' && isTextContent(child))) continue\n if (!isTreeNode(child)) continue\n // Text holds characters and style runs, not layers: a child layer would exist in the graph but\n // not in the text's export, so it is refused rather than silently lost.\n if (node.type === 'TEXT') throw new Error(`<${child.type}> cannot be inside <Text>`)\n await renderNode(services, graph, child, node.id, onNode, scope, refs)\n }\n\n if (node.type === 'COMPONENT_SET') inferComponentSetProperties(graph, node.id)\n\n return node\n}\n","import { parse } from 'acorn'\nimport { transform } from 'sucrase'\n\nconst options = {\n transforms: ['typescript', 'jsx'] as Array<'typescript' | 'jsx'>,\n jsxPragma: '__h',\n jsxFragmentPragma: '__fragment',\n production: true\n}\n\n/**\n * Transformed Design JSX: a function body that returns what the source renders. Its elements\n * carry `__source: { lineNumber }` props; adding `lineOffset` to `lineNumber` gives the 1-based\n * line in the source that was passed in.\n */\nexport interface DesignJSXProgram {\n code: string\n lineOffset: number\n}\n\nconst RULE = 'Design JSX is one JSX expression, or statements that end with `return` and the JSX'\n\nfunction lineCount(text: string): number {\n let lines = 0\n for (const char of text) if (char === '\\n') lines++\n return lines\n}\n\nfunction transformBody(body: string, withLines: boolean): string {\n return withLines\n ? transform(body, { ...options, production: false, filePath: 'design.jsx' }).code\n : transform(body, options).code\n}\n\n/** Whether a function body returns from its top level, as statements must end. */\nfunction returns(code: string): boolean {\n const program = parse(code, { ecmaVersion: 'latest', allowReturnOutsideFunction: true })\n return program.body.some((statement) => statement.type === 'ReturnStatement')\n}\n\n/**\n * The function body a Design JSX string stands for, tried in order: one JSX expression, sibling\n * elements, or statements that end with `return` and the JSX, as a component's body does. Each\n * keeps the source's lines where they are.\n */\nfunction transformProgram(source: string, withLines: boolean): DesignJSXProgram {\n const trimmed = source.trim()\n const lineOffset = lineCount(source.slice(0, source.length - source.trimStart().length))\n const expressions = [`return (${trimmed})`]\n if (trimmed.startsWith('<')) expressions.push(`return (<>${trimmed}</>)`)\n for (const body of expressions) {\n try {\n return { code: transformBody(body, withLines), lineOffset }\n } catch {\n continue\n }\n }\n let code: string\n try {\n code = transformBody(trimmed, withLines)\n } catch (error) {\n throw new Error(`${RULE}: ${error instanceof Error ? error.message : String(error)}`, {\n cause: error\n })\n }\n if (!returns(code)) throw new Error(`${RULE}; these statements return nothing.`)\n return { code, lineOffset }\n}\n\n/** Transform Design JSX into the body of a function that returns what it renders. */\nexport function transformDesignJSXExpression(source: string): string {\n return transformProgram(source, false).code\n}\n\n/** Like {@link transformDesignJSXExpression}, keeping the source line of every element. */\nexport function transformDesignJSXProgram(source: string): DesignJSXProgram {\n return transformProgram(source, true)\n}\n","import { pickBy } from 'es-toolkit'\nimport { uniq } from 'es-toolkit/array'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\nimport { tryParseColor } from '@pairdraw/scene-graph/color'\n\nimport { REKA_ELEMENTS } from './behaviours'\nimport { elementBindings, elementProps, elementSchema } from './elements'\nimport { ENUM_PROPS } from './enums'\nimport { DESIGN_JSX_HELPERS, designJSXHelpers } from './helpers'\nimport * as React from './mini-react'\nimport { normalizeStyleProps } from './props-overrides'\nimport {\n renderRoots,\n renderTree,\n componentPropNames,\n componentReferenceWarnings,\n type RenderResult\n} from './renderer'\nimport { elementPropWarnings, layerPropsSchema, svgLayerPropsSchema } from './schema'\nimport type { DesignJSXServices } from './services'\nimport { TEXT_CONTENT_NAMES } from './text-content'\nimport { transformDesignJSXExpression } from './transform'\nimport { isTreeNode, resolveToTree, type TreeNode } from './tree'\nimport type { RenderOptions as RenderJSXOptions } from './types'\nimport { isVariable } from './variables'\n\nconst SIZE_PROPS = new Set(['w', 'h'])\nconst PAINT_PROPS = new Set(['bg', 'fill', 'stroke'])\n\n/** How a warning names a value it could not read. */\nfunction propValueText(value: unknown): string {\n return typeof value === 'string' ? `\"${value}\"` : String(value)\n}\n\nfunction unreadableSize(value: unknown): boolean {\n return !isVariable(value) && typeof value !== 'number' && value !== 'hug' && value !== 'fill'\n}\n\nfunction unreadablePaint(value: unknown): boolean {\n return typeof value === 'string' && tryParseColor(value) === null\n}\n\n/** `const Switch = { Root: 'Switch.Root', … }`: each Reka namespace as element types. */\nconst REKA_ALIASES = Object.entries(REKA_ELEMENTS)\n .map(\n ([namespace, parts]) =>\n `const ${namespace} = ${JSON.stringify(\n Object.fromEntries(Object.keys(parts).map((part) => [part, `${namespace}.${part}`]))\n )}`\n )\n .join('\\n')\n\n/** `const solid = __helpers.solid`, …: every helper in the scope of the code. */\nconst HELPER_BINDINGS = DESIGN_JSX_HELPERS.map(\n ({ name }) => `const ${name} = __helpers.${name}`\n).join('\\n')\n\n/** Where the scanner is: code (top level or `{…}`), JSX text, or an opening or closing tag. */\ntype ScanFrame = 'code' | 'text' | 'open' | 'close'\n\n/** End (exclusive) of the string that opens at `start`; JSX attribute strings have no escapes. */\nfunction stringEnd(source: string, start: number, escapes: boolean): number {\n const quote = source[start]\n let i = start + 1\n while (i < source.length && source[i] !== quote) i += escapes && source[i] === '\\\\' ? 2 : 1\n return Math.min(i + 1, source.length)\n}\n\n/** End of the string or JS comment at `i`, copied as written, or -1 when none starts there. */\nfunction verbatimEnd(source: string, i: number, frame: ScanFrame): number {\n const char = source.charAt(i)\n if (frame === 'open' || frame === 'close') {\n return /[\"']/.test(char) ? stringEnd(source, i, false) : -1\n }\n if (frame !== 'code') return -1\n if (/[\"'`]/.test(char)) return stringEnd(source, i, true)\n if (source.startsWith('//', i)) {\n const end = source.indexOf('\\n', i)\n return end === -1 ? source.length : end\n }\n if (source.startsWith('/*', i)) {\n const end = source.indexOf('*/', i + 2)\n return end === -1 ? source.length : end + 2\n }\n return -1\n}\n\n/** Whether the `<` just copied to `before` opens a tag rather than comparing, as in `a<b`. */\nfunction startsTag(source: string, next: number, frame: ScanFrame, before: string): boolean {\n const following = source.charAt(next)\n if (frame === 'text') return /[A-Za-z_$/>]/.test(following)\n if (!/[A-Za-z_$>]/.test(following)) return false\n const previous = before.slice(0, -1).trimEnd()\n return !/[\\w$)\\].]$/.test(previous) || /(?:^|[^\\w$])return$/.test(previous)\n}\n\n/** Enter or leave a frame after copying the character just before `next`. */\nfunction updateFrames(stack: ScanFrame[], source: string, next: number, out: string): void {\n const char = source.charAt(next - 1)\n const frame = stack.at(-1) ?? 'code'\n const inTag = frame === 'open' || frame === 'close'\n if (char === '{') stack.push('code')\n else if (char === '}' && frame === 'code' && stack.length > 1) stack.pop()\n else if (char === '<' && !inTag && startsTag(source, next, frame, out)) {\n stack.push(source.charAt(next) === '/' ? 'close' : 'open')\n } else if (char === '>' && frame === 'open') {\n if (source.charAt(next - 2) === '/') stack.pop()\n else stack[stack.length - 1] = 'text'\n } else if (char === '>' && frame === 'close') {\n stack.pop()\n if (stack.at(-1) === 'text') stack.pop()\n }\n}\n\n/**\n * Remove `<!-- … -->` written in JSX text or between statements. Markup inside an attribute\n * string or a JS string literal is part of the value and stays.\n */\nfunction stripHTMLComments(jsxString: string): string {\n const stack: ScanFrame[] = ['code']\n let out = ''\n let i = 0\n while (i < jsxString.length) {\n const frame = stack.at(-1) ?? 'code'\n if (frame !== 'open' && frame !== 'close' && jsxString.startsWith('<!--', i)) {\n const end = jsxString.indexOf('-->', i + 4)\n i = end === -1 ? jsxString.length : end + 3\n continue\n }\n const end = verbatimEnd(jsxString, i, frame)\n if (end !== -1) {\n out += jsxString.slice(i, end)\n i = end\n continue\n }\n out += jsxString.charAt(i)\n i++\n updateFrames(stack, jsxString, i, out)\n }\n return out\n}\n\n/** Why `value` cannot go into the layer field `key` names, or nothing when it can. */\nfunction valueKindWarning(\n key: string,\n value: unknown,\n element: string,\n type: TreeNode['type']\n): string | undefined {\n // An `<svg>`'s attributes are passed to its markup as written, so a value of the wrong kind is\n // the markup's to read: `fill=\"none\"` and `strokeWidth=\"2\"` are not layer fields.\n if (type === 'svg') return undefined\n if (SIZE_PROPS.has(key) && unreadableSize(value))\n return `Invalid ${key} ${propValueText(value)} on <${element}> is ignored; expected a number, \"hug\", or \"fill\".`\n if (PAINT_PROPS.has(key) && unreadablePaint(value))\n return `Invalid ${key} ${propValueText(value)} on <${element}> is ignored; expected a colour or a paint.`\n return undefined\n}\n\nfunction unsupportedPropWarnings(graph: SceneGraph, tree: TreeNode): string[] {\n const warnings: string[] = []\n collectUnsupportedPropWarnings(graph, tree, warnings)\n return warnings\n}\n\nfunction collectUnsupportedPropWarnings(\n graph: SceneGraph,\n tree: TreeNode,\n warnings: string[]\n): void {\n const supported = elementProps(tree.type)\n // An instance sets its component's properties by name, such as `State=\"On\"` or `Title=\"Hi\"`.\n if (tree.type === 'instance') warnings.push(...componentReferenceWarnings(graph, tree.props))\n const properties = componentPropNames(graph, tree.props)\n const element = TEXT_CONTENT_NAMES[tree.type] ?? tree.type\n const schema = elementSchema(tree.type)\n if (schema) warnings.push(...elementPropWarnings(schema, tree.props, element))\n // The layer props an element takes are read by one schema, which its own schema may restate,\n // with the values its `style` gives where the props leave them unset, as rendering reads them.\n const layerSchema = tree.type === 'svg' ? svgLayerPropsSchema : layerPropsSchema\n const layerProps = pickBy(\n normalizeStyleProps(tree.props),\n (_, key) => supported.has(key) && !(schema && Object.hasOwn(schema.entries, key))\n )\n warnings.push(...elementPropWarnings(layerSchema, layerProps, element))\n for (const [key, value] of Object.entries(tree.props)) {\n if (!supported.has(key) && !properties.includes(key)) {\n warnings.push(`Unsupported prop \"${key}\" on <${element}> is ignored.`)\n continue\n }\n // The element's schema already reported a prop it validates, in its own words; warning\n // again here would name the same value twice, as a connector's stroke once was.\n if (schema && key in schema.entries) continue\n const kindWarning = valueKindWarning(key, value, element, tree.type)\n if (kindWarning) {\n warnings.push(kindWarning)\n continue\n }\n const values = ENUM_PROPS[key]\n if (values && typeof value === 'string' && values.parse(value) === undefined) {\n warnings.push(\n `Unknown ${key} \"${value}\" on <${element}> is ignored; expected ${values.names.join(', ')}.`\n )\n }\n }\n\n // SVG descendants are parsed as markup by renderSvgNode, not as Design JSX nodes.\n if (tree.type === 'svg') return\n\n for (const child of tree.children) {\n if (isTreeNode(child)) collectUnsupportedPropWarnings(graph, child, warnings)\n }\n}\n\n/**\n * Build a component function from a JSX string: one JSX expression, sibling elements, or\n * statements that end with `return` and the JSX. The statements run inside the component, so\n * they may shadow an element or helper name. Works in both Node/Bun and the browser.\n */\nexport function buildComponent(jsxString: string, warnings: string[] = []): React.ComponentType {\n const trimmed = stripHTMLComments(jsxString).trim()\n\n const aliases = `\n const __h = React.createElement\n const __fragment = ''\n ${elementBindings()}\n const svg = 'svg'\n ${REKA_ALIASES}\n ${HELPER_BINDINGS}\n `\n\n const body = transformDesignJSXExpression(trimmed)\n // eslint-disable-next-line typescript-eslint/no-implied-eval -- sucrase output must be evaluated at runtime\n return new Function('React', '__helpers', `${aliases}\\nreturn function __render() {\\n${body}\\n}`)(\n React,\n designJSXHelpers(warnings)\n ) as React.ComponentType\n}\n\n/**\n * Render a JSX string into the scene graph.\n * Works in both Node/Bun and the browser.\n */\nasync function renderJSX<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n jsxString: string,\n options?: RenderJSXOptions\n): Promise<RenderResult[]> {\n const helperWarnings: string[] = []\n const Component = buildComponent(jsxString, helperWarnings)\n const element = React.createElement(Component, null)\n const tree = resolveToTree(element)\n\n if (!tree) {\n throw new Error('JSX must return a Figma element (Frame, Text, etc)')\n }\n\n const results = await renderRoots(services, graph, tree, options)\n // After rendering, so an instance's component set drawn in the same JSX names its variants.\n // A helper called in a loop reports each ignored option once.\n // Prop warnings come first, then the render's own, such as a connector end naming no layer.\n const warnings = uniq([\n ...unsupportedPropWarnings(graph, tree),\n ...helperWarnings,\n ...(results[0].warnings ?? [])\n ])\n if (warnings.length > 0) results[0].warnings = warnings\n return results\n}\n\n/**\n * A Design JSX renderer bound to an engine. Rendering needs `services` for icons, inline\n * SVG, and layout; Pairdraw's engine provides them through `@pairdraw/core/design-jsx`.\n */\nexport function createDesignJSXRenderer<Artwork>(services: DesignJSXServices<Artwork>) {\n return {\n /** Render a Design JSX string into the graph, one result per top-level element. */\n renderJSX: (graph: SceneGraph, jsxString: string, options?: RenderJSXOptions) =>\n renderJSX(services, graph, jsxString, options),\n /** Render a tree built with the element functions into the graph. */\n renderTree: (graph: SceneGraph, tree: TreeNode, options?: RenderJSXOptions) =>\n renderTree(services, graph, tree, options),\n /** Render every top-level element of a tree at once, one result per root. */\n renderRoots: (graph: SceneGraph, tree: TreeNode, options?: RenderJSXOptions) =>\n renderRoots(services, graph, tree, options)\n }\n}\n\nexport type DesignJSXRenderer = ReturnType<typeof createDesignJSXRenderer>\n","import { omit } from 'es-toolkit'\n\nimport type { NodeType, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { createDefaultNode } from '@pairdraw/scene-graph/node-defaults'\n\nimport type { JSXAttributeSource } from './export'\nimport * as React from './mini-react'\nimport { buildComponent } from './render'\nimport { elementOverrides } from './renderer'\nimport { resolveToTree } from './tree'\n\nexport interface JSXNodeFields {\n /** Every field the attributes describe, with defaults for the ones they leave out. */\n fields: Partial<SceneNode>\n /** Variable IDs by bound field, such as `fills/0/color`. */\n bindings: Record<string, string>\n}\n\n/**\n * The node state a `nodeType` node under `parentId` gets from `attributes`, as rendering\n * would set it, without creating a node. Diffing two results gives the fields an attribute\n * change moves, so an update leaves state that JSX does not describe untouched.\n */\nexport function jsxNodeFields(\n graph: SceneGraph,\n nodeType: NodeType,\n attributes: JSXAttributeSource[],\n parentId: string\n): JSXNodeFields {\n const source = `<Frame ${attributes.map((attribute) => attribute.source).join(' ')} />`\n const tree = resolveToTree(React.createElement(buildComponent(source), null))\n if (!tree) throw new Error(`Invalid JSX attributes: ${source}`)\n const { overrides, bindings } = elementOverrides(graph, nodeType, tree, parentId)\n const defaults = omit(\n createDefaultNode(() => '', nodeType),\n ['id', 'parentId', 'childIds']\n )\n return { fields: { ...defaults, ...overrides }, bindings }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,SAAgB,cACd,MACA,OACA,GAAG,UACW;CACd,MAAM,eAAe,SAAS,KAAK;CACnC,OAAO;EACL;EACA,OAAO;GACL,GAAG;GACH,UAAU,aAAa,SAAS,IAAI,eAAe,KAAA;EACrD;CACF;AACF;;;ACTA,MAAM,eAAe,EAAE,OAAO;CAC5B,GAAG,EAAE,SAAS,kBAAkB;CAChC,GAAG,EAAE,SAAS,kBAAkB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;;;;;;;;ACzQA,SAAgB,cACd,OACA,UACA,YACA,UACe;CACf,MAAM,SAAS,UAAU,WAAW,KAAK,cAAc,UAAU,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE;CACnF,MAAM,OAAO,cAAcC,cAAoB,eAAe,MAAM,GAAG,IAAI,CAAC;CAC5E,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,2BAA2B,QAAQ;CAC9D,MAAM,EAAE,WAAW,aAAa,iBAAiB,OAAO,UAAU,MAAM,QAAQ;CAKhF,OAAO;EAAE,QAAQ;GAAE,GAJF,KACf,wBAAwB,IAAI,QAAQ,GACpC;IAAC;IAAM;IAAY;GAAU,CAEF;GAAG,GAAG;EAAU;EAAG;CAAS;AAC3D"}
1
+ {"version":3,"file":"fields.js","names":["compact","uniq","namesOnInstance","React","React.createElement","React.createElement"],"sources":["../../src/mini-react.ts","../../src/overrides/effects.ts","../../src/overrides/state.ts","../../src/props-overrides.ts","../../src/order.ts","../../src/overrides/vector.ts","../../src/scalar-bindings.ts","../../src/renderer.ts","../../src/transform.ts","../../src/render.ts","../../src/fields.ts"],"sourcesContent":["export type ComponentType = (props: Record<string, unknown>) => ReactNode\n\nexport type ReactElement = {\n type: string | ComponentType\n props: Record<string, unknown> & { children?: ReactNode[] }\n}\n\nexport type ReactNode = ReactElement | string | number | null | undefined | ReactNode[]\n\nexport function createElement(\n type: string | ComponentType,\n props: Record<string, unknown> | null,\n ...children: ReactNode[]\n): ReactElement {\n const flatChildren = children.flat()\n return {\n type,\n props: {\n ...props,\n children: flatChildren.length > 0 ? flatChildren : undefined\n }\n }\n}\n","import * as v from 'valibot'\n\nimport type { DocumentColorSpace, SceneNode } from '@pairdraw/scene-graph'\nimport { colorSchema } from '@pairdraw/scene-graph/color'\nimport { TRANSPARENT } from '@pairdraw/scene-graph/constants'\nimport { parseCSSShadows } from '@pairdraw/scene-graph/css'\nimport { normalizeEffects } from '@pairdraw/scene-graph/effects'\nimport { finiteNumberSchema, type Vector } from '@pairdraw/scene-graph/primitives'\nimport { shaderUniformValueSchema } from '@pairdraw/scene-graph/shaders'\n\nimport { BLEND_MODE, enumProp } from '../enums'\nimport { parseScriptInput } from '../schema'\n\nconst offsetSchema = v.object({\n x: v.optional(finiteNumberSchema),\n y: v.optional(finiteNumberSchema)\n})\n\nconst effectFields = {\n radius: finiteNumberSchema,\n offset: v.optional(offsetSchema),\n spread: v.optional(finiteNumberSchema, 0),\n visible: v.optional(v.boolean(), true),\n blendMode: v.optional(enumProp(BLEND_MODE)),\n showShadowBehindNode: v.optional(v.boolean())\n}\n\nconst SHADOW_TYPES = ['DROP_SHADOW', 'INNER_SHADOW'] as const\nconst BLUR_TYPES = ['LAYER_BLUR', 'BACKGROUND_BLUR', 'FOREGROUND_BLUR'] as const\n\nfunction shadowEffectSchema(type: (typeof SHADOW_TYPES)[number]) {\n return v.object({\n type: v.literal(type),\n color: colorSchema,\n ...effectFields\n })\n}\n\nfunction blurEffectSchema(type: (typeof BLUR_TYPES)[number]) {\n return v.object({\n type: v.literal(type),\n color: v.optional(colorSchema),\n ...effectFields\n })\n}\n\nconst shaderEffectSchema = v.object({\n type: v.literal('SHADER'),\n source: v.pipe(v.string(), v.minLength(1)),\n uniforms: v.optional(v.record(v.string(), shaderUniformValueSchema)),\n uniformBindings: v.optional(v.record(v.string(), v.string())),\n visible: v.optional(v.boolean(), true),\n blendMode: v.optional(enumProp(BLEND_MODE))\n})\n\nconst effectSchema = v.variant('type', [\n shadowEffectSchema('DROP_SHADOW'),\n shadowEffectSchema('INNER_SHADOW'),\n blurEffectSchema('LAYER_BLUR'),\n blurEffectSchema('BACKGROUND_BLUR'),\n blurEffectSchema('FOREGROUND_BLUR'),\n shaderEffectSchema\n])\n\nconst effectsSchema = v.array(effectSchema)\n\ntype ParsedEffect = v.InferOutput<typeof effectSchema>\ntype NormalizableEffect = Parameters<typeof normalizeEffects>[0][number]\ntype StoredShadow = Exclude<NormalizableEffect, { type: 'SHADER' }>\n\n/** Drop an omitted offset so `normalizeEffects` can apply the shadow or blur default. */\nfunction forNormalize(effect: ParsedEffect): NormalizableEffect {\n if (effect.type === 'SHADER') {\n const shader: Extract<NormalizableEffect, { type: 'SHADER' }> = {\n type: 'SHADER',\n source: effect.source,\n visible: effect.visible\n }\n if (effect.uniforms !== undefined) shader.uniforms = effect.uniforms\n if (effect.uniformBindings !== undefined) shader.uniformBindings = effect.uniformBindings\n if (effect.blendMode !== undefined) shader.blendMode = effect.blendMode\n return shader\n }\n const shadow: StoredShadow = {\n type: effect.type,\n color: effect.color ?? { ...TRANSPARENT },\n radius: effect.radius,\n spread: effect.spread,\n visible: effect.visible\n }\n if (effect.offset !== undefined) {\n const offset: Partial<Vector> = {}\n if (effect.offset.x !== undefined) offset.x = effect.offset.x\n if (effect.offset.y !== undefined) offset.y = effect.offset.y\n shadow.offset = offset\n }\n if (effect.blendMode !== undefined) shadow.blendMode = effect.blendMode\n if (effect.showShadowBehindNode !== undefined) {\n shadow.showShadowBehindNode = effect.showShadowBehindNode\n }\n return shadow\n}\n\n/** `effects` takes structured effects; `shadow` appends its shadows and `blur` a layer blur. */\nexport function applyEffectOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n profile: DocumentColorSpace = 'srgb'\n): void {\n if (Array.isArray(props.effects) && props.effects.length > 0) {\n const effects = parseScriptInput('effects', effectsSchema, props.effects).map(forNormalize)\n o.effects = normalizeEffects(effects)\n }\n\n // A CSS shadow list, as `box-shadow` takes it.\n const shadows = typeof props.shadow === 'string' ? parseCSSShadows(props.shadow, profile) : []\n if (shadows.length > 0) o.effects = [...(o.effects ?? []), ...shadows]\n\n if (typeof props.blur === 'number') {\n o.effects = [\n ...(o.effects ?? []),\n {\n type: 'LAYER_BLUR',\n radius: props.blur,\n visible: true,\n color: { ...TRANSPARENT },\n offset: { x: 0, y: 0 },\n spread: 0\n }\n ]\n }\n}\n","import { CONSTRAINT, MASK_TYPE } from '#design-jsx/enums'\n\nimport type { ConstraintType, SceneNode } from '@pairdraw/scene-graph'\n\nfunction constraintValue(value: unknown): ConstraintType | undefined {\n return CONSTRAINT.parse(value)\n}\n\n/** The `constraints` prop, shaped like Figma's `constraints` object. */\ninterface ConstraintsValue {\n horizontal?: unknown\n vertical?: unknown\n}\n\nfunction isConstraintsValue(value: unknown): value is ConstraintsValue {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nfunction applyConstraints(value: unknown, o: Partial<SceneNode>): void {\n if (!isConstraintsValue(value)) return\n const h = constraintValue(value.horizontal)\n const v = constraintValue(value.vertical)\n if (h) o.horizontalConstraint = h\n if (v) o.verticalConstraint = v\n}\n\nfunction sizeLimit(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined\n}\n\n/**\n * Visibility, locking, mask, constraint, and size-limit props. Constraints follow Figma's\n * `constraints` object with its values in lowercase, as `blendMode` is.\n */\nexport function applyStateOverrides(props: Record<string, unknown>, o: Partial<SceneNode>): void {\n if (typeof props.visible === 'boolean') o.visible = props.visible\n if (typeof props.locked === 'boolean') o.locked = props.locked\n applyConstraints(props.constraints, o)\n\n const minWidth = sizeLimit(props.minW)\n const maxWidth = sizeLimit(props.maxW)\n const minHeight = sizeLimit(props.minH)\n const maxHeight = sizeLimit(props.maxH)\n if (minWidth !== undefined) o.minWidth = minWidth\n if (maxWidth !== undefined) o.maxWidth = maxWidth\n if (minHeight !== undefined) o.minHeight = minHeight\n if (maxHeight !== undefined) o.maxHeight = maxHeight\n\n // `mask` alone masks by alpha; an unknown mask type leaves the layer as it was.\n const maskType = props.mask === true ? 'ALPHA' : MASK_TYPE.parse(props.mask)\n if (maskType) {\n o.isMask = true\n o.maskType = maskType\n }\n}\n","import type { DocumentColorSpace, Fill, SceneNode, ArcData, NodeType } from '@pairdraw/scene-graph'\nimport { colorToFill, tryParseColor } from '@pairdraw/scene-graph/color'\nimport { parseCSSGridTracks, parseCSSNumber } from '@pairdraw/scene-graph/css'\nimport {\n autoLayoutSizingFields,\n fillSizingFields,\n parseAutoLayoutDirection,\n parseCounterAxisAlign,\n parsePrimaryAxisAlign\n} from '@pairdraw/scene-graph/layout'\nimport type { Color, JSONObject } from '@pairdraw/scene-graph/primitives'\nimport { withShaderPaints, type ShaderPaint } from '@pairdraw/scene-graph/shaders'\n\nimport { DESIGN_JSX_STYLE_KEYS, designJSXProp } from './definitions'\nimport {\n BLEND_MODE,\n TEXT_ALIGN,\n TEXT_ALIGN_VERTICAL,\n TEXT_AUTO_RESIZE,\n TEXT_CASE,\n TEXT_DECORATION,\n TEXT_DIRECTION\n} from './enums'\nimport { applyEffectOverrides } from './overrides/effects'\nimport { fillFromValue, isColor, isFillValue } from './overrides/fills'\nimport { applyStateOverrides } from './overrides/state'\nimport { applyStrokeOverrides } from './overrides/strokes'\nimport { applyTextDetailOverrides, AUTO, textLengthProp } from './overrides/text'\nimport { isShaderFill } from './paints'\nimport { readLayerProps, type LayerProps } from './schema'\n\nconst WEIGHT_MAP: Record<string, number> = {\n normal: 400,\n medium: 500,\n bold: 700\n}\n\nfunction parseDirection(value: unknown): SceneNode['textDirection'] | undefined {\n if (typeof value !== 'string') return undefined\n return TEXT_DIRECTION.parse(value) ?? 'AUTO'\n}\n\nfunction numberFromPx(value: unknown): number | undefined {\n if (typeof value === 'number') return value\n return typeof value === 'string' ? (parseCSSNumber(value) ?? undefined) : undefined\n}\n\n/** `props` with the sizes and styles its `style` object gives, where the props leave them unset. */\nexport function normalizeStyleProps(props: Record<string, unknown>): Record<string, unknown> {\n const style = props.style\n if (style === null || typeof style !== 'object' || Array.isArray(style)) return props\n\n const source = style as JSONObject\n const normalized = { ...props }\n for (const [name, keys] of Object.entries(DESIGN_JSX_STYLE_KEYS)) {\n if (designJSXProp(normalized, name) !== undefined) continue\n const found = keys.find(({ key }) => source[key] !== undefined)\n if (found) normalized[name] = found.px ? numberFromPx(source[found.key]) : source[found.key]\n }\n return normalized\n}\n\nexport function applySizeOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n parentLayout: SceneNode['layoutMode']\n): { w: unknown; h: unknown } {\n const w = designJSXProp(props, 'w')\n const h = designJSXProp(props, 'h')\n if (typeof w === 'number') o.width = w\n if (typeof h === 'number') o.height = h\n\n if (w === 'fill') Object.assign(o, fillSizingFields(parentLayout, 'HORIZONTAL'))\n if (h === 'fill') Object.assign(o, fillSizingFields(parentLayout, 'VERTICAL'))\n\n if (props.x !== undefined) o.x = props.x as number\n if (props.y !== undefined) o.y = props.y as number\n if (props.top !== undefined) o.y = props.top as number\n if (props.left !== undefined) o.x = props.left as number\n\n if (props.position === 'absolute') o.layoutPositioning = 'ABSOLUTE'\n const hasExplicitPosition =\n props.x !== undefined ||\n props.y !== undefined ||\n props.top !== undefined ||\n props.left !== undefined\n if (hasExplicitPosition && parentLayout !== 'NONE') {\n o.layoutPositioning = 'ABSOLUTE'\n }\n\n return { w, h }\n}\n\n/**\n * Sets the layer's fills, moving each shader paint's preset into the layer's plugin data,\n * where a shader paint keeps it.\n */\nfunction setFills(\n values: (string | Color | Fill)[],\n o: Partial<SceneNode>,\n profile: DocumentColorSpace\n): void {\n const shaders: ShaderPaint[] = []\n // A colour string no parser reads would otherwise become black, opposite to leaving it out.\n const usable = values.filter(\n (value) => typeof value !== 'string' || tryParseColor(value, profile) !== null\n )\n const fills = usable.map((value) => {\n const fill = fillFromValue(value, profile)\n if (!isShaderFill(fill)) return fill\n const { shader, ...paint } = fill\n if (paint.imageHash) shaders.push(shader)\n return paint\n })\n if (fills.length === 0) return\n o.fills = fills\n if (shaders.length > 0)\n o.pluginData = withShaderPaints({ pluginData: o.pluginData ?? [] }, fills, shaders)\n}\n\nfunction applyFillOverride(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n profile: DocumentColorSpace\n): void {\n // `fills={[]}` paints nothing, which a text, painted black by default, has to say.\n if (Array.isArray(props.fills) && props.fills.length === 0) {\n o.fills = []\n return\n }\n if (Array.isArray(props.fills)) {\n setFills(props.fills.filter(isFillValue), o, profile)\n return\n }\n\n const bg = designJSXProp(props, 'bg')\n if (isFillValue(bg)) setFills([bg], o, profile)\n}\n\nfunction applyCornerOverrides(props: LayerProps, o: Partial<SceneNode>): void {\n const rounded = props.rounded ?? props.cornerRadius ?? props.borderRadius\n if (rounded !== undefined) o.cornerRadius = rounded\n\n if (\n props.roundedTL !== undefined ||\n props.roundedTR !== undefined ||\n props.roundedBL !== undefined ||\n props.roundedBR !== undefined\n ) {\n o.independentCorners = true\n if (props.roundedTL !== undefined) o.topLeftRadius = props.roundedTL\n if (props.roundedTR !== undefined) o.topRightRadius = props.roundedTR\n if (props.roundedBL !== undefined) o.bottomLeftRadius = props.roundedBL\n if (props.roundedBR !== undefined) o.bottomRightRadius = props.roundedBR\n }\n\n if (props.cornerSmoothing !== undefined) o.cornerSmoothing = props.cornerSmoothing\n}\n\nfunction applyVisualOverrides(\n props: LayerProps,\n o: Partial<SceneNode>,\n profile: DocumentColorSpace\n): void {\n applyFillOverride(props, o, profile)\n applyStrokeOverrides(props, o, profile)\n applyCornerOverrides(props, o)\n\n if (props.opacity !== undefined) o.opacity = props.opacity\n applyTransformOverrides(props, o)\n const blendMode = BLEND_MODE.parse(props.blendMode)\n if (blendMode) o.blendMode = blendMode\n if (props.overflow === 'hidden') o.clipsContent = true\n}\n\nfunction applyTransformOverrides(props: LayerProps, o: Partial<SceneNode>): void {\n const rotation = props.rotate ?? props.rotation\n if (rotation !== undefined) o.rotation = rotation\n if (props.flipX !== undefined) o.flipX = props.flipX === true\n if (props.flipY !== undefined) o.flipY = props.flipY === true\n}\n\nfunction applyPaddingOverrides(props: Record<string, unknown>, o: Partial<SceneNode>): void {\n const p = designJSXProp(props, 'p')\n if (typeof p === 'number') {\n o.paddingTop = p\n o.paddingRight = p\n o.paddingBottom = p\n o.paddingLeft = p\n }\n const px = props.px as number | undefined\n const py = props.py as number | undefined\n if (px !== undefined) {\n o.paddingLeft = px\n o.paddingRight = px\n }\n if (py !== undefined) {\n o.paddingTop = py\n o.paddingBottom = py\n }\n if (props.pt !== undefined) o.paddingTop = props.pt as number\n if (props.pr !== undefined) o.paddingRight = props.pr as number\n if (props.pb !== undefined) o.paddingBottom = props.pb as number\n if (props.pl !== undefined) o.paddingLeft = props.pl as number\n}\n\nconst PADDING_KEYS = ['p', 'padding', 'px', 'py', 'pt', 'pr', 'pb', 'pl'] as const\nconst AUTO_LAYOUT_TRIGGER_KEYS = [\n ...PADDING_KEYS,\n 'justify',\n 'justifyContent',\n 'items',\n 'align',\n 'alignItems'\n] as const\n\nfunction hasAutoLayoutTriggerProps(props: Record<string, unknown>): boolean {\n return AUTO_LAYOUT_TRIGGER_KEYS.some((k) => props[k] !== undefined)\n}\n\nfunction applyGridOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n w: unknown,\n h: unknown\n): void {\n o.layoutMode = 'GRID'\n\n if (typeof w === 'number') o.width = w\n if (typeof h === 'number') o.height = h\n\n if (typeof props.columns === 'string') {\n o.gridTemplateColumns = parseCSSGridTracks(props.columns)\n } else if (typeof props.columns === 'number') {\n o.gridTemplateColumns = Array.from({ length: props.columns }, () => ({\n sizing: 'FR' as const,\n value: 1\n }))\n }\n\n if (typeof props.rows === 'string') {\n o.gridTemplateRows = parseCSSGridTracks(props.rows)\n } else if (typeof props.rows === 'number') {\n o.gridTemplateRows = Array.from({ length: props.rows }, () => ({\n sizing: 'FR' as const,\n value: 1\n }))\n }\n\n if (typeof props.columnGap === 'number') o.gridColumnGap = props.columnGap\n if (typeof props.rowGap === 'number') o.gridRowGap = props.rowGap\n if (typeof props.gap === 'number') {\n o.gridColumnGap = props.gap\n o.gridRowGap = props.gap\n }\n\n if (props.rows === undefined && typeof h !== 'number') {\n o.height = 0\n }\n}\n\nfunction applyGridChildOverrides(props: Record<string, unknown>, o: Partial<SceneNode>): void {\n const col = designJSXProp(props, 'colStart')\n const row = designJSXProp(props, 'rowStart')\n const colSpan = designJSXProp(props, 'colSpan')\n const rowSpan = designJSXProp(props, 'rowSpan')\n\n // A span without a start is CSS `grid-column: span N`, which holds while auto placement picks\n // the column; requiring a start here dropped `colSpan` alone.\n if (col === undefined && row === undefined && colSpan === undefined && rowSpan === undefined)\n return\n o.gridPosition = {\n column: (col as number | undefined) ?? 0,\n row: (row as number | undefined) ?? 0,\n columnSpan: (colSpan as number | undefined) ?? 1,\n rowSpan: (rowSpan as number | undefined) ?? 1\n }\n}\n\nfunction applyAutoLayoutSizing(\n o: Partial<SceneNode>,\n props: Record<string, unknown>,\n w: unknown,\n h: unknown\n): void {\n const flex = typeof props.flex === 'string' ? props.flex : 'col'\n o.layoutMode = parseAutoLayoutDirection(flex) ?? 'HORIZONTAL'\n const own = (dim: unknown) => (typeof dim === 'number' ? 'FIXED' : 'HUG')\n Object.assign(o, autoLayoutSizingFields(o.layoutMode, own(w), own(h)))\n}\n\nfunction applyLayoutAlignmentOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode>\n): void {\n const justify = designJSXProp(props, 'justify')\n if (typeof justify === 'string' && justify) {\n o.primaryAxisAlign = parsePrimaryAxisAlign(justify) ?? 'MIN'\n }\n const items = designJSXProp(props, 'items')\n if (typeof items === 'string' && items) {\n o.counterAxisAlign = parseCounterAxisAlign(items) ?? 'MIN'\n }\n}\n\nfunction shouldEnableAutoLayout(props: Record<string, unknown>, isText: boolean): boolean {\n if (props.flex !== undefined) return true\n if (!isText && hasAutoLayoutTriggerProps(props)) return true\n return false\n}\n\nfunction applyLayoutOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n w: unknown,\n h: unknown,\n isText: boolean,\n parentLayout: SceneNode['layoutMode']\n): void {\n if (props.grid) {\n applyGridOverrides(props, o, w, h)\n applyPaddingOverrides(props, o)\n if (props.grow !== undefined) o.layoutGrow = props.grow as number\n return\n }\n\n if (parentLayout === 'GRID') {\n applyGridChildOverrides(props, o)\n }\n\n if (shouldEnableAutoLayout(props, isText)) {\n applyAutoLayoutSizing(o, props, w, h)\n }\n\n o.layoutDirection =\n parseDirection(props.flow ?? (!isText ? props.dir : undefined)) ?? o.layoutDirection\n\n if (props.gap !== undefined) o.itemSpacing = props.gap as number\n\n if (props.wrap) {\n o.layoutWrap = 'WRAP'\n if (props.rowGap !== undefined) o.counterAxisSpacing = props.rowGap as number\n }\n\n applyLayoutAlignmentOverrides(props, o)\n\n applyPaddingOverrides(props, o)\n\n if (props.grow !== undefined) o.layoutGrow = props.grow as number\n}\n\nfunction applyTextStyleOverrides(\n props: LayerProps,\n o: Partial<SceneNode>,\n profile: DocumentColorSpace\n): void {\n const fontSize = designJSXProp(props, 'size')\n if (typeof fontSize === 'number') o.fontSize = fontSize\n\n const fontFamily = designJSXProp(props, 'font')\n if (typeof fontFamily === 'string') o.fontFamily = fontFamily\n\n const weight = designJSXProp(props, 'weight')\n if (typeof props.italic === 'boolean') o.italic = props.italic\n\n if (typeof weight === 'number') {\n o.fontWeight = weight\n } else if (typeof weight === 'string') {\n o.fontWeight = WEIGHT_MAP[weight] ?? 400\n }\n\n if (typeof props.color === 'string' || isColor(props.color)) {\n o.fills = [colorToFill(props.color, profile)]\n }\n\n // A value it cannot read is left out, so the text keeps its own.\n const lineHeight = props.lineHeight === AUTO ? null : textLengthProp(props.lineHeight)\n if (lineHeight !== undefined) o.lineHeight = lineHeight\n const letterSpacing = textLengthProp(props.letterSpacing)\n if (letterSpacing) o.letterSpacing = letterSpacing\n const textDecoration = TEXT_DECORATION.parse(props.textDecoration)\n if (textDecoration) o.textDecoration = textDecoration\n applyTextDetailOverrides(props, o, profile)\n const textCase = TEXT_CASE.parse(props.textCase)\n if (textCase) o.textCase = textCase\n if (props.maxLines !== undefined) {\n o.maxLines = props.maxLines\n o.textTruncation = 'ENDING'\n }\n if (props.truncate) {\n o.textTruncation = 'ENDING'\n }\n\n applyTextAlignmentOverrides(props, o)\n}\n\nfunction applyTextAlignmentOverrides(props: Record<string, unknown>, o: Partial<SceneNode>): void {\n const textAlign = designJSXProp(props, 'textAlign')\n if (typeof textAlign === 'string') {\n o.textAlignHorizontal = TEXT_ALIGN.parse(textAlign) ?? 'LEFT'\n }\n\n const textAlignVertical = designJSXProp(props, 'textAlignVertical')\n if (typeof textAlignVertical === 'string') {\n o.textAlignVertical = TEXT_ALIGN_VERTICAL.parse(textAlignVertical) ?? 'TOP'\n }\n}\n\nfunction applyTextAutoResize(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n parentLayout: SceneNode['layoutMode']\n): void {\n const w = designJSXProp(props, 'w')\n const hasExplicitWidth = w !== undefined\n const grow = typeof props.grow === 'number' ? props.grow : undefined\n const fillsParent = w === 'fill' || (grow !== undefined && grow > 0)\n const isInsideAutoLayout = parentLayout !== 'NONE'\n\n // DO NOT CHANGE these defaults without testing headless layout (no CanvasKit).\n // WIDTH_AND_HEIGHT relies on MeasureFunc — without it, text keeps the 100×100\n // default SceneNode size and blows up every HUG container. layout.ts has a\n // fallback estimator, but changing this logic can silently break all JSX rendering.\n if (props.textAutoResize) {\n o.textAutoResize = TEXT_AUTO_RESIZE.parse(props.textAutoResize) ?? 'NONE'\n } else if (hasExplicitWidth || (isInsideAutoLayout && fillsParent)) {\n o.textAutoResize = 'HEIGHT'\n } else {\n o.textAutoResize = 'WIDTH_AND_HEIGHT'\n }\n}\n\nfunction applyTextOverrides(\n props: LayerProps,\n o: Partial<SceneNode>,\n parentLayout: SceneNode['layoutMode'],\n profile: DocumentColorSpace\n): void {\n applyTextStyleOverrides(props, o, profile)\n // Without `dir` the node keeps the style's own direction, which is auto by default; writing an\n // undefined override would erase it and stop Arabic text from being detected as RTL.\n const direction = parseDirection(props.dir)\n if (direction) o.textDirection = direction\n applyTextAutoResize(props, o, parentLayout)\n}\n\nconst FULL_TURN_DEGREES = 360\n\nfunction numberProp(value: unknown): number | undefined {\n return typeof value === 'number' ? value : undefined\n}\n\n/**\n * An `<Ellipse>`'s arc from its props: angles in degrees, clockwise from three o'clock, as the\n * canvas draws arcs, and the hole as a share of the ellipse. Null when none is set.\n */\nfunction arcOverride(props: Record<string, unknown>): ArcData | null {\n const start = numberProp(props.startAngle)\n const end = numberProp(props.endAngle)\n const innerRadius = numberProp(props.innerRadius)\n if (start === undefined && end === undefined && innerRadius === undefined) return null\n const startDegrees = start ?? 0\n return {\n startingAngle: (startDegrees * Math.PI) / 180,\n endingAngle: ((end ?? startDegrees + FULL_TURN_DEGREES) * Math.PI) / 180,\n innerRadius: innerRadius ?? 0\n }\n}\n\n/** The fields a shape element's own props set, by the layer it makes. */\nexport function shapeOverrides(\n nodeType: NodeType,\n props: Record<string, unknown>\n): Partial<SceneNode> {\n const o: Partial<SceneNode> = {}\n if (nodeType === 'STAR' || nodeType === 'POLYGON') {\n const points = numberProp(props.pointCount) ?? numberProp(props.points)\n if (points !== undefined) o.pointCount = points\n }\n if (nodeType === 'STAR') {\n const innerRadius = numberProp(props.innerRadius)\n if (innerRadius !== undefined) o.starInnerRadius = innerRadius\n }\n if (nodeType === 'ELLIPSE') {\n const arc = arcOverride(props)\n if (arc) o.arcData = arc\n }\n return o\n}\n\nexport function propsToOverrides(\n props: Record<string, unknown>,\n isText: boolean,\n parentLayout: SceneNode['layoutMode'],\n profile: DocumentColorSpace = 'srgb'\n): Partial<SceneNode> {\n // Layer props are read once, after `style` gives the ones the props leave unset.\n const layer = readLayerProps(normalizeStyleProps(props))\n const o: Partial<SceneNode> = {}\n\n if (layer.name) o.name = layer.name\n\n const { w, h } = applySizeOverrides(layer, o, parentLayout)\n applyVisualOverrides(layer, o, profile)\n applyLayoutOverrides(layer, o, w, h, isText, parentLayout)\n if (isText) applyTextOverrides(layer, o, parentLayout, profile)\n applyEffectOverrides(layer, o, profile)\n applyStateOverrides(layer, o)\n\n return o\n}\n","import { compact, isPlainObject, isString, pull, range, uniq } from 'es-toolkit'\n\nimport { namesComponent, rekaRole } from './behaviours'\nimport { isComponentProperty } from './component-properties'\nimport { DESIGN_JSX_SUPPORTED_PROPERTIES } from './definitions'\nimport { elementNodeType } from './elements'\nimport { isLayerRef, type LayerRef } from './refs'\nimport { isTreeNode, type TreeNode } from './tree'\n\n/** A component as an element names it: by name, or by the `ref()` that marks it. */\ntype ComponentKey = string | LayerRef\n\n/**\n * The components an element and its descendants define and name. `mayName` holds the text values\n * property props give, an exposed nested instance's included: a swap takes one as a component's\n * name, other properties as plain text, and which is which is known only once the component\n * renders.\n */\ninterface ComponentUse {\n defines: ComponentKey[]\n names: ComponentKey[]\n mayName: string[]\n}\n\n/** Whether an element defines a component: a component, a set, or a Reka root naming none. */\nfunction definesComponent(node: TreeNode): boolean {\n const nodeType = elementNodeType(node.type)\n if (nodeType === 'COMPONENT' || nodeType === 'COMPONENT_SET') return true\n return rekaRole(node.type)?.role === 'root' && !namesComponent(node.props)\n}\n\n/** What the element itself defines or names, without its descendants. */\nfunction ownUse(node: TreeNode): ComponentUse {\n const { props } = node\n if (definesComponent(node)) {\n const name = isString(props.name) ? props.name : ''\n return { defines: compact([name, isLayerRef(props.ref) && props.ref]), names: [], mayName: [] }\n }\n const of = props.component ?? props.componentId ?? props.of\n const component = isComponentProperty(of) ? of.defaultValue : of\n const assigned = [\n ...Object.entries(props)\n .filter(([key]) => !DESIGN_JSX_SUPPORTED_PROPERTIES.has(key))\n .map(([, value]) => value),\n ...(isPlainObject(props.properties) ? Object.values(props.properties) : [])\n ]\n // An exposed nested instance's values, as in `Action={{ Icon: 'Arrow' }}`.\n const nested = assigned.filter(isPlainObject).flatMap((values) => Object.values(values))\n return {\n defines: [],\n names: [\n ...(isString(component) || isLayerRef(component) ? [component] : []),\n ...assigned.filter(isLayerRef)\n ],\n mayName: [...assigned, ...nested].filter(isString)\n }\n}\n\n/** Reads each element's components once, for every level an order is asked at. */\nexport class RenderOrder {\n private readonly uses = new WeakMap<TreeNode, ComponentUse>()\n\n private use(node: TreeNode): ComponentUse {\n const known = this.uses.get(node)\n if (known) return known\n const parts = [\n ownUse(node),\n ...node.children.filter(isTreeNode).map((child) => this.use(child))\n ]\n const use = {\n defines: uniq(parts.flatMap((part) => part.defines)),\n names: uniq(parts.flatMap((part) => part.names)),\n mayName: uniq(parts.flatMap((part) => part.mayName))\n }\n this.uses.set(node, use)\n return use\n }\n\n /**\n * The indices of `siblings` in render order: those that define a component before those that\n * name it, otherwise as written. When none is ready, what text values may name gives way\n * first, so a text that matches a component's name never holds back a real reference; only\n * components that do name each other keep the written order.\n */\n of(siblings: readonly TreeNode[]): number[] {\n const uses = siblings.map((sibling) => this.use(sibling))\n if (uses.every((use) => use.defines.length === 0)) return range(siblings.length)\n\n const owners = new Map<ComponentKey, number[]>()\n uses.forEach((use, index) => {\n for (const key of use.defines) owners.set(key, [...(owners.get(key) ?? []), index])\n })\n const siblingsDefining = (keys: ComponentKey[], index: number) =>\n uniq(keys.flatMap((key) => owners.get(key) ?? [])).filter((owner) => owner !== index)\n const needs = uses.map((use, index) => siblingsDefining(use.names, index))\n const mayNeed = uses.map((use, index) => siblingsDefining(use.mayName, index))\n\n const order: number[] = []\n const pending = range(siblings.length)\n const rendered = (indices: number[]) => indices.every((index) => order.includes(index))\n while (pending.length > 0) {\n const next =\n pending.find((index) => rendered(needs[index]) && rendered(mayNeed[index])) ??\n pending.find((index) => rendered(needs[index])) ??\n pending[0]\n order.push(next)\n pull(pending, [next])\n }\n return order\n }\n}\n","import * as v from 'valibot'\n\nimport type { SceneGraph, SceneNode, VectorNetwork } from '@pairdraw/scene-graph'\nimport { parsePluginVectorPath, parseSVGPathData } from '@pairdraw/scene-graph/parse-path'\nimport type { Rect } from '@pairdraw/scene-graph/primitives'\nimport { mergeVectorNetworks, transformVectorNetwork } from '@pairdraw/scene-graph/vector-network'\n\nimport { designJSXProp } from '../definitions'\nimport { normalizeStyleProps } from '../props-overrides'\nimport { parseScriptInput } from '../schema'\n\nconst FILL_RULES = { nonzero: 'NONZERO', evenodd: 'EVENODD' } as const\n\nconst vectorPropsSchema = v.pipe(\n v.object({\n d: v.optional(v.pipe(v.string(), v.trim(), v.nonEmpty())),\n fillRule: v.optional(v.picklist(['nonzero', 'evenodd'])),\n paths: v.optional(\n v.array(\n v.object({\n windingRule: v.picklist(['NONZERO', 'EVENODD', 'NONE']),\n data: v.string()\n })\n )\n )\n }),\n v.check((props) => !(props.d && props.paths), 'Expected `d` or `paths`, not both')\n)\n\nfunction parsedNetwork(result: ReturnType<typeof parseSVGPathData>, which: string): VectorNetwork {\n if (!result.ok) throw new Error(`Invalid <Vector> ${which}: ${result.error}`)\n return result.network\n}\n\n/**\n * The vector network a `<Vector>`'s `d` or `paths` draws, in the coordinates they are written\n * in, or null when it has neither. `d` reads as SVG does, its open subpaths filled only when\n * `fillsOpenSubpaths`; `paths` as Figma's `vectorPaths`.\n */\nfunction vectorNetworkProp(\n props: Record<string, unknown>,\n fillsOpenSubpaths: boolean\n): VectorNetwork | null {\n const parsed = parseScriptInput('Invalid <Vector> props', vectorPropsSchema, props)\n if (parsed.d) {\n const windingRule = FILL_RULES[parsed.fillRule ?? 'nonzero']\n return parsedNetwork(\n parseSVGPathData(parsed.d, windingRule, { includeOpenRegions: fillsOpenSubpaths }),\n '`d`'\n )\n }\n if (!parsed.paths) return null\n return mergeVectorNetworks(\n parsed.paths.map(({ windingRule, data }, index) =>\n parsedNetwork(parsePluginVectorPath(data, windingRule), `paths[${index}]`)\n )\n )\n}\n\n/** The size a `<Vector>` is given, on the axes its props size. */\ninterface VectorSize {\n width?: number\n height?: number\n}\n\n/**\n * The size of `node` on the axes `props` set, by `w`/`width` and `h`/`height`, however they set\n * them: a number, a variable, or a layout value. The layer already holds what they resolve to.\n */\nfunction vectorSize(props: Record<string, unknown>, node: SceneNode): VectorSize {\n const sized = normalizeStyleProps(props)\n return {\n width: designJSXProp(sized, 'w') === undefined ? undefined : node.width,\n height: designJSXProp(sized, 'h') === undefined ? undefined : node.height\n }\n}\n\n/**\n * The fields that place a vector network in its layer. On an axis the author sized, the path is\n * drawn in the layer's own box as written, as an SVG icon is in its view box. On an axis left\n * unsized, the layer takes the network's extent and moves to where it starts, as Figma's\n * `vectorPaths` setter does.\n */\nfunction vectorGeometry(\n network: VectorNetwork,\n bounds: Rect,\n size: VectorSize,\n position: Pick<SceneNode, 'x' | 'y'>\n): Partial<SceneNode> {\n const dx = size.width === undefined ? bounds.x : 0\n const dy = size.height === undefined ? bounds.y : 0\n return {\n x: position.x + dx,\n y: position.y + dy,\n width: size.width ?? bounds.width,\n height: size.height ?? bounds.height,\n vectorNetwork: transformVectorNetwork([1, 0, -dx, 0, 1, -dy, 0, 0, 1], network)\n }\n}\n\n/**\n * A `<Vector>`'s `d` or `paths` as its vector network, the layer sized to it. `vectorBounds`\n * measures the network, curves included, which the engine provides.\n */\nexport function placeVectorPaths(\n graph: SceneGraph,\n node: SceneNode,\n props: Record<string, unknown>,\n vectorBounds: (network: VectorNetwork) => Rect\n): void {\n if (node.type !== 'VECTOR') return\n // A filled vector strokes its regions, which close, so an open subpath becomes one only when\n // nothing strokes it, as SVG import decides.\n const fillsOpenSubpaths =\n node.fills.some((fill) => fill.visible) && !node.strokes.some((stroke) => stroke.visible)\n const network = vectorNetworkProp(props, fillsOpenSubpaths)\n if (!network) return\n graph.updateNode(\n node.id,\n vectorGeometry(network, vectorBounds(network), vectorSize(props, node), node)\n )\n}\n","import type { SceneGraph, VariableLiteral } from '@pairdraw/scene-graph'\n\nimport { isVariable } from './variables'\nimport { requireVariableId } from './variables/graph'\nimport { scalarProps } from './variables/props'\n\n/** Resolve numeric props before sizing inference; retain real graph bindings afterward. */\nexport function prepareScalarBindings(\n graph: SceneGraph,\n props: Record<string, unknown>,\n bindings: Record<string, string>,\n isText: boolean,\n resolve: (variableId: string) => VariableLiteral | undefined\n): void {\n const entries = scalarProps({ text: isText, grid: !!props.grid, wrap: !!props.wrap })\n const scalarBindings = new Map<string, string>()\n for (const { prop: key, fields } of entries) {\n const value = props[key]\n if (value === undefined) continue\n // A literal longhand must also override a bound shorthand on that edge.\n for (const field of fields) scalarBindings.delete(field)\n if (!isVariable(value)) continue\n\n const variable = graph.variables.get(requireVariableId(graph, value))\n if (variable?.type !== 'FLOAT') {\n throw new Error(`Expected a FLOAT variable for ${key}: ${value.name}`)\n }\n const resolved = resolve(variable.id)\n if (typeof resolved !== 'number' || !Number.isFinite(resolved)) {\n throw new TypeError(`Cannot resolve numeric variable for ${key}: ${value.name}`)\n }\n props[key] = resolved\n for (const field of fields) scalarBindings.set(field, variable.id)\n }\n Object.assign(bindings, Object.fromEntries(scalarBindings))\n}\n","import { omitBy } from 'es-toolkit/object'\n\nimport type { NodeType, SceneGraph, SceneNode, VariableModeMap } from '@pairdraw/scene-graph'\nimport { parseColor } from '@pairdraw/scene-graph/color'\nimport {\n ownInstanceOverrides,\n setInstanceOverride\n} from '@pairdraw/scene-graph/instances/overrides'\nimport { textLayerName } from '@pairdraw/scene-graph/node-defaults'\n\nimport type { RekaScope } from './behaviours'\nimport { renderRekaNode } from './behaviours/render'\nimport {\n assignComponentProperties,\n assignNamedProperties,\n bindProperties,\n componentPropNames as namesOnInstance,\n exposeInstance,\n inferComponentSetProperties\n} from './component-properties'\nimport { CONNECTOR_ELEMENT, resolveConnectorEnds } from './connectors'\nimport { elementNodeType, elementOwnLayer, type OwnLayerRenderer } from './elements'\nimport { RenderOrder } from './order'\nimport { placeVectorPaths } from './overrides/vector'\nimport { applySizeOverrides, propsToOverrides, shapeOverrides } from './props-overrides'\nimport { isLayerRef, LayerRefs } from './refs'\nimport { prepareScalarBindings } from './scalar-bindings'\nimport { readElementProps } from './schema'\nimport type { DesignJSXServices } from './services'\nimport { isTextContent, TEXT_CONTENT_NAMES, textContentFields } from './text-content'\nimport { FRAGMENT, isTreeNode } from './tree'\nimport type { TreeNode } from './tree'\nimport type { RenderOptions } from './types'\nimport { isVariable } from './variables'\nimport {\n applyVariableDefinitions,\n bindVariableProp,\n requireVariableId,\n resolveForLayer,\n variableModes,\n type LayerContext\n} from './variables/graph'\nimport { paintProps } from './variables/props'\n\nexport interface RenderResult {\n id: string\n name: string\n type: NodeType\n childIds: string[]\n warnings?: string[]\n}\n\n/** The nodes a tree renders as: a fragment's children, or the tree itself. */\nfunction treeRoots(tree: TreeNode): TreeNode[] {\n return tree.type === FRAGMENT ? tree.children.filter(isTreeNode) : [tree]\n}\n\n/** Render every root of `tree` into the parent and lay out once. */\nexport async function renderRoots<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n options: RenderOptions = {}\n): Promise<RenderResult[]> {\n const roots = treeRoots(tree)\n if (roots.length === 0) throw new Error('JSX must return a Figma element (Frame, Text, etc)')\n const parentId = options.parentId ?? graph.getPages()[0].id\n applyVariableDefinitions(graph, tree)\n\n const originalChildCount = graph.getChildren(parentId).length\n // Render roots that define a component before roots that name it, so an `<Instance of={card}>`\n // written before its `<Component ref={card}>` still finds the component (RenderOrder).\n const order = new RenderOrder()\n const nodes: SceneNode[] = []\n const connectors: Array<{ node: SceneNode; tree: TreeNode }> = []\n const refs = new LayerRefs()\n const onNode = (element: TreeNode, node: SceneNode) => {\n if (element.type === CONNECTOR_ELEMENT) connectors.push({ node, tree: element })\n else refs.mark(element.props.ref, node)\n options.onNode?.(element, node)\n }\n for (const index of order.of(roots)) {\n const node = await renderNode(services, graph, roots[index], parentId, onNode, undefined, refs)\n const { x, y } = options.positions?.[index] ?? options\n if (x !== undefined) graph.updateNode(node.id, { x })\n if (y !== undefined) graph.updateNode(node.id, { y })\n nodes[index] = node\n }\n // Keep the written layer order even though components rendered first.\n nodes.forEach((node, index) => graph.insertChildAt(node.id, parentId, originalChildCount + index))\n\n const rootIds = nodes.map((node) => node.id)\n const warnings = [...refs.warnings, ...resolveConnectorEnds(graph, rootIds, connectors, refs)]\n if (!options.deferLayout) services.layout(graph, rootIds)\n\n return nodes.map((node) => ({\n id: node.id,\n name: node.name,\n type: node.type,\n childIds: node.childIds,\n ...(warnings.length > 0 && { warnings })\n }))\n}\n\n/** Render `tree` and return its first root; a fragment's other roots are rendered too. */\nexport async function renderTree<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n options: RenderOptions = {}\n): Promise<RenderResult> {\n const [first] = await renderRoots(services, graph, tree, options)\n return first\n}\n\ninterface PreparedProps {\n props: Record<string, unknown>\n bindings: Record<string, string>\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction preparePropsForRender(\n graph: SceneGraph,\n source: Record<string, unknown>,\n isText: boolean,\n layer: LayerContext\n): PreparedProps {\n const props = { ...source }\n const bindings: Record<string, string> = {}\n\n if (Array.isArray(props.fills)) {\n props.fills = props.fills.map((value: unknown, index) => {\n const fill = { value }\n bindVariableProp(graph, fill, bindings, 'value', `fills/${index}/color`, layer)\n return fill.value\n })\n }\n\n for (const { prop, fields } of paintProps({ text: isText })) {\n bindVariableProp(graph, props, bindings, prop, fields[0], layer)\n }\n\n if (isObjectRecord(props.style)) {\n const style = { ...props.style }\n for (const key of ['background', 'backgroundColor']) {\n bindVariableProp(graph, style, bindings, key, 'fills/0/color', layer)\n }\n if (isText) bindVariableProp(graph, style, bindings, 'color', 'fills/0/color', layer)\n bindVariableProp(graph, style, bindings, 'borderColor', 'strokes/0/color', layer)\n props.style = style\n }\n\n prepareScalarBindings(graph, props, bindings, isText, (variableId) =>\n resolveForLayer(graph, variableId, layer.parentId, layer.modes)\n )\n\n if (isObjectRecord(props.bind)) {\n for (const [field, value] of Object.entries(props.bind)) {\n if (isVariable(value)) {\n bindings[field] = requireVariableId(graph, value)\n } else if (typeof value === 'string') {\n bindings[field] = value\n }\n }\n }\n\n return { props, bindings }\n}\n\n/**\n * An element that draws its own layer. Its props are resolved as any layer's are, so a\n * `designVar()` binds, and its layer props become fields as any layer's do; the element reads the\n * rest itself.\n */\nfunction renderOwnLayerElement(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n element: OwnLayerRenderer\n): SceneNode {\n const modes = variableModes(graph, tree.props.mode)\n const { props, bindings } = preparePropsForRender(graph, tree.props, false, { parentId, modes })\n const parentLayout = graph.getNode(parentId)?.layoutMode ?? 'NONE'\n const layer = omitBy(\n {\n ...propsToOverrides(\n readElementProps(element.layer, props),\n false,\n parentLayout,\n graph.documentColorSpace\n ),\n ...(modes && { variableModes: modes })\n },\n (value) => value === undefined\n )\n const node = element.render(graph, { ...tree, props }, parentId, layer)\n for (const [field, variableId] of Object.entries(bindings)) {\n graph.bindVariable(element.bindingTarget?.(graph, node, field) ?? node.id, field, variableId)\n }\n return node\n}\n\nfunction applyBindings(graph: SceneGraph, nodeId: string, bindings: Record<string, string>): void {\n for (const [field, variableId] of Object.entries(bindings)) {\n graph.bindVariable(nodeId, field, variableId)\n }\n}\n\nfunction applyIconSize(\n props: Record<string, unknown>,\n overrides: Partial<SceneNode>,\n parentLayout: SceneNode['layoutMode'],\n size: number\n): void {\n const { w, h } = applySizeOverrides(props, overrides, parentLayout)\n if (typeof w !== 'number') overrides.width = size\n if (typeof h !== 'number') overrides.height = size\n}\n\nasync function renderIconNode<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string\n): Promise<SceneNode> {\n const props = tree.props\n const iconName = props.name as string | undefined\n if (!iconName) throw new Error('<Icon> requires a name prop (e.g. name=\"lucide:heart\")')\n\n const size = (props.size as number | undefined) ?? 24\n const artwork = await services.icon(iconName, size)\n if (!artwork) throw new Error(`Icon \"${iconName}\" not found`)\n return placeArtwork(services, graph, artwork, props, size, parentId)\n}\n\nfunction placeArtwork<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n artwork: Artwork,\n props: Record<string, unknown>,\n size: number,\n parentId: string\n): SceneNode {\n const parentLayout = graph.getNode(parentId)?.layoutMode ?? 'NONE'\n const overrides: Partial<SceneNode> = {}\n if (typeof props.label === 'string' && props.label) overrides.name = props.label\n applyIconSize(props, overrides, parentLayout, size)\n const modes = variableModes(graph, props.mode)\n if (modes) overrides.variableModes = modes\n const variableId = isVariable(props.color) ? requireVariableId(graph, props.color) : undefined\n const resolved = variableId && resolveForLayer(graph, variableId, parentId, modes)\n if (isVariable(props.color) && typeof resolved !== 'object')\n throw new Error(`Cannot resolve color variable ${props.color.name} for color`)\n const color =\n typeof resolved === 'object'\n ? resolved\n : parseColor(typeof props.color === 'string' ? props.color : '#000000')\n const node = services.createArtwork(graph, artwork, { parentId, size, color, overrides })\n if (variableId) bindSolidPaints(graph, node, variableId)\n return node\n}\n\n/** Bind every solid paint of an artwork's paths, so it follows the variable it was drawn in. */\nfunction bindSolidPaints(graph: SceneGraph, node: SceneNode, variableId: string): void {\n for (const field of ['fills', 'strokes'] as const) {\n node[field].forEach((paint, index) => {\n if (paint.type === 'SOLID') graph.bindVariable(node.id, `${field}/${index}/color`, variableId)\n })\n }\n for (const child of graph.getChildren(node.id)) bindSolidPaints(graph, child, variableId)\n}\n\n/**\n * Render an inline <svg> element into vector nodes through the same artwork path as\n * icons. The body may be string children or a `body` prop; parsed shape children work too.\n */\nfunction renderSVGNode<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string\n): SceneNode {\n const props = tree.props\n const explicitW = typeof props.w === 'number' ? props.w : 0\n const explicitH = typeof props.h === 'number' ? props.h : 0\n const size =\n explicitW > 0 || explicitH > 0\n ? Math.max(explicitW, explicitH)\n : ((props.size as number | undefined) ?? 24)\n const body =\n (typeof props.body === 'string' && props.body) ||\n tree.children.filter((c): c is string => typeof c === 'string').join('')\n const artwork = services.svg({ body, elements: tree.children.filter(isTreeNode), props }, size)\n if (!artwork) {\n throw new Error('<svg> requires SVG markup, a body prop, or supported SVG shape children')\n }\n return placeArtwork(services, graph, artwork, props, size, parentId)\n}\n\n/** Every component or set the reference names: one by ID, or each one sharing the name. */\nfunction componentsNamed(graph: SceneGraph, ref: string): SceneNode[] {\n const byId = graph.getNode(ref)\n if (byId?.type === 'COMPONENT' || byId?.type === 'COMPONENT_SET') return [byId]\n const components: SceneNode[] = []\n const sets: SceneNode[] = []\n for (const node of graph.getAllNodes()) {\n if (node.name !== ref) continue\n if (node.type === 'COMPONENT') components.push(node)\n else if (node.type === 'COMPONENT_SET') sets.push(node)\n }\n return [...components, ...sets]\n}\n\n/** Whether `props` selects a variant of `set`, naming one of its variant properties. */\nfunction selectsVariant(set: SceneNode, props: Record<string, unknown>): boolean {\n return Object.keys(props).some((key) =>\n set.componentPropertyDefinitions.some(\n (definition) => definition.type === 'VARIANT' && definition.name === key\n )\n )\n}\n\n/**\n * The component or component set an element names. A name several of them share uses the set when\n * the props select one of its variants, and the first otherwise; the warning from\n * `componentReferenceWarnings` says so and how to pick one by ID.\n */\nfunction namedComponent(\n graph: SceneGraph,\n props: Record<string, unknown>,\n refs?: LayerRefs\n): SceneNode | undefined {\n const ref = props.component ?? props.componentId ?? props.of\n if (isLayerRef(ref)) {\n const marked = graph.getNode(refs?.layerOf(ref) ?? '')\n return marked?.type === 'COMPONENT' || marked?.type === 'COMPONENT_SET' ? marked : undefined\n }\n if (typeof ref !== 'string') return undefined\n\n const matches = componentsNamed(graph, ref)\n if (matches.length <= 1) return matches[0]\n return (\n matches.find((node) => node.type === 'COMPONENT_SET' && selectsVariant(node, props)) ??\n matches[0]\n )\n}\n\n/** A name several components or sets share, naming each candidate by its ID. */\nexport function componentReferenceWarnings(\n graph: SceneGraph,\n props: Record<string, unknown>\n): string[] {\n const ref = props.component ?? props.componentId ?? props.of\n if (typeof ref !== 'string') return []\n const matches = componentsNamed(graph, ref)\n if (matches.length < 2) return []\n const chosen = namedComponent(graph, props)\n const choices = matches\n .map((node) => `${node.id} (${node.type === 'COMPONENT_SET' ? 'component set' : 'component'})`)\n .join(', ')\n const joined = chosen?.type === 'COMPONENT_SET' ? 'the component set' : 'the first'\n return [\n `<Instance> of \"${ref}\" names ${matches.length} components and joins ${joined}; name the one you mean by its ID: ${choices}.`\n ]\n}\n\nfunction findVariantInSet(\n graph: SceneGraph,\n componentSet: SceneNode,\n props: Record<string, unknown>\n) {\n const requested = Object.fromEntries(\n Object.entries(props)\n .filter(([key]) =>\n componentSet.componentPropertyDefinitions.some(\n (definition) => definition.type === 'VARIANT' && definition.name === key\n )\n )\n .map(([key, value]) => [key, String(value)])\n )\n const variants = graph.getChildren(componentSet.id).filter((node) => node.type === 'COMPONENT')\n return (\n variants.find((variant) =>\n Object.entries(requested).every(\n ([key, value]) => variant.componentPropertyValues[key] === value\n )\n ) ?? variants[0]\n )\n}\n\nfunction resolveComponent(\n graph: SceneGraph,\n props: Record<string, unknown>,\n refs?: LayerRefs\n): SceneNode | undefined {\n const named = namedComponent(graph, props, refs)\n return named?.type === 'COMPONENT_SET' ? findVariantInSet(graph, named, props) : named\n}\n\n/**\n * The names an element sets on its component by prop: properties such as `State` or `Title`, and\n * exposed instances.\n */\nexport function componentPropNames(graph: SceneGraph, props: Record<string, unknown>): string[] {\n const component = resolveComponent(graph, props)\n return component ? namesOnInstance(graph, component) : []\n}\n\nasync function renderInstanceNode(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n refs?: LayerRefs\n): Promise<SceneNode> {\n const parent = graph.getNode(parentId)\n const parentLayout = parent?.layoutMode ?? 'NONE'\n const modes = variableModes(graph, tree.props.mode)\n const bound = bindProperties(\n graph,\n tree.props,\n 'INSTANCE',\n parentId,\n componentIdNamed(graph, refs)\n )\n const { props, bindings } = preparePropsForRender(graph, bound.props, false, { parentId, modes })\n const component = resolveComponent(graph, props, refs)\n if (!component) {\n const ref = props.component ?? props.componentId ?? props.of\n if (isLayerRef(ref)) throw new Error('<Instance> ref() marks no component rendered before it')\n const label = typeof ref === 'string' || typeof ref === 'number' ? String(ref) : ''\n throw new Error(`<Instance> component not found: ${label}`)\n }\n const overrides: Partial<SceneNode> = {\n ...propsToOverrides(props, false, parentLayout, graph.documentColorSpace),\n ...layerMetadata(modes, bound.references)\n }\n // Instances inherit their container layout, but explicitly authored dimensions\n // must also replace the inherited sizing mode on that axis.\n const layout = overrides.layoutMode ?? component.layoutMode\n if (layout !== 'NONE') {\n const axes =\n layout === 'HORIZONTAL'\n ? (['primaryAxisSizing', 'counterAxisSizing'] as const)\n : (['counterAxisSizing', 'primaryAxisSizing'] as const)\n for (const [dimension, field] of [\n ['w', axes[0]],\n ['h', axes[1]]\n ] as const) {\n const value = props[dimension]\n if (typeof value === 'number') overrides[field] = 'FIXED'\n else if (value === 'hug' || value === 'fill') overrides[field] = 'HUG'\n }\n }\n const instance =\n graph.createInstance(component.id, parentId, overrides) ?? graph.createNode('FRAME', parentId)\n try {\n for (const [field, value] of Object.entries(overrides)) {\n setInstanceOverride(ownInstanceOverrides(instance), instance.id, instance.id, field, value)\n }\n graph.updateNode(instance.id, { instanceOverrides: instance.instanceOverrides })\n applyBindings(graph, instance.id, bindings)\n applyInstanceOverrides(graph, instance, tree.props.overrides)\n assignNamedProperties(graph, instance, props, componentIdNamed(graph, refs))\n assignComponentProperties(graph, instance, props.properties, componentIdNamed(graph, refs))\n if (props.exposed === true) exposeInstance(graph, instance)\n return instance\n } catch (error) {\n graph.deleteNode(instance.id)\n throw error\n }\n}\n\n/**\n * Apply child overrides to a freshly created instance. Keys are\n * `childName:prop` (e.g. 'label:text', 'icon:fills'); the child is resolved by\n * name among the instance's descendants, and the value is applied to both the\n * child node and the instance's overrides record so component sync keeps it.\n */\nfunction applyInstanceOverrides(\n graph: SceneGraph,\n instance: SceneNode,\n overridesProp: unknown\n): void {\n if (!overridesProp || typeof overridesProp !== 'object') return\n if (Array.isArray(overridesProp)) return\n const entries = Object.entries(overridesProp)\n if (entries.length === 0) return\n\n const descendants: SceneNode[] = []\n const walk = (id: string) => {\n const node = graph.getNode(id)\n if (!node) return\n descendants.push(node)\n for (const cid of node.childIds) walk(cid)\n }\n walk(instance.id)\n\n let mutated = false\n for (const [key, value] of entries) {\n const sep = key.indexOf(':')\n if (sep === -1) continue\n const childName = key.slice(0, sep)\n const prop = key.slice(sep + 1)\n const child = descendants.find((n) => n.name === childName)\n if (!child || !(prop in child)) continue\n graph.updateNode(child.id, { [prop]: value })\n setInstanceOverride(ownInstanceOverrides(instance), instance.id, child.id, prop, value)\n mutated = true\n }\n if (mutated) {\n graph.updateNode(instance.id, { instanceOverrides: instance.instanceOverrides })\n }\n}\n\nasync function renderArtworkNode<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string\n): Promise<SceneNode> {\n const bound = bindProperties(graph, tree.props, 'VECTOR', parentId, componentIdNamed(graph))\n const artwork = { ...tree, props: bound.props }\n const node =\n tree.type === 'icon'\n ? await renderIconNode(services, graph, artwork, parentId)\n : renderSVGNode(services, graph, artwork, parentId)\n const metadata: Partial<SceneNode> = layerMetadata(undefined, bound.references)\n if (typeof bound.props.visible === 'boolean') metadata.visible = bound.props.visible\n if (Object.keys(metadata).length > 0) graph.updateNode(node.id, metadata)\n return node\n}\n\n/** The modes a layer pins and the component properties its fields are bound to. */\nfunction layerMetadata(\n modes: VariableModeMap | undefined,\n references: SceneNode['componentPropertyReferences']\n): Partial<SceneNode> {\n return {\n ...(modes && { variableModes: modes }),\n ...(references.length > 0 && { componentPropertyReferences: references })\n }\n}\n\n/** The component a swap property's default names, by ID or name, as `<Instance of>` finds it. */\nfunction componentIdNamed(graph: SceneGraph, refs?: LayerRefs) {\n return (name: string) => resolveComponent(graph, { of: name }, refs)?.id\n}\n\nexport interface ElementOverrides {\n overrides: Partial<SceneNode>\n /** Variable IDs by bound field, such as `fills/0/color`. */\n bindings: Record<string, string>\n}\n\n/** The fields and variable bindings an element's props set on a `nodeType` node under `parentId`. */\nexport function elementOverrides(\n graph: SceneGraph,\n nodeType: NodeType,\n tree: TreeNode,\n parentId: string\n): ElementOverrides {\n const parentLayout = graph.getNode(parentId)?.layoutMode ?? 'NONE'\n const isText = nodeType === 'TEXT'\n const modes = variableModes(graph, tree.props.mode)\n const bound = bindProperties(graph, tree.props, nodeType, parentId, componentIdNamed(graph))\n const layer = { parentId, modes }\n const { props, bindings } = preparePropsForRender(graph, bound.props, isText, layer)\n const overrides = {\n ...propsToOverrides(props, isText, parentLayout, graph.documentColorSpace),\n ...shapeOverrides(nodeType, props),\n ...layerMetadata(modes, bound.references)\n }\n\n if (isText) {\n // A span's variables give their values; characters keep no bindings of their own.\n const spanOverrides = (spanProps: Record<string, unknown>) =>\n propsToOverrides(\n preparePropsForRender(graph, spanProps, true, layer).props,\n true,\n 'NONE',\n graph.documentColorSpace\n )\n Object.assign(overrides, textContentFields(tree, props, overrides, spanOverrides))\n // As Figma does, a text layer follows its characters until a name is given, and keeps a given\n // name through later edits.\n if (overrides.name) overrides.autoRename = false\n else if (overrides.text !== undefined) overrides.name = textLayerName('TEXT', overrides.text)\n }\n return { overrides, bindings }\n}\n\nasync function renderNode<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n onNode?: RenderOptions['onNode'],\n scope?: RekaScope,\n refs?: LayerRefs\n): Promise<SceneNode> {\n const node = await renderNodeContent(services, graph, tree, parentId, onNode, scope, refs)\n onNode?.(tree, node)\n return node\n}\n\n/**\n * The elements rendered their own way rather than as the layer their definition names, or null\n * for any other element.\n */\nfunction renderOwnElement<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n refs?: LayerRefs\n): Promise<SceneNode> | null {\n switch (tree.type) {\n case 'icon':\n case 'svg':\n return renderArtworkNode(services, graph, tree, parentId)\n case 'instance':\n return renderInstanceNode(graph, tree, parentId, refs)\n default: {\n const element = elementOwnLayer(tree.type)\n return element ? Promise.resolve(renderOwnLayerElement(graph, tree, parentId, element)) : null\n }\n }\n}\n\nasync function renderNodeContent<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n onNode?: RenderOptions['onNode'],\n scope?: RekaScope,\n refs?: LayerRefs\n): Promise<SceneNode> {\n const own = renderOwnElement(services, graph, tree, parentId, refs)\n if (own) return own\n const reka = await renderRekaNode(graph, tree, parentId, scope, {\n render: (child, childParentId, childScope) =>\n renderNode(services, graph, child, childParentId, onNode, childScope, refs),\n create: (nodeType, element, elementParentId) => {\n const { overrides, bindings } = elementOverrides(graph, nodeType, element, elementParentId)\n const created = graph.createNode(nodeType, elementParentId, overrides)\n applyBindings(graph, created.id, bindings)\n placeVectorPaths(graph, created, element.props, (network) => services.vectorBounds(network))\n return created\n },\n instance: (element, elementParentId) =>\n renderInstanceNode(graph, element, elementParentId, refs),\n finishSet: (setId) => inferComponentSetProperties(graph, setId)\n })\n if (reka) return reka\n\n if (isTextContent(tree))\n throw new Error(`<${TEXT_CONTENT_NAMES[tree.type]}> must be inside <Text>`)\n const nodeType = elementNodeType(tree.type)\n if (!nodeType) throw new Error(`Unknown element: <${tree.type}>`)\n\n const { overrides, bindings } = elementOverrides(graph, nodeType, tree, parentId)\n const node = graph.createNode(nodeType, parentId, overrides)\n applyBindings(graph, node.id, bindings)\n placeVectorPaths(graph, node, tree.props, (network) => services.vectorBounds(network))\n\n for (const child of tree.children) {\n if (typeof child === 'string' || (node.type === 'TEXT' && isTextContent(child))) continue\n if (!isTreeNode(child)) continue\n // Text holds characters and style runs, not layers: a child layer would exist in the graph but\n // not in the text's export, so it is refused rather than silently lost.\n if (node.type === 'TEXT') throw new Error(`<${child.type}> cannot be inside <Text>`)\n await renderNode(services, graph, child, node.id, onNode, scope, refs)\n }\n\n if (node.type === 'COMPONENT_SET') inferComponentSetProperties(graph, node.id)\n\n return node\n}\n","import { parse } from 'acorn'\nimport { transform } from 'sucrase'\n\nconst options = {\n transforms: ['typescript', 'jsx'] as Array<'typescript' | 'jsx'>,\n jsxPragma: '__h',\n jsxFragmentPragma: '__fragment',\n production: true\n}\n\n/**\n * Transformed Design JSX: a function body that returns what the source renders. Its elements\n * carry `__source: { lineNumber }` props; adding `lineOffset` to `lineNumber` gives the 1-based\n * line in the source that was passed in.\n */\nexport interface DesignJSXProgram {\n code: string\n lineOffset: number\n}\n\nconst RULE = 'Design JSX is one JSX expression, or statements that end with `return` and the JSX'\n\nfunction lineCount(text: string): number {\n let lines = 0\n for (const char of text) if (char === '\\n') lines++\n return lines\n}\n\nfunction transformBody(body: string, withLines: boolean): string {\n return withLines\n ? transform(body, { ...options, production: false, filePath: 'design.jsx' }).code\n : transform(body, options).code\n}\n\n/** Whether a function body returns from its top level, as statements must end. */\nfunction returns(code: string): boolean {\n const program = parse(code, { ecmaVersion: 'latest', allowReturnOutsideFunction: true })\n return program.body.some((statement) => statement.type === 'ReturnStatement')\n}\n\n/**\n * The function body a Design JSX string stands for, tried in order: one JSX expression, sibling\n * elements, or statements that end with `return` and the JSX, as a component's body does. Each\n * keeps the source's lines where they are.\n */\nfunction transformProgram(source: string, withLines: boolean): DesignJSXProgram {\n const trimmed = source.trim()\n const lineOffset = lineCount(source.slice(0, source.length - source.trimStart().length))\n const expressions = [`return (${trimmed})`]\n if (trimmed.startsWith('<')) expressions.push(`return (<>${trimmed}</>)`)\n for (const body of expressions) {\n try {\n return { code: transformBody(body, withLines), lineOffset }\n } catch {\n continue\n }\n }\n let code: string\n try {\n code = transformBody(trimmed, withLines)\n } catch (error) {\n throw new Error(`${RULE}: ${error instanceof Error ? error.message : String(error)}`, {\n cause: error\n })\n }\n if (!returns(code)) throw new Error(`${RULE}; these statements return nothing.`)\n return { code, lineOffset }\n}\n\n/** Transform Design JSX into the body of a function that returns what it renders. */\nexport function transformDesignJSXExpression(source: string): string {\n return transformProgram(source, false).code\n}\n\n/** Like {@link transformDesignJSXExpression}, keeping the source line of every element. */\nexport function transformDesignJSXProgram(source: string): DesignJSXProgram {\n return transformProgram(source, true)\n}\n","import { pickBy } from 'es-toolkit'\nimport { uniq } from 'es-toolkit/array'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\nimport { tryParseColor } from '@pairdraw/scene-graph/color'\n\nimport { REKA_ELEMENTS } from './behaviours'\nimport { elementBindings, elementProps, elementSchema } from './elements'\nimport { ENUM_PROPS } from './enums'\nimport { DESIGN_JSX_HELPERS, designJSXHelpers } from './helpers'\nimport * as React from './mini-react'\nimport { normalizeStyleProps } from './props-overrides'\nimport {\n renderRoots,\n renderTree,\n componentPropNames,\n componentReferenceWarnings,\n type RenderResult\n} from './renderer'\nimport { elementPropWarnings, layerPropsSchema, svgLayerPropsSchema } from './schema'\nimport type { DesignJSXServices } from './services'\nimport { TEXT_CONTENT_NAMES } from './text-content'\nimport { transformDesignJSXExpression } from './transform'\nimport { isTreeNode, resolveToTree, type TreeNode } from './tree'\nimport type { RenderOptions as RenderJSXOptions } from './types'\nimport { isVariable } from './variables'\n\nconst SIZE_PROPS = new Set(['w', 'h'])\nconst PAINT_PROPS = new Set(['bg', 'fill', 'stroke'])\n\n/** How a warning names a value it could not read. */\nfunction propValueText(value: unknown): string {\n return typeof value === 'string' ? `\"${value}\"` : String(value)\n}\n\nfunction unreadableSize(value: unknown): boolean {\n return !isVariable(value) && typeof value !== 'number' && value !== 'hug' && value !== 'fill'\n}\n\nfunction unreadablePaint(value: unknown): boolean {\n return typeof value === 'string' && tryParseColor(value) === null\n}\n\n/** `const Switch = { Root: 'Switch.Root', … }`: each Reka namespace as element types. */\nconst REKA_ALIASES = Object.entries(REKA_ELEMENTS)\n .map(\n ([namespace, parts]) =>\n `const ${namespace} = ${JSON.stringify(\n Object.fromEntries(Object.keys(parts).map((part) => [part, `${namespace}.${part}`]))\n )}`\n )\n .join('\\n')\n\n/** `const solid = __helpers.solid`, …: every helper in the scope of the code. */\nconst HELPER_BINDINGS = DESIGN_JSX_HELPERS.map(\n ({ name }) => `const ${name} = __helpers.${name}`\n).join('\\n')\n\n/** Where the scanner is: code (top level or `{…}`), JSX text, or an opening or closing tag. */\ntype ScanFrame = 'code' | 'text' | 'open' | 'close'\n\n/** End (exclusive) of the string that opens at `start`; JSX attribute strings have no escapes. */\nfunction stringEnd(source: string, start: number, escapes: boolean): number {\n const quote = source[start]\n let i = start + 1\n while (i < source.length && source[i] !== quote) i += escapes && source[i] === '\\\\' ? 2 : 1\n return Math.min(i + 1, source.length)\n}\n\n/** End of the string or JS comment at `i`, copied as written, or -1 when none starts there. */\nfunction verbatimEnd(source: string, i: number, frame: ScanFrame): number {\n const char = source.charAt(i)\n if (frame === 'open' || frame === 'close') {\n return /[\"']/.test(char) ? stringEnd(source, i, false) : -1\n }\n if (frame !== 'code') return -1\n if (/[\"'`]/.test(char)) return stringEnd(source, i, true)\n if (source.startsWith('//', i)) {\n const end = source.indexOf('\\n', i)\n return end === -1 ? source.length : end\n }\n if (source.startsWith('/*', i)) {\n const end = source.indexOf('*/', i + 2)\n return end === -1 ? source.length : end + 2\n }\n return -1\n}\n\n/** Whether the `<` just copied to `before` opens a tag rather than comparing, as in `a<b`. */\nfunction startsTag(source: string, next: number, frame: ScanFrame, before: string): boolean {\n const following = source.charAt(next)\n if (frame === 'text') return /[A-Za-z_$/>]/.test(following)\n if (!/[A-Za-z_$>]/.test(following)) return false\n const previous = before.slice(0, -1).trimEnd()\n return !/[\\w$)\\].]$/.test(previous) || /(?:^|[^\\w$])return$/.test(previous)\n}\n\n/** Enter or leave a frame after copying the character just before `next`. */\nfunction updateFrames(stack: ScanFrame[], source: string, next: number, out: string): void {\n const char = source.charAt(next - 1)\n const frame = stack.at(-1) ?? 'code'\n const inTag = frame === 'open' || frame === 'close'\n if (char === '{') stack.push('code')\n else if (char === '}' && frame === 'code' && stack.length > 1) stack.pop()\n else if (char === '<' && !inTag && startsTag(source, next, frame, out)) {\n stack.push(source.charAt(next) === '/' ? 'close' : 'open')\n } else if (char === '>' && frame === 'open') {\n if (source.charAt(next - 2) === '/') stack.pop()\n else stack[stack.length - 1] = 'text'\n } else if (char === '>' && frame === 'close') {\n stack.pop()\n if (stack.at(-1) === 'text') stack.pop()\n }\n}\n\n/**\n * Remove `<!-- … -->` written in JSX text or between statements. Markup inside an attribute\n * string or a JS string literal is part of the value and stays.\n */\nfunction stripHTMLComments(jsxString: string): string {\n const stack: ScanFrame[] = ['code']\n let out = ''\n let i = 0\n while (i < jsxString.length) {\n const frame = stack.at(-1) ?? 'code'\n if (frame !== 'open' && frame !== 'close' && jsxString.startsWith('<!--', i)) {\n const end = jsxString.indexOf('-->', i + 4)\n i = end === -1 ? jsxString.length : end + 3\n continue\n }\n const end = verbatimEnd(jsxString, i, frame)\n if (end !== -1) {\n out += jsxString.slice(i, end)\n i = end\n continue\n }\n out += jsxString.charAt(i)\n i++\n updateFrames(stack, jsxString, i, out)\n }\n return out\n}\n\n/** Why `value` cannot go into the layer field `key` names, or nothing when it can. */\nfunction valueKindWarning(\n key: string,\n value: unknown,\n element: string,\n type: TreeNode['type']\n): string | undefined {\n // An `<svg>`'s attributes are passed to its markup as written, so a value of the wrong kind is\n // the markup's to read: `fill=\"none\"` and `strokeWidth=\"2\"` are not layer fields.\n if (type === 'svg') return undefined\n if (SIZE_PROPS.has(key) && unreadableSize(value))\n return `Invalid ${key} ${propValueText(value)} on <${element}> is ignored; expected a number, \"hug\", or \"fill\".`\n if (PAINT_PROPS.has(key) && unreadablePaint(value))\n return `Invalid ${key} ${propValueText(value)} on <${element}> is ignored; expected a colour or a paint.`\n return undefined\n}\n\nfunction unsupportedPropWarnings(graph: SceneGraph, tree: TreeNode): string[] {\n const warnings: string[] = []\n collectUnsupportedPropWarnings(graph, tree, warnings)\n return warnings\n}\n\nfunction collectUnsupportedPropWarnings(\n graph: SceneGraph,\n tree: TreeNode,\n warnings: string[]\n): void {\n const supported = elementProps(tree.type)\n // An instance sets its component's properties by name, such as `State=\"On\"` or `Title=\"Hi\"`.\n if (tree.type === 'instance') warnings.push(...componentReferenceWarnings(graph, tree.props))\n const properties = componentPropNames(graph, tree.props)\n const element = TEXT_CONTENT_NAMES[tree.type] ?? tree.type\n const schema = elementSchema(tree.type)\n if (schema) warnings.push(...elementPropWarnings(schema, tree.props, element))\n // The layer props an element takes are read by one schema, which its own schema may restate,\n // with the values its `style` gives where the props leave them unset, as rendering reads them.\n const layerSchema = tree.type === 'svg' ? svgLayerPropsSchema : layerPropsSchema\n const layerProps = pickBy(\n normalizeStyleProps(tree.props),\n (_, key) => supported.has(key) && !(schema && Object.hasOwn(schema.entries, key))\n )\n warnings.push(...elementPropWarnings(layerSchema, layerProps, element))\n for (const [key, value] of Object.entries(tree.props)) {\n if (!supported.has(key) && !properties.includes(key)) {\n warnings.push(`Unsupported prop \"${key}\" on <${element}> is ignored.`)\n continue\n }\n // The element's schema already reported a prop it validates, in its own words; warning\n // again here would name the same value twice, as a connector's stroke once was.\n if (schema && key in schema.entries) continue\n const kindWarning = valueKindWarning(key, value, element, tree.type)\n if (kindWarning) {\n warnings.push(kindWarning)\n continue\n }\n const values = ENUM_PROPS[key]\n if (values && typeof value === 'string' && values.parse(value) === undefined) {\n warnings.push(\n `Unknown ${key} \"${value}\" on <${element}> is ignored; expected ${values.names.join(', ')}.`\n )\n }\n }\n\n // SVG descendants are parsed as markup by renderSvgNode, not as Design JSX nodes.\n if (tree.type === 'svg') return\n\n for (const child of tree.children) {\n if (isTreeNode(child)) collectUnsupportedPropWarnings(graph, child, warnings)\n }\n}\n\n/**\n * Build a component function from a JSX string: one JSX expression, sibling elements, or\n * statements that end with `return` and the JSX. The statements run inside the component, so\n * they may shadow an element or helper name. Works in both Node/Bun and the browser.\n */\nexport function buildComponent(jsxString: string, warnings: string[] = []): React.ComponentType {\n const trimmed = stripHTMLComments(jsxString).trim()\n\n const aliases = `\n const __h = React.createElement\n const __fragment = ''\n ${elementBindings()}\n const svg = 'svg'\n ${REKA_ALIASES}\n ${HELPER_BINDINGS}\n `\n\n const body = transformDesignJSXExpression(trimmed)\n // eslint-disable-next-line typescript-eslint/no-implied-eval -- sucrase output must be evaluated at runtime\n return new Function('React', '__helpers', `${aliases}\\nreturn function __render() {\\n${body}\\n}`)(\n React,\n designJSXHelpers(warnings)\n ) as React.ComponentType\n}\n\n/**\n * Render a JSX string into the scene graph.\n * Works in both Node/Bun and the browser.\n */\nasync function renderJSX<Artwork>(\n services: DesignJSXServices<Artwork>,\n graph: SceneGraph,\n jsxString: string,\n options?: RenderJSXOptions\n): Promise<RenderResult[]> {\n const helperWarnings: string[] = []\n const Component = buildComponent(jsxString, helperWarnings)\n const element = React.createElement(Component, null)\n const tree = resolveToTree(element)\n\n if (!tree) {\n throw new Error('JSX must return a Figma element (Frame, Text, etc)')\n }\n\n const results = await renderRoots(services, graph, tree, options)\n // After rendering, so an instance's component set drawn in the same JSX names its variants.\n // A helper called in a loop reports each ignored option once.\n // Prop warnings come first, then the render's own, such as a connector end naming no layer.\n const warnings = uniq([\n ...unsupportedPropWarnings(graph, tree),\n ...helperWarnings,\n ...(results[0].warnings ?? [])\n ])\n if (warnings.length > 0) results[0].warnings = warnings\n return results\n}\n\n/**\n * A Design JSX renderer bound to an engine. Rendering needs `services` for icons, inline\n * SVG, and layout; Pairdraw's engine provides them through `@pairdraw/core/design-jsx`.\n */\nexport function createDesignJSXRenderer<Artwork>(services: DesignJSXServices<Artwork>) {\n return {\n /** Render a Design JSX string into the graph, one result per top-level element. */\n renderJSX: (graph: SceneGraph, jsxString: string, options?: RenderJSXOptions) =>\n renderJSX(services, graph, jsxString, options),\n /** Render a tree built with the element functions into the graph. */\n renderTree: (graph: SceneGraph, tree: TreeNode, options?: RenderJSXOptions) =>\n renderTree(services, graph, tree, options),\n /** Render every top-level element of a tree at once, one result per root. */\n renderRoots: (graph: SceneGraph, tree: TreeNode, options?: RenderJSXOptions) =>\n renderRoots(services, graph, tree, options)\n }\n}\n\nexport type DesignJSXRenderer = ReturnType<typeof createDesignJSXRenderer>\n","import { omit } from 'es-toolkit'\n\nimport type { NodeType, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { createDefaultNode } from '@pairdraw/scene-graph/node-defaults'\n\nimport type { JSXAttributeSource } from './export'\nimport * as React from './mini-react'\nimport { buildComponent } from './render'\nimport { elementOverrides } from './renderer'\nimport { resolveToTree } from './tree'\n\nexport interface JSXNodeFields {\n /** Every field the attributes describe, with defaults for the ones they leave out. */\n fields: Partial<SceneNode>\n /** Variable IDs by bound field, such as `fills/0/color`. */\n bindings: Record<string, string>\n}\n\n/**\n * The node state a `nodeType` node under `parentId` gets from `attributes`, as rendering\n * would set it, without creating a node. Diffing two results gives the fields an attribute\n * change moves, so an update leaves state that JSX does not describe untouched.\n */\nexport function jsxNodeFields(\n graph: SceneGraph,\n nodeType: NodeType,\n attributes: JSXAttributeSource[],\n parentId: string\n): JSXNodeFields {\n const source = `<Frame ${attributes.map((attribute) => attribute.source).join(' ')} />`\n const tree = resolveToTree(React.createElement(buildComponent(source), null))\n if (!tree) throw new Error(`Invalid JSX attributes: ${source}`)\n const { overrides, bindings } = elementOverrides(graph, nodeType, tree, parentId)\n const defaults = omit(\n createDefaultNode(() => '', nodeType),\n ['id', 'parentId', 'childIds']\n )\n return { fields: { ...defaults, ...overrides }, bindings }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,SAAgB,cACd,MACA,OACA,GAAG,UACW;CACd,MAAM,eAAe,SAAS,KAAK;CACnC,OAAO;EACL;EACA,OAAO;GACL,GAAG;GACH,UAAU,aAAa,SAAS,IAAI,eAAe,KAAA;EACrD;CACF;AACF;;;ACTA,MAAM,eAAe,EAAE,OAAO;CAC5B,GAAG,EAAE,SAAS,kBAAkB;CAChC,GAAG,EAAE,SAAS,kBAAkB;AAClC,CAAC;AAED,MAAM,eAAe;CACnB,QAAQ;CACR,QAAQ,EAAE,SAAS,YAAY;CAC/B,QAAQ,EAAE,SAAS,oBAAoB,CAAC;CACxC,SAAS,EAAE,SAAS,EAAE,QAAQ,GAAG,IAAI;CACrC,WAAW,EAAE,SAAS,SAAS,UAAU,CAAC;CAC1C,sBAAsB,EAAE,SAAS,EAAE,QAAQ,CAAC;AAC9C;AAKA,SAAS,mBAAmB,MAAqC;CAC/D,OAAO,EAAE,OAAO;EACd,MAAM,EAAE,QAAQ,IAAI;EACpB,OAAO;EACP,GAAG;CACL,CAAC;AACH;AAEA,SAAS,iBAAiB,MAAmC;CAC3D,OAAO,EAAE,OAAO;EACd,MAAM,EAAE,QAAQ,IAAI;EACpB,OAAO,EAAE,SAAS,WAAW;EAC7B,GAAG;CACL,CAAC;AACH;AAEA,MAAM,qBAAqB,EA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