@pairdraw/core 0.21.1 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/boolean.d.ts +6 -1
- package/dist/canvas/boolean.d.ts.map +1 -1
- package/dist/canvas/boolean.js +10 -2
- package/dist/canvas/boolean.js.map +1 -1
- package/dist/canvas/color-space.d.ts +45 -0
- package/dist/canvas/color-space.d.ts.map +1 -0
- package/dist/canvas/color-space.js +39 -0
- package/dist/canvas/color-space.js.map +1 -0
- package/dist/canvas/fills.d.ts +10 -10
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +116 -62
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/flatten.d.ts +11 -3
- package/dist/canvas/flatten.d.ts.map +1 -1
- package/dist/canvas/flatten.js +62 -4
- package/dist/canvas/flatten.js.map +1 -1
- package/dist/canvas/images/previews.d.ts +1 -1
- package/dist/canvas/index.d.ts +2 -1
- package/dist/canvas/index.js +2 -1
- package/dist/canvas/layout-grids.d.ts +5 -2
- package/dist/canvas/layout-grids.d.ts.map +1 -1
- package/dist/canvas/layout-grids.js +7 -2
- package/dist/canvas/layout-grids.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +17 -4
- package/dist/canvas/noise/render.d.ts.map +1 -1
- package/dist/canvas/noise/render.js +21 -6
- package/dist/canvas/noise/render.js.map +1 -1
- package/dist/canvas/noise/shader.d.ts +4 -4
- package/dist/canvas/noise/shader.d.ts.map +1 -1
- package/dist/canvas/noise/shader.js +5 -6
- package/dist/canvas/noise/shader.js.map +1 -1
- package/dist/canvas/overlays/annotations.d.ts +19 -0
- package/dist/canvas/overlays/annotations.d.ts.map +1 -0
- package/dist/canvas/overlays/annotations.js +110 -0
- package/dist/canvas/overlays/annotations.js.map +1 -0
- package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +25 -1
- package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
- package/dist/canvas/overlays/feedback.js +1 -1
- package/dist/canvas/overlays/feedback.js.map +1 -1
- package/dist/canvas/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/measurement.d.ts +7 -1
- package/dist/canvas/overlays/measurement.d.ts.map +1 -1
- package/dist/canvas/overlays/measurement.js +42 -4
- package/dist/canvas/overlays/measurement.js.map +1 -1
- package/dist/canvas/overlays/presence.d.ts.map +1 -1
- package/dist/canvas/overlays/presence.js +21 -24
- package/dist/canvas/overlays/presence.js.map +1 -1
- package/dist/canvas/renderer/colors.d.ts +7 -1
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +9 -1
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/document-surface.d.ts +15 -6
- package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
- package/dist/canvas/renderer/document-surface.js +1 -0
- package/dist/canvas/renderer/document-surface.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +2 -2
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +1 -0
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +4 -1
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
- package/dist/canvas/renderer/overlay-pass.js +6 -1
- package/dist/canvas/renderer/overlay-pass.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +7 -0
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/types.d.ts +10 -0
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer.d.ts +10 -2
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +15 -3
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +9 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/clipboard/pairdraw.d.ts.map +1 -1
- package/dist/clipboard/pairdraw.js +1 -0
- package/dist/clipboard/pairdraw.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +2 -0
- package/dist/editor/bridges/clipboard.d.ts.map +1 -1
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +1 -1
- package/dist/editor/bridges/components.d.ts +14 -7
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +6 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -1
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/code.d.ts +32 -0
- package/dist/editor/clipboard/code.d.ts.map +1 -0
- package/dist/editor/clipboard/code.js +30 -0
- package/dist/editor/clipboard/code.js.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
- package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/dependencies.js +0 -0
- package/dist/editor/clipboard/paste/run.d.ts +14 -0
- package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
- package/dist/editor/clipboard/paste/run.js +47 -0
- package/dist/editor/clipboard/paste/run.js.map +1 -0
- package/dist/editor/clipboard/styled.d.ts +2 -8
- package/dist/editor/clipboard/styled.d.ts.map +1 -1
- package/dist/editor/clipboard/styled.js +2 -32
- package/dist/editor/clipboard/styled.js.map +1 -1
- package/dist/editor/clipboard.d.ts +2 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +34 -0
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/components/instances.d.ts +5 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +69 -4
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/slots/index.d.ts.map +1 -1
- package/dist/editor/components/slots/index.js +7 -0
- package/dist/editor/components/slots/index.js.map +1 -1
- package/dist/editor/components.d.ts +6 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/components.js +14 -2
- package/dist/editor/components.js.map +1 -1
- package/dist/editor/create.d.ts +30 -3
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +11 -2
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-tokens.d.ts +1 -1
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +4 -18
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/image-edit.d.ts.map +1 -1
- package/dist/editor/image-edit.js +1 -2
- package/dist/editor/image-edit.js.map +1 -1
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts +3 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +97 -2
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/nodes.d.ts +2 -0
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +22 -7
- package/dist/editor/nodes.js.map +1 -1
- package/dist/editor/read-only/actions.js +6 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/selection/overlays.d.ts +1 -0
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +7 -0
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +8 -0
- package/dist/editor/selection.d.ts +9 -0
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/state/shared.js +1 -0
- package/dist/editor/state/shared.js.map +1 -1
- package/dist/editor/state/view.d.ts.map +1 -1
- package/dist/editor/state/view.js +2 -0
- package/dist/editor/state/view.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +1 -1
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js +20 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/container-wrap.d.ts +8 -2
- package/dist/editor/structure/container-wrap.d.ts.map +1 -1
- package/dist/editor/structure/container-wrap.js +17 -5
- package/dist/editor/structure/container-wrap.js.map +1 -1
- package/dist/editor/structure/flatten.d.ts.map +1 -1
- package/dist/editor/structure/flatten.js +8 -7
- package/dist/editor/structure/flatten.js.map +1 -1
- package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
- package/dist/editor/structure/group/ungroup.js +2 -0
- package/dist/editor/structure/group/ungroup.js.map +1 -1
- package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
- package/dist/editor/structure/outline-stroke.js +5 -0
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -1
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/styles.d.ts +26 -0
- package/dist/editor/styles.d.ts.map +1 -0
- package/dist/editor/styles.js +127 -0
- package/dist/editor/styles.js.map +1 -0
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +10 -2
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +6 -0
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +14 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +6 -1
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +22 -1
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/shape.js +1 -1
- package/dist/figma-api/accessors/text/index.js +1 -1
- package/dist/figma-api/accessors/text/ranges.js +1 -1
- package/dist/figma-api/accessors/text/references.js +1 -1
- package/dist/figma-api/accessors/variables.js +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +8 -22
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.js +1 -1
- package/dist/figma-api/compatibility.d.ts +1 -1
- package/dist/figma-api/compatibility.d.ts.map +1 -1
- package/dist/figma-api/component-scope.d.ts +14 -0
- package/dist/figma-api/component-scope.d.ts.map +1 -0
- package/dist/figma-api/component-scope.js +28 -0
- package/dist/figma-api/component-scope.js.map +1 -0
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +26 -2
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/flatten.js +3 -3
- package/dist/figma-api/flatten.js.map +1 -1
- package/dist/figma-api/index.d.ts +77 -6
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +188 -2
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/node-types.d.ts +2 -1
- package/dist/figma-api/node-types.d.ts.map +1 -1
- package/dist/figma-api/overrides.d.ts +26 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +157 -10
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +2 -0
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +10 -2
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +65 -9
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +144 -11
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/shape-with-text.js +1 -1
- package/dist/figma-api/slots.d.ts +3 -1
- package/dist/figma-api/slots.d.ts.map +1 -1
- package/dist/figma-api/slots.js +9 -8
- package/dist/figma-api/slots.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/io/formats/code/detect.d.ts +23 -0
- package/dist/io/formats/code/detect.d.ts.map +1 -0
- package/dist/io/formats/code/detect.js +46 -0
- package/dist/io/formats/code/detect.js.map +1 -0
- package/dist/io/formats/code/index.d.ts +5 -0
- package/dist/io/formats/code/index.js +5 -0
- package/dist/io/formats/code/read.d.ts +45 -0
- package/dist/io/formats/code/read.d.ts.map +1 -0
- package/dist/io/formats/code/read.js +86 -0
- package/dist/io/formats/code/read.js.map +1 -0
- package/dist/io/formats/code/stylesheet.d.ts +13 -0
- package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
- package/dist/io/formats/code/stylesheet.js +21 -0
- package/dist/io/formats/code/stylesheet.js.map +1 -0
- package/dist/io/formats/code/tokens.d.ts +18 -0
- package/dist/io/formats/code/tokens.d.ts.map +1 -0
- package/dist/io/formats/code/tokens.js +135 -0
- package/dist/io/formats/code/tokens.js.map +1 -0
- package/dist/io/formats/design-tokens/apply.d.ts +7 -3
- package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/apply.js.map +1 -1
- package/dist/io/formats/fig/export/patch/fields.js +5 -0
- package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +20 -20
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +5 -1
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/index.d.ts +3 -2
- package/dist/io/formats/fig/index.js +2 -2
- package/dist/io/formats/fig/read.d.ts.map +1 -1
- package/dist/io/formats/fig/read.js +5 -2
- package/dist/io/formats/fig/read.js.map +1 -1
- package/dist/io/formats/html/layers.d.ts +3 -1
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +6 -1
- package/dist/io/formats/html/layers.js.map +1 -1
- package/dist/io/formats/pdf/export.d.ts.map +1 -1
- package/dist/io/formats/pdf/export.js +7 -3
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/plan.d.ts +3 -0
- package/dist/io/formats/pdf/plan.d.ts.map +1 -1
- package/dist/io/formats/pdf/plan.js +60 -36
- package/dist/io/formats/pdf/plan.js.map +1 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +3 -2
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/index.js +2 -2
- package/dist/io/formats/raster/render.d.ts +10 -2
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +35 -9
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +19 -1
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts +5 -2
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +59 -10
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/index.d.ts +2 -2
- package/dist/io/formats/svg/index.js +2 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +4 -2
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/record.d.ts.map +1 -1
- package/dist/io/formats/video/record.js +24 -9
- package/dist/io/formats/video/record.js.map +1 -1
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +20 -13
- package/dist/io/formats.js.map +1 -1
- package/dist/kiwi/fig/population/client.d.ts.map +1 -1
- package/dist/kiwi/fig/population/client.js +2 -1
- package/dist/kiwi/fig/population/client.js.map +1 -1
- package/dist/kiwi/fig/session/document-state.d.ts +46 -2
- package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
- package/dist/kiwi/fig/session/document-state.js +113 -5
- package/dist/kiwi/fig/session/document-state.js.map +1 -1
- package/dist/kiwi/fig/session/options.d.ts +4 -0
- package/dist/kiwi/fig/session/options.d.ts.map +1 -1
- package/dist/kiwi/fig/session/options.js.map +1 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +8 -4
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.js +1 -1
- package/dist/layout/auto-layout-handles.js.map +1 -1
- package/dist/layout/axis-sizing.d.ts.map +1 -1
- package/dist/layout/axis-sizing.js +1 -1
- package/dist/layout/axis-sizing.js.map +1 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +1 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/effective-generated-text.js +1 -1
- package/dist/layout/effective-generated-text.js.map +1 -1
- package/dist/layout/grid.d.ts +3 -1
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +57 -16
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout.d.ts +1 -1
- package/dist/layout.js +6 -5
- package/dist/layout.js.map +1 -1
- package/dist/node/fs.d.ts.map +1 -1
- package/dist/node/fs.js +28 -7
- package/dist/node/fs.js.map +1 -1
- package/dist/prototype/easing.d.ts +13 -5
- package/dist/prototype/easing.d.ts.map +1 -1
- package/dist/prototype/easing.js +46 -6
- package/dist/prototype/easing.js.map +1 -1
- package/dist/prototype/scenes.d.ts +31 -0
- package/dist/prototype/scenes.d.ts.map +1 -1
- package/dist/prototype/scenes.js +220 -31
- package/dist/prototype/scenes.js.map +1 -1
- package/dist/prototype/session.d.ts.map +1 -1
- package/dist/prototype/session.js +1 -0
- package/dist/prototype/session.js.map +1 -1
- package/dist/prototype/smart-animate/animation.d.ts +2 -1
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
- package/dist/prototype/smart-animate/animation.js +2 -2
- package/dist/prototype/smart-animate/animation.js.map +1 -1
- package/dist/prototype/timeline.d.ts +10 -1
- package/dist/prototype/timeline.d.ts.map +1 -1
- package/dist/prototype/timeline.js +69 -23
- package/dist/prototype/timeline.js.map +1 -1
- package/dist/prototype/variables.d.ts +23 -0
- package/dist/prototype/variables.d.ts.map +1 -0
- package/dist/prototype/variables.js +237 -0
- package/dist/prototype/variables.js.map +1 -0
- package/dist/rpc/read-commands.d.ts +5 -0
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +4 -1
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/character-style.d.ts +8 -1
- package/dist/text/character-style.d.ts.map +1 -1
- package/dist/text/character-style.js +39 -1
- package/dist/text/character-style.js.map +1 -1
- package/dist/text/font/batch.d.ts +26 -0
- package/dist/text/font/batch.d.ts.map +1 -0
- package/dist/text/font/batch.js +31 -0
- package/dist/text/font/batch.js.map +1 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +14 -1
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/index.d.ts +3 -2
- package/dist/text/index.js +3 -2
- package/dist/tools/create/basic.js +3 -4
- package/dist/tools/create/basic.js.map +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/code.d.ts +6 -0
- package/dist/tools/create/code.d.ts.map +1 -0
- package/dist/tools/create/code.js +68 -0
- package/dist/tools/create/code.js.map +1 -0
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +9 -57
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.js +1 -1
- package/dist/tools/create/inputs.d.ts +11 -0
- package/dist/tools/create/inputs.d.ts.map +1 -0
- package/dist/tools/create/inputs.js +15 -0
- package/dist/tools/create/inputs.js.map +1 -0
- package/dist/tools/create/mermaid.d.ts.map +1 -1
- package/dist/tools/create/mermaid.js +5 -6
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/place.d.ts +30 -0
- package/dist/tools/create/place.d.ts.map +1 -0
- package/dist/tools/create/place.js +70 -0
- package/dist/tools/create/place.js.map +1 -0
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/create.d.ts +2 -1
- package/dist/tools/create.js +2 -1
- package/dist/tools/css/gradient.d.ts +28 -0
- package/dist/tools/css/gradient.d.ts.map +1 -0
- package/dist/tools/css/gradient.js +118 -0
- package/dist/tools/css/gradient.js.map +1 -0
- package/dist/tools/image-ai/generate.js +1 -1
- package/dist/tools/modify/geometry.js +5 -5
- package/dist/tools/modify/geometry.js.map +1 -1
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +7 -1
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/matching.js +1 -1
- package/dist/tools/modify/overrides.d.ts +6 -0
- package/dist/tools/modify/overrides.d.ts.map +1 -0
- package/dist/tools/modify/overrides.js +27 -0
- package/dist/tools/modify/overrides.js.map +1 -0
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +84 -39
- package/dist/tools/modify/paint.js.map +1 -1
- package/dist/tools/modify/text.d.ts +2 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +79 -8
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +18 -2
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +3 -2
- package/dist/tools/modify.js +3 -2
- package/dist/tools/read/css.d.ts.map +1 -1
- package/dist/tools/read/css.js +29 -12
- package/dist/tools/read/css.js.map +1 -1
- package/dist/tools/read/libraries.js +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js +19 -5
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +6 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/text-range.d.ts +11 -0
- package/dist/tools/text-range.d.ts.map +1 -0
- package/dist/tools/text-range.js +26 -0
- package/dist/tools/text-range.js.map +1 -0
- package/dist/tools/variables/bindings.js +1 -1
- package/dist/tools/variables/bindings.js.map +1 -1
- package/dist/tools/variables/unbind.js +1 -1
- package/dist/tools/variables/unbind.js.map +1 -1
- package/dist/tools/vector/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +7 -21
- package/dist/tools/vector/path.js.map +1 -1
- package/dist/vector/rebase.d.ts +17 -0
- package/dist/vector/rebase.d.ts.map +1 -0
- package/dist/vector/rebase.js +32 -0
- package/dist/vector/rebase.js.map +1 -0
- package/package.json +14 -9
- package/src/canvas/boolean.ts +12 -1
- package/src/canvas/color-space.ts +73 -0
- package/src/canvas/fills.ts +130 -83
- package/src/canvas/flatten.ts +92 -7
- package/src/canvas/index.ts +9 -0
- package/src/canvas/layout-grids.ts +15 -2
- package/src/canvas/noise/render.ts +35 -7
- package/src/canvas/noise/shader.ts +8 -10
- package/src/canvas/overlays/annotations.ts +117 -0
- package/src/canvas/overlays/auto-layout-hover.ts +41 -1
- package/src/canvas/overlays/feedback.ts +7 -2
- package/src/canvas/overlays/index.ts +1 -1
- package/src/canvas/overlays/measurement.ts +49 -3
- package/src/canvas/overlays/presence.ts +35 -32
- package/src/canvas/renderer/colors.ts +14 -0
- package/src/canvas/renderer/document-surface.ts +16 -6
- package/src/canvas/renderer/lifecycle.ts +2 -2
- package/src/canvas/renderer/methods.ts +4 -0
- package/src/canvas/renderer/overlay-pass.ts +4 -0
- package/src/canvas/renderer/pipeline.ts +8 -0
- package/src/canvas/renderer/types.ts +8 -0
- package/src/canvas/renderer.ts +21 -2
- package/src/canvas/scene.ts +15 -7
- package/src/clipboard/pairdraw.ts +1 -0
- package/src/editor/bridges/clipboard.ts +1 -0
- package/src/editor/bridges/components.ts +10 -0
- package/src/editor/clipboard/code.ts +50 -0
- package/src/editor/clipboard/paste/dependencies.ts +18 -0
- package/src/editor/clipboard/paste/run.ts +64 -0
- package/src/editor/clipboard/styled.ts +4 -52
- package/src/editor/clipboard.ts +40 -0
- package/src/editor/components/instances.ts +92 -4
- package/src/editor/components/slots/index.ts +7 -0
- package/src/editor/components.ts +16 -2
- package/src/editor/create.ts +15 -1
- package/src/editor/design-tokens.ts +3 -23
- package/src/editor/image-edit.ts +5 -2
- package/src/editor/index.ts +1 -0
- package/src/editor/layout-mode.ts +131 -3
- package/src/editor/nodes.ts +30 -5
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/selection/overlays.ts +8 -0
- package/src/editor/state/shared.ts +1 -0
- package/src/editor/state/view.ts +2 -0
- package/src/editor/structure/boolean.ts +29 -1
- package/src/editor/structure/container-wrap.ts +20 -4
- package/src/editor/structure/flatten.ts +15 -8
- package/src/editor/structure/group/ungroup.ts +2 -0
- package/src/editor/structure/outline-stroke.ts +5 -0
- package/src/editor/styles.ts +203 -0
- package/src/editor/text/selection-style.ts +18 -1
- package/src/editor/tool-registry.ts +2 -0
- package/src/editor/types.ts +14 -0
- package/src/editor/variable-bindings.ts +11 -0
- package/src/figma-api/accessors/basic.ts +33 -1
- package/src/figma-api/accessors/vector.ts +6 -13
- package/src/figma-api/compatibility.ts +1 -0
- package/src/figma-api/component-scope.ts +36 -0
- package/src/figma-api/components.ts +24 -0
- package/src/figma-api/flatten.ts +7 -3
- package/src/figma-api/index.ts +302 -6
- package/src/figma-api/node-types.ts +1 -0
- package/src/figma-api/overrides.ts +192 -5
- package/src/figma-api/proxy.ts +16 -1
- package/src/figma-api/reactions.ts +163 -12
- package/src/figma-api/slots.ts +10 -9
- package/src/io/formats/code/detect.ts +67 -0
- package/src/io/formats/code/index.ts +17 -0
- package/src/io/formats/code/read.ts +143 -0
- package/src/io/formats/code/stylesheet.ts +24 -0
- package/src/io/formats/code/tokens.ts +159 -0
- package/src/io/formats/design-tokens/apply.ts +3 -2
- package/src/io/formats/fig/export/patch/fields.ts +11 -0
- package/src/io/formats/fig/export/patch/index.ts +23 -19
- package/src/io/formats/fig/export/setup.ts +8 -1
- package/src/io/formats/fig/index.ts +6 -0
- package/src/io/formats/fig/read.ts +11 -2
- package/src/io/formats/html/layers.ts +7 -0
- package/src/io/formats/pdf/export.ts +19 -7
- package/src/io/formats/pdf/plan.ts +71 -32
- package/src/io/formats/raster/headless.ts +3 -1
- package/src/io/formats/raster/index.ts +2 -0
- package/src/io/formats/raster/render.ts +49 -9
- package/src/io/formats/svg/defs.ts +27 -1
- package/src/io/formats/svg/export.ts +75 -13
- package/src/io/formats/svg/index.ts +1 -0
- package/src/io/formats/svg/text/layout.ts +5 -3
- package/src/io/formats/video/record.ts +33 -9
- package/src/io/formats.ts +35 -15
- package/src/kiwi/fig/population/client.ts +6 -1
- package/src/kiwi/fig/session/document-state.ts +195 -5
- package/src/kiwi/fig/session/options.ts +2 -0
- package/src/layout/apply.ts +12 -4
- package/src/layout/auto-layout-handles.ts +1 -1
- package/src/layout/axis-sizing.ts +3 -1
- package/src/layout/derived.ts +3 -1
- package/src/layout/effective-generated-text.ts +1 -1
- package/src/layout/grid.ts +91 -21
- package/src/layout.ts +16 -3
- package/src/node/fs.ts +32 -7
- package/src/prototype/easing.ts +79 -7
- package/src/prototype/scenes.ts +244 -15
- package/src/prototype/session.ts +1 -0
- package/src/prototype/smart-animate/animation.ts +4 -3
- package/src/prototype/timeline.ts +118 -26
- package/src/prototype/variables.ts +189 -0
- package/src/rpc/read-commands.ts +19 -1
- package/src/text/character-style.ts +47 -0
- package/src/text/font/batch.ts +58 -0
- package/src/text/font/manager.ts +17 -1
- package/src/text/index.ts +2 -1
- package/src/tools/create/basic.ts +2 -3
- package/src/tools/create/code.ts +85 -0
- package/src/tools/create/html.ts +9 -46
- package/src/tools/create/inputs.ts +12 -0
- package/src/tools/create/mermaid.ts +6 -6
- package/src/tools/create/place.ts +80 -0
- package/src/tools/create.ts +1 -0
- package/src/tools/css/gradient.ts +147 -0
- package/src/tools/modify/geometry.ts +5 -5
- package/src/tools/modify/layout.ts +19 -0
- package/src/tools/modify/overrides.ts +35 -0
- package/src/tools/modify/paint.ts +124 -54
- package/src/tools/modify/text.ts +91 -7
- package/src/tools/modify/update.ts +23 -2
- package/src/tools/modify.ts +9 -1
- package/src/tools/read/css.ts +46 -12
- package/src/tools/read/nodes.ts +26 -4
- package/src/tools/registry/extended.ts +6 -0
- package/src/tools/text-range.ts +29 -0
- package/src/tools/variables/bindings.ts +4 -1
- package/src/tools/variables/unbind.ts +4 -1
- package/src/tools/vector/path.ts +11 -13
- package/src/vector/rebase.ts +33 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
2
|
+
import type { VisualBounds } from '@pairdraw/scene-graph/geometry'
|
|
3
|
+
|
|
4
|
+
import { computeContentBounds, sliceRegion } from '#core/io/formats/raster/render'
|
|
2
5
|
|
|
3
6
|
export const PDF_MODES = ['single', 'frames', 'pages'] as const
|
|
4
7
|
export type PDFMode = (typeof PDF_MODES)[number]
|
|
@@ -12,6 +15,8 @@ export interface PDFPageSpec {
|
|
|
12
15
|
nodeIds: string[]
|
|
13
16
|
/** Name of the frame or design page the PDF page comes from. */
|
|
14
17
|
label?: string
|
|
18
|
+
/** A slice's box: the page content under it, clipped, is the page. */
|
|
19
|
+
clip?: VisualBounds
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export interface PDFPlanInput {
|
|
@@ -34,10 +39,70 @@ function pageIdOfNode(graph: SceneGraph, nodeId: string): string | null {
|
|
|
34
39
|
return graph.closest(nodeId, (node) => node.type === 'CANVAS')?.id ?? null
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
function visibleChildren(graph: SceneGraph, pageId: string): string[] {
|
|
42
|
+
function visibleChildren(graph: SceneGraph, pageId: string, includeSlices = true): string[] {
|
|
38
43
|
const page = graph.getNode(pageId)
|
|
39
44
|
if (!page) return []
|
|
40
|
-
return page.childIds.filter((id) =>
|
|
45
|
+
return page.childIds.filter((id) => {
|
|
46
|
+
const node = graph.getNode(id)
|
|
47
|
+
if (!node?.visible) return false
|
|
48
|
+
return includeSlices || node.type !== 'SLICE'
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function slicePageSpec(
|
|
53
|
+
graph: SceneGraph,
|
|
54
|
+
pageId: string,
|
|
55
|
+
sliceId: string,
|
|
56
|
+
clip?: VisualBounds
|
|
57
|
+
): PDFPageSpec {
|
|
58
|
+
const slice = graph.getNode(sliceId)
|
|
59
|
+
const page = graph.getNode(pageId)
|
|
60
|
+
return {
|
|
61
|
+
pageId,
|
|
62
|
+
nodeIds: page?.childIds ?? [],
|
|
63
|
+
clip: clip ?? computeContentBounds(graph, [sliceId]) ?? undefined,
|
|
64
|
+
label: slice?.name
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function planSinglePDFPage(graph: SceneGraph, input: PDFPlanInput): PDFPageSpec {
|
|
69
|
+
const ids = input.ids?.length
|
|
70
|
+
? [...input.ids]
|
|
71
|
+
: visibleChildren(graph, input.currentPageId, false)
|
|
72
|
+
const sliceBox = ids.length === 1 ? sliceRegion(graph, ids) : null
|
|
73
|
+
if (sliceBox && ids[0]) {
|
|
74
|
+
const pageId = pageIdOfNode(graph, ids[0]) ?? input.currentPageId
|
|
75
|
+
return slicePageSpec(graph, pageId, ids[0], sliceBox)
|
|
76
|
+
}
|
|
77
|
+
return { pageId: input.currentPageId, nodeIds: ids }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function planFramePDFPages(graph: SceneGraph, input: PDFPlanInput): PDFPageSpec[] {
|
|
81
|
+
const ids = input.ids?.length ? [...input.ids] : visibleChildren(graph, input.currentPageId)
|
|
82
|
+
return ids.map((id) => {
|
|
83
|
+
const node = graph.getNode(id)
|
|
84
|
+
if (!node) throw new PDFPlanError(`Node "${id}" not found`)
|
|
85
|
+
const pageId = pageIdOfNode(graph, id) ?? input.currentPageId
|
|
86
|
+
if (node.type === 'SLICE') return slicePageSpec(graph, pageId, id)
|
|
87
|
+
return { pageId, nodeIds: [id], label: node.name }
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function planDocumentPDFPages(graph: SceneGraph, input: PDFPlanInput): PDFPageSpec[] {
|
|
92
|
+
const designPages = graph.getPages()
|
|
93
|
+
const selected = input.pageIds?.length
|
|
94
|
+
? input.pageIds.map((id) => {
|
|
95
|
+
const page = designPages.find((candidate) => candidate.id === id)
|
|
96
|
+
if (!page) throw new PDFPlanError(`Page "${id}" not found`)
|
|
97
|
+
return page
|
|
98
|
+
})
|
|
99
|
+
: designPages
|
|
100
|
+
const specs: PDFPageSpec[] = []
|
|
101
|
+
for (const page of selected) {
|
|
102
|
+
const ids = visibleChildren(graph, page.id, false)
|
|
103
|
+
if (ids.length > 0) specs.push({ pageId: page.id, nodeIds: ids, label: page.name })
|
|
104
|
+
}
|
|
105
|
+
return specs
|
|
41
106
|
}
|
|
42
107
|
|
|
43
108
|
/**
|
|
@@ -45,36 +110,10 @@ function visibleChildren(graph: SceneGraph, pageId: string): string[] {
|
|
|
45
110
|
* nor a DOM. Throws PDFPlanError when the request names something missing or exports nothing.
|
|
46
111
|
*/
|
|
47
112
|
export function planPDFPages(graph: SceneGraph, input: PDFPlanInput): PDFPageSpec[] {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (input.mode === '
|
|
51
|
-
|
|
52
|
-
specs.push({ pageId: input.currentPageId, nodeIds: ids })
|
|
53
|
-
} else if (input.mode === 'frames') {
|
|
54
|
-
const ids = input.ids?.length ? [...input.ids] : visibleChildren(graph, input.currentPageId)
|
|
55
|
-
for (const id of ids) {
|
|
56
|
-
const node = graph.getNode(id)
|
|
57
|
-
if (!node) throw new PDFPlanError(`Node "${id}" not found`)
|
|
58
|
-
specs.push({
|
|
59
|
-
pageId: pageIdOfNode(graph, id) ?? input.currentPageId,
|
|
60
|
-
nodeIds: [id],
|
|
61
|
-
label: node.name
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
const designPages = graph.getPages()
|
|
66
|
-
const selected = input.pageIds?.length
|
|
67
|
-
? input.pageIds.map((id) => {
|
|
68
|
-
const page = designPages.find((candidate) => candidate.id === id)
|
|
69
|
-
if (!page) throw new PDFPlanError(`Page "${id}" not found`)
|
|
70
|
-
return page
|
|
71
|
-
})
|
|
72
|
-
: designPages
|
|
73
|
-
for (const page of selected) {
|
|
74
|
-
const ids = visibleChildren(graph, page.id)
|
|
75
|
-
if (ids.length > 0) specs.push({ pageId: page.id, nodeIds: ids, label: page.name })
|
|
76
|
-
}
|
|
77
|
-
}
|
|
113
|
+
let specs: PDFPageSpec[]
|
|
114
|
+
if (input.mode === 'single') specs = [planSinglePDFPage(graph, input)]
|
|
115
|
+
else if (input.mode === 'frames') specs = planFramePDFPages(graph, input)
|
|
116
|
+
else specs = planDocumentPDFPages(graph, input)
|
|
78
117
|
|
|
79
118
|
if (specs.every((spec) => spec.nodeIds.length === 0)) {
|
|
80
119
|
throw new PDFPlanError('No visible nodes to export')
|
|
@@ -7,6 +7,7 @@ import { SkiaRenderer } from '#core/canvas'
|
|
|
7
7
|
import {
|
|
8
8
|
renderNodesToImage,
|
|
9
9
|
renderThumbnail,
|
|
10
|
+
sliceRegion,
|
|
10
11
|
type ExportFormat,
|
|
11
12
|
type RasterExportFormat
|
|
12
13
|
} from './render'
|
|
@@ -69,7 +70,8 @@ export async function headlessRenderNodes(
|
|
|
69
70
|
): Promise<Uint8Array<ArrayBuffer> | null> {
|
|
70
71
|
const { ck, renderer } = await headlessRenderer(canvasKit)
|
|
71
72
|
renderer.invalidateAllPictures()
|
|
72
|
-
|
|
73
|
+
const prepareIds = sliceRegion(graph, nodeIds) ? (graph.getNode(pageId)?.childIds ?? []) : nodeIds
|
|
74
|
+
await renderer.prepareForExport(graph, pageId, prepareIds)
|
|
73
75
|
return renderNodesToImage(ck, renderer, graph, pageId, nodeIds, {
|
|
74
76
|
scale: options.scale ?? 1,
|
|
75
77
|
format: options.format ?? 'PNG',
|
|
@@ -358,6 +358,15 @@ export function renderNodesToImage(
|
|
|
358
358
|
throw new Error('Raster export selection must stay on a single page')
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
+
const region = sliceRegion(graph, nodeIds)
|
|
362
|
+
if (region) {
|
|
363
|
+
return drawRegionToImage(ck, renderer, graph, pageId, region, options.scale, {
|
|
364
|
+
format: options.format,
|
|
365
|
+
quality: options.quality,
|
|
366
|
+
background: options.format === 'JPG' ? 'white' : 'transparent'
|
|
367
|
+
})
|
|
368
|
+
}
|
|
369
|
+
|
|
361
370
|
const bounds = computeContentBounds(graph, nodeIds)
|
|
362
371
|
if (!bounds) return null
|
|
363
372
|
|
|
@@ -412,9 +421,11 @@ export function thumbnailFrame(
|
|
|
412
421
|
height: number
|
|
413
422
|
): ThumbnailFrame | null {
|
|
414
423
|
const page = graph.getNode(pageId)
|
|
415
|
-
if (!page
|
|
424
|
+
if (!page) return null
|
|
425
|
+
const contentIds = page.childIds.filter((id) => graph.getNode(id)?.type !== 'SLICE')
|
|
426
|
+
if (contentIds.length === 0) return null
|
|
416
427
|
|
|
417
|
-
const bounds = computeContentBounds(graph,
|
|
428
|
+
const bounds = computeContentBounds(graph, contentIds)
|
|
418
429
|
if (!bounds) return null
|
|
419
430
|
|
|
420
431
|
const contentW = bounds.maxX - bounds.minX
|
|
@@ -456,6 +467,21 @@ export function renderThumbnail(
|
|
|
456
467
|
})
|
|
457
468
|
}
|
|
458
469
|
|
|
470
|
+
export interface RegionImageOptions {
|
|
471
|
+
format?: ExportFormat
|
|
472
|
+
quality?: number
|
|
473
|
+
/** Page colour for canvas snapshots (`'page'`), or `'white'` / `'transparent'` for layer exports. */
|
|
474
|
+
background?: 'page' | 'white' | 'transparent'
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** If `nodeIds` names one slice, returns that slice's page-space bounds; otherwise `null`. */
|
|
478
|
+
export function sliceRegion(graph: SceneGraph, nodeIds: string[]): VisualBounds | null {
|
|
479
|
+
if (nodeIds.length !== 1) return null
|
|
480
|
+
const node = graph.getNode(nodeIds[0] ?? '')
|
|
481
|
+
if (node?.type !== 'SLICE') return null
|
|
482
|
+
return computeContentBounds(graph, [node.id])
|
|
483
|
+
}
|
|
484
|
+
|
|
459
485
|
/** Draws a page region with `renderer`; `region.ts` gives it a renderer of its own. */
|
|
460
486
|
export function drawRegionToImage(
|
|
461
487
|
ck: CanvasKit,
|
|
@@ -463,15 +489,29 @@ export function drawRegionToImage(
|
|
|
463
489
|
graph: SceneGraph,
|
|
464
490
|
pageId: string,
|
|
465
491
|
bounds: VisualBounds,
|
|
466
|
-
scale: number
|
|
492
|
+
scale: number,
|
|
493
|
+
options: RegionImageOptions = {}
|
|
467
494
|
): Uint8Array<ArrayBuffer> | null {
|
|
468
|
-
const
|
|
469
|
-
const
|
|
495
|
+
const contentW = bounds.maxX - bounds.minX
|
|
496
|
+
const contentH = bounds.maxY - bounds.minY
|
|
497
|
+
if (contentW <= 0 || contentH <= 0) return null
|
|
498
|
+
const pixelW = Math.max(1, Math.round(contentW * scale))
|
|
499
|
+
const pixelH = Math.max(1, Math.round(contentH * scale))
|
|
470
500
|
if (!graph.getNode(pageId) || !Number.isFinite(pixelW * pixelH)) return null
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
501
|
+
assertExportSize(pixelW, pixelH)
|
|
502
|
+
const format = options.format ?? 'PNG'
|
|
503
|
+
const quality = options.quality ?? (format === 'PNG' ? 100 : 90)
|
|
504
|
+
const background = options.background ?? 'page'
|
|
505
|
+
return renderToSurface(ck, renderer, graph, pageId, pixelW, pixelH, format, quality, (canvas) => {
|
|
506
|
+
if (background === 'transparent') {
|
|
507
|
+
canvas.clear(ck.TRANSPARENT)
|
|
508
|
+
} else if (background === 'white') {
|
|
509
|
+
canvas.clear(ck.WHITE)
|
|
510
|
+
} else {
|
|
511
|
+
// `renderToSurface` has just set the renderer's profile, so the page color converts in it.
|
|
512
|
+
const pageBackground = renderer.renderColor(renderer.pageColor)
|
|
513
|
+
canvas.clear(ck.Color4f(pageBackground.r, pageBackground.g, pageBackground.b, 1))
|
|
514
|
+
}
|
|
475
515
|
canvas.scale(scale, scale)
|
|
476
516
|
canvas.translate(-bounds.minX, -bounds.minY)
|
|
477
517
|
})
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
invertGradientTransform,
|
|
20
20
|
isIdentityGradientTransform
|
|
21
21
|
} from '@pairdraw/scene-graph/gradient'
|
|
22
|
-
import { imageMimeType } from '@pairdraw/scene-graph/images'
|
|
22
|
+
import { imageMimeType, makeImageFillLocalMatrix } from '@pairdraw/scene-graph/images'
|
|
23
23
|
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
24
24
|
|
|
25
25
|
import type { BooleanPathResolver } from '#core/io/formats/boolean-path'
|
|
@@ -204,6 +204,32 @@ function createImagePattern(
|
|
|
204
204
|
const base64 = fromUint8Array(data)
|
|
205
205
|
const mime = imageMimeType(data)
|
|
206
206
|
|
|
207
|
+
if (fill.imageScaleMode === 'CROP') {
|
|
208
|
+
// A crop places the image by its transform alone, in layer coordinates; `rotation` is
|
|
209
|
+
// automatic for a crop, as it is on the canvas. The pattern tile is the layer, and the unit
|
|
210
|
+
// image inside it is laid out by the same matrix the canvas draws with.
|
|
211
|
+
const matrix = makeImageFillLocalMatrix(fill, node, 1, 1)
|
|
212
|
+
return {
|
|
213
|
+
id,
|
|
214
|
+
node: svg(
|
|
215
|
+
'pattern',
|
|
216
|
+
{
|
|
217
|
+
id,
|
|
218
|
+
patternUnits: 'userSpaceOnUse',
|
|
219
|
+
width: node.width,
|
|
220
|
+
height: node.height
|
|
221
|
+
},
|
|
222
|
+
svg('image', {
|
|
223
|
+
href: `data:${mime};base64,${base64}`,
|
|
224
|
+
width: 1,
|
|
225
|
+
height: 1,
|
|
226
|
+
preserveAspectRatio: 'none',
|
|
227
|
+
transform: `matrix(${round(matrix[0])} ${round(matrix[3])} ${round(matrix[1])} ${round(matrix[4])} ${round(matrix[2])} ${round(matrix[5])})`
|
|
228
|
+
})
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
207
233
|
return {
|
|
208
234
|
id,
|
|
209
235
|
node: svg(
|
|
@@ -7,11 +7,12 @@ import type {
|
|
|
7
7
|
VectorNetwork
|
|
8
8
|
} from '@pairdraw/scene-graph'
|
|
9
9
|
import type { RenderColorSpace } from '@pairdraw/scene-graph/color'
|
|
10
|
+
import type { VisualBounds } from '@pairdraw/scene-graph/geometry'
|
|
10
11
|
|
|
11
12
|
import { normalizeDashPattern } from '#core/canvas/strokes'
|
|
12
13
|
import { lineStrokePath } from '#core/canvas/strokes/line'
|
|
13
14
|
import { fittedDashPattern } from '#core/canvas/strokes/sides'
|
|
14
|
-
import { computeContentBounds } from '#core/io/formats/raster'
|
|
15
|
+
import { computeContentBounds, sliceRegion } from '#core/io/formats/raster'
|
|
15
16
|
|
|
16
17
|
import {
|
|
17
18
|
nextDefId,
|
|
@@ -698,7 +699,7 @@ function renderBooleanNode(
|
|
|
698
699
|
}
|
|
699
700
|
|
|
700
701
|
function renderNode(node: SceneNode, ctx: SVGExportContext): SVGNode | null {
|
|
701
|
-
if (!node.visible) return null
|
|
702
|
+
if (!node.visible || node.type === 'SLICE') return null
|
|
702
703
|
|
|
703
704
|
const { attrs: groupAttrs, clipId } = buildGroupAttrs(node, ctx)
|
|
704
705
|
|
|
@@ -797,12 +798,82 @@ export interface SVGExportOptions {
|
|
|
797
798
|
booleanPath?: BooleanPathResolver
|
|
798
799
|
}
|
|
799
800
|
|
|
801
|
+
function svgExportContext(graph: SceneGraph, options: SVGExportOptions): SVGExportContext {
|
|
802
|
+
return {
|
|
803
|
+
defs: [],
|
|
804
|
+
defIdCounter: 0,
|
|
805
|
+
graph,
|
|
806
|
+
colorSpace: options.colorSpace ?? 'srgb',
|
|
807
|
+
documentColorSpace: options.documentColorSpace ?? graph.documentColorSpace,
|
|
808
|
+
textLayout: options.textLayout,
|
|
809
|
+
fontAlias: options.fontAlias,
|
|
810
|
+
booleanPath: options.booleanPath
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/** The slice's box, and the page content under it, clipped: a slice has no vector geometry of its own. */
|
|
815
|
+
export function renderRegionSVG(
|
|
816
|
+
graph: SceneGraph,
|
|
817
|
+
pageId: string,
|
|
818
|
+
bounds: VisualBounds,
|
|
819
|
+
options: SVGExportOptions = {}
|
|
820
|
+
): string | null {
|
|
821
|
+
const page = graph.getNode(pageId)
|
|
822
|
+
if (!page) return null
|
|
823
|
+
const { minX, minY, maxX, maxY } = bounds
|
|
824
|
+
const width = round(maxX - minX)
|
|
825
|
+
const height = round(maxY - minY)
|
|
826
|
+
if (width <= 0 || height <= 0) return null
|
|
827
|
+
const ctx = svgExportContext(graph, options)
|
|
828
|
+
const contentNodes: SVGNode[] = []
|
|
829
|
+
for (const id of page.childIds) {
|
|
830
|
+
const node = graph.getNode(id)
|
|
831
|
+
if (!node?.visible || node.type === 'SLICE') continue
|
|
832
|
+
const abs = graph.getAbsolutePosition(id)
|
|
833
|
+
const offsetX = abs.x - minX
|
|
834
|
+
const offsetY = abs.y - minY
|
|
835
|
+
const rendered = renderNode(
|
|
836
|
+
offsetX !== node.x || offsetY !== node.y
|
|
837
|
+
? { ...node, x: round(offsetX), y: round(offsetY) }
|
|
838
|
+
: node,
|
|
839
|
+
ctx
|
|
840
|
+
)
|
|
841
|
+
if (rendered) contentNodes.push(rendered)
|
|
842
|
+
}
|
|
843
|
+
if (contentNodes.length === 0) return null
|
|
844
|
+
const clipId = nextDefId(ctx, 'slice')
|
|
845
|
+
ctx.defs.push(
|
|
846
|
+
svg(
|
|
847
|
+
'clipPath',
|
|
848
|
+
{ id: clipId, clipPathUnits: 'userSpaceOnUse' },
|
|
849
|
+
svg('rect', { x: 0, y: 0, width, height })
|
|
850
|
+
)
|
|
851
|
+
)
|
|
852
|
+
const root = svg(
|
|
853
|
+
'svg',
|
|
854
|
+
{
|
|
855
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
856
|
+
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
|
|
857
|
+
width,
|
|
858
|
+
height,
|
|
859
|
+
viewBox: `0 0 ${width} ${height}`
|
|
860
|
+
},
|
|
861
|
+
svg('defs', {}, ...ctx.defs),
|
|
862
|
+
svg('g', { 'clip-path': `url(#${clipId})` }, ...contentNodes)
|
|
863
|
+
)
|
|
864
|
+
const svgStr = renderSVGNode(root)
|
|
865
|
+
const xmlDecl = options.xmlDeclaration !== false ? '<?xml version="1.0" encoding="UTF-8"?>\n' : ''
|
|
866
|
+
return xmlDecl + svgStr
|
|
867
|
+
}
|
|
868
|
+
|
|
800
869
|
export function renderNodesToSVG(
|
|
801
870
|
graph: SceneGraph,
|
|
802
|
-
|
|
871
|
+
pageId: string,
|
|
803
872
|
nodeIds: string[],
|
|
804
873
|
options: SVGExportOptions = {}
|
|
805
874
|
): string | null {
|
|
875
|
+
const box = sliceRegion(graph, nodeIds)
|
|
876
|
+
if (box) return renderRegionSVG(graph, pageId, box, options)
|
|
806
877
|
const bounds = computeContentBounds(graph, nodeIds)
|
|
807
878
|
if (!bounds) return null
|
|
808
879
|
|
|
@@ -810,16 +881,7 @@ export function renderNodesToSVG(
|
|
|
810
881
|
const width = round(maxX - minX)
|
|
811
882
|
const height = round(maxY - minY)
|
|
812
883
|
|
|
813
|
-
const ctx
|
|
814
|
-
defs: [],
|
|
815
|
-
defIdCounter: 0,
|
|
816
|
-
graph,
|
|
817
|
-
colorSpace: options.colorSpace ?? 'srgb',
|
|
818
|
-
documentColorSpace: options.documentColorSpace ?? graph.documentColorSpace,
|
|
819
|
-
textLayout: options.textLayout,
|
|
820
|
-
fontAlias: options.fontAlias,
|
|
821
|
-
booleanPath: options.booleanPath
|
|
822
|
-
}
|
|
884
|
+
const ctx = svgExportContext(graph, options)
|
|
823
885
|
|
|
824
886
|
const contentNodes: SVGNode[] = []
|
|
825
887
|
|
|
@@ -4,6 +4,7 @@ import type { SceneGraph } from '@pairdraw/scene-graph'
|
|
|
4
4
|
|
|
5
5
|
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
6
6
|
import { withPDFTextLayout } from '#core/io/formats/pdf/prepare'
|
|
7
|
+
import { sliceRegion } from '#core/io/formats/raster'
|
|
7
8
|
import { bakeAdjustedImages, hasAdjustedImagePaints } from '#core/io/formats/raster/adjusted-images'
|
|
8
9
|
import { renderNodesToSVG, type SVGExportOptions } from '#core/io/formats/svg/export'
|
|
9
10
|
import { resolveFontReadiness } from '#core/text/prepare'
|
|
@@ -22,9 +23,10 @@ export async function renderNodesToLaidOutSVG(
|
|
|
22
23
|
canvasKit?: CanvasKit,
|
|
23
24
|
renderer?: SkiaRenderer
|
|
24
25
|
): Promise<string | null> {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const prepareIds = sliceRegion(graph, nodeIds) ? (graph.getNode(pageId)?.childIds ?? []) : nodeIds
|
|
27
|
+
await resolveFontReadiness(graph, prepareIds)
|
|
28
|
+
const baked = hasAdjustedImagePaints(graph, prepareIds)
|
|
29
|
+
? await bakeAdjustedImages(graph, prepareIds, canvasKit, renderer)
|
|
28
30
|
: graph
|
|
29
31
|
return withPDFTextLayout(async (textLayout) =>
|
|
30
32
|
renderNodesToSVG(baked, pageId, nodeIds, { textLayout, ...options })
|
|
@@ -90,6 +90,18 @@ function createScreens(
|
|
|
90
90
|
const startId = firstSegment?.kind === 'hold' ? firstSegment.session.frameId : null
|
|
91
91
|
const background = getPageColor(startId ? pageOf(graph, startId) : undefined)
|
|
92
92
|
const cache = new Map<string, RGBAImage>()
|
|
93
|
+
// A graph is one moment of play's variable state; screens showing another state are drawn again.
|
|
94
|
+
const graphTokens = new WeakMap<SceneGraph, number>()
|
|
95
|
+
let nextGraphToken = 1
|
|
96
|
+
function graphToken(source: SceneGraph | undefined): string {
|
|
97
|
+
if (!source) return '0'
|
|
98
|
+
let token = graphTokens.get(source)
|
|
99
|
+
if (token === undefined) {
|
|
100
|
+
token = nextGraphToken++
|
|
101
|
+
graphTokens.set(source, token)
|
|
102
|
+
}
|
|
103
|
+
return String(token)
|
|
104
|
+
}
|
|
93
105
|
|
|
94
106
|
async function drawFrame(
|
|
95
107
|
target: RGBAImage,
|
|
@@ -138,7 +150,7 @@ function createScreens(
|
|
|
138
150
|
overlay.height * scale,
|
|
139
151
|
timeline.overlayPositions[overlayId] ?? 'CENTER'
|
|
140
152
|
)
|
|
141
|
-
await drawFrame(target, overlayId, scale, origin)
|
|
153
|
+
await drawFrame(target, overlayId, scale, origin, base)
|
|
142
154
|
}
|
|
143
155
|
return target
|
|
144
156
|
}
|
|
@@ -149,16 +161,23 @@ function createScreens(
|
|
|
149
161
|
/** A Smart animate `progress` of the way through its time, drawn from its posed copy. */
|
|
150
162
|
async function animated(segment: TimelineSmartSegment, progress: number): Promise<RGBAImage> {
|
|
151
163
|
if (animating?.segment !== segment) {
|
|
152
|
-
const from = { graph, rootId: shownFrame(segment.from) }
|
|
153
|
-
const to = { graph, rootId: segment.to.frameId }
|
|
154
|
-
animating = {
|
|
164
|
+
const from = { graph: segment.fromGraph ?? graph, rootId: shownFrame(segment.from) }
|
|
165
|
+
const to = { graph: segment.toGraph ?? graph, rootId: segment.to.frameId }
|
|
166
|
+
animating = {
|
|
167
|
+
segment,
|
|
168
|
+
animation: createSmartAnimation(from, to, segment.easing, {
|
|
169
|
+
curve: segment.easingCurve,
|
|
170
|
+
spring: segment.easingSpring,
|
|
171
|
+
duration: segment.fadeMs / 1000
|
|
172
|
+
})
|
|
173
|
+
}
|
|
155
174
|
}
|
|
156
175
|
animating.animation.seek(progress)
|
|
157
176
|
return compose(segment.to, animating.animation.graph)
|
|
158
177
|
}
|
|
159
178
|
|
|
160
|
-
async function screen(session: PlaySession): Promise<RGBAImage> {
|
|
161
|
-
const key = sessionDrawKey(session)
|
|
179
|
+
async function screen(session: PlaySession, source?: SceneGraph): Promise<RGBAImage> {
|
|
180
|
+
const key = `${sessionDrawKey(session)}#${graphToken(source)}`
|
|
162
181
|
const cached = cache.get(key)
|
|
163
182
|
if (cached) {
|
|
164
183
|
// Most recently used last, so the oldest screen is the one dropped.
|
|
@@ -166,7 +185,7 @@ function createScreens(
|
|
|
166
185
|
cache.set(key, cached)
|
|
167
186
|
return cached
|
|
168
187
|
}
|
|
169
|
-
const drawn = await compose(session)
|
|
188
|
+
const drawn = await compose(session, source)
|
|
170
189
|
cache.set(key, drawn)
|
|
171
190
|
for (const old of cache.keys()) {
|
|
172
191
|
if (cache.size <= CACHED_SCREENS) break
|
|
@@ -202,9 +221,14 @@ export async function recordPrototype(
|
|
|
202
221
|
const last = index === frameCount - 1 && !timeline.loops
|
|
203
222
|
const shown = frameAt(timeline, last ? timeline.durationMs : index * frameMs)
|
|
204
223
|
let image: RGBAImage
|
|
205
|
-
if ('session' in shown) image = await screen(shown.session)
|
|
224
|
+
if ('session' in shown) image = await screen(shown.session, shown.graph)
|
|
206
225
|
else if ('smart' in shown) image = await animated(shown.smart, shown.progress)
|
|
207
|
-
else
|
|
226
|
+
else
|
|
227
|
+
image = crossfade(
|
|
228
|
+
await screen(shown.from, shown.fromGraph),
|
|
229
|
+
await screen(shown.to, shown.toGraph),
|
|
230
|
+
shown.mix
|
|
231
|
+
)
|
|
208
232
|
await sink.add(image, index * frameMs, frameMs)
|
|
209
233
|
if (options.maxBytes !== undefined && sink.byteLength > options.maxBytes) {
|
|
210
234
|
throw new Error(
|
package/src/io/formats.ts
CHANGED
|
@@ -11,7 +11,12 @@ import { exportFigFile, parseFigFile } from './formats/fig'
|
|
|
11
11
|
import type { PDFPageSpec } from './formats/pdf/plan'
|
|
12
12
|
import { penFormat } from './formats/pen'
|
|
13
13
|
import type { PPTXExportOptions } from './formats/pptx'
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
headlessRenderNodes,
|
|
16
|
+
renderNodesToImage,
|
|
17
|
+
sliceRegion,
|
|
18
|
+
type RasterExportFormat
|
|
19
|
+
} from './formats/raster'
|
|
15
20
|
import { extractExportGraph, findPageId } from './subgraph'
|
|
16
21
|
import type {
|
|
17
22
|
ExportRequest,
|
|
@@ -49,16 +54,21 @@ function ensureSingleNode(target: ExportRequest['target']): string | null {
|
|
|
49
54
|
return null
|
|
50
55
|
}
|
|
51
56
|
|
|
57
|
+
/** A page's top-level layers that draw: a slice names an export region, not page content. */
|
|
58
|
+
function drawingPageChildren(graph: SceneGraph, page: { childIds: readonly string[] }): string[] {
|
|
59
|
+
return page.childIds.filter((id) => graph.getNode(id)?.type !== 'SLICE')
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
function resolveExportNodes(request: ExportRequest): { pageId: string; nodeIds: string[] } | null {
|
|
53
63
|
switch (request.target.scope) {
|
|
54
64
|
case 'document': {
|
|
55
65
|
const page = request.graph.getPages()[0]
|
|
56
|
-
return { pageId: page.id, nodeIds:
|
|
66
|
+
return { pageId: page.id, nodeIds: drawingPageChildren(request.graph, page) }
|
|
57
67
|
}
|
|
58
68
|
case 'page': {
|
|
59
69
|
const page = request.graph.getNode(request.target.pageId)
|
|
60
70
|
if (!page) return null
|
|
61
|
-
return { pageId: page.id, nodeIds:
|
|
71
|
+
return { pageId: page.id, nodeIds: drawingPageChildren(request.graph, page) }
|
|
62
72
|
}
|
|
63
73
|
case 'selection': {
|
|
64
74
|
const first = request.target.nodeIds[0]
|
|
@@ -88,6 +98,12 @@ async function renderRaster(
|
|
|
88
98
|
const target = resolveExportNodes(request)
|
|
89
99
|
if (!target) return null
|
|
90
100
|
const scale = options.scale ?? 1
|
|
101
|
+
const renderOptions = {
|
|
102
|
+
scale,
|
|
103
|
+
format: options.format,
|
|
104
|
+
quality: options.quality,
|
|
105
|
+
trimTransparent: request.target.scope === 'page' || request.target.scope === 'document'
|
|
106
|
+
}
|
|
91
107
|
|
|
92
108
|
if (context?.canvasKit && context.renderer) {
|
|
93
109
|
return renderNodesToImage(
|
|
@@ -96,21 +112,17 @@ async function renderRaster(
|
|
|
96
112
|
request.graph,
|
|
97
113
|
target.pageId,
|
|
98
114
|
target.nodeIds,
|
|
99
|
-
|
|
100
|
-
scale,
|
|
101
|
-
format: options.format,
|
|
102
|
-
quality: options.quality,
|
|
103
|
-
trimTransparent: request.target.scope === 'page' || request.target.scope === 'document'
|
|
104
|
-
}
|
|
115
|
+
renderOptions
|
|
105
116
|
)
|
|
106
117
|
}
|
|
107
118
|
|
|
108
|
-
return headlessRenderNodes(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
return headlessRenderNodes(
|
|
120
|
+
request.graph,
|
|
121
|
+
target.pageId,
|
|
122
|
+
target.nodeIds,
|
|
123
|
+
renderOptions,
|
|
124
|
+
context?.canvasKit
|
|
125
|
+
)
|
|
114
126
|
}
|
|
115
127
|
|
|
116
128
|
function rasterFormat<F extends RasterExportFormat>(format: F): IOFormatAdapter<Lowercase<F>> {
|
|
@@ -406,6 +418,14 @@ async function pdfPageSpecs(
|
|
|
406
418
|
}
|
|
407
419
|
const target = resolveExportNodes(request)
|
|
408
420
|
if (!target) throw new Error('Nothing to export')
|
|
421
|
+
if (sliceRegion(request.graph, target.nodeIds)) {
|
|
422
|
+
const { planPDFPages } = await import('./formats/pdf/plan')
|
|
423
|
+
return planPDFPages(request.graph, {
|
|
424
|
+
mode: 'single',
|
|
425
|
+
ids: target.nodeIds,
|
|
426
|
+
currentPageId: target.pageId
|
|
427
|
+
})
|
|
428
|
+
}
|
|
409
429
|
return [target]
|
|
410
430
|
}
|
|
411
431
|
|
|
@@ -3,7 +3,11 @@ import { randomHex } from '@pairdraw/scene-graph/random'
|
|
|
3
3
|
|
|
4
4
|
import { releaseFigArchive } from '#core/kiwi/fig/session/archive/access'
|
|
5
5
|
import { archiveChanges, trackArchiveChanges } from '#core/kiwi/fig/session/archive/changes'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
normalizeSlotContentOwners,
|
|
8
|
+
releaseReaderRecovery,
|
|
9
|
+
updateReaderRecovery
|
|
10
|
+
} from '#core/kiwi/fig/session/document-state'
|
|
7
11
|
import type { FigSessionRequest, FigSessionResponse } from '#core/kiwi/fig/session/protocol'
|
|
8
12
|
|
|
9
13
|
import { beginFigPopulation, type FigPopulation, type FigPopulationRebase } from './delta'
|
|
@@ -279,6 +283,7 @@ export function createPopulationWorkerClient(
|
|
|
279
283
|
return request.resolve(null)
|
|
280
284
|
}
|
|
281
285
|
|
|
286
|
+
normalizeSlotContentOwners(graph)
|
|
282
287
|
forgetSettledEdits(edits.revision)
|
|
283
288
|
// The worker built what it sent without the edits made meanwhile; it takes this thread's
|
|
284
289
|
// state where they met, and the instances it built from components edited since.
|