@pairdraw/core 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/boolean.d.ts +6 -1
- package/dist/canvas/boolean.d.ts.map +1 -1
- package/dist/canvas/boolean.js +10 -2
- package/dist/canvas/boolean.js.map +1 -1
- package/dist/canvas/color-space.d.ts +45 -0
- package/dist/canvas/color-space.d.ts.map +1 -0
- package/dist/canvas/color-space.js +39 -0
- package/dist/canvas/color-space.js.map +1 -0
- package/dist/canvas/fills.d.ts +10 -10
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +116 -62
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/flatten.d.ts +11 -3
- package/dist/canvas/flatten.d.ts.map +1 -1
- package/dist/canvas/flatten.js +62 -4
- package/dist/canvas/flatten.js.map +1 -1
- package/dist/canvas/index.d.ts +2 -1
- package/dist/canvas/index.js +2 -1
- package/dist/canvas/layout-grids.d.ts +5 -2
- package/dist/canvas/layout-grids.d.ts.map +1 -1
- package/dist/canvas/layout-grids.js +7 -2
- package/dist/canvas/layout-grids.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +17 -4
- package/dist/canvas/noise/render.d.ts.map +1 -1
- package/dist/canvas/noise/render.js +21 -6
- package/dist/canvas/noise/render.js.map +1 -1
- package/dist/canvas/noise/shader.d.ts +4 -4
- package/dist/canvas/noise/shader.d.ts.map +1 -1
- package/dist/canvas/noise/shader.js +5 -6
- package/dist/canvas/noise/shader.js.map +1 -1
- package/dist/canvas/overlays/annotations.d.ts +19 -0
- package/dist/canvas/overlays/annotations.d.ts.map +1 -0
- package/dist/canvas/overlays/annotations.js +110 -0
- package/dist/canvas/overlays/annotations.js.map +1 -0
- package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +25 -1
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/overlays/feedback.js +1 -1
- package/dist/canvas/overlays/feedback.js.map +1 -1
- package/dist/canvas/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/measurement.d.ts +7 -1
- package/dist/canvas/overlays/measurement.d.ts.map +1 -1
- package/dist/canvas/overlays/measurement.js +42 -4
- package/dist/canvas/overlays/measurement.js.map +1 -1
- package/dist/canvas/overlays/presence.d.ts.map +1 -1
- package/dist/canvas/overlays/presence.js +21 -24
- package/dist/canvas/overlays/presence.js.map +1 -1
- package/dist/canvas/renderer/colors.d.ts +7 -1
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +9 -1
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +15 -6
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
- package/dist/canvas/renderer/document-surface.js +1 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +2 -2
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +1 -0
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +4 -1
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +6 -1
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +7 -0
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +10 -0
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer.d.ts +10 -2
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +15 -3
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +9 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/clipboard/pairdraw.d.ts.map +1 -1
- package/dist/clipboard/pairdraw.js +1 -0
- package/dist/clipboard/pairdraw.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +2 -0
- package/dist/editor/bridges/clipboard.d.ts.map +1 -1
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +1 -1
- package/dist/editor/bridges/components.d.ts +14 -7
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +6 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -1
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/clipboard/code.d.ts +32 -0
- package/dist/editor/clipboard/code.d.ts.map +1 -0
- package/dist/editor/clipboard/code.js +30 -0
- package/dist/editor/clipboard/code.js.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.js +0 -0
- package/dist/editor/clipboard/paste/run.d.ts +14 -0
- package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/run.js +47 -0
- package/dist/editor/clipboard/paste/run.js.map +1 -0
- package/dist/editor/clipboard/styled.d.ts +2 -8
- package/dist/editor/clipboard/styled.d.ts.map +1 -1
- package/dist/editor/clipboard/styled.js +2 -32
- package/dist/editor/clipboard/styled.js.map +1 -1
- package/dist/editor/clipboard.d.ts +2 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +34 -0
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +5 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +69 -4
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/slots/index.d.ts.map +1 -1
- package/dist/editor/components/slots/index.js +7 -0
- package/dist/editor/components/slots/index.js.map +1 -1
- package/dist/editor/components.d.ts +6 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/components.js +14 -2
- package/dist/editor/components.js.map +1 -1
- package/dist/editor/create.d.ts +29 -2
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +11 -2
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-tokens.d.ts +1 -1
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +4 -18
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/image-edit.d.ts.map +1 -1
- package/dist/editor/image-edit.js +1 -2
- package/dist/editor/image-edit.js.map +1 -1
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts +3 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +97 -2
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/nodes.d.ts +2 -0
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +22 -7
- package/dist/editor/nodes.js.map +1 -1
- package/dist/editor/read-only/actions.js +6 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/selection/overlays.d.ts +1 -0
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +7 -0
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +8 -0
- package/dist/editor/selection.d.ts +9 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/state/shared.js +1 -0
- package/dist/editor/state/shared.js.map +1 -1
- package/dist/editor/state/view.d.ts.map +1 -1
- package/dist/editor/state/view.js +2 -0
- package/dist/editor/state/view.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +1 -1
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js +20 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/container-wrap.d.ts +8 -2
- package/dist/editor/structure/container-wrap.d.ts.map +1 -1
- package/dist/editor/structure/container-wrap.js +17 -5
- package/dist/editor/structure/container-wrap.js.map +1 -1
- package/dist/editor/structure/flatten.d.ts.map +1 -1
- package/dist/editor/structure/flatten.js +8 -7
- package/dist/editor/structure/flatten.js.map +1 -1
- package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
- package/dist/editor/structure/group/ungroup.js +2 -0
- package/dist/editor/structure/group/ungroup.js.map +1 -1
- package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
- package/dist/editor/structure/outline-stroke.js +5 -0
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -1
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/styles.d.ts +26 -0
- package/dist/editor/styles.d.ts.map +1 -0
- package/dist/editor/styles.js +127 -0
- package/dist/editor/styles.js.map +1 -0
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +10 -2
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +6 -0
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +14 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +6 -1
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +22 -1
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/shape.js +1 -1
- package/dist/figma-api/accessors/text/index.js +1 -1
- package/dist/figma-api/accessors/text/ranges.js +1 -1
- package/dist/figma-api/accessors/text/references.js +1 -1
- package/dist/figma-api/accessors/variables.js +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +8 -22
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.js +1 -1
- package/dist/figma-api/compatibility.d.ts +1 -1
- package/dist/figma-api/compatibility.d.ts.map +1 -1
- package/dist/figma-api/component-scope.d.ts +14 -0
- package/dist/figma-api/component-scope.d.ts.map +1 -0
- package/dist/figma-api/component-scope.js +28 -0
- package/dist/figma-api/component-scope.js.map +1 -0
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +26 -2
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/flatten.js +3 -3
- package/dist/figma-api/flatten.js.map +1 -1
- package/dist/figma-api/index.d.ts +77 -6
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +188 -2
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/node-types.d.ts +2 -1
- package/dist/figma-api/node-types.d.ts.map +1 -1
- package/dist/figma-api/overrides.d.ts +26 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +157 -10
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +2 -0
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +10 -2
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +61 -5
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +144 -11
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/shape-with-text.js +1 -1
- package/dist/figma-api/slots.d.ts +3 -1
- package/dist/figma-api/slots.d.ts.map +1 -1
- package/dist/figma-api/slots.js +9 -8
- package/dist/figma-api/slots.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/io/formats/code/detect.d.ts +23 -0
- package/dist/io/formats/code/detect.d.ts.map +1 -0
- package/dist/io/formats/code/detect.js +46 -0
- package/dist/io/formats/code/detect.js.map +1 -0
- package/dist/io/formats/code/index.d.ts +5 -0
- package/dist/io/formats/code/index.js +5 -0
- package/dist/io/formats/code/read.d.ts +45 -0
- package/dist/io/formats/code/read.d.ts.map +1 -0
- package/dist/io/formats/code/read.js +86 -0
- package/dist/io/formats/code/read.js.map +1 -0
- package/dist/io/formats/code/stylesheet.d.ts +13 -0
- package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
- package/dist/io/formats/code/stylesheet.js +21 -0
- package/dist/io/formats/code/stylesheet.js.map +1 -0
- package/dist/io/formats/code/tokens.d.ts +18 -0
- package/dist/io/formats/code/tokens.d.ts.map +1 -0
- package/dist/io/formats/code/tokens.js +135 -0
- package/dist/io/formats/code/tokens.js.map +1 -0
- package/dist/io/formats/design-tokens/apply.d.ts +7 -3
- package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/apply.js.map +1 -1
- package/dist/io/formats/fig/export/patch/fields.js +5 -0
- package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +20 -20
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +5 -1
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/index.d.ts +3 -2
- package/dist/io/formats/fig/index.js +2 -2
- package/dist/io/formats/fig/read.d.ts.map +1 -1
- package/dist/io/formats/fig/read.js +5 -2
- package/dist/io/formats/fig/read.js.map +1 -1
- package/dist/io/formats/html/layers.d.ts +3 -1
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +6 -1
- package/dist/io/formats/html/layers.js.map +1 -1
- package/dist/io/formats/pdf/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +7 -3
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/plan.d.ts +3 -0
- package/dist/io/formats/pdf/plan.d.ts.map +1 -1
- package/dist/io/formats/pdf/plan.js +60 -36
- package/dist/io/formats/pdf/plan.js.map +1 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +3 -2
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/index.js +2 -2
- package/dist/io/formats/raster/render.d.ts +10 -2
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +35 -9
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +19 -1
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts +5 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +59 -10
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/index.d.ts +2 -2
- package/dist/io/formats/svg/index.js +2 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +4 -2
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/record.d.ts.map +1 -1
- package/dist/io/formats/video/record.js +24 -9
- package/dist/io/formats/video/record.js.map +1 -1
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +20 -13
- package/dist/io/formats.js.map +1 -1
- package/dist/kiwi/fig/population/client.d.ts.map +1 -1
- package/dist/kiwi/fig/population/client.js +2 -1
- package/dist/kiwi/fig/population/client.js.map +1 -1
- package/dist/kiwi/fig/session/document-state.d.ts +46 -2
- package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
- package/dist/kiwi/fig/session/document-state.js +113 -5
- package/dist/kiwi/fig/session/document-state.js.map +1 -1
- package/dist/kiwi/fig/session/options.d.ts +4 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +8 -4
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.js +1 -1
- package/dist/layout/auto-layout-handles.js.map +1 -1
- package/dist/layout/axis-sizing.d.ts.map +1 -1
- package/dist/layout/axis-sizing.js +1 -1
- package/dist/layout/axis-sizing.js.map +1 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +1 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/effective-generated-text.js +1 -1
- package/dist/layout/effective-generated-text.js.map +1 -1
- package/dist/layout/grid.d.ts +3 -1
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +57 -16
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +6 -5
- package/dist/layout.js.map +1 -1
- package/dist/node/fs.d.ts.map +1 -1
- package/dist/node/fs.js +28 -7
- package/dist/node/fs.js.map +1 -1
- package/dist/prototype/easing.d.ts +13 -5
- package/dist/prototype/easing.d.ts.map +1 -1
- package/dist/prototype/easing.js +46 -6
- package/dist/prototype/easing.js.map +1 -1
- package/dist/prototype/scenes.d.ts +31 -0
- package/dist/prototype/scenes.d.ts.map +1 -1
- package/dist/prototype/scenes.js +220 -31
- package/dist/prototype/scenes.js.map +1 -1
- package/dist/prototype/session.d.ts.map +1 -1
- package/dist/prototype/session.js +1 -0
- package/dist/prototype/session.js.map +1 -1
- package/dist/prototype/smart-animate/animation.d.ts +2 -1
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
- package/dist/prototype/smart-animate/animation.js +2 -2
- package/dist/prototype/smart-animate/animation.js.map +1 -1
- package/dist/prototype/timeline.d.ts +10 -1
- package/dist/prototype/timeline.d.ts.map +1 -1
- package/dist/prototype/timeline.js +69 -23
- package/dist/prototype/timeline.js.map +1 -1
- package/dist/prototype/variables.d.ts +23 -0
- package/dist/prototype/variables.d.ts.map +1 -0
- package/dist/prototype/variables.js +237 -0
- package/dist/prototype/variables.js.map +1 -0
- package/dist/rpc/read-commands.d.ts +5 -0
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +4 -1
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/character-style.d.ts +8 -1
- package/dist/text/character-style.d.ts.map +1 -1
- package/dist/text/character-style.js +39 -1
- package/dist/text/character-style.js.map +1 -1
- package/dist/text/index.d.ts +2 -2
- package/dist/text/index.js +2 -2
- package/dist/tools/create/basic.js +3 -4
- package/dist/tools/create/basic.js.map +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/code.d.ts +6 -0
- package/dist/tools/create/code.d.ts.map +1 -0
- package/dist/tools/create/code.js +68 -0
- package/dist/tools/create/code.js.map +1 -0
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +9 -57
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.js +1 -1
- package/dist/tools/create/inputs.d.ts +11 -0
- package/dist/tools/create/inputs.d.ts.map +1 -0
- package/dist/tools/create/inputs.js +15 -0
- package/dist/tools/create/inputs.js.map +1 -0
- package/dist/tools/create/mermaid.d.ts.map +1 -1
- package/dist/tools/create/mermaid.js +5 -6
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/place.d.ts +30 -0
- package/dist/tools/create/place.d.ts.map +1 -0
- package/dist/tools/create/place.js +70 -0
- package/dist/tools/create/place.js.map +1 -0
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/create.d.ts +2 -1
- package/dist/tools/create.js +2 -1
- package/dist/tools/css/gradient.d.ts +28 -0
- package/dist/tools/css/gradient.d.ts.map +1 -0
- package/dist/tools/css/gradient.js +118 -0
- package/dist/tools/css/gradient.js.map +1 -0
- package/dist/tools/image-ai/generate.js +1 -1
- package/dist/tools/modify/geometry.js +5 -5
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +7 -1
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.js +1 -1
- package/dist/tools/modify/overrides.d.ts +6 -0
- package/dist/tools/modify/overrides.d.ts.map +1 -0
- package/dist/tools/modify/overrides.js +27 -0
- package/dist/tools/modify/overrides.js.map +1 -0
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +84 -39
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/text.d.ts +2 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +79 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +18 -2
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +3 -2
- package/dist/tools/modify.js +3 -2
- package/dist/tools/read/css.d.ts.map +1 -1
- package/dist/tools/read/css.js +29 -12
- package/dist/tools/read/css.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js +19 -5
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +6 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/text-range.d.ts +11 -0
- package/dist/tools/text-range.d.ts.map +1 -0
- package/dist/tools/text-range.js +26 -0
- package/dist/tools/text-range.js.map +1 -0
- package/dist/tools/variables/bindings.js +1 -1
- package/dist/tools/variables/bindings.js.map +1 -1
- package/dist/tools/variables/unbind.js +1 -1
- package/dist/tools/variables/unbind.js.map +1 -1
- package/dist/tools/vector/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +7 -21
- package/dist/tools/vector/path.js.map +1 -1
- package/dist/vector/rebase.d.ts +17 -0
- package/dist/vector/rebase.d.ts.map +1 -0
- package/dist/vector/rebase.js +32 -0
- package/dist/vector/rebase.js.map +1 -0
- package/package.json +14 -9
- package/src/canvas/boolean.ts +12 -1
- package/src/canvas/color-space.ts +73 -0
- package/src/canvas/fills.ts +130 -83
- package/src/canvas/flatten.ts +92 -7
- package/src/canvas/index.ts +9 -0
- package/src/canvas/layout-grids.ts +15 -2
- package/src/canvas/noise/render.ts +35 -7
- package/src/canvas/noise/shader.ts +8 -10
- package/src/canvas/overlays/annotations.ts +117 -0
- package/src/canvas/overlays/auto-layout-hover.ts +41 -1
- package/src/canvas/overlays/feedback.ts +7 -2
- package/src/canvas/overlays/index.ts +1 -1
- package/src/canvas/overlays/measurement.ts +49 -3
- package/src/canvas/overlays/presence.ts +35 -32
- package/src/canvas/renderer/colors.ts +14 -0
- package/src/canvas/renderer/document-surface.ts +16 -6
- package/src/canvas/renderer/lifecycle.ts +2 -2
- package/src/canvas/renderer/methods.ts +4 -0
- package/src/canvas/renderer/overlay-pass.ts +4 -0
- package/src/canvas/renderer/pipeline.ts +8 -0
- package/src/canvas/renderer/types.ts +8 -0
- package/src/canvas/renderer.ts +21 -2
- package/src/canvas/scene.ts +15 -7
- package/src/clipboard/pairdraw.ts +1 -0
- package/src/editor/bridges/clipboard.ts +1 -0
- package/src/editor/bridges/components.ts +10 -0
- package/src/editor/clipboard/code.ts +50 -0
- package/src/editor/clipboard/paste/dependencies.ts +18 -0
- package/src/editor/clipboard/paste/run.ts +64 -0
- package/src/editor/clipboard/styled.ts +4 -52
- package/src/editor/clipboard.ts +40 -0
- package/src/editor/components/instances.ts +92 -4
- package/src/editor/components/slots/index.ts +7 -0
- package/src/editor/components.ts +16 -2
- package/src/editor/create.ts +15 -1
- package/src/editor/design-tokens.ts +3 -23
- package/src/editor/image-edit.ts +5 -2
- package/src/editor/index.ts +1 -0
- package/src/editor/layout-mode.ts +131 -3
- package/src/editor/nodes.ts +30 -5
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/selection/overlays.ts +8 -0
- package/src/editor/state/shared.ts +1 -0
- package/src/editor/state/view.ts +2 -0
- package/src/editor/structure/boolean.ts +29 -1
- package/src/editor/structure/container-wrap.ts +20 -4
- package/src/editor/structure/flatten.ts +15 -8
- package/src/editor/structure/group/ungroup.ts +2 -0
- package/src/editor/structure/outline-stroke.ts +5 -0
- package/src/editor/styles.ts +203 -0
- package/src/editor/text/selection-style.ts +18 -1
- package/src/editor/tool-registry.ts +2 -0
- package/src/editor/types.ts +14 -0
- package/src/editor/variable-bindings.ts +11 -0
- package/src/figma-api/accessors/basic.ts +33 -1
- package/src/figma-api/accessors/vector.ts +6 -13
- package/src/figma-api/compatibility.ts +1 -0
- package/src/figma-api/component-scope.ts +36 -0
- package/src/figma-api/components.ts +24 -0
- package/src/figma-api/flatten.ts +7 -3
- package/src/figma-api/index.ts +302 -6
- package/src/figma-api/node-types.ts +1 -0
- package/src/figma-api/overrides.ts +192 -5
- package/src/figma-api/proxy.ts +16 -1
- package/src/figma-api/reactions.ts +163 -12
- package/src/figma-api/slots.ts +10 -9
- package/src/io/formats/code/detect.ts +67 -0
- package/src/io/formats/code/index.ts +17 -0
- package/src/io/formats/code/read.ts +143 -0
- package/src/io/formats/code/stylesheet.ts +24 -0
- package/src/io/formats/code/tokens.ts +159 -0
- package/src/io/formats/design-tokens/apply.ts +3 -2
- package/src/io/formats/fig/export/patch/fields.ts +11 -0
- package/src/io/formats/fig/export/patch/index.ts +23 -19
- package/src/io/formats/fig/export/setup.ts +8 -1
- package/src/io/formats/fig/index.ts +6 -0
- package/src/io/formats/fig/read.ts +11 -2
- package/src/io/formats/html/layers.ts +7 -0
- package/src/io/formats/pdf/export.ts +19 -7
- package/src/io/formats/pdf/plan.ts +71 -32
- package/src/io/formats/raster/headless.ts +3 -1
- package/src/io/formats/raster/index.ts +2 -0
- package/src/io/formats/raster/render.ts +49 -9
- package/src/io/formats/svg/defs.ts +27 -1
- package/src/io/formats/svg/export.ts +75 -13
- package/src/io/formats/svg/index.ts +1 -0
- package/src/io/formats/svg/text/layout.ts +5 -3
- package/src/io/formats/video/record.ts +33 -9
- package/src/io/formats.ts +35 -15
- package/src/kiwi/fig/population/client.ts +6 -1
- package/src/kiwi/fig/session/document-state.ts +195 -5
- package/src/kiwi/fig/session/options.ts +2 -0
- package/src/layout/apply.ts +12 -4
- package/src/layout/auto-layout-handles.ts +1 -1
- package/src/layout/axis-sizing.ts +3 -1
- package/src/layout/derived.ts +3 -1
- package/src/layout/effective-generated-text.ts +1 -1
- package/src/layout/grid.ts +91 -21
- package/src/layout.ts +16 -3
- package/src/node/fs.ts +32 -7
- package/src/prototype/easing.ts +79 -7
- package/src/prototype/scenes.ts +244 -15
- package/src/prototype/session.ts +1 -0
- package/src/prototype/smart-animate/animation.ts +4 -3
- package/src/prototype/timeline.ts +118 -26
- package/src/prototype/variables.ts +189 -0
- package/src/rpc/read-commands.ts +19 -1
- package/src/text/character-style.ts +47 -0
- package/src/text/index.ts +1 -1
- package/src/tools/create/basic.ts +2 -3
- package/src/tools/create/code.ts +85 -0
- package/src/tools/create/html.ts +9 -46
- package/src/tools/create/inputs.ts +12 -0
- package/src/tools/create/mermaid.ts +6 -6
- package/src/tools/create/place.ts +80 -0
- package/src/tools/create.ts +1 -0
- package/src/tools/css/gradient.ts +147 -0
- package/src/tools/modify/geometry.ts +5 -5
- package/src/tools/modify/layout.ts +19 -0
- package/src/tools/modify/overrides.ts +35 -0
- package/src/tools/modify/paint.ts +124 -54
- package/src/tools/modify/text.ts +91 -7
- package/src/tools/modify/update.ts +23 -2
- package/src/tools/modify.ts +9 -1
- package/src/tools/read/css.ts +46 -12
- package/src/tools/read/nodes.ts +26 -4
- package/src/tools/registry/extended.ts +6 -0
- package/src/tools/text-range.ts +29 -0
- package/src/tools/variables/bindings.ts +4 -1
- package/src/tools/variables/unbind.ts +4 -1
- package/src/tools/vector/path.ts +11 -13
- package/src/vector/rebase.ts +33 -0
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
PrototypeAction,
|
|
3
|
+
PrototypeCubicBezier,
|
|
3
4
|
PrototypeEasingType,
|
|
4
5
|
PrototypeOverlayPositionType,
|
|
6
|
+
PrototypeSpring,
|
|
5
7
|
PrototypeTransitionType,
|
|
6
8
|
SceneGraph,
|
|
7
9
|
SceneNode
|
|
8
10
|
} from '@pairdraw/scene-graph'
|
|
9
11
|
|
|
10
12
|
import { easingAt } from './easing'
|
|
13
|
+
import { createPlayScenes, type PlayScenes } from './scenes'
|
|
11
14
|
import {
|
|
12
15
|
primaryAction,
|
|
13
16
|
shownFrame,
|
|
14
17
|
startSession,
|
|
15
|
-
step,
|
|
16
18
|
timeoutReactions,
|
|
17
19
|
topFrameOf,
|
|
18
20
|
type PlaySession
|
|
@@ -44,6 +46,11 @@ interface TimelineTransition {
|
|
|
44
46
|
/** The transition's own length, which keeps its pace when a later step cuts it short. */
|
|
45
47
|
fadeMs: number
|
|
46
48
|
easing?: PrototypeEasingType
|
|
49
|
+
easingCurve?: PrototypeCubicBezier
|
|
50
|
+
easingSpring?: PrototypeSpring
|
|
51
|
+
/** The screens as play showed them, with its variable values and modes applied. */
|
|
52
|
+
fromGraph?: SceneGraph
|
|
53
|
+
toGraph?: SceneGraph
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
/**
|
|
@@ -51,7 +58,7 @@ interface TimelineTransition {
|
|
|
51
58
|
* animate between them.
|
|
52
59
|
*/
|
|
53
60
|
export type TimelineSegment =
|
|
54
|
-
| { kind: 'hold'; session: PlaySession; startMs: number; endMs: number }
|
|
61
|
+
| { kind: 'hold'; session: PlaySession; startMs: number; endMs: number; graph?: SceneGraph }
|
|
55
62
|
| ({ kind: 'dissolve' } & TimelineTransition)
|
|
56
63
|
| ({ kind: 'smart' } & TimelineTransition)
|
|
57
64
|
|
|
@@ -85,8 +92,14 @@ export interface Timeline {
|
|
|
85
92
|
* Smart animate `progress` of the way through its time, which its animation eases.
|
|
86
93
|
*/
|
|
87
94
|
export type TimelineFrame =
|
|
88
|
-
| { session: PlaySession }
|
|
89
|
-
| {
|
|
95
|
+
| { session: PlaySession; graph?: SceneGraph }
|
|
96
|
+
| {
|
|
97
|
+
from: PlaySession
|
|
98
|
+
to: PlaySession
|
|
99
|
+
mix: number
|
|
100
|
+
fromGraph?: SceneGraph
|
|
101
|
+
toGraph?: SceneGraph
|
|
102
|
+
}
|
|
90
103
|
| { smart: TimelineSmartSegment; progress: number }
|
|
91
104
|
|
|
92
105
|
/** Why a flow cannot be played: the start frame has nothing to follow, or anything else. */
|
|
@@ -202,18 +215,24 @@ function clickAction(
|
|
|
202
215
|
|
|
203
216
|
interface ArmedTimer {
|
|
204
217
|
atMs: number
|
|
218
|
+
sourceId: string
|
|
205
219
|
action: PrototypeAction
|
|
206
220
|
}
|
|
207
221
|
|
|
208
222
|
/** The shown frame's After delay reactions, each due `delay` after the frame finished entering. */
|
|
209
223
|
function armTimers(graph: SceneGraph, session: PlaySession, readyMs: number): ArmedTimer[] {
|
|
224
|
+
const sourceId = shownFrame(session)
|
|
210
225
|
return timeoutReactions(graph, session)
|
|
211
|
-
.map(({ action, delayMs }) => ({ atMs: readyMs + delayMs, action }))
|
|
226
|
+
.map(({ action, delayMs }) => ({ atMs: readyMs + delayMs, sourceId, action }))
|
|
212
227
|
.toSorted((a, b) => a.atMs - b.atMs)
|
|
213
228
|
}
|
|
214
229
|
|
|
215
230
|
/** Play at its start frame, which must be a top-level frame with something to follow. */
|
|
216
|
-
function startWalk(
|
|
231
|
+
function startWalk(
|
|
232
|
+
graph: SceneGraph,
|
|
233
|
+
play: PlayScenes,
|
|
234
|
+
options: TimelineOptions
|
|
235
|
+
): { walk: Walk; start: SceneNode } {
|
|
217
236
|
const start = graph.getNode(options.startFrameId)
|
|
218
237
|
if (!start || topFrameOf(graph, start)?.id !== start.id) {
|
|
219
238
|
throw new TimelineError(`'${start?.name ?? options.startFrameId}' is not a top-level frame`)
|
|
@@ -221,7 +240,9 @@ function startWalk(graph: SceneGraph, options: TimelineOptions): { walk: Walk; s
|
|
|
221
240
|
const session = startSession(start.id)
|
|
222
241
|
const walk: Walk = {
|
|
223
242
|
graph,
|
|
243
|
+
play,
|
|
224
244
|
session,
|
|
245
|
+
stateGraph: play.hasVariables() ? play.cloneGraphFor(start.id) : graph,
|
|
225
246
|
readyMs: 0,
|
|
226
247
|
timers: armTimers(graph, session, 0),
|
|
227
248
|
clicks: (options.clicks ?? []).toSorted((a, b) => a.atMs - b.atMs),
|
|
@@ -243,7 +264,10 @@ function startWalk(graph: SceneGraph, options: TimelineOptions): { walk: Walk; s
|
|
|
243
264
|
/** Play in progress on the virtual clock: what is shown, since when, and what is due next. */
|
|
244
265
|
interface Walk {
|
|
245
266
|
graph: SceneGraph
|
|
267
|
+
play: PlayScenes
|
|
246
268
|
session: PlaySession
|
|
269
|
+
/** The shown screen as play draws it now, variables and modes applied. */
|
|
270
|
+
stateGraph: SceneGraph
|
|
247
271
|
/** When the shown screen finished entering; its After delays count from here. */
|
|
248
272
|
readyMs: number
|
|
249
273
|
timers: ArmedTimer[]
|
|
@@ -257,15 +281,23 @@ interface Walk {
|
|
|
257
281
|
|
|
258
282
|
interface WalkEvent {
|
|
259
283
|
atMs: number
|
|
284
|
+
sourceId: string
|
|
260
285
|
action: PrototypeAction | null
|
|
261
286
|
trigger: TimelineStep['trigger']
|
|
262
287
|
}
|
|
263
288
|
|
|
264
289
|
/** Holds the shown screen from when it finished entering until `endMs`. */
|
|
265
|
-
function hold(walk: Walk, endMs: number): void {
|
|
266
|
-
if (endMs
|
|
267
|
-
|
|
290
|
+
function hold(walk: Walk, endMs: number, graph = walk.stateGraph): void {
|
|
291
|
+
if (endMs <= walk.readyMs) return
|
|
292
|
+
const segment: TimelineSegment = {
|
|
293
|
+
kind: 'hold',
|
|
294
|
+
session: walk.session,
|
|
295
|
+
startMs: walk.readyMs,
|
|
296
|
+
endMs
|
|
268
297
|
}
|
|
298
|
+
// The document itself when play changed no variable, so the recorder draws as it always has.
|
|
299
|
+
if (graph !== walk.graph) segment.graph = graph
|
|
300
|
+
walk.segments.push(segment)
|
|
269
301
|
}
|
|
270
302
|
|
|
271
303
|
/** The earliest due timer or click, taken off its queue; null when nothing else will happen. */
|
|
@@ -274,13 +306,18 @@ function takeNextEvent(walk: Walk): WalkEvent | null {
|
|
|
274
306
|
const click = walk.clicks.at(walk.clickIndex)
|
|
275
307
|
if (timer && (!click || timer.atMs <= click.atMs)) {
|
|
276
308
|
walk.timers = walk.timers.slice(1)
|
|
277
|
-
return {
|
|
309
|
+
return {
|
|
310
|
+
atMs: timer.atMs,
|
|
311
|
+
sourceId: timer.sourceId,
|
|
312
|
+
action: timer.action,
|
|
313
|
+
trigger: 'AFTER_TIMEOUT'
|
|
314
|
+
}
|
|
278
315
|
}
|
|
279
316
|
if (!click) return null
|
|
280
317
|
const action = clickAction(walk.graph, walk.session, click, walk.clickIndex)
|
|
281
318
|
walk.clickIndex += 1
|
|
282
319
|
if (!action) walk.skippedClicks.push(click)
|
|
283
|
-
return { atMs: click.atMs, action, trigger: 'ON_CLICK' }
|
|
320
|
+
return { atMs: click.atMs, sourceId: click.nodeId, action, trigger: 'ON_CLICK' }
|
|
284
321
|
}
|
|
285
322
|
|
|
286
323
|
/** The earliest event's time without taking it, or infinity when nothing else will happen. */
|
|
@@ -291,8 +328,14 @@ function nextEventAt(walk: Walk): number {
|
|
|
291
328
|
}
|
|
292
329
|
|
|
293
330
|
/** Runs `action` at `atMs`, recording the hold before it, its crossfade, and the step. */
|
|
294
|
-
function advance(
|
|
331
|
+
function advance(
|
|
332
|
+
walk: Walk,
|
|
333
|
+
event: WalkEvent & { action: PrototypeAction },
|
|
334
|
+
next: PlaySession
|
|
335
|
+
): void {
|
|
295
336
|
const { atMs, action } = event
|
|
337
|
+
const fromGraph = walk.stateGraph
|
|
338
|
+
const toGraph = walk.play.hasVariables() ? walk.play.cloneGraphFor(shownFrame(next)) : walk.graph
|
|
296
339
|
// A step while a transition still runs cuts it short where it is.
|
|
297
340
|
const running = walk.segments.at(-1)
|
|
298
341
|
if (running && running.kind !== 'hold' && running.endMs > atMs) running.endMs = atMs
|
|
@@ -300,17 +343,26 @@ function advance(walk: Walk, event: WalkEvent & { action: PrototypeAction }, nex
|
|
|
300
343
|
const durationMs = transitionMs(action)
|
|
301
344
|
const animation = animationFor(walk.session, action)
|
|
302
345
|
if (animation !== 'cut') {
|
|
303
|
-
|
|
346
|
+
const easing =
|
|
347
|
+
action.type === 'NODE' && action.transition.easing
|
|
348
|
+
? {
|
|
349
|
+
easing: action.transition.easing,
|
|
350
|
+
easingCurve: action.transition.easingCurve,
|
|
351
|
+
easingSpring: action.transition.easingSpring
|
|
352
|
+
}
|
|
353
|
+
: undefined
|
|
354
|
+
const segment: TimelineTransition & { kind: 'smart' | 'dissolve' } = {
|
|
304
355
|
kind: animation === 'smart' ? 'smart' : 'dissolve',
|
|
305
356
|
from: walk.session,
|
|
306
357
|
to: next,
|
|
307
358
|
startMs: atMs,
|
|
308
359
|
endMs: atMs + durationMs,
|
|
309
|
-
fadeMs: durationMs
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
360
|
+
fadeMs: durationMs
|
|
361
|
+
}
|
|
362
|
+
if (fromGraph !== walk.graph) segment.fromGraph = fromGraph
|
|
363
|
+
if (toGraph !== walk.graph) segment.toGraph = toGraph
|
|
364
|
+
if (easing) Object.assign(segment, easing)
|
|
365
|
+
walk.segments.push(segment)
|
|
314
366
|
}
|
|
315
367
|
walk.steps.push({
|
|
316
368
|
atMs,
|
|
@@ -322,6 +374,7 @@ function advance(walk: Walk, event: WalkEvent & { action: PrototypeAction }, nex
|
|
|
322
374
|
walk.overlayPositions[action.nodeId] = action.overlayPosition
|
|
323
375
|
}
|
|
324
376
|
walk.session = next
|
|
377
|
+
walk.stateGraph = toGraph
|
|
325
378
|
walk.readyMs = atMs + durationMs
|
|
326
379
|
walk.timers = armTimers(walk.graph, next, walk.readyMs)
|
|
327
380
|
}
|
|
@@ -346,7 +399,8 @@ function finish(walk: Walk, durationMs: number, end: 'ends' | 'loops' | 'truncat
|
|
|
346
399
|
* held `tailMs`), or at `maxMs` (`truncated`).
|
|
347
400
|
*/
|
|
348
401
|
export function planTimeline(graph: SceneGraph, options: TimelineOptions): Timeline {
|
|
349
|
-
const
|
|
402
|
+
const play = createPlayScenes(() => graph)
|
|
403
|
+
const { walk, start } = startWalk(graph, play, options)
|
|
350
404
|
const startKey = sessionDrawKey(walk.session)
|
|
351
405
|
|
|
352
406
|
for (let taken = 0; taken <= MAX_TIMELINE_STEPS; taken++) {
|
|
@@ -368,11 +422,35 @@ export function planTimeline(graph: SceneGraph, options: TimelineOptions): Timel
|
|
|
368
422
|
return truncated ? finish(walk, options.maxMs, 'truncated') : finish(walk, endMs, 'ends')
|
|
369
423
|
}
|
|
370
424
|
const event = takeNextEvent(walk)
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
425
|
+
if (!event?.action) continue
|
|
426
|
+
const result = walk.play.run(
|
|
427
|
+
walk.session,
|
|
428
|
+
{
|
|
429
|
+
sourceId: event.sourceId,
|
|
430
|
+
action: event.action,
|
|
431
|
+
transition: event.action.type === 'NODE' ? event.action.transition : null
|
|
432
|
+
},
|
|
433
|
+
shownFrame(walk.session)
|
|
434
|
+
)
|
|
435
|
+
if (result.variablesRefused) {
|
|
436
|
+
throw new TimelineError(
|
|
437
|
+
`Could not run a variable action at ${seconds(event.atMs)}: ${result.variablesRefused}`
|
|
438
|
+
)
|
|
439
|
+
}
|
|
440
|
+
const resolved = result.action ?? event.action
|
|
441
|
+
const next = result.session
|
|
442
|
+
if (next === walk.session) {
|
|
443
|
+
// A variable or mode change shows at once, without a transition or a step.
|
|
444
|
+
if (result.repaint) {
|
|
445
|
+
hold(walk, event.atMs)
|
|
446
|
+
walk.readyMs = event.atMs
|
|
447
|
+
walk.stateGraph = walk.play.hasVariables()
|
|
448
|
+
? walk.play.cloneGraphFor(shownFrame(walk.session))
|
|
449
|
+
: walk.graph
|
|
450
|
+
}
|
|
451
|
+
continue
|
|
452
|
+
}
|
|
453
|
+
advance(walk, { ...event, action: resolved }, next)
|
|
376
454
|
|
|
377
455
|
if (sessionDrawKey(next) === startKey && walk.clickIndex >= walk.clicks.length) {
|
|
378
456
|
if (walk.readyMs === 0) {
|
|
@@ -389,10 +467,24 @@ export function planTimeline(graph: SceneGraph, options: TimelineOptions): Timel
|
|
|
389
467
|
export function frameAt(timeline: Timeline, atMs: number): TimelineFrame {
|
|
390
468
|
for (const segment of timeline.segments) {
|
|
391
469
|
if (atMs >= segment.endMs) continue
|
|
392
|
-
if (segment.kind === 'hold')
|
|
470
|
+
if (segment.kind === 'hold')
|
|
471
|
+
return segment.graph
|
|
472
|
+
? { session: segment.session, graph: segment.graph }
|
|
473
|
+
: { session: segment.session }
|
|
393
474
|
const progress = (atMs - segment.startMs) / segment.fadeMs
|
|
394
475
|
if (segment.kind === 'smart') return { smart: segment, progress }
|
|
395
|
-
|
|
476
|
+
const frame: TimelineFrame = {
|
|
477
|
+
from: segment.from,
|
|
478
|
+
to: segment.to,
|
|
479
|
+
mix: easingAt(segment.easing, progress, {
|
|
480
|
+
curve: segment.easingCurve,
|
|
481
|
+
spring: segment.easingSpring,
|
|
482
|
+
duration: segment.fadeMs / 1000
|
|
483
|
+
})
|
|
484
|
+
}
|
|
485
|
+
if (segment.fromGraph) frame.fromGraph = segment.fromGraph
|
|
486
|
+
if (segment.toGraph) frame.toGraph = segment.toGraph
|
|
487
|
+
return frame
|
|
396
488
|
}
|
|
397
489
|
const last = timeline.segments.at(-1)
|
|
398
490
|
if (!last) throw new TimelineError('The timeline is empty')
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { PrototypeVariableValue } from '@pairdraw/scene-graph'
|
|
2
|
+
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
3
|
+
|
|
4
|
+
/** What a variable or expression resolves to at play time. */
|
|
5
|
+
export type PrototypeResolvedValue = boolean | number | string | Color
|
|
6
|
+
|
|
7
|
+
export type PrototypeEvaluation =
|
|
8
|
+
| { ok: true; value: PrototypeResolvedValue }
|
|
9
|
+
| { ok: false; reason: string }
|
|
10
|
+
|
|
11
|
+
/** Resolves an alias to the value its variable holds in this session. */
|
|
12
|
+
export type PrototypeAliasResolver = (variableId: string) => PrototypeResolvedValue | undefined
|
|
13
|
+
|
|
14
|
+
function isColor(value: PrototypeResolvedValue): value is Color {
|
|
15
|
+
return typeof value === 'object' && 'r' in value
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function equal(a: PrototypeResolvedValue, b: PrototypeResolvedValue): boolean {
|
|
19
|
+
if (isColor(a) && isColor(b)) return a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a
|
|
20
|
+
return a === b
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A value written as text, or null for a colour, which has no text form here. */
|
|
24
|
+
function stringOf(value: PrototypeResolvedValue): string | null {
|
|
25
|
+
if (typeof value === 'string') return value
|
|
26
|
+
if (typeof value === 'number' || typeof value === 'boolean') return String(value)
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function numbers(fn: string, ...values: PrototypeResolvedValue[]): number[] | string {
|
|
31
|
+
const result: number[] = []
|
|
32
|
+
for (const value of values) {
|
|
33
|
+
if (typeof value !== 'number') return `${fn} needs numbers`
|
|
34
|
+
result.push(value)
|
|
35
|
+
}
|
|
36
|
+
return result
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function booleans(fn: string, ...values: PrototypeResolvedValue[]): boolean[] | string {
|
|
40
|
+
const result: boolean[] = []
|
|
41
|
+
for (const value of values) {
|
|
42
|
+
if (typeof value !== 'boolean') return `${fn} needs booleans`
|
|
43
|
+
result.push(value)
|
|
44
|
+
}
|
|
45
|
+
return result
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function arithmetic(
|
|
49
|
+
fn: 'ADDITION' | 'DIVIDE' | 'MULTIPLY' | 'SUBTRACTION',
|
|
50
|
+
values: PrototypeResolvedValue[]
|
|
51
|
+
): PrototypeEvaluation {
|
|
52
|
+
if (values.length < 2) return { ok: false, reason: `${fn} needs two values` }
|
|
53
|
+
const left = values[0]
|
|
54
|
+
const right = values[1]
|
|
55
|
+
if (fn === 'ADDITION' && (typeof left === 'string' || typeof right === 'string')) {
|
|
56
|
+
const a = stringOf(left)
|
|
57
|
+
const b = stringOf(right)
|
|
58
|
+
return a === null || b === null
|
|
59
|
+
? { ok: false, reason: 'ADDITION cannot join a colour' }
|
|
60
|
+
: { ok: true, value: a + b }
|
|
61
|
+
}
|
|
62
|
+
const operands = numbers(fn, left, right)
|
|
63
|
+
if (typeof operands === 'string') return { ok: false, reason: operands }
|
|
64
|
+
const a = operands[0]
|
|
65
|
+
const b = operands[1]
|
|
66
|
+
if (fn === 'ADDITION') return { ok: true, value: a + b }
|
|
67
|
+
if (fn === 'SUBTRACTION') return { ok: true, value: a - b }
|
|
68
|
+
if (fn === 'MULTIPLY') return { ok: true, value: a * b }
|
|
69
|
+
return b === 0 ? { ok: false, reason: 'DIVIDE by zero' } : { ok: true, value: a / b }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function comparison(
|
|
73
|
+
fn:
|
|
74
|
+
| 'EQUALS'
|
|
75
|
+
| 'GREATER_THAN'
|
|
76
|
+
| 'GREATER_THAN_OR_EQUAL'
|
|
77
|
+
| 'LESS_THAN'
|
|
78
|
+
| 'LESS_THAN_OR_EQUAL'
|
|
79
|
+
| 'NOT_EQUAL',
|
|
80
|
+
values: PrototypeResolvedValue[]
|
|
81
|
+
): PrototypeEvaluation {
|
|
82
|
+
if (values.length < 2) return { ok: false, reason: `${fn} needs two values` }
|
|
83
|
+
const left = values[0]
|
|
84
|
+
const right = values[1]
|
|
85
|
+
if (fn === 'EQUALS') return { ok: true, value: equal(left, right) }
|
|
86
|
+
if (fn === 'NOT_EQUAL') return { ok: true, value: !equal(left, right) }
|
|
87
|
+
const operands = numbers(fn, left, right)
|
|
88
|
+
if (typeof operands === 'string') return { ok: false, reason: operands }
|
|
89
|
+
const a = operands[0]
|
|
90
|
+
const b = operands[1]
|
|
91
|
+
if (fn === 'LESS_THAN') return { ok: true, value: a < b }
|
|
92
|
+
if (fn === 'LESS_THAN_OR_EQUAL') return { ok: true, value: a <= b }
|
|
93
|
+
if (fn === 'GREATER_THAN') return { ok: true, value: a > b }
|
|
94
|
+
return { ok: true, value: a >= b }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function logic(fn: 'AND' | 'NOT' | 'OR', values: PrototypeResolvedValue[]): PrototypeEvaluation {
|
|
98
|
+
const operands = booleans(fn, ...values)
|
|
99
|
+
if (typeof operands === 'string') return { ok: false, reason: operands }
|
|
100
|
+
if (fn === 'NOT') {
|
|
101
|
+
if (operands.length < 1) return { ok: false, reason: 'NOT needs a value' }
|
|
102
|
+
return { ok: true, value: !operands[0] }
|
|
103
|
+
}
|
|
104
|
+
return { ok: true, value: fn === 'AND' ? operands.every(Boolean) : operands.some(Boolean) }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function conversion(
|
|
108
|
+
fn: 'COMPOSE_COLOR' | 'IS_TRUTHY' | 'NEGATE' | 'STRINGIFY' | 'TERNARY',
|
|
109
|
+
values: PrototypeResolvedValue[]
|
|
110
|
+
): PrototypeEvaluation {
|
|
111
|
+
if (values.length < 1) return { ok: false, reason: `${fn} needs a value` }
|
|
112
|
+
const first = values[0]
|
|
113
|
+
if (fn === 'IS_TRUTHY') return { ok: true, value: Boolean(first) }
|
|
114
|
+
if (fn === 'STRINGIFY') {
|
|
115
|
+
const text = stringOf(first)
|
|
116
|
+
return text === null
|
|
117
|
+
? { ok: false, reason: 'STRINGIFY cannot write a colour as text' }
|
|
118
|
+
: { ok: true, value: text }
|
|
119
|
+
}
|
|
120
|
+
if (fn === 'NEGATE') {
|
|
121
|
+
const number = numbers(fn, first)
|
|
122
|
+
return typeof number === 'string'
|
|
123
|
+
? { ok: false, reason: number }
|
|
124
|
+
: { ok: true, value: -number[0] }
|
|
125
|
+
}
|
|
126
|
+
if (fn === 'COMPOSE_COLOR') {
|
|
127
|
+
if (!isColor(first) || values.length < 2)
|
|
128
|
+
return { ok: false, reason: 'COMPOSE_COLOR needs a colour and an opacity' }
|
|
129
|
+
const opacity = numbers(fn, values[1])
|
|
130
|
+
return typeof opacity === 'string'
|
|
131
|
+
? { ok: false, reason: opacity }
|
|
132
|
+
: { ok: true, value: { ...first, a: opacity[0] / 100 } }
|
|
133
|
+
}
|
|
134
|
+
if (values.length < 3) return { ok: false, reason: 'TERNARY needs three values' }
|
|
135
|
+
const condition = booleans(fn, first)
|
|
136
|
+
return typeof condition === 'string'
|
|
137
|
+
? { ok: false, reason: condition }
|
|
138
|
+
: { ok: true, value: condition[0] ? values[1] : values[2] }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function evaluateFunction(fn: string, values: PrototypeResolvedValue[]): PrototypeEvaluation {
|
|
142
|
+
if (fn === 'ADDITION' || fn === 'SUBTRACTION' || fn === 'MULTIPLY' || fn === 'DIVIDE')
|
|
143
|
+
return arithmetic(fn, values)
|
|
144
|
+
if (
|
|
145
|
+
fn === 'EQUALS' ||
|
|
146
|
+
fn === 'NOT_EQUAL' ||
|
|
147
|
+
fn === 'LESS_THAN' ||
|
|
148
|
+
fn === 'LESS_THAN_OR_EQUAL' ||
|
|
149
|
+
fn === 'GREATER_THAN' ||
|
|
150
|
+
fn === 'GREATER_THAN_OR_EQUAL'
|
|
151
|
+
)
|
|
152
|
+
return comparison(fn, values)
|
|
153
|
+
if (fn === 'AND' || fn === 'OR' || fn === 'NOT') return logic(fn, values)
|
|
154
|
+
if (
|
|
155
|
+
fn === 'IS_TRUTHY' ||
|
|
156
|
+
fn === 'STRINGIFY' ||
|
|
157
|
+
fn === 'NEGATE' ||
|
|
158
|
+
fn === 'TERNARY' ||
|
|
159
|
+
fn === 'COMPOSE_COLOR'
|
|
160
|
+
)
|
|
161
|
+
return conversion(fn, values)
|
|
162
|
+
return { ok: false, reason: `Unsupported expression function ${fn}` }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The value of a variable expression at play time, with aliases read from the session overlay.
|
|
167
|
+
* A function this build cannot compute, or a type a function does not take, is refused with a
|
|
168
|
+
* reason rather than guessed.
|
|
169
|
+
*/
|
|
170
|
+
export function evaluateVariable(
|
|
171
|
+
value: PrototypeVariableValue,
|
|
172
|
+
resolveAlias: PrototypeAliasResolver = () => undefined
|
|
173
|
+
): PrototypeEvaluation {
|
|
174
|
+
if (value.kind === 'alias') {
|
|
175
|
+
const resolved = resolveAlias(value.variableId)
|
|
176
|
+
return resolved === undefined
|
|
177
|
+
? { ok: false, reason: `Variable ${value.variableId} has no value here` }
|
|
178
|
+
: { ok: true, value: resolved }
|
|
179
|
+
}
|
|
180
|
+
if (value.kind !== 'expression') return { ok: true, value: value.value }
|
|
181
|
+
|
|
182
|
+
const evaluated: PrototypeResolvedValue[] = []
|
|
183
|
+
for (const argument of value.args) {
|
|
184
|
+
const result = evaluateVariable(argument, resolveAlias)
|
|
185
|
+
if (!result.ok) return result
|
|
186
|
+
evaluated.push(result.value)
|
|
187
|
+
}
|
|
188
|
+
return evaluateFunction(String(value.fn), evaluated)
|
|
189
|
+
}
|
package/src/rpc/read-commands.ts
CHANGED
|
@@ -3,6 +3,12 @@ import { sumBy } from 'es-toolkit'
|
|
|
3
3
|
import type { BooleanOperation, MaskType, SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
4
4
|
|
|
5
5
|
import { shapeDetailFields } from '#core/figma-api/shape-details'
|
|
6
|
+
import {
|
|
7
|
+
readerDiagnosticComponents,
|
|
8
|
+
readerDiagnosticCounts,
|
|
9
|
+
type ReaderDiagnosticComponent,
|
|
10
|
+
type ReaderDiagnosticCount
|
|
11
|
+
} from '#core/kiwi/fig/session/document-state'
|
|
6
12
|
import { ELLIPSIS } from '#core/text/ellipsis'
|
|
7
13
|
import type { FontReadiness } from '#core/text/font/readiness'
|
|
8
14
|
import { resolveFontReadiness } from '#core/text/prepare'
|
|
@@ -74,6 +80,10 @@ export interface InfoResult {
|
|
|
74
80
|
types: Record<string, number>
|
|
75
81
|
fonts: string[]
|
|
76
82
|
pageCounts: Record<string, number>
|
|
83
|
+
/** What the reader skipped, counted by kind; empty for a graph not read as a Figma file. */
|
|
84
|
+
diagnostics: ReaderDiagnosticCount[]
|
|
85
|
+
/** The same records under the components they belong to, largest first. */
|
|
86
|
+
diagnosticComponents: readonly ReaderDiagnosticComponent[]
|
|
77
87
|
}
|
|
78
88
|
|
|
79
89
|
export const infoCommand: RPCCommand<void, InfoResult> = {
|
|
@@ -100,7 +110,15 @@ export const infoCommand: RPCCommand<void, InfoResult> = {
|
|
|
100
110
|
pageCounts[page.name] = totalNodes - beforePage
|
|
101
111
|
}
|
|
102
112
|
|
|
103
|
-
return {
|
|
113
|
+
return {
|
|
114
|
+
pages: pages.length,
|
|
115
|
+
totalNodes,
|
|
116
|
+
types,
|
|
117
|
+
fonts: [...fonts].sort(),
|
|
118
|
+
pageCounts,
|
|
119
|
+
diagnostics: readerDiagnosticCounts(graph),
|
|
120
|
+
diagnosticComponents: readerDiagnosticComponents(graph)
|
|
121
|
+
}
|
|
104
122
|
}
|
|
105
123
|
}
|
|
106
124
|
|
|
@@ -277,6 +277,53 @@ export function layerTextStyleChanges(
|
|
|
277
277
|
return { ...changes, ...textStyleChanges(node, style) }
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Text styles whose characters do not all have the same effective value, which the panel shows as
|
|
282
|
+
* Mixed: a run's own value where it sets one, the layer's elsewhere. A style every character shares
|
|
283
|
+
* is not mixed even when only the runs set it. `start`/`end` narrow it to a range, as the
|
|
284
|
+
* characters selected while editing.
|
|
285
|
+
*/
|
|
286
|
+
export function mixedTextStyleKeys(
|
|
287
|
+
node: SceneNode,
|
|
288
|
+
start = 0,
|
|
289
|
+
end = node.text.length
|
|
290
|
+
): TextStyleKey[] {
|
|
291
|
+
if (node.type !== 'TEXT' || node.styleRuns.length === 0 || end <= start) return []
|
|
292
|
+
const base = nodeStyle(node)
|
|
293
|
+
const runs = node.styleRuns
|
|
294
|
+
.map((run) => ({
|
|
295
|
+
from: Math.max(start, run.start),
|
|
296
|
+
to: Math.min(end, run.start + run.length),
|
|
297
|
+
style: run.style
|
|
298
|
+
}))
|
|
299
|
+
.filter((run) => run.to > run.from)
|
|
300
|
+
const mixed = new Set<TextStyleKey>()
|
|
301
|
+
for (const key of TEXT_STYLE_KEYS) {
|
|
302
|
+
let first: unknown
|
|
303
|
+
let seen = false
|
|
304
|
+
const outcome = { differs: false }
|
|
305
|
+
const consider = (value: unknown) => {
|
|
306
|
+
if (!seen) {
|
|
307
|
+
first = value
|
|
308
|
+
seen = true
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
if (!isEqual(value, first)) outcome.differs = true
|
|
312
|
+
}
|
|
313
|
+
// The characters a run covers carry its value, or the layer's where the run leaves the key
|
|
314
|
+
// alone; a gap between runs carries the layer's. Only two different values make it mixed.
|
|
315
|
+
let cursor = start
|
|
316
|
+
for (const run of runs) {
|
|
317
|
+
if (run.from > cursor) consider(base[key])
|
|
318
|
+
consider(run.style[key] ?? base[key])
|
|
319
|
+
cursor = Math.max(cursor, run.to)
|
|
320
|
+
}
|
|
321
|
+
if (cursor < end) consider(base[key])
|
|
322
|
+
if (outcome.differs) mixed.add(key)
|
|
323
|
+
}
|
|
324
|
+
return TEXT_STYLE_KEYS.filter((key) => mixed.has(key))
|
|
325
|
+
}
|
|
326
|
+
|
|
280
327
|
/**
|
|
281
328
|
* The style a text layer shows as its own: its first character's, which a range may set; the
|
|
282
329
|
* panel shows it, as it shows the first selected character's while text is edited.
|
package/src/text/index.ts
CHANGED
|
@@ -64,7 +64,7 @@ export const createPage = defineTool({
|
|
|
64
64
|
export const createSlice = defineTool({
|
|
65
65
|
name: 'create_slice',
|
|
66
66
|
|
|
67
|
-
description: 'Create a slice (export region) on the canvas.',
|
|
67
|
+
description: 'Create a slice layer (export region) on the canvas.',
|
|
68
68
|
execution: { kind: 'sync', mutation: 'document' },
|
|
69
69
|
input: v.strictObject({
|
|
70
70
|
...positionInputs,
|
|
@@ -76,12 +76,11 @@ export const createSlice = defineTool({
|
|
|
76
76
|
execute: (figma, args) => {
|
|
77
77
|
const parent = args.parent_id ? figma.getNodeById(args.parent_id) : null
|
|
78
78
|
if (parent) prepareSlotInsertion(figma.graph, parent.id, 'create_slice')
|
|
79
|
-
const node = figma.
|
|
79
|
+
const node = figma.createSlice()
|
|
80
80
|
node.x = args.x
|
|
81
81
|
node.y = args.y
|
|
82
82
|
node.resize(args.width, args.height)
|
|
83
83
|
node.name = args.name ?? 'Slice'
|
|
84
|
-
node.fills = []
|
|
85
84
|
if (parent) parent.appendChild(node)
|
|
86
85
|
return nodeSummary(node)
|
|
87
86
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as v from 'valibot'
|
|
2
|
+
|
|
3
|
+
import { tokenStylesheet } from '@pairdraw/dom-css/export'
|
|
4
|
+
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
5
|
+
|
|
6
|
+
import { prepareSlotInsertion } from '#core/figma-api/slots'
|
|
7
|
+
import { bindCodeTokens, codeLayerNodes, readCodeDocument } from '#core/io/formats/code'
|
|
8
|
+
import { findPageId } from '#core/io/subgraph'
|
|
9
|
+
import { defineTool, toolFailure } from '#core/tools/schema'
|
|
10
|
+
|
|
11
|
+
import { insertionInput } from './inputs'
|
|
12
|
+
import { insertionParent, placeGraphLayers } from './place'
|
|
13
|
+
|
|
14
|
+
interface ImportCodeArgs {
|
|
15
|
+
code: string
|
|
16
|
+
css?: string
|
|
17
|
+
language?: 'auto' | 'jsx' | 'html'
|
|
18
|
+
tailwind?: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The layers a call's code draws, with the document's own tokens as its theme. */
|
|
22
|
+
async function readImportCode(graph: SceneGraph, args: ImportCodeArgs) {
|
|
23
|
+
const tailwind = args.tailwind !== false
|
|
24
|
+
const tokens = tailwind ? await tokenStylesheet(graph, { format: 'tailwind' }) : undefined
|
|
25
|
+
return readCodeDocument(args.code, {
|
|
26
|
+
css: args.css,
|
|
27
|
+
tokensCSS: tokens?.css,
|
|
28
|
+
kind: args.language === 'auto' ? undefined : args.language,
|
|
29
|
+
tailwind
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const importCode = defineTool({
|
|
34
|
+
name: 'import_code',
|
|
35
|
+
description:
|
|
36
|
+
'Import React or JSX source with Tailwind classes or inline styles, or HTML with CSS, as editable layers. Nothing in the pasted code runs: components it does not define become named frames and expressions it cannot know become placeholder text. css adds a stylesheet (a project globals.css); without x and y the layers go to the right of what the parent already holds. Returns the ids of the top-level layers and what the import could not keep.',
|
|
37
|
+
execution: { kind: 'async', mutation: 'document' },
|
|
38
|
+
content: 'imported',
|
|
39
|
+
input: v.strictObject({
|
|
40
|
+
code: v.pipe(
|
|
41
|
+
v.string(),
|
|
42
|
+
v.nonEmpty(),
|
|
43
|
+
v.description('JSX, TSX, or HTML source: a component, a fragment, or a whole document')
|
|
44
|
+
),
|
|
45
|
+
css: v.optional(
|
|
46
|
+
v.pipe(v.string(), v.description('Extra CSS applied after the code’s own styles'))
|
|
47
|
+
),
|
|
48
|
+
language: v.optional(
|
|
49
|
+
v.pipe(
|
|
50
|
+
v.picklist(['auto', 'jsx', 'html']),
|
|
51
|
+
v.description('How to read the code; auto detects it (default)')
|
|
52
|
+
)
|
|
53
|
+
),
|
|
54
|
+
tailwind: v.optional(
|
|
55
|
+
v.pipe(
|
|
56
|
+
v.boolean(),
|
|
57
|
+
v.description('Compile Tailwind classes; true unless the paste carries no Tailwind')
|
|
58
|
+
)
|
|
59
|
+
),
|
|
60
|
+
...insertionInput('X of the imported content', 'Y of the imported content')
|
|
61
|
+
}),
|
|
62
|
+
execute: async (figma, args) => {
|
|
63
|
+
const { graph, parentId } = insertionParent(figma, args.parent_id)
|
|
64
|
+
prepareSlotInsertion(graph, parentId, 'import_code')
|
|
65
|
+
const parent = graph.getNode(parentId)
|
|
66
|
+
if (!parent || (parent.type !== 'CANVAS' && !findPageId(graph, parentId))) {
|
|
67
|
+
return { error: `Parent "${parentId}" not found` }
|
|
68
|
+
}
|
|
69
|
+
let source: SceneGraph
|
|
70
|
+
let report: Awaited<ReturnType<typeof readImportCode>>['report']
|
|
71
|
+
try {
|
|
72
|
+
const read = await readImportCode(graph, args)
|
|
73
|
+
source = read.graph
|
|
74
|
+
report = read.report
|
|
75
|
+
} catch (error) {
|
|
76
|
+
return toolFailure(error)
|
|
77
|
+
}
|
|
78
|
+
const placed = placeGraphLayers(graph, parentId, source, args, (ids) => {
|
|
79
|
+
// Bound after the transfer: the layers now hold the document's own variable IDs.
|
|
80
|
+
bindCodeTokens(codeLayerNodes(graph, ids), graph, report)
|
|
81
|
+
})
|
|
82
|
+
if (!placed) return { error: 'The code draws no layers' }
|
|
83
|
+
return { ...placed, report }
|
|
84
|
+
}
|
|
85
|
+
})
|