@pairdraw/core 0.18.0 → 0.19.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/effects.d.ts +5 -11
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +25 -30
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/labels/hit-test.d.ts +5 -0
- package/dist/canvas/labels/hit-test.d.ts.map +1 -1
- package/dist/canvas/labels/hit-test.js +1 -1
- package/dist/canvas/labels/hit-test.js.map +1 -1
- package/dist/canvas/labels/paragraph-cache.d.ts.map +1 -1
- package/dist/canvas/labels/paragraph-cache.js +3 -2
- package/dist/canvas/labels/paragraph-cache.js.map +1 -1
- package/dist/canvas/labels/selection.js +3 -2
- package/dist/canvas/labels/selection.js.map +1 -1
- package/dist/canvas/labels/style.d.ts +1 -1
- package/dist/canvas/node-edit-overlay.js +2 -2
- package/dist/canvas/node-edit-overlay.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 +4 -37
- package/dist/canvas/overlays/selection.js.map +1 -1
- package/dist/canvas/region-hatch.js +3 -2
- package/dist/canvas/region-hatch.js.map +1 -1
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +36 -18
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/font-waiters.d.ts +9 -0
- package/dist/canvas/renderer/font-waiters.d.ts.map +1 -0
- package/dist/canvas/renderer/font-waiters.js +26 -0
- package/dist/canvas/renderer/font-waiters.js.map +1 -0
- package/dist/canvas/renderer/fonts.d.ts +4 -2
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +23 -9
- 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 -9
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +4 -5
- 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/paints.d.ts.map +1 -1
- package/dist/canvas/renderer/paints.js +0 -6
- package/dist/canvas/renderer/paints.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +20 -2
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/retained-backing.js +4 -4
- package/dist/canvas/renderer/retained-backing.js.map +1 -1
- package/dist/canvas/renderer/state.js +1 -1
- package/dist/canvas/renderer/state.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +2 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +8 -0
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.js +7 -5
- package/dist/canvas/renderer/visual-bounds.js.map +1 -1
- package/dist/canvas/renderer.d.ts +22 -7
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +46 -11
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/rulers.d.ts +8 -1
- package/dist/canvas/rulers.d.ts.map +1 -1
- package/dist/canvas/rulers.js +30 -5
- package/dist/canvas/rulers.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 +30 -18
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/shape.js +1 -1
- package/dist/canvas/shadows/shape.js.map +1 -1
- package/dist/canvas/shadows/silhouette.d.ts.map +1 -1
- package/dist/canvas/shadows/silhouette.js +4 -2
- package/dist/canvas/shadows/silhouette.js.map +1 -1
- package/dist/canvas/shadows.d.ts.map +1 -1
- package/dist/canvas/shadows.js +3 -2
- package/dist/canvas/shadows.js.map +1 -1
- package/dist/canvas/text/derived.d.ts +1 -2
- package/dist/canvas/text/derived.d.ts.map +1 -1
- package/dist/canvas/text/derived.js +1 -7
- package/dist/canvas/text/derived.js.map +1 -1
- package/dist/canvas/text/emoji/index.js +1 -1
- package/dist/canvas/text/emoji/raster.d.ts.map +1 -1
- package/dist/canvas/text/emoji/raster.js +14 -10
- package/dist/canvas/text/emoji/raster.js.map +1 -1
- package/dist/canvas/text/font-families.d.ts.map +1 -1
- package/dist/canvas/text/font-families.js +5 -2
- package/dist/canvas/text/font-families.js.map +1 -1
- package/dist/canvas/text/index.d.ts +1 -3
- package/dist/canvas/text/index.d.ts.map +1 -1
- package/dist/canvas/text/index.js +1 -8
- package/dist/canvas/text/index.js.map +1 -1
- package/dist/canvas/text/layout/build.d.ts.map +1 -1
- package/dist/canvas/text/layout/build.js +25 -9
- package/dist/canvas/text/layout/build.js.map +1 -1
- package/dist/canvas/text/layout/index.d.ts.map +1 -1
- package/dist/canvas/text/layout/index.js +8 -4
- package/dist/canvas/text/layout/index.js.map +1 -1
- package/dist/canvas/text/layout/lines.js +5 -3
- package/dist/canvas/text/layout/lines.js.map +1 -1
- package/dist/canvas/text/paragraph/index.d.ts +5 -0
- package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/index.js +16 -7
- package/dist/canvas/text/paragraph/index.js.map +1 -1
- package/dist/canvas/text/paragraph/inputs.d.ts +1 -1
- package/dist/canvas/text/paragraph/inputs.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/inputs.js +9 -2
- package/dist/canvas/text/paragraph/inputs.js.map +1 -1
- package/dist/canvas/text/placed.js +1 -1
- package/dist/canvas/text/shape.d.ts +4 -3
- package/dist/canvas/text/shape.d.ts.map +1 -1
- package/dist/canvas/text/shape.js +9 -22
- package/dist/canvas/text/shape.js.map +1 -1
- package/dist/constants.d.ts +6 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -2
- package/dist/constants.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +1 -0
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +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/frames.d.ts +4 -3
- package/dist/editor/bridges/frames.d.ts.map +1 -1
- package/dist/editor/bridges/frames.js +6 -4
- package/dist/editor/bridges/frames.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -0
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/bridges/structure.js +1 -0
- package/dist/editor/bridges/structure.js.map +1 -1
- package/dist/editor/clipboard/detach.js +2 -2
- package/dist/editor/clipboard/detach.js.map +1 -1
- package/dist/editor/clipboard/paste/properties.js +1 -1
- package/dist/editor/clipboard/paste/target.js +2 -2
- package/dist/editor/clipboard/paste/target.js.map +1 -1
- package/dist/editor/clipboard/snapshot.d.ts +3 -0
- package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
- package/dist/editor/clipboard/snapshot.js +2 -0
- package/dist/editor/clipboard/snapshot.js.map +1 -1
- package/dist/editor/clipboard/variables.d.ts.map +1 -1
- package/dist/editor/clipboard/variables.js +14 -1
- package/dist/editor/clipboard/variables.js.map +1 -1
- package/dist/editor/clipboard.d.ts +1 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +122 -16
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/component-sync.d.ts +10 -1
- package/dist/editor/component-sync.d.ts.map +1 -1
- package/dist/editor/component-sync.js +25 -8
- package/dist/editor/component-sync.js.map +1 -1
- package/dist/editor/components/authoring/text-edit.d.ts.map +1 -1
- package/dist/editor/components/authoring/text-edit.js +11 -2
- package/dist/editor/components/authoring/text-edit.js.map +1 -1
- package/dist/editor/components/authoring/visibility-edit.d.ts.map +1 -1
- package/dist/editor/components/authoring/visibility-edit.js +7 -3
- package/dist/editor/components/authoring/visibility-edit.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 +37 -7
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/properties.d.ts.map +1 -1
- package/dist/editor/components/properties.js +3 -0
- package/dist/editor/components/properties.js.map +1 -1
- package/dist/editor/components/slots/authoring.js +2 -1
- package/dist/editor/components/slots/authoring.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/create.d.ts +17 -3
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +43 -6
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/guides.d.ts.map +1 -1
- package/dist/editor/guides.js +20 -13
- package/dist/editor/guides.js.map +1 -1
- package/dist/editor/history/document-change.d.ts +19 -3
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +94 -8
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +56 -12
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/position.js +1 -4
- package/dist/editor/history/position.js.map +1 -1
- package/dist/editor/history/sources.d.ts +14 -0
- package/dist/editor/history/sources.d.ts.map +1 -0
- package/dist/editor/history/sources.js +24 -0
- package/dist/editor/history/sources.js.map +1 -0
- package/dist/editor/index.d.ts +2 -2
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +16 -1
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/node-preview.d.ts.map +1 -1
- package/dist/editor/node-preview.js +26 -7
- package/dist/editor/node-preview.js.map +1 -1
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +33 -10
- package/dist/editor/nodes.js.map +1 -1
- package/dist/editor/nudge.d.ts.map +1 -1
- package/dist/editor/nudge.js +12 -2
- package/dist/editor/nudge.js.map +1 -1
- package/dist/editor/pages.d.ts +2 -1
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +94 -15
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +0 -5
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +3 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/selection/hit-test.d.ts +2 -1
- package/dist/editor/selection/hit-test.d.ts.map +1 -1
- package/dist/editor/selection/hit-test.js +29 -4
- package/dist/editor/selection/hit-test.js.map +1 -1
- package/dist/editor/selection.d.ts +2 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/pen.js +6 -2
- package/dist/editor/shapes/pen.js.map +1 -1
- package/dist/editor/shapes.d.ts.map +1 -1
- package/dist/editor/shapes.js +2 -1
- package/dist/editor/shapes.js.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.d.ts.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.js +12 -0
- package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
- package/dist/editor/structure/boolean.js +1 -1
- package/dist/editor/structure/group/bounds.d.ts +4 -2
- package/dist/editor/structure/group/bounds.d.ts.map +1 -1
- package/dist/editor/structure/group/bounds.js +17 -4
- package/dist/editor/structure/group/bounds.js.map +1 -1
- package/dist/editor/structure/rename.d.ts +2 -3
- package/dist/editor/structure/rename.d.ts.map +1 -1
- package/dist/editor/structure/rename.js +2 -5
- package/dist/editor/structure/rename.js.map +1 -1
- package/dist/editor/structure/reorder.d.ts.map +1 -1
- package/dist/editor/structure/reorder.js +20 -9
- package/dist/editor/structure/reorder.js.map +1 -1
- package/dist/editor/structure/state.js +1 -1
- package/dist/editor/structure.d.ts +1 -0
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/structure.js +76 -20
- package/dist/editor/structure.js.map +1 -1
- package/dist/editor/text/hyperlink.d.ts.map +1 -1
- package/dist/editor/text/hyperlink.js +1 -1
- package/dist/editor/text/hyperlink.js.map +1 -1
- package/dist/editor/text/name.d.ts +13 -5
- package/dist/editor/text/name.d.ts.map +1 -1
- package/dist/editor/text/name.js +47 -17
- package/dist/editor/text/name.js.map +1 -1
- package/dist/editor/text/pending-layout.d.ts +2 -1
- package/dist/editor/text/pending-layout.d.ts.map +1 -1
- package/dist/editor/text/pending-layout.js +33 -6
- package/dist/editor/text/pending-layout.js.map +1 -1
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +16 -4
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/text.d.ts +5 -0
- package/dist/editor/text.d.ts.map +1 -1
- package/dist/editor/text.js +70 -3
- package/dist/editor/text.js.map +1 -1
- package/dist/editor/types.d.ts +18 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/undo.d.ts.map +1 -1
- package/dist/editor/undo.js +14 -2
- package/dist/editor/undo.js.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +21 -2
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/editor/variables.d.ts +1 -1
- package/dist/editor/variables.d.ts.map +1 -1
- package/dist/editor/variables.js +7 -8
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/viewport.d.ts +11 -2
- package/dist/editor/viewport.d.ts.map +1 -1
- package/dist/editor/viewport.js +61 -21
- package/dist/editor/viewport.js.map +1 -1
- package/dist/editor/views/actions.d.ts.map +1 -1
- package/dist/editor/views/actions.js +13 -5
- package/dist/editor/views/actions.js.map +1 -1
- package/dist/editor/views/present.d.ts +6 -4
- package/dist/editor/views/present.d.ts.map +1 -1
- package/dist/editor/views/present.js +12 -10
- package/dist/editor/views/present.js.map +1 -1
- package/dist/editor/views/types.d.ts +11 -5
- package/dist/editor/views/types.d.ts.map +1 -1
- package/dist/figma-api/accessor-utils.d.ts.map +1 -1
- package/dist/figma-api/accessor-utils.js +4 -1
- package/dist/figma-api/accessor-utils.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +41 -21
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/layout.d.ts.map +1 -1
- package/dist/figma-api/accessors/layout.js +37 -7
- package/dist/figma-api/accessors/layout.js.map +1 -1
- package/dist/figma-api/accessors/reactions.d.ts +11 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -0
- package/dist/figma-api/accessors/reactions.js +30 -0
- package/dist/figma-api/accessors/reactions.js.map +1 -0
- package/dist/figma-api/accessors/strokes.d.ts.map +1 -1
- package/dist/figma-api/accessors/strokes.js +12 -4
- package/dist/figma-api/accessors/strokes.js.map +1 -1
- package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
- package/dist/figma-api/accessors/text/index.js +3 -1
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +1 -1
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.d.ts +6 -5
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +20 -17
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +2 -1
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/finite.d.ts +27 -0
- package/dist/figma-api/finite.d.ts.map +1 -0
- package/dist/figma-api/finite.js +69 -0
- package/dist/figma-api/finite.js.map +1 -0
- package/dist/figma-api/fonts/list.d.ts +13 -0
- package/dist/figma-api/fonts/list.d.ts.map +1 -0
- package/dist/figma-api/fonts/list.js +25 -0
- package/dist/figma-api/fonts/list.js.map +1 -0
- package/dist/figma-api/index.d.ts +21 -3
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +58 -13
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +6 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +2 -2
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/pending-layout.d.ts +12 -2
- package/dist/figma-api/pending-layout.d.ts.map +1 -1
- package/dist/figma-api/pending-layout.js +41 -1
- package/dist/figma-api/pending-layout.js.map +1 -1
- package/dist/figma-api/pending-sync.d.ts +19 -0
- package/dist/figma-api/pending-sync.d.ts.map +1 -0
- package/dist/figma-api/pending-sync.js +52 -0
- package/dist/figma-api/pending-sync.js.map +1 -0
- package/dist/figma-api/proxy.d.ts +15 -2
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +23 -3
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +104 -0
- package/dist/figma-api/reactions.d.ts.map +1 -0
- package/dist/figma-api/reactions.js +157 -0
- package/dist/figma-api/reactions.js.map +1 -0
- package/dist/figma-api/render-bounds.d.ts.map +1 -1
- package/dist/figma-api/render-bounds.js +4 -4
- package/dist/figma-api/render-bounds.js.map +1 -1
- package/dist/figma-api/serialization.js +2 -2
- package/dist/figma-api/serialization.js.map +1 -1
- package/dist/figma-api/slots.d.ts +7 -1
- package/dist/figma-api/slots.d.ts.map +1 -1
- package/dist/figma-api/slots.js +12 -4
- package/dist/figma-api/slots.js.map +1 -1
- package/dist/figma-api/strokes.d.ts +5 -2
- package/dist/figma-api/strokes.d.ts.map +1 -1
- package/dist/figma-api/strokes.js +12 -19
- package/dist/figma-api/strokes.js.map +1 -1
- package/dist/figma-api/text/bindings.js +1 -1
- package/dist/figma-api/text/index.d.ts +2 -3
- package/dist/figma-api/text/index.d.ts.map +1 -1
- package/dist/figma-api/text/index.js +2 -12
- package/dist/figma-api/text/index.js.map +1 -1
- package/dist/figma-api/variables/bindings.js +1 -1
- package/dist/figma-api/variables/variable.d.ts.map +1 -1
- package/dist/figma-api/variables/variable.js +2 -2
- package/dist/figma-api/variables/variable.js.map +1 -1
- package/dist/geometry/figma.d.ts +6 -1
- package/dist/geometry/figma.d.ts.map +1 -1
- package/dist/geometry/figma.js +8 -1
- package/dist/geometry/figma.js.map +1 -1
- package/dist/geometry/index.d.ts +2 -2
- package/dist/geometry/index.js +2 -2
- package/dist/icons/api.d.ts +3 -2
- package/dist/icons/api.d.ts.map +1 -1
- package/dist/icons/api.js +12 -12
- package/dist/icons/api.js.map +1 -1
- package/dist/icons/provider.d.ts +4 -3
- package/dist/icons/provider.d.ts.map +1 -1
- package/dist/icons/provider.js +6 -13
- package/dist/icons/provider.js.map +1 -1
- package/dist/icons/schema.d.ts +33 -1
- package/dist/icons/schema.d.ts.map +1 -1
- package/dist/icons/schema.js +30 -1
- package/dist/icons/schema.js.map +1 -1
- package/dist/icons/svg/presentation.d.ts +8 -1
- package/dist/icons/svg/presentation.d.ts.map +1 -1
- package/dist/icons/svg/presentation.js +21 -3
- package/dist/icons/svg/presentation.js.map +1 -1
- package/dist/icons/svg/text.js +1 -1
- package/dist/icons/svg/text.js.map +1 -1
- package/dist/icons/svg.d.ts +8 -3
- package/dist/icons/svg.d.ts.map +1 -1
- package/dist/icons/svg.js +15 -13
- package/dist/icons/svg.js.map +1 -1
- package/dist/icons/types.d.ts +1 -19
- package/dist/icons/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/io/formats/design-tokens/css/read.js +1 -1
- package/dist/io/formats/design-tokens/decode.js +1 -1
- package/dist/io/formats/design-tokens/plan/index.js +4 -2
- package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts +9 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.js +23 -3
- package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts +9 -1
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js +41 -4
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/types.d.ts +5 -0
- package/dist/io/formats/design-tokens/types.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/types.js +1 -0
- package/dist/io/formats/design-tokens/types.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +8 -4
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
- package/dist/io/formats/fig/export/variables.js +2 -2
- package/dist/io/formats/fig/export/variables.js.map +1 -1
- package/dist/io/formats/fig/index.d.ts +2 -2
- package/dist/io/formats/fig/index.js +2 -2
- package/dist/io/formats/fig/read.d.ts +9 -2
- package/dist/io/formats/fig/read.d.ts.map +1 -1
- package/dist/io/formats/fig/read.js +44 -20
- package/dist/io/formats/fig/read.js.map +1 -1
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +2 -6
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +65 -1
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/prepare.js +1 -1
- package/dist/io/formats/pen/fonts.d.ts +14 -0
- package/dist/io/formats/pen/fonts.d.ts.map +1 -0
- package/dist/io/formats/pen/fonts.js +39 -0
- package/dist/io/formats/pen/fonts.js.map +1 -0
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +25 -6
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/raster/headless.d.ts +2 -2
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +24 -13
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/index.js +2 -2
- package/dist/io/formats/raster/render.d.ts +7 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +40 -6
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +28 -24
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/paths.d.ts +8 -2
- package/dist/io/formats/svg/paths.d.ts.map +1 -1
- package/dist/io/formats/svg/paths.js +11 -3
- package/dist/io/formats/svg/paths.js.map +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +2 -5
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/export.d.ts.map +1 -1
- package/dist/io/formats/svg/text/export.js +19 -1
- package/dist/io/formats/svg/text/export.js.map +1 -1
- package/dist/io/formats/svg/text/import.d.ts.map +1 -1
- package/dist/io/formats/svg/text/import.js +2 -1
- package/dist/io/formats/svg/text/import.js.map +1 -1
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +5 -2
- package/dist/io/subgraph.js.map +1 -1
- package/dist/kiwi/fig/population/client.d.ts.map +1 -1
- package/dist/kiwi/fig/population/client.js +63 -45
- package/dist/kiwi/fig/population/client.js.map +1 -1
- package/dist/kiwi/fig/population/delta.d.ts +34 -3
- package/dist/kiwi/fig/population/delta.d.ts.map +1 -1
- package/dist/kiwi/fig/population/delta.js +99 -16
- package/dist/kiwi/fig/population/delta.js.map +1 -1
- package/dist/kiwi/fig/population/edits.d.ts +51 -0
- package/dist/kiwi/fig/population/edits.d.ts.map +1 -0
- package/dist/kiwi/fig/population/edits.js +169 -0
- package/dist/kiwi/fig/population/edits.js.map +1 -0
- package/dist/kiwi/fig/session/archive/access.d.ts +3 -0
- package/dist/kiwi/fig/session/archive/access.d.ts.map +1 -1
- package/dist/kiwi/fig/session/archive/access.js +8 -1
- package/dist/kiwi/fig/session/archive/access.js.map +1 -1
- package/dist/kiwi/fig/session/archive/changes.d.ts +2 -1
- package/dist/kiwi/fig/session/archive/changes.d.ts.map +1 -1
- package/dist/kiwi/fig/session/archive/changes.js +12 -5
- package/dist/kiwi/fig/session/archive/changes.js.map +1 -1
- package/dist/kiwi/fig/session/document-state.d.ts +7 -1
- package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
- package/dist/kiwi/fig/session/document-state.js +16 -2
- package/dist/kiwi/fig/session/document-state.js.map +1 -1
- package/dist/kiwi/fig/session/protocol.d.ts +31 -3
- package/dist/kiwi/fig/session/protocol.d.ts.map +1 -1
- package/dist/kiwi/fig/session/worker.js +33 -8
- package/dist/kiwi/fig/session/worker.js.map +1 -1
- package/dist/layout/apply.d.ts +6 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +39 -14
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/arrange/boxes.d.ts.map +1 -1
- package/dist/layout/arrange/boxes.js +31 -0
- package/dist/layout/arrange/boxes.js.map +1 -1
- package/dist/layout/flow-edges.d.ts +26 -0
- package/dist/layout/flow-edges.d.ts.map +1 -0
- package/dist/layout/flow-edges.js +105 -0
- package/dist/layout/flow-edges.js.map +1 -0
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +9 -5
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/text-auto-resize.d.ts.map +1 -1
- package/dist/layout/text-auto-resize.js +9 -4
- package/dist/layout/text-auto-resize.js.map +1 -1
- package/dist/layout/text-measurement.d.ts +15 -1
- package/dist/layout/text-measurement.d.ts.map +1 -1
- package/dist/layout/text-measurement.js +40 -4
- package/dist/layout/text-measurement.js.map +1 -1
- package/dist/layout/variables.d.ts +1 -1
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +35 -35
- package/dist/layout.js.map +1 -1
- package/dist/library/asset-keys.d.ts +3 -2
- package/dist/library/asset-keys.d.ts.map +1 -1
- package/dist/library/asset-keys.js +4 -3
- package/dist/library/asset-keys.js.map +1 -1
- package/dist/library/copied-references.d.ts +8 -3
- package/dist/library/copied-references.d.ts.map +1 -1
- package/dist/library/copied-references.js +15 -5
- package/dist/library/copied-references.js.map +1 -1
- package/dist/library/materialize.js +1 -1
- package/dist/library/materialize.js.map +1 -1
- package/dist/library/schema.js.map +1 -1
- package/dist/library/snapshot.d.ts.map +1 -1
- package/dist/library/snapshot.js +10 -2
- package/dist/library/snapshot.js.map +1 -1
- package/dist/pairdraw-api/variables.d.ts.map +1 -1
- package/dist/pairdraw-api/variables.js +0 -2
- package/dist/pairdraw-api/variables.js.map +1 -1
- package/dist/profiler/hud-controller.d.ts +4 -3
- package/dist/profiler/hud-controller.d.ts.map +1 -1
- package/dist/profiler/hud-controller.js +7 -5
- package/dist/profiler/hud-controller.js.map +1 -1
- package/dist/profiler/hud-renderer.d.ts +5 -2
- package/dist/profiler/hud-renderer.d.ts.map +1 -1
- package/dist/profiler/hud-renderer.js +8 -5
- package/dist/profiler/hud-renderer.js.map +1 -1
- package/dist/profiler/render-profiler.d.ts +3 -2
- package/dist/profiler/render-profiler.d.ts.map +1 -1
- package/dist/profiler/render-profiler.js +3 -2
- package/dist/profiler/render-profiler.js.map +1 -1
- package/dist/text/character-style.d.ts +11 -1
- package/dist/text/character-style.d.ts.map +1 -1
- package/dist/text/character-style.js +27 -5
- package/dist/text/character-style.js.map +1 -1
- package/dist/text/coverage.d.ts.map +1 -1
- package/dist/text/coverage.js +15 -16
- package/dist/text/coverage.js.map +1 -1
- package/dist/text/editor.d.ts.map +1 -1
- package/dist/text/editor.js +3 -8
- package/dist/text/editor.js.map +1 -1
- package/dist/text/fallbacks.d.ts +19 -2
- package/dist/text/fallbacks.d.ts.map +1 -1
- package/dist/text/fallbacks.js +63 -12
- package/dist/text/fallbacks.js.map +1 -1
- package/dist/text/font/catalog.d.ts +4 -0
- package/dist/text/font/catalog.d.ts.map +1 -1
- package/dist/text/font/catalog.js +8 -0
- package/dist/text/font/catalog.js.map +1 -1
- package/dist/text/font/collection.d.ts +13 -0
- package/dist/text/font/collection.d.ts.map +1 -0
- package/dist/text/font/collection.js +51 -0
- package/dist/text/font/collection.js.map +1 -0
- package/dist/text/font/faces.d.ts +2 -1
- package/dist/text/font/faces.d.ts.map +1 -1
- package/dist/text/font/faces.js +9 -5
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/font/glyphs.d.ts +14 -3
- package/dist/text/font/glyphs.d.ts.map +1 -1
- package/dist/text/font/glyphs.js +22 -5
- package/dist/text/font/glyphs.js.map +1 -1
- package/dist/text/font/local.js +2 -2
- package/dist/text/font/local.js.map +1 -1
- package/dist/text/font/manager.d.ts +36 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +139 -19
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/font/style.d.ts +7 -2
- package/dist/text/font/style.d.ts.map +1 -1
- package/dist/text/font/style.js +31 -3
- package/dist/text/font/style.js.map +1 -1
- package/dist/text/index.d.ts +5 -4
- package/dist/text/index.js +5 -4
- package/dist/text/outlines.d.ts.map +1 -1
- package/dist/text/outlines.js +70 -70
- package/dist/text/outlines.js.map +1 -1
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +7 -1
- package/dist/text/prepare.js.map +1 -1
- package/dist/text/style-runs.d.ts +14 -2
- package/dist/text/style-runs.d.ts.map +1 -1
- package/dist/text/style-runs.js +22 -14
- package/dist/text/style-runs.js.map +1 -1
- package/dist/tools/analyze/overlaps/helpers.d.ts.map +1 -1
- package/dist/tools/analyze/overlaps/helpers.js +9 -1
- package/dist/tools/analyze/overlaps/helpers.js.map +1 -1
- package/dist/tools/analyze/overlaps/index.d.ts.map +1 -1
- package/dist/tools/analyze/overlaps/index.js +27 -5
- package/dist/tools/analyze/overlaps/index.js.map +1 -1
- package/dist/tools/codegen/component-map.js +3 -3
- package/dist/tools/codegen/component-map.js.map +1 -1
- package/dist/tools/create/basic.d.ts.map +1 -1
- package/dist/tools/create/basic.js +5 -4
- package/dist/tools/create/basic.js.map +1 -1
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +4 -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 +3 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.d.ts.map +1 -1
- package/dist/tools/create/mermaid.js +2 -0
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.d.ts.map +1 -1
- package/dist/tools/create/render.js +2 -0
- package/dist/tools/create/render.js.map +1 -1
- package/dist/tools/create/script.js +3 -1
- package/dist/tools/create/script.js.map +1 -1
- package/dist/tools/create/svg.d.ts.map +1 -1
- package/dist/tools/create/svg.js +4 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.d.ts.map +1 -1
- package/dist/tools/create/vector.js +4 -4
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/image-ai/apply.js +1 -1
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -0
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/modify/matching.js +1 -1
- package/dist/tools/modify/reactions.d.ts +6 -0
- package/dist/tools/modify/reactions.d.ts.map +1 -0
- package/dist/tools/modify/reactions.js +35 -0
- package/dist/tools/modify/reactions.js.map +1 -0
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/read/components.js +20 -22
- package/dist/tools/read/components.js.map +1 -1
- package/dist/tools/read/fonts.js +1 -1
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.d.ts.map +1 -1
- package/dist/tools/read/libraries.js +2 -0
- 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 +38 -16
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/read/pages.d.ts.map +1 -1
- package/dist/tools/read/pages.js +4 -3
- package/dist/tools/read/pages.js.map +1 -1
- package/dist/tools/read/query.js +1 -0
- package/dist/tools/read/query.js.map +1 -1
- package/dist/tools/read/reactions.d.ts +6 -0
- package/dist/tools/read/reactions.d.ts.map +1 -0
- package/dist/tools/read/reactions.js +24 -0
- package/dist/tools/read/reactions.js.map +1 -0
- package/dist/tools/read/space.js +1 -1
- package/dist/tools/read.d.ts +2 -1
- package/dist/tools/read.js +2 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +4 -0
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +6 -0
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +53 -9
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/stock-photo/apply.js +8 -9
- package/dist/tools/stock-photo/apply.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +85 -90
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/vector/fill-geometry.d.ts +4 -1
- package/dist/vector/fill-geometry.d.ts.map +1 -1
- package/dist/vector/fill-geometry.js +8 -5
- package/dist/vector/fill-geometry.js.map +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/path-helpers.d.ts +1 -1
- package/dist/vector/path-helpers.d.ts.map +1 -1
- package/dist/vector/path-helpers.js +24 -7
- package/dist/vector/path-helpers.js.map +1 -1
- package/dist/vector/placement.js +1 -1
- package/dist/vector/placement.js.map +1 -1
- package/dist/vector/vectorize/preprocess.js +1 -1
- package/dist/vector/vectorize/preprocess.js.map +1 -1
- package/package.json +10 -10
- package/src/canvas/effects.ts +29 -33
- package/src/canvas/labels/hit-test.ts +6 -2
- package/src/canvas/labels/paragraph-cache.ts +2 -1
- package/src/canvas/labels/selection.ts +3 -3
- package/src/canvas/node-edit-overlay.ts +3 -2
- package/src/canvas/overlays/index.ts +0 -1
- package/src/canvas/overlays/selection.ts +4 -52
- package/src/canvas/region-hatch.ts +7 -2
- package/src/canvas/renderer/colors.ts +41 -26
- package/src/canvas/renderer/font-waiters.ts +25 -0
- package/src/canvas/renderer/fonts.ts +40 -17
- package/src/canvas/renderer/lifecycle.ts +8 -10
- package/src/canvas/renderer/methods.ts +9 -13
- package/src/canvas/renderer/paints.ts +0 -10
- package/src/canvas/renderer/pipeline.ts +29 -3
- package/src/canvas/renderer/retained-backing.ts +4 -4
- package/src/canvas/renderer/state.ts +1 -1
- package/src/canvas/renderer/tiles/controller.ts +8 -0
- package/src/canvas/renderer/tiles/surface-pool.ts +1 -1
- package/src/canvas/renderer/visual-bounds.ts +7 -6
- package/src/canvas/renderer.ts +39 -11
- package/src/canvas/rulers.ts +55 -26
- package/src/canvas/scene.ts +37 -16
- package/src/canvas/shadows/shape.ts +1 -1
- package/src/canvas/shadows/silhouette.ts +4 -2
- package/src/canvas/shadows.ts +4 -2
- package/src/canvas/text/derived.ts +0 -9
- package/src/canvas/text/emoji/raster.ts +14 -10
- package/src/canvas/text/font-families.ts +6 -0
- package/src/canvas/text/index.ts +0 -8
- package/src/canvas/text/layout/build.ts +35 -18
- package/src/canvas/text/layout/index.ts +15 -6
- package/src/canvas/text/layout/lines.ts +10 -4
- package/src/canvas/text/paragraph/index.ts +17 -8
- package/src/canvas/text/paragraph/inputs.ts +4 -2
- package/src/canvas/text/shape.ts +20 -31
- package/src/constants.ts +6 -1
- package/src/editor/bridges/clipboard.ts +1 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/bridges/frames.ts +6 -4
- package/src/editor/bridges/structure.ts +1 -0
- package/src/editor/clipboard/detach.ts +3 -3
- package/src/editor/clipboard/paste/target.ts +2 -2
- package/src/editor/clipboard/snapshot.ts +7 -0
- package/src/editor/clipboard/variables.ts +20 -0
- package/src/editor/clipboard.ts +133 -14
- package/src/editor/component-sync.ts +28 -7
- package/src/editor/components/authoring/text-edit.ts +15 -2
- package/src/editor/components/authoring/visibility-edit.ts +11 -3
- package/src/editor/components/instances.ts +61 -11
- package/src/editor/components/properties.ts +10 -0
- package/src/editor/components/slots/authoring.ts +4 -1
- package/src/editor/create.ts +58 -8
- package/src/editor/guides.ts +27 -12
- package/src/editor/history/document-change.ts +115 -7
- package/src/editor/history/edit.ts +62 -14
- package/src/editor/history/position.ts +1 -4
- package/src/editor/history/sources.ts +25 -0
- package/src/editor/index.ts +3 -1
- package/src/editor/layout-mode.ts +20 -1
- package/src/editor/node-preview.ts +44 -8
- package/src/editor/nodes.ts +52 -12
- package/src/editor/nudge.ts +16 -2
- package/src/editor/pages.ts +100 -17
- package/src/editor/play/states.ts +0 -7
- package/src/editor/read-only/actions.ts +4 -0
- package/src/editor/selection/hit-test.ts +37 -4
- package/src/editor/shapes/pen.ts +6 -3
- package/src/editor/shapes.ts +2 -1
- package/src/editor/structure/auto-layout-wrap.ts +26 -0
- package/src/editor/structure/group/bounds.ts +22 -4
- package/src/editor/structure/rename.ts +2 -6
- package/src/editor/structure/reorder.ts +26 -8
- package/src/editor/structure.ts +88 -24
- package/src/editor/text/hyperlink.ts +2 -1
- package/src/editor/text/name.ts +51 -15
- package/src/editor/text/pending-layout.ts +42 -4
- package/src/editor/text/selection-style.ts +17 -3
- package/src/editor/text.ts +86 -4
- package/src/editor/types.ts +19 -0
- package/src/editor/undo.ts +21 -2
- package/src/editor/variable-bindings.ts +22 -2
- package/src/editor/variables.ts +10 -6
- package/src/editor/viewport.ts +55 -21
- package/src/editor/views/actions.ts +17 -7
- package/src/editor/views/present.ts +20 -11
- package/src/editor/views/types.ts +11 -5
- package/src/figma-api/accessor-utils.ts +4 -1
- package/src/figma-api/accessors/basic.ts +54 -18
- package/src/figma-api/accessors/layout.ts +46 -7
- package/src/figma-api/accessors/reactions.ts +29 -0
- package/src/figma-api/accessors/strokes.ts +28 -8
- package/src/figma-api/accessors/text/index.ts +4 -0
- package/src/figma-api/accessors/vector.ts +3 -1
- package/src/figma-api/accessors/visual.ts +25 -28
- package/src/figma-api/components.ts +9 -7
- package/src/figma-api/finite.ts +102 -0
- package/src/figma-api/fonts/list.ts +24 -0
- package/src/figma-api/index.ts +82 -12
- package/src/figma-api/overrides.ts +1 -1
- package/src/figma-api/pending-layout.ts +50 -1
- package/src/figma-api/pending-sync.ts +61 -0
- package/src/figma-api/proxy.ts +35 -2
- package/src/figma-api/reactions.ts +212 -0
- package/src/figma-api/render-bounds.ts +13 -4
- package/src/figma-api/serialization.ts +2 -2
- package/src/figma-api/slots.ts +12 -3
- package/src/figma-api/strokes.ts +16 -12
- package/src/figma-api/text/index.ts +9 -15
- package/src/figma-api/variables/variable.ts +3 -2
- package/src/geometry/figma.ts +9 -0
- package/src/geometry/index.ts +1 -0
- package/src/global.d.ts +6 -0
- package/src/icons/api.ts +27 -16
- package/src/icons/provider.ts +9 -20
- package/src/icons/schema.ts +31 -0
- package/src/icons/svg/presentation.ts +27 -3
- package/src/icons/svg/text.ts +1 -1
- package/src/icons/svg.ts +21 -19
- package/src/icons/types.ts +0 -14
- package/src/io/formats/design-tokens/plan/index.ts +7 -1
- package/src/io/formats/design-tokens/plan/styles.ts +40 -4
- package/src/io/formats/design-tokens/styles.ts +60 -3
- package/src/io/formats/design-tokens/types.ts +3 -0
- package/src/io/formats/fig/export/setup.ts +16 -14
- package/src/io/formats/fig/export/variables.ts +7 -8
- package/src/io/formats/fig/index.ts +1 -0
- package/src/io/formats/fig/read.ts +66 -23
- package/src/io/formats/html/index.ts +2 -6
- package/src/io/formats/pdf/dom.ts +96 -3
- package/src/io/formats/pen/fonts.ts +45 -0
- package/src/io/formats/pen/index.ts +30 -6
- package/src/io/formats/raster/headless.ts +31 -12
- package/src/io/formats/raster/index.ts +3 -0
- package/src/io/formats/raster/render.ts +62 -6
- package/src/io/formats/svg/export.ts +24 -25
- package/src/io/formats/svg/paths.ts +11 -2
- package/src/io/formats/svg/strokes.ts +8 -2
- package/src/io/formats/svg/text/export.ts +23 -0
- package/src/io/formats/svg/text/import.ts +2 -1
- package/src/io/subgraph.ts +3 -1
- package/src/kiwi/fig/population/client.ts +77 -43
- package/src/kiwi/fig/population/delta.ts +141 -18
- package/src/kiwi/fig/population/edits.ts +235 -0
- package/src/kiwi/fig/session/archive/access.ts +15 -0
- package/src/kiwi/fig/session/archive/changes.ts +27 -6
- package/src/kiwi/fig/session/document-state.ts +23 -1
- package/src/kiwi/fig/session/protocol.ts +26 -1
- package/src/kiwi/fig/session/worker.ts +38 -11
- package/src/layout/apply.ts +52 -10
- package/src/layout/arrange/boxes.ts +36 -0
- package/src/layout/flow-edges.ts +139 -0
- package/src/layout/grid.ts +14 -4
- package/src/layout/text-auto-resize.ts +13 -4
- package/src/layout/text-measurement.ts +46 -3
- package/src/layout.ts +60 -66
- package/src/library/asset-keys.ts +4 -3
- package/src/library/copied-references.ts +29 -5
- package/src/library/materialize.ts +1 -1
- package/src/library/schema.ts +1 -1
- package/src/library/snapshot.ts +11 -2
- package/src/pairdraw-api/variables.ts +1 -3
- package/src/profiler/hud-controller.ts +8 -6
- package/src/profiler/hud-renderer.ts +9 -6
- package/src/profiler/render-profiler.ts +4 -3
- package/src/text/character-style.ts +29 -9
- package/src/text/coverage.ts +17 -18
- package/src/text/editor.ts +3 -8
- package/src/text/fallbacks.ts +82 -15
- package/src/text/font/catalog.ts +10 -0
- package/src/text/font/collection.ts +60 -0
- package/src/text/font/faces.ts +9 -5
- package/src/text/font/glyphs.ts +29 -4
- package/src/text/font/local.ts +2 -2
- package/src/text/font/manager.ts +170 -32
- package/src/text/font/style.ts +52 -3
- package/src/text/index.ts +1 -0
- package/src/text/outlines.ts +105 -89
- package/src/text/prepare.ts +17 -0
- package/src/text/style-runs.ts +43 -16
- package/src/tools/analyze/overlaps/helpers.ts +18 -1
- package/src/tools/analyze/overlaps/index.ts +37 -6
- package/src/tools/codegen/component-map.ts +3 -3
- package/src/tools/create/basic.ts +6 -4
- package/src/tools/create/html.ts +3 -1
- package/src/tools/create/icons.ts +3 -1
- package/src/tools/create/mermaid.ts +2 -0
- package/src/tools/create/render.ts +2 -0
- package/src/tools/create/script.ts +5 -1
- package/src/tools/create/svg.ts +4 -1
- package/src/tools/create/vector.ts +4 -4
- package/src/tools/image-ai/generate.ts +3 -0
- package/src/tools/modify/reactions.ts +40 -0
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/components.ts +28 -25
- package/src/tools/read/fonts.ts +1 -1
- package/src/tools/read/libraries.ts +3 -0
- package/src/tools/read/nodes.ts +47 -17
- package/src/tools/read/pages.ts +7 -4
- package/src/tools/read/query.ts +2 -0
- package/src/tools/read/reactions.ts +21 -0
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/extended.ts +4 -0
- package/src/tools/schema.ts +68 -12
- package/src/tools/stock-photo/apply.ts +17 -5
- package/src/tools/structure/batch.ts +82 -101
- package/src/vector/fill-geometry.ts +11 -5
- package/src/vector/index.ts +1 -1
- package/src/vector/path-helpers.ts +34 -8
- package/src/vector/placement.ts +1 -1
- package/src/vector/vectorize/preprocess.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyDocumentChange,
|
|
1
|
+
import { applyDocumentChange, isEmptyDocumentChange, recordDocumentChange, restoreDocumentChange } from "./document-change.js";
|
|
2
2
|
//#region src/editor/history/edit.ts
|
|
3
3
|
function unchanged(pageId) {
|
|
4
4
|
return {
|
|
@@ -15,8 +15,50 @@ function unchanged(pageId) {
|
|
|
15
15
|
collections: []
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The undo step of a recorded change. Built outside the edit's own scope, so the step keeps only
|
|
20
|
+
* the change: not the edit's recording state, nor its options, whose `onRecorded` can hold the
|
|
21
|
+
* step before it and so every step back to the first, past the history limit.
|
|
22
|
+
*/
|
|
23
|
+
function changeStep(ctx, label, change) {
|
|
24
|
+
return {
|
|
25
|
+
label,
|
|
26
|
+
forward: () => restoreDocumentChange(ctx, change, "after"),
|
|
27
|
+
inverse: () => restoreDocumentChange(ctx, change, "before")
|
|
28
|
+
};
|
|
29
|
+
}
|
|
18
30
|
/** How many edits that await are running in each history. */
|
|
19
31
|
const runningEdits = /* @__PURE__ */ new WeakMap();
|
|
32
|
+
/** The recorders of edits still open in each editor, which anyone else's edit waits outside. */
|
|
33
|
+
const openRecorders = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
function keepOpenRecorder(ctx, recorder) {
|
|
35
|
+
let recorders = openRecorders.get(ctx);
|
|
36
|
+
if (!recorders) {
|
|
37
|
+
recorders = /* @__PURE__ */ new Set();
|
|
38
|
+
openRecorders.set(ctx, recorders);
|
|
39
|
+
}
|
|
40
|
+
recorders.add(recorder);
|
|
41
|
+
}
|
|
42
|
+
function releaseOpenRecorder(ctx, recorder) {
|
|
43
|
+
const recorders = openRecorders.get(ctx);
|
|
44
|
+
if (!recorders) return;
|
|
45
|
+
recorders.delete(recorder);
|
|
46
|
+
if (recorders.size === 0) openRecorders.delete(ctx);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Runs a separate edit, or an undo or redo, while the edits that are still open treat what it
|
|
50
|
+
* changes as someone else's: their steps leave it alone. The edit is synchronous, so nothing it
|
|
51
|
+
* runs interleaves with their awaits.
|
|
52
|
+
*/
|
|
53
|
+
function withOpenEditsPaused(ctx, run, own) {
|
|
54
|
+
const recorders = [...openRecorders.get(ctx) ?? []].filter((recorder) => recorder !== own);
|
|
55
|
+
for (const recorder of recorders) recorder.pause();
|
|
56
|
+
try {
|
|
57
|
+
return run();
|
|
58
|
+
} finally {
|
|
59
|
+
for (const recorder of recorders) recorder.resume();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
20
62
|
/**
|
|
21
63
|
* Watches, while an edit awaits, for writes it does not own: a step recorded, undone, or redone,
|
|
22
64
|
* another edit or a batch open, or text being edited. They land in the edit's change, so rolling
|
|
@@ -58,27 +100,29 @@ function rollBack(ctx, graph, change) {
|
|
|
58
100
|
function begin(ctx, options, awaits = false) {
|
|
59
101
|
const graph = ctx.graph;
|
|
60
102
|
const pageId = options.pageId ?? ctx.state.currentPageId;
|
|
61
|
-
const
|
|
103
|
+
const recorder = recordDocumentChange(graph, pageId);
|
|
104
|
+
if (awaits) keepOpenRecorder(ctx, recorder);
|
|
62
105
|
const othersWrote = awaits ? watchOtherWrites(ctx) : () => false;
|
|
63
|
-
|
|
106
|
+
const finish = (failed) => {
|
|
107
|
+
if (awaits) releaseOpenRecorder(ctx, recorder);
|
|
64
108
|
const others = othersWrote();
|
|
65
|
-
const change = finish();
|
|
109
|
+
const change = recorder.finish();
|
|
66
110
|
const empty = isEmptyDocumentChange(change);
|
|
67
111
|
if (failed && options.rollbackOnThrow && !empty && !others && options.canRollBack?.() !== false && rollBack(ctx, graph, change)) {
|
|
68
112
|
options.onRecorded?.(unchanged(pageId));
|
|
69
113
|
return;
|
|
70
114
|
}
|
|
71
115
|
if (options.push !== false && !empty) {
|
|
72
|
-
const entry =
|
|
73
|
-
label: options.label,
|
|
74
|
-
forward: () => restoreDocumentChange(ctx, change, "after"),
|
|
75
|
-
inverse: () => restoreDocumentChange(ctx, change, "before")
|
|
76
|
-
};
|
|
116
|
+
const entry = changeStep(ctx, options.label, change);
|
|
77
117
|
if (options.ownStep) ctx.undo.pushStep(entry);
|
|
78
118
|
else ctx.undo.push(entry);
|
|
79
119
|
}
|
|
80
120
|
options.onRecorded?.(change);
|
|
81
121
|
};
|
|
122
|
+
return {
|
|
123
|
+
finish,
|
|
124
|
+
recorder
|
|
125
|
+
};
|
|
82
126
|
}
|
|
83
127
|
/**
|
|
84
128
|
* Runs a synchronous edit as one undo step of everything it changed in the document, also when
|
|
@@ -87,10 +131,10 @@ function begin(ctx, options, awaits = false) {
|
|
|
87
131
|
* edit, and joins a batch open around it.
|
|
88
132
|
*/
|
|
89
133
|
function recordEdit(ctx, options, run) {
|
|
90
|
-
const finish = begin(ctx, options);
|
|
134
|
+
const { finish, recorder } = begin(ctx, options);
|
|
91
135
|
let failed = true;
|
|
92
136
|
try {
|
|
93
|
-
const result = run
|
|
137
|
+
const result = withOpenEditsPaused(ctx, run, recorder);
|
|
94
138
|
failed = false;
|
|
95
139
|
return result;
|
|
96
140
|
} finally {
|
|
@@ -108,7 +152,7 @@ function recordEdit(ctx, options, run) {
|
|
|
108
152
|
* instead.
|
|
109
153
|
*/
|
|
110
154
|
async function recordEditAsync(ctx, options, run) {
|
|
111
|
-
const finish = begin(ctx, {
|
|
155
|
+
const { finish } = begin(ctx, {
|
|
112
156
|
...options,
|
|
113
157
|
ownStep: true
|
|
114
158
|
}, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.js","names":[],"sources":["../../../src/editor/history/edit.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport type { UndoManager } from '@pairdraw/scene-graph/undo'\n\nimport {\n applyDocumentChange,\n captureDocumentChange,\n isEmptyDocumentChange,\n restoreDocumentChange,\n type DocumentChange\n} from '#core/editor/history/document-change'\nimport type { EditorContext } from '#core/editor/types'\n\nexport interface RecordEditOptions {\n /** The undo step's label. */\n label: string\n /** The page the edit is made from; it is recorded wherever in the document it lands. */\n pageId?: string\n /** False for an edit that records its own steps, such as an atomic tool's. */\n push?: boolean\n /**\n * Records the step on its own, settling any batch first, rather than as part of an open batch.\n * An edit that finishes after an await needs this: a batch open by then belongs to another\n * edit, such as a picker drag. `recordEditAsync` always does.\n */\n ownStep?: boolean\n /**\n * Puts back everything the edit changed when it throws, so a failed agent call or script leaves\n * the document as it found it and records no step. Undoing it costs what the edit touched, not\n * a copy of the document. Without it, or when something else wrote to the document while the\n * edit ran, what the edit did before it threw stays as one step.\n */\n rollbackOnThrow?: boolean\n /**\n * Whether nothing outside the editor's history wrote to the document since the edit began, such\n * as a collaborator. Asked once the edit has thrown; false records the edit's step instead of a\n * rollback that would revert those writes too. Writes the history sees are checked anyway.\n */\n canRollBack?: () => boolean\n /**\n * Receives what the edit changed, also when it fails, before its step closes. An edit rolled\n * back after it threw changed nothing.\n */\n onRecorded?: (change: DocumentChange) => void\n}\n\nfunction unchanged(pageId: string): DocumentChange {\n return {\n pageId,\n pageIds: [],\n created: [],\n deleted: [],\n updated: [],\n children: { before: [], after: [] },\n variables: [],\n collections: []\n }\n}\n\n/** How many edits that await are running in each history. */\nconst runningEdits = new WeakMap<UndoManager, number>()\n\n/**\n * Watches, while an edit awaits, for writes it does not own: a step recorded, undone, or redone,\n * another edit or a batch open, or text being edited. They land in the edit's change, so rolling\n * it back would revert them too. Returns the function that stops watching and tells.\n */\nfunction watchOtherWrites(ctx: EditorContext): () => boolean {\n const { undo } = ctx\n const running = runningEdits.get(undo) ?? 0\n let others = running > 0 || undo.isRecording || ctx.state.editingTextId !== null\n runningEdits.set(undo, running + 1)\n const stop = ctx.onEditorEvent('history:changed', () => {\n others = true\n })\n return () => {\n stop()\n const left = (runningEdits.get(undo) ?? 1) - 1\n runningEdits.set(undo, left)\n return others || left > 0 || undo.isBatching || ctx.state.editingTextId !== null\n }\n}\n\n/**\n * Puts the document back as it was before a failed edit, keeping the selection the edit left\n * alone; false when that failed too, and the edit's step is then recorded instead, so what it did\n * stays undoable.\n */\nfunction rollBack(ctx: EditorContext, graph: SceneGraph, change: DocumentChange): boolean {\n try {\n if (ctx.graph !== graph) {\n // The document the edit ran in is no longer shown, so only its graph goes back.\n applyDocumentChange(graph, change, 'before')\n return true\n }\n restoreDocumentChange(ctx, change, 'before', { keepSelection: true })\n } catch {\n return false\n }\n // The document is back where its history left it, so what follows the history, such as its\n // unsaved state, settles as after an undo.\n ctx.emitEditorEvent('history:changed')\n return true\n}\n\nfunction begin(ctx: EditorContext, options: RecordEditOptions, awaits = false) {\n const graph = ctx.graph\n const pageId = options.pageId ?? ctx.state.currentPageId\n const finish = captureDocumentChange(graph, pageId)\n // A synchronous edit runs alone; one that awaits shares the document while it waits.\n const othersWrote = awaits ? watchOtherWrites(ctx) : () => false\n return (failed: boolean) => {\n const others = othersWrote()\n const change = finish()\n const empty = isEmptyDocumentChange(change)\n if (\n failed &&\n options.rollbackOnThrow &&\n !empty &&\n !others &&\n options.canRollBack?.() !== false &&\n rollBack(ctx, graph, change)\n ) {\n options.onRecorded?.(unchanged(pageId))\n return\n }\n // An edit that changed nothing, such as a read-only script, leaves no empty step behind.\n if (options.push !== false && !empty) {\n const entry = {\n label: options.label,\n forward: () => restoreDocumentChange(ctx, change, 'after'),\n inverse: () => restoreDocumentChange(ctx, change, 'before')\n }\n if (options.ownStep) ctx.undo.pushStep(entry)\n else ctx.undo.push(entry)\n }\n options.onRecorded?.(change)\n }\n}\n\n/**\n * Runs a synchronous edit as one undo step of everything it changed in the document, also when\n * it throws part way, so what it did stays undoable, unless `rollbackOnThrow` puts it back. Its\n * step is recorded in the same task as its changes, as the document's unsaved state expects of an\n * edit, and joins a batch open around it.\n */\nexport function recordEdit<T>(ctx: EditorContext, options: RecordEditOptions, run: () => T): T {\n const finish = begin(ctx, options)\n let failed = true\n try {\n const result = run()\n failed = false\n return result\n } finally {\n finish(failed)\n }\n}\n\n/**\n * Runs an edit that awaits before it finishes, such as an agent's tool call that loads fonts or\n * runs a layout, as one undo step. The edit stays open until its step is recorded, so the changes\n * it makes meanwhile count as its own rather than as edits outside the history. An edit made\n * elsewhere while it runs, such as the user's, lands in the same step: nothing tells whose write\n * is whose across an await. So `rollbackOnThrow` rolls back only an edit nothing else wrote\n * beside, as far as the history and `canRollBack` can tell, and otherwise records its step. An\n * edit that can compute first and apply in one go records only the apply with `recordEdit`\n * instead.\n */\nexport async function recordEditAsync<T>(\n ctx: EditorContext,\n options: RecordEditOptions,\n run: () => Promise<T>\n): Promise<T> {\n // Capturing can throw; the edit opens only once it has, so a failure never leaves it open.\n const finish = begin(ctx, { ...options, ownStep: true }, true)\n const close = ctx.undo.openEdit()\n let failed = true\n try {\n const result = await run()\n failed = false\n return result\n } finally {\n try {\n finish(failed)\n } finally {\n close()\n }\n }\n}\n"],"mappings":";;AA6CA,SAAS,UAAU,QAAgC;CACjD,OAAO;EACL;EACA,SAAS,CAAC;EACV,SAAS,CAAC;EACV,SAAS,CAAC;EACV,SAAS,CAAC;EACV,UAAU;GAAE,QAAQ,CAAC;GAAG,OAAO,CAAC;EAAE;EAClC,WAAW,CAAC;EACZ,aAAa,CAAC;CAChB;AACF;;AAGA,MAAM,+BAAe,IAAI,QAA6B;;;;;;AAOtD,SAAS,iBAAiB,KAAmC;CAC3D,MAAM,EAAE,SAAS;CACjB,MAAM,UAAU,aAAa,IAAI,IAAI,KAAK;CAC1C,IAAI,SAAS,UAAU,KAAK,KAAK,eAAe,IAAI,MAAM,kBAAkB;CAC5E,aAAa,IAAI,MAAM,UAAU,CAAC;CAClC,MAAM,OAAO,IAAI,cAAc,yBAAyB;EACtD,SAAS;CACX,CAAC;CACD,aAAa;EACX,KAAK;EACL,MAAM,QAAQ,aAAa,IAAI,IAAI,KAAK,KAAK;EAC7C,aAAa,IAAI,MAAM,IAAI;EAC3B,OAAO,UAAU,OAAO,KAAK,KAAK,cAAc,IAAI,MAAM,kBAAkB;CAC9E;AACF;;;;;;AAOA,SAAS,SAAS,KAAoB,OAAmB,QAAiC;CACxF,IAAI;EACF,IAAI,IAAI,UAAU,OAAO;GAEvB,oBAAoB,OAAO,QAAQ,QAAQ;GAC3C,OAAO;EACT;EACA,sBAAsB,KAAK,QAAQ,UAAU,EAAE,eAAe,KAAK,CAAC;CACtE,QAAQ;EACN,OAAO;CACT;CAGA,IAAI,gBAAgB,iBAAiB;CACrC,OAAO;AACT;AAEA,SAAS,MAAM,KAAoB,SAA4B,SAAS,OAAO;CAC7E,MAAM,QAAQ,IAAI;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":["../../../src/editor/history/edit.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport type { UndoEntry, UndoManager } from '@pairdraw/scene-graph/undo'\n\nimport {\n applyDocumentChange,\n isEmptyDocumentChange,\n recordDocumentChange,\n restoreDocumentChange,\n type DocumentChange,\n type DocumentChangeRecorder\n} from '#core/editor/history/document-change'\nimport type { EditorContext } from '#core/editor/types'\n\nexport interface RecordEditOptions {\n /** The undo step's label. */\n label: string\n /** The page the edit is made from; it is recorded wherever in the document it lands. */\n pageId?: string\n /** False for an edit that records its own steps, such as an atomic tool's. */\n push?: boolean\n /**\n * Records the step on its own, settling any batch first, rather than as part of an open batch.\n * An edit that finishes after an await needs this: a batch open by then belongs to another\n * edit, such as a picker drag. `recordEditAsync` always does.\n */\n ownStep?: boolean\n /**\n * Puts back everything the edit changed when it throws, so a failed agent call or script leaves\n * the document as it found it and records no step. Undoing it costs what the edit touched, not\n * a copy of the document. Without it, or when something else wrote to the document while the\n * edit ran, what the edit did before it threw stays as one step.\n */\n rollbackOnThrow?: boolean\n /**\n * Whether nothing outside the editor's history wrote to the document since the edit began, such\n * as a collaborator. Asked once the edit has thrown; false records the edit's step instead of a\n * rollback that would revert those writes too. Writes the history sees are checked anyway.\n */\n canRollBack?: () => boolean\n /**\n * Receives what the edit changed, also when it fails, before its step closes. An edit rolled\n * back after it threw changed nothing.\n */\n onRecorded?: (change: DocumentChange) => void\n}\n\nfunction unchanged(pageId: string): DocumentChange {\n return {\n pageId,\n pageIds: [],\n created: [],\n deleted: [],\n updated: [],\n children: { before: [], after: [] },\n variables: [],\n collections: []\n }\n}\n\n/**\n * The undo step of a recorded change. Built outside the edit's own scope, so the step keeps only\n * the change: not the edit's recording state, nor its options, whose `onRecorded` can hold the\n * step before it and so every step back to the first, past the history limit.\n */\nfunction changeStep(ctx: EditorContext, label: string, change: DocumentChange): UndoEntry {\n return {\n label,\n forward: () => restoreDocumentChange(ctx, change, 'after'),\n inverse: () => restoreDocumentChange(ctx, change, 'before')\n }\n}\n\n/** How many edits that await are running in each history. */\nconst runningEdits = new WeakMap<UndoManager, number>()\n\n/** The recorders of edits still open in each editor, which anyone else's edit waits outside. */\nconst openRecorders = new WeakMap<EditorContext, Set<DocumentChangeRecorder>>()\n\nfunction keepOpenRecorder(ctx: EditorContext, recorder: DocumentChangeRecorder): void {\n let recorders = openRecorders.get(ctx)\n if (!recorders) {\n recorders = new Set()\n openRecorders.set(ctx, recorders)\n }\n recorders.add(recorder)\n}\n\nfunction releaseOpenRecorder(ctx: EditorContext, recorder: DocumentChangeRecorder): void {\n const recorders = openRecorders.get(ctx)\n if (!recorders) return\n recorders.delete(recorder)\n if (recorders.size === 0) openRecorders.delete(ctx)\n}\n\n/**\n * Runs a separate edit, or an undo or redo, while the edits that are still open treat what it\n * changes as someone else's: their steps leave it alone. The edit is synchronous, so nothing it\n * runs interleaves with their awaits.\n */\nfunction withOpenEditsPaused<T>(ctx: EditorContext, run: () => T, own?: DocumentChangeRecorder): T {\n const recorders = [...(openRecorders.get(ctx) ?? [])].filter((recorder) => recorder !== own)\n for (const recorder of recorders) recorder.pause()\n try {\n return run()\n } finally {\n for (const recorder of recorders) recorder.resume()\n }\n}\n\n/**\n * Watches, while an edit awaits, for writes it does not own: a step recorded, undone, or redone,\n * another edit or a batch open, or text being edited. They land in the edit's change, so rolling\n * it back would revert them too. Returns the function that stops watching and tells.\n */\nfunction watchOtherWrites(ctx: EditorContext): () => boolean {\n const { undo } = ctx\n const running = runningEdits.get(undo) ?? 0\n let others = running > 0 || undo.isRecording || ctx.state.editingTextId !== null\n runningEdits.set(undo, running + 1)\n const stop = ctx.onEditorEvent('history:changed', () => {\n others = true\n })\n return () => {\n stop()\n const left = (runningEdits.get(undo) ?? 1) - 1\n runningEdits.set(undo, left)\n return others || left > 0 || undo.isBatching || ctx.state.editingTextId !== null\n }\n}\n\n/**\n * Puts the document back as it was before a failed edit, keeping the selection the edit left\n * alone; false when that failed too, and the edit's step is then recorded instead, so what it did\n * stays undoable.\n */\nfunction rollBack(ctx: EditorContext, graph: SceneGraph, change: DocumentChange): boolean {\n try {\n if (ctx.graph !== graph) {\n // The document the edit ran in is no longer shown, so only its graph goes back.\n applyDocumentChange(graph, change, 'before')\n return true\n }\n restoreDocumentChange(ctx, change, 'before', { keepSelection: true })\n } catch {\n return false\n }\n // The document is back where its history left it, so what follows the history, such as its\n // unsaved state, settles as after an undo.\n ctx.emitEditorEvent('history:changed')\n return true\n}\n\nfunction begin(ctx: EditorContext, options: RecordEditOptions, awaits = false) {\n const graph = ctx.graph\n const pageId = options.pageId ?? ctx.state.currentPageId\n const recorder = recordDocumentChange(graph, pageId)\n if (awaits) keepOpenRecorder(ctx, recorder)\n // A synchronous edit runs alone; one that awaits shares the document while it waits.\n const othersWrote = awaits ? watchOtherWrites(ctx) : () => false\n const finish = (failed: boolean) => {\n if (awaits) releaseOpenRecorder(ctx, recorder)\n const others = othersWrote()\n const change = recorder.finish()\n const empty = isEmptyDocumentChange(change)\n if (\n failed &&\n options.rollbackOnThrow &&\n !empty &&\n !others &&\n options.canRollBack?.() !== false &&\n rollBack(ctx, graph, change)\n ) {\n options.onRecorded?.(unchanged(pageId))\n return\n }\n // An edit that changed nothing, such as a read-only script, leaves no empty step behind.\n if (options.push !== false && !empty) {\n const entry = changeStep(ctx, options.label, change)\n if (options.ownStep) ctx.undo.pushStep(entry)\n else ctx.undo.push(entry)\n }\n options.onRecorded?.(change)\n }\n return { finish, recorder }\n}\n\n/**\n * Runs a synchronous edit as one undo step of everything it changed in the document, also when\n * it throws part way, so what it did stays undoable, unless `rollbackOnThrow` puts it back. Its\n * step is recorded in the same task as its changes, as the document's unsaved state expects of an\n * edit, and joins a batch open around it.\n */\nexport function recordEdit<T>(ctx: EditorContext, options: RecordEditOptions, run: () => T): T {\n const { finish, recorder } = begin(ctx, options)\n let failed = true\n try {\n // An edit that awaits meanwhile keeps what this one changes out of its step.\n const result = withOpenEditsPaused(ctx, run, recorder)\n failed = false\n return result\n } finally {\n finish(failed)\n }\n}\n\n/**\n * Runs an edit that awaits before it finishes, such as an agent's tool call that loads fonts or\n * runs a layout, as one undo step. The edit stays open until its step is recorded, so the changes\n * it makes meanwhile count as its own rather than as edits outside the history. An edit made\n * elsewhere while it runs, such as the user's, lands in the same step: nothing tells whose write\n * is whose across an await. So `rollbackOnThrow` rolls back only an edit nothing else wrote\n * beside, as far as the history and `canRollBack` can tell, and otherwise records its step. An\n * edit that can compute first and apply in one go records only the apply with `recordEdit`\n * instead.\n */\nexport async function recordEditAsync<T>(\n ctx: EditorContext,\n options: RecordEditOptions,\n run: () => Promise<T>\n): Promise<T> {\n // Capturing can throw; the edit opens only once it has, so a failure never leaves it open.\n const { finish } = begin(ctx, { ...options, ownStep: true }, true)\n const close = ctx.undo.openEdit()\n let failed = true\n try {\n const result = await run()\n failed = false\n return result\n } finally {\n try {\n finish(failed)\n } finally {\n close()\n }\n }\n}\n"],"mappings":";;AA8CA,SAAS,UAAU,QAAgC;CACjD,OAAO;EACL;EACA,SAAS,CAAC;EACV,SAAS,CAAC;EACV,SAAS,CAAC;EACV,SAAS,CAAC;EACV,UAAU;GAAE,QAAQ,CAAC;GAAG,OAAO,CAAC;EAAE;EAClC,WAAW,CAAC;EACZ,aAAa,CAAC;CAChB;AACF;;;;;;AAOA,SAAS,WAAW,KAAoB,OAAe,QAAmC;CACxF,OAAO;EACL;EACA,eAAe,sBAAsB,KAAK,QAAQ,OAAO;EACzD,eAAe,sBAAsB,KAAK,QAAQ,QAAQ;CAC5D;AACF;;AAGA,MAAM,+BAAe,IAAI,QAA6B;;AAGtD,MAAM,gCAAgB,IAAI,QAAoD;AAE9E,SAAS,iBAAiB,KAAoB,UAAwC;CACpF,IAAI,YAAY,cAAc,IAAI,GAAG;CACrC,IAAI,CAAC,WAAW;EACd,4BAAY,IAAI,IAAI;EACpB,cAAc,IAAI,KAAK,SAAS;CAClC;CACA,UAAU,IAAI,QAAQ;AACxB;AAEA,SAAS,oBAAoB,KAAoB,UAAwC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,UAAU;GACR,MAAM;EACR;CACF;AACF"}
|
|
@@ -30,10 +30,7 @@ function commitPositionChange(ctx, label, originals) {
|
|
|
30
30
|
})) pushPositionUndo(ctx, label, originals, finals);
|
|
31
31
|
}
|
|
32
32
|
function applyPositions(ctx, positions) {
|
|
33
|
-
for (const [id, pos] of positions)
|
|
34
|
-
ctx.graph.updateNode(id, pos);
|
|
35
|
-
ctx.runLayoutForNode(id);
|
|
36
|
-
}
|
|
33
|
+
for (const [id, pos] of positions) ctx.graph.updateNode(id, pos);
|
|
37
34
|
}
|
|
38
35
|
//#endregion
|
|
39
36
|
export { collectNodePositions, commitPositionChange, pushPositionUndo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"position.js","names":[],"sources":["../../../src/editor/history/position.ts"],"sourcesContent":["import type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport type { EditorContext } from '#core/editor/types'\n\nexport function collectNodePositions(\n ctx: EditorContext,\n ids: Iterable<string>\n): Map<string, Vector> {\n const positions = new Map<string, Vector>()\n for (const id of ids) {\n const node = ctx.graph.getNode(id)\n if (node) positions.set(id, { x: node.x, y: node.y })\n }\n return positions\n}\n\nexport function pushPositionUndo(\n ctx: EditorContext,\n label: string,\n originals: Map<string, Vector>,\n finals: Map<string, Vector>\n): void {\n ctx.undo.push({\n label,\n forward: () => applyPositions(ctx, finals),\n inverse: () => applyPositions(ctx, originals)\n })\n}\n\n/**\n * Lays the moved layers out, then records one undo step from `originals` to where they ended up.\n * Layers an auto layout holds in place snap back, so an edit that moves nothing records nothing.\n */\nexport function commitPositionChange(\n ctx: EditorContext,\n label: string,\n originals: Map<string, Vector>\n): void {\n for (const id of originals.keys()) ctx.runLayoutForNode(id)\n const finals = collectNodePositions(ctx, originals.keys())\n const moved = [...finals].some(([id, place]) => {\n const before = originals.get(id)\n return !before || before.x !== place.x || before.y !== place.y\n })\n if (moved) pushPositionUndo(ctx, label, originals, finals)\n}\n\nfunction applyPositions(ctx: EditorContext, positions: Map<string, Vector>): void {\n for (const [id, pos] of positions)
|
|
1
|
+
{"version":3,"file":"position.js","names":[],"sources":["../../../src/editor/history/position.ts"],"sourcesContent":["import type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport type { EditorContext } from '#core/editor/types'\n\nexport function collectNodePositions(\n ctx: EditorContext,\n ids: Iterable<string>\n): Map<string, Vector> {\n const positions = new Map<string, Vector>()\n for (const id of ids) {\n const node = ctx.graph.getNode(id)\n if (node) positions.set(id, { x: node.x, y: node.y })\n }\n return positions\n}\n\nexport function pushPositionUndo(\n ctx: EditorContext,\n label: string,\n originals: Map<string, Vector>,\n finals: Map<string, Vector>\n): void {\n ctx.undo.push({\n label,\n forward: () => applyPositions(ctx, finals),\n inverse: () => applyPositions(ctx, originals)\n })\n}\n\n/**\n * Lays the moved layers out, then records one undo step from `originals` to where they ended up.\n * Layers an auto layout holds in place snap back, so an edit that moves nothing records nothing.\n */\nexport function commitPositionChange(\n ctx: EditorContext,\n label: string,\n originals: Map<string, Vector>\n): void {\n for (const id of originals.keys()) ctx.runLayoutForNode(id)\n const finals = collectNodePositions(ctx, originals.keys())\n const moved = [...finals].some(([id, place]) => {\n const before = originals.get(id)\n return !before || before.x !== place.x || before.y !== place.y\n })\n if (moved) pushPositionUndo(ctx, label, originals, finals)\n}\n\nfunction applyPositions(ctx: EditorContext, positions: Map<string, Vector>): void {\n for (const [id, pos] of positions) ctx.graph.updateNode(id, pos)\n}\n"],"mappings":";AAIA,SAAgB,qBACd,KACA,KACqB;CACrB,MAAM,4BAAY,IAAI,IAAoB;CAC1C,KAAK,MAAM,MAAM,KAAK;EACpB,MAAM,OAAO,IAAI,MAAM,QAAQ,EAAE;EACjC,IAAI,MAAM,UAAU,IAAI,IAAI;GAAE,GAAG,KAAK;GAAG,GAAG,KAAK;EAAE,CAAC;CACtD;CACA,OAAO;AACT;AAEA,SAAgB,iBACd,KACA,OACA,WACA,QACM;CACN,IAAI,KAAK,KAAK;EACZ;EACA,eAAe,eAAe,KAAK,MAAM;EACzC,eAAe,eAAe,KAAK,SAAS;CAC9C,CAAC;AACH;;;;;AAMA,SAAgB,qBACd,KACA,OACA,WACM;CACN,KAAK,MAAM,MAAM,UAAU,KAAK,GAAG,IAAI,iBAAiB,EAAE;CAC1D,MAAM,SAAS,qBAAqB,KAAK,UAAU,KAAK,CAAC;CAKzD,IAJc,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,WAAW;EAC9C,MAAM,SAAS,UAAU,IAAI,EAAE;EAC/B,OAAO,CAAC,UAAU,OAAO,MAAM,MAAM,KAAK,OAAO,MAAM,MAAM;CAC/D,CACQ,GAAG,iBAAiB,KAAK,OAAO,WAAW,MAAM;AAC3D;AAEA,SAAS,eAAe,KAAoB,WAAsC;CAChF,KAAK,MAAM,CAAC,IAAI,QAAQ,WAAW,IAAI,MAAM,WAAW,IAAI,GAAG;AACjE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
|
+
//#region src/editor/history/sources.d.ts
|
|
3
|
+
/** A node's source metadata as it stood at one point, by node id. */
|
|
4
|
+
type SourceSnapshots = Map<string, SceneNode['source']>;
|
|
5
|
+
/**
|
|
6
|
+
* The source marks of these layers. A recorded edit restores them with the values it restores,
|
|
7
|
+
* so undoing the last edit leaves a layer as it was, its edited-field marks included.
|
|
8
|
+
*/
|
|
9
|
+
declare function captureSources(graph: SceneGraph, ids: Iterable<string>): SourceSnapshots;
|
|
10
|
+
/** Puts the marks back without touching values, so the graph does not mark them again. */
|
|
11
|
+
declare function restoreSources(graph: SceneGraph, sources: SourceSnapshots | undefined): void;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { SourceSnapshots, captureSources, restoreSources };
|
|
14
|
+
//# sourceMappingURL=sources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sources.d.ts","names":[],"sources":["../../../src/editor/history/sources.ts"],"mappings":";;;KAGY,kBAAkB,YAAY;;;;;iBAM1B,eAAe,OAAO,YAAY,KAAK,mBAAmB;;iBAU1D,eAAe,OAAO,YAAY,SAAS"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/editor/history/sources.ts
|
|
2
|
+
/**
|
|
3
|
+
* The source marks of these layers. A recorded edit restores them with the values it restores,
|
|
4
|
+
* so undoing the last edit leaves a layer as it was, its edited-field marks included.
|
|
5
|
+
*/
|
|
6
|
+
function captureSources(graph, ids) {
|
|
7
|
+
const sources = /* @__PURE__ */ new Map();
|
|
8
|
+
for (const id of ids) {
|
|
9
|
+
const node = graph.getNode(id);
|
|
10
|
+
if (node) sources.set(id, structuredClone(node.source));
|
|
11
|
+
}
|
|
12
|
+
return sources;
|
|
13
|
+
}
|
|
14
|
+
/** Puts the marks back without touching values, so the graph does not mark them again. */
|
|
15
|
+
function restoreSources(graph, sources) {
|
|
16
|
+
if (!sources) return;
|
|
17
|
+
graph.preserveSourceMetadataDuring(() => {
|
|
18
|
+
for (const [id, source] of sources) graph.restoreNodeProperties(id, { source }, []);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { captureSources, restoreSources };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sources.js","names":[],"sources":["../../../src/editor/history/sources.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\n/** A node's source metadata as it stood at one point, by node id. */\nexport type SourceSnapshots = Map<string, SceneNode['source']>\n\n/**\n * The source marks of these layers. A recorded edit restores them with the values it restores,\n * so undoing the last edit leaves a layer as it was, its edited-field marks included.\n */\nexport function captureSources(graph: SceneGraph, ids: Iterable<string>): SourceSnapshots {\n const sources: SourceSnapshots = new Map()\n for (const id of ids) {\n const node = graph.getNode(id)\n if (node) sources.set(id, structuredClone(node.source))\n }\n return sources\n}\n\n/** Puts the marks back without touching values, so the graph does not mark them again. */\nexport function restoreSources(graph: SceneGraph, sources: SourceSnapshots | undefined): void {\n if (!sources) return\n graph.preserveSourceMetadataDuring(() => {\n for (const [id, source] of sources) graph.restoreNodeProperties(id, { source }, [])\n })\n}\n"],"mappings":";;;;;AASA,SAAgB,eAAe,OAAmB,KAAwC;CACxF,MAAM,0BAA2B,IAAI,IAAI;CACzC,KAAK,MAAM,MAAM,KAAK;EACpB,MAAM,OAAO,MAAM,QAAQ,EAAE;EAC7B,IAAI,MAAM,QAAQ,IAAI,IAAI,gBAAgB,KAAK,MAAM,CAAC;CACxD;CACA,OAAO;AACT;;AAGA,SAAgB,eAAe,OAAmB,SAA4C;CAC5F,IAAI,CAAC,SAAS;CACd,MAAM,mCAAmC;EACvC,KAAK,MAAM,CAAC,IAAI,WAAW,SAAS,MAAM,sBAAsB,IAAI,EAAE,OAAO,GAAG,CAAC,CAAC;CACpF,CAAC;AACH"}
|
package/dist/editor/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AttachModifiers } from "./connectors/attach.js";
|
|
|
2
2
|
import { DEFAULT_SNAPPING_PREFERENCES, SnappingPreferences } from "./preferences.js";
|
|
3
3
|
import { ShaderRasterizer } from "./shaders/types.js";
|
|
4
4
|
import { CanvasView, EditorProfile, EditorProfileInputs, EditorRestrictions, PresentationScale, ShaderView } from "./views/types.js";
|
|
5
|
-
import { ClipboardImageResolution, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, ResumedPath, ShapeHandleHover, Tool } from "./types.js";
|
|
5
|
+
import { ClipboardImageResolution, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas } from "./types.js";
|
|
6
6
|
import { ClipboardCollectionDependency, ClipboardConflictResolution, ClipboardImportChoice, ClipboardImportPlan, ClipboardStyleDependency, clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./clipboard/conflicts.js";
|
|
7
7
|
import { ClipboardSnapshot } from "./clipboard/snapshot.js";
|
|
8
8
|
import { ClipboardPayload, CopyOptions } from "./clipboard/copy.js";
|
|
@@ -54,4 +54,4 @@ import { LayerType, layerTypeOptions } from "./structure/layer-type.js";
|
|
|
54
54
|
import { BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, EDITOR_TOOLS, EditorToolDef, TOOL_SHORTCUTS } from "./tool-registry.js";
|
|
55
55
|
import { newLayerDefaults } from "./shapes/defaults.js";
|
|
56
56
|
import { RenameSelectionOptions, RenameSelectionPreview } from "./structure/rename.js";
|
|
57
|
-
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, type DocumentChange, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
|
57
|
+
export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, type DocumentChange, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
|
package/dist/editor/index.js
CHANGED
|
@@ -17,10 +17,10 @@ import { isEmptyDocumentChange, touchedTopLevelIds } from "./history/document-ch
|
|
|
17
17
|
import { resolvePasteTarget } from "./clipboard/paste/target.js";
|
|
18
18
|
import { clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./clipboard/conflicts.js";
|
|
19
19
|
import { reapplyInstanceComponentProperties } from "./components/properties.js";
|
|
20
|
+
import { newLayerDefaults } from "./shapes/defaults.js";
|
|
20
21
|
import { pastedPropertyChanges } from "./clipboard/paste/properties.js";
|
|
21
22
|
import { syncEditedComponents } from "./component-sync.js";
|
|
22
23
|
import { resizedPathTextGlyphs } from "./text/path-edit.js";
|
|
23
|
-
import { newLayerDefaults } from "./shapes/defaults.js";
|
|
24
24
|
import { createGuideActions } from "./guides.js";
|
|
25
25
|
import { opacityFromBuffer } from "./nodes.js";
|
|
26
26
|
import { DEFAULT_SCALE_ANCHOR, SCALE_ANCHORS, isScaleAnchor, parseScaleFactor, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds } from "./scale/anchor.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout-mode.d.ts","names":[],"sources":["../../src/editor/layout-mode.ts"],"mappings":";;;;iBAKgB,wBACd,KAAK,eACL,mBAAmB,kBAAkB;EAOV,gBAAA,YAAM,MAAQ;
|
|
1
|
+
{"version":3,"file":"layout-mode.d.ts","names":[],"sources":["../../src/editor/layout-mode.ts"],"mappings":";;;;iBAKgB,wBACd,KAAK,eACL,mBAAmB,kBAAkB;EAOV,gBAAA,YAAM,MAAQ;EAeN,uBAAA,eAAQ,aAAe"}
|
|
@@ -9,6 +9,7 @@ function createLayoutModeActions(ctx, beginNodePreview) {
|
|
|
9
9
|
const node = ctx.graph.getNode(id);
|
|
10
10
|
if (!node || node.layoutMode === mode) return;
|
|
11
11
|
const preview = beginNodePreview(mode === "NONE" ? "Remove auto layout" : "Add auto layout");
|
|
12
|
+
if (node.type === "GROUP" && mode !== "NONE") preview.update(id, { type: "FRAME" });
|
|
12
13
|
preview.update(id, layoutModeUpdates(ctx, node, id, mode));
|
|
13
14
|
preview.commit();
|
|
14
15
|
}
|
|
@@ -46,7 +47,21 @@ function createLayoutModeActions(ctx, beginNodePreview) {
|
|
|
46
47
|
function layoutModeUpdates(ctx, node, id, mode) {
|
|
47
48
|
const updates = { layoutMode: mode };
|
|
48
49
|
if (mode === "GRID" && node.layoutMode !== "GRID") applyGridDefaults(ctx, node, id, updates);
|
|
49
|
-
else if (mode
|
|
50
|
+
else if (mode === "NONE") Object.assign(updates, {
|
|
51
|
+
itemSpacing: 0,
|
|
52
|
+
paddingTop: 0,
|
|
53
|
+
paddingRight: 0,
|
|
54
|
+
paddingBottom: 0,
|
|
55
|
+
paddingLeft: 0,
|
|
56
|
+
primaryAxisSizing: "FIXED",
|
|
57
|
+
counterAxisSizing: "FIXED",
|
|
58
|
+
layoutWrap: "NO_WRAP",
|
|
59
|
+
primaryAxisAlign: "MIN",
|
|
60
|
+
counterAxisAlign: "MIN",
|
|
61
|
+
counterAxisSpacing: 0,
|
|
62
|
+
layoutDirection: "AUTO"
|
|
63
|
+
});
|
|
64
|
+
else if (node.layoutMode === "NONE") Object.assign(updates, autoLayoutDefaults());
|
|
50
65
|
return updates;
|
|
51
66
|
}
|
|
52
67
|
function applyGridDefaults(ctx, node, id, updates) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout-mode.js","names":[],"sources":["../../src/editor/layout-mode.ts"],"sourcesContent":["import type { LayoutMode, SceneNode } from '@pairdraw/scene-graph'\n\nimport type { NodePreview } from './node-preview'\nimport type { EditorContext } from './types'\n\nexport function createLayoutModeActions(\n ctx: EditorContext,\n beginNodePreview: (label: string) => NodePreview\n) {\n /**\n * Adding, switching, or removing auto layout moves and resizes children, nested layouts, and\n * Hug ancestors. A node preview records every layer it changes, so one undo puts them all back\n * where they were; setting the mode a frame already has records nothing.\n */\n function setLayoutMode(id: string, mode: LayoutMode) {\n const node = ctx.graph.getNode(id)\n if (!node || node.layoutMode === mode) return\n const preview = beginNodePreview(mode === 'NONE' ? 'Remove auto layout' : 'Add auto layout')\n preview.update(id, layoutModeUpdates(ctx, node, id, mode))\n preview.commit()\n }\n\n /**\n * Takes layers out of their parent's auto layout or puts them back, as Figma's Ignore auto\n * layout toggle does. A layer taken out stays where it is and keeps its sizing, which applies\n * again when it returns; its siblings close the gap in the same undo step.\n */\n function setLayoutPositioning(ids: string[], positioning: SceneNode['layoutPositioning']) {\n // Read every place first: taking one layer out moves the siblings after it.\n const targets = ids.flatMap((id) => {\n const node = ctx.graph.getNode(id)\n const parent = node?.parentId ? ctx.graph.getNode(node.parentId) : undefined\n if (!node || !parent || parent.layoutMode === 'NONE') return []\n if (node.layoutPositioning === positioning) return []\n return [{ id, x: node.x, y: node.y }]\n })\n if (targets.length === 0) return\n const preview = beginNodePreview(\n positioning === 'ABSOLUTE' ? 'Ignore auto layout' : 'Use auto layout'\n )\n for (const { id, x, y } of targets) {\n preview.update(\n id,\n positioning === 'ABSOLUTE'\n ? { layoutPositioning: positioning, x, y }\n : { layoutPositioning: positioning }\n )\n }\n preview.commit()\n }\n\n return { setLayoutMode, setLayoutPositioning }\n}\n\nfunction layoutModeUpdates(\n ctx: EditorContext,\n node: SceneNode,\n id: string,\n mode: LayoutMode\n): Partial<SceneNode> {\n const updates: Partial<SceneNode> = { layoutMode: mode }\n if (mode === 'GRID' && node.layoutMode !== 'GRID') {\n applyGridDefaults(ctx, node, id, updates)\n } else if (mode
|
|
1
|
+
{"version":3,"file":"layout-mode.js","names":[],"sources":["../../src/editor/layout-mode.ts"],"sourcesContent":["import type { LayoutMode, SceneNode } from '@pairdraw/scene-graph'\n\nimport type { NodePreview } from './node-preview'\nimport type { EditorContext } from './types'\n\nexport function createLayoutModeActions(\n ctx: EditorContext,\n beginNodePreview: (label: string) => NodePreview\n) {\n /**\n * Adding, switching, or removing auto layout moves and resizes children, nested layouts, and\n * Hug ancestors. A node preview records every layer it changes, so one undo puts them all back\n * where they were; setting the mode a frame already has records nothing.\n */\n function setLayoutMode(id: string, mode: LayoutMode) {\n const node = ctx.graph.getNode(id)\n if (!node || node.layoutMode === mode) return\n const preview = beginNodePreview(mode === 'NONE' ? 'Remove auto layout' : 'Add auto layout')\n // A group is only its children's bounds; a flow needs a frame to own it, as Figma converts.\n if (node.type === 'GROUP' && mode !== 'NONE') preview.update(id, { type: 'FRAME' })\n preview.update(id, layoutModeUpdates(ctx, node, id, mode))\n preview.commit()\n }\n\n /**\n * Takes layers out of their parent's auto layout or puts them back, as Figma's Ignore auto\n * layout toggle does. A layer taken out stays where it is and keeps its sizing, which applies\n * again when it returns; its siblings close the gap in the same undo step.\n */\n function setLayoutPositioning(ids: string[], positioning: SceneNode['layoutPositioning']) {\n // Read every place first: taking one layer out moves the siblings after it.\n const targets = ids.flatMap((id) => {\n const node = ctx.graph.getNode(id)\n const parent = node?.parentId ? ctx.graph.getNode(node.parentId) : undefined\n if (!node || !parent || parent.layoutMode === 'NONE') return []\n if (node.layoutPositioning === positioning) return []\n return [{ id, x: node.x, y: node.y }]\n })\n if (targets.length === 0) return\n const preview = beginNodePreview(\n positioning === 'ABSOLUTE' ? 'Ignore auto layout' : 'Use auto layout'\n )\n for (const { id, x, y } of targets) {\n preview.update(\n id,\n positioning === 'ABSOLUTE'\n ? { layoutPositioning: positioning, x, y }\n : { layoutPositioning: positioning }\n )\n }\n preview.commit()\n }\n\n return { setLayoutMode, setLayoutPositioning }\n}\n\nfunction layoutModeUpdates(\n ctx: EditorContext,\n node: SceneNode,\n id: string,\n mode: LayoutMode\n): Partial<SceneNode> {\n const updates: Partial<SceneNode> = { layoutMode: mode }\n if (mode === 'GRID' && node.layoutMode !== 'GRID') {\n applyGridDefaults(ctx, node, id, updates)\n } else if (mode === 'NONE') {\n // A frame with no flow cannot wrap, align or space one, and the format stores none of it, so\n // the frame gives them all up rather than reopening with them dropped.\n Object.assign(updates, {\n itemSpacing: 0,\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n layoutWrap: 'NO_WRAP',\n primaryAxisAlign: 'MIN',\n counterAxisAlign: 'MIN',\n counterAxisSpacing: 0,\n layoutDirection: 'AUTO'\n })\n } else if (node.layoutMode === 'NONE') {\n Object.assign(updates, autoLayoutDefaults())\n }\n return updates\n}\n\nfunction applyGridDefaults(\n ctx: EditorContext,\n node: SceneNode,\n id: string,\n updates: Partial<SceneNode>\n) {\n const children = ctx.graph.getChildren(id)\n const cols = Math.max(2, Math.ceil(Math.sqrt(children.length)))\n const rows = Math.max(1, Math.ceil(children.length / cols))\n updates.gridTemplateColumns = Array.from({ length: cols }, () => ({\n sizing: 'FR' as const,\n value: 1\n }))\n updates.gridTemplateRows = Array.from({ length: rows }, () => ({\n sizing: 'FR' as const,\n value: 1\n }))\n updates.gridColumnGap = 0\n updates.gridRowGap = 0\n updates.primaryAxisSizing = 'FIXED'\n updates.counterAxisSizing = 'FIXED'\n if (node.primaryAxisSizing === 'HUG' || node.counterAxisSizing === 'HUG') {\n const maxChildW = Math.max(...children.map((child) => child.width), 100)\n const maxChildH = Math.max(...children.map((child) => child.height), 100)\n updates.width = maxChildW * cols\n updates.height = maxChildH * rows\n }\n updates.paddingTop = 0\n updates.paddingRight = 0\n updates.paddingBottom = 0\n updates.paddingLeft = 0\n}\n\nfunction autoLayoutDefaults(): Partial<SceneNode> {\n return {\n itemSpacing: 0,\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n primaryAxisSizing: 'HUG',\n counterAxisSizing: 'HUG',\n primaryAxisAlign: 'MIN',\n counterAxisAlign: 'MIN'\n }\n}\n"],"mappings":";AAKA,SAAgB,wBACd,KACA,kBACA;;;;;;CAMA,SAAS,cAAc,IAAY,MAAkB;EACnD,MAAM,OAAO,IAAI,MAAM,QAAQ,EAAE;EACjC,IAAI,CAAC,QAAQ,KAAK,eAAe,MAAM;EACvC,MAAM,UAAU,iBAAiB,SAAS,SAAS,uBAAuB,iBAAiB;EAE3F,IAAI,KAAK,SAAS,WAAW,SAAS,QAAQ,QAAQ,OAAO,IAAI,EAAE,MAAM,QAAQ,CAAC;EA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A,MACA,IACA,SACA;CACA,MAAM,WAAW,IAAI,MAAM,YAAY,EAAE;CACzC,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,KAAK,KAAK,KAAK,SAAS,MAAM,CAAC,CAAC;CAC9D,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,KAAK,SAAS,SAAS,IAAI,CAAC;CAC1D,QAAQ,sBAAsB,MAAM,KAAK,EAAE,QAAQ,KAAK,UAAU;EAChE,QAAQ;EACR,OAAO;CACT,EAAE;CACF,QAAQ,mBAAmB,MAAM,KAAK,EAAE,QAAQ,KAAK,UAAU;EAC7D,QAAQ;EACR,OAAO;CACT,EAAE;CACF,QAAQ,gBAAgB;CACxB,QAAQ,aAAa;CACrB,QAAQ,oBAAoB;CAC5B,QAAQ,oBAAoB;CAC5B,IAAI,KAAK,sBAAsB,SAAS,KAAK,sBAAsB,OAAO;EACxE,MAAM,YAAY,KAAK,IAAI,GAAG,SAAS,KAAK,UAAU,MAAM,KAAK,GAAG,GAAG;EACvE,MAAM,YAAY,KAAK,IAAI,GAAG,SAAS,KAAK,UAAU,MAAM,MAAM,GAAG,GAAG;EACxE,QAAQ,QAAQ,YAAY;EAC5B,QAAQ,SAAS,YAAY;CAC/B;CACA,QAAQ,aAAa;CACrB,QAAQ,eAAe;CACvB,QAAQ,gBAAgB;CACxB,QAAQ,cAAc;AACxB;AAEA,SAAS,qBAAyC;CAChD,OAAO;EACL,aAAa;EACb,YAAY;EACZ,cAAc;EACd,eAAe;EACf,aAAa;EACb,mBAAmB;EACnB,mBAAmB;EACnB,kBAAkB;EAClB,kBAAkB;CACpB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-preview.d.ts","names":[],"sources":["../../src/editor/node-preview.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"node-preview.d.ts","names":[],"sources":["../../src/editor/node-preview.ts"],"mappings":";;;UAWiB;WACN;EACT,SAAS,YAAY,SAAS,QAAQ;EACtC;EACA;;;iBAUc,yBACd,KAAK,eACL,aAAa,YAAY,SAAS,QAAQ;EAQG,mBAAA,mBAAA"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import { groupFitOptions } from "../canvas/boolean.js";
|
|
1
2
|
import { assertNodeEditable } from "./capabilities.js";
|
|
3
|
+
import { restoreSources } from "./history/sources.js";
|
|
2
4
|
import { isEqual, pick, uniq } from "es-toolkit";
|
|
5
|
+
import { fitEnclosingGroups, redoGroupFit, undoGroupFit } from "@pairdraw/scene-graph/group-bounds";
|
|
3
6
|
//#region src/editor/node-preview.ts
|
|
7
|
+
/** Whether an auto layout frame places this layer, so the boxes of the groups above it are theirs. */
|
|
8
|
+
function placedByParent(graph, id) {
|
|
9
|
+
const parent = graph.getNode(graph.getNode(id)?.parentId ?? "");
|
|
10
|
+
return parent !== void 0 && parent.layoutMode !== "NONE";
|
|
11
|
+
}
|
|
4
12
|
/** One owned numeric/property edit, including every node changed by its layout. */
|
|
5
13
|
function createNodePreviewActions(ctx, updateNode) {
|
|
6
14
|
let current = null;
|
|
@@ -13,7 +21,7 @@ function createNodePreviewActions(ctx, updateNode) {
|
|
|
13
21
|
const originals = /* @__PURE__ */ new Map();
|
|
14
22
|
const targets = /* @__PURE__ */ new Set();
|
|
15
23
|
const layoutOnly = /* @__PURE__ */ new Set();
|
|
16
|
-
const
|
|
24
|
+
const sourcesBefore = /* @__PURE__ */ new Map();
|
|
17
25
|
let closed = false;
|
|
18
26
|
let endInteraction;
|
|
19
27
|
const subscriptions = [];
|
|
@@ -30,7 +38,7 @@ function createNodePreviewActions(ctx, updateNode) {
|
|
|
30
38
|
}
|
|
31
39
|
function markEdited(node, changes) {
|
|
32
40
|
if (graph.isPreservingSourceMetadata) return;
|
|
33
|
-
if (!
|
|
41
|
+
if (!sourcesBefore.has(node.id)) sourcesBefore.set(node.id, structuredClone(node.source));
|
|
34
42
|
node.source.editedFields = uniq([...node.source.editedFields, ...Object.keys(changes)]);
|
|
35
43
|
}
|
|
36
44
|
function close() {
|
|
@@ -87,22 +95,33 @@ function createNodePreviewActions(ctx, updateNode) {
|
|
|
87
95
|
if (layoutOnly.has(edit.id)) graph.withLayoutMutations(update);
|
|
88
96
|
else update();
|
|
89
97
|
}
|
|
98
|
+
if (direction === "before") restoreSources(graph, sourcesBefore);
|
|
90
99
|
ctx.requestRender();
|
|
91
100
|
}
|
|
101
|
+
apply("after");
|
|
102
|
+
const parents = uniq(edits.filter((edit) => !placedByParent(graph, edit.id)).map((edit) => graph.getNode(edit.id)?.parentId ?? "")).filter((parentId) => parentId !== "");
|
|
103
|
+
const options = groupFitOptions(ctx.getRenderer(), graph);
|
|
104
|
+
const fits = parents.map((parentId) => fitEnclosingGroups(graph, [parentId], options)).filter((fit) => fit !== null);
|
|
105
|
+
for (const fit of fits) redoGroupFit(graph, fit);
|
|
92
106
|
ctx.undo.push({
|
|
93
107
|
label,
|
|
94
|
-
forward: () =>
|
|
95
|
-
|
|
108
|
+
forward: () => {
|
|
109
|
+
apply("after");
|
|
110
|
+
for (const fit of fits) redoGroupFit(graph, fit);
|
|
111
|
+
},
|
|
112
|
+
inverse: () => {
|
|
113
|
+
for (const fit of fits) undoGroupFit(graph, fit);
|
|
114
|
+
apply("before");
|
|
115
|
+
}
|
|
96
116
|
});
|
|
97
|
-
apply("after");
|
|
98
117
|
},
|
|
99
118
|
cancel() {
|
|
100
119
|
if (closed) return;
|
|
101
120
|
close();
|
|
102
121
|
for (const [id, previous] of originals) graph.updateNodePreview(id, structuredClone(previous));
|
|
103
|
-
for (const [id,
|
|
122
|
+
for (const [id, source] of sourcesBefore) {
|
|
104
123
|
const node = graph.getNode(id);
|
|
105
|
-
if (node) node.source
|
|
124
|
+
if (node) node.source = structuredClone(source);
|
|
106
125
|
}
|
|
107
126
|
if (originals.size) ctx.requestRender();
|
|
108
127
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-preview.js","names":[],"sources":["../../src/editor/node-preview.ts"],"sourcesContent":["import { isEqual, pick, uniq } from 'es-toolkit'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { assertNodeEditable } from './capabilities'\nimport type { EditorContext } from './types'\n\nexport interface NodePreview {\n readonly closed: boolean\n update: (id: string, changes: Partial<SceneNode>) => void\n commit: () => void\n cancel: () => void\n}\n\n/** One owned numeric/property edit, including every node changed by its layout. */\nexport function createNodePreviewActions(\n ctx: EditorContext,\n updateNode: (id: string, changes: Partial<SceneNode>) => void\n) {\n let current: NodePreview | null = null\n\n function cancelNodePreviews() {\n current?.cancel()\n }\n\n function beginNodePreview(label = 'Update'): NodePreview {\n cancelNodePreviews()\n const graph = ctx.graph\n const originals = new Map<string, Partial<SceneNode>>()\n const targets = new Set<string>()\n const layoutOnly = new Set<string>()\n const editedBefore = new Map<string, string[]>()\n let closed = false\n let endInteraction: (() => void) | undefined\n const subscriptions: Array<() => void> = []\n\n function capture(node: SceneNode, changes: Partial<SceneNode>) {\n if (!originals.has(node.id) && graph.isApplyingLayout) layoutOnly.add(node.id)\n if (!graph.isApplyingLayout) {\n layoutOnly.delete(node.id)\n markEdited(node, changes)\n }\n const previous = originals.get(node.id) ?? {}\n const keys = (Object.keys(changes) as (keyof SceneNode)[]).filter(\n (key) => !Object.hasOwn(previous, key)\n )\n if (keys.length) Object.assign(previous, structuredClone(pick(node, keys)))\n originals.set(node.id, previous)\n }\n\n // Fields count as edited while previewed, as a committed edit marks them, so the preview's\n // own layout stops keeping geometry a file saved; cancel takes the marks back.\n function markEdited(node: SceneNode, changes: Partial<SceneNode>) {\n if (graph.isPreservingSourceMetadata) return\n if (!editedBefore.has(node.id)) editedBefore.set(node.id, node.source.editedFields)\n node.source.editedFields = uniq([...node.source.editedFields, ...Object.keys(changes)])\n }\n\n function close() {\n closed = true\n for (const stop of subscriptions) stop()\n endInteraction?.()\n if (current === preview) current = null\n }\n\n const preview: NodePreview = {\n get closed() {\n return closed\n },\n update(id, changes) {\n if (closed || graph !== ctx.graph || !graph.getNode(id)) return\n targets.add(id)\n endInteraction ??= ctx.beginInteractiveEdit()\n try {\n assertNodeEditable(graph, id)\n graph.runPreviewUpdates(() => updateNode(id, changes), capture)\n ctx.requestRepaint()\n } catch (error) {\n preview.cancel()\n throw error\n }\n },\n commit() {\n if (closed) return\n try {\n for (const id of targets) assertNodeEditable(graph, id)\n } catch (error) {\n preview.cancel()\n throw error\n }\n const edits: Array<{ id: string; before: Partial<SceneNode>; after: Partial<SceneNode> }> =\n []\n for (const [id, before] of originals) {\n const node = graph.getNode(id)\n if (!node) continue\n const after = structuredClone(pick(node, Object.keys(before) as (keyof SceneNode)[]))\n if (!isEqual(before, after)) edits.push({ id, before, after })\n }\n close()\n if (edits.length === 0) {\n if (originals.size) ctx.requestRender()\n return\n }\n // Back to what the layers held, so the commit reports each to graph observers before it\n // changes them, as the other previews do; otherwise a saved .fig sees no change.\n for (const edit of edits) graph.updateNodePreview(edit.id, structuredClone(edit.before))\n function apply(direction: 'before' | 'after') {\n for (const edit of edits) {\n const update = () => graph.updateNode(edit.id, structuredClone(edit[direction]))\n if (layoutOnly.has(edit.id)) graph.withLayoutMutations(update)\n else update()\n }\n ctx.requestRender()\n }\n ctx.undo.push({ label, forward: () => apply('after'), inverse: () => apply('before') })\n // Publish the complete preview delta, including layout children and implicit edits.\n apply('after')\n },\n cancel() {\n if (closed) return\n close()\n for (const [id, previous] of originals)\n graph.updateNodePreview(id, structuredClone(previous))\n for (const [id, fields] of editedBefore) {\n const node = graph.getNode(id)\n if (node) node.source.editedFields = fields\n }\n // Reconcile retained/tiled resources once; cancellation publishes no committed node edits.\n if (originals.size) ctx.requestRender()\n }\n }\n for (const event of ['selection:changed', 'page:changed', 'graph:replaced'] as const) {\n subscriptions.push(ctx.onEditorEvent(event, preview.cancel))\n }\n subscriptions.push(\n ctx.onEditorEvent('node:deleted', (id) => {\n if (targets.has(id) || originals.has(id)) preview.cancel()\n })\n )\n current = preview\n return preview\n }\n\n return { beginNodePreview, cancelNodePreviews }\n}\n"],"mappings":";;;;AA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;KAAG,eAAe,MAAM,QAAQ;IAAE,CAAC;IAEtF,MAAM,OAAO;GACf;GACA,SAAS;IACP,IAAI,QAAQ;IACZ,MAAM;IACN,KAAK,MAAM,CAAC,IAAI,aAAa,WAC3B,MAAM,kBAAkB,IAAI,gBAAgB,QAAQ,CAAC;IACvD,KAAK,MAAM,CAAC,IAAI,WAAW,cAAc;KACvC,MAAM,OAAO,MAAM,QAAQ,EAAE;KAC7B,IAAI,MAAM,KAAK,OAAO,eAAe;IACvC;IAEA,IAAI,UAAU,MAAM,IAAI,cAAc;GACxC;EACF;EACA,KAAK,MAAM,SAAS;GAAC;GAAqB;GAAgB;EAAgB,GACxE,cAAc,KAAK,IAAI,cAAc,OAAO,QAAQ,MAAM,CAAC;EAE7D,cAAc,KACZ,IAAI,cAAc,iBAAiB,OAAO;GACxC,IAAI,QAAQ,IAAI,EAAE,KAAK,UAAU,IAAI,EAAE,GAAG,QAAQ,OAAO;EAC3D,CAAC,CACH;EACA,UAAU;EACV,OAAO;CACT;CAEA,OAAO;EAAE;EAAkB;CAAmB;AAChD"}
|
|
1
|
+
{"version":3,"file":"node-preview.js","names":[],"sources":["../../src/editor/node-preview.ts"],"sourcesContent":["import { isEqual, pick, uniq } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { fitEnclosingGroups, redoGroupFit, undoGroupFit } from '@pairdraw/scene-graph/group-bounds'\n\nimport { groupFitOptions } from '#core/canvas/boolean'\n\nimport { assertNodeEditable } from './capabilities'\nimport { restoreSources, type SourceSnapshots } from './history/sources'\nimport type { EditorContext } from './types'\n\nexport interface NodePreview {\n readonly closed: boolean\n update: (id: string, changes: Partial<SceneNode>) => void\n commit: () => void\n cancel: () => void\n}\n\n/** Whether an auto layout frame places this layer, so the boxes of the groups above it are theirs. */\nfunction placedByParent(graph: SceneGraph, id: string): boolean {\n const parent = graph.getNode(graph.getNode(id)?.parentId ?? '')\n return parent !== undefined && parent.layoutMode !== 'NONE'\n}\n\n/** One owned numeric/property edit, including every node changed by its layout. */\nexport function createNodePreviewActions(\n ctx: EditorContext,\n updateNode: (id: string, changes: Partial<SceneNode>) => void\n) {\n let current: NodePreview | null = null\n\n function cancelNodePreviews() {\n current?.cancel()\n }\n\n function beginNodePreview(label = 'Update'): NodePreview {\n cancelNodePreviews()\n const graph = ctx.graph\n const originals = new Map<string, Partial<SceneNode>>()\n const targets = new Set<string>()\n const layoutOnly = new Set<string>()\n const sourcesBefore: SourceSnapshots = new Map()\n let closed = false\n let endInteraction: (() => void) | undefined\n const subscriptions: Array<() => void> = []\n\n function capture(node: SceneNode, changes: Partial<SceneNode>) {\n if (!originals.has(node.id) && graph.isApplyingLayout) layoutOnly.add(node.id)\n if (!graph.isApplyingLayout) {\n layoutOnly.delete(node.id)\n markEdited(node, changes)\n }\n const previous = originals.get(node.id) ?? {}\n const keys = (Object.keys(changes) as (keyof SceneNode)[]).filter(\n (key) => !Object.hasOwn(previous, key)\n )\n if (keys.length) Object.assign(previous, structuredClone(pick(node, keys)))\n originals.set(node.id, previous)\n }\n\n // Fields count as edited while previewed, as a committed edit marks them, so the preview's\n // own layout stops keeping geometry a file saved; cancel takes the marks back.\n function markEdited(node: SceneNode, changes: Partial<SceneNode>) {\n if (graph.isPreservingSourceMetadata) return\n if (!sourcesBefore.has(node.id)) sourcesBefore.set(node.id, structuredClone(node.source))\n node.source.editedFields = uniq([...node.source.editedFields, ...Object.keys(changes)])\n }\n\n function close() {\n closed = true\n for (const stop of subscriptions) stop()\n endInteraction?.()\n if (current === preview) current = null\n }\n\n const preview: NodePreview = {\n get closed() {\n return closed\n },\n update(id, changes) {\n if (closed || graph !== ctx.graph || !graph.getNode(id)) return\n targets.add(id)\n endInteraction ??= ctx.beginInteractiveEdit()\n try {\n assertNodeEditable(graph, id)\n graph.runPreviewUpdates(() => updateNode(id, changes), capture)\n ctx.requestRepaint()\n } catch (error) {\n preview.cancel()\n throw error\n }\n },\n commit() {\n if (closed) return\n try {\n for (const id of targets) assertNodeEditable(graph, id)\n } catch (error) {\n preview.cancel()\n throw error\n }\n const edits: Array<{ id: string; before: Partial<SceneNode>; after: Partial<SceneNode> }> =\n []\n for (const [id, before] of originals) {\n const node = graph.getNode(id)\n if (!node) continue\n const after = structuredClone(pick(node, Object.keys(before) as (keyof SceneNode)[]))\n if (!isEqual(before, after)) edits.push({ id, before, after })\n }\n close()\n if (edits.length === 0) {\n if (originals.size) ctx.requestRender()\n return\n }\n // Back to what the layers held, so the commit reports each to graph observers before it\n // changes them, as the other previews do; otherwise a saved .fig sees no change.\n for (const edit of edits) graph.updateNodePreview(edit.id, structuredClone(edit.before))\n function apply(direction: 'before' | 'after') {\n for (const edit of edits) {\n const update = () => graph.updateNode(edit.id, structuredClone(edit[direction]))\n if (layoutOnly.has(edit.id)) graph.withLayoutMutations(update)\n else update()\n }\n // Undo gives the previewed layers the marks they had before it; redo marks them again\n // as the commit did.\n if (direction === 'before') restoreSources(graph, sourcesBefore)\n ctx.requestRender()\n }\n // Publish the complete preview delta, including the layout children and implicit edits,\n // before recording it, so the step owns the marks this commit adds.\n apply('after')\n // The preview moved the layers without fitting the groups around them, so the box each\n // group takes follows here, inside the step that undo takes back.\n const parents = uniq(\n edits\n .filter((edit) => !placedByParent(graph, edit.id))\n .map((edit) => graph.getNode(edit.id)?.parentId ?? '')\n ).filter((parentId) => parentId !== '')\n const options = groupFitOptions(ctx.getRenderer(), graph)\n const fits = parents\n .map((parentId) => fitEnclosingGroups(graph, [parentId], options))\n .filter((fit) => fit !== null)\n for (const fit of fits) redoGroupFit(graph, fit)\n ctx.undo.push({\n label,\n forward: () => {\n apply('after')\n for (const fit of fits) redoGroupFit(graph, fit)\n },\n inverse: () => {\n for (const fit of fits) undoGroupFit(graph, fit)\n apply('before')\n }\n })\n },\n cancel() {\n if (closed) return\n close()\n for (const [id, previous] of originals)\n graph.updateNodePreview(id, structuredClone(previous))\n // The marks go back without a node update: cancelling publishes no committed node edits.\n for (const [id, source] of sourcesBefore) {\n const node = graph.getNode(id)\n if (node) node.source = structuredClone(source)\n }\n if (originals.size) ctx.requestRender()\n }\n }\n for (const event of ['selection:changed', 'page:changed', 'graph:replaced'] as const) {\n subscriptions.push(ctx.onEditorEvent(event, preview.cancel))\n }\n subscriptions.push(\n ctx.onEditorEvent('node:deleted', (id) => {\n if (targets.has(id) || originals.has(id)) preview.cancel()\n })\n )\n current = preview\n return preview\n }\n\n return { beginNodePreview, cancelNodePreviews }\n}\n"],"mappings":";;;;;;;AAmBA,SAAS,eAAe,OAAmB,IAAqB;CAC9D,MAAM,SAAS,MAAM,QAAQ,MAAM,QAAQ,EAAE,CAAC,EAAE,YAAY,EAAE;CAC9D,OAAO,WAAW,KAAA,KAAa,OAAO,eAAe;AACvD;;AAGA,SAAgB,yBACd,KACA,YACA;CACA,IAAI,UAA8B;CAElC,SAAS,qBAAqB;EAC5B,SAAS,OAAO;CAClB;CAEA,SAAS,iBAAiB,QAAQ,UAAuB;EACvD,mBAAmB;EACnB,MAAM,QAAQ,IAAI;EAClB,MAAM,4BAAY,IAAI,IAAgC;EACtD,MAAM,0BAAU,IAAI,IAAY;EAChC,MAAM,6BAAa,IAAI,IAAY;EACnC,MAAM,gCAAiC,IAAI,IAAI;EAC/C,IAAI,SAAS;EACb,IAAI;EACJ,MAAM,gBAAmC,CAAC;EAE1C,SAAS,QAAQ,MAAiB,SAA6B;GAC7D,IAAI,CAAC,UAAU,IAAI,KAAK,EAAE,KAAK,MAAM,kBAAkB,WAAW,IAAI,KAAK,EAAE;GAC7E,IAAI,CAAC,MAAM,kBAAkB;IAC3B,WAAW,OAAO,KAAK,EAAE;IACzB,WAAW,MAAM,OAAO;GAC1B;GACA,MAAM,WAAW,UAAU,IAAI,KAAK,EAAE,KAAK,CAAC;GAC5C,MAAM,OAAQ,OAAO,KAAK,OAAO,CAAC,CAAyB,QACxD,QAAQ,CAAC,OAAO,OAAO,UAAU,GAAG,CACvC;GACA,IAAI,KAAK,QAAQ,OAAO,OAAO,UAAU,gBA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C;IAEvD,KAAK,MAAM,CAAC,IAAI,WAAW,eAAe;KACxC,MAAM,OAAO,MAAM,QAAQ,EAAE;KAC7B,IAAI,MAAM,KAAK,SAAS,gBAAgB,MAAM;IAChD;IACA,IAAI,UAAU,MAAM,IAAI,cAAc;GACxC;EACF;EACA,KAAK,MAAM,SAAS;GAAC;GAAqB;GAAgB;EAAgB,GACxE,cAAc,KAAK,IAAI,cAAc,OAAO,QAAQ,MAAM,CAAC;EAE7D,cAAc,KACZ,IAAI,cAAc,iBAAiB,OAAO;GACxC,IAAI,QAAQ,IAAI,EAAE,KAAK,UAAU,IAAI,EAAE,GAAG,QAAQ,OAAO;EAC3D,CAAC,CACH;EACA,UAAU;EACV,OAAO;CACT;CAEA,OAAO;EAAE;EAAkB;CAAmB;AAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","names":[],"sources":["../../src/editor/nodes.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","names":[],"sources":["../../src/editor/nodes.ts"],"mappings":";;;;iBA2BgB,kBAAkB;iBAkBlB,kBAAkB,KAAK;;;;;;;EAqCL,qBAAA,YAAM,SAAW,QAAQ,YAAU;EAuEtC,aAAA,iBAAM;wCAvEc;;EAnBzB,aAAA,YAAM,SAAW,QAAQ;;;KAyHvC,cAAc,kBAAkB"}
|
package/dist/editor/nodes.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { groupFitOptions } from "../canvas/boolean.js";
|
|
1
2
|
import { textAutoResizeChanges } from "../layout/text-auto-resize.js";
|
|
2
3
|
import { reconcileVariableLayouts } from "../layout/variables.js";
|
|
4
|
+
import { refitGroupsAroundLayers } from "./structure/group/bounds.js";
|
|
3
5
|
import { loadBoundFonts } from "./text/bound-fonts.js";
|
|
4
6
|
import { pathTextEditChanges } from "./text/path-edit.js";
|
|
5
|
-
import { refitGroupsAroundLayers } from "./structure/group/bounds.js";
|
|
6
7
|
import { applyBoundVisibilityEdit, bindsVisibility } from "./components/authoring/visibility-edit.js";
|
|
7
8
|
import { createLayoutModeActions } from "./layout-mode.js";
|
|
8
9
|
import { createNodePreviewActions } from "./node-preview.js";
|
|
@@ -10,8 +11,10 @@ import { createNudgeActions } from "./nudge.js";
|
|
|
10
11
|
import { createVariableBindingActions } from "./variable-bindings.js";
|
|
11
12
|
import { styleDetachmentChanges } from "@pairdraw/scene-graph/shared-styles";
|
|
12
13
|
import { pick } from "es-toolkit/object";
|
|
14
|
+
import { findInstanceAncestor, instanceOverrideFields, recordInstanceOverride } from "@pairdraw/scene-graph/instances";
|
|
13
15
|
import { cloneInstanceOverrideState } from "@pairdraw/scene-graph/instances/overrides";
|
|
14
|
-
import {
|
|
16
|
+
import { fitEnclosingGroups, redoGroupFit, undoGroupFit } from "@pairdraw/scene-graph/group-bounds";
|
|
17
|
+
import { strokeLineChanges } from "@pairdraw/scene-graph/strokes";
|
|
15
18
|
//#region src/editor/nodes.ts
|
|
16
19
|
function opacityFromBuffer(buffer) {
|
|
17
20
|
if (buffer === "0") return 1;
|
|
@@ -21,14 +24,26 @@ function opacityFromBuffer(buffer) {
|
|
|
21
24
|
const percent = buffer.length === 1 ? n * 10 : n;
|
|
22
25
|
return Math.min(100, Math.max(0, percent)) / 100;
|
|
23
26
|
}
|
|
27
|
+
/** Fields whose change makes a frame take a new size of its own. */
|
|
28
|
+
const SIZE_DEPENDENT_FIELDS = [
|
|
29
|
+
"primaryAxisSizing",
|
|
30
|
+
"counterAxisSizing",
|
|
31
|
+
"layoutMode"
|
|
32
|
+
];
|
|
33
|
+
/** Whether an auto layout frame places this layer, so its own x and y do not stay where they are put. */
|
|
34
|
+
function layOutByParent(ctx, id) {
|
|
35
|
+
const parent = ctx.graph.getNode(ctx.graph.getNode(id)?.parentId ?? "");
|
|
36
|
+
return parent !== void 0 && parent.layoutMode !== "NONE";
|
|
37
|
+
}
|
|
24
38
|
function createNodeActions(ctx) {
|
|
25
39
|
const previewActions = createNodePreviewActions(ctx, updateNode);
|
|
26
40
|
const layoutModeActions = createLayoutModeActions(ctx, previewActions.beginNodePreview);
|
|
27
41
|
const nudgeActions = createNudgeActions(ctx);
|
|
28
42
|
const variableBindingActions = createVariableBindingActions(ctx);
|
|
29
|
-
function runChangedLayout(id, changes) {
|
|
43
|
+
function runChangedLayout(id, changes, fitGroups = false) {
|
|
30
44
|
if (changes.variableModes) loadBoundFonts(ctx, reconcileVariableLayouts(ctx.graph, { subtrees: [id] }));
|
|
31
45
|
if (changes.visible !== void 0) refitGroupsAroundLayers(ctx, [id]);
|
|
46
|
+
if (fitGroups && !layOutByParent(ctx, id)) refitGroupsAroundLayers(ctx, [id]);
|
|
32
47
|
ctx.runLayoutForNode(id);
|
|
33
48
|
}
|
|
34
49
|
function updateNode(id, changes) {
|
|
@@ -36,11 +51,13 @@ function createNodeActions(ctx) {
|
|
|
36
51
|
if (!node) return;
|
|
37
52
|
const nextChanges = styleDetachmentChanges(node, {
|
|
38
53
|
...changes,
|
|
54
|
+
...strokeLineChanges(node, changes),
|
|
39
55
|
...textAutoResizeChanges(node, changes),
|
|
40
56
|
...pathTextEditChanges(node, changes)
|
|
41
57
|
});
|
|
58
|
+
const overridden = instanceOverrideFields(node, nextChanges);
|
|
42
59
|
ctx.graph.updateNode(id, nextChanges);
|
|
43
|
-
recordInstanceOverride(ctx.graph, id,
|
|
60
|
+
recordInstanceOverride(ctx.graph, id, overridden);
|
|
44
61
|
runChangedLayout(id, nextChanges);
|
|
45
62
|
}
|
|
46
63
|
function updateNodeWithUndo(id, changes, label = "Update") {
|
|
@@ -60,26 +77,32 @@ function createNodeActions(ctx) {
|
|
|
60
77
|
const { id } = node;
|
|
61
78
|
const nextChanges = styleDetachmentChanges(node, {
|
|
62
79
|
...changes,
|
|
80
|
+
...strokeLineChanges(node, changes),
|
|
63
81
|
...textAutoResizeChanges(node, changes),
|
|
64
82
|
...pathTextEditChanges(node, changes)
|
|
65
83
|
});
|
|
66
84
|
const owner = findInstanceAncestor(ctx.graph, id);
|
|
67
85
|
const previousOverrides = owner ? cloneInstanceOverrideState(owner.instanceOverrides) : void 0;
|
|
68
|
-
const
|
|
86
|
+
const restoreSize = SIZE_DEPENDENT_FIELDS.some((field) => field in nextChanges);
|
|
87
|
+
const previous = pick(node, [...Object.keys(nextChanges), ...restoreSize ? ["width", "height"] : []]);
|
|
88
|
+
const overridden = instanceOverrideFields(node, nextChanges);
|
|
69
89
|
ctx.graph.updateNode(id, nextChanges);
|
|
70
|
-
recordInstanceOverride(ctx.graph, id,
|
|
71
|
-
runChangedLayout(id, nextChanges);
|
|
90
|
+
recordInstanceOverride(ctx.graph, id, overridden);
|
|
91
|
+
runChangedLayout(id, nextChanges, false);
|
|
92
|
+
const fit = layOutByParent(ctx, id) ? null : fitEnclosingGroups(ctx.graph, [node.parentId ?? id], groupFitOptions(ctx.getRenderer(), ctx.graph));
|
|
72
93
|
ctx.undo.push({
|
|
73
94
|
label,
|
|
74
95
|
forward: () => {
|
|
75
96
|
ctx.graph.updateNode(id, nextChanges);
|
|
76
|
-
recordInstanceOverride(ctx.graph, id,
|
|
77
|
-
runChangedLayout(id, nextChanges);
|
|
97
|
+
recordInstanceOverride(ctx.graph, id, overridden);
|
|
98
|
+
runChangedLayout(id, nextChanges, false);
|
|
99
|
+
if (fit) redoGroupFit(ctx.graph, fit);
|
|
78
100
|
},
|
|
79
101
|
inverse: () => {
|
|
102
|
+
if (fit) undoGroupFit(ctx.graph, fit);
|
|
80
103
|
ctx.graph.updateNode(id, previous);
|
|
81
104
|
if (owner && previousOverrides) ctx.graph.updateNode(owner.id, { instanceOverrides: cloneInstanceOverrideState(previousOverrides) });
|
|
82
|
-
runChangedLayout(id, nextChanges);
|
|
105
|
+
runChangedLayout(id, nextChanges, false);
|
|
83
106
|
}
|
|
84
107
|
});
|
|
85
108
|
ctx.requestRender();
|