@pairdraw/core 0.19.1 → 0.20.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/ai/providers.d.ts +6 -0
- package/dist/ai/providers.d.ts.map +1 -1
- package/dist/ai/providers.js.map +1 -1
- package/dist/cache/resource.d.ts +8 -1
- package/dist/cache/resource.d.ts.map +1 -1
- package/dist/cache/resource.js +18 -0
- package/dist/cache/resource.js.map +1 -1
- package/dist/canvas/effects.d.ts +6 -4
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +37 -34
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/fills.d.ts.map +1 -1
- package/dist/canvas/fills.js +12 -8
- package/dist/canvas/fills.js.map +1 -1
- package/dist/canvas/images/adjustments.d.ts +18 -0
- package/dist/canvas/images/adjustments.d.ts.map +1 -0
- package/dist/canvas/images/adjustments.js +184 -0
- package/dist/canvas/images/adjustments.js.map +1 -0
- package/dist/canvas/images/previews.d.ts +1 -1
- package/dist/canvas/images/sampling.d.ts +13 -0
- package/dist/canvas/images/sampling.d.ts.map +1 -0
- package/dist/canvas/images/sampling.js +49 -0
- package/dist/canvas/images/sampling.js.map +1 -0
- package/dist/canvas/index.d.ts +2 -2
- package/dist/canvas/masks.d.ts +1 -1
- package/dist/canvas/masks.d.ts.map +1 -1
- package/dist/canvas/masks.js.map +1 -1
- package/dist/canvas/noise/render.d.ts +15 -0
- package/dist/canvas/noise/render.d.ts.map +1 -0
- package/dist/canvas/noise/render.js +56 -0
- package/dist/canvas/noise/render.js.map +1 -0
- package/dist/canvas/noise/shader.d.ts +43 -0
- package/dist/canvas/noise/shader.d.ts.map +1 -0
- package/dist/canvas/noise/shader.js +161 -0
- package/dist/canvas/noise/shader.js.map +1 -0
- package/dist/canvas/noise/table.d.ts +13 -0
- package/dist/canvas/noise/table.d.ts.map +1 -0
- package/dist/canvas/noise/table.js +408 -0
- package/dist/canvas/noise/table.js.map +1 -0
- package/dist/canvas/noise/tile.d.ts +22 -0
- package/dist/canvas/noise/tile.d.ts.map +1 -0
- package/dist/canvas/noise/tile.js +73 -0
- package/dist/canvas/noise/tile.js.map +1 -0
- package/dist/canvas/outline-stroke.js +1 -1
- package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
- package/dist/canvas/overlays/auto-layout-hover.js +31 -71
- package/dist/canvas/overlays/auto-layout-hover.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/selection.d.ts +1 -2
- package/dist/canvas/overlays/selection.d.ts.map +1 -1
- package/dist/canvas/overlays/selection.js +2 -9
- package/dist/canvas/overlays/selection.js.map +1 -1
- package/dist/canvas/renderer/chunks/index.d.ts +1 -1
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +2 -0
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -0
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +0 -1
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -4
- 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 +0 -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 +13 -2
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/play-scenes.d.ts +13 -0
- package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
- package/dist/canvas/renderer/play-scenes.js +40 -0
- package/dist/canvas/renderer/play-scenes.js.map +1 -0
- package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
- package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/cache.js +32 -1
- package/dist/canvas/renderer/tiles/cache.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +18 -1
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/index.d.ts +2 -2
- package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
- package/dist/canvas/renderer/types.d.ts +18 -4
- package/dist/canvas/renderer/types.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
- package/dist/canvas/renderer/visual-bounds.js +1 -1
- package/dist/canvas/renderer.d.ts +22 -3
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +29 -1
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +41 -9
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/silhouette.js +1 -1
- package/dist/canvas/texture.d.ts +20 -0
- package/dist/canvas/texture.d.ts.map +1 -0
- package/dist/canvas/texture.js +100 -0
- package/dist/canvas/texture.js.map +1 -0
- package/dist/clipboard.js +16 -5
- package/dist/clipboard.js.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/constants.js.map +1 -1
- package/dist/design-jsx/index.d.ts +2 -2
- package/dist/design-jsx/index.js +2 -2
- package/dist/design-jsx/renderer.d.ts +3 -2
- package/dist/design-jsx/renderer.d.ts.map +1 -1
- package/dist/design-jsx/renderer.js +2 -2
- package/dist/design-jsx/renderer.js.map +1 -1
- package/dist/design-memory/check.d.ts +90 -0
- package/dist/design-memory/check.d.ts.map +1 -0
- package/dist/design-memory/check.js +281 -0
- package/dist/design-memory/check.js.map +1 -0
- package/dist/design-memory/describe.d.ts +37 -0
- package/dist/design-memory/describe.d.ts.map +1 -0
- package/dist/design-memory/describe.js +52 -0
- package/dist/design-memory/describe.js.map +1 -0
- package/dist/design-memory/distil.d.ts +22 -0
- package/dist/design-memory/distil.d.ts.map +1 -0
- package/dist/design-memory/distil.js +54 -0
- package/dist/design-memory/distil.js.map +1 -0
- package/dist/design-memory/document.d.ts +12 -0
- package/dist/design-memory/document.d.ts.map +1 -0
- package/dist/design-memory/document.js +64 -0
- package/dist/design-memory/document.js.map +1 -0
- package/dist/design-memory/guard.d.ts +48 -0
- package/dist/design-memory/guard.d.ts.map +1 -0
- package/dist/design-memory/guard.js +105 -0
- package/dist/design-memory/guard.js.map +1 -0
- package/dist/design-memory/index.d.ts +9 -0
- package/dist/design-memory/index.js +9 -0
- package/dist/design-memory/refusal.d.ts +32 -0
- package/dist/design-memory/refusal.d.ts.map +1 -0
- package/dist/design-memory/refusal.js +68 -0
- package/dist/design-memory/refusal.js.map +1 -0
- package/dist/design-memory/rules.d.ts +63 -0
- package/dist/design-memory/rules.d.ts.map +1 -0
- package/dist/design-memory/rules.js +224 -0
- package/dist/design-memory/rules.js.map +1 -0
- package/dist/design-memory/values.d.ts +28 -0
- package/dist/design-memory/values.d.ts.map +1 -0
- package/dist/design-memory/values.js +160 -0
- package/dist/design-memory/values.js.map +1 -0
- package/dist/editor/alignment.js +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/undo.d.ts +1 -1
- package/dist/editor/clipboard/assets.js +1 -1
- package/dist/editor/clipboard/export.d.ts.map +1 -1
- package/dist/editor/clipboard/export.js +16 -2
- package/dist/editor/clipboard/export.js.map +1 -1
- package/dist/editor/clipboard/placement.d.ts +1 -1
- package/dist/editor/clipboard/placement.js +1 -1
- package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
- package/dist/editor/clipboard/snapshot.js +12 -4
- package/dist/editor/clipboard/snapshot.js.map +1 -1
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +2 -7
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/color-space.d.ts.map +1 -1
- package/dist/editor/color-space.js +33 -38
- package/dist/editor/color-space.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +22 -1
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/connectors/attach.js +1 -1
- package/dist/editor/create.d.ts +36 -8
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +26 -61
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/design-memory.d.ts +11 -0
- package/dist/editor/design-memory.d.ts.map +1 -0
- package/dist/editor/design-memory.js +40 -0
- package/dist/editor/design-memory.js.map +1 -0
- package/dist/editor/design-tokens.d.ts +4 -0
- package/dist/editor/design-tokens.d.ts.map +1 -1
- package/dist/editor/design-tokens.js +30 -1
- package/dist/editor/design-tokens.js.map +1 -1
- package/dist/editor/document-colors.d.ts +23 -0
- package/dist/editor/document-colors.d.ts.map +1 -0
- package/dist/editor/document-colors.js +53 -0
- package/dist/editor/document-colors.js.map +1 -0
- package/dist/editor/eyedropper.d.ts +47 -0
- package/dist/editor/eyedropper.d.ts.map +1 -0
- package/dist/editor/eyedropper.js +168 -0
- package/dist/editor/eyedropper.js.map +1 -0
- package/dist/editor/fonts.d.ts +9 -0
- package/dist/editor/fonts.d.ts.map +1 -0
- package/dist/editor/fonts.js +14 -0
- package/dist/editor/fonts.js.map +1 -0
- package/dist/editor/history/atomic-tool.d.ts +9 -2
- package/dist/editor/history/atomic-tool.d.ts.map +1 -1
- package/dist/editor/history/atomic-tool.js +6 -0
- package/dist/editor/history/atomic-tool.js.map +1 -1
- package/dist/editor/history/capture.d.ts +13 -0
- package/dist/editor/history/capture.d.ts.map +1 -0
- package/dist/editor/history/capture.js +28 -0
- package/dist/editor/history/capture.js.map +1 -0
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +2 -22
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts +7 -0
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +6 -3
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/subtree.d.ts +9 -0
- package/dist/editor/history/subtree.d.ts.map +1 -1
- package/dist/editor/history/subtree.js +12 -2
- package/dist/editor/history/subtree.js.map +1 -1
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +4 -2
- package/dist/editor/nudge.js +1 -1
- package/dist/editor/nudge.js.map +1 -1
- package/dist/editor/pages.d.ts +7 -5
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +35 -25
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts +3 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +1 -1
- package/dist/editor/play/states.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/render-requests.d.ts +18 -0
- package/dist/editor/render-requests.d.ts.map +1 -0
- package/dist/editor/render-requests.js +76 -0
- package/dist/editor/render-requests.js.map +1 -0
- package/dist/editor/scale/rescale.d.ts +1 -1
- package/dist/editor/selection/container.d.ts +2 -0
- package/dist/editor/selection/container.d.ts.map +1 -1
- package/dist/editor/selection/container.js +17 -1
- package/dist/editor/selection/container.js.map +1 -1
- package/dist/editor/selection/navigation.js +7 -4
- package/dist/editor/selection/navigation.js.map +1 -1
- package/dist/editor/selection/overlays.d.ts.map +1 -1
- package/dist/editor/selection/overlays.js +1 -1
- package/dist/editor/selection/overlays.js.map +1 -1
- package/dist/editor/selection/read.d.ts +6 -2
- package/dist/editor/selection.d.ts +9 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.d.ts.map +1 -1
- package/dist/editor/shapes/with-text.js +2 -5
- package/dist/editor/shapes/with-text.js.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.js +1 -1
- package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
- package/dist/editor/structure/boolean.d.ts +2 -3
- package/dist/editor/structure/boolean.d.ts.map +1 -1
- package/dist/editor/structure/boolean.js.map +1 -1
- package/dist/editor/structure/group/bounds.d.ts.map +1 -1
- package/dist/editor/structure/group/bounds.js +1 -3
- package/dist/editor/structure/group/bounds.js.map +1 -1
- package/dist/editor/structure/outline-stroke.js +3 -3
- package/dist/editor/structure/outline-stroke.js.map +1 -1
- package/dist/editor/structure/reorder.d.ts.map +1 -1
- package/dist/editor/structure/reorder.js +7 -14
- package/dist/editor/structure/reorder.js.map +1 -1
- package/dist/editor/structure/state.js +1 -1
- package/dist/editor/structure/state.js.map +1 -1
- package/dist/editor/structure.d.ts +1 -2
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/structure.js +3 -3
- package/dist/editor/structure.js.map +1 -1
- package/dist/editor/tool-registry.d.ts.map +1 -1
- package/dist/editor/tool-registry.js +2 -1
- package/dist/editor/tool-registry.js.map +1 -1
- package/dist/editor/types.d.ts +9 -2
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/variables.d.ts.map +1 -1
- package/dist/editor/variables.js +57 -1
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/variations/create.d.ts +28 -0
- package/dist/editor/variations/create.d.ts.map +1 -0
- package/dist/editor/variations/create.js +176 -0
- package/dist/editor/variations/create.js.map +1 -0
- package/dist/editor/variations/pick.d.ts +16 -0
- package/dist/editor/variations/pick.d.ts.map +1 -0
- package/dist/editor/variations/pick.js +23 -0
- package/dist/editor/variations/pick.js.map +1 -0
- package/dist/editor/variations.d.ts +28 -0
- package/dist/editor/variations.d.ts.map +1 -0
- package/dist/editor/variations.js +88 -0
- package/dist/editor/variations.js.map +1 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
- package/dist/figma-api/accessors/reactions.js +4 -1
- package/dist/figma-api/accessors/reactions.js.map +1 -1
- package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
- package/dist/figma-api/accessors/text/index.js +7 -1
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
- package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
- package/dist/figma-api/accessors/text/opentype.js +28 -0
- package/dist/figma-api/accessors/text/opentype.js.map +1 -0
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +33 -0
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/effects.d.ts +79 -3
- package/dist/figma-api/effects.d.ts.map +1 -1
- package/dist/figma-api/effects.js +150 -9
- package/dist/figma-api/effects.js.map +1 -1
- package/dist/figma-api/fonts/loaded.d.ts +3 -1
- package/dist/figma-api/fonts/loaded.d.ts.map +1 -1
- package/dist/figma-api/fonts/loaded.js +8 -1
- package/dist/figma-api/fonts/loaded.js.map +1 -1
- package/dist/figma-api/index.d.ts +18 -0
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +19 -1
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +13 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +196 -4
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/paints.d.ts +3 -3
- package/dist/figma-api/paints.d.ts.map +1 -1
- package/dist/figma-api/paints.js +14 -4
- package/dist/figma-api/paints.js.map +1 -1
- package/dist/figma-api/proxy.d.ts +4 -1
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +1 -1
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +41 -13
- package/dist/figma-api/reactions.d.ts.map +1 -1
- package/dist/figma-api/reactions.js +113 -31
- package/dist/figma-api/reactions.js.map +1 -1
- package/dist/figma-api/render-bounds.js +1 -1
- package/dist/figma-api/serialization.d.ts.map +1 -1
- package/dist/figma-api/serialization.js +2 -1
- package/dist/figma-api/serialization.js.map +1 -1
- package/dist/figma-api/shape-details.d.ts +26 -0
- package/dist/figma-api/shape-details.d.ts.map +1 -0
- package/dist/figma-api/shape-details.js +28 -0
- package/dist/figma-api/shape-details.js.map +1 -0
- package/dist/figma-api/shape-with-text.js +2 -5
- package/dist/figma-api/shape-with-text.js.map +1 -1
- package/dist/figma-api/surface.d.ts +7 -4
- package/dist/figma-api/surface.d.ts.map +1 -1
- package/dist/figma-api/surface.js +7 -2
- package/dist/figma-api/surface.js.map +1 -1
- package/dist/figma-api/transform.d.ts +1 -1
- package/dist/geometry/figma.d.ts +1 -1
- package/dist/geometry/image-crop.d.ts +1 -1
- package/dist/geometry/image-crop.js +1 -1
- package/dist/icons/svg.js +1 -1
- package/dist/icons/svg.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/io/formats/boolean-path.d.ts +19 -0
- package/dist/io/formats/boolean-path.d.ts.map +1 -0
- package/dist/io/formats/boolean-path.js +47 -0
- package/dist/io/formats/boolean-path.js.map +1 -0
- package/dist/io/formats/design-tokens/decode.js +1 -1
- package/dist/io/formats/design-tokens/index.d.ts +4 -1
- package/dist/io/formats/design-tokens/index.js +4 -1
- package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
- package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js +1 -1
- package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
- package/dist/io/formats/design-tokens/project.d.ts +17 -2
- package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/project.js +29 -8
- package/dist/io/formats/design-tokens/project.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
- package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/apply.js +73 -0
- package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
- package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/drift.js +391 -0
- package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
- package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
- package/dist/io/formats/design-tokens/sync/files.js +35 -0
- package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
- package/dist/io/formats/drawio/edges.d.ts +7 -1
- package/dist/io/formats/drawio/edges.d.ts.map +1 -1
- package/dist/io/formats/drawio/edges.js +54 -1
- package/dist/io/formats/drawio/edges.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +19 -2
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.d.ts.map +1 -1
- package/dist/io/formats/drawio/index.js +2 -1
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/label.js +1 -1
- package/dist/io/formats/drawio/paint.js +1 -1
- package/dist/io/formats/drawio/placement.d.ts +1 -1
- package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
- package/dist/io/formats/fig/export/patch/index.js +5 -0
- package/dist/io/formats/fig/export/patch/index.js.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
- package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
- package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
- package/dist/io/formats/html/import.d.ts.map +1 -1
- package/dist/io/formats/html/import.js +3 -1
- package/dist/io/formats/html/import.js.map +1 -1
- package/dist/io/formats/html/index.d.ts +2 -2
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +6 -4
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/html/layers.d.ts +7 -4
- package/dist/io/formats/html/layers.d.ts.map +1 -1
- package/dist/io/formats/html/layers.js +4 -1
- package/dist/io/formats/html/layers.js.map +1 -1
- package/dist/io/formats/html/vectors.d.ts +2 -1
- package/dist/io/formats/html/vectors.d.ts.map +1 -1
- package/dist/io/formats/html/vectors.js +3 -2
- package/dist/io/formats/html/vectors.js.map +1 -1
- package/dist/io/formats/mermaid/styles.js +1 -1
- package/dist/io/formats/pdf/document.d.ts +3 -1
- package/dist/io/formats/pdf/document.d.ts.map +1 -1
- package/dist/io/formats/pdf/document.js +6 -3
- package/dist/io/formats/pdf/document.js.map +1 -1
- package/dist/io/formats/pdf/dom.d.ts +6 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +9 -22
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/export.js +1 -1
- package/dist/io/formats/pdf/export.js.map +1 -1
- package/dist/io/formats/pdf/prepare.d.ts +1 -1
- package/dist/io/formats/pen/imports.d.ts +4 -1
- package/dist/io/formats/pen/imports.d.ts.map +1 -1
- package/dist/io/formats/pen/imports.js.map +1 -1
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +31 -3
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/pptx/export.js +1 -1
- package/dist/io/formats/pptx/geometry.d.ts +1 -1
- package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
- package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
- package/dist/io/formats/raster/adjusted-images.js +118 -0
- package/dist/io/formats/raster/adjusted-images.js.map +1 -0
- package/dist/io/formats/raster/headless.d.ts +11 -1
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +4 -4
- 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/pixels.d.ts +7 -1
- package/dist/io/formats/raster/pixels.d.ts.map +1 -1
- package/dist/io/formats/raster/pixels.js.map +1 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +4 -0
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/defs.d.ts +5 -6
- package/dist/io/formats/svg/defs.d.ts.map +1 -1
- package/dist/io/formats/svg/defs.js +4 -54
- package/dist/io/formats/svg/defs.js.map +1 -1
- package/dist/io/formats/svg/effects.d.ts +16 -0
- package/dist/io/formats/svg/effects.d.ts.map +1 -0
- package/dist/io/formats/svg/effects.js +126 -0
- package/dist/io/formats/svg/effects.js.map +1 -0
- package/dist/io/formats/svg/export.d.ts +7 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +224 -50
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/filter.d.ts +27 -0
- package/dist/io/formats/svg/filter.d.ts.map +1 -0
- package/dist/io/formats/svg/filter.js +44 -0
- package/dist/io/formats/svg/filter.js.map +1 -0
- package/dist/io/formats/svg/grain.d.ts +26 -0
- package/dist/io/formats/svg/grain.d.ts.map +1 -0
- package/dist/io/formats/svg/grain.js +298 -0
- package/dist/io/formats/svg/grain.js.map +1 -0
- package/dist/io/formats/svg/strokes.d.ts +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +1 -2
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/import.js +1 -1
- package/dist/io/formats/svg/text/layout.d.ts +5 -2
- package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
- package/dist/io/formats/svg/text/layout.js +6 -3
- package/dist/io/formats/svg/text/layout.js.map +1 -1
- package/dist/io/formats/video/composite.d.ts +18 -0
- package/dist/io/formats/video/composite.d.ts.map +1 -0
- package/dist/io/formats/video/composite.js +79 -0
- package/dist/io/formats/video/composite.js.map +1 -0
- package/dist/io/formats/video/formats.d.ts +29 -0
- package/dist/io/formats/video/formats.d.ts.map +1 -0
- package/dist/io/formats/video/formats.js +43 -0
- package/dist/io/formats/video/formats.js.map +1 -0
- package/dist/io/formats/video/gif.d.ts +13 -0
- package/dist/io/formats/video/gif.d.ts.map +1 -0
- package/dist/io/formats/video/gif.js +56 -0
- package/dist/io/formats/video/gif.js.map +1 -0
- package/dist/io/formats/video/index.d.ts +9 -0
- package/dist/io/formats/video/index.js +9 -0
- package/dist/io/formats/video/plan.d.ts +64 -0
- package/dist/io/formats/video/plan.d.ts.map +1 -0
- package/dist/io/formats/video/plan.js +90 -0
- package/dist/io/formats/video/plan.js.map +1 -0
- package/dist/io/formats/video/record.d.ts +36 -0
- package/dist/io/formats/video/record.d.ts.map +1 -0
- package/dist/io/formats/video/record.js +154 -0
- package/dist/io/formats/video/record.js.map +1 -0
- package/dist/io/formats/video/sink.d.ts +29 -0
- package/dist/io/formats/video/sink.d.ts.map +1 -0
- package/dist/io/formats/video/sink.js +16 -0
- package/dist/io/formats/video/sink.js.map +1 -0
- package/dist/io/formats/video/size.d.ts +19 -0
- package/dist/io/formats/video/size.d.ts.map +1 -0
- package/dist/io/formats/video/size.js +26 -0
- package/dist/io/formats/video/size.js.map +1 -0
- package/dist/io/formats/video/webcodecs.d.ts +18 -0
- package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
- package/dist/io/formats/video/webcodecs.js +74 -0
- package/dist/io/formats/video/webcodecs.js.map +1 -0
- package/dist/io/formats.d.ts.map +1 -1
- package/dist/io/formats.js +40 -11
- package/dist/io/formats.js.map +1 -1
- package/dist/io/types.d.ts +19 -4
- package/dist/io/types.d.ts.map +1 -1
- package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +50 -12
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/auto-layout-handles.d.ts +66 -0
- package/dist/layout/auto-layout-handles.d.ts.map +1 -0
- package/dist/layout/auto-layout-handles.js +291 -0
- package/dist/layout/auto-layout-handles.js.map +1 -0
- package/dist/layout/derived.d.ts +7 -1
- package/dist/layout/derived.d.ts.map +1 -1
- package/dist/layout/derived.js +11 -1
- package/dist/layout/derived.js.map +1 -1
- package/dist/layout/grid.d.ts +7 -2
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +27 -9
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/mutations.d.ts +1 -0
- package/dist/layout/mutations.d.ts.map +1 -1
- package/dist/layout/mutations.js +10 -0
- package/dist/layout/mutations.js.map +1 -1
- package/dist/layout/strokes.d.ts +9 -1
- package/dist/layout/strokes.d.ts.map +1 -1
- package/dist/layout/strokes.js +12 -1
- package/dist/layout/strokes.js.map +1 -1
- package/dist/layout/yoga-helpers.d.ts +3 -1
- package/dist/layout/yoga-helpers.d.ts.map +1 -1
- package/dist/layout/yoga-helpers.js +16 -2
- package/dist/layout/yoga-helpers.js.map +1 -1
- package/dist/layout.d.ts +3 -2
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +73 -39
- package/dist/layout.js.map +1 -1
- package/dist/lint/fixes.d.ts.map +1 -1
- package/dist/lint/fixes.js +9 -3
- package/dist/lint/fixes.js.map +1 -1
- package/dist/lint/index.d.ts +3 -2
- package/dist/lint/index.js +2 -1
- package/dist/lint/linter.d.ts +13 -0
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +123 -9
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/presets.d.ts.map +1 -1
- package/dist/lint/presets.js +2 -0
- package/dist/lint/presets.js.map +1 -1
- package/dist/lint/rules/design-memory.d.ts +15 -0
- package/dist/lint/rules/design-memory.d.ts.map +1 -0
- package/dist/lint/rules/design-memory.js +90 -0
- package/dist/lint/rules/design-memory.js.map +1 -0
- package/dist/lint/rules/effect-style-required.js +1 -0
- package/dist/lint/rules/effect-style-required.js.map +1 -1
- package/dist/lint/rules/index.d.ts +6 -5
- package/dist/lint/rules/index.d.ts.map +1 -1
- package/dist/lint/rules/index.js +6 -2
- package/dist/lint/rules/index.js.map +1 -1
- package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
- package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
- package/dist/lint/rules/no-unbound-token-values.js +79 -0
- package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
- package/dist/lint/rules/text-style-required.js +1 -0
- package/dist/lint/rules/text-style-required.js.map +1 -1
- package/dist/lint/types.d.ts +32 -2
- package/dist/lint/types.d.ts.map +1 -1
- package/dist/node/video.d.ts +12 -0
- package/dist/node/video.d.ts.map +1 -0
- package/dist/node/video.js +206 -0
- package/dist/node/video.js.map +1 -0
- package/dist/pairdraw-api/design-memory.d.ts +19 -0
- package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
- package/dist/pairdraw-api/design-memory.js +39 -0
- package/dist/pairdraw-api/design-memory.js.map +1 -0
- package/dist/pairdraw-api/index.d.ts +45 -1
- package/dist/pairdraw-api/index.d.ts.map +1 -1
- package/dist/pairdraw-api/index.js +55 -2
- package/dist/pairdraw-api/index.js.map +1 -1
- package/dist/pairdraw-api/nodes.d.ts +12 -1
- package/dist/pairdraw-api/nodes.d.ts.map +1 -1
- package/dist/pairdraw-api/nodes.js +28 -1
- package/dist/pairdraw-api/nodes.js.map +1 -1
- package/dist/pairdraw-api/variations.d.ts +48 -0
- package/dist/pairdraw-api/variations.d.ts.map +1 -0
- package/dist/pairdraw-api/variations.js +76 -0
- package/dist/pairdraw-api/variations.js.map +1 -0
- package/dist/prototype/easing.d.ts +13 -0
- package/dist/prototype/easing.d.ts.map +1 -0
- package/dist/prototype/easing.js +36 -0
- package/dist/prototype/easing.js.map +1 -0
- package/dist/prototype/frames.d.ts +10 -0
- package/dist/prototype/frames.d.ts.map +1 -0
- package/dist/prototype/frames.js +12 -0
- package/dist/prototype/frames.js.map +1 -0
- package/dist/prototype/hit.d.ts +17 -0
- package/dist/prototype/hit.d.ts.map +1 -0
- package/dist/prototype/hit.js +45 -0
- package/dist/prototype/hit.js.map +1 -0
- package/dist/prototype/index.d.ts +14 -0
- package/dist/prototype/index.js +14 -0
- package/dist/prototype/pointer.d.ts +63 -0
- package/dist/prototype/pointer.d.ts.map +1 -0
- package/dist/prototype/pointer.js +104 -0
- package/dist/prototype/pointer.js.map +1 -0
- package/dist/prototype/reactions.d.ts +45 -0
- package/dist/prototype/reactions.d.ts.map +1 -0
- package/dist/prototype/reactions.js +122 -0
- package/dist/prototype/reactions.js.map +1 -0
- package/dist/prototype/scene.d.ts +35 -0
- package/dist/prototype/scene.d.ts.map +1 -0
- package/dist/prototype/scene.js +86 -0
- package/dist/prototype/scene.js.map +1 -0
- package/dist/prototype/scenes.d.ts +81 -0
- package/dist/prototype/scenes.d.ts.map +1 -0
- package/dist/prototype/scenes.js +175 -0
- package/dist/prototype/scenes.js.map +1 -0
- package/dist/prototype/scroll.d.ts +48 -0
- package/dist/prototype/scroll.d.ts.map +1 -0
- package/dist/prototype/scroll.js +159 -0
- package/dist/prototype/scroll.js.map +1 -0
- package/dist/prototype/session.d.ts +71 -0
- package/dist/prototype/session.d.ts.map +1 -0
- package/dist/prototype/session.js +135 -0
- package/dist/prototype/session.js.map +1 -0
- package/dist/prototype/smart-animate/animation.d.ts +34 -0
- package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
- package/dist/prototype/smart-animate/animation.js +212 -0
- package/dist/prototype/smart-animate/animation.js.map +1 -0
- package/dist/prototype/smart-animate/match.d.ts +24 -0
- package/dist/prototype/smart-animate/match.d.ts.map +1 -0
- package/dist/prototype/smart-animate/match.js +72 -0
- package/dist/prototype/smart-animate/match.js.map +1 -0
- package/dist/prototype/snapshot.d.ts +19 -0
- package/dist/prototype/snapshot.d.ts.map +1 -0
- package/dist/prototype/snapshot.js +56 -0
- package/dist/prototype/snapshot.js.map +1 -0
- package/dist/prototype/timeline.d.ts +132 -0
- package/dist/prototype/timeline.d.ts.map +1 -0
- package/dist/prototype/timeline.js +260 -0
- package/dist/prototype/timeline.js.map +1 -0
- package/dist/rpc/commands.d.ts +2 -2
- package/dist/rpc/index.d.ts +2 -2
- package/dist/rpc/read-commands.d.ts +18 -8
- package/dist/rpc/read-commands.d.ts.map +1 -1
- package/dist/rpc/read-commands.js +18 -9
- package/dist/rpc/read-commands.js.map +1 -1
- package/dist/text/font/faces.d.ts +12 -1
- package/dist/text/font/faces.d.ts.map +1 -1
- package/dist/text/font/faces.js +15 -1
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/font/features.d.ts +9 -0
- package/dist/text/font/features.d.ts.map +1 -0
- package/dist/text/font/features.js +27 -0
- package/dist/text/font/features.js.map +1 -0
- package/dist/text/font/manager.d.ts +12 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +66 -12
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/index.d.ts +11 -9
- package/dist/text/index.js +4 -2
- package/dist/text/replace-fonts.d.ts +41 -0
- package/dist/text/replace-fonts.d.ts.map +1 -0
- package/dist/text/replace-fonts.js +121 -0
- package/dist/text/replace-fonts.js.map +1 -0
- package/dist/tools/analyze/responsive/index.d.ts +15 -0
- package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
- package/dist/tools/analyze/responsive/index.js +203 -0
- package/dist/tools/analyze/responsive/index.js.map +1 -0
- package/dist/tools/analyze.d.ts +2 -1
- package/dist/tools/analyze.js +2 -1
- package/dist/tools/codegen/token-sync.d.ts +7 -0
- package/dist/tools/codegen/token-sync.d.ts.map +1 -0
- package/dist/tools/codegen/token-sync.js +85 -0
- package/dist/tools/codegen/token-sync.js.map +1 -0
- package/dist/tools/codegen/tokens.d.ts +1 -1
- package/dist/tools/codegen.d.ts +2 -1
- package/dist/tools/codegen.js +2 -1
- package/dist/tools/create/basic.js +1 -1
- package/dist/tools/create/behaviours.js +1 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +4 -0
- package/dist/tools/create/components.js.map +1 -1
- package/dist/tools/create/html.js +3 -2
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +2 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.js +2 -1
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.js +1 -1
- package/dist/tools/create/svg.js +2 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.js +1 -1
- package/dist/tools/design-memory.d.ts +8 -0
- package/dist/tools/design-memory.d.ts.map +1 -0
- package/dist/tools/design-memory.js +68 -0
- package/dist/tools/design-memory.js.map +1 -0
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -1
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +2 -1
- package/dist/tools/modify/fonts.d.ts +6 -0
- package/dist/tools/modify/fonts.d.ts.map +1 -0
- package/dist/tools/modify/fonts.js +27 -0
- package/dist/tools/modify/fonts.js.map +1 -0
- package/dist/tools/modify/layout.d.ts.map +1 -1
- package/dist/tools/modify/layout.js +1 -0
- package/dist/tools/modify/layout.js.map +1 -1
- package/dist/tools/modify/paint.js +1 -1
- package/dist/tools/modify/reactions.d.ts.map +1 -1
- package/dist/tools/modify/reactions.js +3 -3
- package/dist/tools/modify/reactions.js.map +1 -1
- package/dist/tools/modify/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +26 -5
- package/dist/tools/modify/text.js.map +1 -1
- package/dist/tools/modify/update.d.ts +10 -1
- package/dist/tools/modify/update.d.ts.map +1 -1
- package/dist/tools/modify/update.js +34 -3
- package/dist/tools/modify/update.js.map +1 -1
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/read/fonts.d.ts.map +1 -1
- package/dist/tools/read/fonts.js +17 -2
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.js +2 -1
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/read/space.d.ts +3 -1
- package/dist/tools/read/space.d.ts.map +1 -1
- package/dist/tools/read/space.js +4 -3
- package/dist/tools/read/space.js.map +1 -1
- package/dist/tools/registry/core.d.ts +1 -1
- package/dist/tools/registry/core.d.ts.map +1 -1
- package/dist/tools/registry/core.js +3 -1
- package/dist/tools/registry/core.js.map +1 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +16 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +18 -2
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +1 -1
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/stock-photo.js +1 -0
- package/dist/tools/stock-photo.js.map +1 -1
- package/dist/tools/structure/basic.d.ts.map +1 -1
- package/dist/tools/structure/basic.js +1 -0
- package/dist/tools/structure/basic.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +22 -1
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/structure/hierarchy.d.ts.map +1 -1
- package/dist/tools/structure/hierarchy.js +4 -0
- package/dist/tools/structure/hierarchy.js.map +1 -1
- package/dist/tools/structure/variations.d.ts +8 -0
- package/dist/tools/structure/variations.d.ts.map +1 -0
- package/dist/tools/structure/variations.js +106 -0
- package/dist/tools/structure/variations.js.map +1 -0
- package/dist/tools/structure.d.ts +2 -1
- package/dist/tools/structure.js +2 -1
- package/dist/tools/styles/types.d.ts +2 -4
- package/dist/tools/styles/types.d.ts.map +1 -1
- package/dist/tools/styles/types.js.map +1 -1
- package/dist/tools/vector/boolean.d.ts.map +1 -1
- package/dist/tools/vector/boolean.js +4 -0
- package/dist/tools/vector/boolean.js.map +1 -1
- package/dist/tools/vector/path.d.ts.map +1 -1
- package/dist/tools/vector/path.js +39 -7
- package/dist/tools/vector/path.js.map +1 -1
- package/dist/tools/vector/vectorize.js +1 -0
- package/dist/tools/vector/vectorize.js.map +1 -1
- package/dist/tools/vector/video.d.ts +6 -0
- package/dist/tools/vector/video.d.ts.map +1 -0
- package/dist/tools/vector/video.js +133 -0
- package/dist/tools/vector/video.js.map +1 -0
- package/dist/tools/vector.d.ts +2 -1
- package/dist/tools/vector.js +2 -1
- package/dist/tools/video-host.d.ts +12 -0
- package/dist/tools/video-host.d.ts.map +1 -0
- package/dist/tools/video-host.js +19 -0
- package/dist/tools/video-host.js.map +1 -0
- package/dist/vector/point-transform.d.ts +1 -1
- package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
- package/dist/xpath.d.ts +3 -0
- package/dist/xpath.d.ts.map +1 -1
- package/dist/xpath.js +3 -1
- package/dist/xpath.js.map +1 -1
- package/package.json +31 -9
- package/src/ai/providers.ts +2 -0
- package/src/cache/resource.ts +24 -1
- package/src/canvas/effects.ts +47 -50
- package/src/canvas/fills.ts +19 -15
- package/src/canvas/images/adjustments.ts +203 -0
- package/src/canvas/images/sampling.ts +88 -0
- package/src/canvas/index.ts +1 -0
- package/src/canvas/masks.ts +1 -1
- package/src/canvas/noise/render.ts +75 -0
- package/src/canvas/noise/shader.ts +161 -0
- package/src/canvas/noise/table.ts +91 -0
- package/src/canvas/noise/tile.ts +94 -0
- package/src/canvas/overlays/auto-layout-hover.ts +47 -65
- package/src/canvas/overlays/index.ts +0 -1
- package/src/canvas/overlays/selection.ts +1 -12
- package/src/canvas/renderer/fonts.ts +2 -0
- package/src/canvas/renderer/lifecycle.ts +6 -0
- package/src/canvas/renderer/methods.ts +0 -9
- package/src/canvas/renderer/overlay-pass.ts +0 -1
- package/src/canvas/renderer/pipeline.ts +19 -2
- package/src/canvas/renderer/play-scenes.ts +51 -0
- package/src/canvas/renderer/tiles/cache.ts +54 -1
- package/src/canvas/renderer/tiles/controller.ts +30 -1
- package/src/canvas/renderer/types.ts +18 -3
- package/src/canvas/renderer.ts +40 -4
- package/src/canvas/scene.ts +65 -9
- package/src/canvas/texture.ts +136 -0
- package/src/clipboard.ts +23 -10
- package/src/constants.ts +6 -0
- package/src/design-jsx/index.ts +1 -1
- package/src/design-jsx/renderer.ts +1 -1
- package/src/design-memory/check.ts +376 -0
- package/src/design-memory/describe.ts +77 -0
- package/src/design-memory/distil.ts +69 -0
- package/src/design-memory/document.ts +80 -0
- package/src/design-memory/guard.ts +157 -0
- package/src/design-memory/index.ts +8 -0
- package/src/design-memory/refusal.ts +90 -0
- package/src/design-memory/rules.ts +274 -0
- package/src/design-memory/values.ts +179 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/clipboard/export.ts +24 -7
- package/src/editor/clipboard/snapshot.ts +21 -4
- package/src/editor/clipboard.ts +4 -14
- package/src/editor/color-space.ts +47 -38
- package/src/editor/components/instances.ts +31 -0
- package/src/editor/create.ts +39 -71
- package/src/editor/design-memory.ts +39 -0
- package/src/editor/design-tokens.ts +41 -2
- package/src/editor/document-colors.ts +65 -0
- package/src/editor/eyedropper.ts +198 -0
- package/src/editor/fonts.ts +19 -0
- package/src/editor/history/atomic-tool.ts +29 -1
- package/src/editor/history/capture.ts +19 -0
- package/src/editor/history/document-change.ts +5 -17
- package/src/editor/history/edit.ts +16 -2
- package/src/editor/history/subtree.ts +13 -2
- package/src/editor/index.ts +11 -0
- package/src/editor/nudge.ts +1 -1
- package/src/editor/pages.ts +40 -29
- package/src/editor/play/states.ts +1 -1
- package/src/editor/read-only/actions.ts +6 -0
- package/src/editor/render-requests.ts +83 -0
- package/src/editor/selection/container.ts +24 -1
- package/src/editor/selection/navigation.ts +8 -6
- package/src/editor/selection/overlays.ts +1 -0
- package/src/editor/shapes/with-text.ts +2 -5
- package/src/editor/structure/auto-layout-wrap.ts +1 -1
- package/src/editor/structure/boolean.ts +1 -3
- package/src/editor/structure/group/bounds.ts +1 -5
- package/src/editor/structure/outline-stroke.ts +3 -3
- package/src/editor/structure/reorder.ts +8 -14
- package/src/editor/structure/state.ts +1 -1
- package/src/editor/structure.ts +5 -8
- package/src/editor/tool-registry.ts +2 -1
- package/src/editor/types.ts +8 -1
- package/src/editor/variables.ts +74 -2
- package/src/editor/variations/create.ts +235 -0
- package/src/editor/variations/pick.ts +35 -0
- package/src/editor/variations.ts +110 -0
- package/src/figma-api/accessors/reactions.ts +11 -1
- package/src/figma-api/accessors/text/index.ts +17 -1
- package/src/figma-api/accessors/text/opentype.ts +33 -0
- package/src/figma-api/accessors/visual.ts +55 -2
- package/src/figma-api/compatibility.ts +5 -2
- package/src/figma-api/effects.ts +143 -5
- package/src/figma-api/fonts/loaded.ts +9 -0
- package/src/figma-api/index.ts +35 -0
- package/src/figma-api/overrides.ts +295 -3
- package/src/figma-api/paints.ts +24 -9
- package/src/figma-api/proxy.ts +6 -1
- package/src/figma-api/reactions.ts +130 -32
- package/src/figma-api/serialization.ts +2 -1
- package/src/figma-api/shape-details.ts +50 -0
- package/src/figma-api/shape-with-text.ts +2 -5
- package/src/figma-api/surface.ts +7 -2
- package/src/global.d.ts +31 -0
- package/src/icons/svg.ts +3 -1
- package/src/io/formats/boolean-path.ts +60 -0
- package/src/io/formats/design-tokens/index.ts +21 -0
- package/src/io/formats/design-tokens/plan/changes.ts +4 -1
- package/src/io/formats/design-tokens/project.ts +40 -9
- package/src/io/formats/design-tokens/styles.ts +10 -2
- package/src/io/formats/design-tokens/sync/apply.ts +130 -0
- package/src/io/formats/design-tokens/sync/drift.ts +587 -0
- package/src/io/formats/design-tokens/sync/files.ts +40 -0
- package/src/io/formats/drawio/edges.ts +65 -0
- package/src/io/formats/drawio/export.ts +37 -14
- package/src/io/formats/drawio/index.ts +5 -1
- package/src/io/formats/fig/export/patch/index.ts +8 -0
- package/src/io/formats/fig/thumbnail-page.ts +4 -4
- package/src/io/formats/html/import.ts +9 -1
- package/src/io/formats/html/index.ts +14 -7
- package/src/io/formats/html/layers.ts +11 -2
- package/src/io/formats/html/vectors.ts +8 -2
- package/src/io/formats/pdf/document.ts +14 -4
- package/src/io/formats/pdf/dom.ts +10 -18
- package/src/io/formats/pdf/export.ts +1 -1
- package/src/io/formats/pen/imports.ts +5 -6
- package/src/io/formats/pen/index.ts +36 -5
- package/src/io/formats/raster/adjusted-images.ts +125 -0
- package/src/io/formats/raster/headless.ts +3 -3
- package/src/io/formats/raster/index.ts +6 -1
- package/src/io/formats/raster/pixels.ts +7 -0
- package/src/io/formats/raster/render.ts +12 -1
- package/src/io/formats/svg/defs.ts +14 -73
- package/src/io/formats/svg/effects.ts +131 -0
- package/src/io/formats/svg/export.ts +371 -64
- package/src/io/formats/svg/filter.ts +47 -0
- package/src/io/formats/svg/grain.ts +249 -0
- package/src/io/formats/svg/strokes.ts +2 -2
- package/src/io/formats/svg/text/layout.ts +13 -3
- package/src/io/formats/video/composite.ts +79 -0
- package/src/io/formats/video/formats.ts +77 -0
- package/src/io/formats/video/gif.ts +65 -0
- package/src/io/formats/video/index.ts +30 -0
- package/src/io/formats/video/plan.ts +116 -0
- package/src/io/formats/video/record.ts +227 -0
- package/src/io/formats/video/sink.ts +32 -0
- package/src/io/formats/video/size.ts +25 -0
- package/src/io/formats/video/webcodecs.ts +89 -0
- package/src/io/formats.ts +59 -11
- package/src/io/types.ts +29 -10
- package/src/layout/apply.ts +87 -21
- package/src/layout/auto-layout-handles.ts +396 -0
- package/src/layout/derived.ts +14 -0
- package/src/layout/grid.ts +33 -9
- package/src/layout/mutations.ts +13 -1
- package/src/layout/strokes.ts +12 -0
- package/src/layout/yoga-helpers.ts +18 -1
- package/src/layout.ts +96 -49
- package/src/lint/fixes.ts +12 -3
- package/src/lint/index.ts +3 -1
- package/src/lint/linter.ts +124 -12
- package/src/lint/presets.ts +2 -0
- package/src/lint/rules/design-memory.ts +97 -0
- package/src/lint/rules/effect-style-required.ts +2 -0
- package/src/lint/rules/index.ts +6 -1
- package/src/lint/rules/no-unbound-token-values.ts +73 -0
- package/src/lint/rules/text-style-required.ts +2 -0
- package/src/lint/types.ts +40 -0
- package/src/node/video.ts +196 -0
- package/src/pairdraw-api/design-memory.ts +61 -0
- package/src/pairdraw-api/index.ts +81 -0
- package/src/pairdraw-api/nodes.ts +38 -0
- package/src/pairdraw-api/variations.ts +109 -0
- package/src/prototype/easing.ts +37 -0
- package/src/prototype/frames.ts +9 -0
- package/src/prototype/hit.ts +70 -0
- package/src/prototype/index.ts +69 -0
- package/src/prototype/pointer.ts +146 -0
- package/src/prototype/reactions.ts +178 -0
- package/src/prototype/scene.ts +116 -0
- package/src/prototype/scenes.ts +256 -0
- package/src/prototype/scroll.ts +190 -0
- package/src/prototype/session.ts +188 -0
- package/src/prototype/smart-animate/animation.ts +267 -0
- package/src/prototype/smart-animate/match.ts +85 -0
- package/src/prototype/snapshot.ts +60 -0
- package/src/prototype/timeline.ts +400 -0
- package/src/rpc/index.ts +1 -0
- package/src/rpc/read-commands.ts +40 -23
- package/src/text/font/faces.ts +22 -0
- package/src/text/font/features.ts +27 -0
- package/src/text/font/manager.ts +88 -12
- package/src/text/index.ts +2 -0
- package/src/text/replace-fonts.ts +171 -0
- package/src/tools/analyze/responsive/index.ts +264 -0
- package/src/tools/analyze.ts +2 -0
- package/src/tools/codegen/token-sync.ts +98 -0
- package/src/tools/codegen.ts +1 -0
- package/src/tools/create/components.ts +4 -0
- package/src/tools/create/html.ts +1 -0
- package/src/tools/create/icons.ts +1 -0
- package/src/tools/create/mermaid.ts +1 -0
- package/src/tools/create/svg.ts +1 -0
- package/src/tools/design-memory.ts +72 -0
- package/src/tools/image-ai/generate.ts +2 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/modify/fonts.ts +34 -0
- package/src/tools/modify/layout.ts +5 -0
- package/src/tools/modify/reactions.ts +15 -8
- package/src/tools/modify/text.ts +42 -5
- package/src/tools/modify/update.ts +46 -2
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/fonts.ts +24 -2
- package/src/tools/read/libraries.ts +1 -0
- package/src/tools/read/nodes.ts +0 -1
- package/src/tools/read/space.ts +3 -2
- package/src/tools/registry/core.ts +3 -1
- package/src/tools/registry/extended.ts +28 -1
- package/src/tools/schema.ts +28 -4
- package/src/tools/stock-photo.ts +1 -0
- package/src/tools/structure/basic.ts +1 -0
- package/src/tools/structure/batch.ts +34 -1
- package/src/tools/structure/hierarchy.ts +4 -0
- package/src/tools/structure/variations.ts +118 -0
- package/src/tools/structure.ts +2 -0
- package/src/tools/styles/types.ts +3 -4
- package/src/tools/vector/boolean.ts +4 -0
- package/src/tools/vector/path.ts +30 -6
- package/src/tools/vector/vectorize.ts +1 -0
- package/src/tools/vector/video.ts +228 -0
- package/src/tools/vector.ts +1 -0
- package/src/tools/video-host.ts +18 -0
- package/src/xpath.ts +6 -1
package/src/editor/create.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { createNanoEvents } from 'nanoevents'
|
|
|
3
3
|
import type { Emitter } from 'nanoevents'
|
|
4
4
|
|
|
5
5
|
import { SceneGraph, type SceneNode } from '@pairdraw/scene-graph'
|
|
6
|
-
import { UndoManager, type UndoHistory } from '@pairdraw/scene-graph/undo'
|
|
6
|
+
import { UndoManager, type UndoEntry, type UndoHistory } from '@pairdraw/scene-graph/undo'
|
|
7
7
|
|
|
8
8
|
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
9
9
|
import { prefetchFigmaSchema } from '#core/clipboard'
|
|
@@ -18,7 +18,6 @@ import { releaseFigPopulationWorker } from '#core/kiwi/fig/population/client'
|
|
|
18
18
|
import { releaseOriginalFigArchive } from '#core/kiwi/fig/session/original-archive'
|
|
19
19
|
import { installTextMeasurer } from '#core/layout'
|
|
20
20
|
import { createLayoutRunner } from '#core/layout/mutations'
|
|
21
|
-
import { emitNavigationTrace } from '#core/profiler'
|
|
22
21
|
import { TextEditor } from '#core/text/editor'
|
|
23
22
|
import { fontManager } from '#core/text/font/manager'
|
|
24
23
|
import { fontResolver } from '#core/text/resolver'
|
|
@@ -39,9 +38,11 @@ import { createConnectorDrawActions, createConnectorEndpointActions } from './co
|
|
|
39
38
|
import { createConnectorLineActions } from './connectors/line'
|
|
40
39
|
import { createConnectorRouting } from './connectors/routing'
|
|
41
40
|
import { createConnectorStyleActions } from './connectors/style'
|
|
41
|
+
import { createDesignMemoryActions } from './design-memory'
|
|
42
42
|
import { createDesignTokenActions } from './design-tokens'
|
|
43
43
|
import { createDocumentSettingsActions } from './document-settings'
|
|
44
44
|
import { createFigCompressionActions } from './fig-compression'
|
|
45
|
+
import { createFontActions } from './fonts'
|
|
45
46
|
import { createGraphEventSubscription } from './graph-events'
|
|
46
47
|
import { createGraphReadActions } from './graph-reads'
|
|
47
48
|
import { createGuideActions } from './guides'
|
|
@@ -52,6 +53,7 @@ import { createLineEndActions } from './line-ends'
|
|
|
52
53
|
import { createNodeActions } from './nodes'
|
|
53
54
|
import { createPageActions } from './pages'
|
|
54
55
|
import { createReadOnlyActions, guardReadOnly, guardUndo } from './read-only'
|
|
56
|
+
import { createRenderRequests } from './render-requests'
|
|
55
57
|
import { createScaleActions } from './scale'
|
|
56
58
|
import { createSelectionActions } from './selection'
|
|
57
59
|
import { createShaderActions } from './shaders/actions'
|
|
@@ -77,6 +79,7 @@ import type {
|
|
|
77
79
|
} from './types'
|
|
78
80
|
import { createUndoActions } from './undo'
|
|
79
81
|
import { createVariableActions } from './variables'
|
|
82
|
+
import { createVariationActions } from './variations'
|
|
80
83
|
import { createVectorizeActions } from './vectorize'
|
|
81
84
|
import { createViewportActions, NO_VIEWPORT_INSETS } from './viewport'
|
|
82
85
|
import { createCanvasViewActions, offeredTool, resolveEditorProfile } from './views'
|
|
@@ -156,46 +159,13 @@ export function createEditor(options?: EditorOptions) {
|
|
|
156
159
|
return events.on(event, handler)
|
|
157
160
|
}
|
|
158
161
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
sceneVersion: state.sceneVersion
|
|
167
|
-
})
|
|
168
|
-
emitEditorEvent('render:requested', {
|
|
169
|
-
renderVersion: state.renderVersion,
|
|
170
|
-
sceneVersion: state.sceneVersion
|
|
171
|
-
})
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* The caret or selection of the edited text moved: the canvas repaints its overlay and the
|
|
176
|
-
* views that follow the selection update, without the document counting as changed.
|
|
177
|
-
*/
|
|
178
|
-
function textSelectionChanged() {
|
|
179
|
-
state.textSelectionVersion++
|
|
180
|
-
requestRepaint()
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function requestRefresh() {
|
|
184
|
-
state.sceneVersion++
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function requestRepaint() {
|
|
188
|
-
state.renderVersion++
|
|
189
|
-
emitNavigationTrace('render:requested', {
|
|
190
|
-
kind: 'repaint',
|
|
191
|
-
renderVersion: state.renderVersion,
|
|
192
|
-
sceneVersion: state.sceneVersion
|
|
193
|
-
})
|
|
194
|
-
emitEditorEvent('repaint:requested', {
|
|
195
|
-
renderVersion: state.renderVersion,
|
|
196
|
-
sceneVersion: state.sceneVersion
|
|
197
|
-
})
|
|
198
|
-
}
|
|
162
|
+
const {
|
|
163
|
+
requestRender,
|
|
164
|
+
requestRefresh,
|
|
165
|
+
requestRepaint,
|
|
166
|
+
textSelectionChanged,
|
|
167
|
+
setNavigationPhase
|
|
168
|
+
} = createRenderRequests(state, emitEditorEvent)
|
|
199
169
|
|
|
200
170
|
/** Track an actual live edit independently of history batching. Release is idempotent. */
|
|
201
171
|
function beginInteractiveEdit() {
|
|
@@ -207,31 +177,6 @@ export function createEditor(options?: EditorOptions) {
|
|
|
207
177
|
}
|
|
208
178
|
}
|
|
209
179
|
|
|
210
|
-
function setNavigationPhase(phase: EditorState['navigation']['phase'], inputAt = 0) {
|
|
211
|
-
const previous = { ...state.navigation }
|
|
212
|
-
const active = phase === 'pan' || phase === 'zoom' || phase === 'momentum'
|
|
213
|
-
const wasActive =
|
|
214
|
-
previous.phase === 'pan' || previous.phase === 'zoom' || previous.phase === 'momentum'
|
|
215
|
-
state.navigation = {
|
|
216
|
-
phase,
|
|
217
|
-
generation: active && !wasActive ? previous.generation + 1 : previous.generation,
|
|
218
|
-
lastInputAt: inputAt || previous.lastInputAt
|
|
219
|
-
}
|
|
220
|
-
if (
|
|
221
|
-
state.navigation.phase !== previous.phase ||
|
|
222
|
-
state.navigation.generation !== previous.generation ||
|
|
223
|
-
state.navigation.lastInputAt !== previous.lastInputAt
|
|
224
|
-
) {
|
|
225
|
-
emitNavigationTrace('navigation:phase', {
|
|
226
|
-
phase: state.navigation.phase,
|
|
227
|
-
previousPhase: previous.phase,
|
|
228
|
-
generation: state.navigation.generation,
|
|
229
|
-
lastInputAt: state.navigation.lastInputAt
|
|
230
|
-
})
|
|
231
|
-
emitEditorEvent('navigation:changed', state.navigation, previous)
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
180
|
function setSelectedIds(ids: Set<string>) {
|
|
236
181
|
const previous = [...state.selectedIds]
|
|
237
182
|
state.selectedIds = ids
|
|
@@ -257,7 +202,9 @@ export function createEditor(options?: EditorOptions) {
|
|
|
257
202
|
}
|
|
258
203
|
|
|
259
204
|
const graphReads = createGraphReadActions(() => _graph)
|
|
260
|
-
const { runLayoutForNode, runMutationWithLayout } = createLayoutRunner(
|
|
205
|
+
const { runLayoutForNode, runLayoutForParents, runMutationWithLayout } = createLayoutRunner(
|
|
206
|
+
() => _graph
|
|
207
|
+
)
|
|
261
208
|
const pendingTextLayout = createPendingTextLayout({
|
|
262
209
|
getGraph: () => _graph,
|
|
263
210
|
runLayoutForNode,
|
|
@@ -294,6 +241,7 @@ export function createEditor(options?: EditorOptions) {
|
|
|
294
241
|
_graph = g
|
|
295
242
|
},
|
|
296
243
|
undo,
|
|
244
|
+
parkStep,
|
|
297
245
|
state,
|
|
298
246
|
loadFont: _loadFont,
|
|
299
247
|
resolveFigmaClipboardImages: options?.resolveFigmaClipboardImages ?? null,
|
|
@@ -315,6 +263,7 @@ export function createEditor(options?: EditorOptions) {
|
|
|
315
263
|
setActiveTool,
|
|
316
264
|
setNavigationPhase,
|
|
317
265
|
runLayoutForNode,
|
|
266
|
+
runLayoutForParents,
|
|
318
267
|
runMutationWithLayout,
|
|
319
268
|
subscribeToGraph
|
|
320
269
|
}
|
|
@@ -333,6 +282,7 @@ export function createEditor(options?: EditorOptions) {
|
|
|
333
282
|
const documentSettings = createDocumentSettingsActions(ctx)
|
|
334
283
|
const undoActions = createUndoActions(ctx)
|
|
335
284
|
const text = createTextActions(ctx)
|
|
285
|
+
const fonts = createFontActions(ctx)
|
|
336
286
|
const nodes = createNodeActions(ctx)
|
|
337
287
|
const shapes = createShapeActions(ctx, nodes.updateNodeWithUndo)
|
|
338
288
|
const clipboardProperties = createClipboardPropertiesActions(
|
|
@@ -349,6 +299,8 @@ export function createEditor(options?: EditorOptions) {
|
|
|
349
299
|
const shapesWithText = createShapeWithTextActions(ctx, nodes)
|
|
350
300
|
const generatedText = createGeneratedTextActions(ctx, nodes)
|
|
351
301
|
const statuses = createStatusActions(ctx)
|
|
302
|
+
const designMemory = createDesignMemoryActions(ctx)
|
|
303
|
+
const variations = createVariationActions(ctx)
|
|
352
304
|
const figCompression = createFigCompressionActions(ctx)
|
|
353
305
|
createConnectorRouting(ctx)
|
|
354
306
|
const connectorDrawing = createConnectorDrawActions(ctx)
|
|
@@ -402,6 +354,7 @@ export function createEditor(options?: EditorOptions) {
|
|
|
402
354
|
function setCanvasKit(ck: CanvasKit, renderer: SkiaRenderer) {
|
|
403
355
|
_ck = ck
|
|
404
356
|
_renderer = renderer
|
|
357
|
+
const first = _renderers.size === 0
|
|
405
358
|
_renderers.add(renderer)
|
|
406
359
|
_textEditor ??= new TextEditor(ck)
|
|
407
360
|
uninstallTextMeasurer?.()
|
|
@@ -411,6 +364,9 @@ export function createEditor(options?: EditorOptions) {
|
|
|
411
364
|
pendingTextLayout.measure(renderer, node, maxWidth)
|
|
412
365
|
)
|
|
413
366
|
: null
|
|
367
|
+
// A page shown before this editor had a canvas to measure its text, as one a tab opens while
|
|
368
|
+
// its canvas loads, is laid out now that one can.
|
|
369
|
+
if (first) pages.layOutStaleCurrentPage()
|
|
414
370
|
}
|
|
415
371
|
|
|
416
372
|
function releaseTextMeasurer() {
|
|
@@ -429,6 +385,12 @@ export function createEditor(options?: EditorOptions) {
|
|
|
429
385
|
/** Each graph's committed history, kept aside while another graph is open in this editor. */
|
|
430
386
|
const histories = new WeakMap<SceneGraph, UndoHistory>()
|
|
431
387
|
|
|
388
|
+
/** A step recorded while its document was swapped away joins that document's own history. */
|
|
389
|
+
function parkStep(graph: SceneGraph, entry: UndoEntry) {
|
|
390
|
+
const history = histories.get(graph)
|
|
391
|
+
if (history) histories.set(graph, undo.pushIntoParked(history, entry))
|
|
392
|
+
}
|
|
393
|
+
|
|
432
394
|
function replaceGraph(newGraph: SceneGraph) {
|
|
433
395
|
nodes.cancelNodePreviews()
|
|
434
396
|
if (newGraph !== _graph) {
|
|
@@ -475,9 +437,9 @@ export function createEditor(options?: EditorOptions) {
|
|
|
475
437
|
unsubscribeFromGraph()
|
|
476
438
|
}
|
|
477
439
|
|
|
478
|
-
function releaseGraphResources() {
|
|
479
|
-
releaseFigPopulationWorker(
|
|
480
|
-
releaseOriginalFigArchive(
|
|
440
|
+
function releaseGraphResources(graph: SceneGraph = _graph) {
|
|
441
|
+
releaseFigPopulationWorker(graph)
|
|
442
|
+
releaseOriginalFigArchive(graph)
|
|
481
443
|
}
|
|
482
444
|
|
|
483
445
|
const editor = {
|
|
@@ -496,10 +458,12 @@ export function createEditor(options?: EditorOptions) {
|
|
|
496
458
|
return _textEditor
|
|
497
459
|
},
|
|
498
460
|
undo: guardUndo(undo, readsOnly),
|
|
461
|
+
parkStep,
|
|
499
462
|
state,
|
|
500
463
|
|
|
501
464
|
// Graph reads
|
|
502
465
|
runLayoutForNode,
|
|
466
|
+
runLayoutForParents,
|
|
503
467
|
runMutationWithLayout,
|
|
504
468
|
...graphReads,
|
|
505
469
|
|
|
@@ -565,6 +529,9 @@ export function createEditor(options?: EditorOptions) {
|
|
|
565
529
|
getShownStatus: statuses.getShownStatus,
|
|
566
530
|
setStatus: statuses.setStatus,
|
|
567
531
|
setStatusWorkflow: statuses.setStatusWorkflow,
|
|
532
|
+
...designMemory,
|
|
533
|
+
// Variations: copies of a layer side by side, one of which can replace it
|
|
534
|
+
...variations,
|
|
568
535
|
...connectorDrawing,
|
|
569
536
|
...connectorEndpoints,
|
|
570
537
|
...connectorLines,
|
|
@@ -580,6 +547,7 @@ export function createEditor(options?: EditorOptions) {
|
|
|
580
547
|
|
|
581
548
|
// Text editing
|
|
582
549
|
...text,
|
|
550
|
+
...fonts,
|
|
583
551
|
...textHyperlinks,
|
|
584
552
|
|
|
585
553
|
// Viewport
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cachedDesignMemory, type DesignMemory } from '@pairdraw/scene-graph/design-memory'
|
|
2
|
+
import {
|
|
3
|
+
PAIRDRAW_PLUGIN_DATA,
|
|
4
|
+
readPluginData,
|
|
5
|
+
withPluginData
|
|
6
|
+
} from '@pairdraw/scene-graph/plugin-data'
|
|
7
|
+
|
|
8
|
+
import type { EditorContext } from './types'
|
|
9
|
+
|
|
10
|
+
/** The document's design memory, and the command that replaces it. */
|
|
11
|
+
export function createDesignMemoryActions(ctx: EditorContext) {
|
|
12
|
+
function designMemory(): DesignMemory | null {
|
|
13
|
+
return cachedDesignMemory(ctx.graph)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Replaces the document's design memory, or removes it with null, as one undo step labelled
|
|
18
|
+
* `label`. Undo restores only the memory, so comments written meanwhile on the document node
|
|
19
|
+
* stay.
|
|
20
|
+
*/
|
|
21
|
+
function setDesignMemory(next: DesignMemory | null, label = 'Edit design memory'): void {
|
|
22
|
+
const field = PAIRDRAW_PLUGIN_DATA.designMemory
|
|
23
|
+
const rootId = ctx.graph.rootId
|
|
24
|
+
const previous = readPluginData(ctx.graph.getNode(rootId)?.pluginData, field)
|
|
25
|
+
const write = (value: DesignMemory | undefined) => {
|
|
26
|
+
const root = ctx.graph.getNode(rootId)
|
|
27
|
+
if (!root) return
|
|
28
|
+
ctx.graph.updateNode(rootId, {
|
|
29
|
+
pluginData: withPluginData(root.pluginData, field, value && structuredClone(value))
|
|
30
|
+
})
|
|
31
|
+
ctx.requestRender()
|
|
32
|
+
}
|
|
33
|
+
const value = next ?? undefined
|
|
34
|
+
write(value)
|
|
35
|
+
ctx.undo.push({ label, forward: () => write(value), inverse: () => write(previous) })
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return { designMemory, setDesignMemory }
|
|
39
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type { SceneNode } from '@pairdraw/scene-graph'
|
|
1
|
+
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
2
|
+
import {
|
|
3
|
+
readTokenSources,
|
|
4
|
+
tokenSourcesPluginData,
|
|
5
|
+
type TokenSource
|
|
6
|
+
} from '@pairdraw/scene-graph/token-sources'
|
|
2
7
|
|
|
3
8
|
// Not the format's barrel: the editor always loads this file, and the exporter is loaded on demand.
|
|
4
9
|
import {
|
|
@@ -82,5 +87,39 @@ export function createDesignTokenActions(
|
|
|
82
87
|
})
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Brings linked code in as one undo step: the imports in order, then the document's links as
|
|
92
|
+
* `sources` gives them once the imports are applied, so undo takes back both.
|
|
93
|
+
*/
|
|
94
|
+
function syncDesignTokens(
|
|
95
|
+
plans: readonly TokenImportPlan[],
|
|
96
|
+
sources: (graph: SceneGraph) => TokenSource[]
|
|
97
|
+
): TokenImportResult[] {
|
|
98
|
+
return ctx.undo.runBatch('Sync design tokens', () => {
|
|
99
|
+
const results = plans.map((plan) => applyTokenImport({ ...target, graph: ctx.graph }, plan))
|
|
100
|
+
writeTokenSources(sources(ctx.graph), 'Sync design tokens')
|
|
101
|
+
ctx.requestRender()
|
|
102
|
+
return results
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function writeTokenSources(sources: readonly TokenSource[], label: string) {
|
|
107
|
+
nodes.updateNodeWithUndo(
|
|
108
|
+
ctx.graph.rootId,
|
|
109
|
+
{ pluginData: tokenSourcesPluginData(ctx.graph, sources) },
|
|
110
|
+
label
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Forgets a link to code; the variables it brought in stay. */
|
|
115
|
+
function unlinkTokenSource(id: string) {
|
|
116
|
+
const sources = readTokenSources(ctx.graph)
|
|
117
|
+
if (!sources.some((source) => source.id === id)) return
|
|
118
|
+
writeTokenSources(
|
|
119
|
+
sources.filter((source) => source.id !== id),
|
|
120
|
+
'Unlink code'
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return { importDesignTokens, syncDesignTokens, unlinkTokenSource }
|
|
86
125
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
|
|
2
|
+
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
3
|
+
|
|
4
|
+
/** A solid colour the page uses, and how many paints use it. */
|
|
5
|
+
export interface DocumentColor {
|
|
6
|
+
color: Color
|
|
7
|
+
/** Fill and stroke paints with this exact RGBA, across the page's visible layers. */
|
|
8
|
+
count: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** How many colours the picker lists; Figma's document colours stop at a screenful too. */
|
|
12
|
+
export const DOCUMENT_COLOR_LIMIT = 48
|
|
13
|
+
|
|
14
|
+
/** The RGBA as a map key; colours are kept exact, alpha included. */
|
|
15
|
+
function colorKey(color: Color): string {
|
|
16
|
+
return `${color.r},${color.g},${color.b},${color.a}`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The solid fills and strokes a page's visible layers use, most used first.
|
|
21
|
+
*
|
|
22
|
+
* One pass over the page tree. A hidden layer takes its whole subtree with it. Paints bound to a
|
|
23
|
+
* variable or covered by a colour style are left to the variable/style sections instead. Gradient,
|
|
24
|
+
* image, mesh, pattern, noise, video and custom paints are not listed: this list is for reusing a
|
|
25
|
+
* solid colour, not for its stops.
|
|
26
|
+
*/
|
|
27
|
+
export function documentColors(graph: SceneGraph, pageId: string): DocumentColor[] {
|
|
28
|
+
const colors = new Map<string, DocumentColor>()
|
|
29
|
+
|
|
30
|
+
const count = (color: Color) => {
|
|
31
|
+
const key = colorKey(color)
|
|
32
|
+
const entry = colors.get(key)
|
|
33
|
+
if (entry) entry.count++
|
|
34
|
+
else colors.set(key, { color: { r: color.r, g: color.g, b: color.b, a: color.a }, count: 1 })
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const isBound = (node: SceneNode, path: string) => Object.hasOwn(node.boundVariables, path)
|
|
38
|
+
|
|
39
|
+
const walk = (node: SceneNode) => {
|
|
40
|
+
if (!node.visible) return
|
|
41
|
+
if (!node.fillStyleId) {
|
|
42
|
+
node.fills.forEach((fill, index) => {
|
|
43
|
+
if (fill.visible && fill.type === 'SOLID' && !isBound(node, `fills/${index}/color`))
|
|
44
|
+
count(fill.color)
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
if (!node.strokeStyleId) {
|
|
48
|
+
node.strokes.forEach((stroke, index) => {
|
|
49
|
+
if (stroke.visible && stroke.type === 'SOLID' && !isBound(node, `strokes/${index}/color`))
|
|
50
|
+
count(stroke.color)
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
for (const childId of node.childIds) {
|
|
54
|
+
const child = graph.getNode(childId)
|
|
55
|
+
if (child) walk(child)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const page = graph.getNode(pageId)
|
|
60
|
+
if (page) walk(page)
|
|
61
|
+
|
|
62
|
+
return [...colors.values()]
|
|
63
|
+
.sort((a, b) => b.count - a.count || colorKey(a.color).localeCompare(colorKey(b.color)))
|
|
64
|
+
.slice(0, DOCUMENT_COLOR_LIMIT)
|
|
65
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { CanvasKit } from 'canvaskit-wasm'
|
|
2
|
+
import { isEqual } from 'es-toolkit'
|
|
3
|
+
|
|
4
|
+
import type { Fill, SceneGraph, SceneNode, Stroke } from '@pairdraw/scene-graph'
|
|
5
|
+
import { newStrokeGeometry } from '@pairdraw/scene-graph/node-defaults'
|
|
6
|
+
import type { Color } from '@pairdraw/scene-graph/primitives'
|
|
7
|
+
import type { UndoManager } from '@pairdraw/scene-graph/undo'
|
|
8
|
+
|
|
9
|
+
import type { SkiaRenderer } from '#core/canvas/renderer'
|
|
10
|
+
import { getPageColor } from '#core/figma-api/page-backgrounds'
|
|
11
|
+
|
|
12
|
+
/** Which paint of the selection a sampled colour replaces. Alt samples into the stroke. */
|
|
13
|
+
export type EyedropperTarget = 'fill' | 'stroke'
|
|
14
|
+
|
|
15
|
+
type SampleRenderer = Pick<
|
|
16
|
+
SkiaRenderer,
|
|
17
|
+
'worldViewport' | 'viewportImageRendering' | 'presentationColorSpace' | 'renderNode'
|
|
18
|
+
>
|
|
19
|
+
|
|
20
|
+
/** A square of the document's pixels: RGBA rows, `size` pixels a side, the centre one sampled. */
|
|
21
|
+
export interface ScenePixels {
|
|
22
|
+
size: number
|
|
23
|
+
data: Uint8Array
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The document's pixels in a square of `size` (odd) pixels centred on a world point, each
|
|
28
|
+
* `1 / scale` world units wide, composited over the page background, so at the view's zoom they
|
|
29
|
+
* are the pixels the screen shows there.
|
|
30
|
+
*
|
|
31
|
+
* Renders only what intersects the square into a raster surface, so selection chrome, rulers and
|
|
32
|
+
* the screen's colour profile never leak into the result, unlike `window.EyeDropper`, which
|
|
33
|
+
* samples the screen. Components come back in the document's own colour space: the renderer
|
|
34
|
+
* presents in that space and the surface is not converted.
|
|
35
|
+
*/
|
|
36
|
+
export function sampleScenePixels(
|
|
37
|
+
ck: CanvasKit,
|
|
38
|
+
renderer: SampleRenderer,
|
|
39
|
+
graph: SceneGraph,
|
|
40
|
+
pageId: string,
|
|
41
|
+
x: number,
|
|
42
|
+
y: number,
|
|
43
|
+
size = 1,
|
|
44
|
+
scale = 1
|
|
45
|
+
): ScenePixels | null {
|
|
46
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return null
|
|
47
|
+
if (!Number.isInteger(size) || size < 1 || size % 2 === 0 || !(scale > 0)) return null
|
|
48
|
+
const page = graph.getNode(pageId)
|
|
49
|
+
if (!page) return null
|
|
50
|
+
const surface = ck.MakeSurface(size, size)
|
|
51
|
+
if (!surface) return null
|
|
52
|
+
const previousViewport = renderer.worldViewport
|
|
53
|
+
const previousImageRendering = renderer.viewportImageRendering
|
|
54
|
+
const previousColorSpace = renderer.presentationColorSpace
|
|
55
|
+
try {
|
|
56
|
+
const canvas = surface.getCanvas()
|
|
57
|
+
const background = getPageColor(page)
|
|
58
|
+
canvas.clear(ck.Color4f(background.r, background.g, background.b, 1))
|
|
59
|
+
// Pixel (i, j) covers [i, i + 1); put the sampled point at the centre pixel's centre.
|
|
60
|
+
const half = (size - 1) / 2
|
|
61
|
+
canvas.translate(half + 0.5, half + 0.5)
|
|
62
|
+
canvas.scale(scale, scale)
|
|
63
|
+
canvas.translate(-x, -y)
|
|
64
|
+
const reach = (half + 1) / scale
|
|
65
|
+
renderer.worldViewport = { x: x - reach, y: y - reach, w: reach * 2, h: reach * 2 }
|
|
66
|
+
renderer.viewportImageRendering = false
|
|
67
|
+
renderer.presentationColorSpace = graph.documentColorSpace
|
|
68
|
+
for (const childId of page.childIds) renderer.renderNode(canvas, graph, childId, {})
|
|
69
|
+
surface.flush()
|
|
70
|
+
const data = canvas.readPixels(0, 0, {
|
|
71
|
+
width: size,
|
|
72
|
+
height: size,
|
|
73
|
+
alphaType: ck.AlphaType.Unpremul,
|
|
74
|
+
colorType: ck.ColorType.RGBA_8888,
|
|
75
|
+
colorSpace: ck.ColorSpace.SRGB
|
|
76
|
+
})
|
|
77
|
+
if (!(data instanceof Uint8Array) || data.length < size * size * 4) return null
|
|
78
|
+
return { size, data }
|
|
79
|
+
} finally {
|
|
80
|
+
renderer.worldViewport = previousViewport
|
|
81
|
+
renderer.viewportImageRendering = previousImageRendering
|
|
82
|
+
renderer.presentationColorSpace = previousColorSpace
|
|
83
|
+
surface.dispose()
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The opaque colour of one pixel of a sample, by column and row. */
|
|
88
|
+
export function scenePixelColor(pixels: ScenePixels, column: number, row: number): Color {
|
|
89
|
+
const at = (row * pixels.size + column) * 4
|
|
90
|
+
const { data } = pixels
|
|
91
|
+
return { r: data[at] / 255, g: data[at + 1] / 255, b: data[at + 2] / 255, a: 1 }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The colour the document shows at a world point, one `1 / scale`-wide pixel of it. */
|
|
95
|
+
export function sampleSceneColor(
|
|
96
|
+
ck: CanvasKit,
|
|
97
|
+
renderer: SampleRenderer,
|
|
98
|
+
graph: SceneGraph,
|
|
99
|
+
pageId: string,
|
|
100
|
+
x: number,
|
|
101
|
+
y: number,
|
|
102
|
+
scale = 1
|
|
103
|
+
): Color | null {
|
|
104
|
+
const pixels = sampleScenePixels(ck, renderer, graph, pageId, x, y, 1, scale)
|
|
105
|
+
return pixels ? scenePixelColor(pixels, 0, 0) : null
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function solidPaint(color: Color): Fill {
|
|
109
|
+
return { type: 'SOLID', color: { ...color, a: 1 }, opacity: 1, visible: true }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Replaces the top solid paint's colour, keeping its opacity, or adds an opaque solid paint. A
|
|
114
|
+
* solid paint's alpha is its opacity, as the colour picker writes them, so the alpha stays too.
|
|
115
|
+
*/
|
|
116
|
+
function withSampledPaint<T extends Fill>(
|
|
117
|
+
paints: readonly T[],
|
|
118
|
+
color: Color,
|
|
119
|
+
create: (paint: Fill) => T
|
|
120
|
+
): { paints: T[]; index: number } {
|
|
121
|
+
const next = paints.map((paint) => ({ ...paint }))
|
|
122
|
+
for (let index = next.length - 1; index >= 0; index--) {
|
|
123
|
+
if (next[index].type !== 'SOLID') continue
|
|
124
|
+
next[index] = { ...next[index], color: { ...color, a: next[index].color.a } }
|
|
125
|
+
return { paints: next, index }
|
|
126
|
+
}
|
|
127
|
+
next.push(create(solidPaint(color)))
|
|
128
|
+
return { paints: next, index: next.length - 1 }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function eyedropperChanges(
|
|
132
|
+
node: SceneNode,
|
|
133
|
+
color: Color,
|
|
134
|
+
target: EyedropperTarget
|
|
135
|
+
): Partial<SceneNode> {
|
|
136
|
+
const boundVariables = { ...node.boundVariables }
|
|
137
|
+
if (target === 'stroke') {
|
|
138
|
+
// A first stroke takes the weight and alignment the node keeps for its strokes.
|
|
139
|
+
const { paints, index } = withSampledPaint<Stroke>(node.strokes, color, (paint) => ({
|
|
140
|
+
...paint,
|
|
141
|
+
...newStrokeGeometry(node)
|
|
142
|
+
}))
|
|
143
|
+
delete boundVariables[`strokes/${index}/color`]
|
|
144
|
+
return { strokes: paints, boundVariables }
|
|
145
|
+
}
|
|
146
|
+
const { paints, index } = withSampledPaint<Fill>(node.fills, color, (paint) => paint)
|
|
147
|
+
delete boundVariables[`fills/${index}/color`]
|
|
148
|
+
const changes: Partial<SceneNode> = { fills: paints, boundVariables }
|
|
149
|
+
// Text colour lives in the node fills; per-character fills would hide the sample.
|
|
150
|
+
if (node.type === 'TEXT' && node.styleRuns.some((run) => run.style.fills)) {
|
|
151
|
+
changes.styleRuns = node.styleRuns.map((run) => {
|
|
152
|
+
const style = { ...run.style }
|
|
153
|
+
delete style.fills
|
|
154
|
+
return { ...run, style }
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
return changes
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface EyedropperEditor {
|
|
161
|
+
graph: SceneGraph
|
|
162
|
+
undo: UndoManager
|
|
163
|
+
state: { selectedIds: ReadonlySet<string> }
|
|
164
|
+
updateNodeWithUndo: (id: string, changes: Partial<SceneNode>, label?: string) => void
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Whether the changes would leave the layer as it is, as when it already has the colour. */
|
|
168
|
+
function changesNothing(node: SceneNode, changes: Partial<SceneNode>): boolean {
|
|
169
|
+
return Object.entries(changes).every(([key, value]) =>
|
|
170
|
+
isEqual(node[key as keyof SceneNode], value)
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Applies a sampled colour to every selected layer that can take a paint, as one undo step.
|
|
176
|
+
* Layers that already show it are left alone, so a sample that changes nothing records nothing.
|
|
177
|
+
* Returns how many layers changed.
|
|
178
|
+
*/
|
|
179
|
+
export function applySampledColor(
|
|
180
|
+
editor: EyedropperEditor,
|
|
181
|
+
color: Color,
|
|
182
|
+
target: EyedropperTarget = 'fill'
|
|
183
|
+
): number {
|
|
184
|
+
const nodes = [...editor.state.selectedIds]
|
|
185
|
+
.map((id) => editor.graph.getNode(id))
|
|
186
|
+
.filter((node): node is SceneNode => node !== undefined && !node.locked)
|
|
187
|
+
.filter((node) => node.type !== 'GROUP')
|
|
188
|
+
const edits = nodes
|
|
189
|
+
.map((node) => ({ node, changes: eyedropperChanges(node, color, target) }))
|
|
190
|
+
.filter(({ node, changes }) => !changesNothing(node, changes))
|
|
191
|
+
if (edits.length === 0) return 0
|
|
192
|
+
editor.undo.runBatch('Eyedropper', () => {
|
|
193
|
+
for (const { node, changes } of edits) {
|
|
194
|
+
editor.updateNodeWithUndo(node.id, changes, 'Eyedropper')
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
return edits.length
|
|
198
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
replaceDocumentFonts,
|
|
3
|
+
type FontReplacement,
|
|
4
|
+
type FontReplacementCounts
|
|
5
|
+
} from '#core/text/replace-fonts'
|
|
6
|
+
|
|
7
|
+
import { recordEdit } from './history/edit'
|
|
8
|
+
import type { EditorContext } from './types'
|
|
9
|
+
|
|
10
|
+
export function createFontActions(ctx: EditorContext) {
|
|
11
|
+
/** Replaces font faces across the document as one undoable step. */
|
|
12
|
+
function replaceFonts(replacements: readonly FontReplacement[]): FontReplacementCounts {
|
|
13
|
+
return recordEdit(ctx, { label: 'Replace fonts' }, () =>
|
|
14
|
+
replaceDocumentFonts(ctx.graph, replacements)
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return { replaceFonts }
|
|
19
|
+
}
|
|
@@ -46,7 +46,19 @@ export function executeAtomicTool(
|
|
|
46
46
|
figma: FigmaAPI,
|
|
47
47
|
def: ToolDef,
|
|
48
48
|
args: Record<string, unknown>,
|
|
49
|
-
options: {
|
|
49
|
+
options: {
|
|
50
|
+
signal?: AbortSignal
|
|
51
|
+
isLive?: () => boolean
|
|
52
|
+
label?: string
|
|
53
|
+
/**
|
|
54
|
+
* Judges the layer fields the call changed once it ran; an error it returns undoes the call
|
|
55
|
+
* and is thrown, as the document's design memory refuses an agent's off-system values.
|
|
56
|
+
*/
|
|
57
|
+
verify?: (
|
|
58
|
+
nodes: readonly FieldChanges<SceneNode>[],
|
|
59
|
+
variables: readonly FieldChanges<Variable>[]
|
|
60
|
+
) => Error | null
|
|
61
|
+
} = {}
|
|
50
62
|
): unknown {
|
|
51
63
|
if (!isAtomicTool(def)) throw new Error(`Not an atomic tool: ${def.name}`)
|
|
52
64
|
if (!resolveEditorProfile(editor.state).edits) throw new ReadOnlyDocumentError()
|
|
@@ -112,6 +124,7 @@ export function executeAtomicTool(
|
|
|
112
124
|
)
|
|
113
125
|
// Layout may change other layers too.
|
|
114
126
|
const nodeChanges = changes(checkpoint.changedNodes(), graph.nodes, nodeCount)
|
|
127
|
+
rejectRefused(options.verify, nodeChanges, variableChanges)
|
|
115
128
|
const contentChanged =
|
|
116
129
|
variableChanges.length > 0 ||
|
|
117
130
|
nodeChanges.some((change) => Object.keys(change.after).some((key) => key !== 'source'))
|
|
@@ -134,6 +147,21 @@ export function executeAtomicTool(
|
|
|
134
147
|
}
|
|
135
148
|
}
|
|
136
149
|
|
|
150
|
+
/** Throws the error `verify` judges the changes with, which undoes the call. */
|
|
151
|
+
function rejectRefused(
|
|
152
|
+
verify:
|
|
153
|
+
| ((
|
|
154
|
+
nodes: readonly FieldChanges<SceneNode>[],
|
|
155
|
+
variables: readonly FieldChanges<Variable>[]
|
|
156
|
+
) => Error | null)
|
|
157
|
+
| undefined,
|
|
158
|
+
nodes: readonly FieldChanges<SceneNode>[],
|
|
159
|
+
variables: readonly FieldChanges<Variable>[]
|
|
160
|
+
): void {
|
|
161
|
+
const refusal = verify ? verify(nodes, variables) : null
|
|
162
|
+
if (refusal) throw refusal
|
|
163
|
+
}
|
|
164
|
+
|
|
137
165
|
function layout(
|
|
138
166
|
graph: SceneGraph,
|
|
139
167
|
editor: MutationEditor,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SceneNode } from '@pairdraw/scene-graph'
|
|
2
|
+
import { cloneInstanceOverrideState } from '@pairdraw/scene-graph/instances/overrides'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A copy that keeps the layer's values as they are now. Values are replaced, never written into
|
|
6
|
+
* (`materialize-instance.ts` in `@pairdraw/fig`), so sharing them is safe; the graph edits
|
|
7
|
+
* child lists, source metadata, and override maps in place, so those are copied. It costs a few
|
|
8
|
+
* object spreads where a deep clone of the layer costs its whole value tree, which is what lets
|
|
9
|
+
* undo record thousands of layers.
|
|
10
|
+
*/
|
|
11
|
+
export function captureNode(node: SceneNode): SceneNode {
|
|
12
|
+
const { source, instanceOverrides } = node
|
|
13
|
+
return {
|
|
14
|
+
...node,
|
|
15
|
+
childIds: [...node.childIds],
|
|
16
|
+
source: { ...source, fig: { ...source.fig, rawNodeFields: { ...source.fig.rawNodeFields } } },
|
|
17
|
+
instanceOverrides: cloneInstanceOverrideState(instanceOverrides)
|
|
18
|
+
}
|
|
19
|
+
}
|