@pairdraw/core 0.18.0 → 0.19.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/effects.d.ts +5 -11
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +25 -30
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/labels/hit-test.d.ts +5 -0
- package/dist/canvas/labels/hit-test.d.ts.map +1 -1
- package/dist/canvas/labels/hit-test.js +1 -1
- package/dist/canvas/labels/hit-test.js.map +1 -1
- package/dist/canvas/labels/paragraph-cache.d.ts.map +1 -1
- package/dist/canvas/labels/paragraph-cache.js +3 -2
- package/dist/canvas/labels/paragraph-cache.js.map +1 -1
- package/dist/canvas/labels/selection.js +3 -2
- package/dist/canvas/labels/selection.js.map +1 -1
- package/dist/canvas/labels/style.d.ts +1 -1
- package/dist/canvas/node-edit-overlay.js +2 -2
- package/dist/canvas/node-edit-overlay.js.map +1 -1
- package/dist/canvas/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/selection.d.ts +1 -2
- package/dist/canvas/overlays/selection.d.ts.map +1 -1
- package/dist/canvas/overlays/selection.js +4 -37
- package/dist/canvas/overlays/selection.js.map +1 -1
- package/dist/canvas/region-hatch.js +3 -2
- package/dist/canvas/region-hatch.js.map +1 -1
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +36 -18
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/font-waiters.d.ts +9 -0
- package/dist/canvas/renderer/font-waiters.d.ts.map +1 -0
- package/dist/canvas/renderer/font-waiters.js +26 -0
- package/dist/canvas/renderer/font-waiters.js.map +1 -0
- package/dist/canvas/renderer/fonts.d.ts +4 -2
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +23 -9
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -9
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +4 -5
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -4
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/paints.d.ts.map +1 -1
- package/dist/canvas/renderer/paints.js +0 -6
- package/dist/canvas/renderer/paints.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +20 -2
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/retained-backing.js +4 -4
- package/dist/canvas/renderer/retained-backing.js.map +1 -1
- package/dist/canvas/renderer/state.js +1 -1
- package/dist/canvas/renderer/state.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +2 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +8 -0
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.js +7 -5
- package/dist/canvas/renderer/visual-bounds.js.map +1 -1
- package/dist/canvas/renderer.d.ts +22 -7
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +46 -11
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/rulers.d.ts +8 -1
- package/dist/canvas/rulers.d.ts.map +1 -1
- package/dist/canvas/rulers.js +30 -5
- package/dist/canvas/rulers.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +30 -18
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/shape.js +1 -1
- package/dist/canvas/shadows/shape.js.map +1 -1
- package/dist/canvas/shadows/silhouette.d.ts.map +1 -1
- package/dist/canvas/shadows/silhouette.js +4 -2
- package/dist/canvas/shadows/silhouette.js.map +1 -1
- package/dist/canvas/shadows.d.ts.map +1 -1
- package/dist/canvas/shadows.js +3 -2
- package/dist/canvas/shadows.js.map +1 -1
- package/dist/canvas/text/derived.d.ts +1 -2
- package/dist/canvas/text/derived.d.ts.map +1 -1
- package/dist/canvas/text/derived.js +1 -7
- package/dist/canvas/text/derived.js.map +1 -1
- package/dist/canvas/text/emoji/index.js +1 -1
- package/dist/canvas/text/emoji/raster.d.ts.map +1 -1
- package/dist/canvas/text/emoji/raster.js +14 -10
- package/dist/canvas/text/emoji/raster.js.map +1 -1
- package/dist/canvas/text/font-families.d.ts.map +1 -1
- package/dist/canvas/text/font-families.js +5 -2
- package/dist/canvas/text/font-families.js.map +1 -1
- package/dist/canvas/text/index.d.ts +1 -3
- package/dist/canvas/text/index.d.ts.map +1 -1
- package/dist/canvas/text/index.js +1 -8
- package/dist/canvas/text/index.js.map +1 -1
- package/dist/canvas/text/layout/build.d.ts.map +1 -1
- package/dist/canvas/text/layout/build.js +25 -9
- package/dist/canvas/text/layout/build.js.map +1 -1
- package/dist/canvas/text/layout/index.d.ts.map +1 -1
- package/dist/canvas/text/layout/index.js +8 -4
- package/dist/canvas/text/layout/index.js.map +1 -1
- package/dist/canvas/text/layout/lines.js +5 -3
- package/dist/canvas/text/layout/lines.js.map +1 -1
- package/dist/canvas/text/paragraph/index.d.ts +5 -0
- package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/index.js +16 -7
- package/dist/canvas/text/paragraph/index.js.map +1 -1
- package/dist/canvas/text/paragraph/inputs.d.ts +1 -1
- package/dist/canvas/text/paragraph/inputs.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/inputs.js +9 -2
- package/dist/canvas/text/paragraph/inputs.js.map +1 -1
- package/dist/canvas/text/placed.js +1 -1
- package/dist/canvas/text/shape.d.ts +4 -3
- package/dist/canvas/text/shape.d.ts.map +1 -1
- package/dist/canvas/text/shape.js +9 -22
- package/dist/canvas/text/shape.js.map +1 -1
- package/dist/constants.d.ts +6 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -2
- package/dist/constants.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +1 -0
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/frames.d.ts +4 -3
- package/dist/editor/bridges/frames.d.ts.map +1 -1
- package/dist/editor/bridges/frames.js +6 -4
- package/dist/editor/bridges/frames.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -0
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/bridges/structure.js +1 -0
- package/dist/editor/bridges/structure.js.map +1 -1
- package/dist/editor/clipboard/detach.js +2 -2
- package/dist/editor/clipboard/detach.js.map +1 -1
- package/dist/editor/clipboard/paste/properties.js +1 -1
- package/dist/editor/clipboard/paste/target.js +2 -2
- package/dist/editor/clipboard/paste/target.js.map +1 -1
- package/dist/editor/clipboard/snapshot.d.ts +3 -0
- package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
- package/dist/editor/clipboard/snapshot.js +2 -0
- package/dist/editor/clipboard/snapshot.js.map +1 -1
- package/dist/editor/clipboard/variables.d.ts.map +1 -1
- package/dist/editor/clipboard/variables.js +14 -1
- package/dist/editor/clipboard/variables.js.map +1 -1
- package/dist/editor/clipboard.d.ts +1 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +122 -16
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/component-sync.d.ts +10 -1
- package/dist/editor/component-sync.d.ts.map +1 -1
- package/dist/editor/component-sync.js +25 -8
- package/dist/editor/component-sync.js.map +1 -1
- package/dist/editor/components/authoring/text-edit.d.ts.map +1 -1
- package/dist/editor/components/authoring/text-edit.js +11 -2
- package/dist/editor/components/authoring/text-edit.js.map +1 -1
- package/dist/editor/components/authoring/visibility-edit.d.ts.map +1 -1
- package/dist/editor/components/authoring/visibility-edit.js +7 -3
- package/dist/editor/components/authoring/visibility-edit.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +37 -7
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/properties.d.ts.map +1 -1
- package/dist/editor/components/properties.js +3 -0
- package/dist/editor/components/properties.js.map +1 -1
- package/dist/editor/components/slots/authoring.js +2 -1
- package/dist/editor/components/slots/authoring.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/create.d.ts +17 -3
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +43 -6
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/guides.d.ts.map +1 -1
- package/dist/editor/guides.js +20 -13
- package/dist/editor/guides.js.map +1 -1
- package/dist/editor/history/document-change.d.ts +19 -3
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +94 -8
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +56 -12
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/position.js +1 -4
- package/dist/editor/history/position.js.map +1 -1
- package/dist/editor/history/sources.d.ts +14 -0
- package/dist/editor/history/sources.d.ts.map +1 -0
- package/dist/editor/history/sources.js +24 -0
- package/dist/editor/history/sources.js.map +1 -0
- package/dist/editor/index.d.ts +2 -2
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +16 -1
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/node-preview.d.ts.map +1 -1
- package/dist/editor/node-preview.js +26 -7
- package/dist/editor/node-preview.js.map +1 -1
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +33 -10
- package/dist/editor/nodes.js.map +1 -1
- package/dist/editor/nudge.d.ts.map +1 -1
- package/dist/editor/nudge.js +12 -2
- package/dist/editor/nudge.js.map +1 -1
- package/dist/editor/pages.d.ts +2 -1
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +94 -15
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +0 -5
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +3 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/selection/hit-test.d.ts +2 -1
- package/dist/editor/selection/hit-test.d.ts.map +1 -1
- package/dist/editor/selection/hit-test.js +29 -4
- package/dist/editor/selection/hit-test.js.map +1 -1
- package/dist/editor/selection.d.ts +2 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/pen.js +6 -2
- package/dist/editor/shapes/pen.js.map +1 -1
- package/dist/editor/shapes.d.ts.map +1 -1
- package/dist/editor/shapes.js +2 -1
- package/dist/editor/shapes.js.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.d.ts.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.js +12 -0
- package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
- package/dist/editor/structure/boolean.js +1 -1
- package/dist/editor/structure/group/bounds.d.ts +4 -2
- package/dist/editor/structure/group/bounds.d.ts.map +1 -1
- package/dist/editor/structure/group/bounds.js +17 -4
- package/dist/editor/structure/group/bounds.js.map +1 -1
- package/dist/editor/structure/rename.d.ts +2 -3
- package/dist/editor/structure/rename.d.ts.map +1 -1
- package/dist/editor/structure/rename.js +2 -5
- package/dist/editor/structure/rename.js.map +1 -1
- package/dist/editor/structure/reorder.d.ts.map +1 -1
- package/dist/editor/structure/reorder.js +20 -9
- package/dist/editor/structure/reorder.js.map +1 -1
- package/dist/editor/structure/state.js +1 -1
- package/dist/editor/structure.d.ts +1 -0
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/structure.js +76 -20
- package/dist/editor/structure.js.map +1 -1
- package/dist/editor/text/hyperlink.d.ts.map +1 -1
- package/dist/editor/text/hyperlink.js +1 -1
- package/dist/editor/text/hyperlink.js.map +1 -1
- package/dist/editor/text/name.d.ts +13 -5
- package/dist/editor/text/name.d.ts.map +1 -1
- package/dist/editor/text/name.js +47 -17
- package/dist/editor/text/name.js.map +1 -1
- package/dist/editor/text/pending-layout.d.ts +2 -1
- package/dist/editor/text/pending-layout.d.ts.map +1 -1
- package/dist/editor/text/pending-layout.js +33 -6
- package/dist/editor/text/pending-layout.js.map +1 -1
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +16 -4
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/text.d.ts +5 -0
- package/dist/editor/text.d.ts.map +1 -1
- package/dist/editor/text.js +70 -3
- package/dist/editor/text.js.map +1 -1
- package/dist/editor/types.d.ts +18 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/undo.d.ts.map +1 -1
- package/dist/editor/undo.js +14 -2
- package/dist/editor/undo.js.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +21 -2
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/editor/variables.d.ts +1 -1
- package/dist/editor/variables.d.ts.map +1 -1
- package/dist/editor/variables.js +7 -8
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/viewport.d.ts +11 -2
- package/dist/editor/viewport.d.ts.map +1 -1
- package/dist/editor/viewport.js +61 -21
- package/dist/editor/viewport.js.map +1 -1
- package/dist/editor/views/actions.d.ts.map +1 -1
- package/dist/editor/views/actions.js +13 -5
- package/dist/editor/views/actions.js.map +1 -1
- package/dist/editor/views/present.d.ts +6 -4
- package/dist/editor/views/present.d.ts.map +1 -1
- package/dist/editor/views/present.js +12 -10
- package/dist/editor/views/present.js.map +1 -1
- package/dist/editor/views/types.d.ts +11 -5
- package/dist/editor/views/types.d.ts.map +1 -1
- package/dist/figma-api/accessor-utils.d.ts.map +1 -1
- package/dist/figma-api/accessor-utils.js +4 -1
- package/dist/figma-api/accessor-utils.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +41 -21
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/layout.d.ts.map +1 -1
- package/dist/figma-api/accessors/layout.js +37 -7
- package/dist/figma-api/accessors/layout.js.map +1 -1
- package/dist/figma-api/accessors/reactions.d.ts +11 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -0
- package/dist/figma-api/accessors/reactions.js +30 -0
- package/dist/figma-api/accessors/reactions.js.map +1 -0
- package/dist/figma-api/accessors/strokes.d.ts.map +1 -1
- package/dist/figma-api/accessors/strokes.js +12 -4
- package/dist/figma-api/accessors/strokes.js.map +1 -1
- package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
- package/dist/figma-api/accessors/text/index.js +3 -1
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +1 -1
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.d.ts +6 -5
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +20 -17
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +2 -1
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/finite.d.ts +27 -0
- package/dist/figma-api/finite.d.ts.map +1 -0
- package/dist/figma-api/finite.js +69 -0
- package/dist/figma-api/finite.js.map +1 -0
- package/dist/figma-api/fonts/list.d.ts +13 -0
- package/dist/figma-api/fonts/list.d.ts.map +1 -0
- package/dist/figma-api/fonts/list.js +25 -0
- package/dist/figma-api/fonts/list.js.map +1 -0
- package/dist/figma-api/index.d.ts +21 -3
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +58 -13
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +6 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +2 -2
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/pending-layout.d.ts +12 -2
- package/dist/figma-api/pending-layout.d.ts.map +1 -1
- package/dist/figma-api/pending-layout.js +41 -1
- package/dist/figma-api/pending-layout.js.map +1 -1
- package/dist/figma-api/pending-sync.d.ts +19 -0
- package/dist/figma-api/pending-sync.d.ts.map +1 -0
- package/dist/figma-api/pending-sync.js +52 -0
- package/dist/figma-api/pending-sync.js.map +1 -0
- package/dist/figma-api/proxy.d.ts +15 -2
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +23 -3
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +104 -0
- package/dist/figma-api/reactions.d.ts.map +1 -0
- package/dist/figma-api/reactions.js +157 -0
- package/dist/figma-api/reactions.js.map +1 -0
- package/dist/figma-api/render-bounds.d.ts.map +1 -1
- package/dist/figma-api/render-bounds.js +4 -4
- package/dist/figma-api/render-bounds.js.map +1 -1
- package/dist/figma-api/serialization.js +2 -2
- package/dist/figma-api/serialization.js.map +1 -1
- package/dist/figma-api/slots.d.ts +7 -1
- package/dist/figma-api/slots.d.ts.map +1 -1
- package/dist/figma-api/slots.js +12 -4
- package/dist/figma-api/slots.js.map +1 -1
- package/dist/figma-api/strokes.d.ts +5 -2
- package/dist/figma-api/strokes.d.ts.map +1 -1
- package/dist/figma-api/strokes.js +12 -19
- package/dist/figma-api/strokes.js.map +1 -1
- package/dist/figma-api/text/bindings.js +1 -1
- package/dist/figma-api/text/index.d.ts +2 -3
- package/dist/figma-api/text/index.d.ts.map +1 -1
- package/dist/figma-api/text/index.js +2 -12
- package/dist/figma-api/text/index.js.map +1 -1
- package/dist/figma-api/variables/bindings.js +1 -1
- package/dist/figma-api/variables/variable.d.ts.map +1 -1
- package/dist/figma-api/variables/variable.js +2 -2
- package/dist/figma-api/variables/variable.js.map +1 -1
- package/dist/geometry/figma.d.ts +6 -1
- package/dist/geometry/figma.d.ts.map +1 -1
- package/dist/geometry/figma.js +8 -1
- package/dist/geometry/figma.js.map +1 -1
- package/dist/geometry/index.d.ts +2 -2
- package/dist/geometry/index.js +2 -2
- package/dist/icons/api.d.ts +3 -2
- package/dist/icons/api.d.ts.map +1 -1
- package/dist/icons/api.js +12 -12
- package/dist/icons/api.js.map +1 -1
- package/dist/icons/provider.d.ts +4 -3
- package/dist/icons/provider.d.ts.map +1 -1
- package/dist/icons/provider.js +6 -13
- package/dist/icons/provider.js.map +1 -1
- package/dist/icons/schema.d.ts +33 -1
- package/dist/icons/schema.d.ts.map +1 -1
- package/dist/icons/schema.js +30 -1
- package/dist/icons/schema.js.map +1 -1
- package/dist/icons/svg/presentation.d.ts +8 -1
- package/dist/icons/svg/presentation.d.ts.map +1 -1
- package/dist/icons/svg/presentation.js +21 -3
- package/dist/icons/svg/presentation.js.map +1 -1
- package/dist/icons/svg/text.js +1 -1
- package/dist/icons/svg/text.js.map +1 -1
- package/dist/icons/svg.d.ts +8 -3
- package/dist/icons/svg.d.ts.map +1 -1
- package/dist/icons/svg.js +15 -13
- package/dist/icons/svg.js.map +1 -1
- package/dist/icons/types.d.ts +1 -19
- package/dist/icons/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/io/formats/design-tokens/css/read.js +1 -1
- package/dist/io/formats/design-tokens/decode.js +1 -1
- package/dist/io/formats/design-tokens/plan/index.js +4 -2
- package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts +9 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.js +23 -3
- package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts +9 -1
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js +41 -4
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/types.d.ts +5 -0
- package/dist/io/formats/design-tokens/types.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/types.js +1 -0
- package/dist/io/formats/design-tokens/types.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +8 -4
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
- package/dist/io/formats/fig/export/variables.js +2 -2
- package/dist/io/formats/fig/export/variables.js.map +1 -1
- package/dist/io/formats/fig/index.d.ts +2 -2
- package/dist/io/formats/fig/index.js +2 -2
- package/dist/io/formats/fig/read.d.ts +9 -2
- package/dist/io/formats/fig/read.d.ts.map +1 -1
- package/dist/io/formats/fig/read.js +44 -20
- package/dist/io/formats/fig/read.js.map +1 -1
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +2 -6
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +65 -1
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/prepare.js +1 -1
- package/dist/io/formats/pen/fonts.d.ts +14 -0
- package/dist/io/formats/pen/fonts.d.ts.map +1 -0
- package/dist/io/formats/pen/fonts.js +39 -0
- package/dist/io/formats/pen/fonts.js.map +1 -0
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +25 -6
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/raster/headless.d.ts +2 -2
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +24 -13
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/index.js +2 -2
- package/dist/io/formats/raster/render.d.ts +7 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +40 -6
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +28 -24
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/paths.d.ts +8 -2
- package/dist/io/formats/svg/paths.d.ts.map +1 -1
- package/dist/io/formats/svg/paths.js +11 -3
- package/dist/io/formats/svg/paths.js.map +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +2 -5
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/export.d.ts.map +1 -1
- package/dist/io/formats/svg/text/export.js +19 -1
- package/dist/io/formats/svg/text/export.js.map +1 -1
- package/dist/io/formats/svg/text/import.d.ts.map +1 -1
- package/dist/io/formats/svg/text/import.js +2 -1
- package/dist/io/formats/svg/text/import.js.map +1 -1
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +5 -2
- package/dist/io/subgraph.js.map +1 -1
- package/dist/kiwi/fig/population/client.d.ts.map +1 -1
- package/dist/kiwi/fig/population/client.js +63 -45
- package/dist/kiwi/fig/population/client.js.map +1 -1
- package/dist/kiwi/fig/population/delta.d.ts +34 -3
- package/dist/kiwi/fig/population/delta.d.ts.map +1 -1
- package/dist/kiwi/fig/population/delta.js +99 -16
- package/dist/kiwi/fig/population/delta.js.map +1 -1
- package/dist/kiwi/fig/population/edits.d.ts +51 -0
- package/dist/kiwi/fig/population/edits.d.ts.map +1 -0
- package/dist/kiwi/fig/population/edits.js +169 -0
- package/dist/kiwi/fig/population/edits.js.map +1 -0
- package/dist/kiwi/fig/session/archive/access.d.ts +3 -0
- package/dist/kiwi/fig/session/archive/access.d.ts.map +1 -1
- package/dist/kiwi/fig/session/archive/access.js +8 -1
- package/dist/kiwi/fig/session/archive/access.js.map +1 -1
- package/dist/kiwi/fig/session/archive/changes.d.ts +2 -1
- package/dist/kiwi/fig/session/archive/changes.d.ts.map +1 -1
- package/dist/kiwi/fig/session/archive/changes.js +12 -5
- package/dist/kiwi/fig/session/archive/changes.js.map +1 -1
- package/dist/kiwi/fig/session/document-state.d.ts +7 -1
- package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
- package/dist/kiwi/fig/session/document-state.js +16 -2
- package/dist/kiwi/fig/session/document-state.js.map +1 -1
- package/dist/kiwi/fig/session/protocol.d.ts +31 -3
- package/dist/kiwi/fig/session/protocol.d.ts.map +1 -1
- package/dist/kiwi/fig/session/worker.js +33 -8
- package/dist/kiwi/fig/session/worker.js.map +1 -1
- package/dist/layout/apply.d.ts +6 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +39 -14
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/arrange/boxes.d.ts.map +1 -1
- package/dist/layout/arrange/boxes.js +31 -0
- package/dist/layout/arrange/boxes.js.map +1 -1
- package/dist/layout/flow-edges.d.ts +26 -0
- package/dist/layout/flow-edges.d.ts.map +1 -0
- package/dist/layout/flow-edges.js +105 -0
- package/dist/layout/flow-edges.js.map +1 -0
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +9 -5
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/text-auto-resize.d.ts.map +1 -1
- package/dist/layout/text-auto-resize.js +9 -4
- package/dist/layout/text-auto-resize.js.map +1 -1
- package/dist/layout/text-measurement.d.ts +15 -1
- package/dist/layout/text-measurement.d.ts.map +1 -1
- package/dist/layout/text-measurement.js +40 -4
- package/dist/layout/text-measurement.js.map +1 -1
- package/dist/layout/variables.d.ts +1 -1
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +35 -35
- package/dist/layout.js.map +1 -1
- package/dist/library/asset-keys.d.ts +3 -2
- package/dist/library/asset-keys.d.ts.map +1 -1
- package/dist/library/asset-keys.js +4 -3
- package/dist/library/asset-keys.js.map +1 -1
- package/dist/library/copied-references.d.ts +8 -3
- package/dist/library/copied-references.d.ts.map +1 -1
- package/dist/library/copied-references.js +15 -5
- package/dist/library/copied-references.js.map +1 -1
- package/dist/library/materialize.js +1 -1
- package/dist/library/materialize.js.map +1 -1
- package/dist/library/schema.js.map +1 -1
- package/dist/library/snapshot.d.ts.map +1 -1
- package/dist/library/snapshot.js +10 -2
- package/dist/library/snapshot.js.map +1 -1
- package/dist/pairdraw-api/variables.d.ts.map +1 -1
- package/dist/pairdraw-api/variables.js +0 -2
- package/dist/pairdraw-api/variables.js.map +1 -1
- package/dist/profiler/hud-controller.d.ts +4 -3
- package/dist/profiler/hud-controller.d.ts.map +1 -1
- package/dist/profiler/hud-controller.js +7 -5
- package/dist/profiler/hud-controller.js.map +1 -1
- package/dist/profiler/hud-renderer.d.ts +5 -2
- package/dist/profiler/hud-renderer.d.ts.map +1 -1
- package/dist/profiler/hud-renderer.js +8 -5
- package/dist/profiler/hud-renderer.js.map +1 -1
- package/dist/profiler/render-profiler.d.ts +3 -2
- package/dist/profiler/render-profiler.d.ts.map +1 -1
- package/dist/profiler/render-profiler.js +3 -2
- package/dist/profiler/render-profiler.js.map +1 -1
- package/dist/text/character-style.d.ts +11 -1
- package/dist/text/character-style.d.ts.map +1 -1
- package/dist/text/character-style.js +27 -5
- package/dist/text/character-style.js.map +1 -1
- package/dist/text/coverage.d.ts.map +1 -1
- package/dist/text/coverage.js +15 -16
- package/dist/text/coverage.js.map +1 -1
- package/dist/text/editor.d.ts.map +1 -1
- package/dist/text/editor.js +3 -8
- package/dist/text/editor.js.map +1 -1
- package/dist/text/fallbacks.d.ts +19 -2
- package/dist/text/fallbacks.d.ts.map +1 -1
- package/dist/text/fallbacks.js +63 -12
- package/dist/text/fallbacks.js.map +1 -1
- package/dist/text/font/catalog.d.ts +4 -0
- package/dist/text/font/catalog.d.ts.map +1 -1
- package/dist/text/font/catalog.js +8 -0
- package/dist/text/font/catalog.js.map +1 -1
- package/dist/text/font/collection.d.ts +13 -0
- package/dist/text/font/collection.d.ts.map +1 -0
- package/dist/text/font/collection.js +51 -0
- package/dist/text/font/collection.js.map +1 -0
- package/dist/text/font/faces.d.ts +2 -1
- package/dist/text/font/faces.d.ts.map +1 -1
- package/dist/text/font/faces.js +9 -5
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/font/glyphs.d.ts +14 -3
- package/dist/text/font/glyphs.d.ts.map +1 -1
- package/dist/text/font/glyphs.js +22 -5
- package/dist/text/font/glyphs.js.map +1 -1
- package/dist/text/font/local.js +2 -2
- package/dist/text/font/local.js.map +1 -1
- package/dist/text/font/manager.d.ts +36 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +139 -19
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/font/style.d.ts +7 -2
- package/dist/text/font/style.d.ts.map +1 -1
- package/dist/text/font/style.js +31 -3
- package/dist/text/font/style.js.map +1 -1
- package/dist/text/index.d.ts +5 -4
- package/dist/text/index.js +5 -4
- package/dist/text/outlines.d.ts.map +1 -1
- package/dist/text/outlines.js +70 -70
- package/dist/text/outlines.js.map +1 -1
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +7 -1
- package/dist/text/prepare.js.map +1 -1
- package/dist/text/style-runs.d.ts +14 -2
- package/dist/text/style-runs.d.ts.map +1 -1
- package/dist/text/style-runs.js +22 -14
- package/dist/text/style-runs.js.map +1 -1
- package/dist/tools/analyze/overlaps/helpers.d.ts.map +1 -1
- package/dist/tools/analyze/overlaps/helpers.js +9 -1
- package/dist/tools/analyze/overlaps/helpers.js.map +1 -1
- package/dist/tools/analyze/overlaps/index.d.ts.map +1 -1
- package/dist/tools/analyze/overlaps/index.js +27 -5
- package/dist/tools/analyze/overlaps/index.js.map +1 -1
- package/dist/tools/codegen/component-map.js +3 -3
- package/dist/tools/codegen/component-map.js.map +1 -1
- package/dist/tools/create/basic.d.ts.map +1 -1
- package/dist/tools/create/basic.js +5 -4
- package/dist/tools/create/basic.js.map +1 -1
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +4 -2
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +3 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.d.ts.map +1 -1
- package/dist/tools/create/mermaid.js +2 -0
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.d.ts.map +1 -1
- package/dist/tools/create/render.js +2 -0
- package/dist/tools/create/render.js.map +1 -1
- package/dist/tools/create/script.js +3 -1
- package/dist/tools/create/script.js.map +1 -1
- package/dist/tools/create/svg.d.ts.map +1 -1
- package/dist/tools/create/svg.js +4 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.d.ts.map +1 -1
- package/dist/tools/create/vector.js +4 -4
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/image-ai/apply.js +1 -1
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -0
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/modify/matching.js +1 -1
- package/dist/tools/modify/reactions.d.ts +6 -0
- package/dist/tools/modify/reactions.d.ts.map +1 -0
- package/dist/tools/modify/reactions.js +35 -0
- package/dist/tools/modify/reactions.js.map +1 -0
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/read/components.js +20 -22
- package/dist/tools/read/components.js.map +1 -1
- package/dist/tools/read/fonts.js +1 -1
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.d.ts.map +1 -1
- package/dist/tools/read/libraries.js +2 -0
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js +38 -16
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/read/pages.d.ts.map +1 -1
- package/dist/tools/read/pages.js +4 -3
- package/dist/tools/read/pages.js.map +1 -1
- package/dist/tools/read/query.js +1 -0
- package/dist/tools/read/query.js.map +1 -1
- package/dist/tools/read/reactions.d.ts +6 -0
- package/dist/tools/read/reactions.d.ts.map +1 -0
- package/dist/tools/read/reactions.js +24 -0
- package/dist/tools/read/reactions.js.map +1 -0
- package/dist/tools/read/space.js +1 -1
- package/dist/tools/read.d.ts +2 -1
- package/dist/tools/read.js +2 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +4 -0
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +6 -0
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +53 -9
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/stock-photo/apply.js +8 -9
- package/dist/tools/stock-photo/apply.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +85 -90
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/vector/fill-geometry.d.ts +4 -1
- package/dist/vector/fill-geometry.d.ts.map +1 -1
- package/dist/vector/fill-geometry.js +8 -5
- package/dist/vector/fill-geometry.js.map +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/path-helpers.d.ts +1 -1
- package/dist/vector/path-helpers.d.ts.map +1 -1
- package/dist/vector/path-helpers.js +24 -7
- package/dist/vector/path-helpers.js.map +1 -1
- package/dist/vector/placement.js +1 -1
- package/dist/vector/placement.js.map +1 -1
- package/dist/vector/vectorize/preprocess.js +1 -1
- package/dist/vector/vectorize/preprocess.js.map +1 -1
- package/package.json +10 -10
- package/src/canvas/effects.ts +29 -33
- package/src/canvas/labels/hit-test.ts +6 -2
- package/src/canvas/labels/paragraph-cache.ts +2 -1
- package/src/canvas/labels/selection.ts +3 -3
- package/src/canvas/node-edit-overlay.ts +3 -2
- package/src/canvas/overlays/index.ts +0 -1
- package/src/canvas/overlays/selection.ts +4 -52
- package/src/canvas/region-hatch.ts +7 -2
- package/src/canvas/renderer/colors.ts +41 -26
- package/src/canvas/renderer/font-waiters.ts +25 -0
- package/src/canvas/renderer/fonts.ts +40 -17
- package/src/canvas/renderer/lifecycle.ts +8 -10
- package/src/canvas/renderer/methods.ts +9 -13
- package/src/canvas/renderer/paints.ts +0 -10
- package/src/canvas/renderer/pipeline.ts +29 -3
- package/src/canvas/renderer/retained-backing.ts +4 -4
- package/src/canvas/renderer/state.ts +1 -1
- package/src/canvas/renderer/tiles/controller.ts +8 -0
- package/src/canvas/renderer/tiles/surface-pool.ts +1 -1
- package/src/canvas/renderer/visual-bounds.ts +7 -6
- package/src/canvas/renderer.ts +39 -11
- package/src/canvas/rulers.ts +55 -26
- package/src/canvas/scene.ts +37 -16
- package/src/canvas/shadows/shape.ts +1 -1
- package/src/canvas/shadows/silhouette.ts +4 -2
- package/src/canvas/shadows.ts +4 -2
- package/src/canvas/text/derived.ts +0 -9
- package/src/canvas/text/emoji/raster.ts +14 -10
- package/src/canvas/text/font-families.ts +6 -0
- package/src/canvas/text/index.ts +0 -8
- package/src/canvas/text/layout/build.ts +35 -18
- package/src/canvas/text/layout/index.ts +15 -6
- package/src/canvas/text/layout/lines.ts +10 -4
- package/src/canvas/text/paragraph/index.ts +17 -8
- package/src/canvas/text/paragraph/inputs.ts +4 -2
- package/src/canvas/text/shape.ts +20 -31
- package/src/constants.ts +6 -1
- package/src/editor/bridges/clipboard.ts +1 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/bridges/frames.ts +6 -4
- package/src/editor/bridges/structure.ts +1 -0
- package/src/editor/clipboard/detach.ts +3 -3
- package/src/editor/clipboard/paste/target.ts +2 -2
- package/src/editor/clipboard/snapshot.ts +7 -0
- package/src/editor/clipboard/variables.ts +20 -0
- package/src/editor/clipboard.ts +133 -14
- package/src/editor/component-sync.ts +28 -7
- package/src/editor/components/authoring/text-edit.ts +15 -2
- package/src/editor/components/authoring/visibility-edit.ts +11 -3
- package/src/editor/components/instances.ts +61 -11
- package/src/editor/components/properties.ts +10 -0
- package/src/editor/components/slots/authoring.ts +4 -1
- package/src/editor/create.ts +58 -8
- package/src/editor/guides.ts +27 -12
- package/src/editor/history/document-change.ts +115 -7
- package/src/editor/history/edit.ts +62 -14
- package/src/editor/history/position.ts +1 -4
- package/src/editor/history/sources.ts +25 -0
- package/src/editor/index.ts +3 -1
- package/src/editor/layout-mode.ts +20 -1
- package/src/editor/node-preview.ts +44 -8
- package/src/editor/nodes.ts +52 -12
- package/src/editor/nudge.ts +16 -2
- package/src/editor/pages.ts +100 -17
- package/src/editor/play/states.ts +0 -7
- package/src/editor/read-only/actions.ts +4 -0
- package/src/editor/selection/hit-test.ts +37 -4
- package/src/editor/shapes/pen.ts +6 -3
- package/src/editor/shapes.ts +2 -1
- package/src/editor/structure/auto-layout-wrap.ts +26 -0
- package/src/editor/structure/group/bounds.ts +22 -4
- package/src/editor/structure/rename.ts +2 -6
- package/src/editor/structure/reorder.ts +26 -8
- package/src/editor/structure.ts +88 -24
- package/src/editor/text/hyperlink.ts +2 -1
- package/src/editor/text/name.ts +51 -15
- package/src/editor/text/pending-layout.ts +42 -4
- package/src/editor/text/selection-style.ts +17 -3
- package/src/editor/text.ts +86 -4
- package/src/editor/types.ts +19 -0
- package/src/editor/undo.ts +21 -2
- package/src/editor/variable-bindings.ts +22 -2
- package/src/editor/variables.ts +10 -6
- package/src/editor/viewport.ts +55 -21
- package/src/editor/views/actions.ts +17 -7
- package/src/editor/views/present.ts +20 -11
- package/src/editor/views/types.ts +11 -5
- package/src/figma-api/accessor-utils.ts +4 -1
- package/src/figma-api/accessors/basic.ts +54 -18
- package/src/figma-api/accessors/layout.ts +46 -7
- package/src/figma-api/accessors/reactions.ts +29 -0
- package/src/figma-api/accessors/strokes.ts +28 -8
- package/src/figma-api/accessors/text/index.ts +4 -0
- package/src/figma-api/accessors/vector.ts +3 -1
- package/src/figma-api/accessors/visual.ts +25 -28
- package/src/figma-api/components.ts +9 -7
- package/src/figma-api/finite.ts +102 -0
- package/src/figma-api/fonts/list.ts +24 -0
- package/src/figma-api/index.ts +82 -12
- package/src/figma-api/overrides.ts +1 -1
- package/src/figma-api/pending-layout.ts +50 -1
- package/src/figma-api/pending-sync.ts +61 -0
- package/src/figma-api/proxy.ts +35 -2
- package/src/figma-api/reactions.ts +212 -0
- package/src/figma-api/render-bounds.ts +13 -4
- package/src/figma-api/serialization.ts +2 -2
- package/src/figma-api/slots.ts +12 -3
- package/src/figma-api/strokes.ts +16 -12
- package/src/figma-api/text/index.ts +9 -15
- package/src/figma-api/variables/variable.ts +3 -2
- package/src/geometry/figma.ts +9 -0
- package/src/geometry/index.ts +1 -0
- package/src/global.d.ts +6 -0
- package/src/icons/api.ts +27 -16
- package/src/icons/provider.ts +9 -20
- package/src/icons/schema.ts +31 -0
- package/src/icons/svg/presentation.ts +27 -3
- package/src/icons/svg/text.ts +1 -1
- package/src/icons/svg.ts +21 -19
- package/src/icons/types.ts +0 -14
- package/src/io/formats/design-tokens/plan/index.ts +7 -1
- package/src/io/formats/design-tokens/plan/styles.ts +40 -4
- package/src/io/formats/design-tokens/styles.ts +60 -3
- package/src/io/formats/design-tokens/types.ts +3 -0
- package/src/io/formats/fig/export/setup.ts +16 -14
- package/src/io/formats/fig/export/variables.ts +7 -8
- package/src/io/formats/fig/index.ts +1 -0
- package/src/io/formats/fig/read.ts +66 -23
- package/src/io/formats/html/index.ts +2 -6
- package/src/io/formats/pdf/dom.ts +96 -3
- package/src/io/formats/pen/fonts.ts +45 -0
- package/src/io/formats/pen/index.ts +30 -6
- package/src/io/formats/raster/headless.ts +31 -12
- package/src/io/formats/raster/index.ts +3 -0
- package/src/io/formats/raster/render.ts +62 -6
- package/src/io/formats/svg/export.ts +24 -25
- package/src/io/formats/svg/paths.ts +11 -2
- package/src/io/formats/svg/strokes.ts +8 -2
- package/src/io/formats/svg/text/export.ts +23 -0
- package/src/io/formats/svg/text/import.ts +2 -1
- package/src/io/subgraph.ts +3 -1
- package/src/kiwi/fig/population/client.ts +77 -43
- package/src/kiwi/fig/population/delta.ts +141 -18
- package/src/kiwi/fig/population/edits.ts +235 -0
- package/src/kiwi/fig/session/archive/access.ts +15 -0
- package/src/kiwi/fig/session/archive/changes.ts +27 -6
- package/src/kiwi/fig/session/document-state.ts +23 -1
- package/src/kiwi/fig/session/protocol.ts +26 -1
- package/src/kiwi/fig/session/worker.ts +38 -11
- package/src/layout/apply.ts +52 -10
- package/src/layout/arrange/boxes.ts +36 -0
- package/src/layout/flow-edges.ts +139 -0
- package/src/layout/grid.ts +14 -4
- package/src/layout/text-auto-resize.ts +13 -4
- package/src/layout/text-measurement.ts +46 -3
- package/src/layout.ts +60 -66
- package/src/library/asset-keys.ts +4 -3
- package/src/library/copied-references.ts +29 -5
- package/src/library/materialize.ts +1 -1
- package/src/library/schema.ts +1 -1
- package/src/library/snapshot.ts +11 -2
- package/src/pairdraw-api/variables.ts +1 -3
- package/src/profiler/hud-controller.ts +8 -6
- package/src/profiler/hud-renderer.ts +9 -6
- package/src/profiler/render-profiler.ts +4 -3
- package/src/text/character-style.ts +29 -9
- package/src/text/coverage.ts +17 -18
- package/src/text/editor.ts +3 -8
- package/src/text/fallbacks.ts +82 -15
- package/src/text/font/catalog.ts +10 -0
- package/src/text/font/collection.ts +60 -0
- package/src/text/font/faces.ts +9 -5
- package/src/text/font/glyphs.ts +29 -4
- package/src/text/font/local.ts +2 -2
- package/src/text/font/manager.ts +170 -32
- package/src/text/font/style.ts +52 -3
- package/src/text/index.ts +1 -0
- package/src/text/outlines.ts +105 -89
- package/src/text/prepare.ts +17 -0
- package/src/text/style-runs.ts +43 -16
- package/src/tools/analyze/overlaps/helpers.ts +18 -1
- package/src/tools/analyze/overlaps/index.ts +37 -6
- package/src/tools/codegen/component-map.ts +3 -3
- package/src/tools/create/basic.ts +6 -4
- package/src/tools/create/html.ts +3 -1
- package/src/tools/create/icons.ts +3 -1
- package/src/tools/create/mermaid.ts +2 -0
- package/src/tools/create/render.ts +2 -0
- package/src/tools/create/script.ts +5 -1
- package/src/tools/create/svg.ts +4 -1
- package/src/tools/create/vector.ts +4 -4
- package/src/tools/image-ai/generate.ts +3 -0
- package/src/tools/modify/reactions.ts +40 -0
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/components.ts +28 -25
- package/src/tools/read/fonts.ts +1 -1
- package/src/tools/read/libraries.ts +3 -0
- package/src/tools/read/nodes.ts +47 -17
- package/src/tools/read/pages.ts +7 -4
- package/src/tools/read/query.ts +2 -0
- package/src/tools/read/reactions.ts +21 -0
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/extended.ts +4 -0
- package/src/tools/schema.ts +68 -12
- package/src/tools/stock-photo/apply.ts +17 -5
- package/src/tools/structure/batch.ts +82 -101
- package/src/vector/fill-geometry.ts +11 -5
- package/src/vector/index.ts +1 -1
- package/src/vector/path-helpers.ts +34 -8
- package/src/vector/placement.ts +1 -1
- package/src/vector/vectorize/preprocess.ts +1 -1
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { nodeId, raw, strokeOwner, updateNode } from "../accessor-utils.js";
|
|
2
|
+
import { dashPatternValues, finiteNumber } from "../finite.js";
|
|
2
3
|
import { setIndependentStrokeWeight, setStrokeAlign, setStrokeWeight } from "../strokes.js";
|
|
3
4
|
import { newStrokeGeometry } from "@pairdraw/scene-graph/node-defaults";
|
|
4
5
|
//#region src/figma-api/accessors/strokes.ts
|
|
5
6
|
function graph(target, internals) {
|
|
6
7
|
return target[internals.graph];
|
|
7
8
|
}
|
|
9
|
+
/** The plugin API's name for each independent weight, which its refusals are worded with. */
|
|
10
|
+
const WEIGHT_PROPERTIES = {
|
|
11
|
+
borderTopWeight: "strokeTopWeight",
|
|
12
|
+
borderRightWeight: "strokeRightWeight",
|
|
13
|
+
borderBottomWeight: "strokeBottomWeight",
|
|
14
|
+
borderLeftWeight: "strokeLeftWeight"
|
|
15
|
+
};
|
|
8
16
|
function independentWeight(internals, field) {
|
|
9
17
|
return {
|
|
10
18
|
get() {
|
|
11
19
|
return raw(this, internals)[field];
|
|
12
20
|
},
|
|
13
21
|
set(value) {
|
|
14
|
-
setIndependentStrokeWeight(graph(this, internals), nodeId(this, internals), field, value);
|
|
22
|
+
setIndependentStrokeWeight(graph(this, internals), nodeId(this, internals), field, finiteNumber(value, WEIGHT_PROPERTIES[field]));
|
|
15
23
|
}
|
|
16
24
|
};
|
|
17
25
|
}
|
|
@@ -22,7 +30,7 @@ function installStrokeNodeProxyAccessors(prototype, internals) {
|
|
|
22
30
|
return newStrokeGeometry(raw(strokeOwner(this, internals), internals)).weight;
|
|
23
31
|
},
|
|
24
32
|
set(value) {
|
|
25
|
-
setStrokeWeight(graph(this, internals), raw(strokeOwner(this, internals), internals), value);
|
|
33
|
+
setStrokeWeight(graph(this, internals), raw(strokeOwner(this, internals), internals), finiteNumber(value, "strokeWeight"));
|
|
26
34
|
}
|
|
27
35
|
},
|
|
28
36
|
strokeAlign: {
|
|
@@ -38,7 +46,7 @@ function installStrokeNodeProxyAccessors(prototype, internals) {
|
|
|
38
46
|
return Object.freeze([...raw(strokeOwner(this, internals), internals).dashPattern]);
|
|
39
47
|
},
|
|
40
48
|
set(value) {
|
|
41
|
-
updateNode(strokeOwner(this, internals), internals, { dashPattern:
|
|
49
|
+
updateNode(strokeOwner(this, internals), internals, { dashPattern: dashPatternValues(value) });
|
|
42
50
|
}
|
|
43
51
|
},
|
|
44
52
|
strokeCap: {
|
|
@@ -79,7 +87,7 @@ function installStrokeNodeProxyAccessors(prototype, internals) {
|
|
|
79
87
|
return raw(this, internals).strokeMiterLimit;
|
|
80
88
|
},
|
|
81
89
|
set(value) {
|
|
82
|
-
updateNode(this, internals, { strokeMiterLimit: value });
|
|
90
|
+
updateNode(this, internals, { strokeMiterLimit: finiteNumber(value, "strokeMiterLimit") });
|
|
83
91
|
}
|
|
84
92
|
},
|
|
85
93
|
strokeTopWeight: independentWeight(internals, "borderTopWeight"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strokes.js","names":[],"sources":["../../../src/figma-api/accessors/strokes.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { newStrokeGeometry } from '@pairdraw/scene-graph/node-defaults'\n\nimport {\n nodeId,\n raw,\n strokeOwner,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport {\n setIndependentStrokeWeight,\n setStrokeAlign,\n setStrokeWeight\n} from '#core/figma-api/strokes'\n\ntype IndependentWeightField =\n | 'borderTopWeight'\n | 'borderRightWeight'\n | 'borderBottomWeight'\n | 'borderLeftWeight'\n\nfunction graph(target: ProxyThis, internals: NodeProxyInternals): SceneGraph {\n return target[internals.graph] as SceneGraph\n}\n\nfunction independentWeight(internals: NodeProxyInternals, field: IndependentWeightField) {\n return {\n get(this: ProxyThis): number {\n return raw(this, internals)[field]\n },\n set(this: ProxyThis, value:
|
|
1
|
+
{"version":3,"file":"strokes.js","names":[],"sources":["../../../src/figma-api/accessors/strokes.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { newStrokeGeometry } from '@pairdraw/scene-graph/node-defaults'\n\nimport {\n nodeId,\n raw,\n strokeOwner,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport { dashPatternValues, finiteNumber } from '#core/figma-api/finite'\nimport {\n setIndependentStrokeWeight,\n setStrokeAlign,\n setStrokeWeight\n} from '#core/figma-api/strokes'\n\ntype IndependentWeightField =\n | 'borderTopWeight'\n | 'borderRightWeight'\n | 'borderBottomWeight'\n | 'borderLeftWeight'\n\nfunction graph(target: ProxyThis, internals: NodeProxyInternals): SceneGraph {\n return target[internals.graph] as SceneGraph\n}\n\n/** The plugin API's name for each independent weight, which its refusals are worded with. */\nconst WEIGHT_PROPERTIES: Record<IndependentWeightField, string> = {\n borderTopWeight: 'strokeTopWeight',\n borderRightWeight: 'strokeRightWeight',\n borderBottomWeight: 'strokeBottomWeight',\n borderLeftWeight: 'strokeLeftWeight'\n}\n\nfunction independentWeight(internals: NodeProxyInternals, field: IndependentWeightField) {\n return {\n get(this: ProxyThis): number {\n return raw(this, internals)[field]\n },\n set(this: ProxyThis, value: unknown) {\n setIndependentStrokeWeight(\n graph(this, internals),\n nodeId(this, internals),\n field,\n finiteNumber(value, WEIGHT_PROPERTIES[field])\n )\n }\n }\n}\n\nexport function installStrokeNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals\n): void {\n Object.defineProperties(prototype, {\n // Figma keeps stroke weight and alignment on the node, with or without strokes.\n strokeWeight: {\n get(this: ProxyThis): number {\n return newStrokeGeometry(raw(strokeOwner(this, internals), internals)).weight\n },\n set(this: ProxyThis, value: unknown) {\n setStrokeWeight(\n graph(this, internals),\n raw(strokeOwner(this, internals), internals),\n finiteNumber(value, 'strokeWeight')\n )\n }\n },\n strokeAlign: {\n get(this: ProxyThis): string {\n return newStrokeGeometry(raw(strokeOwner(this, internals), internals)).align\n },\n set(this: ProxyThis, value: SceneNode['strokeAlign']) {\n setStrokeAlign(graph(this, internals), raw(strokeOwner(this, internals), internals), value)\n }\n },\n dashPattern: {\n get(this: ProxyThis): readonly number[] {\n return Object.freeze([...raw(strokeOwner(this, internals), internals).dashPattern])\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(strokeOwner(this, internals), internals, {\n dashPattern: dashPatternValues(value)\n })\n }\n },\n strokeCap: {\n get(this: ProxyThis): string {\n return raw(this, internals).strokeCap\n },\n set(this: ProxyThis, value: string) {\n const strokeCap = value as SceneNode['strokeCap']\n const node = raw(this, internals)\n updateNode(this, internals, {\n strokeCap,\n strokes: node.strokes.map((stroke) => ({ ...stroke, cap: strokeCap }))\n })\n }\n },\n strokeJoin: {\n get(this: ProxyThis): string {\n return raw(strokeOwner(this, internals), internals).strokeJoin\n },\n set(this: ProxyThis, value: string) {\n const strokeJoin = value as SceneNode['strokeJoin']\n const owner = strokeOwner(this, internals)\n const node = raw(owner, internals)\n updateNode(owner, internals, {\n strokeJoin,\n strokes: node.strokes.map((stroke) => ({ ...stroke, join: strokeJoin }))\n })\n }\n },\n strokeMiterLimit: {\n get(this: ProxyThis): number {\n return raw(this, internals).strokeMiterLimit\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, { strokeMiterLimit: finiteNumber(value, 'strokeMiterLimit') })\n }\n },\n strokeTopWeight: independentWeight(internals, 'borderTopWeight'),\n strokeBottomWeight: independentWeight(internals, 'borderBottomWeight'),\n strokeLeftWeight: independentWeight(internals, 'borderLeftWeight'),\n strokeRightWeight: independentWeight(internals, 'borderRightWeight')\n })\n}\n"],"mappings":";;;;;AAwBA,SAAS,MAAM,QAAmB,WAA2C;CAC3E,OAAO,OAAO,UAAU;AAC1B;;AAGA,MAAM,oBAA4D;CAChE,iBAAiB;CACjB,mBAAmB;CACnB,oBAAoB;CACpB,kBAAkB;AACpB;AAEA,SAAS,kBAAkB,WAA+B,OAA+B;CACvF,OAAO;EACL,MAA6B;GAC3B,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;EAC9B;EACA,IAAqB,OAAgB;GACnC,2BACE,MAAM,MAAM,SAAS,GACrB,OAAO,MAAM,SAAS,GACtB,OACA,aAAa,OAAO,kBAAkB,MAAM,CAC9C;EACF;CACF;AACF;AAEA,SAAgB,gCACd,WACA,WACM;CACN,OAAO,iBAAiB,WAAW;EAEjC,cAAc;GACZ,MAA6B;IAC3B,OAAO,kBAAkB,IAAI,YAAY,MAAM,SAAS,GA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GAChB,MAA6B;IAC3B,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;GAC9B;GACA,IAAqB,OAAgB;IACnC,WAAW,MAAM,WAAW,EAAE,kBAAkB,aAAa,OAAO,kBAAkB,EAAE,CAAC;GAC3F;EACF;EACA,iBAAiB,kBAAkB,WAAW,iBAAiB;EAC/D,oBAAoB,kBAAkB,WAAW,oBAAoB;EACrE,kBAAkB,kBAAkB,WAAW,kBAAkB;EACjE,mBAAmB,kBAAkB,WAAW,mBAAmB;CACrE,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/figma-api/accessors/text/index.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/figma-api/accessors/text/index.ts"],"mappings":";;iBAmGgB,8BACd,mBACA,WAAW,oBACX"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { styleRunsWithPatch, textStyleChanges } from "../../../text/character-style.js";
|
|
2
2
|
import { getTextStyle } from "../../text/style.js";
|
|
3
|
-
import { graph, raw, updateNode } from "../../accessor-utils.js";
|
|
3
|
+
import { graph, nodeId, raw, updateNode } from "../../accessor-utils.js";
|
|
4
|
+
import { renameTextLayer } from "../../../editor/text/name.js";
|
|
4
5
|
import { assertFontLoaded, assertTextFontsLoaded } from "../../fonts/loaded.js";
|
|
5
6
|
import { getParagraphSpacing, letterSpacingValue, lineHeightValue, paragraphStylesForCharacters, spacingProblem, styleRunsForCharacters } from "../../text/index.js";
|
|
6
7
|
import { hyperlinkTarget } from "./hyperlink.js";
|
|
@@ -71,6 +72,7 @@ function installTextNodeProxyAccessors(prototype, internals, mixed) {
|
|
|
71
72
|
textParagraphs,
|
|
72
73
|
styleRuns
|
|
73
74
|
});
|
|
75
|
+
renameTextLayer(graph(this, internals), nodeId(this, internals), value);
|
|
74
76
|
}
|
|
75
77
|
},
|
|
76
78
|
fontName: characterStyle(internals, "fontName", mixed, (node, value) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/figma-api/accessors/text/index.ts"],"sourcesContent":["import type {\n HyperlinkTarget,\n SceneNode,\n TextCase,\n TextParagraphSpacingField\n} from '@pairdraw/scene-graph'\n\nimport {\n graph,\n raw,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport { assertFontLoaded, assertTextFontsLoaded } from '#core/figma-api/fonts/loaded'\nimport type { FigmaFontNameInput } from '#core/figma-api/fonts/names'\nimport {\n getParagraphSpacing,\n letterSpacingValue,\n lineHeightValue,\n paragraphStylesForCharacters,\n styleRunsForCharacters,\n spacingProblem,\n type FigmaLetterSpacing,\n type FigmaLineHeight\n} from '#core/figma-api/text'\nimport { getTextStyle, type TextSegmentField } from '#core/figma-api/text/style'\nimport { styleRunsWithPatch, textStyleChanges } from '#core/text/character-style'\n\nimport { hyperlinkTarget } from './hyperlink'\nimport { fontNameStyle } from './ranges'\n\n/**\n * Getter/setter pair for a spacing Figma keeps at zero or more. It reads `mixed` while paragraphs\n * differ, and setting it changes the text's own value, which paragraphs with theirs keep.\n */\nfunction spacing(internals: NodeProxyInternals, name: TextParagraphSpacingField, mixed: symbol) {\n return {\n get(this: ProxyThis): number | symbol {\n return getParagraphSpacing(raw(this, internals), name, mixed)\n },\n set(this: ProxyThis, value: number) {\n const invalid = spacingProblem(value)\n if (invalid) {\n throw new Error(`in set_${name}: Property \"${name}\" failed validation: ${invalid}`)\n }\n assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\n/**\n * Getter/setter pair for a style characters can override: it reads `mixed` while they differ,\n * and setting it gives every character the value, as Figma's node setters do. Setting one that\n * lays the text out again needs the text's fonts loaded, as in Figma.\n */\nfunction characterStyle<T>(\n internals: NodeProxyInternals,\n field: TextSegmentField,\n mixed: symbol,\n changes: (node: SceneNode, value: T) => Partial<SceneNode>,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), field, mixed)\n },\n set(this: ProxyThis, value: T) {\n const node = raw(this, internals)\n const patch = changes(node, value)\n if (needsFonts) assertTextFontsLoaded(`set_${field}`, node)\n updateNode(this, internals, textStyleChanges(node, patch))\n }\n }\n}\n\n/**\n * Getter/setter pair for a text property stored verbatim on the node; one that lays the text out\n * again needs its fonts loaded, as in Figma.\n */\nfunction field<Field extends keyof SceneNode>(\n internals: NodeProxyInternals,\n name: Field,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): SceneNode[Field] {\n return raw(this, internals)[name]\n },\n set(this: ProxyThis, value: SceneNode[Field]) {\n if (needsFonts) assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\nexport function installTextNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(prototype, {\n characters: {\n get(this: ProxyThis): string {\n return raw(this, internals).text\n },\n set(this: ProxyThis, value: string) {\n assertTextFontsLoaded('set_characters', raw(this, internals))\n const textParagraphs = paragraphStylesForCharacters(raw(this, internals), value)\n const styleRuns = styleRunsForCharacters(raw(this, internals), value)\n updateNode(this, internals, { text: value, textParagraphs, styleRuns })\n }\n },\n // The new font replaces every character's, so only it has to be loaded, as in Figma.\n fontName: characterStyle<FigmaFontNameInput>(\n internals,\n 'fontName',\n mixed,\n (node, value) => {\n const style = fontNameStyle('set_fontName', node, 0, value)\n assertFontLoaded('set_fontName', node, style)\n return style\n },\n false\n ),\n fontSize: characterStyle<number>(internals, 'fontSize', mixed, (_node, fontSize) => ({\n fontSize\n })),\n textStyleId: characterStyle<string>(\n internals,\n 'textStyleId',\n mixed,\n (_node, value) => ({ textStyleId: value || null }),\n false\n ),\n // A weight is a face of its own, which has to be loaded as a new font does.\n fontWeight: characterStyle<number>(internals, 'fontWeight', mixed, (node, fontWeight) => {\n const style = { fontWeight, fontStyle: null }\n assertFontLoaded('set_fontWeight', node, style)\n return style\n }),\n textAlignHorizontal: field(internals, 'textAlignHorizontal'),\n textAlignVertical: field(internals, 'textAlignVertical'),\n textAutoResize: field(internals, 'textAutoResize'),\n // Figma's plugin API reads and writes these as { unit, value }; a bare object stored on the\n // node instead of pixels would leave the text unmeasurable.\n letterSpacing: characterStyle<FigmaLetterSpacing | number>(\n internals,\n 'letterSpacing',\n mixed,\n (_node, value) => ({ letterSpacing: letterSpacingValue(value) })\n ),\n lineHeight: characterStyle<FigmaLineHeight | number | null>(\n internals,\n 'lineHeight',\n mixed,\n (_node, value) => ({ lineHeight: lineHeightValue(value) })\n ),\n textCase: characterStyle<TextCase>(internals, 'textCase', mixed, (_node, textCase) => ({\n textCase\n })),\n hyperlink: {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), 'hyperlink', mixed)\n },\n set(this: ProxyThis, value: HyperlinkTarget | null) {\n const node = raw(this, internals)\n const hyperlink = hyperlinkTarget('set_hyperlink', value, graph(this, internals))\n const styleRuns = styleRunsWithPatch(node, 0, node.text.length, { hyperlink })\n updateNode(this, internals, { styleRuns })\n }\n },\n textDecoration: characterStyle<SceneNode['textDecoration']>(\n internals,\n 'textDecoration',\n mixed,\n (_node, textDecoration) => ({ textDecoration })\n ),\n maxLines: field(internals, 'maxLines'),\n listSpacing: spacing(internals, 'listSpacing', mixed),\n paragraphSpacing: spacing(internals, 'paragraphSpacing', mixed),\n paragraphIndent: spacing(internals, 'paragraphIndent', mixed),\n hangingList: field(internals, 'hangingList'),\n textTruncation: field(internals, 'textTruncation'),\n autoRename: field(internals, 'autoRename', false)\n })\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/figma-api/accessors/text/index.ts"],"sourcesContent":["import type {\n HyperlinkTarget,\n SceneNode,\n TextCase,\n TextParagraphSpacingField\n} from '@pairdraw/scene-graph'\n\nimport { renameTextLayer } from '#core/editor/text/name'\nimport {\n graph,\n nodeId,\n raw,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport { assertFontLoaded, assertTextFontsLoaded } from '#core/figma-api/fonts/loaded'\nimport type { FigmaFontNameInput } from '#core/figma-api/fonts/names'\nimport {\n getParagraphSpacing,\n letterSpacingValue,\n lineHeightValue,\n paragraphStylesForCharacters,\n styleRunsForCharacters,\n spacingProblem,\n type FigmaLetterSpacing,\n type FigmaLineHeight\n} from '#core/figma-api/text'\nimport { getTextStyle, type TextSegmentField } from '#core/figma-api/text/style'\nimport { styleRunsWithPatch, textStyleChanges } from '#core/text/character-style'\n\nimport { hyperlinkTarget } from './hyperlink'\nimport { fontNameStyle } from './ranges'\n\n/**\n * Getter/setter pair for a spacing Figma keeps at zero or more. It reads `mixed` while paragraphs\n * differ, and setting it changes the text's own value, which paragraphs with theirs keep.\n */\nfunction spacing(internals: NodeProxyInternals, name: TextParagraphSpacingField, mixed: symbol) {\n return {\n get(this: ProxyThis): number | symbol {\n return getParagraphSpacing(raw(this, internals), name, mixed)\n },\n set(this: ProxyThis, value: number) {\n const invalid = spacingProblem(value)\n if (invalid) {\n throw new Error(`in set_${name}: Property \"${name}\" failed validation: ${invalid}`)\n }\n assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\n/**\n * Getter/setter pair for a style characters can override: it reads `mixed` while they differ,\n * and setting it gives every character the value, as Figma's node setters do. Setting one that\n * lays the text out again needs the text's fonts loaded, as in Figma.\n */\nfunction characterStyle<T>(\n internals: NodeProxyInternals,\n field: TextSegmentField,\n mixed: symbol,\n changes: (node: SceneNode, value: T) => Partial<SceneNode>,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), field, mixed)\n },\n set(this: ProxyThis, value: T) {\n const node = raw(this, internals)\n const patch = changes(node, value)\n if (needsFonts) assertTextFontsLoaded(`set_${field}`, node)\n updateNode(this, internals, textStyleChanges(node, patch))\n }\n }\n}\n\n/**\n * Getter/setter pair for a text property stored verbatim on the node; one that lays the text out\n * again needs its fonts loaded, as in Figma.\n */\nfunction field<Field extends keyof SceneNode>(\n internals: NodeProxyInternals,\n name: Field,\n needsFonts = true\n) {\n return {\n get(this: ProxyThis): SceneNode[Field] {\n return raw(this, internals)[name]\n },\n set(this: ProxyThis, value: SceneNode[Field]) {\n if (needsFonts) assertTextFontsLoaded(`set_${name}`, raw(this, internals))\n updateNode(this, internals, { [name]: value })\n }\n }\n}\n\nexport function installTextNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(prototype, {\n characters: {\n get(this: ProxyThis): string {\n return raw(this, internals).text\n },\n set(this: ProxyThis, value: string) {\n assertTextFontsLoaded('set_characters', raw(this, internals))\n const textParagraphs = paragraphStylesForCharacters(raw(this, internals), value)\n const styleRuns = styleRunsForCharacters(raw(this, internals), value)\n updateNode(this, internals, { text: value, textParagraphs, styleRuns })\n // A text layer that was never renamed follows its characters, as in Figma.\n renameTextLayer(graph(this, internals), nodeId(this, internals), value)\n }\n },\n // The new font replaces every character's, so only it has to be loaded, as in Figma.\n fontName: characterStyle<FigmaFontNameInput>(\n internals,\n 'fontName',\n mixed,\n (node, value) => {\n const style = fontNameStyle('set_fontName', node, 0, value)\n assertFontLoaded('set_fontName', node, style)\n return style\n },\n false\n ),\n fontSize: characterStyle<number>(internals, 'fontSize', mixed, (_node, fontSize) => ({\n fontSize\n })),\n textStyleId: characterStyle<string>(\n internals,\n 'textStyleId',\n mixed,\n (_node, value) => ({ textStyleId: value || null }),\n false\n ),\n // A weight is a face of its own, which has to be loaded as a new font does.\n fontWeight: characterStyle<number>(internals, 'fontWeight', mixed, (node, fontWeight) => {\n const style = { fontWeight, fontStyle: null }\n assertFontLoaded('set_fontWeight', node, style)\n return style\n }),\n textAlignHorizontal: field(internals, 'textAlignHorizontal'),\n textAlignVertical: field(internals, 'textAlignVertical'),\n textAutoResize: field(internals, 'textAutoResize'),\n // Figma's plugin API reads and writes these as { unit, value }; a bare object stored on the\n // node instead of pixels would leave the text unmeasurable.\n letterSpacing: characterStyle<FigmaLetterSpacing | number>(\n internals,\n 'letterSpacing',\n mixed,\n (_node, value) => ({ letterSpacing: letterSpacingValue(value) })\n ),\n lineHeight: characterStyle<FigmaLineHeight | number | null>(\n internals,\n 'lineHeight',\n mixed,\n (_node, value) => ({ lineHeight: lineHeightValue(value) })\n ),\n textCase: characterStyle<TextCase>(internals, 'textCase', mixed, (_node, textCase) => ({\n textCase\n })),\n hyperlink: {\n get(this: ProxyThis): unknown {\n return getTextStyle(raw(this, internals), 'hyperlink', mixed)\n },\n set(this: ProxyThis, value: HyperlinkTarget | null) {\n const node = raw(this, internals)\n const hyperlink = hyperlinkTarget('set_hyperlink', value, graph(this, internals))\n const styleRuns = styleRunsWithPatch(node, 0, node.text.length, { hyperlink })\n updateNode(this, internals, { styleRuns })\n }\n },\n textDecoration: characterStyle<SceneNode['textDecoration']>(\n internals,\n 'textDecoration',\n mixed,\n (_node, textDecoration) => ({ textDecoration })\n ),\n maxLines: field(internals, 'maxLines'),\n listSpacing: spacing(internals, 'listSpacing', mixed),\n paragraphSpacing: spacing(internals, 'paragraphSpacing', mixed),\n paragraphIndent: spacing(internals, 'paragraphIndent', mixed),\n hangingList: field(internals, 'hangingList'),\n textTruncation: field(internals, 'textTruncation'),\n autoRename: field(internals, 'autoRename', false)\n })\n}\n"],"mappings":";;;;;;;;;;;;;AAsCA,SAAS,QAAQ,WAA+B,MAAiC,OAAe;CAC9F,OAAO;EACL,MAAsC;GACpC,OAAO,oBAAoB,IAAI,MAAM,SAAS,GAAG,MAAM,KAAK;EAC9D;EACA,IAAqB,OAAe;GAClC,MAAM,UAAU,eAAe,KAAK;GACpC,IAAI,SACF,MAAM,IAAI,MAAM,UAAU,KAAK,cAAc,KAAK,uBAAuB,SAAS;GAEpF,sBAAsB,OAAO,QAAQ,IAAI,MAAM,SAAS,CAAC;GACz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AmB,KAAK;EAC5D,aAAa,MAAM,WAAW,aAAa;EAC3C,gBAAgB,MAAM,WAAW,gBAAgB;EACjD,YAAY,MAAM,WAAW,cAAc,KAAK;CAClD,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","names":[],"sources":["../../../src/figma-api/accessors/vector.ts"],"mappings":";;;;UA8BiB;WACN,aAAa;WACb;;UAGD;WACC,aAAa;WACb,OAAO,cAAc;WACrB,iBAAiB;WACjB;;UAGM;WACN,mBAAmB;WACnB,oBAAoB,KAAK;aACvB,eAAe;aACf,aAAa;;WAEf,mBAAmB;;
|
|
1
|
+
{"version":3,"file":"vector.d.ts","names":[],"sources":["../../../src/figma-api/accessors/vector.ts"],"mappings":";;;;UA8BiB;WACN,aAAa;WACb;;UAGD;WACC,aAAa;WACb,OAAO,cAAc;WACrB,iBAAiB;WACjB;;UAGM;WACN,mBAAmB;WACnB,oBAAoB,KAAK;aACvB,eAAe;aACf,aAAa;;WAEf,mBAAmB;;iBAgMd,gCACd,gBACA,WAAW,oBACX"}
|
|
@@ -83,7 +83,7 @@ function setGeometry(target, internals, network, fillGeometry) {
|
|
|
83
83
|
0,
|
|
84
84
|
1
|
|
85
85
|
], network) : structuredClone(EMPTY_NETWORK);
|
|
86
|
-
const normalizedGeometry = fillGeometry.length > 0 ? regenerateFillGeometry(normalized, fillGeometry) : [];
|
|
86
|
+
const normalizedGeometry = fillGeometry.length > 0 ? regenerateFillGeometry(normalized, fillGeometry, node.cornerRadius) : [];
|
|
87
87
|
updateNode(target, internals, {
|
|
88
88
|
x: hasGeometry ? node.x + bounds.x : node.x,
|
|
89
89
|
y: hasGeometry ? node.y + bounds.y : node.y,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.js","names":[],"sources":["../../../src/figma-api/accessors/vector.ts"],"sourcesContent":["import type {\n GeometryPath,\n HandleMirroring,\n VectorNetwork as SceneVectorNetwork,\n VectorSegment,\n VectorVertex,\n WindingRule\n} from '@pairdraw/scene-graph'\nimport { parsePluginVectorPath } from '@pairdraw/scene-graph/parse-path'\nimport {\n mergeVectorNetworks,\n normalizeVectorNetwork,\n transformVectorNetwork,\n validateVectorNetwork,\n vectorNetworkPaths\n} from '@pairdraw/scene-graph/vector-network'\n\nimport {\n graph,\n prepareFollowedFieldEdit,\n raw,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from '#core/figma-api/paints'\nimport { geometryBlobToSVGPath } from '#core/io/formats/svg/paths'\nimport { computeAccurateBounds } from '#core/vector/curve-math'\nimport { regenerateFillGeometry } from '#core/vector/fill-geometry'\n\nexport interface FigmaVectorPath {\n readonly windingRule: WindingRule | 'NONE'\n readonly data: string\n}\n\ninterface FigmaVectorRegion {\n readonly windingRule: WindingRule\n readonly loops: ReadonlyArray<ReadonlyArray<number>>\n readonly fills?: readonly FigmaPaint[]\n readonly fillStyleId?: string\n}\n\nexport interface FigmaVectorNetwork {\n readonly vertices: readonly VectorVertex[]\n readonly segments: readonly (Omit<VectorSegment, 'tangentStart' | 'tangentEnd'> & {\n readonly tangentStart?: VectorSegment['tangentStart']\n readonly tangentEnd?: VectorSegment['tangentEnd']\n })[]\n readonly regions?: readonly FigmaVectorRegion[]\n}\n\nconst EMPTY_NETWORK: SceneVectorNetwork = { vertices: [], segments: [], regions: [] }\nconst HANDLE_MIRRORING_VALUES = new Set<HandleMirroring>(['NONE', 'ANGLE', 'ANGLE_AND_LENGTH'])\n\nfunction networkFromVectorPaths(paths: readonly FigmaVectorPath[]): SceneVectorNetwork {\n const networks: SceneVectorNetwork[] = []\n for (let index = 0; index < paths.length; index++) {\n const path: unknown = paths[index]\n if (typeof path !== 'object' || path === null || !('data' in path)) {\n throw new TypeError(`vectorPaths[${index}].data must be a string`)\n }\n const data = path.data\n if (typeof data !== 'string') {\n throw new TypeError(`vectorPaths[${index}].data must be a string`)\n }\n const windingRule: unknown = 'windingRule' in path ? path.windingRule : undefined\n if (windingRule !== 'NONZERO' && windingRule !== 'EVENODD' && windingRule !== 'NONE') {\n throw new TypeError(`vectorPaths[${index}].windingRule is invalid`)\n }\n const parsed = parsePluginVectorPath(data, windingRule)\n if (!parsed.ok) throw new TypeError(`Invalid vector path: ${parsed.error}`)\n if (parsed.network.segments.length > 0) networks.push(parsed.network)\n }\n return networks.length > 0 ? mergeVectorNetworks(networks) : structuredClone(EMPTY_NETWORK)\n}\n\nfunction normalizeInputNetwork(value: FigmaVectorNetwork): SceneVectorNetwork {\n const regions = value.regions ?? []\n return normalizeVectorNetwork({\n vertices: value.vertices.map((vertex) => ({ ...vertex })),\n segments: value.segments.map((segment) => ({\n ...segment,\n tangentStart: {\n x: segment.tangentStart?.x ?? 0,\n y: segment.tangentStart?.y ?? 0\n },\n tangentEnd: {\n x: segment.tangentEnd?.x ?? 0,\n y: segment.tangentEnd?.y ?? 0\n }\n })),\n regions: regions.map((region) => ({\n windingRule: region.windingRule,\n loops: region.loops.map((loop) => [...loop])\n }))\n })\n}\n\nfunction validateRegionPaintMetadata(regions: readonly FigmaVectorRegion[]): void {\n for (let index = 0; index < regions.length; index++) {\n const region = regions[index]\n if (region.fills !== undefined && !Array.isArray(region.fills)) {\n throw new TypeError(`vectorNetwork.regions[${index}].fills must be an array`)\n }\n if (region.fillStyleId !== undefined && typeof region.fillStyleId !== 'string') {\n throw new TypeError(`vectorNetwork.regions[${index}].fillStyleId must be a string`)\n }\n }\n}\n\nfunction geometryForRegions(regions: readonly FigmaVectorRegion[]): GeometryPath[] {\n if (!regions.some((region) => region.fills !== undefined || region.fillStyleId !== undefined)) {\n return []\n }\n return regions.map((region) => ({\n windingRule: region.windingRule,\n commandsBlob: new Uint8Array(),\n fills: parseFigmaPaints(region.fills ?? [], 'set_vectorNetwork', 'vectorNetwork'),\n fillStyleId: region.fillStyleId ?? ''\n }))\n}\n\nfunction setGeometry(\n target: ProxyThis,\n internals: NodeProxyInternals,\n network: SceneVectorNetwork,\n fillGeometry: GeometryPath[]\n): void {\n const node = raw(target, internals)\n const bounds = computeAccurateBounds(network)\n const hasGeometry = network.vertices.length > 0\n const normalized = hasGeometry\n ? transformVectorNetwork([1, 0, -bounds.x, 0, 1, -bounds.y, 0, 0, 1], network)\n : structuredClone(EMPTY_NETWORK)\n const normalizedGeometry =\n fillGeometry.length > 0 ? regenerateFillGeometry(normalized, fillGeometry) : []\n\n updateNode(target, internals, {\n x: hasGeometry ? node.x + bounds.x : node.x,\n y: hasGeometry ? node.y + bounds.y : node.y,\n width: hasGeometry ? bounds.width : 0,\n height: hasGeometry ? bounds.height : 0,\n vectorNetwork: normalized,\n fillGeometry: normalizedGeometry,\n strokeGeometry: []\n })\n}\n\n/** A vector inside an instance draws its component's path, which Figma refuses to override. */\nfunction prepareVectorDataEdit(\n target: ProxyThis,\n internals: NodeProxyInternals,\n setter: string | null\n): void {\n prepareFollowedFieldEdit(graph(target, internals), raw(target, internals), setter, 'vector-data')\n}\n\n/** Checks the network before readying the edit, so a rejected one leaves a slot unclaimed. */\nfunction assignVectorNetwork(\n target: ProxyThis,\n internals: NodeProxyInternals,\n value: FigmaVectorNetwork,\n setter: string | null\n): void {\n const errors = validateVectorNetwork(value)\n if (errors.length > 0) throw new TypeError(`Invalid vectorNetwork: ${errors.join('; ')}`)\n validateRegionPaintMetadata(value.regions ?? [])\n const network = normalizeInputNetwork(value)\n const fillGeometry = geometryForRegions(value.regions ?? [])\n prepareVectorDataEdit(target, internals, setter)\n setGeometry(target, internals, network, fillGeometry)\n}\n\nfunction readVectorPaths(\n target: ProxyThis,\n internals: NodeProxyInternals\n): readonly FigmaVectorPath[] {\n const node = raw(target, internals)\n const paths =\n node.vectorNetwork && node.vectorNetwork.segments.length > 0\n ? vectorNetworkPaths(node.vectorNetwork)\n : node.fillGeometry.map((geometry) => ({\n windingRule: geometry.windingRule,\n data: geometryBlobToSVGPath(geometry.commandsBlob, null)\n }))\n return Object.freeze(paths.map((path) => Object.freeze(path)))\n}\n\nfunction readVectorNetwork(target: ProxyThis, internals: NodeProxyInternals): FigmaVectorNetwork {\n const node = raw(target, internals)\n const network = node.vectorNetwork ?? EMPTY_NETWORK\n const vertices = network.vertices.map((vertex) =>\n Object.freeze({\n ...vertex,\n strokeCap: vertex.strokeCap ?? node.strokeCap,\n strokeJoin: vertex.strokeJoin ?? node.strokeJoin,\n cornerRadius: vertex.cornerRadius ?? 0,\n handleMirroring: vertex.handleMirroring ?? 'NONE'\n })\n )\n const segments = network.segments.map((segment) =>\n Object.freeze({\n ...segment,\n tangentStart: Object.freeze({ ...segment.tangentStart }),\n tangentEnd: Object.freeze({ ...segment.tangentEnd })\n })\n )\n const sourceRegions = (network as Partial<SceneVectorNetwork>).regions ?? []\n const regions = sourceRegions.map((region, index) => {\n const geometry = node.fillGeometry.at(index)\n return Object.freeze({\n windingRule: region.windingRule,\n loops: Object.freeze(region.loops.map((loop) => Object.freeze([...loop]))),\n fillStyleId: geometry?.fillStyleId ?? '',\n fills: Object.freeze((geometry?.fills ?? []).map((paint) => toFigmaPaint(paint)))\n })\n })\n return Object.freeze({\n vertices: Object.freeze(vertices),\n segments: Object.freeze(segments),\n regions: Object.freeze(regions)\n })\n}\n\nfunction readHandleMirroring(\n target: ProxyThis,\n internals: NodeProxyInternals,\n mixed: symbol\n): HandleMirroring | symbol {\n const node = raw(target, internals)\n const values = new Set(\n (node.vectorNetwork?.vertices ?? []).map((vertex) => vertex.handleMirroring ?? 'NONE')\n )\n if (values.size === 0) return node.handleMirroring\n if (values.size > 1) return mixed\n return values.values().next().value ?? node.handleMirroring\n}\n\nexport function installVectorNodeProxyAccessors(\n target: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(target, {\n vectorPaths: {\n get(this: ProxyThis): readonly FigmaVectorPath[] {\n return readVectorPaths(this, internals)\n },\n set(this: ProxyThis, value: readonly FigmaVectorPath[]) {\n if (!Array.isArray(value)) throw new TypeError('vectorPaths must be an array')\n const network = networkFromVectorPaths(value)\n prepareVectorDataEdit(this, internals, 'vectorPaths')\n setGeometry(this, internals, network, [])\n },\n enumerable: true,\n configurable: true\n },\n vectorNetwork: {\n get(this: ProxyThis): FigmaVectorNetwork {\n return readVectorNetwork(this, internals)\n },\n set(this: ProxyThis, value: FigmaVectorNetwork) {\n assignVectorNetwork(this, internals, value, 'vectorNetwork')\n },\n enumerable: true,\n configurable: true\n },\n setVectorNetworkAsync: {\n value(this: ProxyThis, value: FigmaVectorNetwork): Promise<void> {\n try {\n assignVectorNetwork(this, internals, value, null)\n return Promise.resolve()\n } catch (error) {\n return Promise.reject(error instanceof Error ? error : new Error(String(error)))\n }\n },\n enumerable: true,\n configurable: true\n },\n handleMirroring: {\n get(this: ProxyThis): HandleMirroring | symbol {\n return readHandleMirroring(this, internals, mixed)\n },\n set(this: ProxyThis, value: HandleMirroring) {\n if (!HANDLE_MIRRORING_VALUES.has(value)) {\n throw new TypeError(`Invalid handleMirroring: ${String(value)}`)\n }\n const node = raw(this, internals)\n prepareFollowedFieldEdit(\n graph(this, internals),\n node,\n 'handleMirroring',\n 'handle-mirroring'\n )\n updateNode(this, internals, {\n handleMirroring: value,\n vectorNetwork: node.vectorNetwork\n ? {\n ...node.vectorNetwork,\n vertices: node.vectorNetwork.vertices.map((vertex) => ({\n ...vertex,\n handleMirroring: value\n }))\n }\n : null\n })\n },\n enumerable: true,\n configurable: true\n }\n })\n}\n"],"mappings":";;;;;;;;AAmDA,MAAM,gBAAoC;CAAE,UAAU,CAAC;CAAG,UAAU,CAAC;CAAG,SAAS,CAAC;AAAE;AACpF,MAAM,0CAA0B,IAAI,IAAqB;CAAC;CAAQ;CAAS;AAAkB,CAAC;AAE9F,SAAS,uBAAuB,OAAuD;CACrF,MAAM,WAAiC,CAAC;CACxC,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,OAAgB,MAAM;EAC5B,IAAI,OAAO,SAAS,YAAY,SAAS,QAA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C9C,oBAAoB,MAAM,WAAW,OAAO,eAAe;GAC7D;GACA,YAAY;GACZ,cAAc;EAChB;EACA,uBAAuB;GACrB,MAAuB,OAA0C;IAC/D,IAAI;KACF,oBAAoB,MAAM,WAAW,OAAO,IAAI;KAChD,OAAO,QAAQ,QAAQ;IACzB,SAAS,OAAO;KACd,OAAO,QAAQ,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;IACjF;GACF;GACA,YAAY;GACZ,cAAc;EAChB;EACA,iBAAiB;GACf,MAA+C;IAC7C,OAAO,oBAAoB,MAAM,WAAW,KAAK;GACnD;GACA,IAAqB,OAAwB;IAC3C,IAAI,CAAC,wBAAwB,IAAI,KAAK,GACpC,MAAM,IAAI,UAAU,4BAA4B,OAAO,KAAK,GAAG;IAEjE,MAAM,OAAO,IAAI,MAAM,SAAS;IAChC,yBACE,MAAM,MAAM,SAAS,GACrB,MACA,mBACA,kBACF;IACA,WAAW,MAAM,WAAW;KAC1B,iBAAiB;KACjB,eAAe,KAAK,gBAChB;MACE,GAAG,KAAK;MACR,UAAU,KAAK,cAAc,SAAS,KAAK,YAAY;OACrD,GAAG;OACH,iBAAiB;MACnB,EAAE;KACJ,IACA;IACN,CAAC;GACH;GACA,YAAY;GACZ,cAAc;EAChB;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"vector.js","names":[],"sources":["../../../src/figma-api/accessors/vector.ts"],"sourcesContent":["import type {\n GeometryPath,\n HandleMirroring,\n VectorNetwork as SceneVectorNetwork,\n VectorSegment,\n VectorVertex,\n WindingRule\n} from '@pairdraw/scene-graph'\nimport { parsePluginVectorPath } from '@pairdraw/scene-graph/parse-path'\nimport {\n mergeVectorNetworks,\n normalizeVectorNetwork,\n transformVectorNetwork,\n validateVectorNetwork,\n vectorNetworkPaths\n} from '@pairdraw/scene-graph/vector-network'\n\nimport {\n graph,\n prepareFollowedFieldEdit,\n raw,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from '#core/figma-api/paints'\nimport { geometryBlobToSVGPath } from '#core/io/formats/svg/paths'\nimport { computeAccurateBounds } from '#core/vector/curve-math'\nimport { regenerateFillGeometry } from '#core/vector/fill-geometry'\n\nexport interface FigmaVectorPath {\n readonly windingRule: WindingRule | 'NONE'\n readonly data: string\n}\n\ninterface FigmaVectorRegion {\n readonly windingRule: WindingRule\n readonly loops: ReadonlyArray<ReadonlyArray<number>>\n readonly fills?: readonly FigmaPaint[]\n readonly fillStyleId?: string\n}\n\nexport interface FigmaVectorNetwork {\n readonly vertices: readonly VectorVertex[]\n readonly segments: readonly (Omit<VectorSegment, 'tangentStart' | 'tangentEnd'> & {\n readonly tangentStart?: VectorSegment['tangentStart']\n readonly tangentEnd?: VectorSegment['tangentEnd']\n })[]\n readonly regions?: readonly FigmaVectorRegion[]\n}\n\nconst EMPTY_NETWORK: SceneVectorNetwork = { vertices: [], segments: [], regions: [] }\nconst HANDLE_MIRRORING_VALUES = new Set<HandleMirroring>(['NONE', 'ANGLE', 'ANGLE_AND_LENGTH'])\n\nfunction networkFromVectorPaths(paths: readonly FigmaVectorPath[]): SceneVectorNetwork {\n const networks: SceneVectorNetwork[] = []\n for (let index = 0; index < paths.length; index++) {\n const path: unknown = paths[index]\n if (typeof path !== 'object' || path === null || !('data' in path)) {\n throw new TypeError(`vectorPaths[${index}].data must be a string`)\n }\n const data = path.data\n if (typeof data !== 'string') {\n throw new TypeError(`vectorPaths[${index}].data must be a string`)\n }\n const windingRule: unknown = 'windingRule' in path ? path.windingRule : undefined\n if (windingRule !== 'NONZERO' && windingRule !== 'EVENODD' && windingRule !== 'NONE') {\n throw new TypeError(`vectorPaths[${index}].windingRule is invalid`)\n }\n const parsed = parsePluginVectorPath(data, windingRule)\n if (!parsed.ok) throw new TypeError(`Invalid vector path: ${parsed.error}`)\n if (parsed.network.segments.length > 0) networks.push(parsed.network)\n }\n return networks.length > 0 ? mergeVectorNetworks(networks) : structuredClone(EMPTY_NETWORK)\n}\n\nfunction normalizeInputNetwork(value: FigmaVectorNetwork): SceneVectorNetwork {\n const regions = value.regions ?? []\n return normalizeVectorNetwork({\n vertices: value.vertices.map((vertex) => ({ ...vertex })),\n segments: value.segments.map((segment) => ({\n ...segment,\n tangentStart: {\n x: segment.tangentStart?.x ?? 0,\n y: segment.tangentStart?.y ?? 0\n },\n tangentEnd: {\n x: segment.tangentEnd?.x ?? 0,\n y: segment.tangentEnd?.y ?? 0\n }\n })),\n regions: regions.map((region) => ({\n windingRule: region.windingRule,\n loops: region.loops.map((loop) => [...loop])\n }))\n })\n}\n\nfunction validateRegionPaintMetadata(regions: readonly FigmaVectorRegion[]): void {\n for (let index = 0; index < regions.length; index++) {\n const region = regions[index]\n if (region.fills !== undefined && !Array.isArray(region.fills)) {\n throw new TypeError(`vectorNetwork.regions[${index}].fills must be an array`)\n }\n if (region.fillStyleId !== undefined && typeof region.fillStyleId !== 'string') {\n throw new TypeError(`vectorNetwork.regions[${index}].fillStyleId must be a string`)\n }\n }\n}\n\nfunction geometryForRegions(regions: readonly FigmaVectorRegion[]): GeometryPath[] {\n if (!regions.some((region) => region.fills !== undefined || region.fillStyleId !== undefined)) {\n return []\n }\n return regions.map((region) => ({\n windingRule: region.windingRule,\n commandsBlob: new Uint8Array(),\n fills: parseFigmaPaints(region.fills ?? [], 'set_vectorNetwork', 'vectorNetwork'),\n fillStyleId: region.fillStyleId ?? ''\n }))\n}\n\nfunction setGeometry(\n target: ProxyThis,\n internals: NodeProxyInternals,\n network: SceneVectorNetwork,\n fillGeometry: GeometryPath[]\n): void {\n const node = raw(target, internals)\n const bounds = computeAccurateBounds(network)\n const hasGeometry = network.vertices.length > 0\n const normalized = hasGeometry\n ? transformVectorNetwork([1, 0, -bounds.x, 0, 1, -bounds.y, 0, 0, 1], network)\n : structuredClone(EMPTY_NETWORK)\n const normalizedGeometry =\n fillGeometry.length > 0\n ? regenerateFillGeometry(normalized, fillGeometry, node.cornerRadius)\n : []\n\n updateNode(target, internals, {\n x: hasGeometry ? node.x + bounds.x : node.x,\n y: hasGeometry ? node.y + bounds.y : node.y,\n width: hasGeometry ? bounds.width : 0,\n height: hasGeometry ? bounds.height : 0,\n vectorNetwork: normalized,\n fillGeometry: normalizedGeometry,\n strokeGeometry: []\n })\n}\n\n/** A vector inside an instance draws its component's path, which Figma refuses to override. */\nfunction prepareVectorDataEdit(\n target: ProxyThis,\n internals: NodeProxyInternals,\n setter: string | null\n): void {\n prepareFollowedFieldEdit(graph(target, internals), raw(target, internals), setter, 'vector-data')\n}\n\n/** Checks the network before readying the edit, so a rejected one leaves a slot unclaimed. */\nfunction assignVectorNetwork(\n target: ProxyThis,\n internals: NodeProxyInternals,\n value: FigmaVectorNetwork,\n setter: string | null\n): void {\n const errors = validateVectorNetwork(value)\n if (errors.length > 0) throw new TypeError(`Invalid vectorNetwork: ${errors.join('; ')}`)\n validateRegionPaintMetadata(value.regions ?? [])\n const network = normalizeInputNetwork(value)\n const fillGeometry = geometryForRegions(value.regions ?? [])\n prepareVectorDataEdit(target, internals, setter)\n setGeometry(target, internals, network, fillGeometry)\n}\n\nfunction readVectorPaths(\n target: ProxyThis,\n internals: NodeProxyInternals\n): readonly FigmaVectorPath[] {\n const node = raw(target, internals)\n const paths =\n node.vectorNetwork && node.vectorNetwork.segments.length > 0\n ? vectorNetworkPaths(node.vectorNetwork)\n : node.fillGeometry.map((geometry) => ({\n windingRule: geometry.windingRule,\n data: geometryBlobToSVGPath(geometry.commandsBlob, null)\n }))\n return Object.freeze(paths.map((path) => Object.freeze(path)))\n}\n\nfunction readVectorNetwork(target: ProxyThis, internals: NodeProxyInternals): FigmaVectorNetwork {\n const node = raw(target, internals)\n const network = node.vectorNetwork ?? EMPTY_NETWORK\n const vertices = network.vertices.map((vertex) =>\n Object.freeze({\n ...vertex,\n strokeCap: vertex.strokeCap ?? node.strokeCap,\n strokeJoin: vertex.strokeJoin ?? node.strokeJoin,\n cornerRadius: vertex.cornerRadius ?? 0,\n handleMirroring: vertex.handleMirroring ?? 'NONE'\n })\n )\n const segments = network.segments.map((segment) =>\n Object.freeze({\n ...segment,\n tangentStart: Object.freeze({ ...segment.tangentStart }),\n tangentEnd: Object.freeze({ ...segment.tangentEnd })\n })\n )\n const sourceRegions = (network as Partial<SceneVectorNetwork>).regions ?? []\n const regions = sourceRegions.map((region, index) => {\n const geometry = node.fillGeometry.at(index)\n return Object.freeze({\n windingRule: region.windingRule,\n loops: Object.freeze(region.loops.map((loop) => Object.freeze([...loop]))),\n fillStyleId: geometry?.fillStyleId ?? '',\n fills: Object.freeze((geometry?.fills ?? []).map((paint) => toFigmaPaint(paint)))\n })\n })\n return Object.freeze({\n vertices: Object.freeze(vertices),\n segments: Object.freeze(segments),\n regions: Object.freeze(regions)\n })\n}\n\nfunction readHandleMirroring(\n target: ProxyThis,\n internals: NodeProxyInternals,\n mixed: symbol\n): HandleMirroring | symbol {\n const node = raw(target, internals)\n const values = new Set(\n (node.vectorNetwork?.vertices ?? []).map((vertex) => vertex.handleMirroring ?? 'NONE')\n )\n if (values.size === 0) return node.handleMirroring\n if (values.size > 1) return mixed\n return values.values().next().value ?? node.handleMirroring\n}\n\nexport function installVectorNodeProxyAccessors(\n target: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(target, {\n vectorPaths: {\n get(this: ProxyThis): readonly FigmaVectorPath[] {\n return readVectorPaths(this, internals)\n },\n set(this: ProxyThis, value: readonly FigmaVectorPath[]) {\n if (!Array.isArray(value)) throw new TypeError('vectorPaths must be an array')\n const network = networkFromVectorPaths(value)\n prepareVectorDataEdit(this, internals, 'vectorPaths')\n setGeometry(this, internals, network, [])\n },\n enumerable: true,\n configurable: true\n },\n vectorNetwork: {\n get(this: ProxyThis): FigmaVectorNetwork {\n return readVectorNetwork(this, internals)\n },\n set(this: ProxyThis, value: FigmaVectorNetwork) {\n assignVectorNetwork(this, internals, value, 'vectorNetwork')\n },\n enumerable: true,\n configurable: true\n },\n setVectorNetworkAsync: {\n value(this: ProxyThis, value: FigmaVectorNetwork): Promise<void> {\n try {\n assignVectorNetwork(this, internals, value, null)\n return Promise.resolve()\n } catch (error) {\n return Promise.reject(error instanceof Error ? error : new Error(String(error)))\n }\n },\n enumerable: true,\n configurable: true\n },\n handleMirroring: {\n get(this: ProxyThis): HandleMirroring | symbol {\n return readHandleMirroring(this, internals, mixed)\n },\n set(this: ProxyThis, value: HandleMirroring) {\n if (!HANDLE_MIRRORING_VALUES.has(value)) {\n throw new TypeError(`Invalid handleMirroring: ${String(value)}`)\n }\n const node = raw(this, internals)\n prepareFollowedFieldEdit(\n graph(this, internals),\n node,\n 'handleMirroring',\n 'handle-mirroring'\n )\n updateNode(this, internals, {\n handleMirroring: value,\n vectorNetwork: node.vectorNetwork\n ? {\n ...node.vectorNetwork,\n vertices: node.vectorNetwork.vertices.map((vertex) => ({\n ...vertex,\n handleMirroring: value\n }))\n }\n : null\n })\n },\n enumerable: true,\n configurable: true\n }\n })\n}\n"],"mappings":";;;;;;;;AAmDA,MAAM,gBAAoC;CAAE,UAAU,CAAC;CAAG,UAAU,CAAC;CAAG,SAAS,CAAC;AAAE;AACpF,MAAM,0CAA0B,IAAI,IAAqB;CAAC;CAAQ;CAAS;AAAkB,CAAC;AAE9F,SAAS,uBAAuB,OAAuD;CACrF,MAAM,WAAiC,CAAC;CACxC,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,OAAgB,MAAM;EAC5B,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,EAAE,UAAU,OAC3D,MAAM,IAAI,UAAU,eAAe,MAAM,wBAAwB;EAEnE,MAAM,OAAO,KAAK;EAClB,IAAI,OAAO,SAAS,UAClB,MAAM,IAAI,UAAU,eAAe,MAAM,wBAAwB;EAEnE,MAAM,cAAuB,iBAAiB,OAAO,KAAK,cAAc,KAAA;EACxE,IAAI,gBAAgB,aAAa,gBAAgB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iB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;IACjF;GACF;GACA,YAAY;GACZ,cAAc;EAChB;EACA,iBAAiB;GACf,MAA+C;IAC7C,OAAO,oBAAoB,MAAM,WAAW,KAAK;GACnD;GACA,IAAqB,OAAwB;IAC3C,IAAI,CAAC,wBAAwB,IAAI,KAAK,GACpC,MAAM,IAAI,UAAU,4BAA4B,OAAO,KAAK,GAAG;IAEjE,MAAM,OAAO,IAAI,MAAM,SAAS;IAChC,yBACE,MAAM,MAAM,SAAS,GACrB,MACA,mBACA,kBACF;IACA,WAAW,MAAM,WAAW;KAC1B,iBAAiB;KACjB,eAAe,KAAK,gBAChB;MACE,GAAG,KAAK;MACR,UAAU,KAAK,cAAc,SAAS,KAAK,YAAY;OACrD,GAAG;OACH,iBAAiB;MACnB,EAAE;KACJ,IACA;IACN,CAAC;GACH;GACA,YAAY;GACZ,cAAc;EAChB;CACF,CAAC;AACH"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { NodeProxyInternals } from "../accessor-utils.js";
|
|
2
2
|
import { FigmaPaint } from "../paints.js";
|
|
3
|
-
import {
|
|
3
|
+
import { SceneNode } from "@pairdraw/scene-graph";
|
|
4
4
|
//#region src/figma-api/accessors/visual.d.ts
|
|
5
5
|
/**
|
|
6
|
-
* `node`'s fills as Figma's plugin API reads them,
|
|
7
|
-
* variable
|
|
6
|
+
* `node`'s fills as Figma's plugin API reads them, each carrying the variable it is bound to. A
|
|
7
|
+
* bound paint reads as it stores its color and opacity, which its variable writes into it when it
|
|
8
|
+
* binds and whenever the color it gives the layer changes, as in Figma.
|
|
8
9
|
*/
|
|
9
|
-
declare function figmaFills(
|
|
10
|
+
declare function figmaFills(node: SceneNode): FigmaPaint[];
|
|
10
11
|
/** `node`'s strokes as Figma's plugin API reads them, as {@link figmaFills} reads fills. */
|
|
11
|
-
declare function figmaStrokes(
|
|
12
|
+
declare function figmaStrokes(node: SceneNode): FigmaPaint[];
|
|
12
13
|
declare function installVisualNodeProxyAccessors(prototype: object, internals: NodeProxyInternals, mixed: symbol): void;
|
|
13
14
|
//#endregion
|
|
14
15
|
export { figmaFills, figmaStrokes, installVisualNodeProxyAccessors };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual.d.ts","names":[],"sources":["../../../src/figma-api/accessors/visual.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"visual.d.ts","names":[],"sources":["../../../src/figma-api/accessors/visual.ts"],"mappings":";;;;;;;;;iBAkDgB,WAAW,MAAM,YAAY;;iBAM7B,aAAa,MAAM,YAAY;iBAK/B,gCACd,mBACA,WAAW,oBACX"}
|
|
@@ -3,8 +3,9 @@ import { parseFigmaEffects, toFigmaEffect } from "../effects.js";
|
|
|
3
3
|
import { parseFigmaPaints, toFigmaPaint } from "../paints.js";
|
|
4
4
|
import { getTextStyle } from "../text/style.js";
|
|
5
5
|
import { graph, raw, strokeOwner, updateNode } from "../accessor-utils.js";
|
|
6
|
+
import { finiteNumber } from "../finite.js";
|
|
6
7
|
import { paintBindings, setPaintBindings } from "../variables/bindings.js";
|
|
7
|
-
import { independentCornerChanges
|
|
8
|
+
import { independentCornerChanges } from "@pairdraw/scene-graph/variables";
|
|
8
9
|
import { newStrokeGeometry } from "@pairdraw/scene-graph/node-defaults";
|
|
9
10
|
//#region src/figma-api/accessors/visual.ts
|
|
10
11
|
function styleReference(internals, field, mixed) {
|
|
@@ -22,24 +23,25 @@ function styleReference(internals, field, mixed) {
|
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
|
-
* `node`'s fills as Figma's plugin API reads them,
|
|
26
|
-
* variable
|
|
26
|
+
* `node`'s fills as Figma's plugin API reads them, each carrying the variable it is bound to. A
|
|
27
|
+
* bound paint reads as it stores its color and opacity, which its variable writes into it when it
|
|
28
|
+
* binds and whenever the color it gives the layer changes, as in Figma.
|
|
27
29
|
*/
|
|
28
|
-
function figmaFills(
|
|
30
|
+
function figmaFills(node) {
|
|
29
31
|
const bound = paintBindings(node, "fills");
|
|
30
|
-
return
|
|
32
|
+
return node.fills.map((fill, index) => toFigmaPaint(fill, bound.get(index)));
|
|
31
33
|
}
|
|
32
34
|
/** `node`'s strokes as Figma's plugin API reads them, as {@link figmaFills} reads fills. */
|
|
33
|
-
function figmaStrokes(
|
|
35
|
+
function figmaStrokes(node) {
|
|
34
36
|
const bound = paintBindings(node, "strokes");
|
|
35
|
-
return
|
|
37
|
+
return node.strokes.map((stroke, index) => toFigmaPaint(stroke, bound.get(index)));
|
|
36
38
|
}
|
|
37
39
|
function installVisualNodeProxyAccessors(prototype, internals, mixed) {
|
|
38
40
|
Object.defineProperties(prototype, {
|
|
39
41
|
fills: {
|
|
40
42
|
get() {
|
|
41
43
|
const node = raw(this, internals);
|
|
42
|
-
if (node.type !== "TEXT") return Object.freeze(figmaFills(
|
|
44
|
+
if (node.type !== "TEXT") return Object.freeze(figmaFills(node));
|
|
43
45
|
const fills = getTextStyle(node, "fills", mixed);
|
|
44
46
|
return typeof fills === "symbol" ? fills : Object.freeze(fills);
|
|
45
47
|
},
|
|
@@ -53,7 +55,7 @@ function installVisualNodeProxyAccessors(prototype, internals, mixed) {
|
|
|
53
55
|
strokes: {
|
|
54
56
|
get() {
|
|
55
57
|
const owner = raw(strokeOwner(this, internals), internals);
|
|
56
|
-
return Object.freeze(figmaStrokes(
|
|
58
|
+
return Object.freeze(figmaStrokes(owner));
|
|
57
59
|
},
|
|
58
60
|
set(value) {
|
|
59
61
|
const owner = strokeOwner(this, internals);
|
|
@@ -93,7 +95,7 @@ function installVisualNodeProxyAccessors(prototype, internals, mixed) {
|
|
|
93
95
|
return raw(this, internals).opacity;
|
|
94
96
|
},
|
|
95
97
|
set(value) {
|
|
96
|
-
updateNode(this, internals, { opacity: value });
|
|
98
|
+
updateNode(this, internals, { opacity: finiteNumber(value, "opacity") });
|
|
97
99
|
}
|
|
98
100
|
},
|
|
99
101
|
visible: {
|
|
@@ -141,12 +143,13 @@ function installVisualNodeProxyAccessors(prototype, internals, mixed) {
|
|
|
141
143
|
},
|
|
142
144
|
set(value) {
|
|
143
145
|
if (value === mixed) return;
|
|
146
|
+
const radius = finiteNumber(value, "cornerRadius");
|
|
144
147
|
updateNode(this, internals, {
|
|
145
|
-
cornerRadius:
|
|
146
|
-
topLeftRadius:
|
|
147
|
-
topRightRadius:
|
|
148
|
-
bottomRightRadius:
|
|
149
|
-
bottomLeftRadius:
|
|
148
|
+
cornerRadius: radius,
|
|
149
|
+
topLeftRadius: radius,
|
|
150
|
+
topRightRadius: radius,
|
|
151
|
+
bottomRightRadius: radius,
|
|
152
|
+
bottomLeftRadius: radius,
|
|
150
153
|
independentCorners: false
|
|
151
154
|
});
|
|
152
155
|
}
|
|
@@ -160,7 +163,7 @@ function installVisualNodeProxyAccessors(prototype, internals, mixed) {
|
|
|
160
163
|
return raw(this, internals).cornerSmoothing;
|
|
161
164
|
},
|
|
162
165
|
set(value) {
|
|
163
|
-
updateNode(this, internals, { cornerSmoothing: value });
|
|
166
|
+
updateNode(this, internals, { cornerSmoothing: finiteNumber(value, "cornerSmoothing") });
|
|
164
167
|
}
|
|
165
168
|
}
|
|
166
169
|
});
|
|
@@ -173,7 +176,7 @@ function cornerAccessor(internals, field) {
|
|
|
173
176
|
set(value) {
|
|
174
177
|
updateNode(this, internals, {
|
|
175
178
|
...independentCornerChanges(raw(this, internals)),
|
|
176
|
-
[field]: value
|
|
179
|
+
[field]: finiteNumber(value, field)
|
|
177
180
|
});
|
|
178
181
|
}
|
|
179
182
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual.js","names":[],"sources":["../../../src/figma-api/accessors/visual.ts"],"sourcesContent":["import type { SceneGraph, SceneNode, ShadowEffect, Stroke } from '@pairdraw/scene-graph'\nimport { newStrokeGeometry } from '@pairdraw/scene-graph/node-defaults'\nimport { independentCornerChanges, resolvedPaintBindings } from '@pairdraw/scene-graph/variables'\n\nimport {\n graph,\n raw,\n strokeOwner,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport { parseFigmaEffects, toFigmaEffect, type FigmaEffect } from '#core/figma-api/effects'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from '#core/figma-api/paints'\nimport { getTextStyle } from '#core/figma-api/text/style'\nimport { paintBindings, setPaintBindings } from '#core/figma-api/variables/bindings'\nimport { textStyleChanges } from '#core/text/character-style'\n\nfunction styleReference(\n internals: NodeProxyInternals,\n field: 'fillStyleId' | 'strokeStyleId' | 'effectStyleId' | 'gridStyleId',\n mixed: symbol\n): PropertyDescriptor {\n return {\n get(this: ProxyThis): string | symbol {\n const node = raw(this, internals)\n // Characters of a text can each use a fill style of their own.\n if (field === 'fillStyleId' && node.type === 'TEXT') {\n return getTextStyle(node, 'fillStyleId', mixed) as string | symbol\n }\n return node[field] ?? ''\n },\n set(this: ProxyThis, value: string) {\n const node = raw(this, internals)\n const changes = { [field]: value || null }\n updateNode(\n this,\n internals,\n field === 'fillStyleId' && node.type === 'TEXT' ? textStyleChanges(node, changes) : changes\n )\n }\n }\n}\n\n/**\n * `node`'s fills as Figma's plugin API reads them, bound colours resolved and carrying the\n * variable they are bound to.\n */\nexport function figmaFills(sceneGraph: SceneGraph, node: SceneNode): FigmaPaint[] {\n const bound = paintBindings(node, 'fills')\n const fills = bound.size\n ? (resolvedPaintBindings(sceneGraph, node).fills ?? node.fills)\n : node.fills\n return fills.map((fill, index) => toFigmaPaint(fill, bound.get(index)))\n}\n\n/** `node`'s strokes as Figma's plugin API reads them, as {@link figmaFills} reads fills. */\nexport function figmaStrokes(sceneGraph: SceneGraph, node: SceneNode): FigmaPaint[] {\n const bound = paintBindings(node, 'strokes')\n const strokes = bound.size\n ? (resolvedPaintBindings(sceneGraph, node).strokes ?? node.strokes)\n : node.strokes\n return strokes.map((stroke, index) => toFigmaPaint(stroke, bound.get(index)))\n}\n\nexport function installVisualNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(prototype, {\n fills: {\n // Text reads mixed while its characters are filled differently, and setting it fills them all.\n get(this: ProxyThis): readonly FigmaPaint[] | symbol {\n const node = raw(this, internals)\n if (node.type !== 'TEXT') return Object.freeze(figmaFills(graph(this, internals), node))\n const fills = getTextStyle(node, 'fills', mixed)\n // Text styles read for scripts already give Figma's paints.\n return typeof fills === 'symbol' ? fills : Object.freeze(fills as FigmaPaint[])\n },\n set(this: ProxyThis, value: readonly FigmaPaint[]) {\n const node = raw(this, internals)\n const fills = parseFigmaPaints(value)\n updateNode(\n this,\n internals,\n node.type === 'TEXT' ? textStyleChanges(node, { fills }) : { fills }\n )\n setPaintBindings(graph(this, internals), raw(this, internals), 'fills', value)\n }\n },\n strokes: {\n get(this: ProxyThis): readonly FigmaPaint[] {\n const owner = raw(strokeOwner(this, internals), internals)\n return Object.freeze(figmaStrokes(graph(this, internals), owner))\n },\n // Figma paints carry no geometry; a stroke takes the node's weight and alignment, which\n // outlast its strokes.\n set(this: ProxyThis, value: readonly FigmaPaint[]) {\n const owner = strokeOwner(this, internals)\n const geometry = newStrokeGeometry(raw(owner, internals))\n const strokes = parseFigmaPaints(value, 'set_strokes', 'strokes').map((paint): Stroke => ({\n ...paint,\n weight: geometry.weight,\n align: geometry.align\n }))\n const kept = newStrokeGeometry({\n strokes,\n strokeWeight: geometry.weight,\n strokeAlign: geometry.align\n })\n updateNode(owner, internals, {\n strokes,\n strokeWeight: kept.weight,\n strokeAlign: kept.align\n })\n setPaintBindings(graph(this, internals), raw(owner, internals), 'strokes', value)\n }\n },\n effects: {\n get(this: ProxyThis): readonly FigmaEffect[] {\n // A shader effect has no Figma plugin-API form yet (`UNSUPPORTED_EFFECT_TYPES`).\n return Object.freeze(\n raw(this, internals)\n .effects.filter((effect): effect is ShadowEffect => effect.type !== 'SHADER')\n .map(toFigmaEffect)\n )\n },\n set(this: ProxyThis, value: readonly FigmaEffect[]) {\n updateNode(this, internals, { effects: parseFigmaEffects(value) })\n }\n },\n // Applied shared styles, as Figma exposes them; an assignment inside an instance is an override.\n fillStyleId: styleReference(internals, 'fillStyleId', mixed),\n strokeStyleId: styleReference(internals, 'strokeStyleId', mixed),\n effectStyleId: styleReference(internals, 'effectStyleId', mixed),\n gridStyleId: styleReference(internals, 'gridStyleId', mixed),\n opacity: {\n get(this: ProxyThis): number {\n return raw(this, internals).opacity\n },\n set(this: ProxyThis, value: number) {\n updateNode(this, internals, { opacity: value })\n }\n },\n visible: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).visible\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { visible: value })\n }\n },\n locked: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).locked\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { locked: value })\n }\n },\n blendMode: {\n get(this: ProxyThis): string {\n return raw(this, internals).blendMode\n },\n set(this: ProxyThis, value: string) {\n updateNode(this, internals, { blendMode: value as SceneNode['blendMode'] })\n }\n },\n clipsContent: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).clipsContent\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { clipsContent: value })\n }\n },\n cornerRadius: {\n get(this: ProxyThis): number | symbol {\n const node = raw(this, internals)\n if (!node.independentCorners) return node.cornerRadius\n // Corners set or bound one by one read as one radius while they agree, as in Figma.\n const { topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius } = node\n const agree = [topRightRadius, bottomLeftRadius, bottomRightRadius].every(\n (radius) => radius === topLeftRadius\n )\n return agree ? topLeftRadius : mixed\n },\n set(this: ProxyThis, value: number | symbol) {\n if (value === mixed) return\n updateNode(this, internals, {\n cornerRadius: value as number,\n topLeftRadius: value as number,\n topRightRadius: value as number,\n bottomRightRadius: value as number,\n bottomLeftRadius: value as number,\n independentCorners: false\n })\n }\n },\n topLeftRadius: cornerAccessor(internals, 'topLeftRadius'),\n topRightRadius: cornerAccessor(internals, 'topRightRadius'),\n bottomLeftRadius: cornerAccessor(internals, 'bottomLeftRadius'),\n bottomRightRadius: cornerAccessor(internals, 'bottomRightRadius'),\n cornerSmoothing: {\n get(this: ProxyThis): number {\n return raw(this, internals).cornerSmoothing\n },\n set(this: ProxyThis, value: number) {\n updateNode(this, internals, { cornerSmoothing: value })\n }\n }\n })\n}\n\nfunction cornerAccessor(\n internals: NodeProxyInternals,\n field: 'topLeftRadius' | 'topRightRadius' | 'bottomLeftRadius' | 'bottomRightRadius'\n): PropertyDescriptor {\n return {\n get(this: ProxyThis): number {\n return raw(this, internals)[field]\n },\n set(this: ProxyThis, value: number) {\n updateNode(this, internals, {\n ...independentCornerChanges(raw(this, internals)),\n [field]: value\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAS,eACP,WACA,OACA,OACoB;CACpB,OAAO;EACL,MAAsC;GACpC,MAAM,OAAO,IAAI,MAAM,SAAS;GAEhC,IAAI,UAAU,iBAAiB,KAAK,SAAS,QAC3C,OAAO,aAAa,MAAM,eAAe,KAAK;GAEhD,OAAO,KAAK,UAAU;EACxB;EACA,IAAqB,OAAe;GAClC,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,MAAM,UAAU,GAAG,QAAQ,SAAS,KAAK;GACzC,WACE,MACA,WACA,UAAU,iBAAiB,KAAK,SAAS,SAAS,iBAAiB,MAAM,OAAO,IAAI,OACtF;EACF;CACF;AACF;;;;;AAMA,SAAgB,WAAW,YAAwB,MAA+B;CAChF,MAAM,QAAQ,cAAc,MAAM,OAAO;CAIzC,QAHc,MAAM,OACf,sBAAsB,YAAY,IAAI,CAAC,CAAC,SAAS,KAAK,QACvD,KAAK,MAAA,CACI,KAAK,MAAM,UAAU,aAAa,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC;AACxE;;AAGA,SAAgB,aAAa,YAAwB,MAA+B;CAClF,MAAM,QAAQ,cAAc,MAAM,SAAS;CAI3C,QAHgB,MAAM,OACjB,sBAAsB,YAAY,IAAI,CAAC,CAAC,WAAW,KA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CAAC;GACrD;EACF;EACA,cAAc;GACZ,MAAsC;IACpC,MAAM,OAAO,IAAI,MAAM,SAAS;IAChC,IAAI,CAAC,KAAK,oBAAoB,OAAO,KAAK;IAE1C,MAAM,EAAE,eAAe,gBAAgB,kBAAkB,sBAAsB;IAI/E,OAHc;KAAC;KAAgB;KAAkB;IAAiB,CAAC,CAAC,OACjE,WAAW,WAAW,aAEd,IAAI,gBAAgB;GACjC;GACA,IAAqB,OAAwB;IAC3C,IAAI,UAAU,OAAO;IACrB,WAAW,MAAM,WAAW;KAC1B,cAAc;KACd,eAAe;KACf,gBAAgB;KAChB,mBAAmB;KACnB,kBAAkB;KAClB,oBAAoB;IACtB,CAAC;GACH;EACF;EACA,eAAe,eAAe,WAAW,eAAe;EACxD,gBAAgB,eAAe,WAAW,gBAAgB;EAC1D,kBAAkB,eAAe,WAAW,kBAAkB;EAC9D,mBAAmB,eAAe,WAAW,mBAAmB;EAChE,iBAAiB;GACf,MAA6B;IAC3B,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;GAC9B;GACA,IAAqB,OAAe;IAClC,WAAW,MAAM,WAAW,EAAE,iBAAiB,MAAM,CAAC;GACxD;EACF;CACF,CAAC;AACH;AAEA,SAAS,eACP,WACA,OACoB;CACpB,OAAO;EACL,MAA6B;GAC3B,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;EAC9B;EACA,IAAqB,OAAe;GAClC,WAAW,MAAM,WAAW;IAC1B,GAAG,yBAAyB,IAAI,MAAM,SAAS,CAAC;KAC/C,QAAQ;GACX,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"visual.js","names":[],"sources":["../../../src/figma-api/accessors/visual.ts"],"sourcesContent":["import type { SceneNode, ShadowEffect, Stroke } from '@pairdraw/scene-graph'\nimport { newStrokeGeometry } from '@pairdraw/scene-graph/node-defaults'\nimport { independentCornerChanges } from '@pairdraw/scene-graph/variables'\n\nimport {\n graph,\n raw,\n strokeOwner,\n updateNode,\n type NodeProxyInternals,\n type ProxyThis\n} from '#core/figma-api/accessor-utils'\nimport { parseFigmaEffects, toFigmaEffect, type FigmaEffect } from '#core/figma-api/effects'\nimport { finiteNumber } from '#core/figma-api/finite'\nimport { parseFigmaPaints, toFigmaPaint, type FigmaPaint } from '#core/figma-api/paints'\nimport { getTextStyle } from '#core/figma-api/text/style'\nimport { paintBindings, setPaintBindings } from '#core/figma-api/variables/bindings'\nimport { textStyleChanges } from '#core/text/character-style'\n\nfunction styleReference(\n internals: NodeProxyInternals,\n field: 'fillStyleId' | 'strokeStyleId' | 'effectStyleId' | 'gridStyleId',\n mixed: symbol\n): PropertyDescriptor {\n return {\n get(this: ProxyThis): string | symbol {\n const node = raw(this, internals)\n // Characters of a text can each use a fill style of their own.\n if (field === 'fillStyleId' && node.type === 'TEXT') {\n return getTextStyle(node, 'fillStyleId', mixed) as string | symbol\n }\n return node[field] ?? ''\n },\n set(this: ProxyThis, value: string) {\n const node = raw(this, internals)\n const changes = { [field]: value || null }\n updateNode(\n this,\n internals,\n field === 'fillStyleId' && node.type === 'TEXT' ? textStyleChanges(node, changes) : changes\n )\n }\n }\n}\n\n/**\n * `node`'s fills as Figma's plugin API reads them, each carrying the variable it is bound to. A\n * bound paint reads as it stores its color and opacity, which its variable writes into it when it\n * binds and whenever the color it gives the layer changes, as in Figma.\n */\nexport function figmaFills(node: SceneNode): FigmaPaint[] {\n const bound = paintBindings(node, 'fills')\n return node.fills.map((fill, index) => toFigmaPaint(fill, bound.get(index)))\n}\n\n/** `node`'s strokes as Figma's plugin API reads them, as {@link figmaFills} reads fills. */\nexport function figmaStrokes(node: SceneNode): FigmaPaint[] {\n const bound = paintBindings(node, 'strokes')\n return node.strokes.map((stroke, index) => toFigmaPaint(stroke, bound.get(index)))\n}\n\nexport function installVisualNodeProxyAccessors(\n prototype: object,\n internals: NodeProxyInternals,\n mixed: symbol\n): void {\n Object.defineProperties(prototype, {\n fills: {\n // Text reads mixed while its characters are filled differently, and setting it fills them all.\n get(this: ProxyThis): readonly FigmaPaint[] | symbol {\n const node = raw(this, internals)\n if (node.type !== 'TEXT') return Object.freeze(figmaFills(node))\n const fills = getTextStyle(node, 'fills', mixed)\n // Text styles read for scripts already give Figma's paints.\n return typeof fills === 'symbol' ? fills : Object.freeze(fills as FigmaPaint[])\n },\n set(this: ProxyThis, value: readonly FigmaPaint[]) {\n const node = raw(this, internals)\n const fills = parseFigmaPaints(value)\n updateNode(\n this,\n internals,\n node.type === 'TEXT' ? textStyleChanges(node, { fills }) : { fills }\n )\n setPaintBindings(graph(this, internals), raw(this, internals), 'fills', value)\n }\n },\n strokes: {\n get(this: ProxyThis): readonly FigmaPaint[] {\n const owner = raw(strokeOwner(this, internals), internals)\n return Object.freeze(figmaStrokes(owner))\n },\n // Figma paints carry no geometry; a stroke takes the node's weight and alignment, which\n // outlast its strokes.\n set(this: ProxyThis, value: readonly FigmaPaint[]) {\n const owner = strokeOwner(this, internals)\n const geometry = newStrokeGeometry(raw(owner, internals))\n const strokes = parseFigmaPaints(value, 'set_strokes', 'strokes').map((paint): Stroke => ({\n ...paint,\n weight: geometry.weight,\n align: geometry.align\n }))\n const kept = newStrokeGeometry({\n strokes,\n strokeWeight: geometry.weight,\n strokeAlign: geometry.align\n })\n updateNode(owner, internals, {\n strokes,\n strokeWeight: kept.weight,\n strokeAlign: kept.align\n })\n setPaintBindings(graph(this, internals), raw(owner, internals), 'strokes', value)\n }\n },\n effects: {\n get(this: ProxyThis): readonly FigmaEffect[] {\n // A shader effect has no Figma plugin-API form yet (`UNSUPPORTED_EFFECT_TYPES`).\n return Object.freeze(\n raw(this, internals)\n .effects.filter((effect): effect is ShadowEffect => effect.type !== 'SHADER')\n .map(toFigmaEffect)\n )\n },\n set(this: ProxyThis, value: readonly FigmaEffect[]) {\n updateNode(this, internals, { effects: parseFigmaEffects(value) })\n }\n },\n // Applied shared styles, as Figma exposes them; an assignment inside an instance is an override.\n fillStyleId: styleReference(internals, 'fillStyleId', mixed),\n strokeStyleId: styleReference(internals, 'strokeStyleId', mixed),\n effectStyleId: styleReference(internals, 'effectStyleId', mixed),\n gridStyleId: styleReference(internals, 'gridStyleId', mixed),\n opacity: {\n get(this: ProxyThis): number {\n return raw(this, internals).opacity\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, { opacity: finiteNumber(value, 'opacity') })\n }\n },\n visible: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).visible\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { visible: value })\n }\n },\n locked: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).locked\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { locked: value })\n }\n },\n blendMode: {\n get(this: ProxyThis): string {\n return raw(this, internals).blendMode\n },\n set(this: ProxyThis, value: string) {\n updateNode(this, internals, { blendMode: value as SceneNode['blendMode'] })\n }\n },\n clipsContent: {\n get(this: ProxyThis): boolean {\n return raw(this, internals).clipsContent\n },\n set(this: ProxyThis, value: boolean) {\n updateNode(this, internals, { clipsContent: value })\n }\n },\n cornerRadius: {\n get(this: ProxyThis): number | symbol {\n const node = raw(this, internals)\n if (!node.independentCorners) return node.cornerRadius\n // Corners set or bound one by one read as one radius while they agree, as in Figma.\n const { topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius } = node\n const agree = [topRightRadius, bottomLeftRadius, bottomRightRadius].every(\n (radius) => radius === topLeftRadius\n )\n return agree ? topLeftRadius : mixed\n },\n set(this: ProxyThis, value: unknown) {\n if (value === mixed) return\n const radius = finiteNumber(value, 'cornerRadius')\n updateNode(this, internals, {\n cornerRadius: radius,\n topLeftRadius: radius,\n topRightRadius: radius,\n bottomRightRadius: radius,\n bottomLeftRadius: radius,\n independentCorners: false\n })\n }\n },\n topLeftRadius: cornerAccessor(internals, 'topLeftRadius'),\n topRightRadius: cornerAccessor(internals, 'topRightRadius'),\n bottomLeftRadius: cornerAccessor(internals, 'bottomLeftRadius'),\n bottomRightRadius: cornerAccessor(internals, 'bottomRightRadius'),\n cornerSmoothing: {\n get(this: ProxyThis): number {\n return raw(this, internals).cornerSmoothing\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, { cornerSmoothing: finiteNumber(value, 'cornerSmoothing') })\n }\n }\n })\n}\n\nfunction cornerAccessor(\n internals: NodeProxyInternals,\n field: 'topLeftRadius' | 'topRightRadius' | 'bottomLeftRadius' | 'bottomRightRadius'\n): PropertyDescriptor {\n return {\n get(this: ProxyThis): number {\n return raw(this, internals)[field]\n },\n set(this: ProxyThis, value: unknown) {\n updateNode(this, internals, {\n ...independentCornerChanges(raw(this, internals)),\n [field]: finiteNumber(value, field)\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAmBA,SAAS,eACP,WACA,OACA,OACoB;CACpB,OAAO;EACL,MAAsC;GACpC,MAAM,OAAO,IAAI,MAAM,SAAS;GAEhC,IAAI,UAAU,iBAAiB,KAAK,SAAS,QAC3C,OAAO,aAAa,MAAM,eAAe,KAAK;GAEhD,OAAO,KAAK,UAAU;EACxB;EACA,IAAqB,OAAe;GAClC,MAAM,OAAO,IAAI,MAAM,SAAS;GAChC,MAAM,UAAU,GAAG,QAAQ,SAAS,KAAK;GACzC,WACE,MACA,WACA,UAAU,iBAAiB,KAAK,SAAS,SAAS,iBAAiB,MAAM,OAAO,IAAI,OACtF;EACF;CACF;AACF;;;;;;AAOA,SAAgB,WAAW,MAA+B;CACxD,MAAM,QAAQ,cAAc,MAAM,OAAO;CACzC,OAAO,KAAK,MAAM,KAAK,MAAM,UAAU,aAAa,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC;AAC7E;;AAGA,SAAgB,aAAa,MAA+B;CAC1D,MAAM,QAAQ,cAAc,MAAM,SAAS;CAC3C,OAAO,KAAK,QAAQ,KAAK,QAAQ,UAAU,aAAa,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC;AACnF;AAEA,SAAgB,gCACd,WACA,WACA,OACM;CACN,OAAO,iBAAiB,WAAW;EACjC,OAAO;GAEL,MAAqD;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AAiB,CAAC,CAAC,OACjE,WAAW,WAAW,aAEd,IAAI,gBAAgB;GACjC;GACA,IAAqB,OAAgB;IACnC,IAAI,UAAU,OAAO;IACrB,MAAM,SAAS,aAAa,OAAO,cAAc;IACjD,WAAW,MAAM,WAAW;KAC1B,cAAc;KACd,eAAe;KACf,gBAAgB;KAChB,mBAAmB;KACnB,kBAAkB;KAClB,oBAAoB;IACtB,CAAC;GACH;EACF;EACA,eAAe,eAAe,WAAW,eAAe;EACxD,gBAAgB,eAAe,WAAW,gBAAgB;EAC1D,kBAAkB,eAAe,WAAW,kBAAkB;EAC9D,mBAAmB,eAAe,WAAW,mBAAmB;EAChE,iBAAiB;GACf,MAA6B;IAC3B,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;GAC9B;GACA,IAAqB,OAAgB;IACnC,WAAW,MAAM,WAAW,EAAE,iBAAiB,aAAa,OAAO,iBAAiB,EAAE,CAAC;GACzF;EACF;CACF,CAAC;AACH;AAEA,SAAS,eACP,WACA,OACoB;CACpB,OAAO;EACL,MAA6B;GAC3B,OAAO,IAAI,MAAM,SAAS,CAAC,CAAC;EAC9B;EACA,IAAqB,OAAgB;GACnC,WAAW,MAAM,WAAW;IAC1B,GAAG,yBAAyB,IAAI,MAAM,SAAS,CAAC;KAC/C,QAAQ,aAAa,OAAO,KAAK;GACpC,CAAC;EACH;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","names":[],"sources":["../../src/figma-api/components.ts"],"mappings":";;;;;iBA2DgB,mBACd,OAAO,YACP,OAAO,cAAc,iBACrB,YAAY,cAAc,iBAC1B,wBACC;iBAwQa,kCACd,mBACA,WAAW;;;;;;
|
|
1
|
+
{"version":3,"file":"components.d.ts","names":[],"sources":["../../src/figma-api/components.ts"],"mappings":";;;;;iBA2DgB,mBACd,OAAO,YACP,OAAO,cAAc,iBACrB,YAAY,cAAc,iBAC1B,wBACC;iBAwQa,kCACd,mBACA,WAAW;;;;;;iBAyMG,kBAAkB,OAAO,YAAY,MAAM,WAAW,mBAAmB"}
|
|
@@ -164,7 +164,8 @@ function installComponentPropertyAccessors(prototype, internals) {
|
|
|
164
164
|
componentPropertyReferences: {
|
|
165
165
|
get() {
|
|
166
166
|
const node = raw(this, internals);
|
|
167
|
-
|
|
167
|
+
const holder = node.parentId ? graph(this, internals).closest(node.parentId, (ancestor) => ancestor.type === "COMPONENT" || ancestor.type === "INSTANCE") : void 0;
|
|
168
|
+
if (node.type !== "COMPONENT" && !holder) return null;
|
|
168
169
|
const definitions = referableDefinitions(graph(this, internals), node);
|
|
169
170
|
return Object.fromEntries(node.componentPropertyReferences.map((reference) => {
|
|
170
171
|
const definition = definitions.find((item) => item.id === reference.propertyId);
|