@pairdraw/core 0.19.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/providers.d.ts +6 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js.map +1 -1
- package/dist/cache/resource.d.ts +8 -1
- package/dist/cache/resource.d.ts.map +1 -1
- package/dist/cache/resource.js +18 -0
- package/dist/cache/resource.js.map +1 -1
- package/dist/canvas/effects.d.ts +6 -4
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +37 -34
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +12 -8
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/images/adjustments.d.ts +18 -0
- package/dist/canvas/images/adjustments.d.ts.map +1 -0
- package/dist/canvas/images/adjustments.js +184 -0
- package/dist/canvas/images/adjustments.js.map +1 -0
- package/dist/canvas/images/sampling.d.ts +13 -0
- package/dist/canvas/images/sampling.d.ts.map +1 -0
- package/dist/canvas/images/sampling.js +49 -0
- package/dist/canvas/images/sampling.js.map +1 -0
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/masks.d.ts +1 -1
- package/dist/canvas/masks.d.ts.map +1 -1
- package/dist/canvas/masks.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +15 -0
- package/dist/canvas/noise/render.d.ts.map +1 -0
- package/dist/canvas/noise/render.js +56 -0
- package/dist/canvas/noise/render.js.map +1 -0
- package/dist/canvas/noise/shader.d.ts +46 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +166 -0
- package/dist/canvas/noise/shader.js.map +1 -0
- package/dist/canvas/noise/table.d.ts +13 -0
- package/dist/canvas/noise/table.d.ts.map +1 -0
- package/dist/canvas/noise/table.js +408 -0
- package/dist/canvas/noise/table.js.map +1 -0
- package/dist/canvas/noise/tile.d.ts +22 -0
- package/dist/canvas/noise/tile.d.ts.map +1 -0
- package/dist/canvas/noise/tile.js +74 -0
- package/dist/canvas/noise/tile.js.map +1 -0
- package/dist/canvas/outline-stroke.js +1 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +31 -71
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/colors.d.ts +20 -5
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +48 -42
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +25 -0
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -0
- package/dist/canvas/renderer/document-surface.js +46 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -0
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +6 -4
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +10 -3
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -0
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +36 -3
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/play-scenes.d.ts +13 -0
- package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
- package/dist/canvas/renderer/play-scenes.js +40 -0
- package/dist/canvas/renderer/play-scenes.js.map +1 -0
- package/dist/canvas/renderer/retained-backing.d.ts.map +1 -1
- package/dist/canvas/renderer/retained-backing.js +2 -1
- package/dist/canvas/renderer/retained-backing.js.map +1 -1
- package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
- package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/cache.js +32 -1
- package/dist/canvas/renderer/tiles/cache.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +18 -1
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/index.d.ts +2 -2
- package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js +2 -7
- package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +18 -3
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
- package/dist/canvas/renderer/visual-bounds.js +1 -1
- package/dist/canvas/renderer.d.ts +42 -4
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +57 -5
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +45 -12
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shaders/effect.d.ts.map +1 -1
- package/dist/canvas/shaders/effect.js +2 -1
- package/dist/canvas/shaders/effect.js.map +1 -1
- package/dist/canvas/shadows/shape.d.ts.map +1 -1
- package/dist/canvas/shadows/shape.js +4 -2
- package/dist/canvas/shadows/shape.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/shadows.d.ts.map +1 -1
- package/dist/canvas/shadows.js +4 -2
- package/dist/canvas/shadows.js.map +1 -1
- package/dist/canvas/text/decorations.d.ts +2 -2
- package/dist/canvas/text/decorations.d.ts.map +1 -1
- package/dist/canvas/text/decorations.js +5 -5
- package/dist/canvas/text/decorations.js.map +1 -1
- package/dist/canvas/text/index.js +1 -1
- package/dist/canvas/text/index.js.map +1 -1
- package/dist/canvas/text/paragraph/index.d.ts +2 -2
- package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/index.js +16 -5
- package/dist/canvas/text/paragraph/index.js.map +1 -1
- package/dist/canvas/text/renderer.d.ts +2 -1
- package/dist/canvas/text/renderer.d.ts.map +1 -1
- package/dist/canvas/text/shape.js +4 -4
- package/dist/canvas/text/shape.js.map +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +101 -0
- package/dist/canvas/texture.js.map +1 -0
- package/dist/clipboard.js +16 -5
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-memory/check.d.ts +90 -0
- package/dist/design-memory/check.d.ts.map +1 -0
- package/dist/design-memory/check.js +281 -0
- package/dist/design-memory/check.js.map +1 -0
- package/dist/design-memory/describe.d.ts +37 -0
- package/dist/design-memory/describe.d.ts.map +1 -0
- package/dist/design-memory/describe.js +52 -0
- package/dist/design-memory/describe.js.map +1 -0
- package/dist/design-memory/distil.d.ts +22 -0
- package/dist/design-memory/distil.d.ts.map +1 -0
- package/dist/design-memory/distil.js +54 -0
- package/dist/design-memory/distil.js.map +1 -0
- package/dist/design-memory/document.d.ts +12 -0
- package/dist/design-memory/document.d.ts.map +1 -0
- package/dist/design-memory/document.js +64 -0
- package/dist/design-memory/document.js.map +1 -0
- package/dist/design-memory/guard.d.ts +48 -0
- package/dist/design-memory/guard.d.ts.map +1 -0
- package/dist/design-memory/guard.js +105 -0
- package/dist/design-memory/guard.js.map +1 -0
- package/dist/design-memory/index.d.ts +9 -0
- package/dist/design-memory/index.js +9 -0
- package/dist/design-memory/refusal.d.ts +32 -0
- package/dist/design-memory/refusal.d.ts.map +1 -0
- package/dist/design-memory/refusal.js +68 -0
- package/dist/design-memory/refusal.js.map +1 -0
- package/dist/design-memory/rules.d.ts +63 -0
- package/dist/design-memory/rules.d.ts.map +1 -0
- package/dist/design-memory/rules.js +224 -0
- package/dist/design-memory/rules.js.map +1 -0
- package/dist/design-memory/values.d.ts +28 -0
- package/dist/design-memory/values.d.ts.map +1 -0
- package/dist/design-memory/values.js +160 -0
- package/dist/design-memory/values.js.map +1 -0
- package/dist/editor/alignment.js +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/clipboard/assets.d.ts.map +1 -1
- package/dist/editor/clipboard/assets.js +3 -3
- package/dist/editor/clipboard/assets.js.map +1 -1
- package/dist/editor/clipboard/component-matches.d.ts +13 -0
- package/dist/editor/clipboard/component-matches.d.ts.map +1 -0
- package/dist/editor/clipboard/component-matches.js +50 -0
- package/dist/editor/clipboard/component-matches.js.map +1 -0
- package/dist/editor/clipboard/dependencies.d.ts +7 -0
- package/dist/editor/clipboard/dependencies.d.ts.map +1 -1
- package/dist/editor/clipboard/dependencies.js +5 -0
- package/dist/editor/clipboard/dependencies.js.map +1 -1
- package/dist/editor/clipboard/export.d.ts.map +1 -1
- package/dist/editor/clipboard/export.js +16 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/placement.d.ts +1 -1
- package/dist/editor/clipboard/placement.js +1 -1
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +48 -19
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/properties.d.ts.map +1 -1
- package/dist/editor/components/properties.js +3 -3
- package/dist/editor/components/properties.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/connectors/attach.js +1 -1
- package/dist/editor/create.d.ts +26 -2
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +16 -60
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-memory.d.ts +11 -0
- package/dist/editor/design-memory.d.ts.map +1 -0
- package/dist/editor/design-memory.js +40 -0
- package/dist/editor/design-memory.js.map +1 -0
- package/dist/editor/design-tokens.d.ts +4 -0
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +30 -1
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/document-colors.d.ts +23 -0
- package/dist/editor/document-colors.d.ts.map +1 -0
- package/dist/editor/document-colors.js +53 -0
- package/dist/editor/document-colors.js.map +1 -0
- package/dist/editor/eyedropper.d.ts +47 -0
- package/dist/editor/eyedropper.d.ts.map +1 -0
- package/dist/editor/eyedropper.js +171 -0
- package/dist/editor/eyedropper.js.map +1 -0
- package/dist/editor/fonts.d.ts +9 -0
- package/dist/editor/fonts.d.ts.map +1 -0
- package/dist/editor/fonts.js +14 -0
- package/dist/editor/fonts.js.map +1 -0
- package/dist/editor/history/atomic-tool.d.ts +9 -2
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +9 -2
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/capture.d.ts +13 -0
- package/dist/editor/history/capture.d.ts.map +1 -0
- package/dist/editor/history/capture.js +28 -0
- package/dist/editor/history/capture.js.map +1 -0
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +2 -22
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts +7 -0
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +4 -2
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/subtree.d.ts +9 -0
- package/dist/editor/history/subtree.d.ts.map +1 -1
- package/dist/editor/history/subtree.js +12 -2
- package/dist/editor/history/subtree.js.map +1 -1
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +4 -2
- package/dist/editor/pages.d.ts +7 -5
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +35 -25
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts +3 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +1 -1
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +4 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/render-requests.d.ts +18 -0
- package/dist/editor/render-requests.d.ts.map +1 -0
- package/dist/editor/render-requests.js +76 -0
- package/dist/editor/render-requests.js.map +1 -0
- package/dist/editor/scale/rescale.d.ts +1 -1
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +1 -1
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +4 -0
- package/dist/editor/selection.d.ts +5 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/pencil.js +1 -1
- package/dist/editor/structure/state.d.ts.map +1 -1
- package/dist/editor/structure/state.js +2 -2
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/text.d.ts.map +1 -1
- package/dist/editor/text.js +2 -2
- package/dist/editor/text.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +5 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.js +3 -3
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.js +3 -0
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
- package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
- package/dist/figma-api/accessors/text/opentype.js +28 -0
- package/dist/figma-api/accessors/text/opentype.js.map +1 -0
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +33 -0
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/effects.d.ts +79 -3
- package/dist/figma-api/effects.d.ts.map +1 -1
- package/dist/figma-api/effects.js +150 -9
- package/dist/figma-api/effects.js.map +1 -1
- package/dist/figma-api/fresh-read.d.ts +15 -0
- package/dist/figma-api/fresh-read.d.ts.map +1 -0
- package/dist/figma-api/fresh-read.js +54 -0
- package/dist/figma-api/fresh-read.js.map +1 -0
- package/dist/figma-api/graph-ref.d.ts +9 -0
- package/dist/figma-api/graph-ref.d.ts.map +1 -0
- package/dist/figma-api/graph-ref.js +14 -0
- package/dist/figma-api/graph-ref.js.map +1 -0
- package/dist/figma-api/index.d.ts +11 -1
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +16 -4
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +13 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +196 -4
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/paints.d.ts +3 -3
- package/dist/figma-api/paints.d.ts.map +1 -1
- package/dist/figma-api/paints.js +14 -4
- package/dist/figma-api/paints.js.map +1 -1
- package/dist/figma-api/pending-layout.d.ts +3 -3
- package/dist/figma-api/pending-layout.d.ts.map +1 -1
- package/dist/figma-api/pending-layout.js +7 -3
- package/dist/figma-api/pending-layout.js.map +1 -1
- package/dist/figma-api/pending-sync.d.ts +1 -1
- package/dist/figma-api/pending-sync.d.ts.map +1 -1
- package/dist/figma-api/pending-sync.js +3 -1
- package/dist/figma-api/pending-sync.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +2 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +59 -15
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +160 -32
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/render-bounds.js +1 -1
- package/dist/figma-api/surface.d.ts +6 -3
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +6 -2
- package/dist/figma-api/surface.js.map +1 -1
- package/dist/figma-api/transform.d.ts +1 -1
- package/dist/figma-api/variables/index.d.ts.map +1 -1
- package/dist/figma-api/variables/index.js +2 -2
- package/dist/figma-api/variables/index.js.map +1 -1
- package/dist/geometry/figma.d.ts +1 -1
- package/dist/geometry/image-crop.d.ts +1 -1
- package/dist/geometry/image-crop.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/formats/boolean-path.d.ts +19 -0
- package/dist/io/formats/boolean-path.d.ts.map +1 -0
- package/dist/io/formats/boolean-path.js +47 -0
- package/dist/io/formats/boolean-path.js.map +1 -0
- package/dist/io/formats/design-tokens/css/known.js +1 -1
- package/dist/io/formats/design-tokens/css/known.js.map +1 -1
- package/dist/io/formats/design-tokens/css/read.d.ts +3 -1
- package/dist/io/formats/design-tokens/css/read.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/read.js +11 -5
- package/dist/io/formats/design-tokens/css/read.js.map +1 -1
- package/dist/io/formats/design-tokens/css/sync.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/sync.js +17 -4
- package/dist/io/formats/design-tokens/css/sync.js.map +1 -1
- package/dist/io/formats/design-tokens/css/values.d.ts +6 -5
- package/dist/io/formats/design-tokens/css/values.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/css/values.js +24 -8
- package/dist/io/formats/design-tokens/css/values.js.map +1 -1
- package/dist/io/formats/design-tokens/decode.d.ts +7 -6
- package/dist/io/formats/design-tokens/decode.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/decode.js +14 -13
- package/dist/io/formats/design-tokens/decode.js.map +1 -1
- package/dist/io/formats/design-tokens/export.js +3 -3
- package/dist/io/formats/design-tokens/export.js.map +1 -1
- package/dist/io/formats/design-tokens/index.d.ts +4 -1
- package/dist/io/formats/design-tokens/index.js +4 -1
- package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
- package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/index.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/index.js +4 -3
- package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.js +9 -9
- package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/project.d.ts +17 -2
- package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/project.js +29 -8
- package/dist/io/formats/design-tokens/project.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts +4 -4
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js +7 -7
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
- package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/apply.js +73 -0
- package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.js +391 -0
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.js +35 -0
- package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
- package/dist/io/formats/design-tokens/values.d.ts +10 -5
- package/dist/io/formats/design-tokens/values.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/values.js +13 -7
- package/dist/io/formats/design-tokens/values.js.map +1 -1
- package/dist/io/formats/drawio/edges.d.ts +7 -1
- package/dist/io/formats/drawio/edges.d.ts.map +1 -1
- package/dist/io/formats/drawio/edges.js +54 -1
- package/dist/io/formats/drawio/edges.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +19 -2
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.js +1 -0
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/drawio/warnings.js +2 -2
- package/dist/io/formats/drawio/warnings.js.map +1 -1
- package/dist/io/formats/fig/export/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/index.js +15 -3
- package/dist/io/formats/fig/export/index.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +7 -1
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts +7 -2
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +12 -13
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
- package/dist/io/formats/fig/export/variables.js +9 -7
- package/dist/io/formats/fig/export/variables.js.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
- package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
- package/dist/io/formats/html/import.d.ts.map +1 -1
- package/dist/io/formats/html/import.js +3 -1
- package/dist/io/formats/html/import.js.map +1 -1
- package/dist/io/formats/html/index.d.ts +2 -2
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +6 -4
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/vectors.d.ts +2 -1
- package/dist/io/formats/html/vectors.d.ts.map +1 -1
- package/dist/io/formats/html/vectors.js +4 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/layers.js +2 -2
- package/dist/io/formats/mermaid/layers.js.map +1 -1
- package/dist/io/formats/pdf/document.d.ts +3 -1
- package/dist/io/formats/pdf/document.d.ts.map +1 -1
- package/dist/io/formats/pdf/document.js +6 -3
- package/dist/io/formats/pdf/document.js.map +1 -1
- package/dist/io/formats/pdf/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -0
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/prepare.d.ts +4 -4
- package/dist/io/formats/pdf/prepare.d.ts.map +1 -1
- package/dist/io/formats/pdf/prepare.js +2 -2
- package/dist/io/formats/pdf/prepare.js.map +1 -1
- package/dist/io/formats/pen/imports.d.ts +4 -1
- package/dist/io/formats/pen/imports.d.ts.map +1 -1
- package/dist/io/formats/pen/imports.js.map +1 -1
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +35 -5
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/export.js +1 -1
- package/dist/io/formats/pptx/geometry.d.ts +1 -1
- package/dist/io/formats/pptx/style.js +1 -1
- package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
- package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
- package/dist/io/formats/raster/adjusted-images.js +118 -0
- package/dist/io/formats/raster/adjusted-images.js.map +1 -0
- package/dist/io/formats/raster/headless.d.ts +11 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +4 -4
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/pixels.d.ts +7 -1
- package/dist/io/formats/raster/pixels.d.ts.map +1 -1
- package/dist/io/formats/raster/pixels.js.map +1 -1
- package/dist/io/formats/raster/render.d.ts +1 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +13 -4
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +10 -8
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +13 -64
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.d.ts +16 -0
- package/dist/io/formats/svg/effects.d.ts.map +1 -0
- package/dist/io/formats/svg/effects.js +126 -0
- package/dist/io/formats/svg/effects.js.map +1 -0
- package/dist/io/formats/svg/export.d.ts +11 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +177 -37
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +30 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +48 -0
- package/dist/io/formats/svg/filter.js.map +1 -0
- package/dist/io/formats/svg/grain.d.ts +26 -0
- package/dist/io/formats/svg/grain.d.ts.map +1 -0
- package/dist/io/formats/svg/grain.js +298 -0
- package/dist/io/formats/svg/grain.js.map +1 -0
- package/dist/io/formats/svg/import.d.ts +4 -2
- package/dist/io/formats/svg/import.d.ts.map +1 -1
- package/dist/io/formats/svg/import.js +2 -1
- package/dist/io/formats/svg/import.js.map +1 -1
- package/dist/io/formats/svg/strokes.d.ts +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +1 -2
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/export.d.ts.map +1 -1
- package/dist/io/formats/svg/text/export.js +8 -8
- package/dist/io/formats/svg/text/export.js.map +1 -1
- package/dist/io/formats/svg/text/import.js +1 -1
- package/dist/io/formats/svg/text/layout.d.ts +5 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +8 -5
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/composite.d.ts +18 -0
- package/dist/io/formats/video/composite.d.ts.map +1 -0
- package/dist/io/formats/video/composite.js +79 -0
- package/dist/io/formats/video/composite.js.map +1 -0
- package/dist/io/formats/video/formats.d.ts +29 -0
- package/dist/io/formats/video/formats.d.ts.map +1 -0
- package/dist/io/formats/video/formats.js +43 -0
- package/dist/io/formats/video/formats.js.map +1 -0
- package/dist/io/formats/video/gif.d.ts +13 -0
- package/dist/io/formats/video/gif.d.ts.map +1 -0
- package/dist/io/formats/video/gif.js +56 -0
- package/dist/io/formats/video/gif.js.map +1 -0
- package/dist/io/formats/video/index.d.ts +9 -0
- package/dist/io/formats/video/index.js +9 -0
- package/dist/io/formats/video/plan.d.ts +64 -0
- package/dist/io/formats/video/plan.d.ts.map +1 -0
- package/dist/io/formats/video/plan.js +90 -0
- package/dist/io/formats/video/plan.js.map +1 -0
- package/dist/io/formats/video/record.d.ts +36 -0
- package/dist/io/formats/video/record.d.ts.map +1 -0
- package/dist/io/formats/video/record.js +154 -0
- package/dist/io/formats/video/record.js.map +1 -0
- package/dist/io/formats/video/sink.d.ts +29 -0
- package/dist/io/formats/video/sink.d.ts.map +1 -0
- package/dist/io/formats/video/sink.js +16 -0
- package/dist/io/formats/video/sink.js.map +1 -0
- package/dist/io/formats/video/size.d.ts +19 -0
- package/dist/io/formats/video/size.d.ts.map +1 -0
- package/dist/io/formats/video/size.js +26 -0
- package/dist/io/formats/video/size.js.map +1 -0
- package/dist/io/formats/video/webcodecs.d.ts +18 -0
- package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
- package/dist/io/formats/video/webcodecs.js +74 -0
- package/dist/io/formats/video/webcodecs.js.map +1 -0
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +41 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +1 -1
- package/dist/io/subgraph.js.map +1 -1
- package/dist/io/types.d.ts +20 -5
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/kiwi/fig/session/options.d.ts +3 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js +4 -0
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout/yoga-helpers.d.ts +2 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +7 -1
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +26 -2
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +10 -4
- package/dist/lint/fixes.js.map +1 -1
- package/dist/lint/index.d.ts +3 -2
- package/dist/lint/index.js +2 -1
- package/dist/lint/linter.d.ts +12 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +112 -10
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/presets.d.ts.map +1 -1
- package/dist/lint/presets.js +2 -0
- package/dist/lint/presets.js.map +1 -1
- package/dist/lint/rules/design-memory.d.ts +15 -0
- package/dist/lint/rules/design-memory.d.ts.map +1 -0
- package/dist/lint/rules/design-memory.js +90 -0
- package/dist/lint/rules/design-memory.js.map +1 -0
- package/dist/lint/rules/index.d.ts +6 -5
- package/dist/lint/rules/index.d.ts.map +1 -1
- package/dist/lint/rules/index.js +6 -2
- package/dist/lint/rules/index.js.map +1 -1
- package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
- package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
- package/dist/lint/rules/no-unbound-token-values.js +79 -0
- package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
- package/dist/lint/types.d.ts +25 -2
- package/dist/lint/types.d.ts.map +1 -1
- package/dist/node/video.d.ts +12 -0
- package/dist/node/video.d.ts.map +1 -0
- package/dist/node/video.js +206 -0
- package/dist/node/video.js.map +1 -0
- package/dist/pairdraw-api/comments.d.ts +4 -1
- package/dist/pairdraw-api/comments.d.ts.map +1 -1
- package/dist/pairdraw-api/comments.js +5 -0
- package/dist/pairdraw-api/comments.js.map +1 -1
- package/dist/pairdraw-api/design-memory.d.ts +19 -0
- package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
- package/dist/pairdraw-api/design-memory.js +39 -0
- package/dist/pairdraw-api/design-memory.js.map +1 -0
- package/dist/pairdraw-api/index.d.ts +48 -4
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +59 -6
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +13 -2
- package/dist/pairdraw-api/nodes.d.ts.map +1 -1
- package/dist/pairdraw-api/nodes.js +28 -1
- package/dist/pairdraw-api/nodes.js.map +1 -1
- package/dist/pairdraw-api/variations.d.ts +48 -0
- package/dist/pairdraw-api/variations.d.ts.map +1 -0
- package/dist/pairdraw-api/variations.js +76 -0
- package/dist/pairdraw-api/variations.js.map +1 -0
- package/dist/prototype/easing.d.ts +13 -0
- package/dist/prototype/easing.d.ts.map +1 -0
- package/dist/prototype/easing.js +36 -0
- package/dist/prototype/easing.js.map +1 -0
- package/dist/prototype/frames.d.ts +10 -0
- package/dist/prototype/frames.d.ts.map +1 -0
- package/dist/prototype/frames.js +12 -0
- package/dist/prototype/frames.js.map +1 -0
- package/dist/prototype/hit.d.ts +17 -0
- package/dist/prototype/hit.d.ts.map +1 -0
- package/dist/prototype/hit.js +45 -0
- package/dist/prototype/hit.js.map +1 -0
- package/dist/prototype/index.d.ts +14 -0
- package/dist/prototype/index.js +14 -0
- package/dist/prototype/pointer.d.ts +63 -0
- package/dist/prototype/pointer.d.ts.map +1 -0
- package/dist/prototype/pointer.js +104 -0
- package/dist/prototype/pointer.js.map +1 -0
- package/dist/prototype/reactions.d.ts +45 -0
- package/dist/prototype/reactions.d.ts.map +1 -0
- package/dist/prototype/reactions.js +122 -0
- package/dist/prototype/reactions.js.map +1 -0
- package/dist/prototype/scene.d.ts +35 -0
- package/dist/prototype/scene.d.ts.map +1 -0
- package/dist/prototype/scene.js +86 -0
- package/dist/prototype/scene.js.map +1 -0
- package/dist/prototype/scenes.d.ts +81 -0
- package/dist/prototype/scenes.d.ts.map +1 -0
- package/dist/prototype/scenes.js +175 -0
- package/dist/prototype/scenes.js.map +1 -0
- package/dist/prototype/scroll.d.ts +48 -0
- package/dist/prototype/scroll.d.ts.map +1 -0
- package/dist/prototype/scroll.js +159 -0
- package/dist/prototype/scroll.js.map +1 -0
- package/dist/prototype/session.d.ts +71 -0
- package/dist/prototype/session.d.ts.map +1 -0
- package/dist/prototype/session.js +135 -0
- package/dist/prototype/session.js.map +1 -0
- package/dist/prototype/smart-animate/animation.d.ts +34 -0
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
- package/dist/prototype/smart-animate/animation.js +212 -0
- package/dist/prototype/smart-animate/animation.js.map +1 -0
- package/dist/prototype/smart-animate/match.d.ts +24 -0
- package/dist/prototype/smart-animate/match.d.ts.map +1 -0
- package/dist/prototype/smart-animate/match.js +72 -0
- package/dist/prototype/smart-animate/match.js.map +1 -0
- package/dist/prototype/snapshot.d.ts +19 -0
- package/dist/prototype/snapshot.d.ts.map +1 -0
- package/dist/prototype/snapshot.js +56 -0
- package/dist/prototype/snapshot.js.map +1 -0
- package/dist/prototype/timeline.d.ts +132 -0
- package/dist/prototype/timeline.d.ts.map +1 -0
- package/dist/prototype/timeline.js +260 -0
- package/dist/prototype/timeline.js.map +1 -0
- package/dist/rpc/analyze-commands.js +1 -1
- package/dist/rpc/read-commands.d.ts +2 -2
- package/dist/rpc/read-commands.js +2 -2
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/rpc/variables-command.js +2 -2
- package/dist/rpc/variables-command.js.map +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +60 -1
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/font/provider.d.ts +15 -0
- package/dist/text/font/provider.d.ts.map +1 -0
- package/dist/text/font/provider.js +18 -0
- package/dist/text/font/provider.js.map +1 -0
- package/dist/text/font/readiness.d.ts +32 -0
- package/dist/text/font/readiness.d.ts.map +1 -0
- package/dist/text/font/{status.js → readiness.js} +8 -4
- package/dist/text/font/readiness.js.map +1 -0
- package/dist/text/index.d.ts +12 -9
- package/dist/text/index.js +6 -3
- package/dist/text/prepare.d.ts +9 -4
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +9 -4
- package/dist/text/prepare.js.map +1 -1
- package/dist/text/replace-fonts.d.ts +41 -0
- package/dist/text/replace-fonts.d.ts.map +1 -0
- package/dist/text/replace-fonts.js +121 -0
- package/dist/text/replace-fonts.js.map +1 -0
- package/dist/tools/analyze/colors.js +1 -1
- package/dist/tools/analyze/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +192 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze/responsive/widths.d.ts +27 -0
- package/dist/tools/analyze/responsive/widths.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/widths.js +49 -0
- package/dist/tools/analyze/responsive/widths.js.map +1 -0
- package/dist/tools/analyze.d.ts +3 -1
- package/dist/tools/analyze.js +3 -1
- package/dist/tools/codegen/token-sync.d.ts +7 -0
- package/dist/tools/codegen/token-sync.d.ts.map +1 -0
- package/dist/tools/codegen/token-sync.js +85 -0
- package/dist/tools/codegen/token-sync.js.map +1 -0
- package/dist/tools/codegen/tokens.d.ts +1 -1
- package/dist/tools/codegen/tokens.d.ts.map +1 -1
- package/dist/tools/codegen/tokens.js +2 -2
- package/dist/tools/codegen/tokens.js.map +1 -1
- package/dist/tools/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +2 -2
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/component-catalog.d.ts.map +1 -1
- package/dist/tools/component-catalog.js +5 -3
- package/dist/tools/component-catalog.js.map +1 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +4 -0
- package/dist/tools/create/components.js.map +1 -1
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +2 -3
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +2 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +1 -0
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/svg.js +5 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +2 -2
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/css/shorthand.d.ts +20 -0
- package/dist/tools/css/shorthand.d.ts.map +1 -0
- package/dist/tools/css/shorthand.js +54 -0
- package/dist/tools/css/shorthand.js.map +1 -0
- package/dist/tools/describe/index.js +2 -2
- package/dist/tools/describe/index.js.map +1 -1
- package/dist/tools/describe/issues.js +1 -1
- package/dist/tools/design-memory.d.ts +8 -0
- package/dist/tools/design-memory.d.ts.map +1 -0
- package/dist/tools/design-memory.js +68 -0
- package/dist/tools/design-memory.js.map +1 -0
- package/dist/tools/html-host.d.ts.map +1 -1
- package/dist/tools/html-host.js +5 -3
- package/dist/tools/html-host.js.map +1 -1
- package/dist/tools/image-ai/apply.d.ts.map +1 -1
- package/dist/tools/image-ai/apply.js +1 -3
- package/dist/tools/image-ai/apply.js.map +1 -1
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +2 -0
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/image-ai/service.d.ts.map +1 -1
- package/dist/tools/image-ai/service.js +5 -3
- package/dist/tools/image-ai/service.js.map +1 -1
- package/dist/tools/index.d.ts +3 -1
- package/dist/tools/index.js +3 -1
- package/dist/tools/modify/effects.js +1 -1
- package/dist/tools/modify/effects.js.map +1 -1
- package/dist/tools/modify/fonts.d.ts +6 -0
- package/dist/tools/modify/fonts.d.ts.map +1 -0
- package/dist/tools/modify/fonts.js +27 -0
- package/dist/tools/modify/fonts.js.map +1 -0
- package/dist/tools/modify/geometry.d.ts.map +1 -1
- package/dist/tools/modify/geometry.js +14 -3
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +35 -8
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.d.ts.map +1 -1
- package/dist/tools/modify/matching.js +10 -10
- package/dist/tools/modify/matching.js.map +1 -1
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +56 -4
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +2 -2
- package/dist/tools/modify/reactions.js.map +1 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +29 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts +10 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +34 -3
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/prompts/codegen.js +1 -1
- package/dist/tools/prompts/codegen.js.map +1 -1
- package/dist/tools/read/css.d.ts +14 -0
- package/dist/tools/read/css.d.ts.map +1 -0
- package/dist/tools/read/css.js +306 -0
- package/dist/tools/read/css.js.map +1 -0
- package/dist/tools/read/fonts.d.ts.map +1 -1
- package/dist/tools/read/fonts.js +17 -2
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -0
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/reactions.js +1 -1
- package/dist/tools/read/reactions.js.map +1 -1
- package/dist/tools/read/space.d.ts +3 -1
- package/dist/tools/read/space.d.ts.map +1 -1
- package/dist/tools/read/space.js +4 -5
- package/dist/tools/read/space.js.map +1 -1
- package/dist/tools/read.d.ts +2 -1
- package/dist/tools/read.js +2 -1
- package/dist/tools/registry/core.d.ts +1 -1
- package/dist/tools/registry/core.d.ts.map +1 -1
- package/dist/tools/registry/core.js +5 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +16 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +24 -6
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +10 -6
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/script/host.d.ts.map +1 -1
- package/dist/tools/script/host.js +5 -3
- package/dist/tools/script/host.js.map +1 -1
- package/dist/tools/stock-photo.js +1 -0
- package/dist/tools/stock-photo.js.map +1 -1
- package/dist/tools/structure/basic.d.ts.map +1 -1
- package/dist/tools/structure/basic.js +1 -0
- package/dist/tools/structure/basic.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +8 -1
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/structure/hierarchy.d.ts.map +1 -1
- package/dist/tools/structure/hierarchy.js +4 -0
- package/dist/tools/structure/hierarchy.js.map +1 -1
- package/dist/tools/structure/variations.d.ts +8 -0
- package/dist/tools/structure/variations.d.ts.map +1 -0
- package/dist/tools/structure/variations.js +106 -0
- package/dist/tools/structure/variations.js.map +1 -0
- package/dist/tools/structure.d.ts +2 -1
- package/dist/tools/structure.js +2 -1
- package/dist/tools/styles/types.d.ts +2 -4
- package/dist/tools/styles/types.d.ts.map +1 -1
- package/dist/tools/styles/types.js.map +1 -1
- package/dist/tools/variables/collections.js +1 -1
- package/dist/tools/variables/collections.js.map +1 -1
- package/dist/tools/variables/values.d.ts.map +1 -1
- package/dist/tools/variables/values.js +4 -4
- package/dist/tools/variables/values.js.map +1 -1
- package/dist/tools/vector/boolean.d.ts.map +1 -1
- package/dist/tools/vector/boolean.js +4 -0
- package/dist/tools/vector/boolean.js.map +1 -1
- package/dist/tools/vector/vectorize.d.ts.map +1 -1
- package/dist/tools/vector/vectorize.js +7 -4
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/vector/video.d.ts +6 -0
- package/dist/tools/vector/video.d.ts.map +1 -0
- package/dist/tools/vector/video.js +133 -0
- package/dist/tools/vector/video.js.map +1 -0
- package/dist/tools/vector.d.ts +2 -1
- package/dist/tools/vector.js +2 -1
- package/dist/tools/video-host.d.ts +12 -0
- package/dist/tools/video-host.d.ts.map +1 -0
- package/dist/tools/video-host.js +21 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/gradients.d.ts +2 -2
- package/dist/vector/vectorize/svg/gradients.d.ts.map +1 -1
- package/dist/vector/vectorize/svg/gradients.js +5 -5
- package/dist/vector/vectorize/svg/gradients.js.map +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +3 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts.map +1 -1
- package/dist/vector/vectorize/svg/to-vectors.js +13 -12
- package/dist/vector/vectorize/svg/to-vectors.js.map +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +169 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +95 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/renderer/colors.ts +76 -50
- package/src/canvas/renderer/document-surface.ts +53 -0
- package/src/canvas/renderer/fonts.ts +6 -4
- package/src/canvas/renderer/lifecycle.ts +10 -4
- package/src/canvas/renderer/methods.ts +1 -0
- package/src/canvas/renderer/pipeline.ts +40 -4
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/retained-backing.ts +2 -1
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/tiles/surface-pool.ts +9 -7
- package/src/canvas/renderer/types.ts +18 -2
- package/src/canvas/renderer.ts +76 -14
- package/src/canvas/scene.ts +69 -12
- package/src/canvas/shaders/effect.ts +2 -1
- package/src/canvas/shadows/shape.ts +4 -2
- package/src/canvas/shadows.ts +5 -2
- package/src/canvas/text/decorations.ts +15 -5
- package/src/canvas/text/index.ts +9 -1
- package/src/canvas/text/paragraph/index.ts +16 -6
- package/src/canvas/text/renderer.ts +2 -1
- package/src/canvas/text/shape.ts +4 -4
- package/src/canvas/texture.ts +137 -0
- package/src/clipboard.ts +23 -10
- package/src/constants.ts +6 -0
- package/src/design-memory/check.ts +376 -0
- package/src/design-memory/describe.ts +77 -0
- package/src/design-memory/distil.ts +69 -0
- package/src/design-memory/document.ts +80 -0
- package/src/design-memory/guard.ts +157 -0
- package/src/design-memory/index.ts +8 -0
- package/src/design-memory/refusal.ts +90 -0
- package/src/design-memory/rules.ts +274 -0
- package/src/design-memory/values.ts +179 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/clipboard/assets.ts +6 -2
- package/src/editor/clipboard/component-matches.ts +65 -0
- package/src/editor/clipboard/dependencies.ts +22 -1
- package/src/editor/clipboard/export.ts +24 -7
- package/src/editor/clipboard.ts +74 -20
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/components/properties.ts +3 -2
- package/src/editor/create.ts +25 -69
- package/src/editor/design-memory.ts +39 -0
- package/src/editor/design-tokens.ts +41 -2
- package/src/editor/document-colors.ts +65 -0
- package/src/editor/eyedropper.ts +208 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +32 -3
- package/src/editor/history/capture.ts +19 -0
- package/src/editor/history/document-change.ts +5 -17
- package/src/editor/history/edit.ts +11 -1
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +4 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/structure/state.ts +2 -1
- package/src/editor/text.ts +2 -1
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +4 -0
- package/src/editor/variables.ts +3 -3
- package/src/editor/variations/create.ts +235 -0
- package/src/editor/variations/pick.ts +35 -0
- package/src/editor/variations.ts +110 -0
- package/src/figma-api/accessors/reactions.ts +11 -1
- package/src/figma-api/accessors/text/index.ts +7 -0
- package/src/figma-api/accessors/text/opentype.ts +33 -0
- package/src/figma-api/accessors/visual.ts +55 -2
- package/src/figma-api/compatibility.ts +5 -2
- package/src/figma-api/effects.ts +143 -5
- package/src/figma-api/fresh-read.ts +57 -0
- package/src/figma-api/graph-ref.ts +13 -0
- package/src/figma-api/index.ts +22 -4
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/pending-layout.ts +7 -3
- package/src/figma-api/pending-sync.ts +4 -1
- package/src/figma-api/proxy.ts +8 -2
- package/src/figma-api/reactions.ts +212 -33
- package/src/figma-api/surface.ts +6 -2
- package/src/figma-api/variables/index.ts +5 -4
- package/src/global.d.ts +26 -0
- package/src/io/formats/boolean-path.ts +60 -0
- package/src/io/formats/design-tokens/css/known.ts +1 -1
- package/src/io/formats/design-tokens/css/read.ts +20 -7
- package/src/io/formats/design-tokens/css/sync.ts +9 -4
- package/src/io/formats/design-tokens/css/values.ts +37 -9
- package/src/io/formats/design-tokens/decode.ts +17 -12
- package/src/io/formats/design-tokens/export.ts +3 -3
- package/src/io/formats/design-tokens/index.ts +21 -0
- package/src/io/formats/design-tokens/plan/changes.ts +4 -1
- package/src/io/formats/design-tokens/plan/index.ts +6 -5
- package/src/io/formats/design-tokens/plan/styles.ts +37 -10
- package/src/io/formats/design-tokens/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +20 -9
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +589 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/design-tokens/values.ts +15 -8
- package/src/io/formats/drawio/edges.ts +65 -0
- package/src/io/formats/drawio/export.ts +37 -14
- package/src/io/formats/drawio/index.ts +2 -0
- package/src/io/formats/drawio/warnings.ts +2 -2
- package/src/io/formats/fig/export/index.ts +36 -3
- package/src/io/formats/fig/export/patch/index.ts +12 -1
- package/src/io/formats/fig/export/setup.ts +25 -15
- package/src/io/formats/fig/export/variables.ts +17 -6
- package/src/io/formats/fig/thumbnail-page.ts +4 -4
- package/src/io/formats/html/import.ts +9 -1
- package/src/io/formats/html/index.ts +14 -7
- package/src/io/formats/html/vectors.ts +9 -2
- package/src/io/formats/mermaid/layers.ts +2 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/export.ts +1 -0
- package/src/io/formats/pdf/prepare.ts +6 -6
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +41 -7
- package/src/io/formats/raster/adjusted-images.ts +125 -0
- package/src/io/formats/raster/headless.ts +3 -3
- package/src/io/formats/raster/index.ts +6 -1
- package/src/io/formats/raster/pixels.ts +7 -0
- package/src/io/formats/raster/render.ts +24 -5
- package/src/io/formats/svg/defs.ts +24 -80
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +295 -49
- package/src/io/formats/svg/filter.ts +57 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/import.ts +6 -3
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/export.ts +10 -8
- package/src/io/formats/svg/text/layout.ts +15 -5
- package/src/io/formats/video/composite.ts +79 -0
- package/src/io/formats/video/formats.ts +77 -0
- package/src/io/formats/video/gif.ts +65 -0
- package/src/io/formats/video/index.ts +30 -0
- package/src/io/formats/video/plan.ts +116 -0
- package/src/io/formats/video/record.ts +227 -0
- package/src/io/formats/video/sink.ts +32 -0
- package/src/io/formats/video/size.ts +25 -0
- package/src/io/formats/video/webcodecs.ts +89 -0
- package/src/io/formats.ts +66 -11
- package/src/io/subgraph.ts +4 -1
- package/src/io/types.ts +29 -10
- package/src/kiwi/fig/session/options.ts +4 -1
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/yoga-helpers.ts +8 -0
- package/src/layout.ts +49 -1
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +108 -11
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/types.ts +32 -0
- package/src/node/video.ts +196 -0
- package/src/pairdraw-api/comments.ts +6 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +88 -9
- package/src/pairdraw-api/nodes.ts +38 -0
- package/src/pairdraw-api/variations.ts +109 -0
- package/src/prototype/easing.ts +37 -0
- package/src/prototype/frames.ts +9 -0
- package/src/prototype/hit.ts +70 -0
- package/src/prototype/index.ts +69 -0
- package/src/prototype/pointer.ts +146 -0
- package/src/prototype/reactions.ts +178 -0
- package/src/prototype/scene.ts +116 -0
- package/src/prototype/scenes.ts +256 -0
- package/src/prototype/scroll.ts +190 -0
- package/src/prototype/session.ts +188 -0
- package/src/prototype/smart-animate/animation.ts +267 -0
- package/src/prototype/smart-animate/match.ts +85 -0
- package/src/prototype/snapshot.ts +60 -0
- package/src/prototype/timeline.ts +400 -0
- package/src/rpc/read-commands.ts +4 -4
- package/src/rpc/variables-command.ts +2 -2
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +79 -1
- package/src/text/font/provider.ts +26 -0
- package/src/text/font/{status.ts → readiness.ts} +13 -9
- package/src/text/index.ts +4 -1
- package/src/text/prepare.ts +9 -4
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +257 -0
- package/src/tools/analyze/responsive/widths.ts +63 -0
- package/src/tools/analyze.ts +4 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen/tokens.ts +4 -2
- package/src/tools/codegen.ts +1 -0
- package/src/tools/comments.ts +6 -4
- package/src/tools/component-catalog.ts +5 -3
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -3
- package/src/tools/create/icons.ts +2 -1
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +5 -1
- package/src/tools/create/vector.ts +2 -2
- package/src/tools/css/shorthand.ts +64 -0
- package/src/tools/describe/index.ts +2 -8
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/html-host.ts +5 -3
- package/src/tools/image-ai/apply.ts +0 -2
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/image-ai/service.ts +5 -3
- package/src/tools/index.ts +3 -0
- package/src/tools/modify/effects.ts +1 -1
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/geometry.ts +16 -3
- package/src/tools/modify/layout.ts +47 -13
- package/src/tools/modify/matching.ts +14 -11
- package/src/tools/modify/paint.ts +85 -5
- package/src/tools/modify/reactions.ts +16 -8
- package/src/tools/modify/text.ts +56 -15
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/prompts/codegen.md +2 -1
- package/src/tools/read/css.ts +365 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/reactions.ts +3 -2
- package/src/tools/read/space.ts +3 -4
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/core.ts +5 -2
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +42 -9
- package/src/tools/script/host.ts +6 -3
- package/src/tools/stock-photo.ts +1 -0
- package/src/tools/structure/basic.ts +1 -0
- package/src/tools/structure/batch.ts +12 -1
- package/src/tools/structure/hierarchy.ts +4 -0
- package/src/tools/structure/variations.ts +118 -0
- package/src/tools/structure.ts +2 -0
- package/src/tools/styles/types.ts +3 -4
- package/src/tools/variables/collections.ts +1 -1
- package/src/tools/variables/values.ts +16 -5
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/vectorize.ts +11 -4
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +20 -0
- package/src/vector/vectorize/svg/gradients.ts +8 -5
- package/src/vector/vectorize/svg/to-vectors.ts +48 -14
- package/dist/text/font/status.d.ts +0 -28
- package/dist/text/font/status.d.ts.map +0 -1
- package/dist/text/font/status.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/tools/prompts/codegen.md?raw
|
|
2
|
-
var codegen_default = "# Design to Code\n\nYou convert Figma designs into production frontend code. You have full access to the design document through tools. Never guess — always read the actual design data.\n\n> Note: Auto-layout and visual property names match the JSX props in the render system. See `describe` tool output for semantic role and layout analysis of any node.\n\n## Workflow\n\n### Step 1 — Survey\n\nUnderstand the full picture before writing any code.\n\n```\nget_page_tree → document structure, all top-level frames\nget_components → reusable components defined by the designer\nlist_variables → design tokens (colors, numbers, strings, booleans)\nlist_collections → variable collections and modes (light/dark, density, etc.)\nanalyze_colors → color palette, frequencies, which colors use variables\nanalyze_typography → font stacks, sizes, weights in use\nanalyze_spacing → gap and padding values, grid compliance\n```\n\nAfter this step you should know:\n\n- How many screens/pages the design has\n- What components exist\n- What the token system looks like (or if there is none)\n- The typographic scale\n- The spacing system (4px grid? 8px grid? irregular?)\n\n### Step 2 — Decompose\n\nIdentify the component architecture.\n\n```\nanalyze_clusters → find repeated visual patterns that should be components\ndescribe (per node) → semantic role, layout direction, visual properties, issues\nget_jsx (per node) → structural JSX to understand nesting and layout\n```\n\nBuild a component map:\n\n- **Screens** — top-level frames that represent pages/views\n- **Components** — COMPONENT/COMPONENT_SET nodes or repeated patterns from analyze_clusters\n- **Primitives** — leaf elements (text, icons, dividers) that don't need their own component file\n\nFor each component determine:\n\n- **Props** — what content varies between instances (text, color, icon, visibility)\n- **Variants** — if the component has multiple states (default/hover/active, small/medium/large)\n- **Slots** — where child content is injected\n- **Behaviour** — `get_behaviour id=<component_id>` tells whether the designer made it a control, after Reka UI's primitives. Build such a component on that Reka primitive (`SwitchRoot` with `SwitchThumb`, `SliderRoot` with `SliderTrack`, `SliderRange`, and `SliderThumb`, `TabsRoot` with `TabsList`, `TabsTrigger`, and `TabsContent`, …): each part is the slot the behaviour names, its values are the properties it binds (`v-model` for the value, `disabled`), and its interaction states map to the variants for `data-state`, `:hover`, `:active`, `:focus-visible`, and `[data-disabled]`. Do not reimplement the control's keyboard and accessibility handling. In React use the Radix primitive with the same parts (Reka UI is the Vue port of Radix), and with a component library use its equivalent; see **Component libraries** below.\n\n### Step 3 — Extract tokens\n\n```\nlist_variables → all variables with values per mode\nlist_collections → collection structure and mode names\n```\n\nMap design variables to code tokens. The approach depends on the target stack:\n\n#### Tailwind projects\n\nDo NOT create CSS custom properties for font sizes, font weights, spacing, or border radius — Tailwind has its own system for these. Use Tailwind utility classes directly:\n\n- Font sizes → `text-[13px]`, `text-sm`, `text-base`, etc.\n- Font weights → `font-bold`, `font-medium`, `font-[600]`\n- Spacing → `gap-3`, `p-4`, `px-5`, `py-[14px]`, or arbitrary `gap-[12px]`\n- Border radius → `rounded-xl`, `rounded-[14px]`, `rounded-full`\n\nOnly create CSS custom properties for **semantic colors** — these are the values that would change across themes. Name them to avoid conflicts with Tailwind's built-in variables (do NOT use names like `--font-bold`, `--text-sm`, `--radius-lg`):\n\n```css\n:root {\n --movie-bg: #0f0f1a;\n --movie-surface: #1a1a2e;\n --movie-accent: #7c3aed;\n --movie-text: #ffffff;\n --movie-text-dim: #ffffff80;\n}\n```\n\nReference in Tailwind classes: `bg-[var(--movie-bg)]`, `text-[var(--movie-text)]`\n\n#### CSS Modules / plain CSS projects\n\nCreate CSS custom properties for all token categories (colors, spacing, typography, radius). Use a project-specific prefix to avoid collisions:\n\n```css\n:root {\n --app-color-bg: #0f0f1a;\n --app-space-sm: 4px;\n --app-text-sm: 12px;\n --app-radius-md: 8px;\n}\n```\n\n#### Styled Components projects\n\nPut every token category in a typed theme object passed to `ThemeProvider`, and read it in styles as `${({ theme }) => theme.color.bg}`. Declare its type once by augmenting `DefaultTheme` in `styled.d.ts`:\n\n```ts\nexport const theme = {\n color: { bg: '#0f0f1a', surface: '#1a1a2e', accent: '#7c3aed', text: '#ffffff' },\n space: { sm: '4px', md: '8px', lg: '16px' },\n radius: { md: '8px', full: '9999px' },\n font: { body: \"'Inter', sans-serif\" }\n} as const\n```\n\nFor multi-mode collections either build one theme object per mode and swap it on `ThemeProvider`, or write the colors as CSS custom properties in `createGlobalStyle` and keep the theme pointing at `var(--…)`, which switches without re-rendering.\n\n#### Component library projects\n\nWhen the project uses shadcn/ui, Chakra UI, or MUI, write tokens into the library's own theme instead of a parallel set of custom properties; see **Component libraries** below for where each one keeps them.\n\n#### No design variables in the file\n\nIf the design has no Figma variables, extract implicit tokens from `analyze_colors` and `analyze_typography` output — identify the de facto palette and type scale. For Tailwind projects, only extract semantic colors as CSS custom properties; use Tailwind utilities for everything else.\n\n#### Multi-mode collections (light/dark)\n\n- Generate token values for each mode\n- Use CSS custom properties with class-based switching (`.dark { ... }`)\n\n### Step 4 — Generate code\n\nFor each component, bottom-up (primitives first, then composites, then screens):\n\n```\nget_jsx id=<component_id> → read structure\ndescribe id=<component_id> → understand semantic role\nexport_svg ids=[<icon_ids>] → extract vector assets\n```\n\n**Rules:**\n\n- One component per file\n- Component name comes from the Figma node name, converted to PascalCase\n- Props interface reflects the variable content identified in Step 2\n- Use design tokens from Step 3 for semantic colors\n- For Tailwind: use utility classes directly for spacing, font sizes, weights, radius — do NOT wrap them in `var()` indirection\n- Match measurements exactly: font sizes, spacing, border radii, colors\n- Use auto-layout data to determine flex direction, gap, padding, alignment\n- Preserve text direction and container flow direction separately when the design uses RTL.\n- Absolute positioning only when `layoutPositioning` is `ABSOLUTE` or layout mode is `NONE`\n- If a node has `clipsContent: true`, use `overflow: hidden`\n- Text nodes: preserve font family, size, weight, line height, letter spacing, alignment\n- Images/illustrations: use `export_svg` for vectors, placeholder `<img>` for raster (`next/image` in Next.js)\n- Icons: an `<Icon name=\"set:name\">` in `get_jsx` is an Iconify icon; emit it from the chosen icon package (see **Icons** below). An icon drawn as paths was edited or comes from no set, so export it with `export_svg`\n\n**Interactive states:**\n\nFigma designs rarely include hover/active/focus states unless the component has explicit variants for them. Always add sensible interactive feedback to clickable elements:\n\n- **Buttons (primary):** `hover:brightness-110 active:brightness-90 transition-all`\n- **Buttons (secondary/ghost):** `hover:bg-white/[0.12] active:bg-white/[0.06] transition-colors`\n- **Icon buttons:** `hover:bg-white/[0.15] active:scale-95 transition-all`\n- **Cards/list items (if clickable):** `hover:bg-white/[0.04] transition-colors`\n- **Links/text buttons:** `hover:underline` or `hover:opacity-80`\n- **All interactive elements:** add `cursor-pointer` and `select-none`\n- **Focus visible:** add `focus-visible:ring-2 focus-visible:ring-offset-2` with accent color for accessibility\n\nWith plain CSS, CSS Modules, or Styled Components write the same feedback as `:hover`, `:active`, and `:focus-visible` rules; with a component library keep its built-in states and adjust them through its theme.\n\nIf the design HAS explicit hover/active variants (COMPONENT_SET with state property), use those exact styles instead of defaults above.\n\n### Step 5 — Verify\n\nAfter generating code, verify against the design:\n\n```\ndescribe id=<root> → re-check structure matches\nget_jsx id=<root> → compare JSX structure with generated component tree\n```\n\nCheck:\n\n- All text content from the design appears in the code\n- All colors reference tokens or use correct hex/opacity values\n- Spacing values match the design\n- Component hierarchy matches the design's node tree\n- No nodes were skipped or merged incorrectly\n\nList any deviations with rationale.\n\n## Target stack\n\nThe user specifies the target stack. Adapt code generation accordingly:\n\n**React + Tailwind** — functional components, TypeScript, utility classes, `className`\n**React + CSS Modules** — functional components, TypeScript, `.module.css` files, `styles.className`\n**React + Styled Components** — functional components, TypeScript, `styled.*` components and a typed theme (see **Styled Components**)\n**Next.js** — React with the App Router, styled with Tailwind, CSS Modules, or Styled Components (see **Next.js**)\n**Vue 3 + Tailwind** — `<script setup lang=\"ts\">`, `defineProps`, `<template>`, Tailwind utility classes\n**Vue 3 + CSS** — `<script setup lang=\"ts\">`, `defineProps`, `<template>`, scoped `<style>`\n**Svelte + Tailwind** — `<script lang=\"ts\">`, `$props()`, Tailwind utility classes\n**HTML + CSS** — semantic HTML, BEM or utility classes, CSS custom properties\n\nTwo choices sit on top of the stack: the **component library** (shadcn/ui, Radix, Chakra UI, MUI, Reka UI, or the project's own components) and the **icon package** (Lucide, Heroicons, Font Awesome, React Icons, or Iconify). Read them from the project when you can see it: `package.json` dependencies, a `components.json` (shadcn/ui), existing imports.\n\nIf the user hasn't specified a stack, ask before generating code. Ask about the component library and icon package in the same question when the project does not show them.\n\n## Next.js\n\nTarget the App Router unless the project already uses `pages/`.\n\n- **Routes** — each screen is `app/<route>/page.tsx`; the home screen is `app/page.tsx`. Chrome shared by several screens (header, sidebar, footer that are the same instance or layers on each) goes in `app/layout.tsx` or a nested `layout.tsx`, not into every page. Name routes after the frame names in kebab-case.\n- **Server and client components** — components are Server Components by default. Add `'use client'` only to the components that need state, event handlers, effects, or browser APIs: every behaviour control, anything with `onClick`, and Radix, Chakra, MUI, or Styled Components wrappers. Keep the boundary at the leaves: a page stays a Server Component that renders client leaves, and passes them data as serializable props.\n- **Images** — use `next/image` for raster fills with the design's `width` and `height`; for an image that fills its frame use `fill` with `sizes`, on a parent with `position: relative`. Put exported assets in `public/` and reference them from `/`. Always pass `alt`, from the layer name or the surrounding text.\n- **Fonts** — load design fonts with `next/font/google` (or `next/font/local` for fonts that are not on Google Fonts) in `app/layout.tsx`, only the weights `analyze_typography` reports, and expose each as a CSS variable (`variable: '--font-inter'`) that Tailwind or the theme reads.\n- **Links** — a layer that navigates to another screen (nav items, text links, cards that open a detail screen) is `next/link`'s `<Link href>`, not a `<button>` or `<a onClick>`.\n- **Metadata** — export `metadata` from each `page.tsx` with a `title` taken from the frame name.\n- **Styling** — Tailwind tokens go in `app/globals.css`. CSS Modules work as in React. Styled Components need the compiler option (`compiler: { styledComponents: true }` in `next.config`) and a style registry client component that collects styles with `ServerStyleSheet` and `useServerInsertedHTML`, wrapped around `children` in `app/layout.tsx`; every file that calls `styled` is a client component.\n\n## Styled Components\n\n- One component file holds its styled elements, named after the layers they draw (`const Root = styled.button`, `const Label = styled.span`), or a sibling `Button.styles.ts` when it grows long.\n- Variant properties become transient props (`$variant`, `$size`) so they never reach the DOM; select their styles with the `css` helper from a lookup keyed by the variant value, not nested ternaries.\n- Interaction states are `&:hover`, `&:active`, `&:focus-visible`, and `&:disabled`. On a Radix primitive wrap it (`styled(Switch.Root)`) and style its `&[data-state='checked']` and `&[data-disabled]` attributes.\n- Tokens come from the theme (see **Step 3**); never hard-code a value the design binds to a variable.\n- Global resets, font faces, and mode custom properties go in one `createGlobalStyle`.\n- Styled Components is React only. For Vue or Svelte write scoped styles instead.\n\n## Component libraries\n\nWhen the project uses a component library, build each behaviour control on that library's component instead of its own markup, and map the design's variant properties to the library's own props (`variant`, `size`, `disabled`). Style the parts the design draws differently through the library's styling hooks; do not rebuild a component the library provides. Components with no behaviour (cards, headers, list rows) stay the project's own components built from library layout primitives or plain elements.\n\nReka UI (Vue) and Radix (React) share part names: Reka's `SwitchRoot` is Radix's `Switch.Root`, and so on. shadcn/ui wraps Radix in React and shadcn-vue wraps Reka UI in Vue under the same component names. Both expose state as `data-state` (`checked`/`unchecked`, `on`/`off`, `open`/`closed`, `active`/`inactive`) and `data-disabled`, which is where the design's state variants go. Radix takes the value as a controlled pair instead of `v-model`: `checked`/`onCheckedChange` (switch, checkbox), `pressed`/`onPressedChange` (toggle), `open`/`onOpenChange` (collapsible), `value`/`onValueChange` (tabs, radio group, toggle group, accordion, slider with an array value). Import Radix from the unified `radix-ui` package (`import { Switch } from 'radix-ui'`) unless the project already uses the per-primitive `@radix-ui/react-*` packages.\n\n- `button` — Reka UI native `<button>`; Radix native `<button>`; shadcn/ui `Button`; Chakra UI `Button`; MUI `Button`\n- `textField` — Reka UI native `<input>`; Radix native `<input>`; shadcn/ui `Input`; Chakra UI `Input` in `Field.Root`; MUI `TextField`\n- `textarea` — Reka UI native `<textarea>`; Radix native `<textarea>`; shadcn/ui `Textarea`; Chakra UI `Textarea` in `Field.Root`; MUI `TextField multiline`\n- `numberField` — Reka UI `NumberFieldRoot`, `NumberFieldInput`, `NumberFieldIncrement`, `NumberFieldDecrement`; Radix native `<input type=\"number\">` with stepper buttons; shadcn/ui `Input type=\"number\"`; Chakra UI `NumberInput.Root`, `NumberInput.Input`, `NumberInput.IncrementTrigger`, `NumberInput.DecrementTrigger`; MUI `TextField type=\"number\"`\n- `toggle` — Reka UI `Toggle`; Radix `Toggle.Root`; shadcn/ui `Toggle`; Chakra UI `Button` with `aria-pressed`; MUI `ToggleButton`\n- `switch` — Reka UI `SwitchRoot`, `SwitchThumb`; Radix `Switch.Root`, `Switch.Thumb`; shadcn/ui `Switch`; Chakra UI `Switch.Root`, `Switch.Control`, `Switch.Thumb`; MUI `Switch`\n- `checkbox` — Reka UI `CheckboxRoot`, `CheckboxIndicator`; Radix `Checkbox.Root`, `Checkbox.Indicator`; shadcn/ui `Checkbox`; Chakra UI `Checkbox.Root`, `Checkbox.Control`, `Checkbox.Indicator`; MUI `Checkbox`\n- `radioGroup` — Reka UI `RadioGroupRoot`, `RadioGroupItem`, `RadioGroupIndicator`; Radix `RadioGroup.Root`, `RadioGroup.Item`, `RadioGroup.Indicator`; shadcn/ui `RadioGroup`, `RadioGroupItem`; Chakra UI `RadioGroup.Root`, `RadioGroup.Item`, `RadioGroup.ItemIndicator`; MUI `RadioGroup` with `Radio` in `FormControlLabel`\n- `toggleGroup` — Reka UI `ToggleGroupRoot`, `ToggleGroupItem`; Radix `ToggleGroup.Root`, `ToggleGroup.Item`; shadcn/ui `ToggleGroup`, `ToggleGroupItem`; Chakra UI `SegmentGroup.Root`, `SegmentGroup.Item`; MUI `ToggleButtonGroup`, `ToggleButton`\n- `slider` — Reka UI `SliderRoot`, `SliderTrack`, `SliderRange`, `SliderThumb`; Radix `Slider.Root`, `Slider.Track`, `Slider.Range`, `Slider.Thumb`; shadcn/ui `Slider`; Chakra UI `Slider.Root`, `Slider.Control`, `Slider.Track`, `Slider.Range`, `Slider.Thumb`; MUI `Slider` (`rail`, `track`, `thumb` slots)\n- `progress` — Reka UI `ProgressRoot`, `ProgressIndicator`; Radix `Progress.Root`, `Progress.Indicator`; shadcn/ui `Progress`; Chakra UI `Progress.Root`, `Progress.Track`, `Progress.Range`; MUI `LinearProgress variant=\"determinate\"`\n- `tabs` — Reka UI `TabsRoot`, `TabsList`, `TabsTrigger`, `TabsContent`; Radix `Tabs.Root`, `Tabs.List`, `Tabs.Trigger`, `Tabs.Content`; shadcn/ui `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent`; Chakra UI `Tabs.Root`, `Tabs.List`, `Tabs.Trigger`, `Tabs.Content`; MUI `Tabs`, `Tab`, with a panel per tab\n- `collapsible` — Reka UI `CollapsibleRoot`, `CollapsibleTrigger`, `CollapsibleContent`; Radix `Collapsible.Root`, `Collapsible.Trigger`, `Collapsible.Content`; shadcn/ui `Collapsible`, `CollapsibleTrigger`, `CollapsibleContent`; Chakra UI `Collapsible.Root`, `Collapsible.Trigger`, `Collapsible.Content`; MUI `Collapse` toggled by a `Button`\n- `accordion` — Reka UI `AccordionRoot`, `AccordionItem`, `AccordionTrigger`, `AccordionContent`; Radix `Accordion.Root`, `Accordion.Item`, `Accordion.Trigger`, `Accordion.Content`; shadcn/ui `Accordion`, `AccordionItem`, `AccordionTrigger`, `AccordionContent`; Chakra UI `Accordion.Root`, `Accordion.Item`, `Accordion.ItemTrigger`, `Accordion.ItemContent`; MUI `Accordion`, `AccordionSummary`, `AccordionDetails` per item\n\nA `radio` behaviour is one item of a `radioGroup`: its `RadioGroupItem`, `RadioGroup.Item`, or `Radio`. A behaviour's `items` slot holds the group's items and a tab list's children are its triggers, so the list above names the item parts too. In Reka UI and Radix an accordion trigger sits inside `AccordionHeader` / `Accordion.Header`. A `progress` behaviour's `track` slot is the root itself, `ProgressRoot` / `Progress.Root` in Reka UI and Radix (`Progress.Track` in Chakra UI), so do not add a wrapper for it. A `tabs` behaviour's `panels` slot has no part of its own: its children are the content parts, `TabsContent` / `Tabs.Content`, placed directly under the root.\n\nWhere each library keeps tokens and variants:\n\n- **shadcn/ui** — components are copied into the project (`components/ui`), so restyle them there to match the design rather than overriding every call site. Map semantic colors to its CSS variables (`--background`, `--foreground`, `--primary`, `--primary-foreground`, `--secondary`, `--muted`, `--accent`, `--destructive`, `--border`, `--input`, `--ring`) and the base corner radius to `--radius`, per mode under `.dark`. These replace the Tailwind rule against radius custom properties above because shadcn/ui already defines them. Add design variants to the component's `cva` `variants` (`variant`, `size`) under the design's own value names, and merge classes with `cn()`.\n- **Radix (unstyled)** — style each part directly with the project's styling approach; state selectors are `[data-state=…]` and `[data-disabled]`, and Tailwind's `data-[state=checked]:` variants.\n- **Chakra UI v3** — put tokens in `createSystem(defaultConfig, { theme: { tokens, semanticTokens } })`, with mode values as `{ base, _dark }` semantic tokens, and pass the system to `ChakraProvider`. Spacing, radius, and typography use style props (`gap`, `px`, `rounded`, `fontSize`). Component variants go in a `recipe` (single part) or `slotRecipe` (multi-part, such as switch or tabs).\n- **MUI** — put tokens in `createTheme`: `palette` (one theme per mode, or `colorSchemes` with CSS variables), `typography`, `spacing`, and `shape.borderRadius`. Style instances with `sx` and reusable pieces with `styled()` from `@mui/material/styles`; add design variants to `components.<Name>.variants` and part overrides to `components.<Name>.styleOverrides` (`MuiSwitch`'s `thumb` and `track`, `MuiSlider`'s `rail`, `track`, and `thumb`).\n- **The project's own components** — `design_to_component_map` lists the design's components with their variants and instance counts. Match each to an existing component in the codebase by name and role before writing a new one, and extend an existing component's props for a new variant rather than duplicating it.\n\n## Icons\n\n`get_jsx` writes a named icon as `<Icon name=\"lucide:arrow-right\" size={16} color=\"#6b7280\" />`. The name is an Iconify name, `<set>:<icon>`; `size` is its width and height; `color` is its color (black when absent); `label`, when present, is the name the designer gave the layer. Use it as `aria-label` when the icon stands alone and carries meaning (an icon button); otherwise the icon is decorative, so give it `aria-hidden=\"true\"`. Use the color through the same token the surrounding text uses when it matches one.\n\nEmit each icon from the icon package the user chose. Iconify set prefixes map to packages mechanically; convert the kebab-case icon name to PascalCase for the component:\n\n- `lucide:arrow-right` — `lucide-react`, `lucide-vue-next`, `@lucide/svelte`: `ArrowRight`, with `size` and `strokeWidth`\n- `heroicons:arrow-right` (24 outline) — `@heroicons/react/24/outline` or `@heroicons/vue/24/outline`: `ArrowRightIcon`\n- `heroicons:arrow-right-solid`, `-20-solid`, `-16-solid` — `@heroicons/react/24/solid`, `/20/solid`, `/16/solid`: `ArrowRightIcon`\n- `fa6-solid:house`, `fa6-regular:heart`, `fa6-brands:github` — `@fortawesome/react-fontawesome` (or `vue-fontawesome`) with `@fortawesome/free-solid-svg-icons`, `free-regular-svg-icons`, `free-brands-svg-icons`: `<FontAwesomeIcon icon={faHouse} />`\n- `tabler:home` — `@tabler/icons-react`: `IconHome`\n- `ph:house` — `@phosphor-icons/react`: `House` (`@phosphor-icons/vue`: `PhHouse`). A `-thin`, `-light`, `-bold`, `-fill`, or `-duotone` suffix is the `weight` prop on the base component, not part of its name: `ph:house-bold` → `<House weight=\"bold\" />`\n- `radix-icons:home` — `@radix-ui/react-icons`: `HomeIcon`\n- `mdi:home` — `@mdi/react` with `@mdi/js`: `<Icon path={mdiHome} />`\n\nReact Icons bundles many sets under one package, each behind a prefix: `lucide:` → `react-icons/lu` (`LuArrowRight`), `heroicons:` → `react-icons/hi2` (`HiOutlineArrowRight`, `HiArrowRight` for solid, `HiMiniArrowRight` for `-20-solid`, `HiMicroArrowRight` for `-16-solid`), `fa6-solid:` / `fa6-regular:` / `fa6-brands:` → `react-icons/fa6` (`FaHouse`, `FaRegHeart`, `FaGithub`), `tabler:` → `react-icons/tb` (`TbHome`), `ph:` → `react-icons/pi` (`PiHouse`, with the weight kept in the name: `PiHouseBold`, `PiHouseFill`), `ic:` → `react-icons/md` (`MdHome`), `bi:` → `react-icons/bs` (`BsHouse`), `ri:` → `react-icons/ri` (`RiHomeLine`), `feather:` → `react-icons/fi` (`FiHome`), `simple-icons:` → `react-icons/si` (`SiGithub`). Size with `size`, color with `color` or a text color class.\n\nRules:\n\n- Check that the export exists in the installed package version; sets rename icons between releases. When the name differs, pick the package's equivalent and say so.\n- When the design's set has no package in the chosen library (an `mdi:` icon with Lucide chosen), do not silently swap in a different-looking icon. Use Iconify for that icon (`@iconify/react` or `@iconify/vue`, `<Icon icon=\"mdi:home\" />`) or export it with `export_svg`, and list it under deviations. Replace it with the chosen set's closest icon only when the user asks for one consistent set.\n- With no package chosen, use the package that owns the design's set (`lucide:` → `lucide-react`), or Iconify when the design mixes sets.\n- Import icons by name from the package (`import { ArrowRight } from 'lucide-react'`); never import a whole set.\n\n## Component file structure\n\n```\ncomponents/\n Button.tsx (or .vue, .svelte)\n Card.tsx\n Header.tsx\n ...\ntokens.css (semantic color tokens only, for Tailwind projects)\npages/\n HomePage.tsx (or routes, views — depends on framework)\nassets/\n icon-arrow.svg\n icon-check.svg\n```\n\nIn Next.js screens are routes and assets are public files:\n\n```\napp/\n layout.tsx (fonts, shared chrome, global styles)\n globals.css (tokens)\n page.tsx (home screen)\n settings/\n page.tsx\ncomponents/\n Button.tsx\n ui/ (shadcn/ui components, when used)\npublic/\n hero.png\n```\n\n## Common patterns\n\n**Auto-layout → Flexbox**\n\n- `layoutMode: HORIZONTAL` → `flex-direction: row`\n- `layoutMode: VERTICAL` → `flex-direction: column`\n- `itemSpacing` → `gap`\n- `paddingTop/Right/Bottom/Left` → `padding`\n- `primaryAxisAlign: CENTER` → `justify-content: center`\n- `counterAxisAlign: CENTER` → `align-items: center`\n- `layoutWrap: WRAP` → `flex-wrap: wrap`\n- `primaryAxisSizing: HUG` / `counterAxisSizing: HUG` → no explicit size on that axis (content-sized)\n\n**Grid layout**\n\n- `layoutMode: GRID` → `display: grid`\n- `gridTemplateColumns` → `grid-template-columns`\n- `gridTemplateRows` → `grid-template-rows`\n- `gridColumnGap/gridRowGap` → `column-gap/row-gap`\n\n**Sizing**\n\n- Fill lives on the child: `layoutGrow > 0` fills the parent's primary axis (`flex-grow: 1`), `layoutAlignSelf: STRETCH` fills the cross axis (`align-self: stretch`, no fixed size on that axis). In a grid, `layoutGrow` fills the cell's width and `STRETCH` its height.\n- Fixed width/height only on axes that neither hug nor fill\n\n**Corner radius**\n\n- `independentCorners: true` → per-corner border-radius\n- `cornerRadius` → uniform border-radius\n\n**Effects**\n\n- `DROP_SHADOW` → `box-shadow`\n- `INNER_SHADOW` → `box-shadow: inset ...`\n- `LAYER_BLUR` → `filter: blur(...)`\n- `BACKGROUND_BLUR` → `backdrop-filter: blur(...)`\n\n**Text**\n\n- `fontFamily` → `font-family`\n- `fontSize` → `font-size`\n- `fontWeight` → `font-weight`\n- `lineHeight` → `line-height` (null = normal/auto)\n- `letterSpacing` → `letter-spacing`\n- `textAlignHorizontal` → `text-align`\n- `textAutoResize: WIDTH_AND_HEIGHT` → no explicit dimensions\n- `textAutoResize: HEIGHT` → fixed width, auto height\n- `textAutoResize: NONE` → fixed width and height\n- `textDecoration` → `text-decoration`\n- `textCase` → `text-transform`\n\n## Scene authoring reference\n\nThe appended reference applies when inspecting or editing Pairdraw scenes, not to the target frontend framework's API.\n";
|
|
2
|
+
var codegen_default = "# Design to Code\n\nYou convert Figma designs into production frontend code. You have full access to the design document through tools. Never guess — always read the actual design data.\n\n> Note: Auto-layout and visual property names match the JSX props in the render system. Read geometry and style with `get_css` (CSS-like lines, colours as tokens), roles and design issues with `describe`, and structure with `get_jsx`.\n\n## Workflow\n\n### Step 1 — Survey\n\nUnderstand the full picture before writing any code.\n\n```\nget_page_tree → document structure, all top-level frames\nget_components → reusable components defined by the designer\nlist_variables → design tokens (colors, numbers, strings, booleans)\nlist_collections → variable collections and modes (light/dark, density, etc.)\nanalyze_colors → color palette, frequencies, which colors use variables\nanalyze_typography → font stacks, sizes, weights in use\nanalyze_spacing → gap and padding values, grid compliance\n```\n\nAfter this step you should know:\n\n- How many screens/pages the design has\n- What components exist\n- What the token system looks like (or if there is none)\n- The typographic scale\n- The spacing system (4px grid? 8px grid? irregular?)\n\n### Step 2 — Decompose\n\nIdentify the component architecture.\n\n```\nanalyze_clusters → find repeated visual patterns that should be components\nget_css (per node) → CSS shape: flex, gap, padding, size constraints, token colours, text\ndescribe (per node) → semantic role, layout direction, visual properties, issues\nget_jsx (per node) → structural JSX to understand nesting and layout\n```\n\nBuild a component map:\n\n- **Screens** — top-level frames that represent pages/views\n- **Components** — COMPONENT/COMPONENT_SET nodes or repeated patterns from analyze_clusters\n- **Primitives** — leaf elements (text, icons, dividers) that don't need their own component file\n\nFor each component determine:\n\n- **Props** — what content varies between instances (text, color, icon, visibility)\n- **Variants** — if the component has multiple states (default/hover/active, small/medium/large)\n- **Slots** — where child content is injected\n- **Behaviour** — `get_behaviour id=<component_id>` tells whether the designer made it a control, after Reka UI's primitives. Build such a component on that Reka primitive (`SwitchRoot` with `SwitchThumb`, `SliderRoot` with `SliderTrack`, `SliderRange`, and `SliderThumb`, `TabsRoot` with `TabsList`, `TabsTrigger`, and `TabsContent`, …): each part is the slot the behaviour names, its values are the properties it binds (`v-model` for the value, `disabled`), and its interaction states map to the variants for `data-state`, `:hover`, `:active`, `:focus-visible`, and `[data-disabled]`. Do not reimplement the control's keyboard and accessibility handling. In React use the Radix primitive with the same parts (Reka UI is the Vue port of Radix), and with a component library use its equivalent; see **Component libraries** below.\n\n### Step 3 — Extract tokens\n\n```\nlist_variables → all variables with values per mode\nlist_collections → collection structure and mode names\n```\n\nMap design variables to code tokens. The approach depends on the target stack:\n\n#### Tailwind projects\n\nDo NOT create CSS custom properties for font sizes, font weights, spacing, or border radius — Tailwind has its own system for these. Use Tailwind utility classes directly:\n\n- Font sizes → `text-[13px]`, `text-sm`, `text-base`, etc.\n- Font weights → `font-bold`, `font-medium`, `font-[600]`\n- Spacing → `gap-3`, `p-4`, `px-5`, `py-[14px]`, or arbitrary `gap-[12px]`\n- Border radius → `rounded-xl`, `rounded-[14px]`, `rounded-full`\n\nOnly create CSS custom properties for **semantic colors** — these are the values that would change across themes. Name them to avoid conflicts with Tailwind's built-in variables (do NOT use names like `--font-bold`, `--text-sm`, `--radius-lg`):\n\n```css\n:root {\n --movie-bg: #0f0f1a;\n --movie-surface: #1a1a2e;\n --movie-accent: #7c3aed;\n --movie-text: #ffffff;\n --movie-text-dim: #ffffff80;\n}\n```\n\nReference in Tailwind classes: `bg-[var(--movie-bg)]`, `text-[var(--movie-text)]`\n\n#### CSS Modules / plain CSS projects\n\nCreate CSS custom properties for all token categories (colors, spacing, typography, radius). Use a project-specific prefix to avoid collisions:\n\n```css\n:root {\n --app-color-bg: #0f0f1a;\n --app-space-sm: 4px;\n --app-text-sm: 12px;\n --app-radius-md: 8px;\n}\n```\n\n#### Styled Components projects\n\nPut every token category in a typed theme object passed to `ThemeProvider`, and read it in styles as `${({ theme }) => theme.color.bg}`. Declare its type once by augmenting `DefaultTheme` in `styled.d.ts`:\n\n```ts\nexport const theme = {\n color: { bg: '#0f0f1a', surface: '#1a1a2e', accent: '#7c3aed', text: '#ffffff' },\n space: { sm: '4px', md: '8px', lg: '16px' },\n radius: { md: '8px', full: '9999px' },\n font: { body: \"'Inter', sans-serif\" }\n} as const\n```\n\nFor multi-mode collections either build one theme object per mode and swap it on `ThemeProvider`, or write the colors as CSS custom properties in `createGlobalStyle` and keep the theme pointing at `var(--…)`, which switches without re-rendering.\n\n#### Component library projects\n\nWhen the project uses shadcn/ui, Chakra UI, or MUI, write tokens into the library's own theme instead of a parallel set of custom properties; see **Component libraries** below for where each one keeps them.\n\n#### No design variables in the file\n\nIf the design has no Figma variables, extract implicit tokens from `analyze_colors` and `analyze_typography` output — identify the de facto palette and type scale. For Tailwind projects, only extract semantic colors as CSS custom properties; use Tailwind utilities for everything else.\n\n#### Multi-mode collections (light/dark)\n\n- Generate token values for each mode\n- Use CSS custom properties with class-based switching (`.dark { ... }`)\n\n### Step 4 — Generate code\n\nFor each component, bottom-up (primitives first, then composites, then screens):\n\n```\nget_jsx id=<component_id> → read structure\ndescribe id=<component_id> → understand semantic role\nexport_svg ids=[<icon_ids>] → extract vector assets\n```\n\n**Rules:**\n\n- One component per file\n- Component name comes from the Figma node name, converted to PascalCase\n- Props interface reflects the variable content identified in Step 2\n- Use design tokens from Step 3 for semantic colors\n- For Tailwind: use utility classes directly for spacing, font sizes, weights, radius — do NOT wrap them in `var()` indirection\n- Match measurements exactly: font sizes, spacing, border radii, colors\n- Use auto-layout data to determine flex direction, gap, padding, alignment\n- Preserve text direction and container flow direction separately when the design uses RTL.\n- Absolute positioning only when `layoutPositioning` is `ABSOLUTE` or layout mode is `NONE`\n- If a node has `clipsContent: true`, use `overflow: hidden`\n- Text nodes: preserve font family, size, weight, line height, letter spacing, alignment\n- Images/illustrations: use `export_svg` for vectors, placeholder `<img>` for raster (`next/image` in Next.js)\n- Icons: an `<Icon name=\"set:name\">` in `get_jsx` is an Iconify icon; emit it from the chosen icon package (see **Icons** below). An icon drawn as paths was edited or comes from no set, so export it with `export_svg`\n\n**Interactive states:**\n\nFigma designs rarely include hover/active/focus states unless the component has explicit variants for them. Always add sensible interactive feedback to clickable elements:\n\n- **Buttons (primary):** `hover:brightness-110 active:brightness-90 transition-all`\n- **Buttons (secondary/ghost):** `hover:bg-white/[0.12] active:bg-white/[0.06] transition-colors`\n- **Icon buttons:** `hover:bg-white/[0.15] active:scale-95 transition-all`\n- **Cards/list items (if clickable):** `hover:bg-white/[0.04] transition-colors`\n- **Links/text buttons:** `hover:underline` or `hover:opacity-80`\n- **All interactive elements:** add `cursor-pointer` and `select-none`\n- **Focus visible:** add `focus-visible:ring-2 focus-visible:ring-offset-2` with accent color for accessibility\n\nWith plain CSS, CSS Modules, or Styled Components write the same feedback as `:hover`, `:active`, and `:focus-visible` rules; with a component library keep its built-in states and adjust them through its theme.\n\nIf the design HAS explicit hover/active variants (COMPONENT_SET with state property), use those exact styles instead of defaults above.\n\n### Step 5 — Verify\n\nAfter generating code, verify against the design:\n\n```\ndescribe id=<root> → re-check structure matches\nget_jsx id=<root> → compare JSX structure with generated component tree\n```\n\nCheck:\n\n- All text content from the design appears in the code\n- All colors reference tokens or use correct hex/opacity values\n- Spacing values match the design\n- Component hierarchy matches the design's node tree\n- No nodes were skipped or merged incorrectly\n\nList any deviations with rationale.\n\n## Target stack\n\nThe user specifies the target stack. Adapt code generation accordingly:\n\n**React + Tailwind** — functional components, TypeScript, utility classes, `className`\n**React + CSS Modules** — functional components, TypeScript, `.module.css` files, `styles.className`\n**React + Styled Components** — functional components, TypeScript, `styled.*` components and a typed theme (see **Styled Components**)\n**Next.js** — React with the App Router, styled with Tailwind, CSS Modules, or Styled Components (see **Next.js**)\n**Vue 3 + Tailwind** — `<script setup lang=\"ts\">`, `defineProps`, `<template>`, Tailwind utility classes\n**Vue 3 + CSS** — `<script setup lang=\"ts\">`, `defineProps`, `<template>`, scoped `<style>`\n**Svelte + Tailwind** — `<script lang=\"ts\">`, `$props()`, Tailwind utility classes\n**HTML + CSS** — semantic HTML, BEM or utility classes, CSS custom properties\n\nTwo choices sit on top of the stack: the **component library** (shadcn/ui, Radix, Chakra UI, MUI, Reka UI, or the project's own components) and the **icon package** (Lucide, Heroicons, Font Awesome, React Icons, or Iconify). Read them from the project when you can see it: `package.json` dependencies, a `components.json` (shadcn/ui), existing imports.\n\nIf the user hasn't specified a stack, ask before generating code. Ask about the component library and icon package in the same question when the project does not show them.\n\n## Next.js\n\nTarget the App Router unless the project already uses `pages/`.\n\n- **Routes** — each screen is `app/<route>/page.tsx`; the home screen is `app/page.tsx`. Chrome shared by several screens (header, sidebar, footer that are the same instance or layers on each) goes in `app/layout.tsx` or a nested `layout.tsx`, not into every page. Name routes after the frame names in kebab-case.\n- **Server and client components** — components are Server Components by default. Add `'use client'` only to the components that need state, event handlers, effects, or browser APIs: every behaviour control, anything with `onClick`, and Radix, Chakra, MUI, or Styled Components wrappers. Keep the boundary at the leaves: a page stays a Server Component that renders client leaves, and passes them data as serializable props.\n- **Images** — use `next/image` for raster fills with the design's `width` and `height`; for an image that fills its frame use `fill` with `sizes`, on a parent with `position: relative`. Put exported assets in `public/` and reference them from `/`. Always pass `alt`, from the layer name or the surrounding text.\n- **Fonts** — load design fonts with `next/font/google` (or `next/font/local` for fonts that are not on Google Fonts) in `app/layout.tsx`, only the weights `analyze_typography` reports, and expose each as a CSS variable (`variable: '--font-inter'`) that Tailwind or the theme reads.\n- **Links** — a layer that navigates to another screen (nav items, text links, cards that open a detail screen) is `next/link`'s `<Link href>`, not a `<button>` or `<a onClick>`.\n- **Metadata** — export `metadata` from each `page.tsx` with a `title` taken from the frame name.\n- **Styling** — Tailwind tokens go in `app/globals.css`. CSS Modules work as in React. Styled Components need the compiler option (`compiler: { styledComponents: true }` in `next.config`) and a style registry client component that collects styles with `ServerStyleSheet` and `useServerInsertedHTML`, wrapped around `children` in `app/layout.tsx`; every file that calls `styled` is a client component.\n\n## Styled Components\n\n- One component file holds its styled elements, named after the layers they draw (`const Root = styled.button`, `const Label = styled.span`), or a sibling `Button.styles.ts` when it grows long.\n- Variant properties become transient props (`$variant`, `$size`) so they never reach the DOM; select their styles with the `css` helper from a lookup keyed by the variant value, not nested ternaries.\n- Interaction states are `&:hover`, `&:active`, `&:focus-visible`, and `&:disabled`. On a Radix primitive wrap it (`styled(Switch.Root)`) and style its `&[data-state='checked']` and `&[data-disabled]` attributes.\n- Tokens come from the theme (see **Step 3**); never hard-code a value the design binds to a variable.\n- Global resets, font faces, and mode custom properties go in one `createGlobalStyle`.\n- Styled Components is React only. For Vue or Svelte write scoped styles instead.\n\n## Component libraries\n\nWhen the project uses a component library, build each behaviour control on that library's component instead of its own markup, and map the design's variant properties to the library's own props (`variant`, `size`, `disabled`). Style the parts the design draws differently through the library's styling hooks; do not rebuild a component the library provides. Components with no behaviour (cards, headers, list rows) stay the project's own components built from library layout primitives or plain elements.\n\nReka UI (Vue) and Radix (React) share part names: Reka's `SwitchRoot` is Radix's `Switch.Root`, and so on. shadcn/ui wraps Radix in React and shadcn-vue wraps Reka UI in Vue under the same component names. Both expose state as `data-state` (`checked`/`unchecked`, `on`/`off`, `open`/`closed`, `active`/`inactive`) and `data-disabled`, which is where the design's state variants go. Radix takes the value as a controlled pair instead of `v-model`: `checked`/`onCheckedChange` (switch, checkbox), `pressed`/`onPressedChange` (toggle), `open`/`onOpenChange` (collapsible), `value`/`onValueChange` (tabs, radio group, toggle group, accordion, slider with an array value). Import Radix from the unified `radix-ui` package (`import { Switch } from 'radix-ui'`) unless the project already uses the per-primitive `@radix-ui/react-*` packages.\n\n- `button` — Reka UI native `<button>`; Radix native `<button>`; shadcn/ui `Button`; Chakra UI `Button`; MUI `Button`\n- `textField` — Reka UI native `<input>`; Radix native `<input>`; shadcn/ui `Input`; Chakra UI `Input` in `Field.Root`; MUI `TextField`\n- `textarea` — Reka UI native `<textarea>`; Radix native `<textarea>`; shadcn/ui `Textarea`; Chakra UI `Textarea` in `Field.Root`; MUI `TextField multiline`\n- `numberField` — Reka UI `NumberFieldRoot`, `NumberFieldInput`, `NumberFieldIncrement`, `NumberFieldDecrement`; Radix native `<input type=\"number\">` with stepper buttons; shadcn/ui `Input type=\"number\"`; Chakra UI `NumberInput.Root`, `NumberInput.Input`, `NumberInput.IncrementTrigger`, `NumberInput.DecrementTrigger`; MUI `TextField type=\"number\"`\n- `toggle` — Reka UI `Toggle`; Radix `Toggle.Root`; shadcn/ui `Toggle`; Chakra UI `Button` with `aria-pressed`; MUI `ToggleButton`\n- `switch` — Reka UI `SwitchRoot`, `SwitchThumb`; Radix `Switch.Root`, `Switch.Thumb`; shadcn/ui `Switch`; Chakra UI `Switch.Root`, `Switch.Control`, `Switch.Thumb`; MUI `Switch`\n- `checkbox` — Reka UI `CheckboxRoot`, `CheckboxIndicator`; Radix `Checkbox.Root`, `Checkbox.Indicator`; shadcn/ui `Checkbox`; Chakra UI `Checkbox.Root`, `Checkbox.Control`, `Checkbox.Indicator`; MUI `Checkbox`\n- `radioGroup` — Reka UI `RadioGroupRoot`, `RadioGroupItem`, `RadioGroupIndicator`; Radix `RadioGroup.Root`, `RadioGroup.Item`, `RadioGroup.Indicator`; shadcn/ui `RadioGroup`, `RadioGroupItem`; Chakra UI `RadioGroup.Root`, `RadioGroup.Item`, `RadioGroup.ItemIndicator`; MUI `RadioGroup` with `Radio` in `FormControlLabel`\n- `toggleGroup` — Reka UI `ToggleGroupRoot`, `ToggleGroupItem`; Radix `ToggleGroup.Root`, `ToggleGroup.Item`; shadcn/ui `ToggleGroup`, `ToggleGroupItem`; Chakra UI `SegmentGroup.Root`, `SegmentGroup.Item`; MUI `ToggleButtonGroup`, `ToggleButton`\n- `slider` — Reka UI `SliderRoot`, `SliderTrack`, `SliderRange`, `SliderThumb`; Radix `Slider.Root`, `Slider.Track`, `Slider.Range`, `Slider.Thumb`; shadcn/ui `Slider`; Chakra UI `Slider.Root`, `Slider.Control`, `Slider.Track`, `Slider.Range`, `Slider.Thumb`; MUI `Slider` (`rail`, `track`, `thumb` slots)\n- `progress` — Reka UI `ProgressRoot`, `ProgressIndicator`; Radix `Progress.Root`, `Progress.Indicator`; shadcn/ui `Progress`; Chakra UI `Progress.Root`, `Progress.Track`, `Progress.Range`; MUI `LinearProgress variant=\"determinate\"`\n- `tabs` — Reka UI `TabsRoot`, `TabsList`, `TabsTrigger`, `TabsContent`; Radix `Tabs.Root`, `Tabs.List`, `Tabs.Trigger`, `Tabs.Content`; shadcn/ui `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent`; Chakra UI `Tabs.Root`, `Tabs.List`, `Tabs.Trigger`, `Tabs.Content`; MUI `Tabs`, `Tab`, with a panel per tab\n- `collapsible` — Reka UI `CollapsibleRoot`, `CollapsibleTrigger`, `CollapsibleContent`; Radix `Collapsible.Root`, `Collapsible.Trigger`, `Collapsible.Content`; shadcn/ui `Collapsible`, `CollapsibleTrigger`, `CollapsibleContent`; Chakra UI `Collapsible.Root`, `Collapsible.Trigger`, `Collapsible.Content`; MUI `Collapse` toggled by a `Button`\n- `accordion` — Reka UI `AccordionRoot`, `AccordionItem`, `AccordionTrigger`, `AccordionContent`; Radix `Accordion.Root`, `Accordion.Item`, `Accordion.Trigger`, `Accordion.Content`; shadcn/ui `Accordion`, `AccordionItem`, `AccordionTrigger`, `AccordionContent`; Chakra UI `Accordion.Root`, `Accordion.Item`, `Accordion.ItemTrigger`, `Accordion.ItemContent`; MUI `Accordion`, `AccordionSummary`, `AccordionDetails` per item\n\nA `radio` behaviour is one item of a `radioGroup`: its `RadioGroupItem`, `RadioGroup.Item`, or `Radio`. A behaviour's `items` slot holds the group's items and a tab list's children are its triggers, so the list above names the item parts too. In Reka UI and Radix an accordion trigger sits inside `AccordionHeader` / `Accordion.Header`. A `progress` behaviour's `track` slot is the root itself, `ProgressRoot` / `Progress.Root` in Reka UI and Radix (`Progress.Track` in Chakra UI), so do not add a wrapper for it. A `tabs` behaviour's `panels` slot has no part of its own: its children are the content parts, `TabsContent` / `Tabs.Content`, placed directly under the root.\n\nWhere each library keeps tokens and variants:\n\n- **shadcn/ui** — components are copied into the project (`components/ui`), so restyle them there to match the design rather than overriding every call site. Map semantic colors to its CSS variables (`--background`, `--foreground`, `--primary`, `--primary-foreground`, `--secondary`, `--muted`, `--accent`, `--destructive`, `--border`, `--input`, `--ring`) and the base corner radius to `--radius`, per mode under `.dark`. These replace the Tailwind rule against radius custom properties above because shadcn/ui already defines them. Add design variants to the component's `cva` `variants` (`variant`, `size`) under the design's own value names, and merge classes with `cn()`.\n- **Radix (unstyled)** — style each part directly with the project's styling approach; state selectors are `[data-state=…]` and `[data-disabled]`, and Tailwind's `data-[state=checked]:` variants.\n- **Chakra UI v3** — put tokens in `createSystem(defaultConfig, { theme: { tokens, semanticTokens } })`, with mode values as `{ base, _dark }` semantic tokens, and pass the system to `ChakraProvider`. Spacing, radius, and typography use style props (`gap`, `px`, `rounded`, `fontSize`). Component variants go in a `recipe` (single part) or `slotRecipe` (multi-part, such as switch or tabs).\n- **MUI** — put tokens in `createTheme`: `palette` (one theme per mode, or `colorSchemes` with CSS variables), `typography`, `spacing`, and `shape.borderRadius`. Style instances with `sx` and reusable pieces with `styled()` from `@mui/material/styles`; add design variants to `components.<Name>.variants` and part overrides to `components.<Name>.styleOverrides` (`MuiSwitch`'s `thumb` and `track`, `MuiSlider`'s `rail`, `track`, and `thumb`).\n- **The project's own components** — `design_to_component_map` lists the design's components with their variants and instance counts. Match each to an existing component in the codebase by name and role before writing a new one, and extend an existing component's props for a new variant rather than duplicating it.\n\n## Icons\n\n`get_jsx` writes a named icon as `<Icon name=\"lucide:arrow-right\" size={16} color=\"#6b7280\" />`. The name is an Iconify name, `<set>:<icon>`; `size` is its width and height; `color` is its color (black when absent); `label`, when present, is the name the designer gave the layer. Use it as `aria-label` when the icon stands alone and carries meaning (an icon button); otherwise the icon is decorative, so give it `aria-hidden=\"true\"`. Use the color through the same token the surrounding text uses when it matches one.\n\nEmit each icon from the icon package the user chose. Iconify set prefixes map to packages mechanically; convert the kebab-case icon name to PascalCase for the component:\n\n- `lucide:arrow-right` — `lucide-react`, `lucide-vue-next`, `@lucide/svelte`: `ArrowRight`, with `size` and `strokeWidth`\n- `heroicons:arrow-right` (24 outline) — `@heroicons/react/24/outline` or `@heroicons/vue/24/outline`: `ArrowRightIcon`\n- `heroicons:arrow-right-solid`, `-20-solid`, `-16-solid` — `@heroicons/react/24/solid`, `/20/solid`, `/16/solid`: `ArrowRightIcon`\n- `fa6-solid:house`, `fa6-regular:heart`, `fa6-brands:github` — `@fortawesome/react-fontawesome` (or `vue-fontawesome`) with `@fortawesome/free-solid-svg-icons`, `free-regular-svg-icons`, `free-brands-svg-icons`: `<FontAwesomeIcon icon={faHouse} />`\n- `tabler:home` — `@tabler/icons-react`: `IconHome`\n- `ph:house` — `@phosphor-icons/react`: `House` (`@phosphor-icons/vue`: `PhHouse`). A `-thin`, `-light`, `-bold`, `-fill`, or `-duotone` suffix is the `weight` prop on the base component, not part of its name: `ph:house-bold` → `<House weight=\"bold\" />`\n- `radix-icons:home` — `@radix-ui/react-icons`: `HomeIcon`\n- `mdi:home` — `@mdi/react` with `@mdi/js`: `<Icon path={mdiHome} />`\n\nReact Icons bundles many sets under one package, each behind a prefix: `lucide:` → `react-icons/lu` (`LuArrowRight`), `heroicons:` → `react-icons/hi2` (`HiOutlineArrowRight`, `HiArrowRight` for solid, `HiMiniArrowRight` for `-20-solid`, `HiMicroArrowRight` for `-16-solid`), `fa6-solid:` / `fa6-regular:` / `fa6-brands:` → `react-icons/fa6` (`FaHouse`, `FaRegHeart`, `FaGithub`), `tabler:` → `react-icons/tb` (`TbHome`), `ph:` → `react-icons/pi` (`PiHouse`, with the weight kept in the name: `PiHouseBold`, `PiHouseFill`), `ic:` → `react-icons/md` (`MdHome`), `bi:` → `react-icons/bs` (`BsHouse`), `ri:` → `react-icons/ri` (`RiHomeLine`), `feather:` → `react-icons/fi` (`FiHome`), `simple-icons:` → `react-icons/si` (`SiGithub`). Size with `size`, color with `color` or a text color class.\n\nRules:\n\n- Check that the export exists in the installed package version; sets rename icons between releases. When the name differs, pick the package's equivalent and say so.\n- When the design's set has no package in the chosen library (an `mdi:` icon with Lucide chosen), do not silently swap in a different-looking icon. Use Iconify for that icon (`@iconify/react` or `@iconify/vue`, `<Icon icon=\"mdi:home\" />`) or export it with `export_svg`, and list it under deviations. Replace it with the chosen set's closest icon only when the user asks for one consistent set.\n- With no package chosen, use the package that owns the design's set (`lucide:` → `lucide-react`), or Iconify when the design mixes sets.\n- Import icons by name from the package (`import { ArrowRight } from 'lucide-react'`); never import a whole set.\n\n## Component file structure\n\n```\ncomponents/\n Button.tsx (or .vue, .svelte)\n Card.tsx\n Header.tsx\n ...\ntokens.css (semantic color tokens only, for Tailwind projects)\npages/\n HomePage.tsx (or routes, views — depends on framework)\nassets/\n icon-arrow.svg\n icon-check.svg\n```\n\nIn Next.js screens are routes and assets are public files:\n\n```\napp/\n layout.tsx (fonts, shared chrome, global styles)\n globals.css (tokens)\n page.tsx (home screen)\n settings/\n page.tsx\ncomponents/\n Button.tsx\n ui/ (shadcn/ui components, when used)\npublic/\n hero.png\n```\n\n## Common patterns\n\n**Auto-layout → Flexbox**\n\n- `layoutMode: HORIZONTAL` → `flex-direction: row`\n- `layoutMode: VERTICAL` → `flex-direction: column`\n- `itemSpacing` → `gap`\n- `paddingTop/Right/Bottom/Left` → `padding`\n- `primaryAxisAlign: CENTER` → `justify-content: center`\n- `counterAxisAlign: CENTER` → `align-items: center`\n- `layoutWrap: WRAP` → `flex-wrap: wrap`\n- `primaryAxisSizing: HUG` / `counterAxisSizing: HUG` → no explicit size on that axis (content-sized)\n\n**Grid layout**\n\n- `layoutMode: GRID` → `display: grid`\n- `gridTemplateColumns` → `grid-template-columns`\n- `gridTemplateRows` → `grid-template-rows`\n- `gridColumnGap/gridRowGap` → `column-gap/row-gap`\n\n**Sizing**\n\n- Fill lives on the child: `layoutGrow > 0` fills the parent's primary axis (`flex-grow: 1`), `layoutAlignSelf: STRETCH` fills the cross axis (`align-self: stretch`, no fixed size on that axis). In a grid, `layoutGrow` fills the cell's width and `STRETCH` its height.\n- Fixed width/height only on axes that neither hug nor fill\n\n**Corner radius**\n\n- `independentCorners: true` → per-corner border-radius\n- `cornerRadius` → uniform border-radius\n\n**Effects**\n\n- `DROP_SHADOW` → `box-shadow`\n- `INNER_SHADOW` → `box-shadow: inset ...`\n- `LAYER_BLUR` → `filter: blur(...)`\n- `BACKGROUND_BLUR` → `backdrop-filter: blur(...)`\n\n**Text**\n\n- `fontFamily` → `font-family`\n- `fontSize` → `font-size`\n- `fontWeight` → `font-weight`\n- `lineHeight` → `line-height` (null = normal/auto)\n- `letterSpacing` → `letter-spacing`\n- `textAlignHorizontal` → `text-align`\n- `textAutoResize: WIDTH_AND_HEIGHT` → no explicit dimensions\n- `textAutoResize: HEIGHT` → fixed width, auto height\n- `textAutoResize: NONE` → fixed width and height\n- `textDecoration` → `text-decoration`\n- `textCase` → `text-transform`\n\n## Scene authoring reference\n\nThe appended reference applies when inspecting or editing Pairdraw scenes, not to the target frontend framework's API.\n";
|
|
3
3
|
//#endregion
|
|
4
4
|
export { codegen_default as default };
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","names":[],"sources":["../../../src/tools/prompts/codegen.md?raw"],"sourcesContent":["export default \"# Design to Code\\n\\nYou convert Figma designs into production frontend code. You have full access to the design document through tools. Never guess — always read the actual design data.\\n\\n> Note: Auto-layout and visual property names match the JSX props in the render system. See `describe` tool output for semantic role and layout analysis of any node.\\n\\n## Workflow\\n\\n### Step 1 — Survey\\n\\nUnderstand the full picture before writing any code.\\n\\n```\\nget_page_tree → document structure, all top-level frames\\nget_components → reusable components defined by the designer\\nlist_variables → design tokens (colors, numbers, strings, booleans)\\nlist_collections → variable collections and modes (light/dark, density, etc.)\\nanalyze_colors → color palette, frequencies, which colors use variables\\nanalyze_typography → font stacks, sizes, weights in use\\nanalyze_spacing → gap and padding values, grid compliance\\n```\\n\\nAfter this step you should know:\\n\\n- How many screens/pages the design has\\n- What components exist\\n- What the token system looks like (or if there is none)\\n- The typographic scale\\n- The spacing system (4px grid? 8px grid? irregular?)\\n\\n### Step 2 — Decompose\\n\\nIdentify the component architecture.\\n\\n```\\nanalyze_clusters → find repeated visual patterns that should be components\\ndescribe (per node) → semantic role, layout direction, visual properties, issues\\nget_jsx (per node) → structural JSX to understand nesting and layout\\n```\\n\\nBuild a component map:\\n\\n- **Screens** — top-level frames that represent pages/views\\n- **Components** — COMPONENT/COMPONENT_SET nodes or repeated patterns from analyze_clusters\\n- **Primitives** — leaf elements (text, icons, dividers) that don't need their own component file\\n\\nFor each component determine:\\n\\n- **Props** — what content varies between instances (text, color, icon, visibility)\\n- **Variants** — if the component has multiple states (default/hover/active, small/medium/large)\\n- **Slots** — where child content is injected\\n- **Behaviour** — `get_behaviour id=<component_id>` tells whether the designer made it a control, after Reka UI's primitives. Build such a component on that Reka primitive (`SwitchRoot` with `SwitchThumb`, `SliderRoot` with `SliderTrack`, `SliderRange`, and `SliderThumb`, `TabsRoot` with `TabsList`, `TabsTrigger`, and `TabsContent`, …): each part is the slot the behaviour names, its values are the properties it binds (`v-model` for the value, `disabled`), and its interaction states map to the variants for `data-state`, `:hover`, `:active`, `:focus-visible`, and `[data-disabled]`. Do not reimplement the control's keyboard and accessibility handling. In React use the Radix primitive with the same parts (Reka UI is the Vue port of Radix), and with a component library use its equivalent; see **Component libraries** below.\\n\\n### Step 3 — Extract tokens\\n\\n```\\nlist_variables → all variables with values per mode\\nlist_collections → collection structure and mode names\\n```\\n\\nMap design variables to code tokens. The approach depends on the target stack:\\n\\n#### Tailwind projects\\n\\nDo NOT create CSS custom properties for font sizes, font weights, spacing, or border radius — Tailwind has its own system for these. Use Tailwind utility classes directly:\\n\\n- Font sizes → `text-[13px]`, `text-sm`, `text-base`, etc.\\n- Font weights → `font-bold`, `font-medium`, `font-[600]`\\n- Spacing → `gap-3`, `p-4`, `px-5`, `py-[14px]`, or arbitrary `gap-[12px]`\\n- Border radius → `rounded-xl`, `rounded-[14px]`, `rounded-full`\\n\\nOnly create CSS custom properties for **semantic colors** — these are the values that would change across themes. Name them to avoid conflicts with Tailwind's built-in variables (do NOT use names like `--font-bold`, `--text-sm`, `--radius-lg`):\\n\\n```css\\n:root {\\n --movie-bg: #0f0f1a;\\n --movie-surface: #1a1a2e;\\n --movie-accent: #7c3aed;\\n --movie-text: #ffffff;\\n --movie-text-dim: #ffffff80;\\n}\\n```\\n\\nReference in Tailwind classes: `bg-[var(--movie-bg)]`, `text-[var(--movie-text)]`\\n\\n#### CSS Modules / plain CSS projects\\n\\nCreate CSS custom properties for all token categories (colors, spacing, typography, radius). Use a project-specific prefix to avoid collisions:\\n\\n```css\\n:root {\\n --app-color-bg: #0f0f1a;\\n --app-space-sm: 4px;\\n --app-text-sm: 12px;\\n --app-radius-md: 8px;\\n}\\n```\\n\\n#### Styled Components projects\\n\\nPut every token category in a typed theme object passed to `ThemeProvider`, and read it in styles as `${({ theme }) => theme.color.bg}`. Declare its type once by augmenting `DefaultTheme` in `styled.d.ts`:\\n\\n```ts\\nexport const theme = {\\n color: { bg: '#0f0f1a', surface: '#1a1a2e', accent: '#7c3aed', text: '#ffffff' },\\n space: { sm: '4px', md: '8px', lg: '16px' },\\n radius: { md: '8px', full: '9999px' },\\n font: { body: \\\"'Inter', sans-serif\\\" }\\n} as const\\n```\\n\\nFor multi-mode collections either build one theme object per mode and swap it on `ThemeProvider`, or write the colors as CSS custom properties in `createGlobalStyle` and keep the theme pointing at `var(--…)`, which switches without re-rendering.\\n\\n#### Component library projects\\n\\nWhen the project uses shadcn/ui, Chakra UI, or MUI, write tokens into the library's own theme instead of a parallel set of custom properties; see **Component libraries** below for where each one keeps them.\\n\\n#### No design variables in the file\\n\\nIf the design has no Figma variables, extract implicit tokens from `analyze_colors` and `analyze_typography` output — identify the de facto palette and type scale. For Tailwind projects, only extract semantic colors as CSS custom properties; use Tailwind utilities for everything else.\\n\\n#### Multi-mode collections (light/dark)\\n\\n- Generate token values for each mode\\n- Use CSS custom properties with class-based switching (`.dark { ... }`)\\n\\n### Step 4 — Generate code\\n\\nFor each component, bottom-up (primitives first, then composites, then screens):\\n\\n```\\nget_jsx id=<component_id> → read structure\\ndescribe id=<component_id> → understand semantic role\\nexport_svg ids=[<icon_ids>] → extract vector assets\\n```\\n\\n**Rules:**\\n\\n- One component per file\\n- Component name comes from the Figma node name, converted to PascalCase\\n- Props interface reflects the variable content identified in Step 2\\n- Use design tokens from Step 3 for semantic colors\\n- For Tailwind: use utility classes directly for spacing, font sizes, weights, radius — do NOT wrap them in `var()` indirection\\n- Match measurements exactly: font sizes, spacing, border radii, colors\\n- Use auto-layout data to determine flex direction, gap, padding, alignment\\n- Preserve text direction and container flow direction separately when the design uses RTL.\\n- Absolute positioning only when `layoutPositioning` is `ABSOLUTE` or layout mode is `NONE`\\n- If a node has `clipsContent: true`, use `overflow: hidden`\\n- Text nodes: preserve font family, size, weight, line height, letter spacing, alignment\\n- Images/illustrations: use `export_svg` for vectors, placeholder `<img>` for raster (`next/image` in Next.js)\\n- Icons: an `<Icon name=\\\"set:name\\\">` in `get_jsx` is an Iconify icon; emit it from the chosen icon package (see **Icons** below). An icon drawn as paths was edited or comes from no set, so export it with `export_svg`\\n\\n**Interactive states:**\\n\\nFigma designs rarely include hover/active/focus states unless the component has explicit variants for them. Always add sensible interactive feedback to clickable elements:\\n\\n- **Buttons (primary):** `hover:brightness-110 active:brightness-90 transition-all`\\n- **Buttons (secondary/ghost):** `hover:bg-white/[0.12] active:bg-white/[0.06] transition-colors`\\n- **Icon buttons:** `hover:bg-white/[0.15] active:scale-95 transition-all`\\n- **Cards/list items (if clickable):** `hover:bg-white/[0.04] transition-colors`\\n- **Links/text buttons:** `hover:underline` or `hover:opacity-80`\\n- **All interactive elements:** add `cursor-pointer` and `select-none`\\n- **Focus visible:** add `focus-visible:ring-2 focus-visible:ring-offset-2` with accent color for accessibility\\n\\nWith plain CSS, CSS Modules, or Styled Components write the same feedback as `:hover`, `:active`, and `:focus-visible` rules; with a component library keep its built-in states and adjust them through its theme.\\n\\nIf the design HAS explicit hover/active variants (COMPONENT_SET with state property), use those exact styles instead of defaults above.\\n\\n### Step 5 — Verify\\n\\nAfter generating code, verify against the design:\\n\\n```\\ndescribe id=<root> → re-check structure matches\\nget_jsx id=<root> → compare JSX structure with generated component tree\\n```\\n\\nCheck:\\n\\n- All text content from the design appears in the code\\n- All colors reference tokens or use correct hex/opacity values\\n- Spacing values match the design\\n- Component hierarchy matches the design's node tree\\n- No nodes were skipped or merged incorrectly\\n\\nList any deviations with rationale.\\n\\n## Target stack\\n\\nThe user specifies the target stack. Adapt code generation accordingly:\\n\\n**React + Tailwind** — functional components, TypeScript, utility classes, `className`\\n**React + CSS Modules** — functional components, TypeScript, `.module.css` files, `styles.className`\\n**React + Styled Components** — functional components, TypeScript, `styled.*` components and a typed theme (see **Styled Components**)\\n**Next.js** — React with the App Router, styled with Tailwind, CSS Modules, or Styled Components (see **Next.js**)\\n**Vue 3 + Tailwind** — `<script setup lang=\\\"ts\\\">`, `defineProps`, `<template>`, Tailwind utility classes\\n**Vue 3 + CSS** — `<script setup lang=\\\"ts\\\">`, `defineProps`, `<template>`, scoped `<style>`\\n**Svelte + Tailwind** — `<script lang=\\\"ts\\\">`, `$props()`, Tailwind utility classes\\n**HTML + CSS** — semantic HTML, BEM or utility classes, CSS custom properties\\n\\nTwo choices sit on top of the stack: the **component library** (shadcn/ui, Radix, Chakra UI, MUI, Reka UI, or the project's own components) and the **icon package** (Lucide, Heroicons, Font Awesome, React Icons, or Iconify). Read them from the project when you can see it: `package.json` dependencies, a `components.json` (shadcn/ui), existing imports.\\n\\nIf the user hasn't specified a stack, ask before generating code. Ask about the component library and icon package in the same question when the project does not show them.\\n\\n## Next.js\\n\\nTarget the App Router unless the project already uses `pages/`.\\n\\n- **Routes** — each screen is `app/<route>/page.tsx`; the home screen is `app/page.tsx`. Chrome shared by several screens (header, sidebar, footer that are the same instance or layers on each) goes in `app/layout.tsx` or a nested `layout.tsx`, not into every page. Name routes after the frame names in kebab-case.\\n- **Server and client components** — components are Server Components by default. Add `'use client'` only to the components that need state, event handlers, effects, or browser APIs: every behaviour control, anything with `onClick`, and Radix, Chakra, MUI, or Styled Components wrappers. Keep the boundary at the leaves: a page stays a Server Component that renders client leaves, and passes them data as serializable props.\\n- **Images** — use `next/image` for raster fills with the design's `width` and `height`; for an image that fills its frame use `fill` with `sizes`, on a parent with `position: relative`. Put exported assets in `public/` and reference them from `/`. Always pass `alt`, from the layer name or the surrounding text.\\n- **Fonts** — load design fonts with `next/font/google` (or `next/font/local` for fonts that are not on Google Fonts) in `app/layout.tsx`, only the weights `analyze_typography` reports, and expose each as a CSS variable (`variable: '--font-inter'`) that Tailwind or the theme reads.\\n- **Links** — a layer that navigates to another screen (nav items, text links, cards that open a detail screen) is `next/link`'s `<Link href>`, not a `<button>` or `<a onClick>`.\\n- **Metadata** — export `metadata` from each `page.tsx` with a `title` taken from the frame name.\\n- **Styling** — Tailwind tokens go in `app/globals.css`. CSS Modules work as in React. Styled Components need the compiler option (`compiler: { styledComponents: true }` in `next.config`) and a style registry client component that collects styles with `ServerStyleSheet` and `useServerInsertedHTML`, wrapped around `children` in `app/layout.tsx`; every file that calls `styled` is a client component.\\n\\n## Styled Components\\n\\n- One component file holds its styled elements, named after the layers they draw (`const Root = styled.button`, `const Label = styled.span`), or a sibling `Button.styles.ts` when it grows long.\\n- Variant properties become transient props (`$variant`, `$size`) so they never reach the DOM; select their styles with the `css` helper from a lookup keyed by the variant value, not nested ternaries.\\n- Interaction states are `&:hover`, `&:active`, `&:focus-visible`, and `&:disabled`. On a Radix primitive wrap it (`styled(Switch.Root)`) and style its `&[data-state='checked']` and `&[data-disabled]` attributes.\\n- Tokens come from the theme (see **Step 3**); never hard-code a value the design binds to a variable.\\n- Global resets, font faces, and mode custom properties go in one `createGlobalStyle`.\\n- Styled Components is React only. For Vue or Svelte write scoped styles instead.\\n\\n## Component libraries\\n\\nWhen the project uses a component library, build each behaviour control on that library's component instead of its own markup, and map the design's variant properties to the library's own props (`variant`, `size`, `disabled`). Style the parts the design draws differently through the library's styling hooks; do not rebuild a component the library provides. Components with no behaviour (cards, headers, list rows) stay the project's own components built from library layout primitives or plain elements.\\n\\nReka UI (Vue) and Radix (React) share part names: Reka's `SwitchRoot` is Radix's `Switch.Root`, and so on. shadcn/ui wraps Radix in React and shadcn-vue wraps Reka UI in Vue under the same component names. Both expose state as `data-state` (`checked`/`unchecked`, `on`/`off`, `open`/`closed`, `active`/`inactive`) and `data-disabled`, which is where the design's state variants go. Radix takes the value as a controlled pair instead of `v-model`: `checked`/`onCheckedChange` (switch, checkbox), `pressed`/`onPressedChange` (toggle), `open`/`onOpenChange` (collapsible), `value`/`onValueChange` (tabs, radio group, toggle group, accordion, slider with an array value). Import Radix from the unified `radix-ui` package (`import { Switch } from 'radix-ui'`) unless the project already uses the per-primitive `@radix-ui/react-*` packages.\\n\\n- `button` — Reka UI native `<button>`; Radix native `<button>`; shadcn/ui `Button`; Chakra UI `Button`; MUI `Button`\\n- `textField` — Reka UI native `<input>`; Radix native `<input>`; shadcn/ui `Input`; Chakra UI `Input` in `Field.Root`; MUI `TextField`\\n- `textarea` — Reka UI native `<textarea>`; Radix native `<textarea>`; shadcn/ui `Textarea`; Chakra UI `Textarea` in `Field.Root`; MUI `TextField multiline`\\n- `numberField` — Reka UI `NumberFieldRoot`, `NumberFieldInput`, `NumberFieldIncrement`, `NumberFieldDecrement`; Radix native `<input type=\\\"number\\\">` with stepper buttons; shadcn/ui `Input type=\\\"number\\\"`; Chakra UI `NumberInput.Root`, `NumberInput.Input`, `NumberInput.IncrementTrigger`, `NumberInput.DecrementTrigger`; MUI `TextField type=\\\"number\\\"`\\n- `toggle` — Reka UI `Toggle`; Radix `Toggle.Root`; shadcn/ui `Toggle`; Chakra UI `Button` with `aria-pressed`; MUI `ToggleButton`\\n- `switch` — Reka UI `SwitchRoot`, `SwitchThumb`; Radix `Switch.Root`, `Switch.Thumb`; shadcn/ui `Switch`; Chakra UI `Switch.Root`, `Switch.Control`, `Switch.Thumb`; MUI `Switch`\\n- `checkbox` — Reka UI `CheckboxRoot`, `CheckboxIndicator`; Radix `Checkbox.Root`, `Checkbox.Indicator`; shadcn/ui `Checkbox`; Chakra UI `Checkbox.Root`, `Checkbox.Control`, `Checkbox.Indicator`; MUI `Checkbox`\\n- `radioGroup` — Reka UI `RadioGroupRoot`, `RadioGroupItem`, `RadioGroupIndicator`; Radix `RadioGroup.Root`, `RadioGroup.Item`, `RadioGroup.Indicator`; shadcn/ui `RadioGroup`, `RadioGroupItem`; Chakra UI `RadioGroup.Root`, `RadioGroup.Item`, `RadioGroup.ItemIndicator`; MUI `RadioGroup` with `Radio` in `FormControlLabel`\\n- `toggleGroup` — Reka UI `ToggleGroupRoot`, `ToggleGroupItem`; Radix `ToggleGroup.Root`, `ToggleGroup.Item`; shadcn/ui `ToggleGroup`, `ToggleGroupItem`; Chakra UI `SegmentGroup.Root`, `SegmentGroup.Item`; MUI `ToggleButtonGroup`, `ToggleButton`\\n- `slider` — Reka UI `SliderRoot`, `SliderTrack`, `SliderRange`, `SliderThumb`; Radix `Slider.Root`, `Slider.Track`, `Slider.Range`, `Slider.Thumb`; shadcn/ui `Slider`; Chakra UI `Slider.Root`, `Slider.Control`, `Slider.Track`, `Slider.Range`, `Slider.Thumb`; MUI `Slider` (`rail`, `track`, `thumb` slots)\\n- `progress` — Reka UI `ProgressRoot`, `ProgressIndicator`; Radix `Progress.Root`, `Progress.Indicator`; shadcn/ui `Progress`; Chakra UI `Progress.Root`, `Progress.Track`, `Progress.Range`; MUI `LinearProgress variant=\\\"determinate\\\"`\\n- `tabs` — Reka UI `TabsRoot`, `TabsList`, `TabsTrigger`, `TabsContent`; Radix `Tabs.Root`, `Tabs.List`, `Tabs.Trigger`, `Tabs.Content`; shadcn/ui `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent`; Chakra UI `Tabs.Root`, `Tabs.List`, `Tabs.Trigger`, `Tabs.Content`; MUI `Tabs`, `Tab`, with a panel per tab\\n- `collapsible` — Reka UI `CollapsibleRoot`, `CollapsibleTrigger`, `CollapsibleContent`; Radix `Collapsible.Root`, `Collapsible.Trigger`, `Collapsible.Content`; shadcn/ui `Collapsible`, `CollapsibleTrigger`, `CollapsibleContent`; Chakra UI `Collapsible.Root`, `Collapsible.Trigger`, `Collapsible.Content`; MUI `Collapse` toggled by a `Button`\\n- `accordion` — Reka UI `AccordionRoot`, `AccordionItem`, `AccordionTrigger`, `AccordionContent`; Radix `Accordion.Root`, `Accordion.Item`, `Accordion.Trigger`, `Accordion.Content`; shadcn/ui `Accordion`, `AccordionItem`, `AccordionTrigger`, `AccordionContent`; Chakra UI `Accordion.Root`, `Accordion.Item`, `Accordion.ItemTrigger`, `Accordion.ItemContent`; MUI `Accordion`, `AccordionSummary`, `AccordionDetails` per item\\n\\nA `radio` behaviour is one item of a `radioGroup`: its `RadioGroupItem`, `RadioGroup.Item`, or `Radio`. A behaviour's `items` slot holds the group's items and a tab list's children are its triggers, so the list above names the item parts too. In Reka UI and Radix an accordion trigger sits inside `AccordionHeader` / `Accordion.Header`. A `progress` behaviour's `track` slot is the root itself, `ProgressRoot` / `Progress.Root` in Reka UI and Radix (`Progress.Track` in Chakra UI), so do not add a wrapper for it. A `tabs` behaviour's `panels` slot has no part of its own: its children are the content parts, `TabsContent` / `Tabs.Content`, placed directly under the root.\\n\\nWhere each library keeps tokens and variants:\\n\\n- **shadcn/ui** — components are copied into the project (`components/ui`), so restyle them there to match the design rather than overriding every call site. Map semantic colors to its CSS variables (`--background`, `--foreground`, `--primary`, `--primary-foreground`, `--secondary`, `--muted`, `--accent`, `--destructive`, `--border`, `--input`, `--ring`) and the base corner radius to `--radius`, per mode under `.dark`. These replace the Tailwind rule against radius custom properties above because shadcn/ui already defines them. Add design variants to the component's `cva` `variants` (`variant`, `size`) under the design's own value names, and merge classes with `cn()`.\\n- **Radix (unstyled)** — style each part directly with the project's styling approach; state selectors are `[data-state=…]` and `[data-disabled]`, and Tailwind's `data-[state=checked]:` variants.\\n- **Chakra UI v3** — put tokens in `createSystem(defaultConfig, { theme: { tokens, semanticTokens } })`, with mode values as `{ base, _dark }` semantic tokens, and pass the system to `ChakraProvider`. Spacing, radius, and typography use style props (`gap`, `px`, `rounded`, `fontSize`). Component variants go in a `recipe` (single part) or `slotRecipe` (multi-part, such as switch or tabs).\\n- **MUI** — put tokens in `createTheme`: `palette` (one theme per mode, or `colorSchemes` with CSS variables), `typography`, `spacing`, and `shape.borderRadius`. Style instances with `sx` and reusable pieces with `styled()` from `@mui/material/styles`; add design variants to `components.<Name>.variants` and part overrides to `components.<Name>.styleOverrides` (`MuiSwitch`'s `thumb` and `track`, `MuiSlider`'s `rail`, `track`, and `thumb`).\\n- **The project's own components** — `design_to_component_map` lists the design's components with their variants and instance counts. Match each to an existing component in the codebase by name and role before writing a new one, and extend an existing component's props for a new variant rather than duplicating it.\\n\\n## Icons\\n\\n`get_jsx` writes a named icon as `<Icon name=\\\"lucide:arrow-right\\\" size={16} color=\\\"#6b7280\\\" />`. The name is an Iconify name, `<set>:<icon>`; `size` is its width and height; `color` is its color (black when absent); `label`, when present, is the name the designer gave the layer. Use it as `aria-label` when the icon stands alone and carries meaning (an icon button); otherwise the icon is decorative, so give it `aria-hidden=\\\"true\\\"`. Use the color through the same token the surrounding text uses when it matches one.\\n\\nEmit each icon from the icon package the user chose. Iconify set prefixes map to packages mechanically; convert the kebab-case icon name to PascalCase for the component:\\n\\n- `lucide:arrow-right` — `lucide-react`, `lucide-vue-next`, `@lucide/svelte`: `ArrowRight`, with `size` and `strokeWidth`\\n- `heroicons:arrow-right` (24 outline) — `@heroicons/react/24/outline` or `@heroicons/vue/24/outline`: `ArrowRightIcon`\\n- `heroicons:arrow-right-solid`, `-20-solid`, `-16-solid` — `@heroicons/react/24/solid`, `/20/solid`, `/16/solid`: `ArrowRightIcon`\\n- `fa6-solid:house`, `fa6-regular:heart`, `fa6-brands:github` — `@fortawesome/react-fontawesome` (or `vue-fontawesome`) with `@fortawesome/free-solid-svg-icons`, `free-regular-svg-icons`, `free-brands-svg-icons`: `<FontAwesomeIcon icon={faHouse} />`\\n- `tabler:home` — `@tabler/icons-react`: `IconHome`\\n- `ph:house` — `@phosphor-icons/react`: `House` (`@phosphor-icons/vue`: `PhHouse`). A `-thin`, `-light`, `-bold`, `-fill`, or `-duotone` suffix is the `weight` prop on the base component, not part of its name: `ph:house-bold` → `<House weight=\\\"bold\\\" />`\\n- `radix-icons:home` — `@radix-ui/react-icons`: `HomeIcon`\\n- `mdi:home` — `@mdi/react` with `@mdi/js`: `<Icon path={mdiHome} />`\\n\\nReact Icons bundles many sets under one package, each behind a prefix: `lucide:` → `react-icons/lu` (`LuArrowRight`), `heroicons:` → `react-icons/hi2` (`HiOutlineArrowRight`, `HiArrowRight` for solid, `HiMiniArrowRight` for `-20-solid`, `HiMicroArrowRight` for `-16-solid`), `fa6-solid:` / `fa6-regular:` / `fa6-brands:` → `react-icons/fa6` (`FaHouse`, `FaRegHeart`, `FaGithub`), `tabler:` → `react-icons/tb` (`TbHome`), `ph:` → `react-icons/pi` (`PiHouse`, with the weight kept in the name: `PiHouseBold`, `PiHouseFill`), `ic:` → `react-icons/md` (`MdHome`), `bi:` → `react-icons/bs` (`BsHouse`), `ri:` → `react-icons/ri` (`RiHomeLine`), `feather:` → `react-icons/fi` (`FiHome`), `simple-icons:` → `react-icons/si` (`SiGithub`). Size with `size`, color with `color` or a text color class.\\n\\nRules:\\n\\n- Check that the export exists in the installed package version; sets rename icons between releases. When the name differs, pick the package's equivalent and say so.\\n- When the design's set has no package in the chosen library (an `mdi:` icon with Lucide chosen), do not silently swap in a different-looking icon. Use Iconify for that icon (`@iconify/react` or `@iconify/vue`, `<Icon icon=\\\"mdi:home\\\" />`) or export it with `export_svg`, and list it under deviations. Replace it with the chosen set's closest icon only when the user asks for one consistent set.\\n- With no package chosen, use the package that owns the design's set (`lucide:` → `lucide-react`), or Iconify when the design mixes sets.\\n- Import icons by name from the package (`import { ArrowRight } from 'lucide-react'`); never import a whole set.\\n\\n## Component file structure\\n\\n```\\ncomponents/\\n Button.tsx (or .vue, .svelte)\\n Card.tsx\\n Header.tsx\\n ...\\ntokens.css (semantic color tokens only, for Tailwind projects)\\npages/\\n HomePage.tsx (or routes, views — depends on framework)\\nassets/\\n icon-arrow.svg\\n icon-check.svg\\n```\\n\\nIn Next.js screens are routes and assets are public files:\\n\\n```\\napp/\\n layout.tsx (fonts, shared chrome, global styles)\\n globals.css (tokens)\\n page.tsx (home screen)\\n settings/\\n page.tsx\\ncomponents/\\n Button.tsx\\n ui/ (shadcn/ui components, when used)\\npublic/\\n hero.png\\n```\\n\\n## Common patterns\\n\\n**Auto-layout → Flexbox**\\n\\n- `layoutMode: HORIZONTAL` → `flex-direction: row`\\n- `layoutMode: VERTICAL` → `flex-direction: column`\\n- `itemSpacing` → `gap`\\n- `paddingTop/Right/Bottom/Left` → `padding`\\n- `primaryAxisAlign: CENTER` → `justify-content: center`\\n- `counterAxisAlign: CENTER` → `align-items: center`\\n- `layoutWrap: WRAP` → `flex-wrap: wrap`\\n- `primaryAxisSizing: HUG` / `counterAxisSizing: HUG` → no explicit size on that axis (content-sized)\\n\\n**Grid layout**\\n\\n- `layoutMode: GRID` → `display: grid`\\n- `gridTemplateColumns` → `grid-template-columns`\\n- `gridTemplateRows` → `grid-template-rows`\\n- `gridColumnGap/gridRowGap` → `column-gap/row-gap`\\n\\n**Sizing**\\n\\n- Fill lives on the child: `layoutGrow > 0` fills the parent's primary axis (`flex-grow: 1`), `layoutAlignSelf: STRETCH` fills the cross axis (`align-self: stretch`, no fixed size on that axis). In a grid, `layoutGrow` fills the cell's width and `STRETCH` its height.\\n- Fixed width/height only on axes that neither hug nor fill\\n\\n**Corner radius**\\n\\n- `independentCorners: true` → per-corner border-radius\\n- `cornerRadius` → uniform border-radius\\n\\n**Effects**\\n\\n- `DROP_SHADOW` → `box-shadow`\\n- `INNER_SHADOW` → `box-shadow: inset ...`\\n- `LAYER_BLUR` → `filter: blur(...)`\\n- `BACKGROUND_BLUR` → `backdrop-filter: blur(...)`\\n\\n**Text**\\n\\n- `fontFamily` → `font-family`\\n- `fontSize` → `font-size`\\n- `fontWeight` → `font-weight`\\n- `lineHeight` → `line-height` (null = normal/auto)\\n- `letterSpacing` → `letter-spacing`\\n- `textAlignHorizontal` → `text-align`\\n- `textAutoResize: WIDTH_AND_HEIGHT` → no explicit dimensions\\n- `textAutoResize: HEIGHT` → fixed width, auto height\\n- `textAutoResize: NONE` → fixed width and height\\n- `textDecoration` → `text-decoration`\\n- `textCase` → `text-transform`\\n\\n## Scene authoring reference\\n\\nThe appended reference applies when inspecting or editing Pairdraw scenes, not to the target frontend framework's API.\\n\""],"mappings":";AAAA,IAAA,kBAAe"}
|
|
1
|
+
{"version":3,"file":"codegen.js","names":[],"sources":["../../../src/tools/prompts/codegen.md?raw"],"sourcesContent":["export default \"# Design to Code\\n\\nYou convert Figma designs into production frontend code. You have full access to the design document through tools. Never guess — always read the actual design data.\\n\\n> Note: Auto-layout and visual property names match the JSX props in the render system. Read geometry and style with `get_css` (CSS-like lines, colours as tokens), roles and design issues with `describe`, and structure with `get_jsx`.\\n\\n## Workflow\\n\\n### Step 1 — Survey\\n\\nUnderstand the full picture before writing any code.\\n\\n```\\nget_page_tree → document structure, all top-level frames\\nget_components → reusable components defined by the designer\\nlist_variables → design tokens (colors, numbers, strings, booleans)\\nlist_collections → variable collections and modes (light/dark, density, etc.)\\nanalyze_colors → color palette, frequencies, which colors use variables\\nanalyze_typography → font stacks, sizes, weights in use\\nanalyze_spacing → gap and padding values, grid compliance\\n```\\n\\nAfter this step you should know:\\n\\n- How many screens/pages the design has\\n- What components exist\\n- What the token system looks like (or if there is none)\\n- The typographic scale\\n- The spacing system (4px grid? 8px grid? irregular?)\\n\\n### Step 2 — Decompose\\n\\nIdentify the component architecture.\\n\\n```\\nanalyze_clusters → find repeated visual patterns that should be components\\nget_css (per node) → CSS shape: flex, gap, padding, size constraints, token colours, text\\ndescribe (per node) → semantic role, layout direction, visual properties, issues\\nget_jsx (per node) → structural JSX to understand nesting and layout\\n```\\n\\nBuild a component map:\\n\\n- **Screens** — top-level frames that represent pages/views\\n- **Components** — COMPONENT/COMPONENT_SET nodes or repeated patterns from analyze_clusters\\n- **Primitives** — leaf elements (text, icons, dividers) that don't need their own component file\\n\\nFor each component determine:\\n\\n- **Props** — what content varies between instances (text, color, icon, visibility)\\n- **Variants** — if the component has multiple states (default/hover/active, small/medium/large)\\n- **Slots** — where child content is injected\\n- **Behaviour** — `get_behaviour id=<component_id>` tells whether the designer made it a control, after Reka UI's primitives. Build such a component on that Reka primitive (`SwitchRoot` with `SwitchThumb`, `SliderRoot` with `SliderTrack`, `SliderRange`, and `SliderThumb`, `TabsRoot` with `TabsList`, `TabsTrigger`, and `TabsContent`, …): each part is the slot the behaviour names, its values are the properties it binds (`v-model` for the value, `disabled`), and its interaction states map to the variants for `data-state`, `:hover`, `:active`, `:focus-visible`, and `[data-disabled]`. Do not reimplement the control's keyboard and accessibility handling. In React use the Radix primitive with the same parts (Reka UI is the Vue port of Radix), and with a component library use its equivalent; see **Component libraries** below.\\n\\n### Step 3 — Extract tokens\\n\\n```\\nlist_variables → all variables with values per mode\\nlist_collections → collection structure and mode names\\n```\\n\\nMap design variables to code tokens. The approach depends on the target stack:\\n\\n#### Tailwind projects\\n\\nDo NOT create CSS custom properties for font sizes, font weights, spacing, or border radius — Tailwind has its own system for these. Use Tailwind utility classes directly:\\n\\n- Font sizes → `text-[13px]`, `text-sm`, `text-base`, etc.\\n- Font weights → `font-bold`, `font-medium`, `font-[600]`\\n- Spacing → `gap-3`, `p-4`, `px-5`, `py-[14px]`, or arbitrary `gap-[12px]`\\n- Border radius → `rounded-xl`, `rounded-[14px]`, `rounded-full`\\n\\nOnly create CSS custom properties for **semantic colors** — these are the values that would change across themes. Name them to avoid conflicts with Tailwind's built-in variables (do NOT use names like `--font-bold`, `--text-sm`, `--radius-lg`):\\n\\n```css\\n:root {\\n --movie-bg: #0f0f1a;\\n --movie-surface: #1a1a2e;\\n --movie-accent: #7c3aed;\\n --movie-text: #ffffff;\\n --movie-text-dim: #ffffff80;\\n}\\n```\\n\\nReference in Tailwind classes: `bg-[var(--movie-bg)]`, `text-[var(--movie-text)]`\\n\\n#### CSS Modules / plain CSS projects\\n\\nCreate CSS custom properties for all token categories (colors, spacing, typography, radius). Use a project-specific prefix to avoid collisions:\\n\\n```css\\n:root {\\n --app-color-bg: #0f0f1a;\\n --app-space-sm: 4px;\\n --app-text-sm: 12px;\\n --app-radius-md: 8px;\\n}\\n```\\n\\n#### Styled Components projects\\n\\nPut every token category in a typed theme object passed to `ThemeProvider`, and read it in styles as `${({ theme }) => theme.color.bg}`. Declare its type once by augmenting `DefaultTheme` in `styled.d.ts`:\\n\\n```ts\\nexport const theme = {\\n color: { bg: '#0f0f1a', surface: '#1a1a2e', accent: '#7c3aed', text: '#ffffff' },\\n space: { sm: '4px', md: '8px', lg: '16px' },\\n radius: { md: '8px', full: '9999px' },\\n font: { body: \\\"'Inter', sans-serif\\\" }\\n} as const\\n```\\n\\nFor multi-mode collections either build one theme object per mode and swap it on `ThemeProvider`, or write the colors as CSS custom properties in `createGlobalStyle` and keep the theme pointing at `var(--…)`, which switches without re-rendering.\\n\\n#### Component library projects\\n\\nWhen the project uses shadcn/ui, Chakra UI, or MUI, write tokens into the library's own theme instead of a parallel set of custom properties; see **Component libraries** below for where each one keeps them.\\n\\n#### No design variables in the file\\n\\nIf the design has no Figma variables, extract implicit tokens from `analyze_colors` and `analyze_typography` output — identify the de facto palette and type scale. For Tailwind projects, only extract semantic colors as CSS custom properties; use Tailwind utilities for everything else.\\n\\n#### Multi-mode collections (light/dark)\\n\\n- Generate token values for each mode\\n- Use CSS custom properties with class-based switching (`.dark { ... }`)\\n\\n### Step 4 — Generate code\\n\\nFor each component, bottom-up (primitives first, then composites, then screens):\\n\\n```\\nget_jsx id=<component_id> → read structure\\ndescribe id=<component_id> → understand semantic role\\nexport_svg ids=[<icon_ids>] → extract vector assets\\n```\\n\\n**Rules:**\\n\\n- One component per file\\n- Component name comes from the Figma node name, converted to PascalCase\\n- Props interface reflects the variable content identified in Step 2\\n- Use design tokens from Step 3 for semantic colors\\n- For Tailwind: use utility classes directly for spacing, font sizes, weights, radius — do NOT wrap them in `var()` indirection\\n- Match measurements exactly: font sizes, spacing, border radii, colors\\n- Use auto-layout data to determine flex direction, gap, padding, alignment\\n- Preserve text direction and container flow direction separately when the design uses RTL.\\n- Absolute positioning only when `layoutPositioning` is `ABSOLUTE` or layout mode is `NONE`\\n- If a node has `clipsContent: true`, use `overflow: hidden`\\n- Text nodes: preserve font family, size, weight, line height, letter spacing, alignment\\n- Images/illustrations: use `export_svg` for vectors, placeholder `<img>` for raster (`next/image` in Next.js)\\n- Icons: an `<Icon name=\\\"set:name\\\">` in `get_jsx` is an Iconify icon; emit it from the chosen icon package (see **Icons** below). An icon drawn as paths was edited or comes from no set, so export it with `export_svg`\\n\\n**Interactive states:**\\n\\nFigma designs rarely include hover/active/focus states unless the component has explicit variants for them. Always add sensible interactive feedback to clickable elements:\\n\\n- **Buttons (primary):** `hover:brightness-110 active:brightness-90 transition-all`\\n- **Buttons (secondary/ghost):** `hover:bg-white/[0.12] active:bg-white/[0.06] transition-colors`\\n- **Icon buttons:** `hover:bg-white/[0.15] active:scale-95 transition-all`\\n- **Cards/list items (if clickable):** `hover:bg-white/[0.04] transition-colors`\\n- **Links/text buttons:** `hover:underline` or `hover:opacity-80`\\n- **All interactive elements:** add `cursor-pointer` and `select-none`\\n- **Focus visible:** add `focus-visible:ring-2 focus-visible:ring-offset-2` with accent color for accessibility\\n\\nWith plain CSS, CSS Modules, or Styled Components write the same feedback as `:hover`, `:active`, and `:focus-visible` rules; with a component library keep its built-in states and adjust them through its theme.\\n\\nIf the design HAS explicit hover/active variants (COMPONENT_SET with state property), use those exact styles instead of defaults above.\\n\\n### Step 5 — Verify\\n\\nAfter generating code, verify against the design:\\n\\n```\\ndescribe id=<root> → re-check structure matches\\nget_jsx id=<root> → compare JSX structure with generated component tree\\n```\\n\\nCheck:\\n\\n- All text content from the design appears in the code\\n- All colors reference tokens or use correct hex/opacity values\\n- Spacing values match the design\\n- Component hierarchy matches the design's node tree\\n- No nodes were skipped or merged incorrectly\\n\\nList any deviations with rationale.\\n\\n## Target stack\\n\\nThe user specifies the target stack. Adapt code generation accordingly:\\n\\n**React + Tailwind** — functional components, TypeScript, utility classes, `className`\\n**React + CSS Modules** — functional components, TypeScript, `.module.css` files, `styles.className`\\n**React + Styled Components** — functional components, TypeScript, `styled.*` components and a typed theme (see **Styled Components**)\\n**Next.js** — React with the App Router, styled with Tailwind, CSS Modules, or Styled Components (see **Next.js**)\\n**Vue 3 + Tailwind** — `<script setup lang=\\\"ts\\\">`, `defineProps`, `<template>`, Tailwind utility classes\\n**Vue 3 + CSS** — `<script setup lang=\\\"ts\\\">`, `defineProps`, `<template>`, scoped `<style>`\\n**Svelte + Tailwind** — `<script lang=\\\"ts\\\">`, `$props()`, Tailwind utility classes\\n**HTML + CSS** — semantic HTML, BEM or utility classes, CSS custom properties\\n\\nTwo choices sit on top of the stack: the **component library** (shadcn/ui, Radix, Chakra UI, MUI, Reka UI, or the project's own components) and the **icon package** (Lucide, Heroicons, Font Awesome, React Icons, or Iconify). Read them from the project when you can see it: `package.json` dependencies, a `components.json` (shadcn/ui), existing imports.\\n\\nIf the user hasn't specified a stack, ask before generating code. Ask about the component library and icon package in the same question when the project does not show them.\\n\\n## Next.js\\n\\nTarget the App Router unless the project already uses `pages/`.\\n\\n- **Routes** — each screen is `app/<route>/page.tsx`; the home screen is `app/page.tsx`. Chrome shared by several screens (header, sidebar, footer that are the same instance or layers on each) goes in `app/layout.tsx` or a nested `layout.tsx`, not into every page. Name routes after the frame names in kebab-case.\\n- **Server and client components** — components are Server Components by default. Add `'use client'` only to the components that need state, event handlers, effects, or browser APIs: every behaviour control, anything with `onClick`, and Radix, Chakra, MUI, or Styled Components wrappers. Keep the boundary at the leaves: a page stays a Server Component that renders client leaves, and passes them data as serializable props.\\n- **Images** — use `next/image` for raster fills with the design's `width` and `height`; for an image that fills its frame use `fill` with `sizes`, on a parent with `position: relative`. Put exported assets in `public/` and reference them from `/`. Always pass `alt`, from the layer name or the surrounding text.\\n- **Fonts** — load design fonts with `next/font/google` (or `next/font/local` for fonts that are not on Google Fonts) in `app/layout.tsx`, only the weights `analyze_typography` reports, and expose each as a CSS variable (`variable: '--font-inter'`) that Tailwind or the theme reads.\\n- **Links** — a layer that navigates to another screen (nav items, text links, cards that open a detail screen) is `next/link`'s `<Link href>`, not a `<button>` or `<a onClick>`.\\n- **Metadata** — export `metadata` from each `page.tsx` with a `title` taken from the frame name.\\n- **Styling** — Tailwind tokens go in `app/globals.css`. CSS Modules work as in React. Styled Components need the compiler option (`compiler: { styledComponents: true }` in `next.config`) and a style registry client component that collects styles with `ServerStyleSheet` and `useServerInsertedHTML`, wrapped around `children` in `app/layout.tsx`; every file that calls `styled` is a client component.\\n\\n## Styled Components\\n\\n- One component file holds its styled elements, named after the layers they draw (`const Root = styled.button`, `const Label = styled.span`), or a sibling `Button.styles.ts` when it grows long.\\n- Variant properties become transient props (`$variant`, `$size`) so they never reach the DOM; select their styles with the `css` helper from a lookup keyed by the variant value, not nested ternaries.\\n- Interaction states are `&:hover`, `&:active`, `&:focus-visible`, and `&:disabled`. On a Radix primitive wrap it (`styled(Switch.Root)`) and style its `&[data-state='checked']` and `&[data-disabled]` attributes.\\n- Tokens come from the theme (see **Step 3**); never hard-code a value the design binds to a variable.\\n- Global resets, font faces, and mode custom properties go in one `createGlobalStyle`.\\n- Styled Components is React only. For Vue or Svelte write scoped styles instead.\\n\\n## Component libraries\\n\\nWhen the project uses a component library, build each behaviour control on that library's component instead of its own markup, and map the design's variant properties to the library's own props (`variant`, `size`, `disabled`). Style the parts the design draws differently through the library's styling hooks; do not rebuild a component the library provides. Components with no behaviour (cards, headers, list rows) stay the project's own components built from library layout primitives or plain elements.\\n\\nReka UI (Vue) and Radix (React) share part names: Reka's `SwitchRoot` is Radix's `Switch.Root`, and so on. shadcn/ui wraps Radix in React and shadcn-vue wraps Reka UI in Vue under the same component names. Both expose state as `data-state` (`checked`/`unchecked`, `on`/`off`, `open`/`closed`, `active`/`inactive`) and `data-disabled`, which is where the design's state variants go. Radix takes the value as a controlled pair instead of `v-model`: `checked`/`onCheckedChange` (switch, checkbox), `pressed`/`onPressedChange` (toggle), `open`/`onOpenChange` (collapsible), `value`/`onValueChange` (tabs, radio group, toggle group, accordion, slider with an array value). Import Radix from the unified `radix-ui` package (`import { Switch } from 'radix-ui'`) unless the project already uses the per-primitive `@radix-ui/react-*` packages.\\n\\n- `button` — Reka UI native `<button>`; Radix native `<button>`; shadcn/ui `Button`; Chakra UI `Button`; MUI `Button`\\n- `textField` — Reka UI native `<input>`; Radix native `<input>`; shadcn/ui `Input`; Chakra UI `Input` in `Field.Root`; MUI `TextField`\\n- `textarea` — Reka UI native `<textarea>`; Radix native `<textarea>`; shadcn/ui `Textarea`; Chakra UI `Textarea` in `Field.Root`; MUI `TextField multiline`\\n- `numberField` — Reka UI `NumberFieldRoot`, `NumberFieldInput`, `NumberFieldIncrement`, `NumberFieldDecrement`; Radix native `<input type=\\\"number\\\">` with stepper buttons; shadcn/ui `Input type=\\\"number\\\"`; Chakra UI `NumberInput.Root`, `NumberInput.Input`, `NumberInput.IncrementTrigger`, `NumberInput.DecrementTrigger`; MUI `TextField type=\\\"number\\\"`\\n- `toggle` — Reka UI `Toggle`; Radix `Toggle.Root`; shadcn/ui `Toggle`; Chakra UI `Button` with `aria-pressed`; MUI `ToggleButton`\\n- `switch` — Reka UI `SwitchRoot`, `SwitchThumb`; Radix `Switch.Root`, `Switch.Thumb`; shadcn/ui `Switch`; Chakra UI `Switch.Root`, `Switch.Control`, `Switch.Thumb`; MUI `Switch`\\n- `checkbox` — Reka UI `CheckboxRoot`, `CheckboxIndicator`; Radix `Checkbox.Root`, `Checkbox.Indicator`; shadcn/ui `Checkbox`; Chakra UI `Checkbox.Root`, `Checkbox.Control`, `Checkbox.Indicator`; MUI `Checkbox`\\n- `radioGroup` — Reka UI `RadioGroupRoot`, `RadioGroupItem`, `RadioGroupIndicator`; Radix `RadioGroup.Root`, `RadioGroup.Item`, `RadioGroup.Indicator`; shadcn/ui `RadioGroup`, `RadioGroupItem`; Chakra UI `RadioGroup.Root`, `RadioGroup.Item`, `RadioGroup.ItemIndicator`; MUI `RadioGroup` with `Radio` in `FormControlLabel`\\n- `toggleGroup` — Reka UI `ToggleGroupRoot`, `ToggleGroupItem`; Radix `ToggleGroup.Root`, `ToggleGroup.Item`; shadcn/ui `ToggleGroup`, `ToggleGroupItem`; Chakra UI `SegmentGroup.Root`, `SegmentGroup.Item`; MUI `ToggleButtonGroup`, `ToggleButton`\\n- `slider` — Reka UI `SliderRoot`, `SliderTrack`, `SliderRange`, `SliderThumb`; Radix `Slider.Root`, `Slider.Track`, `Slider.Range`, `Slider.Thumb`; shadcn/ui `Slider`; Chakra UI `Slider.Root`, `Slider.Control`, `Slider.Track`, `Slider.Range`, `Slider.Thumb`; MUI `Slider` (`rail`, `track`, `thumb` slots)\\n- `progress` — Reka UI `ProgressRoot`, `ProgressIndicator`; Radix `Progress.Root`, `Progress.Indicator`; shadcn/ui `Progress`; Chakra UI `Progress.Root`, `Progress.Track`, `Progress.Range`; MUI `LinearProgress variant=\\\"determinate\\\"`\\n- `tabs` — Reka UI `TabsRoot`, `TabsList`, `TabsTrigger`, `TabsContent`; Radix `Tabs.Root`, `Tabs.List`, `Tabs.Trigger`, `Tabs.Content`; shadcn/ui `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent`; Chakra UI `Tabs.Root`, `Tabs.List`, `Tabs.Trigger`, `Tabs.Content`; MUI `Tabs`, `Tab`, with a panel per tab\\n- `collapsible` — Reka UI `CollapsibleRoot`, `CollapsibleTrigger`, `CollapsibleContent`; Radix `Collapsible.Root`, `Collapsible.Trigger`, `Collapsible.Content`; shadcn/ui `Collapsible`, `CollapsibleTrigger`, `CollapsibleContent`; Chakra UI `Collapsible.Root`, `Collapsible.Trigger`, `Collapsible.Content`; MUI `Collapse` toggled by a `Button`\\n- `accordion` — Reka UI `AccordionRoot`, `AccordionItem`, `AccordionTrigger`, `AccordionContent`; Radix `Accordion.Root`, `Accordion.Item`, `Accordion.Trigger`, `Accordion.Content`; shadcn/ui `Accordion`, `AccordionItem`, `AccordionTrigger`, `AccordionContent`; Chakra UI `Accordion.Root`, `Accordion.Item`, `Accordion.ItemTrigger`, `Accordion.ItemContent`; MUI `Accordion`, `AccordionSummary`, `AccordionDetails` per item\\n\\nA `radio` behaviour is one item of a `radioGroup`: its `RadioGroupItem`, `RadioGroup.Item`, or `Radio`. A behaviour's `items` slot holds the group's items and a tab list's children are its triggers, so the list above names the item parts too. In Reka UI and Radix an accordion trigger sits inside `AccordionHeader` / `Accordion.Header`. A `progress` behaviour's `track` slot is the root itself, `ProgressRoot` / `Progress.Root` in Reka UI and Radix (`Progress.Track` in Chakra UI), so do not add a wrapper for it. A `tabs` behaviour's `panels` slot has no part of its own: its children are the content parts, `TabsContent` / `Tabs.Content`, placed directly under the root.\\n\\nWhere each library keeps tokens and variants:\\n\\n- **shadcn/ui** — components are copied into the project (`components/ui`), so restyle them there to match the design rather than overriding every call site. Map semantic colors to its CSS variables (`--background`, `--foreground`, `--primary`, `--primary-foreground`, `--secondary`, `--muted`, `--accent`, `--destructive`, `--border`, `--input`, `--ring`) and the base corner radius to `--radius`, per mode under `.dark`. These replace the Tailwind rule against radius custom properties above because shadcn/ui already defines them. Add design variants to the component's `cva` `variants` (`variant`, `size`) under the design's own value names, and merge classes with `cn()`.\\n- **Radix (unstyled)** — style each part directly with the project's styling approach; state selectors are `[data-state=…]` and `[data-disabled]`, and Tailwind's `data-[state=checked]:` variants.\\n- **Chakra UI v3** — put tokens in `createSystem(defaultConfig, { theme: { tokens, semanticTokens } })`, with mode values as `{ base, _dark }` semantic tokens, and pass the system to `ChakraProvider`. Spacing, radius, and typography use style props (`gap`, `px`, `rounded`, `fontSize`). Component variants go in a `recipe` (single part) or `slotRecipe` (multi-part, such as switch or tabs).\\n- **MUI** — put tokens in `createTheme`: `palette` (one theme per mode, or `colorSchemes` with CSS variables), `typography`, `spacing`, and `shape.borderRadius`. Style instances with `sx` and reusable pieces with `styled()` from `@mui/material/styles`; add design variants to `components.<Name>.variants` and part overrides to `components.<Name>.styleOverrides` (`MuiSwitch`'s `thumb` and `track`, `MuiSlider`'s `rail`, `track`, and `thumb`).\\n- **The project's own components** — `design_to_component_map` lists the design's components with their variants and instance counts. Match each to an existing component in the codebase by name and role before writing a new one, and extend an existing component's props for a new variant rather than duplicating it.\\n\\n## Icons\\n\\n`get_jsx` writes a named icon as `<Icon name=\\\"lucide:arrow-right\\\" size={16} color=\\\"#6b7280\\\" />`. The name is an Iconify name, `<set>:<icon>`; `size` is its width and height; `color` is its color (black when absent); `label`, when present, is the name the designer gave the layer. Use it as `aria-label` when the icon stands alone and carries meaning (an icon button); otherwise the icon is decorative, so give it `aria-hidden=\\\"true\\\"`. Use the color through the same token the surrounding text uses when it matches one.\\n\\nEmit each icon from the icon package the user chose. Iconify set prefixes map to packages mechanically; convert the kebab-case icon name to PascalCase for the component:\\n\\n- `lucide:arrow-right` — `lucide-react`, `lucide-vue-next`, `@lucide/svelte`: `ArrowRight`, with `size` and `strokeWidth`\\n- `heroicons:arrow-right` (24 outline) — `@heroicons/react/24/outline` or `@heroicons/vue/24/outline`: `ArrowRightIcon`\\n- `heroicons:arrow-right-solid`, `-20-solid`, `-16-solid` — `@heroicons/react/24/solid`, `/20/solid`, `/16/solid`: `ArrowRightIcon`\\n- `fa6-solid:house`, `fa6-regular:heart`, `fa6-brands:github` — `@fortawesome/react-fontawesome` (or `vue-fontawesome`) with `@fortawesome/free-solid-svg-icons`, `free-regular-svg-icons`, `free-brands-svg-icons`: `<FontAwesomeIcon icon={faHouse} />`\\n- `tabler:home` — `@tabler/icons-react`: `IconHome`\\n- `ph:house` — `@phosphor-icons/react`: `House` (`@phosphor-icons/vue`: `PhHouse`). A `-thin`, `-light`, `-bold`, `-fill`, or `-duotone` suffix is the `weight` prop on the base component, not part of its name: `ph:house-bold` → `<House weight=\\\"bold\\\" />`\\n- `radix-icons:home` — `@radix-ui/react-icons`: `HomeIcon`\\n- `mdi:home` — `@mdi/react` with `@mdi/js`: `<Icon path={mdiHome} />`\\n\\nReact Icons bundles many sets under one package, each behind a prefix: `lucide:` → `react-icons/lu` (`LuArrowRight`), `heroicons:` → `react-icons/hi2` (`HiOutlineArrowRight`, `HiArrowRight` for solid, `HiMiniArrowRight` for `-20-solid`, `HiMicroArrowRight` for `-16-solid`), `fa6-solid:` / `fa6-regular:` / `fa6-brands:` → `react-icons/fa6` (`FaHouse`, `FaRegHeart`, `FaGithub`), `tabler:` → `react-icons/tb` (`TbHome`), `ph:` → `react-icons/pi` (`PiHouse`, with the weight kept in the name: `PiHouseBold`, `PiHouseFill`), `ic:` → `react-icons/md` (`MdHome`), `bi:` → `react-icons/bs` (`BsHouse`), `ri:` → `react-icons/ri` (`RiHomeLine`), `feather:` → `react-icons/fi` (`FiHome`), `simple-icons:` → `react-icons/si` (`SiGithub`). Size with `size`, color with `color` or a text color class.\\n\\nRules:\\n\\n- Check that the export exists in the installed package version; sets rename icons between releases. When the name differs, pick the package's equivalent and say so.\\n- When the design's set has no package in the chosen library (an `mdi:` icon with Lucide chosen), do not silently swap in a different-looking icon. Use Iconify for that icon (`@iconify/react` or `@iconify/vue`, `<Icon icon=\\\"mdi:home\\\" />`) or export it with `export_svg`, and list it under deviations. Replace it with the chosen set's closest icon only when the user asks for one consistent set.\\n- With no package chosen, use the package that owns the design's set (`lucide:` → `lucide-react`), or Iconify when the design mixes sets.\\n- Import icons by name from the package (`import { ArrowRight } from 'lucide-react'`); never import a whole set.\\n\\n## Component file structure\\n\\n```\\ncomponents/\\n Button.tsx (or .vue, .svelte)\\n Card.tsx\\n Header.tsx\\n ...\\ntokens.css (semantic color tokens only, for Tailwind projects)\\npages/\\n HomePage.tsx (or routes, views — depends on framework)\\nassets/\\n icon-arrow.svg\\n icon-check.svg\\n```\\n\\nIn Next.js screens are routes and assets are public files:\\n\\n```\\napp/\\n layout.tsx (fonts, shared chrome, global styles)\\n globals.css (tokens)\\n page.tsx (home screen)\\n settings/\\n page.tsx\\ncomponents/\\n Button.tsx\\n ui/ (shadcn/ui components, when used)\\npublic/\\n hero.png\\n```\\n\\n## Common patterns\\n\\n**Auto-layout → Flexbox**\\n\\n- `layoutMode: HORIZONTAL` → `flex-direction: row`\\n- `layoutMode: VERTICAL` → `flex-direction: column`\\n- `itemSpacing` → `gap`\\n- `paddingTop/Right/Bottom/Left` → `padding`\\n- `primaryAxisAlign: CENTER` → `justify-content: center`\\n- `counterAxisAlign: CENTER` → `align-items: center`\\n- `layoutWrap: WRAP` → `flex-wrap: wrap`\\n- `primaryAxisSizing: HUG` / `counterAxisSizing: HUG` → no explicit size on that axis (content-sized)\\n\\n**Grid layout**\\n\\n- `layoutMode: GRID` → `display: grid`\\n- `gridTemplateColumns` → `grid-template-columns`\\n- `gridTemplateRows` → `grid-template-rows`\\n- `gridColumnGap/gridRowGap` → `column-gap/row-gap`\\n\\n**Sizing**\\n\\n- Fill lives on the child: `layoutGrow > 0` fills the parent's primary axis (`flex-grow: 1`), `layoutAlignSelf: STRETCH` fills the cross axis (`align-self: stretch`, no fixed size on that axis). In a grid, `layoutGrow` fills the cell's width and `STRETCH` its height.\\n- Fixed width/height only on axes that neither hug nor fill\\n\\n**Corner radius**\\n\\n- `independentCorners: true` → per-corner border-radius\\n- `cornerRadius` → uniform border-radius\\n\\n**Effects**\\n\\n- `DROP_SHADOW` → `box-shadow`\\n- `INNER_SHADOW` → `box-shadow: inset ...`\\n- `LAYER_BLUR` → `filter: blur(...)`\\n- `BACKGROUND_BLUR` → `backdrop-filter: blur(...)`\\n\\n**Text**\\n\\n- `fontFamily` → `font-family`\\n- `fontSize` → `font-size`\\n- `fontWeight` → `font-weight`\\n- `lineHeight` → `line-height` (null = normal/auto)\\n- `letterSpacing` → `letter-spacing`\\n- `textAlignHorizontal` → `text-align`\\n- `textAutoResize: WIDTH_AND_HEIGHT` → no explicit dimensions\\n- `textAutoResize: HEIGHT` → fixed width, auto height\\n- `textAutoResize: NONE` → fixed width and height\\n- `textDecoration` → `text-decoration`\\n- `textCase` → `text-transform`\\n\\n## Scene authoring reference\\n\\nThe appended reference applies when inspecting or editing Pairdraw scenes, not to the target frontend framework's API.\\n\""],"mappings":";AAAA,IAAA,kBAAe"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ToolDef } from "../schema.js";
|
|
2
|
+
//#region src/tools/read/css.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* A subtree as CSS-shaped lines: one line per node, lengths in px, colours in the document's
|
|
5
|
+
* profile with the token that binds them in `var(--name, …)` form: hex in an sRGB document,
|
|
6
|
+
* `color(display-p3 …)` in a Display P3 one. This is the read side of the CSS shorthand the
|
|
7
|
+
* setters accept, so a value read here can be written back unchanged.
|
|
8
|
+
*/
|
|
9
|
+
declare const DEFAULT_MAX_BYTES = 6000;
|
|
10
|
+
declare const HARD_MAX_BYTES = 20000;
|
|
11
|
+
declare const getCSS: ToolDef;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { DEFAULT_MAX_BYTES, HARD_MAX_BYTES, getCSS };
|
|
14
|
+
//# sourceMappingURL=css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.d.ts","names":[],"sources":["../../../src/tools/read/css.ts"],"mappings":";;;;;;;;cAca;cACA;cAmSA,QAAA"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { defineTool, nodeIdsField, toolNumber } from "../schema.js";
|
|
2
|
+
import { colorToDocumentCSS } from "@pairdraw/scene-graph/color";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
//#region src/tools/read/css.ts
|
|
5
|
+
/**
|
|
6
|
+
* A subtree as CSS-shaped lines: one line per node, lengths in px, colours in the document's
|
|
7
|
+
* profile with the token that binds them in `var(--name, …)` form: hex in an sRGB document,
|
|
8
|
+
* `color(display-p3 …)` in a Display P3 one. This is the read side of the CSS shorthand the
|
|
9
|
+
* setters accept, so a value read here can be written back unchanged.
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_MAX_BYTES = 6e3;
|
|
12
|
+
const HARD_MAX_BYTES = 2e4;
|
|
13
|
+
const AXIS_JUSTIFY = {
|
|
14
|
+
CENTER: "center",
|
|
15
|
+
MAX: "end",
|
|
16
|
+
SPACE_BETWEEN: "space-between",
|
|
17
|
+
SPACE_AROUND: "space-around"
|
|
18
|
+
};
|
|
19
|
+
const AXIS_ITEMS = {
|
|
20
|
+
CENTER: "center",
|
|
21
|
+
MAX: "end",
|
|
22
|
+
STRETCH: "stretch",
|
|
23
|
+
BASELINE: "baseline"
|
|
24
|
+
};
|
|
25
|
+
/** A length as CSS writes it: whole px where it is whole, up to two decimals otherwise. */
|
|
26
|
+
function px(value) {
|
|
27
|
+
return `${Math.round(value * 100) / 100}px`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The radius line, read the way `shape-details` reads corners: the per-corner fields while
|
|
31
|
+
* `independentCorners` is set (the uniform field is stale then), four values in CSS order when
|
|
32
|
+
* they differ, one otherwise. The four values write back through `set_radius`'s shorthand.
|
|
33
|
+
*/
|
|
34
|
+
function radiusOf(node) {
|
|
35
|
+
if (node.independentCorners) {
|
|
36
|
+
const corners = [
|
|
37
|
+
node.topLeftRadius,
|
|
38
|
+
node.topRightRadius,
|
|
39
|
+
node.bottomRightRadius,
|
|
40
|
+
node.bottomLeftRadius
|
|
41
|
+
];
|
|
42
|
+
if (corners.every((value) => value === corners[0])) return corners[0] > 0 ? px(corners[0]) : null;
|
|
43
|
+
return corners.map((value) => value === 0 ? "0" : px(value)).join(" ");
|
|
44
|
+
}
|
|
45
|
+
return node.cornerRadius > 0 ? px(node.cornerRadius) : null;
|
|
46
|
+
}
|
|
47
|
+
function box(value) {
|
|
48
|
+
return String(Math.round(value));
|
|
49
|
+
}
|
|
50
|
+
/** UTF-8 bytes without a Node Buffer, so the tool runs in the app as well as headless. */
|
|
51
|
+
function utf8Length(text) {
|
|
52
|
+
let bytes = 0;
|
|
53
|
+
for (let index = 0; index < text.length; index++) {
|
|
54
|
+
const code = text.charCodeAt(index);
|
|
55
|
+
if (code < 128) bytes += 1;
|
|
56
|
+
else if (code < 2048) bytes += 2;
|
|
57
|
+
else if (code < 55296 || code >= 57344) bytes += 3;
|
|
58
|
+
else bytes += 4;
|
|
59
|
+
}
|
|
60
|
+
return bytes;
|
|
61
|
+
}
|
|
62
|
+
function boundName(graph, node, field) {
|
|
63
|
+
const variableId = node.boundVariables[field];
|
|
64
|
+
if (!variableId) return null;
|
|
65
|
+
return graph.variables.get(variableId)?.name ?? null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A stored colour as the shorthand writes it: `#RRGGBB` in an sRGB document, `color(display-p3 …)`
|
|
69
|
+
* in a Display P3 one, where hex would name a different colour. The shorthand carries no alpha, as
|
|
70
|
+
* it never has, so the paint's opacity is left to `opacity`.
|
|
71
|
+
*/
|
|
72
|
+
function cssColor(color, profile) {
|
|
73
|
+
return colorToDocumentCSS({
|
|
74
|
+
...color,
|
|
75
|
+
a: 1
|
|
76
|
+
}, profile);
|
|
77
|
+
}
|
|
78
|
+
/** A colour in the document's profile, or `var(--token, …)` when a variable paints it. */
|
|
79
|
+
function paintOf(node, graph, field, paint) {
|
|
80
|
+
const name = boundName(graph, node, field);
|
|
81
|
+
return name ? `var(--${name}, ${paint})` : paint;
|
|
82
|
+
}
|
|
83
|
+
function background(node, graph) {
|
|
84
|
+
const index = node.fills.findIndex((candidate) => candidate.type === "SOLID" && candidate.visible);
|
|
85
|
+
const solid = index === -1 ? void 0 : node.fills[index];
|
|
86
|
+
if (solid) {
|
|
87
|
+
const paint = cssColor(solid.color, graph.documentColorSpace);
|
|
88
|
+
return paintOf(node, graph, `fills/${index}/color`, paint);
|
|
89
|
+
}
|
|
90
|
+
const otherIndex = node.fills.findIndex((candidate) => candidate.visible);
|
|
91
|
+
const other = otherIndex === -1 ? void 0 : node.fills[otherIndex];
|
|
92
|
+
if (!other) return null;
|
|
93
|
+
return other.type.startsWith("GRADIENT") ? "gradient" : "image";
|
|
94
|
+
}
|
|
95
|
+
function border(node, graph) {
|
|
96
|
+
const index = node.strokes.findIndex((candidate) => candidate.visible);
|
|
97
|
+
const stroke = index === -1 ? void 0 : node.strokes[index];
|
|
98
|
+
if (!stroke) return null;
|
|
99
|
+
const paint = cssColor(stroke.color, graph.documentColorSpace);
|
|
100
|
+
return `${px(stroke.weight)} ${paintOf(node, graph, `strokes/${index}/color`, paint)}`;
|
|
101
|
+
}
|
|
102
|
+
/** Padding in CSS order, compressed to the fewest values that say the same thing. */
|
|
103
|
+
function padding(node) {
|
|
104
|
+
const top = node.paddingTop;
|
|
105
|
+
const right = node.paddingRight;
|
|
106
|
+
const bottom = node.paddingBottom;
|
|
107
|
+
const left = node.paddingLeft;
|
|
108
|
+
if (top === 0 && right === 0 && bottom === 0 && left === 0) return null;
|
|
109
|
+
if (top === right && right === bottom && bottom === left) return px(top);
|
|
110
|
+
if (top === bottom && right === left) return `${px(top)} ${px(right)}`;
|
|
111
|
+
return `${px(top)} ${px(right)} ${px(bottom)} ${px(left)}`;
|
|
112
|
+
}
|
|
113
|
+
function shadowOf(prefix, effect, profile) {
|
|
114
|
+
return `${prefix}:${px(effect.offset.x)} ${px(effect.offset.y)} ${px(effect.radius)} ${cssColor(effect.color, profile)}`;
|
|
115
|
+
}
|
|
116
|
+
function effects(node, profile) {
|
|
117
|
+
const out = [];
|
|
118
|
+
for (const effect of node.effects) {
|
|
119
|
+
if (!effect.visible) continue;
|
|
120
|
+
if (effect.type === "DROP_SHADOW") out.push(shadowOf("shadow", effect, profile));
|
|
121
|
+
else if (effect.type === "INNER_SHADOW") out.push(shadowOf("inner-shadow", effect, profile));
|
|
122
|
+
else if (effect.type === "LAYER_BLUR" || effect.type === "FOREGROUND_BLUR") out.push(`blur:${px(effect.radius)}`);
|
|
123
|
+
else out.push("backdrop-blur");
|
|
124
|
+
}
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
function layoutDecls(node) {
|
|
128
|
+
if (node.layoutMode === "NONE") return [];
|
|
129
|
+
const out = [node.layoutMode === "HORIZONTAL" ? "flex:row" : "flex:column"];
|
|
130
|
+
if (node.itemSpacing > 0) out.push(node.layoutWrap === "WRAP" && node.counterAxisSpacing > 0 ? `gap:${px(node.itemSpacing)} ${px(node.counterAxisSpacing)}` : `gap:${px(node.itemSpacing)}`);
|
|
131
|
+
const paddingValue = padding(node);
|
|
132
|
+
if (paddingValue) out.push(`padding:${paddingValue}`);
|
|
133
|
+
const justify = AXIS_JUSTIFY[node.primaryAxisAlign];
|
|
134
|
+
if (justify) out.push(`justify:${justify}`);
|
|
135
|
+
const items = AXIS_ITEMS[node.counterAxisAlign];
|
|
136
|
+
if (items) out.push(`items:${items}`);
|
|
137
|
+
if (node.layoutWrap === "WRAP") out.push("wrap");
|
|
138
|
+
if (node.primaryAxisSizing === "HUG") out.push("hug:main");
|
|
139
|
+
if (node.counterAxisSizing === "HUG") out.push("hug:cross");
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
function boxDecls(node, graph) {
|
|
143
|
+
const out = [];
|
|
144
|
+
if (node.layoutAlignSelf === "STRETCH") out.push("stretch");
|
|
145
|
+
if (node.layoutGrow > 0) out.push(`grow:${Math.round(node.layoutGrow * 100) / 100}`);
|
|
146
|
+
const bg = background(node, graph);
|
|
147
|
+
if (bg) out.push(`bg:${bg}`);
|
|
148
|
+
const stroke = border(node, graph);
|
|
149
|
+
if (stroke) out.push(`border:${stroke}`);
|
|
150
|
+
const radius = radiusOf(node);
|
|
151
|
+
if (radius) out.push(`radius:${radius}`);
|
|
152
|
+
if (node.minWidth !== null) out.push(`min-w:${px(node.minWidth)}`);
|
|
153
|
+
if (node.maxWidth !== null) out.push(`max-w:${px(node.maxWidth)}`);
|
|
154
|
+
if (node.minHeight !== null) out.push(`min-h:${px(node.minHeight)}`);
|
|
155
|
+
if (node.maxHeight !== null) out.push(`max-h:${px(node.maxHeight)}`);
|
|
156
|
+
out.push(...effects(node, graph.documentColorSpace));
|
|
157
|
+
if (node.opacity !== 1) out.push(`opacity:${Math.round(node.opacity * 100) / 100}`);
|
|
158
|
+
if (node.clipsContent) out.push("clip");
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
function lineHeightOf(node) {
|
|
162
|
+
const lineHeight = node.lineHeight;
|
|
163
|
+
if (!lineHeight) return "auto";
|
|
164
|
+
return lineHeight.unit === "PERCENT" ? `${Math.round(lineHeight.value * 100) / 100}%` : px(lineHeight.value);
|
|
165
|
+
}
|
|
166
|
+
function textDecls(node, graph) {
|
|
167
|
+
const out = [`font:${node.fontWeight} ${px(node.fontSize)}/${lineHeightOf(node)} ${node.fontFamily}`];
|
|
168
|
+
const bg = background(node, graph);
|
|
169
|
+
if (bg) out.push(`color:${bg}`);
|
|
170
|
+
if (node.textAlignHorizontal !== "LEFT") out.push(`text-align:${node.textAlignHorizontal.toLowerCase()}`);
|
|
171
|
+
if (node.maxLines !== null && node.maxLines > 0) out.push(`max-lines:${node.maxLines}`);
|
|
172
|
+
if (node.textAutoResize === "NONE") out.push("fixed");
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
function lineOf(node, graph) {
|
|
176
|
+
const decls = node.type === "TEXT" ? textDecls(node, graph) : [...layoutDecls(node), ...boxDecls(node, graph)];
|
|
177
|
+
const label = node.type === "TEXT" ? `"${node.text.slice(0, 40).replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("\n", "\\n")}"` : node.name;
|
|
178
|
+
const body = decls.length > 0 ? ` {${decls.join(";")}}` : "";
|
|
179
|
+
return `${label}#${node.id} ${box(node.width)}×${box(node.height)}${body}`;
|
|
180
|
+
}
|
|
181
|
+
/** What a cut-off walk left out, counted through the same visible-node rule as the lines. */
|
|
182
|
+
function countVisible(graph, nodeId) {
|
|
183
|
+
const node = graph.getNode(nodeId);
|
|
184
|
+
if (!node || !node.visible) return 0;
|
|
185
|
+
let count = 1;
|
|
186
|
+
for (const childId of node.childIds) count += countVisible(graph, childId);
|
|
187
|
+
return count;
|
|
188
|
+
}
|
|
189
|
+
function truncationTail(omitted) {
|
|
190
|
+
return `… +${omitted} node${omitted === 1 ? "" : "s"} (raise max_bytes or narrow with depth)`;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Depth-first lines until the budget is spent. A line that does not fit ends the walk; the kept
|
|
194
|
+
* lines never exceed the limit on their own, so the reply can always stay within `max_bytes`.
|
|
195
|
+
*/
|
|
196
|
+
function collect(graph, nodeId, depth, indent, lines, budget) {
|
|
197
|
+
const node = graph.getNode(nodeId);
|
|
198
|
+
if (!node || !node.visible) return;
|
|
199
|
+
if (budget.truncated) return;
|
|
200
|
+
const line = `${indent}${lineOf(node, graph)}`;
|
|
201
|
+
if (!(budget.bytes + utf8Length(line) + 1 <= budget.limit)) {
|
|
202
|
+
budget.truncated = true;
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
budget.bytes += utf8Length(line) + 1;
|
|
206
|
+
lines.push(line);
|
|
207
|
+
if (depth > 0) for (const childId of node.childIds) collect(graph, childId, depth - 1, `${indent} `, lines, budget);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* A subtree within `maxBytes`. The truncation tail is charged to the same budget: trailing lines
|
|
211
|
+
* give way first, then the tail is left out when only the kept lines fit. A block whose first line
|
|
212
|
+
* does not fit returns no CSS at all; the reply's `truncated`/`omitted` fields report the cut.
|
|
213
|
+
*/
|
|
214
|
+
function blockFor(graph, nodeId, depth, maxBytes) {
|
|
215
|
+
const lines = [];
|
|
216
|
+
const budget = {
|
|
217
|
+
bytes: 0,
|
|
218
|
+
limit: maxBytes,
|
|
219
|
+
truncated: false
|
|
220
|
+
};
|
|
221
|
+
collect(graph, nodeId, depth, "", lines, budget);
|
|
222
|
+
if (!budget.truncated) return { css: lines.join("\n") };
|
|
223
|
+
let omitted = countVisible(graph, nodeId) - lines.length;
|
|
224
|
+
while (lines.length > 1 && budget.bytes + 1 + utf8Length(truncationTail(omitted)) > budget.limit) {
|
|
225
|
+
const last = lines.pop();
|
|
226
|
+
if (last === void 0) break;
|
|
227
|
+
budget.bytes -= utf8Length(last) + 1;
|
|
228
|
+
omitted = countVisible(graph, nodeId) - lines.length;
|
|
229
|
+
}
|
|
230
|
+
if (lines.length === 0) return {
|
|
231
|
+
css: "",
|
|
232
|
+
truncated: true,
|
|
233
|
+
omitted: countVisible(graph, nodeId)
|
|
234
|
+
};
|
|
235
|
+
const head = lines.join("\n");
|
|
236
|
+
if (budget.bytes + 1 + utf8Length(truncationTail(omitted)) > budget.limit) return {
|
|
237
|
+
css: head,
|
|
238
|
+
truncated: true,
|
|
239
|
+
omitted
|
|
240
|
+
};
|
|
241
|
+
return {
|
|
242
|
+
css: `${head}\n${truncationTail(omitted)}`,
|
|
243
|
+
truncated: true,
|
|
244
|
+
omitted
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
const getCSS = defineTool({
|
|
248
|
+
name: "get_css",
|
|
249
|
+
description: "Read a node subtree as compact CSS-like lines: `Name#id W×H {flex:row;gap:12px;padding:16px 24px;bg:var(--color/brand, #4F46E5);radius:8px}`. Lengths are px; short names: flex (implies display:flex), gap, padding, justify, items, wrap, hug, stretch, grow, bg, border, radius, min/max-w/h, shadow, blur, opacity, clip; text: `font:600 14px/20px Inter`, color, text-align, max-lines. Colours follow the document's profile, as get_jsx writes them: `#RRGGBB` in an sRGB document, `color(display-p3 r g b)` in a Display P3 one, and either inside the `var()` fallback. Use it for geometry and style; describe gives roles and design issues. The setters accept the same shorthand (padding/gap/radius strings, `var(--token)` colours).",
|
|
250
|
+
execution: {
|
|
251
|
+
kind: "sync",
|
|
252
|
+
mutation: "none"
|
|
253
|
+
},
|
|
254
|
+
input: v.strictObject({
|
|
255
|
+
id: v.optional(v.pipe(v.string(), v.description("Node ID (single node)"))),
|
|
256
|
+
ids: nodeIdsField("Node IDs (several nodes in one call)"),
|
|
257
|
+
depth: v.optional(toolNumber(v.pipe(v.number(), v.description("Child levels to include (default: as many as the budget holds)")))),
|
|
258
|
+
max_bytes: v.optional(toolNumber(v.pipe(v.number(), v.description("Byte budget for the reply (default 6000, max 20000)"))))
|
|
259
|
+
}),
|
|
260
|
+
execute: (figma, args) => {
|
|
261
|
+
const maxBytes = Math.min(args.max_bytes ?? 6e3, HARD_MAX_BYTES);
|
|
262
|
+
const depth = args.depth ?? 100;
|
|
263
|
+
if (args.ids && Array.isArray(args.ids)) {
|
|
264
|
+
const blocks = [];
|
|
265
|
+
let omitted = 0;
|
|
266
|
+
let truncated = false;
|
|
267
|
+
let used = 0;
|
|
268
|
+
for (const nodeId of args.ids) {
|
|
269
|
+
if (!figma.graph.getNode(nodeId)) return { error: `Node "${nodeId}" not found` };
|
|
270
|
+
const separator = blocks.length === 0 ? 0 : 1;
|
|
271
|
+
const block = blockFor(figma.graph, nodeId, depth, maxBytes - used - separator);
|
|
272
|
+
if (block.css === "") {
|
|
273
|
+
omitted += block.omitted ?? 0;
|
|
274
|
+
truncated = truncated || block.truncated === true;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
blocks.push(block.css);
|
|
278
|
+
used += utf8Length(block.css) + separator;
|
|
279
|
+
omitted += block.omitted ?? 0;
|
|
280
|
+
truncated = truncated || block.truncated === true;
|
|
281
|
+
}
|
|
282
|
+
const css = blocks.join("\n");
|
|
283
|
+
if (!truncated) return {
|
|
284
|
+
ids: args.ids,
|
|
285
|
+
css
|
|
286
|
+
};
|
|
287
|
+
return {
|
|
288
|
+
ids: args.ids,
|
|
289
|
+
css,
|
|
290
|
+
truncated: true,
|
|
291
|
+
omitted
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
if (!args.id) return { error: "Provide id (string) or ids (string[])" };
|
|
295
|
+
if (!figma.graph.getNode(args.id)) return { error: `Node "${args.id}" not found` };
|
|
296
|
+
const block = blockFor(figma.graph, args.id, depth, maxBytes);
|
|
297
|
+
return {
|
|
298
|
+
id: args.id,
|
|
299
|
+
...block
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
//#endregion
|
|
304
|
+
export { DEFAULT_MAX_BYTES, HARD_MAX_BYTES, getCSS };
|
|
305
|
+
|
|
306
|
+
//# sourceMappingURL=css.js.map
|