@pairdraw/core 0.17.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/outline-stroke.d.ts.map +1 -1
- package/dist/canvas/outline-stroke.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/prototype.d.ts +2 -5
- package/dist/canvas/overlays/prototype.d.ts.map +1 -1
- package/dist/canvas/overlays/prototype.js +3 -19
- package/dist/canvas/overlays/prototype.js.map +1 -1
- 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 +25 -10
- 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 +26 -7
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +50 -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 +90 -54
- 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 +4 -3
- package/dist/canvas/text/font-families.d.ts.map +1 -1
- package/dist/canvas/text/font-families.js +13 -9
- 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 +2 -9
- 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 +18 -9
- 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 +3 -3
- package/dist/canvas/text/placed.js.map +1 -1
- package/dist/canvas/text/renderer.d.ts +2 -0
- package/dist/canvas/text/renderer.d.ts.map +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/design-jsx/renderer.d.ts.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/bridges/undo.d.ts +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 +18 -4
- 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 +63 -10
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +104 -17
- 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 +12 -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/connectors.js +2 -14
- package/dist/geometry/connectors.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 +3 -3
- package/dist/geometry/index.js +2 -2
- package/dist/geometry/scene.d.ts +3 -1
- package/dist/geometry/scene.d.ts.map +1 -1
- package/dist/geometry/scene.js +16 -1
- package/dist/geometry/scene.js.map +1 -1
- package/dist/geometry/types.d.ts +7 -1
- package/dist/geometry/types.d.ts.map +1 -1
- 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/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +10 -0
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.d.ts.map +1 -1
- package/dist/io/formats/drawio/index.js +32 -1
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/shapes.d.ts +10 -5
- package/dist/io/formats/drawio/shapes.d.ts.map +1 -1
- package/dist/io/formats/drawio/shapes.js +10 -6
- package/dist/io/formats/drawio/shapes.js.map +1 -1
- package/dist/io/formats/drawio/warnings.d.ts +11 -0
- package/dist/io/formats/drawio/warnings.d.ts.map +1 -0
- package/dist/io/formats/drawio/warnings.js +23 -0
- package/dist/io/formats/drawio/warnings.js.map +1 -0
- 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 +10 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +96 -2
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/export.js +3 -2
- package/dist/io/formats/pdf/export.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 +3 -3
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +25 -14
- 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 +8 -2
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +42 -8
- 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/formats.d.ts.map +1 -1
- package/dist/io/formats.js +3 -1
- package/dist/io/formats.js.map +1 -1
- package/dist/io/registry.d.ts +2 -0
- package/dist/io/registry.d.ts.map +1 -1
- package/dist/io/registry.js +5 -0
- package/dist/io/registry.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/io/types.d.ts +2 -0
- package/dist/io/types.d.ts.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 +11 -2
- package/dist/library/snapshot.js.map +1 -1
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +11 -2
- package/dist/lint/linter.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/rpc/variables-command.d.ts.map +1 -1
- package/dist/rpc/variables-command.js +4 -2
- package/dist/rpc/variables-command.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 +16 -14
- 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 +26 -3
- package/dist/text/fallbacks.d.ts.map +1 -1
- package/dist/text/fallbacks.js +135 -18
- 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 +50 -6
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +178 -32
- 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 +71 -71
- package/dist/text/outlines.js.map +1 -1
- package/dist/text/path/caret.d.ts +2 -4
- package/dist/text/path/caret.d.ts.map +1 -1
- package/dist/text/path/caret.js.map +1 -1
- package/dist/text/prepare.d.ts +5 -1
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +26 -3
- 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/text/web-font/assets.d.ts.map +1 -1
- package/dist/text/web-font/assets.js +13 -21
- package/dist/text/web-font/assets.js.map +1 -1
- package/dist/text/web-font/resolver.d.ts.map +1 -1
- package/dist/text/web-font/resolver.js +4 -1
- package/dist/text/web-font/resolver.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/components.d.ts +2 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +27 -1
- package/dist/tools/create/components.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 +14 -6
- 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 +13 -10
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/create.d.ts +2 -2
- package/dist/tools/create.js +2 -2
- 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/effects.d.ts.map +1 -1
- package/dist/tools/modify/effects.js +5 -3
- package/dist/tools/modify/effects.js.map +1 -1
- package/dist/tools/modify/matching.d.ts.map +1 -1
- package/dist/tools/modify/matching.js +9 -6
- package/dist/tools/modify/matching.js.map +1 -1
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +7 -5
- package/dist/tools/modify/paint.js.map +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/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +28 -8
- package/dist/tools/modify/text.js.map +1 -1
- 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 +18 -4
- 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 +6 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +30 -5
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +125 -7
- 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 +86 -90
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/variables/values.d.ts.map +1 -1
- package/dist/tools/variables/values.js +4 -2
- package/dist/tools/variables/values.js.map +1 -1
- package/dist/tools/vector/export.d.ts.map +1 -1
- package/dist/tools/vector/export.js +5 -2
- package/dist/tools/vector/export.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/outline-stroke.ts +2 -6
- package/src/canvas/overlays/index.ts +0 -1
- package/src/canvas/overlays/prototype.ts +5 -27
- 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 +42 -18
- 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 +43 -11
- package/src/canvas/rulers.ts +55 -26
- package/src/canvas/scene.ts +127 -77
- 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 +14 -7
- package/src/canvas/text/index.ts +3 -9
- 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 +19 -10
- package/src/canvas/text/paragraph/inputs.ts +4 -2
- package/src/canvas/text/placed.ts +2 -2
- package/src/canvas/text/renderer.ts +2 -0
- 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 +170 -19
- 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 +16 -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/connectors.ts +2 -12
- package/src/geometry/figma.ts +9 -0
- package/src/geometry/index.ts +2 -1
- package/src/geometry/scene.ts +19 -0
- package/src/geometry/types.ts +8 -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/drawio/export.ts +11 -0
- package/src/io/formats/drawio/index.ts +36 -1
- package/src/io/formats/drawio/shapes.ts +13 -9
- package/src/io/formats/drawio/warnings.ts +27 -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 +125 -3
- package/src/io/formats/pdf/export.ts +3 -2
- 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 +40 -14
- package/src/io/formats/raster/index.ts +3 -0
- package/src/io/formats/raster/render.ts +66 -8
- 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/formats.ts +3 -1
- package/src/io/registry.ts +12 -0
- package/src/io/subgraph.ts +3 -1
- package/src/io/types.ts +2 -0
- 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 +12 -2
- package/src/lint/linter.ts +12 -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/rpc/variables-command.ts +6 -5
- package/src/text/character-style.ts +29 -9
- package/src/text/coverage.ts +29 -15
- package/src/text/editor.ts +3 -8
- package/src/text/fallbacks.ts +163 -22
- 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 +220 -49
- package/src/text/font/style.ts +52 -3
- package/src/text/index.ts +1 -0
- package/src/text/outlines.ts +106 -90
- package/src/text/path/caret.ts +3 -4
- package/src/text/prepare.ts +51 -2
- package/src/text/style-runs.ts +43 -16
- package/src/text/web-font/assets.ts +11 -15
- package/src/text/web-font/resolver.ts +7 -1
- 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/components.ts +33 -0
- package/src/tools/create/html.ts +3 -1
- package/src/tools/create/icons.ts +16 -6
- 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 +20 -10
- package/src/tools/create.ts +1 -0
- package/src/tools/image-ai/generate.ts +3 -0
- package/src/tools/modify/effects.ts +11 -4
- package/src/tools/modify/matching.ts +10 -6
- package/src/tools/modify/paint.ts +13 -5
- package/src/tools/modify/reactions.ts +40 -0
- package/src/tools/modify/text.ts +53 -20
- 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 +24 -4
- package/src/tools/read/nodes.ts +47 -17
- package/src/tools/read/pages.ts +7 -3
- 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 +6 -0
- package/src/tools/schema.ts +166 -6
- package/src/tools/stock-photo/apply.ts +17 -5
- package/src/tools/structure/batch.ts +84 -98
- package/src/tools/variables/values.ts +6 -3
- package/src/tools/vector/export.ts +5 -1
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport.js","names":[],"sources":["../../src/editor/viewport.ts"],"sourcesContent":["import { getAxisAlignedWorldBounds } from '@pairdraw/scene-graph/coordinate'\nimport { computeBounds, computeAbsoluteBounds } from '@pairdraw/scene-graph/geometry'\n\nimport { ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN } from '#core/constants'\nimport { emitNavigationTrace } from '#core/profiler'\n\nimport type { EditorContext } from './types'\n\n/** Space kept between revealed layers and the viewport edge. */\nconst REVEAL_MARGIN = 48\n\nexport function createViewportActions(ctx: EditorContext) {\n function currentViewport() {\n return { panX: ctx.state.panX, panY: ctx.state.panY, zoom: ctx.state.zoom }\n }\n\n function emitViewportChanged(previous: ReturnType<typeof currentViewport>) {\n const next = currentViewport()\n if (next.panX !== previous.panX || next.panY !== previous.panY || next.zoom !== previous.zoom) {\n emitNavigationTrace('viewport:changed', {\n panX: next.panX,\n panY: next.panY,\n zoom: next.zoom,\n previousPanX: previous.panX,\n previousPanY: previous.panY,\n previousZoom: previous.zoom\n })\n ctx.emitEditorEvent('viewport:changed', next, previous)\n }\n }\n\n function screenToCanvas(sx: number, sy: number) {\n return {\n x: (sx - ctx.state.panX) / ctx.state.zoom,\n y: (sy - ctx.state.panY) / ctx.state.zoom\n }\n }\n\n function setZoomAroundPoint(level: number, centerX: number, centerY: number) {\n const previous = currentViewport()\n const newZoom = Math.max(0.02, Math.min(256, level))\n ctx.state.panX = centerX - (centerX - ctx.state.panX) * (newZoom / ctx.state.zoom)\n ctx.state.panY = centerY - (centerY - ctx.state.panY) * (newZoom / ctx.state.zoom)\n ctx.state.zoom = newZoom\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n function applyZoom(delta: number, centerX: number, centerY: number) {\n const factor = Math.min(\n ZOOM_SCALE_MAX,\n Math.max(ZOOM_SCALE_MIN, Math.exp(-delta / ZOOM_DIVISOR))\n )\n setZoomAroundPoint(ctx.state.zoom * factor, centerX, centerY)\n }\n\n function pan(dx: number, dy: number) {\n const previous = currentViewport()\n ctx.state.panX += dx\n ctx.state.panY += dy\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n function zoomToBounds(minX: number, minY: number, maxX: number, maxY: number) {\n const previous = currentViewport()\n const padding = 80\n const w = maxX - minX + padding * 2\n const h = maxY - minY + padding * 2\n\n const { width: viewW, height: viewH } = ctx.getViewportSize()\n const zoom = Math.max(0.02, Math.min(viewW / w, viewH / h, 1))\n\n ctx.state.zoom = zoom\n ctx.state.panX = (viewW - w * zoom) / 2 - minX * zoom + padding * zoom\n ctx.state.panY = (viewH - h * zoom) / 2 - minY * zoom + padding * zoom\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n /**\n * Fits the world area to the viewport, edge to edge and at any zoom, as a drag of Figma's zoom\n * tool does; `zoomToBounds` instead leaves a margin and never zooms past 100%. An area with no\n * width or height leaves the view alone.\n */\n function zoomToArea(minX: number, minY: number, maxX: number, maxY: number) {\n const width = maxX - minX\n const height = maxY - minY\n if (!(width > 0) || !(height > 0)) return\n const previous = currentViewport()\n const { width: viewW, height: viewH } = ctx.getViewportSize()\n const zoom = Math.max(0.02, Math.min(256, Math.min(viewW / width, viewH / height)))\n ctx.state.zoom = zoom\n ctx.state.panX = viewW / 2 - (minX + width / 2) * zoom\n ctx.state.panY = viewH / 2 - (minY + height / 2) * zoom\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n /** Put the world point (x, y) at the center of the viewport, at `zoom` (the current one by default). */\n function centerOn(x: number, y: number, zoom = ctx.state.zoom) {\n const previous = currentViewport()\n const { width, height } = ctx.getViewportSize()\n const nextZoom = Math.max(0.02, Math.min(256, zoom))\n const panX = width / 2 - x * nextZoom\n const panY = height / 2 - y * nextZoom\n // Remote cursors are finite but unbounded; a point that overflows leaves the view alone.\n if (!Number.isFinite(panX) || !Number.isFinite(panY)) return\n ctx.state.zoom = nextZoom\n ctx.state.panX = panX\n ctx.state.panY = panY\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n function zoomToFit() {\n const nodes = ctx.graph.getChildren(ctx.state.currentPageId)\n if (nodes.length === 0) return\n\n const b = computeBounds(nodes)\n zoomToBounds(b.x, b.y, b.x + b.width, b.y + b.height)\n }\n\n function zoomToLevel(level: number) {\n const { width: viewW, height: viewH } = ctx.getViewportSize()\n const centerX = (-ctx.state.panX + viewW / 2) / ctx.state.zoom\n const centerY = (-ctx.state.panY + viewH / 2) / ctx.state.zoom\n\n const previous = currentViewport()\n ctx.state.zoom = Math.max(0.02, Math.min(256, level))\n // Keep the world point at the center of the viewport where it was.\n ctx.state.panX = viewW / 2 - centerX * ctx.state.zoom\n ctx.state.panY = viewH / 2 - centerY * ctx.state.zoom\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n function zoomTo100() {\n zoomToLevel(1)\n }\n\n function zoomToSelection() {\n if (ctx.state.selectedIds.size === 0) return\n\n const nodes = [...ctx.state.selectedIds]\n .map((id) => ctx.graph.getNode(id))\n .filter((n): n is NonNullable<typeof n> => n != null)\n if (nodes.length === 0) return\n\n const b = computeAbsoluteBounds(nodes, ctx.graph)\n zoomToBounds(b.x, b.y, b.x + b.width, b.y + b.height)\n }\n\n /**\n * Brings layers into view: pans to center them when they fit at the current zoom and are not\n * already visible, and zooms out to fit them only when they do not fit.\n */\n function revealNodes(nodeIds: readonly string[], margin = REVEAL_MARGIN) {\n const nodes = nodeIds.map((id) => ctx.graph.getNode(id)).filter((node) => node !== undefined)\n if (nodes.length === 0) return\n const bounds = computeBounds(nodes.map((node) => getAxisAlignedWorldBounds(node, ctx.graph)))\n const { width, height } = ctx.getViewportSize()\n const { zoom, panX, panY } = ctx.state\n const fits =\n bounds.width * zoom <= width - margin * 2 && bounds.height * zoom <= height - margin * 2\n if (!fits) {\n zoomToBounds(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height)\n return\n }\n const left = bounds.x * zoom + panX\n const top = bounds.y * zoom + panY\n const right = left + bounds.width * zoom\n const bottom = top + bounds.height * zoom\n const visible =\n left >= margin && top >= margin && right <= width - margin && bottom <= height - margin\n if (visible) return\n pan(width / 2 - (left + right) / 2, height / 2 - (top + bottom) / 2)\n }\n\n return {\n revealNodes,\n screenToCanvas,\n setZoomAroundPoint,\n applyZoom,\n pan,\n zoomToBounds,\n zoomToArea,\n centerOn,\n zoomToFit,\n zoomTo100,\n zoomToLevel,\n zoomToSelection\n }\n}\n"],"mappings":";;;;;;AASA,MAAM,gBAAgB;AAEtB,SAAgB,sBAAsB,KAAoB;CACxD,SAAS,kBAAkB;EACzB,OAAO;GAAE,MAAM,IAAI,MAAM;GAAM,MAAM,IAAI,MAAM;GAAM,MAAM,IAAI,MAAM;EAAK;CAC5E;CAEA,SAAS,oBAAoB,UAA8C;EACzE,MAAM,OAAO,gBAAgB;EAC7B,IAAI,KAAK,SAAS,SAAS,QAAQ,KAAK,SAAS,SAAS,QAAQ,KAAK,SAAS,SAAS,MAAM;GAC7F,oBAAoB,oBAAoB;IACtC,MAAM,KAAK;IACX,MAAM,KAAK;IACX,MAAM,KAAK;IACX,cAAc,SAAS;IACvB,cAAc,SAAS;IACvB,cAAc,SAAS;GACzB,CAAC;GACD,IAAI,gBAAgB,oBAAoB,MAAM,QAAQ;EACxD;CACF;CAEA,SAAS,eAAe,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,CAAC,CAAC;EAC5F,MAAM,EAAE,OAAO,WAAW,IAAI,gBAAgB;EAC9C,MAAM,EAAE,MAAM,MAAM,SAAS,IAAI;EAGjC,IAAI,EADF,OAAO,QAAQ,QAAQ,QAAQ,SAAS,KAAK,OAAO,SAAS,QAAQ,SAAS,SAAS,IAC9E;GACT,aAAa,OAAO,GAAG,OAAO,GAAG,OAAO,IAAI,OAAO,OAAO,OAAO,IAAI,OAAO,MAAM;GAClF;EACF;EACA,MAAM,OAAO,OAAO,IAAI,OAAO;EAC/B,MAAM,MAAM,OAAO,IAAI,OAAO;EAC9B,MAAM,QAAQ,OAAO,OAAO,QAAQ;EACpC,MAAM,SAAS,MAAM,OAAO,SAAS;EAGrC,IADE,QAAQ,UAAU,OAAO,UAAU,SAAS,QAAQ,UAAU,UAAU,SAAS,QACtE;EACb,IAAI,QAAQ,KAAK,OAAO,SAAS,GAAG,SAAS,KAAK,MAAM,UAAU,CAAC;CACrE;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"viewport.js","names":[],"sources":["../../src/editor/viewport.ts"],"sourcesContent":["import { getAxisAlignedWorldBounds } from '@pairdraw/scene-graph/coordinate'\nimport { computeBounds, computeAbsoluteBounds } from '@pairdraw/scene-graph/geometry'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN } from '#core/constants'\nimport { emitNavigationTrace } from '#core/profiler'\n\nimport type { EditorContext, ViewportInsets, VisibleCanvas } from './types'\n\n/** Space kept between revealed layers and the viewport edge. */\nconst REVEAL_MARGIN = 48\n\n/** No floating chrome, for an editor whose canvas is bare. */\nexport const NO_VIEWPORT_INSETS: ViewportInsets = { top: 0, right: 0, bottom: 0, left: 0 }\n\n/**\n * The part of the canvas no floating chrome covers. A rail on the left or a pill at the bottom sits\n * above the canvas element, so fitting to the whole element hides content under it.\n */\nexport function visibleCanvas(ctx: EditorContext): VisibleCanvas {\n const { width, height } = ctx.getViewportSize()\n const insets = ctx.getViewportInsets()\n const left = Math.min(Math.max(insets.left, 0), width)\n const top = Math.min(Math.max(insets.top, 0), height)\n const right = Math.min(Math.max(insets.right, 0), width - left)\n const bottom = Math.min(Math.max(insets.bottom, 0), height - top)\n const area = { left, top, width: width - left - right, height: height - top - bottom }\n // Chrome that covers everything is no guide at all; the whole canvas is then the best guess.\n return area.width > 0 && area.height > 0 ? area : { left: 0, top: 0, width, height }\n}\n\nexport function createViewportActions(ctx: EditorContext) {\n function currentViewport() {\n return { panX: ctx.state.panX, panY: ctx.state.panY, zoom: ctx.state.zoom }\n }\n\n function emitViewportChanged(previous: ReturnType<typeof currentViewport>) {\n const next = currentViewport()\n if (next.panX !== previous.panX || next.panY !== previous.panY || next.zoom !== previous.zoom) {\n emitNavigationTrace('viewport:changed', {\n panX: next.panX,\n panY: next.panY,\n zoom: next.zoom,\n previousPanX: previous.panX,\n previousPanY: previous.panY,\n previousZoom: previous.zoom\n })\n ctx.emitEditorEvent('viewport:changed', next, previous)\n }\n }\n\n function screenToCanvas(sx: number, sy: number) {\n return {\n x: (sx - ctx.state.panX) / ctx.state.zoom,\n y: (sy - ctx.state.panY) / ctx.state.zoom\n }\n }\n\n function setZoomAroundPoint(level: number, centerX: number, centerY: number) {\n const previous = currentViewport()\n const newZoom = Math.max(0.02, Math.min(256, level))\n ctx.state.panX = centerX - (centerX - ctx.state.panX) * (newZoom / ctx.state.zoom)\n ctx.state.panY = centerY - (centerY - ctx.state.panY) * (newZoom / ctx.state.zoom)\n ctx.state.zoom = newZoom\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n function applyZoom(delta: number, centerX: number, centerY: number) {\n const factor = Math.min(\n ZOOM_SCALE_MAX,\n Math.max(ZOOM_SCALE_MIN, Math.exp(-delta / ZOOM_DIVISOR))\n )\n setZoomAroundPoint(ctx.state.zoom * factor, centerX, centerY)\n }\n\n function pan(dx: number, dy: number) {\n const previous = currentViewport()\n ctx.state.panX += dx\n ctx.state.panY += dy\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n function zoomToBounds(minX: number, minY: number, maxX: number, maxY: number) {\n const previous = currentViewport()\n const padding = 80\n const w = maxX - minX + padding * 2\n const h = maxY - minY + padding * 2\n\n const area = visibleCanvas(ctx)\n const zoom = Math.max(0.02, Math.min(area.width / w, area.height / h, 1))\n\n ctx.state.zoom = zoom\n ctx.state.panX = area.left + (area.width - w * zoom) / 2 - minX * zoom + padding * zoom\n ctx.state.panY = area.top + (area.height - h * zoom) / 2 - minY * zoom + padding * zoom\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n /**\n * Fits the world area to the viewport, edge to edge and at any zoom, as a drag of Figma's zoom\n * tool does; `zoomToBounds` instead leaves a margin and never zooms past 100%. An area with no\n * width or height leaves the view alone.\n */\n function zoomToArea(minX: number, minY: number, maxX: number, maxY: number) {\n const width = maxX - minX\n const height = maxY - minY\n if (!(width > 0) || !(height > 0)) return\n const previous = currentViewport()\n const area = visibleCanvas(ctx)\n const zoom = Math.max(0.02, Math.min(256, Math.min(area.width / width, area.height / height)))\n ctx.state.zoom = zoom\n ctx.state.panX = area.left + area.width / 2 - (minX + width / 2) * zoom\n ctx.state.panY = area.top + area.height / 2 - (minY + height / 2) * zoom\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n /** Put the world point (x, y) at the center of the viewport, at `zoom` (the current one by default). */\n function centerOn(x: number, y: number, zoom = ctx.state.zoom) {\n const previous = currentViewport()\n const area = visibleCanvas(ctx)\n const nextZoom = Math.max(0.02, Math.min(256, zoom))\n const panX = area.left + area.width / 2 - x * nextZoom\n const panY = area.top + area.height / 2 - y * nextZoom\n // Remote cursors are finite but unbounded; a point that overflows leaves the view alone.\n if (!Number.isFinite(panX) || !Number.isFinite(panY)) return\n ctx.state.zoom = nextZoom\n ctx.state.panX = panX\n ctx.state.panY = panY\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n function zoomToFit() {\n const nodes = ctx.graph.getChildren(ctx.state.currentPageId)\n if (nodes.length === 0) return\n\n const b = computeBounds(nodes)\n zoomToBounds(b.x, b.y, b.x + b.width, b.y + b.height)\n }\n\n function zoomToLevel(level: number) {\n const area = visibleCanvas(ctx)\n const centerX = (-ctx.state.panX + area.left + area.width / 2) / ctx.state.zoom\n const centerY = (-ctx.state.panY + area.top + area.height / 2) / ctx.state.zoom\n\n const previous = currentViewport()\n ctx.state.zoom = Math.max(0.02, Math.min(256, level))\n // Keep the world point at the center of the viewport where it was.\n ctx.state.panX = area.left + area.width / 2 - centerX * ctx.state.zoom\n ctx.state.panY = area.top + area.height / 2 - centerY * ctx.state.zoom\n ctx.requestRepaint()\n emitViewportChanged(previous)\n }\n\n function zoomTo100() {\n zoomToLevel(1)\n }\n\n function zoomToSelection() {\n if (ctx.state.selectedIds.size === 0) return\n\n const nodes = [...ctx.state.selectedIds]\n .map((id) => ctx.graph.getNode(id))\n .filter((n): n is NonNullable<typeof n> => n != null)\n if (nodes.length === 0) return\n\n const b = computeAbsoluteBounds(nodes, ctx.graph)\n zoomToBounds(b.x, b.y, b.x + b.width, b.y + b.height)\n }\n\n /**\n * Brings layers into view: pans to center them when they fit at the current zoom and are not\n * already visible, and zooms out to fit them only when they do not fit.\n */\n function revealNodes(nodeIds: readonly string[], margin = REVEAL_MARGIN) {\n const nodes = nodeIds.map((id) => ctx.graph.getNode(id)).filter((node) => node !== undefined)\n if (nodes.length === 0) return\n const bounds = computeBounds(nodes.map((node) => getAxisAlignedWorldBounds(node, ctx.graph)))\n const area = visibleCanvas(ctx)\n const { zoom, panX, panY } = ctx.state\n const fits =\n bounds.width * zoom <= area.width - margin * 2 &&\n bounds.height * zoom <= area.height - margin * 2\n if (!fits) {\n zoomToBounds(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height)\n return\n }\n const left = bounds.x * zoom + panX\n const top = bounds.y * zoom + panY\n const right = left + bounds.width * zoom\n const bottom = top + bounds.height * zoom\n const visible =\n left >= area.left + margin &&\n top >= area.top + margin &&\n right <= area.left + area.width - margin &&\n bottom <= area.top + area.height - margin\n if (visible) return\n pan(\n area.left + area.width / 2 - (left + right) / 2,\n area.top + area.height / 2 - (top + bottom) / 2\n )\n }\n\n /** The middle of the canvas the floating chrome leaves, in canvas pixels from its top-left. */\n function viewportCanvasCenter(): Vector {\n const area = visibleCanvas(ctx)\n return { x: area.left + area.width / 2, y: area.top + area.height / 2 }\n }\n\n return {\n viewportCanvasCenter,\n revealNodes,\n screenToCanvas,\n setZoomAroundPoint,\n applyZoom,\n pan,\n zoomToBounds,\n zoomToArea,\n centerOn,\n zoomToFit,\n zoomTo100,\n zoomToLevel,\n zoomToSelection\n }\n}\n"],"mappings":";;;;;;AAUA,MAAM,gBAAgB;;AAGtB,MAAa,qBAAqC;CAAE,KAAK;CAAG,OAAO;CAAG,QAAQ;CAAG,MAAM;AAAE;;;;;AAMzF,SAAgB,cAAc,KAAmC;CAC/D,MAAM,EAAE,OAAO,WAAW,IAAI,gBAAgB;CAC9C,MAAM,SAAS,IAAI,kBAAkB;CACrC,MAAM,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK;CACrD,MAAM,MAAM,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,GAAG,MAAM;CACpD,MAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,OAAO,OAAO,CAAC,GAAG,QAAQ,IAAI;CAC9D,MAAM,SAAS,KAAK,IAAI,KAAK,IAAI,OAAO,QAAQ,CAAC,GAAG,SAAS,GAAG;CAChE,MAAM,OAAO;EAAE;EAAM;EAAK,OAAO,QAAQ,OAAO;EAAO,QAAQ,SAAS,MAAM;CAAO;CAErF,OAAO,KAAK,QAAQ,KAAK,KAAK,SAAS,IAAI,OAAO;EAAE,MAAM;EAAG,KAAK;EAAG;EAAO;CAAO;AACrF;AAEA,SAAgB,sBAAsB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AAS,KAAK,MAAM,UAAU,CAChD;CACF;;CAGA,SAAS,uBAA+B;EACtC,MAAM,OAAO,cAAc,GAAG;EAC9B,OAAO;GAAE,GAAG,KAAK,OAAO,KAAK,QAAQ;GAAG,GAAG,KAAK,MAAM,KAAK,SAAS;EAAE;CACxE;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","names":[],"sources":["../../../src/editor/views/actions.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"actions.d.ts","names":[],"sources":["../../../src/editor/views/actions.ts"],"mappings":";;;;;iBAkBgB,wBAAwB,KAAK,eAAe,UAAU;uBAAA;;;;;;;;;;;;;;;;EAWxC;EAQN;EAOD;EAIE;EAMD"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { EDIT_VIEW, resolveEditorProfile } from "./profile.js";
|
|
2
|
-
import { createPresentationActions,
|
|
2
|
+
import { createPresentationActions, currentPlace, returnToPlace } from "./present.js";
|
|
3
3
|
import { createShaderModeActions } from "./shader.js";
|
|
4
4
|
//#region src/editor/views/actions.ts
|
|
5
|
+
/** The place a view put the canvas aside from, for a view that fits or scrolls it. */
|
|
6
|
+
function returnPlace(view) {
|
|
7
|
+
if (view.id === "present") return view.returnTo;
|
|
8
|
+
return view.id === "play" ? view.returnTo : null;
|
|
9
|
+
}
|
|
5
10
|
function createCanvasViewActions(ctx, viewport) {
|
|
6
11
|
function setCanvasView(view) {
|
|
7
12
|
const left = ctx.state.canvasView;
|
|
8
13
|
ctx.state.canvasView = view;
|
|
9
|
-
|
|
14
|
+
const back = left.id === view.id ? null : returnPlace(left);
|
|
15
|
+
if (back) returnToPlace(ctx, back, viewport);
|
|
10
16
|
ctx.requestRepaint();
|
|
11
17
|
}
|
|
12
18
|
/** Leaves the canvas's view for the one it returns to; false when there is none to leave. */
|
|
@@ -22,10 +28,11 @@ function createCanvasViewActions(ctx, viewport) {
|
|
|
22
28
|
ctx.state.hoveredNodeId = null;
|
|
23
29
|
setCanvasView({
|
|
24
30
|
id: "play",
|
|
25
|
-
revision: 0
|
|
31
|
+
revision: 0,
|
|
32
|
+
returnTo: currentPlace(ctx)
|
|
26
33
|
});
|
|
27
34
|
}
|
|
28
|
-
/** Go back to editing; the canvas draws every layer again. */
|
|
35
|
+
/** Go back to editing; the canvas draws every layer again where it looked before. */
|
|
29
36
|
function stopPlay() {
|
|
30
37
|
if (ctx.state.canvasView.id === "play") setCanvasView(EDIT_VIEW);
|
|
31
38
|
}
|
|
@@ -38,7 +45,8 @@ function createCanvasViewActions(ctx, viewport) {
|
|
|
38
45
|
const view = ctx.state.canvasView;
|
|
39
46
|
if (view.id === "play") ctx.state.canvasView = {
|
|
40
47
|
id: "play",
|
|
41
|
-
revision: view.revision + 1
|
|
48
|
+
revision: view.revision + 1,
|
|
49
|
+
returnTo: view.returnTo
|
|
42
50
|
};
|
|
43
51
|
}
|
|
44
52
|
ctx.onEditorEvent("graph:replaced", resetPlay);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","names":[],"sources":["../../../src/editor/views/actions.ts"],"sourcesContent":["import type { EditorContext } from '#core/editor/types'\n\nimport {\n createPresentationActions,\n
|
|
1
|
+
{"version":3,"file":"actions.js","names":[],"sources":["../../../src/editor/views/actions.ts"],"sourcesContent":["import type { EditorContext } from '#core/editor/types'\n\nimport {\n createPresentationActions,\n currentPlace,\n returnToPlace,\n type PresentationViewport\n} from './present'\nimport { EDIT_VIEW, resolveEditorProfile } from './profile'\nimport { createShaderModeActions } from './shader'\nimport type { CanvasView, ViewportPlace } from './types'\n\n/** The place a view put the canvas aside from, for a view that fits or scrolls it. */\nfunction returnPlace(view: CanvasView): ViewportPlace | null {\n if (view.id === 'present') return view.returnTo\n return view.id === 'play' ? view.returnTo : null\n}\n\nexport function createCanvasViewActions(ctx: EditorContext, viewport: PresentationViewport) {\n function setCanvasView(view: CanvasView): void {\n const left = ctx.state.canvasView\n ctx.state.canvasView = view\n // However a preview or presentation is left, the canvas returns to where it looked before it.\n const back = left.id === view.id ? null : returnPlace(left)\n if (back) returnToPlace(ctx, back, viewport)\n ctx.requestRepaint()\n }\n\n /** Leaves the canvas's view for the one it returns to; false when there is none to leave. */\n function leaveCanvasView(): boolean {\n const target = resolveEditorProfile(ctx.state).leaveTo\n if (!target) return false\n setCanvasView(target)\n return true\n }\n\n /** Preview this canvas: layers holding controls run as live components. */\n function startPlay(): void {\n if (ctx.state.canvasView.id === 'play') return\n ctx.state.hoveredNodeId = null\n setCanvasView({ id: 'play', revision: 0, returnTo: currentPlace(ctx) })\n }\n\n /** Go back to editing; the canvas draws every layer again where it looked before. */\n function stopPlay(): void {\n if (ctx.state.canvasView.id === 'play') setCanvasView(EDIT_VIEW)\n }\n\n function togglePlay(): void {\n if (ctx.state.canvasView.id === 'play') stopPlay()\n else startPlay()\n }\n\n /** Put every control back as designed by running the islands afresh. */\n function resetPlay(): void {\n const view = ctx.state.canvasView\n if (view.id === 'play') {\n ctx.state.canvasView = { id: 'play', revision: view.revision + 1, returnTo: view.returnTo }\n }\n }\n\n // Another document's layers start from their designed state, not from the old islands'.\n ctx.onEditorEvent('graph:replaced', resetPlay)\n\n const presentation = createPresentationActions(ctx, viewport, setCanvasView)\n const shaderMode = createShaderModeActions(ctx, setCanvasView)\n\n return {\n leaveCanvasView,\n startPlay,\n stopPlay,\n togglePlay,\n resetPlay,\n ...presentation,\n ...shaderMode\n }\n}\n"],"mappings":";;;;;AAaA,SAAS,YAAY,MAAwC;CAC3D,IAAI,KAAK,OAAO,WAAW,OAAO,KAAK;CACvC,OAAO,KAAK,OAAO,SAAS,KAAK,WAAW;AAC9C;AAEA,SAAgB,wBAAwB,KAAoB,UAAgC;CAC1F,SAAS,cAAc,MAAwB;EAC7C,MAAM,OAAO,IAAI,MAAM;EACvB,IAAI,MAAM,aAAa;EAEvB,MAAM,OAAO,KAAK,OAAO,KAAK,KAAK,OAAO,YAAY,IAAI;EAC1D,IAAI,MAAM,cAAc,KAAK,MAAM,QAAQ;EAC3C,IAAI,eAAe;CACrB;;CAGA,SAAS,kBAA2B;EAClC,MAAM,SAAS,qBAAqB,IAAI,KAAK,CAAC,CAAC;EAC/C,IAAI,CAAC,QAAQ,OAAO;EACpB,cAAc,MAAM;EACpB,OAAO;CACT;;CAGA,SAAS,YAAkB;EACzB,IAAI,IAAI,MAAM,WAAW,OAAO,QAAQ;EACxC,IAAI,MAAM,gBAAgB;EAC1B,cAAc;GAAE,IAAI;GAAQ,UAAU;GAAG,UAAU,aAAa,GAAG;EAAE,CAAC;CACxE;;CAGA,SAAS,WAAiB;EACxB,IAAI,IAAI,MAAM,WAAW,OAAO,QAAQ,cAAc,SAAS;CACjE;CAEA,SAAS,aAAmB;EAC1B,IAAI,IAAI,MAAM,WAAW,OAAO,QAAQ,SAAS;OAC5C,UAAU;CACjB;;CAGA,SAAS,YAAkB;EACzB,MAAM,OAAO,IAAI,MAAM;EACvB,IAAI,KAAK,OAAO,QACd,IAAI,MAAM,aAAa;GAAE,IAAI;GAAQ,UAAU,KAAK,WAAW;GAAG,UAAU,KAAK;EAAS;CAE9F;CAGA,IAAI,cAAc,kBAAkB,SAAS;CAE7C,MAAM,eAAe,0BAA0B,KAAK,UAAU,aAAa;CAC3E,MAAM,aAAa,wBAAwB,KAAK,aAAa;CAE7D,OAAO;EACL;EACA;EACA;EACA;EACA;EACA,GAAG;EACH,GAAG;CACL;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CanvasView,
|
|
1
|
+
import { CanvasView, PresentationScale, ViewportCenter, ViewportPlace } from "./types.js";
|
|
2
2
|
import { EditorContext } from "../types.js";
|
|
3
3
|
import { createViewportActions } from "../viewport.js";
|
|
4
4
|
import { Rect, Size } from "@pairdraw/scene-graph/primitives";
|
|
@@ -20,11 +20,13 @@ interface PresentationState {
|
|
|
20
20
|
* that axis.
|
|
21
21
|
*/
|
|
22
22
|
declare function presentationViewport(slide: Rect, screen: Size, scale: PresentationScale, scrolledTo?: Pick<ViewportCenter, 'x' | 'y'>): ViewportCenter;
|
|
23
|
+
/** Where the canvas looked before a view replaces it, as the place to return to. */
|
|
24
|
+
declare function currentPlace(ctx: EditorContext): ViewportPlace;
|
|
23
25
|
/**
|
|
24
|
-
* Puts the canvas back where it looked before
|
|
26
|
+
* Puts the canvas back where it looked before a view took it elsewhere: its pan and zoom, so the
|
|
25
27
|
* editor's canvas, back at its own size, shows what it showed.
|
|
26
28
|
*/
|
|
27
|
-
declare function
|
|
29
|
+
declare function returnToPlace(ctx: EditorContext, place: ViewportPlace, viewport: PresentationViewport): void;
|
|
28
30
|
/**
|
|
29
31
|
* Presenting the page's slides, a slide at a time: the canvas runs as a preview and shows one
|
|
30
32
|
* slide, fitted or at 100%, and steps through the slides in the page's layer order. Leaving the
|
|
@@ -44,5 +46,5 @@ declare function createPresentationActions(ctx: EditorContext, viewport: Present
|
|
|
44
46
|
scrollPresentation: (dx: number, dy: number) => boolean;
|
|
45
47
|
};
|
|
46
48
|
//#endregion
|
|
47
|
-
export { PresentationState, PresentationViewport, createPresentationActions, presentationViewport,
|
|
49
|
+
export { PresentationState, PresentationViewport, createPresentationActions, currentPlace, presentationViewport, returnToPlace };
|
|
48
50
|
//# sourceMappingURL=present.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"present.d.ts","names":[],"sources":["../../../src/editor/views/present.ts"],"mappings":";;;;;;KAgBY,uBAAuB,KAAK,kBAAkB;;UAGzC;EACf;;EAEA;EACA;EACA,OAAO;;;;;;;;iBAmBO,qBACd,OAAO,MACP,QAAQ,MACR,OAAO,mBACP,aAAa,KAAK,6BACjB;;;;;
|
|
1
|
+
{"version":3,"file":"present.d.ts","names":[],"sources":["../../../src/editor/views/present.ts"],"mappings":";;;;;;KAgBY,uBAAuB,KAAK,kBAAkB;;UAGzC;EACf;;EAEA;EACA;EACA,OAAO;;;;;;;;iBAmBO,qBACd,OAAO,MACP,QAAQ,MACR,OAAO,mBACP,aAAa,KAAK,6BACjB;;iBA8Ba,aAAa,KAAK,gBAAgB;;;;;iBASlC,cACd,KAAK,eACL,OAAO,eACP,UAAU;;;;;;iBAgBI,0BACd,KAAK,eACL,UAAU,sBACV,gBAAgB,MAAM;;EAyBM,uBAAA;EAaS,oBAAA;EAsBR;EAIE;EAMA,eAAA;EA0BF;EAII;EAKI,uBAAA,OAAA;EAST;EAUI,qBAAA,YAAM"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { pageSlides } from "../bridges/frames.js";
|
|
2
|
+
import { visibleCanvas } from "../viewport.js";
|
|
2
3
|
import { getAxisAlignedWorldBounds } from "@pairdraw/scene-graph/coordinate";
|
|
3
4
|
//#region src/editor/views/present.ts
|
|
4
5
|
/**
|
|
@@ -36,16 +37,17 @@ function presentationViewport(slide, screen, scale, scrolledTo) {
|
|
|
36
37
|
zoom
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
/** The world point at the
|
|
40
|
+
/** The world point at the middle of the canvas the chrome leaves, as `centerOn` takes it back. */
|
|
40
41
|
function currentCenter(ctx) {
|
|
41
|
-
const
|
|
42
|
+
const area = visibleCanvas(ctx);
|
|
42
43
|
const { panX, panY, zoom } = ctx.state;
|
|
43
44
|
return {
|
|
44
|
-
x: (width / 2 - panX) / zoom,
|
|
45
|
-
y: (height / 2 - panY) / zoom,
|
|
45
|
+
x: (area.left + area.width / 2 - panX) / zoom,
|
|
46
|
+
y: (area.top + area.height / 2 - panY) / zoom,
|
|
46
47
|
zoom
|
|
47
48
|
};
|
|
48
49
|
}
|
|
50
|
+
/** Where the canvas looked before a view replaces it, as the place to return to. */
|
|
49
51
|
function currentPlace(ctx) {
|
|
50
52
|
const { panX, panY, zoom } = ctx.state;
|
|
51
53
|
return {
|
|
@@ -55,13 +57,13 @@ function currentPlace(ctx) {
|
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
|
-
* Puts the canvas back where it looked before
|
|
60
|
+
* Puts the canvas back where it looked before a view took it elsewhere: its pan and zoom, so the
|
|
59
61
|
* editor's canvas, back at its own size, shows what it showed.
|
|
60
62
|
*/
|
|
61
|
-
function
|
|
62
|
-
const
|
|
63
|
-
const { panX, panY, zoom } =
|
|
64
|
-
viewport.centerOn((width / 2 - panX) / zoom, (height / 2 - panY) / zoom, zoom);
|
|
63
|
+
function returnToPlace(ctx, place, viewport) {
|
|
64
|
+
const area = visibleCanvas(ctx);
|
|
65
|
+
const { panX, panY, zoom } = place;
|
|
66
|
+
viewport.centerOn((area.left + area.width / 2 - panX) / zoom, (area.top + area.height / 2 - panY) / zoom, zoom);
|
|
65
67
|
}
|
|
66
68
|
/**
|
|
67
69
|
* Presenting the page's slides, a slide at a time: the canvas runs as a preview and shows one
|
|
@@ -222,6 +224,6 @@ function createPresentationActions(ctx, viewport, setCanvasView) {
|
|
|
222
224
|
};
|
|
223
225
|
}
|
|
224
226
|
//#endregion
|
|
225
|
-
export { createPresentationActions, presentationViewport,
|
|
227
|
+
export { createPresentationActions, currentPlace, presentationViewport, returnToPlace };
|
|
226
228
|
|
|
227
229
|
//# sourceMappingURL=present.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"present.js","names":[],"sources":["../../../src/editor/views/present.ts"],"sourcesContent":["import { getAxisAlignedWorldBounds } from '@pairdraw/scene-graph/coordinate'\nimport type { Rect, Size } from '@pairdraw/scene-graph/primitives'\n\nimport { pageSlides } from '#core/editor/bridges/frames'\nimport type { EditorContext } from '#core/editor/types'\nimport type { createViewportActions } from '#core/editor/viewport'\n\nimport type {\n CanvasView,\n PresentationScale,\n PresentView,\n ViewportCenter,\n ViewportPlace\n} from './types'\n\n/** The viewport action a presentation moves the canvas with. */\nexport type PresentationViewport = Pick<ReturnType<typeof createViewportActions>, 'centerOn'>\n\n/** What a front end shows of a presentation: the slide on screen, its place, and its scale. */\nexport interface PresentationState {\n slideId: string\n /** The slide's place in the page's slide order, from 0. */\n index: number\n count: number\n scale: PresentationScale\n}\n\n/**\n * Where on one axis the screen's center goes: the slide's middle when the slide fits the screen,\n * otherwise as near `center` as keeps the screen inside the slide.\n */\nfunction clampAxis(start: number, extent: number, screen: number, zoom: number, center: number) {\n const visible = screen / zoom\n if (extent <= visible) return start + extent / 2\n return Math.min(Math.max(center, start + visible / 2), start + extent - visible / 2)\n}\n\n/**\n * Where a presentation puts the canvas for a slide: fitted, the whole slide centered as large as\n * the screen holds; at 100%, the screen kept inside the slide, from its top-left corner unless\n * `scrolledTo` says where it scrolled. A slide narrower or shorter than the screen centers on\n * that axis.\n */\nexport function presentationViewport(\n slide: Rect,\n screen: Size,\n scale: PresentationScale,\n scrolledTo?: Pick<ViewportCenter, 'x' | 'y'>\n): ViewportCenter {\n if (scale === 'fit') {\n const fitted = Math.min(screen.width / slide.width, screen.height / slide.height)\n return {\n x: slide.x + slide.width / 2,\n y: slide.y + slide.height / 2,\n zoom: Number.isFinite(fitted) && fitted > 0 ? fitted : 1\n }\n }\n const zoom = 1\n const center = scrolledTo ?? { x: -Infinity, y: -Infinity }\n return {\n x: clampAxis(slide.x, slide.width, screen.width, zoom, center.x),\n y: clampAxis(slide.y, slide.height, screen.height, zoom, center.y),\n zoom\n }\n}\n\n/** The world point at the screen's center and the zoom, as `centerOn` takes them back. */\nfunction currentCenter(ctx: EditorContext): ViewportCenter {\n const { width, height } = ctx.getViewportSize()\n const { panX, panY, zoom } = ctx.state\n return { x: (width / 2 - panX) / zoom, y: (height / 2 - panY) / zoom, zoom }\n}\n\nfunction currentPlace(ctx: EditorContext): ViewportPlace {\n const { panX, panY, zoom } = ctx.state\n return { panX, panY, zoom }\n}\n\n/**\n * Puts the canvas back where it looked before the presentation started: its pan and zoom, so the\n * editor's canvas, back at its own size, shows what it showed.\n */\nexport function returnFromPresentation(\n ctx: EditorContext,\n view: PresentView,\n viewport: PresentationViewport\n): void {\n const { width, height } = ctx.getViewportSize()\n const { panX, panY, zoom } = view.returnTo\n viewport.centerOn((width / 2 - panX) / zoom, (height / 2 - panY) / zoom, zoom)\n}\n\n/**\n * Presenting the page's slides, a slide at a time: the canvas runs as a preview and shows one\n * slide, fitted or at 100%, and steps through the slides in the page's layer order. Leaving the\n * presentation, by any way out of the view, returns the canvas to where it looked.\n */\nexport function createPresentationActions(\n ctx: EditorContext,\n viewport: PresentationViewport,\n setCanvasView: (view: CanvasView) => void\n) {\n function presented(): PresentView | null {\n const view = ctx.state.canvasView\n return view.id === 'present' ? view : null\n }\n\n /** The page's slides, in the order they are presented and exported. */\n function getSlides() {\n return pageSlides(ctx.graph, ctx.state.currentPageId)\n }\n\n function slideBounds(slideId: string): Rect | null {\n const node = ctx.graph.getNode(slideId)\n return node ? getAxisAlignedWorldBounds(node, ctx.graph) : null\n }\n\n function show(view: PresentView, scrolledTo?: Pick<ViewportCenter, 'x' | 'y'>) {\n const bounds = slideBounds(view.slideId)\n if (!bounds) return\n const target = presentationViewport(bounds, ctx.getViewportSize(), view.scale, scrolledTo)\n viewport.centerOn(target.x, target.y, target.zoom)\n }\n\n /** The presentation on this canvas, or null while it shows something else. */\n function getPresentation(): PresentationState | null {\n const view = presented()\n if (!view) return null\n const order = getSlides()\n const index = order.findIndex((slide) => slide.id === view.slideId)\n if (index === -1) return null\n return { slideId: view.slideId, index, count: order.length, scale: view.scale }\n }\n\n /**\n * Presents the page's slides from `slideId`, or from the slide holding the selection, or from\n * the first; false when the page has no slides.\n */\n function startPresentation(slideId?: string): boolean {\n const order = getSlides()\n if (order.length === 0) return false\n const ids = new Set(order.map((slide) => slide.id))\n const [selectedId] = ctx.state.selectedIds\n const holding = selectedId ? ctx.graph.closest(selectedId, (node) => ids.has(node.id)) : null\n const start = (slideId && ids.has(slideId) ? slideId : null) ?? holding?.id ?? order[0].id\n const current = presented()\n const view: PresentView = {\n id: 'present',\n revision: current?.revision ?? 0,\n slideId: start,\n scale: current?.scale ?? 'fit',\n returnTo: current?.returnTo ?? currentPlace(ctx)\n }\n ctx.state.hoveredNodeId = null\n setCanvasView(view)\n show(view)\n return true\n }\n\n /** Leaves the presentation for editing, back where the canvas looked before it. */\n function stopPresentation(): void {\n if (presented()) setCanvasView({ id: 'edit' })\n }\n\n function togglePresentation(): void {\n if (presented()) stopPresentation()\n else startPresentation()\n }\n\n /** Shows another slide of the presentation; false when there is none to show. */\n function presentSlide(slideId: string): boolean {\n const view = presented()\n if (!view || !getSlides().some((slide) => slide.id === slideId)) return false\n const next: PresentView = { ...view, slideId }\n setCanvasView(next)\n show(next)\n return true\n }\n\n /**\n * Steps to the next or previous slide; false at either end, where the presentation stays. A\n * slide removed while it was shown ends the presentation.\n */\n function presentAdjacentSlide(step: 1 | -1): boolean {\n const view = presented()\n if (!view) return false\n const order = getSlides()\n const index = order.findIndex((slide) => slide.id === view.slideId)\n if (index === -1) {\n stopPresentation()\n return false\n }\n const target = order.at(index + step)\n return index + step >= 0 && target ? presentSlide(target.id) : false\n }\n\n function presentNextSlide(): boolean {\n return presentAdjacentSlide(1)\n }\n\n function presentPreviousSlide(): boolean {\n return presentAdjacentSlide(-1)\n }\n\n /** Shows the slide fitted to the screen or at 100%. */\n function setPresentationScale(scale: PresentationScale): void {\n const view = presented()\n if (!view || view.scale === scale) return\n const next: PresentView = { ...view, scale }\n setCanvasView(next)\n show(next)\n }\n\n /** Puts the slide back in place, as after the screen changed size. */\n function fitPresentation(): void {\n const view = presented()\n if (!view) return\n show(view, view.scale === 'actual' ? currentCenter(ctx) : undefined)\n }\n\n /**\n * Scrolls a slide shown at 100% by screen pixels, within the slide; false when it is already\n * at that edge or fits the screen, so a front end can step to the next slide instead.\n */\n function scrollPresentation(dx: number, dy: number): boolean {\n const view = presented()\n if (view?.scale !== 'actual') return false\n const bounds = slideBounds(view.slideId)\n if (!bounds) return false\n const from = currentCenter(ctx)\n const target = presentationViewport(bounds, ctx.getViewportSize(), 'actual', {\n x: from.x + dx / from.zoom,\n y: from.y + dy / from.zoom\n })\n if (Math.abs(target.x - from.x) < 0.5 && Math.abs(target.y - from.y) < 0.5) return false\n viewport.centerOn(target.x, target.y, target.zoom)\n return true\n }\n\n // Another document has other slides, so its arrival ends the presentation; the canvas stays\n // where the new document puts it rather than returning to a place in the old one.\n ctx.onEditorEvent('graph:replaced', () => {\n if (!presented()) return\n ctx.state.canvasView = { id: 'edit' }\n ctx.requestRepaint()\n })\n\n return {\n getSlides,\n getPresentation,\n startPresentation,\n stopPresentation,\n togglePresentation,\n presentSlide,\n presentNextSlide,\n presentPreviousSlide,\n setPresentationScale,\n fitPresentation,\n scrollPresentation\n }\n}\n"],"mappings":";;;;;;;AA+BA,SAAS,UAAU,OAAe,QAAgB,QAAgB,MAAc,QAAgB;CAC9F,MAAM,UAAU,SAAS;CACzB,IAAI,UAAU,SAAS,OAAO,QAAQ,SAAS;CAC/C,OAAO,KAAK,IAAI,KAAK,IAAI,QAAQ,QAAQ,UAAU,CAAC,GAAG,QAAQ,SAAS,UAAU,CAAC;AACrF;;;;;;;AAQA,SAAgB,qBACd,OACA,QACA,OACA,YACgB;CAChB,IAAI,UAAU,OAAO;EACnB,MAAM,SAAS,KAAK,IAAI,OAAO,QAAQ,MAAM,OAAO,OAAO,SAAS,MAAM,MAAM;EAChF,OAAO;GACL,GAAG,MAAM,IAAI,MAAM,QAAQ;GAC3B,GAAG,MAAM,IAAI,MAAM,SAAS;GAC5B,MAAM,OAAO,SAAS,MAAM,KAAK,SAAS,IAAI,SAAS;EACzD;CACF;CACA,MAAM,OAAO;CACb,MAAM,SAAS,cAAc;EAAE,GAAG;EAAW,GAAG;CAAU;CAC1D,OAAO;EACL,GAAG,UAAU,MAAM,GAAG,MAAM,OAAO,OAAO,OAAO,MAAM,OAAO,CAAC;EAC/D,GAAG,UAAU,MAAM,GAAG,MAAM,QAAQ,OAAO,QAAQ,MAAM,OAAO,CAAC;EACjE;CACF;AACF;;AAGA,SAAS,cAAc,KAAoC;CACzD,MAAM,EAAE,OAAO,WAAW,IAAI,gBA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,IAAI,OAAO;EACpC,IAAI,eAAe;CACrB,CAAC;CAED,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"present.js","names":[],"sources":["../../../src/editor/views/present.ts"],"sourcesContent":["import { getAxisAlignedWorldBounds } from '@pairdraw/scene-graph/coordinate'\nimport type { Rect, Size } from '@pairdraw/scene-graph/primitives'\n\nimport { pageSlides } from '#core/editor/bridges/frames'\nimport type { EditorContext } from '#core/editor/types'\nimport { visibleCanvas, type createViewportActions } from '#core/editor/viewport'\n\nimport type {\n CanvasView,\n PresentationScale,\n PresentView,\n ViewportCenter,\n ViewportPlace\n} from './types'\n\n/** The viewport action a presentation moves the canvas with. */\nexport type PresentationViewport = Pick<ReturnType<typeof createViewportActions>, 'centerOn'>\n\n/** What a front end shows of a presentation: the slide on screen, its place, and its scale. */\nexport interface PresentationState {\n slideId: string\n /** The slide's place in the page's slide order, from 0. */\n index: number\n count: number\n scale: PresentationScale\n}\n\n/**\n * Where on one axis the screen's center goes: the slide's middle when the slide fits the screen,\n * otherwise as near `center` as keeps the screen inside the slide.\n */\nfunction clampAxis(start: number, extent: number, screen: number, zoom: number, center: number) {\n const visible = screen / zoom\n if (extent <= visible) return start + extent / 2\n return Math.min(Math.max(center, start + visible / 2), start + extent - visible / 2)\n}\n\n/**\n * Where a presentation puts the canvas for a slide: fitted, the whole slide centered as large as\n * the screen holds; at 100%, the screen kept inside the slide, from its top-left corner unless\n * `scrolledTo` says where it scrolled. A slide narrower or shorter than the screen centers on\n * that axis.\n */\nexport function presentationViewport(\n slide: Rect,\n screen: Size,\n scale: PresentationScale,\n scrolledTo?: Pick<ViewportCenter, 'x' | 'y'>\n): ViewportCenter {\n if (scale === 'fit') {\n const fitted = Math.min(screen.width / slide.width, screen.height / slide.height)\n return {\n x: slide.x + slide.width / 2,\n y: slide.y + slide.height / 2,\n zoom: Number.isFinite(fitted) && fitted > 0 ? fitted : 1\n }\n }\n const zoom = 1\n const center = scrolledTo ?? { x: -Infinity, y: -Infinity }\n return {\n x: clampAxis(slide.x, slide.width, screen.width, zoom, center.x),\n y: clampAxis(slide.y, slide.height, screen.height, zoom, center.y),\n zoom\n }\n}\n\n/** The world point at the middle of the canvas the chrome leaves, as `centerOn` takes it back. */\nfunction currentCenter(ctx: EditorContext): ViewportCenter {\n const area = visibleCanvas(ctx)\n const { panX, panY, zoom } = ctx.state\n return {\n x: (area.left + area.width / 2 - panX) / zoom,\n y: (area.top + area.height / 2 - panY) / zoom,\n zoom\n }\n}\n\n/** Where the canvas looked before a view replaces it, as the place to return to. */\nexport function currentPlace(ctx: EditorContext): ViewportPlace {\n const { panX, panY, zoom } = ctx.state\n return { panX, panY, zoom }\n}\n\n/**\n * Puts the canvas back where it looked before a view took it elsewhere: its pan and zoom, so the\n * editor's canvas, back at its own size, shows what it showed.\n */\nexport function returnToPlace(\n ctx: EditorContext,\n place: ViewportPlace,\n viewport: PresentationViewport\n): void {\n const area = visibleCanvas(ctx)\n const { panX, panY, zoom } = place\n viewport.centerOn(\n (area.left + area.width / 2 - panX) / zoom,\n (area.top + area.height / 2 - panY) / zoom,\n zoom\n )\n}\n\n/**\n * Presenting the page's slides, a slide at a time: the canvas runs as a preview and shows one\n * slide, fitted or at 100%, and steps through the slides in the page's layer order. Leaving the\n * presentation, by any way out of the view, returns the canvas to where it looked.\n */\nexport function createPresentationActions(\n ctx: EditorContext,\n viewport: PresentationViewport,\n setCanvasView: (view: CanvasView) => void\n) {\n function presented(): PresentView | null {\n const view = ctx.state.canvasView\n return view.id === 'present' ? view : null\n }\n\n /** The page's slides, in the order they are presented and exported. */\n function getSlides() {\n return pageSlides(ctx.graph, ctx.state.currentPageId)\n }\n\n function slideBounds(slideId: string): Rect | null {\n const node = ctx.graph.getNode(slideId)\n return node ? getAxisAlignedWorldBounds(node, ctx.graph) : null\n }\n\n function show(view: PresentView, scrolledTo?: Pick<ViewportCenter, 'x' | 'y'>) {\n const bounds = slideBounds(view.slideId)\n if (!bounds) return\n const target = presentationViewport(bounds, ctx.getViewportSize(), view.scale, scrolledTo)\n viewport.centerOn(target.x, target.y, target.zoom)\n }\n\n /** The presentation on this canvas, or null while it shows something else. */\n function getPresentation(): PresentationState | null {\n const view = presented()\n if (!view) return null\n const order = getSlides()\n const index = order.findIndex((slide) => slide.id === view.slideId)\n if (index === -1) return null\n return { slideId: view.slideId, index, count: order.length, scale: view.scale }\n }\n\n /**\n * Presents the page's slides from `slideId`, or from the slide holding the selection, or from\n * the first; false when the page has no slides.\n */\n function startPresentation(slideId?: string): boolean {\n const order = getSlides()\n if (order.length === 0) return false\n const ids = new Set(order.map((slide) => slide.id))\n const [selectedId] = ctx.state.selectedIds\n const holding = selectedId ? ctx.graph.closest(selectedId, (node) => ids.has(node.id)) : null\n const start = (slideId && ids.has(slideId) ? slideId : null) ?? holding?.id ?? order[0].id\n const current = presented()\n const view: PresentView = {\n id: 'present',\n revision: current?.revision ?? 0,\n slideId: start,\n scale: current?.scale ?? 'fit',\n returnTo: current?.returnTo ?? currentPlace(ctx)\n }\n ctx.state.hoveredNodeId = null\n setCanvasView(view)\n show(view)\n return true\n }\n\n /** Leaves the presentation for editing, back where the canvas looked before it. */\n function stopPresentation(): void {\n if (presented()) setCanvasView({ id: 'edit' })\n }\n\n function togglePresentation(): void {\n if (presented()) stopPresentation()\n else startPresentation()\n }\n\n /** Shows another slide of the presentation; false when there is none to show. */\n function presentSlide(slideId: string): boolean {\n const view = presented()\n if (!view || !getSlides().some((slide) => slide.id === slideId)) return false\n const next: PresentView = { ...view, slideId }\n setCanvasView(next)\n show(next)\n return true\n }\n\n /**\n * Steps to the next or previous slide; false at either end, where the presentation stays. A\n * slide removed while it was shown ends the presentation.\n */\n function presentAdjacentSlide(step: 1 | -1): boolean {\n const view = presented()\n if (!view) return false\n const order = getSlides()\n const index = order.findIndex((slide) => slide.id === view.slideId)\n if (index === -1) {\n stopPresentation()\n return false\n }\n const target = order.at(index + step)\n return index + step >= 0 && target ? presentSlide(target.id) : false\n }\n\n function presentNextSlide(): boolean {\n return presentAdjacentSlide(1)\n }\n\n function presentPreviousSlide(): boolean {\n return presentAdjacentSlide(-1)\n }\n\n /** Shows the slide fitted to the screen or at 100%. */\n function setPresentationScale(scale: PresentationScale): void {\n const view = presented()\n if (!view || view.scale === scale) return\n const next: PresentView = { ...view, scale }\n setCanvasView(next)\n show(next)\n }\n\n /** Puts the slide back in place, as after the screen changed size. */\n function fitPresentation(): void {\n const view = presented()\n if (!view) return\n show(view, view.scale === 'actual' ? currentCenter(ctx) : undefined)\n }\n\n /**\n * Scrolls a slide shown at 100% by screen pixels, within the slide; false when it is already\n * at that edge or fits the screen, so a front end can step to the next slide instead.\n */\n function scrollPresentation(dx: number, dy: number): boolean {\n const view = presented()\n if (view?.scale !== 'actual') return false\n const bounds = slideBounds(view.slideId)\n if (!bounds) return false\n const from = currentCenter(ctx)\n const target = presentationViewport(bounds, ctx.getViewportSize(), 'actual', {\n x: from.x + dx / from.zoom,\n y: from.y + dy / from.zoom\n })\n if (Math.abs(target.x - from.x) < 0.5 && Math.abs(target.y - from.y) < 0.5) return false\n viewport.centerOn(target.x, target.y, target.zoom)\n return true\n }\n\n // Another document has other slides, so its arrival ends the presentation; the canvas stays\n // where the new document puts it rather than returning to a place in the old one.\n ctx.onEditorEvent('graph:replaced', () => {\n if (!presented()) return\n ctx.state.canvasView = { id: 'edit' }\n ctx.requestRepaint()\n })\n\n return {\n getSlides,\n getPresentation,\n startPresentation,\n stopPresentation,\n togglePresentation,\n presentSlide,\n presentNextSlide,\n presentPreviousSlide,\n setPresentationScale,\n fitPresentation,\n scrollPresentation\n }\n}\n"],"mappings":";;;;;;;;AA+BA,SAAS,UAAU,OAAe,QAAgB,QAAgB,MAAc,QAAgB;CAC9F,MAAM,UAAU,SAAS;CACzB,IAAI,UAAU,SAAS,OAAO,QAAQ,SAAS;CAC/C,OAAO,KAAK,IAAI,KAAK,IAAI,QAAQ,QAAQ,UAAU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AAM;EACX,KAAK,MAAM,KAAK,UAAU,WAAW,cAAc,GAAG,IAAI,KAAA,CAAS;CACrE;;;;;CAMA,SAAS,mBAAmB,IAAY,IAAqB;EAC3D,MAAM,OAAO,UAAU;EACvB,IAAI,MAAM,UAAU,UAAU,OAAO;EACrC,MAAM,SAAS,YAAY,KAAK,OAAO;EACvC,IAAI,CAAC,QAAQ,OAAO;EACpB,MAAM,OAAO,cAAc,GAAG;EAC9B,MAAM,SAAS,qBAAqB,QAAQ,IAAI,gBAAgB,GAAG,UAAU;GAC3E,GAAG,KAAK,IAAI,KAAK,KAAK;GACtB,GAAG,KAAK,IAAI,KAAK,KAAK;EACxB,CAAC;EACD,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,CAAC,IAAI,MAAO,KAAK,IAAI,OAAO,IAAI,KAAK,CAAC,IAAI,IAAK,OAAO;EACnF,SAAS,SAAS,OAAO,GAAG,OAAO,GAAG,OAAO,IAAI;EACjD,OAAO;CACT;CAIA,IAAI,cAAc,wBAAwB;EACxC,IAAI,CAAC,UAAU,GAAG;EAClB,IAAI,MAAM,aAAa,EAAE,IAAI,OAAO;EACpC,IAAI,eAAe;CACrB,CAAC;CAED,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -37,6 +37,15 @@ interface PresentView {
|
|
|
37
37
|
scale: PresentationScale;
|
|
38
38
|
returnTo: ViewportPlace;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* A preview: the design running, its controls responding to the pointer. It keeps the pan and
|
|
42
|
+
* zoom the canvas had before it fitted its frame, so leaving it returns there.
|
|
43
|
+
*/
|
|
44
|
+
interface PlayView {
|
|
45
|
+
id: 'play';
|
|
46
|
+
revision: number;
|
|
47
|
+
returnTo: ViewportPlace;
|
|
48
|
+
}
|
|
40
49
|
/**
|
|
41
50
|
* Shader Mode: one shader paint of a layer shown large on its own, to play, scrub, and tune. The
|
|
42
51
|
* paint is named by its image, which stays with the shader however the layer's paints move.
|
|
@@ -53,10 +62,7 @@ interface ShaderView {
|
|
|
53
62
|
*/
|
|
54
63
|
type CanvasView = {
|
|
55
64
|
id: 'edit';
|
|
56
|
-
} |
|
|
57
|
-
id: 'play';
|
|
58
|
-
revision: number;
|
|
59
|
-
} | PresentView | ShaderView;
|
|
65
|
+
} | PlayView | PresentView | ShaderView;
|
|
60
66
|
/**
|
|
61
67
|
* How the editor behaves for a canvas, resolved from what the document is for and the view it
|
|
62
68
|
* shows. Front ends read these values
|
|
@@ -99,5 +105,5 @@ interface EditorProfile {
|
|
|
99
105
|
/** The state a profile resolves from: the document's kind, the pane's view, and the host's limits. */
|
|
100
106
|
type EditorProfileInputs = Pick<EditorState, 'documentKind' | 'canvasView' | 'hostRestrictions'>;
|
|
101
107
|
//#endregion
|
|
102
|
-
export { CanvasView, EditorProfile, EditorProfileInputs, EditorRestrictions, PresentView, PresentationScale, ShaderView, ViewportCenter, ViewportPlace };
|
|
108
|
+
export { CanvasView, EditorProfile, EditorProfileInputs, EditorRestrictions, PlayView, PresentView, PresentationScale, ShaderView, ViewportCenter, ViewportPlace };
|
|
103
109
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/editor/views/types.ts"],"mappings":";;;;;;;;UASiB;EACf;;;;;EAKA;;;;;;KAOU;;KAGA,iBAAiB;EAAW;;;KAG5B,gBAAgB;;;;;;UAOX;EACf;EACA;EACA;EACA,OAAO;EACP,UAAU;;;;;;UAOK;EACf;EACA;EACA;;;;;;;KAQU;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/editor/views/types.ts"],"mappings":";;;;;;;;UASiB;EACf;;;;;EAKA;;;;;;KAOU;;KAGA,iBAAiB;EAAW;;;KAG5B,gBAAgB;;;;;;UAOX;EACf;EACA;EACA;EACA,OAAO;EACP,UAAU;;;;;;UAOK;EACf;EACA;EACA,UAAU;;;;;;UAOK;EACf;EACA;EACA;;;;;;;KAQU;EAAe;IAAe,WAAW,cAAc;;;;;;;UAQlD;;EAEf;;EAEA;;EAEA;;;;;EAKA;IAAQ;;;EAER;;EAEA,SAAS;;;;;EAKT;;EAEA,OAAO,YAAY;;EAEnB,UAAU,SAAS,QAAQ,eAAe;;;;;EAK1C;;;KAIU,sBAAsB,KAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessor-utils.d.ts","names":[],"sources":["../../src/figma-api/accessor-utils.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"accessor-utils.d.ts","names":[],"sources":["../../src/figma-api/accessor-utils.ts"],"mappings":";;;UAeiB;EACf;EACA;EACA;;KAGU,YAAY;iBAER,OAAO,QAAQ,WAAW,WAAW;iBAIrC,MAAM,QAAQ,WAAW,WAAW,qBAAqB;iBAIzD,IAAI,QAAQ,WAAW,WAAW,qBAAqB;;;;;iBAavD,YAAY,QAAQ,WAAW,WAAW,qBAAqB;iBAU/D,oBAAoB,QAAQ,WAAW,WAAW;;;;;;;;iBAWlD,yBACd,OAAO,YACP,MAAM,WACN,uBACA;;iBAgCc,gBACd,OAAO,YACP,qCACA,SAAS;;iBASK,eAAe,QAAQ,WAAW,WAAW,qBAAqB;iBAIlE,WACd,QAAQ,WACR,WAAW,oBACX,SAAS,QAAQ;;;;;;iBAeH,SACd,GAAG,YACH,YACA,SAAS,QAAQ,YACjB,YAAY"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertNodeEditable } from "../editor/capabilities.js";
|
|
2
2
|
import { textAutoResizeChanges } from "../layout/text-auto-resize.js";
|
|
3
|
+
import { flushPendingComponentSync } from "./pending-sync.js";
|
|
3
4
|
import { claimSlotContent, slotScope } from "@pairdraw/scene-graph/slots";
|
|
4
5
|
import { styleDetachmentChanges } from "@pairdraw/scene-graph/shared-styles";
|
|
5
6
|
import { FITTED_CONTAINER_TYPES } from "@pairdraw/scene-graph/node-defaults";
|
|
@@ -16,7 +17,9 @@ function graph(target, internals) {
|
|
|
16
17
|
}
|
|
17
18
|
function raw(target, internals) {
|
|
18
19
|
const id = nodeId(target, internals);
|
|
19
|
-
const
|
|
20
|
+
const scene = graph(target, internals);
|
|
21
|
+
flushPendingComponentSync(scene, id);
|
|
22
|
+
const node = scene.getNode(id);
|
|
20
23
|
if (!node) throw new Error(`Node ${id} has been removed`);
|
|
21
24
|
return node;
|
|
22
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessor-utils.js","names":[],"sources":["../../src/figma-api/accessor-utils.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { connectorSublayers } from '@pairdraw/scene-graph/connectors'\nimport { fitEnclosingGroups, type GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'\nimport { recordInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport { FITTED_CONTAINER_TYPES } from '@pairdraw/scene-graph/node-defaults'\nimport { styleDetachmentChanges } from '@pairdraw/scene-graph/shared-styles'\nimport { claimSlotContent, slotScope } from '@pairdraw/scene-graph/slots'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport type { NodeProxyHost } from '#core/figma-api/proxy'\nimport { textAutoResizeChanges } from '#core/layout/text-auto-resize'\n\nexport interface NodeProxyInternals {\n id: symbol\n graph: symbol\n api: symbol\n}\n\nexport type ProxyThis = Record<symbol, unknown>\n\nexport function nodeId(target: ProxyThis, internals: NodeProxyInternals): string {\n return target[internals.id] as string\n}\n\nexport function graph(target: ProxyThis, internals: NodeProxyInternals): SceneGraph {\n return target[internals.graph] as SceneGraph\n}\n\nexport function raw(target: ProxyThis, internals: NodeProxyInternals): SceneNode {\n const id = nodeId(target, internals)\n const
|
|
1
|
+
{"version":3,"file":"accessor-utils.js","names":[],"sources":["../../src/figma-api/accessor-utils.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { connectorSublayers } from '@pairdraw/scene-graph/connectors'\nimport { fitEnclosingGroups, type GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'\nimport { recordInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport { FITTED_CONTAINER_TYPES } from '@pairdraw/scene-graph/node-defaults'\nimport { styleDetachmentChanges } from '@pairdraw/scene-graph/shared-styles'\nimport { claimSlotContent, slotScope } from '@pairdraw/scene-graph/slots'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport { flushPendingComponentSync } from '#core/figma-api/pending-sync'\nimport type { NodeProxyHost } from '#core/figma-api/proxy'\nimport { textAutoResizeChanges } from '#core/layout/text-auto-resize'\n\nexport interface NodeProxyInternals {\n id: symbol\n graph: symbol\n api: symbol\n}\n\nexport type ProxyThis = Record<symbol, unknown>\n\nexport function nodeId(target: ProxyThis, internals: NodeProxyInternals): string {\n return target[internals.id] as string\n}\n\nexport function graph(target: ProxyThis, internals: NodeProxyInternals): SceneGraph {\n return target[internals.graph] as SceneGraph\n}\n\nexport function raw(target: ProxyThis, internals: NodeProxyInternals): SceneNode {\n const id = nodeId(target, internals)\n const scene = graph(target, internals)\n flushPendingComponentSync(scene, id)\n const node = scene.getNode(id)\n if (!node) throw new Error(`Node ${id} has been removed`)\n return node\n}\n\n/**\n * The layer a node's strokes live on, as a proxy target: a connector keeps its stroke on its\n * line, which Figma presents as the connector's own.\n */\nexport function strokeOwner(target: ProxyThis, internals: NodeProxyInternals): ProxyThis {\n const node = raw(target, internals)\n if (node.type !== 'CONNECTOR') return target\n const line = connectorSublayers(graph(target, internals), node)?.line\n if (!line) return target\n const owner: ProxyThis = Object.create(target)\n owner[internals.id] = line.id\n return owner\n}\n\nexport function assertProxyEditable(target: ProxyThis, internals: NodeProxyInternals): void {\n assertNodeEditable(graph(target, internals), nodeId(target, internals))\n}\n\n/**\n * Readies an edit to a field a layer inside an instance always takes from its component. Figma\n * refuses it there, naming the setter and the property it would have overridden (Figma desktop\n * 126); an async method's rejection names no setter, so it passes none. Slot content is the\n * instance's own and keeps the edit: a slot still showing the component's default content is\n * claimed first, as Figma does on the first edit, so a later sync leaves it alone.\n */\nexport function prepareFollowedFieldEdit(\n scene: SceneGraph,\n node: SceneNode,\n setter: string | null,\n property:\n | 'relative-transform'\n | 'vertical-constraint'\n | 'is-mask'\n | 'mask-type'\n | 'vector-data'\n | 'handle-mirroring'\n | 'stack-counter-align-content'\n | 'shape-type'\n): void {\n if (!node.parentId) return\n const scope = slotScope(scene, node.parentId)\n if (scope.kind === 'locked') {\n const message = `This property cannot be overridden in an instance: ${property}`\n throw new Error(setter ? `in set_${setter}: ${message}` : message)\n }\n if (scope.kind === 'slot') claimSlotContent(scene, scope)\n}\n\n/** Fields whose change can move a node's bounds or drop it from its group's, so groups refit. */\nconst GEOMETRY_FIELDS: ReadonlySet<string> = new Set([\n 'visible',\n 'x',\n 'y',\n 'width',\n 'height',\n 'rotation',\n 'flipX',\n 'flipY'\n])\n\n/** Refits the groups around a node's parent, as Figma does after a script changes it. */\nexport function fitGroupsAround(\n graph: SceneGraph,\n parentId: string | null | undefined,\n options: GroupFitOptions\n): void {\n const parent = parentId ? graph.getNode(parentId) : undefined\n if (parent && FITTED_CONTAINER_TYPES.has(parent.type)) {\n fitEnclosingGroups(graph, [parent.id], options)\n }\n}\n\n/** Refit options of the API a proxy belongs to. */\nexport function hostFitOptions(target: ProxyThis, internals: NodeProxyInternals): GroupFitOptions {\n return (target[internals.api] as NodeProxyHost).groupFitOptions\n}\n\nexport function updateNode(\n target: ProxyThis,\n internals: NodeProxyInternals,\n changes: Partial<SceneNode>\n): void {\n editNode(\n graph(target, internals),\n nodeId(target, internals),\n changes,\n hostFitOptions(target, internals)\n )\n}\n\n/**\n * Applies `changes` to a layer as node proxy setters do: refused on a read-only library\n * definition, leaving the styles whose fields it changes, measuring auto-sizing text, recording\n * an override inside an instance, and refitting the groups a moved layer sits in.\n */\nexport function editNode(\n g: SceneGraph,\n id: string,\n changes: Partial<SceneNode>,\n fitOptions: GroupFitOptions\n): void {\n assertNodeEditable(g, id)\n const applied = Object.fromEntries(\n Object.keys(changes)\n .filter((key) => Reflect.get(changes, key) !== undefined)\n .map((key) => [key, Reflect.get(changes, key)])\n ) as Partial<SceneNode>\n if (Object.keys(applied).length === 0) return\n const before = g.getNode(id)\n // Auto-sizing text measures its new content, as the editor's updates do.\n Object.assign(applied, textAutoResizeChanges(before, applied))\n // An edit to a style's fields leaves that style, as the editor's updates do.\n const edit = before ? styleDetachmentChanges(before, applied) : applied\n // Figma overrides only what an edit changes, so setting a layer's own value claims nothing.\n const changed = Object.keys(edit).filter(\n (key) => !before || !isEqual(Reflect.get(edit, key), Reflect.get(before, key))\n )\n g.updateNode(id, edit)\n recordInstanceOverride(g, id, changed)\n if (Object.keys(edit).some((key) => GEOMETRY_FIELDS.has(key))) {\n fitGroupsAround(g, g.getNode(id)?.parentId, fitOptions)\n }\n}\n"],"mappings":";;;;;;;;;;;AAuBA,SAAgB,OAAO,QAAmB,WAAuC;CAC/E,OAAO,OAAO,UAAU;AAC1B;AAEA,SAAgB,MAAM,QAAmB,WAA2C;CAClF,OAAO,OAAO,UAAU;AAC1B;AAEA,SAAgB,IAAI,QAAmB,WAA0C;CAC/E,MAAM,KAAK,OAAO,QAAQ,SAAS;CACnC,MAAM,QAAQ,MAAM,QAAQ,SAAS;CACrC,0BAA0B,OAAO,EAAE;CACnC,MAAM,OAAO,MAAM,QAAQ,EAAE;CAC7B,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,QAAQ,GAAG,kBAAkB;CACxD,OAAO;AACT;;;;;AAMA,SAAgB,YAAY,QAAmB,WAA0C;CACvF,MAAM,OAAO,IAAI,QAAQ,SAAS;CAClC,IAAI,KAAK,SAAS,aAAa,OAAO;CACtC,MAAM,OAAO,mBAAmB,MAAM,QAAQ,SAAS,GAAG,IAAI,CAAC,EAAE;CACjE,IAAI,CAAC,MAAM,OAAO;CA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CAAC,CAClD;CACA,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,WAAW,GAAG;CACvC,MAAM,SAAS,EAAE,QAAQ,EAAE;CAE3B,OAAO,OAAO,SAAS,sBAAsB,QAAQ,OAAO,CAAC;CAE7D,MAAM,OAAO,SAAS,uBAAuB,QAAQ,OAAO,IAAI;CAEhE,MAAM,UAAU,OAAO,KAAK,IAAI,CAAC,CAAC,QAC/B,QAAQ,CAAC,UAAU,CAAC,QAAQ,QAAQ,IAAI,MAAM,GAAG,GAAG,QAAQ,IAAI,QAAQ,GAAG,CAAC,CAC/E;CACA,EAAE,WAAW,IAAI,IAAI;CACrB,uBAAuB,GAAG,IAAI,OAAO;CACrC,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC,MAAM,QAAQ,gBAAgB,IAAI,GAAG,CAAC,GAC1D,gBAAgB,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,UAAU,UAAU;AAE1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic.d.ts","names":[],"sources":["../../../src/figma-api/accessors/basic.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"basic.d.ts","names":[],"sources":["../../../src/figma-api/accessors/basic.ts"],"mappings":";;;iBAmGgB,+BACd,mBACA,WAAW"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { figmaRotation } from "../../geometry/figma.js";
|
|
2
2
|
import { computeAccurateBounds } from "../../vector/curve-math.js";
|
|
3
3
|
import { assertNodeEditable } from "../../editor/capabilities.js";
|
|
4
|
+
import { restoredHuggedSize } from "../../layout/apply.js";
|
|
4
5
|
import { invalid, numberProblem } from "./text/messages.js";
|
|
5
6
|
import { fitGroupsAround, graph, hostFitOptions, nodeId, prepareFollowedFieldEdit, raw, updateNode } from "../accessor-utils.js";
|
|
7
|
+
import { flushPendingLayout, flushPendingLayoutBefore } from "../pending-layout.js";
|
|
8
|
+
import { namedByText } from "../../editor/text/name.js";
|
|
6
9
|
import { syncVariantName } from "../variants.js";
|
|
7
|
-
import {
|
|
10
|
+
import { finiteNumber, finiteTransform } from "../finite.js";
|
|
8
11
|
import { computeAbsoluteRenderBounds } from "../render-bounds.js";
|
|
9
12
|
import { containerTransform, setContainerTransform, withFigmaRotation, withOrigin } from "../transform.js";
|
|
10
13
|
import { slotPropertyId } from "@pairdraw/scene-graph/slots";
|
|
11
14
|
import { getAxisAlignedWorldBounds, getWorldMatrix } from "@pairdraw/scene-graph/coordinate";
|
|
12
15
|
import { FITTED_CONTAINER_TYPES } from "@pairdraw/scene-graph/node-defaults";
|
|
13
|
-
import { computeConstrainedResizeChanges, createResizeSnapshot, scaledGeometryChanges } from "@pairdraw/scene-graph/resize";
|
|
16
|
+
import { computeConstrainedResizeChanges, createResizeSnapshot, scaledGeometryChanges, shapeGeometryChanges } from "@pairdraw/scene-graph/resize";
|
|
17
|
+
import { findInstanceAncestor, recordInstanceOverride } from "@pairdraw/scene-graph/instances";
|
|
14
18
|
import { recapturedAspectRatio } from "@pairdraw/scene-graph/layout";
|
|
15
19
|
import { TRANSFORM_FIELDS } from "@pairdraw/scene-graph/fields";
|
|
16
|
-
import { findInstanceAncestor, recordInstanceOverride } from "@pairdraw/scene-graph/instances";
|
|
17
20
|
import { rescaleNodeTree } from "@pairdraw/scene-graph/scaling";
|
|
18
21
|
//#region src/figma-api/accessors/basic.ts
|
|
19
22
|
const TRANSFORM_FIELDS$1 = new Set(TRANSFORM_FIELDS);
|
|
@@ -52,6 +55,7 @@ function setTransform(target, internals, change) {
|
|
|
52
55
|
assertEditable(target, internals);
|
|
53
56
|
const scene = graph(target, internals);
|
|
54
57
|
const node = raw(target, internals);
|
|
58
|
+
flushPendingLayoutBefore(scene, node);
|
|
55
59
|
setContainerTransform(scene, node, change(containerTransform(node, scene)));
|
|
56
60
|
fitGroupsAround(scene, node.parentId, hostFitOptions(target, internals));
|
|
57
61
|
}
|
|
@@ -69,7 +73,11 @@ function installBasicNodeProxyAccessors(prototype, internals) {
|
|
|
69
73
|
return raw(this, internals).name;
|
|
70
74
|
},
|
|
71
75
|
set(value) {
|
|
72
|
-
|
|
76
|
+
const node = raw(this, internals);
|
|
77
|
+
updateNode(this, internals, {
|
|
78
|
+
name: value,
|
|
79
|
+
...namedByText(node) ? { autoRename: false } : {}
|
|
80
|
+
});
|
|
73
81
|
syncVariantName(graph(this, internals), raw(this, internals));
|
|
74
82
|
}
|
|
75
83
|
},
|
|
@@ -82,8 +90,9 @@ function installBasicNodeProxyAccessors(prototype, internals) {
|
|
|
82
90
|
return containerTransform(raw(this, internals), graph(this, internals))[2];
|
|
83
91
|
},
|
|
84
92
|
set(value) {
|
|
93
|
+
const x = finiteNumber(value, "x");
|
|
85
94
|
prepareFollowedFieldEdit(graph(this, internals), raw(this, internals), "x", "relative-transform");
|
|
86
|
-
setTransform(this, internals, (matrix) => withOrigin(matrix,
|
|
95
|
+
setTransform(this, internals, (matrix) => withOrigin(matrix, x, matrix[5]));
|
|
87
96
|
}
|
|
88
97
|
},
|
|
89
98
|
y: {
|
|
@@ -92,8 +101,9 @@ function installBasicNodeProxyAccessors(prototype, internals) {
|
|
|
92
101
|
return containerTransform(raw(this, internals), graph(this, internals))[5];
|
|
93
102
|
},
|
|
94
103
|
set(value) {
|
|
104
|
+
const y = finiteNumber(value, "y");
|
|
95
105
|
prepareFollowedFieldEdit(graph(this, internals), raw(this, internals), "y", "relative-transform");
|
|
96
|
-
setTransform(this, internals, (matrix) => withOrigin(matrix, matrix[2],
|
|
106
|
+
setTransform(this, internals, (matrix) => withOrigin(matrix, matrix[2], y));
|
|
97
107
|
}
|
|
98
108
|
},
|
|
99
109
|
width: { get() {
|
|
@@ -112,8 +122,9 @@ function installBasicNodeProxyAccessors(prototype, internals) {
|
|
|
112
122
|
return figmaRotation(containerTransform(node, graph(this, internals)));
|
|
113
123
|
},
|
|
114
124
|
set(value) {
|
|
125
|
+
const rotation = finiteNumber(value, "rotation");
|
|
115
126
|
prepareFollowedFieldEdit(graph(this, internals), raw(this, internals), "rotation", "relative-transform");
|
|
116
|
-
setTransform(this, internals, (matrix) => withFigmaRotation(matrix,
|
|
127
|
+
setTransform(this, internals, (matrix) => withFigmaRotation(matrix, rotation));
|
|
117
128
|
}
|
|
118
129
|
},
|
|
119
130
|
relativeTransform: {
|
|
@@ -134,15 +145,15 @@ function installBasicNodeProxyAccessors(prototype, internals) {
|
|
|
134
145
|
return figmaTransform(containerTransform(node, scene));
|
|
135
146
|
},
|
|
136
147
|
set(value) {
|
|
148
|
+
const { first, second } = finiteTransform(value);
|
|
137
149
|
prepareFollowedFieldEdit(graph(this, internals), raw(this, internals), "relativeTransform", "relative-transform");
|
|
138
|
-
const [[a, b, x], [c, d, y]] = value;
|
|
139
150
|
setTransform(this, internals, () => [
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
first[0],
|
|
152
|
+
first[1],
|
|
153
|
+
first[2],
|
|
154
|
+
second[0],
|
|
155
|
+
second[1],
|
|
156
|
+
second[2],
|
|
146
157
|
0,
|
|
147
158
|
0,
|
|
148
159
|
1
|
|
@@ -169,12 +180,18 @@ function installBasicNodeProxyAccessors(prototype, internals) {
|
|
|
169
180
|
resizeWithoutConstraints(width, height) {
|
|
170
181
|
resizeNode(this, internals, width, height, false);
|
|
171
182
|
},
|
|
172
|
-
rescale(
|
|
183
|
+
rescale(value) {
|
|
184
|
+
const scale = finiteNumber(value, "scale", "rescale");
|
|
173
185
|
assertEditable(this, internals);
|
|
174
186
|
const scene = graph(this, internals);
|
|
175
187
|
const node = raw(this, internals);
|
|
188
|
+
flushPendingLayoutBefore(scene, node, { placesChildren: true });
|
|
176
189
|
if (node.parentId && findInstanceAncestor(scene, node.parentId)) throw new Error("This property cannot be overridden in an instance: size");
|
|
177
190
|
rescaleNodeTree(scene, node.id, scale);
|
|
191
|
+
for (const scaled of [node, ...descendants(scene, node)]) {
|
|
192
|
+
const current = scene.getNode(scaled.id);
|
|
193
|
+
if (current) restoredHuggedSize(current);
|
|
194
|
+
}
|
|
178
195
|
}
|
|
179
196
|
});
|
|
180
197
|
}
|
|
@@ -183,12 +200,14 @@ function descendants(scene, node) {
|
|
|
183
200
|
return scene.getChildren(node.id).flatMap((child) => [child, ...descendants(scene, child)]);
|
|
184
201
|
}
|
|
185
202
|
/**
|
|
186
|
-
* A
|
|
187
|
-
* a path to stroke, the saved stroke outline goes and the
|
|
188
|
-
* when the path is set; without one, the outline is all that
|
|
203
|
+
* A layer's geometry for its new size, as Figma's resize does. A vector's path scales to the new
|
|
204
|
+
* size; the stroke keeps its weight: with a path to stroke, the saved stroke outline goes and the
|
|
205
|
+
* stroke draws from the scaled path, as when the path is set; without one, the outline is all that
|
|
206
|
+
* draws the stroke, so it scales. Any other layer draws from its live box, so the saved outlines
|
|
207
|
+
* a file gave it follow the new box the same way.
|
|
189
208
|
*/
|
|
190
|
-
function
|
|
191
|
-
if (node.type !== "VECTOR") return
|
|
209
|
+
function resizedNodeGeometry(node, width, height) {
|
|
210
|
+
if (node.type !== "VECTOR") return shapeGeometryChanges(node, width, height);
|
|
192
211
|
const bounds = node.vectorNetwork ? computeAccurateBounds(node.vectorNetwork) : null;
|
|
193
212
|
const fromWidth = node.width > 0 ? node.width : bounds?.width ?? 0;
|
|
194
213
|
const fromHeight = node.height > 0 ? node.height : bounds?.height ?? 0;
|
|
@@ -247,6 +266,7 @@ function resizeNode(target, internals, requestedWidth, requestedHeight, constrai
|
|
|
247
266
|
assertEditable(target, internals);
|
|
248
267
|
const scene = graph(target, internals);
|
|
249
268
|
const node = raw(target, internals);
|
|
269
|
+
flushPendingLayoutBefore(scene, node, { placesChildren: constrained });
|
|
250
270
|
const { width, height } = resizedSize(node, requestedWidth, requestedHeight, constrained);
|
|
251
271
|
if (node.parentId && findInstanceAncestor(scene, node.parentId)) return;
|
|
252
272
|
const before = containerTransform(node, scene);
|
|
@@ -255,7 +275,7 @@ function resizeNode(target, internals, requestedWidth, requestedHeight, constrai
|
|
|
255
275
|
height: node.height
|
|
256
276
|
};
|
|
257
277
|
const placed = constrained || node.type === "INSTANCE" ? new Map(descendants(scene, node).map((child) => [child.id, createResizeSnapshot(child)])) : /* @__PURE__ */ new Map();
|
|
258
|
-
const geometry =
|
|
278
|
+
const geometry = resizedNodeGeometry(node, width, height);
|
|
259
279
|
const recaptured = recapturedAspectRatio(node, width, height);
|
|
260
280
|
const changed = {
|
|
261
281
|
width: width !== size.width,
|