@pairdraw/core 0.21.0 → 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/canvas/shaders/compile.d.ts +3 -1
- package/dist/canvas/shaders/compile.d.ts.map +1 -1
- package/dist/canvas/shaders/compile.js +12 -3
- package/dist/canvas/shaders/compile.js.map +1 -1
- package/dist/canvas/shaders/draw.d.ts.map +1 -1
- package/dist/canvas/shaders/draw.js +10 -3
- package/dist/canvas/shaders/draw.js.map +1 -1
- package/dist/canvas/shaders/effect.d.ts.map +1 -1
- package/dist/canvas/shaders/effect.js +6 -16
- package/dist/canvas/shaders/effect.js.map +1 -1
- package/dist/clipboard/pairdraw.d.ts.map +1 -1
- package/dist/clipboard/pairdraw.js +1 -0
- package/dist/clipboard/pairdraw.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +2 -0
- package/dist/editor/bridges/clipboard.d.ts.map +1 -1
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +1 -1
- package/dist/editor/bridges/components.d.ts +14 -7
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +6 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -1
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/code.d.ts +32 -0
- package/dist/editor/clipboard/code.d.ts.map +1 -0
- package/dist/editor/clipboard/code.js +30 -0
- package/dist/editor/clipboard/code.js.map +1 -0
- package/dist/editor/clipboard/export.js +2 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.js +0 -0
- package/dist/editor/clipboard/paste/run.d.ts +14 -0
- package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/run.js +47 -0
- package/dist/editor/clipboard/paste/run.js.map +1 -0
- package/dist/editor/clipboard/styled.d.ts +2 -8
- package/dist/editor/clipboard/styled.d.ts.map +1 -1
- package/dist/editor/clipboard/styled.js +2 -32
- package/dist/editor/clipboard/styled.js.map +1 -1
- package/dist/editor/clipboard.d.ts +2 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +34 -0
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +5 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +69 -4
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/slots/index.d.ts.map +1 -1
- package/dist/editor/components/slots/index.js +7 -0
- package/dist/editor/components/slots/index.js.map +1 -1
- package/dist/editor/components.d.ts +6 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/components.js +14 -2
- package/dist/editor/components.js.map +1 -1
- package/dist/editor/create.d.ts +30 -3
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +11 -2
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-tokens.d.ts +1 -1
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +4 -18
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/image-edit.d.ts.map +1 -1
- package/dist/editor/image-edit.js +1 -2
- package/dist/editor/image-edit.js.map +1 -1
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts +3 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +97 -2
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/nodes.d.ts +2 -0
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +22 -7
- package/dist/editor/nodes.js.map +1 -1
- package/dist/editor/read-only/actions.js +6 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/selection/overlays.d.ts +1 -0
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +7 -0
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +8 -0
- package/dist/editor/selection.d.ts +9 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/state/shared.js +1 -0
- package/dist/editor/state/shared.js.map +1 -1
- package/dist/editor/state/view.d.ts.map +1 -1
- package/dist/editor/state/view.js +2 -0
- package/dist/editor/state/view.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +1 -1
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js +20 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/container-wrap.d.ts +8 -2
- package/dist/editor/structure/container-wrap.d.ts.map +1 -1
- package/dist/editor/structure/container-wrap.js +17 -5
- package/dist/editor/structure/container-wrap.js.map +1 -1
- package/dist/editor/structure/flatten.d.ts.map +1 -1
- package/dist/editor/structure/flatten.js +8 -7
- package/dist/editor/structure/flatten.js.map +1 -1
- package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
- package/dist/editor/structure/group/ungroup.js +2 -0
- package/dist/editor/structure/group/ungroup.js.map +1 -1
- package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
- package/dist/editor/structure/outline-stroke.js +5 -0
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -1
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/styles.d.ts +26 -0
- package/dist/editor/styles.d.ts.map +1 -0
- package/dist/editor/styles.js +127 -0
- package/dist/editor/styles.js.map +1 -0
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +10 -2
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +6 -0
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +14 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +6 -1
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +22 -1
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/shape.js +1 -1
- package/dist/figma-api/accessors/text/index.js +1 -1
- package/dist/figma-api/accessors/text/ranges.js +1 -1
- package/dist/figma-api/accessors/text/references.js +1 -1
- package/dist/figma-api/accessors/variables.js +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +8 -22
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.js +1 -1
- package/dist/figma-api/compatibility.d.ts +1 -1
- package/dist/figma-api/compatibility.d.ts.map +1 -1
- package/dist/figma-api/component-scope.d.ts +14 -0
- package/dist/figma-api/component-scope.d.ts.map +1 -0
- package/dist/figma-api/component-scope.js +28 -0
- package/dist/figma-api/component-scope.js.map +1 -0
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +26 -2
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/flatten.js +3 -3
- package/dist/figma-api/flatten.js.map +1 -1
- package/dist/figma-api/index.d.ts +77 -6
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +188 -2
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/node-types.d.ts +2 -1
- package/dist/figma-api/node-types.d.ts.map +1 -1
- package/dist/figma-api/overrides.d.ts +26 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +157 -10
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +2 -0
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +10 -2
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +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/drawio/warnings.d.ts +17 -2
- package/dist/io/formats/drawio/warnings.d.ts.map +1 -1
- package/dist/io/formats/drawio/warnings.js +14 -7
- package/dist/io/formats/drawio/warnings.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/index.d.ts +1 -0
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +5 -3
- package/dist/io/formats/html/index.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/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +13 -4
- package/dist/io/formats/pen/index.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 +30 -17
- package/dist/io/formats.js.map +1 -1
- package/dist/io/index.d.ts +2 -2
- package/dist/io/types.d.ts +11 -2
- package/dist/io/types.d.ts.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/canvas/shaders/compile.ts +14 -3
- package/src/canvas/shaders/draw.ts +11 -4
- package/src/canvas/shaders/effect.ts +6 -18
- 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/export.ts +2 -2
- 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/drawio/warnings.ts +27 -8
- 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/index.ts +9 -3
- 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/pen/index.ts +14 -6
- 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 +45 -19
- package/src/io/index.ts +1 -0
- package/src/io/types.ts +10 -0
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.js","names":["isEqual"],"sources":["../../src/figma-api/overrides.ts"],"sourcesContent":["import { omit, uniq } from 'es-toolkit'\nimport { isEqual } from 'es-toolkit/predicate'\n\nimport type {\n ComponentPropertyReferenceField,\n SceneGraph,\n SceneNode,\n Stroke\n} from '@pairdraw/scene-graph'\nimport { findInstanceAncestor, isReplacedLayer } from '@pairdraw/scene-graph/instances'\nimport {\n overriddenAssignmentId,\n overriddenBindingField,\n overriddenVariableModeCollection,\n REPLACED_LAYER_OVERRIDE,\n type InstanceOverrideState\n} from '@pairdraw/scene-graph/instances/overrides'\n\nimport type { NodeProxyInternals, ProxyThis } from './accessor-utils'\nimport { assertProxyEditable, graph, raw } from './accessor-utils'\nimport { flushPendingLayout } from './pending-layout'\n\n/** One layer of an instance and the fields an edit changed on it, as Figma's `overrides`. */\nexport interface FigmaInstanceOverride {\n id: string\n overriddenFields: string[]\n}\n\n/**\n * The fields Figma desktop 126 lists for an override of each of ours. Unlisted fields are ones\n * Figma does not report: a layer's own size, size limits, clipping, the layout mode, a swap.\n * Figma spells the top stroke weight `stokeTopWeight`.\n */\nconst FIGMA_OVERRIDE_FIELDS: Readonly<Partial<Record<string, readonly string[]>>> = {\n // Figma keeps a size as one field, so a changed width or height lists both.\n width: ['height', 'width'],\n height: ['height', 'width'],\n name: ['name'],\n visible: ['visible'],\n locked: ['locked'],\n text: ['characters', 'styledTextSegments'],\n styleRuns: ['styledTextSegments'],\n textParagraphs: ['styledTextSegments'],\n listSpacing: ['styledTextSegments'],\n fontSize: ['fontSize'],\n fontFamily: ['fontName'],\n fontWeight: ['fontName'],\n italic: ['fontName'],\n fontStyle: ['fontName'],\n letterSpacing: ['letterSpacing'],\n lineHeight: ['lineHeight'],\n textCase: ['textCase'],\n textDecoration: ['textDecoration'],\n textDecorationStyle: ['textDecorationStyle'],\n textDecorationThickness: ['textDecorationThickness'],\n textUnderlineOffset: ['textDecorationOffset'],\n textDecorationFills: ['textDecorationColor'],\n textDecorationSkipInk: ['textDecorationSkipInk'],\n textAlignHorizontal: ['textAlignHorizontal'],\n textAlignVertical: ['textAlignVertical'],\n textAutoResize: ['textAutoResize'],\n textTruncation: ['textTruncation'],\n maxLines: ['maxLines'],\n leadingTrim: ['leadingTrim'],\n paragraphSpacing: ['paragraphSpacing'],\n paragraphIndent: ['paragraphIndent'],\n hangingList: ['hangingList'],\n fills: ['fills'],\n strokes: ['strokes'],\n effects: ['effects'],\n opacity: ['opacity'],\n blendMode: ['blendMode'],\n cornerRadius: [\n 'bottomLeftRadius',\n 'bottomRightRadius',\n 'cornerRadius',\n 'topLeftRadius',\n 'topRightRadius'\n ],\n topLeftRadius: ['topLeftRadius'],\n topRightRadius: ['topRightRadius'],\n bottomRightRadius: ['bottomRightRadius'],\n bottomLeftRadius: ['bottomLeftRadius'],\n cornerSmoothing: ['cornerSmoothing'],\n strokeWeight: [\n 'strokeBottomWeight',\n 'strokeLeftWeight',\n 'strokeRightWeight',\n 'stokeTopWeight',\n 'strokeWeight'\n ],\n borderTopWeight: ['stokeTopWeight'],\n borderRightWeight: ['strokeRightWeight'],\n borderBottomWeight: ['strokeBottomWeight'],\n borderLeftWeight: ['strokeLeftWeight'],\n strokeAlign: ['strokeAlign'],\n strokeCap: ['strokeCap'],\n strokeJoin: ['strokeJoin'],\n strokeMiterLimit: ['strokeMiterLimit'],\n dashPattern: ['dashPattern'],\n layoutWrap: ['layoutWrap'],\n primaryAxisAlign: ['primaryAxisAlignItems'],\n counterAxisAlign: ['counterAxisAlignItems'],\n primaryAxisSizing: ['primaryAxisSizingMode'],\n counterAxisSizing: ['counterAxisSizingMode'],\n itemSpacing: ['itemSpacing'],\n counterAxisSpacing: ['counterAxisSpacing'],\n paddingTop: ['paddingTop'],\n paddingRight: ['paddingRight'],\n paddingBottom: ['paddingBottom'],\n paddingLeft: ['paddingLeft'],\n gridColumnGap: ['gridColumnGap'],\n gridRowGap: ['gridRowGap'],\n itemReverseZIndex: ['itemReverseZIndex'],\n layoutGrids: ['layoutGrids'],\n layoutGrow: ['layoutGrow'],\n layoutAlignSelf: ['layoutAlign'],\n boundVariables: ['boundVariables'],\n variableModes: ['explicitVariableModes'],\n fillStyleId: ['fillStyleId'],\n strokeStyleId: ['strokeStyleId'],\n textStyleId: ['textStyleId'],\n effectStyleId: ['effectStyleId'],\n gridStyleId: ['gridStyleId']\n}\n\n/** Fields a component property sets on a layer, which Figma reports as the property's, not an override. */\nconst PROPERTY_FIELDS: Record<ComponentPropertyReferenceField, readonly string[]> = {\n TEXT: ['text', 'styleRuns', 'textParagraphs'],\n VISIBLE: ['visible'],\n INSTANCE_SWAP: ['componentId', 'name'],\n SLOT_CONTENT: []\n}\n\nfunction propertyFields(node: SceneNode): Set<string> {\n return new Set(node.componentPropertyReferences.flatMap(({ field }) => PROPERTY_FIELDS[field]))\n}\n\n/** Figma sorts the names as spelled right, so its misspelled top weight sorts as `strokeTop…`. */\nconst sortKey = (name: string) => (name === 'stokeTopWeight' ? 'strokeTopWeight' : name)\n\nfunction figmaFields(fields: Iterable<string>, skipped: Set<string>): string[] {\n const names = new Set<string>()\n for (const field of fields) {\n if (skipped.has(field)) continue\n for (const name of FIGMA_OVERRIDE_FIELDS[field] ?? []) names.add(name)\n }\n return [...names].sort((a, b) => sortKey(a).localeCompare(sortKey(b)))\n}\n\n/**\n * The layer of the component a node copies, which its overrides are measured against. A nested\n * instance links to the component's instance it copies, until a swap points it at a component;\n * the enclosing instance then keeps the layer it copied.\n */\nfunction componentLayer(\n graph: SceneGraph,\n node: SceneNode,\n owner: SceneNode | undefined\n): SceneNode | undefined {\n const linked = node.componentId ? graph.getNode(node.componentId) : undefined\n if (node.type !== 'INSTANCE' || linked?.type === 'INSTANCE') {\n return linked ? resolveCopiedLayer(graph, linked) : linked\n }\n const source = owner?.instanceOverrides.descendants.get(node.id)?.get('sourceComponentId')\n if (typeof source === 'string') return graph.getNode(source)\n return componentLayerByName(graph, node, owner)\n}\n\n/**\n * A copy inside a nested instance links to the enclosing component's copy, which in turn links\n * to the nested component's layer. Follow that chain to the layer an edit belongs to.\n */\nfunction resolveCopiedLayer(graph: SceneGraph, linked: SceneNode): SceneNode {\n let target = linked\n for (let depth = 0; depth < 32 && target.componentId; depth++) {\n const parent = target.parentId ? graph.getNode(target.parentId) : undefined\n if (parent?.type !== 'INSTANCE') break\n const next = graph.getNode(target.componentId)\n if (!next) break\n target = next\n }\n return target\n}\n\n/**\n * A copy made by cloning carries no link to its source, so match the path from its instance to\n * the instance's component by sibling position and name.\n */\nfunction componentLayerByName(\n graph: SceneGraph,\n node: SceneNode,\n owner: SceneNode | undefined\n): SceneNode | undefined {\n if (owner?.type !== 'INSTANCE' || !owner.componentId) return undefined\n const path: SceneNode[] = []\n let current: SceneNode | undefined = node\n while (current && current.id !== owner.id) {\n path.unshift(current)\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n if (!current) return undefined\n let source = graph.getNode(owner.componentId)\n // A nested instance copies the enclosing component's nested instance, so follow its link to\n // the component that instance actually shows.\n while (source?.type === 'INSTANCE' && source.componentId)\n source = graph.getNode(source.componentId)\n for (const step of path) {\n if (!source) return undefined\n source = matchingComponentChild(graph, source, step)\n }\n return source\n}\n\n/** The component child a copy at the same place shows, preferring its sibling position. */\nfunction matchingComponentChild(\n graph: SceneGraph,\n source: SceneNode,\n step: SceneNode\n): SceneNode | undefined {\n const siblings = graph.getChildren(source.id)\n const index = step.parentId ? graph.getNode(step.parentId)?.childIds.indexOf(step.id) : -1\n const atIndex = index !== undefined && index >= 0 ? siblings[index] : undefined\n if (atIndex?.type === step.type) return atIndex\n return (\n siblings.find((sibling) => sibling.type === step.type && sibling.name === step.name) ??\n siblings.find((sibling) => sibling.type === step.type)\n )\n}\n\n/** Figma keeps stroke weight and alignment on the layer, so a paint differs by its colour alone. */\nconst paints = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => omit(stroke, ['weight', 'align']))\n\nfunction differs(node: SceneNode, source: SceneNode | undefined, field: string): boolean {\n if (!source) return true\n if (field === 'strokes') return !isEqual(paints(node.strokes), paints(source.strokes))\n return !isEqual(Reflect.get(node, field), Reflect.get(source, field))\n}\n\n/**\n * The fields recorded as edited on a node that still differ from its component layer: an edit\n * kept in the nearest instance above it, and one kept on the node itself if it is an instance.\n * Figma lists a field as overridden only while it differs.\n */\nfunction editedFields(graph: SceneGraph, node: SceneNode, root: SceneNode): string[] {\n const owner =\n node.id === root.id || !node.parentId ? undefined : findInstanceAncestor(graph, node.parentId)\n const source =\n node.id === root.id ? graph.getNode(root.componentId ?? '') : componentLayer(graph, node, owner)\n const fields = [\n ...(node.type === 'INSTANCE' ? node.instanceOverrides.self.keys() : []),\n ...(owner?.instanceOverrides.descendants.get(node.id)?.keys() ?? [])\n ].map((field) =>\n // A mode set for one collection is an override of the layer's modes, as Figma lists it.\n overriddenVariableModeCollection(field) === null ? field : 'variableModes'\n )\n // The instance's own size counts once it differs, as a layer that grows it makes it.\n if (node.id === root.id) fields.push('width', 'height')\n return uniq(fields).filter((field) => differs(node, source, field))\n}\n\n/**\n * Figma's `overrides`: each layer of the instance, itself first and then in layer order, with\n * the fields edited on it, including those inside nested instances. Figma lists no layer's own\n * size but the instance's.\n */\nexport function instanceOverrides(graph: SceneGraph, root: SceneNode): FigmaInstanceOverride[] {\n const result: FigmaInstanceOverride[] = []\n const visit = (node: SceneNode) => {\n const skipped = propertyFields(node)\n if (node.id !== root.id) skipped.add('width').add('height')\n const overriddenFields = figmaFields(editedFields(graph, node, root), skipped)\n if (overriddenFields.length > 0) result.push({ id: node.id, overriddenFields })\n for (const child of graph.getChildren(node.id)) visit(child)\n }\n visit(root)\n return result\n}\n\n/** Clears an override state but what component properties set, which Figma keeps on reset. */\nfunction withoutEdits(graph: SceneGraph, state: InstanceOverrideState): InstanceOverrideState {\n const keep = (nodeId: string, fields: Map<string, unknown>) => {\n const node = graph.getNode(nodeId)\n const driven = node ? propertyFields(node) : new Set<string>()\n return new Map([...fields].filter(([field]) => driven.has(field)))\n }\n const descendants = new Map(\n [...state.descendants]\n .map(([nodeId, fields]) => [nodeId, keep(nodeId, fields)] as const)\n .filter(([, fields]) => fields.size > 0)\n )\n return { self: new Map(), descendants }\n}\n\n/** Every instance at or below `root`, deepest first, as pushing each one's edits needs them. */\nfunction instancesDeepestFirst(graph: SceneGraph, root: SceneNode): SceneNode[] {\n const result: SceneNode[] = []\n const visit = (node: SceneNode): void => {\n for (const child of graph.getChildren(node.id)) visit(child)\n if (node.type === 'INSTANCE') result.push(node)\n }\n visit(root)\n return result\n}\n\n/** The main component an instance's own edits belong to, if it can take them. */\nfunction pushableMainComponent(\n graph: SceneGraph,\n instance: SceneNode,\n canEditMain: ((componentId: string) => boolean) | undefined\n): SceneNode | null {\n let component = instance.componentId ? graph.getNode(instance.componentId) : undefined\n // A nested copy's link points at the enclosing component's nested instance, not at the\n // component that instance shows, so follow it to the main component the edits belong to.\n while (component?.type === 'INSTANCE' && component.componentId) {\n component = graph.getNode(component.componentId)\n }\n if (component?.type !== 'COMPONENT') return null\n if (canEditMain && !canEditMain(component.id)) return null\n return component\n}\n\n/**\n * Applies one recorded override field from an instance layer to the component layer it copies.\n * Returns whether the field was a text pushed into a component property's default.\n */\nfunction pushOverrideField(\n graph: SceneGraph,\n target: SceneNode,\n source: SceneNode,\n field: string\n): boolean {\n // A source link is bookkeeping for sync; a replaced layer is a structural edit, not a field.\n if (field === 'sourceComponentId' || field === REPLACED_LAYER_OVERRIDE) return false\n // Assigning a component property belongs to the instance, not to the main component.\n if (overriddenAssignmentId(field) !== null) return false\n const collection = overriddenVariableModeCollection(field)\n if (collection !== null) {\n const modes = Object.hasOwn(source.variableModes, collection)\n ? { ...target.variableModes, [collection]: source.variableModes[collection] }\n : omit(target.variableModes, [collection])\n graph.updateNode(target.id, { variableModes: modes })\n return false\n }\n const binding = overriddenBindingField(field)\n if (binding !== null) {\n const bindings = Object.hasOwn(source.boundVariables, binding)\n ? {\n ...target.boundVariables,\n [binding]: structuredClone(source.boundVariables[binding])\n }\n : omit(target.boundVariables, [binding])\n graph.updateNode(target.id, { boundVariables: bindings })\n return false\n }\n const value = Reflect.get(source, field)\n if (value === undefined) return false\n const defaulted =\n field === 'text' && typeof value === 'string'\n ? pushBoundTextDefault(graph, target, value)\n : false\n graph.updateNode(target.id, { [field]: structuredClone(value) })\n return defaulted\n}\n\n/** The override state after a push: property values stay, but a text pushed as a default goes. */\nfunction clearedAfterPush(\n graph: SceneGraph,\n state: InstanceOverrideState,\n defaulted: Set<string>\n): InstanceOverrideState {\n const cleared = withoutEdits(graph, state)\n const descendants = new Map(cleared.descendants)\n for (const nodeId of defaulted) {\n const fields = descendants.get(nodeId)\n if (!fields) continue\n fields.delete('text')\n if (fields.size === 0) descendants.delete(nodeId)\n }\n return { self: cleared.self, descendants }\n}\n\n/**\n * A text layer bound to a text property shows the property's default on the main component.\n * Pushing the edit moves that default with it, so the canvas and the property panel agree.\n * Returns whether the field was pushed as a default.\n */\nfunction pushBoundTextDefault(graph: SceneGraph, target: SceneNode, text: string): boolean {\n const propertyId = target.componentPropertyReferences.find(\n (reference) => reference.field === 'TEXT'\n )?.propertyId\n if (!propertyId) return false\n const owner = graph.closest(\n target.parentId ?? target.id,\n (node) =>\n (node.type === 'COMPONENT' || node.type === 'COMPONENT_SET') &&\n node.componentPropertyDefinitions.some((definition) => definition.id === propertyId)\n )\n const definition = owner?.componentPropertyDefinitions.find((item) => item.id === propertyId)\n if (!owner || !definition) return false\n if (definition.defaultValue !== text)\n graph.updateNode(owner.id, {\n componentPropertyDefinitions: owner.componentPropertyDefinitions.map((item) =>\n item.id === propertyId ? { ...item, defaultValue: text } : item\n )\n })\n // Every other definition layer the property drives follows the new default, as editing the\n // default does. A nested instance's copies belong to their own component and are left to sync.\n const visit = (node: SceneNode): void => {\n for (const child of graph.getChildren(node.id)) {\n if (child.type === 'INSTANCE') continue\n if (\n child.type === 'TEXT' &&\n child.componentPropertyReferences.some(\n (reference) => reference.propertyId === propertyId && reference.field === 'TEXT'\n )\n )\n graph.updateNode(child.id, { text })\n visit(child)\n }\n }\n visit(owner)\n return true\n}\n\n/**\n * Whether pushing `root`'s changes can reach every main component they belong to. Pushing is\n * refused for a library component, whose main is read-only.\n */\nexport function canPushInstanceOverrides(\n graph: SceneGraph,\n root: SceneNode,\n canEditMain?: (componentId: string) => boolean\n): boolean {\n if (root.type !== 'INSTANCE') return false\n let found = false\n for (const instance of instancesDeepestFirst(graph, root)) {\n if (\n instance.instanceOverrides.self.size === 0 &&\n instance.instanceOverrides.descendants.size === 0\n )\n continue\n if (!pushableMainComponent(graph, instance, canEditMain)) return false\n found = true\n }\n return found\n}\n\n/**\n * Figma's Push changes to main component: writes the edits of `root` and the instances inside\n * it to their own main components, then clears those edits so every instance follows. A\n * nested instance's edits go to its nested main; the outer main then picks them up by sync.\n * Returns false, changing nothing, when a main component is missing or read-only.\n */\nexport function pushInstanceOverrides(\n graph: SceneGraph,\n root: SceneNode,\n canEditMain?: (componentId: string) => boolean\n): boolean {\n if (!canPushInstanceOverrides(graph, root, canEditMain)) return false\n const instances = instancesDeepestFirst(graph, root).filter(\n (instance) =>\n instance.instanceOverrides.self.size > 0 || instance.instanceOverrides.descendants.size > 0\n )\n const components: string[] = []\n const defaulted = new Set<string>()\n for (const instance of instances) {\n const main = pushableMainComponent(graph, instance, canEditMain)\n if (!main) return false\n if (!components.includes(main.id)) components.push(main.id)\n const state = instance.instanceOverrides\n for (const [field] of state.self) {\n pushOverrideField(graph, main, instance, field)\n }\n for (const [nodeId, fields] of state.descendants) {\n const node = graph.getNode(nodeId)\n if (!node) continue\n const owner = node.parentId ? findInstanceAncestor(graph, node.parentId) : undefined\n const target = componentLayer(graph, node, owner)\n if (!target) continue\n for (const [field] of fields) {\n if (pushOverrideField(graph, target, node, field)) defaulted.add(nodeId)\n }\n }\n }\n for (const instance of instances) {\n graph.updateNode(instance.id, {\n instanceOverrides: clearedAfterPush(graph, instance.instanceOverrides, defaulted)\n })\n }\n // Deepest main first, then every component holding an instance of one: an outer main syncs\n // the nested instance the inner main changed, and so on up to the page.\n graph.syncInstancesTogether(followingComponents(graph, components))\n return true\n}\n\n/** The pushed mains and every component whose instances show one of them, deepest first. */\nfunction followingComponents(graph: SceneGraph, components: string[]): string[] {\n const order: string[] = []\n const seen = new Set<string>()\n const visit = (id: string): void => {\n if (seen.has(id)) return\n seen.add(id)\n order.push(id)\n for (const instance of graph.getInstances(id)) {\n const holder = instance.parentId\n ? graph.closest(instance.parentId, (node) => node.type === 'COMPONENT')\n : undefined\n if (holder) visit(holder.id)\n }\n }\n for (const id of components) visit(id)\n return order\n}\n\n/**\n * Figma's `resetOverrides`: the instance and every instance inside it go back to their\n * components, keeping the values their component properties set.\n */\nexport function resetInstanceOverrides(graph: SceneGraph, root: SceneNode): void {\n // A layer put in place of a component's layer goes, and the sync brings that layer back.\n const replaced: string[] = []\n const collect = (node: SceneNode) => {\n for (const child of graph.getChildren(node.id)) {\n if (isReplacedLayer(graph, child)) replaced.push(child.id)\n else collect(child)\n }\n }\n collect(root)\n for (const id of replaced) graph.deleteNode(id)\n const visit = (node: SceneNode) => {\n if (node.type === 'INSTANCE')\n graph.updateNode(node.id, { instanceOverrides: withoutEdits(graph, node.instanceOverrides) })\n for (const child of graph.getChildren(node.id)) visit(child)\n }\n visit(root)\n // The outermost instance passes its component's content down to the ones inside it.\n let outermost = root\n for (\n let parent = root.parentId ? findInstanceAncestor(graph, root.parentId) : undefined;\n parent;\n ) {\n outermost = parent\n parent = parent.parentId ? findInstanceAncestor(graph, parent.parentId) : undefined\n }\n graph.syncInstance(outermost.id)\n}\n\nexport function installInstanceOverrideAccessors(\n prototype: object,\n internals: NodeProxyInternals\n): void {\n Object.defineProperties(prototype, {\n overrides: {\n get(this: ProxyThis): FigmaInstanceOverride[] | undefined {\n const node = raw(this, internals)\n if (node.type !== 'INSTANCE') return undefined\n // Figma lists the size its layout gives the instance.\n flushPendingLayout(graph(this, internals))\n return instanceOverrides(graph(this, internals), node)\n }\n },\n resetOverrides: {\n value(this: ProxyThis) {\n const node = raw(this, internals)\n if (node.type !== 'INSTANCE')\n throw new TypeError('resetOverrides() can only be called on instances')\n assertProxyEditable(this, internals)\n resetInstanceOverr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B;EACnC,KAAK,MAAM,SAAS,MAAM,YAAY,KAAK,EAAE,GAC3C,IAAI,gBAAgB,OAAO,KAAK,GAAG,SAAS,KAAK,MAAM,EAAE;OACpD,QAAQ,KAAK;CAEtB;CACA,QAAQ,IAAI;CACZ,KAAK,MAAM,MAAM,UAAU,MAAM,WAAW,EAAE;CAC9C,MAAM,SAAS,SAAoB;EACjC,IAAI,KAAK,SAAS,YAChB,MAAM,WAAW,KAAK,IAAI,EAAE,mBAAmB,aAAa,OAAO,KAAK,iBAAiB,EAAE,CAAC;EAC9F,KAAK,MAAM,SAAS,MAAM,YAAY,KAAK,EAAE,GAAG,MAAM,KAAK;CAC7D;CACA,MAAM,IAAI;CAEV,IAAI,YAAY;CAChB,KACE,IAAI,SAAS,KAAK,WAAW,qBAAqB,OAAO,KAAK,QAAQ,IAAI,KAAA,GAC1E,SACA;EACA,YAAY;EACZ,SAAS,OAAO,WAAW,qBAAqB,OAAO,OAAO,QAAQ,IAAI,KAAA;CAC5E;CACA,MAAM,aAAa,UAAU,EAAE;AACjC;AAEA,SAAgB,iCACd,WACA,WACM;CACN,OAAO,iBAAiB,WAAW;EACjC,WAAW,EACT,MAA0D;GACxD,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,IAAI,KAAK,SAAS,YAAY,OAAO,KAAA;GAErC,mBAAmB,MAAM,MAAM,SAAS,CAAC;GACzC,OAAO,kBAAkB,MAAM,MAAM,SAAS,GAAG,IAAI;EACvD,EACF;EACA,gBAAgB,EACd,QAAuB;GACrB,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,IAAI,KAAK,SAAS,YAChB,MAAM,IAAI,UAAU,kDAAkD;GACxE,oBAAoB,MAAM,SAAS;GACnC,uBAAuB,MAAM,MAAM,SAAS,GAAG,IAAI;EACrD,EACF;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"overrides.js","names":["isEqual"],"sources":["../../src/figma-api/overrides.ts"],"sourcesContent":["import { omit, uniq } from 'es-toolkit'\nimport { isEqual } from 'es-toolkit/predicate'\n\nimport type {\n ComponentPropertyReferenceField,\n SceneGraph,\n SceneNode,\n Stroke\n} from '@pairdraw/scene-graph'\nimport { AUTO_LAYOUT_FIELDS, SIZE_FIELDS } from '@pairdraw/scene-graph/fields'\nimport {\n findInstanceAncestor,\n INSTANCE_OVERRIDE_FIELDS,\n INSTANCE_SYNC_FIELD_OWNERS,\n isReplacedLayer\n} from '@pairdraw/scene-graph/instances'\nimport {\n clearInstanceOverrides,\n cloneInstanceOverrideState,\n overriddenAssignmentId,\n overriddenBindingField,\n overriddenVariableModeCollection,\n REPLACED_LAYER_OVERRIDE,\n type InstanceOverrideState\n} from '@pairdraw/scene-graph/instances/overrides'\nimport { slotScope } from '@pairdraw/scene-graph/slots'\n\nimport type { NodeProxyInternals, ProxyThis } from './accessor-utils'\nimport { assertProxyEditable, graph, raw } from './accessor-utils'\nimport { flushPendingLayout } from './pending-layout'\n\n/** The names an instance can record, as the file's own table says. */\nconst recordableOverrideFields = new Set<string>(INSTANCE_OVERRIDE_FIELDS)\nconst onlyRecorded = (fields: readonly string[]): readonly string[] =>\n fields.filter((field) => recordableOverrideFields.has(field))\n\n/*\n * The fields each property marker row writes, as the panel's sections pass them. They live here so\n * the reset tool and the editor reset clear the same names.\n */\nexport const FILL_OVERRIDE_FIELDS = onlyRecorded(['fills', 'fillStyleId'])\nexport const STROKE_OVERRIDE_FIELDS = onlyRecorded([\n 'strokes',\n 'strokeWeight',\n 'strokeAlign',\n 'strokeJoin',\n 'strokeMiterLimit',\n 'dashPattern',\n 'strokeStyleId'\n])\nexport const EFFECT_OVERRIDE_FIELDS = onlyRecorded(['effects', 'effectStyleId'])\nexport const TEXT_OVERRIDE_FIELDS = onlyRecorded([\n 'text',\n 'fontFamily',\n 'fontSize',\n 'fontWeight',\n 'lineHeight',\n 'letterSpacing',\n 'italic',\n 'textAlignHorizontal',\n 'textAlignVertical',\n 'textCase',\n 'textDecoration',\n 'fontVariations',\n 'fontFeatures',\n 'textAutoResize',\n 'textTruncation',\n 'maxLines',\n 'leadingTrim',\n 'listSpacing',\n 'hangingList',\n 'textDirection',\n 'styleRuns',\n 'textParagraphs',\n 'textStyleId'\n])\n/** A layer in an instance keeps no size limit of its own (the file holds one for the component). */\nexport const SIZE_OVERRIDE_FIELDS = onlyRecorded([...SIZE_FIELDS])\nexport const CORNER_OVERRIDE_FIELDS = onlyRecorded([\n 'cornerRadius',\n 'topLeftRadius',\n 'topRightRadius',\n 'bottomLeftRadius',\n 'bottomRightRadius',\n 'cornerSmoothing'\n])\nexport const AUTO_LAYOUT_OVERRIDE_FIELDS = onlyRecorded([\n ...AUTO_LAYOUT_FIELDS,\n 'itemReverseZIndex',\n 'layoutAlignSelf',\n 'layoutGrow',\n 'counterAxisAlignContent'\n])\nexport const GRID_OVERRIDE_FIELDS = onlyRecorded(['layoutGrids', 'gridStyleId'])\n/** Only what a control edits today; overflow and scroll behaviour are whole-layer reset only. */\nexport const CLIP_OVERRIDE_FIELDS = onlyRecorded(['clipsContent'])\nexport const APPEARANCE_OVERRIDE_FIELDS = onlyRecorded(['visible'])\nexport const OPACITY_OVERRIDE_FIELDS = onlyRecorded(['opacity', 'blendMode'])\n\n/** The marker names an agent can pass, each standing for the row's fields. */\nexport const OVERRIDE_FIELD_GROUPS: Readonly<Record<string, readonly string[]>> = {\n fills: FILL_OVERRIDE_FIELDS,\n strokes: STROKE_OVERRIDE_FIELDS,\n effects: EFFECT_OVERRIDE_FIELDS,\n text: TEXT_OVERRIDE_FIELDS,\n size: SIZE_OVERRIDE_FIELDS,\n corners: CORNER_OVERRIDE_FIELDS,\n autoLayout: AUTO_LAYOUT_OVERRIDE_FIELDS,\n layoutGrids: GRID_OVERRIDE_FIELDS,\n clip: CLIP_OVERRIDE_FIELDS,\n appearance: APPEARANCE_OVERRIDE_FIELDS,\n opacity: OPACITY_OVERRIDE_FIELDS\n}\n\n/** One layer of an instance and the fields an edit changed on it, as Figma's `overrides`. */\nexport interface FigmaInstanceOverride {\n id: string\n overriddenFields: string[]\n}\n\n/**\n * The fields Figma desktop 126 lists for an override of each of ours. Unlisted fields are ones\n * Figma does not report: a layer's own size, size limits, clipping, the layout mode, a swap.\n * Figma spells the top stroke weight `stokeTopWeight`.\n */\nconst FIGMA_OVERRIDE_FIELDS: Readonly<Partial<Record<string, readonly string[]>>> = {\n // Figma keeps a size as one field, so a changed width or height lists both.\n width: ['height', 'width'],\n height: ['height', 'width'],\n name: ['name'],\n visible: ['visible'],\n locked: ['locked'],\n text: ['characters', 'styledTextSegments'],\n styleRuns: ['styledTextSegments'],\n textParagraphs: ['styledTextSegments'],\n listSpacing: ['styledTextSegments'],\n fontSize: ['fontSize'],\n fontFamily: ['fontName'],\n fontWeight: ['fontName'],\n italic: ['fontName'],\n fontStyle: ['fontName'],\n letterSpacing: ['letterSpacing'],\n lineHeight: ['lineHeight'],\n textCase: ['textCase'],\n textDecoration: ['textDecoration'],\n textDecorationStyle: ['textDecorationStyle'],\n textDecorationThickness: ['textDecorationThickness'],\n textUnderlineOffset: ['textDecorationOffset'],\n textDecorationFills: ['textDecorationColor'],\n textDecorationSkipInk: ['textDecorationSkipInk'],\n textAlignHorizontal: ['textAlignHorizontal'],\n textAlignVertical: ['textAlignVertical'],\n textAutoResize: ['textAutoResize'],\n textTruncation: ['textTruncation'],\n maxLines: ['maxLines'],\n leadingTrim: ['leadingTrim'],\n paragraphSpacing: ['paragraphSpacing'],\n paragraphIndent: ['paragraphIndent'],\n hangingList: ['hangingList'],\n fills: ['fills'],\n strokes: ['strokes'],\n effects: ['effects'],\n opacity: ['opacity'],\n blendMode: ['blendMode'],\n cornerRadius: [\n 'bottomLeftRadius',\n 'bottomRightRadius',\n 'cornerRadius',\n 'topLeftRadius',\n 'topRightRadius'\n ],\n topLeftRadius: ['topLeftRadius'],\n topRightRadius: ['topRightRadius'],\n bottomRightRadius: ['bottomRightRadius'],\n bottomLeftRadius: ['bottomLeftRadius'],\n cornerSmoothing: ['cornerSmoothing'],\n strokeWeight: [\n 'strokeBottomWeight',\n 'strokeLeftWeight',\n 'strokeRightWeight',\n 'stokeTopWeight',\n 'strokeWeight'\n ],\n borderTopWeight: ['stokeTopWeight'],\n borderRightWeight: ['strokeRightWeight'],\n borderBottomWeight: ['strokeBottomWeight'],\n borderLeftWeight: ['strokeLeftWeight'],\n strokeAlign: ['strokeAlign'],\n strokeCap: ['strokeCap'],\n strokeJoin: ['strokeJoin'],\n strokeMiterLimit: ['strokeMiterLimit'],\n dashPattern: ['dashPattern'],\n layoutWrap: ['layoutWrap'],\n primaryAxisAlign: ['primaryAxisAlignItems'],\n counterAxisAlign: ['counterAxisAlignItems'],\n primaryAxisSizing: ['primaryAxisSizingMode'],\n counterAxisSizing: ['counterAxisSizingMode'],\n itemSpacing: ['itemSpacing'],\n counterAxisSpacing: ['counterAxisSpacing'],\n paddingTop: ['paddingTop'],\n paddingRight: ['paddingRight'],\n paddingBottom: ['paddingBottom'],\n paddingLeft: ['paddingLeft'],\n gridColumnGap: ['gridColumnGap'],\n gridRowGap: ['gridRowGap'],\n itemReverseZIndex: ['itemReverseZIndex'],\n layoutGrids: ['layoutGrids'],\n layoutGrow: ['layoutGrow'],\n layoutAlignSelf: ['layoutAlign'],\n boundVariables: ['boundVariables'],\n variableModes: ['explicitVariableModes'],\n fillStyleId: ['fillStyleId'],\n strokeStyleId: ['strokeStyleId'],\n textStyleId: ['textStyleId'],\n effectStyleId: ['effectStyleId'],\n gridStyleId: ['gridStyleId']\n}\n\n/** Fields a component property sets on a layer, which Figma reports as the property's, not an override. */\nconst PROPERTY_FIELDS: Record<ComponentPropertyReferenceField, readonly string[]> = {\n TEXT: ['text', 'styleRuns', 'textParagraphs'],\n VISIBLE: ['visible'],\n INSTANCE_SWAP: ['componentId', 'name'],\n SLOT_CONTENT: []\n}\n\nfunction propertyFields(node: SceneNode): Set<string> {\n return new Set(node.componentPropertyReferences.flatMap(({ field }) => PROPERTY_FIELDS[field]))\n}\n\n/** Figma sorts the names as spelled right, so its misspelled top weight sorts as `strokeTop…`. */\nconst sortKey = (name: string) => (name === 'stokeTopWeight' ? 'strokeTopWeight' : name)\n\nfunction figmaFields(fields: Iterable<string>, skipped: Set<string>): string[] {\n const names = new Set<string>()\n for (const field of fields) {\n if (skipped.has(field)) continue\n for (const name of FIGMA_OVERRIDE_FIELDS[field] ?? []) names.add(name)\n }\n return [...names].sort((a, b) => sortKey(a).localeCompare(sortKey(b)))\n}\n\n/**\n * The layer of the component a node copies, which its overrides are measured against. A nested\n * instance links to the component's instance it copies, until a swap points it at a component;\n * the enclosing instance then keeps the layer it copied.\n */\nfunction componentLayer(\n graph: SceneGraph,\n node: SceneNode,\n owner: SceneNode | undefined\n): SceneNode | undefined {\n const linked = node.componentId ? graph.getNode(node.componentId) : undefined\n if (node.type !== 'INSTANCE' || linked?.type === 'INSTANCE') {\n return linked ? resolveCopiedLayer(graph, linked) : linked\n }\n const source = owner?.instanceOverrides.descendants.get(node.id)?.get('sourceComponentId')\n if (typeof source === 'string') return graph.getNode(source)\n return componentLayerByName(graph, node, owner)\n}\n\n/**\n * A copy inside a nested instance links to the enclosing component's copy, which in turn links\n * to the nested component's layer. Follow that chain to the layer an edit belongs to.\n */\nfunction resolveCopiedLayer(graph: SceneGraph, linked: SceneNode): SceneNode {\n let target = linked\n for (let depth = 0; depth < 32 && target.componentId; depth++) {\n const parent = target.parentId ? graph.getNode(target.parentId) : undefined\n if (parent?.type !== 'INSTANCE') break\n const next = graph.getNode(target.componentId)\n if (!next) break\n target = next\n }\n return target\n}\n\n/**\n * A copy made by cloning carries no link to its source, so match the path from its instance to\n * the instance's component by sibling position and name.\n */\nfunction componentLayerByName(\n graph: SceneGraph,\n node: SceneNode,\n owner: SceneNode | undefined\n): SceneNode | undefined {\n if (owner?.type !== 'INSTANCE' || !owner.componentId) return undefined\n const path: SceneNode[] = []\n let current: SceneNode | undefined = node\n while (current && current.id !== owner.id) {\n path.unshift(current)\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n if (!current) return undefined\n let source = graph.getNode(owner.componentId)\n // A nested instance copies the enclosing component's nested instance, so follow its link to\n // the component that instance actually shows.\n while (source?.type === 'INSTANCE' && source.componentId)\n source = graph.getNode(source.componentId)\n for (const step of path) {\n if (!source) return undefined\n source = matchingComponentChild(graph, source, step)\n }\n return source\n}\n\n/** The component child a copy at the same place shows, preferring its sibling position. */\nfunction matchingComponentChild(\n graph: SceneGraph,\n source: SceneNode,\n step: SceneNode\n): SceneNode | undefined {\n const siblings = graph.getChildren(source.id)\n const index = step.parentId ? graph.getNode(step.parentId)?.childIds.indexOf(step.id) : -1\n const atIndex = index !== undefined && index >= 0 ? siblings[index] : undefined\n if (atIndex?.type === step.type) return atIndex\n return (\n siblings.find((sibling) => sibling.type === step.type && sibling.name === step.name) ??\n siblings.find((sibling) => sibling.type === step.type)\n )\n}\n\n/** Figma keeps stroke weight and alignment on the layer, so a paint differs by its colour alone. */\nconst paints = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => omit(stroke, ['weight', 'align']))\n\nfunction differs(node: SceneNode, source: SceneNode | undefined, field: string): boolean {\n if (!source) return true\n if (field === 'strokes') return !isEqual(paints(node.strokes), paints(source.strokes))\n return !isEqual(Reflect.get(node, field), Reflect.get(source, field))\n}\n\n/**\n * The fields recorded as edited on a node that still differ from its component layer: an edit\n * kept in the nearest instance above it, and one kept on the node itself if it is an instance.\n * Figma lists a field as overridden only while it differs.\n */\nfunction editedFields(graph: SceneGraph, node: SceneNode, root: SceneNode): string[] {\n const owner =\n node.id === root.id || !node.parentId ? undefined : findInstanceAncestor(graph, node.parentId)\n const source =\n node.id === root.id ? graph.getNode(root.componentId ?? '') : componentLayer(graph, node, owner)\n const fields = [\n ...(node.type === 'INSTANCE' ? node.instanceOverrides.self.keys() : []),\n ...(owner?.instanceOverrides.descendants.get(node.id)?.keys() ?? [])\n ].map((field) =>\n // A mode set for one collection is an override of the layer's modes, as Figma lists it.\n overriddenVariableModeCollection(field) === null ? field : 'variableModes'\n )\n // The instance's own size counts once it differs, as a layer that grows it makes it.\n if (node.id === root.id) fields.push('width', 'height')\n return uniq(fields).filter((field) => differs(node, source, field))\n}\n\n/**\n * Figma's `overrides`: each layer of the instance, itself first and then in layer order, with\n * the fields edited on it, including those inside nested instances. Figma lists no layer's own\n * size but the instance's.\n */\nexport function instanceOverrides(graph: SceneGraph, root: SceneNode): FigmaInstanceOverride[] {\n const result: FigmaInstanceOverride[] = []\n const visit = (node: SceneNode) => {\n const parentId = node.parentId\n // Content an instance put in a slot is its own layer, not an override Figma lists; layers\n // inside it can still carry overrides of nested instances.\n const slotContent =\n node.id !== root.id && !!parentId && slotScope(graph, parentId).kind === 'slot'\n if (!slotContent) {\n const skipped = propertyFields(node)\n if (node.id !== root.id) skipped.add('width').add('height')\n const overriddenFields = figmaFields(editedFields(graph, node, root), skipped)\n if (overriddenFields.length > 0) result.push({ id: node.id, overriddenFields })\n }\n for (const child of graph.getChildren(node.id)) visit(child)\n }\n visit(root)\n return result\n}\n\n/** Clears an override state but what component properties set, which Figma keeps on reset. */\nfunction withoutEdits(graph: SceneGraph, state: InstanceOverrideState): InstanceOverrideState {\n const keep = (nodeId: string, fields: Map<string, unknown>) => {\n // A layer the instance itself put inside a slot is its content, not a component override:\n // Reset all changes keeps it whole, as Figma does.\n const parentId = graph.getNode(nodeId)?.parentId\n if (parentId && slotScope(graph, parentId).kind === 'slot') return new Map(fields)\n const node = graph.getNode(nodeId)\n const driven = node ? propertyFields(node) : new Set<string>()\n return new Map([...fields].filter(([field]) => driven.has(field)))\n }\n const descendants = new Map(\n [...state.descendants]\n .map(([nodeId, fields]) => [nodeId, keep(nodeId, fields)] as const)\n .filter(([, fields]) => fields.size > 0)\n )\n return { self: new Map(), descendants }\n}\n\n/** Every instance at or below `root`, deepest first, as pushing each one's edits needs them. */\nfunction instancesDeepestFirst(graph: SceneGraph, root: SceneNode): SceneNode[] {\n const result: SceneNode[] = []\n const visit = (node: SceneNode): void => {\n for (const child of graph.getChildren(node.id)) visit(child)\n if (node.type === 'INSTANCE') result.push(node)\n }\n visit(root)\n return result\n}\n\n/** The main component an instance's own edits belong to, if it can take them. */\nfunction pushableMainComponent(\n graph: SceneGraph,\n instance: SceneNode,\n canEditMain: ((componentId: string) => boolean) | undefined\n): SceneNode | null {\n let component = instance.componentId ? graph.getNode(instance.componentId) : undefined\n // A nested copy's link points at the enclosing component's nested instance, not at the\n // component that instance shows, so follow it to the main component the edits belong to.\n while (component?.type === 'INSTANCE' && component.componentId) {\n component = graph.getNode(component.componentId)\n }\n if (component?.type !== 'COMPONENT') return null\n if (canEditMain && !canEditMain(component.id)) return null\n return component\n}\n\n/**\n * Applies one recorded override field from an instance layer to the component layer it copies.\n * Returns whether the field was a text pushed into a component property's default.\n */\nfunction pushOverrideField(\n graph: SceneGraph,\n target: SceneNode,\n source: SceneNode,\n field: string\n): boolean {\n // A source link is bookkeeping for sync; a replaced layer is a structural edit, not a field.\n if (field === 'sourceComponentId' || field === REPLACED_LAYER_OVERRIDE) return false\n // Assigning a component property belongs to the instance, not to the main component.\n if (overriddenAssignmentId(field) !== null) return false\n const collection = overriddenVariableModeCollection(field)\n if (collection !== null) {\n const modes = Object.hasOwn(source.variableModes, collection)\n ? { ...target.variableModes, [collection]: source.variableModes[collection] }\n : omit(target.variableModes, [collection])\n graph.updateNode(target.id, { variableModes: modes })\n return false\n }\n const binding = overriddenBindingField(field)\n if (binding !== null) {\n const bindings = Object.hasOwn(source.boundVariables, binding)\n ? {\n ...target.boundVariables,\n [binding]: structuredClone(source.boundVariables[binding])\n }\n : omit(target.boundVariables, [binding])\n graph.updateNode(target.id, { boundVariables: bindings })\n return false\n }\n const value = Reflect.get(source, field)\n if (value === undefined) return false\n const defaulted =\n field === 'text' && typeof value === 'string'\n ? pushBoundTextDefault(graph, target, value)\n : false\n graph.updateNode(target.id, { [field]: structuredClone(value) })\n return defaulted\n}\n\n/** The override state after a push: property values stay, but a text pushed as a default goes. */\nfunction clearedAfterPush(\n graph: SceneGraph,\n state: InstanceOverrideState,\n defaulted: Set<string>\n): InstanceOverrideState {\n const cleared = withoutEdits(graph, state)\n const descendants = new Map(cleared.descendants)\n for (const nodeId of defaulted) {\n const fields = descendants.get(nodeId)\n if (!fields) continue\n fields.delete('text')\n if (fields.size === 0) descendants.delete(nodeId)\n }\n return { self: cleared.self, descendants }\n}\n\n/**\n * A text layer bound to a text property shows the property's default on the main component.\n * Pushing the edit moves that default with it, so the canvas and the property panel agree.\n * Returns whether the field was pushed as a default.\n */\nfunction pushBoundTextDefault(graph: SceneGraph, target: SceneNode, text: string): boolean {\n const propertyId = target.componentPropertyReferences.find(\n (reference) => reference.field === 'TEXT'\n )?.propertyId\n if (!propertyId) return false\n const owner = graph.closest(\n target.parentId ?? target.id,\n (node) =>\n (node.type === 'COMPONENT' || node.type === 'COMPONENT_SET') &&\n node.componentPropertyDefinitions.some((definition) => definition.id === propertyId)\n )\n const definition = owner?.componentPropertyDefinitions.find((item) => item.id === propertyId)\n if (!owner || !definition) return false\n if (definition.defaultValue !== text)\n graph.updateNode(owner.id, {\n componentPropertyDefinitions: owner.componentPropertyDefinitions.map((item) =>\n item.id === propertyId ? { ...item, defaultValue: text } : item\n )\n })\n // Every other definition layer the property drives follows the new default, as editing the\n // default does. A nested instance's copies belong to their own component and are left to sync.\n const visit = (node: SceneNode): void => {\n for (const child of graph.getChildren(node.id)) {\n if (child.type === 'INSTANCE') continue\n if (\n child.type === 'TEXT' &&\n child.componentPropertyReferences.some(\n (reference) => reference.propertyId === propertyId && reference.field === 'TEXT'\n )\n )\n graph.updateNode(child.id, { text })\n visit(child)\n }\n }\n visit(owner)\n return true\n}\n\n/**\n * Whether pushing `root`'s changes can reach every main component they belong to. Pushing is\n * refused for a library component, whose main is read-only.\n */\nexport function canPushInstanceOverrides(\n graph: SceneGraph,\n root: SceneNode,\n canEditMain?: (componentId: string) => boolean\n): boolean {\n if (root.type !== 'INSTANCE') return false\n let found = false\n for (const instance of instancesDeepestFirst(graph, root)) {\n if (\n instance.instanceOverrides.self.size === 0 &&\n instance.instanceOverrides.descendants.size === 0\n )\n continue\n if (!pushableMainComponent(graph, instance, canEditMain)) return false\n found = true\n }\n return found\n}\n\n/**\n * Figma's Push changes to main component: writes the edits of `root` and the instances inside\n * it to their own main components, then clears those edits so every instance follows. A\n * nested instance's edits go to its nested main; the outer main then picks them up by sync.\n * Returns false, changing nothing, when a main component is missing or read-only.\n */\nexport function pushInstanceOverrides(\n graph: SceneGraph,\n root: SceneNode,\n canEditMain?: (componentId: string) => boolean\n): boolean {\n if (!canPushInstanceOverrides(graph, root, canEditMain)) return false\n const instances = instancesDeepestFirst(graph, root).filter(\n (instance) =>\n instance.instanceOverrides.self.size > 0 || instance.instanceOverrides.descendants.size > 0\n )\n const components: string[] = []\n const defaulted = new Set<string>()\n for (const instance of instances) {\n const main = pushableMainComponent(graph, instance, canEditMain)\n if (!main) return false\n if (!components.includes(main.id)) components.push(main.id)\n const state = instance.instanceOverrides\n for (const [field] of state.self) {\n pushOverrideField(graph, main, instance, field)\n }\n for (const [nodeId, fields] of state.descendants) {\n const node = graph.getNode(nodeId)\n if (!node) continue\n const owner = node.parentId ? findInstanceAncestor(graph, node.parentId) : undefined\n const target = componentLayer(graph, node, owner)\n if (!target) continue\n for (const [field] of fields) {\n if (pushOverrideField(graph, target, node, field)) defaulted.add(nodeId)\n }\n }\n }\n for (const instance of instances) {\n graph.updateNode(instance.id, {\n instanceOverrides: clearedAfterPush(graph, instance.instanceOverrides, defaulted)\n })\n }\n // Deepest main first, then every component holding an instance of one: an outer main syncs\n // the nested instance the inner main changed, and so on up to the page.\n graph.syncInstancesTogether(followingComponents(graph, components))\n return true\n}\n\n/** The pushed mains and every component whose instances show one of them, deepest first. */\nfunction followingComponents(graph: SceneGraph, components: string[]): string[] {\n const order: string[] = []\n const seen = new Set<string>()\n const visit = (id: string): void => {\n if (seen.has(id)) return\n seen.add(id)\n order.push(id)\n for (const instance of graph.getInstances(id)) {\n const holder = instance.parentId\n ? graph.closest(instance.parentId, (node) => node.type === 'COMPONENT')\n : undefined\n if (holder) visit(holder.id)\n }\n }\n for (const id of components) visit(id)\n return order\n}\n\n/**\n * Figma's `resetOverrides`: the instance and every instance inside it go back to their\n * components, keeping the values their component properties set.\n */\n/** The fields a marker name stands for: itself plus every recorded key it owns. */\nexport function overrideRecordedKeys(fields: readonly string[]): string[] {\n const keys = new Set<string>(fields)\n for (const [recorded, owner] of Object.entries(INSTANCE_SYNC_FIELD_OWNERS)) {\n if (owner && fields.includes(owner)) keys.add(recorded)\n }\n return [...keys]\n}\n\n/** Whether a name is a field the property markers can reset. */\nexport function isOverrideMarkerField(field: string): boolean {\n return (\n Object.hasOwn(OVERRIDE_FIELD_GROUPS, field) ||\n (INSTANCE_OVERRIDE_FIELDS as readonly string[]).includes(field) ||\n Object.values(INSTANCE_SYNC_FIELD_OWNERS).includes(field)\n )\n}\n\n/** The recorded keys a marker name's row writes: the group's fields and their owned keys. */\nfunction resetKeys(fields: readonly string[]): string[] {\n const names = fields.flatMap((field) => OVERRIDE_FIELD_GROUPS[field] ?? [field])\n return overrideRecordedKeys(names)\n}\n\n/**\n * Resets named fields on one layer of an instance, as the property markers do, and syncs the\n * outermost instance once. Without fields it resets the whole layer; an instance resets its own\n * self state. Returns an error for slot content, which is the instance's content, not an override.\n */\nexport function resetInstanceOverrideFields(\n graph: SceneGraph,\n nodeId: string,\n fields?: readonly string[]\n): string | null {\n const node = graph.getNode(nodeId)\n if (!node) return `Node \"${nodeId}\" not found.`\n const parentId = node.type === 'INSTANCE' ? undefined : node.parentId\n if (parentId && slotScope(graph, parentId).kind === 'slot')\n return 'slot content is not an override; reset the content instead.'\n let owner: SceneNode | undefined = node.type === 'INSTANCE' ? node : undefined\n if (!owner && node.parentId) owner = findInstanceAncestor(graph, node.parentId)\n if (!owner) return `Layer \"${nodeId}\" is not inside an instance.`\n if (fields) {\n const unknown = fields.find((field) => !isOverrideMarkerField(field))\n if (unknown !== undefined) return `Unknown override field \"${unknown}\".`\n }\n const keys = fields ? resetKeys(fields) : undefined\n const without = (state: InstanceOverrideState, targetId: string): void => {\n if (!keys) {\n state.descendants.delete(targetId)\n return\n }\n const entry = state.descendants.get(targetId)\n if (!entry) return\n for (const key of keys) entry.delete(key)\n if (entry.size === 0) state.descendants.delete(targetId)\n }\n if (node.type === 'INSTANCE') {\n const state = cloneInstanceOverrideState(node.instanceOverrides)\n if (keys) for (const field of keys) state.self.delete(field)\n else clearInstanceOverrides(state)\n graph.updateNode(node.id, { instanceOverrides: state })\n if (node.id !== owner.id) {\n const holding = cloneInstanceOverrideState(owner.instanceOverrides)\n without(holding, node.id)\n graph.updateNode(owner.id, { instanceOverrides: holding })\n }\n } else {\n const state = cloneInstanceOverrideState(owner.instanceOverrides)\n without(state, node.id)\n graph.updateNode(owner.id, { instanceOverrides: state })\n }\n let outermost = owner\n for (\n let parent = owner.parentId ? findInstanceAncestor(graph, owner.parentId) : undefined;\n parent;\n ) {\n outermost = parent\n parent = parent.parentId ? findInstanceAncestor(graph, parent.parentId) : undefined\n }\n graph.syncInstance(outermost.id)\n return null\n}\n\nexport function resetInstanceOverrides(graph: SceneGraph, root: SceneNode): void {\n // A layer put in place of a component's layer goes, and the sync brings that layer back.\n const replaced: string[] = []\n const collect = (node: SceneNode) => {\n for (const child of graph.getChildren(node.id)) {\n if (isReplacedLayer(graph, child)) replaced.push(child.id)\n else collect(child)\n }\n }\n collect(root)\n for (const id of replaced) graph.deleteNode(id)\n const visit = (node: SceneNode) => {\n if (node.type === 'INSTANCE')\n graph.updateNode(node.id, { instanceOverrides: withoutEdits(graph, node.instanceOverrides) })\n for (const child of graph.getChildren(node.id)) visit(child)\n }\n visit(root)\n // The outermost instance passes its component's content down to the ones inside it.\n let outermost = root\n for (\n let parent = root.parentId ? findInstanceAncestor(graph, root.parentId) : undefined;\n parent;\n ) {\n outermost = parent\n parent = parent.parentId ? findInstanceAncestor(graph, parent.parentId) : undefined\n }\n graph.syncInstance(outermost.id)\n}\n\nexport function installInstanceOverrideAccessors(\n prototype: object,\n internals: NodeProxyInternals\n): void {\n Object.defineProperties(prototype, {\n overrides: {\n get(this: ProxyThis): FigmaInstanceOverride[] | undefined {\n const node = raw(this, internals)\n if (node.type !== 'INSTANCE') return undefined\n // Figma lists the size its layout gives the instance.\n flushPendingLayout(graph(this, internals))\n return instanceOverrides(graph(this, internals), node)\n }\n },\n resetOverrides: {\n value(this: ProxyThis) {\n const node = raw(this, internals)\n if (node.type !== 'INSTANCE')\n throw new TypeError('resetOverrides() can only be called on instances')\n assertProxyEditable(this, internals)\n resetInstanceOverrides(graph(this, internals), node)\n }\n }\n })\n}\n"],"mappings":";;;;;;;;;;AAgCA,MAAM,2BAA2B,IAAI,IAAY,wBAAwB;AACzE,MAAM,gBAAgB,WACpB,OAAO,QAAQ,UAAU,yBAAyB,IAAI,KAAK,CAAC;AAM9D,MAAa,uBAAuB,aAAa,CAAC,SAAS,aAAa,CAAC;AACzE,MAAa,yBAAyB,aAAa;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAa,yBAAyB,aAAa,CAAC,WAAW,eAAe,CAAC;AAC/E,MAAa,uBAAuB,aAAa;CAC/C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAED,MAAa,uBAAuB,aAAa,CAAC,GAAG,WAAW,CAAC;AACjE,MAAa,yBAAyB,aAAa;CACjD;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAa,8BAA8B,aAAa;CACtD,GAAG;CACH;CACA;CACA;CACA;AACF,CAAC;AACD,MAAa,uBAAuB,aAAa,CAAC,eAAe,aAAa,CAAC;;AAE/E,MAAa,uBAAuB,aAAa,CAAC,cAAc,CAAC;AACjE,MAAa,6BAA6B,aAAa,CAAC,SAAS,CAAC;AAClE,MAAa,0BAA0B,aAAa,CAAC,WAAW,WAAW,CAAC;;AAG5E,MAAa,wBAAqE;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set maskType(v: string);
|
|
231
|
+
get booleanOperation(): string | undefined;
|
|
232
|
+
set booleanOperation(v: string);
|
|
231
233
|
get expanded(): boolean;
|
|
232
234
|
set expanded(v: boolean);
|
|
233
235
|
get backgrounds(): readonly FigmaPaint[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","names":[],"sources":["../../src/figma-api/proxy.ts"],"mappings":";;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","names":[],"sources":["../../src/figma-api/proxy.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAkEM;cAIO;cACA;cACA;;UAGI;EACf,OAAO,mBAAmB;EAC1B,cAAc,mBAAmB;;iBASnB,YAAY,KAAK,eAAe,MAAM;iBAItC,SAAS,KAAK,eAAe,iBAAiB;;iBAK9C,WAAW,KAAK,eAAe,iBAAiB;UAI/C;EACf,SAAS,aAAa;WACb;;WAEA,iBAAiB;;cAgBf;GACV;GACA,iBAAiB;GACjB,eAAe;WAEC;;WAEA,MAAM;EACf;WACS;EACT;EACA;WACS;WACA;EACT;EACA,mBAAmB;EACnB,SAAS,eAAe;EACxB,2BAA2B,eAAe;EAC1C,UAAU;WACD,mBAAmB;WACnB,qBAAqB;WACrB,sBAAsB;EAE/B,gBAAgB;EAChB,kBAAkB;EAClB,kBAAkB;EAClB;EACA;EACA;EACA,WAAW;EACX;EACA;EACA,mBAAmB;EACnB,gBAAgB;EAChB,8BAA8B;EAC9B;EACA;EACA;EACA;EACA;EAEA,YAAY;EACZ,sBAAsB;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAe;IAAoB;;EACnC;EACA;EACA;EACA;WACS,mBAAmB;;EAE5B;EACA;EACA;EACA;EACA;EACA,SAAS,SAAS;EAClB,sBAAsB;EACtB,eAAe;EACf,wBAAwB,eAAe,uBAAuB;EAC9D,iBAAiB,sCAAsC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oBACA,WAAU;EAKZ,iBAAiB,eAAe;MAI5B;MAIA,OAAO;MAOP;MAIA,SAAS;MAKT;MAIA,iBAAiB;MAOjB;MAIA,SAAS;MAMT,wBAAwB;MAUxB,YAAY,gBAAgB;;EAM1B,yBAAyB,QAAQ;MAInC,iBAAiB;EAQrB,kBAAkB;;EAWlB,kBAAkB;;EAUlB,cAAc,WAAW;MAWrB,UAAU;MAMV,YAAY;EAOhB,YAAY,OAAO;;;;;UAiBX;EAaR,YAAY,eAAe,OAAO;EAclC,SAAS;EAiBT;EAWA,QAAQ,YAAY,MAAM,6BAA6B;EAIvD,QAAQ,WAAW,MAAM,6BAA6B;EAItD,UAAU,WAAW,MAAM,6BAA6B;EASxD,aAAa,YAAY,MAAM,6BAA6B;EAS5D,oBAAoB;IAAY;MAAqB;EAWrD,OAAO,mBAAmB,wBAAmB;EAU7C"}
|
package/dist/figma-api/proxy.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getPageBackgrounds, setPageBackgrounds } from "./page-backgrounds.js";
|
|
2
2
|
import { assertNodeEditable } from "../editor/capabilities.js";
|
|
3
|
-
import { parseFigmaPaints, toFigmaPaint } from "./paints.js";
|
|
4
3
|
import { underlyingGraph } from "./graph-ref.js";
|
|
5
4
|
import { flushPendingComponentSync } from "./pending-sync.js";
|
|
6
5
|
import { fitGroupsAround, prepareFollowedFieldEdit } from "./accessor-utils.js";
|
|
6
|
+
import { installSlotAccessors, prepareNodeClone, prepareSlotMove, prepareSlotRemoval } from "./slots.js";
|
|
7
|
+
import { parseFigmaPaints, toFigmaPaint } from "./paints.js";
|
|
7
8
|
import { installInstanceOverrideAccessors } from "./overrides.js";
|
|
8
|
-
import { installSlotAccessors, prepareSlotMove, prepareSlotRemoval } from "./slots.js";
|
|
9
9
|
import { installComponentPropertyAccessors } from "./components.js";
|
|
10
10
|
import { installDevStatusAccessors } from "./dev-status.js";
|
|
11
11
|
import { containerTransform, setContainerTransform } from "./transform.js";
|
|
@@ -105,6 +105,13 @@ var FigmaNodeProxy = class {
|
|
|
105
105
|
prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), "maskType", "mask-type");
|
|
106
106
|
this._update({ maskType: v });
|
|
107
107
|
}
|
|
108
|
+
get booleanOperation() {
|
|
109
|
+
return this._raw().booleanOperation;
|
|
110
|
+
}
|
|
111
|
+
set booleanOperation(v) {
|
|
112
|
+
if (this._raw().type !== "BOOLEAN_OPERATION") return;
|
|
113
|
+
this._update({ booleanOperation: v });
|
|
114
|
+
}
|
|
108
115
|
get expanded() {
|
|
109
116
|
return this._raw().expanded;
|
|
110
117
|
}
|
|
@@ -200,6 +207,7 @@ var FigmaNodeProxy = class {
|
|
|
200
207
|
clone() {
|
|
201
208
|
assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID]);
|
|
202
209
|
const parentId = this._raw().parentId ?? this[INTERNAL_API].currentPageId;
|
|
210
|
+
prepareNodeClone(this[INTERNAL_GRAPH], this[INTERNAL_ID], "clone");
|
|
203
211
|
const cloned = this[INTERNAL_GRAPH].cloneTree(this[INTERNAL_ID], parentId);
|
|
204
212
|
if (!cloned) throw new Error(`Failed to clone node ${this[INTERNAL_ID]}`);
|
|
205
213
|
if (slotPropertyId(cloned)) this[INTERNAL_GRAPH].updateNode(cloned.id, { componentPropertyReferences: cloned.componentPropertyReferences.filter((reference) => reference.field !== "SLOT_CONTENT") });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","names":["Traversal.findAll","Traversal.findOne","Traversal.findChild","Traversal.findChildren","Traversal.findAllWithCriteria"],"sources":["../../src/figma-api/proxy.ts"],"sourcesContent":["import type {\n ArcData,\n HyperlinkTarget,\n SceneGraph,\n SceneNode,\n NodeType,\n LayoutGrid,\n LayoutMode,\n OverflowDirection,\n ScrollBehavior\n} from '@pairdraw/scene-graph'\nimport { attachedConnectors } from '@pairdraw/scene-graph/connectors'\nimport type { GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'\nimport { createsComponentCycle, recordInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport type { ShapeWithTextType } from '@pairdraw/scene-graph/shape-with-text'\nimport { slotPropertyId } from '@pairdraw/scene-graph/slots'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport type { FigmaEffect } from '#core/figma-api/effects'\n\nimport { prepareFollowedFieldEdit, fitGroupsAround } from './accessor-utils'\nimport { installBasicNodeProxyAccessors } from './accessors/basic'\nimport { installConnectorNodeProxyAccessors } from './accessors/connector'\nimport { installLayoutNodeProxyAccessors } from './accessors/layout'\nimport { installReactionAccessors } from './accessors/reactions'\nimport { installShapeNodeProxyAccessors } from './accessors/shape'\nimport { installStickyNodeProxyAccessors, pluginChildren } from './accessors/sticky'\nimport { installStrokeNodeProxyAccessors } from './accessors/strokes'\nimport { installTextNodeProxyAccessors } from './accessors/text'\nimport { installTextRangeMethods, type TextRangeMethods } from './accessors/text/ranges'\nimport {\n installVariableModeNodeProxyAccessors,\n type VariableNodeMembers\n} from './accessors/variables'\nimport {\n installVectorNodeProxyAccessors,\n type FigmaVectorNetwork,\n type FigmaVectorPath\n} from './accessors/vector'\nimport { installVisualNodeProxyAccessors } from './accessors/visual'\nimport { installComponentPropertyAccessors } from './components'\nimport { installDevStatusAccessors, type FigmaDevStatusValue } from './dev-status'\nimport type { FigmaFontName } from './fonts/names'\nimport { underlyingGraph } from './graph-ref'\nimport type { FigmaFrameNode, FigmaInstanceNode } from './node-types'\nimport { installInstanceOverrideAccessors, type FigmaInstanceOverride } from './overrides'\nimport { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from './paints'\nimport { flushPendingComponentSync } from './pending-sync'\nimport { installPluginDataMethods, type PluginDataMethods } from './plugin-data'\nimport type { FigmaReaction } from './reactions'\nimport { nodeProxyToJSON } from './serialization'\nimport { installShapeWithTextAccessors } from './shape-with-text'\nimport { installSlotAccessors, prepareSlotMove, prepareSlotRemoval } from './slots'\nimport type { FigmaLetterSpacing, FigmaLineHeight } from './text'\nimport * as TextProxy from './text'\nimport { containerTransform, setContainerTransform } from './transform'\nimport * as Traversal from './traversal'\nimport type { FigmaTransform } from './types'\n\nconst MIXED = Symbol('mixed')\n\nexport type { FigmaFont, FigmaFontName } from './fonts/names'\n\nexport const INTERNAL_ID = Symbol('id')\nexport const INTERNAL_GRAPH = Symbol('graph')\nexport const INTERNAL_API = Symbol('api')\n\n/** How a host loads pages as they are visited; see `FigmaAPIOptions`. */\nexport interface PageHost {\n load: (pageId: string) => Promise<void>\n pageOfNode?: (nodeId: string) => Promise<string | null>\n}\n\n/**\n * How each API loads a page's layers, a host's hook kept off `figma`, which has only Figma's\n * members. Without one every page is in memory.\n */\nconst pageHosts = new WeakMap<NodeProxyHost, PageHost>()\n\nexport function setPageHost(api: NodeProxyHost, host: PageHost): void {\n pageHosts.set(api, host)\n}\n\nexport function loadPage(api: NodeProxyHost, pageId: string): Promise<void> {\n return pageHosts.get(api)?.load(pageId) ?? Promise.resolve()\n}\n\n/** The page holding a layer not loaded yet, which loading that page brings in. */\nexport function pageOfNode(api: NodeProxyHost, nodeId: string): Promise<string | null> {\n return pageHosts.get(api)?.pageOfNode?.(nodeId) ?? Promise.resolve(null)\n}\n\nexport interface NodeProxyHost {\n wrapNode(id: string): FigmaNodeProxy\n readonly currentPageId: string\n /** How groups and booleans refit; booleans size to their result when a renderer is attached. */\n readonly groupFitOptions: GroupFitOptions\n}\n\nexport { MIXED }\n\n/** Figma refuses a move that would make a component contain itself. */\nfunction assertNoComponentCycle(\n graph: SceneGraph,\n parentId: string,\n childId: string,\n method: 'appendChild' | 'insertChild'\n): void {\n if (createsComponentCycle(graph, childId, parentId))\n throw new Error(`in ${method}: Cannot move node. Reparenting would create a component cycle`)\n}\n\nexport class FigmaNodeProxy {\n [INTERNAL_ID]: string;\n [INTERNAL_GRAPH]: SceneGraph;\n [INTERNAL_API]: NodeProxyHost\n\n declare readonly id: string\n /** A slot frame reads as `'SLOT'`, as Figma's `SlotNode` does. */\n declare readonly type: NodeType | 'SLOT'\n declare name: string\n declare readonly removed: boolean\n declare x: number\n declare y: number\n declare readonly width: number\n declare readonly height: number\n declare rotation: number\n declare relativeTransform: FigmaTransform\n declare resize: (width: number, height: number) => void\n declare resizeWithoutConstraints: (width: number, height: number) => void\n declare rescale: (scale: number) => void\n declare readonly absoluteTransform: FigmaTransform\n declare readonly absoluteBoundingBox: Rect\n declare readonly absoluteRenderBounds: Rect | null\n\n declare fills: readonly FigmaPaint[] | symbol\n declare strokes: readonly FigmaPaint[]\n declare effects: readonly FigmaEffect[]\n declare opacity: number\n declare visible: boolean\n declare locked: boolean\n declare devStatus: FigmaDevStatusValue | undefined\n declare blendMode: string\n declare clipsContent: boolean\n declare overflowDirection: OverflowDirection\n declare scrollBehavior: ScrollBehavior\n declare cornerRadius: number | typeof MIXED\n declare topLeftRadius: number\n declare topRightRadius: number\n declare bottomLeftRadius: number\n declare bottomRightRadius: number\n declare cornerSmoothing: number\n\n declare layoutMode: LayoutMode\n declare layoutGrids: readonly LayoutGrid[]\n declare primaryAxisAlignItems: string\n declare counterAxisAlignItems: string\n declare itemSpacing: number\n declare counterAxisSpacing: number\n declare paddingTop: number\n declare paddingRight: number\n declare paddingBottom: number\n declare paddingLeft: number\n declare layoutWrap: string\n declare primaryAxisSizingMode: string\n declare counterAxisSizingMode: string\n declare counterAxisAlignContent: string\n declare itemReverseZIndex: boolean\n declare strokesIncludedInLayout: boolean\n declare layoutPositioning: string\n declare layoutGrow: number\n declare layoutAlign: string\n declare layoutSizingHorizontal: string\n declare layoutSizingVertical: string\n declare constraints: { horizontal: string; vertical: string }\n declare minWidth: number | null\n declare maxWidth: number | null\n declare minHeight: number | null\n declare maxHeight: number | null\n declare readonly targetAspectRatio: Vector | null\n /** @deprecated Figma's alias for whether `targetAspectRatio` is set. */\n declare constrainProportions: boolean\n declare lockAspectRatio: () => void\n declare unlockAspectRatio: () => void\n declare pointCount: number\n declare innerRadius: number\n declare arcData: Readonly<ArcData>\n declare vectorPaths: readonly FigmaVectorPath[]\n declare vectorNetwork: FigmaVectorNetwork\n declare setVectorNetworkAsync: (vectorNetwork: FigmaVectorNetwork) => Promise<void>\n declare handleMirroring: SceneNode['handleMirroring'] | typeof MIXED\n declare getPluginData: PluginDataMethods['getPluginData']\n declare setPluginData: PluginDataMethods['setPluginData']\n declare getPluginDataKeys: PluginDataMethods['getPluginDataKeys']\n declare getSharedPluginData: PluginDataMethods['getSharedPluginData']\n declare setSharedPluginData: PluginDataMethods['setSharedPluginData']\n declare getSharedPluginDataKeys: PluginDataMethods['getSharedPluginDataKeys']\n declare readonly explicitVariableModes: VariableNodeMembers['explicitVariableModes']\n declare readonly resolvedVariableModes: VariableNodeMembers['resolvedVariableModes']\n declare setExplicitVariableModeForCollection: VariableNodeMembers['setExplicitVariableModeForCollection']\n declare clearExplicitVariableModeForCollection: VariableNodeMembers['clearExplicitVariableModeForCollection']\n declare readonly boundVariables: VariableNodeMembers['boundVariables']\n declare setBoundVariable: VariableNodeMembers['setBoundVariable']\n declare readonly overrides: FigmaInstanceOverride[] | undefined\n /** Prototype connections, in Figma's plugin shape; refused when the play cannot run them. */\n declare reactions: readonly FigmaReaction[]\n /** A sticky note's body or a shape's label, a sticky's author line, and whether it is wide. */\n declare readonly text: FigmaNodeProxy | undefined\n declare readonly authorName: string | undefined\n declare authorVisible: boolean | undefined\n declare isWideWidth: boolean | undefined\n declare shapeType: ShapeWithTextType | undefined\n /** On pages alone, as in Figma. */\n declare loadAsync: () => Promise<void>\n declare resetOverrides: () => void\n\n declare strokeWeight: number\n declare strokeAlign: string\n declare dashPattern: readonly number[]\n declare strokeCap: string\n declare strokeJoin: string\n declare strokeMiterLimit: number\n declare strokeTopWeight: number\n declare strokeBottomWeight: number\n declare strokeLeftWeight: number\n declare strokeRightWeight: number\n\n declare characters: string\n declare fontSize: number | symbol\n declare fontName: FigmaFontName | symbol\n declare fontWeight: number | symbol\n declare textAlignHorizontal: string\n declare textAlignVertical: string\n declare textAutoResize: string\n declare letterSpacing: FigmaLetterSpacing | symbol\n declare lineHeight: FigmaLineHeight | symbol\n declare textCase: SceneNode['textCase'] | symbol\n declare hyperlink: HyperlinkTarget | null | symbol\n declare textStyleId: string | symbol\n declare fillStyleId: string | symbol\n declare textDecoration: SceneNode['textDecoration'] | symbol\n declare readonly openTypeFeatures: Record<string, boolean> | symbol\n declare maxLines: number | null\n declare listSpacing: number | symbol\n declare paragraphSpacing: number | symbol\n declare paragraphIndent: number | symbol\n declare hangingList: boolean\n declare textTruncation: string\n declare autoRename: boolean\n\n // Per-character and per-paragraph methods: accessors/text/ranges.ts.\n declare getStyledTextSegments: TextRangeMethods['getStyledTextSegments']\n declare getRangeAllFontNames: TextRangeMethods['getRangeAllFontNames']\n declare getRangeFontSize: TextRangeMethods['getRangeFontSize']\n declare setRangeFontSize: TextRangeMethods['setRangeFontSize']\n declare getRangeFontName: TextRangeMethods['getRangeFontName']\n declare setRangeFontName: TextRangeMethods['setRangeFontName']\n declare getRangeFontWeight: TextRangeMethods['getRangeFontWeight']\n declare getRangeFills: TextRangeMethods['getRangeFills']\n declare setRangeFills: TextRangeMethods['setRangeFills']\n declare getRangeLetterSpacing: TextRangeMethods['getRangeLetterSpacing']\n declare setRangeLetterSpacing: TextRangeMethods['setRangeLetterSpacing']\n declare getRangeLineHeight: TextRangeMethods['getRangeLineHeight']\n declare setRangeLineHeight: TextRangeMethods['setRangeLineHeight']\n declare getRangeTextDecoration: TextRangeMethods['getRangeTextDecoration']\n declare setRangeTextDecoration: TextRangeMethods['setRangeTextDecoration']\n declare getRangeTextDecorationStyle: TextRangeMethods['getRangeTextDecorationStyle']\n declare setRangeTextDecorationStyle: TextRangeMethods['setRangeTextDecorationStyle']\n declare getRangeTextDecorationOffset: TextRangeMethods['getRangeTextDecorationOffset']\n declare setRangeTextDecorationOffset: TextRangeMethods['setRangeTextDecorationOffset']\n declare getRangeTextDecorationThickness: TextRangeMethods['getRangeTextDecorationThickness']\n declare setRangeTextDecorationThickness: TextRangeMethods['setRangeTextDecorationThickness']\n declare getRangeTextDecorationColor: TextRangeMethods['getRangeTextDecorationColor']\n declare setRangeTextDecorationColor: TextRangeMethods['setRangeTextDecorationColor']\n declare getRangeTextDecorationSkipInk: TextRangeMethods['getRangeTextDecorationSkipInk']\n declare setRangeTextDecorationSkipInk: TextRangeMethods['setRangeTextDecorationSkipInk']\n declare getRangeOpenTypeFeatures: TextRangeMethods['getRangeOpenTypeFeatures']\n declare getRangeListOptions: TextRangeMethods['getRangeListOptions']\n declare setRangeListOptions: TextRangeMethods['setRangeListOptions']\n declare getRangeIndentation: TextRangeMethods['getRangeIndentation']\n declare setRangeIndentation: TextRangeMethods['setRangeIndentation']\n declare getRangeListSpacing: TextRangeMethods['getRangeListSpacing']\n declare setRangeListSpacing: TextRangeMethods['setRangeListSpacing']\n declare getRangeParagraphSpacing: TextRangeMethods['getRangeParagraphSpacing']\n declare setRangeParagraphSpacing: TextRangeMethods['setRangeParagraphSpacing']\n declare getRangeParagraphIndent: TextRangeMethods['getRangeParagraphIndent']\n declare setRangeParagraphIndent: TextRangeMethods['setRangeParagraphIndent']\n declare getRangeTextCase: TextRangeMethods['getRangeTextCase']\n declare setRangeTextCase: TextRangeMethods['setRangeTextCase']\n declare getRangeHyperlink: TextRangeMethods['getRangeHyperlink']\n declare setRangeHyperlink: TextRangeMethods['setRangeHyperlink']\n declare getRangeTextStyleId: TextRangeMethods['getRangeTextStyleId']\n declare setRangeTextStyleId: TextRangeMethods['setRangeTextStyleId']\n declare setRangeTextStyleIdAsync: TextRangeMethods['setRangeTextStyleIdAsync']\n declare getRangeFillStyleId: TextRangeMethods['getRangeFillStyleId']\n declare setRangeFillStyleId: TextRangeMethods['setRangeFillStyleId']\n declare setRangeFillStyleIdAsync: TextRangeMethods['setRangeFillStyleIdAsync']\n declare getRangeBoundVariable: TextRangeMethods['getRangeBoundVariable']\n declare setRangeBoundVariable: TextRangeMethods['setRangeBoundVariable']\n\n constructor(id: string, graph: SceneGraph, api: NodeProxyHost) {\n this[INTERNAL_ID] = id\n this[INTERNAL_GRAPH] = underlyingGraph(graph)\n this[INTERNAL_API] = api\n const type = graph.getNode(id)?.type\n const internals = { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API }\n if (type === 'VECTOR') installVectorNodeProxyAccessors(this, internals, MIXED)\n if (type) installShapeNodeProxyAccessors(this, internals, type)\n // Figma loads a page's layers on demand in dynamic-page mode and has `loadAsync` on pages\n // alone, as the editor loads a page's layers when it is first visited.\n if (type === 'CANVAS')\n Object.defineProperty(this, 'loadAsync', { value: () => loadPage(api, id) })\n }\n\n private _update(changes: Partial<SceneNode>): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const graph = this[INTERNAL_GRAPH]\n const id = this[INTERNAL_ID]\n graph.updateNode(id, changes)\n recordInstanceOverride(graph, id, Object.keys(changes))\n }\n\n private _raw(): SceneNode {\n flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this[INTERNAL_GRAPH].getNode(this[INTERNAL_ID])\n if (!n) throw new Error(`Node ${this[INTERNAL_ID]} has been removed`)\n return n\n }\n\n insertCharacters(\n start: number,\n characters: string,\n useStyle: TextProxy.InsertStyleSource = 'BEFORE'\n ): void {\n TextProxy.insertCharacters(this[INTERNAL_GRAPH], this._raw(), start, characters, useStyle)\n }\n\n deleteCharacters(start: number, end: number): void {\n TextProxy.deleteCharacters(this[INTERNAL_GRAPH], this._raw(), start, end)\n }\n\n get isMask(): boolean {\n return this._raw().isMask\n }\n\n set isMask(v: boolean) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'isMask', 'is-mask')\n this._update({ isMask: v })\n // A mask limits what its group spans.\n fitGroupsAround(this[INTERNAL_GRAPH], this._raw().parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n get maskType(): string {\n return this._raw().maskType\n }\n\n set maskType(v: string) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'maskType', 'mask-type')\n this._update({ maskType: v as SceneNode['maskType'] })\n }\n\n // --- UI state ---\n\n get expanded(): boolean {\n return this._raw().expanded\n }\n\n set expanded(v: boolean) {\n this._update({ expanded: v })\n }\n\n // --- Components ---\n\n get backgrounds(): readonly FigmaPaint[] {\n // A page draws its background colour's alpha times the paint's opacity, which Figma reads as\n // the opacity alone.\n return Object.freeze(\n getPageBackgrounds(this._raw()).map((paint) =>\n toFigmaPaint({ ...paint, opacity: paint.opacity * paint.color.a })\n )\n )\n }\n\n set backgrounds(value: readonly FigmaPaint[]) {\n const fills = parseFigmaPaints(value, 'set_backgrounds', 'backgrounds')\n setPageBackgrounds(this[INTERNAL_GRAPH], this._raw(), fills)\n }\n\n /** The async form Figma requires in dynamic-page mode; same result as mainComponent. */\n async getMainComponentAsync(): Promise<FigmaNodeProxy | null> {\n return this.mainComponent\n }\n\n get mainComponent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.componentId) return null\n const comp = this[INTERNAL_GRAPH].getNode(n.componentId)\n if (!comp) return null\n return this[INTERNAL_API].wrapNode(comp.id)\n }\n\n createInstance(): FigmaInstanceNode {\n const n = this._raw()\n if (n.type !== 'COMPONENT') throw new Error('createInstance() can only be called on components')\n const pageId = this[INTERNAL_API].currentPageId\n const inst = this[INTERNAL_GRAPH].createInstance(n.id, pageId)\n if (!inst) throw new Error('Failed to create instance')\n // `wrapNode` cannot know the node's type; this one just built an instance.\n return this[INTERNAL_API].wrapNode(inst.id) as FigmaInstanceNode\n }\n\n /** Turns this instance into a frame that keeps its current content, like Figma's. */\n detachInstance(): FigmaFrameNode {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('detachInstance() can only be called on instances')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].detachInstance(n.id)\n // The node is a frame once detached, which `wrapNode` has no way to tell.\n return this[INTERNAL_API].wrapNode(n.id) as FigmaFrameNode\n }\n\n /** Points this instance at another component, as Figma's swapComponent does. */\n swapComponent(component: FigmaNodeProxy): void {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('swapComponent() can only be called on instances')\n const target = this[INTERNAL_GRAPH].getNode(component[INTERNAL_ID])\n if (target?.type !== 'COMPONENT') throw new Error('swapComponent() needs a component')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].swapInstanceComponent(n.id, target.id)\n }\n\n // --- Tree ---\n\n get parent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.parentId) return null\n return this[INTERNAL_API].wrapNode(n.parentId)\n }\n\n get children(): FigmaNodeProxy[] {\n flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n return pluginChildren(this[INTERNAL_GRAPH], this[INTERNAL_ID]).map((c) =>\n this[INTERNAL_API].wrapNode(c.id)\n )\n }\n\n appendChild(child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'appendChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'appendChild')\n this._reparentAndFit(child[INTERNAL_ID])\n }\n\n /**\n * Moves a child here as Figma does: it keeps its transform into its container, so its `x`, `y`,\n * and rotation stay and it moves with its new parent. The groups it left and joined refit.\n */\n private _reparentAndFit(childId: string): void {\n const scene = this[INTERNAL_GRAPH]\n const child = scene.getNode(childId)\n if (!child) return\n const previousParentId = child.parentId\n const transform = containerTransform(child, scene)\n scene.reparentNode(childId, this[INTERNAL_ID])\n setContainerTransform(scene, child, transform)\n const options = this[INTERNAL_API].groupFitOptions\n fitGroupsAround(scene, previousParentId, options)\n fitGroupsAround(scene, this[INTERNAL_ID], options)\n }\n\n insertChild(index: number, child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'insertChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'insertChild')\n this._reparentAndFit(child[INTERNAL_ID])\n this[INTERNAL_GRAPH].insertChildAt(child[INTERNAL_ID], this[INTERNAL_ID], index)\n }\n\n clone(): FigmaNodeProxy {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this._raw()\n const parentId = n.parentId ?? this[INTERNAL_API].currentPageId\n const cloned = this[INTERNAL_GRAPH].cloneTree(this[INTERNAL_ID], parentId)\n if (!cloned) throw new Error(`Failed to clone node ${this[INTERNAL_ID]}`)\n // A slot's copy is a plain frame: the slot binding belongs to the original alone.\n if (slotPropertyId(cloned))\n this[INTERNAL_GRAPH].updateNode(cloned.id, {\n componentPropertyReferences: cloned.componentPropertyReferences.filter(\n (reference) => reference.field !== 'SLOT_CONTENT'\n )\n })\n return this[INTERNAL_API].wrapNode(cloned.id)\n }\n\n remove(): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n prepareSlotRemoval(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const parentId = this._raw().parentId\n // Connectors go with a layer they attach to, as Figma removes them.\n const attached = attachedConnectors(this[INTERNAL_GRAPH], [this[INTERNAL_ID]])\n this[INTERNAL_GRAPH].deleteNode(this[INTERNAL_ID])\n for (const connector of attached) this[INTERNAL_GRAPH].deleteNode(connector.id)\n fitGroupsAround(this[INTERNAL_GRAPH], parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n findAll(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findAll(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findOne(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findOne(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findChild(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findChild(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findChildren(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findChildren(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findAllWithCriteria(criteria: { types?: string[] }): FigmaNodeProxy[] {\n return Traversal.findAllWithCriteria(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n criteria\n )\n }\n\n // --- Serialization ---\n\n toJSON(maxDepth?: number, currentDepth = 0): Record<string, unknown> {\n return nodeProxyToJSON(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n maxDepth,\n currentDepth\n )\n }\n\n toString(): string {\n const n = this._raw()\n return `[${n.type} \"${n.name}\" ${n.id}]`\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n}\n\ninstallBasicNodeProxyAccessors(FigmaNodeProxy.prototype, {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n})\n\ninstallVisualNodeProxyAccessors(\n FigmaNodeProxy.prototype,\n { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API },\n MIXED\n)\n\nconst proxyInternals = {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n}\n\ninstallStrokeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallStickyNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallConnectorNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallTextNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallTextRangeMethods(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallLayoutNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallVariableModeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallReactionAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallPluginDataMethods(FigmaNodeProxy.prototype, proxyInternals)\ninstallComponentPropertyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallInstanceOverrideAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallSlotAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallDevStatusAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallShapeWithTextAccessors(FigmaNodeProxy.prototype, proxyInternals)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAM,QAAQ,OAAO,OAAO;AAI5B,MAAa,cAAc,OAAO,IAAI;AACtC,MAAa,iBAAiB,OAAO,OAAO;AAC5C,MAAa,eAAe,OAAO,KAAK;;;;;AAYxC,MAAM,4BAAY,IAAI,QAAiC;AAEvD,SAAgB,YAAY,KAAoB,MAAsB;CACpE,UAAU,IAAI,KAAK,IAAI;AACzB;AAEA,SAAgB,SAAS,KAAoB,QAA+B;CAC1E,OAAO,UAAU,IAAI,GAAG,CAAC,EAAE,KAAK,MAAM,KAAK,QAAQ,QAAQ;AAC7D;;AAGA,SAAgB,WAAW,KAAoB,QAAwC;CACrF,OAAO,UAAU,IAAI,GAAG,CAAC,EAAE,aAAa,MAAM,KAAK,QAAQ,QAAQ,IAAI;AACzE;;AAYA,SAAS,uBACP,OACA,UACA,SACA,QACM;CACN,IAAI,sBAAsB,OAAO,SAAS,QAAQ,GAChD,MAAM,IAAI,MAAM,MAAM,OAAO,+DAA+D;AAChG;AAEA,IAA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,WAAW,cAAc;AACxE,gCAAgC,eAAe,WAAW,cAAc;AACxE,mCAAmC,eAAe,WAAW,cAAc;AAC3E,8BAA8B,eAAe,WAAW,gBAAgB,KAAK;AAC7E,wBAAwB,eAAe,WAAW,gBAAgB,KAAK;AACvE,gCAAgC,eAAe,WAAW,cAAc;AACxE,sCAAsC,eAAe,WAAW,cAAc;AAC9E,yBAAyB,eAAe,WAAW,cAAc;AACjE,yBAAyB,eAAe,WAAW,cAAc;AACjE,kCAAkC,eAAe,WAAW,cAAc;AAC1E,iCAAiC,eAAe,WAAW,cAAc;AACzE,qBAAqB,eAAe,WAAW,cAAc;AAC7D,0BAA0B,eAAe,WAAW,cAAc;AAClE,8BAA8B,eAAe,WAAW,cAAc"}
|
|
1
|
+
{"version":3,"file":"proxy.js","names":["Traversal.findAll","Traversal.findOne","Traversal.findChild","Traversal.findChildren","Traversal.findAllWithCriteria"],"sources":["../../src/figma-api/proxy.ts"],"sourcesContent":["import type {\n ArcData,\n HyperlinkTarget,\n SceneGraph,\n SceneNode,\n NodeType,\n LayoutGrid,\n LayoutMode,\n OverflowDirection,\n ScrollBehavior\n} from '@pairdraw/scene-graph'\nimport { attachedConnectors } from '@pairdraw/scene-graph/connectors'\nimport type { GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'\nimport { createsComponentCycle, recordInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport type { ShapeWithTextType } from '@pairdraw/scene-graph/shape-with-text'\nimport { slotPropertyId } from '@pairdraw/scene-graph/slots'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport type { FigmaEffect } from '#core/figma-api/effects'\n\nimport { prepareFollowedFieldEdit, fitGroupsAround } from './accessor-utils'\nimport { installBasicNodeProxyAccessors } from './accessors/basic'\nimport { installConnectorNodeProxyAccessors } from './accessors/connector'\nimport { installLayoutNodeProxyAccessors } from './accessors/layout'\nimport { installReactionAccessors } from './accessors/reactions'\nimport { installShapeNodeProxyAccessors } from './accessors/shape'\nimport { installStickyNodeProxyAccessors, pluginChildren } from './accessors/sticky'\nimport { installStrokeNodeProxyAccessors } from './accessors/strokes'\nimport { installTextNodeProxyAccessors } from './accessors/text'\nimport { installTextRangeMethods, type TextRangeMethods } from './accessors/text/ranges'\nimport {\n installVariableModeNodeProxyAccessors,\n type VariableNodeMembers\n} from './accessors/variables'\nimport {\n installVectorNodeProxyAccessors,\n type FigmaVectorNetwork,\n type FigmaVectorPath\n} from './accessors/vector'\nimport { installVisualNodeProxyAccessors } from './accessors/visual'\nimport { installComponentPropertyAccessors } from './components'\nimport { installDevStatusAccessors, type FigmaDevStatusValue } from './dev-status'\nimport type { FigmaFontName } from './fonts/names'\nimport { underlyingGraph } from './graph-ref'\nimport type { FigmaFrameNode, FigmaInstanceNode } from './node-types'\nimport { installInstanceOverrideAccessors, type FigmaInstanceOverride } from './overrides'\nimport { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from './paints'\nimport { flushPendingComponentSync } from './pending-sync'\nimport { installPluginDataMethods, type PluginDataMethods } from './plugin-data'\nimport type { FigmaReaction } from './reactions'\nimport { nodeProxyToJSON } from './serialization'\nimport { installShapeWithTextAccessors } from './shape-with-text'\nimport {\n installSlotAccessors,\n prepareNodeClone,\n prepareSlotMove,\n prepareSlotRemoval\n} from './slots'\nimport type { FigmaLetterSpacing, FigmaLineHeight } from './text'\nimport * as TextProxy from './text'\nimport { containerTransform, setContainerTransform } from './transform'\nimport * as Traversal from './traversal'\nimport type { FigmaTransform } from './types'\n\nconst MIXED = Symbol('mixed')\n\nexport type { FigmaFont, FigmaFontName } from './fonts/names'\n\nexport const INTERNAL_ID = Symbol('id')\nexport const INTERNAL_GRAPH = Symbol('graph')\nexport const INTERNAL_API = Symbol('api')\n\n/** How a host loads pages as they are visited; see `FigmaAPIOptions`. */\nexport interface PageHost {\n load: (pageId: string) => Promise<void>\n pageOfNode?: (nodeId: string) => Promise<string | null>\n}\n\n/**\n * How each API loads a page's layers, a host's hook kept off `figma`, which has only Figma's\n * members. Without one every page is in memory.\n */\nconst pageHosts = new WeakMap<NodeProxyHost, PageHost>()\n\nexport function setPageHost(api: NodeProxyHost, host: PageHost): void {\n pageHosts.set(api, host)\n}\n\nexport function loadPage(api: NodeProxyHost, pageId: string): Promise<void> {\n return pageHosts.get(api)?.load(pageId) ?? Promise.resolve()\n}\n\n/** The page holding a layer not loaded yet, which loading that page brings in. */\nexport function pageOfNode(api: NodeProxyHost, nodeId: string): Promise<string | null> {\n return pageHosts.get(api)?.pageOfNode?.(nodeId) ?? Promise.resolve(null)\n}\n\nexport interface NodeProxyHost {\n wrapNode(id: string): FigmaNodeProxy\n readonly currentPageId: string\n /** How groups and booleans refit; booleans size to their result when a renderer is attached. */\n readonly groupFitOptions: GroupFitOptions\n}\n\nexport { MIXED }\n\n/** Figma refuses a move that would make a component contain itself. */\nfunction assertNoComponentCycle(\n graph: SceneGraph,\n parentId: string,\n childId: string,\n method: 'appendChild' | 'insertChild'\n): void {\n if (createsComponentCycle(graph, childId, parentId))\n throw new Error(`in ${method}: Cannot move node. Reparenting would create a component cycle`)\n}\n\nexport class FigmaNodeProxy {\n [INTERNAL_ID]: string;\n [INTERNAL_GRAPH]: SceneGraph;\n [INTERNAL_API]: NodeProxyHost\n\n declare readonly id: string\n /** A slot frame reads as `'SLOT'`, as Figma's `SlotNode` does. */\n declare readonly type: NodeType | 'SLOT'\n declare name: string\n declare readonly removed: boolean\n declare x: number\n declare y: number\n declare readonly width: number\n declare readonly height: number\n declare rotation: number\n declare relativeTransform: FigmaTransform\n declare resize: (width: number, height: number) => void\n declare resizeWithoutConstraints: (width: number, height: number) => void\n declare rescale: (scale: number) => void\n declare readonly absoluteTransform: FigmaTransform\n declare readonly absoluteBoundingBox: Rect\n declare readonly absoluteRenderBounds: Rect | null\n\n declare fills: readonly FigmaPaint[] | symbol\n declare strokes: readonly FigmaPaint[]\n declare effects: readonly FigmaEffect[]\n declare opacity: number\n declare visible: boolean\n declare locked: boolean\n declare devStatus: FigmaDevStatusValue | undefined\n declare blendMode: string\n declare clipsContent: boolean\n declare overflowDirection: OverflowDirection\n declare scrollBehavior: ScrollBehavior\n declare cornerRadius: number | typeof MIXED\n declare topLeftRadius: number\n declare topRightRadius: number\n declare bottomLeftRadius: number\n declare bottomRightRadius: number\n declare cornerSmoothing: number\n\n declare layoutMode: LayoutMode\n declare layoutGrids: readonly LayoutGrid[]\n declare primaryAxisAlignItems: string\n declare counterAxisAlignItems: string\n declare itemSpacing: number\n declare counterAxisSpacing: number\n declare paddingTop: number\n declare paddingRight: number\n declare paddingBottom: number\n declare paddingLeft: number\n declare layoutWrap: string\n declare primaryAxisSizingMode: string\n declare counterAxisSizingMode: string\n declare counterAxisAlignContent: string\n declare itemReverseZIndex: boolean\n declare strokesIncludedInLayout: boolean\n declare layoutPositioning: string\n declare layoutGrow: number\n declare layoutAlign: string\n declare layoutSizingHorizontal: string\n declare layoutSizingVertical: string\n declare constraints: { horizontal: string; vertical: string }\n declare minWidth: number | null\n declare maxWidth: number | null\n declare minHeight: number | null\n declare maxHeight: number | null\n declare readonly targetAspectRatio: Vector | null\n /** @deprecated Figma's alias for whether `targetAspectRatio` is set. */\n declare constrainProportions: boolean\n declare lockAspectRatio: () => void\n declare unlockAspectRatio: () => void\n declare pointCount: number\n declare innerRadius: number\n declare arcData: Readonly<ArcData>\n declare vectorPaths: readonly FigmaVectorPath[]\n declare vectorNetwork: FigmaVectorNetwork\n declare setVectorNetworkAsync: (vectorNetwork: FigmaVectorNetwork) => Promise<void>\n declare handleMirroring: SceneNode['handleMirroring'] | typeof MIXED\n declare getPluginData: PluginDataMethods['getPluginData']\n declare setPluginData: PluginDataMethods['setPluginData']\n declare getPluginDataKeys: PluginDataMethods['getPluginDataKeys']\n declare getSharedPluginData: PluginDataMethods['getSharedPluginData']\n declare setSharedPluginData: PluginDataMethods['setSharedPluginData']\n declare getSharedPluginDataKeys: PluginDataMethods['getSharedPluginDataKeys']\n declare readonly explicitVariableModes: VariableNodeMembers['explicitVariableModes']\n declare readonly resolvedVariableModes: VariableNodeMembers['resolvedVariableModes']\n declare setExplicitVariableModeForCollection: VariableNodeMembers['setExplicitVariableModeForCollection']\n declare clearExplicitVariableModeForCollection: VariableNodeMembers['clearExplicitVariableModeForCollection']\n declare readonly boundVariables: VariableNodeMembers['boundVariables']\n declare setBoundVariable: VariableNodeMembers['setBoundVariable']\n declare readonly overrides: FigmaInstanceOverride[] | undefined\n /** Prototype connections, in Figma's plugin shape; refused when the play cannot run them. */\n declare reactions: readonly FigmaReaction[]\n /** A sticky note's body or a shape's label, a sticky's author line, and whether it is wide. */\n declare readonly text: FigmaNodeProxy | undefined\n declare readonly authorName: string | undefined\n declare authorVisible: boolean | undefined\n declare isWideWidth: boolean | undefined\n declare shapeType: ShapeWithTextType | undefined\n /** On pages alone, as in Figma. */\n declare loadAsync: () => Promise<void>\n declare resetOverrides: () => void\n\n declare strokeWeight: number\n declare strokeAlign: string\n declare dashPattern: readonly number[]\n declare strokeCap: string\n declare strokeJoin: string\n declare strokeMiterLimit: number\n declare strokeTopWeight: number\n declare strokeBottomWeight: number\n declare strokeLeftWeight: number\n declare strokeRightWeight: number\n\n declare characters: string\n declare fontSize: number | symbol\n declare fontName: FigmaFontName | symbol\n declare fontWeight: number | symbol\n declare textAlignHorizontal: string\n declare textAlignVertical: string\n declare textAutoResize: string\n declare letterSpacing: FigmaLetterSpacing | symbol\n declare lineHeight: FigmaLineHeight | symbol\n declare textCase: SceneNode['textCase'] | symbol\n declare hyperlink: HyperlinkTarget | null | symbol\n declare textStyleId: string | symbol\n declare fillStyleId: string | symbol\n declare textDecoration: SceneNode['textDecoration'] | symbol\n declare readonly openTypeFeatures: Record<string, boolean> | symbol\n declare maxLines: number | null\n declare listSpacing: number | symbol\n declare paragraphSpacing: number | symbol\n declare paragraphIndent: number | symbol\n declare hangingList: boolean\n declare textTruncation: string\n declare autoRename: boolean\n\n // Per-character and per-paragraph methods: accessors/text/ranges.ts.\n declare getStyledTextSegments: TextRangeMethods['getStyledTextSegments']\n declare getRangeAllFontNames: TextRangeMethods['getRangeAllFontNames']\n declare getRangeFontSize: TextRangeMethods['getRangeFontSize']\n declare setRangeFontSize: TextRangeMethods['setRangeFontSize']\n declare getRangeFontName: TextRangeMethods['getRangeFontName']\n declare setRangeFontName: TextRangeMethods['setRangeFontName']\n declare getRangeFontWeight: TextRangeMethods['getRangeFontWeight']\n declare getRangeFills: TextRangeMethods['getRangeFills']\n declare setRangeFills: TextRangeMethods['setRangeFills']\n declare getRangeLetterSpacing: TextRangeMethods['getRangeLetterSpacing']\n declare setRangeLetterSpacing: TextRangeMethods['setRangeLetterSpacing']\n declare getRangeLineHeight: TextRangeMethods['getRangeLineHeight']\n declare setRangeLineHeight: TextRangeMethods['setRangeLineHeight']\n declare getRangeTextDecoration: TextRangeMethods['getRangeTextDecoration']\n declare setRangeTextDecoration: TextRangeMethods['setRangeTextDecoration']\n declare getRangeTextDecorationStyle: TextRangeMethods['getRangeTextDecorationStyle']\n declare setRangeTextDecorationStyle: TextRangeMethods['setRangeTextDecorationStyle']\n declare getRangeTextDecorationOffset: TextRangeMethods['getRangeTextDecorationOffset']\n declare setRangeTextDecorationOffset: TextRangeMethods['setRangeTextDecorationOffset']\n declare getRangeTextDecorationThickness: TextRangeMethods['getRangeTextDecorationThickness']\n declare setRangeTextDecorationThickness: TextRangeMethods['setRangeTextDecorationThickness']\n declare getRangeTextDecorationColor: TextRangeMethods['getRangeTextDecorationColor']\n declare setRangeTextDecorationColor: TextRangeMethods['setRangeTextDecorationColor']\n declare getRangeTextDecorationSkipInk: TextRangeMethods['getRangeTextDecorationSkipInk']\n declare setRangeTextDecorationSkipInk: TextRangeMethods['setRangeTextDecorationSkipInk']\n declare getRangeOpenTypeFeatures: TextRangeMethods['getRangeOpenTypeFeatures']\n declare getRangeListOptions: TextRangeMethods['getRangeListOptions']\n declare setRangeListOptions: TextRangeMethods['setRangeListOptions']\n declare getRangeIndentation: TextRangeMethods['getRangeIndentation']\n declare setRangeIndentation: TextRangeMethods['setRangeIndentation']\n declare getRangeListSpacing: TextRangeMethods['getRangeListSpacing']\n declare setRangeListSpacing: TextRangeMethods['setRangeListSpacing']\n declare getRangeParagraphSpacing: TextRangeMethods['getRangeParagraphSpacing']\n declare setRangeParagraphSpacing: TextRangeMethods['setRangeParagraphSpacing']\n declare getRangeParagraphIndent: TextRangeMethods['getRangeParagraphIndent']\n declare setRangeParagraphIndent: TextRangeMethods['setRangeParagraphIndent']\n declare getRangeTextCase: TextRangeMethods['getRangeTextCase']\n declare setRangeTextCase: TextRangeMethods['setRangeTextCase']\n declare getRangeHyperlink: TextRangeMethods['getRangeHyperlink']\n declare setRangeHyperlink: TextRangeMethods['setRangeHyperlink']\n declare getRangeTextStyleId: TextRangeMethods['getRangeTextStyleId']\n declare setRangeTextStyleId: TextRangeMethods['setRangeTextStyleId']\n declare setRangeTextStyleIdAsync: TextRangeMethods['setRangeTextStyleIdAsync']\n declare getRangeFillStyleId: TextRangeMethods['getRangeFillStyleId']\n declare setRangeFillStyleId: TextRangeMethods['setRangeFillStyleId']\n declare setRangeFillStyleIdAsync: TextRangeMethods['setRangeFillStyleIdAsync']\n declare getRangeBoundVariable: TextRangeMethods['getRangeBoundVariable']\n declare setRangeBoundVariable: TextRangeMethods['setRangeBoundVariable']\n\n constructor(id: string, graph: SceneGraph, api: NodeProxyHost) {\n this[INTERNAL_ID] = id\n this[INTERNAL_GRAPH] = underlyingGraph(graph)\n this[INTERNAL_API] = api\n const type = graph.getNode(id)?.type\n const internals = { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API }\n if (type === 'VECTOR') installVectorNodeProxyAccessors(this, internals, MIXED)\n if (type) installShapeNodeProxyAccessors(this, internals, type)\n // Figma loads a page's layers on demand in dynamic-page mode and has `loadAsync` on pages\n // alone, as the editor loads a page's layers when it is first visited.\n if (type === 'CANVAS')\n Object.defineProperty(this, 'loadAsync', { value: () => loadPage(api, id) })\n }\n\n private _update(changes: Partial<SceneNode>): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const graph = this[INTERNAL_GRAPH]\n const id = this[INTERNAL_ID]\n graph.updateNode(id, changes)\n recordInstanceOverride(graph, id, Object.keys(changes))\n }\n\n private _raw(): SceneNode {\n flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this[INTERNAL_GRAPH].getNode(this[INTERNAL_ID])\n if (!n) throw new Error(`Node ${this[INTERNAL_ID]} has been removed`)\n return n\n }\n\n insertCharacters(\n start: number,\n characters: string,\n useStyle: TextProxy.InsertStyleSource = 'BEFORE'\n ): void {\n TextProxy.insertCharacters(this[INTERNAL_GRAPH], this._raw(), start, characters, useStyle)\n }\n\n deleteCharacters(start: number, end: number): void {\n TextProxy.deleteCharacters(this[INTERNAL_GRAPH], this._raw(), start, end)\n }\n\n get isMask(): boolean {\n return this._raw().isMask\n }\n\n set isMask(v: boolean) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'isMask', 'is-mask')\n this._update({ isMask: v })\n // A mask limits what its group spans.\n fitGroupsAround(this[INTERNAL_GRAPH], this._raw().parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n get maskType(): string {\n return this._raw().maskType\n }\n\n set maskType(v: string) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'maskType', 'mask-type')\n this._update({ maskType: v as SceneNode['maskType'] })\n }\n\n get booleanOperation(): string | undefined {\n return this._raw().booleanOperation\n }\n\n set booleanOperation(v: string) {\n if (this._raw().type !== 'BOOLEAN_OPERATION') return\n this._update({ booleanOperation: v as SceneNode['booleanOperation'] })\n }\n\n // --- UI state ---\n\n get expanded(): boolean {\n return this._raw().expanded\n }\n\n set expanded(v: boolean) {\n this._update({ expanded: v })\n }\n\n // --- Components ---\n\n get backgrounds(): readonly FigmaPaint[] {\n // A page draws its background colour's alpha times the paint's opacity, which Figma reads as\n // the opacity alone.\n return Object.freeze(\n getPageBackgrounds(this._raw()).map((paint) =>\n toFigmaPaint({ ...paint, opacity: paint.opacity * paint.color.a })\n )\n )\n }\n\n set backgrounds(value: readonly FigmaPaint[]) {\n const fills = parseFigmaPaints(value, 'set_backgrounds', 'backgrounds')\n setPageBackgrounds(this[INTERNAL_GRAPH], this._raw(), fills)\n }\n\n /** The async form Figma requires in dynamic-page mode; same result as mainComponent. */\n async getMainComponentAsync(): Promise<FigmaNodeProxy | null> {\n return this.mainComponent\n }\n\n get mainComponent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.componentId) return null\n const comp = this[INTERNAL_GRAPH].getNode(n.componentId)\n if (!comp) return null\n return this[INTERNAL_API].wrapNode(comp.id)\n }\n\n createInstance(): FigmaInstanceNode {\n const n = this._raw()\n if (n.type !== 'COMPONENT') throw new Error('createInstance() can only be called on components')\n const pageId = this[INTERNAL_API].currentPageId\n const inst = this[INTERNAL_GRAPH].createInstance(n.id, pageId)\n if (!inst) throw new Error('Failed to create instance')\n // `wrapNode` cannot know the node's type; this one just built an instance.\n return this[INTERNAL_API].wrapNode(inst.id) as FigmaInstanceNode\n }\n\n /** Turns this instance into a frame that keeps its current content, like Figma's. */\n detachInstance(): FigmaFrameNode {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('detachInstance() can only be called on instances')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].detachInstance(n.id)\n // The node is a frame once detached, which `wrapNode` has no way to tell.\n return this[INTERNAL_API].wrapNode(n.id) as FigmaFrameNode\n }\n\n /** Points this instance at another component, as Figma's swapComponent does. */\n swapComponent(component: FigmaNodeProxy): void {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('swapComponent() can only be called on instances')\n const target = this[INTERNAL_GRAPH].getNode(component[INTERNAL_ID])\n if (target?.type !== 'COMPONENT') throw new Error('swapComponent() needs a component')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].swapInstanceComponent(n.id, target.id)\n }\n\n // --- Tree ---\n\n get parent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.parentId) return null\n return this[INTERNAL_API].wrapNode(n.parentId)\n }\n\n get children(): FigmaNodeProxy[] {\n flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n return pluginChildren(this[INTERNAL_GRAPH], this[INTERNAL_ID]).map((c) =>\n this[INTERNAL_API].wrapNode(c.id)\n )\n }\n\n appendChild(child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'appendChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'appendChild')\n this._reparentAndFit(child[INTERNAL_ID])\n }\n\n /**\n * Moves a child here as Figma does: it keeps its transform into its container, so its `x`, `y`,\n * and rotation stay and it moves with its new parent. The groups it left and joined refit.\n */\n private _reparentAndFit(childId: string): void {\n const scene = this[INTERNAL_GRAPH]\n const child = scene.getNode(childId)\n if (!child) return\n const previousParentId = child.parentId\n const transform = containerTransform(child, scene)\n scene.reparentNode(childId, this[INTERNAL_ID])\n setContainerTransform(scene, child, transform)\n const options = this[INTERNAL_API].groupFitOptions\n fitGroupsAround(scene, previousParentId, options)\n fitGroupsAround(scene, this[INTERNAL_ID], options)\n }\n\n insertChild(index: number, child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'insertChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'insertChild')\n this._reparentAndFit(child[INTERNAL_ID])\n this[INTERNAL_GRAPH].insertChildAt(child[INTERNAL_ID], this[INTERNAL_ID], index)\n }\n\n clone(): FigmaNodeProxy {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this._raw()\n const parentId = n.parentId ?? this[INTERNAL_API].currentPageId\n prepareNodeClone(this[INTERNAL_GRAPH], this[INTERNAL_ID], 'clone')\n const cloned = this[INTERNAL_GRAPH].cloneTree(this[INTERNAL_ID], parentId)\n if (!cloned) throw new Error(`Failed to clone node ${this[INTERNAL_ID]}`)\n // A slot's copy is a plain frame: the slot binding belongs to the original alone.\n if (slotPropertyId(cloned))\n this[INTERNAL_GRAPH].updateNode(cloned.id, {\n componentPropertyReferences: cloned.componentPropertyReferences.filter(\n (reference) => reference.field !== 'SLOT_CONTENT'\n )\n })\n return this[INTERNAL_API].wrapNode(cloned.id)\n }\n\n remove(): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n prepareSlotRemoval(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const parentId = this._raw().parentId\n // Connectors go with a layer they attach to, as Figma removes them.\n const attached = attachedConnectors(this[INTERNAL_GRAPH], [this[INTERNAL_ID]])\n this[INTERNAL_GRAPH].deleteNode(this[INTERNAL_ID])\n for (const connector of attached) this[INTERNAL_GRAPH].deleteNode(connector.id)\n fitGroupsAround(this[INTERNAL_GRAPH], parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n findAll(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findAll(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findOne(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findOne(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findChild(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findChild(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findChildren(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findChildren(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findAllWithCriteria(criteria: { types?: string[] }): FigmaNodeProxy[] {\n return Traversal.findAllWithCriteria(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n criteria\n )\n }\n\n // --- Serialization ---\n\n toJSON(maxDepth?: number, currentDepth = 0): Record<string, unknown> {\n return nodeProxyToJSON(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n maxDepth,\n currentDepth\n )\n }\n\n toString(): string {\n const n = this._raw()\n return `[${n.type} \"${n.name}\" ${n.id}]`\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n}\n\ninstallBasicNodeProxyAccessors(FigmaNodeProxy.prototype, {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n})\n\ninstallVisualNodeProxyAccessors(\n FigmaNodeProxy.prototype,\n { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API },\n MIXED\n)\n\nconst proxyInternals = {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n}\n\ninstallStrokeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallStickyNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallConnectorNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallTextNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallTextRangeMethods(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallLayoutNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallVariableModeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallReactionAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallPluginDataMethods(FigmaNodeProxy.prototype, proxyInternals)\ninstallComponentPropertyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallInstanceOverrideAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallSlotAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallDevStatusAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallShapeWithTextAccessors(FigmaNodeProxy.prototype, proxyInternals)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,MAAM,QAAQ,OAAO,OAAO;AAI5B,MAAa,cAAc,OAAO,IAAI;AACtC,MAAa,iBAAiB,OAAO,OAAO;AAC5C,MAAa,eAAe,OAAO,KAAK;;;;;AAYxC,MAAM,4BAAY,IAAI,QAAiC;AAEvD,SAAgB,YAAY,KAAoB,MAAsB;CACpE,UAAU,IAAI,KAAK,IAAI;AACzB;AAEA,SAAgB,SAAS,KAAoB,QAA+B;CAC1E,OAAO,UAAU,IAAI,GAAG,CAAC,EAAE,KAAK,MAAM,KAAK,QAAQ,QAAQ;AAC7D;;AAGA,SAAgB,WAAW,KAAoB,QAAwC;CACrF,OAAO,UAAU,IAAI,GAAG,CAAC,EAAE,aAAa,MAAM,KAAK,QAAQ,QAAQ,IAAI;AACzE;;AAYA,SAAS,uBACP,OACA,UACA,SACA,QACM;CACN,IAAI,sBAAsB,OAAO,SAAS,QAAQ,GAChD,MAAM,IAAI,MAAM,MAAM,OAAO,+DAA+D;AAChG;AAEA,IAAa,iBAAb,MAA4B;CAC1B,CAAC;CACD,CAAC;CACD,CAAC;CAyLD,YAAY,IAAY,OAAmB,KAAoB;EAC7D,KAAK,eAAe;EACpB,KAAK,kBAAkB,gBAAgB,KAAK;EAC5C,KAAK,gBAAgB;EACrB,MAAM,OAAO,MAAM,QAAQ,EAAE,CAAC,EAAE;EAChC,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;AACP;AAEA,gCAAgC,eAAe,WAAW,cAAc;AACxE,gCAAgC,eAAe,WAAW,cAAc;AACxE,mCAAmC,eAAe,WAAW,cAAc;AAC3E,8BAA8B,eAAe,WAAW,gBAAgB,KAAK;AAC7E,wBAAwB,eAAe,WAAW,gBAAgB,KAAK;AACvE,gCAAgC,eAAe,WAAW,cAAc;AACxE,sCAAsC,eAAe,WAAW,cAAc;AAC9E,yBAAyB,eAAe,WAAW,cAAc;AACjE,yBAAyB,eAAe,WAAW,cAAc;AACjE,kCAAkC,eAAe,WAAW,cAAc;AAC1E,iCAAiC,eAAe,WAAW,cAAc;AACzE,qBAAqB,eAAe,WAAW,cAAc;AAC7D,0BAA0B,eAAe,WAAW,cAAc;AAClE,8BAA8B,eAAe,WAAW,cAAc"}
|
|
@@ -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"}
|