@pairdraw/design-jsx 0.0.0-stage → 0.16.1

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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/chunks/attributes.js +32 -0
  4. package/dist/chunks/attributes.js.map +1 -0
  5. package/dist/chunks/behaviours/elements.js +321 -0
  6. package/dist/chunks/behaviours/elements.js.map +1 -0
  7. package/dist/chunks/behaviours/render.js +368 -0
  8. package/dist/chunks/behaviours/render.js.map +1 -0
  9. package/dist/chunks/component-properties.js +809 -0
  10. package/dist/chunks/component-properties.js.map +1 -0
  11. package/dist/chunks/components.js +78 -0
  12. package/dist/chunks/components.js.map +1 -0
  13. package/dist/chunks/connectors.js +290 -0
  14. package/dist/chunks/connectors.js.map +1 -0
  15. package/dist/chunks/effects.js +57 -0
  16. package/dist/chunks/effects.js.map +1 -0
  17. package/dist/chunks/elements.js +618 -0
  18. package/dist/chunks/elements.js.map +1 -0
  19. package/dist/chunks/export/behaviours.js +113 -0
  20. package/dist/chunks/export/behaviours.js.map +1 -0
  21. package/dist/chunks/export/bindings.js +273 -0
  22. package/dist/chunks/export/bindings.js.map +1 -0
  23. package/dist/chunks/export/decoration.js +96 -0
  24. package/dist/chunks/export/decoration.js.map +1 -0
  25. package/dist/chunks/export/font.js +17 -0
  26. package/dist/chunks/export/font.js.map +1 -0
  27. package/dist/chunks/export/icons.js +34 -0
  28. package/dist/chunks/export/icons.js.map +1 -0
  29. package/dist/chunks/export/index.js +1390 -0
  30. package/dist/chunks/export/index.js.map +1 -0
  31. package/dist/chunks/fields.js +1065 -0
  32. package/dist/chunks/fields.js.map +1 -0
  33. package/dist/chunks/index.js +438 -0
  34. package/dist/chunks/index.js.map +1 -0
  35. package/dist/chunks/jsx-dev-runtime.js +16 -0
  36. package/dist/chunks/jsx-dev-runtime.js.map +1 -0
  37. package/dist/index.d.ts +543 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +11 -0
  40. package/dist/jsx-dev-runtime.d.ts +2 -0
  41. package/dist/jsx-dev-runtime.js +2 -0
  42. package/dist/jsx-runtime.d.ts +44 -0
  43. package/dist/jsx-runtime.d.ts.map +1 -0
  44. package/dist/jsx-runtime.js +2 -0
  45. package/dist/tree.d.ts +261 -0
  46. package/dist/tree.d.ts.map +1 -0
  47. package/package.json +66 -4
  48. package/src/attributes.ts +30 -0
  49. package/src/behaviours/elements.ts +47 -0
  50. package/src/behaviours/index.ts +253 -0
  51. package/src/behaviours/render.ts +144 -0
  52. package/src/component-properties.ts +428 -0
  53. package/src/components.ts +109 -0
  54. package/src/connectors.ts +316 -0
  55. package/src/definitions.ts +277 -0
  56. package/src/effects.ts +80 -0
  57. package/src/elements.ts +321 -0
  58. package/src/enums.ts +182 -0
  59. package/src/export/behaviours.ts +143 -0
  60. package/src/export/bindings.ts +155 -0
  61. package/src/export/decoration.ts +39 -0
  62. package/src/export/font.ts +25 -0
  63. package/src/export/helpers.ts +75 -0
  64. package/src/export/icons.ts +42 -0
  65. package/src/export/index.ts +297 -0
  66. package/src/export/paint.ts +276 -0
  67. package/src/export/props.ts +369 -0
  68. package/src/export/state.ts +52 -0
  69. package/src/export/text.ts +155 -0
  70. package/src/export/value.ts +99 -0
  71. package/src/export/variables.ts +393 -0
  72. package/src/fields.ts +39 -0
  73. package/src/figjam-text.ts +37 -0
  74. package/src/global.d.ts +4 -0
  75. package/src/helpers.ts +135 -0
  76. package/src/index.ts +155 -0
  77. package/src/jsx-dev-runtime.ts +1 -0
  78. package/src/jsx-runtime.ts +51 -0
  79. package/src/mini-react.ts +23 -0
  80. package/src/overrides/effects.ts +39 -0
  81. package/src/overrides/fills.ts +56 -0
  82. package/src/overrides/state.ts +55 -0
  83. package/src/overrides/strokes.ts +109 -0
  84. package/src/overrides/text.ts +116 -0
  85. package/src/overrides/vector.ts +122 -0
  86. package/src/paints.ts +230 -0
  87. package/src/props-overrides.ts +481 -0
  88. package/src/reconcile.ts +134 -0
  89. package/src/reference/authoring.md +76 -0
  90. package/src/reference/examples.ts +49 -0
  91. package/src/reference.ts +19 -0
  92. package/src/refs.ts +48 -0
  93. package/src/render.ts +147 -0
  94. package/src/renderer.ts +598 -0
  95. package/src/scalar-bindings.ts +36 -0
  96. package/src/schema.ts +213 -0
  97. package/src/services.ts +36 -0
  98. package/src/shapes-with-text.ts +73 -0
  99. package/src/stickies.ts +72 -0
  100. package/src/streaming/index.ts +47 -0
  101. package/src/streaming/literals.ts +82 -0
  102. package/src/streaming/projection.ts +189 -0
  103. package/src/text-content.ts +233 -0
  104. package/src/transform.ts +78 -0
  105. package/src/tree.ts +285 -0
  106. package/src/types.ts +13 -0
  107. package/src/variables/graph.ts +265 -0
  108. package/src/variables/index.ts +124 -0
  109. package/src/variables/props.ts +77 -0
