@pairdraw/design-jsx 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/behaviours/elements.js +2 -1
- package/dist/chunks/behaviours/elements.js.map +1 -1
- package/dist/chunks/effects.js +54 -2
- package/dist/chunks/effects.js.map +1 -1
- package/dist/chunks/elements.js +37 -5
- package/dist/chunks/elements.js.map +1 -1
- package/dist/chunks/export/index.js +22 -2
- package/dist/chunks/export/index.js.map +1 -1
- package/dist/chunks/fields.js +111 -29
- package/dist/chunks/fields.js.map +1 -1
- package/dist/chunks/index.js +3 -1
- package/dist/chunks/index.js.map +1 -1
- package/dist/index.d.ts +33 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/package.json +3 -3
- package/src/behaviours/index.ts +3 -0
- package/src/effects.ts +81 -2
- package/src/elements.ts +1 -1
- package/src/export/index.ts +2 -0
- package/src/export/paint.ts +50 -9
- package/src/export/props.ts +1 -1
- package/src/helpers.ts +26 -1
- package/src/index.ts +6 -1
- package/src/order.ts +111 -0
- package/src/reconcile.ts +2 -0
- package/src/reference/authoring.md +1 -1
- package/src/render.ts +4 -1
- package/src/renderer.ts +54 -25
- package/src/types.ts +3 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { behaviourFromSpec, withBehaviour } from "@pairdraw/scene-graph/behaviours";
|
|
1
|
+
import { behaviourFromSpec, validateChoiceValues, withBehaviour } from "@pairdraw/scene-graph/behaviours";
|
|
2
2
|
import { createComponentPropertyId } from "@pairdraw/scene-graph/components";
|
|
3
3
|
import { createSlotProperty } from "@pairdraw/scene-graph/slots";
|
|
4
4
|
function inlineFragments(children) {
|
|
@@ -289,6 +289,7 @@ function finishRoot(graph, scope, props) {
|
|
|
289
289
|
...behaviour.texts,
|
|
290
290
|
...Object.fromEntries([...scope.texts].map(([valueId, id]) => [valueId, { propertyId: id }]))
|
|
291
291
|
};
|
|
292
|
+
validateChoiceValues(graph, owner, behaviour);
|
|
292
293
|
graph.updateNode(owner.id, { pluginData: withBehaviour(owner, behaviour) });
|
|
293
294
|
}
|
|
294
295
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.js","names":[],"sources":["../../../src/tree.ts","../../../src/behaviours/index.ts","../../../src/behaviours/elements.ts"],"sourcesContent":["import type { Effect, Fill } from '@pairdraw/scene-graph'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { ComponentProperty } from './component-properties'\nimport type { DesignMode, DesignVariable } from './variables'\n\nexport interface TreeNode {\n type: string\n props: Record<string, unknown>\n children: (TreeNode | string)[]\n /** Where the element was written, when the source is known. */\n source?: { line: number }\n}\n\n/** A fragment (`<>…</>`) groups siblings without creating a node of its own. */\nexport const FRAGMENT = ''\n\nfunction inlineFragments(children: (TreeNode | string)[]): (TreeNode | string)[] {\n return children.flatMap((child) =>\n typeof child !== 'string' && child.type === FRAGMENT ? child.children : [child]\n )\n}\n\n/**\n * The text an element holds as children, such as a sticky note's body or a connector's label.\n * Elements among its children are not text and are skipped.\n */\nexport function plainTextOf(tree: TreeNode): string {\n return tree.children.filter((child): child is string => typeof child === 'string').join('')\n}\n\nexport function isTreeNode(x: unknown): x is TreeNode {\n if (x === null || typeof x !== 'object') return false\n return (\n 'type' in x &&\n typeof x.type === 'string' &&\n 'props' in x &&\n 'children' in x &&\n Array.isArray(x.children)\n )\n}\n\ntype FunctionComponent = (props: Record<string, unknown>) => unknown\n\ninterface ReactElement {\n type: unknown\n props: Record<string, unknown>\n}\n\nfunction isReactElement(x: unknown): x is ReactElement {\n return x !== null && typeof x === 'object' && 'type' in x && 'props' in x\n}\n\n/**\n * Resolve any element-like value (ReactElement, TreeNode, function component)\n * into a TreeNode. Handles recursive function components up to depth 100.\n */\nexport function resolveToTree(element: unknown, depth = 0): TreeNode | null {\n if (depth > 100) throw new Error('Component resolution depth exceeded')\n if (element == null) return null\n if (isTreeNode(element)) return element\n if (!isReactElement(element)) return null\n\n if (typeof element.type === 'function') {\n const component = element.type as FunctionComponent\n return resolveToTree(component(element.props), depth + 1)\n }\n\n if (typeof element.type === 'string') {\n const children: (TreeNode | string)[] = []\n const elChildren = element.props.children\n if (elChildren != null) {\n const childArray = Array.isArray(elChildren) ? elChildren : [elChildren]\n for (const child of childArray.flat()) {\n if (child == null) continue\n if (typeof child === 'string' || typeof child === 'number') {\n children.push(String(child))\n } else {\n const resolved = resolveToTree(child, depth + 1)\n if (resolved) children.push(resolved)\n }\n }\n }\n const { children: _, ...props } = element.props\n return { type: element.type, props, children: inlineFragments(children) }\n }\n\n return null\n}\n\nfunction resolveChild(child: unknown): TreeNode | string | null {\n if (child == null) return null\n if (typeof child === 'string' || typeof child === 'number') return String(child)\n return resolveToTree(child)\n}\n\nexport function node(\n type: string,\n props: { children?: unknown; [key: string]: unknown }\n): TreeNode {\n const { children, ...rest } = props\n const processed = [children]\n .flat(Infinity)\n .map(resolveChild)\n .filter((c): c is TreeNode | string => c !== null)\n return { type, props: rest, children: inlineFragments(processed) }\n}\n\nexport type PaintProp = string | Color | Fill | DesignVariable\n\nexport type StyleProps = {\n flex?: 'row' | 'col' | 'column'\n flow?: 'auto' | 'ltr' | 'rtl'\n dir?: 'auto' | 'ltr' | 'rtl'\n gap?: number | DesignVariable\n wrap?: boolean\n rowGap?: number | DesignVariable\n columnGap?: number | DesignVariable\n justify?: 'start' | 'end' | 'center' | 'between' | 'around'\n justifyContent?: 'start' | 'end' | 'center' | 'between' | 'around'\n items?: 'start' | 'end' | 'center' | 'stretch' | 'baseline'\n align?: 'start' | 'end' | 'center' | 'stretch' | 'baseline'\n alignItems?: 'start' | 'end' | 'center' | 'stretch' | 'baseline'\n grow?: number\n\n w?: number | 'fill' | 'hug' | DesignVariable\n h?: number | 'fill' | 'hug' | DesignVariable\n minW?: number\n maxW?: number\n minH?: number\n maxH?: number\n\n x?: number\n y?: number\n\n p?: number | DesignVariable\n px?: number | DesignVariable\n py?: number | DesignVariable\n pt?: number | DesignVariable\n pr?: number | DesignVariable\n pb?: number | DesignVariable\n pl?: number | DesignVariable\n\n bg?: PaintProp\n fill?: PaintProp\n fills?: PaintProp[]\n stroke?: PaintProp\n strokeWidth?: number | DesignVariable\n strokeAlign?: 'inside' | 'outside' | 'center'\n strokeDash?: number[] | boolean\n dashPattern?: number[]\n rounded?: number | DesignVariable\n roundedTL?: number | DesignVariable\n roundedTR?: number | DesignVariable\n roundedBL?: number | DesignVariable\n roundedBR?: number | DesignVariable\n cornerSmoothing?: number\n opacity?: number | DesignVariable\n blendMode?: string\n mask?: boolean | 'alpha' | 'luminance' | 'vector'\n rotate?: number\n rotation?: number\n /** Reflects the layer across its vertical centre line, before it turns. */\n flipX?: boolean\n /** Reflects the layer across its horizontal centre line, before it turns. */\n flipY?: boolean\n overflow?: 'hidden' | 'visible'\n shadow?: string\n blur?: number\n effects?: Effect[]\n\n size?: number | DesignVariable\n fontSize?: number | DesignVariable\n /** Pixels, or a percent of the font size such as `'150%'`. */\n lineHeight?: number | `${number}%` | 'auto' | DesignVariable\n /** Pixels, or a percent of the font size such as `'5%'`. */\n letterSpacing?: number | `${number}%` | DesignVariable\n /** OpenType features on or off by tag, as CSS's `font-feature-settings`: `{ tnum: true }`. */\n fontFeatures?: Record<string, boolean>\n /** Variable-font axis values by tag, as CSS's `font-variation-settings`: `{ wght: 650 }`. */\n fontVariations?: Record<string, number>\n /** The language the text is in, as a BCP 47 tag such as `de` or `sr-Latn`. */\n lang?: string | null\n /**\n * Whether a variable font's optical size follows the font size (`auto`, the default) or takes\n * the `opsz` in `fontVariations` (`none`), as CSS's `font-optical-sizing`.\n */\n fontOpticalSizing?: 'auto' | 'none'\n font?: string\n fontFamily?: string\n weight?: number | 'bold' | 'medium' | 'normal'\n fontWeight?: number | 'bold' | 'medium' | 'normal'\n color?: PaintProp\n text?: string | ComponentProperty<string>\n characters?: string\n textAlign?: 'left' | 'center' | 'right' | 'justified'\n textAlignHorizontal?: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'\n textHorizontalAlignment?: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'\n textAlignVertical?: 'TOP' | 'CENTER' | 'BOTTOM'\n textVerticalAlignment?: 'TOP' | 'CENTER' | 'BOTTOM'\n textAutoResize?: 'none' | 'width' | 'height'\n}\n\ntype NodeProps = StyleProps & {\n name?: string\n key?: string | number\n children?: unknown\n bind?: Record<string, unknown>\n visible?: boolean | ComponentProperty<boolean>\n /** The modes the layer shows collections in, as the Appearance panel sets them. */\n mode?: DesignMode | DesignMode[]\n [key: string]: unknown\n}\n\nexport type BaseProps = NodeProps & { properties?: never }\n\n/** An `<Ellipse>`'s arc: angles in degrees, clockwise from three o'clock, and its hole. */\nexport type EllipseProps = {\n startAngle?: number\n endAngle?: number\n /** The hole as a share of the ellipse, from 0 (none) to 1. */\n innerRadius?: number\n}\n/** A `<Vector>`'s path, in SVG's syntax as `d` or as Figma's `vectorPaths`. */\nexport type VectorProps = {\n /** Path data as SVG writes it, filled under `fillRule`; an open subpath fills only without a stroke. */\n d?: string\n fillRule?: 'nonzero' | 'evenodd'\n /** Paths with their own winding rules, as export writes them; `NONE` draws an open path. */\n paths?: Array<{ windingRule: 'NONZERO' | 'EVENODD' | 'NONE'; data: string }>\n}\nexport type TextProps = BaseProps\n\n/** A `<Span>`'s props: the character styles of `<Text>`, under the same names. */\nexport type SpanProps = Pick<\n StyleProps,\n | 'size'\n | 'fontSize'\n | 'font'\n | 'fontFamily'\n | 'weight'\n | 'fontWeight'\n | 'color'\n | 'fill'\n | 'fills'\n | 'lineHeight'\n | 'letterSpacing'\n | 'fontFeatures'\n | 'fontVariations'\n | 'lang'\n> & {\n key?: string | number\n style?: Record<string, unknown>\n italic?: boolean\n textDecoration?: 'none' | 'underline' | 'strikethrough'\n textDecorationStyle?: 'solid' | 'dotted' | 'wavy'\n textDecorationColor?: string | Color | Fill\n textDecorationThickness?: number | 'auto'\n textUnderlineOffset?: number | 'auto'\n textDecorationSkipInk?: boolean\n children?: unknown\n}\n\n/** A `<Paragraph>`'s props: a list item at `level` 1–5, or a plain paragraph, and its spacing. */\nexport type ParagraphProps = {\n key?: string | number\n list?: 'ordered' | 'unordered'\n level?: number\n spacing?: number\n listSpacing?: number\n indent?: number\n children?: unknown\n}\n\nexport type ComponentProps = BaseProps\n\nexport type InstanceProps = NodeProps & {\n component?: string\n componentId?: string\n of?: string | ComponentProperty<string>\n /** Show the instance's own properties on instances of the component it is in, as Figma does. */\n exposed?: boolean\n /** Values by property ID or name, or an exposed nested instance's values by its name. */\n properties?: Record<string, string | boolean | number | Record<string, string | boolean | number>>\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n behaviourFromSpec,\n withBehaviour,\n type BehaviourKind,\n type BehaviourSpec\n} from '@pairdraw/scene-graph/behaviours'\nimport { createComponentPropertyId } from '@pairdraw/scene-graph/components'\nimport { createSlotProperty } from '@pairdraw/scene-graph/slots'\n\nimport { node, type TreeNode } from '../tree'\n\n/** What a Reka UI element is to the component it builds. */\nexport type RekaRole =\n | { role: 'root'; kind: BehaviourKind }\n /** A Reka subcomponent drawn by a slot of the component, such as a switch's thumb. */\n | { role: 'part'; part: string }\n /** One of a slot's repeated parts, such as a tab trigger in the tab list. */\n | { role: 'repeat'; container: string }\n /** The text layer a text value shows, which becomes the field's text property. */\n | { role: 'input'; valueId: string }\n /** A Reka wrapper with no state of its own, drawn as a plain frame. */\n | { role: 'frame' }\n\nconst root = (kind: BehaviourKind): RekaRole => ({ role: 'root', kind })\nconst part = (id: string): RekaRole => ({ role: 'part', part: id })\nconst repeat = (container: string): RekaRole => ({ role: 'repeat', container })\nconst input = (valueId: string): RekaRole => ({ role: 'input', valueId })\n\n/**\n * Design JSX's Reka UI elements, by namespace and part, after Reka's own anatomy: `Switch.Root`\n * is a main component that behaves as a switch and `Switch.Thumb` its thumb slot. A group's\n * `Item` is the component of its items when written on its own, and an item when it names one\n * with `of`, as an `Instance` does.\n */\nconst REKA_PARTS = {\n Button: { Root: root('button') },\n Toggle: { Root: root('toggle') },\n Switch: { Root: root('switch'), Thumb: part('thumb') },\n Checkbox: { Root: root('checkbox'), Indicator: part('indicator') },\n RadioGroup: { Root: root('radioGroup'), Item: root('radio'), Indicator: part('indicator') },\n ToggleGroup: { Root: root('toggleGroup'), Item: root('toggle') },\n Slider: {\n Root: root('slider'),\n Track: part('track'),\n Range: part('range'),\n Thumb: part('thumb')\n },\n Progress: { Root: root('progress'), Track: part('track'), Indicator: part('indicator') },\n Tabs: {\n Root: root('tabs'),\n List: part('list'),\n Trigger: repeat('list'),\n Content: repeat('panels')\n },\n Collapsible: { Root: root('collapsible'), Trigger: part('trigger'), Content: part('content') },\n Accordion: {\n Root: root('accordion'),\n Item: root('collapsible'),\n Header: { role: 'frame' },\n Trigger: part('trigger'),\n Content: part('content')\n },\n NumberField: {\n Root: root('numberField'),\n Input: input('text'),\n Increment: part('increment'),\n Decrement: part('decrement')\n },\n TextField: { Root: root('textField'), Input: input('value') },\n Textarea: { Root: root('textarea'), Input: input('value') }\n} as const satisfies Readonly<Record<string, Readonly<Record<string, RekaRole>>>>\n\n/** Each Reka namespace and its parts, as typed elements are built from them. */\nexport type RekaNamespaces = typeof REKA_PARTS\n\n/** The same elements, looked up by any element name, as parsing and export do. */\nexport const REKA_ELEMENTS: Readonly<Record<string, Readonly<Record<string, RekaRole>>>> =\n REKA_PARTS\n\n/** The container a repeated part goes in when written directly under its root. */\nconst CONTAINER_NAMES: Record<string, string> = { list: 'List', panels: 'Panels', items: 'Items' }\n\n/** The role of a Reka element type such as `Switch.Thumb`, or undefined for other elements. */\nexport function rekaRole(type: string): RekaRole | undefined {\n const dot = type.indexOf('.')\n if (dot === -1) return undefined\n const namespace = REKA_ELEMENTS[type.slice(0, dot)] as Record<string, RekaRole> | undefined\n return namespace?.[type.slice(dot + 1)]\n}\n\n/** The element type for a part container that JSX leaves implicit. */\nconst containerType = (container: string) => `reka-container:${container}`\n\nexport function containerPart(type: string): string | undefined {\n return type.startsWith('reka-container:') ? type.slice('reka-container:'.length) : undefined\n}\n\n/** Whether an element names an existing component, as an item of a group does. */\nexport function namesComponent(props: Record<string, unknown>): boolean {\n return props.of !== undefined || props.component !== undefined || props.componentId !== undefined\n}\n\nconst GROUPS = new Set<BehaviourKind>(['radioGroup', 'toggleGroup', 'accordion'])\n\n/** The container slot a child written directly under a root belongs in, if any. */\nfunction containerOf(child: TreeNode, kind: BehaviourKind): string | undefined {\n const role = rekaRole(child.type)\n if (role?.role === 'repeat') return role.container\n if (GROUPS.has(kind) && role?.role === 'root' && namesComponent(child.props)) return 'items'\n return undefined\n}\n\n/**\n * A root's children with repeated parts and group items that are written directly under it\n * wrapped in their container slot, as the behaviour binds them: tab panels in Panels, a group's\n * items in Items. Containers the JSX writes itself are kept.\n */\nexport function wrapRepeatedParts(tree: TreeNode, kind: BehaviourKind): TreeNode['children'] {\n const result: TreeNode['children'] = []\n let open: TreeNode | null = null\n for (const child of tree.children) {\n const container = typeof child === 'string' ? undefined : containerOf(child, kind)\n if (!container || typeof child === 'string') {\n open = null\n result.push(child)\n continue\n }\n if (open?.type !== containerType(container)) {\n open = node(containerType(container), {\n name: CONTAINER_NAMES[container] ?? container,\n flex: kind === 'toggleGroup' ? 'row' : 'col',\n gap: kind === 'toggleGroup' ? 4 : 8\n })\n result.push(open)\n }\n open.children.push(child)\n }\n return result\n}\n\n/** What a root collects from its parts while they render. */\nexport interface RekaScope {\n kind: BehaviourKind\n ownerId: string\n /** Slot property ids by part, shared by every variant of a set. */\n slots: Map<string, string>\n /** Text property ids by value, defined once on the root. */\n texts: Map<string, string>\n}\n\nexport function createScope(kind: BehaviourKind, ownerId: string): RekaScope {\n return { kind, ownerId, slots: new Map(), texts: new Map() }\n}\n\n/** Make a rendered part frame its part's slot, with the id the part has in this component. */\nexport function bindPart(graph: SceneGraph, scope: RekaScope, frame: SceneNode, partId: string) {\n const id = scope.slots.get(partId) ?? createComponentPropertyId()\n if (!createSlotProperty(graph, frame.id, id))\n throw new Error(`<${partId}> must be inside a main component`)\n scope.slots.set(partId, id)\n}\n\n/** Make a rendered text layer show the value's text property, defined on the root. */\nexport function bindInput(\n graph: SceneGraph,\n scope: RekaScope,\n text: SceneNode,\n valueId: string,\n propertyName: string\n) {\n let id = scope.texts.get(valueId)\n if (!id) {\n id = createComponentPropertyId()\n scope.texts.set(valueId, id)\n const owner = graph.getNode(scope.ownerId)\n graph.updateNode(scope.ownerId, {\n componentPropertyDefinitions: [\n ...(owner?.componentPropertyDefinitions ?? []),\n { id, name: propertyName, type: 'TEXT', defaultValue: text.text }\n ]\n })\n }\n graph.updateNode(text.id, {\n componentPropertyReferences: [\n ...text.componentPropertyReferences,\n { propertyId: id, field: 'TEXT' }\n ]\n })\n}\n\n/** Root props that describe the behaviour rather than the drawing. */\nexport const BEHAVIOUR_PROPS = [\n 'modelValue',\n 'open',\n 'disabled',\n 'filled',\n 'states',\n 'min',\n 'max',\n 'step',\n 'defaultValue'\n] as const\n\n/** A value bound to a component property by name; a variant property may name its on and off. */\nexport type BindingProp = string | { property: string; on?: string; off?: string }\n\nfunction isBinding(value: unknown): value is BindingProp {\n return (\n typeof value === 'string' ||\n (typeof value === 'object' &&\n value !== null &&\n 'property' in value &&\n typeof value.property === 'string')\n )\n}\n\n/** The spec a root's props give: values by property name, a range, and states. */\nfunction rootSpec(kind: BehaviourKind, props: Record<string, unknown>): BehaviourSpec {\n const values: NonNullable<BehaviourSpec['values']> = {}\n const main = kind === 'collapsible' ? props.open : props.modelValue\n if (isBinding(main)) values[kind === 'collapsible' ? 'open' : 'value'] = main\n if (isBinding(props.disabled)) values.disabled = props.disabled\n if (isBinding(props.filled)) values.filled = props.filled\n const range = Object.fromEntries(\n (['min', 'max', 'step'] as const).flatMap((key) =>\n typeof props[key] === 'number' ? [[key, props[key]]] : []\n )\n )\n if (typeof props.defaultValue === 'number') range.default = props.defaultValue\n const spec: BehaviourSpec = { kind }\n if (Object.keys(values).length) spec.values = values\n if (Object.keys(range).length) spec.numbers = { value: range }\n if (typeof props.states === 'string') spec.states = props.states\n return spec\n}\n\n/** Store the behaviour a rendered root describes, with the slots and texts its parts made. */\nexport function finishRoot(\n graph: SceneGraph,\n scope: RekaScope,\n props: Record<string, unknown>\n): void {\n const owner = graph.getNode(scope.ownerId)\n if (!owner) return\n const behaviour = behaviourFromSpec(graph, owner, rootSpec(scope.kind, props))\n behaviour.parts = { ...behaviour.parts, ...Object.fromEntries(scope.slots) }\n behaviour.texts = {\n ...behaviour.texts,\n ...Object.fromEntries([...scope.texts].map(([valueId, id]) => [valueId, { propertyId: id }]))\n }\n graph.updateNode(owner.id, { pluginData: withBehaviour(owner, behaviour) })\n}\n","import { node, type BaseProps, type TreeNode } from '../tree'\nimport { REKA_ELEMENTS, type BindingProp, type RekaNamespaces } from './index'\n\n/** Props of a Reka element: a frame's, plus the behaviour a root binds and a group item's component. */\nexport interface RekaProps extends BaseProps {\n modelValue?: BindingProp\n open?: BindingProp\n disabled?: BindingProp\n filled?: BindingProp\n /** The variant property whose values draw rest, hover, pressed, focus, and disabled. */\n states?: string\n min?: number\n max?: number\n step?: number\n defaultValue?: number\n /** For a group's item: the component or set it is an instance of. */\n of?: string\n}\n\ntype Child = TreeNode | string\nexport type RekaElement = (props?: RekaProps, ...children: Child[]) => TreeNode\n\n/** One Reka namespace as element functions, such as `Switch.Root` and `Switch.Thumb`. */\nfunction namespace<N extends keyof RekaNamespaces>(name: N) {\n const element =\n (part: string): RekaElement =>\n (props = {}, ...children) =>\n node(`${name}.${part}`, children.length > 0 ? { ...props, children } : props)\n return Object.fromEntries(\n Object.keys(REKA_ELEMENTS[name]).map((part) => [part, element(part)])\n ) as { [P in keyof RekaNamespaces[N]]: RekaElement }\n}\n\nexport const Button = namespace('Button')\nexport const Toggle = namespace('Toggle')\nexport const Switch = namespace('Switch')\nexport const Checkbox = namespace('Checkbox')\nexport const RadioGroup = namespace('RadioGroup')\nexport const ToggleGroup = namespace('ToggleGroup')\nexport const Slider = namespace('Slider')\nexport const Progress = namespace('Progress')\nexport const Tabs = namespace('Tabs')\nexport const Collapsible = namespace('Collapsible')\nexport const Accordion = namespace('Accordion')\nexport const NumberField = namespace('NumberField')\nexport const TextField = namespace('TextField')\nexport const Textarea = namespace('Textarea')\n"],"mappings":";;;AAiBA,SAAS,gBAAgB,UAAwD;CAC/E,OAAO,SAAS,SAAS,UACvB,OAAO,UAAU,YAAY,MAAM,SAAA,KAAoB,MAAM,WAAW,CAAC,KAAK,CAChF;AACF;;;;;AAMA,SAAgB,YAAY,MAAwB;CAClD,OAAO,KAAK,SAAS,QAAQ,UAA2B,OAAO,UAAU,QAAQ,CAAC,CAAC,KAAK,EAAE;AAC5F;AAEA,SAAgB,WAAW,GAA2B;CACpD,IAAI,MAAM,QAAQ,OAAO,MAAM,UAAU,OAAO;CAChD,OACE,UAAU,KACV,OAAO,EAAE,SAAS,YAClB,WAAW,KACX,cAAc,KACd,MAAM,QAAQ,EAAE,QAAQ;AAE5B;AASA,SAAS,eAAe,GAA+B;CACrD,OAAO,MAAM,QAAQ,OAAO,MAAM,YAAY,UAAU,KAAK,WAAW;AAC1E;;;;;AAMA,SAAgB,cAAc,SAAkB,QAAQ,GAAoB;CAC1E,IAAI,QAAQ,KAAK,MAAM,IAAI,MAAM,qCAAqC;CACtE,IAAI,WAAW,MAAM,OAAO;CAC5B,IAAI,WAAW,OAAO,GAAG,OAAO;CAChC,IAAI,CAAC,eAAe,OAAO,GAAG,OAAO;CAErC,IAAI,OAAO,QAAQ,SAAS,YAAY;EACtC,MAAM,YAAY,QAAQ;EAC1B,OAAO,cAAc,UAAU,QAAQ,KAAK,GAAG,QAAQ,CAAC;CAC1D;CAEA,IAAI,OAAO,QAAQ,SAAS,UAAU;EACpC,MAAM,WAAkC,CAAC;EACzC,MAAM,aAAa,QAAQ,MAAM;EACjC,IAAI,cAAc,MAAM;GACtB,MAAM,aAAa,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,UAAU;GACvE,KA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;AACxC,MAAa,SAAS,UAAU,QAAQ;AACxC,MAAa,SAAS,UAAU,QAAQ;AACxC,MAAa,WAAW,UAAU,UAAU;AAC5C,MAAa,aAAa,UAAU,YAAY;AAChD,MAAa,cAAc,UAAU,aAAa;AAClD,MAAa,SAAS,UAAU,QAAQ;AACxC,MAAa,WAAW,UAAU,UAAU;AAC5C,MAAa,OAAO,UAAU,MAAM;AACpC,MAAa,cAAc,UAAU,aAAa;AAClD,MAAa,YAAY,UAAU,WAAW;AAC9C,MAAa,cAAc,UAAU,aAAa;AAClD,MAAa,YAAY,UAAU,WAAW;AAC9C,MAAa,WAAW,UAAU,UAAU"}
|
|
1
|
+
{"version":3,"file":"elements.js","names":[],"sources":["../../../src/tree.ts","../../../src/behaviours/index.ts","../../../src/behaviours/elements.ts"],"sourcesContent":["import type { Effect, Fill } from '@pairdraw/scene-graph'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { ComponentProperty } from './component-properties'\nimport type { DesignMode, DesignVariable } from './variables'\n\nexport interface TreeNode {\n type: string\n props: Record<string, unknown>\n children: (TreeNode | string)[]\n /** Where the element was written, when the source is known. */\n source?: { line: number }\n}\n\n/** A fragment (`<>…</>`) groups siblings without creating a node of its own. */\nexport const FRAGMENT = ''\n\nfunction inlineFragments(children: (TreeNode | string)[]): (TreeNode | string)[] {\n return children.flatMap((child) =>\n typeof child !== 'string' && child.type === FRAGMENT ? child.children : [child]\n )\n}\n\n/**\n * The text an element holds as children, such as a sticky note's body or a connector's label.\n * Elements among its children are not text and are skipped.\n */\nexport function plainTextOf(tree: TreeNode): string {\n return tree.children.filter((child): child is string => typeof child === 'string').join('')\n}\n\nexport function isTreeNode(x: unknown): x is TreeNode {\n if (x === null || typeof x !== 'object') return false\n return (\n 'type' in x &&\n typeof x.type === 'string' &&\n 'props' in x &&\n 'children' in x &&\n Array.isArray(x.children)\n )\n}\n\ntype FunctionComponent = (props: Record<string, unknown>) => unknown\n\ninterface ReactElement {\n type: unknown\n props: Record<string, unknown>\n}\n\nfunction isReactElement(x: unknown): x is ReactElement {\n return x !== null && typeof x === 'object' && 'type' in x && 'props' in x\n}\n\n/**\n * Resolve any element-like value (ReactElement, TreeNode, function component)\n * into a TreeNode. Handles recursive function components up to depth 100.\n */\nexport function resolveToTree(element: unknown, depth = 0): TreeNode | null {\n if (depth > 100) throw new Error('Component resolution depth exceeded')\n if (element == null) return null\n if (isTreeNode(element)) return element\n if (!isReactElement(element)) return null\n\n if (typeof element.type === 'function') {\n const component = element.type as FunctionComponent\n return resolveToTree(component(element.props), depth + 1)\n }\n\n if (typeof element.type === 'string') {\n const children: (TreeNode | string)[] = []\n const elChildren = element.props.children\n if (elChildren != null) {\n const childArray = Array.isArray(elChildren) ? elChildren : [elChildren]\n for (const child of childArray.flat()) {\n if (child == null) continue\n if (typeof child === 'string' || typeof child === 'number') {\n children.push(String(child))\n } else {\n const resolved = resolveToTree(child, depth + 1)\n if (resolved) children.push(resolved)\n }\n }\n }\n const { children: _, ...props } = element.props\n return { type: element.type, props, children: inlineFragments(children) }\n }\n\n return null\n}\n\nfunction resolveChild(child: unknown): TreeNode | string | null {\n if (child == null) return null\n if (typeof child === 'string' || typeof child === 'number') return String(child)\n return resolveToTree(child)\n}\n\nexport function node(\n type: string,\n props: { children?: unknown; [key: string]: unknown }\n): TreeNode {\n const { children, ...rest } = props\n const processed = [children]\n .flat(Infinity)\n .map(resolveChild)\n .filter((c): c is TreeNode | string => c !== null)\n return { type, props: rest, children: inlineFragments(processed) }\n}\n\nexport type PaintProp = string | Color | Fill | DesignVariable\n\nexport type StyleProps = {\n flex?: 'row' | 'col' | 'column'\n flow?: 'auto' | 'ltr' | 'rtl'\n dir?: 'auto' | 'ltr' | 'rtl'\n gap?: number | DesignVariable\n wrap?: boolean\n rowGap?: number | DesignVariable\n columnGap?: number | DesignVariable\n justify?: 'start' | 'end' | 'center' | 'between' | 'around'\n justifyContent?: 'start' | 'end' | 'center' | 'between' | 'around'\n items?: 'start' | 'end' | 'center' | 'stretch' | 'baseline'\n align?: 'start' | 'end' | 'center' | 'stretch' | 'baseline'\n alignItems?: 'start' | 'end' | 'center' | 'stretch' | 'baseline'\n grow?: number\n\n w?: number | 'fill' | 'hug' | DesignVariable\n h?: number | 'fill' | 'hug' | DesignVariable\n minW?: number\n maxW?: number\n minH?: number\n maxH?: number\n\n x?: number\n y?: number\n\n p?: number | DesignVariable\n px?: number | DesignVariable\n py?: number | DesignVariable\n pt?: number | DesignVariable\n pr?: number | DesignVariable\n pb?: number | DesignVariable\n pl?: number | DesignVariable\n\n bg?: PaintProp\n fill?: PaintProp\n fills?: PaintProp[]\n stroke?: PaintProp\n strokeWidth?: number | DesignVariable\n strokeAlign?: 'inside' | 'outside' | 'center'\n strokeDash?: number[] | boolean\n dashPattern?: number[]\n rounded?: number | DesignVariable\n roundedTL?: number | DesignVariable\n roundedTR?: number | DesignVariable\n roundedBL?: number | DesignVariable\n roundedBR?: number | DesignVariable\n cornerSmoothing?: number\n opacity?: number | DesignVariable\n blendMode?: string\n mask?: boolean | 'alpha' | 'luminance' | 'vector'\n rotate?: number\n rotation?: number\n /** Reflects the layer across its vertical centre line, before it turns. */\n flipX?: boolean\n /** Reflects the layer across its horizontal centre line, before it turns. */\n flipY?: boolean\n overflow?: 'hidden' | 'visible'\n shadow?: string\n blur?: number\n effects?: Effect[]\n\n size?: number | DesignVariable\n fontSize?: number | DesignVariable\n /** Pixels, or a percent of the font size such as `'150%'`. */\n lineHeight?: number | `${number}%` | 'auto' | DesignVariable\n /** Pixels, or a percent of the font size such as `'5%'`. */\n letterSpacing?: number | `${number}%` | DesignVariable\n /** OpenType features on or off by tag, as CSS's `font-feature-settings`: `{ tnum: true }`. */\n fontFeatures?: Record<string, boolean>\n /** Variable-font axis values by tag, as CSS's `font-variation-settings`: `{ wght: 650 }`. */\n fontVariations?: Record<string, number>\n /** The language the text is in, as a BCP 47 tag such as `de` or `sr-Latn`. */\n lang?: string | null\n /**\n * Whether a variable font's optical size follows the font size (`auto`, the default) or takes\n * the `opsz` in `fontVariations` (`none`), as CSS's `font-optical-sizing`.\n */\n fontOpticalSizing?: 'auto' | 'none'\n font?: string\n fontFamily?: string\n weight?: number | 'bold' | 'medium' | 'normal'\n fontWeight?: number | 'bold' | 'medium' | 'normal'\n color?: PaintProp\n text?: string | ComponentProperty<string>\n characters?: string\n textAlign?: 'left' | 'center' | 'right' | 'justified'\n textAlignHorizontal?: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'\n textHorizontalAlignment?: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'\n textAlignVertical?: 'TOP' | 'CENTER' | 'BOTTOM'\n textVerticalAlignment?: 'TOP' | 'CENTER' | 'BOTTOM'\n textAutoResize?: 'none' | 'width' | 'height'\n}\n\ntype NodeProps = StyleProps & {\n name?: string\n key?: string | number\n children?: unknown\n bind?: Record<string, unknown>\n visible?: boolean | ComponentProperty<boolean>\n /** The modes the layer shows collections in, as the Appearance panel sets them. */\n mode?: DesignMode | DesignMode[]\n [key: string]: unknown\n}\n\nexport type BaseProps = NodeProps & { properties?: never }\n\n/** An `<Ellipse>`'s arc: angles in degrees, clockwise from three o'clock, and its hole. */\nexport type EllipseProps = {\n startAngle?: number\n endAngle?: number\n /** The hole as a share of the ellipse, from 0 (none) to 1. */\n innerRadius?: number\n}\n/** A `<Vector>`'s path, in SVG's syntax as `d` or as Figma's `vectorPaths`. */\nexport type VectorProps = {\n /** Path data as SVG writes it, filled under `fillRule`; an open subpath fills only without a stroke. */\n d?: string\n fillRule?: 'nonzero' | 'evenodd'\n /** Paths with their own winding rules, as export writes them; `NONE` draws an open path. */\n paths?: Array<{ windingRule: 'NONZERO' | 'EVENODD' | 'NONE'; data: string }>\n}\nexport type TextProps = BaseProps\n\n/** A `<Span>`'s props: the character styles of `<Text>`, under the same names. */\nexport type SpanProps = Pick<\n StyleProps,\n | 'size'\n | 'fontSize'\n | 'font'\n | 'fontFamily'\n | 'weight'\n | 'fontWeight'\n | 'color'\n | 'fill'\n | 'fills'\n | 'lineHeight'\n | 'letterSpacing'\n | 'fontFeatures'\n | 'fontVariations'\n | 'lang'\n> & {\n key?: string | number\n style?: Record<string, unknown>\n italic?: boolean\n textDecoration?: 'none' | 'underline' | 'strikethrough'\n textDecorationStyle?: 'solid' | 'dotted' | 'wavy'\n textDecorationColor?: string | Color | Fill\n textDecorationThickness?: number | 'auto'\n textUnderlineOffset?: number | 'auto'\n textDecorationSkipInk?: boolean\n children?: unknown\n}\n\n/** A `<Paragraph>`'s props: a list item at `level` 1–5, or a plain paragraph, and its spacing. */\nexport type ParagraphProps = {\n key?: string | number\n list?: 'ordered' | 'unordered'\n level?: number\n spacing?: number\n listSpacing?: number\n indent?: number\n children?: unknown\n}\n\nexport type ComponentProps = BaseProps\n\nexport type InstanceProps = NodeProps & {\n component?: string\n componentId?: string\n of?: string | ComponentProperty<string>\n /** Show the instance's own properties on instances of the component it is in, as Figma does. */\n exposed?: boolean\n /** Values by property ID or name, or an exposed nested instance's values by its name. */\n properties?: Record<string, string | boolean | number | Record<string, string | boolean | number>>\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n behaviourFromSpec,\n validateChoiceValues,\n withBehaviour,\n type BehaviourKind,\n type BehaviourSpec\n} from '@pairdraw/scene-graph/behaviours'\nimport { createComponentPropertyId } from '@pairdraw/scene-graph/components'\nimport { createSlotProperty } from '@pairdraw/scene-graph/slots'\n\nimport { node, type TreeNode } from '../tree'\n\n/** What a Reka UI element is to the component it builds. */\nexport type RekaRole =\n | { role: 'root'; kind: BehaviourKind }\n /** A Reka subcomponent drawn by a slot of the component, such as a switch's thumb. */\n | { role: 'part'; part: string }\n /** One of a slot's repeated parts, such as a tab trigger in the tab list. */\n | { role: 'repeat'; container: string }\n /** The text layer a text value shows, which becomes the field's text property. */\n | { role: 'input'; valueId: string }\n /** A Reka wrapper with no state of its own, drawn as a plain frame. */\n | { role: 'frame' }\n\nconst root = (kind: BehaviourKind): RekaRole => ({ role: 'root', kind })\nconst part = (id: string): RekaRole => ({ role: 'part', part: id })\nconst repeat = (container: string): RekaRole => ({ role: 'repeat', container })\nconst input = (valueId: string): RekaRole => ({ role: 'input', valueId })\n\n/**\n * Design JSX's Reka UI elements, by namespace and part, after Reka's own anatomy: `Switch.Root`\n * is a main component that behaves as a switch and `Switch.Thumb` its thumb slot. A group's\n * `Item` is the component of its items when written on its own, and an item when it names one\n * with `of`, as an `Instance` does.\n */\nconst REKA_PARTS = {\n Button: { Root: root('button') },\n Toggle: { Root: root('toggle') },\n Switch: { Root: root('switch'), Thumb: part('thumb') },\n Checkbox: { Root: root('checkbox'), Indicator: part('indicator') },\n RadioGroup: { Root: root('radioGroup'), Item: root('radio'), Indicator: part('indicator') },\n ToggleGroup: { Root: root('toggleGroup'), Item: root('toggle') },\n Slider: {\n Root: root('slider'),\n Track: part('track'),\n Range: part('range'),\n Thumb: part('thumb')\n },\n Progress: { Root: root('progress'), Track: part('track'), Indicator: part('indicator') },\n Tabs: {\n Root: root('tabs'),\n List: part('list'),\n Trigger: repeat('list'),\n Content: repeat('panels')\n },\n Collapsible: { Root: root('collapsible'), Trigger: part('trigger'), Content: part('content') },\n Accordion: {\n Root: root('accordion'),\n Item: root('collapsible'),\n Header: { role: 'frame' },\n Trigger: part('trigger'),\n Content: part('content')\n },\n NumberField: {\n Root: root('numberField'),\n Input: input('text'),\n Increment: part('increment'),\n Decrement: part('decrement')\n },\n TextField: { Root: root('textField'), Input: input('value') },\n Textarea: { Root: root('textarea'), Input: input('value') }\n} as const satisfies Readonly<Record<string, Readonly<Record<string, RekaRole>>>>\n\n/** Each Reka namespace and its parts, as typed elements are built from them. */\nexport type RekaNamespaces = typeof REKA_PARTS\n\n/** The same elements, looked up by any element name, as parsing and export do. */\nexport const REKA_ELEMENTS: Readonly<Record<string, Readonly<Record<string, RekaRole>>>> =\n REKA_PARTS\n\n/** The container a repeated part goes in when written directly under its root. */\nconst CONTAINER_NAMES: Record<string, string> = { list: 'List', panels: 'Panels', items: 'Items' }\n\n/** The role of a Reka element type such as `Switch.Thumb`, or undefined for other elements. */\nexport function rekaRole(type: string): RekaRole | undefined {\n const dot = type.indexOf('.')\n if (dot === -1) return undefined\n const namespace = REKA_ELEMENTS[type.slice(0, dot)] as Record<string, RekaRole> | undefined\n return namespace?.[type.slice(dot + 1)]\n}\n\n/** The element type for a part container that JSX leaves implicit. */\nconst containerType = (container: string) => `reka-container:${container}`\n\nexport function containerPart(type: string): string | undefined {\n return type.startsWith('reka-container:') ? type.slice('reka-container:'.length) : undefined\n}\n\n/** Whether an element names an existing component, as an item of a group does. */\nexport function namesComponent(props: Record<string, unknown>): boolean {\n return props.of !== undefined || props.component !== undefined || props.componentId !== undefined\n}\n\nconst GROUPS = new Set<BehaviourKind>(['radioGroup', 'toggleGroup', 'accordion'])\n\n/** The container slot a child written directly under a root belongs in, if any. */\nfunction containerOf(child: TreeNode, kind: BehaviourKind): string | undefined {\n const role = rekaRole(child.type)\n if (role?.role === 'repeat') return role.container\n if (GROUPS.has(kind) && role?.role === 'root' && namesComponent(child.props)) return 'items'\n return undefined\n}\n\n/**\n * A root's children with repeated parts and group items that are written directly under it\n * wrapped in their container slot, as the behaviour binds them: tab panels in Panels, a group's\n * items in Items. Containers the JSX writes itself are kept.\n */\nexport function wrapRepeatedParts(tree: TreeNode, kind: BehaviourKind): TreeNode['children'] {\n const result: TreeNode['children'] = []\n let open: TreeNode | null = null\n for (const child of tree.children) {\n const container = typeof child === 'string' ? undefined : containerOf(child, kind)\n if (!container || typeof child === 'string') {\n open = null\n result.push(child)\n continue\n }\n if (open?.type !== containerType(container)) {\n open = node(containerType(container), {\n name: CONTAINER_NAMES[container] ?? container,\n flex: kind === 'toggleGroup' ? 'row' : 'col',\n gap: kind === 'toggleGroup' ? 4 : 8\n })\n result.push(open)\n }\n open.children.push(child)\n }\n return result\n}\n\n/** What a root collects from its parts while they render. */\nexport interface RekaScope {\n kind: BehaviourKind\n ownerId: string\n /** Slot property ids by part, shared by every variant of a set. */\n slots: Map<string, string>\n /** Text property ids by value, defined once on the root. */\n texts: Map<string, string>\n}\n\nexport function createScope(kind: BehaviourKind, ownerId: string): RekaScope {\n return { kind, ownerId, slots: new Map(), texts: new Map() }\n}\n\n/** Make a rendered part frame its part's slot, with the id the part has in this component. */\nexport function bindPart(graph: SceneGraph, scope: RekaScope, frame: SceneNode, partId: string) {\n const id = scope.slots.get(partId) ?? createComponentPropertyId()\n if (!createSlotProperty(graph, frame.id, id))\n throw new Error(`<${partId}> must be inside a main component`)\n scope.slots.set(partId, id)\n}\n\n/** Make a rendered text layer show the value's text property, defined on the root. */\nexport function bindInput(\n graph: SceneGraph,\n scope: RekaScope,\n text: SceneNode,\n valueId: string,\n propertyName: string\n) {\n let id = scope.texts.get(valueId)\n if (!id) {\n id = createComponentPropertyId()\n scope.texts.set(valueId, id)\n const owner = graph.getNode(scope.ownerId)\n graph.updateNode(scope.ownerId, {\n componentPropertyDefinitions: [\n ...(owner?.componentPropertyDefinitions ?? []),\n { id, name: propertyName, type: 'TEXT', defaultValue: text.text }\n ]\n })\n }\n graph.updateNode(text.id, {\n componentPropertyReferences: [\n ...text.componentPropertyReferences,\n { propertyId: id, field: 'TEXT' }\n ]\n })\n}\n\n/** Root props that describe the behaviour rather than the drawing. */\nexport const BEHAVIOUR_PROPS = [\n 'modelValue',\n 'open',\n 'disabled',\n 'filled',\n 'states',\n 'min',\n 'max',\n 'step',\n 'defaultValue'\n] as const\n\n/** A value bound to a component property by name; a variant property may name its on and off. */\nexport type BindingProp = string | { property: string; on?: string; off?: string }\n\nfunction isBinding(value: unknown): value is BindingProp {\n return (\n typeof value === 'string' ||\n (typeof value === 'object' &&\n value !== null &&\n 'property' in value &&\n typeof value.property === 'string')\n )\n}\n\n/** The spec a root's props give: values by property name, a range, and states. */\nfunction rootSpec(kind: BehaviourKind, props: Record<string, unknown>): BehaviourSpec {\n const values: NonNullable<BehaviourSpec['values']> = {}\n const main = kind === 'collapsible' ? props.open : props.modelValue\n if (isBinding(main)) values[kind === 'collapsible' ? 'open' : 'value'] = main\n if (isBinding(props.disabled)) values.disabled = props.disabled\n if (isBinding(props.filled)) values.filled = props.filled\n const range = Object.fromEntries(\n (['min', 'max', 'step'] as const).flatMap((key) =>\n typeof props[key] === 'number' ? [[key, props[key]]] : []\n )\n )\n if (typeof props.defaultValue === 'number') range.default = props.defaultValue\n const spec: BehaviourSpec = { kind }\n if (Object.keys(values).length) spec.values = values\n if (Object.keys(range).length) spec.numbers = { value: range }\n if (typeof props.states === 'string') spec.states = props.states\n return spec\n}\n\n/** Store the behaviour a rendered root describes, with the slots and texts its parts made. */\nexport function finishRoot(\n graph: SceneGraph,\n scope: RekaScope,\n props: Record<string, unknown>\n): void {\n const owner = graph.getNode(scope.ownerId)\n if (!owner) return\n const behaviour = behaviourFromSpec(graph, owner, rootSpec(scope.kind, props))\n behaviour.parts = { ...behaviour.parts, ...Object.fromEntries(scope.slots) }\n behaviour.texts = {\n ...behaviour.texts,\n ...Object.fromEntries([...scope.texts].map(([valueId, id]) => [valueId, { propertyId: id }]))\n }\n // The parts are made while the root's children render, so their triggers are checked now.\n validateChoiceValues(graph, owner, behaviour)\n graph.updateNode(owner.id, { pluginData: withBehaviour(owner, behaviour) })\n}\n","import { node, type BaseProps, type TreeNode } from '../tree'\nimport { REKA_ELEMENTS, type BindingProp, type RekaNamespaces } from './index'\n\n/** Props of a Reka element: a frame's, plus the behaviour a root binds and a group item's component. */\nexport interface RekaProps extends BaseProps {\n modelValue?: BindingProp\n open?: BindingProp\n disabled?: BindingProp\n filled?: BindingProp\n /** The variant property whose values draw rest, hover, pressed, focus, and disabled. */\n states?: string\n min?: number\n max?: number\n step?: number\n defaultValue?: number\n /** For a group's item: the component or set it is an instance of. */\n of?: string\n}\n\ntype Child = TreeNode | string\nexport type RekaElement = (props?: RekaProps, ...children: Child[]) => TreeNode\n\n/** One Reka namespace as element functions, such as `Switch.Root` and `Switch.Thumb`. */\nfunction namespace<N extends keyof RekaNamespaces>(name: N) {\n const element =\n (part: string): RekaElement =>\n (props = {}, ...children) =>\n node(`${name}.${part}`, children.length > 0 ? { ...props, children } : props)\n return Object.fromEntries(\n Object.keys(REKA_ELEMENTS[name]).map((part) => [part, element(part)])\n ) as { [P in keyof RekaNamespaces[N]]: RekaElement }\n}\n\nexport const Button = namespace('Button')\nexport const Toggle = namespace('Toggle')\nexport const Switch = namespace('Switch')\nexport const Checkbox = namespace('Checkbox')\nexport const RadioGroup = namespace('RadioGroup')\nexport const ToggleGroup = namespace('ToggleGroup')\nexport const Slider = namespace('Slider')\nexport const Progress = namespace('Progress')\nexport const Tabs = namespace('Tabs')\nexport const Collapsible = namespace('Collapsible')\nexport const Accordion = namespace('Accordion')\nexport const NumberField = namespace('NumberField')\nexport const TextField = namespace('TextField')\nexport const Textarea = namespace('Textarea')\n"],"mappings":";;;AAiBA,SAAS,gBAAgB,UAAwD;CAC/E,OAAO,SAAS,SAAS,UACvB,OAAO,UAAU,YAAY,MAAM,SAAA,KAAoB,MAAM,WAAW,CAAC,KAAK,CAChF;AACF;;;;;AAMA,SAAgB,YAAY,MAAwB;CAClD,OAAO,KAAK,SAAS,QAAQ,UAA2B,OAAO,UAAU,QAAQ,CAAC,CAAC,KAAK,EAAE;AAC5F;AAEA,SAAgB,WAAW,GAA2B;CACpD,IAAI,MAAM,QAAQ,OAAO,MAAM,UAAU,OAAO;CAChD,OACE,UAAU,KACV,OAAO,EAAE,SAAS,YAClB,WAAW,KACX,cAAc,KACd,MAAM,QAAQ,EAAE,QAAQ;AAE5B;AASA,SAAS,eAAe,GAA+B;CACrD,OAAO,MAAM,QAAQ,OAAO,MAAM,YAAY,UAAU,KAAK,WAAW;AAC1E;;;;;AAMA,SAAgB,cAAc,SAAkB,QAAQ,GAAoB;CAC1E,IAAI,QAAQ,KAAK,MAAM,IAAI,MAAM,qCAAqC;CACtE,IAAI,WAAW,MAAM,OAAO;CAC5B,IAAI,WAAW,OAAO,GAAG,OAAO;CAChC,IAAI,CAAC,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M,IAAI,EAAE,YAAY,cAAc,OAAO,SAAS,EAAE,CAAC;AAC5E;;;;ACxOA,SAAS,UAA0C,MAAS;CAC1D,MAAM,WACH,UACA,QAAQ,CAAC,GAAG,GAAG,aACd,KAAK,GAAG,KAAK,GAAG,QAAQ,SAAS,SAAS,IAAI;EAAE,GAAG;EAAO;CAAS,IAAI,KAAK;CAChF,OAAO,OAAO,YACZ,OAAO,KAAK,cAAc,KAAK,CAAC,CAAC,KAAK,SAAS,CAAC,MAAM,QAAQ,IAAI,CAAC,CAAC,CACtE;AACF;AAEA,MAAa,SAAS,UAAU,QAAQ;AACxC,MAAa,SAAS,UAAU,QAAQ;AACxC,MAAa,SAAS,UAAU,QAAQ;AACxC,MAAa,WAAW,UAAU,UAAU;AAC5C,MAAa,aAAa,UAAU,YAAY;AAChD,MAAa,cAAc,UAAU,aAAa;AAClD,MAAa,SAAS,UAAU,QAAQ;AACxC,MAAa,WAAW,UAAU,UAAU;AAC5C,MAAa,OAAO,UAAU,MAAM;AACpC,MAAa,cAAc,UAAU,aAAa;AAClD,MAAa,YAAY,UAAU,WAAW;AAC9C,MAAa,cAAc,UAAU,aAAa;AAClD,MAAa,YAAY,UAAU,WAAW;AAC9C,MAAa,WAAW,UAAU,UAAU"}
|
package/dist/chunks/effects.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BLEND_MODE } from "./component-properties.js";
|
|
2
2
|
import { parseColor } from "@pairdraw/scene-graph/color";
|
|
3
|
-
import { TRANSPARENT } from "@pairdraw/scene-graph/constants";
|
|
3
|
+
import { BLACK, DEFAULT_NOISE, DEFAULT_NOISE_COLOR, DEFAULT_TEXTURE, TRANSPARENT } from "@pairdraw/scene-graph/constants";
|
|
4
4
|
//#region src/effects.ts
|
|
5
5
|
/** Radius of a shadow or blur that does not set one. */
|
|
6
6
|
const DEFAULT_EFFECT_RADIUS = 8;
|
|
@@ -56,7 +56,59 @@ function backgroundBlur(radiusOrOptions) {
|
|
|
56
56
|
function foregroundBlur(radiusOrOptions) {
|
|
57
57
|
return blurEffect("FOREGROUND_BLUR", radiusOrOptions);
|
|
58
58
|
}
|
|
59
|
+
/** Radius of a new texture effect, as Figma's effects panel starts one. */
|
|
60
|
+
const DEFAULT_TEXTURE_RADIUS = 4;
|
|
61
|
+
function noiseSize(size, fallback) {
|
|
62
|
+
if (size === void 0) return { ...fallback };
|
|
63
|
+
return typeof size === "number" ? {
|
|
64
|
+
x: size,
|
|
65
|
+
y: size
|
|
66
|
+
} : { ...size };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A noise effect. A duotone's second colour starts white at the first colour's opacity and a
|
|
70
|
+
* multitone's opacity at that opacity, as Figma's panel switches them.
|
|
71
|
+
*/
|
|
72
|
+
function noise(options = {}) {
|
|
73
|
+
const color = options.color === void 0 ? { ...DEFAULT_NOISE_COLOR } : toColor(options.color);
|
|
74
|
+
const params = {
|
|
75
|
+
noiseType: options.noiseType ?? DEFAULT_NOISE.noiseType,
|
|
76
|
+
noiseSize: noiseSize(options.noiseSize, DEFAULT_NOISE.noiseSize),
|
|
77
|
+
density: options.density ?? DEFAULT_NOISE.density
|
|
78
|
+
};
|
|
79
|
+
if (options.secondaryColor !== void 0) params.secondaryColor = toColor(options.secondaryColor);
|
|
80
|
+
else if (params.noiseType === "DUOTONE") params.secondaryColor = {
|
|
81
|
+
r: 1,
|
|
82
|
+
g: 1,
|
|
83
|
+
b: 1,
|
|
84
|
+
a: color.a
|
|
85
|
+
};
|
|
86
|
+
if (options.opacity !== void 0) params.opacity = options.opacity;
|
|
87
|
+
else if (params.noiseType === "MULTITONE") params.opacity = color.a;
|
|
88
|
+
if (options.seed !== void 0) params.seed = options.seed;
|
|
89
|
+
return {
|
|
90
|
+
type: "NOISE",
|
|
91
|
+
color,
|
|
92
|
+
visible: options.visible ?? true,
|
|
93
|
+
noise: params
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** A texture effect, which roughens the layer's edges by `radius`. */
|
|
97
|
+
function texture(options = {}) {
|
|
98
|
+
const params = {
|
|
99
|
+
noiseSize: noiseSize(options.noiseSize, DEFAULT_TEXTURE.noiseSize),
|
|
100
|
+
clipToShape: options.clipToShape ?? DEFAULT_TEXTURE.clipToShape
|
|
101
|
+
};
|
|
102
|
+
if (options.seed !== void 0) params.seed = options.seed;
|
|
103
|
+
return {
|
|
104
|
+
type: "TEXTURE",
|
|
105
|
+
color: { ...BLACK },
|
|
106
|
+
radius: options.radius ?? DEFAULT_TEXTURE_RADIUS,
|
|
107
|
+
visible: options.visible ?? true,
|
|
108
|
+
texture: params
|
|
109
|
+
};
|
|
110
|
+
}
|
|
59
111
|
//#endregion
|
|
60
|
-
export { backgroundBlur, dropShadow, foregroundBlur, innerShadow, layerBlur };
|
|
112
|
+
export { backgroundBlur, dropShadow, foregroundBlur, innerShadow, layerBlur, noise, texture };
|
|
61
113
|
|
|
62
114
|
//# sourceMappingURL=effects.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.js","names":[],"sources":["../../src/effects.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"effects.js","names":[],"sources":["../../src/effects.ts"],"sourcesContent":["import type {\n BlendMode,\n Effect,\n NoiseEffectParams,\n TextureEffectParams\n} from '@pairdraw/scene-graph'\nimport { parseColor } from '@pairdraw/scene-graph/color'\nimport {\n BLACK,\n DEFAULT_NOISE,\n DEFAULT_NOISE_COLOR,\n DEFAULT_TEXTURE,\n TRANSPARENT\n} from '@pairdraw/scene-graph/constants'\nimport type { Color, Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { BLEND_MODE } from './enums'\n\nexport type EffectColor = string | Color\n\nexport interface ShadowEffectOptions {\n color?: EffectColor\n x?: number\n y?: number\n offset?: Vector\n radius?: number\n spread?: number\n visible?: boolean\n /** Same spellings as a layer's `blendMode`, read case-insensitively. */\n blendMode?: string\n showShadowBehindNode?: boolean\n}\n\nexport interface BlurEffectOptions {\n radius?: number\n visible?: boolean\n}\n\n/** Radius of a shadow or blur that does not set one. */\nconst DEFAULT_EFFECT_RADIUS = 8\n\nfunction toColor(color: EffectColor | undefined): Color {\n if (color === undefined) return { ...TRANSPARENT }\n return typeof color === 'string' ? parseColor(color) : color\n}\n\n/** A layer's `blendMode` spelling, or undefined when the helper omits it or names none. */\nfunction parsedBlendMode(blendMode: string | undefined): BlendMode | undefined {\n return blendMode === undefined ? undefined : BLEND_MODE.parse(blendMode)\n}\n\nfunction shadowEffect(type: 'DROP_SHADOW' | 'INNER_SHADOW', options: ShadowEffectOptions): Effect {\n return {\n type,\n color: toColor(options.color ?? 'rgba(0, 0, 0, 0.25)'),\n offset: options.offset ?? { x: options.x ?? 0, y: options.y ?? 4 },\n radius: options.radius ?? DEFAULT_EFFECT_RADIUS,\n spread: options.spread ?? 0,\n visible: options.visible ?? true,\n blendMode: parsedBlendMode(options.blendMode),\n showShadowBehindNode: options.showShadowBehindNode\n }\n}\n\nfunction blurEffect(\n type: 'LAYER_BLUR' | 'BACKGROUND_BLUR' | 'FOREGROUND_BLUR',\n radiusOrOptions: number | BlurEffectOptions = {}\n): Effect {\n const options =\n typeof radiusOrOptions === 'number' ? { radius: radiusOrOptions } : radiusOrOptions\n return {\n type,\n color: { ...TRANSPARENT },\n offset: { x: 0, y: 0 },\n radius: options.radius ?? DEFAULT_EFFECT_RADIUS,\n spread: 0,\n visible: options.visible ?? true\n }\n}\n\nexport function dropShadow(options: ShadowEffectOptions = {}): Effect {\n return shadowEffect('DROP_SHADOW', options)\n}\n\nexport function innerShadow(options: ShadowEffectOptions = {}): Effect {\n return shadowEffect('INNER_SHADOW', options)\n}\n\nexport function layerBlur(radiusOrOptions?: number | BlurEffectOptions): Effect {\n return blurEffect('LAYER_BLUR', radiusOrOptions)\n}\n\nexport function backgroundBlur(radiusOrOptions?: number | BlurEffectOptions): Effect {\n return blurEffect('BACKGROUND_BLUR', radiusOrOptions)\n}\n\nexport function foregroundBlur(radiusOrOptions?: number | BlurEffectOptions): Effect {\n return blurEffect('FOREGROUND_BLUR', radiusOrOptions)\n}\n\n/** A grain size as Figma's plugin API takes it, one number for both axes, or each axis apart. */\nexport type NoiseSize = number | Vector\n\n/**\n * A noise effect in Figma's terms: grains in `color`, a duotone's `secondaryColor` too, or a\n * multitone's many colours at `opacity`. Left out, each value is what Figma's panel starts with.\n */\nexport interface NoiseEffectOptions extends Partial<\n Omit<NoiseEffectParams, 'noiseSize' | 'secondaryColor'>\n> {\n noiseSize?: NoiseSize\n color?: EffectColor\n secondaryColor?: EffectColor\n visible?: boolean\n}\n\n/** A texture effect in Figma's terms, `radius` being how far its grain moves the edges. */\nexport interface TextureEffectOptions extends Partial<Omit<TextureEffectParams, 'noiseSize'>> {\n noiseSize?: NoiseSize\n radius?: number\n visible?: boolean\n}\n\n/** Radius of a new texture effect, as Figma's effects panel starts one. */\nconst DEFAULT_TEXTURE_RADIUS = 4\n\nfunction noiseSize(size: NoiseSize | undefined, fallback: Vector): Vector {\n if (size === undefined) return { ...fallback }\n return typeof size === 'number' ? { x: size, y: size } : { ...size }\n}\n\n/**\n * A noise effect. A duotone's second colour starts white at the first colour's opacity and a\n * multitone's opacity at that opacity, as Figma's panel switches them.\n */\nexport function noise(options: NoiseEffectOptions = {}): Effect {\n const color = options.color === undefined ? { ...DEFAULT_NOISE_COLOR } : toColor(options.color)\n const params: NoiseEffectParams = {\n noiseType: options.noiseType ?? DEFAULT_NOISE.noiseType,\n noiseSize: noiseSize(options.noiseSize, DEFAULT_NOISE.noiseSize),\n density: options.density ?? DEFAULT_NOISE.density\n }\n // A second colour or opacity given is kept whatever the type, so switching back finds it; a\n // duotone or multitone that lacks one starts where Figma's panel does.\n if (options.secondaryColor !== undefined) params.secondaryColor = toColor(options.secondaryColor)\n else if (params.noiseType === 'DUOTONE') params.secondaryColor = { r: 1, g: 1, b: 1, a: color.a }\n if (options.opacity !== undefined) params.opacity = options.opacity\n else if (params.noiseType === 'MULTITONE') params.opacity = color.a\n if (options.seed !== undefined) params.seed = options.seed\n return { type: 'NOISE', color, visible: options.visible ?? true, noise: params }\n}\n\n/** A texture effect, which roughens the layer's edges by `radius`. */\nexport function texture(options: TextureEffectOptions = {}): Effect {\n const params: TextureEffectParams = {\n noiseSize: noiseSize(options.noiseSize, DEFAULT_TEXTURE.noiseSize),\n clipToShape: options.clipToShape ?? DEFAULT_TEXTURE.clipToShape\n }\n if (options.seed !== undefined) params.seed = options.seed\n return {\n type: 'TEXTURE',\n color: { ...BLACK },\n radius: options.radius ?? DEFAULT_TEXTURE_RADIUS,\n visible: options.visible ?? true,\n texture: params\n }\n}\n"],"mappings":";;;;;AAuCA,MAAM,wBAAwB;AAE9B,SAAS,QAAQ,OAAuC;CACtD,IAAI,UAAU,KAAA,GAAW,OAAO,EAAE,GAAG,YAAY;CACjD,OAAO,OAAO,UAAU,WAAW,WAAW,KAAK,IAAI;AACzD;;AAGA,SAAS,gBAAgB,WAAsD;CAC7E,OAAO,cAAc,KAAA,IAAY,KAAA,IAAY,WAAW,MAAM,SAAS;AACzE;AAEA,SAAS,aAAa,MAAsC,SAAsC;CAChG,OAAO;EACL;EACA,OAAO,QAAQ,QAAQ,SAAS,qBAAqB;EACrD,QAAQ,QAAQ,UAAU;GAAE,GAAG,QAAQ,KAAK;GAAG,GAAG,QAAQ,KAAK;EAAE;EACjE,QAAQ,QAAQ,UAAU;EAC1B,QAAQ,QAAQ,UAAU;EAC1B,SAAS,QAAQ,WAAW;EAC5B,WAAW,gBAAgB,QAAQ,SAAS;EAC5C,sBAAsB,QAAQ;CAChC;AACF;AAEA,SAAS,WACP,MACA,kBAA8C,CAAC,GACvC;CACR,MAAM,UACJ,OAAO,oBAAoB,WAAW,EAAE,QAAQ,gBAAgB,IAAI;CACtE,OAAO;EACL;EACA,OAAO,EAAE,GAAG,YAAY;EACxB,QAAQ;GAAE,GAAG;GAAG,GAAG;EAAE;EACrB,QAAQ,QAAQ,UAAU;EAC1B,QAAQ;EACR,SAAS,QAAQ,WAAW;CAC9B;AACF;AA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CAAO;AACjF;;AAGA,SAAgB,QAAQ,UAAgC,CAAC,GAAW;CAClE,MAAM,SAA8B;EAClC,WAAW,UAAU,QAAQ,WAAW,gBAAgB,SAAS;EACjE,aAAa,QAAQ,eAAe,gBAAgB;CACtD;CACA,IAAI,QAAQ,SAAS,KAAA,GAAW,OAAO,OAAO,QAAQ;CACtD,OAAO;EACL,MAAM;EACN,OAAO,EAAE,GAAG,MAAM;EAClB,QAAQ,QAAQ,UAAU;EAC1B,SAAS,QAAQ,WAAW;EAC5B,SAAS;CACX;AACF"}
|
package/dist/chunks/elements.js
CHANGED
|
@@ -210,8 +210,17 @@ const EFFECT_HELPERS = {
|
|
|
210
210
|
INNER_SHADOW: "innerShadow",
|
|
211
211
|
LAYER_BLUR: "layerBlur",
|
|
212
212
|
BACKGROUND_BLUR: "backgroundBlur",
|
|
213
|
-
FOREGROUND_BLUR: "foregroundBlur"
|
|
213
|
+
FOREGROUND_BLUR: "foregroundBlur",
|
|
214
|
+
NOISE: "noise",
|
|
215
|
+
TEXTURE: "texture"
|
|
214
216
|
};
|
|
217
|
+
/** A grain size as one number when both axes match, as Figma's plugin API writes it. */
|
|
218
|
+
function noiseSizeValue(size) {
|
|
219
|
+
return size.x === size.y ? size.x : {
|
|
220
|
+
x: size.x,
|
|
221
|
+
y: size.y
|
|
222
|
+
};
|
|
223
|
+
}
|
|
215
224
|
function effectValue(effect) {
|
|
216
225
|
const visible = effect.visible ? void 0 : false;
|
|
217
226
|
if (effect.type === "DROP_SHADOW" || effect.type === "INNER_SHADOW") return helperCall(EFFECT_HELPERS[effect.type], options({
|
|
@@ -224,6 +233,29 @@ function effectValue(effect) {
|
|
|
224
233
|
blendMode: blendMode(effect.blendMode),
|
|
225
234
|
showShadowBehindNode: effect.showShadowBehindNode
|
|
226
235
|
}));
|
|
236
|
+
if (effect.type === "NOISE") {
|
|
237
|
+
const grain = effect.noise;
|
|
238
|
+
return helperCall(EFFECT_HELPERS.NOISE, options({
|
|
239
|
+
noiseType: grain.noiseType,
|
|
240
|
+
noiseSize: noiseSizeValue(grain.noiseSize),
|
|
241
|
+
density: grain.density,
|
|
242
|
+
color: formatColor(effect.color, effect.color.a),
|
|
243
|
+
secondaryColor: grain.secondaryColor ? formatColor(grain.secondaryColor, grain.secondaryColor.a) : void 0,
|
|
244
|
+
opacity: grain.opacity,
|
|
245
|
+
seed: grain.seed,
|
|
246
|
+
visible
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
if (effect.type === "TEXTURE") {
|
|
250
|
+
const grain = effect.texture;
|
|
251
|
+
return helperCall(EFFECT_HELPERS.TEXTURE, options({
|
|
252
|
+
noiseSize: noiseSizeValue(grain.noiseSize),
|
|
253
|
+
radius: effect.radius,
|
|
254
|
+
clipToShape: grain.clipToShape,
|
|
255
|
+
seed: grain.seed,
|
|
256
|
+
visible
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
227
259
|
return helperCall(EFFECT_HELPERS[effect.type], visible === void 0 ? effect.radius : {
|
|
228
260
|
radius: effect.radius,
|
|
229
261
|
visible
|
|
@@ -243,12 +275,12 @@ function effectShorthand(effects) {
|
|
|
243
275
|
if (rest.length > 1 || rest.some((effect) => effect.type !== "LAYER_BLUR")) return null;
|
|
244
276
|
const props = [];
|
|
245
277
|
if (shadow) props.push(["shadow", shadow]);
|
|
246
|
-
for (const blur of rest) props.push(["blur", blur.radius]);
|
|
278
|
+
for (const blur of rest) if (blur.type === "LAYER_BLUR") props.push(["blur", blur.radius]);
|
|
247
279
|
return props;
|
|
248
280
|
}
|
|
249
|
-
/** An effect JSX has a helper for;
|
|
281
|
+
/** An effect JSX has a helper for; a shader effect is not written back as JSX source. */
|
|
250
282
|
function hasJSXHelper(effect) {
|
|
251
|
-
return Object.hasOwn(EFFECT_HELPERS, effect.type);
|
|
283
|
+
return effect.type !== "SHADER" && Object.hasOwn(EFFECT_HELPERS, effect.type);
|
|
252
284
|
}
|
|
253
285
|
function collectEffectProps(node, props) {
|
|
254
286
|
const effects = node.effects.filter(hasJSXHelper);
|
|
@@ -458,7 +490,7 @@ const DESIGN_JSX_ELEMENTS = [
|
|
|
458
490
|
runtimeType: "vector",
|
|
459
491
|
description: "A vector layer.",
|
|
460
492
|
nodeType: "VECTOR",
|
|
461
|
-
writes: ["VECTOR"]
|
|
493
|
+
writes: ["VECTOR", "BOOLEAN_OPERATION"]
|
|
462
494
|
},
|
|
463
495
|
{
|
|
464
496
|
name: "Group",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.js","names":[],"sources":["../../src/export/helpers.ts","../../src/export/paint.ts","../../src/figjam-text.ts","../../src/shapes-with-text.ts","../../src/stickies.ts","../../src/elements.ts"],"sourcesContent":["import type { SceneGraph, SceneNode, Effect, GridTrack } from '@pairdraw/scene-graph'\nimport { colorToHex8 } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nexport function formatColor(color: Color, opacity = 1): string {\n return colorToHex8(color, opacity)\n}\n\nexport function formatShadow(e: Effect): string | null {\n if (e.type !== 'DROP_SHADOW' && e.type !== 'INNER_SHADOW') return null\n return `${e.offset.x} ${e.offset.y} ${e.radius} ${formatColor(e.color, e.color.a)}`\n}\n\nexport function getNodeContext(node: SceneNode, graph: SceneGraph) {\n const parent = node.parentId ? graph.getNode(node.parentId) : null\n return {\n isAutoLayout: node.layoutMode !== 'NONE',\n isGrid: node.layoutMode === 'GRID',\n isFlex: node.layoutMode === 'HORIZONTAL' || node.layoutMode === 'VERTICAL',\n parentIsAutoLayout: parent ? parent.layoutMode !== 'NONE' : false,\n parentIsGrid: parent ? parent.layoutMode === 'GRID' : false\n }\n}\n\nexport type PaddingEdges = { pt: number; pr: number; pb: number; pl: number }\n\nexport function collectPadding(node: SceneNode): PaddingEdges | null {\n const { paddingTop: pt, paddingRight: pr, paddingBottom: pb, paddingLeft: pl } = node\n if (pt === 0 && pr === 0 && pb === 0 && pl === 0) return null\n return { pt, pr, pb, pl }\n}\n\nexport function emitPadding<T>(\n edges: PaddingEdges,\n uniform: (v: number) => T,\n symmetric: (y: number, x: number) => T[],\n individual: (edges: PaddingEdges) => T[]\n): T[] {\n const { pt, pr, pb, pl } = edges\n if (pt === pr && pr === pb && pb === pl) return [uniform(pt)]\n if (pt === pb && pl === pr) return symmetric(pt, pl)\n return individual(edges)\n}\n\nexport interface CornerRadii {\n tl: number\n tr: number\n br: number\n bl: number\n}\n\nexport function collectCornerRadii(node: SceneNode): CornerRadii | null {\n if (node.independentCorners) {\n const corners = {\n tl: node.topLeftRadius,\n tr: node.topRightRadius,\n br: node.bottomRightRadius,\n bl: node.bottomLeftRadius\n }\n return Object.values(corners).some((radius) => radius > 0) ? corners : null\n }\n if (node.cornerRadius <= 0) return null\n const r = node.cornerRadius\n return { tl: r, tr: r, br: r, bl: r }\n}\n\nfunction formatTrack(t: GridTrack): string {\n if (t.sizing === 'FR') return `${t.value}fr`\n if (t.sizing === 'FIXED') return `${t.value}px`\n return 'auto'\n}\n\nexport function formatTracks(tracks: GridTrack[]): string {\n return tracks.map(formatTrack).join(' ')\n}\n","import type {\n Effect,\n Fill,\n GradientTransform,\n SceneNode,\n ShadowEffect,\n Stroke\n} from '@pairdraw/scene-graph'\nimport { gradientTransformRows, isIdentityGradientTransform } from '@pairdraw/scene-graph/gradient'\nimport { isShaderPresetPaint, shaderOfPaint } from '@pairdraw/scene-graph/shaders'\n\nimport { STROKE_ALIGN, STROKE_CAP, STROKE_JOIN } from '../enums'\nimport { formatColor, formatShadow } from './helpers'\nimport { helperCall, plainValue, type HelperCall, type JSXProp, type JSXValue } from './value'\n\nconst GRADIENT_HELPERS: Partial<Record<Fill['type'], string>> = {\n GRADIENT_LINEAR: 'linearGradient',\n GRADIENT_RADIAL: 'radialGradient',\n GRADIENT_ANGULAR: 'angularGradient',\n GRADIENT_DIAMOND: 'diamondGradient'\n}\n\nfunction isIdentity(transform: GradientTransform | undefined): boolean {\n return !transform || isIdentityGradientTransform(transform)\n}\n\n/** A paint transform as authors write it, in Figma's rows. */\nfunction rows(transform: GradientTransform | undefined) {\n return transform && gradientTransformRows(transform)\n}\n\n/** Paints and effects imported from Figma often spell out the default blend mode. */\nfunction blendMode(mode: Fill['blendMode']): Fill['blendMode'] {\n return mode === 'NORMAL' || mode === 'PASS_THROUGH' ? undefined : mode\n}\n\ntype Options = Record<string, JSXValue | undefined>\n\n/** Helper options with defaults left out, or `undefined` when none differ. */\nfunction options(entries: Options): Options | undefined {\n return Object.values(entries).some((value) => value !== undefined) ? entries : undefined\n}\n\nfunction fillValue(fill: Fill, node: SceneNode): JSXValue {\n const visible = fill.visible ? undefined : false\n const shader = shaderOfPaint(node, fill)\n if (shader && isShaderPresetPaint(shader)) {\n // A preset with nothing but effects is written as just its effects.\n const { components, ...rest } = shader.preset\n return helperCall(\n 'shader',\n plainValue(Object.keys(rest).length === 0 ? components : shader.preset),\n options({\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode)\n })\n )\n }\n // Code the user wrote comes back as the same paint only through its own helper.\n if (shader) {\n const uniforms = shader.uniforms ?? {}\n return helperCall(\n 'shaderSource',\n shader.source,\n options({\n uniforms: Object.keys(uniforms).length === 0 ? undefined : plainValue(uniforms),\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode)\n })\n )\n }\n if (fill.type === 'SOLID') {\n const color = formatColor(fill.color, fill.color.a)\n const opacity = fill.opacity === fill.color.a ? undefined : fill.opacity\n return helperCall(\n 'solid',\n color,\n options({ opacity, visible, blendMode: blendMode(fill.blendMode) })\n )\n }\n const helper = GRADIENT_HELPERS[fill.type]\n if (helper && fill.gradientStops) {\n const stops = fill.gradientStops.map((stop) => [\n formatColor(stop.color, stop.color.a),\n stop.position\n ])\n return helperCall(\n helper,\n stops,\n options({\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode),\n transform: isIdentity(fill.gradientTransform)\n ? undefined\n : plainValue(rows(fill.gradientTransform))\n })\n )\n }\n // Image, pattern, and other paints have no helper; they render back from their fields.\n return plainValue({\n ...fill,\n gradientTransform: rows(fill.gradientTransform),\n imageTransform: rows(fill.imageTransform)\n })\n}\n\n/** A single visible solid paint fits the `bg` or text `color` shorthand. */\nfunction solidShorthand(fills: Fill[]): string | null {\n if (fills.length !== 1) return null\n const [fill] = fills\n if (fill.type !== 'SOLID' || !fill.visible || blendMode(fill.blendMode)) return null\n // The shorthand has one alpha; a fill whose opacity differs from its colour's needs `solid`.\n if (fill.opacity !== fill.color.a) return null\n return formatColor(fill.color, fill.color.a)\n}\n\n/** One paint as a colour prop takes it: a colour string when it is plain, its helper otherwise. */\nexport function paintPropValue(fill: Fill, node: SceneNode): JSXValue {\n return solidShorthand([fill]) ?? fillValue(fill, node)\n}\n\nexport function collectFillProps(node: SceneNode, props: JSXProp[]): void {\n if (node.fills.length === 0) {\n // A text is painted black unless it says it is not painted.\n if (node.type === 'TEXT') props.push(['fills', []])\n return\n }\n const shorthand = solidShorthand(node.fills)\n if (shorthand) props.push([node.type === 'TEXT' ? 'color' : 'bg', shorthand])\n else props.push(['fills', node.fills.map((fill) => fillValue(fill, node))])\n}\n\ninterface StrokeValue {\n [key: string]: JSXValue | undefined\n color: string\n /** Only when it differs from the colour's alpha, which the colour already carries. */\n opacity?: number\n weight?: number\n align?: string\n dash?: number[]\n cap?: string\n join?: string\n visible?: false\n}\n\nfunction strokeValue(stroke: Stroke): StrokeValue {\n return {\n color: formatColor(stroke.color, stroke.color.a),\n opacity: stroke.opacity === stroke.color.a ? undefined : stroke.opacity,\n weight: stroke.weight === 1 ? undefined : stroke.weight,\n align: stroke.align === 'INSIDE' ? undefined : STROKE_ALIGN.print(stroke.align),\n dash: stroke.dashPattern && stroke.dashPattern.length > 0 ? [...stroke.dashPattern] : undefined,\n cap: stroke.cap && STROKE_CAP.print(stroke.cap),\n join: stroke.join && STROKE_JOIN.print(stroke.join),\n visible: stroke.visible ? undefined : false\n }\n}\n\nconst STROKE_SHORTHAND: Record<string, string> = {\n color: 'stroke',\n weight: 'strokeWidth',\n align: 'strokeAlign',\n dash: 'strokeDash'\n}\n\n/** Node-level cap and join apply to strokes that do not set their own. */\nconst DEFAULT_STROKE_CAP = 'NONE'\nconst DEFAULT_STROKE_JOIN = 'MITER'\n\n/**\n * The shorthand props describe one stroke, and `strokeCap`/`strokeJoin` also set the node's\n * cap and join; they fit only when the stroke agrees with the node on both.\n */\nfunction fitsStrokeShorthand(node: SceneNode, stroke: StrokeValue): boolean {\n if (stroke.visible !== undefined || stroke.opacity !== undefined) return false\n const nodeCap = STROKE_CAP.print(node.strokeCap)\n const nodeJoin = STROKE_JOIN.print(node.strokeJoin)\n return (stroke.cap ?? nodeCap) === nodeCap && (stroke.join ?? nodeJoin) === nodeJoin\n}\n\nexport function collectStrokeProps(node: SceneNode, props: JSXProp[]): void {\n const strokes = node.strokes.map(strokeValue)\n const [only] = strokes\n const shorthand = strokes.length === 1 && fitsStrokeShorthand(node, only)\n if (shorthand) {\n for (const [key, value] of Object.entries(only)) {\n if (value !== undefined && key !== 'cap' && key !== 'join') {\n props.push([STROKE_SHORTHAND[key], value])\n }\n }\n } else if (strokes.length > 0) {\n props.push(['strokes', strokes])\n }\n if (node.strokeCap !== DEFAULT_STROKE_CAP)\n props.push(['strokeCap', STROKE_CAP.print(node.strokeCap)])\n if (node.strokeJoin !== DEFAULT_STROKE_JOIN) {\n props.push(['strokeJoin', STROKE_JOIN.print(node.strokeJoin)])\n }\n // With strokes, each stroke's own dash says it; the layer's follows the first.\n if (node.strokes.length === 0 && node.dashPattern.length > 0)\n props.push(['dashPattern', [...node.dashPattern]])\n if (node.independentStrokeWeights) {\n props.push([\n 'strokeWeights',\n {\n top: node.borderTopWeight,\n right: node.borderRightWeight,\n bottom: node.borderBottomWeight,\n left: node.borderLeftWeight\n }\n ])\n }\n}\n\nconst EFFECT_HELPERS: Record<ShadowEffect['type'], string> = {\n DROP_SHADOW: 'dropShadow',\n INNER_SHADOW: 'innerShadow',\n LAYER_BLUR: 'layerBlur',\n BACKGROUND_BLUR: 'backgroundBlur',\n FOREGROUND_BLUR: 'foregroundBlur'\n}\n\nfunction effectValue(effect: ShadowEffect): HelperCall {\n const visible = effect.visible ? undefined : false\n if (effect.type === 'DROP_SHADOW' || effect.type === 'INNER_SHADOW') {\n return helperCall(\n EFFECT_HELPERS[effect.type],\n options({\n x: effect.offset.x,\n y: effect.offset.y,\n radius: effect.radius,\n spread: effect.spread === 0 ? undefined : effect.spread,\n color: formatColor(effect.color, effect.color.a),\n visible,\n blendMode: blendMode(effect.blendMode),\n showShadowBehindNode: effect.showShadowBehindNode\n })\n )\n }\n return helperCall(\n EFFECT_HELPERS[effect.type],\n visible === undefined ? effect.radius : { radius: effect.radius, visible }\n )\n}\n\nfunction plainDropShadow(effect: Effect): string | null {\n const plain =\n effect.type === 'DROP_SHADOW' &&\n effect.spread === 0 &&\n !blendMode(effect.blendMode) &&\n effect.showShadowBehindNode === undefined\n return plain ? formatShadow(effect) : null\n}\n\n/**\n * `shadow` and `blur` describe a plain drop shadow followed by a layer blur, each optional,\n * in the order the renderer appends them; anything else needs `effects`.\n */\nfunction effectShorthand(effects: ShadowEffect[]): JSXProp[] | null {\n if (effects.some((effect) => !effect.visible)) return null\n const shadow = effects.length > 0 ? plainDropShadow(effects[0]) : null\n const rest = shadow ? effects.slice(1) : effects\n if (rest.length > 1 || rest.some((effect) => effect.type !== 'LAYER_BLUR')) return null\n const props: JSXProp[] = []\n if (shadow) props.push(['shadow', shadow])\n for (const blur of rest) props.push(['blur', blur.radius])\n return props\n}\n\n/** An effect JSX has a helper for; an imported one the modeller lacks, such as noise, has none. */\nfunction hasJSXHelper(effect: Effect): effect is ShadowEffect {\n return Object.hasOwn(EFFECT_HELPERS, effect.type)\n}\n\nexport function collectEffectProps(node: SceneNode, props: JSXProp[]): void {\n // An effect without a helper cannot be written as JSX; leaving it out keeps the source importable.\n const effects = node.effects.filter(hasJSXHelper)\n if (effects.length === 0) return\n props.push(...(effectShorthand(effects) ?? [['effects', effects.map(effectValue)]]))\n}\n","import type { SceneNode } from '@pairdraw/scene-graph'\nimport {\n figJamTextSize,\n figJamTextSizeFields,\n figJamTypeface,\n figJamTypefaceFields,\n type FigJamTextSize,\n type FigJamTypeface\n} from '@pairdraw/scene-graph/figjam'\n\nimport { FIGJAM_TEXT_SIZE, FIGJAM_TYPEFACE } from './enums'\n\n/**\n * The fields a sticky note's body or a shape's label takes from `textSize` and `typeface`, as\n * FigJam's text menus set them; the typeface keeps the size the text ends up at.\n */\nexport function figJamTextFields(\n text: Pick<SceneNode, 'fontSize'>,\n textSize: FigJamTextSize | undefined,\n typeface: FigJamTypeface | undefined\n): Partial<SceneNode> {\n const sized = textSize ? figJamTextSizeFields(textSize, typeface) : {}\n if (!typeface) return sized\n return figJamTypefaceFields(typeface, { fontSize: sized.fontSize ?? text.fontSize })\n}\n\n/** `textSize` and `typeface` as an element writes them, each left out at FigJam's default. */\nexport function figJamTextProps(\n text: Pick<SceneNode, 'fontSize' | 'fontFamily'>\n): Array<[string, string]> {\n const props: Array<[string, string]> = []\n const size = figJamTextSize(text)\n if (size !== 'small') props.push(['textSize', FIGJAM_TEXT_SIZE.print(size)])\n const typeface = figJamTypeface(text)\n if (typeface && typeface !== 'simple') props.push(['typeface', FIGJAM_TYPEFACE.print(typeface)])\n return props\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n createShapeWithText,\n SHAPE_WITH_TEXT_CORNER_RADIUS,\n SHAPE_WITH_TEXT_SIZE,\n shapeWithTextLabel\n} from '@pairdraw/scene-graph/generated'\n\nimport { SHAPE_KIND } from './enums'\nimport { collectFillProps, collectStrokeProps } from './export/paint'\nimport type { JSXProp } from './export/value'\nimport { figJamTextFields, figJamTextProps } from './figjam-text'\nimport { readElementProps, shapePropsSchema } from './schema'\nimport { plainTextOf, type TreeNode } from './tree'\n\n/**\n * The shape an element describes, with `layer`'s fields; it is named by its label, as FigJam\n * names a shape, until given a name.\n */\nexport function renderShapeNode(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n layer: Partial<SceneNode>\n) {\n const props = readElementProps(shapePropsSchema, tree.props)\n const text = plainTextOf(tree)\n const shape = createShapeWithText(\n graph,\n parentId,\n {\n ...layer,\n name: layer.name ?? (text.trim() || 'Shape with text'),\n autoRename: !layer.name,\n shapeWithTextType: props.kind ?? 'SQUARE',\n shapeTruncates: props.truncate ?? false\n },\n { text }\n )\n const label = shapeWithTextLabel(graph, shape)\n if (label) graph.updateNode(label.id, figJamTextFields(label, props.textSize, props.typeface))\n return shape\n}\n\n/**\n * A shape's own props as `<Shape>` writes them, after its name and position: the height it was\n * given rather than the height its label grew it to, so it grows the same way when read back.\n */\nexport function shapeWithTextProps(graph: SceneGraph, node: SceneNode): JSXProp[] {\n const props: JSXProp[] = []\n if (node.shapeWithTextType !== 'SQUARE') {\n props.push(['kind', SHAPE_KIND.print(node.shapeWithTextType)])\n }\n const label = shapeWithTextLabel(graph, node)\n if (label) props.push(...figJamTextProps(label))\n // A truncating shape keeps the height it has; any other grows from the height it was given.\n const height =\n !node.shapeTruncates && node.shapeUserHeight > 0 ? node.shapeUserHeight : node.height\n if (node.width !== SHAPE_WITH_TEXT_SIZE) props.push(['w', node.width])\n if (height !== SHAPE_WITH_TEXT_SIZE) props.push(['h', height])\n if (node.shapeTruncates) props.push(['truncate', true])\n if (node.rotation !== 0) props.push(['rotate', Math.round(node.rotation * 100) / 100])\n collectFillProps(node, props)\n collectStrokeProps(node, props)\n if (node.cornerRadius !== SHAPE_WITH_TEXT_CORNER_RADIUS)\n props.push(['rounded', node.cornerRadius])\n return props\n}\n\n/** The label a shape writes as its children. */\nexport function shapeWithTextLabelText(graph: SceneGraph, node: SceneNode): string {\n return shapeWithTextLabel(graph, node)?.text ?? ''\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport {\n createSticky,\n isWideSticky,\n STICKY_COLORS,\n stickyScale,\n stickySublayers\n} from '@pairdraw/scene-graph/generated'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { figJamTextFields, figJamTextProps } from './figjam-text'\nimport { readElementProps, stickyPropsSchema } from './schema'\nimport { plainTextOf, type TreeNode } from './tree'\n\n/**\n * The note an element describes, with `layer`'s fields; it is named by its body, as FigJam names\n * a note, until given a name.\n */\nexport function renderStickyNode(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n layer: Partial<SceneNode>\n) {\n const props = readElementProps(stickyPropsSchema, tree.props)\n const text = plainTextOf(tree)\n const author = props.author ?? ''\n const sticky = createSticky(\n graph,\n parentId,\n {\n text,\n author,\n authorVisible: props.authorVisible !== false && author !== '',\n color: props.color,\n wide: props.wide === true,\n scale: props.scale ?? 1\n },\n { ...layer, name: layer.name ?? (text.trim() || 'Sticky'), autoRename: !layer.name }\n )\n const body = stickySublayers(graph, sticky)?.body\n if (body) graph.updateNode(body.id, figJamTextFields(body, props.textSize, props.typeface))\n return sticky\n}\n\n/** The colour as `<Sticky>` writes it: its palette name, or a hex colour off the palette. */\nfunction colorName(color: Color): string {\n const hex = colorToHex(color)\n const named = Object.entries(STICKY_COLORS).find(([, value]) => colorToHex(value) === hex)\n return named ? named[0] : hex\n}\n\n/** A note's own props as `<Sticky>` writes them, after its name and position. */\nexport function stickyProps(graph: SceneGraph, node: SceneNode): Array<[string, unknown]> {\n const layers = stickySublayers(graph, node)\n const color = node.fills.at(0)?.color\n const props: Array<[string, unknown]> = []\n if (color) props.push(['color', colorName(color)])\n if (layers?.author.text) props.push(['author', layers.author.text])\n if (layers?.author.text && !layers.author.visible) props.push(['authorVisible', false])\n if (isWideSticky(graph, node)) props.push(['wide', true])\n if (layers) props.push(...figJamTextProps(layers.body))\n const scale = layers ? stickyScale(layers.author) : 1\n if (scale !== 1) props.push(['scale', scale])\n return props\n}\n\n/** The body a note writes as its children. */\nexport function stickyBody(graph: SceneGraph, node: SceneNode): string {\n return stickySublayers(graph, node)?.body.text ?? ''\n}\n","import { difference } from 'es-toolkit/array'\n\nimport type { NodeType, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { REKA_ELEMENTS, rekaRole } from './behaviours'\nimport { connectorBindingTarget, renderConnectorNode } from './connectors'\nimport {\n DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES,\n DESIGN_JSX_SPAN_PROPERTY_NAMES,\n DESIGN_JSX_SUPPORTED_PROPERTY_NAMES,\n DESIGN_JSX_TEXT_PARAGRAPH_PROPERTY_NAMES\n} from './definitions'\nimport {\n connectorPropsSchema,\n ownLayerPropsSchema,\n placedOwnLayerPropsSchema,\n shapeLayerPropsSchema,\n shapePropsSchema,\n stickyPropsSchema,\n type ElementPropsSchema\n} from './schema'\nimport { renderShapeNode } from './shapes-with-text'\nimport { renderStickyNode } from './stickies'\nimport type { TreeNode } from './tree'\n\n/** How an element that draws a layer of its own, such as a sticky note, renders it. */\nexport interface OwnLayerRenderer {\n /** The layer props it takes, made into fields as any layer's are. */\n layer: ElementPropsSchema\n render(graph: SceneGraph, tree: TreeNode, parentId: string, layer: Partial<SceneNode>): SceneNode\n /** The layer a variable binding of `field` goes on, when not the element's own. */\n bindingTarget?(graph: SceneGraph, node: SceneNode, field: string): string\n}\n\n/**\n * One design JSX element: what JSX names it, what it makes, the props it takes, and which layers\n * export writes as it. The renderer, the export, the prop checks, the streaming preview, and the\n * authoring reference all read this list rather than keeping their own.\n */\nexport type DesignJSXElementDefinition = {\n name: string\n /** The type its tree nodes carry, such as `frame`. */\n runtimeType: string\n description: string\n /** The layer a plain element makes; an element rendered its own way, such as `Icon`, has none. */\n nodeType?: NodeType\n /** The props it takes; every layer prop when left out. */\n props?: readonly string[]\n /** The props it takes and what each holds, for an element that reads them by this schema. */\n schema?: ElementPropsSchema\n /** How it draws its own layer, for an element that does. */\n ownLayer?: OwnLayerRenderer\n /** The layers export writes as this element. */\n writes?: readonly NodeType[]\n}\n\nfunction rekaDescription(namespace: string, part: string): string {\n const role = rekaRole(`${namespace}.${part}`)\n if (role?.role === 'root')\n return `A main component that behaves as Reka UI's ${namespace} ${part}.`\n if (role?.role === 'input') return `The text layer of a ${namespace}'s text property.`\n return `The ${namespace} ${part}, drawn by a slot of its component.`\n}\n\n/** A Reka UI element as the element list describes it. */\nfunction rekaElementDefinitions(): DesignJSXElementDefinition[] {\n return Object.entries(REKA_ELEMENTS).flatMap(([namespace, parts]) =>\n Object.keys(parts).map((part) => {\n const type = `${namespace}.${part}`\n return { name: type, runtimeType: type, description: rekaDescription(namespace, part) }\n })\n )\n}\n\nexport const DESIGN_JSX_ELEMENTS: DesignJSXElementDefinition[] = [\n {\n name: 'Frame',\n runtimeType: 'frame',\n description: 'A frame or auto-layout container.',\n nodeType: 'FRAME',\n // A set and an instance read back as frames: JSX cannot name what they come from.\n writes: ['FRAME', 'COMPONENT_SET', 'INSTANCE']\n },\n {\n name: 'Text',\n runtimeType: 'text',\n description: 'A text layer.',\n nodeType: 'TEXT',\n writes: ['TEXT']\n },\n {\n name: 'Span',\n runtimeType: 'text-span',\n description: 'Characters inside a Text, styled apart from the rest.',\n props: ['key', ...DESIGN_JSX_SPAN_PROPERTY_NAMES]\n },\n {\n name: 'Paragraph',\n runtimeType: 'text-paragraph',\n description: 'One paragraph of a Text, plain or a list item.',\n props: ['key', ...DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES]\n },\n {\n name: 'Rectangle',\n runtimeType: 'rectangle',\n description: 'A rectangle layer.',\n nodeType: 'RECTANGLE',\n writes: ['RECTANGLE', 'ROUNDED_RECTANGLE']\n },\n {\n name: 'Ellipse',\n runtimeType: 'ellipse',\n description: 'An ellipse layer.',\n nodeType: 'ELLIPSE',\n writes: ['ELLIPSE']\n },\n {\n name: 'Line',\n runtimeType: 'line',\n description: 'A line layer.',\n nodeType: 'LINE',\n writes: ['LINE']\n },\n {\n name: 'Star',\n runtimeType: 'star',\n description: 'A star layer.',\n nodeType: 'STAR',\n writes: ['STAR']\n },\n {\n name: 'Polygon',\n runtimeType: 'polygon',\n description: 'A polygon layer.',\n nodeType: 'POLYGON',\n writes: ['POLYGON']\n },\n {\n name: 'Vector',\n runtimeType: 'vector',\n description: 'A vector layer.',\n nodeType: 'VECTOR',\n writes: ['VECTOR']\n },\n {\n name: 'Group',\n runtimeType: 'group',\n description: 'A group of layers.',\n nodeType: 'GROUP',\n writes: ['GROUP']\n },\n {\n name: 'Section',\n runtimeType: 'section',\n description: 'A canvas section.',\n nodeType: 'SECTION',\n writes: ['SECTION']\n },\n {\n name: 'Component',\n runtimeType: 'component',\n description: 'A reusable component.',\n nodeType: 'COMPONENT',\n writes: ['COMPONENT']\n },\n {\n name: 'ComponentSet',\n runtimeType: 'component-set',\n description: 'A component variant set.',\n nodeType: 'COMPONENT_SET'\n },\n { name: 'Instance', runtimeType: 'instance', description: 'An instance of a component.' },\n { name: 'View', runtimeType: 'frame', description: 'An alias for Frame.', nodeType: 'FRAME' },\n {\n name: 'Rect',\n runtimeType: 'rectangle',\n description: 'An alias for Rectangle.',\n nodeType: 'RECTANGLE'\n },\n { name: 'Icon', runtimeType: 'icon', description: 'An Iconify icon.' },\n {\n name: 'Sticky',\n runtimeType: 'sticky',\n description: 'A FigJam sticky note; its text is the body.',\n schema: stickyPropsSchema,\n ownLayer: { layer: placedOwnLayerPropsSchema, render: renderStickyNode },\n writes: ['STICKY']\n },\n {\n name: 'Shape',\n runtimeType: 'shape',\n description: 'A FigJam shape with text; its text is the label.',\n schema: shapePropsSchema,\n ownLayer: { layer: shapeLayerPropsSchema, render: renderShapeNode },\n writes: ['SHAPE_WITH_TEXT']\n },\n {\n name: 'Connector',\n runtimeType: 'connector',\n description:\n 'A FigJam connector between two layers of the same JSX, named by `from` and `to`, or points.',\n schema: connectorPropsSchema,\n ownLayer: {\n layer: ownLayerPropsSchema,\n render: renderConnectorNode,\n bindingTarget: connectorBindingTarget\n },\n writes: ['CONNECTOR']\n },\n ...rekaElementDefinitions()\n]\n\n/** Props an inline `<svg>` takes besides a layer's: its markup's view box and body. */\nconst SVG_PROPERTY_NAMES = ['viewBox', 'body'] as const\n\n/**\n * Lowercase tags JSX also accepts, as HTML names them, with the layer each makes; they are\n * not written back.\n */\nconst INTRINSIC_ELEMENTS: Readonly<Record<string, NodeType | null>> = {\n componentset: 'COMPONENT_SET',\n div: 'FRAME',\n main: 'FRAME',\n header: 'FRAME',\n footer: 'FRAME',\n nav: 'FRAME',\n article: 'FRAME',\n aside: 'FRAME',\n span: 'TEXT',\n p: 'TEXT',\n h1: 'TEXT',\n h2: 'TEXT',\n h3: 'TEXT',\n h4: 'TEXT',\n h5: 'TEXT',\n h6: 'TEXT',\n // Inline SVG markup, which the artwork service draws.\n svg: null\n}\n\n/** Paragraph props describe a paragraph of a text, never a layer, unless a text sets them too. */\nconst LAYER_PROPS: ReadonlySet<string> = new Set<string>(\n difference(\n DESIGN_JSX_SUPPORTED_PROPERTY_NAMES,\n difference(DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES, DESIGN_JSX_TEXT_PARAGRAPH_PROPERTY_NAMES)\n )\n)\n\nconst BY_RUNTIME_TYPE = new Map(\n DESIGN_JSX_ELEMENTS.map((element): [string, DesignJSXElementDefinition] => [\n element.runtimeType,\n element\n ]).reverse()\n)\n\nconst PROPS_BY_RUNTIME_TYPE = new Map<string, ReadonlySet<string>>([\n ['svg', new Set([...LAYER_PROPS, ...SVG_PROPERTY_NAMES])],\n ...DESIGN_JSX_ELEMENTS.flatMap((element): [string, ReadonlySet<string>][] => {\n const props = element.schema ? Object.keys(element.schema.entries) : element.props\n return props ? [[element.runtimeType, new Set(props)]] : []\n })\n])\n\nconst TAG_BY_NODE_TYPE = new Map(\n DESIGN_JSX_ELEMENTS.flatMap((element) =>\n (element.writes ?? []).map((type): [NodeType, string] => [type, element.name])\n )\n)\n\n/** The layer an element of `runtimeType` makes, for an element without its own renderer. */\nexport function elementNodeType(runtimeType: string): NodeType | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.nodeType ?? INTRINSIC_ELEMENTS[runtimeType] ?? undefined\n}\n\n/** The props an element of `runtimeType` takes. */\nexport function elementProps(runtimeType: string): ReadonlySet<string> {\n return PROPS_BY_RUNTIME_TYPE.get(runtimeType) ?? LAYER_PROPS\n}\n\nconst BY_NAME = new Map(\n DESIGN_JSX_ELEMENTS.map((element): [string, DesignJSXElementDefinition] => [\n element.name,\n element\n ])\n)\n\n/**\n * The props an element written `<name>` takes, as the renderer checks them, for an editor that\n * checks them as they are typed; null for a name that is no element, and for an instance, which\n * also takes its component's properties by name.\n */\nexport function elementPropsByName(name: string): ReadonlySet<string> | null {\n const element = BY_NAME.get(name)\n if (!element) return Object.hasOwn(INTRINSIC_ELEMENTS, name) ? elementProps(name) : null\n return element.runtimeType === 'instance' ? null : elementProps(element.runtimeType)\n}\n\n/** The schema an element of `runtimeType` reads its props by, if it has one. */\nexport function elementSchema(runtimeType: string): ElementPropsSchema | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.schema\n}\n\n/** How an element of `runtimeType` draws its own layer, if it does. */\nexport function elementOwnLayer(runtimeType: string): OwnLayerRenderer | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.ownLayer\n}\n\n/** The element export writes a layer of `type` as, if any. */\nexport function elementTag(type: NodeType): string | undefined {\n return TAG_BY_NODE_TYPE.get(type)\n}\n\n/**\n * `const Frame = 'frame', …`: the element names a JSX string's code can use, bound to their\n * runtime types. Reka UI elements, named `Switch.Root`, are bound by their namespaces.\n */\nexport function elementBindings(): string {\n return DESIGN_JSX_ELEMENTS.filter((element) => !element.name.includes('.'))\n .map((element) => `const ${element.name} = '${element.runtimeType}'`)\n .join('\\n')\n}\n"],"mappings":";;;;;;;;;;;AAIA,SAAgB,YAAY,OAAc,UAAU,GAAW;CAC7D,OAAO,YAAY,OAAO,OAAO;AACnC;AAEA,SAAgB,aAAa,GAA0B;CACrD,IAAI,EAAE,SAAS,iBAAiB,EAAE,SAAS,gBAAgB,OAAO;CAClE,OAAO,GA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,"file":"elements.js","names":[],"sources":["../../src/export/helpers.ts","../../src/export/paint.ts","../../src/figjam-text.ts","../../src/shapes-with-text.ts","../../src/stickies.ts","../../src/elements.ts"],"sourcesContent":["import type { SceneGraph, SceneNode, Effect, GridTrack } from '@pairdraw/scene-graph'\nimport { colorToHex8 } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nexport function formatColor(color: Color, opacity = 1): string {\n return colorToHex8(color, opacity)\n}\n\nexport function formatShadow(e: Effect): string | null {\n if (e.type !== 'DROP_SHADOW' && e.type !== 'INNER_SHADOW') return null\n return `${e.offset.x} ${e.offset.y} ${e.radius} ${formatColor(e.color, e.color.a)}`\n}\n\nexport function getNodeContext(node: SceneNode, graph: SceneGraph) {\n const parent = node.parentId ? graph.getNode(node.parentId) : null\n return {\n isAutoLayout: node.layoutMode !== 'NONE',\n isGrid: node.layoutMode === 'GRID',\n isFlex: node.layoutMode === 'HORIZONTAL' || node.layoutMode === 'VERTICAL',\n parentIsAutoLayout: parent ? parent.layoutMode !== 'NONE' : false,\n parentIsGrid: parent ? parent.layoutMode === 'GRID' : false\n }\n}\n\nexport type PaddingEdges = { pt: number; pr: number; pb: number; pl: number }\n\nexport function collectPadding(node: SceneNode): PaddingEdges | null {\n const { paddingTop: pt, paddingRight: pr, paddingBottom: pb, paddingLeft: pl } = node\n if (pt === 0 && pr === 0 && pb === 0 && pl === 0) return null\n return { pt, pr, pb, pl }\n}\n\nexport function emitPadding<T>(\n edges: PaddingEdges,\n uniform: (v: number) => T,\n symmetric: (y: number, x: number) => T[],\n individual: (edges: PaddingEdges) => T[]\n): T[] {\n const { pt, pr, pb, pl } = edges\n if (pt === pr && pr === pb && pb === pl) return [uniform(pt)]\n if (pt === pb && pl === pr) return symmetric(pt, pl)\n return individual(edges)\n}\n\nexport interface CornerRadii {\n tl: number\n tr: number\n br: number\n bl: number\n}\n\nexport function collectCornerRadii(node: SceneNode): CornerRadii | null {\n if (node.independentCorners) {\n const corners = {\n tl: node.topLeftRadius,\n tr: node.topRightRadius,\n br: node.bottomRightRadius,\n bl: node.bottomLeftRadius\n }\n return Object.values(corners).some((radius) => radius > 0) ? corners : null\n }\n if (node.cornerRadius <= 0) return null\n const r = node.cornerRadius\n return { tl: r, tr: r, br: r, bl: r }\n}\n\nfunction formatTrack(t: GridTrack): string {\n if (t.sizing === 'FR') return `${t.value}fr`\n if (t.sizing === 'FIXED') return `${t.value}px`\n return 'auto'\n}\n\nexport function formatTracks(tracks: GridTrack[]): string {\n return tracks.map(formatTrack).join(' ')\n}\n","import type {\n Effect,\n Fill,\n GradientTransform,\n SceneNode,\n ShaderEffect,\n Stroke\n} from '@pairdraw/scene-graph'\nimport { gradientTransformRows, isIdentityGradientTransform } from '@pairdraw/scene-graph/gradient'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\nimport { isShaderPresetPaint, shaderOfPaint } from '@pairdraw/scene-graph/shaders'\n\nimport { STROKE_ALIGN, STROKE_CAP, STROKE_JOIN } from '../enums'\nimport { formatColor, formatShadow } from './helpers'\nimport { helperCall, plainValue, type HelperCall, type JSXProp, type JSXValue } from './value'\n\nconst GRADIENT_HELPERS: Partial<Record<Fill['type'], string>> = {\n GRADIENT_LINEAR: 'linearGradient',\n GRADIENT_RADIAL: 'radialGradient',\n GRADIENT_ANGULAR: 'angularGradient',\n GRADIENT_DIAMOND: 'diamondGradient'\n}\n\nfunction isIdentity(transform: GradientTransform | undefined): boolean {\n return !transform || isIdentityGradientTransform(transform)\n}\n\n/** A paint transform as authors write it, in Figma's rows. */\nfunction rows(transform: GradientTransform | undefined) {\n return transform && gradientTransformRows(transform)\n}\n\n/** Paints and effects imported from Figma often spell out the default blend mode. */\nfunction blendMode(mode: Fill['blendMode']): Fill['blendMode'] {\n return mode === 'NORMAL' || mode === 'PASS_THROUGH' ? undefined : mode\n}\n\ntype Options = Record<string, JSXValue | undefined>\n\n/** Helper options with defaults left out, or `undefined` when none differ. */\nfunction options(entries: Options): Options | undefined {\n return Object.values(entries).some((value) => value !== undefined) ? entries : undefined\n}\n\nfunction fillValue(fill: Fill, node: SceneNode): JSXValue {\n const visible = fill.visible ? undefined : false\n const shader = shaderOfPaint(node, fill)\n if (shader && isShaderPresetPaint(shader)) {\n // A preset with nothing but effects is written as just its effects.\n const { components, ...rest } = shader.preset\n return helperCall(\n 'shader',\n plainValue(Object.keys(rest).length === 0 ? components : shader.preset),\n options({\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode)\n })\n )\n }\n // Code the user wrote comes back as the same paint only through its own helper.\n if (shader) {\n const uniforms = shader.uniforms ?? {}\n return helperCall(\n 'shaderSource',\n shader.source,\n options({\n uniforms: Object.keys(uniforms).length === 0 ? undefined : plainValue(uniforms),\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode)\n })\n )\n }\n if (fill.type === 'SOLID') {\n const color = formatColor(fill.color, fill.color.a)\n const opacity = fill.opacity === fill.color.a ? undefined : fill.opacity\n return helperCall(\n 'solid',\n color,\n options({ opacity, visible, blendMode: blendMode(fill.blendMode) })\n )\n }\n const helper = GRADIENT_HELPERS[fill.type]\n if (helper && fill.gradientStops) {\n const stops = fill.gradientStops.map((stop) => [\n formatColor(stop.color, stop.color.a),\n stop.position\n ])\n return helperCall(\n helper,\n stops,\n options({\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode),\n transform: isIdentity(fill.gradientTransform)\n ? undefined\n : plainValue(rows(fill.gradientTransform))\n })\n )\n }\n // Image, pattern, and other paints have no helper; they render back from their fields.\n return plainValue({\n ...fill,\n gradientTransform: rows(fill.gradientTransform),\n imageTransform: rows(fill.imageTransform)\n })\n}\n\n/** A single visible solid paint fits the `bg` or text `color` shorthand. */\nfunction solidShorthand(fills: Fill[]): string | null {\n if (fills.length !== 1) return null\n const [fill] = fills\n if (fill.type !== 'SOLID' || !fill.visible || blendMode(fill.blendMode)) return null\n // The shorthand has one alpha; a fill whose opacity differs from its colour's needs `solid`.\n if (fill.opacity !== fill.color.a) return null\n return formatColor(fill.color, fill.color.a)\n}\n\n/** One paint as a colour prop takes it: a colour string when it is plain, its helper otherwise. */\nexport function paintPropValue(fill: Fill, node: SceneNode): JSXValue {\n return solidShorthand([fill]) ?? fillValue(fill, node)\n}\n\nexport function collectFillProps(node: SceneNode, props: JSXProp[]): void {\n if (node.fills.length === 0) {\n // A text is painted black unless it says it is not painted.\n if (node.type === 'TEXT') props.push(['fills', []])\n return\n }\n const shorthand = solidShorthand(node.fills)\n if (shorthand) props.push([node.type === 'TEXT' ? 'color' : 'bg', shorthand])\n else props.push(['fills', node.fills.map((fill) => fillValue(fill, node))])\n}\n\ninterface StrokeValue {\n [key: string]: JSXValue | undefined\n color: string\n /** Only when it differs from the colour's alpha, which the colour already carries. */\n opacity?: number\n weight?: number\n align?: string\n dash?: number[]\n cap?: string\n join?: string\n visible?: false\n}\n\nfunction strokeValue(stroke: Stroke): StrokeValue {\n return {\n color: formatColor(stroke.color, stroke.color.a),\n opacity: stroke.opacity === stroke.color.a ? undefined : stroke.opacity,\n weight: stroke.weight === 1 ? undefined : stroke.weight,\n align: stroke.align === 'INSIDE' ? undefined : STROKE_ALIGN.print(stroke.align),\n dash: stroke.dashPattern && stroke.dashPattern.length > 0 ? [...stroke.dashPattern] : undefined,\n cap: stroke.cap && STROKE_CAP.print(stroke.cap),\n join: stroke.join && STROKE_JOIN.print(stroke.join),\n visible: stroke.visible ? undefined : false\n }\n}\n\nconst STROKE_SHORTHAND: Record<string, string> = {\n color: 'stroke',\n weight: 'strokeWidth',\n align: 'strokeAlign',\n dash: 'strokeDash'\n}\n\n/** Node-level cap and join apply to strokes that do not set their own. */\nconst DEFAULT_STROKE_CAP = 'NONE'\nconst DEFAULT_STROKE_JOIN = 'MITER'\n\n/**\n * The shorthand props describe one stroke, and `strokeCap`/`strokeJoin` also set the node's\n * cap and join; they fit only when the stroke agrees with the node on both.\n */\nfunction fitsStrokeShorthand(node: SceneNode, stroke: StrokeValue): boolean {\n if (stroke.visible !== undefined || stroke.opacity !== undefined) return false\n const nodeCap = STROKE_CAP.print(node.strokeCap)\n const nodeJoin = STROKE_JOIN.print(node.strokeJoin)\n return (stroke.cap ?? nodeCap) === nodeCap && (stroke.join ?? nodeJoin) === nodeJoin\n}\n\nexport function collectStrokeProps(node: SceneNode, props: JSXProp[]): void {\n const strokes = node.strokes.map(strokeValue)\n const [only] = strokes\n const shorthand = strokes.length === 1 && fitsStrokeShorthand(node, only)\n if (shorthand) {\n for (const [key, value] of Object.entries(only)) {\n if (value !== undefined && key !== 'cap' && key !== 'join') {\n props.push([STROKE_SHORTHAND[key], value])\n }\n }\n } else if (strokes.length > 0) {\n props.push(['strokes', strokes])\n }\n if (node.strokeCap !== DEFAULT_STROKE_CAP)\n props.push(['strokeCap', STROKE_CAP.print(node.strokeCap)])\n if (node.strokeJoin !== DEFAULT_STROKE_JOIN) {\n props.push(['strokeJoin', STROKE_JOIN.print(node.strokeJoin)])\n }\n // With strokes, each stroke's own dash says it; the layer's follows the first.\n if (node.strokes.length === 0 && node.dashPattern.length > 0)\n props.push(['dashPattern', [...node.dashPattern]])\n if (node.independentStrokeWeights) {\n props.push([\n 'strokeWeights',\n {\n top: node.borderTopWeight,\n right: node.borderRightWeight,\n bottom: node.borderBottomWeight,\n left: node.borderLeftWeight\n }\n ])\n }\n}\n\nconst EFFECT_HELPERS: Record<Exclude<Effect['type'], 'SHADER'>, string> = {\n DROP_SHADOW: 'dropShadow',\n INNER_SHADOW: 'innerShadow',\n LAYER_BLUR: 'layerBlur',\n BACKGROUND_BLUR: 'backgroundBlur',\n FOREGROUND_BLUR: 'foregroundBlur',\n NOISE: 'noise',\n TEXTURE: 'texture'\n}\n\n/** A grain size as one number when both axes match, as Figma's plugin API writes it. */\nfunction noiseSizeValue(size: Vector): JSXValue {\n return size.x === size.y ? size.x : { x: size.x, y: size.y }\n}\n\nfunction effectValue(effect: Exclude<Effect, ShaderEffect>): HelperCall {\n const visible = effect.visible ? undefined : false\n if (effect.type === 'DROP_SHADOW' || effect.type === 'INNER_SHADOW') {\n return helperCall(\n EFFECT_HELPERS[effect.type],\n options({\n x: effect.offset.x,\n y: effect.offset.y,\n radius: effect.radius,\n spread: effect.spread === 0 ? undefined : effect.spread,\n color: formatColor(effect.color, effect.color.a),\n visible,\n blendMode: blendMode(effect.blendMode),\n showShadowBehindNode: effect.showShadowBehindNode\n })\n )\n }\n if (effect.type === 'NOISE') {\n const grain = effect.noise\n return helperCall(\n EFFECT_HELPERS.NOISE,\n options({\n noiseType: grain.noiseType,\n noiseSize: noiseSizeValue(grain.noiseSize),\n density: grain.density,\n color: formatColor(effect.color, effect.color.a),\n secondaryColor: grain.secondaryColor\n ? formatColor(grain.secondaryColor, grain.secondaryColor.a)\n : undefined,\n opacity: grain.opacity,\n seed: grain.seed,\n visible\n })\n )\n }\n if (effect.type === 'TEXTURE') {\n const grain = effect.texture\n return helperCall(\n EFFECT_HELPERS.TEXTURE,\n options({\n noiseSize: noiseSizeValue(grain.noiseSize),\n radius: effect.radius,\n clipToShape: grain.clipToShape,\n seed: grain.seed,\n visible\n })\n )\n }\n return helperCall(\n EFFECT_HELPERS[effect.type],\n visible === undefined ? effect.radius : { radius: effect.radius, visible }\n )\n}\n\nfunction plainDropShadow(effect: Effect): string | null {\n const plain =\n effect.type === 'DROP_SHADOW' &&\n effect.spread === 0 &&\n !blendMode(effect.blendMode) &&\n effect.showShadowBehindNode === undefined\n return plain ? formatShadow(effect) : null\n}\n\n/**\n * `shadow` and `blur` describe a plain drop shadow followed by a layer blur, each optional,\n * in the order the renderer appends them; anything else needs `effects`.\n */\nfunction effectShorthand(effects: Effect[]): JSXProp[] | null {\n if (effects.some((effect) => !effect.visible)) return null\n const shadow = effects.length > 0 ? plainDropShadow(effects[0]) : null\n const rest = shadow ? effects.slice(1) : effects\n if (rest.length > 1 || rest.some((effect) => effect.type !== 'LAYER_BLUR')) return null\n const props: JSXProp[] = []\n if (shadow) props.push(['shadow', shadow])\n for (const blur of rest) {\n if (blur.type === 'LAYER_BLUR') props.push(['blur', blur.radius])\n }\n return props\n}\n\n/** An effect JSX has a helper for; a shader effect is not written back as JSX source. */\nfunction hasJSXHelper(effect: Effect): effect is Exclude<Effect, ShaderEffect> {\n return effect.type !== 'SHADER' && Object.hasOwn(EFFECT_HELPERS, effect.type)\n}\n\nexport function collectEffectProps(node: SceneNode, props: JSXProp[]): void {\n // An effect without a helper cannot be written as JSX; leaving it out keeps the source importable.\n const effects = node.effects.filter(hasJSXHelper)\n if (effects.length === 0) return\n props.push(...(effectShorthand(effects) ?? [['effects', effects.map(effectValue)]]))\n}\n","import type { SceneNode } from '@pairdraw/scene-graph'\nimport {\n figJamTextSize,\n figJamTextSizeFields,\n figJamTypeface,\n figJamTypefaceFields,\n type FigJamTextSize,\n type FigJamTypeface\n} from '@pairdraw/scene-graph/figjam'\n\nimport { FIGJAM_TEXT_SIZE, FIGJAM_TYPEFACE } from './enums'\n\n/**\n * The fields a sticky note's body or a shape's label takes from `textSize` and `typeface`, as\n * FigJam's text menus set them; the typeface keeps the size the text ends up at.\n */\nexport function figJamTextFields(\n text: Pick<SceneNode, 'fontSize'>,\n textSize: FigJamTextSize | undefined,\n typeface: FigJamTypeface | undefined\n): Partial<SceneNode> {\n const sized = textSize ? figJamTextSizeFields(textSize, typeface) : {}\n if (!typeface) return sized\n return figJamTypefaceFields(typeface, { fontSize: sized.fontSize ?? text.fontSize })\n}\n\n/** `textSize` and `typeface` as an element writes them, each left out at FigJam's default. */\nexport function figJamTextProps(\n text: Pick<SceneNode, 'fontSize' | 'fontFamily'>\n): Array<[string, string]> {\n const props: Array<[string, string]> = []\n const size = figJamTextSize(text)\n if (size !== 'small') props.push(['textSize', FIGJAM_TEXT_SIZE.print(size)])\n const typeface = figJamTypeface(text)\n if (typeface && typeface !== 'simple') props.push(['typeface', FIGJAM_TYPEFACE.print(typeface)])\n return props\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n createShapeWithText,\n SHAPE_WITH_TEXT_CORNER_RADIUS,\n SHAPE_WITH_TEXT_SIZE,\n shapeWithTextLabel\n} from '@pairdraw/scene-graph/generated'\n\nimport { SHAPE_KIND } from './enums'\nimport { collectFillProps, collectStrokeProps } from './export/paint'\nimport type { JSXProp } from './export/value'\nimport { figJamTextFields, figJamTextProps } from './figjam-text'\nimport { readElementProps, shapePropsSchema } from './schema'\nimport { plainTextOf, type TreeNode } from './tree'\n\n/**\n * The shape an element describes, with `layer`'s fields; it is named by its label, as FigJam\n * names a shape, until given a name.\n */\nexport function renderShapeNode(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n layer: Partial<SceneNode>\n) {\n const props = readElementProps(shapePropsSchema, tree.props)\n const text = plainTextOf(tree)\n const shape = createShapeWithText(\n graph,\n parentId,\n {\n ...layer,\n name: layer.name ?? (text.trim() || 'Shape with text'),\n autoRename: !layer.name,\n shapeWithTextType: props.kind ?? 'SQUARE',\n shapeTruncates: props.truncate ?? false\n },\n { text }\n )\n const label = shapeWithTextLabel(graph, shape)\n if (label) graph.updateNode(label.id, figJamTextFields(label, props.textSize, props.typeface))\n return shape\n}\n\n/**\n * A shape's own props as `<Shape>` writes them, after its name and position: the height it was\n * given rather than the height its label grew it to, so it grows the same way when read back.\n */\nexport function shapeWithTextProps(graph: SceneGraph, node: SceneNode): JSXProp[] {\n const props: JSXProp[] = []\n if (node.shapeWithTextType !== 'SQUARE') {\n props.push(['kind', SHAPE_KIND.print(node.shapeWithTextType)])\n }\n const label = shapeWithTextLabel(graph, node)\n if (label) props.push(...figJamTextProps(label))\n // A truncating shape keeps the height it has; any other grows from the height it was given.\n const height =\n !node.shapeTruncates && node.shapeUserHeight > 0 ? node.shapeUserHeight : node.height\n if (node.width !== SHAPE_WITH_TEXT_SIZE) props.push(['w', node.width])\n if (height !== SHAPE_WITH_TEXT_SIZE) props.push(['h', height])\n if (node.shapeTruncates) props.push(['truncate', true])\n if (node.rotation !== 0) props.push(['rotate', Math.round(node.rotation * 100) / 100])\n collectFillProps(node, props)\n collectStrokeProps(node, props)\n if (node.cornerRadius !== SHAPE_WITH_TEXT_CORNER_RADIUS)\n props.push(['rounded', node.cornerRadius])\n return props\n}\n\n/** The label a shape writes as its children. */\nexport function shapeWithTextLabelText(graph: SceneGraph, node: SceneNode): string {\n return shapeWithTextLabel(graph, node)?.text ?? ''\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport {\n createSticky,\n isWideSticky,\n STICKY_COLORS,\n stickyScale,\n stickySublayers\n} from '@pairdraw/scene-graph/generated'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { figJamTextFields, figJamTextProps } from './figjam-text'\nimport { readElementProps, stickyPropsSchema } from './schema'\nimport { plainTextOf, type TreeNode } from './tree'\n\n/**\n * The note an element describes, with `layer`'s fields; it is named by its body, as FigJam names\n * a note, until given a name.\n */\nexport function renderStickyNode(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n layer: Partial<SceneNode>\n) {\n const props = readElementProps(stickyPropsSchema, tree.props)\n const text = plainTextOf(tree)\n const author = props.author ?? ''\n const sticky = createSticky(\n graph,\n parentId,\n {\n text,\n author,\n authorVisible: props.authorVisible !== false && author !== '',\n color: props.color,\n wide: props.wide === true,\n scale: props.scale ?? 1\n },\n { ...layer, name: layer.name ?? (text.trim() || 'Sticky'), autoRename: !layer.name }\n )\n const body = stickySublayers(graph, sticky)?.body\n if (body) graph.updateNode(body.id, figJamTextFields(body, props.textSize, props.typeface))\n return sticky\n}\n\n/** The colour as `<Sticky>` writes it: its palette name, or a hex colour off the palette. */\nfunction colorName(color: Color): string {\n const hex = colorToHex(color)\n const named = Object.entries(STICKY_COLORS).find(([, value]) => colorToHex(value) === hex)\n return named ? named[0] : hex\n}\n\n/** A note's own props as `<Sticky>` writes them, after its name and position. */\nexport function stickyProps(graph: SceneGraph, node: SceneNode): Array<[string, unknown]> {\n const layers = stickySublayers(graph, node)\n const color = node.fills.at(0)?.color\n const props: Array<[string, unknown]> = []\n if (color) props.push(['color', colorName(color)])\n if (layers?.author.text) props.push(['author', layers.author.text])\n if (layers?.author.text && !layers.author.visible) props.push(['authorVisible', false])\n if (isWideSticky(graph, node)) props.push(['wide', true])\n if (layers) props.push(...figJamTextProps(layers.body))\n const scale = layers ? stickyScale(layers.author) : 1\n if (scale !== 1) props.push(['scale', scale])\n return props\n}\n\n/** The body a note writes as its children. */\nexport function stickyBody(graph: SceneGraph, node: SceneNode): string {\n return stickySublayers(graph, node)?.body.text ?? ''\n}\n","import { difference } from 'es-toolkit/array'\n\nimport type { NodeType, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { REKA_ELEMENTS, rekaRole } from './behaviours'\nimport { connectorBindingTarget, renderConnectorNode } from './connectors'\nimport {\n DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES,\n DESIGN_JSX_SPAN_PROPERTY_NAMES,\n DESIGN_JSX_SUPPORTED_PROPERTY_NAMES,\n DESIGN_JSX_TEXT_PARAGRAPH_PROPERTY_NAMES\n} from './definitions'\nimport {\n connectorPropsSchema,\n ownLayerPropsSchema,\n placedOwnLayerPropsSchema,\n shapeLayerPropsSchema,\n shapePropsSchema,\n stickyPropsSchema,\n type ElementPropsSchema\n} from './schema'\nimport { renderShapeNode } from './shapes-with-text'\nimport { renderStickyNode } from './stickies'\nimport type { TreeNode } from './tree'\n\n/** How an element that draws a layer of its own, such as a sticky note, renders it. */\nexport interface OwnLayerRenderer {\n /** The layer props it takes, made into fields as any layer's are. */\n layer: ElementPropsSchema\n render(graph: SceneGraph, tree: TreeNode, parentId: string, layer: Partial<SceneNode>): SceneNode\n /** The layer a variable binding of `field` goes on, when not the element's own. */\n bindingTarget?(graph: SceneGraph, node: SceneNode, field: string): string\n}\n\n/**\n * One design JSX element: what JSX names it, what it makes, the props it takes, and which layers\n * export writes as it. The renderer, the export, the prop checks, the streaming preview, and the\n * authoring reference all read this list rather than keeping their own.\n */\nexport type DesignJSXElementDefinition = {\n name: string\n /** The type its tree nodes carry, such as `frame`. */\n runtimeType: string\n description: string\n /** The layer a plain element makes; an element rendered its own way, such as `Icon`, has none. */\n nodeType?: NodeType\n /** The props it takes; every layer prop when left out. */\n props?: readonly string[]\n /** The props it takes and what each holds, for an element that reads them by this schema. */\n schema?: ElementPropsSchema\n /** How it draws its own layer, for an element that does. */\n ownLayer?: OwnLayerRenderer\n /** The layers export writes as this element. */\n writes?: readonly NodeType[]\n}\n\nfunction rekaDescription(namespace: string, part: string): string {\n const role = rekaRole(`${namespace}.${part}`)\n if (role?.role === 'root')\n return `A main component that behaves as Reka UI's ${namespace} ${part}.`\n if (role?.role === 'input') return `The text layer of a ${namespace}'s text property.`\n return `The ${namespace} ${part}, drawn by a slot of its component.`\n}\n\n/** A Reka UI element as the element list describes it. */\nfunction rekaElementDefinitions(): DesignJSXElementDefinition[] {\n return Object.entries(REKA_ELEMENTS).flatMap(([namespace, parts]) =>\n Object.keys(parts).map((part) => {\n const type = `${namespace}.${part}`\n return { name: type, runtimeType: type, description: rekaDescription(namespace, part) }\n })\n )\n}\n\nexport const DESIGN_JSX_ELEMENTS: DesignJSXElementDefinition[] = [\n {\n name: 'Frame',\n runtimeType: 'frame',\n description: 'A frame or auto-layout container.',\n nodeType: 'FRAME',\n // A set and an instance read back as frames: JSX cannot name what they come from.\n writes: ['FRAME', 'COMPONENT_SET', 'INSTANCE']\n },\n {\n name: 'Text',\n runtimeType: 'text',\n description: 'A text layer.',\n nodeType: 'TEXT',\n writes: ['TEXT']\n },\n {\n name: 'Span',\n runtimeType: 'text-span',\n description: 'Characters inside a Text, styled apart from the rest.',\n props: ['key', ...DESIGN_JSX_SPAN_PROPERTY_NAMES]\n },\n {\n name: 'Paragraph',\n runtimeType: 'text-paragraph',\n description: 'One paragraph of a Text, plain or a list item.',\n props: ['key', ...DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES]\n },\n {\n name: 'Rectangle',\n runtimeType: 'rectangle',\n description: 'A rectangle layer.',\n nodeType: 'RECTANGLE',\n writes: ['RECTANGLE', 'ROUNDED_RECTANGLE']\n },\n {\n name: 'Ellipse',\n runtimeType: 'ellipse',\n description: 'An ellipse layer.',\n nodeType: 'ELLIPSE',\n writes: ['ELLIPSE']\n },\n {\n name: 'Line',\n runtimeType: 'line',\n description: 'A line layer.',\n nodeType: 'LINE',\n writes: ['LINE']\n },\n {\n name: 'Star',\n runtimeType: 'star',\n description: 'A star layer.',\n nodeType: 'STAR',\n writes: ['STAR']\n },\n {\n name: 'Polygon',\n runtimeType: 'polygon',\n description: 'A polygon layer.',\n nodeType: 'POLYGON',\n writes: ['POLYGON']\n },\n {\n name: 'Vector',\n runtimeType: 'vector',\n description: 'A vector layer.',\n nodeType: 'VECTOR',\n writes: ['VECTOR', 'BOOLEAN_OPERATION']\n },\n {\n name: 'Group',\n runtimeType: 'group',\n description: 'A group of layers.',\n nodeType: 'GROUP',\n writes: ['GROUP']\n },\n {\n name: 'Section',\n runtimeType: 'section',\n description: 'A canvas section.',\n nodeType: 'SECTION',\n writes: ['SECTION']\n },\n {\n name: 'Component',\n runtimeType: 'component',\n description: 'A reusable component.',\n nodeType: 'COMPONENT',\n writes: ['COMPONENT']\n },\n {\n name: 'ComponentSet',\n runtimeType: 'component-set',\n description: 'A component variant set.',\n nodeType: 'COMPONENT_SET'\n },\n { name: 'Instance', runtimeType: 'instance', description: 'An instance of a component.' },\n { name: 'View', runtimeType: 'frame', description: 'An alias for Frame.', nodeType: 'FRAME' },\n {\n name: 'Rect',\n runtimeType: 'rectangle',\n description: 'An alias for Rectangle.',\n nodeType: 'RECTANGLE'\n },\n { name: 'Icon', runtimeType: 'icon', description: 'An Iconify icon.' },\n {\n name: 'Sticky',\n runtimeType: 'sticky',\n description: 'A FigJam sticky note; its text is the body.',\n schema: stickyPropsSchema,\n ownLayer: { layer: placedOwnLayerPropsSchema, render: renderStickyNode },\n writes: ['STICKY']\n },\n {\n name: 'Shape',\n runtimeType: 'shape',\n description: 'A FigJam shape with text; its text is the label.',\n schema: shapePropsSchema,\n ownLayer: { layer: shapeLayerPropsSchema, render: renderShapeNode },\n writes: ['SHAPE_WITH_TEXT']\n },\n {\n name: 'Connector',\n runtimeType: 'connector',\n description:\n 'A FigJam connector between two layers of the same JSX, named by `from` and `to`, or points.',\n schema: connectorPropsSchema,\n ownLayer: {\n layer: ownLayerPropsSchema,\n render: renderConnectorNode,\n bindingTarget: connectorBindingTarget\n },\n writes: ['CONNECTOR']\n },\n ...rekaElementDefinitions()\n]\n\n/** Props an inline `<svg>` takes besides a layer's: its markup's view box and body. */\nconst SVG_PROPERTY_NAMES = ['viewBox', 'body'] as const\n\n/**\n * Lowercase tags JSX also accepts, as HTML names them, with the layer each makes; they are\n * not written back.\n */\nconst INTRINSIC_ELEMENTS: Readonly<Record<string, NodeType | null>> = {\n componentset: 'COMPONENT_SET',\n div: 'FRAME',\n main: 'FRAME',\n header: 'FRAME',\n footer: 'FRAME',\n nav: 'FRAME',\n article: 'FRAME',\n aside: 'FRAME',\n span: 'TEXT',\n p: 'TEXT',\n h1: 'TEXT',\n h2: 'TEXT',\n h3: 'TEXT',\n h4: 'TEXT',\n h5: 'TEXT',\n h6: 'TEXT',\n // Inline SVG markup, which the artwork service draws.\n svg: null\n}\n\n/** Paragraph props describe a paragraph of a text, never a layer, unless a text sets them too. */\nconst LAYER_PROPS: ReadonlySet<string> = new Set<string>(\n difference(\n DESIGN_JSX_SUPPORTED_PROPERTY_NAMES,\n difference(DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES, DESIGN_JSX_TEXT_PARAGRAPH_PROPERTY_NAMES)\n )\n)\n\nconst BY_RUNTIME_TYPE = new Map(\n DESIGN_JSX_ELEMENTS.map((element): [string, DesignJSXElementDefinition] => [\n element.runtimeType,\n element\n ]).reverse()\n)\n\nconst PROPS_BY_RUNTIME_TYPE = new Map<string, ReadonlySet<string>>([\n ['svg', new Set([...LAYER_PROPS, ...SVG_PROPERTY_NAMES])],\n ...DESIGN_JSX_ELEMENTS.flatMap((element): [string, ReadonlySet<string>][] => {\n const props = element.schema ? Object.keys(element.schema.entries) : element.props\n return props ? [[element.runtimeType, new Set(props)]] : []\n })\n])\n\nconst TAG_BY_NODE_TYPE = new Map(\n DESIGN_JSX_ELEMENTS.flatMap((element) =>\n (element.writes ?? []).map((type): [NodeType, string] => [type, element.name])\n )\n)\n\n/** The layer an element of `runtimeType` makes, for an element without its own renderer. */\nexport function elementNodeType(runtimeType: string): NodeType | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.nodeType ?? INTRINSIC_ELEMENTS[runtimeType] ?? undefined\n}\n\n/** The props an element of `runtimeType` takes. */\nexport function elementProps(runtimeType: string): ReadonlySet<string> {\n return PROPS_BY_RUNTIME_TYPE.get(runtimeType) ?? LAYER_PROPS\n}\n\nconst BY_NAME = new Map(\n DESIGN_JSX_ELEMENTS.map((element): [string, DesignJSXElementDefinition] => [\n element.name,\n element\n ])\n)\n\n/**\n * The props an element written `<name>` takes, as the renderer checks them, for an editor that\n * checks them as they are typed; null for a name that is no element, and for an instance, which\n * also takes its component's properties by name.\n */\nexport function elementPropsByName(name: string): ReadonlySet<string> | null {\n const element = BY_NAME.get(name)\n if (!element) return Object.hasOwn(INTRINSIC_ELEMENTS, name) ? elementProps(name) : null\n return element.runtimeType === 'instance' ? null : elementProps(element.runtimeType)\n}\n\n/** The schema an element of `runtimeType` reads its props by, if it has one. */\nexport function elementSchema(runtimeType: string): ElementPropsSchema | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.schema\n}\n\n/** How an element of `runtimeType` draws its own layer, if it does. */\nexport function elementOwnLayer(runtimeType: string): OwnLayerRenderer | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.ownLayer\n}\n\n/** The element export writes a layer of `type` as, if any. */\nexport function elementTag(type: NodeType): string | undefined {\n return TAG_BY_NODE_TYPE.get(type)\n}\n\n/**\n * `const Frame = 'frame', …`: the element names a JSX string's code can use, bound to their\n * runtime types. Reka UI elements, named `Switch.Root`, are bound by their namespaces.\n */\nexport function elementBindings(): string {\n return DESIGN_JSX_ELEMENTS.filter((element) => !element.name.includes('.'))\n .map((element) => `const ${element.name} = '${element.runtimeType}'`)\n .join('\\n')\n}\n"],"mappings":";;;;;;;;;;;AAIA,SAAgB,YAAY,OAAc,UAAU,GAAW;CAC7D,OAAO,YAAY,OAAO,OAAO;AACnC;AAEA,SAAgB,aAAa,GAA0B;CACrD,IAAI,EAAE,SAAS,iBAAiB,EAAE,SAAS,gBAAgB,OAAO;CAClE,OAAO,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC;AAClF;AAEA,SAAgB,eAAe,MAAiB,OAAmB;CACjE,MAAM,SAAS,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI;CAC9D,OAAO;EACL,cAAc,KAAK,eAAe;EAClC,QAAQ,KAAK,eAAe;EAC5B,QAAQ,KAAK,eAAe,gBAAgB,KAAK,eAAe;EAChE,oBAAoB,SAAS,OAAO,eAAe,SAAS;EAC5D,cAAc,SAAS,OAAO,eAAe,SAAS;CACxD;AACF;AAIA,SAAgB,eAAe,MAAsC;CACnE,MAAM,EAAE,YAAY,IAAI,cAAc,IAAI,eAAe,IAAI,aAAa,OAAO;CACjF,IAAI,OAAO,KAAK,OAAO,KAAK,OAAO,KAAK,OAAO,GAAG,OAAO;CACzD,OAAO;EAAE;EAAI;EAAI;EAAI;CAAG;AAC1B;AAEA,SAAgB,YACd,OACA,SACA,WACA,YACK;CACL,MAAM,EAAE,IAAI,IAAI,IAAI,OAAO;CAC3B,IAAI,OAAO,MAAM,OAAO,MAAM,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;CAC5D,IAAI,OAAO,MAAM,OAAO,IAAI,OAAO,UAAU,IAAI,EAAE;CACnD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