@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","names":[],"sources":["../../../src/tools/create/icons.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { iconOptionsSchema, type IconOptions } from '@pairdraw/scene-graph/icons'\n\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { placeIcon } from '#core/icons'\nimport { defineTool, parseToolColor, toolNumber } from '#core/tools/schema'\n\nexport const fetchIconsTool = defineTool({\n name: 'fetch_icons',\n exposure: { webmcp: false },\n description:\n 'Pre-fetch icons from Iconify into cache. Batches by prefix (one HTTP request per set). Call this once with all needed icons, then use insert_icon to place them instantly. Popular sets: lucide (outline), mdi (filled), heroicons, tabler, solar, mingcute, ri (remix).',\n execution: { kind: 'async', mutation: 'none' },\n capabilities: ['network:access'],\n input: v.strictObject({\n names: v.pipe(\n v.array(v.string()),\n v.minLength(1),\n v.description('Icon names as prefix:name (e.g. [\"lucide:heart\", \"lucide:home\", \"mdi:star\"])')\n ),\n size: v.optional(\n toolNumber(v.pipe(v.number(), v.description('Icon size in pixels (default: 24)')))\n )\n }),\n execute: async (figma, args) => {\n const size = args.size ?? 24\n try {\n const icons = await figma.icons.icons(args.names, size)\n const fetched = [...icons.keys()]\n const notFound = args.names.filter((name) => !icons.has(name))\n const result: Record<string, unknown> = { fetched, count: fetched.length }\n if (notFound.length > 0) result.not_found = notFound\n return result\n } catch (e) {\n return { error: (e as Error).message }\n }\n }\n})\n\n/**\n * How a set with options draws its icons, as Material Symbols' variable axes. Sets without\n * options ignore them; a value outside an axis is clamped to it.\n */\nconst iconOptionInputs = {\n weight: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.description('Stroke weight, 100 to 700 (Material Symbols; default: 400)')\n )\n )\n ),\n fill: v.optional(\n v.pipe(v.boolean(), v.description('Filled rather than outlined (Material Symbols)'))\n ),\n grade: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.description('Grade, -50 to 200: thickness without resizing (Material Symbols)')\n )\n )\n ),\n optical_size: v.optional(\n toolNumber(\n v.pipe(v.number(), v.description('Optical size, 20 to 48 (Material Symbols; default: 24)'))\n )\n ),\n options: v.optional(\n v.pipe(\n iconOptionsSchema,\n v.description(\n 'Other options of a set that has them, by key, such as an SF Symbols weight or scale'\n )\n )\n )\n}\n\n/** The named options as the axes a set reads, over any given by key. */\nfunction iconOptions(args: {\n weight?: number\n fill?: boolean\n grade?: number\n optical_size?: number\n options?: IconOptions\n}): IconOptions | undefined {\n const options: IconOptions = { ...args.options }\n if (args.optical_size !== undefined) options.opsz = args.optical_size\n if (args.weight !== undefined) options.wght = args.weight\n if (args.fill !== undefined) options.FILL = args.fill ? 1 : 0\n if (args.grade !== undefined) options.GRAD = args.grade\n return Object.keys(options).length > 0 ? options : undefined\n}\n\nexport const insertIcon = defineTool({\n name: 'insert_icon',\n\n description:\n 'Insert one or more vector icons onto the canvas. Pass a single name or multiple names to batch-insert into the same parent. If already cached by fetch_icons — instant, no network request. Material Symbols icons (material-symbols-outlined, -rounded, -sharp) take weight, fill, grade, and optical_size; the icon keeps them when swapped.',\n execution: { kind: 'async', mutation: 'document' },\n capabilities: ['document:write', 'network:access'],\n input: v.strictObject({\n names: v.optional(\n v.pipe(\n v.array(v.string()),\n v.minLength(1),\n v.description(\n 'Icon names as prefix:name (e.g. [\"lucide:heart\"] or [\"lucide:heart\",\"lucide:home\",\"lucide:star\"])'\n )\n )\n ),\n name: v.optional(\n v.pipe(v.string(), v.description('Single icon name (shorthand for names with one icon)'))\n ),\n size: v.optional(\n toolNumber(v.pipe(v.number(), v.description('Icon size in pixels (default: 24)')))\n ),\n color: v.optional(\n v.pipe(v.string(), v.description('Icon color hex (replaces currentColor). Default: #000000'))\n ),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID for all icons'))),\n x: v.optional(toolNumber(v.pipe(v.number(), v.description('X position in the parent')))),\n y: v.optional(toolNumber(v.pipe(v.number(), v.description('Y position in the parent')))),\n ...iconOptionInputs\n }),\n execute: async (figma, args) => {\n const names = args.names ?? (args.name ? [args.name] : [])\n if (names.length === 0) return { error: 'Provide \"names\" (array) or \"name\" (string)' }\n\n const size = args.size ?? 24\n const parsedColor = parseToolColor(args.color ?? '#000000')\n if ('error' in parsedColor) return parsedColor\n const options = iconOptions(args)\n\n let icons\n try {\n icons = await figma.icons.icons(names, size, options)\n } catch (e) {\n return { error: (e as Error).message }\n }\n\n const inserted: { id: string; name: string; icon: string }[] = []\n const notFound: string[] = []\n\n const parentId = args.parent_id ?? figma.currentPage.id\n prepareSlotInsertion(figma.graph, parentId, 'insert_icon')\n for (const name of names) {\n const icon = icons.get(name)\n if (!icon || icon.paths.length === 0) {\n notFound.push(name)\n continue\n }\n // A position puts the icon there; without one, its parent's layout places it.\n const overrides =\n args.x === undefined && args.y === undefined ? {} : { x: args.x ?? 0, y: args.y ?? 0 }\n const frame = placeIcon(figma.graph, parentId, icon, {\n size,\n color: parsedColor,\n overrides\n })\n inserted.push({ id: frame.id, name: frame.name, icon: name })\n }\n\n if (args.name && inserted.length === 1) {\n return { id: inserted[0].id, name: inserted[0].name, type: 'FRAME' as const }\n }\n\n const result: Record<string, unknown> = { inserted }\n if (notFound.length > 0) result.not_found = notFound\n return result\n }\n})\n\nexport const searchIconsTool = defineTool({\n name: 'search_icons',\n exposure: { webmcp: false },\n description:\n 'Search Iconify for icons by keyword. Accepts multiple queries — all searched in parallel. Returns results keyed by query.',\n execution: { kind: 'async', mutation: 'none' },\n capabilities: ['network:access'],\n input: v.strictObject({\n queries: v.pipe(\n v.array(v.string()),\n v.minLength(1),\n v.description('Search keywords (e.g. [\"heart\", \"arrow\", \"settings\"])')\n ),\n limit: v.optional(\n toolNumber(v.pipe(v.number(), v.description('Max results per query (default: 5)')))\n ),\n prefix: v.optional(\n v.pipe(v.string(), v.description('Filter by icon set prefix (e.g. \"lucide\", \"mdi\")'))\n )\n }),\n execute: async (figma, args) => {\n try {\n const options = { limit: args.limit ?? 5, prefix: args.prefix }\n const results = await Promise.all(\n args.queries.map(\n async (query) => [query, await figma.icons.search(query, options)] as const\n )\n )\n return Object.fromEntries(\n results.map(([query, result]) => [query, { icons: result.icons, total: result.total }])\n )\n } catch (e) {\n return { error: (e as Error).message }\n }\n }\n})\n"],"mappings":";;;;;;AAQA,MAAa,iBAAiB,WAAW;CACvC,MAAM;CACN,UAAU,EAAE,QAAQ,MAAM;CAC1B,aACE;CACF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAO;CAC7C,cAAc,CAAC,gBAAgB;CAC/B,OAAO,EAAE,aAAa;EACpB,OAAO,EAAE,KACP,EAAE,MAAM,EAAE,OAAO,CAAC,GAClB,EAAE,UAAU,CAAC,GACb,EAAE,YAAY,oFAA8E,CAC9F;EACA,MAAM,EAAE,SACN,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,mCAAmC,CAAC,CAAC,CACnF;CACF,CAAC;CACD,SAAS,OAAO,OAAO,SAAS;EAC9B,MAAM,OAAO,KAAK,QAAQ;EAC1B,IAAI;GACF,MAAM,QAAQ,MAAM,MAAM,MAAM,MAAM,KAAK,OAAO,IAAI;GACtD,MAAM,UAAU,CAAC,GAAG,MAAM,KAAK,CAAC;GAChC,MAAM,WAAW,KAAK,MAAM,QAAQ,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC;GAC7D,MAAM,SAAkC;IAAE;IAAS,OAAO,QAAQ;GAAO;GACzE,IAAI,SAAS,SAAS,GAAG,OAAO,YAAY;GAC5C,OAAO;EACT,SAAS,GAAG;GACV,OAAO,EAAE,OAAQ,EAAY,QAAQ;EACvC;CACF;AACF,CAAC;;;;;AAMD,MAAM,mBAAmB;CACvB,QAAQ,EAAE,SACR,WACE,EAAE,KACA,EAAE,OAAO,GACT,EAAE,YAAY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AG;GACV,OAAO,EAAE,OAAQ,EAAY,QAAQ;EACvC;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"icons.js","names":[],"sources":["../../../src/tools/create/icons.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { iconOptionsSchema, type IconOptions } from '@pairdraw/scene-graph/icons'\n\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { placeIcon } from '#core/icons'\nimport { defineTool, parseToolColor, toolNumber } from '#core/tools/schema'\n\nexport const fetchIconsTool = defineTool({\n name: 'fetch_icons',\n exposure: { webmcp: false },\n description:\n 'Pre-fetch icons from Iconify into cache. Batches by prefix (one HTTP request per set). Call this once with all needed icons, then use insert_icon to place them instantly. Popular sets: lucide (outline), mdi (filled), heroicons, tabler, solar, mingcute, ri (remix).',\n execution: { kind: 'async', mutation: 'none' },\n capabilities: ['network:access'],\n input: v.strictObject({\n names: v.pipe(\n v.array(v.string()),\n v.minLength(1),\n v.description('Icon names as prefix:name (e.g. [\"lucide:heart\", \"lucide:home\", \"mdi:star\"])')\n ),\n size: v.optional(\n toolNumber(v.pipe(v.number(), v.description('Icon size in pixels (default: 24)')))\n )\n }),\n execute: async (figma, args) => {\n const size = args.size ?? 24\n try {\n const icons = await figma.icons.icons(args.names, size)\n const fetched = [...icons.keys()]\n const notFound = args.names.filter((name) => !icons.has(name))\n const result: Record<string, unknown> = { fetched, count: fetched.length }\n if (notFound.length > 0) result.not_found = notFound\n return result\n } catch (e) {\n return { error: (e as Error).message }\n }\n }\n})\n\n/**\n * How a set with options draws its icons, as Material Symbols' variable axes. Sets without\n * options ignore them; a value outside an axis is clamped to it.\n */\nconst iconOptionInputs = {\n weight: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.description('Stroke weight, 100 to 700 (Material Symbols; default: 400)')\n )\n )\n ),\n fill: v.optional(\n v.pipe(v.boolean(), v.description('Filled rather than outlined (Material Symbols)'))\n ),\n grade: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.description('Grade, -50 to 200: thickness without resizing (Material Symbols)')\n )\n )\n ),\n optical_size: v.optional(\n toolNumber(\n v.pipe(v.number(), v.description('Optical size, 20 to 48 (Material Symbols; default: 24)'))\n )\n ),\n options: v.optional(\n v.pipe(\n iconOptionsSchema,\n v.description(\n 'Other options of a set that has them, by key, such as an SF Symbols weight or scale'\n )\n )\n )\n}\n\n/** The named options as the axes a set reads, over any given by key. */\nfunction iconOptions(args: {\n weight?: number\n fill?: boolean\n grade?: number\n optical_size?: number\n options?: IconOptions\n}): IconOptions | undefined {\n const options: IconOptions = { ...args.options }\n if (args.optical_size !== undefined) options.opsz = args.optical_size\n if (args.weight !== undefined) options.wght = args.weight\n if (args.fill !== undefined) options.FILL = args.fill ? 1 : 0\n if (args.grade !== undefined) options.GRAD = args.grade\n return Object.keys(options).length > 0 ? options : undefined\n}\n\nexport const insertIcon = defineTool({\n name: 'insert_icon',\n\n description:\n 'Insert one or more vector icons onto the canvas. Pass a single name or multiple names to batch-insert into the same parent. If already cached by fetch_icons — instant, no network request. Material Symbols icons (material-symbols-outlined, -rounded, -sharp) take weight, fill, grade, and optical_size; the icon keeps them when swapped.',\n execution: { kind: 'async', mutation: 'document' },\n content: 'imported',\n capabilities: ['document:write', 'network:access'],\n input: v.strictObject({\n names: v.optional(\n v.pipe(\n v.array(v.string()),\n v.minLength(1),\n v.description(\n 'Icon names as prefix:name (e.g. [\"lucide:heart\"] or [\"lucide:heart\",\"lucide:home\",\"lucide:star\"])'\n )\n )\n ),\n name: v.optional(\n v.pipe(v.string(), v.description('Single icon name (shorthand for names with one icon)'))\n ),\n size: v.optional(\n toolNumber(v.pipe(v.number(), v.description('Icon size in pixels (default: 24)')))\n ),\n color: v.optional(\n v.pipe(v.string(), v.description('Icon color hex (replaces currentColor). Default: #000000'))\n ),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID for all icons'))),\n x: v.optional(toolNumber(v.pipe(v.number(), v.description('X position in the parent')))),\n y: v.optional(toolNumber(v.pipe(v.number(), v.description('Y position in the parent')))),\n ...iconOptionInputs\n }),\n execute: async (figma, args) => {\n const names = args.names ?? (args.name ? [args.name] : [])\n if (names.length === 0) return { error: 'Provide \"names\" (array) or \"name\" (string)' }\n\n const size = args.size ?? 24\n const parsedColor = parseToolColor(args.color ?? '#000000')\n if ('error' in parsedColor) return parsedColor\n const options = iconOptions(args)\n\n let icons\n try {\n icons = await figma.icons.icons(names, size, options)\n } catch (e) {\n return { error: (e as Error).message }\n }\n\n const inserted: { id: string; name: string; icon: string }[] = []\n const notFound: string[] = []\n\n const parentId = args.parent_id ?? figma.currentPage.id\n prepareSlotInsertion(figma.graph, parentId, 'insert_icon')\n for (const name of names) {\n const icon = icons.get(name)\n if (!icon || icon.paths.length === 0) {\n notFound.push(name)\n continue\n }\n // A position puts the icon there; without one, its parent's layout places it.\n const overrides =\n args.x === undefined && args.y === undefined ? {} : { x: args.x ?? 0, y: args.y ?? 0 }\n const frame = placeIcon(figma.graph, parentId, icon, {\n size,\n color: parsedColor,\n overrides\n })\n inserted.push({ id: frame.id, name: frame.name, icon: name })\n }\n\n if (args.name && inserted.length === 1) {\n return { id: inserted[0].id, name: inserted[0].name, type: 'FRAME' as const }\n }\n\n const result: Record<string, unknown> = { inserted }\n if (notFound.length > 0) result.not_found = notFound\n return result\n }\n})\n\nexport const searchIconsTool = defineTool({\n name: 'search_icons',\n exposure: { webmcp: false },\n description:\n 'Search Iconify for icons by keyword. Accepts multiple queries — all searched in parallel. Returns results keyed by query.',\n execution: { kind: 'async', mutation: 'none' },\n capabilities: ['network:access'],\n input: v.strictObject({\n queries: v.pipe(\n v.array(v.string()),\n v.minLength(1),\n v.description('Search keywords (e.g. [\"heart\", \"arrow\", \"settings\"])')\n ),\n limit: v.optional(\n toolNumber(v.pipe(v.number(), v.description('Max results per query (default: 5)')))\n ),\n prefix: v.optional(\n v.pipe(v.string(), v.description('Filter by icon set prefix (e.g. \"lucide\", \"mdi\")'))\n )\n }),\n execute: async (figma, args) => {\n try {\n const options = { limit: args.limit ?? 5, prefix: args.prefix }\n const results = await Promise.all(\n args.queries.map(\n async (query) => [query, await figma.icons.search(query, options)] as const\n )\n )\n return Object.fromEntries(\n results.map(([query, result]) => [query, { icons: result.icons, total: result.total }])\n )\n } catch (e) {\n return { error: (e as Error).message }\n }\n }\n})\n"],"mappings":";;;;;;AAQA,MAAa,iBAAiB,WAAW;CACvC,MAAM;CACN,UAAU,EAAE,QAAQ,MAAM;CAC1B,aACE;CACF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAO;CAC7C,cAAc,CAAC,gBAAgB;CAC/B,OAAO,EAAE,aAAa;EACpB,OAAO,EAAE,KACP,EAAE,MAAM,EAAE,OAAO,CAAC,GAClB,EAAE,UAAU,CAAC,GACb,EAAE,YAAY,oFAA8E,CAC9F;EACA,MAAM,EAAE,SACN,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,mCAAmC,CAAC,CAAC,CACnF;CACF,CAAC;CACD,SAAS,OAAO,OAAO,SAAS;EAC9B,MAAM,OAAO,KAAK,QAAQ;EAC1B,IAAI;GACF,MAAM,QAAQ,MAAM,MAAM,MAAM,MAAM,KAAK,OAAO,IAAI;GACtD,MAAM,UAAU,CAAC,GAAG,MAAM,KAAK,CAAC;GAChC,MAAM,WAAW,KAAK,MAAM,QAAQ,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC;GAC7D,MAAM,SAAkC;IAAE;IAAS,OAAO,QAAQ;GAAO;GACzE,IAAI,SAAS,SAAS,GAAG,OAAO,YAAY;GAC5C,OAAO;EACT,SAAS,GAAG;GACV,OAAO,EAAE,OAAQ,EAAY,QAAQ;EACvC;CACF;AACF,CAAC;;;;;AAMD,MAAM,mBAAmB;CACvB,QAAQ,EAAE,SACR,WACE,EAAE,KACA,EAAE,OAAO,GACT,EAAE,YAAY,4DAA4D,CAC5E,CACF,CACF;CACA,MAAM,EAAE,SACN,EAAE,KAAK,EAAE,QAAQ,GAAG,EAAE,YAAY,gDAAg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@
|
|
|
1
|
-
import { defineTool, toolNumber } from "../schema.js";
|
|
2
1
|
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
2
|
+
import { defineTool, toolNumber } from "../schema.js";
|
|
3
3
|
import { addFlowchart } from "../../io/formats/mermaid/layers.js";
|
|
4
4
|
import { getAxisAlignedBoundsInParent } from "@pairdraw/scene-graph/coordinate";
|
|
5
5
|
import * as v from "valibot";
|
|
@@ -14,6 +14,7 @@ const importMermaid = defineTool({
|
|
|
14
14
|
kind: "async",
|
|
15
15
|
mutation: "document"
|
|
16
16
|
},
|
|
17
|
+
content: "imported",
|
|
17
18
|
input: v.strictObject({
|
|
18
19
|
mermaid: v.pipe(v.string(), v.description("Mermaid flowchart source (e.g. \"flowchart LR\\n A[Start] --> B{Ready?}\")")),
|
|
19
20
|
parent_id: v.optional(v.pipe(v.string(), v.description("Parent node ID (default: the page)"))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mermaid.js","names":[],"sources":["../../../src/tools/create/mermaid.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { detectMermaidDiagram, parseFlowchart } from '@pairdraw/mermaid'\nimport { getAxisAlignedBoundsInParent } from '@pairdraw/scene-graph/coordinate'\n\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { addFlowchart } from '#core/io/formats/mermaid'\nimport { toolNumber, defineTool } from '#core/tools/schema'\n\n/** Room left between a parent's content and a diagram placed beside it. */\nconst BESIDE_GAP = 100\n\nexport const importMermaid = defineTool({\n name: 'import_mermaid',\n\n description:\n 'Import a Mermaid flowchart (`flowchart` or `graph`) as editable FigJam layers, laid out automatically so nothing overlaps: each node a shape with text in its Mermaid shape, each subgraph a section, and each edge an elbowed connector joined to the layers it links, with its arrowheads, dotted or thick line, and label. classDef, class, and style fills, strokes, and text colours carry over. Without x and y the diagram goes to the right of what the parent already holds. Returns the layer id of every node and subgraph and the connector id of every edge, by Mermaid id.',\n execution: { kind: 'async', mutation: 'document' },\n input: v.strictObject({\n mermaid: v.pipe(\n v.string(),\n v.description('Mermaid flowchart source (e.g. \"flowchart LR\\\\n A[Start] --> B{Ready?}\")')\n ),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID (default: the page)'))),\n x: v.optional(toolNumber(v.pipe(v.number(), v.description('X of the diagram’s left edge')))),\n y: v.optional(toolNumber(v.pipe(v.number(), v.description('Y of the diagram’s top edge'))))\n }),\n execute: async (figma, args) => {\n if (detectMermaidDiagram(args.mermaid) !== 'flowchart') {\n return {\n error: 'Only Mermaid flowcharts, starting with `flowchart` or `graph`, are supported'\n }\n }\n let chart\n try {\n chart = parseFlowchart(args.mermaid)\n } catch (error) {\n return { error: error instanceof Error ? error.message : String(error) }\n }\n const { graph } = figma\n const parentId = args.parent_id ?? figma.currentPage.id\n if (!graph.getNode(parentId)) return { error: `Parent ${parentId} not found` }\n prepareSlotInsertion(graph, parentId, 'import_mermaid')\n const content = graph.getNode(parentId)?.childIds ?? []\n const bounds =\n content.length > 0\n ? getAxisAlignedBoundsInParent(\n content.flatMap((id) => graph.getNode(id) ?? []),\n parentId,\n graph\n )\n : null\n const topLeft = {\n x: args.x ?? (bounds ? bounds.x + bounds.width + BESIDE_GAP : 0),\n y: args.y ?? bounds?.y ?? 0\n }\n const result = await addFlowchart(graph, parentId, chart, { topLeft })\n return {\n ids: result.ids,\n nodes: Object.fromEntries(result.layers),\n connectors: Object.fromEntries(result.connectors)\n }\n }\n})\n"],"mappings":";;;;;;;;AAUA,MAAM,aAAa;AAEnB,MAAa,gBAAgB,WAAW;CACtC,MAAM;CAEN,aACE;CACF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAW;CACjD,OAAO,EAAE,aAAa;EACpB,SAAS,EAAE,KACT,EAAE,OAAO,GACT,EAAE,YAAY,6EAA2E,CAC3F;EACA,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,oCAAoC,CAAC,CAAC;EAC7F,GAAG,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,8BAA8B,CAAC,CAAC,CAAC;EAC3F,GAAG,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,6BAA6B,CAAC,CAAC,CAAC;CAC5F,CAAC;CACD,SAAS,OAAO,OAAO,SAAS;EAC9B,IAAI,qBAAqB,KAAK,OAAO,MAAM,aACzC,OAAO,EACL,OAAO,+EACT;EAEF,IAAI;EACJ,IAAI;GACF,QAAQ,eAAe,KAAK,OAAO;EACrC,SAAS,OAAO;GACd,OAAO,EAAE,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE;EACzE;EACA,MAAM,EAAE,UAAU;EAClB,MAAM,WAAW,KAAK,aAAa,MAAM,YAAY;EACrD,IAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG,OAAO,EAAE,OAAO,UAAU,SAAS,YAAY;EAC7E,qBAAqB,OAAO,UAAU,gBAAgB;EACtD,MAAM,UAAU,MAAM,QAAQ,QAAQ,CAAC,EAAE,YAAY,CAAC;EACtD,MAAM,SACJ,QAAQ,SAAS,IACb,6BACE,QAAQ,SAAS,OAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,CAAC,GAC/C,UACA,KACF,IACA;EACN,MAAM,UAAU;GACd,GAAG,KAAK,MAAM,SAAS,OAAO,IAAI,OAAO,QAAQ,aAAa;GAC9D,GAAG,KAAK,KAAK,QAAQ,KAAK;EAC5B;EACA,MAAM,SAAS,MAAM,aAAa,OAAO,UAAU,OAAO,EAAE,QAAQ,CAAC;EACrE,OAAO;GACL,KAAK,OAAO;GACZ,OAAO,OAAO,YAAY,OAAO,MAAM;GACvC,YAAY,OAAO,YAAY,OAAO,UAAU;EAClD;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"mermaid.js","names":[],"sources":["../../../src/tools/create/mermaid.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { detectMermaidDiagram, parseFlowchart } from '@pairdraw/mermaid'\nimport { getAxisAlignedBoundsInParent } from '@pairdraw/scene-graph/coordinate'\n\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { addFlowchart } from '#core/io/formats/mermaid'\nimport { toolNumber, defineTool } from '#core/tools/schema'\n\n/** Room left between a parent's content and a diagram placed beside it. */\nconst BESIDE_GAP = 100\n\nexport const importMermaid = defineTool({\n name: 'import_mermaid',\n\n description:\n 'Import a Mermaid flowchart (`flowchart` or `graph`) as editable FigJam layers, laid out automatically so nothing overlaps: each node a shape with text in its Mermaid shape, each subgraph a section, and each edge an elbowed connector joined to the layers it links, with its arrowheads, dotted or thick line, and label. classDef, class, and style fills, strokes, and text colours carry over. Without x and y the diagram goes to the right of what the parent already holds. Returns the layer id of every node and subgraph and the connector id of every edge, by Mermaid id.',\n execution: { kind: 'async', mutation: 'document' },\n content: 'imported',\n input: v.strictObject({\n mermaid: v.pipe(\n v.string(),\n v.description('Mermaid flowchart source (e.g. \"flowchart LR\\\\n A[Start] --> B{Ready?}\")')\n ),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID (default: the page)'))),\n x: v.optional(toolNumber(v.pipe(v.number(), v.description('X of the diagram’s left edge')))),\n y: v.optional(toolNumber(v.pipe(v.number(), v.description('Y of the diagram’s top edge'))))\n }),\n execute: async (figma, args) => {\n if (detectMermaidDiagram(args.mermaid) !== 'flowchart') {\n return {\n error: 'Only Mermaid flowcharts, starting with `flowchart` or `graph`, are supported'\n }\n }\n let chart\n try {\n chart = parseFlowchart(args.mermaid)\n } catch (error) {\n return { error: error instanceof Error ? error.message : String(error) }\n }\n const { graph } = figma\n const parentId = args.parent_id ?? figma.currentPage.id\n if (!graph.getNode(parentId)) return { error: `Parent ${parentId} not found` }\n prepareSlotInsertion(graph, parentId, 'import_mermaid')\n const content = graph.getNode(parentId)?.childIds ?? []\n const bounds =\n content.length > 0\n ? getAxisAlignedBoundsInParent(\n content.flatMap((id) => graph.getNode(id) ?? []),\n parentId,\n graph\n )\n : null\n const topLeft = {\n x: args.x ?? (bounds ? bounds.x + bounds.width + BESIDE_GAP : 0),\n y: args.y ?? bounds?.y ?? 0\n }\n const result = await addFlowchart(graph, parentId, chart, { topLeft })\n return {\n ids: result.ids,\n nodes: Object.fromEntries(result.layers),\n connectors: Object.fromEntries(result.connectors)\n }\n }\n})\n"],"mappings":";;;;;;;;AAUA,MAAM,aAAa;AAEnB,MAAa,gBAAgB,WAAW;CACtC,MAAM;CAEN,aACE;CACF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAW;CACjD,SAAS;CACT,OAAO,EAAE,aAAa;EACpB,SAAS,EAAE,KACT,EAAE,OAAO,GACT,EAAE,YAAY,6EAA2E,CAC3F;EACA,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,oCAAoC,CAAC,CAAC;EAC7F,GAAG,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,8BAA8B,CAAC,CAAC,CAAC;EAC3F,GAAG,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,6BAA6B,CAAC,CAAC,CAAC;CAC5F,CAAC;CACD,SAAS,OAAO,OAAO,SAAS;EAC9B,IAAI,qBAAqB,KAAK,OAAO,MAAM,aACzC,OAAO,EACL,OAAO,+EACT;EAEF,IAAI;EACJ,IAAI;GACF,QAAQ,eAAe,KAAK,OAAO;EACrC,SAAS,OAAO;GACd,OAAO,EAAE,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE;EACzE;EACA,MAAM,EAAE,UAAU;EAClB,MAAM,WAAW,KAAK,aAAa,MAAM,YAAY;EACrD,IAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG,OAAO,EAAE,OAAO,UAAU,SAAS,YAAY;EAC7E,qBAAqB,OAAO,UAAU,gBAAgB;EACtD,MAAM,UAAU,MAAM,QAAQ,QAAQ,CAAC,EAAE,YAAY,CAAC;EACtD,MAAM,SACJ,QAAQ,SAAS,IACb,6BACE,QAAQ,SAAS,OAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,CAAC,GAC/C,UACA,KACF,IACA;EACN,MAAM,UAAU;GACd,GAAG,KAAK,MAAM,SAAS,OAAO,IAAI,OAAO,QAAQ,aAAa;GAC9D,GAAG,KAAK,KAAK,QAAQ,KAAK;EAC5B;EACA,MAAM,SAAS,MAAM,aAAa,OAAO,UAAU,OAAO,EAAE,QAAQ,CAAC;EACrE,OAAO;GACL,KAAK,OAAO;GACZ,OAAO,OAAO,YAAY,OAAO,MAAM;GACvC,YAAY,OAAO,YAAY,OAAO,UAAU;EAClD;CACF;AACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
1
2
|
import { defineTool, toolNumber } from "../schema.js";
|
|
2
3
|
import { finishRenderPlacement, resolveRenderPlacement } from "../../design-jsx/placement.js";
|
|
3
|
-
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
4
4
|
import * as v from "valibot";
|
|
5
5
|
//#region src/tools/create/render.ts
|
|
6
6
|
const render = defineTool({
|
package/dist/tools/create/svg.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { svgImportFonts } from "../../io/formats/svg/text/import.js";
|
|
2
2
|
import { createSVGNodesFromImport, prepareSVGImport } from "../../io/formats/svg/import.js";
|
|
3
|
-
import { defineTool, toolNumber } from "../schema.js";
|
|
4
3
|
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
4
|
+
import { defineTool, toolNumber } from "../schema.js";
|
|
5
5
|
import * as v from "valibot";
|
|
6
6
|
//#region src/tools/create/svg.ts
|
|
7
7
|
const importSVG = defineTool({
|
|
@@ -11,6 +11,7 @@ const importSVG = defineTool({
|
|
|
11
11
|
kind: "async",
|
|
12
12
|
mutation: "document"
|
|
13
13
|
},
|
|
14
|
+
content: "imported",
|
|
14
15
|
input: v.strictObject({
|
|
15
16
|
svg: v.pipe(v.string(), v.description("SVG markup string (e.g. '<svg viewBox=\"0 0 24 24\"><path d=\"M...\"/></svg>')")),
|
|
16
17
|
name: v.optional(v.pipe(v.string(), v.description("Name for the created frame or group (default: the root <svg> id, else \"Frame\" or \"Group\")"))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.js","names":[],"sources":["../../../src/tools/create/svg.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { createSVGNodesFromImport, prepareSVGImport, svgImportFonts } from '#core/io/formats/svg'\nimport { toolNumber, defineTool } from '#core/tools/schema'\n\nexport const importSVG = defineTool({\n name: 'import_svg',\n\n description:\n 'Import raw SVG markup onto the canvas as editable layers, as pasting it into Figma does: a frame (a group when the SVG has no width, height, or viewBox) with a group per <g>, a vector per shape, and a text layer per <text>, named by their ids, and a mask group around clipped content. Supports common SVG shapes, text with <tspan> styles, inherited presentation attributes, opacity, transforms, gradients, clip paths, and internal <use> references.',\n execution: { kind: 'async', mutation: 'document' },\n input: v.strictObject({\n svg: v.pipe(\n v.string(),\n v.description('SVG markup string (e.g. \\'<svg viewBox=\"0 0 24 24\"><path d=\"M...\"/></svg>\\')')\n ),\n name: v.optional(\n v.pipe(\n v.string(),\n v.description(\n 'Name for the created frame or group (default: the root <svg> id, else \"Frame\" or \"Group\")'\n )\n )\n ),\n color: v.optional(\n v.pipe(\n v.string(),\n v.description('Default color for currentColor fills/strokes (default: #000000)')\n )\n ),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID'))),\n x: v.optional(toolNumber(v.pipe(v.number(), v.description('X position')))),\n y: v.optional(toolNumber(v.pipe(v.number(), v.description('Y position'))))\n }),\n execute: async (figma, args) => {\n if (!args.svg || typeof args.svg !== 'string') return { error: 'svg parameter is required' }\n\n const data = prepareSVGImport(args.svg, { defaultColor: args.color })\n // Text is measured and placed as it is created, so its fonts load first.\n await Promise.all(\n (data ? svgImportFonts(data) : []).map(({ family, style }) =>\n figma.loadFontAsync({ family, style })\n )\n )\n const parentId = args.parent_id ?? figma.currentPage.id\n if (data) prepareSlotInsertion(figma.graph, parentId, 'import_svg')\n const frame =\n data &&\n createSVGNodesFromImport(figma.graph, parentId, data, {\n name: args.name,\n x: args.x,\n y: args.y\n })\n if (!frame) return { error: 'No supported SVG elements found in the markup' }\n return { id: frame.id, name: frame.name, type: frame.type }\n }\n})\n"],"mappings":";;;;;;AAMA,MAAa,YAAY,WAAW;CAClC,MAAM;CAEN,aACE;CACF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAW;CACjD,OAAO,EAAE,aAAa;EACpB,KAAK,EAAE,KACL,EAAE,OAAO,GACT,EAAE,YAAY,gFAA8E,CAC9F;EACA,MAAM,EAAE,SACN,EAAE,KACA,EAAE,OAAO,GACT,EAAE,YACA,+FACF,CACF,CACF;EACA,OAAO,EAAE,SACP,EAAE,KACA,EAAE,OAAO,GACT,EAAE,YAAY,iEAAiE,CACjF,CACF;EACA,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,gBAAgB,CAAC,CAAC;EACzE,GAAG,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,YAAY,CAAC,CAAC,CAAC;EACzE,GAAG,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,YAAY,CAAC,CAAC,CAAC;CAC3E,CAAC;CACD,SAAS,OAAO,OAAO,SAAS;EAC9B,IAAI,CAAC,KAAK,OAAO,OAAO,KAAK,QAAQ,UAAU,OAAO,EAAE,OAAO,4BAA4B;EAE3F,MAAM,OAAO,iBAAiB,KAAK,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;EAEpE,MAAM,QAAQ,KACX,OAAO,eAAe,IAAI,IAAI,CAAC,EAAA,CAAG,KAAK,EAAE,QAAQ,YAChD,MAAM,cAAc;GAAE;GAAQ;EAAM,CAAC,CACvC,CACF;EACA,MAAM,WAAW,KAAK,aAAa,MAAM,YAAY;EACrD,IAAI,MAAM,qBAAqB,MAAM,OAAO,UAAU,YAAY;EAClE,MAAM,QACJ,QACA,yBAAyB,MAAM,OAAO,UAAU,MAAM;GACpD,MAAM,KAAK;GACX,GAAG,KAAK;GACR,GAAG,KAAK;EACV,CAAC;EACH,IAAI,CAAC,OAAO,OAAO,EAAE,OAAO,gDAAgD;EAC5E,OAAO;GAAE,IAAI,MAAM;GAAI,MAAM,MAAM;GAAM,MAAM,MAAM;EAAK;CAC5D;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"svg.js","names":[],"sources":["../../../src/tools/create/svg.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { createSVGNodesFromImport, prepareSVGImport, svgImportFonts } from '#core/io/formats/svg'\nimport { toolNumber, defineTool } from '#core/tools/schema'\n\nexport const importSVG = defineTool({\n name: 'import_svg',\n\n description:\n 'Import raw SVG markup onto the canvas as editable layers, as pasting it into Figma does: a frame (a group when the SVG has no width, height, or viewBox) with a group per <g>, a vector per shape, and a text layer per <text>, named by their ids, and a mask group around clipped content. Supports common SVG shapes, text with <tspan> styles, inherited presentation attributes, opacity, transforms, gradients, clip paths, and internal <use> references.',\n execution: { kind: 'async', mutation: 'document' },\n content: 'imported',\n input: v.strictObject({\n svg: v.pipe(\n v.string(),\n v.description('SVG markup string (e.g. \\'<svg viewBox=\"0 0 24 24\"><path d=\"M...\"/></svg>\\')')\n ),\n name: v.optional(\n v.pipe(\n v.string(),\n v.description(\n 'Name for the created frame or group (default: the root <svg> id, else \"Frame\" or \"Group\")'\n )\n )\n ),\n color: v.optional(\n v.pipe(\n v.string(),\n v.description('Default color for currentColor fills/strokes (default: #000000)')\n )\n ),\n parent_id: v.optional(v.pipe(v.string(), v.description('Parent node ID'))),\n x: v.optional(toolNumber(v.pipe(v.number(), v.description('X position')))),\n y: v.optional(toolNumber(v.pipe(v.number(), v.description('Y position'))))\n }),\n execute: async (figma, args) => {\n if (!args.svg || typeof args.svg !== 'string') return { error: 'svg parameter is required' }\n\n const data = prepareSVGImport(args.svg, { defaultColor: args.color })\n // Text is measured and placed as it is created, so its fonts load first.\n await Promise.all(\n (data ? svgImportFonts(data) : []).map(({ family, style }) =>\n figma.loadFontAsync({ family, style })\n )\n )\n const parentId = args.parent_id ?? figma.currentPage.id\n if (data) prepareSlotInsertion(figma.graph, parentId, 'import_svg')\n const frame =\n data &&\n createSVGNodesFromImport(figma.graph, parentId, data, {\n name: args.name,\n x: args.x,\n y: args.y\n })\n if (!frame) return { error: 'No supported SVG elements found in the markup' }\n return { id: frame.id, name: frame.name, type: frame.type }\n }\n})\n"],"mappings":";;;;;;AAMA,MAAa,YAAY,WAAW;CAClC,MAAM;CAEN,aACE;CACF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAW;CACjD,SAAS;CACT,OAAO,EAAE,aAAa;EACpB,KAAK,EAAE,KACL,EAAE,OAAO,GACT,EAAE,YAAY,gFAA8E,CAC9F;EACA,MAAM,EAAE,SACN,EAAE,KACA,EAAE,OAAO,GACT,EAAE,YACA,+FACF,CACF,CACF;EACA,OAAO,EAAE,SACP,EAAE,KACA,EAAE,OAAO,GACT,EAAE,YAAY,iEAAiE,CACjF,CACF;EACA,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,gBAAgB,CAAC,CAAC;EACzE,GAAG,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,YAAY,CAAC,CAAC,CAAC;EACzE,GAAG,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,YAAY,CAAC,CAAC,CAAC;CAC3E,CAAC;CACD,SAAS,OAAO,OAAO,SAAS;EAC9B,IAAI,CAAC,KAAK,OAAO,OAAO,KAAK,QAAQ,UAAU,OAAO,EAAE,OAAO,4BAA4B;EAE3F,MAAM,OAAO,iBAAiB,KAAK,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;EAEpE,MAAM,QAAQ,KACX,OAAO,eAAe,IAAI,IAAI,CAAC,EAAA,CAAG,KAAK,EAAE,QAAQ,YAChD,MAAM,cAAc;GAAE;GAAQ;EAAM,CAAC,CACvC,CACF;EACA,MAAM,WAAW,KAAK,aAAa,MAAM,YAAY;EACrD,IAAI,MAAM,qBAAqB,MAAM,OAAO,UAAU,YAAY;EAClE,MAAM,QACJ,QACA,yBAAyB,MAAM,OAAO,UAAU,MAAM;GACpD,MAAM,KAAK;GACX,GAAG,KAAK;GACR,GAAG,KAAK;EACV,CAAC;EACH,IAAI,CAAC,OAAO,OAAO,EAAE,OAAO,gDAAgD;EAC5E,OAAO;GAAE,IAAI,MAAM;GAAI,MAAM,MAAM;GAAM,MAAM,MAAM;EAAK;CAC5D;AACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computeAccurateBounds } from "../../vector/curve-math.js";
|
|
2
|
-
import { defineTool, nodeSummary, parseOptionalToolColor, positionInputs, toolNumber } from "../schema.js";
|
|
3
2
|
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
3
|
+
import { defineTool, nodeSummary, parseOptionalToolColor, positionInputs, toolNumber } from "../schema.js";
|
|
4
4
|
import { parseVectorNetworkJSON } from "../vector/network.js";
|
|
5
5
|
import { parseSVGPath } from "@pairdraw/scene-graph/parse-path";
|
|
6
6
|
import { transformVectorNetwork } from "@pairdraw/scene-graph/vector-network";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ToolDef } from "./schema.js";
|
|
2
|
+
//#region src/tools/design-memory.d.ts
|
|
3
|
+
declare const getDesignMemory: ToolDef;
|
|
4
|
+
declare const checkDesignValuesTool: ToolDef;
|
|
5
|
+
declare const recordDesignDecisionTool: ToolDef;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { checkDesignValuesTool, getDesignMemory, recordDesignDecisionTool };
|
|
8
|
+
//# sourceMappingURL=design-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design-memory.d.ts","names":[],"sources":["../../src/tools/design-memory.ts"],"mappings":";;cASa,iBAAA;cAaA,uBAAA;cA8BA,0BAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineTool, toolFailure } from "./schema.js";
|
|
2
|
+
import { PairdrawAPI } from "../pairdraw-api/index.js";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
//#region src/tools/design-memory.ts
|
|
5
|
+
function valuesInput(description, value) {
|
|
6
|
+
return v.optional(v.pipe(v.array(value), v.maxLength(64), v.description(description)));
|
|
7
|
+
}
|
|
8
|
+
const getDesignMemory = defineTool({
|
|
9
|
+
name: "get_design_memory",
|
|
10
|
+
description: "Read the document’s design memory before you design in it: the colors, fonts, font sizes, spacing and corner radii it allows (its variables and styles plus values the person added), whether an edit with another value is refused or warned about, the decisions written down, and frames pinned as examples to follow (read them with get_jsx or export_image). Returns null when the document has none.",
|
|
11
|
+
execution: {
|
|
12
|
+
kind: "sync",
|
|
13
|
+
mutation: "none"
|
|
14
|
+
},
|
|
15
|
+
input: v.strictObject({}),
|
|
16
|
+
execute: (figma) => ({ design_memory: new PairdrawAPI(figma).designMemory })
|
|
17
|
+
});
|
|
18
|
+
const checkDesignValuesTool = defineTool({
|
|
19
|
+
name: "check_design_values",
|
|
20
|
+
description: "Check values against the document’s design memory before you use them: each comes back ok, warn (allowed with a warning), refuse (an edit using it is undone) or invalid, with the nearest allowed value and the variable that holds it.",
|
|
21
|
+
execution: {
|
|
22
|
+
kind: "sync",
|
|
23
|
+
mutation: "none"
|
|
24
|
+
},
|
|
25
|
+
input: v.strictObject({
|
|
26
|
+
colors: valuesInput("CSS colors, such as #1A73E8", v.string()),
|
|
27
|
+
fonts: valuesInput("Font families", v.string()),
|
|
28
|
+
font_sizes: valuesInput("Font sizes in px", v.number()),
|
|
29
|
+
spacing: valuesInput("Gaps and padding in px", v.number()),
|
|
30
|
+
radius: valuesInput("Corner radii in px", v.number())
|
|
31
|
+
}),
|
|
32
|
+
execute: (figma, { colors, fonts, font_sizes, spacing, radius }) => {
|
|
33
|
+
try {
|
|
34
|
+
return { verdicts: new PairdrawAPI(figma).checkDesignValues({
|
|
35
|
+
colors,
|
|
36
|
+
fonts,
|
|
37
|
+
fontSizes: font_sizes,
|
|
38
|
+
spacing,
|
|
39
|
+
radius
|
|
40
|
+
}) };
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return toolFailure(error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const recordDesignDecisionTool = defineTool({
|
|
47
|
+
name: "record_design_decision",
|
|
48
|
+
description: "Write a design decision down in the document’s design memory, such as “Cards use 16 px padding and the Surface/Raised color”, so later work follows it; optionally pin a frame that shows it as an example. It cannot change which values the memory allows: only the person can.",
|
|
49
|
+
execution: {
|
|
50
|
+
kind: "sync",
|
|
51
|
+
mutation: "document"
|
|
52
|
+
},
|
|
53
|
+
input: v.strictObject({
|
|
54
|
+
text: v.pipe(v.string(), v.description("The decision, at most 400 characters")),
|
|
55
|
+
example_node_id: v.optional(v.pipe(v.string(), v.description("A layer that shows it")))
|
|
56
|
+
}),
|
|
57
|
+
execute: (figma, { text, example_node_id }) => {
|
|
58
|
+
try {
|
|
59
|
+
return new PairdrawAPI(figma).recordDesignDecision(text, example_node_id);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
return toolFailure(error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
//#endregion
|
|
66
|
+
export { checkDesignValuesTool, getDesignMemory, recordDesignDecisionTool };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=design-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"design-memory.js","names":[],"sources":["../../src/tools/design-memory.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { PairdrawAPI } from '#core/pairdraw-api'\nimport { defineTool, toolFailure } from '#core/tools/schema'\n\nfunction valuesInput<T extends v.GenericSchema>(description: string, value: T) {\n return v.optional(v.pipe(v.array(value), v.maxLength(64), v.description(description)))\n}\n\nexport const getDesignMemory = defineTool({\n name: 'get_design_memory',\n description:\n 'Read the document’s design memory before you design in it: the colors, fonts, font sizes, ' +\n 'spacing and corner radii it allows (its variables and styles plus values the person added), ' +\n 'whether an edit with another value is refused or warned about, the decisions written down, ' +\n 'and frames pinned as examples to follow (read them with get_jsx or export_image). ' +\n 'Returns null when the document has none.',\n execution: { kind: 'sync', mutation: 'none' },\n input: v.strictObject({}),\n execute: (figma) => ({ design_memory: new PairdrawAPI(figma).designMemory })\n})\n\nexport const checkDesignValuesTool = defineTool({\n name: 'check_design_values',\n description:\n 'Check values against the document’s design memory before you use them: each comes back ' +\n 'ok, warn (allowed with a warning), refuse (an edit using it is undone) or invalid, with the ' +\n 'nearest allowed value and the variable that holds it.',\n execution: { kind: 'sync', mutation: 'none' },\n input: v.strictObject({\n colors: valuesInput('CSS colors, such as #1A73E8', v.string()),\n fonts: valuesInput('Font families', v.string()),\n font_sizes: valuesInput('Font sizes in px', v.number()),\n spacing: valuesInput('Gaps and padding in px', v.number()),\n radius: valuesInput('Corner radii in px', v.number())\n }),\n execute: (figma, { colors, fonts, font_sizes, spacing, radius }) => {\n try {\n const verdicts = new PairdrawAPI(figma).checkDesignValues({\n colors,\n fonts,\n fontSizes: font_sizes,\n spacing,\n radius\n })\n return { verdicts }\n } catch (error) {\n return toolFailure(error)\n }\n }\n})\n\nexport const recordDesignDecisionTool = defineTool({\n name: 'record_design_decision',\n description:\n 'Write a design decision down in the document’s design memory, such as “Cards use 16 px ' +\n 'padding and the Surface/Raised color”, so later work follows it; optionally pin a frame ' +\n 'that shows it as an example. It cannot change which values the memory allows: only the ' +\n 'person can.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n text: v.pipe(v.string(), v.description('The decision, at most 400 characters')),\n example_node_id: v.optional(v.pipe(v.string(), v.description('A layer that shows it')))\n }),\n execute: (figma, { text, example_node_id }) => {\n try {\n return new PairdrawAPI(figma).recordDesignDecision(text, example_node_id)\n } catch (error) {\n return toolFailure(error)\n }\n }\n})\n"],"mappings":";;;;AAKA,SAAS,YAAuC,aAAqB,OAAU;CAC7E,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,WAAW,CAAC,CAAC;AACvF;AAEA,MAAa,kBAAkB,WAAW;CACxC,MAAM;CACN,aACE;CAKF,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAO;CAC5C,OAAO,EAAE,aAAa,CAAC,CAAC;CACxB,UAAU,WAAW,EAAE,eAAe,IAAI,YAAY,KAAK,CAAC,CAAC,aAAa;AAC5E,CAAC;AAED,MAAa,wBAAwB,WAAW;CAC9C,MAAM;CACN,aACE;CAGF,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAO;CAC5C,OAAO,EAAE,aAAa;EACpB,QAAQ,YAAY,+BAA+B,EAAE,OAAO,CAAC;EAC7D,OAAO,YAAY,iBAAiB,EAAE,OAAO,CAAC;EAC9C,YAAY,YAAY,oBAAoB,EAAE,OAAO,CAAC;EACtD,SAAS,YAAY,0BAA0B,EAAE,OAAO,CAAC;EACzD,QAAQ,YAAY,sBAAsB,EAAE,OAAO,CAAC;CACtD,CAAC;CACD,UAAU,OAAO,EAAE,QAAQ,OAAO,YAAY,SAAS,aAAa;EAClE,IAAI;GAQF,OAAO,EAAE,UAPQ,IAAI,YAAY,KAAK,CAAC,CAAC,kBAAkB;IACxD;IACA;IACA,WAAW;IACX;IACA;GACF,CACgB,EAAE;EACpB,SAAS,OAAO;GACd,OAAO,YAAY,KAAK;EAC1B;CACF;AACF,CAAC;AAED,MAAa,2BAA2B,WAAW;CACjD,MAAM;CACN,aACE;CAIF,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa;EACpB,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,sCAAsC,CAAC;EAC9E,iBAAiB,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,uBAAuB,CAAC,CAAC;CACxF,CAAC;CACD,UAAU,OAAO,EAAE,MAAM,sBAAsB;EAC7C,IAAI;GACF,OAAO,IAAI,YAAY,KAAK,CAAC,CAAC,qBAAqB,MAAM,eAAe;EAC1E,SAAS,OAAO;GACd,OAAO,YAAY,KAAK;EAC1B;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","names":[],"sources":["../../../src/tools/image-ai/generate.ts"],"mappings":";;cAgGa,eAAA;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","names":[],"sources":["../../../src/tools/image-ai/generate.ts"],"mappings":";;cAgGa,eAAA;cAiEA,aAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { vectorizableImageFill } from "../../vector/vectorize/image.js";
|
|
2
|
-
import { defineTool, nodeNotFound, toolFailure, toolNumber } from "../schema.js";
|
|
3
2
|
import { prepareSlotInsertion } from "../../figma-api/slots.js";
|
|
4
3
|
import { storeImage } from "../../figma-api/images.js";
|
|
4
|
+
import { defineTool, nodeNotFound, toolFailure, toolNumber } from "../schema.js";
|
|
5
5
|
import { importSVG } from "../create/svg.js";
|
|
6
6
|
import { canHoldImageFill, imageFill, layerNameFromPrompt, orientationFor, placeBesideSiblings, swapLayerImage } from "./apply.js";
|
|
7
7
|
import { IMAGE_AI_ORIENTATIONS, IMAGE_AI_UNAVAILABLE, getImageAIService } from "./service.js";
|
|
@@ -58,6 +58,7 @@ const generateImage = defineTool({
|
|
|
58
58
|
kind: "async",
|
|
59
59
|
mutation: "document"
|
|
60
60
|
},
|
|
61
|
+
content: "imported",
|
|
61
62
|
capabilities: ["document:write", "network:access"],
|
|
62
63
|
input: v.strictObject({
|
|
63
64
|
prompt: promptInput("What the image shows, its style, and its mood, in English"),
|
|
@@ -101,6 +102,7 @@ const generateSVG = defineTool({
|
|
|
101
102
|
kind: "async",
|
|
102
103
|
mutation: "document"
|
|
103
104
|
},
|
|
105
|
+
content: "imported",
|
|
104
106
|
capabilities: ["document:write", "network:access"],
|
|
105
107
|
input: v.strictObject({
|
|
106
108
|
prompt: promptInput("What the artwork shows and its style, in English"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","names":[],"sources":["../../../src/tools/image-ai/generate.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { imageSize } from '@pairdraw/scene-graph/images'\nimport type { Size } from '@pairdraw/scene-graph/primitives'\n\nimport { storeImage } from '#core/figma-api/images'\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { importSVG } from '#core/tools/create/svg'\nimport { defineTool, nodeNotFound, toolFailure, toolNumber } from '#core/tools/schema'\nimport { vectorizableImageFill } from '#core/vector/vectorize'\n\nimport {\n canHoldImageFill,\n imageFill,\n layerNameFromPrompt,\n orientationFor,\n placeBesideSiblings,\n swapLayerImage\n} from './apply'\nimport { getImageAIService, IMAGE_AI_ORIENTATIONS, IMAGE_AI_UNAVAILABLE } from './service'\n\nconst GENERATED_IMAGE_NAME = 'Generated image'\nconst GENERATED_SVG_NAME = 'Generated SVG'\n\nconst promptInput = (description: string) =>\n v.pipe(v.string(), v.regex(/\\S/, 'Describe what to generate'), v.description(description))\n\nconst placementInputs = {\n name: v.optional(\n v.pipe(v.string(), v.description('Name of the new layer (default: the prompt’s first words)'))\n ),\n parent_id: v.optional(\n v.pipe(v.string(), v.description('Parent of the new layer (default: the current page)'))\n ),\n x: v.optional(\n toolNumber(v.pipe(v.number(), v.description('X in the parent (default: beside its content)')))\n ),\n y: v.optional(\n toolNumber(v.pipe(v.number(), v.description('Y in the parent (default: beside its content)')))\n )\n}\n\n/** Shows `bytes` in `target`, unless another edit removed the layer or changed its image meanwhile. */\nfunction fillLayerWithImage(\n graph: SceneGraph,\n target: SceneNode,\n previousHash: string | undefined,\n bytes: Uint8Array,\n size: Size\n) {\n // The service may outlast the layer or its image: another edit can change either meanwhile.\n const current = graph.getNode(target.id)\n if (!current) return { error: `\"${target.name}\" was deleted before the image arrived` }\n if (previousHash) {\n if (!swapLayerImage(graph, current.id, previousHash, bytes)) {\n return { error: `The image of \"${current.name}\" changed before the new one arrived` }\n }\n } else {\n graph.updateNode(current.id, {\n fills: [...current.fills, imageFill(storeImage(graph, bytes))]\n })\n }\n return { id: current.id, name: current.name, type: current.type, image: size }\n}\n\ninterface ImageLayerPlacement {\n prompt: string\n name?: string\n width?: number\n x?: number\n y?: number\n}\n\n/** A new rectangle in `parentId` showing `bytes` at the image's aspect ratio. */\nfunction createImageLayer(\n graph: SceneGraph,\n parentId: string,\n args: ImageLayerPlacement,\n bytes: Uint8Array,\n size: Size\n) {\n if (!graph.getNode(parentId)) return { error: `Parent \"${parentId}\" was deleted meanwhile` }\n const width = args.width ?? size.width\n const node = graph.createNode('RECTANGLE', parentId, {\n name: args.name ?? layerNameFromPrompt(args.prompt, GENERATED_IMAGE_NAME),\n x: args.x ?? 0,\n y: args.y ?? 0,\n width,\n height: (width * size.height) / size.width,\n fills: [imageFill(storeImage(graph, bytes))]\n })\n if (args.x === undefined && args.y === undefined) placeBesideSiblings(graph, node.id)\n return { id: node.id, name: node.name, type: node.type, image: size }\n}\n\nexport const generateImage = defineTool({\n name: 'generate_image',\n description:\n 'Generate an image from a text prompt with the image service the user set up in Settings → Image services (BYOK). With id, the image fills that layer: it replaces the image the layer shows, or goes on top of its fills. Without id, it becomes a new rectangle layer at the image’s size (or the given width), beside the parent’s content unless x and y are given. It sends the prompt to that service with the user’s own key, costs them money, and takes a while, so call it only when the user asks for a generated image; prefer stock_photo for ordinary photography.',\n execution: { kind: 'async', mutation: 'document' },\n capabilities: ['document:write', 'network:access'],\n input: v.strictObject({\n prompt: promptInput('What the image shows, its style, and its mood, in English'),\n id: v.optional(v.pipe(v.string(), v.description('Layer to fill with the image'))),\n orientation: v.optional(\n v.pipe(\n v.picklist(IMAGE_AI_ORIENTATIONS),\n v.description('Shape of the image (default: the layer’s, else square)')\n )\n ),\n transparent: v.optional(\n v.pipe(v.boolean(), v.description('Ask for a transparent background, for cut-out subjects'))\n ),\n width: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.minValue(1),\n v.description('Width of a new layer; its height follows the image (default: image size)')\n )\n )\n ),\n ...placementInputs\n }),\n execute: async (figma, args) => {\n const graph = figma.graph\n const target = args.id ? graph.getNode(args.id) : undefined\n if (args.id && !target) return nodeNotFound(args.id)\n if (target && !canHoldImageFill(target)) {\n return { error: `\"${target.name}\" (${target.type}) cannot show an image fill` }\n }\n const parentId = args.parent_id ?? figma.currentPage.id\n if (!target && !graph.getNode(parentId)) return { error: `Parent \"${parentId}\" not found` }\n if (!target) prepareSlotInsertion(graph, parentId, 'generate_image')\n const service = getImageAIService(graph)\n if (!service) return { error: IMAGE_AI_UNAVAILABLE }\n\n const previousHash = target ? vectorizableImageFill(target)?.imageHash : undefined\n let bytes: Uint8Array\n try {\n bytes = await service.generateImage({\n prompt: args.prompt,\n orientation:\n args.orientation ?? (target ? orientationFor(target.width, target.height) : 'square'),\n transparent: args.transparent\n })\n } catch (error) {\n return toolFailure(error)\n }\n const size = imageSize(bytes)\n if (!size || size.width <= 0 || size.height <= 0) {\n return { error: 'The image service returned no image this document can show' }\n }\n\n if (target) return fillLayerWithImage(graph, target, previousHash, bytes, size)\n return createImageLayer(graph, parentId, args, bytes, size)\n }\n})\n\nexport const generateSVG = defineTool({\n name: 'generate_svg',\n description:\n 'Generate an illustration, icon, or logo mark from a text prompt as SVG with the vectorize service the user set up in Settings → Image services, and import it as editable vector layers, as import_svg does. The new frame goes beside the parent’s content unless x and y are given. It uses the user’s own key and takes a while, so call it only when the user asks for generated vector art; use insert_icon for standard icons.',\n execution: { kind: 'async', mutation: 'document' },\n capabilities: ['document:write', 'network:access'],\n input: v.strictObject({\n prompt: promptInput('What the artwork shows and its style, in English'),\n ...placementInputs\n }),\n execute: async (figma, args) => {\n const graph = figma.graph\n const parentId = args.parent_id ?? figma.currentPage.id\n if (!graph.getNode(parentId)) return { error: `Parent \"${parentId}\" not found` }\n prepareSlotInsertion(graph, parentId, 'generate_svg')\n const service = getImageAIService(graph)\n if (!service) return { error: IMAGE_AI_UNAVAILABLE }\n\n let svg: string\n try {\n svg = await service.generateSVG({ prompt: args.prompt })\n } catch (error) {\n return toolFailure(error)\n }\n if (!graph.getNode(parentId)) return { error: `Parent \"${parentId}\" was deleted meanwhile` }\n const result = await importSVG.execute(figma, {\n svg,\n name: args.name ?? layerNameFromPrompt(args.prompt, GENERATED_SVG_NAME),\n parent_id: parentId,\n x: args.x,\n y: args.y\n })\n const id = v.safeParse(v.object({ id: v.string() }), result)\n if (!id.success) return result\n if (args.x === undefined && args.y === undefined) placeBesideSiblings(graph, id.output.id)\n return result\n }\n})\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AAE3B,MAAM,eAAe,gBACnB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,MAAM,MAAM,2BAA2B,GAAG,EAAE,YAAY,WAAW,CAAC;AAE3F,MAAM,kBAAkB;CACtB,MAAM,EAAE,SACN,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,2DAA2D,CAAC,CAC/F;CACA,WAAW,EAAE,SACX,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,qDAAqD,CAAC,CACzF;CACA,GAAG,EAAE,SACH,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,+CAA+C,CAAC,CAAC,CAC/F;CACA,GAAG,EAAE,SACH,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,+CAA+C,CAAC,CAAC,CAC/F;AACF;;AAGA,SAAS,mBACP,OACA,QACA,cACA,OACA,MACA;CAEA,MAAM,UAAU,MAAM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AO;EACxB,IAAI,KAAK,MAAM,KAAA,KAAa,KAAK,MAAM,KAAA,GAAW,oBAAoB,OAAO,GAAG,OAAO,EAAE;EACzF,OAAO;CACT;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"generate.js","names":[],"sources":["../../../src/tools/image-ai/generate.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { imageSize } from '@pairdraw/scene-graph/images'\nimport type { Size } from '@pairdraw/scene-graph/primitives'\n\nimport { storeImage } from '#core/figma-api/images'\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { importSVG } from '#core/tools/create/svg'\nimport { defineTool, nodeNotFound, toolFailure, toolNumber } from '#core/tools/schema'\nimport { vectorizableImageFill } from '#core/vector/vectorize'\n\nimport {\n canHoldImageFill,\n imageFill,\n layerNameFromPrompt,\n orientationFor,\n placeBesideSiblings,\n swapLayerImage\n} from './apply'\nimport { getImageAIService, IMAGE_AI_ORIENTATIONS, IMAGE_AI_UNAVAILABLE } from './service'\n\nconst GENERATED_IMAGE_NAME = 'Generated image'\nconst GENERATED_SVG_NAME = 'Generated SVG'\n\nconst promptInput = (description: string) =>\n v.pipe(v.string(), v.regex(/\\S/, 'Describe what to generate'), v.description(description))\n\nconst placementInputs = {\n name: v.optional(\n v.pipe(v.string(), v.description('Name of the new layer (default: the prompt’s first words)'))\n ),\n parent_id: v.optional(\n v.pipe(v.string(), v.description('Parent of the new layer (default: the current page)'))\n ),\n x: v.optional(\n toolNumber(v.pipe(v.number(), v.description('X in the parent (default: beside its content)')))\n ),\n y: v.optional(\n toolNumber(v.pipe(v.number(), v.description('Y in the parent (default: beside its content)')))\n )\n}\n\n/** Shows `bytes` in `target`, unless another edit removed the layer or changed its image meanwhile. */\nfunction fillLayerWithImage(\n graph: SceneGraph,\n target: SceneNode,\n previousHash: string | undefined,\n bytes: Uint8Array,\n size: Size\n) {\n // The service may outlast the layer or its image: another edit can change either meanwhile.\n const current = graph.getNode(target.id)\n if (!current) return { error: `\"${target.name}\" was deleted before the image arrived` }\n if (previousHash) {\n if (!swapLayerImage(graph, current.id, previousHash, bytes)) {\n return { error: `The image of \"${current.name}\" changed before the new one arrived` }\n }\n } else {\n graph.updateNode(current.id, {\n fills: [...current.fills, imageFill(storeImage(graph, bytes))]\n })\n }\n return { id: current.id, name: current.name, type: current.type, image: size }\n}\n\ninterface ImageLayerPlacement {\n prompt: string\n name?: string\n width?: number\n x?: number\n y?: number\n}\n\n/** A new rectangle in `parentId` showing `bytes` at the image's aspect ratio. */\nfunction createImageLayer(\n graph: SceneGraph,\n parentId: string,\n args: ImageLayerPlacement,\n bytes: Uint8Array,\n size: Size\n) {\n if (!graph.getNode(parentId)) return { error: `Parent \"${parentId}\" was deleted meanwhile` }\n const width = args.width ?? size.width\n const node = graph.createNode('RECTANGLE', parentId, {\n name: args.name ?? layerNameFromPrompt(args.prompt, GENERATED_IMAGE_NAME),\n x: args.x ?? 0,\n y: args.y ?? 0,\n width,\n height: (width * size.height) / size.width,\n fills: [imageFill(storeImage(graph, bytes))]\n })\n if (args.x === undefined && args.y === undefined) placeBesideSiblings(graph, node.id)\n return { id: node.id, name: node.name, type: node.type, image: size }\n}\n\nexport const generateImage = defineTool({\n name: 'generate_image',\n description:\n 'Generate an image from a text prompt with the image service the user set up in Settings → Image services (BYOK). With id, the image fills that layer: it replaces the image the layer shows, or goes on top of its fills. Without id, it becomes a new rectangle layer at the image’s size (or the given width), beside the parent’s content unless x and y are given. It sends the prompt to that service with the user’s own key, costs them money, and takes a while, so call it only when the user asks for a generated image; prefer stock_photo for ordinary photography.',\n execution: { kind: 'async', mutation: 'document' },\n content: 'imported',\n capabilities: ['document:write', 'network:access'],\n input: v.strictObject({\n prompt: promptInput('What the image shows, its style, and its mood, in English'),\n id: v.optional(v.pipe(v.string(), v.description('Layer to fill with the image'))),\n orientation: v.optional(\n v.pipe(\n v.picklist(IMAGE_AI_ORIENTATIONS),\n v.description('Shape of the image (default: the layer’s, else square)')\n )\n ),\n transparent: v.optional(\n v.pipe(v.boolean(), v.description('Ask for a transparent background, for cut-out subjects'))\n ),\n width: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.minValue(1),\n v.description('Width of a new layer; its height follows the image (default: image size)')\n )\n )\n ),\n ...placementInputs\n }),\n execute: async (figma, args) => {\n const graph = figma.graph\n const target = args.id ? graph.getNode(args.id) : undefined\n if (args.id && !target) return nodeNotFound(args.id)\n if (target && !canHoldImageFill(target)) {\n return { error: `\"${target.name}\" (${target.type}) cannot show an image fill` }\n }\n const parentId = args.parent_id ?? figma.currentPage.id\n if (!target && !graph.getNode(parentId)) return { error: `Parent \"${parentId}\" not found` }\n if (!target) prepareSlotInsertion(graph, parentId, 'generate_image')\n const service = getImageAIService(graph)\n if (!service) return { error: IMAGE_AI_UNAVAILABLE }\n\n const previousHash = target ? vectorizableImageFill(target)?.imageHash : undefined\n let bytes: Uint8Array\n try {\n bytes = await service.generateImage({\n prompt: args.prompt,\n orientation:\n args.orientation ?? (target ? orientationFor(target.width, target.height) : 'square'),\n transparent: args.transparent\n })\n } catch (error) {\n return toolFailure(error)\n }\n const size = imageSize(bytes)\n if (!size || size.width <= 0 || size.height <= 0) {\n return { error: 'The image service returned no image this document can show' }\n }\n\n if (target) return fillLayerWithImage(graph, target, previousHash, bytes, size)\n return createImageLayer(graph, parentId, args, bytes, size)\n }\n})\n\nexport const generateSVG = defineTool({\n name: 'generate_svg',\n description:\n 'Generate an illustration, icon, or logo mark from a text prompt as SVG with the vectorize service the user set up in Settings → Image services, and import it as editable vector layers, as import_svg does. The new frame goes beside the parent’s content unless x and y are given. It uses the user’s own key and takes a while, so call it only when the user asks for generated vector art; use insert_icon for standard icons.',\n execution: { kind: 'async', mutation: 'document' },\n content: 'imported',\n capabilities: ['document:write', 'network:access'],\n input: v.strictObject({\n prompt: promptInput('What the artwork shows and its style, in English'),\n ...placementInputs\n }),\n execute: async (figma, args) => {\n const graph = figma.graph\n const parentId = args.parent_id ?? figma.currentPage.id\n if (!graph.getNode(parentId)) return { error: `Parent \"${parentId}\" not found` }\n prepareSlotInsertion(graph, parentId, 'generate_svg')\n const service = getImageAIService(graph)\n if (!service) return { error: IMAGE_AI_UNAVAILABLE }\n\n let svg: string\n try {\n svg = await service.generateSVG({ prompt: args.prompt })\n } catch (error) {\n return toolFailure(error)\n }\n if (!graph.getNode(parentId)) return { error: `Parent \"${parentId}\" was deleted meanwhile` }\n const result = await importSVG.execute(figma, {\n svg,\n name: args.name ?? layerNameFromPrompt(args.prompt, GENERATED_SVG_NAME),\n parent_id: parentId,\n x: args.x,\n y: args.y\n })\n const id = v.safeParse(v.object({ id: v.string() }), result)\n if (!id.success) return result\n if (args.x === undefined && args.y === undefined) placeBesideSiblings(graph, id.output.id)\n return result\n }\n})\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AAE3B,MAAM,eAAe,gBACnB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,MAAM,MAAM,2BAA2B,GAAG,EAAE,YAAY,WAAW,CAAC;AAE3F,MAAM,kBAAkB;CACtB,MAAM,EAAE,SACN,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,2DAA2D,CAAC,CAC/F;CACA,WAAW,EAAE,SACX,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,qDAAqD,CAAC,CACzF;CACA,GAAG,EAAE,SACH,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,+CAA+C,CAAC,CAAC,CAC/F;CACA,GAAG,EAAE,SACH,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,+CAA+C,CAAC,CAAC,CAC/F;AACF;;AAGA,SAAS,mBACP,OACA,QACA,cACA,OACA,MACA;CAEA,MAAM,UAAU,MAAM,QAAQ,OAAO,EAAE;CACvC,IAAI,CAAC,SAAS,OAAO,EAAE,OAAO,IAAI,OAAO,KAAK,wCAAwC;CACtF,IAA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,GAAG,OAAO,EAAE;EACzF,OAAO;CACT;AACF,CAAC"}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { IMAGE_AI_ORIENTATIONS, ImageAIImage, ImageAIOrientation, ImageAIService
|
|
|
16
16
|
import { canHoldImageFill, layerNameFromPrompt, orientationFor } from "./image-ai/apply.js";
|
|
17
17
|
import "./image-ai.js";
|
|
18
18
|
import { CODEGEN_PROMPT } from "./prompts/index.js";
|
|
19
|
+
import { getVideoEncoder, registerVideoEncoder } from "./video-host.js";
|
|
19
20
|
import { ScriptToolHost, getScriptToolHost, registerScriptToolHost } from "./script/host.js";
|
|
20
21
|
import { SCRIPT_EXAMPLES, ScriptExampleName } from "./script/examples.js";
|
|
21
22
|
import { CORE_TOOLS } from "./registry/core.js";
|
|
@@ -30,4 +31,4 @@ import { STYLE_ARCHETYPES, StyleArchetypeWithGuide, StyleSearch, getStyleArchety
|
|
|
30
31
|
import "./styles.js";
|
|
31
32
|
import { arrangeNodes } from "./structure/arrange.js";
|
|
32
33
|
import "./structure.js";
|
|
33
|
-
export { type AIAdapterOptions, ALL_TOOLS, CODEGEN_PROMPT, CORE_TOOLS, type ComponentCatalog, type ComponentCatalogInsertInput, type ComponentCatalogLibraryAsset, type DocumentDiff, type DocumentDiffOptions, EXTENDED_TOOLS, type HTMLToolHost, IMAGE_AI_ORIENTATIONS, type ImageAIImage, type ImageAIOrientation, type ImageAIService, type ImageVectorizeRequest, type ImageVectorizer, type LayerJSXChange, NodeNotFoundError, SCRIPT_EXAMPLES, STYLE_ARCHETYPES, STYLE_ARCHETYPE_IDS, type ScriptExampleName, type ScriptToolHost, type StepBudget, type StockPhotoKeyCheck, type StockPhotoOrientation, type StockPhotoProvider, type StockPhotoResult, type StockPhotoSearchOptions, type StyleArchetype, type StyleArchetypeId, type StyleArchetypeWithGuide, type StyleElevation, type StyleFont, type StylePalette, type StyleSearch, type ToolCapability, type ToolDebugLog, type ToolDef, type ToolExecution, type ToolExposure, type ToolInterface, type ToolLogEntry, VALID_OVERLAP_CATEGORIES, VALID_OVERLAP_SCOPES, VALID_OVERLAP_SEVERITIES, arrangeNodes, buildDebugLog, calcClusterConfidence, canHoldImageFill, checkStockPhotoKey, compileScript, defineTool, diffDocuments, diffPageLayersJSX, exportImage, getComponentCatalog, getHTMLToolHost, getImageAIService, getImageVectorizer, getScriptToolHost, getStockPhotoProvider, getStockPhotoProviders, getStyleArchetype, importMermaid, importSVG, isAtomicTool, isToolExposed, layerNameFromPrompt, nodeSummary, nodeToResult, orientationFor, parseOverlapCategories, parseOverlapScope, parseOverlapSeverity, parseToolArgs, registerComponentCatalog, registerHTMLToolHost, registerImageAIService, registerImageVectorizer, registerScriptToolHost, registerStockPhotoProvider, requireNode, searchStyleArchetypes, setActiveStockPhotoProvider, setPexelsAPIKey, setUnsplashAccessKey, toolChangesDocument, toolFailure, toolNumber, toolsToAI, wrapEvalCode };
|
|
34
|
+
export { type AIAdapterOptions, ALL_TOOLS, CODEGEN_PROMPT, CORE_TOOLS, type ComponentCatalog, type ComponentCatalogInsertInput, type ComponentCatalogLibraryAsset, type DocumentDiff, type DocumentDiffOptions, EXTENDED_TOOLS, type HTMLToolHost, IMAGE_AI_ORIENTATIONS, type ImageAIImage, type ImageAIOrientation, type ImageAIService, type ImageVectorizeRequest, type ImageVectorizer, type LayerJSXChange, NodeNotFoundError, SCRIPT_EXAMPLES, STYLE_ARCHETYPES, STYLE_ARCHETYPE_IDS, type ScriptExampleName, type ScriptToolHost, type StepBudget, type StockPhotoKeyCheck, type StockPhotoOrientation, type StockPhotoProvider, type StockPhotoResult, type StockPhotoSearchOptions, type StyleArchetype, type StyleArchetypeId, type StyleArchetypeWithGuide, type StyleElevation, type StyleFont, type StylePalette, type StyleSearch, type ToolCapability, type ToolDebugLog, type ToolDef, type ToolExecution, type ToolExposure, type ToolInterface, type ToolLogEntry, VALID_OVERLAP_CATEGORIES, VALID_OVERLAP_SCOPES, VALID_OVERLAP_SEVERITIES, arrangeNodes, buildDebugLog, calcClusterConfidence, canHoldImageFill, checkStockPhotoKey, compileScript, defineTool, diffDocuments, diffPageLayersJSX, exportImage, getComponentCatalog, getHTMLToolHost, getImageAIService, getImageVectorizer, getScriptToolHost, getStockPhotoProvider, getStockPhotoProviders, getStyleArchetype, getVideoEncoder, importMermaid, importSVG, isAtomicTool, isToolExposed, layerNameFromPrompt, nodeSummary, nodeToResult, orientationFor, parseOverlapCategories, parseOverlapScope, parseOverlapSeverity, parseToolArgs, registerComponentCatalog, registerHTMLToolHost, registerImageAIService, registerImageVectorizer, registerScriptToolHost, registerStockPhotoProvider, registerVideoEncoder, requireNode, searchStyleArchetypes, setActiveStockPhotoProvider, setPexelsAPIKey, setUnsplashAccessKey, toolChangesDocument, toolFailure, toolNumber, toolsToAI, wrapEvalCode };
|
package/dist/tools/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { importSVG } from "./create/svg.js";
|
|
|
14
14
|
import { canHoldImageFill, layerNameFromPrompt, orientationFor } from "./image-ai/apply.js";
|
|
15
15
|
import { IMAGE_AI_ORIENTATIONS, getImageAIService, registerImageAIService } from "./image-ai/service.js";
|
|
16
16
|
import { CODEGEN_PROMPT } from "./prompts/index.js";
|
|
17
|
+
import { getVideoEncoder, registerVideoEncoder } from "./video-host.js";
|
|
17
18
|
import { SCRIPT_EXAMPLES } from "./script/examples.js";
|
|
18
19
|
import { checkStockPhotoKey, getStockPhotoProvider, getStockPhotoProviders, registerStockPhotoProvider, setActiveStockPhotoProvider, setPexelsAPIKey, setUnsplashAccessKey } from "./stock-photo/providers.js";
|
|
19
20
|
import { arrangeNodes } from "./structure/arrange.js";
|
|
@@ -23,4 +24,4 @@ import { STYLE_ARCHETYPES, getStyleArchetype, searchStyleArchetypes } from "./st
|
|
|
23
24
|
import { STYLE_ARCHETYPE_IDS } from "./styles/types.js";
|
|
24
25
|
import { EXTENDED_TOOLS } from "./registry/extended.js";
|
|
25
26
|
import { ALL_TOOLS } from "./registry/index.js";
|
|
26
|
-
export { ALL_TOOLS, CODEGEN_PROMPT, CORE_TOOLS, EXTENDED_TOOLS, IMAGE_AI_ORIENTATIONS, NodeNotFoundError, SCRIPT_EXAMPLES, STYLE_ARCHETYPES, STYLE_ARCHETYPE_IDS, VALID_OVERLAP_CATEGORIES, VALID_OVERLAP_SCOPES, VALID_OVERLAP_SEVERITIES, arrangeNodes, buildDebugLog, calcClusterConfidence, canHoldImageFill, checkStockPhotoKey, compileScript, defineTool, diffDocuments, diffPageLayersJSX, exportImage, getComponentCatalog, getHTMLToolHost, getImageAIService, getImageVectorizer, getScriptToolHost, getStockPhotoProvider, getStockPhotoProviders, getStyleArchetype, importMermaid, importSVG, isAtomicTool, isToolExposed, layerNameFromPrompt, nodeSummary, nodeToResult, orientationFor, parseOverlapCategories, parseOverlapScope, parseOverlapSeverity, parseToolArgs, registerComponentCatalog, registerHTMLToolHost, registerImageAIService, registerImageVectorizer, registerScriptToolHost, registerStockPhotoProvider, requireNode, searchStyleArchetypes, setActiveStockPhotoProvider, setPexelsAPIKey, setUnsplashAccessKey, toolChangesDocument, toolFailure, toolNumber, toolsToAI, wrapEvalCode };
|
|
27
|
+
export { ALL_TOOLS, CODEGEN_PROMPT, CORE_TOOLS, EXTENDED_TOOLS, IMAGE_AI_ORIENTATIONS, NodeNotFoundError, SCRIPT_EXAMPLES, STYLE_ARCHETYPES, STYLE_ARCHETYPE_IDS, VALID_OVERLAP_CATEGORIES, VALID_OVERLAP_SCOPES, VALID_OVERLAP_SEVERITIES, arrangeNodes, buildDebugLog, calcClusterConfidence, canHoldImageFill, checkStockPhotoKey, compileScript, defineTool, diffDocuments, diffPageLayersJSX, exportImage, getComponentCatalog, getHTMLToolHost, getImageAIService, getImageVectorizer, getScriptToolHost, getStockPhotoProvider, getStockPhotoProviders, getStyleArchetype, getVideoEncoder, importMermaid, importSVG, isAtomicTool, isToolExposed, layerNameFromPrompt, nodeSummary, nodeToResult, orientationFor, parseOverlapCategories, parseOverlapScope, parseOverlapSeverity, parseToolArgs, registerComponentCatalog, registerHTMLToolHost, registerImageAIService, registerImageVectorizer, registerScriptToolHost, registerStockPhotoProvider, registerVideoEncoder, requireNode, searchStyleArchetypes, setActiveStockPhotoProvider, setPexelsAPIKey, setUnsplashAccessKey, toolChangesDocument, toolFailure, toolNumber, toolsToAI, wrapEvalCode };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","names":[],"sources":["../../../src/tools/modify/fonts.ts"],"mappings":";;cAea,cAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { replaceDocumentFonts } from "../../text/replace-fonts.js";
|
|
2
|
+
import { defineTool } from "../schema.js";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
//#region src/tools/modify/fonts.ts
|
|
5
|
+
const faceInputSchema = v.strictObject({
|
|
6
|
+
family: v.pipe(v.string(), v.description("Font family, as list_fonts or a text node names it")),
|
|
7
|
+
style: v.pipe(v.string(), v.description("Face style, such as \"Regular\" or \"Semi Bold\""))
|
|
8
|
+
});
|
|
9
|
+
const replacementInputSchema = v.strictObject({
|
|
10
|
+
from: faceInputSchema,
|
|
11
|
+
to: faceInputSchema
|
|
12
|
+
});
|
|
13
|
+
const replaceFonts = defineTool({
|
|
14
|
+
name: "replace_fonts",
|
|
15
|
+
description: "Replace font faces everywhere in the document: text layers, character runs, and text styles. Other faces keep their runs. One undoable step. Run list_fonts with scope \"document\" first to see the faces in use and which are missing.",
|
|
16
|
+
execution: {
|
|
17
|
+
kind: "sync",
|
|
18
|
+
mutation: "document"
|
|
19
|
+
},
|
|
20
|
+
exposure: { webmcp: false },
|
|
21
|
+
input: v.strictObject({ replacements: v.pipe(v.array(replacementInputSchema), v.minLength(1), v.description("Faces to swap, each { from: { family, style }, to: { family, style } }. A source face may appear once.")) }),
|
|
22
|
+
execute: (figma, args) => replaceDocumentFonts(figma.graph, args.replacements)
|
|
23
|
+
});
|
|
24
|
+
//#endregion
|
|
25
|
+
export { replaceFonts };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=fonts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.js","names":[],"sources":["../../../src/tools/modify/fonts.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { replaceDocumentFonts } from '#core/text/replace-fonts'\nimport { defineTool } from '#core/tools/schema'\n\nconst faceInputSchema = v.strictObject({\n family: v.pipe(v.string(), v.description('Font family, as list_fonts or a text node names it')),\n style: v.pipe(v.string(), v.description('Face style, such as \"Regular\" or \"Semi Bold\"'))\n})\n\nconst replacementInputSchema = v.strictObject({\n from: faceInputSchema,\n to: faceInputSchema\n})\n\nexport const replaceFonts = defineTool({\n name: 'replace_fonts',\n description:\n 'Replace font faces everywhere in the document: text layers, character runs, and text ' +\n 'styles. Other faces keep their runs. One undoable step. Run list_fonts with scope ' +\n '\"document\" first to see the faces in use and which are missing.',\n execution: { kind: 'sync', mutation: 'document' },\n exposure: { webmcp: false },\n input: v.strictObject({\n replacements: v.pipe(\n v.array(replacementInputSchema),\n v.minLength(1),\n v.description(\n 'Faces to swap, each { from: { family, style }, to: { family, style } }. A source face may appear once.'\n )\n )\n }),\n execute: (figma, args) => replaceDocumentFonts(figma.graph, args.replacements)\n})\n"],"mappings":";;;;AAKA,MAAM,kBAAkB,EAAE,aAAa;CACrC,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,oDAAoD,CAAC;CAC9F,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,kDAA8C,CAAC;AACzF,CAAC;AAED,MAAM,yBAAyB,EAAE,aAAa;CAC5C,MAAM;CACN,IAAI;AACN,CAAC;AAED,MAAa,eAAe,WAAW;CACrC,MAAM;CACN,aACE;CAGF,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,UAAU,EAAE,QAAQ,MAAM;CAC1B,OAAO,EAAE,aAAa,EACpB,cAAc,EAAE,KACd,EAAE,MAAM,sBAAsB,GAC9B,EAAE,UAAU,CAAC,GACb,EAAE,YACA,wGACF,CACF,EACF,CAAC;CACD,UAAU,OAAO,SAAS,qBAAqB,MAAM,OAAO,KAAK,YAAY;AAC/E,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineTool, nodeIdInputSchema, parseToolColor, toolFailure, toolNumber } from "../schema.js";
|
|
2
1
|
import { storeImage } from "../../figma-api/images.js";
|
|
2
|
+
import { defineTool, nodeIdInputSchema, parseToolColor, toolFailure, toolNumber } from "../schema.js";
|
|
3
3
|
import { isValid, toUint8Array } from "js-base64";
|
|
4
4
|
import { gradientTransformRows, linearGradientTransform } from "@pairdraw/scene-graph/gradient";
|
|
5
5
|
import * as v from "valibot";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions.d.ts","names":[],"sources":["../../../src/tools/modify/reactions.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"reactions.d.ts","names":[],"sources":["../../../src/tools/modify/reactions.ts"],"mappings":";;cAwBa,cAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineTool, nodeIdInputSchema, nodeNotFound, toolFailure } from "../schema.js";
|
|
2
1
|
import { figmaReactionsSchema } from "../../figma-api/reactions.js";
|
|
2
|
+
import { defineTool, nodeIdInputSchema, nodeNotFound, toolFailure } from "../schema.js";
|
|
3
3
|
import * as v from "valibot";
|
|
4
4
|
//#region src/tools/modify/reactions.ts
|
|
5
5
|
/** Connections in Figma's plugin shape, which the layer's `reactions` reads and writes. */
|
|
6
|
-
const reactionsInputSchema = v.pipe(figmaReactionsSchema, v.description("Prototype connections in Figma's plugin shape: [{ trigger: { type: 'ON_CLICK' } | { type: 'AFTER_TIMEOUT', timeout: seconds }, actions: [{ type: 'NODE', destinationId: '
|
|
6
|
+
const reactionsInputSchema = v.pipe(figmaReactionsSchema, v.description("Prototype connections in Figma's plugin shape: [{ trigger: { type: 'ON_CLICK' | 'ON_HOVER' | 'ON_PRESS' } | { type: 'MOUSE_ENTER' | 'MOUSE_LEAVE', delay?: seconds } | { type: 'AFTER_TIMEOUT', timeout: seconds }, actions: [{ type: 'NODE', destinationId, navigation: 'NAVIGATE' | 'OVERLAY' | 'CHANGE_TO' | 'SCROLL_TO', transition: { type: 'INSTANT' | 'DISSOLVE' | 'SMART_ANIMATE', duration: seconds, easing?: { type: 'EASE_OUT' | 'EASE_IN' | 'EASE_IN_AND_OUT' | 'LINEAR' } }, overlayRelativePosition?: 'CENTER' | ... } | { type: 'BACK' } | { type: 'CLOSE' }] }]. NAVIGATE and OVERLAY point at a top-level frame on the same page; CHANGE_TO at another variant of the set the layer is a variant of, an instance of, or inside (set it once on the main component variant and every instance gets it); SCROLL_TO at a layer in the layer's top-level frame. ON_HOVER and ON_PRESS undo their action when the pointer leaves or lifts. SMART_ANIMATE moves the layers two frames or variants share by name and place, and fades the rest; easing defaults to EASE_OUT."));
|
|
7
7
|
const setReactions = defineTool({
|
|
8
8
|
name: "set_reactions",
|
|
9
|
-
description: "Replace the prototype connections on a layer. Use get_reactions to read them back
|
|
9
|
+
description: "Replace the prototype connections on a layer. Use get_reactions to read them back. Refuses a trigger, action, transition, navigation or destination the prototype play cannot run. Set overflow scrolling with update_node overflow_direction.",
|
|
10
10
|
execution: {
|
|
11
11
|
kind: "sync",
|
|
12
12
|
mutation: "properties"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions.js","names":[],"sources":["../../../src/tools/modify/reactions.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { figmaReactionsSchema } from '#core/figma-api/reactions'\nimport { defineTool, nodeIdInputSchema, nodeNotFound, toolFailure } from '#core/tools/schema'\n\n/** Connections in Figma's plugin shape, which the layer's `reactions` reads and writes. */\nconst reactionsInputSchema = v.pipe(\n figmaReactionsSchema,\n v.description(\n \"Prototype connections in Figma's plugin shape: [{ trigger: { type: 'ON_CLICK' } | \" +\n \"{ type: 'AFTER_TIMEOUT', timeout: seconds }, actions: [{ type: 'NODE', \" +\n \"
|
|
1
|
+
{"version":3,"file":"reactions.js","names":[],"sources":["../../../src/tools/modify/reactions.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { figmaReactionsSchema } from '#core/figma-api/reactions'\nimport { defineTool, nodeIdInputSchema, nodeNotFound, toolFailure } from '#core/tools/schema'\n\n/** Connections in Figma's plugin shape, which the layer's `reactions` reads and writes. */\nconst reactionsInputSchema = v.pipe(\n figmaReactionsSchema,\n v.description(\n \"Prototype connections in Figma's plugin shape: [{ trigger: { type: 'ON_CLICK' | \" +\n \"'ON_HOVER' | 'ON_PRESS' } | { type: 'MOUSE_ENTER' | 'MOUSE_LEAVE', delay?: seconds } | \" +\n \"{ type: 'AFTER_TIMEOUT', timeout: seconds }, actions: [{ type: 'NODE', destinationId, \" +\n \"navigation: 'NAVIGATE' | 'OVERLAY' | 'CHANGE_TO' | 'SCROLL_TO', transition: { type: \" +\n \"'INSTANT' | 'DISSOLVE' | 'SMART_ANIMATE', duration: seconds, easing?: { type: 'EASE_OUT' | \" +\n \"'EASE_IN' | 'EASE_IN_AND_OUT' | 'LINEAR' } }, overlayRelativePosition?: 'CENTER' | ... } | \" +\n \"{ type: 'BACK' } | { type: 'CLOSE' }] }]. NAVIGATE and OVERLAY point at a top-level frame \" +\n 'on the same page; CHANGE_TO at another variant of the set the layer is a variant of, an ' +\n 'instance of, or inside (set it once on the main component variant and every instance ' +\n \"gets it); SCROLL_TO at a layer in the layer's top-level frame. ON_HOVER and ON_PRESS undo \" +\n 'their action when the pointer leaves or lifts. SMART_ANIMATE moves the layers two frames or ' +\n 'variants share by name and place, and fades the rest; easing defaults to EASE_OUT.'\n )\n)\n\nexport const setReactions = defineTool({\n name: 'set_reactions',\n\n description:\n 'Replace the prototype connections on a layer. Use get_reactions to read them back. ' +\n 'Refuses a trigger, action, transition, navigation or destination the prototype play ' +\n 'cannot run. Set overflow scrolling with update_node overflow_direction.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n reactions: reactionsInputSchema\n }),\n execute: (figma, { id, reactions }) => {\n const node = figma.getNodeById(id)\n if (!node) return nodeNotFound(id)\n try {\n node.reactions = reactions\n } catch (error) {\n return toolFailure(error)\n }\n return { id, reactions: node.reactions }\n }\n})\n"],"mappings":";;;;;AAMA,MAAM,uBAAuB,EAAE,KAC7B,sBACA,EAAE,YACA,whCAYF,CACF;AAEA,MAAa,eAAe,WAAW;CACrC,MAAM;CAEN,aACE;CAGF,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAa;CAClD,OAAO,EAAE,aAAa;EACpB,IAAI;EACJ,WAAW;CACb,CAAC;CACD,UAAU,OAAO,EAAE,IAAI,gBAAgB;EACrC,MAAM,OAAO,MAAM,YAAY,EAAE;EACjC,IAAI,CAAC,MAAM,OAAO,aAAa,EAAE;EACjC,IAAI;GACF,KAAK,YAAY;EACnB,SAAS,OAAO;GACd,OAAO,YAAY,KAAK;EAC1B;EACA,OAAO;GAAE;GAAI,WAAW,KAAK;EAAU;CACzC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","names":[],"sources":["../../../src/tools/modify/text.ts"],"mappings":";;;;;iBAqEgB,UAAU,OAAO,UAAU,aAAa;cAK3C,SAAA;
|
|
1
|
+
{"version":3,"file":"text.d.ts","names":[],"sources":["../../../src/tools/modify/text.ts"],"mappings":";;;;;iBAqEgB,UAAU,OAAO,UAAU,aAAa;cAK3C,SAAA;cAyFA,SAAA;cA4FA,cAAA;cA2DA,eAAA;cAqBA,mBAAA"}
|
|
@@ -67,6 +67,16 @@ const setText = defineTool({
|
|
|
67
67
|
});
|
|
68
68
|
/** Variable font axes a font tool can set, as Figma's `variationSettings`. */
|
|
69
69
|
const variationsInputSchema = v.optional(v.pipe(v.objectWithRest({}, v.number()), v.description("Variable font axis values by OpenType tag (e.g. {\"wght\": 550, \"wdth\": 75}); axes left out keep the style's values. Without a style, the nearest named style is picked.")));
|
|
70
|
+
/** OpenType features a text tool sets, by tag; tags left out keep their state. */
|
|
71
|
+
const fontFeaturesInputSchema = v.optional(v.pipe(v.objectWithRest({}, v.boolean()), v.description("OpenType feature toggles by four-letter tag (e.g. {\"TNUM\": true, \"LIGA\": false, \"SS02\": true}); tags left out keep their state. Only features the font has take effect.")));
|
|
72
|
+
/** Why a feature map cannot apply: a tag is not four letters, or a value is not a boolean. */
|
|
73
|
+
function badFeatureEntry(features) {
|
|
74
|
+
for (const [tag, enabled] of Object.entries(features ?? {})) {
|
|
75
|
+
if (tag.length !== 4) return { error: `"${tag}" is not a four-letter OpenType feature tag` };
|
|
76
|
+
if (typeof enabled !== "boolean") return { error: `Feature "${tag}" needs a boolean value, received ${typeof enabled}` };
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
70
80
|
/**
|
|
71
81
|
* The font a font tool gives text: what it names, the rest from `current`. Axes without a style
|
|
72
82
|
* leave the style out, for the nearest named style to be picked.
|
|
@@ -150,7 +160,7 @@ function badVariationTag(variations) {
|
|
|
150
160
|
}
|
|
151
161
|
/** What a range edit sets, or why it cannot run: nothing named, a bad colour, or a bad link. */
|
|
152
162
|
function rangeEdit(args) {
|
|
153
|
-
if (!args.family && !args.size && !args.style && !args.variations && !args.color && args.hyperlink === void 0) return { error: "set_font_range needs at least one of family, size, style, variations, color, or hyperlink" };
|
|
163
|
+
if (!args.family && !args.size && !args.style && !args.variations && !args.font_features && !args.color && args.hyperlink === void 0) return { error: "set_font_range needs at least one of family, size, style, variations, font_features, color, or hyperlink" };
|
|
154
164
|
const hyperlink = requestedHyperlink(args.hyperlink);
|
|
155
165
|
if (hyperlink && "error" in hyperlink) return hyperlink;
|
|
156
166
|
const color = parseOptionalToolColor(args.color);
|
|
@@ -162,7 +172,7 @@ function rangeEdit(args) {
|
|
|
162
172
|
}
|
|
163
173
|
const setFontRange = defineTool({
|
|
164
174
|
name: "set_font_range",
|
|
165
|
-
description: "Set font properties, color, or a link for a text range.",
|
|
175
|
+
description: "Set font properties, OpenType features, color, or a link for a text range.",
|
|
166
176
|
execution: {
|
|
167
177
|
kind: "sync",
|
|
168
178
|
mutation: "properties"
|
|
@@ -175,6 +185,7 @@ const setFontRange = defineTool({
|
|
|
175
185
|
size: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description("Font size")))),
|
|
176
186
|
style: v.optional(v.pipe(v.string(), v.description("Font style"))),
|
|
177
187
|
variations: variationsInputSchema,
|
|
188
|
+
font_features: fontFeaturesInputSchema,
|
|
178
189
|
color: v.optional(v.pipe(v.string(), v.description("Text color (hex)"))),
|
|
179
190
|
hyperlink: hyperlinkInputSchema
|
|
180
191
|
}),
|
|
@@ -182,7 +193,7 @@ const setFontRange = defineTool({
|
|
|
182
193
|
const node = figma.getNodeById(args.id);
|
|
183
194
|
if (!node) return [];
|
|
184
195
|
const font = args.family || args.style || args.variations ? rangeFont(node, args) : null;
|
|
185
|
-
const laysOut = font !== null || args.size !== void 0;
|
|
196
|
+
const laysOut = font !== null || args.size !== void 0 || args.font_features !== void 0;
|
|
186
197
|
return [...font ? [font] : [], ...laysOut ? textFonts(figma, args.id) : []];
|
|
187
198
|
},
|
|
188
199
|
execute: (figma, args) => {
|
|
@@ -191,6 +202,8 @@ const setFontRange = defineTool({
|
|
|
191
202
|
const { start, end } = args;
|
|
192
203
|
const badTag = badVariationTag(args.variations);
|
|
193
204
|
if (badTag) return badTag;
|
|
205
|
+
const badFeature = badFeatureEntry(args.font_features);
|
|
206
|
+
if (badFeature) return badFeature;
|
|
194
207
|
const edit = rangeEdit(args);
|
|
195
208
|
if ("error" in edit) return edit;
|
|
196
209
|
const { hyperlink, color } = edit;
|
|
@@ -202,6 +215,7 @@ const setFontRange = defineTool({
|
|
|
202
215
|
color
|
|
203
216
|
}]);
|
|
204
217
|
if (hyperlink) node.setRangeHyperlink(start, end, hyperlink.link);
|
|
218
|
+
if (args.font_features) new PairdrawAPI(figma).setRangeFontFeatures(node, start, end, args.font_features);
|
|
205
219
|
} catch (error) {
|
|
206
220
|
return toolFailure(error);
|
|
207
221
|
}
|
|
@@ -244,7 +258,7 @@ const setTextResize = defineTool({
|
|
|
244
258
|
});
|
|
245
259
|
const setTextProperties = defineTool({
|
|
246
260
|
name: "set_text_properties",
|
|
247
|
-
description: "Set text layout properties: alignment, auto-resize, text case, decoration, truncation, and a link for the whole text.",
|
|
261
|
+
description: "Set text layout properties: alignment, auto-resize, text case, decoration, truncation, OpenType features, and a link for the whole text.",
|
|
248
262
|
execution: {
|
|
249
263
|
kind: "sync",
|
|
250
264
|
mutation: "properties"
|
|
@@ -278,7 +292,8 @@ const setTextProperties = defineTool({
|
|
|
278
292
|
"UNDERLINE",
|
|
279
293
|
"STRIKETHROUGH"
|
|
280
294
|
]), v.description("Text decoration"))),
|
|
281
|
-
hyperlink: hyperlinkInputSchema
|
|
295
|
+
hyperlink: hyperlinkInputSchema,
|
|
296
|
+
font_features: fontFeaturesInputSchema
|
|
282
297
|
}),
|
|
283
298
|
fonts: (figma, { id }) => textFonts(figma, id),
|
|
284
299
|
execute: (figma, args) => {
|
|
@@ -287,6 +302,8 @@ const setTextProperties = defineTool({
|
|
|
287
302
|
if (node.type !== "TEXT") return { error: `Node "${args.id}" is not a TEXT node` };
|
|
288
303
|
const hyperlink = requestedHyperlink(args.hyperlink);
|
|
289
304
|
if (hyperlink && "error" in hyperlink) return hyperlink;
|
|
305
|
+
const badFeature = badFeatureEntry(args.font_features);
|
|
306
|
+
if (badFeature) return badFeature;
|
|
290
307
|
const updated = [];
|
|
291
308
|
if (args.align_horizontal !== void 0) {
|
|
292
309
|
node.textAlignHorizontal = args.align_horizontal;
|
|
@@ -308,6 +325,10 @@ const setTextProperties = defineTool({
|
|
|
308
325
|
node.textDecoration = args.text_decoration;
|
|
309
326
|
updated.push("textDecoration");
|
|
310
327
|
}
|
|
328
|
+
if (args.font_features) {
|
|
329
|
+
new PairdrawAPI(figma).setFontFeatures(node, args.font_features);
|
|
330
|
+
updated.push("fontFeatures");
|
|
331
|
+
}
|
|
311
332
|
if (hyperlink) {
|
|
312
333
|
try {
|
|
313
334
|
node.hyperlink = hyperlink.link;
|