@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-tokens.d.ts","names":[],"sources":["../../src/editor/design-tokens.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"design-tokens.d.ts","names":[],"sources":["../../src/editor/design-tokens.ts"],"mappings":";;;;;;;;KAqBK,kBAAkB,kBAAkB;iBACzB,yBACd,KAAK,eACL,WAAW,iBACX,OAAO;EAwD2B,qBAAA,MAAA,oBAAkB;EAa3C,mBAAA,gBAAS,mBAAiB,UACvB,OAAO,eAAe,kBAC/B;EAkB4B,oBAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { applyTokenImport, styleNodeProps, styleNodeType } from "../io/formats/design-tokens/apply.js";
|
|
2
|
+
import { readTokenSources, tokenSourcesPluginData } from "@pairdraw/scene-graph/token-sources";
|
|
2
3
|
//#region src/editor/design-tokens.ts
|
|
3
4
|
function createDesignTokenActions(ctx, variables, nodes) {
|
|
4
5
|
/** A new style node, which redo makes again with the same ids so layers stay attached. */
|
|
@@ -54,7 +55,35 @@ function createDesignTokenActions(ctx, variables, nodes) {
|
|
|
54
55
|
return result;
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Brings linked code in as one undo step: the imports in order, then the document's links as
|
|
60
|
+
* `sources` gives them once the imports are applied, so undo takes back both.
|
|
61
|
+
*/
|
|
62
|
+
function syncDesignTokens(plans, sources) {
|
|
63
|
+
return ctx.undo.runBatch("Sync design tokens", () => {
|
|
64
|
+
const results = plans.map((plan) => applyTokenImport({
|
|
65
|
+
...target,
|
|
66
|
+
graph: ctx.graph
|
|
67
|
+
}, plan));
|
|
68
|
+
writeTokenSources(sources(ctx.graph), "Sync design tokens");
|
|
69
|
+
ctx.requestRender();
|
|
70
|
+
return results;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function writeTokenSources(sources, label) {
|
|
74
|
+
nodes.updateNodeWithUndo(ctx.graph.rootId, { pluginData: tokenSourcesPluginData(ctx.graph, sources) }, label);
|
|
75
|
+
}
|
|
76
|
+
/** Forgets a link to code; the variables it brought in stay. */
|
|
77
|
+
function unlinkTokenSource(id) {
|
|
78
|
+
const sources = readTokenSources(ctx.graph);
|
|
79
|
+
if (!sources.some((source) => source.id === id)) return;
|
|
80
|
+
writeTokenSources(sources.filter((source) => source.id !== id), "Unlink code");
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
importDesignTokens,
|
|
84
|
+
syncDesignTokens,
|
|
85
|
+
unlinkTokenSource
|
|
86
|
+
};
|
|
58
87
|
}
|
|
59
88
|
//#endregion
|
|
60
89
|
export { createDesignTokenActions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-tokens.js","names":[],"sources":["../../src/editor/design-tokens.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\n\n// Not the format's barrel: the editor always loads this file, and the exporter is loaded on demand.\nimport {\n applyTokenImport,\n styleNodeProps,\n styleNodeType,\n type TokenImportResult,\n type TokenImportTarget\n} from '#core/io/formats/design-tokens/apply'\nimport type { TokenImportPlan } from '#core/io/formats/design-tokens/plan'\n\nimport type { NodeActions } from './nodes'\nimport type { EditorContext } from './types'\nimport type { createVariableActions } from './variables'\n\ntype VariableActions = ReturnType<typeof createVariableActions>\nexport function createDesignTokenActions(\n ctx: EditorContext,\n variables: VariableActions,\n nodes: NodeActions\n) {\n /** A new style node, which redo makes again with the same ids so layers stay attached. */\n function addStyle(\n style: Parameters<TokenImportTarget['addStyle']>[0],\n fields: Partial<SceneNode>\n ) {\n const node = ctx.graph.createNode(\n styleNodeType(style),\n ctx.state.currentPageId,\n styleNodeProps(style, fields)\n )\n node.source.id = crypto.randomUUID()\n const snapshot = structuredClone(node)\n const parentId = node.parentId\n ctx.undo.push({\n label: 'Add style',\n forward: () => {\n ctx.graph.createNodeWithId(snapshot.id, snapshot.type, parentId, structuredClone(snapshot))\n ctx.requestRender()\n },\n inverse: () => {\n ctx.graph.deleteNode(snapshot.id)\n ctx.requestRender()\n }\n })\n return node\n }\n\n /** The import's changes made through the editor's actions, each one undoable. */\n const target: Omit<TokenImportTarget, 'graph'> = {\n addCollection: (name) => {\n const collection = ctx.graph.createCollection(name)\n variables.addCollection(collection)\n return collection\n },\n addMode: (collectionId, name) => variables.addMode(collectionId, name),\n renameMode: (collectionId, modeId, name) => variables.renameMode(collectionId, modeId, name),\n setDefaultMode: (collectionId, modeId) => variables.setDefaultMode(collectionId, modeId),\n setModeCondition: (collectionId, modeId, condition) =>\n variables.setModeCondition(collectionId, modeId, condition),\n setModeAttribute: (collectionId, name) => variables.setModeAttribute(collectionId, name),\n addVariable: (planned, collectionId) => {\n const variable = ctx.graph.createVariable(planned.name, planned.type, collectionId)\n variables.addVariable(variable)\n return variable\n },\n setValue: (variableId, modeId, value) =>\n variables.updateVariableValue(variableId, modeId, value),\n setTokenFields: (variableId, fields) => variables.updateVariableToken(variableId, fields),\n addStyle,\n updateNode: (nodeId, changes) => nodes.updateNodeWithUndo(nodeId, changes, 'Update style'),\n bindVariable: (nodeId, field, variableId) => nodes.bindVariable(nodeId, field, variableId)\n }\n\n /** Applies an import plan as one undo step; nothing is deleted. */\n function importDesignTokens(plan: TokenImportPlan): TokenImportResult {\n return ctx.undo.runBatch('Import design tokens', () => {\n const result = applyTokenImport({ ...target, graph: ctx.graph }, plan)\n ctx.requestRender()\n return result\n })\n }\n\n return { importDesignTokens }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"design-tokens.js","names":[],"sources":["../../src/editor/design-tokens.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n readTokenSources,\n tokenSourcesPluginData,\n type TokenSource\n} from '@pairdraw/scene-graph/token-sources'\n\n// Not the format's barrel: the editor always loads this file, and the exporter is loaded on demand.\nimport {\n applyTokenImport,\n styleNodeProps,\n styleNodeType,\n type TokenImportResult,\n type TokenImportTarget\n} from '#core/io/formats/design-tokens/apply'\nimport type { TokenImportPlan } from '#core/io/formats/design-tokens/plan'\n\nimport type { NodeActions } from './nodes'\nimport type { EditorContext } from './types'\nimport type { createVariableActions } from './variables'\n\ntype VariableActions = ReturnType<typeof createVariableActions>\nexport function createDesignTokenActions(\n ctx: EditorContext,\n variables: VariableActions,\n nodes: NodeActions\n) {\n /** A new style node, which redo makes again with the same ids so layers stay attached. */\n function addStyle(\n style: Parameters<TokenImportTarget['addStyle']>[0],\n fields: Partial<SceneNode>\n ) {\n const node = ctx.graph.createNode(\n styleNodeType(style),\n ctx.state.currentPageId,\n styleNodeProps(style, fields)\n )\n node.source.id = crypto.randomUUID()\n const snapshot = structuredClone(node)\n const parentId = node.parentId\n ctx.undo.push({\n label: 'Add style',\n forward: () => {\n ctx.graph.createNodeWithId(snapshot.id, snapshot.type, parentId, structuredClone(snapshot))\n ctx.requestRender()\n },\n inverse: () => {\n ctx.graph.deleteNode(snapshot.id)\n ctx.requestRender()\n }\n })\n return node\n }\n\n /** The import's changes made through the editor's actions, each one undoable. */\n const target: Omit<TokenImportTarget, 'graph'> = {\n addCollection: (name) => {\n const collection = ctx.graph.createCollection(name)\n variables.addCollection(collection)\n return collection\n },\n addMode: (collectionId, name) => variables.addMode(collectionId, name),\n renameMode: (collectionId, modeId, name) => variables.renameMode(collectionId, modeId, name),\n setDefaultMode: (collectionId, modeId) => variables.setDefaultMode(collectionId, modeId),\n setModeCondition: (collectionId, modeId, condition) =>\n variables.setModeCondition(collectionId, modeId, condition),\n setModeAttribute: (collectionId, name) => variables.setModeAttribute(collectionId, name),\n addVariable: (planned, collectionId) => {\n const variable = ctx.graph.createVariable(planned.name, planned.type, collectionId)\n variables.addVariable(variable)\n return variable\n },\n setValue: (variableId, modeId, value) =>\n variables.updateVariableValue(variableId, modeId, value),\n setTokenFields: (variableId, fields) => variables.updateVariableToken(variableId, fields),\n addStyle,\n updateNode: (nodeId, changes) => nodes.updateNodeWithUndo(nodeId, changes, 'Update style'),\n bindVariable: (nodeId, field, variableId) => nodes.bindVariable(nodeId, field, variableId)\n }\n\n /** Applies an import plan as one undo step; nothing is deleted. */\n function importDesignTokens(plan: TokenImportPlan): TokenImportResult {\n return ctx.undo.runBatch('Import design tokens', () => {\n const result = applyTokenImport({ ...target, graph: ctx.graph }, plan)\n ctx.requestRender()\n return result\n })\n }\n\n /**\n * Brings linked code in as one undo step: the imports in order, then the document's links as\n * `sources` gives them once the imports are applied, so undo takes back both.\n */\n function syncDesignTokens(\n plans: readonly TokenImportPlan[],\n sources: (graph: SceneGraph) => TokenSource[]\n ): TokenImportResult[] {\n return ctx.undo.runBatch('Sync design tokens', () => {\n const results = plans.map((plan) => applyTokenImport({ ...target, graph: ctx.graph }, plan))\n writeTokenSources(sources(ctx.graph), 'Sync design tokens')\n ctx.requestRender()\n return results\n })\n }\n\n function writeTokenSources(sources: readonly TokenSource[], label: string) {\n nodes.updateNodeWithUndo(\n ctx.graph.rootId,\n { pluginData: tokenSourcesPluginData(ctx.graph, sources) },\n label\n )\n }\n\n /** Forgets a link to code; the variables it brought in stay. */\n function unlinkTokenSource(id: string) {\n const sources = readTokenSources(ctx.graph)\n if (!sources.some((source) => source.id === id)) return\n writeTokenSources(\n sources.filter((source) => source.id !== id),\n 'Unlink code'\n )\n }\n\n return { importDesignTokens, syncDesignTokens, unlinkTokenSource }\n}\n"],"mappings":";;;AAsBA,SAAgB,yBACd,KACA,WACA,OACA;;CAEA,SAAS,SACP,OACA,QACA;EACA,MAAM,OAAO,IAAI,MAAM,WACrB,cAAc,KAAK,GACnB,IAAI,MAAM,eACV,eAAe,OAAO,MAAM,CAC9B;EACA,KAAK,OAAO,KAAK,OAAO,WAAW;EACnC,MAAM,WAAW,gBAAgB,IAAI;EACrC,MAAM,WAAW,KAAK;EACtB,IAAI,KAAK,KAAK;GACZ,OAAO;GACP,eAAe;IACb,IAAI,MAAM,iBAAiB,SAAS,IAAI,SAAS,MAAM,UAAU,gBAAgB,QAAQ,CAAC;IAC1F,IAAI,cAAc;GACpB;GACA,eAAe;IACb,IAAI,MAAM,WAAW,SAAS,EAAE;IAChC,IAAI,cAAc;GACpB;EACF,CAAC;EACD,OAAO;CACT;;CAGA,MAAM,SAA2C;EAC/C,gBAAgB,SAAS;GACvB,MAAM,aAAa,IAAI,MAAM,iBAAiB,IAAI;GAClD,UAAU,cAAc,UAAU;GAClC,OAAO;EACT;EACA,UAAU,cAAc,SAAS,UAAU,QAAQ,cAAc,IAAI;EACrE,aAAa,cAAc,QAAQ,SAAS,UAAU,WAAW,cAAc,QAAQ,IAAI;EAC3F,iBAAiB,cAAc,WAAW,UAAU,eAAe,cAAc,MAAM;EACvF,mBAAmB,cAAc,QAAQ,cACvC,UAAU,iBAAiB,cAAc,QAAQ,SAAS;EAC5D,mBAAmB,cAAc,SAAS,UAAU,iBAAiB,cAAc,IAAI;EACvF,cAAc,SAAS,iBAAiB;GACtC,MAAM,WAAW,IAAI,MAAM,eAAe,QAAQ,MAAM,QAAQ,MAAM,YAAY;GAClF,UAAU,YAAY,QAAQ;GAC9B,OAAO;EACT;EACA,WAAW,YAAY,QAAQ,UAC7B,UAAU,oBAAoB,YAAY,QAAQ,KAAK;EACzD,iBAAiB,YAAY,WAAW,UAAU,oBAAoB,YAAY,MAAM;EACxF;EACA,aAAa,QAAQ,YAAY,MAAM,mBAAmB,QAAQ,SAAS,cAAc;EACzF,eAAe,QAAQ,OAAO,eAAe,MAAM,aAAa,QAAQ,OAAO,UAAU;CAC3F;;CAGA,SAAS,mBAAmB,MAA0C;EACpE,OAAO,IAAI,KAAK,SAAS,8BAA8B;GACrD,MAAM,SAAS,iBAAiB;IAAE,GAAG;IAAQ,OAAO,IAAI;GAAM,GAAG,IAAI;GACrE,IAAI,cAAc;GAClB,OAAO;EACT,CAAC;CACH;;;;;CAMA,SAAS,iBACP,OACA,SACqB;EACrB,OAAO,IAAI,KAAK,SAAS,4BAA4B;GACnD,MAAM,UAAU,MAAM,KAAK,SAAS,iBAAiB;IAAE,GAAG;IAAQ,OAAO,IAAI;GAAM,GAAG,IAAI,CAAC;GAC3F,kBAAkB,QAAQ,IAAI,KAAK,GAAG,oBAAoB;GAC1D,IAAI,cAAc;GAClB,OAAO;EACT,CAAC;CACH;CAEA,SAAS,kBAAkB,SAAiC,OAAe;EACzE,MAAM,mBACJ,IAAI,MAAM,QACV,EAAE,YAAY,uBAAuB,IAAI,OAAO,OAAO,EAAE,GACzD,KACF;CACF;;CAGA,SAAS,kBAAkB,IAAY;EACrC,MAAM,UAAU,iBAAiB,IAAI,KAAK;EAC1C,IAAI,CAAC,QAAQ,MAAM,WAAW,OAAO,OAAO,EAAE,GAAG;EACjD,kBACE,QAAQ,QAAQ,WAAW,OAAO,OAAO,EAAE,GAC3C,aACF;CACF;CAEA,OAAO;EAAE;EAAoB;EAAkB;CAAkB;AACnE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
2
|
+
import { Color } from "@pairdraw/scene-graph/primitives";
|
|
3
|
+
//#region src/editor/document-colors.d.ts
|
|
4
|
+
/** A solid colour the page uses, and how many paints use it. */
|
|
5
|
+
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
|
+
/** How many colours the picker lists; Figma's document colours stop at a screenful too. */
|
|
11
|
+
declare const DOCUMENT_COLOR_LIMIT = 48;
|
|
12
|
+
/**
|
|
13
|
+
* The solid fills and strokes a page's visible layers use, most used first.
|
|
14
|
+
*
|
|
15
|
+
* One pass over the page tree. A hidden layer takes its whole subtree with it. Paints bound to a
|
|
16
|
+
* variable or covered by a colour style are left to the variable/style sections instead. Gradient,
|
|
17
|
+
* image, mesh, pattern, noise, video and custom paints are not listed: this list is for reusing a
|
|
18
|
+
* solid colour, not for its stops.
|
|
19
|
+
*/
|
|
20
|
+
declare function documentColors(graph: SceneGraph, pageId: string): DocumentColor[];
|
|
21
|
+
//#endregion
|
|
22
|
+
export { DOCUMENT_COLOR_LIMIT, DocumentColor, documentColors };
|
|
23
|
+
//# sourceMappingURL=document-colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-colors.d.ts","names":[],"sources":["../../src/editor/document-colors.ts"],"mappings":";;;;UAIiB;EACf,OAAO;;EAEP;;;cAIW;;;;;;;;;iBAeG,eAAe,OAAO,YAAY,iBAAiB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region src/editor/document-colors.ts
|
|
2
|
+
/** How many colours the picker lists; Figma's document colours stop at a screenful too. */
|
|
3
|
+
const DOCUMENT_COLOR_LIMIT = 48;
|
|
4
|
+
/** The RGBA as a map key; colours are kept exact, alpha included. */
|
|
5
|
+
function colorKey(color) {
|
|
6
|
+
return `${color.r},${color.g},${color.b},${color.a}`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The solid fills and strokes a page's visible layers use, most used first.
|
|
10
|
+
*
|
|
11
|
+
* One pass over the page tree. A hidden layer takes its whole subtree with it. Paints bound to a
|
|
12
|
+
* variable or covered by a colour style are left to the variable/style sections instead. Gradient,
|
|
13
|
+
* image, mesh, pattern, noise, video and custom paints are not listed: this list is for reusing a
|
|
14
|
+
* solid colour, not for its stops.
|
|
15
|
+
*/
|
|
16
|
+
function documentColors(graph, pageId) {
|
|
17
|
+
const colors = /* @__PURE__ */ new Map();
|
|
18
|
+
const count = (color) => {
|
|
19
|
+
const key = colorKey(color);
|
|
20
|
+
const entry = colors.get(key);
|
|
21
|
+
if (entry) entry.count++;
|
|
22
|
+
else colors.set(key, {
|
|
23
|
+
color: {
|
|
24
|
+
r: color.r,
|
|
25
|
+
g: color.g,
|
|
26
|
+
b: color.b,
|
|
27
|
+
a: color.a
|
|
28
|
+
},
|
|
29
|
+
count: 1
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const isBound = (node, path) => Object.hasOwn(node.boundVariables, path);
|
|
33
|
+
const walk = (node) => {
|
|
34
|
+
if (!node.visible) return;
|
|
35
|
+
if (!node.fillStyleId) node.fills.forEach((fill, index) => {
|
|
36
|
+
if (fill.visible && fill.type === "SOLID" && !isBound(node, `fills/${index}/color`)) count(fill.color);
|
|
37
|
+
});
|
|
38
|
+
if (!node.strokeStyleId) node.strokes.forEach((stroke, index) => {
|
|
39
|
+
if (stroke.visible && stroke.type === "SOLID" && !isBound(node, `strokes/${index}/color`)) count(stroke.color);
|
|
40
|
+
});
|
|
41
|
+
for (const childId of node.childIds) {
|
|
42
|
+
const child = graph.getNode(childId);
|
|
43
|
+
if (child) walk(child);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const page = graph.getNode(pageId);
|
|
47
|
+
if (page) walk(page);
|
|
48
|
+
return [...colors.values()].sort((a, b) => b.count - a.count || colorKey(a.color).localeCompare(colorKey(b.color))).slice(0, 48);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { DOCUMENT_COLOR_LIMIT, documentColors };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=document-colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-colors.js","names":[],"sources":["../../src/editor/document-colors.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\n/** A solid colour the page uses, and how many paints use it. */\nexport interface DocumentColor {\n color: Color\n /** Fill and stroke paints with this exact RGBA, across the page's visible layers. */\n count: number\n}\n\n/** How many colours the picker lists; Figma's document colours stop at a screenful too. */\nexport const DOCUMENT_COLOR_LIMIT = 48\n\n/** The RGBA as a map key; colours are kept exact, alpha included. */\nfunction colorKey(color: Color): string {\n return `${color.r},${color.g},${color.b},${color.a}`\n}\n\n/**\n * The solid fills and strokes a page's visible layers use, most used first.\n *\n * One pass over the page tree. A hidden layer takes its whole subtree with it. Paints bound to a\n * variable or covered by a colour style are left to the variable/style sections instead. Gradient,\n * image, mesh, pattern, noise, video and custom paints are not listed: this list is for reusing a\n * solid colour, not for its stops.\n */\nexport function documentColors(graph: SceneGraph, pageId: string): DocumentColor[] {\n const colors = new Map<string, DocumentColor>()\n\n const count = (color: Color) => {\n const key = colorKey(color)\n const entry = colors.get(key)\n if (entry) entry.count++\n else colors.set(key, { color: { r: color.r, g: color.g, b: color.b, a: color.a }, count: 1 })\n }\n\n const isBound = (node: SceneNode, path: string) => Object.hasOwn(node.boundVariables, path)\n\n const walk = (node: SceneNode) => {\n if (!node.visible) return\n if (!node.fillStyleId) {\n node.fills.forEach((fill, index) => {\n if (fill.visible && fill.type === 'SOLID' && !isBound(node, `fills/${index}/color`))\n count(fill.color)\n })\n }\n if (!node.strokeStyleId) {\n node.strokes.forEach((stroke, index) => {\n if (stroke.visible && stroke.type === 'SOLID' && !isBound(node, `strokes/${index}/color`))\n count(stroke.color)\n })\n }\n for (const childId of node.childIds) {\n const child = graph.getNode(childId)\n if (child) walk(child)\n }\n }\n\n const page = graph.getNode(pageId)\n if (page) walk(page)\n\n return [...colors.values()]\n .sort((a, b) => b.count - a.count || colorKey(a.color).localeCompare(colorKey(b.color)))\n .slice(0, DOCUMENT_COLOR_LIMIT)\n}\n"],"mappings":";;AAWA,MAAa,uBAAuB;;AAGpC,SAAS,SAAS,OAAsB;CACtC,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM;AACnD;;;;;;;;;AAUA,SAAgB,eAAe,OAAmB,QAAiC;CACjF,MAAM,yBAAS,IAAI,IAA2B;CAE9C,MAAM,SAAS,UAAiB;EAC9B,MAAM,MAAM,SAAS,KAAK;EAC1B,MAAM,QAAQ,OAAO,IAAI,GAAG;EAC5B,IAAI,OAAO,MAAM;OACZ,OAAO,IAAI,KAAK;GAAE,OAAO;IAAE,GAAG,MAAM;IAAG,GAAG,MAAM;IAAG,GAAG,MAAM;IAAG,GAAG,MAAM;GAAE;GAAG,OAAO;EAAE,CAAC;CAC9F;CAEA,MAAM,WAAW,MAAiB,SAAiB,OAAO,OAAO,KAAK,gBAAgB,IAAI;CAE1F,MAAM,QAAQ,SAAoB;EAChC,IAAI,CAAC,KAAK,SAAS;EACnB,IAAI,CAAC,KAAK,aACR,KAAK,MAAM,SAAS,MAAM,UAAU;GAClC,IAAI,KAAK,WAAW,KAAK,SAAS,WAAW,CAAC,QAAQ,MAAM,SAAS,MAAM,OAAO,GAChF,MAAM,KAAK,KAAK;EACpB,CAAC;EAEH,IAAI,CAAC,KAAK,eACR,KAAK,QAAQ,SAAS,QAAQ,UAAU;GACtC,IAAI,OAAO,WAAW,OAAO,SAAS,WAAW,CAAC,QAAQ,MAAM,WAAW,MAAM,OAAO,GACtF,MAAM,OAAO,KAAK;EACtB,CAAC;EAEH,KAAK,MAAM,WAAW,KAAK,UAAU;GACnC,MAAM,QAAQ,MAAM,QAAQ,OAAO;GACnC,IAAI,OAAO,KAAK,KAAK;EACvB;CACF;CAEA,MAAM,OAAO,MAAM,QAAQ,MAAM;CACjC,IAAI,MAAM,KAAK,IAAI;CAEnB,OAAO,CAAC,GAAG,OAAO,OAAO,CAAC,CAAC,CACxB,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,SAAS,SAAS,EAAE,KAAK,CAAC,CAAC,cAAc,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CACvF,MAAM,GAAA,EAAuB;AAClC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SkiaRenderer } from "../canvas/renderer.js";
|
|
2
|
+
import { CanvasKit } from "canvaskit-wasm";
|
|
3
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
4
|
+
import { UndoManager } from "@pairdraw/scene-graph/undo";
|
|
5
|
+
import { Color as Color$1 } from "@pairdraw/scene-graph/primitives";
|
|
6
|
+
//#region src/editor/eyedropper.d.ts
|
|
7
|
+
/** Which paint of the selection a sampled colour replaces. Alt samples into the stroke. */
|
|
8
|
+
type EyedropperTarget = 'fill' | 'stroke';
|
|
9
|
+
type SampleRenderer = Pick<SkiaRenderer, 'worldViewport' | 'viewportImageRendering' | 'presentationColorSpace' | 'renderNode'>;
|
|
10
|
+
/** A square of the document's pixels: RGBA rows, `size` pixels a side, the centre one sampled. */
|
|
11
|
+
interface ScenePixels {
|
|
12
|
+
size: number;
|
|
13
|
+
data: Uint8Array;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The document's pixels in a square of `size` (odd) pixels centred on a world point, each
|
|
17
|
+
* `1 / scale` world units wide, composited over the page background, so at the view's zoom they
|
|
18
|
+
* are the pixels the screen shows there.
|
|
19
|
+
*
|
|
20
|
+
* Renders only what intersects the square into a raster surface, so selection chrome, rulers and
|
|
21
|
+
* the screen's colour profile never leak into the result, unlike `window.EyeDropper`, which
|
|
22
|
+
* samples the screen. Components come back in the document's own colour space: the renderer
|
|
23
|
+
* presents in that space and the surface is not converted.
|
|
24
|
+
*/
|
|
25
|
+
declare function sampleScenePixels(ck: CanvasKit, renderer: SampleRenderer, graph: SceneGraph, pageId: string, x: number, y: number, size?: number, scale?: number): ScenePixels | null;
|
|
26
|
+
/** The opaque colour of one pixel of a sample, by column and row. */
|
|
27
|
+
declare function scenePixelColor(pixels: ScenePixels, column: number, row: number): Color$1;
|
|
28
|
+
/** The colour the document shows at a world point, one `1 / scale`-wide pixel of it. */
|
|
29
|
+
declare function sampleSceneColor(ck: CanvasKit, renderer: SampleRenderer, graph: SceneGraph, pageId: string, x: number, y: number, scale?: number): Color$1 | null;
|
|
30
|
+
declare function eyedropperChanges(node: SceneNode, color: Color$1, target: EyedropperTarget): Partial<SceneNode>;
|
|
31
|
+
interface EyedropperEditor {
|
|
32
|
+
graph: SceneGraph;
|
|
33
|
+
undo: UndoManager;
|
|
34
|
+
state: {
|
|
35
|
+
selectedIds: ReadonlySet<string>;
|
|
36
|
+
};
|
|
37
|
+
updateNodeWithUndo: (id: string, changes: Partial<SceneNode>, label?: string) => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Applies a sampled colour to every selected layer that can take a paint, as one undo step.
|
|
41
|
+
* Layers that already show it are left alone, so a sample that changes nothing records nothing.
|
|
42
|
+
* Returns how many layers changed.
|
|
43
|
+
*/
|
|
44
|
+
declare function applySampledColor(editor: EyedropperEditor, color: Color$1, target?: EyedropperTarget): number;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { EyedropperTarget, ScenePixels, applySampledColor, eyedropperChanges, sampleSceneColor, sampleScenePixels, scenePixelColor };
|
|
47
|
+
//# sourceMappingURL=eyedropper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eyedropper.d.ts","names":[],"sources":["../../src/editor/eyedropper.ts"],"mappings":";;;;;;;KAYY;KAEP,iBAAiB,KACpB;;UAKe;EACf;EACA,MAAM;;;;;;;;;;;;iBAaQ,kBACd,IAAI,WACJ,UAAU,gBACV,OAAO,YACP,gBACA,WACA,WACA,eACA,iBACC;;iBA2Ca,gBAAgB,QAAQ,aAAa,gBAAgB,cAAc;;iBAOnE,iBACd,IAAI,WACJ,UAAU,gBACV,OAAO,YACP,gBACA,WACA,WACA,iBACC;iBA4Ba,kBACd,MAAM,WACN,OAAO,SACP,QAAQ,mBACP,QAAQ;UAyBD;EACR,OAAO;EACP,MAAM;EACN;IAAS,aAAa;;EACtB,qBAAqB,YAAY,SAAS,QAAQ,YAAY;;;;;;;iBAehD,kBACd,QAAQ,kBACR,OAAO,SACP,SAAQ"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { getPageColor } from "../figma-api/page-backgrounds.js";
|
|
2
|
+
import { isEqual } from "es-toolkit";
|
|
3
|
+
import { newStrokeGeometry } from "@pairdraw/scene-graph/node-defaults";
|
|
4
|
+
//#region src/editor/eyedropper.ts
|
|
5
|
+
/**
|
|
6
|
+
* The document's pixels in a square of `size` (odd) pixels centred on a world point, each
|
|
7
|
+
* `1 / scale` world units wide, composited over the page background, so at the view's zoom they
|
|
8
|
+
* are the pixels the screen shows there.
|
|
9
|
+
*
|
|
10
|
+
* Renders only what intersects the square into a raster surface, so selection chrome, rulers and
|
|
11
|
+
* the screen's colour profile never leak into the result, unlike `window.EyeDropper`, which
|
|
12
|
+
* samples the screen. Components come back in the document's own colour space: the renderer
|
|
13
|
+
* presents in that space and the surface is not converted.
|
|
14
|
+
*/
|
|
15
|
+
function sampleScenePixels(ck, renderer, graph, pageId, x, y, size = 1, scale = 1) {
|
|
16
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return null;
|
|
17
|
+
if (!Number.isInteger(size) || size < 1 || size % 2 === 0 || !(scale > 0)) return null;
|
|
18
|
+
const page = graph.getNode(pageId);
|
|
19
|
+
if (!page) return null;
|
|
20
|
+
const surface = ck.MakeSurface(size, size);
|
|
21
|
+
if (!surface) return null;
|
|
22
|
+
const previousViewport = renderer.worldViewport;
|
|
23
|
+
const previousImageRendering = renderer.viewportImageRendering;
|
|
24
|
+
const previousColorSpace = renderer.presentationColorSpace;
|
|
25
|
+
try {
|
|
26
|
+
const canvas = surface.getCanvas();
|
|
27
|
+
const background = getPageColor(page);
|
|
28
|
+
canvas.clear(ck.Color4f(background.r, background.g, background.b, 1));
|
|
29
|
+
const half = (size - 1) / 2;
|
|
30
|
+
canvas.translate(half + .5, half + .5);
|
|
31
|
+
canvas.scale(scale, scale);
|
|
32
|
+
canvas.translate(-x, -y);
|
|
33
|
+
const reach = (half + 1) / scale;
|
|
34
|
+
renderer.worldViewport = {
|
|
35
|
+
x: x - reach,
|
|
36
|
+
y: y - reach,
|
|
37
|
+
w: reach * 2,
|
|
38
|
+
h: reach * 2
|
|
39
|
+
};
|
|
40
|
+
renderer.viewportImageRendering = false;
|
|
41
|
+
renderer.presentationColorSpace = graph.documentColorSpace;
|
|
42
|
+
for (const childId of page.childIds) renderer.renderNode(canvas, graph, childId, {});
|
|
43
|
+
surface.flush();
|
|
44
|
+
const data = canvas.readPixels(0, 0, {
|
|
45
|
+
width: size,
|
|
46
|
+
height: size,
|
|
47
|
+
alphaType: ck.AlphaType.Unpremul,
|
|
48
|
+
colorType: ck.ColorType.RGBA_8888,
|
|
49
|
+
colorSpace: ck.ColorSpace.SRGB
|
|
50
|
+
});
|
|
51
|
+
if (!(data instanceof Uint8Array) || data.length < size * size * 4) return null;
|
|
52
|
+
return {
|
|
53
|
+
size,
|
|
54
|
+
data
|
|
55
|
+
};
|
|
56
|
+
} finally {
|
|
57
|
+
renderer.worldViewport = previousViewport;
|
|
58
|
+
renderer.viewportImageRendering = previousImageRendering;
|
|
59
|
+
renderer.presentationColorSpace = previousColorSpace;
|
|
60
|
+
surface.dispose();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** The opaque colour of one pixel of a sample, by column and row. */
|
|
64
|
+
function scenePixelColor(pixels, column, row) {
|
|
65
|
+
const at = (row * pixels.size + column) * 4;
|
|
66
|
+
const { data } = pixels;
|
|
67
|
+
return {
|
|
68
|
+
r: data[at] / 255,
|
|
69
|
+
g: data[at + 1] / 255,
|
|
70
|
+
b: data[at + 2] / 255,
|
|
71
|
+
a: 1
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** The colour the document shows at a world point, one `1 / scale`-wide pixel of it. */
|
|
75
|
+
function sampleSceneColor(ck, renderer, graph, pageId, x, y, scale = 1) {
|
|
76
|
+
const pixels = sampleScenePixels(ck, renderer, graph, pageId, x, y, 1, scale);
|
|
77
|
+
return pixels ? scenePixelColor(pixels, 0, 0) : null;
|
|
78
|
+
}
|
|
79
|
+
function solidPaint(color) {
|
|
80
|
+
return {
|
|
81
|
+
type: "SOLID",
|
|
82
|
+
color: {
|
|
83
|
+
...color,
|
|
84
|
+
a: 1
|
|
85
|
+
},
|
|
86
|
+
opacity: 1,
|
|
87
|
+
visible: true
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Replaces the top solid paint's colour, keeping its opacity, or adds an opaque solid paint. A
|
|
92
|
+
* solid paint's alpha is its opacity, as the colour picker writes them, so the alpha stays too.
|
|
93
|
+
*/
|
|
94
|
+
function withSampledPaint(paints, color, create) {
|
|
95
|
+
const next = paints.map((paint) => ({ ...paint }));
|
|
96
|
+
for (let index = next.length - 1; index >= 0; index--) {
|
|
97
|
+
if (next[index].type !== "SOLID") continue;
|
|
98
|
+
next[index] = {
|
|
99
|
+
...next[index],
|
|
100
|
+
color: {
|
|
101
|
+
...color,
|
|
102
|
+
a: next[index].color.a
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
paints: next,
|
|
107
|
+
index
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
next.push(create(solidPaint(color)));
|
|
111
|
+
return {
|
|
112
|
+
paints: next,
|
|
113
|
+
index: next.length - 1
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function eyedropperChanges(node, color, target) {
|
|
117
|
+
const boundVariables = { ...node.boundVariables };
|
|
118
|
+
if (target === "stroke") {
|
|
119
|
+
const { paints, index } = withSampledPaint(node.strokes, color, (paint) => ({
|
|
120
|
+
...paint,
|
|
121
|
+
...newStrokeGeometry(node)
|
|
122
|
+
}));
|
|
123
|
+
delete boundVariables[`strokes/${index}/color`];
|
|
124
|
+
return {
|
|
125
|
+
strokes: paints,
|
|
126
|
+
boundVariables
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const { paints, index } = withSampledPaint(node.fills, color, (paint) => paint);
|
|
130
|
+
delete boundVariables[`fills/${index}/color`];
|
|
131
|
+
const changes = {
|
|
132
|
+
fills: paints,
|
|
133
|
+
boundVariables
|
|
134
|
+
};
|
|
135
|
+
if (node.type === "TEXT" && node.styleRuns.some((run) => run.style.fills)) changes.styleRuns = node.styleRuns.map((run) => {
|
|
136
|
+
const style = { ...run.style };
|
|
137
|
+
delete style.fills;
|
|
138
|
+
return {
|
|
139
|
+
...run,
|
|
140
|
+
style
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
return changes;
|
|
144
|
+
}
|
|
145
|
+
/** Whether the changes would leave the layer as it is, as when it already has the colour. */
|
|
146
|
+
function changesNothing(node, changes) {
|
|
147
|
+
return Object.entries(changes).every(([key, value]) => isEqual(node[key], value));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Applies a sampled colour to every selected layer that can take a paint, as one undo step.
|
|
151
|
+
* Layers that already show it are left alone, so a sample that changes nothing records nothing.
|
|
152
|
+
* Returns how many layers changed.
|
|
153
|
+
*/
|
|
154
|
+
function applySampledColor(editor, color, target = "fill") {
|
|
155
|
+
const edits = [...editor.state.selectedIds].map((id) => editor.graph.getNode(id)).filter((node) => node !== void 0 && !node.locked).filter((node) => node.type !== "GROUP").map((node) => ({
|
|
156
|
+
node,
|
|
157
|
+
changes: eyedropperChanges(node, color, target)
|
|
158
|
+
})).filter(({ node, changes }) => !changesNothing(node, changes));
|
|
159
|
+
if (edits.length === 0) return 0;
|
|
160
|
+
editor.undo.runBatch("Eyedropper", () => {
|
|
161
|
+
for (const { node, changes } of edits) editor.updateNodeWithUndo(node.id, changes, "Eyedropper");
|
|
162
|
+
});
|
|
163
|
+
return edits.length;
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
export { applySampledColor, eyedropperChanges, sampleSceneColor, sampleScenePixels, scenePixelColor };
|
|
167
|
+
|
|
168
|
+
//# sourceMappingURL=eyedropper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eyedropper.js","names":[],"sources":["../../src/editor/eyedropper.ts"],"sourcesContent":["import type { CanvasKit } from 'canvaskit-wasm'\nimport { isEqual } from 'es-toolkit'\n\nimport type { Fill, SceneGraph, SceneNode, Stroke } from '@pairdraw/scene-graph'\nimport { newStrokeGeometry } from '@pairdraw/scene-graph/node-defaults'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\nimport type { UndoManager } from '@pairdraw/scene-graph/undo'\n\nimport type { SkiaRenderer } from '#core/canvas/renderer'\nimport { getPageColor } from '#core/figma-api/page-backgrounds'\n\n/** Which paint of the selection a sampled colour replaces. Alt samples into the stroke. */\nexport type EyedropperTarget = 'fill' | 'stroke'\n\ntype SampleRenderer = Pick<\n SkiaRenderer,\n 'worldViewport' | 'viewportImageRendering' | 'presentationColorSpace' | 'renderNode'\n>\n\n/** A square of the document's pixels: RGBA rows, `size` pixels a side, the centre one sampled. */\nexport interface ScenePixels {\n size: number\n data: Uint8Array\n}\n\n/**\n * The document's pixels in a square of `size` (odd) pixels centred on a world point, each\n * `1 / scale` world units wide, composited over the page background, so at the view's zoom they\n * are the pixels the screen shows there.\n *\n * Renders only what intersects the square into a raster surface, so selection chrome, rulers and\n * the screen's colour profile never leak into the result, unlike `window.EyeDropper`, which\n * samples the screen. Components come back in the document's own colour space: the renderer\n * presents in that space and the surface is not converted.\n */\nexport function sampleScenePixels(\n ck: CanvasKit,\n renderer: SampleRenderer,\n graph: SceneGraph,\n pageId: string,\n x: number,\n y: number,\n size = 1,\n scale = 1\n): ScenePixels | null {\n if (!Number.isFinite(x) || !Number.isFinite(y)) return null\n if (!Number.isInteger(size) || size < 1 || size % 2 === 0 || !(scale > 0)) return null\n const page = graph.getNode(pageId)\n if (!page) return null\n const surface = ck.MakeSurface(size, size)\n if (!surface) return null\n const previousViewport = renderer.worldViewport\n const previousImageRendering = renderer.viewportImageRendering\n const previousColorSpace = renderer.presentationColorSpace\n try {\n const canvas = surface.getCanvas()\n const background = getPageColor(page)\n canvas.clear(ck.Color4f(background.r, background.g, background.b, 1))\n // Pixel (i, j) covers [i, i + 1); put the sampled point at the centre pixel's centre.\n const half = (size - 1) / 2\n canvas.translate(half + 0.5, half + 0.5)\n canvas.scale(scale, scale)\n canvas.translate(-x, -y)\n const reach = (half + 1) / scale\n renderer.worldViewport = { x: x - reach, y: y - reach, w: reach * 2, h: reach * 2 }\n renderer.viewportImageRendering = false\n renderer.presentationColorSpace = graph.documentColorSpace\n for (const childId of page.childIds) renderer.renderNode(canvas, graph, childId, {})\n surface.flush()\n const data = canvas.readPixels(0, 0, {\n width: size,\n height: size,\n alphaType: ck.AlphaType.Unpremul,\n colorType: ck.ColorType.RGBA_8888,\n colorSpace: ck.ColorSpace.SRGB\n })\n if (!(data instanceof Uint8Array) || data.length < size * size * 4) return null\n return { size, data }\n } finally {\n renderer.worldViewport = previousViewport\n renderer.viewportImageRendering = previousImageRendering\n renderer.presentationColorSpace = previousColorSpace\n surface.dispose()\n }\n}\n\n/** The opaque colour of one pixel of a sample, by column and row. */\nexport function scenePixelColor(pixels: ScenePixels, column: number, row: number): Color {\n const at = (row * pixels.size + column) * 4\n const { data } = pixels\n return { r: data[at] / 255, g: data[at + 1] / 255, b: data[at + 2] / 255, a: 1 }\n}\n\n/** The colour the document shows at a world point, one `1 / scale`-wide pixel of it. */\nexport function sampleSceneColor(\n ck: CanvasKit,\n renderer: SampleRenderer,\n graph: SceneGraph,\n pageId: string,\n x: number,\n y: number,\n scale = 1\n): Color | null {\n const pixels = sampleScenePixels(ck, renderer, graph, pageId, x, y, 1, scale)\n return pixels ? scenePixelColor(pixels, 0, 0) : null\n}\n\nfunction solidPaint(color: Color): Fill {\n return { type: 'SOLID', color: { ...color, a: 1 }, opacity: 1, visible: true }\n}\n\n/**\n * Replaces the top solid paint's colour, keeping its opacity, or adds an opaque solid paint. A\n * solid paint's alpha is its opacity, as the colour picker writes them, so the alpha stays too.\n */\nfunction withSampledPaint<T extends Fill>(\n paints: readonly T[],\n color: Color,\n create: (paint: Fill) => T\n): { paints: T[]; index: number } {\n const next = paints.map((paint) => ({ ...paint }))\n for (let index = next.length - 1; index >= 0; index--) {\n if (next[index].type !== 'SOLID') continue\n next[index] = { ...next[index], color: { ...color, a: next[index].color.a } }\n return { paints: next, index }\n }\n next.push(create(solidPaint(color)))\n return { paints: next, index: next.length - 1 }\n}\n\nexport function eyedropperChanges(\n node: SceneNode,\n color: Color,\n target: EyedropperTarget\n): Partial<SceneNode> {\n const boundVariables = { ...node.boundVariables }\n if (target === 'stroke') {\n // A first stroke takes the weight and alignment the node keeps for its strokes.\n const { paints, index } = withSampledPaint<Stroke>(node.strokes, color, (paint) => ({\n ...paint,\n ...newStrokeGeometry(node)\n }))\n delete boundVariables[`strokes/${index}/color`]\n return { strokes: paints, boundVariables }\n }\n const { paints, index } = withSampledPaint<Fill>(node.fills, color, (paint) => paint)\n delete boundVariables[`fills/${index}/color`]\n const changes: Partial<SceneNode> = { fills: paints, boundVariables }\n // Text colour lives in the node fills; per-character fills would hide the sample.\n if (node.type === 'TEXT' && node.styleRuns.some((run) => run.style.fills)) {\n changes.styleRuns = node.styleRuns.map((run) => {\n const style = { ...run.style }\n delete style.fills\n return { ...run, style }\n })\n }\n return changes\n}\n\ninterface EyedropperEditor {\n graph: SceneGraph\n undo: UndoManager\n state: { selectedIds: ReadonlySet<string> }\n updateNodeWithUndo: (id: string, changes: Partial<SceneNode>, label?: string) => void\n}\n\n/** Whether the changes would leave the layer as it is, as when it already has the colour. */\nfunction changesNothing(node: SceneNode, changes: Partial<SceneNode>): boolean {\n return Object.entries(changes).every(([key, value]) =>\n isEqual(node[key as keyof SceneNode], value)\n )\n}\n\n/**\n * Applies a sampled colour to every selected layer that can take a paint, as one undo step.\n * Layers that already show it are left alone, so a sample that changes nothing records nothing.\n * Returns how many layers changed.\n */\nexport function applySampledColor(\n editor: EyedropperEditor,\n color: Color,\n target: EyedropperTarget = 'fill'\n): number {\n const nodes = [...editor.state.selectedIds]\n .map((id) => editor.graph.getNode(id))\n .filter((node): node is SceneNode => node !== undefined && !node.locked)\n .filter((node) => node.type !== 'GROUP')\n const edits = nodes\n .map((node) => ({ node, changes: eyedropperChanges(node, color, target) }))\n .filter(({ node, changes }) => !changesNothing(node, changes))\n if (edits.length === 0) return 0\n editor.undo.runBatch('Eyedropper', () => {\n for (const { node, changes } of edits) {\n editor.updateNodeWithUndo(node.id, changes, 'Eyedropper')\n }\n })\n return edits.length\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EditorContext } from "./types.js";
|
|
2
|
+
import { FontReplacement, FontReplacementCounts } from "../text/replace-fonts.js";
|
|
3
|
+
//#region src/editor/fonts.d.ts
|
|
4
|
+
declare function createFontActions(ctx: EditorContext): {
|
|
5
|
+
replaceFonts: (replacements: readonly FontReplacement[]) => FontReplacementCounts;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { createFontActions };
|
|
9
|
+
//# sourceMappingURL=fonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","names":[],"sources":["../../src/editor/fonts.ts"],"mappings":";;;iBASgB,kBAAkB,KAAK;EAED,eAAA,uBAAS,sBAAoB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { recordEdit } from "./history/edit.js";
|
|
2
|
+
import { replaceDocumentFonts } from "../text/replace-fonts.js";
|
|
3
|
+
//#region src/editor/fonts.ts
|
|
4
|
+
function createFontActions(ctx) {
|
|
5
|
+
/** Replaces font faces across the document as one undoable step. */
|
|
6
|
+
function replaceFonts(replacements) {
|
|
7
|
+
return recordEdit(ctx, { label: "Replace fonts" }, () => replaceDocumentFonts(ctx.graph, replacements));
|
|
8
|
+
}
|
|
9
|
+
return { replaceFonts };
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { createFontActions };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=fonts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.js","names":[],"sources":["../../src/editor/fonts.ts"],"sourcesContent":["import {\n replaceDocumentFonts,\n type FontReplacement,\n type FontReplacementCounts\n} from '#core/text/replace-fonts'\n\nimport { recordEdit } from './history/edit'\nimport type { EditorContext } from './types'\n\nexport function createFontActions(ctx: EditorContext) {\n /** Replaces font faces across the document as one undoable step. */\n function replaceFonts(replacements: readonly FontReplacement[]): FontReplacementCounts {\n return recordEdit(ctx, { label: 'Replace fonts' }, () =>\n replaceDocumentFonts(ctx.graph, replacements)\n )\n }\n\n return { replaceFonts }\n}\n"],"mappings":";;;AASA,SAAgB,kBAAkB,KAAoB;;CAEpD,SAAS,aAAa,cAAiE;EACrF,OAAO,WAAW,KAAK,EAAE,OAAO,gBAAgB,SAC9C,qBAAqB,IAAI,OAAO,YAAY,CAC9C;CACF;CAEA,OAAO,EAAE,aAAa;AACxB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { EditorProfileInputs } from "../views/types.js";
|
|
2
|
-
import "
|
|
3
|
-
import { Editor } from "../create.js";
|
|
2
|
+
import { FieldChanges } from "./diff.js";
|
|
4
3
|
import { FigmaAPI } from "../../figma-api/index.js";
|
|
5
4
|
import { ToolDef } from "../../tools/schema.js";
|
|
5
|
+
import "../views/index.js";
|
|
6
|
+
import { Editor } from "../create.js";
|
|
7
|
+
import { SceneNode, Variable } from "@pairdraw/scene-graph";
|
|
6
8
|
//#region src/editor/history/atomic-tool.d.ts
|
|
7
9
|
type MutationEditor = Pick<Editor, 'graph' | 'runLayoutForNode' | 'requestRender' | 'pushUndoStep'> & {
|
|
8
10
|
state: EditorProfileInputs;
|
|
@@ -16,6 +18,11 @@ declare function executeAtomicTool(editor: MutationEditor, figma: FigmaAPI, def:
|
|
|
16
18
|
signal?: AbortSignal;
|
|
17
19
|
isLive?: () => boolean;
|
|
18
20
|
label?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Judges the layer fields the call changed once it ran; an error it returns undoes the call
|
|
23
|
+
* and is thrown, as the document's design memory refuses an agent's off-system values.
|
|
24
|
+
*/
|
|
25
|
+
verify?: (nodes: readonly FieldChanges<SceneNode>[], variables: readonly FieldChanges<Variable>[]) => Error | null;
|
|
19
26
|
}): unknown;
|
|
20
27
|
//#endregion
|
|
21
28
|
export { executeAtomicTool };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomic-tool.d.ts","names":[],"sources":["../../../src/editor/history/atomic-tool.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"atomic-tool.d.ts","names":[],"sources":["../../../src/editor/history/atomic-tool.ts"],"mappings":";;;;;;;;KAcK,iBAAiB,KACpB;EAGA,OAAO;;;;;;;iBAyBO,kBACd,QAAQ,gBACR,OAAO,UACP,KAAK,SACL,MAAM,yBACN;EACE,SAAS;EACT;EACA;;;;;EAKA,UACE,gBAAgB,aAAa,cAC7B,oBAAoB,aAAa,gBAC9B"}
|
|
@@ -55,6 +55,7 @@ function executeAtomicTool(editor, figma, def, args, options = {}) {
|
|
|
55
55
|
const variableChanges = changes(variables, graph.variables);
|
|
56
56
|
layout(graph, editor, pageId, variableChanges.length > 0, changes(touched, graph.nodes, nodeCount).map((change) => change.id));
|
|
57
57
|
const nodeChanges = changes(checkpoint.changedNodes(), graph.nodes, nodeCount);
|
|
58
|
+
rejectRefused(options.verify, nodeChanges, variableChanges);
|
|
58
59
|
const contentChanged = variableChanges.length > 0 || nodeChanges.some((change) => Object.keys(change.after).some((key) => key !== "source"));
|
|
59
60
|
if (!contentChanged && nodeChanges.length) replay(nodeChanges, [], "before");
|
|
60
61
|
if (contentChanged) {
|
|
@@ -74,6 +75,11 @@ function executeAtomicTool(editor, figma, def, args, options = {}) {
|
|
|
74
75
|
checkpoint.release();
|
|
75
76
|
}
|
|
76
77
|
}
|
|
78
|
+
/** Throws the error `verify` judges the changes with, which undoes the call. */
|
|
79
|
+
function rejectRefused(verify, nodes, variables) {
|
|
80
|
+
const refusal = verify ? verify(nodes, variables) : null;
|
|
81
|
+
if (refusal) throw refusal;
|
|
82
|
+
}
|
|
77
83
|
function layout(graph, editor, pageId, allPages, changedIds) {
|
|
78
84
|
const scopes = new Set(allPages ? graph.getPages().map((page) => page.id) : [pageId]);
|
|
79
85
|
for (const id of changedIds) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomic-tool.js","names":[],"sources":["../../../src/editor/history/atomic-tool.ts"],"sourcesContent":["import type { SceneGraph, SceneNode, Variable } from '@pairdraw/scene-graph'\nimport { captureEditCheckpoint } from '@pairdraw/scene-graph/checkpoint'\n\nimport type { Editor } from '#core/editor/create'\nimport { ReadOnlyDocumentError } from '#core/editor/read-only'\nimport { resolveEditorProfile, type EditorProfileInputs } from '#core/editor/views'\nimport type { FigmaAPI } from '#core/figma-api'\nimport { isAtomicTool, type ToolDef } from '#core/tools/schema'\n\nimport { diffFields, type FieldChanges } from './diff'\n\n// Capture property changes across pages. Component synchronization remains editor-owned.\nconst MAX_TRANSACTION_NODES = 10_000\n\ntype MutationEditor = Pick<\n Editor,\n 'graph' | 'runLayoutForNode' | 'requestRender' | 'pushUndoStep'\n> & {\n state: EditorProfileInputs\n}\n\nfunction changes<T extends object>(\n before: Map<string, T>,\n after: Map<string, T>,\n expectedSize = before.size\n): FieldChanges<T>[] {\n const result: FieldChanges<T>[] = []\n for (const [id, previous] of before) {\n const current = after.get(id)\n if (!current) throw new Error('Atomic tools must not remove nodes or variables')\n const change = diffFields(id, previous, current)\n if (change) result.push(change)\n }\n if (after.size !== expectedSize)\n throw new Error('Atomic tools must not create nodes or variables')\n return result\n}\n\n/**\n * No await is permitted between snapshot and commit. Browser events, other agents and\n * cancellation cannot interleave with this bounded transaction. Async tools use their\n * existing execution path and are not exposed through WebMCP.\n */\nexport function executeAtomicTool(\n editor: MutationEditor,\n figma: FigmaAPI,\n def: ToolDef,\n args: Record<string, unknown>,\n options: {
|
|
1
|
+
{"version":3,"file":"atomic-tool.js","names":[],"sources":["../../../src/editor/history/atomic-tool.ts"],"sourcesContent":["import type { SceneGraph, SceneNode, Variable } from '@pairdraw/scene-graph'\nimport { captureEditCheckpoint } from '@pairdraw/scene-graph/checkpoint'\n\nimport type { Editor } from '#core/editor/create'\nimport { ReadOnlyDocumentError } from '#core/editor/read-only'\nimport { resolveEditorProfile, type EditorProfileInputs } from '#core/editor/views'\nimport type { FigmaAPI } from '#core/figma-api'\nimport { isAtomicTool, type ToolDef } from '#core/tools/schema'\n\nimport { diffFields, type FieldChanges } from './diff'\n\n// Capture property changes across pages. Component synchronization remains editor-owned.\nconst MAX_TRANSACTION_NODES = 10_000\n\ntype MutationEditor = Pick<\n Editor,\n 'graph' | 'runLayoutForNode' | 'requestRender' | 'pushUndoStep'\n> & {\n state: EditorProfileInputs\n}\n\nfunction changes<T extends object>(\n before: Map<string, T>,\n after: Map<string, T>,\n expectedSize = before.size\n): FieldChanges<T>[] {\n const result: FieldChanges<T>[] = []\n for (const [id, previous] of before) {\n const current = after.get(id)\n if (!current) throw new Error('Atomic tools must not remove nodes or variables')\n const change = diffFields(id, previous, current)\n if (change) result.push(change)\n }\n if (after.size !== expectedSize)\n throw new Error('Atomic tools must not create nodes or variables')\n return result\n}\n\n/**\n * No await is permitted between snapshot and commit. Browser events, other agents and\n * cancellation cannot interleave with this bounded transaction. Async tools use their\n * existing execution path and are not exposed through WebMCP.\n */\nexport function executeAtomicTool(\n editor: MutationEditor,\n figma: FigmaAPI,\n def: ToolDef,\n args: Record<string, unknown>,\n options: {\n signal?: AbortSignal\n isLive?: () => boolean\n label?: string\n /**\n * Judges the layer fields the call changed once it ran; an error it returns undoes the call\n * and is thrown, as the document's design memory refuses an agent's off-system values.\n */\n verify?: (\n nodes: readonly FieldChanges<SceneNode>[],\n variables: readonly FieldChanges<Variable>[]\n ) => Error | null\n } = {}\n): unknown {\n if (!isAtomicTool(def)) throw new Error(`Not an atomic tool: ${def.name}`)\n if (!resolveEditorProfile(editor.state).edits) throw new ReadOnlyDocumentError()\n options.signal?.throwIfAborted()\n if (editor.graph !== figma.graph || options.isLive?.() === false) {\n throw new Error('The target document is no longer open')\n }\n const graph = figma.graph\n if (graph.nodes.size + graph.variables.size > MAX_TRANSACTION_NODES) {\n throw new Error('Document too large for atomic agent editing (maximum 10000 nodes)')\n }\n // Rollback state costs what the call touches, not a copy of the document.\n const checkpoint = captureEditCheckpoint(graph)\n const { variables } = checkpoint\n const nodeCount = graph.nodes.size\n const pageId = figma.currentPageId\n\n const replay = (\n nodeChanges: FieldChanges<SceneNode>[],\n variableChanges: FieldChanges<Variable>[],\n direction: 'before' | 'after'\n ) => {\n if (editor.graph !== graph) throw new Error('The target document has been replaced')\n for (const change of variableChanges) {\n const variable = graph.variables.get(change.id)\n if (variable) {\n Object.assign(variable, structuredClone(change[direction]))\n for (const key of change.absent[direction]) Reflect.deleteProperty(variable, key)\n }\n }\n graph.preserveSourceMetadataDuring(() => {\n for (const change of nodeChanges)\n graph.restoreNodeProperties(\n change.id,\n structuredClone(change[direction]),\n change.absent[direction]\n )\n })\n layout(\n graph,\n editor,\n pageId,\n variableChanges.length > 0,\n nodeChanges.map((change) => change.id)\n )\n editor.requestRender()\n }\n\n try {\n const result = def.execute(figma, args)\n if (result instanceof Promise) throw new Error('Atomic tools must execute synchronously')\n if (result && typeof result === 'object' && 'error' in result) {\n throw new Error(String(result.error))\n }\n const touched = checkpoint.assertPropertiesOnly()\n const variableChanges = changes(variables, graph.variables)\n layout(\n graph,\n editor,\n pageId,\n variableChanges.length > 0,\n changes(touched, graph.nodes, nodeCount).map((change) => change.id)\n )\n // Layout may change other layers too.\n const nodeChanges = changes(checkpoint.changedNodes(), graph.nodes, nodeCount)\n rejectRefused(options.verify, nodeChanges, variableChanges)\n const contentChanged =\n variableChanges.length > 0 ||\n nodeChanges.some((change) => Object.keys(change.after).some((key) => key !== 'source'))\n if (!contentChanged && nodeChanges.length) replay(nodeChanges, [], 'before')\n if (contentChanged) {\n editor.pushUndoStep({\n label: `${options.label ?? 'Agent'}: ${def.name}`,\n inverse: () => replay(nodeChanges, variableChanges, 'before'),\n forward: () => replay(nodeChanges, variableChanges, 'after')\n })\n editor.requestRender()\n }\n return result\n } catch (error) {\n checkpoint.restore()\n editor.requestRender()\n throw error\n } finally {\n checkpoint.release()\n }\n}\n\n/** Throws the error `verify` judges the changes with, which undoes the call. */\nfunction rejectRefused(\n verify:\n | ((\n nodes: readonly FieldChanges<SceneNode>[],\n variables: readonly FieldChanges<Variable>[]\n ) => Error | null)\n | undefined,\n nodes: readonly FieldChanges<SceneNode>[],\n variables: readonly FieldChanges<Variable>[]\n): void {\n const refusal = verify ? verify(nodes, variables) : null\n if (refusal) throw refusal\n}\n\nfunction layout(\n graph: SceneGraph,\n editor: MutationEditor,\n pageId: string,\n allPages: boolean,\n changedIds: string[]\n): void {\n const scopes = new Set(allPages ? graph.getPages().map((page) => page.id) : [pageId])\n for (const id of changedIds) {\n let node = graph.getNode(id)\n while (node && node.type !== 'CANVAS')\n node = node.parentId ? graph.getNode(node.parentId) : undefined\n if (node) scopes.add(node.id)\n }\n for (const id of scopes) editor.runLayoutForNode(id)\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
//#region src/editor/history/capture.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* A copy that keeps the layer's values as they are now. Values are replaced, never written into
|
|
5
|
+
* (`materialize-instance.ts` in `@pairdraw/fig`), so sharing them is safe; the graph edits
|
|
6
|
+
* child lists, source metadata, and override maps in place, so those are copied. It costs a few
|
|
7
|
+
* object spreads where a deep clone of the layer costs its whole value tree, which is what lets
|
|
8
|
+
* undo record thousands of layers.
|
|
9
|
+
*/
|
|
10
|
+
declare function captureNode(node: SceneNode): SceneNode;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { captureNode };
|
|
13
|
+
//# sourceMappingURL=capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.d.ts","names":[],"sources":["../../../src/editor/history/capture.ts"],"mappings":";;;;;;;;;iBAUgB,YAAY,MAAM,YAAY"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { cloneInstanceOverrideState } from "@pairdraw/scene-graph/instances/overrides";
|
|
2
|
+
//#region src/editor/history/capture.ts
|
|
3
|
+
/**
|
|
4
|
+
* A copy that keeps the layer's values as they are now. Values are replaced, never written into
|
|
5
|
+
* (`materialize-instance.ts` in `@pairdraw/fig`), so sharing them is safe; the graph edits
|
|
6
|
+
* child lists, source metadata, and override maps in place, so those are copied. It costs a few
|
|
7
|
+
* object spreads where a deep clone of the layer costs its whole value tree, which is what lets
|
|
8
|
+
* undo record thousands of layers.
|
|
9
|
+
*/
|
|
10
|
+
function captureNode(node) {
|
|
11
|
+
const { source, instanceOverrides } = node;
|
|
12
|
+
return {
|
|
13
|
+
...node,
|
|
14
|
+
childIds: [...node.childIds],
|
|
15
|
+
source: {
|
|
16
|
+
...source,
|
|
17
|
+
fig: {
|
|
18
|
+
...source.fig,
|
|
19
|
+
rawNodeFields: { ...source.fig.rawNodeFields }
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
instanceOverrides: cloneInstanceOverrideState(instanceOverrides)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { captureNode };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture.js","names":[],"sources":["../../../src/editor/history/capture.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\nimport { cloneInstanceOverrideState } from '@pairdraw/scene-graph/instances/overrides'\n\n/**\n * A copy that keeps the layer's values as they are now. Values are replaced, never written into\n * (`materialize-instance.ts` in `@pairdraw/fig`), so sharing them is safe; the graph edits\n * child lists, source metadata, and override maps in place, so those are copied. It costs a few\n * object spreads where a deep clone of the layer costs its whole value tree, which is what lets\n * undo record thousands of layers.\n */\nexport function captureNode(node: SceneNode): SceneNode {\n const { source, instanceOverrides } = node\n return {\n ...node,\n childIds: [...node.childIds],\n source: { ...source, fig: { ...source.fig, rawNodeFields: { ...source.fig.rawNodeFields } } },\n instanceOverrides: cloneInstanceOverrideState(instanceOverrides)\n }\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,YAAY,MAA4B;CACtD,MAAM,EAAE,QAAQ,sBAAsB;CACtC,OAAO;EACL,GAAG;EACH,UAAU,CAAC,GAAG,KAAK,QAAQ;EAC3B,QAAQ;GAAE,GAAG;GAAQ,KAAK;IAAE,GAAG,OAAO;IAAK,eAAe,EAAE,GAAG,OAAO,IAAI,cAAc;GAAE;EAAE;EAC5F,mBAAmB,2BAA2B,iBAAiB;CACjE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-change.d.ts","names":[],"sources":["../../../src/editor/history/document-change.ts"],"mappings":";;;;KAsBK;;;;;;UAOK;EACR;EACA,QAAQ,aAAa;EACrB,QAAQ,aAAa;EACrB,KAAK,aAAa;;;UAIV;EACR;EACA;;;UAIQ,aAAa;EACrB;EACA,QAAQ;EACR,OAAO;;;;;;;;UASQ;;EAEf;;EAEA;;EAEA,SAAS;;EAET,SAAS;;EAET,SAAS;;EAET,UAAU,OAAO,MAAM;EACvB,WAAW,aAAa;EACxB,aAAa,aAAa;;;;
|
|
1
|
+
{"version":3,"file":"document-change.d.ts","names":[],"sources":["../../../src/editor/history/document-change.ts"],"mappings":";;;;KAsBK;;;;;;UAOK;EACR;EACA,QAAQ,aAAa;EACrB,QAAQ,aAAa;EACrB,KAAK,aAAa;;;UAIV;EACR;EACA;;;UAIQ,aAAa;EACrB;EACA,QAAQ;EACR,OAAO;;;;;;;;UASQ;;EAEf;;EAEA;;EAEA,SAAS;;EAET,SAAS;;EAET,SAAS;;EAET,UAAU,OAAO,MAAM;EACvB,WAAW,aAAa;EACxB,aAAa,aAAa;;;;iBA0IZ,YAAY,kBAC1B,QAAQ,YAAY,IACpB,YACA,OAAO;;UAkEQ;;EAEf,cAAc;;EAEd;;EAEA;;;;;;;;;;;;;;iBAec,qBAAqB,OAAO,YAAY,iBAAiB;;iBA+GzD,sBAAsB,OAAO,YAAY,uBAAuB;;;;;;;;iBAyFhE,mBAAmB,OAAO,YAAY,QAAQ;iBA+B9C,sBAAsB,QAAQ;;;;;;;iBAkB9B,oBAAoB,OAAO,YAAY,QAAQ,gBAAgB,MAAM;;;;;;iBAqCrE,sBACd,KAAK,eACL,QAAQ,gBACR,MAAM,MACN;EAAW"}
|