@@ -0,0 +1,438 @@
1
+ import { DESIGN_JSX_SUPPORTED_PROPERTY_NAMES } from "./behaviours/render.js";
2
+ import { DESIGN_JSX_HELPERS } from "./export/index.js";
3
+ import { DESIGN_JSX_ELEMENTS } from "./elements.js";
4
+ import { parseExpressionAt } from "acorn";
5
+ import { parser } from "@lezer/javascript";
6
+ import dedent from "dedent";
7
+ import { TreeFragment } from "@lezer/common";
8
+ import { decodeHTML } from "entities";
9
+ //#region src/reconcile.ts
10
+ /**
11
+ * Fields a layer keeps when its code is rendered again: its place in the tree and the identity
12
+ * that other layers, libraries and files refer to.
13
+ */
14
+ const IDENTITY_FIELDS = /* @__PURE__ */ new Set([
15
+ "id",
16
+ "type",
17
+ "parentId",
18
+ "childIds",
19
+ "source",
20
+ "componentKey",
21
+ "sourceLibraryKey",
22
+ "publishId",
23
+ "overrideKey"
24
+ ]);
25
+ /**
26
+ * Types rebuilt as a whole: instance overrides are keyed by the ids of their sublayers, and icon
27
+ * and SVG artwork is drawn again from its paths.
28
+ */
29
+ const REPLACED_TYPES = /* @__PURE__ */ new Set([
30
+ "INSTANCE",
31
+ "VECTOR",
32
+ "BOOLEAN_OPERATION"
33
+ ]);
34
+ function updatesInPlace(existing, rendered) {
35
+ return existing.type === rendered.type && !REPLACED_TYPES.has(existing.type);
36
+ }
37
+ /** Pairs rendered children with existing ones: same type and name first, then same type in order. */
38
+ function matchChildren(existing, rendered) {
39
+ const pairs = /* @__PURE__ */ new Map();
40
+ const free = new Set(existing);
41
+ const take = (node, test) => {
42
+ for (const candidate of free) {
43
+ if (!test(candidate)) continue;
44
+ free.delete(candidate);
45
+ pairs.set(node, candidate);
46
+ return;
47
+ }
48
+ };
49
+ for (const node of rendered) take(node, (candidate) => candidate.type === node.type && candidate.name === node.name);
50
+ for (const node of rendered) if (!pairs.has(node)) take(node, (candidate) => candidate.type === node.type);
51
+ return pairs;
52
+ }
53
+ function authoredChanges(existing, rendered) {
54
+ const changes = {};
55
+ for (const key of Object.keys(rendered)) {
56
+ if (IDENTITY_FIELDS.has(key)) continue;
57
+ const next = rendered[key];
58
+ if (JSON.stringify(existing[key]) === JSON.stringify(next)) continue;
59
+ Object.assign(changes, { [key]: structuredClone(next) });
60
+ }
61
+ return changes;
62
+ }
63
+ var Reconciler = class {
64
+ graph;
65
+ /** Rendered layer id → the id it has once reconciled: the existing layer's, or its own. */
66
+ ids = /* @__PURE__ */ new Map();
67
+ constructor(graph) {
68
+ this.graph = graph;
69
+ }
70
+ keepRendered(node) {
71
+ this.ids.set(node.id, node.id);
72
+ for (const child of this.graph.getChildren(node.id)) this.keepRendered(child);
73
+ }
74
+ /** Makes `existing` match `rendered` and returns the id the pair ends up with. */
75
+ pair(existing, rendered) {
76
+ if (!updatesInPlace(existing, rendered)) {
77
+ const parentId = existing.parentId;
78
+ const parent = parentId ? this.graph.getNode(parentId) : void 0;
79
+ if (parent && parentId) this.graph.insertChildAt(rendered.id, parentId, parent.childIds.indexOf(existing.id));
80
+ this.graph.deleteNode(existing.id);
81
+ this.keepRendered(rendered);
82
+ return rendered.id;
83
+ }
84
+ const changes = authoredChanges(existing, rendered);
85
+ if (Object.keys(changes).length > 0) this.graph.updateNode(existing.id, changes);
86
+ this.ids.set(rendered.id, existing.id);
87
+ this.children(existing.id, rendered.id);
88
+ this.graph.deleteNode(rendered.id);
89
+ return existing.id;
90
+ }
91
+ children(existingId, renderedId) {
92
+ const renderedChildren = this.graph.getChildren(renderedId);
93
+ const pairs = matchChildren(this.graph.getChildren(existingId), renderedChildren);
94
+ const order = renderedChildren.map((child) => {
95
+ const match = pairs.get(child);
96
+ return match ? this.pair(match, child) : child.id;
97
+ });
98
+ for (const child of renderedChildren) if (!pairs.has(child)) this.keepRendered(child);
99
+ const kept = new Set(order);
100
+ for (const child of this.graph.getChildren(existingId)) if (!kept.has(child.id)) this.graph.deleteNode(child.id);
101
+ for (const [index, id] of order.entries()) this.graph.insertChildAt(id, existingId, index);
102
+ }
103
+ };
104
+ /**
105
+ * Folds freshly rendered layers into the layers they replace, so code edits update layers in
106
+ * place: matched layers keep their ids, and only the properties that differ change. Roots pair
107
+ * by position; extra rendered roots stay, extra existing roots are deleted. Returns the id each
108
+ * rendered layer ends up with.
109
+ */
110
+ function reconcileRenderedLayers(graph, existingRootIds, renderedRootIds) {
111
+ const reconciler = new Reconciler(graph);
112
+ const rootIds = renderedRootIds.flatMap((renderedId, index) => {
113
+ const rendered = graph.getNode(renderedId);
114
+ if (!rendered) return [];
115
+ const existingId = existingRootIds.at(index);
116
+ const existing = existingId ? graph.getNode(existingId) : void 0;
117
+ if (existing) return [reconciler.pair(existing, rendered)];
118
+ reconciler.keepRendered(rendered);
119
+ return [rendered.id];
120
+ });
121
+ for (const id of existingRootIds.slice(renderedRootIds.length)) graph.deleteNode(id);
122
+ return {
123
+ rootIds,
124
+ ids: reconciler.ids
125
+ };
126
+ }
127
+ //#endregion
128
+ //#region src/reference/authoring.md?raw
129
+ var authoring_default = "# Pairdraw design authoring\n\nThis reference describes scene creation, not React DOM output. Use the `render` tool for JSX strings, or import `Frame`, `Text`, and other authoring exports from `@pairdraw/design-jsx` and render them with `renderTree` from `@pairdraw/core/design-jsx` in library code. Library exports are not automatically globals in agent `eval`; use only the bindings exposed by that execution environment.\n\n## Composition and layout\n\n- `flex=\"row\"` / `flex=\"col\"` enables auto-layout. Use it for content; reserve explicit `x`/`y` or `position=\"absolute\"` for intentional overlays and artwork. Without layout, children share the origin unless positioned.\n- `w` / `h` accept pixels, `\"hug\"` (content-sized), or `\"fill\"` (available space in a supported layout parent). Use Hug for notes, cards, and long pages instead of guessing heights. Fixed viewport sizes and artwork geometry are intentional exceptions.\n- `gap` controls spacing. `p`, `px`, `py`, and `pt`/`pr`/`pb`/`pl` control padding; longhands override shorthands. There is no margin shorthand.\n- `justify=\"start\"|\"end\"|\"center\"|\"between\"|\"around\"` controls the primary axis; `items=\"start\"|\"end\"|\"center\"|\"stretch\"|\"baseline\"` controls the cross axis. `around` gives each child an equal share of the free space, half on each side, on top of `gap`. Distribution needs available space: `between` and `around` cannot create extra room in a Hug container.\n- `grow` distributes available space. Avoid circular Hug/Fill dependencies and redundant fixed widths on growing children. Keep Fill sizing through intermediate containers that should stretch.\n- For wrapping text in a column, prefer `w=\"fill\"`; fixed-width text can use `textAutoResize=\"height\"`. `maxLines` / `truncate` are intentional truncation, not fixes for accidental overflow.\n- `wrap` and `rowGap` enable wrapped flex rows. `grid`, `columns`, and `rows` enable grid (for example `columns=\"1fr 200px 1fr\"` or `columns=\"repeat(7, 1fr)\"`); tracks are `fr`, pixel lengths, `auto`, `repeat()`, and `minmax()`, which grows like its maximum. Grid children use `colStart`, `rowStart`, `colSpan`, and `rowSpan`. The current grid `gap` shorthand takes precedence over `columnGap` and `rowGap`.\n- `flow=\"auto\"|\"ltr\"|\"rtl\"` controls container flow; text `dir` controls writing direction. Preserve these separately.\n- Outside auto-layout, and for `position=\"absolute\"` children, `constraints={{ horizontal, vertical }}` sets how a layer follows its parent's resizing, with Figma's values in lowercase: `\"min\"`, `\"center\"`, `\"max\"`, `\"stretch\"`, or `\"scale\"`. `minW`, `maxW`, `minH`, and `maxH` bound a layer's size. `visible={false}` hides a layer and `locked` locks it.\n- Use measured node bounds and the existing `arrange` tool for independent artboards: `pack` for a page of screens, `spread` when generated layers overlap. Prefer layout constraints to calculating child coordinates; ordinary JavaScript arithmetic is appropriate when real geometry calculations are needed.\n\n## Paint, text, and artwork\n\n- `bg` / `fill`, `stroke`, and text `color` accept colors and supported variable references. Set colors explicitly for predictable contrast. `fills` accepts structured paints; gradient helpers include `linearGradient`, `radialGradient`, `angularGradient`, and `diamondGradient`, each taking an array of stops and optional `{ opacity, transform }`: `fills={[linearGradient([['#3b82f6', 0], ['#8b5cf6', 1]])]}`. Without a `transform` a linear gradient runs left to right and the others are centred; `transform` is Figma's `gradientTransform`, mapping the layer's unit square onto gradient space. Write it as the plugin API's rows, as export does: `linearGradient(stops, { transform: [[0, 1, 0], [-1, 0, 1]] })` runs top to bottom. A paint written as an object takes its `gradientTransform` and `imageTransform` as rows too; the matrix fields `{ m00, m01, m02, m10, m11, m12 }` are accepted as well.\n- `shader(effects, { opacity, visible, blendMode })` fills a layer with a shader from the [`shaders`](https://shaders.com) library: an array of effects such as `bg={shader([{ type: 'Aurora', props: { speed: 2 } }])}`, or a preset as shaders.com exports it, `{ components: [...] }`. The canvas shows the shader's first frame, preview plays it, and files and other formats keep that frame as an image.\n- `shaderSource(code, { uniforms, opacity, visible, blendMode })` fills a layer with shader code written here rather than a preset; `uniforms` gives the values its `@directive` inputs start with, such as `bg={shaderSource(code, { uniforms: { u_color: '#ff0000' } })}`.\n- `stroke` describes one stroke, refined by `strokeWidth`, `strokeAlign` (`\"inside\"`, `\"center\"`, `\"outside\"`), `strokeDash`, `strokeCap`, and `strokeJoin`. `strokes` takes several, as objects with `color`, `weight`, `align`, `dash`, `cap`, `join`, and `visible`; `strokeWeights={{ top, right, bottom, left }}` sets per-side widths. `dashPattern` sets the node's own dash pattern, separate from the per-stroke `strokeDash`.\n- `rounded` and `roundedTL`/`roundedTR`/`roundedBL`/`roundedBR` control corners. `strokeWidth`, `opacity`, `rotate`, and `blendMode` control appearance. `overflow=\"hidden\"` clips content; do not hide accidental text overflow to make a broken layout appear correct.\n- `rotate` turns a layer by degrees, and `flipX` and `flipY` reflect it across its centre before it turns, as the canvas places it. `Star` takes `points` and `innerRadius` (0–1, how deep its points go); `Polygon` takes `points`. `Ellipse` draws an arc or a donut with `startAngle` and `endAngle` in degrees, clockwise from three o'clock (0 to 360 by default), and `innerRadius` (0–1, the hole): `<Ellipse w={80} h={80} startAngle={0} endAngle={270} innerRadius={0.6} />`.\n- `effects` accepts structured effects such as `dropShadow`, `innerShadow`, and `layerBlur`. `shadow` takes a CSS `box-shadow` list, such as `shadow=\"0 4 8 #0002, inset 0 1 0 #fff\"`, and `blur` a layer blur radius; both are convenient shorthands. Effect helpers take `radius`, as Figma's effects do; when a JSX string is rendered, an option a paint or effect helper does not support is reported as a warning.\n- Text content belongs inside `Text`. Use `size`, `font`, `weight`, `italic`, `lineHeight`, `letterSpacing`, `textAlign`, `textAlignVertical`, `textDecoration`, and `textCase`. Decorations take CSS's names and values: `textDecorationStyle` (`solid`, `dotted`, `wavy`), `textDecorationColor` (`currentColor` follows the text), `textDecorationThickness` and `textUnderlineOffset` (pixels or `auto`), and `textDecorationSkipInk`. `fontFeatures` turns OpenType features on or off by tag (`fontFeatures={{ tnum: true, liga: false }}`), `fontVariations` sets variable-font axes by tag (`fontVariations={{ wght: 650 }}`), and `lang` names the text's language (`lang=\"de\"`) for shaping and font fallback. A variable font's optical size follows the font size unless `fontOpticalSizing=\"none\"`, as in CSS; only then does an `opsz` in `fontVariations` apply. `lineHeight=\"auto\"` follows the font, and `fills={[]}` paints no text. Verify fonts actually load before judging dimensions; do not assume every font is available.\n- `Span` styles some characters of a `Text` with `Text`'s own prop names: `size`, `font`, `weight`, `italic`, `color`, `fills`, `lineHeight`, `letterSpacing`, `textDecoration`, the decoration details, `fontFeatures`, `fontVariations`, `lang`, and `textCase`; a span's `fontFeatures` and `fontVariations` replace the text's rather than adding to them, and `fontOpticalSizing` is set on the `Text` for all of it. `href` links its characters to a URL without changing how they look. Spans nest; the inner one wins. `Paragraph` writes one paragraph: `list=\"ordered\"` or `list=\"unordered\"` makes it a list item nested at `level` 1–5, and `spacing`, `listSpacing`, and `indent` override the `Text`'s `paragraphSpacing`, `listSpacing`, and `paragraphIndent` for it; `hangingList` on the `Text` hangs list markers outside the text box. A `Text` holds only `Paragraph`s or none; without them, a line break in its text still starts a paragraph.\n- `Icon` uses an Iconify name, size, and color. Prefer icons to emoji when reliable vector output is needed. Image fills belong on appropriate leaf shapes, not containers whose children must remain visible.\n- Pick artwork by where it comes from. A known icon is an `Icon` by its Iconify name. A shape you draw yourself is a `Vector` with its path in SVG syntax, `<Vector d=\"M11 2L4 11h5l-1 7 7-9h-5z\" bg={designVar(…)} />`: one layer, styled with the same props as any other, so its fills can use variables, stack, and take `strokeAlign` and `effects`. `fillRule=\"evenodd\"` cuts holes. An open path with a `stroke` stays open, a line; with only a `bg` it fills as if closed. Given `w` and `h`, the path is drawn in that box as written, as an icon is in its view box; without them the layer fits the path. `paths` takes several paths as export writes them, each `{ windingRule, data }` with `NONZERO`, `EVENODD`, or `NONE` for an open path: `paths={[{ windingRule: \"EVENODD\", data: \"M0 0L10 0L10 10Z\" }]}`. Inline `<svg>` is for artwork copied from elsewhere: it draws the SVG's shapes, a frame with a layer per shape in the SVG's own colours, and leaves out its text, so do not use it for a shape you will style or bind, nor for text.\n- `Sticky` makes a FigJam sticky note whose text is its body: `<Sticky color=\"yellow\" author=\"Ada\">Ship it</Sticky>`. `color` takes a FigJam palette name (`white`, `gray`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `violet`, `pink`) or any colour, `author` signs it (`authorVisible={false}` hides the line), `wide` makes it 416 wide instead of 240, `textSize` is `small`, `medium`, `large`, `extraLarge`, or `huge`, `typeface` is `simple`, `bookish`, `technical`, or `scribbled`, and `scale` scales the whole note. A note sizes itself; it takes no `w`, `h`, fills, or layout props.\n- `Shape` makes a FigJam shape with text whose text is its label: `<Shape kind=\"diamond\" bg=\"#FFC943\">Valid?</Shape>`. `kind` is `square` (default), `ellipse`, `diamond`, `rounded_rectangle`, `parallelogram_right`, `eng_database`, or another FigJam shape, written in lowercase. `w` and `h` are the size it is given (176 by default); it grows taller to fit its label, never wider, so a word too long for it breaks. `truncate` keeps its height and cuts the label off with \"…\" instead, as FigJam does once a shape's height is set. `bg`, `stroke`, `strokeWidth`, `rounded` (6 by default), and `rotate` style it as any layer; the label is centred in the shape and takes the same `textSize` and `typeface` as `Sticky`.\n- `Connector` draws a FigJam connector that follows the layers it joins: `<Connector from=\"Start\" to=\"Done\">Next</Connector>`. `from` and `to` name layers of the same JSX, take a `ref()` a layer is marked with (`const card = ref()`, then `<Frame ref={card}>` and `from={card}`), or give `{ x, y }` points in the connector's parent; `fromSide`/`toSide` (`top`, `right`, `bottom`, `left`) fix the side it attaches by, `line` is `elbowed` (default), `straight`, or `curved`, and `startCap`/`endCap` take the same caps as `strokeCap`: `none`, `round`, `square`, `arrow_lines`, `arrow_equilateral`, `triangle_filled`, `diamond_filled`, or `circle_filled` (it starts with none and ends with `arrow_lines`). Its text is the label; `stroke`, `strokeWidth`, and `dashPattern` style the line. When layers share a name, join them by `ref()`; a name more than one layer has joins the first, with a warning.\n- Design JSX props are the portable authoring interface. Some CSS-style aliases are supported, but this is not a browser CSS engine; do not assume arbitrary HTML, classes, or styles work.\n\n## Variables and components\n\n- `defineVars('Theme', { Page: '#FFFFFF', Radius: 12 }, { mode: 'Light' })` defines a collection in the file's variables table and returns its variables by name, such as `theme.Page`. Each value is the variable's value in the first mode, named by `mode` (`Mode 1` without one): strings are colors, numbers FLOAT, booleans BOOLEAN, and another collection's variable makes an alias, such as `palette['Gray/900']`. `defineMode(theme, 'Dark', { Page: '#111111' })` adds a mode with the values that differ; the rest keep the first mode's. A render that binds any of the variables creates the collection with all its modes, or updates the one with that name, so running the JSX again changes values instead of adding collections.\n- `designVar('name-or-id')` refers to a variable the document already has; a missing one is an error. When more than one collection has a variable of that name, name the collection too, as `designMode` does: `designVar('Theme', 'Line')`.\n- COLOR references work in paint props. FLOAT references work in `w`, `h`, `gap`, padding, corner radii, `strokeWidth`, `opacity`, text `size`/`fontSize`, `lineHeight`, and `letterSpacing`. Grid `columnGap`/`rowGap` and wrapped flex `rowGap` also support FLOAT references; grid `gap` overrides both axis-specific gaps. Use numbers or FLOAT references for these scalar props, not CSS unit strings; the one exception is `lineHeight` and `letterSpacing`, which also take a percent of the font size such as `\"150%\"` that follows the size when it changes.\n- `mode={dark}` shows a layer and its children in a mode, as the Appearance panel's variable mode control does; a list pins several collections, and `designMode('Theme', 'Dark')` names a mode of a collection the document already has, by the collection's ID when several share its name. Without `mode`, a layer inherits its parent's.\n- Variables bind real graph fields, not copied values. Layout resolves scalar variables in the mode the layer is created in, its own or inherited; it does not lay content out again after a later mode switch. Verify resulting geometry as well as paint when changing modes. Missing or incorrectly typed scalar variables are errors.\n- `bind` maps supported scene-field paths to variable IDs or references when no shorthand exists. Use semantic tokens consistently rather than declaring unused collections.\n- Build repeated or computed content with JavaScript inside `{}` rather than writing each item out: `{days.map((day) => <Text>{day}</Text>)}`, `{Array.from({ length: 35 }, (_, i) => <Frame>…</Frame>)}`, and conditionals. Statements such as `const weeks = …` may come first and then end with `return` and the JSX, as a component's body does: `const weeks = 5` on one line, `return <Frame>…</Frame>` on the next.\n- A reusable JavaScript function shares source code, not component identity. Use `Component`, `ComponentSet`, and `Instance` for editable main components and linked instances.\n- `Instance` resolves an existing component through `of`, `component`, or `componentId`. Component-set children named `variant=Primary`, for example, define variants that can be selected when instantiating the set.\n- `property(name, defaultValue)` binds a field of a component's layer to a component property, created on first use: `text={property('Message', 'Hi')}` on a `Text` makes a TEXT property, `visible={property('Pinned', true)}` a BOOLEAN one, and `of={property('Icon', 'Star')}` on an `Instance` an INSTANCE_SWAP one whose default is the component `of` names. The property belongs to the nearest `Component`, or to its `ComponentSet` for a variant, so the same name in each variant binds one property; one name with two types or two defaults is an error.\n- An `Instance` sets text, boolean, and swap properties by name, the way it picks a variant: `<Instance of=\"Note\" State=\"Done\" Message=\"Updated review\" Pinned={false} />`. `properties` takes the same values keyed by property ID or name, for names that are not JSX identifiers or that design JSX already uses, such as `name`. Only instances accept `properties`.\n- `exposed` on an `Instance` in a component shows that instance's own properties on the component's instances, as Figma's \"Expose properties from nested instances\" does; the instance's component needs properties to expose. An outer instance gives an exposed instance its variant and properties as an object under the exposed layer's name: `<Instance of=\"Card\" Title=\"Welcome\" Action={{ Variant: 'Secondary', Label: 'Save' }} />`, or `properties={{ Action: { … } }}`.\n- Instance assignments take `true` / `false` or the native `'true'` / `'false'` for BOOLEAN properties, and a component's name or ID for swaps, as `of` does, whether set as a prop or in `properties`. Assignments persist through component synchronization; unknown IDs and invalid values fail rather than silently creating inert overrides. Select variants through component-set variant props, not through instance property assignments.\n- Reuse existing local or library components before recreating them. Keep meaningful text, visibility, and swap properties exposed rather than hand-editing cloned child nodes.\n- Explicit instance `w` / `h` replace the inherited sizing mode on that axis; omitted dimensions retain the main component's sizing. Authored overrides survive component synchronization. Distinguish those placement constraints from the main component's default size, and verify actual bounds in narrower parents. Do not compensate for a sizing mismatch with guessed heights, clipping, or manually positioned siblings.\n\n## Controls\n\n- A main component can behave as a Reka UI control in preview and code. Write it with Reka's names: `Switch.Root` is the component (a component set when its children are `Component` variants), and each Reka part is the slot that draws it, such as `Switch.Thumb`, `Slider.Track`, `Slider.Range`, `Slider.Thumb`, `Progress.Track`, `Progress.Indicator`, `Tabs.List`, `Collapsible.Trigger`, or `NumberField.Increment`. Parts in different variants share one slot.\n- The root names the properties that hold its values: `modelValue` (`open` on `Collapsible.Root`), `disabled`, and, for text fields, `filled`, as a variant or boolean property name, or `{ property, on, off }` when the variant values are not named like On and Off. `states` names the variant property that draws default, hover, pressed, focus, and disabled; a slider, progress bar, or number field takes `min`, `max`, `step`, and `defaultValue`.\n- `TextField.Input`, `Textarea.Input`, and `NumberField.Input` are the text layers whose text becomes the field's text property. `Tabs.Trigger` goes in `Tabs.List`; `Tabs.Content` panels may sit directly under `Tabs.Root`, the first showing. A part with children and no `flex`, `display`, `w`, or `h` of its own stacks them in a column that hugs them.\n- A group's item component is written on its own (`RadioGroup.Item`, `ToggleGroup.Item`, `Accordion.Item` with its `Accordion.Trigger` and `Accordion.Content`); the group's root then lists items as `<RadioGroup.Item of={radioId} />`.\n\n```tsx\n<Switch.Root name=\"Switch\" modelValue=\"State\" states=\"Interaction\">\n <Component name=\"State=Off, Interaction=Default\" w={44} h={24} rounded={12} bg=\"#D0D4DA\">\n <Switch.Thumb x={2} y={2} w={20} h={20} rounded={10} bg=\"#FFFFFF\" />\n </Component>\n <Component name=\"State=On, Interaction=Default\" w={44} h={24} rounded={12} bg=\"#3B6CF6\">\n <Switch.Thumb x={22} y={2} w={20} h={20} rounded={10} bg=\"#FFFFFF\" />\n </Component>\n</Switch.Root>\n```\n\n## Verification\n\nInspect structure and actual rendered output. Node counts and `describe` diagnostics do not establish visual fidelity. Check wrapping with longer content, narrower containers, component edits, and relevant modes. Resolve overflow and contrast problems at their source. Reuse IDs returned by creation tools rather than repeatedly searching for the same nodes.\n\nThe examples below are executed by the authoring-reference tests. Create the named variables before running a variable-bound example.\n";
130
+ //#endregion
131
+ //#region src/reference/examples.ts
132
+ /** Shared verbatim by runtime prompts and the installable skill; exercised in engine tests. */
133
+ const AUTHORING_EXAMPLES = [
134
+ {
135
+ title: "Content-sized review note",
136
+ jsx: dedent`<Frame name="Review note" w={280} h="hug" flex="col" gap={8} p={16} bg="#FFFFFF">
137
+ <Text name="Author" size={12} weight="medium" color="#252A31">June Lee</Text>
138
+ <Text name="Message" w="fill" size={12} color="#6B7079">Give the date a little more room at the bottom.</Text>
139
+ </Frame>`
140
+ },
141
+ {
142
+ title: "Variable-bound spacing and typography",
143
+ jsx: dedent`<Frame name="Bound note" w={280} h="hug" flex="col" gap={designVar('Space/small')} p={designVar('Space/medium')} bg="#FFFFFF">
144
+ <Text name="Message" w="fill" size={designVar('Type/body')} lineHeight={designVar('Type/body-leading')} letterSpacing={designVar('Type/body-tracking')} color="#252A31">A note that grows with its content.</Text>
145
+ </Frame>`
146
+ },
147
+ {
148
+ title: "A theme with two modes",
149
+ jsx: dedent`const theme = defineVars('Theme', { Surface: '#FFFFFF', Ink: '#252A31', Radius: 12 }, { mode: 'Light' })
150
+ const dark = defineMode(theme, 'Dark', { Surface: '#1A1A20', Ink: '#F5F5F7' })
151
+ return <Frame name="Dark note" mode={dark} w={280} h="hug" flex="col" gap={8} p={16} bg={theme.Surface} rounded={theme.Radius}>
152
+ <Text name="Message" w="fill" size={12} color={theme.Ink}>Shown in the Dark mode of the Theme collection.</Text>
153
+ </Frame>`
154
+ },
155
+ {
156
+ title: "Component with text and visibility properties",
157
+ jsx: dedent`<Component name="Comment" w={280} h="hug" flex="col" gap={8} p={16} bg="#FFFFFF">
158
+ <Text name="Author" size={12} weight="medium" color="#252A31" text={property('Author', 'June Lee')} />
159
+ <Text name="Message" w="fill" size={12} color="#6B7079" text={property('Message', 'Give the date more room.')} visible={property('Show message', true)} />
160
+ </Component>`
161
+ },
162
+ {
163
+ title: "Rich text with spans and lists",
164
+ jsx: dedent`<Frame name="Release notes" w={280} h="hug" flex="col" gap={8} p={16} bg="#FFFFFF">
165
+ <Text name="Notes" w="fill" size={12} color="#252A31" paragraphSpacing={4}>
166
+ <Paragraph spacing={8}>Version 2 is <Span weight="bold" color="#3B6CF6" textDecoration="underline" textDecorationStyle="wavy" textUnderlineOffset={2}>out now</Span>.</Paragraph>
167
+ <Paragraph list="unordered">Faster export</Paragraph>
168
+ <Paragraph list="unordered" level={2}>PDF and SVG</Paragraph>
169
+ <Paragraph list="ordered">Fewer clicks</Paragraph>
170
+ </Text>
171
+ </Frame>`
172
+ }
173
+ ];
174
+ //#endregion
175
+ //#region src/reference.ts
176
+ /** Canonical scene-authoring guidance shared by runtime prompts and generated skill references. */
177
+ const JSX_REFERENCE = [
178
+ authoring_default.trim(),
179
+ ...AUTHORING_EXAMPLES.map(({ title, jsx }) => `## ${title}\n\n\`\`\`jsx\n${jsx}\n\`\`\``),
180
+ "## Supported syntax inventory",
181
+ "Generated from the renderer metadata. This inventory lists accepted names, not arbitrary browser CSS support.",
182
+ `**Elements:** ${DESIGN_JSX_ELEMENTS.map(({ name }) => `\`${name}\``).join(", ")}.`,
183
+ `**Helpers:** ${DESIGN_JSX_HELPERS.map(({ name }) => `\`${name}\``).join(", ")}.`,
184
+ `**Properties:** ${DESIGN_JSX_SUPPORTED_PROPERTY_NAMES.map((name) => `\`${name}\``).join(", ")}.`
185
+ ].join("\n\n");
186
+ //#endregion
187
+ //#region src/streaming/literals.ts
188
+ const MAX_LITERAL_DEPTH = 32;
189
+ const UNSUPPORTED = Symbol("unsupported-literal");
190
+ /** Decode data only. Calls, getters, spreads, identifiers and computed keys never execute. */
191
+ function readLiteral(source) {
192
+ try {
193
+ const expression = parseExpressionAt(source, 0, { ecmaVersion: "latest" });
194
+ if (source.slice(expression.end).trim()) return null;
195
+ const value = evaluateLiteral(expression, 0);
196
+ return value === UNSUPPORTED ? null : { value };
197
+ } catch {
198
+ return null;
199
+ }
200
+ }
201
+ function evaluateLiteral(expression, depth) {
202
+ if (depth > MAX_LITERAL_DEPTH) return UNSUPPORTED;
203
+ switch (expression.type) {
204
+ case "Literal": {
205
+ const value = expression.value;
206
+ return value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) ? value : UNSUPPORTED;
207
+ }
208
+ case "UnaryExpression": {
209
+ if (expression.operator !== "-" && expression.operator !== "+") return UNSUPPORTED;
210
+ const value = evaluateLiteral(expression.argument, depth + 1);
211
+ if (typeof value !== "number") return UNSUPPORTED;
212
+ return expression.operator === "-" ? -value : value;
213
+ }
214
+ case "ArrayExpression": {
215
+ const values = [];
216
+ for (const element of expression.elements) {
217
+ if (!element || element.type === "SpreadElement") return UNSUPPORTED;
218
+ const value = evaluateLiteral(element, depth + 1);
219
+ if (value === UNSUPPORTED) return UNSUPPORTED;
220
+ values.push(value);
221
+ }
222
+ return values;
223
+ }
224
+ case "ObjectExpression": return evaluateObject(expression, depth);
225
+ default: return UNSUPPORTED;
226
+ }
227
+ }
228
+ function evaluateObject(expression, depth) {
229
+ const entries = [];
230
+ for (const property of expression.properties) {
231
+ if (property.type !== "Property" || property.computed || property.method || property.shorthand || property.kind !== "init") return UNSUPPORTED;
232
+ let key;
233
+ if (property.key.type === "Identifier") key = property.key.name;
234
+ else if (property.key.type === "Literal") key = property.key.value;
235
+ if (typeof key !== "string" && typeof key !== "number") return UNSUPPORTED;
236
+ const value = evaluateLiteral(property.value, depth + 1);
237
+ if (value === UNSUPPORTED) return UNSUPPORTED;
238
+ entries.push([String(key), value]);
239
+ }
240
+ return Object.fromEntries(entries);
241
+ }
242
+ //#endregion
243
+ //#region src/streaming/projection.ts
244
+ const ELEMENT_TYPES = new Map(DESIGN_JSX_ELEMENTS.map(({ name, runtimeType }) => [name, runtimeType]));
245
+ const MAX_PREVIEW_DEPTH = 100;
246
+ const MAX_PREVIEW_NODES = 1e4;
247
+ function children(node) {
248
+ const result = [];
249
+ for (let child = node.firstChild; child; child = child.nextSibling) result.push(child);
250
+ return result;
251
+ }
252
+ function hasError(node) {
253
+ let error = false;
254
+ node.cursor().iterate((child) => {
255
+ if (child.type.isError) error = true;
256
+ return !error;
257
+ });
258
+ return error;
259
+ }
260
+ /** Match JSX's line-oriented whitespace handling, rather than HTML whitespace collapsing. */
261
+ function textValue(raw) {
262
+ const lines = raw.split(/\r\n|\n|\r/);
263
+ const lastNonEmpty = lines.findLastIndex((line) => /[^ \t]/.test(line));
264
+ return lines.map((line, index) => {
265
+ let value = line.replaceAll(" ", " ");
266
+ if (index > 0) value = value.replace(/^ +/, "");
267
+ if (index < lines.length - 1) value = value.replace(/ +$/, "");
268
+ return value && index < lastNonEmpty ? `${value} ` : value;
269
+ }).join("");
270
+ }
271
+ function projectPreview(root, source) {
272
+ const pending = [];
273
+ let nodeCount = 0;
274
+ const raw = (node) => source.slice(node.from, node.to);
275
+ const defer = (node, reason) => {
276
+ pending.push({
277
+ from: node.from,
278
+ to: node.to,
279
+ reason
280
+ });
281
+ };
282
+ function expression(node) {
283
+ if (hasError(node) || !raw(node).endsWith("}")) {
284
+ defer(node, "incomplete");
285
+ return null;
286
+ }
287
+ const value = readLiteral(raw(node).slice(1, -1));
288
+ if (!value) defer(node, "unsupported");
289
+ return value;
290
+ }
291
+ function attributes(opening) {
292
+ const props = {};
293
+ for (const attribute of children(opening)) {
294
+ if (attribute.name === "JSXSpreadAttribute") {
295
+ defer(attribute, "unsupported");
296
+ return null;
297
+ }
298
+ if (attribute.name !== "JSXAttribute") continue;
299
+ const keyNode = attribute.firstChild;
300
+ if (keyNode?.name !== "JSXIdentifier") {
301
+ defer(attribute, "unsupported");
302
+ continue;
303
+ }
304
+ const key = raw(keyNode);
305
+ const valueNode = attribute.lastChild;
306
+ let value = true;
307
+ if (valueNode && valueNode !== keyNode && valueNode.from !== keyNode.from) {
308
+ if (valueNode.name === "JSXAttributeValue") value = decodeHTML(raw(valueNode).slice(1, -1).replace(/\r\n|[\r\n\t]/g, " "));
309
+ else if (valueNode.name === "JSXEscape") {
310
+ const literal = expression(valueNode);
311
+ if (!literal) continue;
312
+ value = literal.value;
313
+ } else {
314
+ defer(attribute, "unsupported");
315
+ continue;
316
+ }
317
+ }
318
+ Object.defineProperty(props, key, {
319
+ value,
320
+ enumerable: true,
321
+ configurable: true,
322
+ writable: true
323
+ });
324
+ }
325
+ return props;
326
+ }
327
+ function element(node, depth) {
328
+ if (depth > MAX_PREVIEW_DEPTH || ++nodeCount > MAX_PREVIEW_NODES) throw new RangeError("JSX preview tree limit exceeded");
329
+ const opening = node.firstChild;
330
+ if (!opening || ![
331
+ "JSXOpenTag",
332
+ "JSXSelfClosingTag",
333
+ "JSXFragmentTag"
334
+ ].includes(opening.name)) {
335
+ defer(node, "unsupported");
336
+ return null;
337
+ }
338
+ const delimiter = opening.lastChild;
339
+ if (hasError(opening) || !delimiter || ![">", "/>"].includes(raw(delimiter))) {
340
+ defer(opening, "incomplete");
341
+ return null;
342
+ }
343
+ const tagName = opening.getChild("JSXIdentifier") ?? opening.getChild("JSXBuiltin");
344
+ const fragment = raw(opening) === "<>";
345
+ const name = tagName ? raw(tagName) : "";
346
+ const type = fragment ? "" : ELEMENT_TYPES.get(name) ?? (/^[a-z][\w-]*$/.test(name) ? name : null);
347
+ if (type === null) {
348
+ defer(opening, "unsupported");
349
+ return null;
350
+ }
351
+ const props = attributes(opening);
352
+ if (!props) return null;
353
+ const result = {
354
+ type,
355
+ props,
356
+ children: [],
357
+ sourceStart: node.from
358
+ };
359
+ appendChildren(node, result, depth);
360
+ return result;
361
+ }
362
+ function appendChildren(node, result, depth) {
363
+ for (const child of children(node).slice(1)) if (child.name === "JSXElement") {
364
+ const projected = element(child, depth + 1);
365
+ if (projected?.type === "") result.children.push(...projected.children);
366
+ else if (projected) result.children.push(projected);
367
+ } else if (child.name === "JSXText") {
368
+ let value = raw(child);
369
+ if (child.to === source.length) value = value.replace(/&(?:#x?[\da-f]*|[a-z]*)$/i, "").replace(/[\uD800-\uDBFF]$/, "");
370
+ value = decodeHTML(textValue(value));
371
+ if (value) result.children.push(value);
372
+ } else if (child.name === "JSXEscape") {
373
+ const literal = expression(child);
374
+ if (literal && (typeof literal.value === "string" || typeof literal.value === "number")) result.children.push(String(literal.value));
375
+ else if (literal && typeof literal.value === "object" && literal.value !== null) defer(child, "unsupported");
376
+ } else if (child.type.isError || hasError(child)) defer(child, "incomplete");
377
+ }
378
+ const first = root.firstChild;
379
+ if (!first) return {
380
+ tree: null,
381
+ pending
382
+ };
383
+ if (first.name !== "JSXElement") {
384
+ defer(first, hasError(root) ? "incomplete" : "unsupported");
385
+ return {
386
+ tree: null,
387
+ pending
388
+ };
389
+ }
390
+ return {
391
+ tree: element(first, 0),
392
+ pending
393
+ };
394
+ }
395
+ //#endregion
396
+ //#region src/streaming/index.ts
397
+ const jsxParser = parser.configure({
398
+ dialect: "jsx",
399
+ top: "SingleExpression"
400
+ });
401
+ const MAX_PREVIEW_SOURCE_LENGTH = 128e3;
402
+ /**
403
+ * Append-only, non-executing Design JSX preview parser. Own one instance per tool call.
404
+ * Snapshots contain fresh data; later appends never mutate an earlier preview.
405
+ * This is not final JSX validation: unsupported expressions are deliberately deferred.
406
+ * Call append on coalesced chunks, not once per token, to bound projection work.
407
+ */
408
+ function createStreamingJSXParser() {
409
+ let source = "";
410
+ let fragments = [];
411
+ function append(chunk) {
412
+ if (source.length + chunk.length > MAX_PREVIEW_SOURCE_LENGTH) throw new RangeError("JSX preview source limit exceeded");
413
+ const next = source + chunk;
414
+ const changed = TreeFragment.applyChanges(fragments, [{
415
+ fromA: source.length,
416
+ toA: source.length,
417
+ fromB: source.length,
418
+ toB: next.length
419
+ }]);
420
+ const tree = jsxParser.parse(next, changed);
421
+ const snapshot = projectPreview(tree.topNode, next);
422
+ source = next;
423
+ fragments = TreeFragment.addTree(tree);
424
+ return snapshot;
425
+ }
426
+ function reset() {
427
+ source = "";
428
+ fragments = [];
429
+ }
430
+ return {
431
+ append,
432
+ reset
433
+ };
434
+ }
435
+ //#endregion
436
+ export { AUTHORING_EXAMPLES, JSX_REFERENCE, createStreamingJSXParser, reconcileRenderedLayers };
437
+
438
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["authoring"],"sources":["../../src/reconcile.ts","../../src/reference/authoring.md?raw","../../src/reference/examples.ts","../../src/reference.ts","../../src/streaming/literals.ts","../../src/streaming/projection.ts","../../src/streaming/index.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\n/**\n * Fields a layer keeps when its code is rendered again: its place in the tree and the identity\n * that other layers, libraries and files refer to.\n */\nconst IDENTITY_FIELDS = new Set<keyof SceneNode>([\n 'id',\n 'type',\n 'parentId',\n 'childIds',\n 'source',\n 'componentKey',\n 'sourceLibraryKey',\n 'publishId',\n 'overrideKey'\n])\n\n/**\n * Types rebuilt as a whole: instance overrides are keyed by the ids of their sublayers, and icon\n * and SVG artwork is drawn again from its paths.\n */\nconst REPLACED_TYPES = new Set<SceneNode['type']>(['INSTANCE', 'VECTOR', 'BOOLEAN_OPERATION'])\n\nfunction updatesInPlace(existing: SceneNode, rendered: SceneNode): boolean {\n return existing.type === rendered.type && !REPLACED_TYPES.has(existing.type)\n}\n\n/** Pairs rendered children with existing ones: same type and name first, then same type in order. */\nfunction matchChildren(\n existing: readonly SceneNode[],\n rendered: readonly SceneNode[]\n): Map<SceneNode, SceneNode> {\n const pairs = new Map<SceneNode, SceneNode>()\n const free = new Set(existing)\n const take = (node: SceneNode, test: (candidate: SceneNode) => boolean) => {\n for (const candidate of free) {\n if (!test(candidate)) continue\n free.delete(candidate)\n pairs.set(node, candidate)\n return\n }\n }\n for (const node of rendered) {\n take(node, (candidate) => candidate.type === node.type && candidate.name === node.name)\n }\n for (const node of rendered) {\n if (!pairs.has(node)) take(node, (candidate) => candidate.type === node.type)\n }\n return pairs\n}\n\nfunction authoredChanges(existing: SceneNode, rendered: SceneNode): Partial<SceneNode> {\n const changes: Partial<SceneNode> = {}\n for (const key of Object.keys(rendered) as (keyof SceneNode)[]) {\n if (IDENTITY_FIELDS.has(key)) continue\n const next = rendered[key]\n if (JSON.stringify(existing[key]) === JSON.stringify(next)) continue\n Object.assign(changes, { [key]: structuredClone(next) })\n }\n return changes\n}\n\nclass Reconciler {\n /** Rendered layer id → the id it has once reconciled: the existing layer's, or its own. */\n readonly ids = new Map<string, string>()\n\n constructor(private readonly graph: SceneGraph) {}\n\n keepRendered(node: SceneNode) {\n this.ids.set(node.id, node.id)\n for (const child of this.graph.getChildren(node.id)) this.keepRendered(child)\n }\n\n /** Makes `existing` match `rendered` and returns the id the pair ends up with. */\n pair(existing: SceneNode, rendered: SceneNode): string {\n if (!updatesInPlace(existing, rendered)) {\n const parentId = existing.parentId\n const parent = parentId ? this.graph.getNode(parentId) : undefined\n if (parent && parentId) {\n this.graph.insertChildAt(rendered.id, parentId, parent.childIds.indexOf(existing.id))\n }\n this.graph.deleteNode(existing.id)\n this.keepRendered(rendered)\n return rendered.id\n }\n const changes = authoredChanges(existing, rendered)\n if (Object.keys(changes).length > 0) this.graph.updateNode(existing.id, changes)\n this.ids.set(rendered.id, existing.id)\n this.children(existing.id, rendered.id)\n this.graph.deleteNode(rendered.id)\n return existing.id\n }\n\n private children(existingId: string, renderedId: string) {\n const renderedChildren = this.graph.getChildren(renderedId)\n const pairs = matchChildren(this.graph.getChildren(existingId), renderedChildren)\n const order = renderedChildren.map((child) => {\n const match = pairs.get(child)\n return match ? this.pair(match, child) : child.id\n })\n for (const child of renderedChildren) if (!pairs.has(child)) this.keepRendered(child)\n const kept = new Set(order)\n for (const child of this.graph.getChildren(existingId)) {\n if (!kept.has(child.id)) this.graph.deleteNode(child.id)\n }\n for (const [index, id] of order.entries()) this.graph.insertChildAt(id, existingId, index)\n }\n}\n\n/**\n * Folds freshly rendered layers into the layers they replace, so code edits update layers in\n * place: matched layers keep their ids, and only the properties that differ change. Roots pair\n * by position; extra rendered roots stay, extra existing roots are deleted. Returns the id each\n * rendered layer ends up with.\n */\nexport function reconcileRenderedLayers(\n graph: SceneGraph,\n existingRootIds: readonly string[],\n renderedRootIds: readonly string[]\n): { rootIds: string[]; ids: Map<string, string> } {\n const reconciler = new Reconciler(graph)\n const rootIds = renderedRootIds.flatMap((renderedId, index) => {\n const rendered = graph.getNode(renderedId)\n if (!rendered) return []\n const existingId = existingRootIds.at(index)\n const existing = existingId ? graph.getNode(existingId) : undefined\n if (existing) return [reconciler.pair(existing, rendered)]\n reconciler.keepRendered(rendered)\n return [rendered.id]\n })\n for (const id of existingRootIds.slice(renderedRootIds.length)) graph.deleteNode(id)\n return { rootIds, ids: reconciler.ids }\n}\n","export default \"# Pairdraw design authoring\\n\\nThis reference describes scene creation, not React DOM output. Use the `render` tool for JSX strings, or import `Frame`, `Text`, and other authoring exports from `@pairdraw/design-jsx` and render them with `renderTree` from `@pairdraw/core/design-jsx` in library code. Library exports are not automatically globals in agent `eval`; use only the bindings exposed by that execution environment.\\n\\n## Composition and layout\\n\\n- `flex=\\\"row\\\"` / `flex=\\\"col\\\"` enables auto-layout. Use it for content; reserve explicit `x`/`y` or `position=\\\"absolute\\\"` for intentional overlays and artwork. Without layout, children share the origin unless positioned.\\n- `w` / `h` accept pixels, `\\\"hug\\\"` (content-sized), or `\\\"fill\\\"` (available space in a supported layout parent). Use Hug for notes, cards, and long pages instead of guessing heights. Fixed viewport sizes and artwork geometry are intentional exceptions.\\n- `gap` controls spacing. `p`, `px`, `py`, and `pt`/`pr`/`pb`/`pl` control padding; longhands override shorthands. There is no margin shorthand.\\n- `justify=\\\"start\\\"|\\\"end\\\"|\\\"center\\\"|\\\"between\\\"|\\\"around\\\"` controls the primary axis; `items=\\\"start\\\"|\\\"end\\\"|\\\"center\\\"|\\\"stretch\\\"|\\\"baseline\\\"` controls the cross axis. `around` gives each child an equal share of the free space, half on each side, on top of `gap`. Distribution needs available space: `between` and `around` cannot create extra room in a Hug container.\\n- `grow` distributes available space. Avoid circular Hug/Fill dependencies and redundant fixed widths on growing children. Keep Fill sizing through intermediate containers that should stretch.\\n- For wrapping text in a column, prefer `w=\\\"fill\\\"`; fixed-width text can use `textAutoResize=\\\"height\\\"`. `maxLines` / `truncate` are intentional truncation, not fixes for accidental overflow.\\n- `wrap` and `rowGap` enable wrapped flex rows. `grid`, `columns`, and `rows` enable grid (for example `columns=\\\"1fr 200px 1fr\\\"` or `columns=\\\"repeat(7, 1fr)\\\"`); tracks are `fr`, pixel lengths, `auto`, `repeat()`, and `minmax()`, which grows like its maximum. Grid children use `colStart`, `rowStart`, `colSpan`, and `rowSpan`. The current grid `gap` shorthand takes precedence over `columnGap` and `rowGap`.\\n- `flow=\\\"auto\\\"|\\\"ltr\\\"|\\\"rtl\\\"` controls container flow; text `dir` controls writing direction. Preserve these separately.\\n- Outside auto-layout, and for `position=\\\"absolute\\\"` children, `constraints={{ horizontal, vertical }}` sets how a layer follows its parent's resizing, with Figma's values in lowercase: `\\\"min\\\"`, `\\\"center\\\"`, `\\\"max\\\"`, `\\\"stretch\\\"`, or `\\\"scale\\\"`. `minW`, `maxW`, `minH`, and `maxH` bound a layer's size. `visible={false}` hides a layer and `locked` locks it.\\n- Use measured node bounds and the existing `arrange` tool for independent artboards: `pack` for a page of screens, `spread` when generated layers overlap. Prefer layout constraints to calculating child coordinates; ordinary JavaScript arithmetic is appropriate when real geometry calculations are needed.\\n\\n## Paint, text, and artwork\\n\\n- `bg` / `fill`, `stroke`, and text `color` accept colors and supported variable references. Set colors explicitly for predictable contrast. `fills` accepts structured paints; gradient helpers include `linearGradient`, `radialGradient`, `angularGradient`, and `diamondGradient`, each taking an array of stops and optional `{ opacity, transform }`: `fills={[linearGradient([['#3b82f6', 0], ['#8b5cf6', 1]])]}`. Without a `transform` a linear gradient runs left to right and the others are centred; `transform` is Figma's `gradientTransform`, mapping the layer's unit square onto gradient space. Write it as the plugin API's rows, as export does: `linearGradient(stops, { transform: [[0, 1, 0], [-1, 0, 1]] })` runs top to bottom. A paint written as an object takes its `gradientTransform` and `imageTransform` as rows too; the matrix fields `{ m00, m01, m02, m10, m11, m12 }` are accepted as well.\\n- `shader(effects, { opacity, visible, blendMode })` fills a layer with a shader from the [`shaders`](https://shaders.com) library: an array of effects such as `bg={shader([{ type: 'Aurora', props: { speed: 2 } }])}`, or a preset as shaders.com exports it, `{ components: [...] }`. The canvas shows the shader's first frame, preview plays it, and files and other formats keep that frame as an image.\\n- `shaderSource(code, { uniforms, opacity, visible, blendMode })` fills a layer with shader code written here rather than a preset; `uniforms` gives the values its `@directive` inputs start with, such as `bg={shaderSource(code, { uniforms: { u_color: '#ff0000' } })}`.\\n- `stroke` describes one stroke, refined by `strokeWidth`, `strokeAlign` (`\\\"inside\\\"`, `\\\"center\\\"`, `\\\"outside\\\"`), `strokeDash`, `strokeCap`, and `strokeJoin`. `strokes` takes several, as objects with `color`, `weight`, `align`, `dash`, `cap`, `join`, and `visible`; `strokeWeights={{ top, right, bottom, left }}` sets per-side widths. `dashPattern` sets the node's own dash pattern, separate from the per-stroke `strokeDash`.\\n- `rounded` and `roundedTL`/`roundedTR`/`roundedBL`/`roundedBR` control corners. `strokeWidth`, `opacity`, `rotate`, and `blendMode` control appearance. `overflow=\\\"hidden\\\"` clips content; do not hide accidental text overflow to make a broken layout appear correct.\\n- `rotate` turns a layer by degrees, and `flipX` and `flipY` reflect it across its centre before it turns, as the canvas places it. `Star` takes `points` and `innerRadius` (0–1, how deep its points go); `Polygon` takes `points`. `Ellipse` draws an arc or a donut with `startAngle` and `endAngle` in degrees, clockwise from three o'clock (0 to 360 by default), and `innerRadius` (0–1, the hole): `<Ellipse w={80} h={80} startAngle={0} endAngle={270} innerRadius={0.6} />`.\\n- `effects` accepts structured effects such as `dropShadow`, `innerShadow`, and `layerBlur`. `shadow` takes a CSS `box-shadow` list, such as `shadow=\\\"0 4 8 #0002, inset 0 1 0 #fff\\\"`, and `blur` a layer blur radius; both are convenient shorthands. Effect helpers take `radius`, as Figma's effects do; when a JSX string is rendered, an option a paint or effect helper does not support is reported as a warning.\\n- Text content belongs inside `Text`. Use `size`, `font`, `weight`, `italic`, `lineHeight`, `letterSpacing`, `textAlign`, `textAlignVertical`, `textDecoration`, and `textCase`. Decorations take CSS's names and values: `textDecorationStyle` (`solid`, `dotted`, `wavy`), `textDecorationColor` (`currentColor` follows the text), `textDecorationThickness` and `textUnderlineOffset` (pixels or `auto`), and `textDecorationSkipInk`. `fontFeatures` turns OpenType features on or off by tag (`fontFeatures={{ tnum: true, liga: false }}`), `fontVariations` sets variable-font axes by tag (`fontVariations={{ wght: 650 }}`), and `lang` names the text's language (`lang=\\\"de\\\"`) for shaping and font fallback. A variable font's optical size follows the font size unless `fontOpticalSizing=\\\"none\\\"`, as in CSS; only then does an `opsz` in `fontVariations` apply. `lineHeight=\\\"auto\\\"` follows the font, and `fills={[]}` paints no text. Verify fonts actually load before judging dimensions; do not assume every font is available.\\n- `Span` styles some characters of a `Text` with `Text`'s own prop names: `size`, `font`, `weight`, `italic`, `color`, `fills`, `lineHeight`, `letterSpacing`, `textDecoration`, the decoration details, `fontFeatures`, `fontVariations`, `lang`, and `textCase`; a span's `fontFeatures` and `fontVariations` replace the text's rather than adding to them, and `fontOpticalSizing` is set on the `Text` for all of it. `href` links its characters to a URL without changing how they look. Spans nest; the inner one wins. `Paragraph` writes one paragraph: `list=\\\"ordered\\\"` or `list=\\\"unordered\\\"` makes it a list item nested at `level` 1–5, and `spacing`, `listSpacing`, and `indent` override the `Text`'s `paragraphSpacing`, `listSpacing`, and `paragraphIndent` for it; `hangingList` on the `Text` hangs list markers outside the text box. A `Text` holds only `Paragraph`s or none; without them, a line break in its text still starts a paragraph.\\n- `Icon` uses an Iconify name, size, and color. Prefer icons to emoji when reliable vector output is needed. Image fills belong on appropriate leaf shapes, not containers whose children must remain visible.\\n- Pick artwork by where it comes from. A known icon is an `Icon` by its Iconify name. A shape you draw yourself is a `Vector` with its path in SVG syntax, `<Vector d=\\\"M11 2L4 11h5l-1 7 7-9h-5z\\\" bg={designVar(…)} />`: one layer, styled with the same props as any other, so its fills can use variables, stack, and take `strokeAlign` and `effects`. `fillRule=\\\"evenodd\\\"` cuts holes. An open path with a `stroke` stays open, a line; with only a `bg` it fills as if closed. Given `w` and `h`, the path is drawn in that box as written, as an icon is in its view box; without them the layer fits the path. `paths` takes several paths as export writes them, each `{ windingRule, data }` with `NONZERO`, `EVENODD`, or `NONE` for an open path: `paths={[{ windingRule: \\\"EVENODD\\\", data: \\\"M0 0L10 0L10 10Z\\\" }]}`. Inline `<svg>` is for artwork copied from elsewhere: it draws the SVG's shapes, a frame with a layer per shape in the SVG's own colours, and leaves out its text, so do not use it for a shape you will style or bind, nor for text.\\n- `Sticky` makes a FigJam sticky note whose text is its body: `<Sticky color=\\\"yellow\\\" author=\\\"Ada\\\">Ship it</Sticky>`. `color` takes a FigJam palette name (`white`, `gray`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `violet`, `pink`) or any colour, `author` signs it (`authorVisible={false}` hides the line), `wide` makes it 416 wide instead of 240, `textSize` is `small`, `medium`, `large`, `extraLarge`, or `huge`, `typeface` is `simple`, `bookish`, `technical`, or `scribbled`, and `scale` scales the whole note. A note sizes itself; it takes no `w`, `h`, fills, or layout props.\\n- `Shape` makes a FigJam shape with text whose text is its label: `<Shape kind=\\\"diamond\\\" bg=\\\"#FFC943\\\">Valid?</Shape>`. `kind` is `square` (default), `ellipse`, `diamond`, `rounded_rectangle`, `parallelogram_right`, `eng_database`, or another FigJam shape, written in lowercase. `w` and `h` are the size it is given (176 by default); it grows taller to fit its label, never wider, so a word too long for it breaks. `truncate` keeps its height and cuts the label off with \\\"…\\\" instead, as FigJam does once a shape's height is set. `bg`, `stroke`, `strokeWidth`, `rounded` (6 by default), and `rotate` style it as any layer; the label is centred in the shape and takes the same `textSize` and `typeface` as `Sticky`.\\n- `Connector` draws a FigJam connector that follows the layers it joins: `<Connector from=\\\"Start\\\" to=\\\"Done\\\">Next</Connector>`. `from` and `to` name layers of the same JSX, take a `ref()` a layer is marked with (`const card = ref()`, then `<Frame ref={card}>` and `from={card}`), or give `{ x, y }` points in the connector's parent; `fromSide`/`toSide` (`top`, `right`, `bottom`, `left`) fix the side it attaches by, `line` is `elbowed` (default), `straight`, or `curved`, and `startCap`/`endCap` take the same caps as `strokeCap`: `none`, `round`, `square`, `arrow_lines`, `arrow_equilateral`, `triangle_filled`, `diamond_filled`, or `circle_filled` (it starts with none and ends with `arrow_lines`). Its text is the label; `stroke`, `strokeWidth`, and `dashPattern` style the line. When layers share a name, join them by `ref()`; a name more than one layer has joins the first, with a warning.\\n- Design JSX props are the portable authoring interface. Some CSS-style aliases are supported, but this is not a browser CSS engine; do not assume arbitrary HTML, classes, or styles work.\\n\\n## Variables and components\\n\\n- `defineVars('Theme', { Page: '#FFFFFF', Radius: 12 }, { mode: 'Light' })` defines a collection in the file's variables table and returns its variables by name, such as `theme.Page`. Each value is the variable's value in the first mode, named by `mode` (`Mode 1` without one): strings are colors, numbers FLOAT, booleans BOOLEAN, and another collection's variable makes an alias, such as `palette['Gray/900']`. `defineMode(theme, 'Dark', { Page: '#111111' })` adds a mode with the values that differ; the rest keep the first mode's. A render that binds any of the variables creates the collection with all its modes, or updates the one with that name, so running the JSX again changes values instead of adding collections.\\n- `designVar('name-or-id')` refers to a variable the document already has; a missing one is an error. When more than one collection has a variable of that name, name the collection too, as `designMode` does: `designVar('Theme', 'Line')`.\\n- COLOR references work in paint props. FLOAT references work in `w`, `h`, `gap`, padding, corner radii, `strokeWidth`, `opacity`, text `size`/`fontSize`, `lineHeight`, and `letterSpacing`. Grid `columnGap`/`rowGap` and wrapped flex `rowGap` also support FLOAT references; grid `gap` overrides both axis-specific gaps. Use numbers or FLOAT references for these scalar props, not CSS unit strings; the one exception is `lineHeight` and `letterSpacing`, which also take a percent of the font size such as `\\\"150%\\\"` that follows the size when it changes.\\n- `mode={dark}` shows a layer and its children in a mode, as the Appearance panel's variable mode control does; a list pins several collections, and `designMode('Theme', 'Dark')` names a mode of a collection the document already has, by the collection's ID when several share its name. Without `mode`, a layer inherits its parent's.\\n- Variables bind real graph fields, not copied values. Layout resolves scalar variables in the mode the layer is created in, its own or inherited; it does not lay content out again after a later mode switch. Verify resulting geometry as well as paint when changing modes. Missing or incorrectly typed scalar variables are errors.\\n- `bind` maps supported scene-field paths to variable IDs or references when no shorthand exists. Use semantic tokens consistently rather than declaring unused collections.\\n- Build repeated or computed content with JavaScript inside `{}` rather than writing each item out: `{days.map((day) => <Text>{day}</Text>)}`, `{Array.from({ length: 35 }, (_, i) => <Frame>…</Frame>)}`, and conditionals. Statements such as `const weeks = …` may come first and then end with `return` and the JSX, as a component's body does: `const weeks = 5` on one line, `return <Frame>…</Frame>` on the next.\\n- A reusable JavaScript function shares source code, not component identity. Use `Component`, `ComponentSet`, and `Instance` for editable main components and linked instances.\\n- `Instance` resolves an existing component through `of`, `component`, or `componentId`. Component-set children named `variant=Primary`, for example, define variants that can be selected when instantiating the set.\\n- `property(name, defaultValue)` binds a field of a component's layer to a component property, created on first use: `text={property('Message', 'Hi')}` on a `Text` makes a TEXT property, `visible={property('Pinned', true)}` a BOOLEAN one, and `of={property('Icon', 'Star')}` on an `Instance` an INSTANCE_SWAP one whose default is the component `of` names. The property belongs to the nearest `Component`, or to its `ComponentSet` for a variant, so the same name in each variant binds one property; one name with two types or two defaults is an error.\\n- An `Instance` sets text, boolean, and swap properties by name, the way it picks a variant: `<Instance of=\\\"Note\\\" State=\\\"Done\\\" Message=\\\"Updated review\\\" Pinned={false} />`. `properties` takes the same values keyed by property ID or name, for names that are not JSX identifiers or that design JSX already uses, such as `name`. Only instances accept `properties`.\\n- `exposed` on an `Instance` in a component shows that instance's own properties on the component's instances, as Figma's \\\"Expose properties from nested instances\\\" does; the instance's component needs properties to expose. An outer instance gives an exposed instance its variant and properties as an object under the exposed layer's name: `<Instance of=\\\"Card\\\" Title=\\\"Welcome\\\" Action={{ Variant: 'Secondary', Label: 'Save' }} />`, or `properties={{ Action: { … } }}`.\\n- Instance assignments take `true` / `false` or the native `'true'` / `'false'` for BOOLEAN properties, and a component's name or ID for swaps, as `of` does, whether set as a prop or in `properties`. Assignments persist through component synchronization; unknown IDs and invalid values fail rather than silently creating inert overrides. Select variants through component-set variant props, not through instance property assignments.\\n- Reuse existing local or library components before recreating them. Keep meaningful text, visibility, and swap properties exposed rather than hand-editing cloned child nodes.\\n- Explicit instance `w` / `h` replace the inherited sizing mode on that axis; omitted dimensions retain the main component's sizing. Authored overrides survive component synchronization. Distinguish those placement constraints from the main component's default size, and verify actual bounds in narrower parents. Do not compensate for a sizing mismatch with guessed heights, clipping, or manually positioned siblings.\\n\\n## Controls\\n\\n- A main component can behave as a Reka UI control in preview and code. Write it with Reka's names: `Switch.Root` is the component (a component set when its children are `Component` variants), and each Reka part is the slot that draws it, such as `Switch.Thumb`, `Slider.Track`, `Slider.Range`, `Slider.Thumb`, `Progress.Track`, `Progress.Indicator`, `Tabs.List`, `Collapsible.Trigger`, or `NumberField.Increment`. Parts in different variants share one slot.\\n- The root names the properties that hold its values: `modelValue` (`open` on `Collapsible.Root`), `disabled`, and, for text fields, `filled`, as a variant or boolean property name, or `{ property, on, off }` when the variant values are not named like On and Off. `states` names the variant property that draws default, hover, pressed, focus, and disabled; a slider, progress bar, or number field takes `min`, `max`, `step`, and `defaultValue`.\\n- `TextField.Input`, `Textarea.Input`, and `NumberField.Input` are the text layers whose text becomes the field's text property. `Tabs.Trigger` goes in `Tabs.List`; `Tabs.Content` panels may sit directly under `Tabs.Root`, the first showing. A part with children and no `flex`, `display`, `w`, or `h` of its own stacks them in a column that hugs them.\\n- A group's item component is written on its own (`RadioGroup.Item`, `ToggleGroup.Item`, `Accordion.Item` with its `Accordion.Trigger` and `Accordion.Content`); the group's root then lists items as `<RadioGroup.Item of={radioId} />`.\\n\\n```tsx\\n<Switch.Root name=\\\"Switch\\\" modelValue=\\\"State\\\" states=\\\"Interaction\\\">\\n <Component name=\\\"State=Off, Interaction=Default\\\" w={44} h={24} rounded={12} bg=\\\"#D0D4DA\\\">\\n <Switch.Thumb x={2} y={2} w={20} h={20} rounded={10} bg=\\\"#FFFFFF\\\" />\\n </Component>\\n <Component name=\\\"State=On, Interaction=Default\\\" w={44} h={24} rounded={12} bg=\\\"#3B6CF6\\\">\\n <Switch.Thumb x={22} y={2} w={20} h={20} rounded={10} bg=\\\"#FFFFFF\\\" />\\n </Component>\\n</Switch.Root>\\n```\\n\\n## Verification\\n\\nInspect structure and actual rendered output. Node counts and `describe` diagnostics do not establish visual fidelity. Check wrapping with longer content, narrower containers, component edits, and relevant modes. Resolve overflow and contrast problems at their source. Reuse IDs returned by creation tools rather than repeatedly searching for the same nodes.\\n\\nThe examples below are executed by the authoring-reference tests. Create the named variables before running a variable-bound example.\\n\"","import dedent from 'dedent'\n\nexport interface AuthoringExample {\n title: string\n jsx: string\n}\n\n/** Shared verbatim by runtime prompts and the installable skill; exercised in engine tests. */\nexport const AUTHORING_EXAMPLES: readonly AuthoringExample[] = [\n {\n title: 'Content-sized review note',\n jsx: dedent`<Frame name=\"Review note\" w={280} h=\"hug\" flex=\"col\" gap={8} p={16} bg=\"#FFFFFF\">\n <Text name=\"Author\" size={12} weight=\"medium\" color=\"#252A31\">June Lee</Text>\n <Text name=\"Message\" w=\"fill\" size={12} color=\"#6B7079\">Give the date a little more room at the bottom.</Text>\n</Frame>`\n },\n {\n title: 'Variable-bound spacing and typography',\n jsx: dedent`<Frame name=\"Bound note\" w={280} h=\"hug\" flex=\"col\" gap={designVar('Space/small')} p={designVar('Space/medium')} bg=\"#FFFFFF\">\n <Text name=\"Message\" w=\"fill\" size={designVar('Type/body')} lineHeight={designVar('Type/body-leading')} letterSpacing={designVar('Type/body-tracking')} color=\"#252A31\">A note that grows with its content.</Text>\n</Frame>`\n },\n {\n title: 'A theme with two modes',\n jsx: dedent`const theme = defineVars('Theme', { Surface: '#FFFFFF', Ink: '#252A31', Radius: 12 }, { mode: 'Light' })\nconst dark = defineMode(theme, 'Dark', { Surface: '#1A1A20', Ink: '#F5F5F7' })\nreturn <Frame name=\"Dark note\" mode={dark} w={280} h=\"hug\" flex=\"col\" gap={8} p={16} bg={theme.Surface} rounded={theme.Radius}>\n <Text name=\"Message\" w=\"fill\" size={12} color={theme.Ink}>Shown in the Dark mode of the Theme collection.</Text>\n</Frame>`\n },\n {\n title: 'Component with text and visibility properties',\n jsx: dedent`<Component name=\"Comment\" w={280} h=\"hug\" flex=\"col\" gap={8} p={16} bg=\"#FFFFFF\">\n <Text name=\"Author\" size={12} weight=\"medium\" color=\"#252A31\" text={property('Author', 'June Lee')} />\n <Text name=\"Message\" w=\"fill\" size={12} color=\"#6B7079\" text={property('Message', 'Give the date more room.')} visible={property('Show message', true)} />\n</Component>`\n },\n {\n title: 'Rich text with spans and lists',\n jsx: dedent`<Frame name=\"Release notes\" w={280} h=\"hug\" flex=\"col\" gap={8} p={16} bg=\"#FFFFFF\">\n <Text name=\"Notes\" w=\"fill\" size={12} color=\"#252A31\" paragraphSpacing={4}>\n <Paragraph spacing={8}>Version 2 is <Span weight=\"bold\" color=\"#3B6CF6\" textDecoration=\"underline\" textDecorationStyle=\"wavy\" textUnderlineOffset={2}>out now</Span>.</Paragraph>\n <Paragraph list=\"unordered\">Faster export</Paragraph>\n <Paragraph list=\"unordered\" level={2}>PDF and SVG</Paragraph>\n <Paragraph list=\"ordered\">Fewer clicks</Paragraph>\n </Text>\n</Frame>`\n }\n]\n","import { DESIGN_JSX_SUPPORTED_PROPERTY_NAMES } from './definitions'\nimport { DESIGN_JSX_ELEMENTS } from './elements'\nimport { DESIGN_JSX_HELPERS } from './helpers'\nimport authoring from './reference/authoring.md?raw'\nimport { AUTHORING_EXAMPLES } from './reference/examples'\n\nexport { AUTHORING_EXAMPLES, type AuthoringExample } from './reference/examples'\n\n/** Canonical scene-authoring guidance shared by runtime prompts and generated skill references. */\nexport const JSX_REFERENCE = [\n authoring.trim(),\n // Examples are written verbatim; dedenting them again would flatten their nesting.\n ...AUTHORING_EXAMPLES.map(({ title, jsx }) => `## ${title}\\n\\n\\`\\`\\`jsx\\n${jsx}\\n\\`\\`\\``),\n '## Supported syntax inventory',\n 'Generated from the renderer metadata. This inventory lists accepted names, not arbitrary browser CSS support.',\n `**Elements:** ${DESIGN_JSX_ELEMENTS.map(({ name }) => `\\`${name}\\``).join(', ')}.`,\n `**Helpers:** ${DESIGN_JSX_HELPERS.map(({ name }) => `\\`${name}\\``).join(', ')}.`,\n `**Properties:** ${DESIGN_JSX_SUPPORTED_PROPERTY_NAMES.map((name) => `\\`${name}\\``).join(', ')}.`\n].join('\\n\\n')\n","import { parseExpressionAt, type Expression, type ObjectExpression } from 'acorn'\n\nconst MAX_LITERAL_DEPTH = 32\nconst UNSUPPORTED = Symbol('unsupported-literal')\n\ntype LiteralValue =\n | string\n | number\n | boolean\n | null\n | LiteralValue[]\n | { [key: string]: LiteralValue }\ntype Result = LiteralValue | typeof UNSUPPORTED\n\n/** Decode data only. Calls, getters, spreads, identifiers and computed keys never execute. */\nexport function readLiteral(source: string): { value: LiteralValue } | null {\n try {\n const expression = parseExpressionAt(source, 0, { ecmaVersion: 'latest' })\n if (source.slice(expression.end).trim()) return null\n const value = evaluateLiteral(expression, 0)\n return value === UNSUPPORTED ? null : { value }\n } catch {\n return null\n }\n}\n\nfunction evaluateLiteral(expression: Expression, depth: number): Result {\n if (depth > MAX_LITERAL_DEPTH) return UNSUPPORTED\n switch (expression.type) {\n case 'Literal': {\n const value = expression.value\n return value === null ||\n typeof value === 'string' ||\n typeof value === 'boolean' ||\n (typeof value === 'number' && Number.isFinite(value))\n ? value\n : UNSUPPORTED\n }\n case 'UnaryExpression': {\n if (expression.operator !== '-' && expression.operator !== '+') return UNSUPPORTED\n const value = evaluateLiteral(expression.argument, depth + 1)\n if (typeof value !== 'number') return UNSUPPORTED\n return expression.operator === '-' ? -value : value\n }\n case 'ArrayExpression': {\n const values: LiteralValue[] = []\n for (const element of expression.elements) {\n if (!element || element.type === 'SpreadElement') return UNSUPPORTED\n const value = evaluateLiteral(element, depth + 1)\n if (value === UNSUPPORTED) return UNSUPPORTED\n values.push(value)\n }\n return values\n }\n case 'ObjectExpression':\n return evaluateObject(expression, depth)\n default:\n return UNSUPPORTED\n }\n}\n\nfunction evaluateObject(expression: ObjectExpression, depth: number): Result {\n const entries: [string, LiteralValue][] = []\n for (const property of expression.properties) {\n if (\n property.type !== 'Property' ||\n property.computed ||\n property.method ||\n property.shorthand ||\n property.kind !== 'init'\n )\n return UNSUPPORTED\n let key: unknown\n if (property.key.type === 'Identifier') key = property.key.name\n else if (property.key.type === 'Literal') key = property.key.value\n if (typeof key !== 'string' && typeof key !== 'number') return UNSUPPORTED\n const value = evaluateLiteral(property.value, depth + 1)\n if (value === UNSUPPORTED) return UNSUPPORTED\n entries.push([String(key), value])\n }\n return Object.fromEntries(entries)\n}\n","import type { SyntaxNode } from '@lezer/common'\nimport { decodeHTML } from 'entities'\n\nimport { DESIGN_JSX_ELEMENTS } from '../elements'\nimport { FRAGMENT, type TreeNode } from '../tree'\nimport { readLiteral } from './literals'\n\nconst ELEMENT_TYPES = new Map(\n DESIGN_JSX_ELEMENTS.map(({ name, runtimeType }) => [name, runtimeType])\n)\nconst MAX_PREVIEW_DEPTH = 100\nconst MAX_PREVIEW_NODES = 10_000\n\nexport interface JSXPreviewNode extends TreeNode {\n /** Stable identity within an append-only source stream; not a permanent scene node ID. */\n sourceStart: number\n children: (JSXPreviewNode | string)[]\n}\n\nexport interface JSXPreviewPending {\n from: number\n to: number\n reason: 'incomplete' | 'unsupported'\n}\n\nexport interface JSXPreviewSnapshot {\n tree: JSXPreviewNode | null\n pending: JSXPreviewPending[]\n}\n\nfunction children(node: SyntaxNode): SyntaxNode[] {\n const result: SyntaxNode[] = []\n for (let child = node.firstChild; child; child = child.nextSibling) result.push(child)\n return result\n}\n\nfunction hasError(node: SyntaxNode): boolean {\n let error = false\n node.cursor().iterate((child) => {\n if (child.type.isError) error = true\n return !error\n })\n return error\n}\n\n/** Match JSX's line-oriented whitespace handling, rather than HTML whitespace collapsing. */\nfunction textValue(raw: string): string {\n const lines = raw.split(/\\r\\n|\\n|\\r/)\n const lastNonEmpty = lines.findLastIndex((line) => /[^ \\t]/.test(line))\n return lines\n .map((line, index) => {\n let value = line.replaceAll('\\t', ' ')\n if (index > 0) value = value.replace(/^ +/, '')\n if (index < lines.length - 1) value = value.replace(/ +$/, '')\n return value && index < lastNonEmpty ? `${value} ` : value\n })\n .join('')\n}\n\nexport function projectPreview(root: SyntaxNode, source: string): JSXPreviewSnapshot {\n const pending: JSXPreviewPending[] = []\n let nodeCount = 0\n const raw = (node: SyntaxNode) => source.slice(node.from, node.to)\n const defer = (node: SyntaxNode, reason: JSXPreviewPending['reason']) => {\n pending.push({ from: node.from, to: node.to, reason })\n }\n\n function expression(node: SyntaxNode) {\n if (hasError(node) || !raw(node).endsWith('}')) {\n defer(node, 'incomplete')\n return null\n }\n const value = readLiteral(raw(node).slice(1, -1))\n if (!value) defer(node, 'unsupported')\n return value\n }\n\n function attributes(opening: SyntaxNode): Record<string, unknown> | null {\n const props: Record<string, unknown> = {}\n for (const attribute of children(opening)) {\n if (attribute.name === 'JSXSpreadAttribute') {\n // A spread can change any prop, so don't guess the element's appearance.\n defer(attribute, 'unsupported')\n return null\n }\n if (attribute.name !== 'JSXAttribute') continue\n const keyNode = attribute.firstChild\n if (keyNode?.name !== 'JSXIdentifier') {\n defer(attribute, 'unsupported')\n continue\n }\n const key = raw(keyNode)\n const valueNode = attribute.lastChild\n let value: unknown = true\n if (valueNode && valueNode !== keyNode && valueNode.from !== keyNode.from) {\n if (valueNode.name === 'JSXAttributeValue') {\n value = decodeHTML(\n raw(valueNode)\n .slice(1, -1)\n .replace(/\\r\\n|[\\r\\n\\t]/g, ' ')\n )\n } else if (valueNode.name === 'JSXEscape') {\n const literal = expression(valueNode)\n if (!literal) continue\n value = literal.value\n } else {\n defer(attribute, 'unsupported')\n continue\n }\n }\n // defineProperty handles __proto__ as data, never as a prototype mutation.\n Object.defineProperty(props, key, {\n value,\n enumerable: true,\n configurable: true,\n writable: true\n })\n }\n return props\n }\n\n function element(node: SyntaxNode, depth: number): JSXPreviewNode | null {\n if (depth > MAX_PREVIEW_DEPTH || ++nodeCount > MAX_PREVIEW_NODES) {\n throw new RangeError('JSX preview tree limit exceeded')\n }\n const opening = node.firstChild\n if (!opening || !['JSXOpenTag', 'JSXSelfClosingTag', 'JSXFragmentTag'].includes(opening.name)) {\n defer(node, 'unsupported')\n return null\n }\n // Recovery can synthesize a self-closing tag without an authored />.\n const delimiter = opening.lastChild\n if (hasError(opening) || !delimiter || !['>', '/>'].includes(raw(delimiter))) {\n defer(opening, 'incomplete')\n return null\n }\n const tagName = opening.getChild('JSXIdentifier') ?? opening.getChild('JSXBuiltin')\n const fragment = raw(opening) === '<>'\n const name = tagName ? raw(tagName) : ''\n const type = fragment\n ? FRAGMENT\n : (ELEMENT_TYPES.get(name) ?? (/^[a-z][\\w-]*$/.test(name) ? name : null))\n if (type === null) {\n defer(opening, 'unsupported')\n return null\n }\n const props = attributes(opening)\n if (!props) return null\n const result: JSXPreviewNode = { type, props, children: [], sourceStart: node.from }\n appendChildren(node, result, depth)\n return result\n }\n\n function appendChildren(node: SyntaxNode, result: JSXPreviewNode, depth: number): void {\n for (const child of children(node).slice(1)) {\n if (child.name === 'JSXElement') {\n const projected = element(child, depth + 1)\n // A nested fragment adds its children, as it does in rendered trees.\n if (projected?.type === FRAGMENT) result.children.push(...projected.children)\n else if (projected) result.children.push(projected)\n } else if (child.name === 'JSXText') {\n let value = raw(child)\n if (child.to === source.length) {\n // Don't flash a partial entity or a split UTF-16 surrogate as literal text.\n value = value.replace(/&(?:#x?[\\da-f]*|[a-z]*)$/i, '').replace(/[\\uD800-\\uDBFF]$/, '')\n }\n value = decodeHTML(textValue(value))\n if (value) result.children.push(value)\n } else if (child.name === 'JSXEscape') {\n const literal = expression(child)\n if (literal && (typeof literal.value === 'string' || typeof literal.value === 'number')) {\n result.children.push(String(literal.value))\n } else if (literal && typeof literal.value === 'object' && literal.value !== null) {\n defer(child, 'unsupported')\n }\n } else if (child.type.isError || hasError(child)) {\n defer(child, 'incomplete')\n }\n }\n }\n\n const first = root.firstChild\n if (!first) return { tree: null, pending }\n if (first.name !== 'JSXElement') {\n defer(first, hasError(root) ? 'incomplete' : 'unsupported')\n return { tree: null, pending }\n }\n return { tree: element(first, 0), pending }\n}\n","import { TreeFragment } from '@lezer/common'\nimport { parser } from '@lezer/javascript'\n\nimport { projectPreview, type JSXPreviewSnapshot } from './projection'\n\nexport type { JSXPreviewNode, JSXPreviewPending, JSXPreviewSnapshot } from './projection'\n\nconst jsxParser = parser.configure({ dialect: 'jsx', top: 'SingleExpression' })\nconst MAX_PREVIEW_SOURCE_LENGTH = 128_000\n\n/**\n * Append-only, non-executing Design JSX preview parser. Own one instance per tool call.\n * Snapshots contain fresh data; later appends never mutate an earlier preview.\n * This is not final JSX validation: unsupported expressions are deliberately deferred.\n * Call append on coalesced chunks, not once per token, to bound projection work.\n */\nexport function createStreamingJSXParser() {\n let source = ''\n let fragments: readonly TreeFragment[] = []\n\n function append(chunk: string): JSXPreviewSnapshot {\n if (source.length + chunk.length > MAX_PREVIEW_SOURCE_LENGTH) {\n throw new RangeError('JSX preview source limit exceeded')\n }\n const next = source + chunk\n const changed = TreeFragment.applyChanges(fragments, [\n {\n fromA: source.length,\n toA: source.length,\n fromB: source.length,\n toB: next.length\n }\n ])\n const tree = jsxParser.parse(next, changed)\n const snapshot = projectPreview(tree.topNode, next)\n source = next\n fragments = TreeFragment.addTree(tree)\n return snapshot\n }\n\n function reset(): void {\n source = ''\n fragments = []\n }\n\n return { append, reset }\n}\n"],"mappings":";;;;;;;;;;;;;AAMA,MAAM,kCAAkB,IAAI,IAAqB;CAC/C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;AAMD,MAAM,iCAAiB,IAAI,IAAuB;CAAC;CAAY;CAAU;AAAmB,CAAC;AAE7F,SAAS,eAAe,UAAqB,UAA8B;CACzE,OAAO,SAAS,SAAS,SAAS,QAAQ,CAAC,eAAe,IAAI,SAAS,IAAI;AAC7E;;AAGA,SAAS,cACP,UACA,UAC2B;CAC3B,MAAM,wBAAQ,IAAI,IAA0B;CAC5C,MAAM,OAAO,IAAI,IAAI,QAAQ;CAC7B,MAAM,QAAQ,MAAiB,SAA4C;EACzE,KAAK,MAAM,aAAa,MAAM;GAC5B,IAAI,CAAC,KAAK,SAAS,GAAG;GACtB,KAAK,OAAO,SAAS;GACrB,MAAM,IAAI,MAAM,SAAS;GACzB;EACF;CACF;CACA,KAAK,MAAM,QAAQ,UACjB,KAAK,OAAO,cAAc,UAAU,SAAS,KAAK,QAAQ,UAAU,SAAS,KAAK,IAAI;CAExF,KAAK,MAAM,QAAQ,UACjB,IAAI,CAAC,MAAM,IAAI,IAAI,GAAG,KAAK,OAAO,cAAc,UAAU,SAAS,KAAK,IAAI;CAE9E,OAAO;AACT;AAEA,SAAS,gBAAgB,UAAq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,UAAU,YAAY,QAAQ,UAAU,MAC3E,MAAM,OAAO,aAAa;EAE9B,OAAO,IAAI,MAAM,KAAK,WAAW,SAAS,KAAK,GAC7C,MAAM,OAAO,YAAY;CAG/B;CAEA,MAAM,QAAQ,KAAK;CACnB,IAAI,CAAC,OAAO,OAAO;EAAE,MAAM;EAAM;CAAQ;CACzC,IAAI,MAAM,SAAS,cAAc;EAC/B,MAAM,OAAO,SAAS,IAAI,IAAI,eAAe,aAAa;EAC1D,OAAO;GAAE,MAAM;GAAM;EAAQ;CAC/B;CACA,OAAO;EAAE,MAAM,QAAQ,OAAO,CAAC;EAAG;CAAQ;AAC5C;;;ACrLA,MAAM,YAAY,OAAO,UAAU;CAAE,SAAS;CAAO,KAAK;AAAmB,CAAC;AAC9E,MAAM,4BAA4B;;;;;;;AAQlC,SAAgB,2BAA2B;CACzC,IAAI,SAAS;CACb,IAAI,YAAqC,CAAC;CAE1C,SAAS,OAAO,OAAmC;EACjD,IAAI,OAAO,SAAS,MAAM,SAAS,2BACjC,MAAM,IAAI,WAAW,mCAAmC;EAE1D,MAAM,OAAO,SAAS;EACtB,MAAM,UAAU,aAAa,aAAa,WAAW,CACnD;GACE,OAAO,OAAO;GACd,KAAK,OAAO;GACZ,OAAO,OAAO;GACd,KAAK,KAAK;EACZ,CACF,CAAC;EACD,MAAM,OAAO,UAAU,MAAM,MAAM,OAAO;EAC1C,MAAM,WAAW,eAAe,KAAK,SAAS,IAAI;EAClD,SAAS;EACT,YAAY,aAAa,QAAQ,IAAI;EACrC,OAAO;CACT;CAEA,SAAS,QAAc;EACrB,SAAS;EACT,YAAY,CAAC;CACf;CAEA,OAAO;EAAE;EAAQ;CAAM;AACzB"}
@@ -0,0 +1,16 @@
1
+ import { node } from "./behaviours/elements.js";
2
+ //#region src/jsx-runtime.ts
3
+ function jsx(type, props) {
4
+ if (typeof type === "function") return type(props);
5
+ return node(type, props);
6
+ }
7
+ const jsxs = jsx;
8
+ const jsxDEV = jsx;
9
+ /** Groups siblings the way `<>…</>` does in `renderJSX` strings: a node with an empty type. */
10
+ function Fragment({ children }) {
11
+ return node("", { children });
12
+ }
13
+ //#endregion
14
+ export { Fragment, jsx, jsxDEV, jsxs };
15
+
16
+ //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-dev-runtime.js","names":[],"sources":["../../src/jsx-runtime.ts"],"sourcesContent":["import {\n FRAGMENT,\n node,\n type BaseProps,\n type EllipseProps,\n type ParagraphProps,\n type SpanProps,\n type TreeNode,\n type TextProps\n} from './tree'\n\nexport function jsx(type: string | ((props: BaseProps) => TreeNode), props: BaseProps): TreeNode {\n if (typeof type === 'function') {\n return type(props)\n }\n return node(type, props)\n}\n\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\n/** Groups siblings the way `<>…</>` does in `renderJSX` strings: a node with an empty type. */\nexport function Fragment({ children }: { children?: unknown }): TreeNode {\n return node(FRAGMENT, { children })\n}\n\nexport namespace JSX {\n export type Element = TreeNode\n\n export interface IntrinsicElements {\n frame: BaseProps\n text: TextProps\n 'text-span': SpanProps\n 'text-paragraph': ParagraphProps\n rectangle: BaseProps\n ellipse: BaseProps & EllipseProps\n line: BaseProps\n star: BaseProps & { points?: number; innerRadius?: number }\n polygon: BaseProps & { pointCount?: number }\n vector: BaseProps\n group: BaseProps\n section: BaseProps\n component: BaseProps\n 'component-set': BaseProps\n instance: BaseProps & { component?: string; componentId?: string; of?: string }\n }\n\n export interface ElementChildrenAttribute {\n children: unknown\n }\n}\n"],"mappings":";;AAWA,SAAgB,IAAI,MAAiD,OAA4B;CAC/F,IAAI,OAAO,SAAS,YAClB,OAAO,KAAK,KAAK;CAEnB,OAAO,KAAK,MAAM,KAAK;AACzB;AAEA,MAAa,OAAO;AACpB,MAAa,SAAS;;AAGtB,SAAgB,SAAS,EAAE,YAA8C;CACvE,OAAO,KAAA,IAAe,EAAE,SAAS,CAAC;AACpC"}