@pairdraw/core 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/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/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 +29 -2
- 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 +61 -5
- 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/index.d.ts +2 -2
- package/dist/text/index.js +2 -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/index.ts +1 -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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PrototypeReaction, SceneGraph } from "@pairdraw/scene-graph";
|
|
1
|
+
import { PrototypeReaction, PrototypeVariableValue, SceneGraph } from "@pairdraw/scene-graph";
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
//#region src/figma-api/reactions.d.ts
|
|
4
4
|
declare const reactionSchema: v.StrictObjectSchema<{
|
|
@@ -25,7 +25,7 @@ declare const reactionSchema: v.StrictObjectSchema<{
|
|
|
25
25
|
readonly type: v.PicklistSchema<("INSTANT" | "DISSOLVE" | "SMART_ANIMATE")[], undefined>;
|
|
26
26
|
readonly duration: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
27
27
|
readonly easing: v.OptionalSchema<v.StrictObjectSchema<{
|
|
28
|
-
readonly type: v.PicklistSchema<readonly ["EASE_OUT", "EASE_IN", "EASE_IN_AND_OUT", "LINEAR"], undefined>;
|
|
28
|
+
readonly type: v.PicklistSchema<readonly ["EASE_OUT", "EASE_IN", "EASE_IN_AND_OUT", "LINEAR", "EASE_IN_BACK", "EASE_OUT_BACK", "EASE_IN_AND_OUT_BACK", "GENTLE", "QUICK", "BOUNCY", "SLOW", "CUSTOM_CUBIC_BEZIER", "CUSTOM_SPRING"], undefined>;
|
|
29
29
|
}, undefined>, undefined>;
|
|
30
30
|
}, undefined>, {
|
|
31
31
|
readonly type: "INSTANT";
|
|
@@ -36,6 +36,20 @@ declare const reactionSchema: v.StrictObjectSchema<{
|
|
|
36
36
|
readonly type: v.LiteralSchema<"BACK", undefined>;
|
|
37
37
|
}, undefined>, v.StrictObjectSchema<{
|
|
38
38
|
readonly type: v.LiteralSchema<"CLOSE", undefined>;
|
|
39
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
40
|
+
readonly type: v.LiteralSchema<"SET_VARIABLE", undefined>;
|
|
41
|
+
readonly variableId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
42
|
+
readonly variableValue: v.GenericSchema<PrototypeVariableValue>;
|
|
43
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
44
|
+
readonly type: v.LiteralSchema<"SET_VARIABLE_MODE", undefined>;
|
|
45
|
+
readonly variableCollectionId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
46
|
+
readonly variableModeId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
47
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
48
|
+
readonly type: v.LiteralSchema<"CONDITIONAL", undefined>;
|
|
49
|
+
readonly conditionalBlocks: v.ArraySchema<v.GenericSchema<{
|
|
50
|
+
condition?: PrototypeVariableValue;
|
|
51
|
+
actions: unknown[];
|
|
52
|
+
}>, undefined>;
|
|
39
53
|
}, undefined>], undefined>, undefined>, v.MinLengthAction<({
|
|
40
54
|
type: "NODE";
|
|
41
55
|
destinationId?: string | undefined;
|
|
@@ -47,7 +61,7 @@ declare const reactionSchema: v.StrictObjectSchema<{
|
|
|
47
61
|
type: "INSTANT" | "DISSOLVE" | "SMART_ANIMATE";
|
|
48
62
|
duration: number;
|
|
49
63
|
easing?: {
|
|
50
|
-
type: "EASE_OUT" | "EASE_IN" | "EASE_IN_AND_OUT" | "LINEAR";
|
|
64
|
+
type: "EASE_OUT" | "EASE_IN" | "EASE_IN_AND_OUT" | "LINEAR" | "EASE_IN_BACK" | "EASE_OUT_BACK" | "EASE_IN_AND_OUT_BACK" | "GENTLE" | "QUICK" | "BOUNCY" | "SLOW" | "CUSTOM_CUBIC_BEZIER" | "CUSTOM_SPRING";
|
|
51
65
|
} | undefined;
|
|
52
66
|
};
|
|
53
67
|
overlayRelativePosition: "CENTER" | "TOP_LEFT" | "TOP_CENTER" | "TOP_RIGHT" | "BOTTOM_LEFT" | "BOTTOM_CENTER" | "BOTTOM_RIGHT";
|
|
@@ -55,6 +69,20 @@ declare const reactionSchema: v.StrictObjectSchema<{
|
|
|
55
69
|
type: "BACK";
|
|
56
70
|
} | {
|
|
57
71
|
type: "CLOSE";
|
|
72
|
+
} | {
|
|
73
|
+
type: "SET_VARIABLE";
|
|
74
|
+
variableId?: string | undefined;
|
|
75
|
+
variableValue: PrototypeVariableValue;
|
|
76
|
+
} | {
|
|
77
|
+
type: "SET_VARIABLE_MODE";
|
|
78
|
+
variableCollectionId?: string | undefined;
|
|
79
|
+
variableModeId?: string | undefined;
|
|
80
|
+
} | {
|
|
81
|
+
type: "CONDITIONAL";
|
|
82
|
+
conditionalBlocks: {
|
|
83
|
+
condition?: PrototypeVariableValue;
|
|
84
|
+
actions: unknown[];
|
|
85
|
+
}[];
|
|
58
86
|
})[], 1, undefined>]>;
|
|
59
87
|
}, undefined>;
|
|
60
88
|
/** The plugin shape as a contract, for a tool that takes connections as arguments. */
|
|
@@ -82,7 +110,7 @@ declare const figmaReactionsSchema: v.ArraySchema<v.StrictObjectSchema<{
|
|
|
82
110
|
readonly type: v.PicklistSchema<("INSTANT" | "DISSOLVE" | "SMART_ANIMATE")[], undefined>;
|
|
83
111
|
readonly duration: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
84
112
|
readonly easing: v.OptionalSchema<v.StrictObjectSchema<{
|
|
85
|
-
readonly type: v.PicklistSchema<readonly ["EASE_OUT", "EASE_IN", "EASE_IN_AND_OUT", "LINEAR"], undefined>;
|
|
113
|
+
readonly type: v.PicklistSchema<readonly ["EASE_OUT", "EASE_IN", "EASE_IN_AND_OUT", "LINEAR", "EASE_IN_BACK", "EASE_OUT_BACK", "EASE_IN_AND_OUT_BACK", "GENTLE", "QUICK", "BOUNCY", "SLOW", "CUSTOM_CUBIC_BEZIER", "CUSTOM_SPRING"], undefined>;
|
|
86
114
|
}, undefined>, undefined>;
|
|
87
115
|
}, undefined>, {
|
|
88
116
|
readonly type: "INSTANT";
|
|
@@ -93,6 +121,20 @@ declare const figmaReactionsSchema: v.ArraySchema<v.StrictObjectSchema<{
|
|
|
93
121
|
readonly type: v.LiteralSchema<"BACK", undefined>;
|
|
94
122
|
}, undefined>, v.StrictObjectSchema<{
|
|
95
123
|
readonly type: v.LiteralSchema<"CLOSE", undefined>;
|
|
124
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
125
|
+
readonly type: v.LiteralSchema<"SET_VARIABLE", undefined>;
|
|
126
|
+
readonly variableId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
127
|
+
readonly variableValue: v.GenericSchema<PrototypeVariableValue>;
|
|
128
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
129
|
+
readonly type: v.LiteralSchema<"SET_VARIABLE_MODE", undefined>;
|
|
130
|
+
readonly variableCollectionId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
131
|
+
readonly variableModeId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
132
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
133
|
+
readonly type: v.LiteralSchema<"CONDITIONAL", undefined>;
|
|
134
|
+
readonly conditionalBlocks: v.ArraySchema<v.GenericSchema<{
|
|
135
|
+
condition?: PrototypeVariableValue;
|
|
136
|
+
actions: unknown[];
|
|
137
|
+
}>, undefined>;
|
|
96
138
|
}, undefined>], undefined>, undefined>, v.MinLengthAction<({
|
|
97
139
|
type: "NODE";
|
|
98
140
|
destinationId?: string | undefined;
|
|
@@ -104,7 +146,7 @@ declare const figmaReactionsSchema: v.ArraySchema<v.StrictObjectSchema<{
|
|
|
104
146
|
type: "INSTANT" | "DISSOLVE" | "SMART_ANIMATE";
|
|
105
147
|
duration: number;
|
|
106
148
|
easing?: {
|
|
107
|
-
type: "EASE_OUT" | "EASE_IN" | "EASE_IN_AND_OUT" | "LINEAR";
|
|
149
|
+
type: "EASE_OUT" | "EASE_IN" | "EASE_IN_AND_OUT" | "LINEAR" | "EASE_IN_BACK" | "EASE_OUT_BACK" | "EASE_IN_AND_OUT_BACK" | "GENTLE" | "QUICK" | "BOUNCY" | "SLOW" | "CUSTOM_CUBIC_BEZIER" | "CUSTOM_SPRING";
|
|
108
150
|
} | undefined;
|
|
109
151
|
};
|
|
110
152
|
overlayRelativePosition: "CENTER" | "TOP_LEFT" | "TOP_CENTER" | "TOP_RIGHT" | "BOTTOM_LEFT" | "BOTTOM_CENTER" | "BOTTOM_RIGHT";
|
|
@@ -112,6 +154,20 @@ declare const figmaReactionsSchema: v.ArraySchema<v.StrictObjectSchema<{
|
|
|
112
154
|
type: "BACK";
|
|
113
155
|
} | {
|
|
114
156
|
type: "CLOSE";
|
|
157
|
+
} | {
|
|
158
|
+
type: "SET_VARIABLE";
|
|
159
|
+
variableId?: string | undefined;
|
|
160
|
+
variableValue: PrototypeVariableValue;
|
|
161
|
+
} | {
|
|
162
|
+
type: "SET_VARIABLE_MODE";
|
|
163
|
+
variableCollectionId?: string | undefined;
|
|
164
|
+
variableModeId?: string | undefined;
|
|
165
|
+
} | {
|
|
166
|
+
type: "CONDITIONAL";
|
|
167
|
+
conditionalBlocks: {
|
|
168
|
+
condition?: PrototypeVariableValue;
|
|
169
|
+
actions: unknown[];
|
|
170
|
+
}[];
|
|
115
171
|
})[], 1, undefined>]>;
|
|
116
172
|
}, undefined>, undefined>;
|
|
117
173
|
/** A reaction as Figma's plugin API reads and writes it (`Reaction` in `@figma/plugin-typings`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions.d.ts","names":[],"sources":["../../src/figma-api/reactions.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"reactions.d.ts","names":[],"sources":["../../src/figma-api/reactions.ts"],"mappings":";;;cA0LM,gBAAc,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAxCN,YAAA;MACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MADG,YAAA;MACH;;;;;cA+CE,sBAAoB,EAAA,YAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAhDnB,YAAA;MACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MADG,YAAA;MACH;;;;;KAkDC,gBAAgB,EAAE,mBAAmB;KACrC,uBAAuB;KACvB,sBAAsB;;iBAGlB,gBAAgB,UAAU,oBAAoB;;UAwD7C;EACf,OAAO;;EAEP;;EAEA;;EAEA,oBAAoB;;;;;;EAMpB,qBAAqB;;;;;;;;iBASP,oBAAoB,gBAAgB,SAAS,kBAAkB"}
|
|
@@ -17,12 +17,7 @@ const UNSUPPORTED_TRIGGERS = {
|
|
|
17
17
|
ON_KEY_DOWN: true
|
|
18
18
|
};
|
|
19
19
|
/** Actions Figma's plugin API offers that a prototype in Pairdraw cannot run. */
|
|
20
|
-
const UNSUPPORTED_ACTIONS = {
|
|
21
|
-
URL: true,
|
|
22
|
-
SET_VARIABLE: true,
|
|
23
|
-
CONDITIONAL: true,
|
|
24
|
-
SET_VARIABLE_MODE: true
|
|
25
|
-
};
|
|
20
|
+
const UNSUPPORTED_ACTIONS = { URL: true };
|
|
26
21
|
const secondsSchema = v.pipe(v.number(), v.minValue(0));
|
|
27
22
|
const overlayPositionSchema = v.picklist([
|
|
28
23
|
"CENTER",
|
|
@@ -62,10 +57,85 @@ const nodeActionSchema = v.strictObject({
|
|
|
62
57
|
}),
|
|
63
58
|
overlayRelativePosition: v.optional(overlayPositionSchema, "CENTER")
|
|
64
59
|
});
|
|
60
|
+
const colorSchema = v.strictObject({
|
|
61
|
+
r: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),
|
|
62
|
+
g: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),
|
|
63
|
+
b: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),
|
|
64
|
+
a: v.optional(v.pipe(v.number(), v.minValue(0), v.maxValue(1)))
|
|
65
|
+
});
|
|
66
|
+
const expressionFunctionSchema = v.picklist([
|
|
67
|
+
"ADDITION",
|
|
68
|
+
"SUBTRACTION",
|
|
69
|
+
"RESOLVE_VARIANT",
|
|
70
|
+
"MULTIPLY",
|
|
71
|
+
"DIVIDE",
|
|
72
|
+
"EQUALS",
|
|
73
|
+
"NOT_EQUAL",
|
|
74
|
+
"LESS_THAN",
|
|
75
|
+
"LESS_THAN_OR_EQUAL",
|
|
76
|
+
"GREATER_THAN",
|
|
77
|
+
"GREATER_THAN_OR_EQUAL",
|
|
78
|
+
"AND",
|
|
79
|
+
"OR",
|
|
80
|
+
"NOT",
|
|
81
|
+
"STRINGIFY",
|
|
82
|
+
"TERNARY",
|
|
83
|
+
"VAR_MODE_LOOKUP",
|
|
84
|
+
"NEGATE",
|
|
85
|
+
"IS_TRUTHY",
|
|
86
|
+
"KEYFRAME",
|
|
87
|
+
"COMPOSE_COLOR"
|
|
88
|
+
]);
|
|
89
|
+
/** Figma's plugin `VariableData`: a literal, an alias, or an expression tree. */
|
|
90
|
+
const variableDataSchema = v.lazy(() => v.variant("kind", [
|
|
91
|
+
v.strictObject({
|
|
92
|
+
kind: v.literal("boolean"),
|
|
93
|
+
value: v.boolean()
|
|
94
|
+
}),
|
|
95
|
+
v.strictObject({
|
|
96
|
+
kind: v.literal("number"),
|
|
97
|
+
value: v.number()
|
|
98
|
+
}),
|
|
99
|
+
v.strictObject({
|
|
100
|
+
kind: v.literal("string"),
|
|
101
|
+
value: v.string()
|
|
102
|
+
}),
|
|
103
|
+
v.strictObject({
|
|
104
|
+
kind: v.literal("color"),
|
|
105
|
+
value: colorSchema
|
|
106
|
+
}),
|
|
107
|
+
v.strictObject({
|
|
108
|
+
kind: v.literal("alias"),
|
|
109
|
+
variableId: v.string()
|
|
110
|
+
}),
|
|
111
|
+
v.strictObject({
|
|
112
|
+
kind: v.literal("expression"),
|
|
113
|
+
fn: expressionFunctionSchema,
|
|
114
|
+
args: v.array(variableDataSchema)
|
|
115
|
+
})
|
|
116
|
+
]));
|
|
117
|
+
const conditionalBlockSchema = v.strictObject({
|
|
118
|
+
condition: v.optional(variableDataSchema),
|
|
119
|
+
actions: v.array(v.unknown())
|
|
120
|
+
});
|
|
65
121
|
const actionSchema = v.variant("type", [
|
|
66
122
|
nodeActionSchema,
|
|
67
123
|
v.strictObject({ type: v.literal("BACK") }),
|
|
68
|
-
v.strictObject({ type: v.literal("CLOSE") })
|
|
124
|
+
v.strictObject({ type: v.literal("CLOSE") }),
|
|
125
|
+
v.strictObject({
|
|
126
|
+
type: v.literal("SET_VARIABLE"),
|
|
127
|
+
variableId: v.optional(v.string()),
|
|
128
|
+
variableValue: variableDataSchema
|
|
129
|
+
}),
|
|
130
|
+
v.strictObject({
|
|
131
|
+
type: v.literal("SET_VARIABLE_MODE"),
|
|
132
|
+
variableCollectionId: v.optional(v.string()),
|
|
133
|
+
variableModeId: v.optional(v.string())
|
|
134
|
+
}),
|
|
135
|
+
v.strictObject({
|
|
136
|
+
type: v.literal("CONDITIONAL"),
|
|
137
|
+
conditionalBlocks: v.array(conditionalBlockSchema)
|
|
138
|
+
})
|
|
69
139
|
]);
|
|
70
140
|
const triggerSchema = v.variant("type", [
|
|
71
141
|
v.strictObject({ type: v.picklist([
|
|
@@ -109,6 +179,28 @@ function toFigmaTrigger({ type, delay }) {
|
|
|
109
179
|
return { type };
|
|
110
180
|
}
|
|
111
181
|
function toFigmaAction(action) {
|
|
182
|
+
if (action.type === "SET_VARIABLE") {
|
|
183
|
+
const set = {
|
|
184
|
+
type: "SET_VARIABLE",
|
|
185
|
+
variableValue: action.value
|
|
186
|
+
};
|
|
187
|
+
return action.variableId ? {
|
|
188
|
+
...set,
|
|
189
|
+
variableId: action.variableId
|
|
190
|
+
} : set;
|
|
191
|
+
}
|
|
192
|
+
if (action.type === "SET_VARIABLE_MODE") return {
|
|
193
|
+
type: "SET_VARIABLE_MODE",
|
|
194
|
+
variableCollectionId: action.collectionId ?? void 0,
|
|
195
|
+
variableModeId: action.modeId ?? void 0
|
|
196
|
+
};
|
|
197
|
+
if (action.type === "CONDITIONAL") return {
|
|
198
|
+
type: "CONDITIONAL",
|
|
199
|
+
conditionalBlocks: action.blocks.map((block) => ({
|
|
200
|
+
...block.condition ? { condition: block.condition } : {},
|
|
201
|
+
actions: block.actions.map(toFigmaAction)
|
|
202
|
+
}))
|
|
203
|
+
};
|
|
112
204
|
if (action.type !== "NODE") return { type: action.type };
|
|
113
205
|
return {
|
|
114
206
|
type: "NODE",
|
|
@@ -174,8 +266,36 @@ function toTrigger(trigger) {
|
|
|
174
266
|
delay: "delay" in trigger ? trigger.delay : 0
|
|
175
267
|
};
|
|
176
268
|
}
|
|
269
|
+
function parseNestedAction(nested, reactionIndex) {
|
|
270
|
+
if (!nested || typeof nested !== "object" || Array.isArray(nested)) throw failure(`reactions[${reactionIndex}] has a conditional action that is not an object`);
|
|
271
|
+
const result = v.safeParse(actionSchema, nested);
|
|
272
|
+
if (!result.success) {
|
|
273
|
+
const [issue] = result.issues;
|
|
274
|
+
const path = issuePath(issue.path);
|
|
275
|
+
throw failure(`reactions[${reactionIndex}] has a conditional action failing validation: ${issue.message}${path ? ` at ${path}` : ""}`);
|
|
276
|
+
}
|
|
277
|
+
return result.output;
|
|
278
|
+
}
|
|
177
279
|
function toAction(action, context, reactionIndex) {
|
|
178
|
-
if (action.type
|
|
280
|
+
if (action.type === "BACK") return { type: "BACK" };
|
|
281
|
+
if (action.type === "CLOSE") return { type: "CLOSE" };
|
|
282
|
+
if (action.type === "SET_VARIABLE") return {
|
|
283
|
+
type: "SET_VARIABLE",
|
|
284
|
+
variableId: action.variableId ?? null,
|
|
285
|
+
value: action.variableValue
|
|
286
|
+
};
|
|
287
|
+
if (action.type === "SET_VARIABLE_MODE") return {
|
|
288
|
+
type: "SET_VARIABLE_MODE",
|
|
289
|
+
collectionId: action.variableCollectionId ?? null,
|
|
290
|
+
modeId: action.variableModeId ?? null
|
|
291
|
+
};
|
|
292
|
+
if (action.type === "CONDITIONAL") return {
|
|
293
|
+
type: "CONDITIONAL",
|
|
294
|
+
blocks: action.conditionalBlocks.map((block) => ({
|
|
295
|
+
...block.condition ? { condition: block.condition } : {},
|
|
296
|
+
actions: block.actions.map((nested) => toAction(parseNestedAction(nested, reactionIndex), context, reactionIndex))
|
|
297
|
+
}))
|
|
298
|
+
};
|
|
179
299
|
const destinationId = resolveDestinationId(action, context, reactionIndex);
|
|
180
300
|
assertDestination({
|
|
181
301
|
...action,
|
|
@@ -260,6 +380,19 @@ function assertScrollTarget(destination, context, at) {
|
|
|
260
380
|
const top = topLevelOf(graph, nodeId, pageId);
|
|
261
381
|
if (!top || destination.id === top.id || !graph.isDescendant(destination.id, top.id)) throw failure(`${at} must Scroll to a layer inside the same top-level frame, not ${destination.type} "${destination.name}"`);
|
|
262
382
|
}
|
|
383
|
+
function unsupportedActionReason(action) {
|
|
384
|
+
if (!action || typeof action !== "object" || !("type" in action)) return null;
|
|
385
|
+
const { type } = action;
|
|
386
|
+
if (typeof type === "string" && type in UNSUPPORTED_ACTIONS) return `an action is NODE, BACK or CLOSE, not ${type}`;
|
|
387
|
+
if (type === "CONDITIONAL" && "conditionalBlocks" in action && Array.isArray(action.conditionalBlocks)) for (const block of action.conditionalBlocks) {
|
|
388
|
+
if (!block || typeof block !== "object" || !("actions" in block) || !Array.isArray(block.actions)) continue;
|
|
389
|
+
for (const nested of block.actions) {
|
|
390
|
+
const nestedReason = unsupportedActionReason(nested);
|
|
391
|
+
if (nestedReason) return nestedReason;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
263
396
|
/** Figma's first unsupported trigger or action kind in `value`, if it has one. */
|
|
264
397
|
function unsupportedKind(value) {
|
|
265
398
|
if (!Array.isArray(value)) return null;
|
|
@@ -272,9 +405,9 @@ function unsupportedKind(value) {
|
|
|
272
405
|
}
|
|
273
406
|
const actions = reaction.actions;
|
|
274
407
|
if (!Array.isArray(actions)) continue;
|
|
275
|
-
for (const action of actions)
|
|
276
|
-
const
|
|
277
|
-
if (
|
|
408
|
+
for (const action of actions) {
|
|
409
|
+
const reason = unsupportedActionReason(action);
|
|
410
|
+
if (reason) return reason;
|
|
278
411
|
}
|
|
279
412
|
}
|
|
280
413
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions.js","names":[],"sources":["../../src/figma-api/reactions.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { generateId } from '@pairdraw/scene-graph'\nimport type {\n PrototypeAction,\n PrototypeNavigationType,\n PrototypeOverlayPositionType,\n PrototypeReaction,\n PrototypeTransition,\n PrototypeTransitionType,\n PrototypeTriggerType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport { variantSetsAround } from '@pairdraw/scene-graph/components'\nimport { PROTOTYPE_EASINGS } from '@pairdraw/scene-graph/constants'\nimport { parseVariantName } from '@pairdraw/scene-graph/variant-name'\n\nimport { issuePath } from '#core/figma-api/effects'\nimport { asInstanceEdit, sameReaction } from '#core/prototype/reactions'\n\n/**\n * Triggers Figma's plugin API offers that a prototype in Pairdraw cannot start from, and the\n * message it gets instead.\n */\nconst UNSUPPORTED_TRIGGERS: Record<string, true> = {\n ON_DRAG: true,\n MOUSE_UP: true,\n MOUSE_DOWN: true,\n ON_KEY_DOWN: true\n}\n\n/** Actions Figma's plugin API offers that a prototype in Pairdraw cannot run. */\nconst UNSUPPORTED_ACTIONS: Record<string, true> = {\n URL: true,\n SET_VARIABLE: true,\n CONDITIONAL: true,\n SET_VARIABLE_MODE: true\n}\n\n// No `v.finite()` action: the MCP tool contract turns this schema into JSON Schema, which\n// has no notion of infinities, and JSON numbers are always finite anyway.\nconst secondsSchema = v.pipe(v.number(), v.minValue(0))\n\nconst overlayPositionSchema = v.picklist([\n 'CENTER',\n 'TOP_LEFT',\n 'TOP_CENTER',\n 'TOP_RIGHT',\n 'BOTTOM_LEFT',\n 'BOTTOM_CENTER',\n 'BOTTOM_RIGHT'\n] satisfies PrototypeOverlayPositionType[])\n\n/** Figma's easing presets, which play has; a spring or a custom curve is refused. */\nconst easingSchema = v.strictObject({ type: v.picklist(PROTOTYPE_EASINGS) })\n\nconst transitionSchema = v.strictObject({\n type: v.picklist(['INSTANT', 'DISSOLVE', 'SMART_ANIMATE'] satisfies PrototypeTransitionType[]),\n duration: secondsSchema,\n easing: v.optional(easingSchema)\n})\n\n/** A variant's values for its set's properties, as `{ State: 'Hover', Size: 'Large' }`. */\nconst variantPropertiesSchema = v.pipe(\n v.record(v.string(), v.string()),\n v.minEntries(1),\n v.description(\n \"CHANGE_TO: the values of the variant to change to, in the layer's nearest component set, \" +\n 'such as { State: \"Hover\" }. Name every property of a set whose variants share values, as ' +\n 'a partial match is refused. Resolved to the variant, so get_reactions reads it back as ' +\n 'a destinationId.'\n )\n)\n\nconst nodeActionSchema = v.strictObject({\n type: v.literal('NODE'),\n destinationId: v.optional(\n v.pipe(\n v.string(),\n v.minLength(1),\n v.description(\n 'NAVIGATE/OVERLAY: a top-level frame on the page; CHANGE_TO: a variant of the set the ' +\n \"layer is a variant of, an instance of, or inside; SCROLL_TO: a layer in the layer's \" +\n 'top-level frame. Omit only for CHANGE_TO, and name the variant with variantProperties.'\n )\n )\n ),\n variantProperties: v.optional(variantPropertiesSchema),\n navigation: v.picklist([\n 'NAVIGATE',\n 'OVERLAY',\n 'CHANGE_TO',\n 'SCROLL_TO'\n ] satisfies PrototypeNavigationType[]),\n transition: v.optional(transitionSchema, { type: 'INSTANT', duration: 0 }),\n overlayRelativePosition: v.optional(overlayPositionSchema, 'CENTER')\n})\n\nconst actionSchema = v.variant('type', [\n nodeActionSchema,\n v.strictObject({ type: v.literal('BACK') }),\n v.strictObject({ type: v.literal('CLOSE') })\n])\n\nconst triggerSchema = v.variant('type', [\n v.strictObject({ type: v.picklist(['ON_CLICK', 'ON_HOVER', 'ON_PRESS']) }),\n v.strictObject({ type: v.literal('AFTER_TIMEOUT'), timeout: secondsSchema }),\n v.strictObject({\n type: v.picklist(['MOUSE_ENTER', 'MOUSE_LEAVE']),\n delay: v.optional(secondsSchema, 0),\n // Figma's plugin API reads it; play treats both versions alike.\n deprecatedVersion: v.optional(v.boolean())\n })\n])\n\nconst reactionSchema = v.strictObject({\n trigger: triggerSchema,\n actions: v.pipe(v.array(actionSchema), v.minLength(1))\n})\n\nconst reactionsSchema = v.array(reactionSchema)\n\n/** The plugin shape as a contract, for a tool that takes connections as arguments. */\nexport const figmaReactionsSchema = reactionsSchema\n\n/** A reaction as Figma's plugin API reads and writes it (`Reaction` in `@figma/plugin-typings`). */\nexport type FigmaReaction = v.InferOutput<typeof reactionSchema>\nexport type FigmaReactionTrigger = FigmaReaction['trigger']\nexport type FigmaReactionAction = FigmaReaction['actions'][number]\n\n/** `reaction` in the plugin shape: the trigger and every action, named as Figma names them. */\nexport function toFigmaReaction(reaction: PrototypeReaction): FigmaReaction {\n return { trigger: toFigmaTrigger(reaction.trigger), actions: reaction.actions.map(toFigmaAction) }\n}\n\nfunction toFigmaTrigger({ type, delay }: PrototypeReaction['trigger']): FigmaReactionTrigger {\n if (type === 'AFTER_TIMEOUT') return { type, timeout: delay }\n if (type === 'MOUSE_ENTER' || type === 'MOUSE_LEAVE') return { type, delay }\n return { type }\n}\n\nfunction toFigmaAction(action: PrototypeAction): FigmaReactionAction {\n if (action.type !== 'NODE') return { type: action.type }\n return {\n type: 'NODE',\n destinationId: action.nodeId ?? '',\n navigation: action.navigation,\n transition: toFigmaTransition(action.transition),\n overlayRelativePosition: action.overlayPosition\n }\n}\n\nfunction toFigmaTransition({\n type,\n duration,\n easing\n}: PrototypeTransition): v.InferOutput<typeof transitionSchema> {\n return easing ? { type, duration, easing: { type: easing } } : { type, duration }\n}\n\nfunction fromFigmaTransition({\n type,\n duration,\n easing\n}: v.InferOutput<typeof transitionSchema>): PrototypeTransition {\n return easing ? { type, duration, easing: easing.type } : { type, duration }\n}\n\n/** The validation context: where the reactions live, and what they may point at. */\nexport interface ReactionContext {\n graph: SceneGraph\n /** The layer the reactions are on, which a Change to or Scroll to destination must suit. */\n nodeId: string\n /** The page the layer is on; a navigation's destination must be a top-level frame on it. */\n pageId: string\n /** The reactions the layer has now, whose ids this keeps by position. */\n previous?: readonly PrototypeReaction[]\n /**\n * An instance's main component's reactions: a reaction kept under one of their ids that an\n * edit changed, from what the layer held at its place and from the main's, becomes the\n * instance's own, with an id of its own.\n */\n inherited?: readonly PrototypeReaction[]\n}\n\n/**\n * `value` as the layer's prototype reactions, or an error naming what Pairdraw cannot play.\n * Accepts Figma's plugin shape only: a trigger Figma offers but playback does not start from,\n * an action, transition, navigation or overlay spot outside the model, and a destination that\n * is not a top-level frame on the layer's page are refused rather than kept unplayable.\n */\nexport function parseFigmaReactions(value: unknown, context: ReactionContext): PrototypeReaction[] {\n const unsupported = unsupportedKind(value)\n if (unsupported) throw new Error(`Property \"reactions\" failed validation: ${unsupported}`)\n const result = v.safeParse(reactionsSchema, value)\n if (!result.success) {\n const [issue] = result.issues\n throw new Error(\n `Property \"reactions\" failed validation: ${issue.message} at ${issuePath(issue.path) || 'reactions'}`\n )\n }\n return result.output.map((reaction, index) => {\n const id = context.previous?.[index]?.id ?? generateId()\n const parsed: PrototypeReaction = {\n id,\n trigger: toTrigger(reaction.trigger),\n actions: reaction.actions.map((action) => toAction(action, context, index))\n }\n // One the layer already held unchanged stays as it was, a copy of the main's included, so\n // writing reactions back as read never re-ids a copy whose main was edited since.\n const held = context.previous?.[index]\n if (held && sameReaction(held, parsed)) return parsed\n return asInstanceEdit(parsed, context.inherited ?? [])\n })\n}\n\nfunction toTrigger(trigger: FigmaReactionTrigger): PrototypeReaction['trigger'] {\n const type: PrototypeTriggerType = trigger.type\n if (trigger.type === 'AFTER_TIMEOUT') return { type, delay: trigger.timeout }\n return { type, delay: 'delay' in trigger ? trigger.delay : 0 }\n}\n\nfunction toAction(\n action: FigmaReactionAction,\n context: ReactionContext,\n reactionIndex: number\n): PrototypeAction {\n if (action.type !== 'NODE') return { type: action.type }\n const destinationId = resolveDestinationId(action, context, reactionIndex)\n assertDestination({ ...action, destinationId }, context, reactionIndex)\n return {\n type: 'NODE',\n nodeId: destinationId,\n navigation: action.navigation,\n transition: fromFigmaTransition(action.transition),\n // Only an overlay uses the spot; Figma keeps CENTER on a navigation.\n overlayPosition: action.navigation === 'OVERLAY' ? action.overlayRelativePosition : 'CENTER'\n }\n}\n\n/**\n * The layer a NODE action points at: its `destinationId`, or for a Change to, the variant of the\n * layer's set whose `variantProperties` it names.\n */\nfunction resolveDestinationId(\n action: v.InferOutput<typeof nodeActionSchema>,\n context: ReactionContext,\n index: number\n): string {\n const at = `reactions[${index}]`\n const { destinationId, variantProperties, navigation } = action\n if (destinationId && variantProperties) {\n throw failure(`${at} names both destinationId and variantProperties; give one`)\n }\n if (variantProperties) {\n if (navigation !== 'CHANGE_TO') {\n throw failure(`${at}: variantProperties is for CHANGE_TO only, not ${navigation}`)\n }\n return variantByProperties(variantProperties, context, at)\n }\n if (!destinationId) {\n throw failure(\n navigation === 'CHANGE_TO'\n ? `${at} must name the variant it Changes to, in destinationId or variantProperties`\n : `${at} must name the layer it goes to, in destinationId`\n )\n }\n return destinationId\n}\n\n/** The id of the variant of the sets around the layer whose properties are `properties`. */\nfunction variantByProperties(\n properties: Record<string, string>,\n context: ReactionContext,\n at: string\n): string {\n const sets = variantSetsAround(context.graph, context.nodeId)\n const nearest = sets.at(0)\n if (!nearest) {\n throw failure(\n `${at}: only a variant, an instance of one, or a layer inside one can Change to another variant`\n )\n }\n const wanted = Object.entries(properties)\n .map(([name, value]) => `${name}=${value}`)\n .join(', ')\n for (const set of sets) {\n const matches = context.graph.getChildren(set.id).filter((child) => {\n if (child.type !== 'COMPONENT') return false\n const values = { ...parseVariantName(child.name), ...child.componentPropertyValues }\n return Object.entries(properties).every(([name, value]) => values[name] === value)\n })\n if (matches.length === 1) return matches[0].id\n // A set can hold variants a partial map matches equally: refuse rather than pick one.\n if (matches.length > 1) {\n const names = matches.map((match) => `\"${match.name}\"`).join(', ')\n throw failure(\n `${at}: ${wanted} matches ${matches.length} variants of ${set.name} (${names}); name every property of the variant`\n )\n }\n }\n throw failure(`${at}: no variant of ${nearest.name} with ${wanted}`)\n}\n\nfunction failure(message: string): Error {\n return new Error(`Property \"reactions\" failed validation: ${message}`)\n}\n\n/**\n * A destination play can show: a navigation's is a frame at the top of the layer's page, a Change\n * to's a variant of a set the layer belongs to, and a Scroll to's a layer in the layer's\n * top-level frame.\n */\nfunction assertDestination(\n action: Pick<v.InferOutput<typeof nodeActionSchema>, 'navigation'> & { destinationId: string },\n context: ReactionContext,\n index: number\n): void {\n const { destinationId, navigation } = action\n const destination = context.graph.getNode(destinationId)\n const at = `reactions[${index}]`\n if (!destination) throw failure(`no layer ${destinationId} at ${at}.actions[0].destinationId`)\n if (navigation === 'CHANGE_TO') return assertVariant(destination, context, at)\n if (navigation === 'SCROLL_TO') return assertScrollTarget(destination, context, at)\n if (destination.type !== 'FRAME' || destination.parentId !== context.pageId) {\n throw failure(\n `${at} must navigate to a top-level frame on the same page, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\nfunction assertVariant(destination: SceneNode, context: ReactionContext, at: string): void {\n const sets = variantSetsAround(context.graph, context.nodeId)\n const nearest = sets.at(0)\n if (!nearest) {\n throw failure(\n `${at}: only a variant, an instance of one, or a layer inside one can Change to another variant`\n )\n }\n const inSet = sets.some((set) => set.id === destination.parentId)\n if (destination.type !== 'COMPONENT' || !inSet) {\n throw failure(\n `${at} must Change to a variant of ${nearest.name}, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\n/** The page's direct child a layer sits in, which play shows as one screen. */\nfunction topLevelOf(graph: SceneGraph, nodeId: string, pageId: string): SceneNode | undefined {\n return graph.closest(nodeId, (node) => node.parentId === pageId)\n}\n\nfunction assertScrollTarget(destination: SceneNode, context: ReactionContext, at: string): void {\n const { graph, nodeId, pageId } = context\n const top = topLevelOf(graph, nodeId, pageId)\n if (!top || destination.id === top.id || !graph.isDescendant(destination.id, top.id)) {\n throw failure(\n `${at} must Scroll to a layer inside the same top-level frame, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\n/** Figma's first unsupported trigger or action kind in `value`, if it has one. */\nfunction unsupportedKind(value: unknown): string | null {\n if (!Array.isArray(value)) return null\n const reactions = value.filter(\n (reaction): reaction is Record<string, unknown> =>\n Boolean(reaction) && typeof reaction === 'object'\n )\n for (const reaction of reactions) {\n const trigger = reaction.trigger\n if (trigger && typeof trigger === 'object' && 'type' in trigger) {\n const type = trigger.type\n if (typeof type === 'string' && type in UNSUPPORTED_TRIGGERS) {\n return `a prototype starts from ON_CLICK, ON_HOVER, ON_PRESS, MOUSE_ENTER, MOUSE_LEAVE or AFTER_TIMEOUT, not ${type}`\n }\n }\n const actions = reaction.actions\n if (!Array.isArray(actions)) continue\n for (const action of actions) {\n if (action && typeof action === 'object' && 'type' in action) {\n const type = action.type\n if (typeof type === 'string' && type in UNSUPPORTED_ACTIONS) {\n return `an action is NODE, BACK or CLOSE, not ${type}`\n }\n }\n }\n }\n return null\n}\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,uBAA6C;CACjD,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;AACf;;AAGA,MAAM,sBAA4C;CAChD,KAAK;CACL,cAAc;CACd,aAAa;CACb,mBAAmB;AACrB;AAIA,MAAM,gBAAgB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC;AAEtD,MAAM,wBAAwB,EAAE,SAAS;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAA0C;;AAG1C,MAAM,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;AAE3E,MAAM,mBAAmB,EAAE,aAAa;CACtC,MAAM,EAAE,SAAS;EAAC;EAAW;EAAY;CAAe,CAAqC;CAC7F,UAAU;CACV,QAAQ,EAAE,SAAS,YAAY;AACjC,CAAC;;AAGD,MAAM,0BAA0B,EAAE,KAChC,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,GAC/B,EAAE,WAAW,CAAC,GACd,EAAE,YACA,6RAIF,CACF;AAEA,MAAM,mBAAmB,EAAE,aAAa;CACt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SAAS;EACzB,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;EAC7B,KAAK,MAAM,UAAU,SACnB,IAAI,UAAU,OAAO,WAAW,YAAY,UAAU,QAAQ;GAC5D,MAAM,OAAO,OAAO;GACpB,IAAI,OAAO,SAAS,YAAY,QAAQ,qBACtC,OAAO,yCAAyC;EAEpD;CAEJ;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"reactions.js","names":[],"sources":["../../src/figma-api/reactions.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { generateId } from '@pairdraw/scene-graph'\nimport type {\n PrototypeAction,\n PrototypeExpressionFunction,\n PrototypeVariableValue,\n PrototypeNavigationType,\n PrototypeOverlayPositionType,\n PrototypeReaction,\n PrototypeTransition,\n PrototypeTransitionType,\n PrototypeTriggerType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport { variantSetsAround } from '@pairdraw/scene-graph/components'\nimport { PROTOTYPE_EASINGS } from '@pairdraw/scene-graph/constants'\nimport { parseVariantName } from '@pairdraw/scene-graph/variant-name'\n\nimport { issuePath } from '#core/figma-api/effects'\nimport { asInstanceEdit, sameReaction } from '#core/prototype/reactions'\n\n/**\n * Triggers Figma's plugin API offers that a prototype in Pairdraw cannot start from, and the\n * message it gets instead.\n */\nconst UNSUPPORTED_TRIGGERS: Record<string, true> = {\n ON_DRAG: true,\n MOUSE_UP: true,\n MOUSE_DOWN: true,\n ON_KEY_DOWN: true\n}\n\n/** Actions Figma's plugin API offers that a prototype in Pairdraw cannot run. */\nconst UNSUPPORTED_ACTIONS: Record<string, true> = {\n URL: true\n}\n\n// No `v.finite()` action: the MCP tool contract turns this schema into JSON Schema, which\n// has no notion of infinities, and JSON numbers are always finite anyway.\nconst secondsSchema = v.pipe(v.number(), v.minValue(0))\n\nconst overlayPositionSchema = v.picklist([\n 'CENTER',\n 'TOP_LEFT',\n 'TOP_CENTER',\n 'TOP_RIGHT',\n 'BOTTOM_LEFT',\n 'BOTTOM_CENTER',\n 'BOTTOM_RIGHT'\n] satisfies PrototypeOverlayPositionType[])\n\n/** Figma's easing presets, which play has; a spring or a custom curve is refused. */\nconst easingSchema = v.strictObject({ type: v.picklist(PROTOTYPE_EASINGS) })\n\nconst transitionSchema = v.strictObject({\n type: v.picklist(['INSTANT', 'DISSOLVE', 'SMART_ANIMATE'] satisfies PrototypeTransitionType[]),\n duration: secondsSchema,\n easing: v.optional(easingSchema)\n})\n\n/** A variant's values for its set's properties, as `{ State: 'Hover', Size: 'Large' }`. */\nconst variantPropertiesSchema = v.pipe(\n v.record(v.string(), v.string()),\n v.minEntries(1),\n v.description(\n \"CHANGE_TO: the values of the variant to change to, in the layer's nearest component set, \" +\n 'such as { State: \"Hover\" }. Name every property of a set whose variants share values, as ' +\n 'a partial match is refused. Resolved to the variant, so get_reactions reads it back as ' +\n 'a destinationId.'\n )\n)\n\nconst nodeActionSchema = v.strictObject({\n type: v.literal('NODE'),\n destinationId: v.optional(\n v.pipe(\n v.string(),\n v.minLength(1),\n v.description(\n 'NAVIGATE/OVERLAY: a top-level frame on the page; CHANGE_TO: a variant of the set the ' +\n \"layer is a variant of, an instance of, or inside; SCROLL_TO: a layer in the layer's \" +\n 'top-level frame. Omit only for CHANGE_TO, and name the variant with variantProperties.'\n )\n )\n ),\n variantProperties: v.optional(variantPropertiesSchema),\n navigation: v.picklist([\n 'NAVIGATE',\n 'OVERLAY',\n 'CHANGE_TO',\n 'SCROLL_TO'\n ] satisfies PrototypeNavigationType[]),\n transition: v.optional(transitionSchema, { type: 'INSTANT', duration: 0 }),\n overlayRelativePosition: v.optional(overlayPositionSchema, 'CENTER')\n})\n\nconst colorSchema = v.strictObject({\n r: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),\n g: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),\n b: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),\n a: v.optional(v.pipe(v.number(), v.minValue(0), v.maxValue(1)))\n})\n\nconst expressionFunctionSchema = v.picklist([\n 'ADDITION',\n 'SUBTRACTION',\n 'RESOLVE_VARIANT',\n 'MULTIPLY',\n 'DIVIDE',\n 'EQUALS',\n 'NOT_EQUAL',\n 'LESS_THAN',\n 'LESS_THAN_OR_EQUAL',\n 'GREATER_THAN',\n 'GREATER_THAN_OR_EQUAL',\n 'AND',\n 'OR',\n 'NOT',\n 'STRINGIFY',\n 'TERNARY',\n 'VAR_MODE_LOOKUP',\n 'NEGATE',\n 'IS_TRUTHY',\n 'KEYFRAME',\n 'COMPOSE_COLOR'\n] satisfies PrototypeExpressionFunction[])\n\n/** Figma's plugin `VariableData`: a literal, an alias, or an expression tree. */\nconst variableDataSchema: v.GenericSchema<PrototypeVariableValue> = v.lazy(() =>\n v.variant('kind', [\n v.strictObject({ kind: v.literal('boolean'), value: v.boolean() }),\n v.strictObject({ kind: v.literal('number'), value: v.number() }),\n v.strictObject({ kind: v.literal('string'), value: v.string() }),\n v.strictObject({ kind: v.literal('color'), value: colorSchema }),\n v.strictObject({ kind: v.literal('alias'), variableId: v.string() }),\n v.strictObject({\n kind: v.literal('expression'),\n fn: expressionFunctionSchema,\n args: v.array(variableDataSchema)\n })\n ])\n) as v.GenericSchema<PrototypeVariableValue>\n\nconst conditionalBlockSchema: v.GenericSchema<{\n condition?: PrototypeVariableValue\n actions: unknown[]\n}> = v.strictObject({\n condition: v.optional(variableDataSchema),\n // Nested actions are validated when the model is written; the schema keeps the tree open to\n // avoid a recursive type that TypeScript cannot name.\n actions: v.array(v.unknown())\n})\n\nconst actionSchema = v.variant('type', [\n nodeActionSchema,\n v.strictObject({ type: v.literal('BACK') }),\n v.strictObject({ type: v.literal('CLOSE') }),\n v.strictObject({\n type: v.literal('SET_VARIABLE'),\n variableId: v.optional(v.string()),\n variableValue: variableDataSchema\n }),\n v.strictObject({\n type: v.literal('SET_VARIABLE_MODE'),\n variableCollectionId: v.optional(v.string()),\n variableModeId: v.optional(v.string())\n }),\n v.strictObject({\n type: v.literal('CONDITIONAL'),\n conditionalBlocks: v.array(conditionalBlockSchema)\n })\n])\n\nconst triggerSchema = v.variant('type', [\n v.strictObject({ type: v.picklist(['ON_CLICK', 'ON_HOVER', 'ON_PRESS']) }),\n v.strictObject({ type: v.literal('AFTER_TIMEOUT'), timeout: secondsSchema }),\n v.strictObject({\n type: v.picklist(['MOUSE_ENTER', 'MOUSE_LEAVE']),\n delay: v.optional(secondsSchema, 0),\n // Figma's plugin API reads it; play treats both versions alike.\n deprecatedVersion: v.optional(v.boolean())\n })\n])\n\nconst reactionSchema = v.strictObject({\n trigger: triggerSchema,\n actions: v.pipe(v.array(actionSchema), v.minLength(1))\n})\n\nconst reactionsSchema = v.array(reactionSchema)\n\n/** The plugin shape as a contract, for a tool that takes connections as arguments. */\nexport const figmaReactionsSchema = reactionsSchema\n\n/** A reaction as Figma's plugin API reads and writes it (`Reaction` in `@figma/plugin-typings`). */\nexport type FigmaReaction = v.InferOutput<typeof reactionSchema>\nexport type FigmaReactionTrigger = FigmaReaction['trigger']\nexport type FigmaReactionAction = FigmaReaction['actions'][number]\n\n/** `reaction` in the plugin shape: the trigger and every action, named as Figma names them. */\nexport function toFigmaReaction(reaction: PrototypeReaction): FigmaReaction {\n return { trigger: toFigmaTrigger(reaction.trigger), actions: reaction.actions.map(toFigmaAction) }\n}\n\nfunction toFigmaTrigger({ type, delay }: PrototypeReaction['trigger']): FigmaReactionTrigger {\n if (type === 'AFTER_TIMEOUT') return { type, timeout: delay }\n if (type === 'MOUSE_ENTER' || type === 'MOUSE_LEAVE') return { type, delay }\n return { type }\n}\n\nfunction toFigmaAction(action: PrototypeAction): FigmaReactionAction {\n if (action.type === 'SET_VARIABLE') {\n const set = { type: 'SET_VARIABLE' as const, variableValue: action.value }\n return action.variableId ? { ...set, variableId: action.variableId } : set\n }\n if (action.type === 'SET_VARIABLE_MODE')\n return {\n type: 'SET_VARIABLE_MODE',\n variableCollectionId: action.collectionId ?? undefined,\n variableModeId: action.modeId ?? undefined\n }\n if (action.type === 'CONDITIONAL')\n return {\n type: 'CONDITIONAL',\n conditionalBlocks: action.blocks.map((block) => ({\n ...(block.condition ? { condition: block.condition } : {}),\n actions: block.actions.map(toFigmaAction)\n }))\n }\n if (action.type !== 'NODE') return { type: action.type }\n return {\n type: 'NODE',\n destinationId: action.nodeId ?? '',\n navigation: action.navigation,\n transition: toFigmaTransition(action.transition),\n overlayRelativePosition: action.overlayPosition\n }\n}\n\nfunction toFigmaTransition({\n type,\n duration,\n easing\n}: PrototypeTransition): v.InferOutput<typeof transitionSchema> {\n return easing ? { type, duration, easing: { type: easing } } : { type, duration }\n}\n\nfunction fromFigmaTransition({\n type,\n duration,\n easing\n}: v.InferOutput<typeof transitionSchema>): PrototypeTransition {\n return easing ? { type, duration, easing: easing.type } : { type, duration }\n}\n\n/** The validation context: where the reactions live, and what they may point at. */\nexport interface ReactionContext {\n graph: SceneGraph\n /** The layer the reactions are on, which a Change to or Scroll to destination must suit. */\n nodeId: string\n /** The page the layer is on; a navigation's destination must be a top-level frame on it. */\n pageId: string\n /** The reactions the layer has now, whose ids this keeps by position. */\n previous?: readonly PrototypeReaction[]\n /**\n * An instance's main component's reactions: a reaction kept under one of their ids that an\n * edit changed, from what the layer held at its place and from the main's, becomes the\n * instance's own, with an id of its own.\n */\n inherited?: readonly PrototypeReaction[]\n}\n\n/**\n * `value` as the layer's prototype reactions, or an error naming what Pairdraw cannot play.\n * Accepts Figma's plugin shape only: a trigger Figma offers but playback does not start from,\n * an action, transition, navigation or overlay spot outside the model, and a destination that\n * is not a top-level frame on the layer's page are refused rather than kept unplayable.\n */\nexport function parseFigmaReactions(value: unknown, context: ReactionContext): PrototypeReaction[] {\n const unsupported = unsupportedKind(value)\n if (unsupported) throw new Error(`Property \"reactions\" failed validation: ${unsupported}`)\n const result = v.safeParse(reactionsSchema, value)\n if (!result.success) {\n const [issue] = result.issues\n throw new Error(\n `Property \"reactions\" failed validation: ${issue.message} at ${issuePath(issue.path) || 'reactions'}`\n )\n }\n return result.output.map((reaction, index) => {\n const id = context.previous?.[index]?.id ?? generateId()\n const parsed: PrototypeReaction = {\n id,\n trigger: toTrigger(reaction.trigger),\n actions: reaction.actions.map((action) => toAction(action, context, index))\n }\n // One the layer already held unchanged stays as it was, a copy of the main's included, so\n // writing reactions back as read never re-ids a copy whose main was edited since.\n const held = context.previous?.[index]\n if (held && sameReaction(held, parsed)) return parsed\n return asInstanceEdit(parsed, context.inherited ?? [])\n })\n}\n\nfunction toTrigger(trigger: FigmaReactionTrigger): PrototypeReaction['trigger'] {\n const type: PrototypeTriggerType = trigger.type\n if (trigger.type === 'AFTER_TIMEOUT') return { type, delay: trigger.timeout }\n return { type, delay: 'delay' in trigger ? trigger.delay : 0 }\n}\n\nfunction parseNestedAction(nested: unknown, reactionIndex: number): FigmaReactionAction {\n if (!nested || typeof nested !== 'object' || Array.isArray(nested)) {\n throw failure(`reactions[${reactionIndex}] has a conditional action that is not an object`)\n }\n const result = v.safeParse(actionSchema, nested)\n if (!result.success) {\n const [issue] = result.issues\n const path = issuePath(issue.path)\n throw failure(\n `reactions[${reactionIndex}] has a conditional action failing validation: ${issue.message}${path ? ` at ${path}` : ''}`\n )\n }\n return result.output\n}\n\nfunction toAction(\n action: FigmaReactionAction,\n context: ReactionContext,\n reactionIndex: number\n): PrototypeAction {\n if (action.type === 'BACK') return { type: 'BACK' }\n if (action.type === 'CLOSE') return { type: 'CLOSE' }\n if (action.type === 'SET_VARIABLE')\n return {\n type: 'SET_VARIABLE',\n variableId: action.variableId ?? null,\n value: action.variableValue\n }\n if (action.type === 'SET_VARIABLE_MODE')\n return {\n type: 'SET_VARIABLE_MODE',\n collectionId: action.variableCollectionId ?? null,\n modeId: action.variableModeId ?? null\n }\n if (action.type === 'CONDITIONAL')\n return {\n type: 'CONDITIONAL',\n blocks: action.conditionalBlocks.map((block) => ({\n ...(block.condition ? { condition: block.condition } : {}),\n actions: block.actions.map((nested) =>\n // The schema keeps nested actions open to a tree, so each nested object is parsed here.\n toAction(parseNestedAction(nested, reactionIndex), context, reactionIndex)\n )\n }))\n }\n const destinationId = resolveDestinationId(action, context, reactionIndex)\n assertDestination({ ...action, destinationId }, context, reactionIndex)\n return {\n type: 'NODE',\n nodeId: destinationId,\n navigation: action.navigation,\n transition: fromFigmaTransition(action.transition),\n // Only an overlay uses the spot; Figma keeps CENTER on a navigation.\n overlayPosition: action.navigation === 'OVERLAY' ? action.overlayRelativePosition : 'CENTER'\n }\n}\n\n/**\n * The layer a NODE action points at: its `destinationId`, or for a Change to, the variant of the\n * layer's set whose `variantProperties` it names.\n */\nfunction resolveDestinationId(\n action: v.InferOutput<typeof nodeActionSchema>,\n context: ReactionContext,\n index: number\n): string {\n const at = `reactions[${index}]`\n const { destinationId, variantProperties, navigation } = action\n if (destinationId && variantProperties) {\n throw failure(`${at} names both destinationId and variantProperties; give one`)\n }\n if (variantProperties) {\n if (navigation !== 'CHANGE_TO') {\n throw failure(`${at}: variantProperties is for CHANGE_TO only, not ${navigation}`)\n }\n return variantByProperties(variantProperties, context, at)\n }\n if (!destinationId) {\n throw failure(\n navigation === 'CHANGE_TO'\n ? `${at} must name the variant it Changes to, in destinationId or variantProperties`\n : `${at} must name the layer it goes to, in destinationId`\n )\n }\n return destinationId\n}\n\n/** The id of the variant of the sets around the layer whose properties are `properties`. */\nfunction variantByProperties(\n properties: Record<string, string>,\n context: ReactionContext,\n at: string\n): string {\n const sets = variantSetsAround(context.graph, context.nodeId)\n const nearest = sets.at(0)\n if (!nearest) {\n throw failure(\n `${at}: only a variant, an instance of one, or a layer inside one can Change to another variant`\n )\n }\n const wanted = Object.entries(properties)\n .map(([name, value]) => `${name}=${value}`)\n .join(', ')\n for (const set of sets) {\n const matches = context.graph.getChildren(set.id).filter((child) => {\n if (child.type !== 'COMPONENT') return false\n const values = { ...parseVariantName(child.name), ...child.componentPropertyValues }\n return Object.entries(properties).every(([name, value]) => values[name] === value)\n })\n if (matches.length === 1) return matches[0].id\n // A set can hold variants a partial map matches equally: refuse rather than pick one.\n if (matches.length > 1) {\n const names = matches.map((match) => `\"${match.name}\"`).join(', ')\n throw failure(\n `${at}: ${wanted} matches ${matches.length} variants of ${set.name} (${names}); name every property of the variant`\n )\n }\n }\n throw failure(`${at}: no variant of ${nearest.name} with ${wanted}`)\n}\n\nfunction failure(message: string): Error {\n return new Error(`Property \"reactions\" failed validation: ${message}`)\n}\n\n/**\n * A destination play can show: a navigation's is a frame at the top of the layer's page, a Change\n * to's a variant of a set the layer belongs to, and a Scroll to's a layer in the layer's\n * top-level frame.\n */\nfunction assertDestination(\n action: Pick<v.InferOutput<typeof nodeActionSchema>, 'navigation'> & { destinationId: string },\n context: ReactionContext,\n index: number\n): void {\n const { destinationId, navigation } = action\n const destination = context.graph.getNode(destinationId)\n const at = `reactions[${index}]`\n if (!destination) throw failure(`no layer ${destinationId} at ${at}.actions[0].destinationId`)\n if (navigation === 'CHANGE_TO') return assertVariant(destination, context, at)\n if (navigation === 'SCROLL_TO') return assertScrollTarget(destination, context, at)\n if (destination.type !== 'FRAME' || destination.parentId !== context.pageId) {\n throw failure(\n `${at} must navigate to a top-level frame on the same page, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\nfunction assertVariant(destination: SceneNode, context: ReactionContext, at: string): void {\n const sets = variantSetsAround(context.graph, context.nodeId)\n const nearest = sets.at(0)\n if (!nearest) {\n throw failure(\n `${at}: only a variant, an instance of one, or a layer inside one can Change to another variant`\n )\n }\n const inSet = sets.some((set) => set.id === destination.parentId)\n if (destination.type !== 'COMPONENT' || !inSet) {\n throw failure(\n `${at} must Change to a variant of ${nearest.name}, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\n/** The page's direct child a layer sits in, which play shows as one screen. */\nfunction topLevelOf(graph: SceneGraph, nodeId: string, pageId: string): SceneNode | undefined {\n return graph.closest(nodeId, (node) => node.parentId === pageId)\n}\n\nfunction assertScrollTarget(destination: SceneNode, context: ReactionContext, at: string): void {\n const { graph, nodeId, pageId } = context\n const top = topLevelOf(graph, nodeId, pageId)\n if (!top || destination.id === top.id || !graph.isDescendant(destination.id, top.id)) {\n throw failure(\n `${at} must Scroll to a layer inside the same top-level frame, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\nfunction unsupportedActionReason(action: unknown): string | null {\n if (!action || typeof action !== 'object' || !('type' in action)) return null\n const { type } = action\n if (typeof type === 'string' && type in UNSUPPORTED_ACTIONS) {\n return `an action is NODE, BACK or CLOSE, not ${type}`\n }\n if (\n type === 'CONDITIONAL' &&\n 'conditionalBlocks' in action &&\n Array.isArray(action.conditionalBlocks)\n ) {\n for (const block of action.conditionalBlocks) {\n if (\n !block ||\n typeof block !== 'object' ||\n !('actions' in block) ||\n !Array.isArray(block.actions)\n )\n continue\n for (const nested of block.actions) {\n const nestedReason = unsupportedActionReason(nested)\n if (nestedReason) return nestedReason\n }\n }\n }\n return null\n}\n\n/** Figma's first unsupported trigger or action kind in `value`, if it has one. */\nfunction unsupportedKind(value: unknown): string | null {\n if (!Array.isArray(value)) return null\n const reactions = value.filter(\n (reaction): reaction is Record<string, unknown> =>\n Boolean(reaction) && typeof reaction === 'object'\n )\n for (const reaction of reactions) {\n const trigger = reaction.trigger\n if (trigger && typeof trigger === 'object' && 'type' in trigger) {\n const type = trigger.type\n if (typeof type === 'string' && type in UNSUPPORTED_TRIGGERS) {\n return `a prototype starts from ON_CLICK, ON_HOVER, ON_PRESS, MOUSE_ENTER, MOUSE_LEAVE or AFTER_TIMEOUT, not ${type}`\n }\n }\n const actions = reaction.actions\n if (!Array.isArray(actions)) continue\n for (const action of actions) {\n const reason = unsupportedActionReason(action)\n if (reason) return reason\n }\n }\n return null\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,uBAA6C;CACjD,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;AACf;;AAGA,MAAM,sBAA4C,EAChD,KAAK,KACP;AAIA,MAAM,gBAAgB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC;AAEtD,MAAM,wBAAwB,EAAE,SAAS;C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ACC,QAAQ,QAAQ,KAAK,OAAO,aAAa,QAC7C;CACA,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,UAAU,SAAS;EACzB,IAAI,WAAW,OAAO,YAAY,YAAY,UAAU,SAAS;GAC/D,MAAM,OAAO,QAAQ;GACrB,IAAI,OAAO,SAAS,YAAY,QAAQ,sBACtC,OAAO,wGAAwG;EAEnH;EACA,MAAM,UAAU,SAAS;EACzB,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;EAC7B,KAAK,MAAM,UAAU,SAAS;GAC5B,MAAM,SAAS,wBAAwB,MAAM;GAC7C,IAAI,QAAQ,OAAO;EACrB;CACF;CACA,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { newLayerDefaults } from "../editor/shapes/defaults.js";
|
|
2
1
|
import { graph, prepareFollowedFieldEdit, raw, updateNode } from "./accessor-utils.js";
|
|
2
|
+
import { newLayerDefaults } from "../editor/shapes/defaults.js";
|
|
3
3
|
import { SHAPE_WITH_TEXT_TYPES, isShapeWithTextType } from "@pairdraw/scene-graph/shape-with-text";
|
|
4
4
|
import { createShapeWithText, shapeWithTextKindFields } from "@pairdraw/scene-graph/generated";
|
|
5
5
|
//#region src/figma-api/shape-with-text.ts
|
|
@@ -24,6 +24,8 @@ declare function prepareSlotMove(g: SceneGraph, parentId: string, childId: strin
|
|
|
24
24
|
* from the component, and a slot's content becomes the instance's own first.
|
|
25
25
|
*/
|
|
26
26
|
declare function prepareSlotInsertion(g: SceneGraph, parentId: string, method: string): void;
|
|
27
|
+
/** Ready a clone under the node's current parent, which that parent's scope decides. */
|
|
28
|
+
declare function prepareNodeClone(g: SceneGraph, nodeId: string, method: string): void;
|
|
27
29
|
/**
|
|
28
30
|
* Ready removing a layer the way Figma's remove() does: the locked part of an instance,
|
|
29
31
|
* slot frames included, refuses it, and slot content becomes the instance's own first.
|
|
@@ -32,5 +34,5 @@ declare function prepareSlotRemoval(g: SceneGraph, nodeId: string): void;
|
|
|
32
34
|
/** `ComponentNode.createSlot` and the `SlotNode` members Figma's plugin API defines. */
|
|
33
35
|
declare function installSlotAccessors(prototype: object, internals: NodeProxyInternals): void;
|
|
34
36
|
//#endregion
|
|
35
|
-
export { FigmaSlotSettings, assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareSlotInsertion, prepareSlotMove, prepareSlotRemoval };
|
|
37
|
+
export { FigmaSlotSettings, assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareNodeClone, prepareSlotInsertion, prepareSlotMove, prepareSlotRemoval };
|
|
36
38
|
//# sourceMappingURL=slots.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slots.d.ts","names":[],"sources":["../../src/figma-api/slots.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"slots.d.ts","names":[],"sources":["../../src/figma-api/slots.ts"],"mappings":";;;;UAuBiB;EACf;EACA;EACA;EACA;EACA;;;iBASc,kBACd,SAAS,0BACT,SAAS,oBACR;iBAca,kBAAkB,UAAU,eAAe;iBAQ3C,mBACd,MAAM,uBACN,UAAU;;;;;iBAUI,gBACd,GAAG,YACH,kBACA,iBACA;;;;;;iBAWc,qBAAqB,GAAG,YAAY,kBAAkB;;iBAKtD,iBAAiB,GAAG,YAAY,gBAAgB;;;;;iBAShD,mBAAmB,GAAG,YAAY;;iBAmBlC,qBAAqB,mBAAmB,WAAW"}
|
package/dist/figma-api/slots.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertProxyEditable, graph, nodeId, raw } from "./accessor-utils.js";
|
|
2
|
-
import { DEFAULT_SLOT_SETTINGS, claimSlotContent, createSlotProperty, resetSlotContent, slotLimitViolations, slotPropertyId, slotScope } from "@pairdraw/scene-graph/slots";
|
|
2
|
+
import { DEFAULT_SLOT_SETTINGS, assertChildPlacement, assertNodeMovable, claimSlotContent, createSlotProperty, resetSlotContent, slotLimitViolations, slotPropertyId, slotScope } from "@pairdraw/scene-graph/slots";
|
|
3
3
|
import { componentPropertyDefinitions, createComponentPropertyId } from "@pairdraw/scene-graph/components";
|
|
4
4
|
//#region src/figma-api/slots.ts
|
|
5
5
|
/** A count after a Figma change: null clears it, undefined keeps the current one. */
|
|
@@ -38,10 +38,8 @@ function assertSlotSettings(type, settings) {
|
|
|
38
38
|
* of an instance refuses it, and a slot on either side becomes the instance's own content.
|
|
39
39
|
*/
|
|
40
40
|
function prepareSlotMove(g, parentId, childId, method) {
|
|
41
|
-
|
|
42
|
-
const source = sourceParentId ? slotScope(g, sourceParentId) : void 0;
|
|
41
|
+
assertNodeMovable(g, childId, method);
|
|
43
42
|
prepareSlotInsertion(g, parentId, method);
|
|
44
|
-
if (source?.kind === "slot") claimSlotContent(g, source);
|
|
45
43
|
}
|
|
46
44
|
/**
|
|
47
45
|
* Ready adding new layers under `parentId`, as a tool that builds layers in place does, by the
|
|
@@ -49,9 +47,12 @@ function prepareSlotMove(g, parentId, childId, method) {
|
|
|
49
47
|
* from the component, and a slot's content becomes the instance's own first.
|
|
50
48
|
*/
|
|
51
49
|
function prepareSlotInsertion(g, parentId, method) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
assertChildPlacement(g, parentId, method);
|
|
51
|
+
}
|
|
52
|
+
/** Ready a clone under the node's current parent, which that parent's scope decides. */
|
|
53
|
+
function prepareNodeClone(g, nodeId, method) {
|
|
54
|
+
const parentId = g.getNode(nodeId)?.parentId;
|
|
55
|
+
if (parentId) assertChildPlacement(g, parentId, method);
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
58
|
* Ready removing a layer the way Figma's remove() does: the locked part of an instance,
|
|
@@ -103,6 +104,6 @@ function installSlotAccessors(prototype, internals) {
|
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
//#endregion
|
|
106
|
-
export { assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareSlotInsertion, prepareSlotMove, prepareSlotRemoval };
|
|
107
|
+
export { assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareNodeClone, prepareSlotInsertion, prepareSlotMove, prepareSlotRemoval };
|
|
107
108
|
|
|
108
109
|
//# sourceMappingURL=slots.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slots.js","names":[],"sources":["../../src/figma-api/slots.ts"],"sourcesContent":["import type { ComponentPropertyType, SceneGraph, SlotSettings } from '@pairdraw/scene-graph'\nimport {\n createComponentPropertyId,\n componentPropertyDefinitions\n} from '@pairdraw/scene-graph/components'\nimport {\n DEFAULT_SLOT_SETTINGS,\n claimSlotContent,\n createSlotProperty,\n resetSlotContent,\n slotLimitViolations,\n slotPropertyId,\n slotScope,\n type SlotLimitViolation\n} from '@pairdraw/scene-graph/slots'\n\nimport type { NodeProxyInternals, ProxyThis } from './accessor-utils'\nimport { assertProxyEditable, graph, nodeId, raw } from './accessor-utils'\nimport type { NodeProxyHost } from './proxy'\n\n/** Figma's slot limits, where an unset count reads as null. */\nexport interface FigmaSlotSettings {\n stretchChildOnInsert?: boolean\n displayEmptyByDefault?: boolean\n minChildren?: number | null\n maxChildren?: number | null\n allowPreferredValuesOnly?: boolean\n}\n\n/** A count after a Figma change: null clears it, undefined keeps the current one. */\nfunction count(change: number | null | undefined, current: number | undefined) {\n return change === null ? undefined : (change ?? current)\n}\n\n/** Apply Figma slot settings to a definition's own. */\nexport function mergeSlotSettings(\n current: SlotSettings | undefined,\n changes: FigmaSlotSettings\n): SlotSettings {\n const base = { ...DEFAULT_SLOT_SETTINGS, ...current }\n const next: SlotSettings = {\n stretchChildOnInsert: changes.stretchChildOnInsert ?? base.stretchChildOnInsert,\n displayEmptyByDefault: changes.displayEmptyByDefault ?? base.displayEmptyByDefault,\n allowPreferredValuesOnly: changes.allowPreferredValuesOnly ?? base.allowPreferredValuesOnly\n }\n const minChildren = count(changes.minChildren, base.minChildren)\n const maxChildren = count(changes.maxChildren, base.maxChildren)\n if (minChildren !== undefined) next.minChildren = minChildren\n if (maxChildren !== undefined) next.maxChildren = maxChildren\n return next\n}\n\nexport function figmaSlotSettings(settings: SlotSettings): FigmaSlotSettings {\n return {\n ...settings,\n minChildren: settings.minChildren ?? null,\n maxChildren: settings.maxChildren ?? null\n }\n}\n\nexport function assertSlotSettings(\n type: ComponentPropertyType,\n settings: FigmaSlotSettings | undefined\n): void {\n if (settings && type !== 'SLOT')\n throw new Error(\"slotSettings is only supported for 'SLOT' properties\")\n}\n\n/**\n * Ready a move of `childId` into `parentId` the way Figma's appendChild does: the locked part\n * of an instance refuses it, and a slot on either side becomes the instance's own content.\n */\nexport function prepareSlotMove(\n g: SceneGraph,\n parentId: string,\n childId: string,\n method: 'appendChild' | 'insertChild'\n): void {\n
|
|
1
|
+
{"version":3,"file":"slots.js","names":[],"sources":["../../src/figma-api/slots.ts"],"sourcesContent":["import type { ComponentPropertyType, SceneGraph, SlotSettings } from '@pairdraw/scene-graph'\nimport {\n createComponentPropertyId,\n componentPropertyDefinitions\n} from '@pairdraw/scene-graph/components'\nimport {\n DEFAULT_SLOT_SETTINGS,\n assertChildPlacement,\n assertNodeMovable,\n claimSlotContent,\n createSlotProperty,\n resetSlotContent,\n slotLimitViolations,\n slotPropertyId,\n slotScope,\n type SlotLimitViolation\n} from '@pairdraw/scene-graph/slots'\n\nimport type { NodeProxyInternals, ProxyThis } from './accessor-utils'\nimport { assertProxyEditable, graph, nodeId, raw } from './accessor-utils'\nimport type { NodeProxyHost } from './proxy'\n\n/** Figma's slot limits, where an unset count reads as null. */\nexport interface FigmaSlotSettings {\n stretchChildOnInsert?: boolean\n displayEmptyByDefault?: boolean\n minChildren?: number | null\n maxChildren?: number | null\n allowPreferredValuesOnly?: boolean\n}\n\n/** A count after a Figma change: null clears it, undefined keeps the current one. */\nfunction count(change: number | null | undefined, current: number | undefined) {\n return change === null ? undefined : (change ?? current)\n}\n\n/** Apply Figma slot settings to a definition's own. */\nexport function mergeSlotSettings(\n current: SlotSettings | undefined,\n changes: FigmaSlotSettings\n): SlotSettings {\n const base = { ...DEFAULT_SLOT_SETTINGS, ...current }\n const next: SlotSettings = {\n stretchChildOnInsert: changes.stretchChildOnInsert ?? base.stretchChildOnInsert,\n displayEmptyByDefault: changes.displayEmptyByDefault ?? base.displayEmptyByDefault,\n allowPreferredValuesOnly: changes.allowPreferredValuesOnly ?? base.allowPreferredValuesOnly\n }\n const minChildren = count(changes.minChildren, base.minChildren)\n const maxChildren = count(changes.maxChildren, base.maxChildren)\n if (minChildren !== undefined) next.minChildren = minChildren\n if (maxChildren !== undefined) next.maxChildren = maxChildren\n return next\n}\n\nexport function figmaSlotSettings(settings: SlotSettings): FigmaSlotSettings {\n return {\n ...settings,\n minChildren: settings.minChildren ?? null,\n maxChildren: settings.maxChildren ?? null\n }\n}\n\nexport function assertSlotSettings(\n type: ComponentPropertyType,\n settings: FigmaSlotSettings | undefined\n): void {\n if (settings && type !== 'SLOT')\n throw new Error(\"slotSettings is only supported for 'SLOT' properties\")\n}\n\n/**\n * Ready a move of `childId` into `parentId` the way Figma's appendChild does: the locked part\n * of an instance refuses it, and a slot on either side becomes the instance's own content.\n */\nexport function prepareSlotMove(\n g: SceneGraph,\n parentId: string,\n childId: string,\n method: 'appendChild' | 'insertChild'\n): void {\n assertNodeMovable(g, childId, method)\n prepareSlotInsertion(g, parentId, method)\n}\n\n/**\n * Ready adding new layers under `parentId`, as a tool that builds layers in place does, by the\n * rule appendChild follows: the locked part of an instance refuses them, since its layers come\n * from the component, and a slot's content becomes the instance's own first.\n */\nexport function prepareSlotInsertion(g: SceneGraph, parentId: string, method: string): void {\n assertChildPlacement(g, parentId, method)\n}\n\n/** Ready a clone under the node's current parent, which that parent's scope decides. */\nexport function prepareNodeClone(g: SceneGraph, nodeId: string, method: string): void {\n const parentId = g.getNode(nodeId)?.parentId\n if (parentId) assertChildPlacement(g, parentId, method)\n}\n\n/**\n * Ready removing a layer the way Figma's remove() does: the locked part of an instance,\n * slot frames included, refuses it, and slot content becomes the instance's own first.\n */\nexport function prepareSlotRemoval(g: SceneGraph, nodeId: string): void {\n const parentId = g.getNode(nodeId)?.parentId\n if (!parentId) return\n const scope = slotScope(g, parentId)\n if (scope.kind === 'locked') throw new Error('in remove: Removing this node is not allowed')\n if (scope.kind === 'slot') claimSlotContent(g, scope)\n}\n\nfunction host(target: ProxyThis, internals: NodeProxyInternals): NodeProxyHost {\n return target[internals.api] as NodeProxyHost\n}\n\n/** The instance slot a proxy is, if it is the frame of one. */\nfunction instanceSlot(target: ProxyThis, internals: NodeProxyInternals) {\n const scope = slotScope(graph(target, internals), nodeId(target, internals))\n return scope.kind === 'slot' && scope.frame.id === nodeId(target, internals) ? scope : undefined\n}\n\n/** `ComponentNode.createSlot` and the `SlotNode` members Figma's plugin API defines. */\nexport function installSlotAccessors(prototype: object, internals: NodeProxyInternals): void {\n Object.defineProperties(prototype, {\n createSlot: {\n // Figma appends a 100×100 frame named Slot, Slot 2, … and a SLOT property of that name.\n value(this: ProxyThis) {\n const component = raw(this, internals)\n if (component.type !== 'COMPONENT')\n throw new Error('createSlot() can only be called on components')\n assertProxyEditable(this, internals)\n const g = graph(this, internals)\n const frame = g.createNode('FRAME', component.id, { name: 'Slot' })\n const definition = createSlotProperty(g, frame.id, createComponentPropertyId())\n if (!definition) throw new Error('Failed to create slot')\n g.updateNode(frame.id, { name: definition.name })\n return host(this, internals).wrapNode(frame.id)\n }\n },\n resetSlot: {\n value(this: ProxyThis) {\n if (!slotPropertyId(raw(this, internals)))\n throw new Error('resetSlot() can only be called on slots')\n assertProxyEditable(this, internals)\n const scope = instanceSlot(this, internals)\n if (scope) resetSlotContent(graph(this, internals), scope)\n }\n },\n limitViolations: {\n // Figma measures limits only where an instance shows the slot; a main component's slot\n // reports none.\n get(this: ProxyThis): SlotLimitViolation[] {\n const scope = instanceSlot(this, internals)\n if (!scope) return []\n const g = graph(this, internals)\n const definition = componentPropertyDefinitions(g, scope.instance).find(\n (item) => item.id === scope.propertyId\n )\n if (!definition) return []\n return slot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EAGf,MAA2C;GACzC,MAAM,QAAQ,aAAa,MAAM,SAAS;GAC1C,IAAI,CAAC,OAAO,OAAO,CAAC;GACpB,MAAM,IAAI,MAAM,MAAM,SAAS;GAC/B,MAAM,aAAa,6BAA6B,GAAG,MAAM,QAAQ,CAAC,CAAC,MAChE,SAAS,KAAK,OAAO,MAAM,UAC9B;GACA,IAAI,CAAC,YAAY,OAAO,CAAC;GACzB,OAAO,oBAAoB,GAAG,YAAY,EAAE,YAAY,MAAM,MAAM,EAAE,CAAC;EACzE,EACF;CACF,CAAC;AACH"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AttachModifiers } from "./editor/connectors/attach.js";
|
|
|
2
2
|
import { DEFAULT_SNAPPING_PREFERENCES, SnappingPreferences } from "./editor/preferences.js";
|
|
3
3
|
import { ShaderRasterizer } from "./editor/shaders/types.js";
|
|
4
4
|
import { CanvasView, EditorProfile, EditorProfileInputs, EditorRestrictions, PresentationScale, ShaderView } from "./editor/views/types.js";
|
|
5
|
-
import { ClipboardImageResolution, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas } from "./editor/types.js";
|
|
5
|
+
import { ClipboardImageResolution, ClipboardPatternSources, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas } from "./editor/types.js";
|
|
6
6
|
import { ClipboardCollectionDependency, ClipboardConflictResolution, ClipboardImportChoice, ClipboardImportPlan, ClipboardStyleDependency, clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./editor/clipboard/conflicts.js";
|
|
7
7
|
import { ClipboardSnapshot } from "./editor/clipboard/snapshot.js";
|
|
8
8
|
import { ClipboardPayload, CopyOptions } from "./editor/clipboard/copy.js";
|
|
@@ -21,8 +21,9 @@ import { SelectionColor, replaceSelectionColor, selectionColors, selectionColors
|
|
|
21
21
|
import { DOCUMENT_COLOR_LIMIT, DocumentColor, documentColors } from "./editor/document-colors.js";
|
|
22
22
|
import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./editor/state/view.js";
|
|
23
23
|
import { VariantConflict, VariantMutationResult, VariantValidationIssue } from "./editor/components/variants/model.js";
|
|
24
|
-
import { VariableTokenFields } from "./editor/variables.js";
|
|
25
24
|
import { NodePreview } from "./editor/node-preview.js";
|
|
25
|
+
import { opacityFromBuffer } from "./editor/nodes.js";
|
|
26
|
+
import { VariableTokenFields } from "./editor/variables.js";
|
|
26
27
|
import { DEFAULT_SCALE_ANCHOR, SCALE_ANCHORS, ScaleAnchor, isScaleAnchor, parseScaleFactor, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds } from "./editor/scale/anchor.js";
|
|
27
28
|
import { ScaleSession } from "./editor/scale/actions.js";
|
|
28
29
|
import { RescaleSnapshot, rescaleNodes } from "./editor/scale/rescale.js";
|
|
@@ -47,11 +48,10 @@ import { reapplyInstanceComponentProperties } from "./editor/components/properti
|
|
|
47
48
|
import { createGuideActions } from "./editor/guides.js";
|
|
48
49
|
import { createTextActions } from "./editor/text.js";
|
|
49
50
|
import { resizedPathTextGlyphs } from "./editor/text/path-edit.js";
|
|
50
|
-
import { opacityFromBuffer } from "./editor/nodes.js";
|
|
51
51
|
import { LayerType, layerTypeOptions } from "./editor/structure/layer-type.js";
|
|
52
52
|
import { BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, EDITOR_TOOLS, EditorToolDef, TOOL_SHORTCUTS } from "./editor/tool-registry.js";
|
|
53
53
|
import { EyedropperTarget, ScenePixels, applySampledColor, eyedropperChanges, sampleSceneColor, sampleScenePixels, scenePixelColor } from "./editor/eyedropper.js";
|
|
54
54
|
import { newLayerDefaults } from "./editor/shapes/defaults.js";
|
|
55
55
|
import { RenameSelectionOptions, RenameSelectionPreview } from "./editor/structure/rename.js";
|
|
56
56
|
import "./editor/index.js";
|
|
57
|
-
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, DOCUMENT_COLOR_LIMIT, type DocumentChange, type DocumentColor, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type EyedropperTarget, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type ScenePixels, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, applyDocumentChange, applySampledColor, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, documentColors, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, eyedropperChanges, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, recordDocumentChange, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, sampleSceneColor, sampleScenePixels, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, scenePixelColor, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
|
57
|
+
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPatternSources, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, DOCUMENT_COLOR_LIMIT, type DocumentChange, type DocumentColor, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type EyedropperTarget, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type ScenePixels, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, applyDocumentChange, applySampledColor, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, documentColors, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, eyedropperChanges, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, recordDocumentChange, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, sampleSceneColor, sampleScenePixels, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, scenePixelColor, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|