@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
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Refuse making a component from a layer that already belongs to one. Figma's
|
|
5
|
+
* `createComponentFromNode` refuses a component, component set, or instance, and any layer inside them,
|
|
6
|
+
* with `Cannot create component from node`. The editor keeps its own rule for component children
|
|
7
|
+
* (`instancesOnly`) because Figma does not document the canvas command there.
|
|
8
|
+
*/
|
|
9
|
+
export function assertComponentSourceScope(
|
|
10
|
+
graph: SceneGraph,
|
|
11
|
+
nodeId: string,
|
|
12
|
+
method: string,
|
|
13
|
+
options: { instancesOnly?: boolean } = {}
|
|
14
|
+
): void {
|
|
15
|
+
const node = graph.getNode(nodeId)
|
|
16
|
+
if (!node) return
|
|
17
|
+
const fail = (detail: string): never => {
|
|
18
|
+
throw new Error(`in ${method}: Cannot create component from node. ${detail}`)
|
|
19
|
+
}
|
|
20
|
+
if (!options.instancesOnly) {
|
|
21
|
+
if (node.type === 'INSTANCE')
|
|
22
|
+
fail(`Instance "${node.name}" is already an instance; detach it first.`)
|
|
23
|
+
if (node.type === 'COMPONENT' || node.type === 'COMPONENT_SET')
|
|
24
|
+
fail(`"${node.name}" is already a component.`)
|
|
25
|
+
}
|
|
26
|
+
let parent: SceneNode | undefined = node.parentId ? graph.getNode(node.parentId) : undefined
|
|
27
|
+
while (parent) {
|
|
28
|
+
if (parent.type === 'INSTANCE')
|
|
29
|
+
fail(
|
|
30
|
+
`Instance "${parent.name}" keeps its own layers; detach it or create the component outside it.`
|
|
31
|
+
)
|
|
32
|
+
if (!options.instancesOnly && (parent.type === 'COMPONENT' || parent.type === 'COMPONENT_SET'))
|
|
33
|
+
fail(`"${parent.name}" holds this layer; create the component outside it.`)
|
|
34
|
+
parent = parent.parentId ? graph.getNode(parent.parentId) : undefined
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -331,6 +331,30 @@ export function installComponentPropertyAccessors(
|
|
|
331
331
|
internals: NodeProxyInternals
|
|
332
332
|
): void {
|
|
333
333
|
Object.defineProperties(prototype, {
|
|
334
|
+
description: {
|
|
335
|
+
get(this: ProxyThis) {
|
|
336
|
+
return raw(this, internals).symbolDescription
|
|
337
|
+
},
|
|
338
|
+
set(this: ProxyThis, value: string) {
|
|
339
|
+
updateNode(this, internals, { symbolDescription: value })
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
descriptionMarkdown: {
|
|
343
|
+
get(this: ProxyThis) {
|
|
344
|
+
return raw(this, internals).symbolDescription
|
|
345
|
+
},
|
|
346
|
+
set(this: ProxyThis, value: string) {
|
|
347
|
+
updateNode(this, internals, { symbolDescription: value })
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
documentationLinks: {
|
|
351
|
+
get(this: ProxyThis) {
|
|
352
|
+
return raw(this, internals).symbolLinks.map((link) => ({ uri: link.uri }))
|
|
353
|
+
},
|
|
354
|
+
set(this: ProxyThis, value: readonly { uri: string }[]) {
|
|
355
|
+
updateNode(this, internals, { symbolLinks: value.map((link) => ({ uri: link.uri })) })
|
|
356
|
+
}
|
|
357
|
+
},
|
|
334
358
|
componentPropertyDefinitions: {
|
|
335
359
|
get(this: ProxyThis) {
|
|
336
360
|
return definitions(this, internals)
|
package/src/figma-api/flatten.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
|
2
2
|
import { copyFills } from '@pairdraw/scene-graph/copy'
|
|
3
3
|
|
|
4
4
|
import type { SkiaRenderer } from '#core/canvas'
|
|
5
|
-
import { canMakeBooleanSourceNode } from '#core/canvas/boolean'
|
|
6
|
-
import { flattenNodesToVectorProps } from '#core/canvas/flatten'
|
|
5
|
+
import { canContainFlattenableChildren, canMakeBooleanSourceNode } from '#core/canvas/boolean'
|
|
6
|
+
import { flattenLayerToVectorProps, flattenNodesToVectorProps } from '#core/canvas/flatten'
|
|
7
7
|
|
|
8
8
|
/** Without a renderer there are no outlines to merge: the first layer's box stands in. */
|
|
9
9
|
function flattenPlaceholder(graph: SceneGraph, nodes: SceneNode[], parentId: string): SceneNode {
|
|
@@ -29,7 +29,11 @@ export function flattenSceneNodes(
|
|
|
29
29
|
if (nodes.some((node) => !canMakeBooleanSourceNode(node, graph))) {
|
|
30
30
|
throw new Error('Cannot flatten unsupported node type')
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
// One non-container layer keeps its appearance here too, so the plugin API and Flatten agree.
|
|
33
|
+
const vectorProps =
|
|
34
|
+
nodes.length === 1 && !canContainFlattenableChildren(nodes[0])
|
|
35
|
+
? flattenLayerToVectorProps(renderer, graph, nodes[0])
|
|
36
|
+
: flattenNodesToVectorProps(renderer, graph, nodes)
|
|
33
37
|
if (!vectorProps) throw new Error('Cannot flatten empty node path')
|
|
34
38
|
return graph.createNode('VECTOR', parentId, vectorProps)
|
|
35
39
|
}
|
package/src/figma-api/index.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { fromUint8Array, isValid, toUint8Array } from 'js-base64'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
AnnotationCategory as AnnotationCategoryModel,
|
|
5
|
+
AnnotationMeasurement as AnnotationMeasurementModel,
|
|
6
|
+
NodeType,
|
|
7
|
+
SceneGraph,
|
|
8
|
+
SceneNode as CoreSceneNode
|
|
9
|
+
} from '@pairdraw/scene-graph'
|
|
4
10
|
import { createConnector, freeEndpoint } from '@pairdraw/scene-graph/connectors'
|
|
5
11
|
import { computeBounds } from '@pairdraw/scene-graph/geometry'
|
|
6
12
|
import type { GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'
|
|
7
13
|
import type { Rect, Vector } from '@pairdraw/scene-graph/primitives'
|
|
14
|
+
import { randomInt } from '@pairdraw/scene-graph/random'
|
|
15
|
+
import { assertGroupPlacement } from '@pairdraw/scene-graph/slots'
|
|
8
16
|
|
|
9
17
|
import type { SkiaRenderer } from '#core/canvas'
|
|
10
18
|
import { groupFitOptions } from '#core/canvas/boolean'
|
|
@@ -20,6 +28,7 @@ import { createSVGNodes } from '#core/io/formats/svg'
|
|
|
20
28
|
import { textAutoResizeChanges } from '#core/layout/text-auto-resize'
|
|
21
29
|
import { fontManager } from '#core/text/font/manager'
|
|
22
30
|
|
|
31
|
+
import { assertComponentSourceScope } from './component-scope'
|
|
23
32
|
import { componentFromNode } from './components'
|
|
24
33
|
import { flattenSceneNodes } from './flatten'
|
|
25
34
|
import { listFigmaFonts } from './fonts/list'
|
|
@@ -40,6 +49,7 @@ import type {
|
|
|
40
49
|
FigmaPolygonNode,
|
|
41
50
|
FigmaRectangleNode,
|
|
42
51
|
FigmaSectionNode,
|
|
52
|
+
FigmaSliceNode,
|
|
43
53
|
FigmaShapeWithTextNode,
|
|
44
54
|
FigmaStarNode,
|
|
45
55
|
FigmaTextNode,
|
|
@@ -123,6 +133,20 @@ export interface FigmaAPIOptions {
|
|
|
123
133
|
|
|
124
134
|
export { FigmaNodeProxy } from './proxy'
|
|
125
135
|
export { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'
|
|
136
|
+
export {
|
|
137
|
+
APPEARANCE_OVERRIDE_FIELDS,
|
|
138
|
+
AUTO_LAYOUT_OVERRIDE_FIELDS,
|
|
139
|
+
CLIP_OVERRIDE_FIELDS,
|
|
140
|
+
CORNER_OVERRIDE_FIELDS,
|
|
141
|
+
EFFECT_OVERRIDE_FIELDS,
|
|
142
|
+
FILL_OVERRIDE_FIELDS,
|
|
143
|
+
GRID_OVERRIDE_FIELDS,
|
|
144
|
+
OPACITY_OVERRIDE_FIELDS,
|
|
145
|
+
OVERRIDE_FIELD_GROUPS,
|
|
146
|
+
SIZE_OVERRIDE_FIELDS,
|
|
147
|
+
STROKE_OVERRIDE_FIELDS,
|
|
148
|
+
TEXT_OVERRIDE_FIELDS
|
|
149
|
+
} from './overrides'
|
|
126
150
|
export { freshRead, freshReadGraph } from './fresh-read'
|
|
127
151
|
export { flushPendingLayout } from './pending-layout'
|
|
128
152
|
export { flushPendingComponentSync } from './pending-sync'
|
|
@@ -155,6 +179,7 @@ export type {
|
|
|
155
179
|
FigmaPolygonNode,
|
|
156
180
|
FigmaRectangleNode,
|
|
157
181
|
FigmaSectionNode,
|
|
182
|
+
FigmaSliceNode,
|
|
158
183
|
FigmaShapeWithTextNode,
|
|
159
184
|
FigmaSlotNode,
|
|
160
185
|
FigmaStarNode,
|
|
@@ -186,12 +211,95 @@ const clientStorage: ClientStorageAPI = {
|
|
|
186
211
|
}
|
|
187
212
|
}
|
|
188
213
|
|
|
214
|
+
/** Figma's live category object: read-only fields plus the edits Figma allows. */
|
|
215
|
+
export interface AnnotationCategoryProxy {
|
|
216
|
+
readonly id: string
|
|
217
|
+
readonly label: string
|
|
218
|
+
readonly color: AnnotationCategoryModel['color']
|
|
219
|
+
readonly isPreset: boolean
|
|
220
|
+
readonly customColor: AnnotationCategoryModel['customColor']
|
|
221
|
+
setLabel(label: string): void
|
|
222
|
+
setColor(color: AnnotationCategoryModel['color']): void
|
|
223
|
+
remove(): void
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export type MeasurementSideProxy = 'TOP' | 'BOTTOM' | 'LEFT' | 'RIGHT'
|
|
227
|
+
export type MeasurementOffsetProxy =
|
|
228
|
+
| { type: 'INNER'; relative: number }
|
|
229
|
+
| { type: 'OUTER'; fixed: number }
|
|
230
|
+
export interface MeasurementProxy {
|
|
231
|
+
id: string
|
|
232
|
+
start: { node: FigmaNodeProxy; side: MeasurementSideProxy }
|
|
233
|
+
end: { node: FigmaNodeProxy; side: MeasurementSideProxy }
|
|
234
|
+
offset: MeasurementOffsetProxy
|
|
235
|
+
freeText: string
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** A page's proxy: a layer proxy plus the page-only selection and measurement methods. */
|
|
239
|
+
export type FigmaPageProxy = FigmaNodeProxy & {
|
|
240
|
+
selection: FigmaNodeProxy[]
|
|
241
|
+
getMeasurements(): MeasurementProxy[]
|
|
242
|
+
getMeasurementsForNode(node: FigmaNodeProxy): MeasurementProxy[]
|
|
243
|
+
addMeasurement(
|
|
244
|
+
start: { node: FigmaNodeProxy; side: MeasurementSideProxy },
|
|
245
|
+
end: { node: FigmaNodeProxy; side: MeasurementSideProxy },
|
|
246
|
+
options?: { offset?: MeasurementOffsetProxy; freeText?: string }
|
|
247
|
+
): MeasurementProxy
|
|
248
|
+
editMeasurement(
|
|
249
|
+
id: string,
|
|
250
|
+
value: { offset?: MeasurementOffsetProxy; freeText?: string }
|
|
251
|
+
): MeasurementProxy
|
|
252
|
+
deleteMeasurement(id: string): void
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** The two storage offsets for a measurement after an offset edit; the other one becomes 0. */
|
|
256
|
+
function switchedOffset(
|
|
257
|
+
measurement: AnnotationMeasurementModel,
|
|
258
|
+
offset: MeasurementOffsetProxy | undefined
|
|
259
|
+
): { inner: number; outer: number } {
|
|
260
|
+
if (offset?.type === 'INNER') return { inner: offset.relative, outer: 0 }
|
|
261
|
+
if (offset?.type === 'OUTER') return { inner: 0, outer: offset.fixed }
|
|
262
|
+
return { inner: measurement.innerOffsetRelative, outer: measurement.outerOffsetFixed }
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function oppositeSide(side: MeasurementSideProxy): MeasurementSideProxy {
|
|
266
|
+
if (side === 'TOP') return 'BOTTOM'
|
|
267
|
+
if (side === 'BOTTOM') return 'TOP'
|
|
268
|
+
if (side === 'LEFT') return 'RIGHT'
|
|
269
|
+
return 'LEFT'
|
|
270
|
+
}
|
|
271
|
+
|
|
189
272
|
export class FigmaAPI implements NodeProxyHost {
|
|
190
273
|
/**
|
|
191
274
|
* The read-freshening proxy. It is not the raw graph, so an identity check against an editor's
|
|
192
275
|
* graph goes through `underlyingGraph`; node internals already hold the raw graph.
|
|
193
276
|
*/
|
|
194
277
|
readonly graph: SceneGraph
|
|
278
|
+
/** Figma's `figma.annotations` surface, over the document's category map. */
|
|
279
|
+
readonly annotations = {
|
|
280
|
+
getAnnotationCategoriesAsync: async (): Promise<AnnotationCategoryProxy[]> =>
|
|
281
|
+
[...this.graph.annotationCategories.values()].map((category) =>
|
|
282
|
+
this._wrapAnnotationCategory(category)
|
|
283
|
+
),
|
|
284
|
+
getAnnotationCategoryByIdAsync: async (id: string): Promise<AnnotationCategoryProxy | null> => {
|
|
285
|
+
const category = this.graph.annotationCategories.get(id)
|
|
286
|
+
return category ? this._wrapAnnotationCategory(category) : null
|
|
287
|
+
},
|
|
288
|
+
addAnnotationCategoryAsync: async (input: {
|
|
289
|
+
label: string
|
|
290
|
+
color: AnnotationCategoryModel['color']
|
|
291
|
+
}): Promise<AnnotationCategoryProxy> => {
|
|
292
|
+
const category: AnnotationCategoryModel = {
|
|
293
|
+
id: `${randomInt()}:${randomInt()}`,
|
|
294
|
+
label: input.label,
|
|
295
|
+
color: input.color,
|
|
296
|
+
isPreset: false,
|
|
297
|
+
customColor: null
|
|
298
|
+
}
|
|
299
|
+
this.graph.annotationCategories.set(category.id, category)
|
|
300
|
+
return this._wrapAnnotationCategory(category)
|
|
301
|
+
}
|
|
302
|
+
}
|
|
195
303
|
private _currentPageId: string
|
|
196
304
|
private _selection: FigmaNodeProxy[] = []
|
|
197
305
|
private _nodeCache = new Map<string, FigmaNodeProxy>()
|
|
@@ -265,9 +373,7 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
265
373
|
return proxy
|
|
266
374
|
}
|
|
267
375
|
|
|
268
|
-
private _ensurePageProxy(
|
|
269
|
-
proxy: FigmaNodeProxy
|
|
270
|
-
): FigmaNodeProxy & { selection: FigmaNodeProxy[] } {
|
|
376
|
+
private _ensurePageProxy(proxy: FigmaNodeProxy): FigmaPageProxy {
|
|
271
377
|
if (!this._pageProxies.has(proxy)) {
|
|
272
378
|
Object.defineProperty(proxy, 'selection', {
|
|
273
379
|
get: () => this._selection,
|
|
@@ -282,16 +388,45 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
282
388
|
enumerable: true,
|
|
283
389
|
configurable: true
|
|
284
390
|
})
|
|
391
|
+
const pageId = this._currentPageId
|
|
392
|
+
const measurements = {
|
|
393
|
+
getMeasurements: () => this._measurementsOnPage(pageId),
|
|
394
|
+
getMeasurementsForNode: (node: FigmaNodeProxy) =>
|
|
395
|
+
this._measurementsOnPage(pageId).filter(
|
|
396
|
+
(measurement) =>
|
|
397
|
+
measurement.start.node.id === node[INTERNAL_ID] ||
|
|
398
|
+
measurement.end.node.id === node[INTERNAL_ID]
|
|
399
|
+
),
|
|
400
|
+
addMeasurement: (
|
|
401
|
+
start: { node: FigmaNodeProxy; side: MeasurementSideProxy },
|
|
402
|
+
end: { node: FigmaNodeProxy; side: MeasurementSideProxy },
|
|
403
|
+
options?: { offset?: MeasurementOffsetProxy; freeText?: string }
|
|
404
|
+
) => this._addMeasurement(pageId, start, end, options),
|
|
405
|
+
editMeasurement: (
|
|
406
|
+
id: string,
|
|
407
|
+
value: { offset?: MeasurementOffsetProxy; freeText?: string }
|
|
408
|
+
) => this._editMeasurement(pageId, id, value),
|
|
409
|
+
deleteMeasurement: (id: string) => this._deleteMeasurement(pageId, id)
|
|
410
|
+
}
|
|
411
|
+
Object.defineProperties(
|
|
412
|
+
proxy,
|
|
413
|
+
Object.fromEntries(
|
|
414
|
+
Object.entries(measurements).map(([name, value]) => [
|
|
415
|
+
name,
|
|
416
|
+
{ value, enumerable: true, configurable: true }
|
|
417
|
+
])
|
|
418
|
+
)
|
|
419
|
+
)
|
|
285
420
|
this._pageProxies.add(proxy)
|
|
286
421
|
}
|
|
287
|
-
return proxy as
|
|
422
|
+
return proxy as FigmaPageProxy
|
|
288
423
|
}
|
|
289
424
|
|
|
290
425
|
get root(): FigmaNodeProxy {
|
|
291
426
|
return this.wrapNode(this.graph.rootId)
|
|
292
427
|
}
|
|
293
428
|
|
|
294
|
-
get currentPage():
|
|
429
|
+
get currentPage(): FigmaPageProxy {
|
|
295
430
|
return this._ensurePageProxy(this.wrapNode(this._currentPageId))
|
|
296
431
|
}
|
|
297
432
|
|
|
@@ -303,6 +438,144 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
303
438
|
this.#pageChange = Promise.resolve(this.#onPageChange?.(pageId))
|
|
304
439
|
}
|
|
305
440
|
|
|
441
|
+
/** Every measurement stored on a layer of `pageId`. */
|
|
442
|
+
private _measurementsOnPage(pageId: string): MeasurementProxy[] {
|
|
443
|
+
const result: MeasurementProxy[] = []
|
|
444
|
+
for (const node of this.graph.nodes.values()) {
|
|
445
|
+
if (node.measurements.length === 0) continue
|
|
446
|
+
if (node.id !== pageId && !this.graph.isDescendant(node.id, pageId)) continue
|
|
447
|
+
for (const measurement of node.measurements) result.push(this._measurementProxy(measurement))
|
|
448
|
+
}
|
|
449
|
+
return result
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
private _measurementProxy(measurement: AnnotationMeasurementModel): MeasurementProxy {
|
|
453
|
+
const start = this.getNodeById(measurement.fromNodeId)
|
|
454
|
+
const end = this.getNodeById(measurement.toNodeId)
|
|
455
|
+
if (!start || !end)
|
|
456
|
+
throw new Error(`in getMeasurements: Measurement ${measurement.id} has no layer`)
|
|
457
|
+
const offset = measurement.outerOffsetFixed
|
|
458
|
+
? { type: 'OUTER' as const, fixed: measurement.outerOffsetFixed }
|
|
459
|
+
: { type: 'INNER' as const, relative: measurement.innerOffsetRelative }
|
|
460
|
+
return {
|
|
461
|
+
id: measurement.id,
|
|
462
|
+
start: { node: start, side: measurement.fromNodeSide },
|
|
463
|
+
end: {
|
|
464
|
+
node: end,
|
|
465
|
+
side: measurement.toSameSide
|
|
466
|
+
? measurement.fromNodeSide
|
|
467
|
+
: oppositeSide(measurement.fromNodeSide)
|
|
468
|
+
},
|
|
469
|
+
offset,
|
|
470
|
+
freeText: measurement.freeText
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
private _addMeasurement(
|
|
475
|
+
pageId: string,
|
|
476
|
+
start: { node: FigmaNodeProxy; side: MeasurementSideProxy },
|
|
477
|
+
end: { node: FigmaNodeProxy; side: MeasurementSideProxy },
|
|
478
|
+
options?: { offset?: MeasurementOffsetProxy; freeText?: string }
|
|
479
|
+
): MeasurementProxy {
|
|
480
|
+
const axis = (side: MeasurementSideProxy) => (side === 'LEFT' || side === 'RIGHT' ? 'x' : 'y')
|
|
481
|
+
if (axis(start.side) !== axis(end.side))
|
|
482
|
+
throw new Error(
|
|
483
|
+
`in addMeasurement: Measurement sides ${start.side} and ${end.side} are not on the same axis`
|
|
484
|
+
)
|
|
485
|
+
const startId = start.node[INTERNAL_ID]
|
|
486
|
+
const measurement: AnnotationMeasurementModel = {
|
|
487
|
+
id: `${randomInt()}:${randomInt()}`,
|
|
488
|
+
fromNodeId: startId,
|
|
489
|
+
toNodeId: end.node[INTERNAL_ID],
|
|
490
|
+
fromNodeSide: start.side,
|
|
491
|
+
toSameSide: end.side === start.side,
|
|
492
|
+
innerOffsetRelative: options?.offset?.type === 'INNER' ? options.offset.relative : 0,
|
|
493
|
+
outerOffsetFixed: options?.offset?.type === 'OUTER' ? options.offset.fixed : 0,
|
|
494
|
+
freeText: options?.freeText ?? ''
|
|
495
|
+
}
|
|
496
|
+
const node = this.graph.getNode(startId)
|
|
497
|
+
if (!node) throw new Error(`in addMeasurement: Node ${startId} is not on page ${pageId}`)
|
|
498
|
+
this.graph.updateNode(startId, { measurements: [...node.measurements, measurement] })
|
|
499
|
+
return this._measurementProxy(measurement)
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
private _findMeasurement(id: string): [string, AnnotationMeasurementModel] | null {
|
|
503
|
+
for (const node of this.graph.nodes.values()) {
|
|
504
|
+
const found = node.measurements.find((measurement) => measurement.id === id)
|
|
505
|
+
if (found) return [node.id, found]
|
|
506
|
+
}
|
|
507
|
+
return null
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
private _editMeasurement(
|
|
511
|
+
pageId: string,
|
|
512
|
+
id: string,
|
|
513
|
+
value: { offset?: MeasurementOffsetProxy; freeText?: string }
|
|
514
|
+
): MeasurementProxy {
|
|
515
|
+
void pageId
|
|
516
|
+
const found = this._findMeasurement(id)
|
|
517
|
+
if (!found) throw new Error(`in editMeasurement: Unknown measurement ${id}`)
|
|
518
|
+
const [nodeId, measurement] = found
|
|
519
|
+
const node = this.graph.getNode(nodeId)
|
|
520
|
+
if (!node) throw new Error(`in editMeasurement: Unknown measurement ${id}`)
|
|
521
|
+
const offsets = switchedOffset(measurement, value.offset)
|
|
522
|
+
const next: AnnotationMeasurementModel = {
|
|
523
|
+
...measurement,
|
|
524
|
+
innerOffsetRelative: offsets.inner,
|
|
525
|
+
outerOffsetFixed: offsets.outer,
|
|
526
|
+
freeText: value.freeText ?? measurement.freeText
|
|
527
|
+
}
|
|
528
|
+
this.graph.updateNode(nodeId, {
|
|
529
|
+
measurements: node.measurements.map((entry) => (entry.id === id ? next : entry))
|
|
530
|
+
})
|
|
531
|
+
return this._measurementProxy(next)
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
private _deleteMeasurement(pageId: string, id: string): void {
|
|
535
|
+
void pageId
|
|
536
|
+
const found = this._findMeasurement(id)
|
|
537
|
+
if (!found) return
|
|
538
|
+
const [nodeId] = found
|
|
539
|
+
const node = this.graph.getNode(nodeId)
|
|
540
|
+
if (!node) return
|
|
541
|
+
this.graph.updateNode(nodeId, {
|
|
542
|
+
measurements: node.measurements.filter((entry) => entry.id !== id)
|
|
543
|
+
})
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/** A live category object, as Figma hands out: setters edit the document's category. */
|
|
547
|
+
private _wrapAnnotationCategory(category: AnnotationCategoryModel): AnnotationCategoryProxy {
|
|
548
|
+
const categories = this.graph.annotationCategories
|
|
549
|
+
return {
|
|
550
|
+
get id() {
|
|
551
|
+
return category.id
|
|
552
|
+
},
|
|
553
|
+
get label() {
|
|
554
|
+
return categories.get(category.id)?.label ?? category.label
|
|
555
|
+
},
|
|
556
|
+
get color() {
|
|
557
|
+
return categories.get(category.id)?.color ?? category.color
|
|
558
|
+
},
|
|
559
|
+
get isPreset() {
|
|
560
|
+
return categories.get(category.id)?.isPreset ?? category.isPreset
|
|
561
|
+
},
|
|
562
|
+
get customColor() {
|
|
563
|
+
return categories.get(category.id)?.customColor ?? null
|
|
564
|
+
},
|
|
565
|
+
setLabel: (label: string) => {
|
|
566
|
+
const current = categories.get(category.id)
|
|
567
|
+
if (current) categories.set(category.id, { ...current, label })
|
|
568
|
+
},
|
|
569
|
+
setColor: (color: AnnotationCategoryModel['color']) => {
|
|
570
|
+
const current = categories.get(category.id)
|
|
571
|
+
if (current) categories.set(category.id, { ...current, color })
|
|
572
|
+
},
|
|
573
|
+
remove: () => {
|
|
574
|
+
categories.delete(category.id)
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
306
579
|
getNodeById(id: string): FigmaNodeProxy | null {
|
|
307
580
|
const node = this.graph.getNode(id)
|
|
308
581
|
return node ? this.wrapNode(id) : null
|
|
@@ -364,6 +637,10 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
364
637
|
return this._createNode('FRAME') as FigmaFrameNode
|
|
365
638
|
}
|
|
366
639
|
|
|
640
|
+
createSlice(): FigmaSliceNode {
|
|
641
|
+
return this._createNode('SLICE') as FigmaSliceNode
|
|
642
|
+
}
|
|
643
|
+
|
|
367
644
|
createRectangle(): FigmaRectangleNode {
|
|
368
645
|
return this._createNode('RECTANGLE') as FigmaRectangleNode
|
|
369
646
|
}
|
|
@@ -467,6 +744,12 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
467
744
|
): FigmaGroupNode {
|
|
468
745
|
const parentId = this._nodeId(parent)
|
|
469
746
|
const members = nodes.map((node) => this._rawNode(node))
|
|
747
|
+
assertGroupPlacement(
|
|
748
|
+
this.graph,
|
|
749
|
+
parentId,
|
|
750
|
+
members.map((member) => member.id),
|
|
751
|
+
'group'
|
|
752
|
+
)
|
|
470
753
|
const groupNode = wrapNodes(this.graph, 'GROUP', members, parentId, index)
|
|
471
754
|
return this.wrapNode(groupNode.id) as FigmaGroupNode
|
|
472
755
|
}
|
|
@@ -481,6 +764,7 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
481
764
|
createComponentFromNode(node: FigmaNodeProxy): FigmaNodeProxy {
|
|
482
765
|
const raw = this.graph.getNode(node[INTERNAL_ID])
|
|
483
766
|
if (!raw) throw new Error('Node not found')
|
|
767
|
+
assertComponentSourceScope(this.graph, raw.id, 'createComponentFromNode')
|
|
484
768
|
return this.wrapNode(componentFromNode(this.graph, raw, raw.parentId ?? this._currentPageId).id)
|
|
485
769
|
}
|
|
486
770
|
|
|
@@ -519,6 +803,12 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
519
803
|
if (nodes.length < 2) throw new Error('Need at least 2 nodes for boolean operation')
|
|
520
804
|
const parentId = this._nodeId(parent)
|
|
521
805
|
const members = nodes.map((node) => this._rawNode(node))
|
|
806
|
+
assertGroupPlacement(
|
|
807
|
+
this.graph,
|
|
808
|
+
parentId,
|
|
809
|
+
members.map((member) => member.id),
|
|
810
|
+
operation.toLowerCase()
|
|
811
|
+
)
|
|
522
812
|
const { node: group } = createBooleanOperation(
|
|
523
813
|
this.graph,
|
|
524
814
|
members,
|
|
@@ -628,6 +918,12 @@ export class FigmaAPI implements NodeProxyHost {
|
|
|
628
918
|
if (!raw) throw new Error('Node not found')
|
|
629
919
|
sourceNodes.push(raw)
|
|
630
920
|
}
|
|
921
|
+
assertGroupPlacement(
|
|
922
|
+
this.graph,
|
|
923
|
+
parentId,
|
|
924
|
+
sourceNodes.map((node) => node.id),
|
|
925
|
+
'flatten'
|
|
926
|
+
)
|
|
631
927
|
const vector = flattenSceneNodes(this.graph, this._renderer, sourceNodes, parentId)
|
|
632
928
|
if (index != null) this.graph.insertChildAt(vector.id, parentId, index)
|
|
633
929
|
for (const node of nodes) {
|
|
@@ -15,6 +15,7 @@ export type FigmaComponentNode = FigmaNodeProxy & ComponentNode
|
|
|
15
15
|
export type FigmaComponentSetNode = FigmaNodeProxy & ComponentSetNode
|
|
16
16
|
export type FigmaInstanceNode = FigmaNodeProxy & InstanceNode
|
|
17
17
|
export type FigmaSlotNode = FigmaNodeProxy & SlotNode
|
|
18
|
+
export type FigmaSliceNode = FigmaNodeProxy & SliceNode
|
|
18
19
|
export type FigmaSectionNode = FigmaNodeProxy & SectionNode
|
|
19
20
|
export type FigmaGroupNode = FigmaNodeProxy & GroupNode
|
|
20
21
|
export type FigmaBooleanOperationNode = FigmaNodeProxy & BooleanOperationNode
|