@pairdraw/core 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/previews.d.ts +1 -1
- 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/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/selection.d.ts +1 -2
- package/dist/canvas/overlays/selection.d.ts.map +1 -1
- package/dist/canvas/overlays/selection.js +2 -9
- package/dist/canvas/overlays/selection.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +2 -0
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -0
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +0 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -4
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +0 -1
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +13 -2
- 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 -4
- 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 -3
- 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/index.d.ts +2 -2
- package/dist/design-jsx/index.js +2 -2
- package/dist/design-jsx/renderer.d.ts +3 -2
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-jsx/renderer.js +2 -2
- package/dist/design-jsx/renderer.js.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/clipboard/snapshot.d.ts.map +1 -1
- package/dist/editor/clipboard/snapshot.js +12 -4
- package/dist/editor/clipboard/snapshot.js.map +1 -1
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +2 -7
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/color-space.d.ts.map +1 -1
- package/dist/editor/color-space.js +33 -38
- package/dist/editor/color-space.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components.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 +36 -8
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +26 -61
- 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 +6 -3
- 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/nudge.js +1 -1
- package/dist/editor/nudge.js.map +1 -1
- 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 +6 -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/container.d.ts +2 -0
- package/dist/editor/selection/container.d.ts.map +1 -1
- package/dist/editor/selection/container.js +17 -1
- package/dist/editor/selection/container.js.map +1 -1
- package/dist/editor/selection/navigation.js +7 -4
- package/dist/editor/selection/navigation.js.map +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 +6 -2
- package/dist/editor/selection.d.ts +9 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.js +2 -5
- package/dist/editor/shapes/with-text.js.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.js +1 -1
- package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +2 -3
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/group/bounds.d.ts.map +1 -1
- package/dist/editor/structure/group/bounds.js +1 -3
- package/dist/editor/structure/group/bounds.js.map +1 -1
- package/dist/editor/structure/outline-stroke.js +3 -3
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure/reorder.d.ts.map +1 -1
- package/dist/editor/structure/reorder.js +7 -14
- package/dist/editor/structure/reorder.js.map +1 -1
- package/dist/editor/structure/state.js +1 -1
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -2
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/structure.js +3 -3
- package/dist/editor/structure.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +9 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.d.ts.map +1 -1
- package/dist/editor/variables.js +57 -1
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
- package/dist/figma-api/accessors/text/index.js +7 -1
- 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/fonts/loaded.d.ts +3 -1
- package/dist/figma-api/fonts/loaded.d.ts.map +1 -1
- package/dist/figma-api/fonts/loaded.js +8 -1
- package/dist/figma-api/fonts/loaded.js.map +1 -1
- package/dist/figma-api/index.d.ts +18 -0
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +19 -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/serialization.d.ts.map +1 -1
- package/dist/figma-api/serialization.js +2 -1
- package/dist/figma-api/serialization.js.map +1 -1
- package/dist/figma-api/shape-details.d.ts +26 -0
- package/dist/figma-api/shape-details.d.ts.map +1 -0
- package/dist/figma-api/shape-details.js +28 -0
- package/dist/figma-api/shape-details.js.map +1 -0
- package/dist/figma-api/shape-with-text.js +2 -5
- package/dist/figma-api/shape-with-text.js.map +1 -1
- package/dist/figma-api/surface.d.ts +7 -4
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +7 -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/icons/svg.js +1 -1
- package/dist/icons/svg.js.map +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.d.ts.map +1 -1
- package/dist/io/formats/drawio/index.js +2 -1
- 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/layers.d.ts +7 -4
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +4 -1
- package/dist/io/formats/html/layers.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/dom.d.ts +6 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +9 -22
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -1
- package/dist/io/formats/pdf/export.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 +4 -54
- 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 +224 -50
- 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/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +50 -12
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout/derived.d.ts +7 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +11 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/grid.d.ts +7 -2
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +27 -9
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/mutations.d.ts +1 -0
- package/dist/layout/mutations.d.ts.map +1 -1
- package/dist/layout/mutations.js +10 -0
- package/dist/layout/mutations.js.map +1 -1
- package/dist/layout/strokes.d.ts +9 -1
- package/dist/layout/strokes.d.ts.map +1 -1
- package/dist/layout/strokes.js +12 -1
- package/dist/layout/strokes.js.map +1 -1
- package/dist/layout/yoga-helpers.d.ts +3 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +16 -2
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +73 -39
- 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 +13 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +123 -9
- 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/effect-style-required.js +1 -0
- package/dist/lint/rules/effect-style-required.js.map +1 -1
- 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/rules/text-style-required.js +1 -0
- package/dist/lint/rules/text-style-required.js.map +1 -1
- package/dist/lint/types.d.ts +32 -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/commands.d.ts +2 -2
- package/dist/rpc/index.d.ts +2 -2
- package/dist/rpc/read-commands.d.ts +18 -8
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +18 -9
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/font/faces.d.ts +12 -1
- package/dist/text/font/faces.d.ts.map +1 -1
- package/dist/text/font/faces.js +15 -1
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +66 -12
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/index.d.ts +11 -9
- package/dist/text/index.js +4 -2
- 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/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +1 -0
- package/dist/tools/modify/layout.js.map +1 -1
- 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/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.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 +22 -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/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +39 -7
- package/dist/tools/vector/path.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/dist/xpath.d.ts +3 -0
- package/dist/xpath.d.ts.map +1 -1
- package/dist/xpath.js +3 -1
- package/dist/xpath.js.map +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +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/overlays/index.ts +0 -1
- package/src/canvas/overlays/selection.ts +1 -12
- package/src/canvas/renderer/fonts.ts +2 -0
- package/src/canvas/renderer/lifecycle.ts +6 -0
- package/src/canvas/renderer/methods.ts +0 -9
- package/src/canvas/renderer/overlay-pass.ts +0 -1
- package/src/canvas/renderer/pipeline.ts +19 -2
- 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 -3
- package/src/canvas/renderer.ts +40 -4
- 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-jsx/index.ts +1 -1
- package/src/design-jsx/renderer.ts +1 -1
- 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/clipboard/snapshot.ts +21 -4
- package/src/editor/clipboard.ts +4 -14
- package/src/editor/color-space.ts +47 -38
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/create.ts +39 -71
- 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 +16 -2
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/nudge.ts +1 -1
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/container.ts +24 -1
- package/src/editor/selection/navigation.ts +8 -6
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/shapes/with-text.ts +2 -5
- package/src/editor/structure/auto-layout-wrap.ts +1 -1
- package/src/editor/structure/boolean.ts +1 -3
- package/src/editor/structure/group/bounds.ts +1 -5
- package/src/editor/structure/outline-stroke.ts +3 -3
- package/src/editor/structure/reorder.ts +8 -14
- package/src/editor/structure/state.ts +1 -1
- package/src/editor/structure.ts +5 -8
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +8 -1
- package/src/editor/variables.ts +74 -2
- 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 +17 -1
- 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/fonts/loaded.ts +9 -0
- package/src/figma-api/index.ts +35 -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/serialization.ts +2 -1
- package/src/figma-api/shape-details.ts +50 -0
- package/src/figma-api/shape-with-text.ts +2 -5
- package/src/figma-api/surface.ts +7 -2
- package/src/global.d.ts +31 -0
- package/src/icons/svg.ts +3 -1
- 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 +5 -1
- 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/layers.ts +11 -2
- package/src/io/formats/html/vectors.ts +8 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/dom.ts +10 -18
- package/src/io/formats/pdf/export.ts +1 -1
- 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 +14 -73
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +371 -64
- 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/apply.ts +87 -21
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/derived.ts +14 -0
- package/src/layout/grid.ts +33 -9
- package/src/layout/mutations.ts +13 -1
- package/src/layout/strokes.ts +12 -0
- package/src/layout/yoga-helpers.ts +18 -1
- package/src/layout.ts +96 -49
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +124 -12
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/effect-style-required.ts +2 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/rules/text-style-required.ts +2 -0
- package/src/lint/types.ts +40 -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/rpc/index.ts +1 -0
- package/src/rpc/read-commands.ts +40 -23
- package/src/text/font/faces.ts +22 -0
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +88 -12
- 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/layout.ts +5 -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/nodes.ts +0 -1
- 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 +34 -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/path.ts +30 -6
- 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
- package/src/xpath.ts +6 -1
|
@@ -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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":[],"sources":["../../../src/tools/modify/text.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api'\nimport type { FigmaFontName, FigmaFontNameInput } from '#core/figma-api/fonts/names'\nimport type { FigmaVariationSettings } from '#core/figma-api/fonts/variations'\nimport { PairdrawAPI } from '#core/pairdraw-api'\nimport { normalizeLinkURL } from '#core/text/hyperlink'\nimport { collectNodeFontFaces } from '#core/text/requirements/collect'\nimport {\n parseOptionalToolColor,\n toolNumber,\n nodeIdInputSchema,\n defineTool,\n nodeNotFound,\n toolFailure\n} from '#core/tools/schema'\n\n/**\n * A link a text tool sets, as the editor's link field takes it: a web or mail address, with\n * `https:` or `mailto:` added when typed without a scheme. Null or blank removes the link.\n */\nconst hyperlinkInputSchema = v.optional(\n v.pipe(\n v.nullable(v.string()),\n v.description(\n 'Link the text opens: an http(s) or mailto address (\"example.com\" becomes https://example.com, \"hi@example.com\" becomes mailto:). null or \"\" removes the link. Links are not underlined automatically; set text_decoration for that.'\n )\n )\n)\n\n/**\n * A scheme at the start of a typed link, even with a digit after its colon (`tel:123`), unless it\n * reads as a host and port (`localhost:3000`, `example.com:8080`), which gets `https://`.\n */\nconst TYPED_SCHEME = /^([a-z][a-z\\d+.-]*):/i\n\n/** A web address in the form the Figma API's link setter takes: `http(s)://host…`. */\nconst WEB_URL = /^https?:\\/\\/[^\\s/?#]+\\S*$/\n\n/** Whether a typed link names a scheme other than the http, https, and mailto links take. */\nfunction hasForeignScheme(typed: string): boolean {\n const scheme = TYPED_SCHEME.exec(typed)?.[1]?.toLowerCase()\n if (!scheme || scheme.includes('.') || scheme === 'localhost') return false\n return !['http', 'https', 'mailto'].includes(scheme)\n}\n\n/** What setting `hyperlink` asks for: no change, a removal, a URL, or an address it refuses. */\nfunction requestedHyperlink(\n hyperlink: string | null | undefined\n): { link: { type: 'URL'; value: string } | null } | { error: string } | null {\n if (hyperlink === undefined) return null\n if (hyperlink === null || hyperlink.trim() === '') return { link: null }\n const url = hasForeignScheme(hyperlink.trim()) ? null : normalizeLinkURL(hyperlink)\n if (!url) {\n return {\n error: `\"${hyperlink}\" is not a link the editor opens: use an http, https, or mailto address`\n }\n }\n // Figma keeps schemes in lower case and web addresses as `scheme://host`, so a loosely typed\n // `http:example.com` is written as the URL it parses to.\n const lowered = url.replace(TYPED_SCHEME, (scheme) => scheme.toLowerCase())\n const value =\n lowered.startsWith('mailto:') || WEB_URL.test(lowered) ? lowered : new URL(lowered).href\n return { link: { type: 'URL', value } }\n}\n\n/** The fonts a text layer uses, which an edit that lays it out again needs loaded. */\nexport function textFonts(figma: FigmaAPI, id: string): FigmaFontNameInput[] {\n const node = figma.graph.getNode(id)\n return node ? collectNodeFontFaces(node) : []\n}\n\nexport const setText = defineTool({\n name: 'set_text',\n\n description: 'Set text content of a text node.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n text: v.pipe(v.string(), v.description('Text content'))\n }),\n fonts: (figma, { id }) => textFonts(figma, id),\n execute: (figma, { id, text }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n node.characters = text\n return { id, text }\n }\n})\n\n/** Variable font axes a font tool can set, as Figma's `variationSettings`. */\n// An object with a value for every key rather than a record: a record publishes `propertyNames`,\n// which OpenAI refuses, and a JSON object's keys are strings anyway.\nconst variationsInputSchema = v.optional(\n v.pipe(\n v.objectWithRest({}, v.number()),\n v.description(\n '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.'\n )\n )\n)\n\n/**\n * The font a font tool gives text: what it names, the rest from `current`. Axes without a style\n * leave the style out, for the nearest named style to be picked.\n */\nfunction fontNameInput(\n args: { family?: string; style?: string; variations?: FigmaVariationSettings },\n current: FigmaFontName | null\n): FigmaFontNameInput {\n return {\n family: args.family ?? current?.family ?? '',\n style: args.style ?? (args.variations ? undefined : (current?.style ?? 'Regular')),\n variationSettings: args.variations\n }\n}\n\n/**\n * The font `set_font` gives the text, or null when it keeps the text's. Text set in several fonts\n * takes the given family or style for all of it, keeping the rest from its first character. Axes\n * without a style are set per range, each range taking its nearest named style, as in Figma.\n */\nfunction requestedFont(\n node: FigmaNodeProxy,\n args: { family?: string; style?: string; variations?: FigmaVariationSettings }\n): { whole: FigmaFontName } | { perRange: FigmaFontNameInput } | null {\n if (!args.family && !args.style && !args.variations) return null\n const fontName =\n typeof node.fontName === 'symbol' && node.characters.length > 0\n ? node.getRangeFontName(0, 1)\n : node.fontName\n const current = typeof fontName === 'symbol' ? null : fontName\n const family = args.family ?? current?.family ?? ''\n if (args.variations && !args.style && node.characters.length > 0) {\n return { perRange: { family, variationSettings: args.variations } }\n }\n const style = args.style ?? current?.style ?? 'Regular'\n return { whole: { family, style, variationSettings: args.variations } }\n}\n\nexport const setFont = defineTool({\n name: 'set_font',\n\n description: 'Set font properties of a text node.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n family: v.optional(v.pipe(v.string(), v.description('Font family name'))),\n size: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Font size')))),\n style: v.optional(\n v.pipe(v.string(), v.description('Font style (e.g. \"Bold\", \"Regular\", \"Bold Italic\")'))\n ),\n variations: variationsInputSchema\n }),\n // A new font replaces the text's, which then need not be loaded, so a missing font can be\n // replaced; a size or per-range axes lay out the text in its own fonts.\n fonts: (figma, args) => {\n const node = figma.getNodeById(args.id)\n const font = node && requestedFont(node, args)\n if (font && 'whole' in font) return [font.whole]\n return [...(font ? [font.perRange] : []), ...textFonts(figma, args.id)]\n },\n execute: (figma, args) => {\n const node = figma.getNodeById(args.id)\n if (!node) return nodeNotFound(args.id)\n const badTag = badVariationTag(args.variations)\n if (badTag) return badTag\n const font = requestedFont(node, args)\n try {\n if (font && 'whole' in font) node.fontName = font.whole\n else if (font) node.setRangeFontName(0, node.characters.length, font.perRange)\n // The size comes after the font, so it lays the text out in the font it ends up in.\n if (args.size !== undefined) node.fontSize = args.size\n } catch (error) {\n return toolFailure(error)\n }\n return { id: args.id, fontName: node.fontName, fontSize: node.fontSize }\n }\n})\n\n/** The font `set_font_range` gives its range: what it names, the rest from the range's start. */\nfunction rangeFont(\n node: FigmaNodeProxy,\n args: { start: number; family?: string; style?: string; variations?: FigmaVariationSettings }\n): FigmaFontNameInput {\n const inText = args.start < node.characters.length\n const current = inText ? node.getRangeFontName(args.start, args.start + 1) : node.fontName\n return fontNameInput(args, typeof current === 'symbol' ? null : current)\n}\n\ntype RangeEdit = {\n hyperlink: { link: { type: 'URL'; value: string } | null } | null\n color: Color | undefined\n}\n\n/** Why a variation setting cannot apply: an axis tag is not four letters. */\nfunction badVariationTag(variations: FigmaVariationSettings | undefined): { error: string } | null {\n const tag = Object.keys(variations ?? {}).find((key) => key.length !== 4)\n return tag === undefined ? null : { error: `\"${tag}\" is not a four-letter OpenType axis tag` }\n}\n\n/** What a range edit sets, or why it cannot run: nothing named, a bad colour, or a bad link. */\nfunction rangeEdit(args: {\n family?: string\n size?: number\n style?: string\n variations?: unknown\n color?: string\n hyperlink?: string | null\n}): RangeEdit | { error: string } {\n if (\n !args.family &&\n !args.size &&\n !args.style &&\n !args.variations &&\n !args.color &&\n args.hyperlink === undefined\n ) {\n return {\n error:\n 'set_font_range needs at least one of family, size, style, variations, color, or hyperlink'\n }\n }\n const hyperlink = requestedHyperlink(args.hyperlink)\n if (hyperlink && 'error' in hyperlink) return hyperlink\n const color = parseOptionalToolColor(args.color)\n if ('error' in color) return color\n return { hyperlink: hyperlink ?? null, color: color.color }\n}\n\nexport const setFontRange = defineTool({\n name: 'set_font_range',\n\n description: 'Set font properties, color, or a link for a text range.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n start: toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Start character index'))),\n end: toolNumber(v.pipe(v.number(), v.minValue(0), v.description('End character index'))),\n family: v.optional(v.pipe(v.string(), v.description('Font family name'))),\n size: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Font size')))),\n style: v.optional(v.pipe(v.string(), v.description('Font style'))),\n variations: variationsInputSchema,\n color: v.optional(v.pipe(v.string(), v.description('Text color (hex)'))),\n hyperlink: hyperlinkInputSchema\n }),\n fonts: (figma, args) => {\n const node = figma.getNodeById(args.id)\n if (!node) return []\n const font = args.family || args.style || args.variations ? rangeFont(node, args) : null\n // A colour alone is a paint and lays nothing out, so text in a missing font can still take it.\n const laysOut = font !== null || args.size !== undefined\n return [...(font ? [font] : []), ...(laysOut ? textFonts(figma, args.id) : [])]\n },\n execute: (figma, args) => {\n const node = figma.getNodeById(args.id)\n if (!node) return nodeNotFound(args.id)\n const { start, end } = args\n const badTag = badVariationTag(args.variations)\n if (badTag) return badTag\n const edit = rangeEdit(args)\n if ('error' in edit) return edit\n const { hyperlink, color } = edit\n // The range methods reject an empty range or one past the text, before changing anything.\n try {\n if (args.size) node.setRangeFontSize(start, end, args.size)\n if (args.family || args.style || args.variations) {\n node.setRangeFontName(start, end, rangeFont(node, args))\n }\n if (color) node.setRangeFills(start, end, [{ type: 'SOLID', color }])\n if (hyperlink) node.setRangeHyperlink(start, end, hyperlink.link)\n } catch (error) {\n return toolFailure(error)\n }\n return {\n id: args.id,\n range: { start, end },\n ...(hyperlink ? { hyperlink: hyperlink.link?.value ?? null } : {})\n }\n }\n})\n\nexport const setTextResize = defineTool({\n name: 'set_text_resize',\n\n description: 'Set text auto-resize mode.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n mode: v.pipe(\n v.picklist(['NONE', 'WIDTH_AND_HEIGHT', 'HEIGHT', 'TRUNCATE']),\n v.description('Resize mode')\n )\n }),\n fonts: (figma, { id }) => textFonts(figma, id),\n execute: (figma, { id, mode }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n node.textAutoResize = mode\n return { id, textAutoResize: mode }\n }\n})\n\nexport const setTextProperties = defineTool({\n name: 'set_text_properties',\n\n description:\n 'Set text layout properties: alignment, auto-resize, text case, decoration, truncation, and a link for the whole text.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Text node ID')),\n align_horizontal: v.optional(\n v.pipe(\n v.picklist(['LEFT', 'CENTER', 'RIGHT', 'JUSTIFIED']),\n v.description('Horizontal text alignment')\n )\n ),\n align_vertical: v.optional(\n v.pipe(v.picklist(['TOP', 'CENTER', 'BOTTOM']), v.description('Vertical text alignment'))\n ),\n auto_resize: v.optional(\n v.pipe(\n v.picklist(['NONE', 'WIDTH_AND_HEIGHT', 'HEIGHT', 'TRUNCATE']),\n v.description('Text auto-resize mode')\n )\n ),\n direction: v.optional(\n v.pipe(v.picklist(['AUTO', 'LTR', 'RTL']), v.description('Text direction'))\n ),\n text_decoration: v.optional(\n v.pipe(v.picklist(['NONE', 'UNDERLINE', 'STRIKETHROUGH']), v.description('Text decoration'))\n ),\n hyperlink: hyperlinkInputSchema\n }),\n fonts: (figma, { id }) => textFonts(figma, id),\n execute: (figma, args) => {\n const node = figma.getNodeById(args.id)\n if (!node) return nodeNotFound(args.id)\n if (node.type !== 'TEXT') return { error: `Node \"${args.id}\" is not a TEXT node` }\n // Refused before anything changes, so a bad address leaves the text as it was.\n const hyperlink = requestedHyperlink(args.hyperlink)\n if (hyperlink && 'error' in hyperlink) return hyperlink\n const updated: string[] = []\n if (args.align_horizontal !== undefined) {\n node.textAlignHorizontal = args.align_horizontal\n updated.push('textAlignHorizontal')\n }\n if (args.align_vertical !== undefined) {\n node.textAlignVertical = args.align_vertical\n updated.push('textAlignVertical')\n }\n if (args.auto_resize !== undefined) {\n node.textAutoResize = args.auto_resize\n updated.push('textAutoResize')\n }\n if (args.direction !== undefined) {\n new PairdrawAPI(figma).setTextDirection(node, args.direction)\n updated.push('textDirection')\n }\n if (args.text_decoration !== undefined) {\n node.textDecoration = args.text_decoration\n updated.push('textDecoration')\n }\n if (hyperlink) {\n try {\n node.hyperlink = hyperlink.link\n } catch (error) {\n return toolFailure(error)\n }\n updated.push('hyperlink')\n }\n return { id: args.id, updated }\n }\n})\n"],"mappings":";;;;;;;;;;AAuBA,MAAM,uBAAuB,EAAE,SAC7B,EAAE,KACA,EAAE,SAAS,EAAE,OAAO,CAAC,GACrB,EAAE,YACA,2OACF,C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BAAiB,CAAC,CAC7F;EACA,WAAW;CACb,CAAC;CACD,QAAQ,OAAO,EAAE,SAAS,UAAU,OAAO,EAAE;CAC7C,UAAU,OAAO,SAAS;EACxB,MAAM,OAAO,MAAM,YAAY,KAAK,EAAE;EACtC,IAAI,CAAC,MAAM,OAAO,aAAa,KAAK,EAAE;EACtC,IAAI,KAAK,SAAS,QAAQ,OAAO,EAAE,OAAO,SAAS,KAAK,GAAG,sBAAsB;EAEjF,MAAM,YAAY,mBAAmB,KAAK,SAAS;EACnD,IAAI,aAAa,WAAW,WAAW,OAAO;EAC9C,MAAM,UAAoB,CAAC;EAC3B,IAAI,KAAK,qBAAqB,KAAA,GAAW;GACvC,KAAK,sBAAsB,KAAK;GAChC,QAAQ,KAAK,qBAAqB;EACpC;EACA,IAAI,KAAK,mBAAmB,KAAA,GAAW;GACrC,KAAK,oBAAoB,KAAK;GAC9B,QAAQ,KAAK,mBAAmB;EAClC;EACA,IAAI,KAAK,gBAAgB,KAAA,GAAW;GAClC,KAAK,iBAAiB,KAAK;GAC3B,QAAQ,KAAK,gBAAgB;EAC/B;EACA,IAAI,KAAK,cAAc,KAAA,GAAW;GAChC,IAAI,YAAY,KAAK,CAAC,CAAC,iBAAiB,MAAM,KAAK,SAAS;GAC5D,QAAQ,KAAK,eAAe;EAC9B;EACA,IAAI,KAAK,oBAAoB,KAAA,GAAW;GACtC,KAAK,iBAAiB,KAAK;GAC3B,QAAQ,KAAK,gBAAgB;EAC/B;EACA,IAAI,WAAW;GACb,IAAI;IACF,KAAK,YAAY,UAAU;GAC7B,SAAS,OAAO;IACd,OAAO,YAAY,KAAK;GAC1B;GACA,QAAQ,KAAK,WAAW;EAC1B;EACA,OAAO;GAAE,IAAI,KAAK;GAAI;EAAQ;CAChC;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../../src/tools/modify/text.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api'\nimport type { FigmaFontName, FigmaFontNameInput } from '#core/figma-api/fonts/names'\nimport type { FigmaVariationSettings } from '#core/figma-api/fonts/variations'\nimport { PairdrawAPI } from '#core/pairdraw-api'\nimport { normalizeLinkURL } from '#core/text/hyperlink'\nimport { collectNodeFontFaces } from '#core/text/requirements/collect'\nimport {\n parseOptionalToolColor,\n toolNumber,\n nodeIdInputSchema,\n defineTool,\n nodeNotFound,\n toolFailure\n} from '#core/tools/schema'\n\n/**\n * A link a text tool sets, as the editor's link field takes it: a web or mail address, with\n * `https:` or `mailto:` added when typed without a scheme. Null or blank removes the link.\n */\nconst hyperlinkInputSchema = v.optional(\n v.pipe(\n v.nullable(v.string()),\n v.description(\n 'Link the text opens: an http(s) or mailto address (\"example.com\" becomes https://example.com, \"hi@example.com\" becomes mailto:). null or \"\" removes the link. Links are not underlined automatically; set text_decoration for that.'\n )\n )\n)\n\n/**\n * A scheme at the start of a typed link, even with a digit after its colon (`tel:123`), unless it\n * reads as a host and port (`localhost:3000`, `example.com:8080`), which gets `https://`.\n */\nconst TYPED_SCHEME = /^([a-z][a-z\\d+.-]*):/i\n\n/** A web address in the form the Figma API's link setter takes: `http(s)://host…`. */\nconst WEB_URL = /^https?:\\/\\/[^\\s/?#]+\\S*$/\n\n/** Whether a typed link names a scheme other than the http, https, and mailto links take. */\nfunction hasForeignScheme(typed: string): boolean {\n const scheme = TYPED_SCHEME.exec(typed)?.[1]?.toLowerCase()\n if (!scheme || scheme.includes('.') || scheme === 'localhost') return false\n return !['http', 'https', 'mailto'].includes(scheme)\n}\n\n/** What setting `hyperlink` asks for: no change, a removal, a URL, or an address it refuses. */\nfunction requestedHyperlink(\n hyperlink: string | null | undefined\n): { link: { type: 'URL'; value: string } | null } | { error: string } | null {\n if (hyperlink === undefined) return null\n if (hyperlink === null || hyperlink.trim() === '') return { link: null }\n const url = hasForeignScheme(hyperlink.trim()) ? null : normalizeLinkURL(hyperlink)\n if (!url) {\n return {\n error: `\"${hyperlink}\" is not a link the editor opens: use an http, https, or mailto address`\n }\n }\n // Figma keeps schemes in lower case and web addresses as `scheme://host`, so a loosely typed\n // `http:example.com` is written as the URL it parses to.\n const lowered = url.replace(TYPED_SCHEME, (scheme) => scheme.toLowerCase())\n const value =\n lowered.startsWith('mailto:') || WEB_URL.test(lowered) ? lowered : new URL(lowered).href\n return { link: { type: 'URL', value } }\n}\n\n/** The fonts a text layer uses, which an edit that lays it out again needs loaded. */\nexport function textFonts(figma: FigmaAPI, id: string): FigmaFontNameInput[] {\n const node = figma.graph.getNode(id)\n return node ? collectNodeFontFaces(node) : []\n}\n\nexport const setText = defineTool({\n name: 'set_text',\n\n description: 'Set text content of a text node.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n text: v.pipe(v.string(), v.description('Text content'))\n }),\n fonts: (figma, { id }) => textFonts(figma, id),\n execute: (figma, { id, text }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n node.characters = text\n return { id, text }\n }\n})\n\n/** Variable font axes a font tool can set, as Figma's `variationSettings`. */\n// An object with a value for every key rather than a record: a record publishes `propertyNames`,\n// which OpenAI refuses, and a JSON object's keys are strings anyway.\nconst variationsInputSchema = v.optional(\n v.pipe(\n v.objectWithRest({}, v.number()),\n v.description(\n '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.'\n )\n )\n)\n\n/** OpenType features a text tool sets, by tag; tags left out keep their state. */\nconst fontFeaturesInputSchema = v.optional(\n v.pipe(\n v.objectWithRest({}, v.boolean()),\n v.description(\n '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.'\n )\n )\n)\n\n/** Why a feature map cannot apply: a tag is not four letters, or a value is not a boolean. */\nfunction badFeatureEntry(features: Record<string, boolean> | undefined): { error: string } | null {\n for (const [tag, enabled] of Object.entries(features ?? {})) {\n if (tag.length !== 4) return { error: `\"${tag}\" is not a four-letter OpenType feature tag` }\n if (typeof enabled !== 'boolean') {\n return { error: `Feature \"${tag}\" needs a boolean value, received ${typeof enabled}` }\n }\n }\n return null\n}\n\n/**\n * The font a font tool gives text: what it names, the rest from `current`. Axes without a style\n * leave the style out, for the nearest named style to be picked.\n */\nfunction fontNameInput(\n args: { family?: string; style?: string; variations?: FigmaVariationSettings },\n current: FigmaFontName | null\n): FigmaFontNameInput {\n return {\n family: args.family ?? current?.family ?? '',\n style: args.style ?? (args.variations ? undefined : (current?.style ?? 'Regular')),\n variationSettings: args.variations\n }\n}\n\n/**\n * The font `set_font` gives the text, or null when it keeps the text's. Text set in several fonts\n * takes the given family or style for all of it, keeping the rest from its first character. Axes\n * without a style are set per range, each range taking its nearest named style, as in Figma.\n */\nfunction requestedFont(\n node: FigmaNodeProxy,\n args: { family?: string; style?: string; variations?: FigmaVariationSettings }\n): { whole: FigmaFontName } | { perRange: FigmaFontNameInput } | null {\n if (!args.family && !args.style && !args.variations) return null\n const fontName =\n typeof node.fontName === 'symbol' && node.characters.length > 0\n ? node.getRangeFontName(0, 1)\n : node.fontName\n const current = typeof fontName === 'symbol' ? null : fontName\n const family = args.family ?? current?.family ?? ''\n if (args.variations && !args.style && node.characters.length > 0) {\n return { perRange: { family, variationSettings: args.variations } }\n }\n const style = args.style ?? current?.style ?? 'Regular'\n return { whole: { family, style, variationSettings: args.variations } }\n}\n\nexport const setFont = defineTool({\n name: 'set_font',\n\n description: 'Set font properties of a text node.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n family: v.optional(v.pipe(v.string(), v.description('Font family name'))),\n size: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Font size')))),\n style: v.optional(\n v.pipe(v.string(), v.description('Font style (e.g. \"Bold\", \"Regular\", \"Bold Italic\")'))\n ),\n variations: variationsInputSchema\n }),\n // A new font replaces the text's, which then need not be loaded, so a missing font can be\n // replaced; a size or per-range axes lay out the text in its own fonts.\n fonts: (figma, args) => {\n const node = figma.getNodeById(args.id)\n const font = node && requestedFont(node, args)\n if (font && 'whole' in font) return [font.whole]\n return [...(font ? [font.perRange] : []), ...textFonts(figma, args.id)]\n },\n execute: (figma, args) => {\n const node = figma.getNodeById(args.id)\n if (!node) return nodeNotFound(args.id)\n const badTag = badVariationTag(args.variations)\n if (badTag) return badTag\n const font = requestedFont(node, args)\n try {\n if (font && 'whole' in font) node.fontName = font.whole\n else if (font) node.setRangeFontName(0, node.characters.length, font.perRange)\n // The size comes after the font, so it lays the text out in the font it ends up in.\n if (args.size !== undefined) node.fontSize = args.size\n } catch (error) {\n return toolFailure(error)\n }\n return { id: args.id, fontName: node.fontName, fontSize: node.fontSize }\n }\n})\n\n/** The font `set_font_range` gives its range: what it names, the rest from the range's start. */\nfunction rangeFont(\n node: FigmaNodeProxy,\n args: { start: number; family?: string; style?: string; variations?: FigmaVariationSettings }\n): FigmaFontNameInput {\n const inText = args.start < node.characters.length\n const current = inText ? node.getRangeFontName(args.start, args.start + 1) : node.fontName\n return fontNameInput(args, typeof current === 'symbol' ? null : current)\n}\n\ntype RangeEdit = {\n hyperlink: { link: { type: 'URL'; value: string } | null } | null\n color: Color | undefined\n}\n\n/** Why a variation setting cannot apply: an axis tag is not four letters. */\nfunction badVariationTag(variations: FigmaVariationSettings | undefined): { error: string } | null {\n const tag = Object.keys(variations ?? {}).find((key) => key.length !== 4)\n return tag === undefined ? null : { error: `\"${tag}\" is not a four-letter OpenType axis tag` }\n}\n\n/** What a range edit sets, or why it cannot run: nothing named, a bad colour, or a bad link. */\nfunction rangeEdit(args: {\n family?: string\n size?: number\n style?: string\n variations?: unknown\n font_features?: Record<string, boolean>\n color?: string\n hyperlink?: string | null\n}): RangeEdit | { error: string } {\n if (\n !args.family &&\n !args.size &&\n !args.style &&\n !args.variations &&\n !args.font_features &&\n !args.color &&\n args.hyperlink === undefined\n ) {\n return {\n error:\n 'set_font_range needs at least one of family, size, style, variations, font_features, color, or hyperlink'\n }\n }\n const hyperlink = requestedHyperlink(args.hyperlink)\n if (hyperlink && 'error' in hyperlink) return hyperlink\n const color = parseOptionalToolColor(args.color)\n if ('error' in color) return color\n return { hyperlink: hyperlink ?? null, color: color.color }\n}\n\nexport const setFontRange = defineTool({\n name: 'set_font_range',\n\n description: 'Set font properties, OpenType features, color, or a link for a text range.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n start: toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Start character index'))),\n end: toolNumber(v.pipe(v.number(), v.minValue(0), v.description('End character index'))),\n family: v.optional(v.pipe(v.string(), v.description('Font family name'))),\n size: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Font size')))),\n style: v.optional(v.pipe(v.string(), v.description('Font style'))),\n variations: variationsInputSchema,\n font_features: fontFeaturesInputSchema,\n color: v.optional(v.pipe(v.string(), v.description('Text color (hex)'))),\n hyperlink: hyperlinkInputSchema\n }),\n fonts: (figma, args) => {\n const node = figma.getNodeById(args.id)\n if (!node) return []\n const font = args.family || args.style || args.variations ? rangeFont(node, args) : null\n // A colour alone is a paint and lays nothing out, so text in a missing font can still take it.\n // Features reshape glyphs, so they need the text's fonts as a size change does.\n const laysOut = font !== null || args.size !== undefined || args.font_features !== undefined\n return [...(font ? [font] : []), ...(laysOut ? textFonts(figma, args.id) : [])]\n },\n execute: (figma, args) => {\n const node = figma.getNodeById(args.id)\n if (!node) return nodeNotFound(args.id)\n const { start, end } = args\n const badTag = badVariationTag(args.variations)\n if (badTag) return badTag\n const badFeature = badFeatureEntry(args.font_features)\n if (badFeature) return badFeature\n const edit = rangeEdit(args)\n if ('error' in edit) return edit\n const { hyperlink, color } = edit\n // The range methods reject an empty range or one past the text, before changing anything.\n try {\n if (args.size) node.setRangeFontSize(start, end, args.size)\n if (args.family || args.style || args.variations) {\n node.setRangeFontName(start, end, rangeFont(node, args))\n }\n if (color) node.setRangeFills(start, end, [{ type: 'SOLID', color }])\n if (hyperlink) node.setRangeHyperlink(start, end, hyperlink.link)\n if (args.font_features) {\n new PairdrawAPI(figma).setRangeFontFeatures(node, start, end, args.font_features)\n }\n } catch (error) {\n return toolFailure(error)\n }\n return {\n id: args.id,\n range: { start, end },\n ...(hyperlink ? { hyperlink: hyperlink.link?.value ?? null } : {})\n }\n }\n})\n\nexport const setTextResize = defineTool({\n name: 'set_text_resize',\n\n description: 'Set text auto-resize mode.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n mode: v.pipe(\n v.picklist(['NONE', 'WIDTH_AND_HEIGHT', 'HEIGHT', 'TRUNCATE']),\n v.description('Resize mode')\n )\n }),\n fonts: (figma, { id }) => textFonts(figma, id),\n execute: (figma, { id, mode }) => {\n const node = figma.getNodeById(id)\n if (!node) return { error: `Node \"${id}\" not found` }\n node.textAutoResize = mode\n return { id, textAutoResize: mode }\n }\n})\n\nexport const setTextProperties = defineTool({\n name: 'set_text_properties',\n\n description:\n 'Set text layout properties: alignment, auto-resize, text case, decoration, truncation, OpenType features, and a link for the whole text.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Text node ID')),\n align_horizontal: v.optional(\n v.pipe(\n v.picklist(['LEFT', 'CENTER', 'RIGHT', 'JUSTIFIED']),\n v.description('Horizontal text alignment')\n )\n ),\n align_vertical: v.optional(\n v.pipe(v.picklist(['TOP', 'CENTER', 'BOTTOM']), v.description('Vertical text alignment'))\n ),\n auto_resize: v.optional(\n v.pipe(\n v.picklist(['NONE', 'WIDTH_AND_HEIGHT', 'HEIGHT', 'TRUNCATE']),\n v.description('Text auto-resize mode')\n )\n ),\n direction: v.optional(\n v.pipe(v.picklist(['AUTO', 'LTR', 'RTL']), v.description('Text direction'))\n ),\n text_decoration: v.optional(\n v.pipe(v.picklist(['NONE', 'UNDERLINE', 'STRIKETHROUGH']), v.description('Text decoration'))\n ),\n hyperlink: hyperlinkInputSchema,\n font_features: fontFeaturesInputSchema\n }),\n fonts: (figma, { id }) => textFonts(figma, id),\n execute: (figma, args) => {\n const node = figma.getNodeById(args.id)\n if (!node) return nodeNotFound(args.id)\n if (node.type !== 'TEXT') return { error: `Node \"${args.id}\" is not a TEXT node` }\n // Refused before anything changes, so a bad address leaves the text as it was.\n const hyperlink = requestedHyperlink(args.hyperlink)\n if (hyperlink && 'error' in hyperlink) return hyperlink\n const badFeature = badFeatureEntry(args.font_features)\n if (badFeature) return badFeature\n const updated: string[] = []\n if (args.align_horizontal !== undefined) {\n node.textAlignHorizontal = args.align_horizontal\n updated.push('textAlignHorizontal')\n }\n if (args.align_vertical !== undefined) {\n node.textAlignVertical = args.align_vertical\n updated.push('textAlignVertical')\n }\n if (args.auto_resize !== undefined) {\n node.textAutoResize = args.auto_resize\n updated.push('textAutoResize')\n }\n if (args.direction !== undefined) {\n new PairdrawAPI(figma).setTextDirection(node, args.direction)\n updated.push('textDirection')\n }\n if (args.text_decoration !== undefined) {\n node.textDecoration = args.text_decoration\n updated.push('textDecoration')\n }\n if (args.font_features) {\n new PairdrawAPI(figma).setFontFeatures(node, args.font_features)\n updated.push('fontFeatures')\n }\n if (hyperlink) {\n try {\n node.hyperlink = hyperlink.link\n } catch (error) {\n return toolFailure(error)\n }\n updated.push('hyperlink')\n }\n return { id: args.id, updated }\n }\n})\n"],"mappings":";;;;;;;;;;AAuBA,MAAM,uBAAuB,EAAE,SAC7B,EAAE,KACA,EAAE,SAAS,EAAE,OAAO,CAAC,GACrB,EAAE,YACA,2OACF,CACF,CACF;;;;;AAMA,MAAM,eAAe;;AAGrB,MAAM,UAAU;;AAGhB,SAAS,iBAAiB,OAAwB;CAChD,MAAM,SAAS,aAAa,KAAK,KAAK,CAAC,GAAG,EAAE,EAAE,YAAY;CAC1D,IAAI,CAAC,UAAU,OAAO,SAAS,GAAG,KAAK,WAAW,aAA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iB,MAAM,KAAK,SAAS;GAC5D,QAAQ,KAAK,eAAe;EAC9B;EACA,IAAI,KAAK,oBAAoB,KAAA,GAAW;GACtC,KAAK,iBAAiB,KAAK;GAC3B,QAAQ,KAAK,gBAAgB;EAC/B;EACA,IAAI,KAAK,eAAe;GACtB,IAAI,YAAY,KAAK,CAAC,CAAC,gBAAgB,MAAM,KAAK,aAAa;GAC/D,QAAQ,KAAK,cAAc;EAC7B;EACA,IAAI,WAAW;GACb,IAAI;IACF,KAAK,YAAY,UAAU;GAC7B,SAAS,OAAO;IACd,OAAO,YAAY,KAAK;GAC1B;GACA,QAAQ,KAAK,WAAW;EAC1B;EACA,OAAO;GAAE,IAAI,KAAK;GAAI;EAAQ;CAChC;AACF,CAAC"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import { FigmaNodeProxy } from "../../figma-api/proxy.js";
|
|
2
|
+
import "../../figma-api/index.js";
|
|
1
3
|
import { ToolDef } from "../schema.js";
|
|
4
|
+
import * as v from "valibot";
|
|
2
5
|
//#region src/tools/modify/update.d.ts
|
|
6
|
+
/** Why a layer cannot take overflow scrolling, or null when it can, as Figma's frames take it. */
|
|
7
|
+
declare function scrollRefusal(node: FigmaNodeProxy): string | null;
|
|
8
|
+
/** Overflow scrolling in play, as Figma's `overflowDirection`. */
|
|
9
|
+
declare function overflowDirectionInput(): v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["NONE", "HORIZONTAL", "VERTICAL", "BOTH"], undefined>, v.DescriptionAction<"NONE" | "HORIZONTAL" | "VERTICAL" | "BOTH", string>]>;
|
|
10
|
+
/** How a layer moves while its parent frame scrolls in prototype play. */
|
|
11
|
+
declare function scrollBehaviorInput(): v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["SCROLLS", "FIXED", "STICKY_SCROLLS"], undefined>, v.DescriptionAction<"SCROLLS" | "FIXED" | "STICKY_SCROLLS", string>]>;
|
|
3
12
|
declare const updateNode: ToolDef;
|
|
4
13
|
//#endregion
|
|
5
|
-
export { updateNode };
|
|
14
|
+
export { overflowDirectionInput, scrollBehaviorInput, scrollRefusal, updateNode };
|
|
6
15
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","names":[],"sources":["../../../src/tools/modify/update.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"update.d.ts","names":[],"sources":["../../../src/tools/modify/update.ts"],"mappings":";;;;;;iBAsCgB,cAAc,MAAM;;iBAMpB,0BAAsB,EAAA,yBAAA,EAAA,gFAAA,EAAA;;iBAWtB,uBAAmB,EAAA,yBAAA,EAAA,4EAAA,EAAA;cAUtB,YAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertNodeEditable } from "../../editor/capabilities.js";
|
|
2
2
|
import { defineTool, nodeIdInputSchema, nodeNotFound, toolNumber } from "../schema.js";
|
|
3
|
+
import { OVERFLOW_DIRECTIONS, SCROLL_BEHAVIORS } from "@pairdraw/scene-graph/constants";
|
|
3
4
|
import { styleDetachmentChanges } from "@pairdraw/scene-graph/shared-styles";
|
|
4
5
|
import * as v from "valibot";
|
|
5
6
|
//#region src/tools/modify/update.ts
|
|
@@ -29,9 +30,27 @@ function resized(node, width = node.width, height = node.height) {
|
|
|
29
30
|
]) if (after[key] !== before[key]) changed.push(key);
|
|
30
31
|
return changed;
|
|
31
32
|
}
|
|
33
|
+
const SCROLLING_TYPES = /* @__PURE__ */ new Set([
|
|
34
|
+
"FRAME",
|
|
35
|
+
"COMPONENT",
|
|
36
|
+
"INSTANCE"
|
|
37
|
+
]);
|
|
38
|
+
/** Why a layer cannot take overflow scrolling, or null when it can, as Figma's frames take it. */
|
|
39
|
+
function scrollRefusal(node) {
|
|
40
|
+
if (SCROLLING_TYPES.has(node.type)) return null;
|
|
41
|
+
return `Only a frame, component or instance scrolls; ${node.type} "${node.name}" cannot.`;
|
|
42
|
+
}
|
|
43
|
+
/** Overflow scrolling in play, as Figma's `overflowDirection`. */
|
|
44
|
+
function overflowDirectionInput() {
|
|
45
|
+
return v.pipe(v.picklist(OVERFLOW_DIRECTIONS), v.description("Overflow scrolling in prototype play (FRAME, COMPONENT, INSTANCE). A nested frame scrolls only while it clips its content."));
|
|
46
|
+
}
|
|
47
|
+
/** How a layer moves while its parent frame scrolls in prototype play. */
|
|
48
|
+
function scrollBehaviorInput() {
|
|
49
|
+
return v.pipe(v.picklist(SCROLL_BEHAVIORS), v.description("Scroll behavior in prototype play: SCROLLS moves with the content, FIXED stays in the frame, STICKY_SCROLLS scrolls until it reaches the frame's top or left edge."));
|
|
50
|
+
}
|
|
32
51
|
const updateNode = defineTool({
|
|
33
52
|
name: "update_node",
|
|
34
|
-
description: "Update properties of an existing node: position, size, opacity, corner radius, visibility, text, font.",
|
|
53
|
+
description: "Update properties of an existing node: position, size, opacity, corner radius, visibility, text, font, overflow scrolling.",
|
|
35
54
|
execution: {
|
|
36
55
|
kind: "sync",
|
|
37
56
|
mutation: "properties"
|
|
@@ -58,12 +77,16 @@ const updateNode = defineTool({
|
|
|
58
77
|
]), v.description("Auto-layout flow direction for FRAME nodes"))),
|
|
59
78
|
font_size: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description("Font size")))),
|
|
60
79
|
font_weight: v.optional(toolNumber(v.pipe(v.number(), v.minValue(100), v.maxValue(900), v.description("Font weight (100-900)")))),
|
|
61
|
-
name: v.optional(v.pipe(v.string(), v.description("Layer name")))
|
|
80
|
+
name: v.optional(v.pipe(v.string(), v.description("Layer name"))),
|
|
81
|
+
overflow_direction: v.optional(overflowDirectionInput()),
|
|
82
|
+
scroll_behavior: v.optional(scrollBehaviorInput())
|
|
62
83
|
}),
|
|
63
84
|
execute: (figma, args) => {
|
|
64
85
|
const node = figma.getNodeById(args.id);
|
|
65
86
|
if (!node) return nodeNotFound(args.id);
|
|
66
87
|
assertNodeEditable(figma.graph, args.id);
|
|
88
|
+
const refusal = args.overflow_direction === void 0 ? null : scrollRefusal(node);
|
|
89
|
+
if (refusal) return { error: refusal };
|
|
67
90
|
const editTypography = (changes) => {
|
|
68
91
|
const scene = figma.graph.getNode(args.id);
|
|
69
92
|
if (scene) figma.graph.updateNode(args.id, styleDetachmentChanges(scene, changes));
|
|
@@ -114,6 +137,14 @@ const updateNode = defineTool({
|
|
|
114
137
|
editTypography({ fontWeight: args.font_weight });
|
|
115
138
|
updated.push("fontWeight");
|
|
116
139
|
}
|
|
140
|
+
if (args.overflow_direction !== void 0) {
|
|
141
|
+
node.overflowDirection = args.overflow_direction;
|
|
142
|
+
updated.push("overflowDirection");
|
|
143
|
+
}
|
|
144
|
+
if (args.scroll_behavior !== void 0) {
|
|
145
|
+
node.scrollBehavior = args.scroll_behavior;
|
|
146
|
+
updated.push("scrollBehavior");
|
|
147
|
+
}
|
|
117
148
|
return {
|
|
118
149
|
id: args.id,
|
|
119
150
|
updated
|
|
@@ -121,6 +152,6 @@ const updateNode = defineTool({
|
|
|
121
152
|
}
|
|
122
153
|
});
|
|
123
154
|
//#endregion
|
|
124
|
-
export { updateNode };
|
|
155
|
+
export { overflowDirectionInput, scrollBehaviorInput, scrollRefusal, updateNode };
|
|
125
156
|
|
|
126
157
|
//# sourceMappingURL=update.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","names":[],"sources":["../../../src/tools/modify/update.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { styleDetachmentChanges } from '@pairdraw/scene-graph/shared-styles'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport type { FigmaNodeProxy } from '#core/figma-api'\nimport { toolNumber, nodeIdInputSchema, defineTool, nodeNotFound } from '#core/tools/schema'\n\n/** The size of a layer and how auto layout or its text sizes it, which a resize may change. */\nfunction sizing(node: FigmaNodeProxy) {\n return {\n width: node.width,\n height: node.height,\n layoutSizingHorizontal: node.layoutSizingHorizontal,\n layoutSizingVertical: node.layoutSizingVertical,\n textAutoResize: node.textAutoResize\n }\n}\n\n/**\n * Resizes a layer and names what the resize changed: a layer inside an instance keeps its size,\n * as in Figma, while an auto layout frame or a text given its own size stops sizing itself.\n */\nfunction resized(node: FigmaNodeProxy, width = node.width, height = node.height): string[] {\n const before = sizing(node)\n node.resize(width, height)\n const after = sizing(node)\n const changed = after.width !== before.width || after.height !== before.height ? ['size'] : []\n for (const key of ['layoutSizingHorizontal', 'layoutSizingVertical', 'textAutoResize'] as const)\n if (after[key] !== before[key]) changed.push(key)\n return changed\n}\n\nexport const updateNode = defineTool({\n name: 'update_node',\n\n description:\n 'Update properties of an existing node: position, size, opacity, corner radius, visibility, text, font.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\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 width: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Width')))),\n height: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Height')))),\n opacity: v.optional(\n toolNumber(v.pipe(v.number(), v.minValue(0), v.maxValue(1), v.description('Opacity (0-1)')))\n ),\n corner_radius: v.optional(\n toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Corner radius')))\n ),\n visible: v.optional(v.pipe(v.boolean(), v.description('Visibility'))),\n text: v.optional(v.pipe(v.string(), v.description('Text content (TEXT nodes)'))),\n text_direction: v.optional(\n v.pipe(v.picklist(['AUTO', 'LTR', 'RTL']), v.description('Text direction for TEXT nodes'))\n ),\n flow_direction: v.optional(\n v.pipe(\n v.picklist(['AUTO', 'LTR', 'RTL']),\n v.description('Auto-layout flow direction for FRAME nodes')\n )\n ),\n font_size: v.optional(\n toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Font size')))\n ),\n font_weight: v.optional(\n toolNumber(\n v.pipe(v.number(), v.minValue(100), v.maxValue(900), v.description('Font weight (100-900)'))\n )\n ),\n name: v.optional(v.pipe(v.string(), v.description('Layer name')))\n }),\n execute: (figma, args) => {\n const node = figma.getNodeById(args.id)\n if (!node) return nodeNotFound(args.id)\n assertNodeEditable(figma.graph, args.id)\n // Written to the layer directly, since the plugin setters need a loaded font; an edit to a\n // text style's field leaves the style, as the editor's updates do.\n const editTypography = (changes: Partial<SceneNode>) => {\n const scene = figma.graph.getNode(args.id)\n if (scene) figma.graph.updateNode(args.id, styleDetachmentChanges(scene, changes))\n }\n const updated: string[] = []\n if (args.x !== undefined) {\n node.x = args.x\n updated.push('x')\n }\n if (args.y !== undefined) {\n node.y = args.y\n updated.push('y')\n }\n if (args.width !== undefined || args.height !== undefined)\n updated.push(...resized(node, args.width, args.height))\n if (args.opacity !== undefined) {\n node.opacity = args.opacity\n updated.push('opacity')\n }\n if (args.corner_radius !== undefined) {\n node.cornerRadius = args.corner_radius\n updated.push('cornerRadius')\n }\n if (args.visible !== undefined) {\n node.visible = args.visible\n updated.push('visible')\n }\n if (args.name !== undefined) {\n node.name = args.name\n updated.push('name')\n }\n if (args.text !== undefined) {\n figma.graph.updateNode(node.id, { text: args.text })\n updated.push('text')\n }\n if (args.text_direction !== undefined) {\n figma.graph.updateNode(node.id, {\n textDirection: args.text_direction\n })\n updated.push('textDirection')\n }\n if (args.flow_direction !== undefined) {\n figma.graph.updateNode(node.id, {\n layoutDirection: args.flow_direction\n })\n updated.push('layoutDirection')\n }\n if (args.font_size !== undefined) {\n editTypography({ fontSize: args.font_size })\n updated.push('fontSize')\n }\n if (args.font_weight !== undefined) {\n editTypography({ fontWeight: args.font_weight })\n updated.push('fontWeight')\n }\n return { id: args.id, updated }\n }\n})\n"],"mappings":";;;;;;AAUA,SAAS,OAAO,MAAsB;CACpC,OAAO;EACL,OAAO,KAAK;EACZ,QAAQ,KAAK;EACb,wBAAwB,KAAK;EAC7B,sBAAsB,KAAK;EAC3B,gBAAgB,KAAK;CACvB;AACF;;;;;AAMA,SAAS,QAAQ,MAAsB,QAAQ,KAAK,OAAO,SAAS,KAAK,QAAkB;CACz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A,GAC9C,QAAQ,KAAK,GAAG,QAAQ,MAAM,KAAK,OAAO,KAAK,MAAM,CAAC;EACxD,IAAI,KAAK,YAAY,KAAA,GAAW;GAC9B,KAAK,UAAU,KAAK;GACpB,QAAQ,KAAK,SAAS;EACxB;EACA,IAAI,KAAK,kBAAkB,KAAA,GAAW;GACpC,KAAK,eAAe,KAAK;GACzB,QAAQ,KAAK,cAAc;EAC7B;EACA,IAAI,KAAK,YAAY,KAAA,GAAW;GAC9B,KAAK,UAAU,KAAK;GACpB,QAAQ,KAAK,SAAS;EACxB;EACA,IAAI,KAAK,SAAS,KAAA,GAAW;GAC3B,KAAK,OAAO,KAAK;GACjB,QAAQ,KAAK,MAAM;EACrB;EACA,IAAI,KAAK,SAAS,KAAA,GAAW;GAC3B,MAAM,MAAM,WAAW,KAAK,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC;GACnD,QAAQ,KAAK,MAAM;EACrB;EACA,IAAI,KAAK,mBAAmB,KAAA,GAAW;GACrC,MAAM,MAAM,WAAW,KAAK,IAAI,EAC9B,eAAe,KAAK,eACtB,CAAC;GACD,QAAQ,KAAK,eAAe;EAC9B;EACA,IAAI,KAAK,mBAAmB,KAAA,GAAW;GACrC,MAAM,MAAM,WAAW,KAAK,IAAI,EAC9B,iBAAiB,KAAK,eACxB,CAAC;GACD,QAAQ,KAAK,iBAAiB;EAChC;EACA,IAAI,KAAK,cAAc,KAAA,GAAW;GAChC,eAAe,EAAE,UAAU,KAAK,UAAU,CAAC;GAC3C,QAAQ,KAAK,UAAU;EACzB;EACA,IAAI,KAAK,gBAAgB,KAAA,GAAW;GAClC,eAAe,EAAE,YAAY,KAAK,YAAY,CAAC;GAC/C,QAAQ,KAAK,YAAY;EAC3B;EACA,OAAO;GAAE,IAAI,KAAK;GAAI;EAAQ;CAChC;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"update.js","names":[],"sources":["../../../src/tools/modify/update.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { OVERFLOW_DIRECTIONS, SCROLL_BEHAVIORS } from '@pairdraw/scene-graph/constants'\nimport { styleDetachmentChanges } from '@pairdraw/scene-graph/shared-styles'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport type { FigmaNodeProxy } from '#core/figma-api'\nimport { toolNumber, nodeIdInputSchema, defineTool, nodeNotFound } from '#core/tools/schema'\n\n/** The size of a layer and how auto layout or its text sizes it, which a resize may change. */\nfunction sizing(node: FigmaNodeProxy) {\n return {\n width: node.width,\n height: node.height,\n layoutSizingHorizontal: node.layoutSizingHorizontal,\n layoutSizingVertical: node.layoutSizingVertical,\n textAutoResize: node.textAutoResize\n }\n}\n\n/**\n * Resizes a layer and names what the resize changed: a layer inside an instance keeps its size,\n * as in Figma, while an auto layout frame or a text given its own size stops sizing itself.\n */\nfunction resized(node: FigmaNodeProxy, width = node.width, height = node.height): string[] {\n const before = sizing(node)\n node.resize(width, height)\n const after = sizing(node)\n const changed = after.width !== before.width || after.height !== before.height ? ['size'] : []\n for (const key of ['layoutSizingHorizontal', 'layoutSizingVertical', 'textAutoResize'] as const)\n if (after[key] !== before[key]) changed.push(key)\n return changed\n}\n\nconst SCROLLING_TYPES: ReadonlySet<string> = new Set(['FRAME', 'COMPONENT', 'INSTANCE'])\n\n/** Why a layer cannot take overflow scrolling, or null when it can, as Figma's frames take it. */\nexport function scrollRefusal(node: FigmaNodeProxy): string | null {\n if (SCROLLING_TYPES.has(node.type)) return null\n return `Only a frame, component or instance scrolls; ${node.type} \"${node.name}\" cannot.`\n}\n\n/** Overflow scrolling in play, as Figma's `overflowDirection`. */\nexport function overflowDirectionInput() {\n return v.pipe(\n v.picklist(OVERFLOW_DIRECTIONS),\n v.description(\n 'Overflow scrolling in prototype play (FRAME, COMPONENT, INSTANCE). A nested frame scrolls ' +\n 'only while it clips its content.'\n )\n )\n}\n\n/** How a layer moves while its parent frame scrolls in prototype play. */\nexport function scrollBehaviorInput() {\n return v.pipe(\n v.picklist(SCROLL_BEHAVIORS),\n v.description(\n 'Scroll behavior in prototype play: SCROLLS moves with the content, FIXED stays in the ' +\n \"frame, STICKY_SCROLLS scrolls until it reaches the frame's top or left edge.\"\n )\n )\n}\n\nexport const updateNode = defineTool({\n name: 'update_node',\n\n description:\n 'Update properties of an existing node: position, size, opacity, corner radius, visibility, text, font, overflow scrolling.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\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 width: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Width')))),\n height: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Height')))),\n opacity: v.optional(\n toolNumber(v.pipe(v.number(), v.minValue(0), v.maxValue(1), v.description('Opacity (0-1)')))\n ),\n corner_radius: v.optional(\n toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Corner radius')))\n ),\n visible: v.optional(v.pipe(v.boolean(), v.description('Visibility'))),\n text: v.optional(v.pipe(v.string(), v.description('Text content (TEXT nodes)'))),\n text_direction: v.optional(\n v.pipe(v.picklist(['AUTO', 'LTR', 'RTL']), v.description('Text direction for TEXT nodes'))\n ),\n flow_direction: v.optional(\n v.pipe(\n v.picklist(['AUTO', 'LTR', 'RTL']),\n v.description('Auto-layout flow direction for FRAME nodes')\n )\n ),\n font_size: v.optional(\n toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Font size')))\n ),\n font_weight: v.optional(\n toolNumber(\n v.pipe(v.number(), v.minValue(100), v.maxValue(900), v.description('Font weight (100-900)'))\n )\n ),\n name: v.optional(v.pipe(v.string(), v.description('Layer name'))),\n overflow_direction: v.optional(overflowDirectionInput()),\n scroll_behavior: v.optional(scrollBehaviorInput())\n }),\n execute: (figma, args) => {\n const node = figma.getNodeById(args.id)\n if (!node) return nodeNotFound(args.id)\n assertNodeEditable(figma.graph, args.id)\n // Refused before anything is written, so the call changes all or nothing.\n const refusal = args.overflow_direction === undefined ? null : scrollRefusal(node)\n if (refusal) return { error: refusal }\n // Written to the layer directly, since the plugin setters need a loaded font; an edit to a\n // text style's field leaves the style, as the editor's updates do.\n const editTypography = (changes: Partial<SceneNode>) => {\n const scene = figma.graph.getNode(args.id)\n if (scene) figma.graph.updateNode(args.id, styleDetachmentChanges(scene, changes))\n }\n const updated: string[] = []\n if (args.x !== undefined) {\n node.x = args.x\n updated.push('x')\n }\n if (args.y !== undefined) {\n node.y = args.y\n updated.push('y')\n }\n if (args.width !== undefined || args.height !== undefined)\n updated.push(...resized(node, args.width, args.height))\n if (args.opacity !== undefined) {\n node.opacity = args.opacity\n updated.push('opacity')\n }\n if (args.corner_radius !== undefined) {\n node.cornerRadius = args.corner_radius\n updated.push('cornerRadius')\n }\n if (args.visible !== undefined) {\n node.visible = args.visible\n updated.push('visible')\n }\n if (args.name !== undefined) {\n node.name = args.name\n updated.push('name')\n }\n if (args.text !== undefined) {\n figma.graph.updateNode(node.id, { text: args.text })\n updated.push('text')\n }\n if (args.text_direction !== undefined) {\n figma.graph.updateNode(node.id, {\n textDirection: args.text_direction\n })\n updated.push('textDirection')\n }\n if (args.flow_direction !== undefined) {\n figma.graph.updateNode(node.id, {\n layoutDirection: args.flow_direction\n })\n updated.push('layoutDirection')\n }\n if (args.font_size !== undefined) {\n editTypography({ fontSize: args.font_size })\n updated.push('fontSize')\n }\n if (args.font_weight !== undefined) {\n editTypography({ fontWeight: args.font_weight })\n updated.push('fontWeight')\n }\n if (args.overflow_direction !== undefined) {\n node.overflowDirection = args.overflow_direction\n updated.push('overflowDirection')\n }\n if (args.scroll_behavior !== undefined) {\n node.scrollBehavior = args.scroll_behavior\n updated.push('scrollBehavior')\n }\n return { id: args.id, updated }\n }\n})\n"],"mappings":";;;;;;;AAWA,SAAS,OAAO,MAAsB;CACpC,OAAO;EACL,OAAO,KAAK;EACZ,QAAQ,KAAK;EACb,wBAAwB,KAAK;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EAAE,MAAM,KAAK,KAAK,CAAC;GACnD,QAAQ,KAAK,MAAM;EACrB;EACA,IAAI,KAAK,mBAAmB,KAAA,GAAW;GACrC,MAAM,MAAM,WAAW,KAAK,IAAI,EAC9B,eAAe,KAAK,eACtB,CAAC;GACD,QAAQ,KAAK,eAAe;EAC9B;EACA,IAAI,KAAK,mBAAmB,KAAA,GAAW;GACrC,MAAM,MAAM,WAAW,KAAK,IAAI,EAC9B,iBAAiB,KAAK,eACxB,CAAC;GACD,QAAQ,KAAK,iBAAiB;EAChC;EACA,IAAI,KAAK,cAAc,KAAA,GAAW;GAChC,eAAe,EAAE,UAAU,KAAK,UAAU,CAAC;GAC3C,QAAQ,KAAK,UAAU;EACzB;EACA,IAAI,KAAK,gBAAgB,KAAA,GAAW;GAClC,eAAe,EAAE,YAAY,KAAK,YAAY,CAAC;GAC/C,QAAQ,KAAK,YAAY;EAC3B;EACA,IAAI,KAAK,uBAAuB,KAAA,GAAW;GACzC,KAAK,oBAAoB,KAAK;GAC9B,QAAQ,KAAK,mBAAmB;EAClC;EACA,IAAI,KAAK,oBAAoB,KAAA,GAAW;GACtC,KAAK,iBAAiB,KAAK;GAC3B,QAAQ,KAAK,gBAAgB;EAC/B;EACA,OAAO;GAAE,IAAI,KAAK;GAAI;EAAQ;CAChC;AACF,CAAC"}
|
package/dist/tools/modify.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { setEffects } from "./modify/effects.js";
|
|
2
|
+
import { replaceFonts } from "./modify/fonts.js";
|
|
2
3
|
import { rescale, setMinMax, setOpacity, setRadius, setRotation } from "./modify/geometry.js";
|
|
3
4
|
import { setConstraints, setLayout, setLayoutChild } from "./modify/layout.js";
|
|
4
5
|
import { replaceMatchingProperties } from "./modify/matching.js";
|
|
@@ -7,4 +8,4 @@ import { setReactions } from "./modify/reactions.js";
|
|
|
7
8
|
import { setBlend, setLocked, setStrokeAlign, setVisible } from "./modify/state.js";
|
|
8
9
|
import { setFont, setFontRange, setText, setTextProperties, setTextResize } from "./modify/text.js";
|
|
9
10
|
import { updateNode } from "./modify/update.js";
|
|
10
|
-
export { replaceMatchingProperties, rescale, setBlend, setConstraints, setEffects, setFill, setFont, setFontRange, setImageFill, setLayout, setLayoutChild, setLocked, setMinMax, setOpacity, setRadius, setReactions, setRotation, setStroke, setStrokeAlign, setText, setTextProperties, setTextResize, setVisible, updateNode };
|
|
11
|
+
export { replaceFonts, replaceMatchingProperties, rescale, setBlend, setConstraints, setEffects, setFill, setFont, setFontRange, setImageFill, setLayout, setLayoutChild, setLocked, setMinMax, setOpacity, setRadius, setReactions, setRotation, setStroke, setStrokeAlign, setText, setTextProperties, setTextResize, setVisible, updateNode };
|
package/dist/tools/modify.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { setEffects } from "./modify/effects.js";
|
|
2
|
+
import { replaceFonts } from "./modify/fonts.js";
|
|
2
3
|
import { rescale, setMinMax, setOpacity, setRadius, setRotation } from "./modify/geometry.js";
|
|
3
4
|
import { setConstraints, setLayout, setLayoutChild } from "./modify/layout.js";
|
|
4
5
|
import { setFont, setFontRange, setText, setTextProperties, setTextResize } from "./modify/text.js";
|
|
@@ -7,4 +8,4 @@ import { setFill, setImageFill, setStroke } from "./modify/paint.js";
|
|
|
7
8
|
import { setReactions } from "./modify/reactions.js";
|
|
8
9
|
import { setBlend, setLocked, setStrokeAlign, setVisible } from "./modify/state.js";
|
|
9
10
|
import { updateNode } from "./modify/update.js";
|
|
10
|
-
export { replaceMatchingProperties, rescale, setBlend, setConstraints, setEffects, setFill, setFont, setFontRange, setImageFill, setLayout, setLayoutChild, setLocked, setMinMax, setOpacity, setRadius, setReactions, setRotation, setStroke, setStrokeAlign, setText, setTextProperties, setTextResize, setVisible, updateNode };
|
|
11
|
+
export { replaceFonts, replaceMatchingProperties, rescale, setBlend, setConstraints, setEffects, setFill, setFont, setFontRange, setImageFill, setLayout, setLayoutChild, setLocked, setMinMax, setOpacity, setRadius, setReactions, setRotation, setStroke, setStrokeAlign, setText, setTextProperties, setTextResize, setVisible, updateNode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.d.ts","names":[],"sources":["../../../src/tools/read/fonts.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","names":[],"sources":["../../../src/tools/read/fonts.ts"],"mappings":";;cAOa,eAAA;cAYA,WAAA;cAuDA,oBAAA"}
|
package/dist/tools/read/fonts.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { listDocumentFonts } from "../../text/replace-fonts.js";
|
|
1
2
|
import { defineTool } from "../schema.js";
|
|
2
3
|
import { PairdrawAPI } from "../../pairdraw-api/index.js";
|
|
3
4
|
import { uniq } from "es-toolkit/array";
|
|
@@ -16,14 +17,28 @@ const getFontStatus = defineTool({
|
|
|
16
17
|
});
|
|
17
18
|
const listFonts = defineTool({
|
|
18
19
|
name: "list_fonts",
|
|
19
|
-
description: "List fonts used in the current page.",
|
|
20
|
+
description: "List fonts used in the current page as families with their weights. Pass scope \"document\" for every face used anywhere in the document, with whether the host has it and how many text layers use it, missing faces first; use replace_fonts to swap one for an available face.",
|
|
20
21
|
execution: {
|
|
21
22
|
kind: "sync",
|
|
22
23
|
mutation: "none"
|
|
23
24
|
},
|
|
24
25
|
exposure: { webmcp: false },
|
|
25
|
-
input: v.strictObject({
|
|
26
|
+
input: v.strictObject({
|
|
27
|
+
family: v.optional(v.pipe(v.string(), v.description("Filter by family name (substring)"))),
|
|
28
|
+
scope: v.optional(v.pipe(v.picklist(["page", "document"]), v.description("page (default): families and weights of the current page. document: every face across the document with missing and layerCount")))
|
|
29
|
+
}),
|
|
26
30
|
execute: (figma, args) => {
|
|
31
|
+
if (args.scope === "document") {
|
|
32
|
+
let fonts = listDocumentFonts(figma.graph);
|
|
33
|
+
if (args.family) {
|
|
34
|
+
const query = args.family.toLocaleLowerCase();
|
|
35
|
+
fonts = fonts.filter((font) => font.family.toLocaleLowerCase().includes(query));
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
count: fonts.length,
|
|
39
|
+
fonts
|
|
40
|
+
};
|
|
41
|
+
}
|
|
27
42
|
const fonts = /* @__PURE__ */ new Map();
|
|
28
43
|
figma.currentPage.findAll((node) => {
|
|
29
44
|
if (node.type === "TEXT") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.js","names":[],"sources":["../../../src/tools/read/fonts.ts"],"sourcesContent":["import { uniq } from 'es-toolkit/array'\nimport * as v from 'valibot'\n\nimport { PairdrawAPI } from '#core/pairdraw-api'\nimport { defineTool } from '#core/tools/schema'\n\nexport const getFontStatus = defineTool({\n name: 'get_font_status',\n description:\n 'Report whether fonts used on the current page are faithfully available. Returns requested ' +\n 'faces, their loaded source, active substitutions, why an installed face could not be ' +\n 'loaded, and affected nodes.',\n execution: { kind: 'sync', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({}),\n execute: (figma) => new PairdrawAPI(figma).getFontStatus()\n})\n\nexport const listFonts = defineTool({\n name: 'list_fonts',\n description
|
|
1
|
+
{"version":3,"file":"fonts.js","names":[],"sources":["../../../src/tools/read/fonts.ts"],"sourcesContent":["import { uniq } from 'es-toolkit/array'\nimport * as v from 'valibot'\n\nimport { PairdrawAPI } from '#core/pairdraw-api'\nimport { listDocumentFonts } from '#core/text/replace-fonts'\nimport { defineTool } from '#core/tools/schema'\n\nexport const getFontStatus = defineTool({\n name: 'get_font_status',\n description:\n 'Report whether fonts used on the current page are faithfully available. Returns requested ' +\n 'faces, their loaded source, active substitutions, why an installed face could not be ' +\n 'loaded, and affected nodes.',\n execution: { kind: 'sync', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({}),\n execute: (figma) => new PairdrawAPI(figma).getFontStatus()\n})\n\nexport const listFonts = defineTool({\n name: 'list_fonts',\n description:\n 'List fonts used in the current page as families with their weights. Pass scope ' +\n '\"document\" for every face used anywhere in the document, with whether the host has it ' +\n 'and how many text layers use it, missing faces first; use replace_fonts to swap one for ' +\n 'an available face.',\n execution: { kind: 'sync', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({\n family: v.optional(v.pipe(v.string(), v.description('Filter by family name (substring)'))),\n scope: v.optional(\n v.pipe(\n v.picklist(['page', 'document']),\n v.description(\n 'page (default): families and weights of the current page. document: every face ' +\n 'across the document with missing and layerCount'\n )\n )\n )\n }),\n execute: (figma, args) => {\n if (args.scope === 'document') {\n let fonts = listDocumentFonts(figma.graph)\n if (args.family) {\n const query = args.family.toLocaleLowerCase()\n fonts = fonts.filter((font) => font.family.toLocaleLowerCase().includes(query))\n }\n return { count: fonts.length, fonts }\n }\n const fonts = new Map<string, Set<number>>()\n const page = figma.currentPage\n page.findAll((node) => {\n if (node.type === 'TEXT') {\n const raw = figma.graph.getNode(node.id)\n if (raw) {\n const key = raw.fontFamily\n if (!fonts.has(key)) fonts.set(key, new Set())\n fonts.get(key)?.add(raw.fontWeight)\n }\n }\n return false\n })\n let result = [...fonts.entries()].map(([family, weights]) => ({\n family,\n weights: [...weights].sort((a, b) => a - b)\n }))\n if (args.family) {\n const q = args.family.toLowerCase()\n result = result.filter((font) => font.family.toLowerCase().includes(q))\n }\n return { count: result.length, fonts: result }\n }\n})\n\nexport const listAvailableFonts = defineTool({\n name: 'list_available_fonts',\n description:\n 'List font families the host can render: installed, bundled, and online families. ' +\n 'Use this to discover what fonts are available to set on a text node — distinct from list_fonts ' +\n 'which only reports families currently used in the page.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({\n family: v.optional(\n v.pipe(v.string(), v.description('Filter by family name (substring, case-insensitive)'))\n )\n }),\n execute: async (figma, args) => {\n const fonts = await figma.listAvailableFontsAsync()\n let families = uniq(fonts.map((font) => font.fontName.family))\n if (args.family) {\n const q = args.family.toLowerCase()\n families = families.filter((family) => family.toLowerCase().includes(q))\n }\n families.sort((a, b) => a.localeCompare(b))\n return { count: families.length, fonts: families }\n }\n})\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EACT,CAAC;EACD,IAAI,SAAS,CAAC,GAAG,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,cAAc;GAC5D;GACA,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC;EAC5C,EAAE;EACF,IAAI,KAAK,QAAQ;GACf,MAAM,IAAI,KAAK,OAAO,YAAY;GAClC,SAAS,OAAO,QAAQ,SAAS,KAAK,OAAO,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC;EACxE;EACA,OAAO;GAAE,OAAO,OAAO;GAAQ,OAAO;EAAO;CAC/C;AACF,CAAC;AAED,MAAa,qBAAqB,WAAW;CAC3C,MAAM;CACN,aACE;CAGF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAO;CAC7C,UAAU,EAAE,QAAQ,MAAM;CAC1B,OAAO,EAAE,aAAa,EACpB,QAAQ,EAAE,SACR,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,qDAAqD,CAAC,CACzF,EACF,CAAC;CACD,SAAS,OAAO,OAAO,SAAS;EAC9B,MAAM,QAAQ,MAAM,MAAM,wBAAwB;EAClD,IAAI,WAAW,KAAK,MAAM,KAAK,SAAS,KAAK,SAAS,MAAM,CAAC;EAC7D,IAAI,KAAK,QAAQ;GACf,MAAM,IAAI,KAAK,OAAO,YAAY;GAClC,WAAW,SAAS,QAAQ,WAAW,OAAO,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC;EACzE;EACA,SAAS,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;EAC1C,OAAO;GAAE,OAAO,SAAS;GAAQ,OAAO;EAAS;CACnD;AACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
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 { getComponentCatalog } from "../component-catalog.js";
|
|
4
4
|
import { groupBy, isPlainObject } from "es-toolkit";
|
|
5
5
|
import * as v from "valibot";
|
|
@@ -42,6 +42,7 @@ const insertLibraryComponent = defineTool({
|
|
|
42
42
|
kind: "async",
|
|
43
43
|
mutation: "document"
|
|
44
44
|
},
|
|
45
|
+
content: "imported",
|
|
45
46
|
input: v.strictObject({
|
|
46
47
|
library_id: v.pipe(v.string(), v.description("Library ID")),
|
|
47
48
|
revision_id: v.optional(v.pipe(v.string(), v.description("Pinned revision ID"))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libraries.js","names":[],"sources":["../../../src/tools/read/libraries.ts"],"sourcesContent":["import { groupBy, isPlainObject } from 'es-toolkit'\nimport * as v from 'valibot'\n\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { getComponentCatalog } from '#core/tools/component-catalog'\nimport { toolNumber, defineTool } from '#core/tools/schema'\n\nconst variantValuesSchema = v.pipe(\n v.string(),\n v.parseJson(),\n // A record also takes an array, as its indices.\n v.check(isPlainObject, 'Expected a JSON object'),\n v.record(v.string(), v.string())\n)\n\nexport const listLibraries = defineTool({\n name: 'list_libraries',\n description:\n 'List available published component libraries and each component asset key, name, and type. Pass a key to insert_library_component. A library does not have to be enabled to be listed.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({}),\n execute: async (figma) => {\n const catalog = getComponentCatalog(figma.graph)\n if (!catalog) return { count: 0, libraries: [] }\n const [libraries, components] = await Promise.all([\n catalog.listLibraries(),\n // Enabled-only would hide the keys of a library the document has not turned on.\n catalog.listComponents({ enabledOnly: false })\n ])\n const byLibrary = groupBy(components, (component) => component.libraryId)\n return {\n count: libraries.length,\n libraries: libraries.map((library) => ({\n ...library,\n assets: (byLibrary[library.libraryId] ?? []).map((component) => ({\n key: component.asset.key,\n name: component.asset.name,\n type: component.asset.type\n }))\n }))\n }\n }\n})\n\nexport const insertLibraryComponent = defineTool({\n name: 'insert_library_component',\n description:\n 'Insert a reusable component from an enabled library by stable library and asset identity.',\n\n execution: { kind: 'async', mutation: 'document' },\n input: v.strictObject({\n library_id: v.pipe(v.string(), v.description('Library ID')),\n revision_id: v.optional(v.pipe(v.string(), v.description('Pinned revision ID'))),\n asset_key: v.pipe(v.string(), v.description('Stable asset key')),\n parent_id: v.optional(v.pipe(v.string(), v.description('Optional 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 variant_values: v.optional(\n v.pipe(v.string(), v.description('Optional JSON object of variant property values'))\n )\n }),\n execute: async (figma, args) => {\n if (args.parent_id)\n prepareSlotInsertion(figma.graph, args.parent_id, 'insert_library_component')\n const catalog = getComponentCatalog(figma.graph)\n if (!catalog) throw new Error('No component library catalog is configured')\n let variantValues: Record<string, string> | undefined\n if (args.variant_values) {\n const parsed = v.safeParse(variantValuesSchema, args.variant_values)\n if (!parsed.success) {\n throw new TypeError(\n `variant_values must be a JSON object of strings: ${v.summarize(parsed.issues)}`\n )\n }\n variantValues = parsed.output\n }\n return catalog.insertComponent({\n libraryId: args.library_id,\n revisionId: args.revision_id,\n assetKey: args.asset_key,\n parentId: args.parent_id,\n x: args.x,\n y: args.y,\n variantValues\n })\n }\n})\n"],"mappings":";;;;;;AAOA,MAAM,sBAAsB,EAAE,KAC5B,EAAE,OAAO,GACT,EAAE,UAAU,GAEZ,EAAE,MAAM,eAAe,wBAAwB,GAC/C,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CACjC;AAEA,MAAa,gBAAgB,WAAW;CACtC,MAAM;CACN,aACE;CACF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAO;CAC7C,UAAU,EAAE,QAAQ,MAAM;CAC1B,OAAO,EAAE,aAAa,CAAC,CAAC;CACxB,SAAS,OAAO,UAAU;EACxB,MAAM,UAAU,oBAAoB,MAAM,KAAK;EAC/C,IAAI,CAAC,SAAS,OAAO;GAAE,OAAO;G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M,OAAO,KAAK,WAAW,0BAA0B;EAC9E,MAAM,UAAU,oBAAoB,MAAM,KAAK;EAC/C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,4CAA4C;EAC1E,IAAI;EACJ,IAAI,KAAK,gBAAgB;GACvB,MAAM,SAAS,EAAE,UAAU,qBAAqB,KAAK,cAAc;GACnE,IAAI,CAAC,OAAO,SACV,MAAM,IAAI,UACR,oDAAoD,EAAE,UAAU,OAAO,MAAM,GAC/E;GAEF,gBAAgB,OAAO;EACzB;EACA,OAAO,QAAQ,gBAAgB;GAC7B,WAAW,KAAK;GAChB,YAAY,KAAK;GACjB,UAAU,KAAK;GACf,UAAU,KAAK;GACf,GAAG,KAAK;GACR,GAAG,KAAK;GACR;EACF,CAAC;CACH;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"libraries.js","names":[],"sources":["../../../src/tools/read/libraries.ts"],"sourcesContent":["import { groupBy, isPlainObject } from 'es-toolkit'\nimport * as v from 'valibot'\n\nimport { prepareSlotInsertion } from '#core/figma-api/slots'\nimport { getComponentCatalog } from '#core/tools/component-catalog'\nimport { toolNumber, defineTool } from '#core/tools/schema'\n\nconst variantValuesSchema = v.pipe(\n v.string(),\n v.parseJson(),\n // A record also takes an array, as its indices.\n v.check(isPlainObject, 'Expected a JSON object'),\n v.record(v.string(), v.string())\n)\n\nexport const listLibraries = defineTool({\n name: 'list_libraries',\n description:\n 'List available published component libraries and each component asset key, name, and type. Pass a key to insert_library_component. A library does not have to be enabled to be listed.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({}),\n execute: async (figma) => {\n const catalog = getComponentCatalog(figma.graph)\n if (!catalog) return { count: 0, libraries: [] }\n const [libraries, components] = await Promise.all([\n catalog.listLibraries(),\n // Enabled-only would hide the keys of a library the document has not turned on.\n catalog.listComponents({ enabledOnly: false })\n ])\n const byLibrary = groupBy(components, (component) => component.libraryId)\n return {\n count: libraries.length,\n libraries: libraries.map((library) => ({\n ...library,\n assets: (byLibrary[library.libraryId] ?? []).map((component) => ({\n key: component.asset.key,\n name: component.asset.name,\n type: component.asset.type\n }))\n }))\n }\n }\n})\n\nexport const insertLibraryComponent = defineTool({\n name: 'insert_library_component',\n description:\n 'Insert a reusable component from an enabled library by stable library and asset identity.',\n\n execution: { kind: 'async', mutation: 'document' },\n content: 'imported',\n input: v.strictObject({\n library_id: v.pipe(v.string(), v.description('Library ID')),\n revision_id: v.optional(v.pipe(v.string(), v.description('Pinned revision ID'))),\n asset_key: v.pipe(v.string(), v.description('Stable asset key')),\n parent_id: v.optional(v.pipe(v.string(), v.description('Optional 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 variant_values: v.optional(\n v.pipe(v.string(), v.description('Optional JSON object of variant property values'))\n )\n }),\n execute: async (figma, args) => {\n if (args.parent_id)\n prepareSlotInsertion(figma.graph, args.parent_id, 'insert_library_component')\n const catalog = getComponentCatalog(figma.graph)\n if (!catalog) throw new Error('No component library catalog is configured')\n let variantValues: Record<string, string> | undefined\n if (args.variant_values) {\n const parsed = v.safeParse(variantValuesSchema, args.variant_values)\n if (!parsed.success) {\n throw new TypeError(\n `variant_values must be a JSON object of strings: ${v.summarize(parsed.issues)}`\n )\n }\n variantValues = parsed.output\n }\n return catalog.insertComponent({\n libraryId: args.library_id,\n revisionId: args.revision_id,\n assetKey: args.asset_key,\n parentId: args.parent_id,\n x: args.x,\n y: args.y,\n variantValues\n })\n }\n})\n"],"mappings":";;;;;;AAOA,MAAM,sBAAsB,EAAE,KAC5B,EAAE,OAAO,GACT,EAAE,UAAU,GAEZ,EAAE,MAAM,eAAe,wBAAwB,GAC/C,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CACjC;AAEA,MAAa,gBAAgB,WAAW;CACtC,MAAM;CACN,aACE;CACF,WAAW;EAAE,MAAM;EAAS,UAAU;CAAO;CAC7C,UAAU,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AC,CAAC;EACzE,gBAAgB,EAAE,SAChB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,iDAAiD,CAAC,CACrF;CACF,CAAC;CACD,SAAS,OAAO,OAAO,SAAS;EAC9B,IAAI,KAAK,WACP,qBAAqB,MAAM,OAAO,KAAK,WAAW,0BAA0B;EAC9E,MAAM,UAAU,oBAAoB,MAAM,KAAK;EAC/C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,4CAA4C;EAC1E,IAAI;EACJ,IAAI,KAAK,gBAAgB;GACvB,MAAM,SAAS,EAAE,UAAU,qBAAqB,KAAK,cAAc;GACnE,IAAI,CAAC,OAAO,SACV,MAAM,IAAI,UACR,oDAAoD,EAAE,UAAU,OAAO,MAAM,GAC/E;GAEF,gBAAgB,OAAO;EACzB;EACA,OAAO,QAAQ,gBAAgB;GAC7B,WAAW,KAAK;GAChB,YAAY,KAAK;GACjB,UAAU,KAAK;GACf,UAAU,KAAK;GACf,GAAG,KAAK;GACR,GAAG,KAAK;GACR;EACF,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","names":[],"sources":["../../../src/tools/read/nodes.ts"],"mappings":";;cAqEa,aAAA;
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","names":[],"sources":["../../../src/tools/read/nodes.ts"],"mappings":";;cAqEa,aAAA;cAuDA,SAAA;cA4BA,WAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","names":[],"sources":["../../../src/tools/read/nodes.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api'\nimport {\n toolNumber,\n nodeIdInputSchema,\n defineTool,\n nodeSummary,\n nodeToResult\n} from '#core/tools/schema'\n\ninterface TreeEntry {\n id: string\n type: string\n name: string\n w: number\n h: number\n text?: string\n children?: TreeEntry[]\n}\n\nfunction nodeToTreeEntry(\n node: FigmaNodeProxy,\n level: number,\n maxDepth?: number,\n typeFilter?: Set<string>\n): TreeEntry | null {\n const children: TreeEntry[] = []\n if ((maxDepth === undefined || level < maxDepth) && node.children.length > 0) {\n for (const child of node.children) {\n const entry = nodeToTreeEntry(child, level + 1, maxDepth, typeFilter)\n if (entry) children.push(entry)\n }\n }\n\n const matches = !typeFilter || typeFilter.has(node.type)\n if (!matches && children.length === 0) return null\n\n const entry: TreeEntry = {\n id: node.id,\n type: node.type,\n name: node.name,\n w: node.width,\n h: node.height\n }\n if (node.type === 'TEXT') entry.text = node.characters\n if (children.length > 0) entry.children = children\n return entry\n}\n\n/** The current page's tree; the answer that never needs a page load. */\nfunction currentPageTree(\n figma: FigmaAPI,\n depth: number | undefined,\n typeFilter: Set<string> | undefined\n) {\n const page = figma.currentPage\n const children: TreeEntry[] = []\n for (const child of page.children) {\n const entry = nodeToTreeEntry(child, 1, depth, typeFilter)\n if (entry) children.push(entry)\n }\n return { page: page.name, children }\n}\n\nfunction typeFilterOf(nodeTypes: readonly string[] | undefined): Set<string> | undefined {\n return nodeTypes && nodeTypes.length > 0 ? new Set(nodeTypes) : undefined\n}\n\nexport const getPageTree = defineTool({\n name: 'get_page_tree',\n description:\n 'Get the node tree of the current page. Returns lightweight hierarchy: id, type, name, size, and text for TEXT nodes. Use depth, root_id, or node_types to keep large pages small. Use get_node for full properties of a specific node.',\n execution: { kind: 'async', mutation: 'none' },\n input: v.strictObject({\n depth: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.minValue(1),\n v.description(\n 'Max nesting depth to return (1 = returned root nodes only). Default: unlimited'\n )\n )\n )\n ),\n root_id: v.optional(\n v.pipe(\n v.string(),\n v.description('Return only this node subtree instead of the whole current page')\n )\n ),\n node_types: v.optional(\n v.pipe(\n v.array(v.string()),\n v.minLength(1),\n v.description('Keep only these node types and their ancestors, for example FRAME or TEXT')\n )\n )\n }),\n executeSync: (figma, { depth, root_id, node_types }) => {\n const typeFilter = typeFilterOf(node_types)\n if (root_id !== undefined) {\n const root = figma.getNodeById(root_id)\n if (!root) return undefined\n // A page root exists before its layers load; only the async path can answer it.\n if (figma.graph.getNode(root.id)?.type === 'CANVAS') return undefined\n return { root: root.id, tree: nodeToTreeEntry(root, 1, depth, typeFilter) }\n
|
|
1
|
+
{"version":3,"file":"nodes.js","names":[],"sources":["../../../src/tools/read/nodes.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api'\nimport {\n toolNumber,\n nodeIdInputSchema,\n defineTool,\n nodeSummary,\n nodeToResult\n} from '#core/tools/schema'\n\ninterface TreeEntry {\n id: string\n type: string\n name: string\n w: number\n h: number\n text?: string\n children?: TreeEntry[]\n}\n\nfunction nodeToTreeEntry(\n node: FigmaNodeProxy,\n level: number,\n maxDepth?: number,\n typeFilter?: Set<string>\n): TreeEntry | null {\n const children: TreeEntry[] = []\n if ((maxDepth === undefined || level < maxDepth) && node.children.length > 0) {\n for (const child of node.children) {\n const entry = nodeToTreeEntry(child, level + 1, maxDepth, typeFilter)\n if (entry) children.push(entry)\n }\n }\n\n const matches = !typeFilter || typeFilter.has(node.type)\n if (!matches && children.length === 0) return null\n\n const entry: TreeEntry = {\n id: node.id,\n type: node.type,\n name: node.name,\n w: node.width,\n h: node.height\n }\n if (node.type === 'TEXT') entry.text = node.characters\n if (children.length > 0) entry.children = children\n return entry\n}\n\n/** The current page's tree; the answer that never needs a page load. */\nfunction currentPageTree(\n figma: FigmaAPI,\n depth: number | undefined,\n typeFilter: Set<string> | undefined\n) {\n const page = figma.currentPage\n const children: TreeEntry[] = []\n for (const child of page.children) {\n const entry = nodeToTreeEntry(child, 1, depth, typeFilter)\n if (entry) children.push(entry)\n }\n return { page: page.name, children }\n}\n\nfunction typeFilterOf(nodeTypes: readonly string[] | undefined): Set<string> | undefined {\n return nodeTypes && nodeTypes.length > 0 ? new Set(nodeTypes) : undefined\n}\n\nexport const getPageTree = defineTool({\n name: 'get_page_tree',\n description:\n 'Get the node tree of the current page. Returns lightweight hierarchy: id, type, name, size, and text for TEXT nodes. Use depth, root_id, or node_types to keep large pages small. Use get_node for full properties of a specific node.',\n execution: { kind: 'async', mutation: 'none' },\n input: v.strictObject({\n depth: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.minValue(1),\n v.description(\n 'Max nesting depth to return (1 = returned root nodes only). Default: unlimited'\n )\n )\n )\n ),\n root_id: v.optional(\n v.pipe(\n v.string(),\n v.description('Return only this node subtree instead of the whole current page')\n )\n ),\n node_types: v.optional(\n v.pipe(\n v.array(v.string()),\n v.minLength(1),\n v.description('Keep only these node types and their ancestors, for example FRAME or TEXT')\n )\n )\n }),\n executeSync: (figma, { depth, root_id, node_types }) => {\n const typeFilter = typeFilterOf(node_types)\n if (root_id !== undefined) {\n const root = figma.getNodeById(root_id)\n if (!root) return undefined\n // A page root exists before its layers load; only the async path can answer it.\n if (figma.graph.getNode(root.id)?.type === 'CANVAS') return undefined\n return { root: root.id, tree: nodeToTreeEntry(root, 1, depth, typeFilter) }\n }\n return currentPageTree(figma, depth, typeFilter)\n },\n execute: async (figma, { depth, root_id, node_types }) => {\n const typeFilter = typeFilterOf(node_types)\n if (root_id === undefined) return currentPageTree(figma, depth, typeFilter)\n const root = figma.getNodeById(root_id)\n // A layer on a page not yet visited loads that page, as in Figma's dynamic-page mode.\n const loaded = root ?? (await figma.getNodeByIdAsync(root_id))\n if (!loaded) return { error: `Node \"${root_id}\" not found` }\n // A page root exists before its layers load; read them first.\n if (figma.graph.getNode(loaded.id)?.type === 'CANVAS') await loaded.loadAsync()\n return { root: loaded.id, tree: nodeToTreeEntry(loaded, 1, depth, typeFilter) }\n }\n})\n\nexport const getNode = defineTool({\n name: 'get_node',\n description:\n 'Get detailed properties of a node by ID. Use depth to limit child recursion (0 = node only, 1 = direct children, etc). Default: unlimited.',\n execution: { kind: 'async', mutation: 'none' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n depth: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.description('Max depth of children to include (0 = no children). Default: unlimited')\n )\n )\n )\n }),\n executeSync: (figma, { id, depth }) => {\n const node = figma.getNodeById(id)\n return node ? nodeToResult(node, depth) : undefined\n },\n execute: async (figma, { id, depth }) => {\n const node = figma.getNodeById(id)\n // A layer on a page not yet visited loads that page, as in Figma's dynamic-page mode.\n const loaded = node ?? (await figma.getNodeByIdAsync(id))\n return loaded ? nodeToResult(loaded, depth) : { error: `Node \"${id}\" not found` }\n }\n})\n\nexport const findNodes = defineTool({\n name: 'find_nodes',\n description: 'Find nodes by name pattern and/or type.',\n execution: { kind: 'sync', mutation: 'none' },\n input: v.strictObject({\n name: v.optional(\n v.pipe(v.string(), v.description('Name substring to match (case-insensitive)'))\n ),\n type: v.optional(\n v.pipe(\n v.picklist([\n 'FRAME',\n 'RECTANGLE',\n 'ELLIPSE',\n 'TEXT',\n 'LINE',\n 'STAR',\n 'POLYGON',\n 'SECTION',\n 'GROUP',\n 'COMPONENT',\n 'INSTANCE',\n 'VECTOR'\n ]),\n v.description('Node type filter')\n )\n )\n }),\n execute: (figma, args) => {\n const page = figma.currentPage\n const matches = page.findAll((node) => {\n if (args.type && node.type !== args.type) return false\n if (args.name && !node.name.toLowerCase().includes(args.name.toLowerCase())) return false\n return true\n })\n return { count: matches.length, nodes: matches.map(nodeSummary) }\n }\n})\n"],"mappings":";;;AAqBA,SAAS,gBACP,MACA,OACA,UACA,YACkB;CAClB,MAAM,WAAwB,CAAC;CAC/B,KAAK,aAAa,KAAA,KAAa,QAAQ,aAAa,KAAK,SAAS,SAAS,GACzE,KAAK,MAAM,SAAS,KAAK,UAAU;EACjC,MAAM,QAAQ,gBAAgB,OAAO,QAAQ,GAAG,UAAU,UAAU;EACpE,IAAI,OAAO,SAAS,KAAK,KAAK;CAChC;CAIF,IAAI,EADY,CAAC,cAAc,WAAW,IAAI,KAAK,IAAI,MACvC,SAAS,WAAW,GAAG,OAAO;CAE9C,MAAM,QAAmB;EACvB,IAAI,KAAK;EACT,M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CAC5C,OAAO,EAAE,aAAa;EACpB,MAAM,EAAE,SACN,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,4CAA4C,CAAC,CAChF;EACA,MAAM,EAAE,SACN,EAAE,KACA,EAAE,SAAS;GACT;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,GACD,EAAE,YAAY,kBAAkB,CAClC,CACF;CACF,CAAC;CACD,UAAU,OAAO,SAAS;EAExB,MAAM,UADO,MAAM,YACE,SAAS,SAAS;GACrC,IAAI,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,OAAO;GACjD,IAAI,KAAK,QAAQ,CAAC,KAAK,KAAK,YAAY,CAAC,CAAC,SAAS,KAAK,KAAK,YAAY,CAAC,GAAG,OAAO;GACpF,OAAO;EACT,CAAC;EACD,OAAO;GAAE,OAAO,QAAQ;GAAQ,OAAO,QAAQ,IAAI,WAAW;EAAE;CAClE;AACF,CAAC"}
|
|
@@ -19,6 +19,8 @@ interface EmptySpaceRequest {
|
|
|
19
19
|
interface EmptySpace extends Rect {
|
|
20
20
|
direction: SpaceDirection | null;
|
|
21
21
|
}
|
|
22
|
+
/** Whether `rect` comes within `gap` of `obstacle`, or covers part of it when `gap` is 0. */
|
|
23
|
+
declare function rectsOverlap(rect: Rect, obstacle: Rect, gap: number): boolean;
|
|
22
24
|
/**
|
|
23
25
|
* A free region of `width` × `height` that keeps `gap` from every obstacle, as close to the
|
|
24
26
|
* anchor as the directions allow; the first direction wins a tie.
|
|
@@ -33,5 +35,5 @@ declare function spaceBesideContent(graph: SceneGraph, parentId: string, size: {
|
|
|
33
35
|
}, gap?: number): EmptySpace;
|
|
34
36
|
declare const findEmptySpaceTool: ToolDef;
|
|
35
37
|
//#endregion
|
|
36
|
-
export { DEFAULT_SPACE_GAP, EmptySpace, EmptySpaceRequest, childBoxes, findEmptySpace, findEmptySpaceTool, spaceBesideContent };
|
|
38
|
+
export { DEFAULT_SPACE_GAP, EmptySpace, EmptySpaceRequest, childBoxes, findEmptySpace, findEmptySpaceTool, rectsOverlap, spaceBesideContent };
|
|
37
39
|
//# sourceMappingURL=space.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space.d.ts","names":[],"sources":["../../../src/tools/read/space.ts"],"mappings":";;;;cAWM;KACD,yBAAyB;;cAGjB;UAEI;;EAEf,oBAAoB;EACpB;EACA;;EAEA,QAAQ;EACR;EACA,qBAAqB;;UAGN,mBAAmB;EAClC,WAAW
|
|
1
|
+
{"version":3,"file":"space.d.ts","names":[],"sources":["../../../src/tools/read/space.ts"],"mappings":";;;;cAWM;KACD,yBAAyB;;cAGjB;UAEI;;EAEf,oBAAoB;EACpB;EACA;;EAEA,QAAQ;EACR;EACA,qBAAqB;;UAGN,mBAAmB;EAClC,WAAW;;;iBAIG,aAAa,MAAM,MAAM,UAAU,MAAM;;;;;iBAsDzC,eAAe,SAAS,oBAAoB;;iBAe5C,WAAW,OAAO,YAAY,mBAAmB;;iBAUjD,mBACd,OAAO,YACP,kBACA;EAAQ;EAAe;GACvB,eACC;cAcU,oBAAA"}
|