@pairdraw/core 0.21.1 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/boolean.d.ts +6 -1
- package/dist/canvas/boolean.d.ts.map +1 -1
- package/dist/canvas/boolean.js +10 -2
- package/dist/canvas/boolean.js.map +1 -1
- package/dist/canvas/color-space.d.ts +45 -0
- package/dist/canvas/color-space.d.ts.map +1 -0
- package/dist/canvas/color-space.js +39 -0
- package/dist/canvas/color-space.js.map +1 -0
- package/dist/canvas/fills.d.ts +10 -10
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +116 -62
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/flatten.d.ts +11 -3
- package/dist/canvas/flatten.d.ts.map +1 -1
- package/dist/canvas/flatten.js +62 -4
- package/dist/canvas/flatten.js.map +1 -1
- package/dist/canvas/images/previews.d.ts +1 -1
- package/dist/canvas/index.d.ts +2 -1
- package/dist/canvas/index.js +2 -1
- package/dist/canvas/layout-grids.d.ts +5 -2
- package/dist/canvas/layout-grids.d.ts.map +1 -1
- package/dist/canvas/layout-grids.js +7 -2
- package/dist/canvas/layout-grids.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +17 -4
- package/dist/canvas/noise/render.d.ts.map +1 -1
- package/dist/canvas/noise/render.js +21 -6
- package/dist/canvas/noise/render.js.map +1 -1
- package/dist/canvas/noise/shader.d.ts +4 -4
- package/dist/canvas/noise/shader.d.ts.map +1 -1
- package/dist/canvas/noise/shader.js +5 -6
- package/dist/canvas/noise/shader.js.map +1 -1
- package/dist/canvas/overlays/annotations.d.ts +19 -0
- package/dist/canvas/overlays/annotations.d.ts.map +1 -0
- package/dist/canvas/overlays/annotations.js +110 -0
- package/dist/canvas/overlays/annotations.js.map +1 -0
- package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +25 -1
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/overlays/feedback.js +1 -1
- package/dist/canvas/overlays/feedback.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/measurement.d.ts +7 -1
- package/dist/canvas/overlays/measurement.d.ts.map +1 -1
- package/dist/canvas/overlays/measurement.js +42 -4
- package/dist/canvas/overlays/measurement.js.map +1 -1
- package/dist/canvas/overlays/presence.d.ts.map +1 -1
- package/dist/canvas/overlays/presence.js +21 -24
- package/dist/canvas/overlays/presence.js.map +1 -1
- package/dist/canvas/renderer/colors.d.ts +7 -1
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +9 -1
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +15 -6
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
- package/dist/canvas/renderer/document-surface.js +1 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +2 -2
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +1 -0
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +4 -1
- 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 +6 -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 +7 -0
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +10 -0
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer.d.ts +10 -2
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +15 -3
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +9 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/clipboard/pairdraw.d.ts.map +1 -1
- package/dist/clipboard/pairdraw.js +1 -0
- package/dist/clipboard/pairdraw.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +2 -0
- package/dist/editor/bridges/clipboard.d.ts.map +1 -1
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +1 -1
- package/dist/editor/bridges/components.d.ts +14 -7
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +6 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -1
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/code.d.ts +32 -0
- package/dist/editor/clipboard/code.d.ts.map +1 -0
- package/dist/editor/clipboard/code.js +30 -0
- package/dist/editor/clipboard/code.js.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.js +0 -0
- package/dist/editor/clipboard/paste/run.d.ts +14 -0
- package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/run.js +47 -0
- package/dist/editor/clipboard/paste/run.js.map +1 -0
- package/dist/editor/clipboard/styled.d.ts +2 -8
- package/dist/editor/clipboard/styled.d.ts.map +1 -1
- package/dist/editor/clipboard/styled.js +2 -32
- package/dist/editor/clipboard/styled.js.map +1 -1
- package/dist/editor/clipboard.d.ts +2 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +34 -0
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +5 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +69 -4
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/slots/index.d.ts.map +1 -1
- package/dist/editor/components/slots/index.js +7 -0
- package/dist/editor/components/slots/index.js.map +1 -1
- package/dist/editor/components.d.ts +6 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/components.js +14 -2
- package/dist/editor/components.js.map +1 -1
- package/dist/editor/create.d.ts +30 -3
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +11 -2
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-tokens.d.ts +1 -1
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +4 -18
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/image-edit.d.ts.map +1 -1
- package/dist/editor/image-edit.js +1 -2
- package/dist/editor/image-edit.js.map +1 -1
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts +3 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +97 -2
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/nodes.d.ts +2 -0
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +22 -7
- package/dist/editor/nodes.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/selection/overlays.d.ts +1 -0
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +7 -0
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +8 -0
- package/dist/editor/selection.d.ts +9 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/state/shared.js +1 -0
- package/dist/editor/state/shared.js.map +1 -1
- package/dist/editor/state/view.d.ts.map +1 -1
- package/dist/editor/state/view.js +2 -0
- package/dist/editor/state/view.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +1 -1
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js +20 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/container-wrap.d.ts +8 -2
- package/dist/editor/structure/container-wrap.d.ts.map +1 -1
- package/dist/editor/structure/container-wrap.js +17 -5
- package/dist/editor/structure/container-wrap.js.map +1 -1
- package/dist/editor/structure/flatten.d.ts.map +1 -1
- package/dist/editor/structure/flatten.js +8 -7
- package/dist/editor/structure/flatten.js.map +1 -1
- package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
- package/dist/editor/structure/group/ungroup.js +2 -0
- package/dist/editor/structure/group/ungroup.js.map +1 -1
- package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
- package/dist/editor/structure/outline-stroke.js +5 -0
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -1
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/styles.d.ts +26 -0
- package/dist/editor/styles.d.ts.map +1 -0
- package/dist/editor/styles.js +127 -0
- package/dist/editor/styles.js.map +1 -0
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +10 -2
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +6 -0
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +14 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +6 -1
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +22 -1
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/shape.js +1 -1
- package/dist/figma-api/accessors/text/index.js +1 -1
- package/dist/figma-api/accessors/text/ranges.js +1 -1
- package/dist/figma-api/accessors/text/references.js +1 -1
- package/dist/figma-api/accessors/variables.js +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +8 -22
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.js +1 -1
- package/dist/figma-api/compatibility.d.ts +1 -1
- package/dist/figma-api/compatibility.d.ts.map +1 -1
- package/dist/figma-api/component-scope.d.ts +14 -0
- package/dist/figma-api/component-scope.d.ts.map +1 -0
- package/dist/figma-api/component-scope.js +28 -0
- package/dist/figma-api/component-scope.js.map +1 -0
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +26 -2
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/flatten.js +3 -3
- package/dist/figma-api/flatten.js.map +1 -1
- package/dist/figma-api/index.d.ts +77 -6
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +188 -2
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/node-types.d.ts +2 -1
- package/dist/figma-api/node-types.d.ts.map +1 -1
- package/dist/figma-api/overrides.d.ts +26 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +157 -10
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +2 -0
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +10 -2
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +65 -9
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +144 -11
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/shape-with-text.js +1 -1
- package/dist/figma-api/slots.d.ts +3 -1
- package/dist/figma-api/slots.d.ts.map +1 -1
- package/dist/figma-api/slots.js +9 -8
- package/dist/figma-api/slots.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/io/formats/code/detect.d.ts +23 -0
- package/dist/io/formats/code/detect.d.ts.map +1 -0
- package/dist/io/formats/code/detect.js +46 -0
- package/dist/io/formats/code/detect.js.map +1 -0
- package/dist/io/formats/code/index.d.ts +5 -0
- package/dist/io/formats/code/index.js +5 -0
- package/dist/io/formats/code/read.d.ts +45 -0
- package/dist/io/formats/code/read.d.ts.map +1 -0
- package/dist/io/formats/code/read.js +86 -0
- package/dist/io/formats/code/read.js.map +1 -0
- package/dist/io/formats/code/stylesheet.d.ts +13 -0
- package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
- package/dist/io/formats/code/stylesheet.js +21 -0
- package/dist/io/formats/code/stylesheet.js.map +1 -0
- package/dist/io/formats/code/tokens.d.ts +18 -0
- package/dist/io/formats/code/tokens.d.ts.map +1 -0
- package/dist/io/formats/code/tokens.js +135 -0
- package/dist/io/formats/code/tokens.js.map +1 -0
- package/dist/io/formats/design-tokens/apply.d.ts +7 -3
- package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/apply.js.map +1 -1
- package/dist/io/formats/fig/export/patch/fields.js +5 -0
- package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +20 -20
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +5 -1
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/index.d.ts +3 -2
- package/dist/io/formats/fig/index.js +2 -2
- package/dist/io/formats/fig/read.d.ts.map +1 -1
- package/dist/io/formats/fig/read.js +5 -2
- package/dist/io/formats/fig/read.js.map +1 -1
- package/dist/io/formats/html/layers.d.ts +3 -1
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +6 -1
- package/dist/io/formats/html/layers.js.map +1 -1
- package/dist/io/formats/pdf/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +7 -3
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/plan.d.ts +3 -0
- package/dist/io/formats/pdf/plan.d.ts.map +1 -1
- package/dist/io/formats/pdf/plan.js +60 -36
- package/dist/io/formats/pdf/plan.js.map +1 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +3 -2
- 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/index.js +2 -2
- package/dist/io/formats/raster/render.d.ts +10 -2
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +35 -9
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +19 -1
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts +5 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +59 -10
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/index.d.ts +2 -2
- package/dist/io/formats/svg/index.js +2 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +4 -2
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/record.d.ts.map +1 -1
- package/dist/io/formats/video/record.js +24 -9
- package/dist/io/formats/video/record.js.map +1 -1
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +20 -13
- package/dist/io/formats.js.map +1 -1
- package/dist/kiwi/fig/population/client.d.ts.map +1 -1
- package/dist/kiwi/fig/population/client.js +2 -1
- package/dist/kiwi/fig/population/client.js.map +1 -1
- package/dist/kiwi/fig/session/document-state.d.ts +46 -2
- package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
- package/dist/kiwi/fig/session/document-state.js +113 -5
- package/dist/kiwi/fig/session/document-state.js.map +1 -1
- package/dist/kiwi/fig/session/options.d.ts +4 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +8 -4
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.js +1 -1
- package/dist/layout/auto-layout-handles.js.map +1 -1
- package/dist/layout/axis-sizing.d.ts.map +1 -1
- package/dist/layout/axis-sizing.js +1 -1
- package/dist/layout/axis-sizing.js.map +1 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +1 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/effective-generated-text.js +1 -1
- package/dist/layout/effective-generated-text.js.map +1 -1
- package/dist/layout/grid.d.ts +3 -1
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +57 -16
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +6 -5
- package/dist/layout.js.map +1 -1
- package/dist/node/fs.d.ts.map +1 -1
- package/dist/node/fs.js +28 -7
- package/dist/node/fs.js.map +1 -1
- package/dist/prototype/easing.d.ts +13 -5
- package/dist/prototype/easing.d.ts.map +1 -1
- package/dist/prototype/easing.js +46 -6
- package/dist/prototype/easing.js.map +1 -1
- package/dist/prototype/scenes.d.ts +31 -0
- package/dist/prototype/scenes.d.ts.map +1 -1
- package/dist/prototype/scenes.js +220 -31
- package/dist/prototype/scenes.js.map +1 -1
- package/dist/prototype/session.d.ts.map +1 -1
- package/dist/prototype/session.js +1 -0
- package/dist/prototype/session.js.map +1 -1
- package/dist/prototype/smart-animate/animation.d.ts +2 -1
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
- package/dist/prototype/smart-animate/animation.js +2 -2
- package/dist/prototype/smart-animate/animation.js.map +1 -1
- package/dist/prototype/timeline.d.ts +10 -1
- package/dist/prototype/timeline.d.ts.map +1 -1
- package/dist/prototype/timeline.js +69 -23
- package/dist/prototype/timeline.js.map +1 -1
- package/dist/prototype/variables.d.ts +23 -0
- package/dist/prototype/variables.d.ts.map +1 -0
- package/dist/prototype/variables.js +237 -0
- package/dist/prototype/variables.js.map +1 -0
- package/dist/rpc/read-commands.d.ts +5 -0
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +4 -1
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/character-style.d.ts +8 -1
- package/dist/text/character-style.d.ts.map +1 -1
- package/dist/text/character-style.js +39 -1
- package/dist/text/character-style.js.map +1 -1
- package/dist/text/font/batch.d.ts +26 -0
- package/dist/text/font/batch.d.ts.map +1 -0
- package/dist/text/font/batch.js +31 -0
- package/dist/text/font/batch.js.map +1 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +14 -1
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/index.d.ts +3 -2
- package/dist/text/index.js +3 -2
- package/dist/tools/create/basic.js +3 -4
- package/dist/tools/create/basic.js.map +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/code.d.ts +6 -0
- package/dist/tools/create/code.d.ts.map +1 -0
- package/dist/tools/create/code.js +68 -0
- package/dist/tools/create/code.js.map +1 -0
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +9 -57
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.js +1 -1
- package/dist/tools/create/inputs.d.ts +11 -0
- package/dist/tools/create/inputs.d.ts.map +1 -0
- package/dist/tools/create/inputs.js +15 -0
- package/dist/tools/create/inputs.js.map +1 -0
- package/dist/tools/create/mermaid.d.ts.map +1 -1
- package/dist/tools/create/mermaid.js +5 -6
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/place.d.ts +30 -0
- package/dist/tools/create/place.d.ts.map +1 -0
- package/dist/tools/create/place.js +70 -0
- package/dist/tools/create/place.js.map +1 -0
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/create.d.ts +2 -1
- package/dist/tools/create.js +2 -1
- package/dist/tools/css/gradient.d.ts +28 -0
- package/dist/tools/css/gradient.d.ts.map +1 -0
- package/dist/tools/css/gradient.js +118 -0
- package/dist/tools/css/gradient.js.map +1 -0
- package/dist/tools/image-ai/generate.js +1 -1
- package/dist/tools/modify/geometry.js +5 -5
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +7 -1
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.js +1 -1
- package/dist/tools/modify/overrides.d.ts +6 -0
- package/dist/tools/modify/overrides.d.ts.map +1 -0
- package/dist/tools/modify/overrides.js +27 -0
- package/dist/tools/modify/overrides.js.map +1 -0
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +84 -39
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/text.d.ts +2 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +79 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +18 -2
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +3 -2
- package/dist/tools/modify.js +3 -2
- package/dist/tools/read/css.d.ts.map +1 -1
- package/dist/tools/read/css.js +29 -12
- package/dist/tools/read/css.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js +19 -5
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +6 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/text-range.d.ts +11 -0
- package/dist/tools/text-range.d.ts.map +1 -0
- package/dist/tools/text-range.js +26 -0
- package/dist/tools/text-range.js.map +1 -0
- package/dist/tools/variables/bindings.js +1 -1
- package/dist/tools/variables/bindings.js.map +1 -1
- package/dist/tools/variables/unbind.js +1 -1
- package/dist/tools/variables/unbind.js.map +1 -1
- package/dist/tools/vector/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +7 -21
- package/dist/tools/vector/path.js.map +1 -1
- package/dist/vector/rebase.d.ts +17 -0
- package/dist/vector/rebase.d.ts.map +1 -0
- package/dist/vector/rebase.js +32 -0
- package/dist/vector/rebase.js.map +1 -0
- package/package.json +14 -9
- package/src/canvas/boolean.ts +12 -1
- package/src/canvas/color-space.ts +73 -0
- package/src/canvas/fills.ts +130 -83
- package/src/canvas/flatten.ts +92 -7
- package/src/canvas/index.ts +9 -0
- package/src/canvas/layout-grids.ts +15 -2
- package/src/canvas/noise/render.ts +35 -7
- package/src/canvas/noise/shader.ts +8 -10
- package/src/canvas/overlays/annotations.ts +117 -0
- package/src/canvas/overlays/auto-layout-hover.ts +41 -1
- package/src/canvas/overlays/feedback.ts +7 -2
- package/src/canvas/overlays/index.ts +1 -1
- package/src/canvas/overlays/measurement.ts +49 -3
- package/src/canvas/overlays/presence.ts +35 -32
- package/src/canvas/renderer/colors.ts +14 -0
- package/src/canvas/renderer/document-surface.ts +16 -6
- package/src/canvas/renderer/lifecycle.ts +2 -2
- package/src/canvas/renderer/methods.ts +4 -0
- package/src/canvas/renderer/overlay-pass.ts +4 -0
- package/src/canvas/renderer/pipeline.ts +8 -0
- package/src/canvas/renderer/types.ts +8 -0
- package/src/canvas/renderer.ts +21 -2
- package/src/canvas/scene.ts +15 -7
- package/src/clipboard/pairdraw.ts +1 -0
- package/src/editor/bridges/clipboard.ts +1 -0
- package/src/editor/bridges/components.ts +10 -0
- package/src/editor/clipboard/code.ts +50 -0
- package/src/editor/clipboard/paste/dependencies.ts +18 -0
- package/src/editor/clipboard/paste/run.ts +64 -0
- package/src/editor/clipboard/styled.ts +4 -52
- package/src/editor/clipboard.ts +40 -0
- package/src/editor/components/instances.ts +92 -4
- package/src/editor/components/slots/index.ts +7 -0
- package/src/editor/components.ts +16 -2
- package/src/editor/create.ts +15 -1
- package/src/editor/design-tokens.ts +3 -23
- package/src/editor/image-edit.ts +5 -2
- package/src/editor/index.ts +1 -0
- package/src/editor/layout-mode.ts +131 -3
- package/src/editor/nodes.ts +30 -5
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/selection/overlays.ts +8 -0
- package/src/editor/state/shared.ts +1 -0
- package/src/editor/state/view.ts +2 -0
- package/src/editor/structure/boolean.ts +29 -1
- package/src/editor/structure/container-wrap.ts +20 -4
- package/src/editor/structure/flatten.ts +15 -8
- package/src/editor/structure/group/ungroup.ts +2 -0
- package/src/editor/structure/outline-stroke.ts +5 -0
- package/src/editor/styles.ts +203 -0
- package/src/editor/text/selection-style.ts +18 -1
- package/src/editor/tool-registry.ts +2 -0
- package/src/editor/types.ts +14 -0
- package/src/editor/variable-bindings.ts +11 -0
- package/src/figma-api/accessors/basic.ts +33 -1
- package/src/figma-api/accessors/vector.ts +6 -13
- package/src/figma-api/compatibility.ts +1 -0
- package/src/figma-api/component-scope.ts +36 -0
- package/src/figma-api/components.ts +24 -0
- package/src/figma-api/flatten.ts +7 -3
- package/src/figma-api/index.ts +302 -6
- package/src/figma-api/node-types.ts +1 -0
- package/src/figma-api/overrides.ts +192 -5
- package/src/figma-api/proxy.ts +16 -1
- package/src/figma-api/reactions.ts +163 -12
- package/src/figma-api/slots.ts +10 -9
- package/src/io/formats/code/detect.ts +67 -0
- package/src/io/formats/code/index.ts +17 -0
- package/src/io/formats/code/read.ts +143 -0
- package/src/io/formats/code/stylesheet.ts +24 -0
- package/src/io/formats/code/tokens.ts +159 -0
- package/src/io/formats/design-tokens/apply.ts +3 -2
- package/src/io/formats/fig/export/patch/fields.ts +11 -0
- package/src/io/formats/fig/export/patch/index.ts +23 -19
- package/src/io/formats/fig/export/setup.ts +8 -1
- package/src/io/formats/fig/index.ts +6 -0
- package/src/io/formats/fig/read.ts +11 -2
- package/src/io/formats/html/layers.ts +7 -0
- package/src/io/formats/pdf/export.ts +19 -7
- package/src/io/formats/pdf/plan.ts +71 -32
- package/src/io/formats/raster/headless.ts +3 -1
- package/src/io/formats/raster/index.ts +2 -0
- package/src/io/formats/raster/render.ts +49 -9
- package/src/io/formats/svg/defs.ts +27 -1
- package/src/io/formats/svg/export.ts +75 -13
- package/src/io/formats/svg/index.ts +1 -0
- package/src/io/formats/svg/text/layout.ts +5 -3
- package/src/io/formats/video/record.ts +33 -9
- package/src/io/formats.ts +35 -15
- package/src/kiwi/fig/population/client.ts +6 -1
- package/src/kiwi/fig/session/document-state.ts +195 -5
- package/src/kiwi/fig/session/options.ts +2 -0
- package/src/layout/apply.ts +12 -4
- package/src/layout/auto-layout-handles.ts +1 -1
- package/src/layout/axis-sizing.ts +3 -1
- package/src/layout/derived.ts +3 -1
- package/src/layout/effective-generated-text.ts +1 -1
- package/src/layout/grid.ts +91 -21
- package/src/layout.ts +16 -3
- package/src/node/fs.ts +32 -7
- package/src/prototype/easing.ts +79 -7
- package/src/prototype/scenes.ts +244 -15
- package/src/prototype/session.ts +1 -0
- package/src/prototype/smart-animate/animation.ts +4 -3
- package/src/prototype/timeline.ts +118 -26
- package/src/prototype/variables.ts +189 -0
- package/src/rpc/read-commands.ts +19 -1
- package/src/text/character-style.ts +47 -0
- package/src/text/font/batch.ts +58 -0
- package/src/text/font/manager.ts +17 -1
- package/src/text/index.ts +2 -1
- package/src/tools/create/basic.ts +2 -3
- package/src/tools/create/code.ts +85 -0
- package/src/tools/create/html.ts +9 -46
- package/src/tools/create/inputs.ts +12 -0
- package/src/tools/create/mermaid.ts +6 -6
- package/src/tools/create/place.ts +80 -0
- package/src/tools/create.ts +1 -0
- package/src/tools/css/gradient.ts +147 -0
- package/src/tools/modify/geometry.ts +5 -5
- package/src/tools/modify/layout.ts +19 -0
- package/src/tools/modify/overrides.ts +35 -0
- package/src/tools/modify/paint.ts +124 -54
- package/src/tools/modify/text.ts +91 -7
- package/src/tools/modify/update.ts +23 -2
- package/src/tools/modify.ts +9 -1
- package/src/tools/read/css.ts +46 -12
- package/src/tools/read/nodes.ts +26 -4
- package/src/tools/registry/extended.ts +6 -0
- package/src/tools/text-range.ts +29 -0
- package/src/tools/variables/bindings.ts +4 -1
- package/src/tools/variables/unbind.ts +4 -1
- package/src/tools/vector/path.ts +11 -13
- package/src/vector/rebase.ts +33 -0
|
@@ -2,6 +2,7 @@ import { collectNodeFontFaces } from "../../text/requirements/collect.js";
|
|
|
2
2
|
import { normalizeLinkURL } from "../../text/hyperlink.js";
|
|
3
3
|
import { defineTool, nodeIdInputSchema, nodeNotFound, parseOptionalToolColor, toolFailure, toolNumber } from "../schema.js";
|
|
4
4
|
import { PairdrawAPI } from "../../pairdraw-api/index.js";
|
|
5
|
+
import { textRangeError } from "../text-range.js";
|
|
5
6
|
import * as v from "valibot";
|
|
6
7
|
//#region src/tools/modify/text.ts
|
|
7
8
|
/**
|
|
@@ -170,6 +171,14 @@ function rangeEdit(args, profile) {
|
|
|
170
171
|
color: color.color
|
|
171
172
|
};
|
|
172
173
|
}
|
|
174
|
+
const rangeIndex = (description) => toolNumber(v.pipe(v.number(), v.integer(), v.minValue(0), v.description(description)));
|
|
175
|
+
/** A TEXT node for a range edit, or the error the tool returns when the id is not one. */
|
|
176
|
+
function textNodeFor(figma, id) {
|
|
177
|
+
const node = figma.getNodeById(id);
|
|
178
|
+
if (!node) return nodeNotFound(id);
|
|
179
|
+
if (node.type !== "TEXT") return { error: `Node "${id}" is not a TEXT node` };
|
|
180
|
+
return node;
|
|
181
|
+
}
|
|
173
182
|
const setFontRange = defineTool({
|
|
174
183
|
name: "set_font_range",
|
|
175
184
|
description: "Set font properties, OpenType features, color, or a link for a text range.",
|
|
@@ -179,8 +188,8 @@ const setFontRange = defineTool({
|
|
|
179
188
|
},
|
|
180
189
|
input: v.strictObject({
|
|
181
190
|
id: nodeIdInputSchema,
|
|
182
|
-
start:
|
|
183
|
-
end:
|
|
191
|
+
start: rangeIndex("Start character index, in UTF-16 code units"),
|
|
192
|
+
end: rangeIndex("End character index, in UTF-16 code units"),
|
|
184
193
|
family: v.optional(v.pipe(v.string(), v.description("Font family name"))),
|
|
185
194
|
size: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description("Font size")))),
|
|
186
195
|
style: v.optional(v.pipe(v.string(), v.description("Font style"))),
|
|
@@ -197,8 +206,8 @@ const setFontRange = defineTool({
|
|
|
197
206
|
return [...font ? [font] : [], ...laysOut ? textFonts(figma, args.id) : []];
|
|
198
207
|
},
|
|
199
208
|
execute: (figma, args) => {
|
|
200
|
-
const node = figma
|
|
201
|
-
if (
|
|
209
|
+
const node = textNodeFor(figma, args.id);
|
|
210
|
+
if ("error" in node) return node;
|
|
202
211
|
const { start, end } = args;
|
|
203
212
|
const badTag = badVariationTag(args.variations);
|
|
204
213
|
if (badTag) return badTag;
|
|
@@ -206,6 +215,8 @@ const setFontRange = defineTool({
|
|
|
206
215
|
if (badFeature) return badFeature;
|
|
207
216
|
const edit = rangeEdit(args, figma.graph.documentColorSpace);
|
|
208
217
|
if ("error" in edit) return edit;
|
|
218
|
+
const rangeError = textRangeError(node.characters, start, end);
|
|
219
|
+
if (rangeError) return { error: rangeError };
|
|
209
220
|
const { hyperlink, color } = edit;
|
|
210
221
|
try {
|
|
211
222
|
if (args.size) node.setRangeFontSize(start, end, args.size);
|
|
@@ -229,6 +240,67 @@ const setFontRange = defineTool({
|
|
|
229
240
|
};
|
|
230
241
|
}
|
|
231
242
|
});
|
|
243
|
+
const setTextRangeStyle = defineTool({
|
|
244
|
+
name: "set_text_range_style",
|
|
245
|
+
description: "Set line height, letter spacing, text case, or decoration for a character range. Indices are UTF-16 code units, as the editor's text ranges are.",
|
|
246
|
+
execution: {
|
|
247
|
+
kind: "sync",
|
|
248
|
+
mutation: "properties"
|
|
249
|
+
},
|
|
250
|
+
input: v.strictObject({
|
|
251
|
+
id: nodeIdInputSchema,
|
|
252
|
+
start: rangeIndex("Start index, in UTF-16 code units"),
|
|
253
|
+
end: rangeIndex("End index, in UTF-16 code units"),
|
|
254
|
+
line_height: v.optional(toolNumber(v.pipe(v.number(), v.minValue(0), v.description("Line height in pixels")))),
|
|
255
|
+
letter_spacing: v.optional(toolNumber(v.pipe(v.number(), v.description("Letter spacing in pixels")))),
|
|
256
|
+
text_case: v.optional(v.pipe(v.picklist([
|
|
257
|
+
"ORIGINAL",
|
|
258
|
+
"UPPER",
|
|
259
|
+
"LOWER",
|
|
260
|
+
"TITLE"
|
|
261
|
+
]), v.description("Letter case in the range"))),
|
|
262
|
+
text_decoration: v.optional(v.pipe(v.picklist([
|
|
263
|
+
"NONE",
|
|
264
|
+
"UNDERLINE",
|
|
265
|
+
"STRIKETHROUGH"
|
|
266
|
+
]), v.description("Decoration in the range")))
|
|
267
|
+
}),
|
|
268
|
+
fonts: (figma, { id }) => textFonts(figma, id),
|
|
269
|
+
execute: (figma, args) => {
|
|
270
|
+
const node = textNodeFor(figma, args.id);
|
|
271
|
+
if ("error" in node) return node;
|
|
272
|
+
const updated = [];
|
|
273
|
+
if (args.line_height !== void 0) updated.push("lineHeight");
|
|
274
|
+
if (args.letter_spacing !== void 0) updated.push("letterSpacing");
|
|
275
|
+
if (args.text_case !== void 0) updated.push("textCase");
|
|
276
|
+
if (args.text_decoration !== void 0) updated.push("textDecoration");
|
|
277
|
+
if (updated.length === 0) return { error: "set_text_range_style needs at least one of line_height, letter_spacing, text_case, or text_decoration" };
|
|
278
|
+
const rangeError = textRangeError(node.characters, args.start, args.end);
|
|
279
|
+
if (rangeError) return { error: rangeError };
|
|
280
|
+
try {
|
|
281
|
+
if (args.line_height !== void 0) node.setRangeLineHeight(args.start, args.end, {
|
|
282
|
+
unit: "PIXELS",
|
|
283
|
+
value: args.line_height
|
|
284
|
+
});
|
|
285
|
+
if (args.letter_spacing !== void 0) node.setRangeLetterSpacing(args.start, args.end, {
|
|
286
|
+
unit: "PIXELS",
|
|
287
|
+
value: args.letter_spacing
|
|
288
|
+
});
|
|
289
|
+
if (args.text_case !== void 0) node.setRangeTextCase(args.start, args.end, args.text_case);
|
|
290
|
+
if (args.text_decoration !== void 0) node.setRangeTextDecoration(args.start, args.end, args.text_decoration);
|
|
291
|
+
} catch (error) {
|
|
292
|
+
return toolFailure(error);
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
id: args.id,
|
|
296
|
+
range: {
|
|
297
|
+
start: args.start,
|
|
298
|
+
end: args.end
|
|
299
|
+
},
|
|
300
|
+
updated
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
});
|
|
232
304
|
const setTextResize = defineTool({
|
|
233
305
|
name: "set_text_resize",
|
|
234
306
|
description: "Set text auto-resize mode.",
|
|
@@ -297,9 +369,8 @@ const setTextProperties = defineTool({
|
|
|
297
369
|
}),
|
|
298
370
|
fonts: (figma, { id }) => textFonts(figma, id),
|
|
299
371
|
execute: (figma, args) => {
|
|
300
|
-
const node = figma
|
|
301
|
-
if (
|
|
302
|
-
if (node.type !== "TEXT") return { error: `Node "${args.id}" is not a TEXT node` };
|
|
372
|
+
const node = textNodeFor(figma, args.id);
|
|
373
|
+
if ("error" in node) return node;
|
|
303
374
|
const hyperlink = requestedHyperlink(args.hyperlink);
|
|
304
375
|
if (hyperlink && "error" in hyperlink) return hyperlink;
|
|
305
376
|
const badFeature = badFeatureEntry(args.font_features);
|
|
@@ -344,6 +415,6 @@ const setTextProperties = defineTool({
|
|
|
344
415
|
}
|
|
345
416
|
});
|
|
346
417
|
//#endregion
|
|
347
|
-
export { setFont, setFontRange, setText, setTextProperties, setTextResize, textFonts };
|
|
418
|
+
export { setFont, setFontRange, setText, setTextProperties, setTextRangeStyle, setTextResize, textFonts };
|
|
348
419
|
|
|
349
420
|
//# sourceMappingURL=text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":[],"sources":["../../../src/tools/modify/text.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { DocumentColorSpace } from '@pairdraw/scene-graph'\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(\n 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 },\n profile: DocumentColorSpace\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, profile)\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, figma.graph.documentColorSpace)\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":";;;;;;;;;;AAwBA,MAAM,uBAAuB,EAAE,SAC7B,EAAE,KACA,EAAE,SAAS,EAAE,OAAO,CAAC,GACrB,EAAE,YACA,2OACF,CACF,CACF;;;;;AAMA,M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,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,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
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../../src/tools/modify/text.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { DocumentColorSpace } from '@pairdraw/scene-graph'\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'\nimport { textRangeError } from '#core/tools/text-range'\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(\n 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 },\n profile: DocumentColorSpace\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, profile)\n if ('error' in color) return color\n return { hyperlink: hyperlink ?? null, color: color.color }\n}\n\nconst rangeIndex = (description: string) =>\n toolNumber(v.pipe(v.number(), v.integer(), v.minValue(0), v.description(description)))\n\n/** A TEXT node for a range edit, or the error the tool returns when the id is not one. */\nfunction textNodeFor(figma: FigmaAPI, id: string): FigmaNodeProxy | { error: string } {\n const node = figma.getNodeById(id)\n if (!node) return nodeNotFound(id)\n if (node.type !== 'TEXT') return { error: `Node \"${id}\" is not a TEXT node` }\n return node\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: rangeIndex('Start character index, in UTF-16 code units'),\n end: rangeIndex('End character index, in UTF-16 code units'),\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 = textNodeFor(figma, args.id)\n if ('error' in node) return node\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, figma.graph.documentColorSpace)\n if ('error' in edit) return edit\n const rangeError = textRangeError(node.characters, start, end)\n if (rangeError) return { error: rangeError }\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 setTextRangeStyle = defineTool({\n name: 'set_text_range_style',\n\n description:\n \"Set line height, letter spacing, text case, or decoration for a character range. Indices are UTF-16 code units, as the editor's text ranges are.\",\n\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: nodeIdInputSchema,\n start: rangeIndex('Start index, in UTF-16 code units'),\n end: rangeIndex('End index, in UTF-16 code units'),\n line_height: v.optional(\n toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Line height in pixels')))\n ),\n letter_spacing: v.optional(\n toolNumber(v.pipe(v.number(), v.description('Letter spacing in pixels')))\n ),\n text_case: v.optional(\n v.pipe(\n v.picklist(['ORIGINAL', 'UPPER', 'LOWER', 'TITLE']),\n v.description('Letter case in the range')\n )\n ),\n text_decoration: v.optional(\n v.pipe(\n v.picklist(['NONE', 'UNDERLINE', 'STRIKETHROUGH']),\n v.description('Decoration in the range')\n )\n )\n }),\n fonts: (figma, { id }) => textFonts(figma, id),\n execute: (figma, args) => {\n const node = textNodeFor(figma, args.id)\n if ('error' in node) return node\n const updated: string[] = []\n if (args.line_height !== undefined) updated.push('lineHeight')\n if (args.letter_spacing !== undefined) updated.push('letterSpacing')\n if (args.text_case !== undefined) updated.push('textCase')\n if (args.text_decoration !== undefined) updated.push('textDecoration')\n if (updated.length === 0) {\n return {\n error:\n 'set_text_range_style needs at least one of line_height, letter_spacing, text_case, or text_decoration'\n }\n }\n const rangeError = textRangeError(node.characters, args.start, args.end)\n if (rangeError) return { error: rangeError }\n // The range setters reject a bad range, but the guard above names what went wrong.\n try {\n if (args.line_height !== undefined) {\n node.setRangeLineHeight(args.start, args.end, { unit: 'PIXELS', value: args.line_height })\n }\n if (args.letter_spacing !== undefined) {\n node.setRangeLetterSpacing(args.start, args.end, {\n unit: 'PIXELS',\n value: args.letter_spacing\n })\n }\n if (args.text_case !== undefined) {\n node.setRangeTextCase(args.start, args.end, args.text_case)\n }\n if (args.text_decoration !== undefined) {\n node.setRangeTextDecoration(args.start, args.end, args.text_decoration)\n }\n } catch (error) {\n return toolFailure(error)\n }\n return { id: args.id, range: { start: args.start, end: args.end }, updated }\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 = textNodeFor(figma, args.id)\n if ('error' in node) return 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":";;;;;;;;;;;AAyBA,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,aAAa,OAAO;CACtE,OAAO,C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|
|
|
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;
|
|
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;cAqBtB,YAAA"}
|
|
@@ -48,6 +48,12 @@ function overflowDirectionInput() {
|
|
|
48
48
|
function scrollBehaviorInput() {
|
|
49
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
50
|
}
|
|
51
|
+
/** Why this edit cannot run, before anything is written. */
|
|
52
|
+
function editRefusal(node, args) {
|
|
53
|
+
if (args.overflow_direction !== void 0) return scrollRefusal(node);
|
|
54
|
+
if (args.boolean_operation !== void 0 && node.type !== "BOOLEAN_OPERATION") return `Only a boolean operation has boolean_operation; ${node.type} "${node.name}" does not.`;
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
51
57
|
const updateNode = defineTool({
|
|
52
58
|
name: "update_node",
|
|
53
59
|
description: "Update properties of an existing node: position, size, opacity, corner radius, visibility, text, font, overflow scrolling.",
|
|
@@ -79,13 +85,19 @@ const updateNode = defineTool({
|
|
|
79
85
|
font_weight: v.optional(toolNumber(v.pipe(v.number(), v.minValue(100), v.maxValue(900), v.description("Font weight (100-900)")))),
|
|
80
86
|
name: v.optional(v.pipe(v.string(), v.description("Layer name"))),
|
|
81
87
|
overflow_direction: v.optional(overflowDirectionInput()),
|
|
82
|
-
scroll_behavior: v.optional(scrollBehaviorInput())
|
|
88
|
+
scroll_behavior: v.optional(scrollBehaviorInput()),
|
|
89
|
+
boolean_operation: v.optional(v.pipe(v.picklist([
|
|
90
|
+
"UNION",
|
|
91
|
+
"SUBTRACT",
|
|
92
|
+
"INTERSECT",
|
|
93
|
+
"EXCLUDE"
|
|
94
|
+
]), v.description("How a BOOLEAN_OPERATION combines its children")))
|
|
83
95
|
}),
|
|
84
96
|
execute: (figma, args) => {
|
|
85
97
|
const node = figma.getNodeById(args.id);
|
|
86
98
|
if (!node) return nodeNotFound(args.id);
|
|
87
99
|
assertNodeEditable(figma.graph, args.id);
|
|
88
|
-
const refusal =
|
|
100
|
+
const refusal = editRefusal(node, args);
|
|
89
101
|
if (refusal) return { error: refusal };
|
|
90
102
|
const editTypography = (changes) => {
|
|
91
103
|
const scene = figma.graph.getNode(args.id);
|
|
@@ -145,6 +157,10 @@ const updateNode = defineTool({
|
|
|
145
157
|
node.scrollBehavior = args.scroll_behavior;
|
|
146
158
|
updated.push("scrollBehavior");
|
|
147
159
|
}
|
|
160
|
+
if (args.boolean_operation !== void 0) {
|
|
161
|
+
node.booleanOperation = args.boolean_operation;
|
|
162
|
+
updated.push("booleanOperation");
|
|
163
|
+
}
|
|
148
164
|
return {
|
|
149
165
|
id: args.id,
|
|
150
166
|
updated
|
|
@@ -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 { 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;EAC7B,sBAAsB,KAAK;EAC3B,gBAAgB,KAAK;CACvB;AACF;;;;;AAMA,SAAS,QAAQ,MAAsB,QAAQ,KAAK,OAAO,SAAS,KAAK,QAAkB;CACzF,MAAM,SAAS,OAAO,IAAI;CAC1B,KAAK,OAAO,OAAO,MAAM;CACzB,MAAM,QAAQ,OAAO,IAAI;CACzB,MAAM,UAAU,MAAM,UAAU,OAAO,SAAS,MAAM,WAAW,OAAO,SAAS,CAAC,MAAM,IAAI,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AC;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"}
|
|
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\n/** Why this edit cannot run, before anything is written. */\nfunction editRefusal(\n node: FigmaNodeProxy,\n args: { overflow_direction?: string; boolean_operation?: string }\n): string | null {\n if (args.overflow_direction !== undefined) return scrollRefusal(node)\n if (args.boolean_operation !== undefined && node.type !== 'BOOLEAN_OPERATION')\n return `Only a boolean operation has boolean_operation; ${node.type} \"${node.name}\" does not.`\n return null\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 boolean_operation: v.optional(\n v.pipe(\n v.picklist(['UNION', 'SUBTRACT', 'INTERSECT', 'EXCLUDE']),\n v.description('How a BOOLEAN_OPERATION combines its children')\n )\n )\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 = editRefusal(node, args)\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 if (args.boolean_operation !== undefined) {\n node.booleanOperation = args.boolean_operation\n updated.push('booleanOperation')\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;EAC7B,sBAAsB,KAAK;EAC3B,gBAAgB,KAAK;CACvB;AACF;;;;;AAMA,SAAS,QAAQ,MAAsB,QAAQ,KAAK,OAAO,SAAS,KAAK,QAAkB;CACzF,MAAM,SAAS,OAAO,IAAI;CAC1B,KAAK,OAAO,OAAO,MAAM;CACzB,MAAM,QAAQ,OAAO,IAAI;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AM;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,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,IAAI,KAAK,sBAAsB,KAAA,GAAW;GACxC,KAAK,mBAAmB,KAAK;GAC7B,QAAQ,KAAK,kBAAkB;EACjC;EACA,OAAO;GAAE,IAAI,KAAK;GAAI;EAAQ;CAChC;AACF,CAAC"}
|
package/dist/tools/modify.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ import { replaceFonts } from "./modify/fonts.js";
|
|
|
3
3
|
import { rescale, setMinMax, setOpacity, setRadius, setRotation } from "./modify/geometry.js";
|
|
4
4
|
import { setConstraints, setLayout, setLayoutChild } from "./modify/layout.js";
|
|
5
5
|
import { replaceMatchingProperties } from "./modify/matching.js";
|
|
6
|
+
import { resetOverrideFields } from "./modify/overrides.js";
|
|
6
7
|
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
|
-
import { setFont, setFontRange, setText, setTextProperties, setTextResize } from "./modify/text.js";
|
|
10
|
+
import { setFont, setFontRange, setText, setTextProperties, setTextRangeStyle, setTextResize } from "./modify/text.js";
|
|
10
11
|
import { updateNode } from "./modify/update.js";
|
|
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 };
|
|
12
|
+
export { replaceFonts, replaceMatchingProperties, rescale, resetOverrideFields, setBlend, setConstraints, setEffects, setFill, setFont, setFontRange, setImageFill, setLayout, setLayoutChild, setLocked, setMinMax, setOpacity, setRadius, setReactions, setRotation, setStroke, setStrokeAlign, setText, setTextProperties, setTextRangeStyle, setTextResize, setVisible, updateNode };
|
package/dist/tools/modify.js
CHANGED
|
@@ -2,10 +2,11 @@ import { setEffects } from "./modify/effects.js";
|
|
|
2
2
|
import { replaceFonts } from "./modify/fonts.js";
|
|
3
3
|
import { rescale, setMinMax, setOpacity, setRadius, setRotation } from "./modify/geometry.js";
|
|
4
4
|
import { setConstraints, setLayout, setLayoutChild } from "./modify/layout.js";
|
|
5
|
-
import { setFont, setFontRange, setText, setTextProperties, setTextResize } from "./modify/text.js";
|
|
5
|
+
import { setFont, setFontRange, setText, setTextProperties, setTextRangeStyle, setTextResize } from "./modify/text.js";
|
|
6
6
|
import { replaceMatchingProperties } from "./modify/matching.js";
|
|
7
|
+
import { resetOverrideFields } from "./modify/overrides.js";
|
|
7
8
|
import { setFill, setImageFill, setStroke } from "./modify/paint.js";
|
|
8
9
|
import { setReactions } from "./modify/reactions.js";
|
|
9
10
|
import { setBlend, setLocked, setStrokeAlign, setVisible } from "./modify/state.js";
|
|
10
11
|
import { updateNode } from "./modify/update.js";
|
|
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 };
|
|
12
|
+
export { replaceFonts, replaceMatchingProperties, rescale, resetOverrideFields, setBlend, setConstraints, setEffects, setFill, setFont, setFontRange, setImageFill, setLayout, setLayoutChild, setLocked, setMinMax, setOpacity, setRadius, setReactions, setRotation, setStroke, setStrokeAlign, setText, setTextProperties, setTextRangeStyle, setTextResize, setVisible, updateNode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css.d.ts","names":[],"sources":["../../../src/tools/read/css.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"css.d.ts","names":[],"sources":["../../../src/tools/read/css.ts"],"mappings":";;;;;;;;cAea;cACA;cAoUA,QAAA"}
|
package/dist/tools/read/css.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineTool, nodeIdsField, toolNumber } from "../schema.js";
|
|
2
2
|
import { colorToDocumentCSS } from "@pairdraw/scene-graph/color";
|
|
3
3
|
import * as v from "valibot";
|
|
4
|
+
import { diamondFillToCSS, gradientFillToCSS } from "@pairdraw/dom-css/export";
|
|
4
5
|
//#region src/tools/read/css.ts
|
|
5
6
|
/**
|
|
6
7
|
* A subtree as CSS-shaped lines: one line per node, lengths in px, colours in the document's
|
|
@@ -66,37 +67,53 @@ function boundName(graph, node, field) {
|
|
|
66
67
|
}
|
|
67
68
|
/**
|
|
68
69
|
* A stored colour as the shorthand writes it: `#RRGGBB` in an sRGB document, `color(display-p3 …)`
|
|
69
|
-
* in a Display P3 one, where hex would name a different colour
|
|
70
|
-
*
|
|
70
|
+
* in a Display P3 one, where hex would name a different colour, and `rgba()` or `color(… / a)` when
|
|
71
|
+
* the paint is translucent. What paints is the colour's alpha times the paint's `opacity`, so both
|
|
72
|
+
* are folded into the shorthand; the setters store that product the same way.
|
|
71
73
|
*/
|
|
72
|
-
function cssColor(color, profile) {
|
|
74
|
+
function cssColor(color, opacity, profile) {
|
|
73
75
|
return colorToDocumentCSS({
|
|
74
76
|
...color,
|
|
75
|
-
a:
|
|
77
|
+
a: color.a * opacity
|
|
76
78
|
}, profile);
|
|
77
79
|
}
|
|
80
|
+
/** The first visible solid fill and its index, which a text colour or a background can name. */
|
|
81
|
+
function solidFill(node) {
|
|
82
|
+
const index = node.fills.findIndex((candidate) => candidate.type === "SOLID" && candidate.visible);
|
|
83
|
+
const fill = index === -1 ? void 0 : node.fills[index];
|
|
84
|
+
return fill?.type === "SOLID" ? {
|
|
85
|
+
index,
|
|
86
|
+
fill
|
|
87
|
+
} : null;
|
|
88
|
+
}
|
|
78
89
|
/** A colour in the document's profile, or `var(--token, …)` when a variable paints it. */
|
|
79
90
|
function paintOf(node, graph, field, paint) {
|
|
80
91
|
const name = boundName(graph, node, field);
|
|
81
92
|
return name ? `var(--${name}, ${paint})` : paint;
|
|
82
93
|
}
|
|
83
94
|
function background(node, graph) {
|
|
84
|
-
const
|
|
85
|
-
const solid = index === -1 ? void 0 : node.fills[index];
|
|
95
|
+
const solid = solidFill(node);
|
|
86
96
|
if (solid) {
|
|
87
|
-
const paint = cssColor(solid.color, graph.documentColorSpace);
|
|
88
|
-
return paintOf(node, graph, `fills/${index}/color`, paint);
|
|
97
|
+
const paint = cssColor(solid.fill.color, solid.fill.opacity, graph.documentColorSpace);
|
|
98
|
+
return paintOf(node, graph, `fills/${solid.index}/color`, paint);
|
|
89
99
|
}
|
|
90
100
|
const otherIndex = node.fills.findIndex((candidate) => candidate.visible);
|
|
91
101
|
const other = otherIndex === -1 ? void 0 : node.fills[otherIndex];
|
|
92
102
|
if (!other) return null;
|
|
93
|
-
|
|
103
|
+
switch (other.type) {
|
|
104
|
+
case "GRADIENT_DIAMOND": return diamondFillToCSS(other, graph.documentColorSpace) ?? "gradient";
|
|
105
|
+
case "GRADIENT_LINEAR":
|
|
106
|
+
case "GRADIENT_RADIAL":
|
|
107
|
+
case "GRADIENT_ANGULAR": return gradientFillToCSS(other, node.width, node.height, graph.documentColorSpace) ?? "gradient";
|
|
108
|
+
case "IMAGE": return `image(${other.imageScaleMode ?? "FILL"})`;
|
|
109
|
+
default: return "image";
|
|
110
|
+
}
|
|
94
111
|
}
|
|
95
112
|
function border(node, graph) {
|
|
96
113
|
const index = node.strokes.findIndex((candidate) => candidate.visible);
|
|
97
114
|
const stroke = index === -1 ? void 0 : node.strokes[index];
|
|
98
115
|
if (!stroke) return null;
|
|
99
|
-
const paint = cssColor(stroke.color, graph.documentColorSpace);
|
|
116
|
+
const paint = cssColor(stroke.color, stroke.opacity, graph.documentColorSpace);
|
|
100
117
|
return `${px(stroke.weight)} ${paintOf(node, graph, `strokes/${index}/color`, paint)}`;
|
|
101
118
|
}
|
|
102
119
|
/** Padding in CSS order, compressed to the fewest values that say the same thing. */
|
|
@@ -111,7 +128,7 @@ function padding(node) {
|
|
|
111
128
|
return `${px(top)} ${px(right)} ${px(bottom)} ${px(left)}`;
|
|
112
129
|
}
|
|
113
130
|
function shadowOf(prefix, effect, profile) {
|
|
114
|
-
return `${prefix}:${px(effect.offset.x)} ${px(effect.offset.y)} ${px(effect.radius)} ${cssColor(effect.color, profile)}`;
|
|
131
|
+
return `${prefix}:${px(effect.offset.x)} ${px(effect.offset.y)} ${px(effect.radius)} ${cssColor(effect.color, 1, profile)}`;
|
|
115
132
|
}
|
|
116
133
|
function effects(node, profile) {
|
|
117
134
|
const out = [];
|
|
@@ -166,7 +183,7 @@ function lineHeightOf(node) {
|
|
|
166
183
|
function textDecls(node, graph) {
|
|
167
184
|
const out = [`font:${node.fontWeight} ${px(node.fontSize)}/${lineHeightOf(node)} ${node.fontFamily}`];
|
|
168
185
|
const bg = background(node, graph);
|
|
169
|
-
if (bg) out.push(`color:${bg}`);
|
|
186
|
+
if (bg && solidFill(node)) out.push(`color:${bg}`);
|
|
170
187
|
if (node.textAlignHorizontal !== "LEFT") out.push(`text-align:${node.textAlignHorizontal.toLowerCase()}`);
|
|
171
188
|
if (node.maxLines !== null && node.maxLines > 0) out.push(`max-lines:${node.maxLines}`);
|
|
172
189
|
if (node.textAutoResize === "NONE") out.push("fixed");
|