@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":"overrides.js","names":["isEqual"],"sources":["../../src/figma-api/overrides.ts"],"sourcesContent":["import { omit, uniq } from 'es-toolkit'\nimport { isEqual } from 'es-toolkit/predicate'\n\nimport type {\n ComponentPropertyReferenceField,\n SceneGraph,\n SceneNode,\n Stroke\n} from '@pairdraw/scene-graph'\nimport { findInstanceAncestor, isReplacedLayer } from '@pairdraw/scene-graph/instances'\nimport {\n overriddenVariableModeCollection,\n type InstanceOverrideState\n} from '@pairdraw/scene-graph/instances/overrides'\n\nimport type { NodeProxyInternals, ProxyThis } from './accessor-utils'\nimport { assertProxyEditable, graph, raw } from './accessor-utils'\nimport { flushPendingLayout } from './pending-layout'\n\n/** One layer of an instance and the fields an edit changed on it, as Figma's `overrides`. */\nexport interface FigmaInstanceOverride {\n id: string\n overriddenFields: string[]\n}\n\n/**\n * The fields Figma desktop 126 lists for an override of each of ours. Unlisted fields are ones\n * Figma does not report: a layer's own size, size limits, clipping, the layout mode, a swap.\n * Figma spells the top stroke weight `stokeTopWeight`.\n */\nconst FIGMA_OVERRIDE_FIELDS: Readonly<Partial<Record<string, readonly string[]>>> = {\n // Figma keeps a size as one field, so a changed width or height lists both.\n width: ['height', 'width'],\n height: ['height', 'width'],\n name: ['name'],\n visible: ['visible'],\n locked: ['locked'],\n text: ['characters', 'styledTextSegments'],\n styleRuns: ['styledTextSegments'],\n textParagraphs: ['styledTextSegments'],\n listSpacing: ['styledTextSegments'],\n fontSize: ['fontSize'],\n fontFamily: ['fontName'],\n fontWeight: ['fontName'],\n italic: ['fontName'],\n fontStyle: ['fontName'],\n letterSpacing: ['letterSpacing'],\n lineHeight: ['lineHeight'],\n textCase: ['textCase'],\n textDecoration: ['textDecoration'],\n textDecorationStyle: ['textDecorationStyle'],\n textDecorationThickness: ['textDecorationThickness'],\n textUnderlineOffset: ['textDecorationOffset'],\n textDecorationFills: ['textDecorationColor'],\n textDecorationSkipInk: ['textDecorationSkipInk'],\n textAlignHorizontal: ['textAlignHorizontal'],\n textAlignVertical: ['textAlignVertical'],\n textAutoResize: ['textAutoResize'],\n textTruncation: ['textTruncation'],\n maxLines: ['maxLines'],\n leadingTrim: ['leadingTrim'],\n paragraphSpacing: ['paragraphSpacing'],\n paragraphIndent: ['paragraphIndent'],\n hangingList: ['hangingList'],\n fills: ['fills'],\n strokes: ['strokes'],\n effects: ['effects'],\n opacity: ['opacity'],\n blendMode: ['blendMode'],\n cornerRadius: [\n 'bottomLeftRadius',\n 'bottomRightRadius',\n 'cornerRadius',\n 'topLeftRadius',\n 'topRightRadius'\n ],\n topLeftRadius: ['topLeftRadius'],\n topRightRadius: ['topRightRadius'],\n bottomRightRadius: ['bottomRightRadius'],\n bottomLeftRadius: ['bottomLeftRadius'],\n cornerSmoothing: ['cornerSmoothing'],\n strokeWeight: [\n 'strokeBottomWeight',\n 'strokeLeftWeight',\n 'strokeRightWeight',\n 'stokeTopWeight',\n 'strokeWeight'\n ],\n borderTopWeight: ['stokeTopWeight'],\n borderRightWeight: ['strokeRightWeight'],\n borderBottomWeight: ['strokeBottomWeight'],\n borderLeftWeight: ['strokeLeftWeight'],\n strokeAlign: ['strokeAlign'],\n strokeCap: ['strokeCap'],\n strokeJoin: ['strokeJoin'],\n strokeMiterLimit: ['strokeMiterLimit'],\n dashPattern: ['dashPattern'],\n layoutWrap: ['layoutWrap'],\n primaryAxisAlign: ['primaryAxisAlignItems'],\n counterAxisAlign: ['counterAxisAlignItems'],\n primaryAxisSizing: ['primaryAxisSizingMode'],\n counterAxisSizing: ['counterAxisSizingMode'],\n itemSpacing: ['itemSpacing'],\n counterAxisSpacing: ['counterAxisSpacing'],\n paddingTop: ['paddingTop'],\n paddingRight: ['paddingRight'],\n paddingBottom: ['paddingBottom'],\n paddingLeft: ['paddingLeft'],\n gridColumnGap: ['gridColumnGap'],\n gridRowGap: ['gridRowGap'],\n itemReverseZIndex: ['itemReverseZIndex'],\n layoutGrids: ['layoutGrids'],\n layoutGrow: ['layoutGrow'],\n layoutAlignSelf: ['layoutAlign'],\n boundVariables: ['boundVariables'],\n variableModes: ['explicitVariableModes'],\n fillStyleId: ['fillStyleId'],\n strokeStyleId: ['strokeStyleId'],\n textStyleId: ['textStyleId'],\n effectStyleId: ['effectStyleId'],\n gridStyleId: ['gridStyleId']\n}\n\n/** Fields a component property sets on a layer, which Figma reports as the property's, not an override. */\nconst PROPERTY_FIELDS: Record<ComponentPropertyReferenceField, readonly string[]> = {\n TEXT: ['text', 'styleRuns', 'textParagraphs'],\n VISIBLE: ['visible'],\n INSTANCE_SWAP: ['componentId', 'name'],\n SLOT_CONTENT: []\n}\n\nfunction propertyFields(node: SceneNode): Set<string> {\n return new Set(node.componentPropertyReferences.flatMap(({ field }) => PROPERTY_FIELDS[field]))\n}\n\n/** Figma sorts the names as spelled right, so its misspelled top weight sorts as `strokeTop…`. */\nconst sortKey = (name: string) => (name === 'stokeTopWeight' ? 'strokeTopWeight' : name)\n\nfunction figmaFields(fields: Iterable<string>, skipped: Set<string>): string[] {\n const names = new Set<string>()\n for (const field of fields) {\n if (skipped.has(field)) continue\n for (const name of FIGMA_OVERRIDE_FIELDS[field] ?? []) names.add(name)\n }\n return [...names].sort((a, b) => sortKey(a).localeCompare(sortKey(b)))\n}\n\n/**\n * The layer of the component a node copies, which its overrides are measured against. A nested\n * instance links to the component's instance it copies, until a swap points it at a component;\n * the enclosing instance then keeps the layer it copied.\n */\nfunction componentLayer(graph: SceneGraph, node: SceneNode, owner: SceneNode | undefined) {\n const linked = node.componentId ? graph.getNode(node.componentId) : undefined\n if (node.type !== 'INSTANCE' || linked?.type === 'INSTANCE') return linked\n const source = owner?.instanceOverrides.descendants.get(node.id)?.get('sourceComponentId')\n return typeof source === 'string' ? graph.getNode(source) : undefined\n}\n\n/** Figma keeps stroke weight and alignment on the layer, so a paint differs by its colour alone. */\nconst paints = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => omit(stroke, ['weight', 'align']))\n\nfunction differs(node: SceneNode, source: SceneNode | undefined, field: string): boolean {\n if (!source) return true\n if (field === 'strokes') return !isEqual(paints(node.strokes), paints(source.strokes))\n return !isEqual(Reflect.get(node, field), Reflect.get(source, field))\n}\n\n/**\n * The fields recorded as edited on a node that still differ from its component layer: an edit\n * kept in the nearest instance above it, and one kept on the node itself if it is an instance.\n * Figma lists a field as overridden only while it differs.\n */\nfunction editedFields(graph: SceneGraph, node: SceneNode, root: SceneNode): string[] {\n const owner =\n node.id === root.id || !node.parentId ? undefined : findInstanceAncestor(graph, node.parentId)\n const source =\n node.id === root.id ? graph.getNode(root.componentId ?? '') : componentLayer(graph, node, owner)\n const fields = [\n ...(node.type === 'INSTANCE' ? node.instanceOverrides.self.keys() : []),\n ...(owner?.instanceOverrides.descendants.get(node.id)?.keys() ?? [])\n ].map((field) =>\n // A mode set for one collection is an override of the layer's modes, as Figma lists it.\n overriddenVariableModeCollection(field) === null ? field : 'variableModes'\n )\n // The instance's own size counts once it differs, as a layer that grows it makes it.\n if (node.id === root.id) fields.push('width', 'height')\n return uniq(fields).filter((field) => differs(node, source, field))\n}\n\n/**\n * Figma's `overrides`: each layer of the instance, itself first and then in layer order, with\n * the fields edited on it, including those inside nested instances. Figma lists no layer's own\n * size but the instance's.\n */\nexport function instanceOverrides(graph: SceneGraph, root: SceneNode): FigmaInstanceOverride[] {\n const result: FigmaInstanceOverride[] = []\n const visit = (node: SceneNode) => {\n const skipped = propertyFields(node)\n if (node.id !== root.id) skipped.add('width').add('height')\n const overriddenFields = figmaFields(editedFields(graph, node, root), skipped)\n if (overriddenFields.length > 0) result.push({ id: node.id, overriddenFields })\n for (const child of graph.getChildren(node.id)) visit(child)\n }\n visit(root)\n return result\n}\n\n/** Clears an override state but what component properties set, which Figma keeps on reset. */\nfunction withoutEdits(graph: SceneGraph, state: InstanceOverrideState): InstanceOverrideState {\n const keep = (nodeId: string, fields: Map<string, unknown>) => {\n const node = graph.getNode(nodeId)\n const driven = node ? propertyFields(node) : new Set<string>()\n return new Map([...fields].filter(([field]) => driven.has(field)))\n }\n const descendants = new Map(\n [...state.descendants]\n .map(([nodeId, fields]) => [nodeId, keep(nodeId, fields)] as const)\n .filter(([, fields]) => fields.size > 0)\n )\n return { self: new Map(), descendants }\n}\n\n/**\n * Figma's `resetOverrides`: the instance and every instance inside it go back to their\n * components, keeping the values their component properties set.\n */\nfunction resetInstanceOverrides(graph: SceneGraph, root: SceneNode): void {\n // A layer put in place of a component's layer goes, and the sync brings that layer back.\n const replaced: string[] = []\n const collect = (node: SceneNode) => {\n for (const child of graph.getChildren(node.id)) {\n if (isReplacedLayer(graph, child)) replaced.push(child.id)\n else collect(child)\n }\n }\n collect(root)\n for (const id of replaced) graph.deleteNode(id)\n const visit = (node: SceneNode) => {\n if (node.type === 'INSTANCE')\n graph.updateNode(node.id, { instanceOverrides: withoutEdits(graph, node.instanceOverrides) })\n for (const child of graph.getChildren(node.id)) visit(child)\n }\n visit(root)\n // The outermost instance passes its component's content down to the ones inside it.\n let outermost = root\n for (\n let parent = root.parentId ? findInstanceAncestor(graph, root.parentId) : undefined;\n parent;\n ) {\n outermost = parent\n parent = parent.parentId ? findInstanceAncestor(graph, parent.parentId) : undefined\n }\n graph.syncInstance(outermost.id)\n}\n\nexport function installInstanceOverrideAccessors(\n prototype: object,\n internals: NodeProxyInternals\n): void {\n Object.defineProperties(prototype, {\n overrides: {\n get(this: ProxyThis): FigmaInstanceOverride[] | undefined {\n const node = raw(this, internals)\n if (node.type !== 'INSTANCE') return undefined\n // Figma lists the size its layout gives the instance.\n flushPendingLayout(graph(this, internals))\n return instanceOverrides(graph(this, internals), node)\n }\n },\n resetOverrides: {\n value(this: ProxyThis) {\n const node = raw(this, internals)\n if (node.type !== 'INSTANCE')\n throw new TypeError('resetOverrides() can only be called on instances')\n assertProxyEditable(this, internals)\n resetInstanceOverrides(graph(this, internals), node)\n }\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,MAAM,wBAA8E;CAElF,OAAO,CAAC,UAAU,OAAO;CACzB,QAAQ,CAAC,UAAU,OAAO;CAC1B,MAAM,CAAC,MAAM;CACb,SAAS,CAAC,SAAS;CACnB,QAAQ,CAAC,QAAQ;CACjB,MAAM,CAAC,cAAc,oBAAoB;CACzC,WAAW,CAAC,oBAAoB;CAChC,gBAAgB,CAAC,oBAAoB;CACrC,aAAa,CAAC,oBAAoB;CAClC,UAAU,CAAC,UAAU;CACrB,YAAY,CAAC,UAAU;CACvB,YAAY,CAAC,UAAU;CACvB,QAAQ,CAAC,UAAU;CACnB,WAAW,CAAC,UAAU;CACtB,eAAe,CAAC,eAAe;CAC/B,YAAY,CAAC,YAAY;CACzB,UAAU,CAAC,UAAU;CACrB,gBAAgB,CAAC,gBAAgB;CACjC,qBAAqB,CAAC,qBAAqB;CAC3C,yBAAyB,CAAC,yBAAyB;CACnD,qBAAqB,CAAC,sBAAsB;CAC5C,qBAAqB,CAAC,qBAAqB;CAC3C,uBAAuB,CAAC,uBAAuB;CAC/C,qBAAqB,CAAC,qBAAqB;CAC3C,mBAAmB,CAAC,mBAAmB;CACvC,gBAAgB,CAAC,gBAAgB;CACjC,gBAAgB,CAAC,gBAAgB;CACjC,UAAU,CAAC,UAAU;CACrB,aAAa,CAAC,aAAa;CAC3B,kBAAkB,CAAC,kBAAkB;CACrC,iBAAiB,CAAC,iBAAiB;C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,WACM;CACN,OAAO,iBAAiB,WAAW;EACjC,WAAW,EACT,MAA0D;GACxD,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,IAAI,KAAK,SAAS,YAAY,OAAO,KAAA;GAErC,mBAAmB,MAAM,MAAM,SAAS,CAAC;GACzC,OAAO,kBAAkB,MAAM,MAAM,SAAS,GAAG,IAAI;EACvD,EACF;EACA,gBAAgB,EACd,QAAuB;GACrB,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,IAAI,KAAK,SAAS,YAChB,MAAM,IAAI,UAAU,kDAAkD;GACxE,oBAAoB,MAAM,SAAS;GACnC,uBAAuB,MAAM,MAAM,SAAS,GAAG,IAAI;EACrD,EACF;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"overrides.js","names":["isEqual"],"sources":["../../src/figma-api/overrides.ts"],"sourcesContent":["import { omit, uniq } from 'es-toolkit'\nimport { isEqual } from 'es-toolkit/predicate'\n\nimport type {\n ComponentPropertyReferenceField,\n SceneGraph,\n SceneNode,\n Stroke\n} from '@pairdraw/scene-graph'\nimport { findInstanceAncestor, isReplacedLayer } from '@pairdraw/scene-graph/instances'\nimport {\n overriddenVariableModeCollection,\n type InstanceOverrideState\n} from '@pairdraw/scene-graph/instances/overrides'\n\nimport type { NodeProxyInternals, ProxyThis } from './accessor-utils'\nimport { assertProxyEditable, graph, raw } from './accessor-utils'\nimport { flushPendingLayout } from './pending-layout'\n\n/** One layer of an instance and the fields an edit changed on it, as Figma's `overrides`. */\nexport interface FigmaInstanceOverride {\n id: string\n overriddenFields: string[]\n}\n\n/**\n * The fields Figma desktop 126 lists for an override of each of ours. Unlisted fields are ones\n * Figma does not report: a layer's own size, size limits, clipping, the layout mode, a swap.\n * Figma spells the top stroke weight `stokeTopWeight`.\n */\nconst FIGMA_OVERRIDE_FIELDS: Readonly<Partial<Record<string, readonly string[]>>> = {\n // Figma keeps a size as one field, so a changed width or height lists both.\n width: ['height', 'width'],\n height: ['height', 'width'],\n name: ['name'],\n visible: ['visible'],\n locked: ['locked'],\n text: ['characters', 'styledTextSegments'],\n styleRuns: ['styledTextSegments'],\n textParagraphs: ['styledTextSegments'],\n listSpacing: ['styledTextSegments'],\n fontSize: ['fontSize'],\n fontFamily: ['fontName'],\n fontWeight: ['fontName'],\n italic: ['fontName'],\n fontStyle: ['fontName'],\n letterSpacing: ['letterSpacing'],\n lineHeight: ['lineHeight'],\n textCase: ['textCase'],\n textDecoration: ['textDecoration'],\n textDecorationStyle: ['textDecorationStyle'],\n textDecorationThickness: ['textDecorationThickness'],\n textUnderlineOffset: ['textDecorationOffset'],\n textDecorationFills: ['textDecorationColor'],\n textDecorationSkipInk: ['textDecorationSkipInk'],\n textAlignHorizontal: ['textAlignHorizontal'],\n textAlignVertical: ['textAlignVertical'],\n textAutoResize: ['textAutoResize'],\n textTruncation: ['textTruncation'],\n maxLines: ['maxLines'],\n leadingTrim: ['leadingTrim'],\n paragraphSpacing: ['paragraphSpacing'],\n paragraphIndent: ['paragraphIndent'],\n hangingList: ['hangingList'],\n fills: ['fills'],\n strokes: ['strokes'],\n effects: ['effects'],\n opacity: ['opacity'],\n blendMode: ['blendMode'],\n cornerRadius: [\n 'bottomLeftRadius',\n 'bottomRightRadius',\n 'cornerRadius',\n 'topLeftRadius',\n 'topRightRadius'\n ],\n topLeftRadius: ['topLeftRadius'],\n topRightRadius: ['topRightRadius'],\n bottomRightRadius: ['bottomRightRadius'],\n bottomLeftRadius: ['bottomLeftRadius'],\n cornerSmoothing: ['cornerSmoothing'],\n strokeWeight: [\n 'strokeBottomWeight',\n 'strokeLeftWeight',\n 'strokeRightWeight',\n 'stokeTopWeight',\n 'strokeWeight'\n ],\n borderTopWeight: ['stokeTopWeight'],\n borderRightWeight: ['strokeRightWeight'],\n borderBottomWeight: ['strokeBottomWeight'],\n borderLeftWeight: ['strokeLeftWeight'],\n strokeAlign: ['strokeAlign'],\n strokeCap: ['strokeCap'],\n strokeJoin: ['strokeJoin'],\n strokeMiterLimit: ['strokeMiterLimit'],\n dashPattern: ['dashPattern'],\n layoutWrap: ['layoutWrap'],\n primaryAxisAlign: ['primaryAxisAlignItems'],\n counterAxisAlign: ['counterAxisAlignItems'],\n primaryAxisSizing: ['primaryAxisSizingMode'],\n counterAxisSizing: ['counterAxisSizingMode'],\n itemSpacing: ['itemSpacing'],\n counterAxisSpacing: ['counterAxisSpacing'],\n paddingTop: ['paddingTop'],\n paddingRight: ['paddingRight'],\n paddingBottom: ['paddingBottom'],\n paddingLeft: ['paddingLeft'],\n gridColumnGap: ['gridColumnGap'],\n gridRowGap: ['gridRowGap'],\n itemReverseZIndex: ['itemReverseZIndex'],\n layoutGrids: ['layoutGrids'],\n layoutGrow: ['layoutGrow'],\n layoutAlignSelf: ['layoutAlign'],\n boundVariables: ['boundVariables'],\n variableModes: ['explicitVariableModes'],\n fillStyleId: ['fillStyleId'],\n strokeStyleId: ['strokeStyleId'],\n textStyleId: ['textStyleId'],\n effectStyleId: ['effectStyleId'],\n gridStyleId: ['gridStyleId']\n}\n\n/** Fields a component property sets on a layer, which Figma reports as the property's, not an override. */\nconst PROPERTY_FIELDS: Record<ComponentPropertyReferenceField, readonly string[]> = {\n TEXT: ['text', 'styleRuns', 'textParagraphs'],\n VISIBLE: ['visible'],\n INSTANCE_SWAP: ['componentId', 'name'],\n SLOT_CONTENT: []\n}\n\nfunction propertyFields(node: SceneNode): Set<string> {\n return new Set(node.componentPropertyReferences.flatMap(({ field }) => PROPERTY_FIELDS[field]))\n}\n\n/** Figma sorts the names as spelled right, so its misspelled top weight sorts as `strokeTop…`. */\nconst sortKey = (name: string) => (name === 'stokeTopWeight' ? 'strokeTopWeight' : name)\n\nfunction figmaFields(fields: Iterable<string>, skipped: Set<string>): string[] {\n const names = new Set<string>()\n for (const field of fields) {\n if (skipped.has(field)) continue\n for (const name of FIGMA_OVERRIDE_FIELDS[field] ?? []) names.add(name)\n }\n return [...names].sort((a, b) => sortKey(a).localeCompare(sortKey(b)))\n}\n\n/**\n * The layer of the component a node copies, which its overrides are measured against. A nested\n * instance links to the component's instance it copies, until a swap points it at a component;\n * the enclosing instance then keeps the layer it copied.\n */\nfunction componentLayer(graph: SceneGraph, node: SceneNode, owner: SceneNode | undefined) {\n const linked = node.componentId ? graph.getNode(node.componentId) : undefined\n if (node.type !== 'INSTANCE' || linked?.type === 'INSTANCE') return linked\n const source = owner?.instanceOverrides.descendants.get(node.id)?.get('sourceComponentId')\n return typeof source === 'string' ? graph.getNode(source) : undefined\n}\n\n/** Figma keeps stroke weight and alignment on the layer, so a paint differs by its colour alone. */\nconst paints = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => omit(stroke, ['weight', 'align']))\n\nfunction differs(node: SceneNode, source: SceneNode | undefined, field: string): boolean {\n if (!source) return true\n if (field === 'strokes') return !isEqual(paints(node.strokes), paints(source.strokes))\n return !isEqual(Reflect.get(node, field), Reflect.get(source, field))\n}\n\n/**\n * The fields recorded as edited on a node that still differ from its component layer: an edit\n * kept in the nearest instance above it, and one kept on the node itself if it is an instance.\n * Figma lists a field as overridden only while it differs.\n */\nfunction editedFields(graph: SceneGraph, node: SceneNode, root: SceneNode): string[] {\n const owner =\n node.id === root.id || !node.parentId ? undefined : findInstanceAncestor(graph, node.parentId)\n const source =\n node.id === root.id ? graph.getNode(root.componentId ?? '') : componentLayer(graph, node, owner)\n const fields = [\n ...(node.type === 'INSTANCE' ? node.instanceOverrides.self.keys() : []),\n ...(owner?.instanceOverrides.descendants.get(node.id)?.keys() ?? [])\n ].map((field) =>\n // A mode set for one collection is an override of the layer's modes, as Figma lists it.\n overriddenVariableModeCollection(field) === null ? field : 'variableModes'\n )\n // The instance's own size counts once it differs, as a layer that grows it makes it.\n if (node.id === root.id) fields.push('width', 'height')\n return uniq(fields).filter((field) => differs(node, source, field))\n}\n\n/**\n * Figma's `overrides`: each layer of the instance, itself first and then in layer order, with\n * the fields edited on it, including those inside nested instances. Figma lists no layer's own\n * size but the instance's.\n */\nexport function instanceOverrides(graph: SceneGraph, root: SceneNode): FigmaInstanceOverride[] {\n const result: FigmaInstanceOverride[] = []\n const visit = (node: SceneNode) => {\n const skipped = propertyFields(node)\n if (node.id !== root.id) skipped.add('width').add('height')\n const overriddenFields = figmaFields(editedFields(graph, node, root), skipped)\n if (overriddenFields.length > 0) result.push({ id: node.id, overriddenFields })\n for (const child of graph.getChildren(node.id)) visit(child)\n }\n visit(root)\n return result\n}\n\n/** Clears an override state but what component properties set, which Figma keeps on reset. */\nfunction withoutEdits(graph: SceneGraph, state: InstanceOverrideState): InstanceOverrideState {\n const keep = (nodeId: string, fields: Map<string, unknown>) => {\n const node = graph.getNode(nodeId)\n const driven = node ? propertyFields(node) : new Set<string>()\n return new Map([...fields].filter(([field]) => driven.has(field)))\n }\n const descendants = new Map(\n [...state.descendants]\n .map(([nodeId, fields]) => [nodeId, keep(nodeId, fields)] as const)\n .filter(([, fields]) => fields.size > 0)\n )\n return { self: new Map(), descendants }\n}\n\n/**\n * Figma's `resetOverrides`: the instance and every instance inside it go back to their\n * components, keeping the values their component properties set.\n */\nexport function resetInstanceOverrides(graph: SceneGraph, root: SceneNode): void {\n // A layer put in place of a component's layer goes, and the sync brings that layer back.\n const replaced: string[] = []\n const collect = (node: SceneNode) => {\n for (const child of graph.getChildren(node.id)) {\n if (isReplacedLayer(graph, child)) replaced.push(child.id)\n else collect(child)\n }\n }\n collect(root)\n for (const id of replaced) graph.deleteNode(id)\n const visit = (node: SceneNode) => {\n if (node.type === 'INSTANCE')\n graph.updateNode(node.id, { instanceOverrides: withoutEdits(graph, node.instanceOverrides) })\n for (const child of graph.getChildren(node.id)) visit(child)\n }\n visit(root)\n // The outermost instance passes its component's content down to the ones inside it.\n let outermost = root\n for (\n let parent = root.parentId ? findInstanceAncestor(graph, root.parentId) : undefined;\n parent;\n ) {\n outermost = parent\n parent = parent.parentId ? findInstanceAncestor(graph, parent.parentId) : undefined\n }\n graph.syncInstance(outermost.id)\n}\n\nexport function installInstanceOverrideAccessors(\n prototype: object,\n internals: NodeProxyInternals\n): void {\n Object.defineProperties(prototype, {\n overrides: {\n get(this: ProxyThis): FigmaInstanceOverride[] | undefined {\n const node = raw(this, internals)\n if (node.type !== 'INSTANCE') return undefined\n // Figma lists the size its layout gives the instance.\n flushPendingLayout(graph(this, internals))\n return instanceOverrides(graph(this, internals), node)\n }\n },\n resetOverrides: {\n value(this: ProxyThis) {\n const node = raw(this, internals)\n if (node.type !== 'INSTANCE')\n throw new TypeError('resetOverrides() can only be called on instances')\n assertProxyEditable(this, internals)\n resetInstanceOverrides(graph(this, internals), node)\n }\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,MAAM,wBAA8E;CAElF,OAAO,CAAC,UAAU,OAAO;CACzB,QAAQ,CAAC,UAAU,OAAO;CAC1B,MAAM,CAAC,MAAM;CACb,SAAS,CAAC,SAAS;CACnB,QAAQ,CAAC,QAAQ;CACjB,MAAM,CAAC,cAAc,oBAAoB;CACzC,WAAW,CAAC,oBAAoB;CAChC,gBAAgB,CAAC,oBAAoB;CACrC,aAAa,CAAC,oBAAoB;CAClC,UAAU,CAAC,UAAU;CACrB,YAAY,CAAC,UAAU;CACvB,YAAY,CAAC,UAAU;CACvB,QAAQ,CAAC,UAAU;CACnB,WAAW,CAAC,UAAU;CACtB,eAAe,CAAC,eAAe;CAC/B,YAAY,CAAC,YAAY;CACzB,UAAU,CAAC,UAAU;CACrB,gBAAgB,CAAC,gBAAgB;CACjC,qBAAqB,CAAC,qBAAqB;CAC3C,yBAAyB,CAAC,yBAAyB;CACnD,qBAAqB,CAAC,sBAAsB;CAC5C,qBAAqB,CAAC,qBAAqB;CAC3C,uBAAuB,CAAC,uBAAuB;CAC/C,qBAAqB,CAAC,qBAAqB;CAC3C,mBAAmB,CAAC,mBAAmB;CACvC,gBAAgB,CAAC,gBAAgB;CACjC,gBAAgB,CAAC,gBAAgB;CACjC,UAAU,CAAC,UAAU;CACrB,aAAa,CAAC,aAAa;CAC3B,kBAAkB,CAAC,kBAAkB;CACrC,iBAAiB,C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SAAgB,iCACd,WACA,WACM;CACN,OAAO,iBAAiB,WAAW;EACjC,WAAW,EACT,MAA0D;GACxD,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,IAAI,KAAK,SAAS,YAAY,OAAO,KAAA;GAErC,mBAAmB,MAAM,MAAM,SAAS,CAAC;GACzC,OAAO,kBAAkB,MAAM,MAAM,SAAS,GAAG,IAAI;EACvD,EACF;EACA,gBAAgB,EACd,QAAuB;GACrB,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,IAAI,KAAK,SAAS,YAChB,MAAM,IAAI,UAAU,kDAAkD;GACxE,oBAAoB,MAAM,SAAS;GACnC,uBAAuB,MAAM,MAAM,SAAS,GAAG,IAAI;EACrD,EACF;CACF,CAAC;AACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
1
|
+
import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
2
2
|
//#region src/figma-api/pending-layout.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Records the graph's edits so that reading geometry lays out what they touched first, as Figma
|
|
@@ -9,6 +9,16 @@ import { SceneGraph } from "@pairdraw/scene-graph";
|
|
|
9
9
|
declare function startPendingLayout(graph: SceneGraph): void;
|
|
10
10
|
/** Lays out the edits recorded since the last geometry read. */
|
|
11
11
|
declare function flushPendingLayout(graph: SceneGraph): void;
|
|
12
|
+
/**
|
|
13
|
+
* Lays out the recorded edits before a script moves or sizes `node`, when that layout could change
|
|
14
|
+
* where it lands, as Figma lays out a script's edits while it runs: the layer follows its frame's
|
|
15
|
+
* size, or a resize places its children from its own size. A layer pinned left and top, or one
|
|
16
|
+
* an auto layout places, lands the same either way, so its edits wait for the next read: a script
|
|
17
|
+
* that builds many layers lays out once rather than once per layer.
|
|
18
|
+
*/
|
|
19
|
+
declare function flushPendingLayoutBefore(graph: SceneGraph, node: SceneNode, { placesChildren }?: {
|
|
20
|
+
placesChildren?: boolean;
|
|
21
|
+
}): void;
|
|
12
22
|
//#endregion
|
|
13
|
-
export { flushPendingLayout, startPendingLayout };
|
|
23
|
+
export { flushPendingLayout, flushPendingLayoutBefore, startPendingLayout };
|
|
14
24
|
//# sourceMappingURL=pending-layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending-layout.d.ts","names":[],"sources":["../../src/figma-api/pending-layout.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"pending-layout.d.ts","names":[],"sources":["../../src/figma-api/pending-layout.ts"],"mappings":";;;;;;;;iBAkCgB,mBAAmB,OAAO;;iBAS1B,mBAAmB,OAAO;;;;;;;;iBAoD1B,yBACd,OAAO,YACP,MAAM,aACJ;EAA4B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createLayoutRunner } from "../layout/mutations.js";
|
|
2
|
+
import { flushPendingComponentSync } from "./pending-sync.js";
|
|
2
3
|
import { createSceneMutationImpact, recordSceneMutations } from "@pairdraw/scene-graph/mutation-impact";
|
|
3
4
|
//#region src/figma-api/pending-layout.ts
|
|
4
5
|
const pendingByGraph = /* @__PURE__ */ new WeakMap();
|
|
@@ -25,6 +26,7 @@ function startPendingLayout(graph) {
|
|
|
25
26
|
}
|
|
26
27
|
/** Lays out the edits recorded since the last geometry read. */
|
|
27
28
|
function flushPendingLayout(graph) {
|
|
29
|
+
flushPendingComponentSync(graph);
|
|
28
30
|
const pending = pendingByGraph.get(graph);
|
|
29
31
|
if (!pending || pending.flushing || pending.impact.changedNodeIds.size === 0) return;
|
|
30
32
|
const impact = structuredClone(pending.impact);
|
|
@@ -39,7 +41,45 @@ function flushPendingLayout(graph) {
|
|
|
39
41
|
pending.flushing = false;
|
|
40
42
|
}
|
|
41
43
|
}
|
|
44
|
+
/** Whether a frame resizing would move or stretch the layer: a constraint other than left or top. */
|
|
45
|
+
function followsFrameSize(node) {
|
|
46
|
+
return node.horizontalConstraint !== "MIN" || node.verticalConstraint !== "MIN";
|
|
47
|
+
}
|
|
48
|
+
/** The layer and the layers above it, up to but not including its page. */
|
|
49
|
+
function layoutChain(graph, id) {
|
|
50
|
+
const chain = [];
|
|
51
|
+
for (let node = graph.getNode(id); node && node.type !== "CANVAS";) {
|
|
52
|
+
chain.push(node.id);
|
|
53
|
+
node = node.parentId ? graph.getNode(node.parentId) : void 0;
|
|
54
|
+
}
|
|
55
|
+
return chain;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Whether laying out the recorded edits could reach the layer: an edit sits in the same frame as
|
|
59
|
+
* the layer, at any depth, since a layer that grows makes every Hug frame around it grow. Edits
|
|
60
|
+
* in another top-level frame share only the page with it, and leave it where it is.
|
|
61
|
+
*/
|
|
62
|
+
function editsReach(graph, impact, node) {
|
|
63
|
+
const above = new Set(layoutChain(graph, node.id));
|
|
64
|
+
return [
|
|
65
|
+
...impact.changedNodeIds,
|
|
66
|
+
...impact.currentParentIds,
|
|
67
|
+
...impact.previousParentIds
|
|
68
|
+
].some((id) => layoutChain(graph, id).some((current) => above.has(current)));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Lays out the recorded edits before a script moves or sizes `node`, when that layout could change
|
|
72
|
+
* where it lands, as Figma lays out a script's edits while it runs: the layer follows its frame's
|
|
73
|
+
* size, or a resize places its children from its own size. A layer pinned left and top, or one
|
|
74
|
+
* an auto layout places, lands the same either way, so its edits wait for the next read: a script
|
|
75
|
+
* that builds many layers lays out once rather than once per layer.
|
|
76
|
+
*/
|
|
77
|
+
function flushPendingLayoutBefore(graph, node, { placesChildren = false } = {}) {
|
|
78
|
+
const pending = pendingByGraph.get(graph);
|
|
79
|
+
if (!pending || pending.flushing || pending.impact.changedNodeIds.size === 0) return;
|
|
80
|
+
if ((followsFrameSize(node) || placesChildren && graph.getChildren(node.id).some(followsFrameSize)) && editsReach(graph, pending.impact, node)) flushPendingLayout(graph);
|
|
81
|
+
}
|
|
42
82
|
//#endregion
|
|
43
|
-
export { flushPendingLayout, startPendingLayout };
|
|
83
|
+
export { flushPendingLayout, flushPendingLayoutBefore, startPendingLayout };
|
|
44
84
|
|
|
45
85
|
//# sourceMappingURL=pending-layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending-layout.js","names":[],"sources":["../../src/figma-api/pending-layout.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n createSceneMutationImpact,\n recordSceneMutations,\n type SceneMutationImpact\n} from '@pairdraw/scene-graph/mutation-impact'\n\nimport { createLayoutRunner } from '#core/layout/mutations'\n\ninterface PendingLayout {\n impact: SceneMutationImpact\n flushing: boolean\n}\n\nconst pendingByGraph = new WeakMap<SceneGraph, PendingLayout>()\n\nfunction clearImpact(impact: SceneMutationImpact): void {\n for (const ids of Object.values(impact)) ids.clear()\n}\n\nfunction mergeImpact(into: SceneMutationImpact, from: SceneMutationImpact): void {\n for (const key of Object.keys(into) as (keyof SceneMutationImpact)[]) {\n for (const id of from[key]) into[key].add(id)\n }\n}\n\n/**\n * Records the graph's edits so that reading geometry lays out what they touched first, as Figma\n * does: a script that fills a child and then reads its width sees the filled width. A graph has\n * one recorder for its lifetime, kept across APIs: a script that failed before its tool laid\n * out its edits leaves them for the next read to lay out.\n */\nexport function startPendingLayout(graph: SceneGraph): void {\n if (pendingByGraph.has(graph)) return\n const pending: PendingLayout = { impact: createSceneMutationImpact(), flushing: false }\n pendingByGraph.set(graph, pending)\n // Layout's own writes are its result, not new edits.\n recordSceneMutations(graph, pending.impact, () => !pending.flushing && !graph.isApplyingLayout)\n}\n\n/** Lays out the edits recorded since the last geometry read. */\nexport function flushPendingLayout(graph: SceneGraph): void {\n const pending = pendingByGraph.get(graph)\n if (!pending || pending.flushing || pending.impact.changedNodeIds.size === 0) return\n const impact = structuredClone(pending.impact)\n clearImpact(pending.impact)\n pending.flushing = true\n try {\n createLayoutRunner(() => graph).runLayoutForImpact(impact)\n } catch (error) {\n // The edits are still unlaid out, so the next read tries again.\n mergeImpact(pending.impact, impact)\n throw error\n } finally {\n pending.flushing = false\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pending-layout.js","names":[],"sources":["../../src/figma-api/pending-layout.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n createSceneMutationImpact,\n recordSceneMutations,\n type SceneMutationImpact\n} from '@pairdraw/scene-graph/mutation-impact'\n\nimport { createLayoutRunner } from '#core/layout/mutations'\n\nimport { flushPendingComponentSync } from './pending-sync'\n\ninterface PendingLayout {\n impact: SceneMutationImpact\n flushing: boolean\n}\n\nconst pendingByGraph = new WeakMap<SceneGraph, PendingLayout>()\n\nfunction clearImpact(impact: SceneMutationImpact): void {\n for (const ids of Object.values(impact)) ids.clear()\n}\n\nfunction mergeImpact(into: SceneMutationImpact, from: SceneMutationImpact): void {\n for (const key of Object.keys(into) as (keyof SceneMutationImpact)[]) {\n for (const id of from[key]) into[key].add(id)\n }\n}\n\n/**\n * Records the graph's edits so that reading geometry lays out what they touched first, as Figma\n * does: a script that fills a child and then reads its width sees the filled width. A graph has\n * one recorder for its lifetime, kept across APIs: a script that failed before its tool laid\n * out its edits leaves them for the next read to lay out.\n */\nexport function startPendingLayout(graph: SceneGraph): void {\n if (pendingByGraph.has(graph)) return\n const pending: PendingLayout = { impact: createSceneMutationImpact(), flushing: false }\n pendingByGraph.set(graph, pending)\n // Layout's own writes are its result, not new edits.\n recordSceneMutations(graph, pending.impact, () => !pending.flushing && !graph.isApplyingLayout)\n}\n\n/** Lays out the edits recorded since the last geometry read. */\nexport function flushPendingLayout(graph: SceneGraph): void {\n // Instances lay out what their components hold now.\n flushPendingComponentSync(graph)\n const pending = pendingByGraph.get(graph)\n if (!pending || pending.flushing || pending.impact.changedNodeIds.size === 0) return\n const impact = structuredClone(pending.impact)\n clearImpact(pending.impact)\n pending.flushing = true\n try {\n createLayoutRunner(() => graph).runLayoutForImpact(impact)\n } catch (error) {\n // The edits are still unlaid out, so the next read tries again.\n mergeImpact(pending.impact, impact)\n throw error\n } finally {\n pending.flushing = false\n }\n}\n\n/** Whether a frame resizing would move or stretch the layer: a constraint other than left or top. */\nfunction followsFrameSize(node: SceneNode): boolean {\n return node.horizontalConstraint !== 'MIN' || node.verticalConstraint !== 'MIN'\n}\n\n/** The layer and the layers above it, up to but not including its page. */\nfunction layoutChain(graph: SceneGraph, id: string): string[] {\n const chain: string[] = []\n for (let node = graph.getNode(id); node && node.type !== 'CANVAS';) {\n chain.push(node.id)\n node = node.parentId ? graph.getNode(node.parentId) : undefined\n }\n return chain\n}\n\n/**\n * Whether laying out the recorded edits could reach the layer: an edit sits in the same frame as\n * the layer, at any depth, since a layer that grows makes every Hug frame around it grow. Edits\n * in another top-level frame share only the page with it, and leave it where it is.\n */\nfunction editsReach(graph: SceneGraph, impact: SceneMutationImpact, node: SceneNode): boolean {\n const above = new Set(layoutChain(graph, node.id))\n const edited = [...impact.changedNodeIds, ...impact.currentParentIds, ...impact.previousParentIds]\n return edited.some((id) => layoutChain(graph, id).some((current) => above.has(current)))\n}\n\n/**\n * Lays out the recorded edits before a script moves or sizes `node`, when that layout could change\n * where it lands, as Figma lays out a script's edits while it runs: the layer follows its frame's\n * size, or a resize places its children from its own size. A layer pinned left and top, or one\n * an auto layout places, lands the same either way, so its edits wait for the next read: a script\n * that builds many layers lays out once rather than once per layer.\n */\nexport function flushPendingLayoutBefore(\n graph: SceneGraph,\n node: SceneNode,\n { placesChildren = false }: { placesChildren?: boolean } = {}\n): void {\n const pending = pendingByGraph.get(graph)\n if (!pending || pending.flushing || pending.impact.changedNodeIds.size === 0) return\n const depends =\n followsFrameSize(node) || (placesChildren && graph.getChildren(node.id).some(followsFrameSize))\n if (depends && editsReach(graph, pending.impact, node)) flushPendingLayout(graph)\n}\n"],"mappings":";;;;AAgBA,MAAM,iCAAiB,IAAI,QAAmC;AAE9D,SAAS,YAAY,QAAmC;CACtD,KAAK,MAAM,OAAO,OAAO,OAAO,MAAM,GAAG,IAAI,MAAM;AACrD;AAEA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AC;CAEjD,OAAO;EADS,GAAG,OAAO;EAAgB,GAAG,OAAO;EAAkB,GAAG,OAAO;CACpE,CAAC,CAAC,MAAM,OAAO,YAAY,OAAO,EAAE,CAAC,CAAC,MAAM,YAAY,MAAM,IAAI,OAAO,CAAC,CAAC;AACzF;;;;;;;;AASA,SAAgB,yBACd,OACA,MACA,EAAE,iBAAiB,UAAwC,CAAC,GACtD;CACN,MAAM,UAAU,eAAe,IAAI,KAAK;CACxC,IAAI,CAAC,WAAW,QAAQ,YAAY,QAAQ,OAAO,eAAe,SAAS,GAAG;CAG9E,KADE,iBAAiB,IAAI,KAAM,kBAAkB,MAAM,YAAY,KAAK,EAAE,CAAC,CAAC,KAAK,gBAAgB,MAChF,WAAW,OAAO,QAAQ,QAAQ,IAAI,GAAG,mBAAmB,KAAK;AAClF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
2
|
+
//#region src/figma-api/pending-sync.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Makes reading a layer bring instances in line with the component edits made before it, as Figma
|
|
5
|
+
* does at once: a script that recolors a component and then reads an instance sees the new color.
|
|
6
|
+
* A host that already syncs instances after edits, such as the editor, passes its own `flush`,
|
|
7
|
+
* which also lays out and redraws what it synced. Without one the graph records its edits itself,
|
|
8
|
+
* for its lifetime, as `startPendingLayout` does.
|
|
9
|
+
*/
|
|
10
|
+
declare function startPendingComponentSync(graph: SceneGraph, flush?: () => void): void;
|
|
11
|
+
/**
|
|
12
|
+
* Syncs the instances of the components edited since, before a read; given the layer about to be
|
|
13
|
+
* read or written, only when it is in an instance, as only those layers change. Edits inside a
|
|
14
|
+
* component then sync once, when an instance is next read, not once per edit.
|
|
15
|
+
*/
|
|
16
|
+
declare function flushPendingComponentSync(graph: SceneGraph, layerId?: string): void;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { flushPendingComponentSync, startPendingComponentSync };
|
|
19
|
+
//# sourceMappingURL=pending-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-sync.d.ts","names":[],"sources":["../../src/figma-api/pending-sync.ts"],"mappings":";;;;;;;;;iBAiBgB,0BAA0B,OAAO,YAAY;;;;;;iBAsC7C,0BAA0B,OAAO,YAAY"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { syncComponentsHolding } from "../editor/component-sync.js";
|
|
2
|
+
import { createSceneMutationImpact, recordSceneMutations } from "@pairdraw/scene-graph/mutation-impact";
|
|
3
|
+
//#region src/figma-api/pending-sync.ts
|
|
4
|
+
const syncByGraph = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
/**
|
|
6
|
+
* Makes reading a layer bring instances in line with the component edits made before it, as Figma
|
|
7
|
+
* does at once: a script that recolors a component and then reads an instance sees the new color.
|
|
8
|
+
* A host that already syncs instances after edits, such as the editor, passes its own `flush`,
|
|
9
|
+
* which also lays out and redraws what it synced. Without one the graph records its edits itself,
|
|
10
|
+
* for its lifetime, as `startPendingLayout` does.
|
|
11
|
+
*/
|
|
12
|
+
function startPendingComponentSync(graph, flush) {
|
|
13
|
+
if (flush) {
|
|
14
|
+
syncByGraph.set(graph, flush);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (syncByGraph.has(graph)) return;
|
|
18
|
+
const impact = createSceneMutationImpact();
|
|
19
|
+
let syncing = false;
|
|
20
|
+
recordSceneMutations(graph, impact, () => !syncing && !graph.isApplyingImportedState && !graph.isApplyingLayout);
|
|
21
|
+
syncByGraph.set(graph, () => {
|
|
22
|
+
if (syncing || impact.changedNodeIds.size === 0) return;
|
|
23
|
+
const changed = [...impact.changedNodeIds];
|
|
24
|
+
const leftParents = [...impact.previousParentIds];
|
|
25
|
+
for (const recorded of Object.values(impact)) recorded.clear();
|
|
26
|
+
syncing = true;
|
|
27
|
+
try {
|
|
28
|
+
syncComponentsHolding(graph, [...changed, ...leftParents]);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
for (const id of changed) impact.changedNodeIds.add(id);
|
|
31
|
+
for (const id of leftParents) impact.previousParentIds.add(id);
|
|
32
|
+
throw error;
|
|
33
|
+
} finally {
|
|
34
|
+
syncing = false;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Syncs the instances of the components edited since, before a read; given the layer about to be
|
|
40
|
+
* read or written, only when it is in an instance, as only those layers change. Edits inside a
|
|
41
|
+
* component then sync once, when an instance is next read, not once per edit.
|
|
42
|
+
*/
|
|
43
|
+
function flushPendingComponentSync(graph, layerId) {
|
|
44
|
+
const flush = syncByGraph.get(graph);
|
|
45
|
+
if (!flush) return;
|
|
46
|
+
if (layerId !== void 0 && !graph.closest(layerId, (node) => node.type === "INSTANCE")) return;
|
|
47
|
+
flush();
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { flushPendingComponentSync, startPendingComponentSync };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=pending-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-sync.js","names":[],"sources":["../../src/figma-api/pending-sync.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n createSceneMutationImpact,\n recordSceneMutations\n} from '@pairdraw/scene-graph/mutation-impact'\n\nimport { syncComponentsHolding } from '#core/editor/component-sync'\n\nconst syncByGraph = new WeakMap<SceneGraph, () => void>()\n\n/**\n * Makes reading a layer bring instances in line with the component edits made before it, as Figma\n * does at once: a script that recolors a component and then reads an instance sees the new color.\n * A host that already syncs instances after edits, such as the editor, passes its own `flush`,\n * which also lays out and redraws what it synced. Without one the graph records its edits itself,\n * for its lifetime, as `startPendingLayout` does.\n */\nexport function startPendingComponentSync(graph: SceneGraph, flush?: () => void): void {\n if (flush) {\n syncByGraph.set(graph, flush)\n return\n }\n if (syncByGraph.has(graph)) return\n const impact = createSceneMutationImpact()\n let syncing = false\n // Syncing writes the instances it updates, which are results, not edits; so do loading and layout.\n recordSceneMutations(\n graph,\n impact,\n () => !syncing && !graph.isApplyingImportedState && !graph.isApplyingLayout\n )\n syncByGraph.set(graph, () => {\n if (syncing || impact.changedNodeIds.size === 0) return\n const changed = [...impact.changedNodeIds]\n const leftParents = [...impact.previousParentIds]\n for (const recorded of Object.values(impact)) recorded.clear()\n syncing = true\n try {\n syncComponentsHolding(graph, [...changed, ...leftParents])\n } catch (error) {\n // The edits are still unsynced, so the next read tries again, as pending layout does.\n for (const id of changed) impact.changedNodeIds.add(id)\n for (const id of leftParents) impact.previousParentIds.add(id)\n throw error\n } finally {\n syncing = false\n }\n })\n}\n\n/**\n * Syncs the instances of the components edited since, before a read; given the layer about to be\n * read or written, only when it is in an instance, as only those layers change. Edits inside a\n * component then sync once, when an instance is next read, not once per edit.\n */\nexport function flushPendingComponentSync(graph: SceneGraph, layerId?: string): void {\n const flush = syncByGraph.get(graph)\n if (!flush) return\n if (layerId !== undefined && !graph.closest(layerId, (node) => node.type === 'INSTANCE')) return\n flush()\n}\n"],"mappings":";;;AAQA,MAAM,8BAAc,IAAI,QAAgC;;;;;;;;AASxD,SAAgB,0BAA0B,OAAmB,OAA0B;CACrF,IAAI,OAAO;EACT,YAAY,IAAI,OAAO,KAAK;EAC5B;CACF;CACA,IAAI,YAAY,IAAI,KAAK,GAAG;CAC5B,MAAM,SAAS,0BAA0B;CACzC,IAAI,UAAU;CAEd,qBACE,OACA,cACM,CAAC,WAAW,CAAC,MAAM,2BAA2B,CAAC,MAAM,gBAC7D;CACA,YAAY,IAAI,aAAa;EAC3B,IAAI,WAAW,OAAO,eAAe,SAAS,GAAG;EACjD,MAAM,UAAU,CAAC,GAAG,OAAO,cAAc;EACzC,MAAM,cAAc,CAAC,GAAG,OAAO,iBAAiB;EAChD,KAAK,MAAM,YAAY,OAAO,OAAO,MAAM,GAAG,SAAS,MAAM;EAC7D,UAAU;EACV,IAAI;GACF,sBAAsB,OAAO,CAAC,GAAG,SAAS,GAAG,WAAW,CAAC;EAC3D,SAAS,OAAO;GAEd,KAAK,MAAM,MAAM,SAAS,OAAO,eAAe,IAAI,EAAE;GACtD,KAAK,MAAM,MAAM,aAAa,OAAO,kBAAkB,IAAI,EAAE;GAC7D,MAAM;EACR,UAAU;GACR,UAAU;EACZ;CACF,CAAC;AACH;;;;;;AAOA,SAAgB,0BAA0B,OAAmB,SAAwB;CACnF,MAAM,QAAQ,YAAY,IAAI,KAAK;CACnC,IAAI,CAAC,OAAO;CACZ,IAAI,YAAY,KAAA,KAAa,CAAC,MAAM,QAAQ,UAAU,SAAS,KAAK,SAAS,UAAU,GAAG;CAC1F,MAAM;AACR"}
|
|
@@ -2,13 +2,15 @@ import { FigmaFont, FigmaFontName } from "./fonts/names.js";
|
|
|
2
2
|
import { FigmaEffect } from "./effects.js";
|
|
3
3
|
import { FigmaTransform } from "./types.js";
|
|
4
4
|
import { FigmaPaint } from "./paints.js";
|
|
5
|
-
import {
|
|
5
|
+
import { InsertStyleSource } from "../text/style-runs.js";
|
|
6
|
+
import { FigmaLetterSpacing, FigmaLineHeight } from "./text/index.js";
|
|
6
7
|
import { TextRangeMethods } from "./accessors/text/ranges.js";
|
|
7
8
|
import { VariableNodeMembers } from "./accessors/variables.js";
|
|
8
9
|
import { FigmaVectorNetwork, FigmaVectorPath } from "./accessors/vector.js";
|
|
9
10
|
import { FigmaDevStatusValue } from "./dev-status.js";
|
|
10
11
|
import { FigmaInstanceOverride } from "./overrides.js";
|
|
11
12
|
import { PluginDataMethods } from "./plugin-data.js";
|
|
13
|
+
import { FigmaReaction } from "./reactions.js";
|
|
12
14
|
import { FigmaFrameNode, FigmaInstanceNode } from "./node-types.js";
|
|
13
15
|
import { ArcData, HyperlinkTarget, LayoutGrid, LayoutMode, NodeType, SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
14
16
|
import { ShapeWithTextType } from "@pairdraw/scene-graph/shape-with-text";
|
|
@@ -19,6 +21,15 @@ declare const MIXED: unique symbol;
|
|
|
19
21
|
declare const INTERNAL_ID: unique symbol;
|
|
20
22
|
declare const INTERNAL_GRAPH: unique symbol;
|
|
21
23
|
declare const INTERNAL_API: unique symbol;
|
|
24
|
+
/** How a host loads pages as they are visited; see `FigmaAPIOptions`. */
|
|
25
|
+
interface PageHost {
|
|
26
|
+
load: (pageId: string) => Promise<void>;
|
|
27
|
+
pageOfNode?: (nodeId: string) => Promise<string | null>;
|
|
28
|
+
}
|
|
29
|
+
declare function setPageHost(api: NodeProxyHost, host: PageHost): void;
|
|
30
|
+
declare function loadPage(api: NodeProxyHost, pageId: string): Promise<void>;
|
|
31
|
+
/** The page holding a layer not loaded yet, which loading that page brings in. */
|
|
32
|
+
declare function pageOfNode(api: NodeProxyHost, nodeId: string): Promise<string | null>;
|
|
22
33
|
interface NodeProxyHost {
|
|
23
34
|
wrapNode(id: string): FigmaNodeProxy;
|
|
24
35
|
readonly currentPageId: string;
|
|
@@ -115,6 +126,8 @@ declare class FigmaNodeProxy {
|
|
|
115
126
|
readonly boundVariables: VariableNodeMembers['boundVariables'];
|
|
116
127
|
setBoundVariable: VariableNodeMembers['setBoundVariable'];
|
|
117
128
|
readonly overrides: FigmaInstanceOverride[] | undefined;
|
|
129
|
+
/** Prototype connections, in Figma's plugin shape; refused when the play cannot run them. */
|
|
130
|
+
reactions: readonly FigmaReaction[];
|
|
118
131
|
/** A sticky note's body or a shape's label, a sticky's author line, and whether it is wide. */
|
|
119
132
|
readonly text: FigmaNodeProxy | undefined;
|
|
120
133
|
readonly authorName: string | undefined;
|
|
@@ -246,5 +259,5 @@ declare class FigmaNodeProxy {
|
|
|
246
259
|
toString(): string;
|
|
247
260
|
}
|
|
248
261
|
//#endregion
|
|
249
|
-
export { type FigmaFont, type FigmaFontName, FigmaNodeProxy, INTERNAL_API, INTERNAL_GRAPH, INTERNAL_ID, MIXED, NodeProxyHost };
|
|
262
|
+
export { type FigmaFont, type FigmaFontName, FigmaNodeProxy, INTERNAL_API, INTERNAL_GRAPH, INTERNAL_ID, MIXED, NodeProxyHost, PageHost, loadPage, pageOfNode, setPageHost };
|
|
250
263
|
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","names":[],"sources":["../../src/figma-api/proxy.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","names":[],"sources":["../../src/figma-api/proxy.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cA0DM;cAIO;cACA;cACA;;UAGI;EACf,OAAO,mBAAmB;EAC1B,cAAc,mBAAmB;;iBASnB,YAAY,KAAK,eAAe,MAAM;iBAItC,SAAS,KAAK,eAAe,iBAAiB;;iBAK9C,WAAW,KAAK,eAAe,iBAAiB;UAI/C;EACf,SAAS,aAAa;WACb;;WAEA,iBAAiB;;cAgBf;GACV;GACA,iBAAiB;GACjB,eAAe;WAEC;;WAEA,MAAM;EACf;WACS;EACT;EACA;WACS;WACA;EACT;EACA,mBAAmB;EACnB,SAAS,eAAe;EACxB,2BAA2B,eAAe;EAC1C,UAAU;WACD,mBAAmB;WACnB,qBAAqB;WACrB,sBAAsB;EAE/B,gBAAgB;EAChB,kBAAkB;EAClB,kBAAkB;EAClB;EACA;EACA;EACA,WAAW;EACX;EACA;EACA,8BAA8B;EAC9B;EACA;EACA;EACA;EACA;EAEA,YAAY;EACZ,sBAAsB;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IAAe;IAAoB;;EACnC;EACA;EACA;EACA;WACS,mBAAmB;;EAE5B;EACA;EACA;EACA;EACA;EACA,SAAS,SAAS;EAClB,sBAAsB;EACtB,eAAe;EACf,wBAAwB,eAAe,uBAAuB;EAC9D,iBAAiB,sCAAsC;EACvD,eAAe;EACf,eAAe;EACf,mBAAmB;EACnB,qBAAqB;EACrB,qBAAqB;EACrB,yBAAyB;WAChB,uBAAuB;WACvB,uBAAuB;EAChC,sCAAsC;EACtC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AAQ;MAInC,iBAAiB;EAQrB,kBAAkB;;EAWlB,kBAAkB;;EAUlB,cAAc,WAAW;MAWrB,UAAU;MAMV,YAAY;EAOhB,YAAY,OAAO;;;;;UAiBX;EAaR,YAAY,eAAe,OAAO;EAclC,SAAS;EAgBT;EAWA,QAAQ,YAAY,MAAM,6BAA6B;EAIvD,QAAQ,WAAW,MAAM,6BAA6B;EAItD,UAAU,WAAW,MAAM,6BAA6B;EASxD,aAAa,YAAY,MAAM,6BAA6B;EAS5D,oBAAoB;IAAY;MAAqB;EAWrD,OAAO,mBAAmB,wBAAmB;EAU7C"}
|
package/dist/figma-api/proxy.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { getPageBackgrounds, setPageBackgrounds } from "./page-backgrounds.js";
|
|
2
2
|
import { assertNodeEditable } from "../editor/capabilities.js";
|
|
3
3
|
import { parseFigmaPaints, toFigmaPaint } from "./paints.js";
|
|
4
|
+
import { flushPendingComponentSync } from "./pending-sync.js";
|
|
4
5
|
import { fitGroupsAround, prepareFollowedFieldEdit } from "./accessor-utils.js";
|
|
6
|
+
import { installInstanceOverrideAccessors } from "./overrides.js";
|
|
5
7
|
import { installSlotAccessors, prepareSlotMove, prepareSlotRemoval } from "./slots.js";
|
|
6
8
|
import { installComponentPropertyAccessors } from "./components.js";
|
|
7
9
|
import { installDevStatusAccessors } from "./dev-status.js";
|
|
@@ -9,6 +11,7 @@ import { containerTransform, setContainerTransform } from "./transform.js";
|
|
|
9
11
|
import { installBasicNodeProxyAccessors } from "./accessors/basic.js";
|
|
10
12
|
import { installConnectorNodeProxyAccessors } from "./accessors/connector.js";
|
|
11
13
|
import { installLayoutNodeProxyAccessors } from "./accessors/layout.js";
|
|
14
|
+
import { installReactionAccessors } from "./accessors/reactions.js";
|
|
12
15
|
import { installShapeNodeProxyAccessors } from "./accessors/shape.js";
|
|
13
16
|
import { installStickyNodeProxyAccessors, pluginChildren } from "./accessors/sticky.js";
|
|
14
17
|
import { installStrokeNodeProxyAccessors } from "./accessors/strokes.js";
|
|
@@ -18,7 +21,6 @@ import { installTextNodeProxyAccessors } from "./accessors/text/index.js";
|
|
|
18
21
|
import { installVariableModeNodeProxyAccessors } from "./accessors/variables.js";
|
|
19
22
|
import { installVectorNodeProxyAccessors } from "./accessors/vector.js";
|
|
20
23
|
import { installVisualNodeProxyAccessors } from "./accessors/visual.js";
|
|
21
|
-
import { installInstanceOverrideAccessors } from "./overrides.js";
|
|
22
24
|
import { installPluginDataMethods } from "./plugin-data.js";
|
|
23
25
|
import { nodeProxyToJSON } from "./serialization.js";
|
|
24
26
|
import { installShapeWithTextAccessors } from "./shape-with-text.js";
|
|
@@ -31,6 +33,21 @@ const MIXED = Symbol("mixed");
|
|
|
31
33
|
const INTERNAL_ID = Symbol("id");
|
|
32
34
|
const INTERNAL_GRAPH = Symbol("graph");
|
|
33
35
|
const INTERNAL_API = Symbol("api");
|
|
36
|
+
/**
|
|
37
|
+
* How each API loads a page's layers, a host's hook kept off `figma`, which has only Figma's
|
|
38
|
+
* members. Without one every page is in memory.
|
|
39
|
+
*/
|
|
40
|
+
const pageHosts = /* @__PURE__ */ new WeakMap();
|
|
41
|
+
function setPageHost(api, host) {
|
|
42
|
+
pageHosts.set(api, host);
|
|
43
|
+
}
|
|
44
|
+
function loadPage(api, pageId) {
|
|
45
|
+
return pageHosts.get(api)?.load(pageId) ?? Promise.resolve();
|
|
46
|
+
}
|
|
47
|
+
/** The page holding a layer not loaded yet, which loading that page brings in. */
|
|
48
|
+
function pageOfNode(api, nodeId) {
|
|
49
|
+
return pageHosts.get(api)?.pageOfNode?.(nodeId) ?? Promise.resolve(null);
|
|
50
|
+
}
|
|
34
51
|
/** Figma refuses a move that would make a component contain itself. */
|
|
35
52
|
function assertNoComponentCycle(graph, parentId, childId, method) {
|
|
36
53
|
if (createsComponentCycle(graph, childId, parentId)) throw new Error(`in ${method}: Cannot move node. Reparenting would create a component cycle`);
|
|
@@ -51,7 +68,7 @@ var FigmaNodeProxy = class {
|
|
|
51
68
|
};
|
|
52
69
|
if (type === "VECTOR") installVectorNodeProxyAccessors(this, internals, MIXED);
|
|
53
70
|
if (type) installShapeNodeProxyAccessors(this, internals, type);
|
|
54
|
-
if (type === "CANVAS") Object.defineProperty(this, "loadAsync", { value: () =>
|
|
71
|
+
if (type === "CANVAS") Object.defineProperty(this, "loadAsync", { value: () => loadPage(api, id) });
|
|
55
72
|
}
|
|
56
73
|
_update(changes) {
|
|
57
74
|
assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID]);
|
|
@@ -61,6 +78,7 @@ var FigmaNodeProxy = class {
|
|
|
61
78
|
recordInstanceOverride(graph, id, Object.keys(changes));
|
|
62
79
|
}
|
|
63
80
|
_raw() {
|
|
81
|
+
flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID]);
|
|
64
82
|
const n = this[INTERNAL_GRAPH].getNode(this[INTERNAL_ID]);
|
|
65
83
|
if (!n) throw new Error(`Node ${this[INTERNAL_ID]} has been removed`);
|
|
66
84
|
return n;
|
|
@@ -144,6 +162,7 @@ var FigmaNodeProxy = class {
|
|
|
144
162
|
return this[INTERNAL_API].wrapNode(n.parentId);
|
|
145
163
|
}
|
|
146
164
|
get children() {
|
|
165
|
+
flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID]);
|
|
147
166
|
return pluginChildren(this[INTERNAL_GRAPH], this[INTERNAL_ID]).map((c) => this[INTERNAL_API].wrapNode(c.id));
|
|
148
167
|
}
|
|
149
168
|
appendChild(child) {
|
|
@@ -242,6 +261,7 @@ installTextNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals, MIXED);
|
|
|
242
261
|
installTextRangeMethods(FigmaNodeProxy.prototype, proxyInternals, MIXED);
|
|
243
262
|
installLayoutNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals);
|
|
244
263
|
installVariableModeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals);
|
|
264
|
+
installReactionAccessors(FigmaNodeProxy.prototype, proxyInternals);
|
|
245
265
|
installPluginDataMethods(FigmaNodeProxy.prototype, proxyInternals);
|
|
246
266
|
installComponentPropertyAccessors(FigmaNodeProxy.prototype, proxyInternals);
|
|
247
267
|
installInstanceOverrideAccessors(FigmaNodeProxy.prototype, proxyInternals);
|
|
@@ -249,6 +269,6 @@ installSlotAccessors(FigmaNodeProxy.prototype, proxyInternals);
|
|
|
249
269
|
installDevStatusAccessors(FigmaNodeProxy.prototype, proxyInternals);
|
|
250
270
|
installShapeWithTextAccessors(FigmaNodeProxy.prototype, proxyInternals);
|
|
251
271
|
//#endregion
|
|
252
|
-
export { FigmaNodeProxy, INTERNAL_API, INTERNAL_GRAPH, INTERNAL_ID, MIXED };
|
|
272
|
+
export { FigmaNodeProxy, INTERNAL_API, INTERNAL_GRAPH, INTERNAL_ID, MIXED, loadPage, pageOfNode, setPageHost };
|
|
253
273
|
|
|
254
274
|
//# sourceMappingURL=proxy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","names":["Traversal.findAll","Traversal.findOne","Traversal.findChild","Traversal.findChildren","Traversal.findAllWithCriteria"],"sources":["../../src/figma-api/proxy.ts"],"sourcesContent":["import type {\n ArcData,\n HyperlinkTarget,\n SceneGraph,\n SceneNode,\n NodeType,\n LayoutGrid,\n LayoutMode\n} from '@pairdraw/scene-graph'\nimport { attachedConnectors } from '@pairdraw/scene-graph/connectors'\nimport type { GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'\nimport { createsComponentCycle, recordInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport type { ShapeWithTextType } from '@pairdraw/scene-graph/shape-with-text'\nimport { slotPropertyId } from '@pairdraw/scene-graph/slots'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport type { FigmaEffect } from '#core/figma-api/effects'\n\nimport { prepareFollowedFieldEdit, fitGroupsAround } from './accessor-utils'\nimport { installBasicNodeProxyAccessors } from './accessors/basic'\nimport { installConnectorNodeProxyAccessors } from './accessors/connector'\nimport { installLayoutNodeProxyAccessors } from './accessors/layout'\nimport { installShapeNodeProxyAccessors } from './accessors/shape'\nimport { installStickyNodeProxyAccessors, pluginChildren } from './accessors/sticky'\nimport { installStrokeNodeProxyAccessors } from './accessors/strokes'\nimport { installTextNodeProxyAccessors } from './accessors/text'\nimport { installTextRangeMethods, type TextRangeMethods } from './accessors/text/ranges'\nimport {\n installVariableModeNodeProxyAccessors,\n type VariableNodeMembers\n} from './accessors/variables'\nimport {\n installVectorNodeProxyAccessors,\n type FigmaVectorNetwork,\n type FigmaVectorPath\n} from './accessors/vector'\nimport { installVisualNodeProxyAccessors } from './accessors/visual'\nimport { installComponentPropertyAccessors } from './components'\nimport { installDevStatusAccessors, type FigmaDevStatusValue } from './dev-status'\nimport type { FigmaFontName } from './fonts/names'\nimport type { FigmaFrameNode, FigmaInstanceNode } from './node-types'\nimport { installInstanceOverrideAccessors, type FigmaInstanceOverride } from './overrides'\nimport { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from './paints'\nimport { installPluginDataMethods, type PluginDataMethods } from './plugin-data'\nimport { nodeProxyToJSON } from './serialization'\nimport { installShapeWithTextAccessors } from './shape-with-text'\nimport { installSlotAccessors, prepareSlotMove, prepareSlotRemoval } from './slots'\nimport type { FigmaLetterSpacing, FigmaLineHeight } from './text'\nimport * as TextProxy from './text'\nimport { containerTransform, setContainerTransform } from './transform'\nimport * as Traversal from './traversal'\nimport type { FigmaTransform } from './types'\n\nconst MIXED = Symbol('mixed')\n\nexport type { FigmaFont, FigmaFontName } from './fonts/names'\n\nexport const INTERNAL_ID = Symbol('id')\nexport const INTERNAL_GRAPH = Symbol('graph')\nexport const INTERNAL_API = Symbol('api')\n\nexport interface NodeProxyHost {\n wrapNode(id: string): FigmaNodeProxy\n readonly currentPageId: string\n /** How groups and booleans refit; booleans size to their result when a renderer is attached. */\n readonly groupFitOptions: GroupFitOptions\n}\n\nexport { MIXED }\n\n/** Figma refuses a move that would make a component contain itself. */\nfunction assertNoComponentCycle(\n graph: SceneGraph,\n parentId: string,\n childId: string,\n method: 'appendChild' | 'insertChild'\n): void {\n if (createsComponentCycle(graph, childId, parentId))\n throw new Error(`in ${method}: Cannot move node. Reparenting would create a component cycle`)\n}\n\nexport class FigmaNodeProxy {\n [INTERNAL_ID]: string;\n [INTERNAL_GRAPH]: SceneGraph;\n [INTERNAL_API]: NodeProxyHost\n\n declare readonly id: string\n /** A slot frame reads as `'SLOT'`, as Figma's `SlotNode` does. */\n declare readonly type: NodeType | 'SLOT'\n declare name: string\n declare readonly removed: boolean\n declare x: number\n declare y: number\n declare readonly width: number\n declare readonly height: number\n declare rotation: number\n declare relativeTransform: FigmaTransform\n declare resize: (width: number, height: number) => void\n declare resizeWithoutConstraints: (width: number, height: number) => void\n declare rescale: (scale: number) => void\n declare readonly absoluteTransform: FigmaTransform\n declare readonly absoluteBoundingBox: Rect\n declare readonly absoluteRenderBounds: Rect | null\n\n declare fills: readonly FigmaPaint[] | symbol\n declare strokes: readonly FigmaPaint[]\n declare effects: readonly FigmaEffect[]\n declare opacity: number\n declare visible: boolean\n declare locked: boolean\n declare devStatus: FigmaDevStatusValue | undefined\n declare blendMode: string\n declare clipsContent: boolean\n declare cornerRadius: number | typeof MIXED\n declare topLeftRadius: number\n declare topRightRadius: number\n declare bottomLeftRadius: number\n declare bottomRightRadius: number\n declare cornerSmoothing: number\n\n declare layoutMode: LayoutMode\n declare layoutGrids: readonly LayoutGrid[]\n declare primaryAxisAlignItems: string\n declare counterAxisAlignItems: string\n declare itemSpacing: number\n declare counterAxisSpacing: number\n declare paddingTop: number\n declare paddingRight: number\n declare paddingBottom: number\n declare paddingLeft: number\n declare layoutWrap: string\n declare primaryAxisSizingMode: string\n declare counterAxisSizingMode: string\n declare counterAxisAlignContent: string\n declare itemReverseZIndex: boolean\n declare strokesIncludedInLayout: boolean\n declare layoutPositioning: string\n declare layoutGrow: number\n declare layoutAlign: string\n declare layoutSizingHorizontal: string\n declare layoutSizingVertical: string\n declare constraints: { horizontal: string; vertical: string }\n declare minWidth: number | null\n declare maxWidth: number | null\n declare minHeight: number | null\n declare maxHeight: number | null\n declare readonly targetAspectRatio: Vector | null\n /** @deprecated Figma's alias for whether `targetAspectRatio` is set. */\n declare constrainProportions: boolean\n declare lockAspectRatio: () => void\n declare unlockAspectRatio: () => void\n declare pointCount: number\n declare innerRadius: number\n declare arcData: Readonly<ArcData>\n declare vectorPaths: readonly FigmaVectorPath[]\n declare vectorNetwork: FigmaVectorNetwork\n declare setVectorNetworkAsync: (vectorNetwork: FigmaVectorNetwork) => Promise<void>\n declare handleMirroring: SceneNode['handleMirroring'] | typeof MIXED\n declare getPluginData: PluginDataMethods['getPluginData']\n declare setPluginData: PluginDataMethods['setPluginData']\n declare getPluginDataKeys: PluginDataMethods['getPluginDataKeys']\n declare getSharedPluginData: PluginDataMethods['getSharedPluginData']\n declare setSharedPluginData: PluginDataMethods['setSharedPluginData']\n declare getSharedPluginDataKeys: PluginDataMethods['getSharedPluginDataKeys']\n declare readonly explicitVariableModes: VariableNodeMembers['explicitVariableModes']\n declare readonly resolvedVariableModes: VariableNodeMembers['resolvedVariableModes']\n declare setExplicitVariableModeForCollection: VariableNodeMembers['setExplicitVariableModeForCollection']\n declare clearExplicitVariableModeForCollection: VariableNodeMembers['clearExplicitVariableModeForCollection']\n declare readonly boundVariables: VariableNodeMembers['boundVariables']\n declare setBoundVariable: VariableNodeMembers['setBoundVariable']\n declare readonly overrides: FigmaInstanceOverride[] | undefined\n /** A sticky note's body or a shape's label, a sticky's author line, and whether it is wide. */\n declare readonly text: FigmaNodeProxy | undefined\n declare readonly authorName: string | undefined\n declare authorVisible: boolean | undefined\n declare isWideWidth: boolean | undefined\n declare shapeType: ShapeWithTextType | undefined\n /** On pages alone, as in Figma. */\n declare loadAsync: () => Promise<void>\n declare resetOverrides: () => void\n\n declare strokeWeight: number\n declare strokeAlign: string\n declare dashPattern: readonly number[]\n declare strokeCap: string\n declare strokeJoin: string\n declare strokeMiterLimit: number\n declare strokeTopWeight: number\n declare strokeBottomWeight: number\n declare strokeLeftWeight: number\n declare strokeRightWeight: number\n\n declare characters: string\n declare fontSize: number | symbol\n declare fontName: FigmaFontName | symbol\n declare fontWeight: number | symbol\n declare textAlignHorizontal: string\n declare textAlignVertical: string\n declare textAutoResize: string\n declare letterSpacing: FigmaLetterSpacing | symbol\n declare lineHeight: FigmaLineHeight | symbol\n declare textCase: SceneNode['textCase'] | symbol\n declare hyperlink: HyperlinkTarget | null | symbol\n declare textStyleId: string | symbol\n declare fillStyleId: string | symbol\n declare textDecoration: SceneNode['textDecoration'] | symbol\n declare maxLines: number | null\n declare listSpacing: number | symbol\n declare paragraphSpacing: number | symbol\n declare paragraphIndent: number | symbol\n declare hangingList: boolean\n declare textTruncation: string\n declare autoRename: boolean\n\n // Per-character and per-paragraph methods: accessors/text/ranges.ts.\n declare getStyledTextSegments: TextRangeMethods['getStyledTextSegments']\n declare getRangeAllFontNames: TextRangeMethods['getRangeAllFontNames']\n declare getRangeFontSize: TextRangeMethods['getRangeFontSize']\n declare setRangeFontSize: TextRangeMethods['setRangeFontSize']\n declare getRangeFontName: TextRangeMethods['getRangeFontName']\n declare setRangeFontName: TextRangeMethods['setRangeFontName']\n declare getRangeFontWeight: TextRangeMethods['getRangeFontWeight']\n declare getRangeFills: TextRangeMethods['getRangeFills']\n declare setRangeFills: TextRangeMethods['setRangeFills']\n declare getRangeLetterSpacing: TextRangeMethods['getRangeLetterSpacing']\n declare setRangeLetterSpacing: TextRangeMethods['setRangeLetterSpacing']\n declare getRangeLineHeight: TextRangeMethods['getRangeLineHeight']\n declare setRangeLineHeight: TextRangeMethods['setRangeLineHeight']\n declare getRangeTextDecoration: TextRangeMethods['getRangeTextDecoration']\n declare setRangeTextDecoration: TextRangeMethods['setRangeTextDecoration']\n declare getRangeTextDecorationStyle: TextRangeMethods['getRangeTextDecorationStyle']\n declare setRangeTextDecorationStyle: TextRangeMethods['setRangeTextDecorationStyle']\n declare getRangeTextDecorationOffset: TextRangeMethods['getRangeTextDecorationOffset']\n declare setRangeTextDecorationOffset: TextRangeMethods['setRangeTextDecorationOffset']\n declare getRangeTextDecorationThickness: TextRangeMethods['getRangeTextDecorationThickness']\n declare setRangeTextDecorationThickness: TextRangeMethods['setRangeTextDecorationThickness']\n declare getRangeTextDecorationColor: TextRangeMethods['getRangeTextDecorationColor']\n declare setRangeTextDecorationColor: TextRangeMethods['setRangeTextDecorationColor']\n declare getRangeTextDecorationSkipInk: TextRangeMethods['getRangeTextDecorationSkipInk']\n declare setRangeTextDecorationSkipInk: TextRangeMethods['setRangeTextDecorationSkipInk']\n declare getRangeOpenTypeFeatures: TextRangeMethods['getRangeOpenTypeFeatures']\n declare getRangeListOptions: TextRangeMethods['getRangeListOptions']\n declare setRangeListOptions: TextRangeMethods['setRangeListOptions']\n declare getRangeIndentation: TextRangeMethods['getRangeIndentation']\n declare setRangeIndentation: TextRangeMethods['setRangeIndentation']\n declare getRangeListSpacing: TextRangeMethods['getRangeListSpacing']\n declare setRangeListSpacing: TextRangeMethods['setRangeListSpacing']\n declare getRangeParagraphSpacing: TextRangeMethods['getRangeParagraphSpacing']\n declare setRangeParagraphSpacing: TextRangeMethods['setRangeParagraphSpacing']\n declare getRangeParagraphIndent: TextRangeMethods['getRangeParagraphIndent']\n declare setRangeParagraphIndent: TextRangeMethods['setRangeParagraphIndent']\n declare getRangeTextCase: TextRangeMethods['getRangeTextCase']\n declare setRangeTextCase: TextRangeMethods['setRangeTextCase']\n declare getRangeHyperlink: TextRangeMethods['getRangeHyperlink']\n declare setRangeHyperlink: TextRangeMethods['setRangeHyperlink']\n declare getRangeTextStyleId: TextRangeMethods['getRangeTextStyleId']\n declare setRangeTextStyleId: TextRangeMethods['setRangeTextStyleId']\n declare setRangeTextStyleIdAsync: TextRangeMethods['setRangeTextStyleIdAsync']\n declare getRangeFillStyleId: TextRangeMethods['getRangeFillStyleId']\n declare setRangeFillStyleId: TextRangeMethods['setRangeFillStyleId']\n declare setRangeFillStyleIdAsync: TextRangeMethods['setRangeFillStyleIdAsync']\n declare getRangeBoundVariable: TextRangeMethods['getRangeBoundVariable']\n declare setRangeBoundVariable: TextRangeMethods['setRangeBoundVariable']\n\n constructor(id: string, graph: SceneGraph, api: NodeProxyHost) {\n this[INTERNAL_ID] = id\n this[INTERNAL_GRAPH] = graph\n this[INTERNAL_API] = api\n const type = graph.getNode(id)?.type\n const internals = { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API }\n if (type === 'VECTOR') installVectorNodeProxyAccessors(this, internals, MIXED)\n if (type) installShapeNodeProxyAccessors(this, internals, type)\n // Figma loads a page's layers on demand in dynamic-page mode and has `loadAsync` on pages\n // alone; every page here is already loaded.\n if (type === 'CANVAS')\n Object.defineProperty(this, 'loadAsync', { value: () => Promise.resolve() })\n }\n\n private _update(changes: Partial<SceneNode>): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const graph = this[INTERNAL_GRAPH]\n const id = this[INTERNAL_ID]\n graph.updateNode(id, changes)\n recordInstanceOverride(graph, id, Object.keys(changes))\n }\n\n private _raw(): SceneNode {\n const n = this[INTERNAL_GRAPH].getNode(this[INTERNAL_ID])\n if (!n) throw new Error(`Node ${this[INTERNAL_ID]} has been removed`)\n return n\n }\n\n insertCharacters(\n start: number,\n characters: string,\n useStyle: TextProxy.InsertStyleSource = 'BEFORE'\n ): void {\n TextProxy.insertCharacters(this[INTERNAL_GRAPH], this._raw(), start, characters, useStyle)\n }\n\n deleteCharacters(start: number, end: number): void {\n TextProxy.deleteCharacters(this[INTERNAL_GRAPH], this._raw(), start, end)\n }\n\n get isMask(): boolean {\n return this._raw().isMask\n }\n\n set isMask(v: boolean) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'isMask', 'is-mask')\n this._update({ isMask: v })\n // A mask limits what its group spans.\n fitGroupsAround(this[INTERNAL_GRAPH], this._raw().parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n get maskType(): string {\n return this._raw().maskType\n }\n\n set maskType(v: string) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'maskType', 'mask-type')\n this._update({ maskType: v as SceneNode['maskType'] })\n }\n\n // --- UI state ---\n\n get expanded(): boolean {\n return this._raw().expanded\n }\n\n set expanded(v: boolean) {\n this._update({ expanded: v })\n }\n\n // --- Components ---\n\n get backgrounds(): readonly FigmaPaint[] {\n // A page draws its background colour's alpha times the paint's opacity, which Figma reads as\n // the opacity alone.\n return Object.freeze(\n getPageBackgrounds(this._raw()).map((paint) =>\n toFigmaPaint({ ...paint, opacity: paint.opacity * paint.color.a })\n )\n )\n }\n\n set backgrounds(value: readonly FigmaPaint[]) {\n const fills = parseFigmaPaints(value, 'set_backgrounds', 'backgrounds')\n setPageBackgrounds(this[INTERNAL_GRAPH], this._raw(), fills)\n }\n\n /** The async form Figma requires in dynamic-page mode; same result as mainComponent. */\n async getMainComponentAsync(): Promise<FigmaNodeProxy | null> {\n return this.mainComponent\n }\n\n get mainComponent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.componentId) return null\n const comp = this[INTERNAL_GRAPH].getNode(n.componentId)\n if (!comp) return null\n return this[INTERNAL_API].wrapNode(comp.id)\n }\n\n createInstance(): FigmaInstanceNode {\n const n = this._raw()\n if (n.type !== 'COMPONENT') throw new Error('createInstance() can only be called on components')\n const pageId = this[INTERNAL_API].currentPageId\n const inst = this[INTERNAL_GRAPH].createInstance(n.id, pageId)\n if (!inst) throw new Error('Failed to create instance')\n // `wrapNode` cannot know the node's type; this one just built an instance.\n return this[INTERNAL_API].wrapNode(inst.id) as FigmaInstanceNode\n }\n\n /** Turns this instance into a frame that keeps its current content, like Figma's. */\n detachInstance(): FigmaFrameNode {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('detachInstance() can only be called on instances')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].detachInstance(n.id)\n // The node is a frame once detached, which `wrapNode` has no way to tell.\n return this[INTERNAL_API].wrapNode(n.id) as FigmaFrameNode\n }\n\n /** Points this instance at another component, as Figma's swapComponent does. */\n swapComponent(component: FigmaNodeProxy): void {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('swapComponent() can only be called on instances')\n const target = this[INTERNAL_GRAPH].getNode(component[INTERNAL_ID])\n if (target?.type !== 'COMPONENT') throw new Error('swapComponent() needs a component')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].swapInstanceComponent(n.id, target.id)\n }\n\n // --- Tree ---\n\n get parent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.parentId) return null\n return this[INTERNAL_API].wrapNode(n.parentId)\n }\n\n get children(): FigmaNodeProxy[] {\n return pluginChildren(this[INTERNAL_GRAPH], this[INTERNAL_ID]).map((c) =>\n this[INTERNAL_API].wrapNode(c.id)\n )\n }\n\n appendChild(child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'appendChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'appendChild')\n this._reparentAndFit(child[INTERNAL_ID])\n }\n\n /**\n * Moves a child here as Figma does: it keeps its transform into its container, so its `x`, `y`,\n * and rotation stay and it moves with its new parent. The groups it left and joined refit.\n */\n private _reparentAndFit(childId: string): void {\n const scene = this[INTERNAL_GRAPH]\n const child = scene.getNode(childId)\n if (!child) return\n const previousParentId = child.parentId\n const transform = containerTransform(child, scene)\n scene.reparentNode(childId, this[INTERNAL_ID])\n setContainerTransform(scene, child, transform)\n const options = this[INTERNAL_API].groupFitOptions\n fitGroupsAround(scene, previousParentId, options)\n fitGroupsAround(scene, this[INTERNAL_ID], options)\n }\n\n insertChild(index: number, child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'insertChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'insertChild')\n this._reparentAndFit(child[INTERNAL_ID])\n this[INTERNAL_GRAPH].insertChildAt(child[INTERNAL_ID], this[INTERNAL_ID], index)\n }\n\n clone(): FigmaNodeProxy {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this._raw()\n const parentId = n.parentId ?? this[INTERNAL_API].currentPageId\n const cloned = this[INTERNAL_GRAPH].cloneTree(this[INTERNAL_ID], parentId)\n if (!cloned) throw new Error(`Failed to clone node ${this[INTERNAL_ID]}`)\n // A slot's copy is a plain frame: the slot binding belongs to the original alone.\n if (slotPropertyId(cloned))\n this[INTERNAL_GRAPH].updateNode(cloned.id, {\n componentPropertyReferences: cloned.componentPropertyReferences.filter(\n (reference) => reference.field !== 'SLOT_CONTENT'\n )\n })\n return this[INTERNAL_API].wrapNode(cloned.id)\n }\n\n remove(): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n prepareSlotRemoval(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const parentId = this._raw().parentId\n // Connectors go with a layer they attach to, as Figma removes them.\n const attached = attachedConnectors(this[INTERNAL_GRAPH], [this[INTERNAL_ID]])\n this[INTERNAL_GRAPH].deleteNode(this[INTERNAL_ID])\n for (const connector of attached) this[INTERNAL_GRAPH].deleteNode(connector.id)\n fitGroupsAround(this[INTERNAL_GRAPH], parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n findAll(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findAll(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findOne(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findOne(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findChild(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findChild(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findChildren(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findChildren(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findAllWithCriteria(criteria: { types?: string[] }): FigmaNodeProxy[] {\n return Traversal.findAllWithCriteria(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n criteria\n )\n }\n\n // --- Serialization ---\n\n toJSON(maxDepth?: number, currentDepth = 0): Record<string, unknown> {\n return nodeProxyToJSON(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n maxDepth,\n currentDepth\n )\n }\n\n toString(): string {\n const n = this._raw()\n return `[${n.type} \"${n.name}\" ${n.id}]`\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n}\n\ninstallBasicNodeProxyAccessors(FigmaNodeProxy.prototype, {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n})\n\ninstallVisualNodeProxyAccessors(\n FigmaNodeProxy.prototype,\n { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API },\n MIXED\n)\n\nconst proxyInternals = {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n}\n\ninstallStrokeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallStickyNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallConnectorNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallTextNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallTextRangeMethods(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallLayoutNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallVariableModeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallPluginDataMethods(FigmaNodeProxy.prototype, proxyInternals)\ninstallComponentPropertyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallInstanceOverrideAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallSlotAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallDevStatusAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallShapeWithTextAccessors(FigmaNodeProxy.prototype, proxyInternals)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAM,QAAQ,OAAO,OAAO;AAI5B,MAAa,cAAc,OAAO,IAAI;AACtC,MAAa,iBAAiB,OAAO,OAAO;AAC5C,MAAa,eAAe,OAAO,KAAK;;AAYxC,SAAS,uBACP,OACA,UACA,SACA,QACM;CACN,IAAI,sBAAsB,OAAO,SAAS,QAAQ,GAChD,MAAM,IAAI,MAAM,MAAM,OAAO,+DAA+D;AAChG;AAEA,IAAa,iBAAb,MAA4B;CAC1B,CAAC;CACD,CAAC;CACD,CAAC;CAoLD,YAAY,IAAY,OAAmB,KAAoB;EAC7D,KAAK,eAAe;EACpB,KAAK,kBAAkB;EACvB,KAAK,gBAAgB;EACrB,MAAM,OAAO,MAAM,QAAQ,EAAE,CAAC,EAAE;EAChC,MAAM,YAAY;GAAE,IAAI;GAAa,OAAO;GAAgB,KAAK;EAAa;EAC9E,IAAI,SAAS,UAAU,gCAAgC,MAAM,WAAW,KAAK;EAC7E,IAAI,MAAM,+BAA+B,M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+
{"version":3,"file":"proxy.js","names":["Traversal.findAll","Traversal.findOne","Traversal.findChild","Traversal.findChildren","Traversal.findAllWithCriteria"],"sources":["../../src/figma-api/proxy.ts"],"sourcesContent":["import type {\n ArcData,\n HyperlinkTarget,\n SceneGraph,\n SceneNode,\n NodeType,\n LayoutGrid,\n LayoutMode\n} from '@pairdraw/scene-graph'\nimport { attachedConnectors } from '@pairdraw/scene-graph/connectors'\nimport type { GroupFitOptions } from '@pairdraw/scene-graph/group-bounds'\nimport { createsComponentCycle, recordInstanceOverride } from '@pairdraw/scene-graph/instances'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport type { ShapeWithTextType } from '@pairdraw/scene-graph/shape-with-text'\nimport { slotPropertyId } from '@pairdraw/scene-graph/slots'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport type { FigmaEffect } from '#core/figma-api/effects'\n\nimport { prepareFollowedFieldEdit, fitGroupsAround } from './accessor-utils'\nimport { installBasicNodeProxyAccessors } from './accessors/basic'\nimport { installConnectorNodeProxyAccessors } from './accessors/connector'\nimport { installLayoutNodeProxyAccessors } from './accessors/layout'\nimport { installReactionAccessors } from './accessors/reactions'\nimport { installShapeNodeProxyAccessors } from './accessors/shape'\nimport { installStickyNodeProxyAccessors, pluginChildren } from './accessors/sticky'\nimport { installStrokeNodeProxyAccessors } from './accessors/strokes'\nimport { installTextNodeProxyAccessors } from './accessors/text'\nimport { installTextRangeMethods, type TextRangeMethods } from './accessors/text/ranges'\nimport {\n installVariableModeNodeProxyAccessors,\n type VariableNodeMembers\n} from './accessors/variables'\nimport {\n installVectorNodeProxyAccessors,\n type FigmaVectorNetwork,\n type FigmaVectorPath\n} from './accessors/vector'\nimport { installVisualNodeProxyAccessors } from './accessors/visual'\nimport { installComponentPropertyAccessors } from './components'\nimport { installDevStatusAccessors, type FigmaDevStatusValue } from './dev-status'\nimport type { FigmaFontName } from './fonts/names'\nimport type { FigmaFrameNode, FigmaInstanceNode } from './node-types'\nimport { installInstanceOverrideAccessors, type FigmaInstanceOverride } from './overrides'\nimport { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from './paints'\nimport { flushPendingComponentSync } from './pending-sync'\nimport { installPluginDataMethods, type PluginDataMethods } from './plugin-data'\nimport type { FigmaReaction } from './reactions'\nimport { nodeProxyToJSON } from './serialization'\nimport { installShapeWithTextAccessors } from './shape-with-text'\nimport { installSlotAccessors, prepareSlotMove, prepareSlotRemoval } from './slots'\nimport type { FigmaLetterSpacing, FigmaLineHeight } from './text'\nimport * as TextProxy from './text'\nimport { containerTransform, setContainerTransform } from './transform'\nimport * as Traversal from './traversal'\nimport type { FigmaTransform } from './types'\n\nconst MIXED = Symbol('mixed')\n\nexport type { FigmaFont, FigmaFontName } from './fonts/names'\n\nexport const INTERNAL_ID = Symbol('id')\nexport const INTERNAL_GRAPH = Symbol('graph')\nexport const INTERNAL_API = Symbol('api')\n\n/** How a host loads pages as they are visited; see `FigmaAPIOptions`. */\nexport interface PageHost {\n load: (pageId: string) => Promise<void>\n pageOfNode?: (nodeId: string) => Promise<string | null>\n}\n\n/**\n * How each API loads a page's layers, a host's hook kept off `figma`, which has only Figma's\n * members. Without one every page is in memory.\n */\nconst pageHosts = new WeakMap<NodeProxyHost, PageHost>()\n\nexport function setPageHost(api: NodeProxyHost, host: PageHost): void {\n pageHosts.set(api, host)\n}\n\nexport function loadPage(api: NodeProxyHost, pageId: string): Promise<void> {\n return pageHosts.get(api)?.load(pageId) ?? Promise.resolve()\n}\n\n/** The page holding a layer not loaded yet, which loading that page brings in. */\nexport function pageOfNode(api: NodeProxyHost, nodeId: string): Promise<string | null> {\n return pageHosts.get(api)?.pageOfNode?.(nodeId) ?? Promise.resolve(null)\n}\n\nexport interface NodeProxyHost {\n wrapNode(id: string): FigmaNodeProxy\n readonly currentPageId: string\n /** How groups and booleans refit; booleans size to their result when a renderer is attached. */\n readonly groupFitOptions: GroupFitOptions\n}\n\nexport { MIXED }\n\n/** Figma refuses a move that would make a component contain itself. */\nfunction assertNoComponentCycle(\n graph: SceneGraph,\n parentId: string,\n childId: string,\n method: 'appendChild' | 'insertChild'\n): void {\n if (createsComponentCycle(graph, childId, parentId))\n throw new Error(`in ${method}: Cannot move node. Reparenting would create a component cycle`)\n}\n\nexport class FigmaNodeProxy {\n [INTERNAL_ID]: string;\n [INTERNAL_GRAPH]: SceneGraph;\n [INTERNAL_API]: NodeProxyHost\n\n declare readonly id: string\n /** A slot frame reads as `'SLOT'`, as Figma's `SlotNode` does. */\n declare readonly type: NodeType | 'SLOT'\n declare name: string\n declare readonly removed: boolean\n declare x: number\n declare y: number\n declare readonly width: number\n declare readonly height: number\n declare rotation: number\n declare relativeTransform: FigmaTransform\n declare resize: (width: number, height: number) => void\n declare resizeWithoutConstraints: (width: number, height: number) => void\n declare rescale: (scale: number) => void\n declare readonly absoluteTransform: FigmaTransform\n declare readonly absoluteBoundingBox: Rect\n declare readonly absoluteRenderBounds: Rect | null\n\n declare fills: readonly FigmaPaint[] | symbol\n declare strokes: readonly FigmaPaint[]\n declare effects: readonly FigmaEffect[]\n declare opacity: number\n declare visible: boolean\n declare locked: boolean\n declare devStatus: FigmaDevStatusValue | undefined\n declare blendMode: string\n declare clipsContent: boolean\n declare cornerRadius: number | typeof MIXED\n declare topLeftRadius: number\n declare topRightRadius: number\n declare bottomLeftRadius: number\n declare bottomRightRadius: number\n declare cornerSmoothing: number\n\n declare layoutMode: LayoutMode\n declare layoutGrids: readonly LayoutGrid[]\n declare primaryAxisAlignItems: string\n declare counterAxisAlignItems: string\n declare itemSpacing: number\n declare counterAxisSpacing: number\n declare paddingTop: number\n declare paddingRight: number\n declare paddingBottom: number\n declare paddingLeft: number\n declare layoutWrap: string\n declare primaryAxisSizingMode: string\n declare counterAxisSizingMode: string\n declare counterAxisAlignContent: string\n declare itemReverseZIndex: boolean\n declare strokesIncludedInLayout: boolean\n declare layoutPositioning: string\n declare layoutGrow: number\n declare layoutAlign: string\n declare layoutSizingHorizontal: string\n declare layoutSizingVertical: string\n declare constraints: { horizontal: string; vertical: string }\n declare minWidth: number | null\n declare maxWidth: number | null\n declare minHeight: number | null\n declare maxHeight: number | null\n declare readonly targetAspectRatio: Vector | null\n /** @deprecated Figma's alias for whether `targetAspectRatio` is set. */\n declare constrainProportions: boolean\n declare lockAspectRatio: () => void\n declare unlockAspectRatio: () => void\n declare pointCount: number\n declare innerRadius: number\n declare arcData: Readonly<ArcData>\n declare vectorPaths: readonly FigmaVectorPath[]\n declare vectorNetwork: FigmaVectorNetwork\n declare setVectorNetworkAsync: (vectorNetwork: FigmaVectorNetwork) => Promise<void>\n declare handleMirroring: SceneNode['handleMirroring'] | typeof MIXED\n declare getPluginData: PluginDataMethods['getPluginData']\n declare setPluginData: PluginDataMethods['setPluginData']\n declare getPluginDataKeys: PluginDataMethods['getPluginDataKeys']\n declare getSharedPluginData: PluginDataMethods['getSharedPluginData']\n declare setSharedPluginData: PluginDataMethods['setSharedPluginData']\n declare getSharedPluginDataKeys: PluginDataMethods['getSharedPluginDataKeys']\n declare readonly explicitVariableModes: VariableNodeMembers['explicitVariableModes']\n declare readonly resolvedVariableModes: VariableNodeMembers['resolvedVariableModes']\n declare setExplicitVariableModeForCollection: VariableNodeMembers['setExplicitVariableModeForCollection']\n declare clearExplicitVariableModeForCollection: VariableNodeMembers['clearExplicitVariableModeForCollection']\n declare readonly boundVariables: VariableNodeMembers['boundVariables']\n declare setBoundVariable: VariableNodeMembers['setBoundVariable']\n declare readonly overrides: FigmaInstanceOverride[] | undefined\n /** Prototype connections, in Figma's plugin shape; refused when the play cannot run them. */\n declare reactions: readonly FigmaReaction[]\n /** A sticky note's body or a shape's label, a sticky's author line, and whether it is wide. */\n declare readonly text: FigmaNodeProxy | undefined\n declare readonly authorName: string | undefined\n declare authorVisible: boolean | undefined\n declare isWideWidth: boolean | undefined\n declare shapeType: ShapeWithTextType | undefined\n /** On pages alone, as in Figma. */\n declare loadAsync: () => Promise<void>\n declare resetOverrides: () => void\n\n declare strokeWeight: number\n declare strokeAlign: string\n declare dashPattern: readonly number[]\n declare strokeCap: string\n declare strokeJoin: string\n declare strokeMiterLimit: number\n declare strokeTopWeight: number\n declare strokeBottomWeight: number\n declare strokeLeftWeight: number\n declare strokeRightWeight: number\n\n declare characters: string\n declare fontSize: number | symbol\n declare fontName: FigmaFontName | symbol\n declare fontWeight: number | symbol\n declare textAlignHorizontal: string\n declare textAlignVertical: string\n declare textAutoResize: string\n declare letterSpacing: FigmaLetterSpacing | symbol\n declare lineHeight: FigmaLineHeight | symbol\n declare textCase: SceneNode['textCase'] | symbol\n declare hyperlink: HyperlinkTarget | null | symbol\n declare textStyleId: string | symbol\n declare fillStyleId: string | symbol\n declare textDecoration: SceneNode['textDecoration'] | symbol\n declare maxLines: number | null\n declare listSpacing: number | symbol\n declare paragraphSpacing: number | symbol\n declare paragraphIndent: number | symbol\n declare hangingList: boolean\n declare textTruncation: string\n declare autoRename: boolean\n\n // Per-character and per-paragraph methods: accessors/text/ranges.ts.\n declare getStyledTextSegments: TextRangeMethods['getStyledTextSegments']\n declare getRangeAllFontNames: TextRangeMethods['getRangeAllFontNames']\n declare getRangeFontSize: TextRangeMethods['getRangeFontSize']\n declare setRangeFontSize: TextRangeMethods['setRangeFontSize']\n declare getRangeFontName: TextRangeMethods['getRangeFontName']\n declare setRangeFontName: TextRangeMethods['setRangeFontName']\n declare getRangeFontWeight: TextRangeMethods['getRangeFontWeight']\n declare getRangeFills: TextRangeMethods['getRangeFills']\n declare setRangeFills: TextRangeMethods['setRangeFills']\n declare getRangeLetterSpacing: TextRangeMethods['getRangeLetterSpacing']\n declare setRangeLetterSpacing: TextRangeMethods['setRangeLetterSpacing']\n declare getRangeLineHeight: TextRangeMethods['getRangeLineHeight']\n declare setRangeLineHeight: TextRangeMethods['setRangeLineHeight']\n declare getRangeTextDecoration: TextRangeMethods['getRangeTextDecoration']\n declare setRangeTextDecoration: TextRangeMethods['setRangeTextDecoration']\n declare getRangeTextDecorationStyle: TextRangeMethods['getRangeTextDecorationStyle']\n declare setRangeTextDecorationStyle: TextRangeMethods['setRangeTextDecorationStyle']\n declare getRangeTextDecorationOffset: TextRangeMethods['getRangeTextDecorationOffset']\n declare setRangeTextDecorationOffset: TextRangeMethods['setRangeTextDecorationOffset']\n declare getRangeTextDecorationThickness: TextRangeMethods['getRangeTextDecorationThickness']\n declare setRangeTextDecorationThickness: TextRangeMethods['setRangeTextDecorationThickness']\n declare getRangeTextDecorationColor: TextRangeMethods['getRangeTextDecorationColor']\n declare setRangeTextDecorationColor: TextRangeMethods['setRangeTextDecorationColor']\n declare getRangeTextDecorationSkipInk: TextRangeMethods['getRangeTextDecorationSkipInk']\n declare setRangeTextDecorationSkipInk: TextRangeMethods['setRangeTextDecorationSkipInk']\n declare getRangeOpenTypeFeatures: TextRangeMethods['getRangeOpenTypeFeatures']\n declare getRangeListOptions: TextRangeMethods['getRangeListOptions']\n declare setRangeListOptions: TextRangeMethods['setRangeListOptions']\n declare getRangeIndentation: TextRangeMethods['getRangeIndentation']\n declare setRangeIndentation: TextRangeMethods['setRangeIndentation']\n declare getRangeListSpacing: TextRangeMethods['getRangeListSpacing']\n declare setRangeListSpacing: TextRangeMethods['setRangeListSpacing']\n declare getRangeParagraphSpacing: TextRangeMethods['getRangeParagraphSpacing']\n declare setRangeParagraphSpacing: TextRangeMethods['setRangeParagraphSpacing']\n declare getRangeParagraphIndent: TextRangeMethods['getRangeParagraphIndent']\n declare setRangeParagraphIndent: TextRangeMethods['setRangeParagraphIndent']\n declare getRangeTextCase: TextRangeMethods['getRangeTextCase']\n declare setRangeTextCase: TextRangeMethods['setRangeTextCase']\n declare getRangeHyperlink: TextRangeMethods['getRangeHyperlink']\n declare setRangeHyperlink: TextRangeMethods['setRangeHyperlink']\n declare getRangeTextStyleId: TextRangeMethods['getRangeTextStyleId']\n declare setRangeTextStyleId: TextRangeMethods['setRangeTextStyleId']\n declare setRangeTextStyleIdAsync: TextRangeMethods['setRangeTextStyleIdAsync']\n declare getRangeFillStyleId: TextRangeMethods['getRangeFillStyleId']\n declare setRangeFillStyleId: TextRangeMethods['setRangeFillStyleId']\n declare setRangeFillStyleIdAsync: TextRangeMethods['setRangeFillStyleIdAsync']\n declare getRangeBoundVariable: TextRangeMethods['getRangeBoundVariable']\n declare setRangeBoundVariable: TextRangeMethods['setRangeBoundVariable']\n\n constructor(id: string, graph: SceneGraph, api: NodeProxyHost) {\n this[INTERNAL_ID] = id\n this[INTERNAL_GRAPH] = graph\n this[INTERNAL_API] = api\n const type = graph.getNode(id)?.type\n const internals = { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API }\n if (type === 'VECTOR') installVectorNodeProxyAccessors(this, internals, MIXED)\n if (type) installShapeNodeProxyAccessors(this, internals, type)\n // Figma loads a page's layers on demand in dynamic-page mode and has `loadAsync` on pages\n // alone, as the editor loads a page's layers when it is first visited.\n if (type === 'CANVAS')\n Object.defineProperty(this, 'loadAsync', { value: () => loadPage(api, id) })\n }\n\n private _update(changes: Partial<SceneNode>): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const graph = this[INTERNAL_GRAPH]\n const id = this[INTERNAL_ID]\n graph.updateNode(id, changes)\n recordInstanceOverride(graph, id, Object.keys(changes))\n }\n\n private _raw(): SceneNode {\n flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this[INTERNAL_GRAPH].getNode(this[INTERNAL_ID])\n if (!n) throw new Error(`Node ${this[INTERNAL_ID]} has been removed`)\n return n\n }\n\n insertCharacters(\n start: number,\n characters: string,\n useStyle: TextProxy.InsertStyleSource = 'BEFORE'\n ): void {\n TextProxy.insertCharacters(this[INTERNAL_GRAPH], this._raw(), start, characters, useStyle)\n }\n\n deleteCharacters(start: number, end: number): void {\n TextProxy.deleteCharacters(this[INTERNAL_GRAPH], this._raw(), start, end)\n }\n\n get isMask(): boolean {\n return this._raw().isMask\n }\n\n set isMask(v: boolean) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'isMask', 'is-mask')\n this._update({ isMask: v })\n // A mask limits what its group spans.\n fitGroupsAround(this[INTERNAL_GRAPH], this._raw().parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n get maskType(): string {\n return this._raw().maskType\n }\n\n set maskType(v: string) {\n prepareFollowedFieldEdit(this[INTERNAL_GRAPH], this._raw(), 'maskType', 'mask-type')\n this._update({ maskType: v as SceneNode['maskType'] })\n }\n\n // --- UI state ---\n\n get expanded(): boolean {\n return this._raw().expanded\n }\n\n set expanded(v: boolean) {\n this._update({ expanded: v })\n }\n\n // --- Components ---\n\n get backgrounds(): readonly FigmaPaint[] {\n // A page draws its background colour's alpha times the paint's opacity, which Figma reads as\n // the opacity alone.\n return Object.freeze(\n getPageBackgrounds(this._raw()).map((paint) =>\n toFigmaPaint({ ...paint, opacity: paint.opacity * paint.color.a })\n )\n )\n }\n\n set backgrounds(value: readonly FigmaPaint[]) {\n const fills = parseFigmaPaints(value, 'set_backgrounds', 'backgrounds')\n setPageBackgrounds(this[INTERNAL_GRAPH], this._raw(), fills)\n }\n\n /** The async form Figma requires in dynamic-page mode; same result as mainComponent. */\n async getMainComponentAsync(): Promise<FigmaNodeProxy | null> {\n return this.mainComponent\n }\n\n get mainComponent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.componentId) return null\n const comp = this[INTERNAL_GRAPH].getNode(n.componentId)\n if (!comp) return null\n return this[INTERNAL_API].wrapNode(comp.id)\n }\n\n createInstance(): FigmaInstanceNode {\n const n = this._raw()\n if (n.type !== 'COMPONENT') throw new Error('createInstance() can only be called on components')\n const pageId = this[INTERNAL_API].currentPageId\n const inst = this[INTERNAL_GRAPH].createInstance(n.id, pageId)\n if (!inst) throw new Error('Failed to create instance')\n // `wrapNode` cannot know the node's type; this one just built an instance.\n return this[INTERNAL_API].wrapNode(inst.id) as FigmaInstanceNode\n }\n\n /** Turns this instance into a frame that keeps its current content, like Figma's. */\n detachInstance(): FigmaFrameNode {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('detachInstance() can only be called on instances')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].detachInstance(n.id)\n // The node is a frame once detached, which `wrapNode` has no way to tell.\n return this[INTERNAL_API].wrapNode(n.id) as FigmaFrameNode\n }\n\n /** Points this instance at another component, as Figma's swapComponent does. */\n swapComponent(component: FigmaNodeProxy): void {\n const n = this._raw()\n if (n.type !== 'INSTANCE') throw new Error('swapComponent() can only be called on instances')\n const target = this[INTERNAL_GRAPH].getNode(component[INTERNAL_ID])\n if (target?.type !== 'COMPONENT') throw new Error('swapComponent() needs a component')\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n this[INTERNAL_GRAPH].swapInstanceComponent(n.id, target.id)\n }\n\n // --- Tree ---\n\n get parent(): FigmaNodeProxy | null {\n const n = this._raw()\n if (!n.parentId) return null\n return this[INTERNAL_API].wrapNode(n.parentId)\n }\n\n get children(): FigmaNodeProxy[] {\n flushPendingComponentSync(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n return pluginChildren(this[INTERNAL_GRAPH], this[INTERNAL_ID]).map((c) =>\n this[INTERNAL_API].wrapNode(c.id)\n )\n }\n\n appendChild(child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'appendChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'appendChild')\n this._reparentAndFit(child[INTERNAL_ID])\n }\n\n /**\n * Moves a child here as Figma does: it keeps its transform into its container, so its `x`, `y`,\n * and rotation stay and it moves with its new parent. The groups it left and joined refit.\n */\n private _reparentAndFit(childId: string): void {\n const scene = this[INTERNAL_GRAPH]\n const child = scene.getNode(childId)\n if (!child) return\n const previousParentId = child.parentId\n const transform = containerTransform(child, scene)\n scene.reparentNode(childId, this[INTERNAL_ID])\n setContainerTransform(scene, child, transform)\n const options = this[INTERNAL_API].groupFitOptions\n fitGroupsAround(scene, previousParentId, options)\n fitGroupsAround(scene, this[INTERNAL_ID], options)\n }\n\n insertChild(index: number, child: FigmaNodeProxy): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n assertNodeEditable(this[INTERNAL_GRAPH], child[INTERNAL_ID])\n assertNoComponentCycle(\n this[INTERNAL_GRAPH],\n this[INTERNAL_ID],\n child[INTERNAL_ID],\n 'insertChild'\n )\n prepareSlotMove(this[INTERNAL_GRAPH], this[INTERNAL_ID], child[INTERNAL_ID], 'insertChild')\n this._reparentAndFit(child[INTERNAL_ID])\n this[INTERNAL_GRAPH].insertChildAt(child[INTERNAL_ID], this[INTERNAL_ID], index)\n }\n\n clone(): FigmaNodeProxy {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const n = this._raw()\n const parentId = n.parentId ?? this[INTERNAL_API].currentPageId\n const cloned = this[INTERNAL_GRAPH].cloneTree(this[INTERNAL_ID], parentId)\n if (!cloned) throw new Error(`Failed to clone node ${this[INTERNAL_ID]}`)\n // A slot's copy is a plain frame: the slot binding belongs to the original alone.\n if (slotPropertyId(cloned))\n this[INTERNAL_GRAPH].updateNode(cloned.id, {\n componentPropertyReferences: cloned.componentPropertyReferences.filter(\n (reference) => reference.field !== 'SLOT_CONTENT'\n )\n })\n return this[INTERNAL_API].wrapNode(cloned.id)\n }\n\n remove(): void {\n assertNodeEditable(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n prepareSlotRemoval(this[INTERNAL_GRAPH], this[INTERNAL_ID])\n const parentId = this._raw().parentId\n // Connectors go with a layer they attach to, as Figma removes them.\n const attached = attachedConnectors(this[INTERNAL_GRAPH], [this[INTERNAL_ID]])\n this[INTERNAL_GRAPH].deleteNode(this[INTERNAL_ID])\n for (const connector of attached) this[INTERNAL_GRAPH].deleteNode(connector.id)\n fitGroupsAround(this[INTERNAL_GRAPH], parentId, this[INTERNAL_API].groupFitOptions)\n }\n\n findAll(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findAll(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findOne(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findOne(this[INTERNAL_GRAPH], this[INTERNAL_API], this[INTERNAL_ID], callback)\n }\n\n findChild(callback: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy | null {\n return Traversal.findChild(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findChildren(callback?: (node: FigmaNodeProxy) => boolean): FigmaNodeProxy[] {\n return Traversal.findChildren(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n callback\n )\n }\n\n findAllWithCriteria(criteria: { types?: string[] }): FigmaNodeProxy[] {\n return Traversal.findAllWithCriteria(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n criteria\n )\n }\n\n // --- Serialization ---\n\n toJSON(maxDepth?: number, currentDepth = 0): Record<string, unknown> {\n return nodeProxyToJSON(\n this[INTERNAL_GRAPH],\n this[INTERNAL_API],\n this[INTERNAL_ID],\n maxDepth,\n currentDepth\n )\n }\n\n toString(): string {\n const n = this._raw()\n return `[${n.type} \"${n.name}\" ${n.id}]`\n }\n\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n}\n\ninstallBasicNodeProxyAccessors(FigmaNodeProxy.prototype, {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n})\n\ninstallVisualNodeProxyAccessors(\n FigmaNodeProxy.prototype,\n { id: INTERNAL_ID, graph: INTERNAL_GRAPH, api: INTERNAL_API },\n MIXED\n)\n\nconst proxyInternals = {\n id: INTERNAL_ID,\n graph: INTERNAL_GRAPH,\n api: INTERNAL_API\n}\n\ninstallStrokeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallStickyNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallConnectorNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallTextNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallTextRangeMethods(FigmaNodeProxy.prototype, proxyInternals, MIXED)\ninstallLayoutNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallVariableModeNodeProxyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallReactionAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallPluginDataMethods(FigmaNodeProxy.prototype, proxyInternals)\ninstallComponentPropertyAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallInstanceOverrideAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallSlotAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallDevStatusAccessors(FigmaNodeProxy.prototype, proxyInternals)\ninstallShapeWithTextAccessors(FigmaNodeProxy.prototype, proxyInternals)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,QAAQ,OAAO,OAAO;AAI5B,MAAa,cAAc,OAAO,IAAI;AACtC,MAAa,iBAAiB,OAAO,OAAO;AAC5C,MAAa,eAAe,OAAO,KAAK;;;;;AAYxC,MAAM,4BAAY,IAAI,QAAiC;AAEvD,SAAgB,YAAY,KAAoB,MAAsB;CACpE,UAAU,IAAI,KAAK,IAAI;AACzB;AAEA,SAAgB,SAAS,KAAoB,QAA+B;CAC1E,OAAO,UAAU,IAAI,GAAG,CAAC,EAAE,KAAK,MAAM,KAAK,QAAQ,QAAQ;AAC7D;;AAGA,SAAgB,WAAW,KAAoB,QAAwC;CACrF,OAAO,UAAU,IAAI,GAAG,CAAC,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