@pairdraw/core 0.19.2 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +43 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +161 -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 +73 -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/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -0
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +13 -1
- 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/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/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 +22 -2
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +29 -1
- 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 +41 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +100 -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/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/assets.js +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/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.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 +27 -3
- 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 +168 -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 +6 -0
- 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/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/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/index.d.ts +5 -0
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +6 -1
- 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/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +1 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +41 -13
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +113 -31
- 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/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/decode.js +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/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.map +1 -1
- 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/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/label.js +1 -1
- package/dist/io/formats/drawio/paint.js +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +5 -0
- package/dist/io/formats/fig/export/patch/index.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 +3 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/styles.js +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/prepare.d.ts +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 +31 -3
- 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/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.map +1 -1
- package/dist/io/formats/raster/render.js +4 -0
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +5 -6
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +1 -53
- 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 +7 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +174 -36
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +27 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +44 -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/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/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 +6 -3
- 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 +40 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/types.d.ts +19 -4
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +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.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +2 -1
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +9 -3
- 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 +110 -8
- 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/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 +45 -1
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +55 -2
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +12 -1
- 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/read-commands.js +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/index.d.ts +10 -8
- package/dist/text/index.js +3 -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/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +203 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze.d.ts +2 -1
- package/dist/tools/analyze.js +2 -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.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/create/basic.js +1 -1
- package/dist/tools/create/behaviours.js +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.js +3 -2
- 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 +2 -1
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +2 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.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/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -1
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +2 -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/paint.js +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +3 -3
- 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 +26 -5
- 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/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 +2 -1
- package/dist/tools/read/libraries.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 -3
- package/dist/tools/read/space.js.map +1 -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 +3 -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 +18 -2
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +1 -1
- package/dist/tools/schema.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/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.js +1 -0
- 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 +19 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +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 +161 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +94 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/renderer/lifecycle.ts +6 -0
- package/src/canvas/renderer/pipeline.ts +19 -1
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/types.ts +18 -2
- package/src/canvas/renderer.ts +40 -3
- package/src/canvas/scene.ts +65 -9
- package/src/canvas/texture.ts +136 -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/export.ts +24 -7
- package/src/editor/components/instances.ts +31 -0
- 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 +198 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +29 -1
- 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/tool-registry.ts +2 -1
- package/src/editor/types.ts +4 -0
- 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/index.ts +10 -0
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/proxy.ts +6 -1
- package/src/figma-api/reactions.ts +130 -32
- package/src/figma-api/surface.ts +6 -2
- package/src/global.d.ts +26 -0
- package/src/io/formats/boolean-path.ts +60 -0
- 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/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +10 -2
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +587 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- 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/fig/export/patch/index.ts +8 -0
- 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 +8 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +36 -5
- 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 +12 -1
- package/src/io/formats/svg/defs.ts +4 -72
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +278 -46
- package/src/io/formats/svg/filter.ts +47 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/layout.ts +13 -3
- 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 +59 -11
- package/src/io/types.ts +29 -10
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout.ts +2 -0
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +107 -10
- 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/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +81 -0
- 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/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +79 -1
- package/src/text/index.ts +2 -0
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +264 -0
- package/src/tools/analyze.ts +2 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen.ts +1 -0
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -0
- package/src/tools/create/icons.ts +1 -0
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +1 -0
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/reactions.ts +15 -8
- package/src/tools/modify/text.ts +42 -5
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/space.ts +3 -2
- package/src/tools/registry/core.ts +3 -1
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +28 -4
- 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/vector/boolean.ts +4 -0
- package/src/tools/vector/vectorize.ts +1 -0
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +18 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findEmptySpaceTool } from "../read/space.js";
|
|
1
2
|
import { analyzeOverlaps } from "../analyze/overlaps/index.js";
|
|
2
3
|
import { designToTokens, importDesignTokens } from "../codegen/tokens.js";
|
|
3
4
|
import { analyzeClusters } from "../analyze/clusters.js";
|
|
@@ -8,6 +9,7 @@ import { lint, lintFix } from "../analyze/lint.js";
|
|
|
8
9
|
import { analyzeSpacing } from "../analyze/spacing.js";
|
|
9
10
|
import { analyzeTypography } from "../analyze/typography.js";
|
|
10
11
|
import { designToComponentMap } from "../codegen/component-map.js";
|
|
12
|
+
import { syncTokens, tokenDrift } from "../codegen/token-sync.js";
|
|
11
13
|
import { addComment, getComments, replyToComment, resolveComment } from "../comments.js";
|
|
12
14
|
import { createPage, createShape, createSlice } from "../create/basic.js";
|
|
13
15
|
import { createSlot, getBehaviour, setBehaviour } from "../create/behaviours.js";
|
|
@@ -16,13 +18,14 @@ import { fetchIconsTool, insertIcon, searchIconsTool } from "../create/icons.js"
|
|
|
16
18
|
import { script } from "../create/script.js";
|
|
17
19
|
import { importMermaid } from "../create/mermaid.js";
|
|
18
20
|
import { importSVG } from "../create/svg.js";
|
|
19
|
-
import { findEmptySpaceTool } from "../read/space.js";
|
|
20
21
|
import { importHTML } from "../create/html.js";
|
|
21
22
|
import { createVector } from "../create/vector.js";
|
|
22
23
|
import { createConnectorTool } from "../create/connector.js";
|
|
24
|
+
import { checkDesignValuesTool, getDesignMemory, recordDesignDecisionTool } from "../design-memory.js";
|
|
23
25
|
import { removeBackground, replaceBackground } from "../image-ai/background.js";
|
|
24
26
|
import { generateImage, generateSVG } from "../image-ai/generate.js";
|
|
25
27
|
import { setEffects } from "../modify/effects.js";
|
|
28
|
+
import { replaceFonts } from "../modify/fonts.js";
|
|
26
29
|
import { rescale, setMinMax, setOpacity, setRotation } from "../modify/geometry.js";
|
|
27
30
|
import { setConstraints } from "../modify/layout.js";
|
|
28
31
|
import { setFont, setFontRange, setTextResize } from "../modify/text.js";
|
|
@@ -43,9 +46,11 @@ import { flattenNodes, groupNodes, nodeToComponent, ungroupNode } from "../struc
|
|
|
43
46
|
import { nodeAncestors, nodeBindings, nodeChildren, nodeTree } from "../structure/tree.js";
|
|
44
47
|
import { nodeReplaceWith } from "../structure/replace.js";
|
|
45
48
|
import { arrangeNodes } from "../structure/arrange.js";
|
|
49
|
+
import { createVariationsTool, listVariations, pickVariation } from "../structure/variations.js";
|
|
46
50
|
import { booleanExclude, booleanIntersect, booleanSubtract, booleanUnion } from "../vector/boolean.js";
|
|
47
51
|
import { pathFlip, pathGet, pathMove, pathScale, pathSet } from "../vector/path.js";
|
|
48
52
|
import { viewportGet, viewportSet } from "../vector/viewport.js";
|
|
53
|
+
import { exportVideo } from "../vector/video.js";
|
|
49
54
|
import { vectorizeImage } from "../vector/vectorize.js";
|
|
50
55
|
import { getStatuses, setStatus } from "../statuses.js";
|
|
51
56
|
import { getStyle } from "../styles/get.js";
|
|
@@ -78,6 +83,9 @@ const EXTENDED_TOOLS = [
|
|
|
78
83
|
resolveComment,
|
|
79
84
|
getStatuses,
|
|
80
85
|
setStatus,
|
|
86
|
+
getDesignMemory,
|
|
87
|
+
checkDesignValuesTool,
|
|
88
|
+
recordDesignDecisionTool,
|
|
81
89
|
getFontStatus,
|
|
82
90
|
listFonts,
|
|
83
91
|
listAvailableFonts,
|
|
@@ -115,6 +123,7 @@ const EXTENDED_TOOLS = [
|
|
|
115
123
|
setMinMax,
|
|
116
124
|
setFontRange,
|
|
117
125
|
setTextResize,
|
|
126
|
+
replaceFonts,
|
|
118
127
|
setBlend,
|
|
119
128
|
setLocked,
|
|
120
129
|
setStrokeAlign,
|
|
@@ -135,6 +144,9 @@ const EXTENDED_TOOLS = [
|
|
|
135
144
|
nodeBindings,
|
|
136
145
|
nodeReplaceWith,
|
|
137
146
|
arrangeNodes,
|
|
147
|
+
createVariationsTool,
|
|
148
|
+
listVariations,
|
|
149
|
+
pickVariation,
|
|
138
150
|
listVariables,
|
|
139
151
|
listCollections,
|
|
140
152
|
getVariable,
|
|
@@ -162,6 +174,7 @@ const EXTENDED_TOOLS = [
|
|
|
162
174
|
exportSVG,
|
|
163
175
|
exportPDF,
|
|
164
176
|
exportImage,
|
|
177
|
+
exportVideo,
|
|
165
178
|
exportHTML,
|
|
166
179
|
analyzeColors,
|
|
167
180
|
analyzeTypography,
|
|
@@ -175,6 +188,8 @@ const EXTENDED_TOOLS = [
|
|
|
175
188
|
script,
|
|
176
189
|
designToTokens,
|
|
177
190
|
importDesignTokens,
|
|
191
|
+
tokenDrift,
|
|
192
|
+
syncTokens,
|
|
178
193
|
designToComponentMap
|
|
179
194
|
];
|
|
180
195
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extended.js","names":[],"sources":["../../../src/tools/registry/extended.ts"],"sourcesContent":["import {\n analyzeClusters,\n analyzeColors,\n analyzeOverlaps,\n analyzeSpacing,\n analyzeTypography,\n diffApply,\n diffShow,\n lint,\n lintFix\n} from '#core/tools/analyze'\nimport {
|
|
1
|
+
{"version":3,"file":"extended.js","names":[],"sources":["../../../src/tools/registry/extended.ts"],"sourcesContent":["import {\n analyzeClusters,\n analyzeColors,\n analyzeOverlaps,\n analyzeSpacing,\n analyzeTypography,\n diffApply,\n diffShow,\n lint,\n lintFix\n} from '#core/tools/analyze'\nimport {\n designToComponentMap,\n designToTokens,\n importDesignTokens,\n syncTokens,\n tokenDrift\n} from '#core/tools/codegen'\nimport { addComment, getComments, replyToComment, resolveComment } from '#core/tools/comments'\nimport {\n createComponent,\n createInstance,\n createPage,\n createConnectorTool,\n createShape,\n createSlice,\n createVector,\n detachInstance,\n exposeInstanceSwap,\n combineAsVariants,\n createSlot,\n fetchIconsTool,\n getBehaviour,\n importHTML,\n importMermaid,\n importSVG,\n insertIcon,\n script,\n searchIconsTool,\n setBehaviour\n} from '#core/tools/create'\nimport {\n checkDesignValuesTool,\n getDesignMemory,\n recordDesignDecisionTool\n} from '#core/tools/design-memory'\nimport {\n generateImage,\n generateSVG,\n removeBackground,\n replaceBackground\n} from '#core/tools/image-ai'\nimport {\n replaceFonts,\n setBlend,\n setConstraints,\n setEffects,\n setFont,\n setFontRange,\n setImageFill,\n setLocked,\n setMinMax,\n replaceMatchingProperties,\n rescale,\n setOpacity,\n setReactions,\n setRotation,\n setStrokeAlign,\n setTextResize,\n setVisible\n} from '#core/tools/modify'\nimport {\n findEmptySpaceTool,\n getComponents,\n getCurrentPage,\n getFontStatus,\n getPageTree,\n getReactions,\n insertLibraryComponent,\n listAvailableFonts,\n listFonts,\n listLibraries,\n listPages,\n pageBounds,\n queryNodes,\n selectNodes,\n switchPage\n} from '#core/tools/read'\nimport type { ToolDef } from '#core/tools/schema'\nimport { getStatuses, setStatus } from '#core/tools/statuses'\nimport {\n arrangeNodes,\n cloneNode,\n createVariationsTool,\n flattenNodes,\n groupNodes,\n listVariations,\n nodeAncestors,\n nodeBindings,\n nodeBounds,\n nodeChildren,\n nodeMove,\n nodeReplaceWith,\n nodeToComponent,\n nodeTree,\n pickVariation,\n renameNode,\n ungroupNode\n} from '#core/tools/structure'\nimport { getStyle } from '#core/tools/styles'\nimport {\n bindVariable,\n createCollection,\n createVariable,\n deleteCollection,\n deleteVariable,\n findVariables,\n getCollection,\n getVariable,\n listCollections,\n listVariables,\n setVariable,\n unbindVariable\n} from '#core/tools/variables'\nimport {\n booleanExclude,\n booleanIntersect,\n booleanSubtract,\n booleanUnion,\n exportHTML,\n exportImage,\n exportPDF,\n exportSVG,\n exportVideo,\n pathFlip,\n pathGet,\n pathMove,\n pathScale,\n pathSet,\n vectorizeImage,\n viewportGet,\n viewportSet\n} from '#core/tools/vector'\n\n/**\n * Extended tools not in CORE_TOOLS — variables, vector ops, analysis,\n * codegen, advanced structure, path manipulation, etc.\n */\nexport const EXTENDED_TOOLS: ToolDef[] = [\n // Read (advanced)\n getPageTree,\n getReactions,\n getCurrentPage,\n listPages,\n selectNodes,\n queryNodes,\n getComponents,\n listLibraries,\n insertLibraryComponent,\n switchPage,\n pageBounds,\n findEmptySpaceTool,\n getComments,\n addComment,\n replyToComment,\n resolveComment,\n getStatuses,\n setStatus,\n getDesignMemory,\n checkDesignValuesTool,\n recordDesignDecisionTool,\n getFontStatus,\n listFonts,\n listAvailableFonts,\n // Style directions\n getStyle,\n // Create (advanced)\n createShape,\n searchIconsTool,\n insertIcon,\n fetchIconsTool,\n combineAsVariants,\n createComponent,\n createInstance,\n detachInstance,\n exposeInstanceSwap,\n createSlot,\n getBehaviour,\n setBehaviour,\n createPage,\n createVector,\n createSlice,\n createConnectorTool,\n importSVG,\n importMermaid,\n importHTML,\n // Image AI, run on the services the user set up in the app\n generateImage,\n generateSVG,\n removeBackground,\n replaceBackground,\n // Modify (advanced)\n setEffects,\n setReactions,\n setOpacity,\n setFont,\n setVisible,\n setConstraints,\n setRotation,\n setMinMax,\n setFontRange,\n setTextResize,\n replaceFonts,\n setBlend,\n setLocked,\n setStrokeAlign,\n setImageFill,\n replaceMatchingProperties,\n rescale,\n // Structure (advanced)\n cloneNode,\n nodeMove,\n renameNode,\n groupNodes,\n ungroupNode,\n flattenNodes,\n nodeToComponent,\n nodeBounds,\n nodeAncestors,\n nodeChildren,\n nodeTree,\n nodeBindings,\n nodeReplaceWith,\n arrangeNodes,\n // Variations: versions of a layer side by side, one of which can replace it\n createVariationsTool,\n listVariations,\n pickVariation,\n // Variables\n listVariables,\n listCollections,\n getVariable,\n findVariables,\n createVariable,\n setVariable,\n deleteVariable,\n bindVariable,\n unbindVariable,\n getCollection,\n createCollection,\n deleteCollection,\n // Vector & export\n booleanUnion,\n booleanSubtract,\n booleanIntersect,\n booleanExclude,\n pathGet,\n pathSet,\n pathScale,\n pathFlip,\n pathMove,\n vectorizeImage,\n viewportGet,\n viewportSet,\n exportSVG,\n exportPDF,\n exportImage,\n exportVideo,\n exportHTML,\n // Analyze & diff\n analyzeColors,\n analyzeTypography,\n lint,\n lintFix,\n analyzeSpacing,\n analyzeClusters,\n analyzeOverlaps,\n diffShow,\n diffApply,\n // Code on canvas\n script,\n // Codegen\n designToTokens,\n importDesignTokens,\n tokenDrift,\n syncTokens,\n designToComponentMap\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoJA,MAAa,iBAA4B;CAEvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CAEA;CACA;CACA;CACA;CACA;AACF"}
|
package/dist/tools/schema.d.ts
CHANGED
|
@@ -12,6 +12,11 @@ type ToolExecution = {
|
|
|
12
12
|
} | {
|
|
13
13
|
kind: 'async';
|
|
14
14
|
mutation: 'none' | 'view' | 'document';
|
|
15
|
+
/**
|
|
16
|
+
* The call can run for a long time even when it only reads, such as recording a video, so
|
|
17
|
+
* bridges give it the deadline they give an edit.
|
|
18
|
+
*/
|
|
19
|
+
long?: boolean;
|
|
15
20
|
};
|
|
16
21
|
type ToolInterface = 'mcp' | 'ai' | 'webmcp';
|
|
17
22
|
type ToolExposure = Partial<Record<ToolInterface, boolean>>;
|
|
@@ -23,6 +28,16 @@ interface ToolMetadata {
|
|
|
23
28
|
exposure: ToolExposure;
|
|
24
29
|
capabilities: readonly ToolCapability[];
|
|
25
30
|
availability: 'default' | 'eval';
|
|
31
|
+
/**
|
|
32
|
+
* What a call's values come from, for the document's design memory:
|
|
33
|
+
* - `imported`: outside content, such as a web page, an SVG, a photo or a library component,
|
|
34
|
+
* whose colors and type are its own, so the memory warns about them rather than refusing;
|
|
35
|
+
* - `copied`: the layers the call names, which it copies or converts with their values, such
|
|
36
|
+
* as a clone, a group or a boolean, so values those layers already had are not new.
|
|
37
|
+
* - `merged`: layers the call joins into one, which may take a paint from any of them, such as
|
|
38
|
+
* flatten and boolean operations; a value is only theirs when every named layer had it.
|
|
39
|
+
*/
|
|
40
|
+
content?: 'imported' | 'copied' | 'merged';
|
|
26
41
|
}
|
|
27
42
|
interface ToolDef extends ToolMetadata {
|
|
28
43
|
input: v.StrictObjectSchema<v.ObjectEntries, undefined>;
|
|
@@ -34,7 +49,8 @@ interface ToolDef extends ToolMetadata {
|
|
|
34
49
|
* synchronous tool still edits in one step.
|
|
35
50
|
*/
|
|
36
51
|
loadFonts: (figma: FigmaAPI, args: Record<string, unknown>) => Promise<void>;
|
|
37
|
-
|
|
52
|
+
/** `signal` aborts a caller's cancelled request, which a long export checks while it runs. */
|
|
53
|
+
execute: (figma: FigmaAPI, args: Record<string, unknown>, signal?: AbortSignal) => unknown;
|
|
38
54
|
/**
|
|
39
55
|
* The synchronous answer of a read whose `execute` may load a page first, or `undefined`
|
|
40
56
|
* when answering would load. Hosts that cannot wait refuse on `undefined` before any load.
|
|
@@ -49,7 +65,7 @@ declare function defineTool<P extends v.ObjectEntries, R>(def: ToolDefinitionMet
|
|
|
49
65
|
} : unknown);
|
|
50
66
|
/** The fonts a call's text edits need loaded first; text edits refuse unloaded fonts. */
|
|
51
67
|
fonts?: (figma: FigmaAPI, args: v.InferOutput<v.StrictObjectSchema<P, undefined>>) => FigmaFontNameInput[];
|
|
52
|
-
execute: (figma: FigmaAPI, args: v.InferOutput<v.StrictObjectSchema<P, undefined
|
|
68
|
+
execute: (figma: FigmaAPI, args: v.InferOutput<v.StrictObjectSchema<P, undefined>>, signal?: AbortSignal) => R;
|
|
53
69
|
executeSync?: (figma: FigmaAPI, args: v.InferOutput<v.StrictObjectSchema<P, undefined>>) => unknown;
|
|
54
70
|
}): ToolDef;
|
|
55
71
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/tools/schema.ts"],"mappings":";;;;;;;KAgBY;KAUA;EACN;EAAc;;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/tools/schema.ts"],"mappings":";;;;;;;KAgBY;KAUA;EACN;EAAc;;EAEd;EACA;;;;;EAKA;;KAGM;KACA,eAAe,QAAQ,OAAO;UAEhC;EACR;EACA;EACA,WAAW;;EAEX,UAAU;EACV,uBAAuB;EACvB;;;;;;;;;;EAUA;;UAGe,gBAAgB;EAC/B,OAAO,EAAE,mBAAmB,EAAE;;WAErB;;;;;;EAMT,YAAY,OAAO,UAAU,MAAM,4BAA4B;;EAE/D,UAAU,OAAO,UAAU,MAAM,yBAAyB,SAAS;;;;;EAKnE,eAAe,OAAO,UAAU,MAAM;;KAGnC,yBAAyB,KAAK,8DACjC,QAAQ,KAAK;iBAEC,WAAW,UAAU,EAAE,eAAe,GACpD,KAAK;EACH,OAAO,EAAE,mBAAmB;EAC5B,WAAW,iBAAiB,UAAU;IAAyB;;;EAE/D,SACE,OAAO,UACP,MAAM,EAAE,YAAY,EAAE,mBAAmB,mBACtC;EACL,UACE,OAAO,UACP,MAAM,EAAE,YAAY,EAAE,mBAAmB,gBACzC,SAAS,gBACN;EACL,eACE,OAAO,UACP,MAAM,EAAE,YAAY,EAAE,mBAAmB;IAG5C;;;;;;;;iBAkCa,cAAc,UAAU,EAAE,eACxC,cACA,QAAQ,GACR,gBACC,EAAE,YAAY;iBA6HD,oBAAoB,KAAK,KAAK;iBAI9B,cAAc,KAAK,KAAK,sBAAsB,QAAQ;iBAItD,aAAa,KAAK;cAIrB,0BAA0B;EACzB,YAAA;;iBAME,YAAY,OAAO,UAAU,aAAa,WAAW;iBAMrD,aAAa,OAAO,UAAU,KAAK,wBAAwB;;iBAW3D,YAAY;EAAmB;;iBAI/B,aAAa;EAAe;;iBAI5B,kBACd,OAAO,UACP;EACG,MAAM;;EAAgB;;iBAKX,aAAa,MAAM,gBAAgB,oBAAoB;iBAIvD,YAAY,MAAM;EAAmB;EAAY;EAAc;;;;;;;iBAS/D,eAAe,gBAAgB;EAAU;;;;;;iBAYzC,uBACd;EACG,OAAO;;EAAwB;;cAOvB,mBAAiB,EAAA,yBAAA,EAAA,yBAAA,EAAA;cACjB,iBAAe,EAAA;;;cACf,2BAAyB,EAAA;;;;iBAKtB,mBAAmB,2BAAwB,EAAA;;;;cAM9C;;;;;iBAMG,WAAW,SAAQ,EAAE,gCAA0C,EAAA,aAAA,EAAA,yBAAA,EAAA,+BAAA,EAAA,2CAAA,EAAA,6CAAA,EAAA,yBAAA,EAAA,yBAAA,EAAA,2DAAA,EAAA,mCAAA,EAAA,8BAAA,EAAA,yBAAA,EAAA,+BAAA,EAAA,2CAAA,EAAA"}
|
package/dist/tools/schema.js
CHANGED
|
@@ -23,7 +23,7 @@ function defineTool(def) {
|
|
|
23
23
|
if (!parsed.success) return;
|
|
24
24
|
for (const font of fonts(figma, parsed.output)) await figma.loadFontAsync(font);
|
|
25
25
|
},
|
|
26
|
-
execute: (figma, args) => def.execute(figma, parseToolArgs(def.name, def.input, args)),
|
|
26
|
+
execute: (figma, args, signal) => def.execute(figma, parseToolArgs(def.name, def.input, args), signal),
|
|
27
27
|
executeSync: def.executeSync ? (figma, args) => def.executeSync?.(figma, parseToolArgs(def.name, def.input, args)) : void 0
|
|
28
28
|
};
|
|
29
29
|
}
|
package/dist/tools/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":[],"sources":["../../src/tools/schema.ts"],"sourcesContent":["/**\n * Tool definition schema.\n *\n * Native Valibot inputs and execution capabilities are owned by each tool.\n * Adapters consume these contracts rather than maintaining transport-specific schemas.\n */\n\nimport * as v from 'valibot'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { tryParseColor } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api'\nimport type { FigmaFontNameInput } from '#core/figma-api/fonts/names'\n\nexport type ToolCapability =\n | 'document:read'\n | 'document:write'\n | 'filesystem:read'\n | 'filesystem:write'\n | 'network:access'\n | 'code:execute'\n | 'settings:read'\n | 'settings:write'\n\nexport type ToolExecution =\n | { kind: 'sync'; mutation: 'none' | 'view' | 'properties' | 'document' }\n | { kind: 'async'; mutation: 'none' | 'view' | 'document' }\n\nexport type ToolInterface = 'mcp' | 'ai' | 'webmcp'\nexport type ToolExposure = Partial<Record<ToolInterface, boolean>>\n\ninterface ToolMetadata {\n name: string\n description: string\n execution: ToolExecution\n /** Interface inclusion defaults to true; execution support and user permissions remain separate. */\n exposure: ToolExposure\n capabilities: readonly ToolCapability[]\n availability: 'default' | 'eval'\n}\n\nexport interface ToolDef extends ToolMetadata {\n input: v.StrictObjectSchema<v.ObjectEntries, undefined>\n /** Derived from execution metadata, never declared independently by a tool. */\n readonly mutates: boolean\n /**\n * Loads the fonts the call's text edits need, as a Figma plugin loads them before it edits\n * text; rejects when one cannot load. Every executor awaits it before `execute`, so a\n * synchronous tool still edits in one step.\n */\n loadFonts: (figma: FigmaAPI, args: Record<string, unknown>) => Promise<void>\n execute: (figma: FigmaAPI, args: Record<string, unknown>) => unknown\n /**\n * The synchronous answer of a read whose `execute` may load a page first, or `undefined`\n * when answering would load. Hosts that cannot wait refuse on `undefined` before any load.\n */\n executeSync?: (figma: FigmaAPI, args: Record<string, unknown>) => unknown\n}\n\ntype ToolDefinitionMetadata = Omit<ToolMetadata, 'exposure' | 'capabilities' | 'availability'> &\n Partial<Pick<ToolMetadata, 'exposure' | 'capabilities' | 'availability'>>\n\nexport function defineTool<P extends v.ObjectEntries, R>(\n def: ToolDefinitionMetadata & {\n input: v.StrictObjectSchema<P, undefined>\n execution: ToolExecution & (R extends PromiseLike<unknown> ? { kind: 'async' } : unknown)\n /** The fonts a call's text edits need loaded first; text edits refuse unloaded fonts. */\n fonts?: (\n figma: FigmaAPI,\n args: v.InferOutput<v.StrictObjectSchema<P, undefined>>\n ) => FigmaFontNameInput[]\n execute: (figma: FigmaAPI, args: v.InferOutput<v.StrictObjectSchema<P, undefined>>) => R\n executeSync?: (\n figma: FigmaAPI,\n args: v.InferOutput<v.StrictObjectSchema<P, undefined>>\n ) => unknown\n }\n): ToolDef {\n const { fonts } = def\n return {\n ...def,\n exposure: def.exposure ?? {},\n capabilities: def.capabilities ?? [\n toolChangesDocument(def) ? 'document:write' : 'document:read'\n ],\n availability: def.availability ?? 'default',\n get mutates() {\n return def.execution.mutation !== 'none'\n },\n async loadFonts(figma, args) {\n if (!fonts) return\n // Wrong arguments are for `execute` to report.\n const parsed = v.safeParse(def.input, args)\n if (!parsed.success) return\n for (const font of fonts(figma, parsed.output)) await figma.loadFontAsync(font)\n },\n execute: (figma, args) => def.execute(figma, parseToolArgs(def.name, def.input, args)),\n executeSync: def.executeSync\n ? (figma, args) => def.executeSync?.(figma, parseToolArgs(def.name, def.input, args))\n : undefined\n }\n}\n\n/**\n * Every tool run goes through here, so a wrong call from AI chat, the CLI, WebMCP, and MCP names\n * the tool and lists each problem with its argument. An unknown or missing argument names the\n * arguments the tool takes, and a picklist names the values it accepts, read from the schema, so\n * the caller does not have to guess. Inputs are strict objects, so a misspelled or mis-nested\n * argument fails here instead of being dropped.\n */\nexport function parseToolArgs<S extends v.GenericSchema>(\n name: string,\n schema: S,\n args: unknown\n): v.InferOutput<S> {\n const result = v.safeParse(schema, args)\n if (result.success) return result.output\n throw new Error(formatToolArgumentError(name, schema, result.issues))\n}\n\n/** One refusal for every surface: the tool, then each problem with where it is. */\nfunction formatToolArgumentError(\n name: string,\n schema: v.GenericSchema,\n issues: readonly v.BaseIssue<unknown>[]\n): string {\n const problems = issues\n .flatMap((issue) => branchIssues(schema, issue))\n .map(({ keys, issue }) => {\n const place = keys.length > 0 ? `\\n → at ${placeOf(keys)}` : ''\n return `× ${formatToolArgIssue(schema, keys, issue)}${place}`\n })\n return `Invalid arguments for ${name}:\\n${problems.join('\\n')}`\n}\n\n/** The parts of a Valibot schema this module reads to name what a call should have sent. */\ntype SchemaParts = {\n readonly entries?: v.ObjectEntries\n readonly item?: v.GenericSchema\n readonly wrapped?: v.GenericSchema\n readonly options?: readonly unknown[]\n}\n\nfunction schemaParts(schema: unknown): SchemaParts {\n return typeof schema === 'object' && schema !== null ? schema : {}\n}\n\n/** The schema a wrapper such as `optional` or `pipe` holds, down to the one with the rules. */\nfunction unwrappedSchema(schema: v.GenericSchema): v.GenericSchema {\n let current = schema\n for (;;) {\n const wrapped = schemaParts(current).wrapped\n if (!wrapped) return current\n current = wrapped\n }\n}\n\ntype ArgumentKey = string | number\n\nfunction issueKeys(issue: v.BaseIssue<unknown>): ArgumentKey[] {\n const keys: ArgumentKey[] = []\n for (const item of issue.path ?? []) {\n if (!('key' in item)) continue\n if (typeof item.key === 'string' || typeof item.key === 'number') keys.push(item.key)\n }\n return keys\n}\n\n/** `operations[0].props`: an index reads as part of its array, a name follows a dot. */\nfunction placeOf(keys: readonly ArgumentKey[]): string {\n return keys.reduce<string>((place, key) => {\n if (typeof key === 'number') return `${place}[${key}]`\n return place ? `${place}.${key}` : key\n }, '')\n}\n\n/**\n * `v.union` reports one issue for every branch, which reads as \"Expected Object but received\n * Object\". Re-check the value against each branch and keep the one that got furthest: the branch\n * whose own problems name the field the caller has to fix.\n */\nfunction branchIssues(\n schema: v.GenericSchema,\n issue: v.BaseIssue<unknown>\n): { keys: ArgumentKey[]; issue: v.BaseIssue<unknown> }[] {\n const keys = issueKeys(issue)\n if (issue.type !== 'union') return [{ keys, issue }]\n const union = schemaAtPath(schema, keys)\n const options = union ? schemaParts(union).options : undefined\n if (!options || options.length === 0) return [{ keys, issue }]\n let best: readonly v.BaseIssue<unknown>[] | null = null\n for (const option of options) {\n const parsed = v.safeParse(option as v.GenericSchema, issue.input)\n if (parsed.success) continue\n if (!best || parsed.issues.length < best.length) best = parsed.issues\n }\n if (!best || best.length === 0) return [{ keys, issue }]\n return best.map((nested) => ({ keys: [...keys, ...issueKeys(nested)], issue: nested }))\n}\n\nfunction schemaAtPath(root: v.GenericSchema, keys: readonly ArgumentKey[]): v.GenericSchema | null {\n let current = unwrappedSchema(root)\n for (const key of keys) {\n const parts = schemaParts(current)\n const name = String(key)\n const next = parts.entries && name in parts.entries ? parts.entries[name] : parts.item\n if (!next) return null\n current = unwrappedSchema(next)\n }\n return current\n}\n\nfunction formatToolArgIssue(\n schema: v.GenericSchema,\n keys: readonly ArgumentKey[],\n issue: v.BaseIssue<unknown>\n): string {\n const key = keys.at(-1)\n if (key !== undefined && (issue.type === 'object' || issue.type === 'strict_object')) {\n if (issue.expected === 'never') {\n const parent = schemaAtPath(schema, keys.slice(0, -1))\n const accepted = parent ? Object.keys(schemaParts(parent).entries ?? {}) : []\n return accepted.length > 0\n ? `Unknown argument \"${key}\". Accepted: ${accepted.join(', ')}`\n : `Unknown argument \"${key}\"`\n }\n if (issue.received === 'undefined') return `Missing required argument \"${key}\"`\n }\n if (issue.type === 'picklist' && key !== undefined) {\n const resolved = schemaAtPath(schema, keys)\n const options = resolved ? schemaParts(resolved).options : undefined\n if (options && options.length > 0) {\n const accepted = options.map((option) => JSON.stringify(option)).join(', ')\n return `Invalid value ${issue.received} for argument \"${key}\". Accepted: ${accepted}`\n }\n }\n return issue.message\n}\n\nexport function toolChangesDocument(def: Pick<ToolDef, 'execution'>): boolean {\n return def.execution.mutation === 'properties' || def.execution.mutation === 'document'\n}\n\nexport function isToolExposed(def: Pick<ToolDef, 'exposure'>, target: ToolInterface): boolean {\n return def.exposure[target] !== false\n}\n\nexport function isAtomicTool(def: ToolDef): boolean {\n return def.execution.kind === 'sync' && def.execution.mutation === 'properties'\n}\n\nexport class NodeNotFoundError extends Error {\n constructor(id: string) {\n super(`Node not found: ${id}`)\n this.name = 'NodeNotFoundError'\n }\n}\n\nexport function requireNode(figma: FigmaAPI, id: string): ReturnType<FigmaAPI['getNodeById']> {\n const node = figma.getNodeById(id)\n if (!node) throw new NodeNotFoundError(id)\n return node\n}\n\nexport function requireNodes(figma: FigmaAPI, ids: ReadonlyArray<string>): FigmaNodeProxy[] | null {\n const nodes: FigmaNodeProxy[] = []\n for (const id of ids) {\n const node = figma.getNodeById(id)\n if (!node) return null\n nodes.push(node)\n }\n return nodes\n}\n\n/** A tool's answer when the operation it wraps throws: the error's message for the caller. */\nexport function toolFailure(error: unknown): { error: string } {\n return { error: error instanceof Error ? error.message : String(error) }\n}\n\nexport function nodeNotFound(id: string): { error: string } {\n return { error: `Node \"${id}\" not found` }\n}\n\nexport function getRawNodeOrError(\n figma: FigmaAPI,\n id: string\n): { node: SceneNode } | { error: string } {\n const node = figma.graph.getNode(id)\n return node ? { node } : nodeNotFound(id)\n}\n\nexport function nodeToResult(node: FigmaNodeProxy, maxDepth?: number): Record<string, unknown> {\n return node.toJSON(maxDepth)\n}\n\nexport function nodeSummary(node: FigmaNodeProxy): { id: string; name: string; type: string } {\n return { id: node.id, name: node.name, type: node.type }\n}\n\n/**\n * A tool colour, refusing text that would otherwise land as black: `set_fill { color: \"#GGG\" }`\n * used to paint black and report success. Read through `tryParseColor`, since a published schema\n * cannot express what the parser accepts.\n */\nexport function parseToolColor(value: string): Color | { error: string } {\n return (\n tryParseColor(value) ?? {\n error: `\"${value}\" is not a color; use a hex value, a color name, or a color function`\n }\n )\n}\n\n/**\n * A colour the caller may leave out. Missing stays missing; text that is not a colour is the\n * same refusal `parseToolColor` gives, so each tool does not repeat that check.\n */\nexport function parseOptionalToolColor(\n value: string | undefined\n): { color: Color | undefined } | { error: string } {\n if (value === undefined) return { color: undefined }\n const parsed = parseToolColor(value)\n if ('error' in parsed) return parsed\n return { color: parsed }\n}\n\nexport const nodeIdInputSchema = v.pipe(v.string(), v.description('Node ID'))\nexport const nodeInputSchema = v.strictObject({ id: nodeIdInputSchema })\nexport const nodeComparisonInputSchema = v.strictObject({\n from: v.pipe(v.string(), v.description('Source node ID')),\n to: v.pipe(v.string(), v.description('Target node ID'))\n})\n\nexport function nodeTraversalInput(depthDescription: string) {\n return v.strictObject({\n id: nodeIdInputSchema,\n depth: v.optional(toolNumber(v.pipe(v.number(), v.description(depthDescription))))\n })\n}\nexport const positionInputs = {\n x: toolNumber(v.pipe(v.number(), v.description('X position in the parent, or on the page'))),\n y: toolNumber(v.pipe(v.number(), v.description('Y position in the parent, or on the page')))\n}\n\n/** Reuse a native number schema for both numeric and numeric-string agent inputs. */\nexport function toolNumber(schema: v.GenericSchema<number, number> = v.number()) {\n // JSON Schema numbers are finite. Express that with representable bounds as well as at runtime.\n const finite = v.pipe(schema, v.minValue(-Number.MAX_VALUE), v.maxValue(Number.MAX_VALUE))\n return v.union([\n finite,\n v.pipe(\n v.string(),\n v.regex(/\\S/, 'Expected a nonblank numeric string'),\n v.description(v.getDescription(schema) ?? 'Numeric value'),\n v.transform(Number),\n finite\n )\n ])\n}\n"],"mappings":";;;;;;;;;AAgEA,SAAgB,WACd,KAcS;CACT,MAAM,EAAE,UAAU;CAClB,OAAO;EACL,GAAG;EACH,UAAU,IAAI,YAAY,CAAC;EAC3B,cAAc,IAAI,gBAAgB,CAChC,oBAAoB,GAAG,IAAI,mBAAmB,eAChD;EACA,cAAc,IAAI,gBAAgB;EAClC,IAAI,UAAU;GACZ,OAAO,IAAI,UAAU,aAAa;EACpC;E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,oBAAoB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,SAAS,CAAC;AAC5E,MAAa,kBAAkB,EAAE,aAAa,EAAE,IAAI,kBAAkB,CAAC;AACvE,MAAa,4BAA4B,EAAE,aAAa;CACtD,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,gBAAgB,CAAC;CACxD,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,gBAAgB,CAAC;AACxD,CAAC;AAED,SAAgB,mBAAmB,kBAA0B;CAC3D,OAAO,EAAE,aAAa;EACpB,IAAI;EACJ,OAAO,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,gBAAgB,CAAC,CAAC,CAAC;CACnF,CAAC;AACH;AACA,MAAa,iBAAiB;CAC5B,GAAG,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,0CAA0C,CAAC,CAAC;CAC3F,GAAG,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,0CAA0C,CAAC,CAAC;AAC7F;;AAGA,SAAgB,WAAW,SAA0C,EAAE,OAAO,GAAG;CAE/E,MAAM,SAAS,EAAE,KAAK,QAAQ,EAAE,SAAS,CAAC,OAAO,SAAS,GAAG,EAAE,SAAS,OAAO,SAAS,CAAC;CACzF,OAAO,EAAE,MAAM,CACb,QACA,EAAE,KACA,EAAE,OAAO,GACT,EAAE,MAAM,MAAM,oCAAoC,GAClD,EAAE,YAAY,EAAE,eAAe,MAAM,KAAK,eAAe,GACzD,EAAE,UAAU,MAAM,GAClB,MACF,CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../src/tools/schema.ts"],"sourcesContent":["/**\n * Tool definition schema.\n *\n * Native Valibot inputs and execution capabilities are owned by each tool.\n * Adapters consume these contracts rather than maintaining transport-specific schemas.\n */\n\nimport * as v from 'valibot'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { tryParseColor } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api'\nimport type { FigmaFontNameInput } from '#core/figma-api/fonts/names'\n\nexport type ToolCapability =\n | 'document:read'\n | 'document:write'\n | 'filesystem:read'\n | 'filesystem:write'\n | 'network:access'\n | 'code:execute'\n | 'settings:read'\n | 'settings:write'\n\nexport type ToolExecution =\n | { kind: 'sync'; mutation: 'none' | 'view' | 'properties' | 'document' }\n | {\n kind: 'async'\n mutation: 'none' | 'view' | 'document'\n /**\n * The call can run for a long time even when it only reads, such as recording a video, so\n * bridges give it the deadline they give an edit.\n */\n long?: boolean\n }\n\nexport type ToolInterface = 'mcp' | 'ai' | 'webmcp'\nexport type ToolExposure = Partial<Record<ToolInterface, boolean>>\n\ninterface ToolMetadata {\n name: string\n description: string\n execution: ToolExecution\n /** Interface inclusion defaults to true; execution support and user permissions remain separate. */\n exposure: ToolExposure\n capabilities: readonly ToolCapability[]\n availability: 'default' | 'eval'\n /**\n * What a call's values come from, for the document's design memory:\n * - `imported`: outside content, such as a web page, an SVG, a photo or a library component,\n * whose colors and type are its own, so the memory warns about them rather than refusing;\n * - `copied`: the layers the call names, which it copies or converts with their values, such\n * as a clone, a group or a boolean, so values those layers already had are not new.\n * - `merged`: layers the call joins into one, which may take a paint from any of them, such as\n * flatten and boolean operations; a value is only theirs when every named layer had it.\n */\n content?: 'imported' | 'copied' | 'merged'\n}\n\nexport interface ToolDef extends ToolMetadata {\n input: v.StrictObjectSchema<v.ObjectEntries, undefined>\n /** Derived from execution metadata, never declared independently by a tool. */\n readonly mutates: boolean\n /**\n * Loads the fonts the call's text edits need, as a Figma plugin loads them before it edits\n * text; rejects when one cannot load. Every executor awaits it before `execute`, so a\n * synchronous tool still edits in one step.\n */\n loadFonts: (figma: FigmaAPI, args: Record<string, unknown>) => Promise<void>\n /** `signal` aborts a caller's cancelled request, which a long export checks while it runs. */\n execute: (figma: FigmaAPI, args: Record<string, unknown>, signal?: AbortSignal) => unknown\n /**\n * The synchronous answer of a read whose `execute` may load a page first, or `undefined`\n * when answering would load. Hosts that cannot wait refuse on `undefined` before any load.\n */\n executeSync?: (figma: FigmaAPI, args: Record<string, unknown>) => unknown\n}\n\ntype ToolDefinitionMetadata = Omit<ToolMetadata, 'exposure' | 'capabilities' | 'availability'> &\n Partial<Pick<ToolMetadata, 'exposure' | 'capabilities' | 'availability'>>\n\nexport function defineTool<P extends v.ObjectEntries, R>(\n def: ToolDefinitionMetadata & {\n input: v.StrictObjectSchema<P, undefined>\n execution: ToolExecution & (R extends PromiseLike<unknown> ? { kind: 'async' } : unknown)\n /** The fonts a call's text edits need loaded first; text edits refuse unloaded fonts. */\n fonts?: (\n figma: FigmaAPI,\n args: v.InferOutput<v.StrictObjectSchema<P, undefined>>\n ) => FigmaFontNameInput[]\n execute: (\n figma: FigmaAPI,\n args: v.InferOutput<v.StrictObjectSchema<P, undefined>>,\n signal?: AbortSignal\n ) => R\n executeSync?: (\n figma: FigmaAPI,\n args: v.InferOutput<v.StrictObjectSchema<P, undefined>>\n ) => unknown\n }\n): ToolDef {\n const { fonts } = def\n return {\n ...def,\n exposure: def.exposure ?? {},\n capabilities: def.capabilities ?? [\n toolChangesDocument(def) ? 'document:write' : 'document:read'\n ],\n availability: def.availability ?? 'default',\n get mutates() {\n return def.execution.mutation !== 'none'\n },\n async loadFonts(figma, args) {\n if (!fonts) return\n // Wrong arguments are for `execute` to report.\n const parsed = v.safeParse(def.input, args)\n if (!parsed.success) return\n for (const font of fonts(figma, parsed.output)) await figma.loadFontAsync(font)\n },\n execute: (figma, args, signal) =>\n def.execute(figma, parseToolArgs(def.name, def.input, args), signal),\n executeSync: def.executeSync\n ? (figma, args) => def.executeSync?.(figma, parseToolArgs(def.name, def.input, args))\n : undefined\n }\n}\n\n/**\n * Every tool run goes through here, so a wrong call from AI chat, the CLI, WebMCP, and MCP names\n * the tool and lists each problem with its argument. An unknown or missing argument names the\n * arguments the tool takes, and a picklist names the values it accepts, read from the schema, so\n * the caller does not have to guess. Inputs are strict objects, so a misspelled or mis-nested\n * argument fails here instead of being dropped.\n */\nexport function parseToolArgs<S extends v.GenericSchema>(\n name: string,\n schema: S,\n args: unknown\n): v.InferOutput<S> {\n const result = v.safeParse(schema, args)\n if (result.success) return result.output\n throw new Error(formatToolArgumentError(name, schema, result.issues))\n}\n\n/** One refusal for every surface: the tool, then each problem with where it is. */\nfunction formatToolArgumentError(\n name: string,\n schema: v.GenericSchema,\n issues: readonly v.BaseIssue<unknown>[]\n): string {\n const problems = issues\n .flatMap((issue) => branchIssues(schema, issue))\n .map(({ keys, issue }) => {\n const place = keys.length > 0 ? `\\n → at ${placeOf(keys)}` : ''\n return `× ${formatToolArgIssue(schema, keys, issue)}${place}`\n })\n return `Invalid arguments for ${name}:\\n${problems.join('\\n')}`\n}\n\n/** The parts of a Valibot schema this module reads to name what a call should have sent. */\ntype SchemaParts = {\n readonly entries?: v.ObjectEntries\n readonly item?: v.GenericSchema\n readonly wrapped?: v.GenericSchema\n readonly options?: readonly unknown[]\n}\n\nfunction schemaParts(schema: unknown): SchemaParts {\n return typeof schema === 'object' && schema !== null ? schema : {}\n}\n\n/** The schema a wrapper such as `optional` or `pipe` holds, down to the one with the rules. */\nfunction unwrappedSchema(schema: v.GenericSchema): v.GenericSchema {\n let current = schema\n for (;;) {\n const wrapped = schemaParts(current).wrapped\n if (!wrapped) return current\n current = wrapped\n }\n}\n\ntype ArgumentKey = string | number\n\nfunction issueKeys(issue: v.BaseIssue<unknown>): ArgumentKey[] {\n const keys: ArgumentKey[] = []\n for (const item of issue.path ?? []) {\n if (!('key' in item)) continue\n if (typeof item.key === 'string' || typeof item.key === 'number') keys.push(item.key)\n }\n return keys\n}\n\n/** `operations[0].props`: an index reads as part of its array, a name follows a dot. */\nfunction placeOf(keys: readonly ArgumentKey[]): string {\n return keys.reduce<string>((place, key) => {\n if (typeof key === 'number') return `${place}[${key}]`\n return place ? `${place}.${key}` : key\n }, '')\n}\n\n/**\n * `v.union` reports one issue for every branch, which reads as \"Expected Object but received\n * Object\". Re-check the value against each branch and keep the one that got furthest: the branch\n * whose own problems name the field the caller has to fix.\n */\nfunction branchIssues(\n schema: v.GenericSchema,\n issue: v.BaseIssue<unknown>\n): { keys: ArgumentKey[]; issue: v.BaseIssue<unknown> }[] {\n const keys = issueKeys(issue)\n if (issue.type !== 'union') return [{ keys, issue }]\n const union = schemaAtPath(schema, keys)\n const options = union ? schemaParts(union).options : undefined\n if (!options || options.length === 0) return [{ keys, issue }]\n let best: readonly v.BaseIssue<unknown>[] | null = null\n for (const option of options) {\n const parsed = v.safeParse(option as v.GenericSchema, issue.input)\n if (parsed.success) continue\n if (!best || parsed.issues.length < best.length) best = parsed.issues\n }\n if (!best || best.length === 0) return [{ keys, issue }]\n return best.map((nested) => ({ keys: [...keys, ...issueKeys(nested)], issue: nested }))\n}\n\nfunction schemaAtPath(root: v.GenericSchema, keys: readonly ArgumentKey[]): v.GenericSchema | null {\n let current = unwrappedSchema(root)\n for (const key of keys) {\n const parts = schemaParts(current)\n const name = String(key)\n const next = parts.entries && name in parts.entries ? parts.entries[name] : parts.item\n if (!next) return null\n current = unwrappedSchema(next)\n }\n return current\n}\n\nfunction formatToolArgIssue(\n schema: v.GenericSchema,\n keys: readonly ArgumentKey[],\n issue: v.BaseIssue<unknown>\n): string {\n const key = keys.at(-1)\n if (key !== undefined && (issue.type === 'object' || issue.type === 'strict_object')) {\n if (issue.expected === 'never') {\n const parent = schemaAtPath(schema, keys.slice(0, -1))\n const accepted = parent ? Object.keys(schemaParts(parent).entries ?? {}) : []\n return accepted.length > 0\n ? `Unknown argument \"${key}\". Accepted: ${accepted.join(', ')}`\n : `Unknown argument \"${key}\"`\n }\n if (issue.received === 'undefined') return `Missing required argument \"${key}\"`\n }\n if (issue.type === 'picklist' && key !== undefined) {\n const resolved = schemaAtPath(schema, keys)\n const options = resolved ? schemaParts(resolved).options : undefined\n if (options && options.length > 0) {\n const accepted = options.map((option) => JSON.stringify(option)).join(', ')\n return `Invalid value ${issue.received} for argument \"${key}\". Accepted: ${accepted}`\n }\n }\n return issue.message\n}\n\nexport function toolChangesDocument(def: Pick<ToolDef, 'execution'>): boolean {\n return def.execution.mutation === 'properties' || def.execution.mutation === 'document'\n}\n\nexport function isToolExposed(def: Pick<ToolDef, 'exposure'>, target: ToolInterface): boolean {\n return def.exposure[target] !== false\n}\n\nexport function isAtomicTool(def: ToolDef): boolean {\n return def.execution.kind === 'sync' && def.execution.mutation === 'properties'\n}\n\nexport class NodeNotFoundError extends Error {\n constructor(id: string) {\n super(`Node not found: ${id}`)\n this.name = 'NodeNotFoundError'\n }\n}\n\nexport function requireNode(figma: FigmaAPI, id: string): ReturnType<FigmaAPI['getNodeById']> {\n const node = figma.getNodeById(id)\n if (!node) throw new NodeNotFoundError(id)\n return node\n}\n\nexport function requireNodes(figma: FigmaAPI, ids: ReadonlyArray<string>): FigmaNodeProxy[] | null {\n const nodes: FigmaNodeProxy[] = []\n for (const id of ids) {\n const node = figma.getNodeById(id)\n if (!node) return null\n nodes.push(node)\n }\n return nodes\n}\n\n/** A tool's answer when the operation it wraps throws: the error's message for the caller. */\nexport function toolFailure(error: unknown): { error: string } {\n return { error: error instanceof Error ? error.message : String(error) }\n}\n\nexport function nodeNotFound(id: string): { error: string } {\n return { error: `Node \"${id}\" not found` }\n}\n\nexport function getRawNodeOrError(\n figma: FigmaAPI,\n id: string\n): { node: SceneNode } | { error: string } {\n const node = figma.graph.getNode(id)\n return node ? { node } : nodeNotFound(id)\n}\n\nexport function nodeToResult(node: FigmaNodeProxy, maxDepth?: number): Record<string, unknown> {\n return node.toJSON(maxDepth)\n}\n\nexport function nodeSummary(node: FigmaNodeProxy): { id: string; name: string; type: string } {\n return { id: node.id, name: node.name, type: node.type }\n}\n\n/**\n * A tool colour, refusing text that would otherwise land as black: `set_fill { color: \"#GGG\" }`\n * used to paint black and report success. Read through `tryParseColor`, since a published schema\n * cannot express what the parser accepts.\n */\nexport function parseToolColor(value: string): Color | { error: string } {\n return (\n tryParseColor(value) ?? {\n error: `\"${value}\" is not a color; use a hex value, a color name, or a color function`\n }\n )\n}\n\n/**\n * A colour the caller may leave out. Missing stays missing; text that is not a colour is the\n * same refusal `parseToolColor` gives, so each tool does not repeat that check.\n */\nexport function parseOptionalToolColor(\n value: string | undefined\n): { color: Color | undefined } | { error: string } {\n if (value === undefined) return { color: undefined }\n const parsed = parseToolColor(value)\n if ('error' in parsed) return parsed\n return { color: parsed }\n}\n\nexport const nodeIdInputSchema = v.pipe(v.string(), v.description('Node ID'))\nexport const nodeInputSchema = v.strictObject({ id: nodeIdInputSchema })\nexport const nodeComparisonInputSchema = v.strictObject({\n from: v.pipe(v.string(), v.description('Source node ID')),\n to: v.pipe(v.string(), v.description('Target node ID'))\n})\n\nexport function nodeTraversalInput(depthDescription: string) {\n return v.strictObject({\n id: nodeIdInputSchema,\n depth: v.optional(toolNumber(v.pipe(v.number(), v.description(depthDescription))))\n })\n}\nexport const positionInputs = {\n x: toolNumber(v.pipe(v.number(), v.description('X position in the parent, or on the page'))),\n y: toolNumber(v.pipe(v.number(), v.description('Y position in the parent, or on the page')))\n}\n\n/** Reuse a native number schema for both numeric and numeric-string agent inputs. */\nexport function toolNumber(schema: v.GenericSchema<number, number> = v.number()) {\n // JSON Schema numbers are finite. Express that with representable bounds as well as at runtime.\n const finite = v.pipe(schema, v.minValue(-Number.MAX_VALUE), v.maxValue(Number.MAX_VALUE))\n return v.union([\n finite,\n v.pipe(\n v.string(),\n v.regex(/\\S/, 'Expected a nonblank numeric string'),\n v.description(v.getDescription(schema) ?? 'Numeric value'),\n v.transform(Number),\n finite\n )\n ])\n}\n"],"mappings":";;;;;;;;;AAmFA,SAAgB,WACd,KAkBS;CACT,MAAM,EAAE,UAAU;CAClB,OAAO;EACL,GAAG;EACH,UAAU,IAAI,YAAY,CAAC;EAC3B,cAAc,IAAI,gBAAgB,CAChC,oBAAoB,GAAG,IAA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
|
+
content: "imported",
|
|
14
15
|
capabilities: ["document:write", "network:access"],
|
|
15
16
|
input: v.strictObject({ requests: v.pipe(v.string(), v.description("JSON array: [{\"id\":\"0:5\",\"query\":\"mountain sunset\"},{\"id\":\"0:8\",\"query\":\"business team\",\"orientation\":\"square\"}]")) }),
|
|
16
17
|
execute: async (figma, { requests }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stock-photo.js","names":[],"sources":["../../src/tools/stock-photo.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { defineTool } from './schema'\nimport { applyPhoto } from './stock-photo/apply'\nimport { getActiveProvider } from './stock-photo/providers'\nimport { parsePhotoRequests } from './stock-photo/requests'\n\nexport { applyPhoto, type PhotoRequest, type PhotoResult } from './stock-photo/apply'\nexport { parsePhotoRequests } from './stock-photo/requests'\nexport { setPexelsAPIKey, setUnsplashAccessKey } from './stock-photo/providers'\n\nexport const stockPhoto = defineTool({\n name: 'stock_photo',\n\n description:\n 'Search stock photos and apply to leaf image placeholders or closed area geometry. ' +\n 'Pass a JSON array; each item is {id, query, index?, orientation?}. ' +\n 'Containers with content, text, lines, and structural nodes are rejected.',\n execution: { kind: 'async', mutation: 'document' },\n capabilities: ['document:write', 'network:access'],\n input: v.strictObject({\n requests: v.pipe(\n v.string(),\n v.description(\n 'JSON array: [{\"id\":\"0:5\",\"query\":\"mountain sunset\"},{\"id\":\"0:8\",\"query\":\"business team\",\"orientation\":\"square\"}]'\n )\n )\n }),\n execute: async (figma, { requests }) => {\n const provider = getActiveProvider()\n if (!provider) {\n return {\n error: `No stock photo service has a key. Ask the user to add a Pexels or Unsplash key: Insert photo in the toolbar asks for one.`\n }\n }\n\n const reqs = parsePhotoRequests(requests)\n if ('error' in reqs) return reqs\n\n const results = await Promise.all(reqs.map((request) => applyPhoto(figma, provider, request)))\n const ok = results.filter((result) => result.photo).length\n\n return { applied: ok, failed: results.length - ok, provider: provider.name, results }\n }\n})\n"],"mappings":";;;;;;AAWA,MAAa,aAAa,WAAW;CACnC,MAAM;CAEN,aACE;CAGF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAW;CACjD,cAAc,CAAC,kBAAkB,gBAAgB;CACjD,OAAO,EAAE,aAAa,EACpB,UAAU,EAAE,KACV,EAAE,OAAO,GACT,EAAE,YACA,sIACF,CACF,EACF,CAAC;CACD,SAAS,OAAO,OAAO,EAAE,eAAe;EACtC,MAAM,WAAW,kBAAkB;EACnC,IAAI,CAAC,UACH,OAAO,EACL,OAAO,4HACT;EAGF,MAAM,OAAO,mBAAmB,QAAQ;EACxC,IAAI,WAAW,MAAM,OAAO;EAE5B,MAAM,UAAU,MAAM,QAAQ,IAAI,KAAK,KAAK,YAAY,WAAW,OAAO,UAAU,OAAO,CAAC,CAAC;EAC7F,MAAM,KAAK,QAAQ,QAAQ,WAAW,OAAO,KAAK,CAAC,CAAC;EAEpD,OAAO;GAAE,SAAS;GAAI,QAAQ,QAAQ,SAAS;GAAI,UAAU,SAAS;GAAM;EAAQ;CACtF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"stock-photo.js","names":[],"sources":["../../src/tools/stock-photo.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { defineTool } from './schema'\nimport { applyPhoto } from './stock-photo/apply'\nimport { getActiveProvider } from './stock-photo/providers'\nimport { parsePhotoRequests } from './stock-photo/requests'\n\nexport { applyPhoto, type PhotoRequest, type PhotoResult } from './stock-photo/apply'\nexport { parsePhotoRequests } from './stock-photo/requests'\nexport { setPexelsAPIKey, setUnsplashAccessKey } from './stock-photo/providers'\n\nexport const stockPhoto = defineTool({\n name: 'stock_photo',\n\n description:\n 'Search stock photos and apply to leaf image placeholders or closed area geometry. ' +\n 'Pass a JSON array; each item is {id, query, index?, orientation?}. ' +\n 'Containers with content, text, lines, and structural nodes are rejected.',\n execution: { kind: 'async', mutation: 'document' },\n content: 'imported',\n capabilities: ['document:write', 'network:access'],\n input: v.strictObject({\n requests: v.pipe(\n v.string(),\n v.description(\n 'JSON array: [{\"id\":\"0:5\",\"query\":\"mountain sunset\"},{\"id\":\"0:8\",\"query\":\"business team\",\"orientation\":\"square\"}]'\n )\n )\n }),\n execute: async (figma, { requests }) => {\n const provider = getActiveProvider()\n if (!provider) {\n return {\n error: `No stock photo service has a key. Ask the user to add a Pexels or Unsplash key: Insert photo in the toolbar asks for one.`\n }\n }\n\n const reqs = parsePhotoRequests(requests)\n if ('error' in reqs) return reqs\n\n const results = await Promise.all(reqs.map((request) => applyPhoto(figma, provider, request)))\n const ok = results.filter((result) => result.photo).length\n\n return { applied: ok, failed: results.length - ok, provider: provider.name, results }\n }\n})\n"],"mappings":";;;;;;AAWA,MAAa,aAAa,WAAW;CACnC,MAAM;CAEN,aACE;CAGF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAW;CACjD,SAAS;CACT,cAAc,CAAC,kBAAkB,gBAAgB;CACjD,OAAO,EAAE,aAAa,EACpB,UAAU,EAAE,KACV,EAAE,OAAO,GACT,EAAE,YACA,sIACF,CACF,EACF,CAAC;CACD,SAAS,OAAO,OAAO,EAAE,eAAe;EACtC,MAAM,WAAW,kBAAkB;EACnC,IAAI,CAAC,UACH,OAAO,EACL,OAAO,4HACT;EAGF,MAAM,OAAO,mBAAmB,QAAQ;EACxC,IAAI,WAAW,MAAM,OAAO;EAE5B,MAAM,UAAU,MAAM,QAAQ,IAAI,KAAK,KAAK,YAAY,WAAW,OAAO,UAAU,OAAO,CAAC,CAAC;EAC7F,MAAM,KAAK,QAAQ,QAAQ,WAAW,OAAO,KAAK,CAAC,CAAC;EAEpD,OAAO;GAAE,SAAS;GAAI,QAAQ,QAAQ,SAAS;GAAI,UAAU,SAAS;GAAM;EAAQ;CACtF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic.d.ts","names":[],"sources":["../../../src/tools/structure/basic.ts"],"mappings":";;cAWa,YAAA;cAgBA,WAAA;
|
|
1
|
+
{"version":3,"file":"basic.d.ts","names":[],"sources":["../../../src/tools/structure/basic.ts"],"mappings":";;cAWa,YAAA;cAgBA,WAAA;cAiBA,YAAA;cAiBA,YAAA;cAYA,UAAA;cAmBA,YAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic.js","names":[],"sources":["../../../src/tools/structure/basic.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport {\n toolNumber,\n nodeIdInputSchema,\n nodeInputSchema,\n defineTool,\n nodeNotFound,\n nodeSummary\n} from '#core/tools/schema'\n\nexport const deleteNode = defineTool({\n name: 'delete_node',\n\n description: 'Delete a node by ID.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Node ID to delete'))\n }),\n execute: (figma, { id }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n node.remove()\n return { deleted: id }\n }\n})\n\nexport const cloneNode = defineTool({\n name: 'clone_node',\n\n description: 'Clone (duplicate) a node.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Node ID to clone'))\n }),\n execute: (figma, { id }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n const clone = node.clone()\n return nodeSummary(clone)\n }\n})\n\nexport const renameNode = defineTool({\n name: 'rename_node',\n\n description: 'Rename a node in the layers panel.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n name: v.pipe(v.string(), v.description('New name'))\n }),\n execute: (figma, { id, name }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n node.name = name\n return { id, name }\n }\n})\n\nexport const nodeBounds = defineTool({\n name: 'node_bounds',\n description: 'Get absolute bounding box of a node.',\n execution: { kind: 'sync', mutation: 'none' },\n exposure: { webmcp: false },\n input: nodeInputSchema,\n execute: (figma, { id }) => {\n const node = figma.getNodeById(id)\n return node ? { id, bounds: node.absoluteBoundingBox } : nodeNotFound(id)\n }\n})\n\nexport const nodeMove = defineTool({\n name: 'node_move',\n\n description: 'Move a node to new coordinates.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n x: toolNumber(v.pipe(v.number(), v.description('X position'))),\n y: toolNumber(v.pipe(v.number(), v.description('Y position')))\n }),\n execute: (figma, { id, x, y }) => {\n const node = figma.getNodeById(id)\n if (!node) return nodeNotFound(id)\n node.x = x\n node.y = y\n return { id, x, y }\n }\n})\n\nexport const nodeResize = defineTool({\n name: 'node_resize',\n\n description: 'Resize a node.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n width: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Width'))),\n height: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Height')))\n }),\n execute: (figma, { id, width, height }) => {\n const node = figma.getNodeById(id)\n if (!node) return nodeNotFound(id)\n node.resize(width, height)\n return { id, width, height }\n }\n})\n"],"mappings":";;;AAWA,MAAa,aAAa,WAAW;CACnC,MAAM;CAEN,aAAa;CACb,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa,EACpB,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,mBAAmB,CAAC,EAC3D,CAAC;CACD,UAAU,OAAO,EAAE,SAAS;EAC1B,MAAM,OAAO,MAAM,YAAY,EAAE;EACjC,IAAI,CAAC,MAAM,OAAO,EAAE,OAAO,SAAS,GAAG,aAAa;EACpD,KAAK,OAAO;EACZ,OAAO,EAAE,SAAS,GAAG;CACvB;AACF,CAAC;AAED,MAAa,YAAY,WAAW;CAClC,MAAM;CAEN,aAAa;CACb,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa,EACpB,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,kBAAkB,CAAC,EAC1D,CAAC;CACD,UAAU,OAAO,EAAE,SAAS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EACjC,IAAI,CAAC,MAAM,OAAO,aAAa,EAAE;EACjC,KAAK,IAAI;EACT,KAAK,IAAI;EACT,OAAO;GAAE;GAAI;GAAG;EAAE;CACpB;AACF,CAAC;AAED,MAAa,aAAa,WAAW;CACnC,MAAM;CAEN,aAAa;CACb,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa;EACpB,IAAI;EACJ,OAAO,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,YAAY,OAAO,CAAC,CAAC;EAC3E,QAAQ,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,YAAY,QAAQ,CAAC,CAAC;CAC/E,CAAC;CACD,UAAU,OAAO,EAAE,IAAI,OAAO,aAAa;EACzC,MAAM,OAAO,MAAM,YAAY,EAAE;EACjC,IAAI,CAAC,MAAM,OAAO,aAAa,EAAE;EACjC,KAAK,OAAO,OAAO,MAAM;EACzB,OAAO;GAAE;GAAI;GAAO;EAAO;CAC7B;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"basic.js","names":[],"sources":["../../../src/tools/structure/basic.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport {\n toolNumber,\n nodeIdInputSchema,\n nodeInputSchema,\n defineTool,\n nodeNotFound,\n nodeSummary\n} from '#core/tools/schema'\n\nexport const deleteNode = defineTool({\n name: 'delete_node',\n\n description: 'Delete a node by ID.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Node ID to delete'))\n }),\n execute: (figma, { id }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n node.remove()\n return { deleted: id }\n }\n})\n\nexport const cloneNode = defineTool({\n name: 'clone_node',\n\n description: 'Clone (duplicate) a node.',\n execution: { kind: 'sync', mutation: 'document' },\n content: 'copied',\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Node ID to clone'))\n }),\n execute: (figma, { id }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n const clone = node.clone()\n return nodeSummary(clone)\n }\n})\n\nexport const renameNode = defineTool({\n name: 'rename_node',\n\n description: 'Rename a node in the layers panel.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n name: v.pipe(v.string(), v.description('New name'))\n }),\n execute: (figma, { id, name }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n node.name = name\n return { id, name }\n }\n})\n\nexport const nodeBounds = defineTool({\n name: 'node_bounds',\n description: 'Get absolute bounding box of a node.',\n execution: { kind: 'sync', mutation: 'none' },\n exposure: { webmcp: false },\n input: nodeInputSchema,\n execute: (figma, { id }) => {\n const node = figma.getNodeById(id)\n return node ? { id, bounds: node.absoluteBoundingBox } : nodeNotFound(id)\n }\n})\n\nexport const nodeMove = defineTool({\n name: 'node_move',\n\n description: 'Move a node to new coordinates.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n x: toolNumber(v.pipe(v.number(), v.description('X position'))),\n y: toolNumber(v.pipe(v.number(), v.description('Y position')))\n }),\n execute: (figma, { id, x, y }) => {\n const node = figma.getNodeById(id)\n if (!node) return nodeNotFound(id)\n node.x = x\n node.y = y\n return { id, x, y }\n }\n})\n\nexport const nodeResize = defineTool({\n name: 'node_resize',\n\n description: 'Resize a node.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n width: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Width'))),\n height: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Height')))\n }),\n execute: (figma, { id, width, height }) => {\n const node = figma.getNodeById(id)\n if (!node) return nodeNotFound(id)\n node.resize(width, height)\n return { id, width, height }\n }\n})\n"],"mappings":";;;AAWA,MAAa,aAAa,WAAW;CACnC,MAAM;CAEN,aAAa;CAC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AC7B;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.d.ts","names":[],"sources":["../../../src/tools/structure/batch.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"batch.d.ts","names":[],"sources":["../../../src/tools/structure/batch.ts"],"mappings":";;cAwGa,aAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineTool, nodeNotFound, toolNumber } from "../schema.js";
|
|
2
2
|
import { textFonts } from "../modify/text.js";
|
|
3
|
+
import { overflowDirectionInput, scrollBehaviorInput, scrollRefusal } from "../modify/update.js";
|
|
3
4
|
import * as v from "valibot";
|
|
4
5
|
//#region src/tools/structure/batch.ts
|
|
5
6
|
const nonNegative = () => toolNumber(v.pipe(v.number(), v.minValue(0)));
|
|
@@ -43,7 +44,9 @@ const batchPropsSchema = v.strictObject({
|
|
|
43
44
|
"HEIGHT",
|
|
44
45
|
"TRUNCATE"
|
|
45
46
|
])),
|
|
46
|
-
direction: v.optional(v.picklist(["HORIZONTAL", "VERTICAL"]))
|
|
47
|
+
direction: v.optional(v.picklist(["HORIZONTAL", "VERTICAL"])),
|
|
48
|
+
overflow_direction: v.optional(overflowDirectionInput()),
|
|
49
|
+
scroll_behavior: v.optional(scrollBehaviorInput())
|
|
47
50
|
});
|
|
48
51
|
const batchOpsSchema = v.array(v.strictObject({
|
|
49
52
|
id: v.string(),
|
|
@@ -95,6 +98,8 @@ function applyBatchProps(node, props) {
|
|
|
95
98
|
if (props.opacity !== void 0) node.opacity = props.opacity;
|
|
96
99
|
if (props.auto_resize !== void 0) node.textAutoResize = props.auto_resize;
|
|
97
100
|
if (props.direction !== void 0) node.layoutMode = props.direction;
|
|
101
|
+
if (props.overflow_direction !== void 0) node.overflowDirection = props.overflow_direction;
|
|
102
|
+
if (props.scroll_behavior !== void 0) node.scrollBehavior = props.scroll_behavior;
|
|
98
103
|
}
|
|
99
104
|
const batchUpdate = defineTool({
|
|
100
105
|
name: "batch_update",
|
|
@@ -117,6 +122,8 @@ const batchUpdate = defineTool({
|
|
|
117
122
|
const node = figma.getNodeById(op.id);
|
|
118
123
|
if (!node) return nodeNotFound(op.id);
|
|
119
124
|
if (figma.graph.getNode(op.id)?.type === "CANVAS" && LAYOUT_PROPS.some((key) => op.props[key] !== void 0)) return { error: `A page cannot hold auto layout. Set it on a frame inside the page (${op.id}).` };
|
|
125
|
+
const refusal = op.props.overflow_direction === void 0 ? null : scrollRefusal(node);
|
|
126
|
+
if (refusal) return { error: refusal };
|
|
120
127
|
targets.push({
|
|
121
128
|
node,
|
|
122
129
|
props: op.props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch.js","names":[],"sources":["../../../src/tools/structure/batch.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { LayoutAlign } from '@pairdraw/scene-graph'\n\nimport type { FigmaNodeProxy } from '#core/figma-api'\nimport { textFonts } from '#core/tools/modify/text'\nimport { defineTool, nodeNotFound, toolNumber } from '#core/tools/schema'\n\nconst nonNegative = () => toolNumber(v.pipe(v.number(), v.minValue(0)))\n\n/** The primary-axis alignments, from the type the graph stores, so the list cannot drift. */\nconst layoutAligns = [\n 'MIN',\n 'CENTER',\n 'MAX',\n 'SPACE_BETWEEN',\n 'SPACE_AROUND'\n] as const satisfies readonly LayoutAlign[]\n\n/** Every prop an operation may set; anything else rejects the whole batch. */\nconst batchPropsSchema = v.strictObject({\n spacing: v.optional(nonNegative()),\n padding: v.optional(nonNegative()),\n padding_horizontal: v.optional(nonNegative()),\n padding_vertical: v.optional(nonNegative()),\n align: v.optional(v.picklist(layoutAligns)),\n counter_align: v.optional(v.picklist(['MIN', 'CENTER', 'MAX', 'STRETCH'])),\n sizing_horizontal: v.optional(v.picklist(['FIXED', 'HUG', 'FILL'])),\n sizing_vertical: v.optional(v.picklist(['FIXED', 'HUG', 'FILL'])),\n grow: v.optional(nonNegative()),\n name: v.optional(v.string()),\n visible: v.optional(v.boolean()),\n corner_radius: v.optional(nonNegative()),\n opacity: v.optional(toolNumber(v.pipe(v.number(), v.minValue(0), v.maxValue(1)))),\n auto_resize: v.optional(v.picklist(['NONE', 'WIDTH_AND_HEIGHT', 'HEIGHT', 'TRUNCATE'])),\n direction: v.optional(v.picklist(['HORIZONTAL', 'VERTICAL']))\n})\ntype BatchProps = v.InferOutput<typeof batchPropsSchema>\n\nconst batchOpsSchema = v.array(v.strictObject({ id: v.string(), props: batchPropsSchema }))\ntype BatchOp = v.InferOutput<typeof batchOpsSchema>[number]\n\n/** The operations a call names, or every problem with them. */\nfunction parseOperations(operations: BatchOp[] | string): BatchOp[] | { error: string } {\n const result =\n typeof operations === 'string'\n ? v.safeParse(v.pipe(v.string(), v.parseJson(), batchOpsSchema), operations)\n : v.safeParse(batchOpsSchema, operations)\n if (result.success) return result.output\n return { error: `Invalid operations:\\n${v.summarize(result.issues)}` }\n}\n\n/** The props a frame's auto layout holds; a page holds no layout, so it takes none of them. */\nconst LAYOUT_PROPS = [\n 'spacing',\n 'padding',\n 'padding_horizontal',\n 'padding_vertical',\n 'align',\n 'counter_align',\n 'sizing_horizontal',\n 'sizing_vertical',\n 'grow',\n 'direction'\n] as const satisfies readonly (keyof BatchProps)[]\n\nfunction applyBatchProps(node: FigmaNodeProxy, props: BatchProps): void {\n if (props.spacing !== undefined) node.itemSpacing = props.spacing\n if (props.padding !== undefined) {\n node.paddingTop = props.padding\n node.paddingRight = props.padding\n node.paddingBottom = props.padding\n node.paddingLeft = props.padding\n }\n if (props.padding_horizontal !== undefined) {\n node.paddingLeft = props.padding_horizontal\n node.paddingRight = props.padding_horizontal\n }\n if (props.padding_vertical !== undefined) {\n node.paddingTop = props.padding_vertical\n node.paddingBottom = props.padding_vertical\n }\n if (props.align !== undefined) node.primaryAxisAlignItems = props.align\n if (props.counter_align !== undefined) node.counterAxisAlignItems = props.counter_align\n if (props.sizing_horizontal !== undefined) node.layoutSizingHorizontal = props.sizing_horizontal\n if (props.sizing_vertical !== undefined) node.layoutSizingVertical = props.sizing_vertical\n if (props.grow !== undefined) node.layoutGrow = props.grow\n if (props.name !== undefined) node.name = props.name\n if (props.visible !== undefined) node.visible = props.visible\n if (props.corner_radius !== undefined) node.cornerRadius = props.corner_radius\n if (props.opacity !== undefined) node.opacity = props.opacity\n if (props.auto_resize !== undefined) node.textAutoResize = props.auto_resize\n if (props.direction !== undefined) node.layoutMode = props.direction\n}\n\nexport const batchUpdate = defineTool({\n name: 'batch_update',\n\n description:\n 'Execute multiple modifications in one call, all or nothing: if any operation names a missing node or an invalid prop, nothing changes. ' +\n `Each operation is {id, props} where props can include: ${Object.keys(batchPropsSchema.entries).join(', ')}. ` +\n 'Runs all updates with one layout recompute.',\n // A document edit, not an atomic property transaction: the runner rolls a thrown batch back\n // whole at the cost of the layers it touched, and documents past the atomic path's node limit\n // still batch-edit. The validate-then-apply above keeps the call all-or-nothing either way.\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n operations: v.pipe(\n v.union([batchOpsSchema, v.string()]),\n v.description(\n 'Array of {\"id\",\"props\"}, or the same array as a JSON string: [{\"id\":\"0:5\",\"props\":{\"spacing\":8}},{\"id\":\"0:6\",\"props\":{\"sizing_horizontal\":\"FILL\",\"grow\":1}}]'\n )\n )\n }),\n // Text that resizes itself lays out again, so its fonts load first.\n fonts: (figma, { operations }) => {\n const ops = parseOperations(operations)\n if (!Array.isArray(ops)) return []\n return ops.flatMap((op) => (op.props.auto_resize === undefined ? [] : textFonts(figma, op.id)))\n },\n execute(figma, { operations }) {\n const ops = parseOperations(operations)\n if (!Array.isArray(ops)) return ops\n\n // Find every layer before writing, so a missing one leaves the document untouched.\n const targets: Array<{ node: FigmaNodeProxy; props: BatchProps }> = []\n for (const op of ops) {\n const node = figma.getNodeById(op.id)\n if (!node) return nodeNotFound(op.id)\n // Refused before anything is written, so the batch stays all or nothing.\n if (\n figma.graph.getNode(op.id)?.type === 'CANVAS' &&\n LAYOUT_PROPS.some((key) => op.props[key] !== undefined)\n )\n return {\n error: `A page cannot hold auto layout. Set it on a frame inside the page (${op.id}).`\n }\n targets.push({ node, props: op.props })\n }\n\n const results: Array<{ id: string; updated: string[] }> = []\n for (const { node, props } of targets) {\n applyBatchProps(node, props)\n const updated = Object.keys(props)\n if (updated.length > 0) results.push({ id: node.id, updated })\n }\n\n const out: Record<string, unknown> = { updated: results.length }\n if (results.length > 0) out.results = results\n return out\n }\n})\n"],"mappings":";;;;AAQA,MAAM,oBAAoB,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;;AAYtE,MAAM,mBAAmB,EAAE,aAAa;CACtC,SAAS,EAAE,SAAS,YAAY,CAAC;CACjC,SAAS,EAAE,SAAS,YAAY,CAAC;CACjC,oBAAoB,EAAE,SAAS,YAAY,CAAC;CAC5C,kBAAkB,EAAE,SAAS,YAAY,CAAC;CAC1C,OAAO,EAAE,SAAS,EAAE,SAAS;EAb7B;EACA;EACA;EACA;EACA;CASwC,CAAC,CAAC;CAC1C,eAAe,EAAE,SAAS,EAAE,SAAS;EAAC;EAAO;EAAU;EAAO;CAAS,CAAC,CAAC;CACzE,mBAAmB,EAAE,SAAS,EAAE,SAAS;EAAC;EAAS;EAAO;CAAM,CAAC,CAAC;CAClE,iBAAiB,EAAE,SAAS,EAAE,SAAS;EAAC;EAAS;EAAO;CAAM,CAAC,CAAC;CAChE,MAAM,EAAE,SAAS,YAAY,CAAC;CAC9B,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC;CAC3B,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC/B,eAAe,EAAE,SAAS,YAAY,CAAC;CACvC,SAAS,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;CAChF,aAAa,EAAE,SAAS,EAAE,SAAS;EAAC;EAAQ;EAAoB;EAAU;CAAU,CAAC,CAAC;CACtF,WAAW,EAAE,SAAS,EAAE,SA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D,OAAO,EACL,OAAO,sEAAsE,GAAG,GAAG,IACrF;GACF,QAAQ,KAAK;IAAE;IAAM,OAAO,GAAG;GAAM,CAAC;EACxC;EAEA,MAAM,UAAoD,CAAC;EAC3D,KAAK,MAAM,EAAE,MAAM,WAAW,SAAS;GACrC,gBAAgB,MAAM,KAAK;GAC3B,MAAM,UAAU,OAAO,KAAK,KAAK;GACjC,IAAI,QAAQ,SAAS,GAAG,QAAQ,KAAK;IAAE,IAAI,KAAK;IAAI;GAAQ,CAAC;EAC/D;EAEA,MAAM,MAA+B,EAAE,SAAS,QAAQ,OAAO;EAC/D,IAAI,QAAQ,SAAS,GAAG,IAAI,UAAU;EACtC,OAAO;CACT;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"batch.js","names":[],"sources":["../../../src/tools/structure/batch.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { LayoutAlign } from '@pairdraw/scene-graph'\n\nimport type { FigmaNodeProxy } from '#core/figma-api'\nimport { textFonts } from '#core/tools/modify/text'\nimport {\n overflowDirectionInput,\n scrollBehaviorInput,\n scrollRefusal\n} from '#core/tools/modify/update'\nimport { defineTool, nodeNotFound, toolNumber } from '#core/tools/schema'\n\nconst nonNegative = () => toolNumber(v.pipe(v.number(), v.minValue(0)))\n\n/** The primary-axis alignments, from the type the graph stores, so the list cannot drift. */\nconst layoutAligns = [\n 'MIN',\n 'CENTER',\n 'MAX',\n 'SPACE_BETWEEN',\n 'SPACE_AROUND'\n] as const satisfies readonly LayoutAlign[]\n\n/** Every prop an operation may set; anything else rejects the whole batch. */\nconst batchPropsSchema = v.strictObject({\n spacing: v.optional(nonNegative()),\n padding: v.optional(nonNegative()),\n padding_horizontal: v.optional(nonNegative()),\n padding_vertical: v.optional(nonNegative()),\n align: v.optional(v.picklist(layoutAligns)),\n counter_align: v.optional(v.picklist(['MIN', 'CENTER', 'MAX', 'STRETCH'])),\n sizing_horizontal: v.optional(v.picklist(['FIXED', 'HUG', 'FILL'])),\n sizing_vertical: v.optional(v.picklist(['FIXED', 'HUG', 'FILL'])),\n grow: v.optional(nonNegative()),\n name: v.optional(v.string()),\n visible: v.optional(v.boolean()),\n corner_radius: v.optional(nonNegative()),\n opacity: v.optional(toolNumber(v.pipe(v.number(), v.minValue(0), v.maxValue(1)))),\n auto_resize: v.optional(v.picklist(['NONE', 'WIDTH_AND_HEIGHT', 'HEIGHT', 'TRUNCATE'])),\n direction: v.optional(v.picklist(['HORIZONTAL', 'VERTICAL'])),\n overflow_direction: v.optional(overflowDirectionInput()),\n scroll_behavior: v.optional(scrollBehaviorInput())\n})\ntype BatchProps = v.InferOutput<typeof batchPropsSchema>\n\nconst batchOpsSchema = v.array(v.strictObject({ id: v.string(), props: batchPropsSchema }))\ntype BatchOp = v.InferOutput<typeof batchOpsSchema>[number]\n\n/** The operations a call names, or every problem with them. */\nfunction parseOperations(operations: BatchOp[] | string): BatchOp[] | { error: string } {\n const result =\n typeof operations === 'string'\n ? v.safeParse(v.pipe(v.string(), v.parseJson(), batchOpsSchema), operations)\n : v.safeParse(batchOpsSchema, operations)\n if (result.success) return result.output\n return { error: `Invalid operations:\\n${v.summarize(result.issues)}` }\n}\n\n/** The props a frame's auto layout holds; a page holds no layout, so it takes none of them. */\nconst LAYOUT_PROPS = [\n 'spacing',\n 'padding',\n 'padding_horizontal',\n 'padding_vertical',\n 'align',\n 'counter_align',\n 'sizing_horizontal',\n 'sizing_vertical',\n 'grow',\n 'direction'\n] as const satisfies readonly (keyof BatchProps)[]\n\nfunction applyBatchProps(node: FigmaNodeProxy, props: BatchProps): void {\n if (props.spacing !== undefined) node.itemSpacing = props.spacing\n if (props.padding !== undefined) {\n node.paddingTop = props.padding\n node.paddingRight = props.padding\n node.paddingBottom = props.padding\n node.paddingLeft = props.padding\n }\n if (props.padding_horizontal !== undefined) {\n node.paddingLeft = props.padding_horizontal\n node.paddingRight = props.padding_horizontal\n }\n if (props.padding_vertical !== undefined) {\n node.paddingTop = props.padding_vertical\n node.paddingBottom = props.padding_vertical\n }\n if (props.align !== undefined) node.primaryAxisAlignItems = props.align\n if (props.counter_align !== undefined) node.counterAxisAlignItems = props.counter_align\n if (props.sizing_horizontal !== undefined) node.layoutSizingHorizontal = props.sizing_horizontal\n if (props.sizing_vertical !== undefined) node.layoutSizingVertical = props.sizing_vertical\n if (props.grow !== undefined) node.layoutGrow = props.grow\n if (props.name !== undefined) node.name = props.name\n if (props.visible !== undefined) node.visible = props.visible\n if (props.corner_radius !== undefined) node.cornerRadius = props.corner_radius\n if (props.opacity !== undefined) node.opacity = props.opacity\n if (props.auto_resize !== undefined) node.textAutoResize = props.auto_resize\n if (props.direction !== undefined) node.layoutMode = props.direction\n if (props.overflow_direction !== undefined) node.overflowDirection = props.overflow_direction\n if (props.scroll_behavior !== undefined) node.scrollBehavior = props.scroll_behavior\n}\n\nexport const batchUpdate = defineTool({\n name: 'batch_update',\n\n description:\n 'Execute multiple modifications in one call, all or nothing: if any operation names a missing node or an invalid prop, nothing changes. ' +\n `Each operation is {id, props} where props can include: ${Object.keys(batchPropsSchema.entries).join(', ')}. ` +\n 'Runs all updates with one layout recompute.',\n // A document edit, not an atomic property transaction: the runner rolls a thrown batch back\n // whole at the cost of the layers it touched, and documents past the atomic path's node limit\n // still batch-edit. The validate-then-apply above keeps the call all-or-nothing either way.\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n operations: v.pipe(\n v.union([batchOpsSchema, v.string()]),\n v.description(\n 'Array of {\"id\",\"props\"}, or the same array as a JSON string: [{\"id\":\"0:5\",\"props\":{\"spacing\":8}},{\"id\":\"0:6\",\"props\":{\"sizing_horizontal\":\"FILL\",\"grow\":1}}]'\n )\n )\n }),\n // Text that resizes itself lays out again, so its fonts load first.\n fonts: (figma, { operations }) => {\n const ops = parseOperations(operations)\n if (!Array.isArray(ops)) return []\n return ops.flatMap((op) => (op.props.auto_resize === undefined ? [] : textFonts(figma, op.id)))\n },\n execute(figma, { operations }) {\n const ops = parseOperations(operations)\n if (!Array.isArray(ops)) return ops\n\n // Find every layer before writing, so a missing one leaves the document untouched.\n const targets: Array<{ node: FigmaNodeProxy; props: BatchProps }> = []\n for (const op of ops) {\n const node = figma.getNodeById(op.id)\n if (!node) return nodeNotFound(op.id)\n // Refused before anything is written, so the batch stays all or nothing.\n if (\n figma.graph.getNode(op.id)?.type === 'CANVAS' &&\n LAYOUT_PROPS.some((key) => op.props[key] !== undefined)\n )\n return {\n error: `A page cannot hold auto layout. Set it on a frame inside the page (${op.id}).`\n }\n const refusal = op.props.overflow_direction === undefined ? null : scrollRefusal(node)\n if (refusal) return { error: refusal }\n targets.push({ node, props: op.props })\n }\n\n const results: Array<{ id: string; updated: string[] }> = []\n for (const { node, props } of targets) {\n applyBatchProps(node, props)\n const updated = Object.keys(props)\n if (updated.length > 0) results.push({ id: node.id, updated })\n }\n\n const out: Record<string, unknown> = { updated: results.length }\n if (results.length > 0) out.results = results\n return out\n }\n})\n"],"mappings":";;;;;AAaA,MAAM,oBAAoB,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;;AAYtE,MAAM,mBAAmB,EAAE,aAAa;CACtC,SAAS,EAAE,SAAS,YAAY,CAAC;CACjC,SAAS,EAAE,SAAS,YAAY,CAAC;CACjC,oBAAoB,EAAE,SAAS,YAAY,CAAC;CAC5C,kBAAkB,EAAE,SAAS,YAAY,CAAC;CAC1C,OAAO,EAAE,SAAS,EAAE,SAAS;EAb7B;EACA;EACA;EACA;EACA;CASwC,CAAC,CAAC;CAC1C,eAAe,EAAE,SAAS,EAAE,SAAS;EAAC;EAAO;EAAU;EAAO;CAAS,CAAC,CAAC;CACzE,mBAAmB,EAAE,SAAS,EAAE,SAAS;EAAC;EAAS;EAAO;CAAM,CAAC,CAAC;CAClE,iBAAiB,EAAE,SAAS,EAAE,SAAS;EAAC;EAAS;EAAO;CAAM,CAAC,CAAC;CAChE,MAAM,EAAE,SAAS,YAAY,CAAC;CAC9B,MAAM,EAAE,SAAS,EA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{"version":3,"file":"hierarchy.d.ts","names":[],"sources":["../../../src/tools/structure/hierarchy.ts"],"mappings":";;cAIa,cAAA;cAmBA,YAAA;cAkBA,aAAA;cAiBA,cAAA;cAgBA,iBAAA"}
|
|
@@ -31,6 +31,7 @@ const groupNodes = defineTool({
|
|
|
31
31
|
kind: "sync",
|
|
32
32
|
mutation: "document"
|
|
33
33
|
},
|
|
34
|
+
content: "copied",
|
|
34
35
|
input: v.strictObject({ ids: v.pipe(v.array(v.string()), v.minLength(2), v.description("Node IDs to group")) }),
|
|
35
36
|
execute: (figma, { ids }) => {
|
|
36
37
|
const nodes = requireNodes(figma, ids);
|
|
@@ -47,6 +48,7 @@ const ungroupNode = defineTool({
|
|
|
47
48
|
kind: "sync",
|
|
48
49
|
mutation: "document"
|
|
49
50
|
},
|
|
51
|
+
content: "copied",
|
|
50
52
|
input: v.strictObject({ id: v.pipe(v.string(), v.description("Group node ID")) }),
|
|
51
53
|
execute: (figma, { id }) => {
|
|
52
54
|
const node = figma.getNodeById(id);
|
|
@@ -62,6 +64,7 @@ const flattenNodes = defineTool({
|
|
|
62
64
|
kind: "sync",
|
|
63
65
|
mutation: "document"
|
|
64
66
|
},
|
|
67
|
+
content: "merged",
|
|
65
68
|
input: v.strictObject({ ids: v.pipe(v.array(v.string()), v.minLength(1), v.description("Node IDs to flatten")) }),
|
|
66
69
|
execute: (figma, { ids }) => {
|
|
67
70
|
const nodes = requireNodes(figma, ids);
|
|
@@ -76,6 +79,7 @@ const nodeToComponent = defineTool({
|
|
|
76
79
|
kind: "sync",
|
|
77
80
|
mutation: "document"
|
|
78
81
|
},
|
|
82
|
+
content: "copied",
|
|
79
83
|
input: v.strictObject({ ids: v.pipe(v.array(v.string()), v.minLength(1), v.description("Node IDs to convert")) }),
|
|
80
84
|
execute: (figma, { ids }) => {
|
|
81
85
|
const results = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hierarchy.js","names":[],"sources":["../../../src/tools/structure/hierarchy.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { defineTool, nodeSummary, requireNodes } from '#core/tools/schema'\n\nexport const reparentNode = defineTool({\n name: 'reparent_node',\n\n description: 'Move a node into a different parent.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Node ID to move')),\n parent_id: v.pipe(v.string(), v.description('New parent node ID'))\n }),\n execute: (figma, { id, parent_id }) => {\n const node = figma.getNodeById(id)\n const parent = figma.getNodeById(parent_id)\n if (!node) return { error: `Node \"${id}\" not found` }\n if (!parent) return { error: `Parent \"${parent_id}\" not found` }\n parent.appendChild(node)\n return { id, parent_id }\n }\n})\n\nexport const groupNodes = defineTool({\n name: 'group_nodes',\n\n description: 'Group selected nodes.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n ids: v.pipe(v.array(v.string()), v.minLength(2), v.description('Node IDs to group'))\n }),\n execute: (figma, { ids }) => {\n const nodes = requireNodes(figma, ids)\n if (!nodes || nodes.length < 2) return { error: 'Need at least 2 nodes to group' }\n const parent = nodes[0].parent ?? figma.currentPage\n const group = figma.group(nodes, parent)\n return nodeSummary(group)\n }\n})\n\nexport const ungroupNode = defineTool({\n name: 'ungroup_node',\n\n description: 'Ungroup a group node.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Group node ID'))\n }),\n execute: (figma, { id }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n figma.ungroup(node)\n return { ungrouped: id }\n }\n})\n\nexport const flattenNodes = defineTool({\n name: 'flatten_nodes',\n\n description: 'Flatten nodes into a single vector.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n ids: v.pipe(v.array(v.string()), v.minLength(1), v.description('Node IDs to flatten'))\n }),\n execute: (figma, { ids }) => {\n const nodes = requireNodes(figma, ids)\n if (!nodes) return { error: 'One or more node IDs were not found' }\n return nodeSummary(figma.flatten(nodes, nodes[0].parent ?? figma.currentPage))\n }\n})\n\nexport const nodeToComponent = defineTool({\n name: 'node_to_component',\n\n description: 'Convert one or more frames/groups into components.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n ids: v.pipe(v.array(v.string()), v.minLength(1), v.description('Node IDs to convert'))\n }),\n execute: (figma, { ids }) => {\n const results: { id: string; name: string; originalId: string }[] = []\n for (const id of ids) {\n const node = figma.getNodeById(id)\n if (!node) continue\n const comp = figma.createComponentFromNode(node)\n results.push({ id: comp.id, name: comp.name, originalId: id })\n }\n return { converted: results }\n }\n})\n"],"mappings":";;;AAIA,MAAa,eAAe,WAAW;CACrC,MAAM;CAEN,aAAa;CACb,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa;EACpB,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,iBAAiB,CAAC;EACvD,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,oBAAoB,CAAC;CACnE,CAAC;CACD,UAAU,OAAO,EAAE,IAAI,gBAAgB;EACrC,MAAM,OAAO,MAAM,YAAY,EAAE;EACjC,MAAM,SAAS,MAAM,YAAY,SAAS;EAC1C,IAAI,CAAC,MAAM,OAAO,EAAE,OAAO,SAAS,GAAG,aAAa;EACpD,IAAI,CAAC,QAAQ,OAAO,EAAE,OAAO,WAAW,UAAU,aAAa;EAC/D,OAAO,YAAY,IAAI;EACvB,OAAO;GAAE;GAAI;EAAU;CACzB;AACF,CAAC;AAED,MAAa,aAAa,WAAW;CACnC,MAAM;CAEN,aAAa;CACb,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa,EACpB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,mBAAmB,CAAC,EACrF,CAAC;CACD,UAAU,OAAO,EAAE,UAAU;EAC3B,MAAM,QAAQ,aAAa,O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AE,UAAU,CAAC,GAAG,EAAE,YAAY,qBAAqB,CAAC,EACvF,CAAC;CACD,UAAU,OAAO,EAAE,UAAU;EAC3B,MAAM,UAA8D,CAAC;EACrE,KAAK,MAAM,MAAM,KAAK;GACpB,MAAM,OAAO,MAAM,YAAY,EAAE;GACjC,IAAI,CAAC,MAAM;GACX,MAAM,OAAO,MAAM,wBAAwB,IAAI;GAC/C,QAAQ,KAAK;IAAE,IAAI,KAAK;IAAI,MAAM,KAAK;IAAM,YAAY;GAAG,CAAC;EAC/D;EACA,OAAO,EAAE,WAAW,QAAQ;CAC9B;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"hierarchy.js","names":[],"sources":["../../../src/tools/structure/hierarchy.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { defineTool, nodeSummary, requireNodes } from '#core/tools/schema'\n\nexport const reparentNode = defineTool({\n name: 'reparent_node',\n\n description: 'Move a node into a different parent.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Node ID to move')),\n parent_id: v.pipe(v.string(), v.description('New parent node ID'))\n }),\n execute: (figma, { id, parent_id }) => {\n const node = figma.getNodeById(id)\n const parent = figma.getNodeById(parent_id)\n if (!node) return { error: `Node \"${id}\" not found` }\n if (!parent) return { error: `Parent \"${parent_id}\" not found` }\n parent.appendChild(node)\n return { id, parent_id }\n }\n})\n\nexport const groupNodes = defineTool({\n name: 'group_nodes',\n\n description: 'Group selected nodes.',\n execution: { kind: 'sync', mutation: 'document' },\n content: 'copied',\n input: v.strictObject({\n ids: v.pipe(v.array(v.string()), v.minLength(2), v.description('Node IDs to group'))\n }),\n execute: (figma, { ids }) => {\n const nodes = requireNodes(figma, ids)\n if (!nodes || nodes.length < 2) return { error: 'Need at least 2 nodes to group' }\n const parent = nodes[0].parent ?? figma.currentPage\n const group = figma.group(nodes, parent)\n return nodeSummary(group)\n }\n})\n\nexport const ungroupNode = defineTool({\n name: 'ungroup_node',\n\n description: 'Ungroup a group node.',\n execution: { kind: 'sync', mutation: 'document' },\n content: 'copied',\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Group node ID'))\n }),\n execute: (figma, { id }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n figma.ungroup(node)\n return { ungrouped: id }\n }\n})\n\nexport const flattenNodes = defineTool({\n name: 'flatten_nodes',\n\n description: 'Flatten nodes into a single vector.',\n execution: { kind: 'sync', mutation: 'document' },\n content: 'merged',\n input: v.strictObject({\n ids: v.pipe(v.array(v.string()), v.minLength(1), v.description('Node IDs to flatten'))\n }),\n execute: (figma, { ids }) => {\n const nodes = requireNodes(figma, ids)\n if (!nodes) return { error: 'One or more node IDs were not found' }\n return nodeSummary(figma.flatten(nodes, nodes[0].parent ?? figma.currentPage))\n }\n})\n\nexport const nodeToComponent = defineTool({\n name: 'node_to_component',\n\n description: 'Convert one or more frames/groups into components.',\n execution: { kind: 'sync', mutation: 'document' },\n content: 'copied',\n input: v.strictObject({\n ids: v.pipe(v.array(v.string()), v.minLength(1), v.description('Node IDs to convert'))\n }),\n execute: (figma, { ids }) => {\n const results: { id: string; name: string; originalId: string }[] = []\n for (const id of ids) {\n const node = figma.getNodeById(id)\n if (!node) continue\n const comp = figma.createComponentFromNode(node)\n results.push({ id: comp.id, name: comp.name, originalId: id })\n }\n return { converted: results }\n }\n})\n"],"mappings":";;;AAIA,MAAa,eAAe,WAAW;CACrC,MAAM;CAEN,aAAa;CACb,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa;EACpB,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,iBAAiB,CAAC;EACvD,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,oBAAoB,CAAC;CACnE,CAAC;CACD,UAAU,OAAO,EAAE,IAAI,gBAAgB;EACrC,MAAM,OAAO,MAAM,YAAY,EAAE;EACjC,MAAM,SAAS,MAAM,YAAY,SA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,aAAa,EACpB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,qBAAqB,CAAC,EACvF,CAAC;CACD,UAAU,OAAO,EAAE,UAAU;EAC3B,MAAM,QAAQ,aAAa,OAAO,GAAG;EACrC,IAAI,CAAC,OAAO,OAAO,EAAE,OAAO,sCAAsC;EAClE,OAAO,YAAY,MAAM,QAAQ,OAAO,MAAM,EAAE,CAAC,UAAU,MAAM,WAAW,CAAC;CAC/E;AACF,CAAC;AAED,MAAa,kBAAkB,WAAW;CACxC,MAAM;CAEN,aAAa;CACb,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,SAAS;CACT,OAAO,EAAE,aAAa,EACpB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,qBAAqB,CAAC,EACvF,CAAC;CACD,UAAU,OAAO,EAAE,UAAU;EAC3B,MAAM,UAA8D,CAAC;EACrE,KAAK,MAAM,MAAM,KAAK;GACpB,MAAM,OAAO,MAAM,YAAY,EAAE;GACjC,IAAI,CAAC,MAAM;GACX,MAAM,OAAO,MAAM,wBAAwB,IAAI;GAC/C,QAAQ,KAAK;IAAE,IAAI,KAAK;IAAI,MAAM,KAAK;IAAM,YAAY;GAAG,CAAC;EAC/D;EACA,OAAO,EAAE,WAAW,QAAQ;CAC9B;AACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ToolDef } from "../schema.js";
|
|
2
|
+
//#region src/tools/structure/variations.d.ts
|
|
3
|
+
declare const createVariationsTool: ToolDef;
|
|
4
|
+
declare const listVariations: ToolDef;
|
|
5
|
+
declare const pickVariation: ToolDef;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createVariationsTool, listVariations, pickVariation };
|
|
8
|
+
//# sourceMappingURL=variations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variations.d.ts","names":[],"sources":["../../../src/tools/structure/variations.ts"],"mappings":";;cAoBa,sBAAA;cA+CA,gBAAA;cAqBA,eAAA"}
|