@pairdraw/core 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/apply.d.ts +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
package/dist/layout.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
import { estimateTextSize, getTextMeasurer, installTextMeasurer, measureTextForLayout, setTextMeasurer } from "./layout/text-measurement.js";
|
|
1
|
+
import { autoWidthWrapWidth, estimateTextSize, getTextMeasurer, installTextMeasurer, measureAutoWidthText, measureTextForLayout, setTextMeasurer } from "./layout/text-measurement.js";
|
|
2
2
|
import { keepsSavedLayout, usesDetachedDerivedLayout } from "./layout/derived.js";
|
|
3
|
+
import { applyLockedAspectRatio, applyMinMaxConstraints, configureAbsoluteChild, configureNonTextLeaf, createYogaNode, freeYogaTree, mapAlignSelf, mapGridTrack, parentStretchedAxis } from "./layout/yoga-helpers.js";
|
|
4
|
+
import { insertFlowBox, setFlexFlow, setFlowEdges } from "./layout/flow-edges.js";
|
|
3
5
|
import { applyYogaLayout } from "./layout/apply.js";
|
|
4
6
|
import { asFlatLeaf, asLaidOutIn, fillKeepsSizeInHuggingParent, heldHugAxis, ownAxisSizing, setCrossAxisSizing, setMainAxisSizing } from "./layout/axis-sizing.js";
|
|
5
7
|
import { applyEffectiveGeneratedTextLayout } from "./layout/effective-generated-text.js";
|
|
6
8
|
import { applyContentInsets, applyStrokeMargins, strokeRoom } from "./layout/strokes.js";
|
|
7
|
-
import { applyLockedAspectRatio, applyMinMaxConstraints, configureAbsoluteChild, configureNonTextLeaf, createYogaNode, freeYogaTree, mapAlign, mapAlignSelf, mapGridTrack, mapJustify, parentStretchedAxis } from "./layout/yoga-helpers.js";
|
|
8
9
|
import { buildGridTree, createGridChildNode } from "./layout/grid.js";
|
|
9
10
|
import { sizeAutoResizingText } from "./layout/text-auto-resize.js";
|
|
10
11
|
import { fitShapeWithTextFrame } from "./layout/shape-with-text.js";
|
|
11
12
|
import { connectorSublayers, layoutConnector } from "@pairdraw/scene-graph/connectors";
|
|
12
13
|
import { resolveNodeLayoutDirection } from "@pairdraw/scene-graph/text/direction";
|
|
13
|
-
import { isGeneratedFrame } from "@pairdraw/scene-graph/generated";
|
|
14
14
|
import { layoutSizing } from "@pairdraw/scene-graph/layout";
|
|
15
|
-
import {
|
|
15
|
+
import { Direction, Display, Gutter, MeasureMode, Overflow } from "yoga-layout";
|
|
16
16
|
//#region src/layout.ts
|
|
17
17
|
function computeLayout(graph, frameId) {
|
|
18
18
|
graph.withLayoutMutations(() => computeLayoutInternal(graph, frameId));
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The deepest chain of auto-layout frames one layout pass may build. Yoga lays a tree out by
|
|
22
|
+
* recursing in its WebAssembly stack, which overruns at about 150 nested frames here; that throws
|
|
23
|
+
* an out-of-bounds memory error and leaves the shared Yoga instance unusable for every later
|
|
24
|
+
* layout. Refusing the pass before the call keeps the editor working.
|
|
25
|
+
*/
|
|
26
|
+
const MAX_LAYOUT_DEPTH = 128;
|
|
20
27
|
function computeLayoutInternal(graph, frameId) {
|
|
21
28
|
const frame = graph.getNode(frameId);
|
|
22
29
|
if (!frame || frame.layoutMode === "NONE") return;
|
|
@@ -105,31 +112,14 @@ function buildYogaTree(graph, frame, inheritedDirection) {
|
|
|
105
112
|
if (heldAxis === "width") root.setWidth(frame.width);
|
|
106
113
|
if (heldAxis === "height") root.setHeight(frame.height);
|
|
107
114
|
configureFlexContainer(root, frame, direction);
|
|
108
|
-
|
|
109
|
-
for (const child of children) {
|
|
110
|
-
const yogaChild = createYogaNode();
|
|
111
|
-
if (child.layoutPositioning === "ABSOLUTE") configureAbsoluteChild(yogaChild, child);
|
|
112
|
-
else if (!child.visible) yogaChild.setDisplay(Display.None);
|
|
113
|
-
else if (child.layoutMode === "GRID") configureChildAsGrid(yogaChild, child, frame, graph, direction);
|
|
114
|
-
else if (child.layoutMode !== "NONE") configureChildAsAutoLayout(yogaChild, child, frame, graph, direction);
|
|
115
|
-
else configureChildAsLeaf(yogaChild, child, frame, graph);
|
|
116
|
-
applyStrokeMargins(yogaChild, child, frame);
|
|
117
|
-
root.insertChild(yogaChild, root.getChildCount());
|
|
118
|
-
}
|
|
115
|
+
insertFlexChildren(root, frame, graph, direction, 1);
|
|
119
116
|
return root;
|
|
120
117
|
}
|
|
121
118
|
function configureFlexContainer(yogaNode, node, direction) {
|
|
122
119
|
yogaNode.setDirection(direction === "RTL" ? Direction.RTL : Direction.LTR);
|
|
123
|
-
yogaNode
|
|
124
|
-
yogaNode.setFlexWrap(node.layoutWrap === "WRAP" ? Wrap.Wrap : Wrap.NoWrap);
|
|
125
|
-
yogaNode.setJustifyContent(mapJustify(node.primaryAxisAlign));
|
|
126
|
-
yogaNode.setAlignItems(mapAlign(node.counterAxisAlign));
|
|
120
|
+
setFlexFlow(yogaNode, node);
|
|
127
121
|
if (node.clipsContent) yogaNode.setOverflow(Overflow.Hidden);
|
|
128
|
-
if (node.layoutWrap === "WRAP" && node.counterAxisAlignContent === "SPACE_BETWEEN") yogaNode.setAlignContent(Align.SpaceBetween);
|
|
129
122
|
applyContentInsets(yogaNode, node);
|
|
130
|
-
const primaryGap = node.primaryAxisAlign === "SPACE_BETWEEN" && !isGeneratedFrame(node) ? 0 : node.itemSpacing;
|
|
131
|
-
yogaNode.setGap(Gutter.Column, node.layoutMode === "HORIZONTAL" ? primaryGap : node.counterAxisSpacing);
|
|
132
|
-
yogaNode.setGap(Gutter.Row, node.layoutMode === "HORIZONTAL" ? node.counterAxisSpacing : primaryGap);
|
|
133
123
|
applyMinMaxConstraints(yogaNode, node);
|
|
134
124
|
}
|
|
135
125
|
function configureChildAsGrid(yogaChild, child, parent, graph, inheritedDirection) {
|
|
@@ -202,7 +192,8 @@ function configureAutoLayoutChildSizing(yogaChild, child, parent, graph, widthSi
|
|
|
202
192
|
if (fixedDerivedMainAxis) yogaChild.setHeight(child.derivedLayout?.height ?? child.height);
|
|
203
193
|
else setMainAxisSizing(yogaChild, "height", heightSizing, child.height, child.layoutGrow);
|
|
204
194
|
}
|
|
205
|
-
function configureChildAsAutoLayout(yogaChild, child, parent, graph, inheritedDirection) {
|
|
195
|
+
function configureChildAsAutoLayout(yogaChild, child, parent, graph, inheritedDirection, depth) {
|
|
196
|
+
if (depth > MAX_LAYOUT_DEPTH) throw new RangeError(`Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`);
|
|
206
197
|
const direction = resolveNodeLayoutDirection(child, inheritedDirection);
|
|
207
198
|
const widthSizing = layoutSizing(graph, child, "HORIZONTAL");
|
|
208
199
|
const heightSizing = layoutSizing(graph, child, "VERTICAL");
|
|
@@ -221,17 +212,26 @@ function configureChildAsAutoLayout(yogaChild, child, parent, graph, inheritedDi
|
|
|
221
212
|
const heldAxis = heldHugAxis(graph, child);
|
|
222
213
|
if (heldAxis === "width" && widthSizing === "HUG") yogaChild.setWidth(child.width);
|
|
223
214
|
if (heldAxis === "height" && heightSizing === "HUG") yogaChild.setHeight(child.height);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
215
|
+
insertFlexChildren(yogaChild, child, graph, direction, depth + 1);
|
|
216
|
+
}
|
|
217
|
+
/** Puts a frame's children into its Yoga node, through the flow box a negative edge needs. */
|
|
218
|
+
function insertFlexChildren(yogaParent, parent, graph, direction, depth) {
|
|
219
|
+
const box = insertFlowBox(yogaParent, parent);
|
|
220
|
+
const flow = [];
|
|
221
|
+
for (const child of graph.getChildren(parent.id).map((node) => asLaidOutIn(graph, node, parent))) {
|
|
222
|
+
const yogaChild = createYogaNode();
|
|
223
|
+
if (child.layoutPositioning === "ABSOLUTE") configureAbsoluteChild(yogaChild, child);
|
|
224
|
+
else if (!child.visible) yogaChild.setDisplay(Display.None);
|
|
225
|
+
else {
|
|
226
|
+
if (child.layoutMode === "GRID") configureChildAsGrid(yogaChild, child, parent, graph, direction);
|
|
227
|
+
else if (child.layoutMode !== "NONE") configureChildAsAutoLayout(yogaChild, child, parent, graph, direction, depth);
|
|
228
|
+
else configureChildAsLeaf(yogaChild, child, parent, graph);
|
|
229
|
+
flow.push(yogaChild);
|
|
230
|
+
}
|
|
231
|
+
applyStrokeMargins(yogaChild, child, parent);
|
|
232
|
+
box.insertChild(yogaChild, box.getChildCount());
|
|
234
233
|
}
|
|
234
|
+
setFlowEdges(yogaParent, box, parent, flow, direction);
|
|
235
235
|
}
|
|
236
236
|
function derivedGrowingLeafFitsParent(graph, parent, child, axis) {
|
|
237
237
|
if (child.type !== "TEXT" || child.layoutGrow <= 0 || child.derivedLayout?.[axis] === void 0) return false;
|
|
@@ -322,7 +322,7 @@ function configureTextLeaf(yogaChild, child, parent, fixedDerivedMainAxis = fals
|
|
|
322
322
|
const cacheKey = maxW === void 0 ? UNCONSTRAINED_KEY : Math.round(maxW);
|
|
323
323
|
const cached = cache.get(cacheKey);
|
|
324
324
|
if (cached) return cached;
|
|
325
|
-
const result =
|
|
325
|
+
const result = measureAutoWidthText(child, maxW ?? autoWidthWrapWidth(child));
|
|
326
326
|
cache.set(cacheKey, result);
|
|
327
327
|
return result;
|
|
328
328
|
});
|
package/dist/layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","names":[],"sources":["../src/layout.ts"],"sourcesContent":["import {\n Align,\n Direction,\n Display,\n FlexDirection,\n Gutter,\n MeasureMode,\n Overflow,\n Wrap,\n type Node as YogaNode\n} from 'yoga-layout'\n\nimport { resolveNodeLayoutDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { applyYogaLayout } from './layout/apply'\nimport {\n asFlatLeaf,\n asLaidOutIn,\n fillKeepsSizeInHuggingParent,\n heldHugAxis,\n ownAxisSizing,\n setCrossAxisSizing,\n setMainAxisSizing\n} from './layout/axis-sizing'\nimport { keepsSavedLayout, usesDetachedDerivedLayout } from './layout/derived'\nimport { applyEffectiveGeneratedTextLayout } from './layout/effective-generated-text'\nimport { buildGridTree, createGridChildNode } from './layout/grid'\nimport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport {\n estimateTextSize,\n getTextMeasurer,\n installTextMeasurer,\n setTextMeasurer,\n type TextMeasurer\n} from './layout/text-measurement'\nimport type { LayoutSizing, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { connectorSublayers, layoutConnector } from '@pairdraw/scene-graph/connectors'\nimport { isGeneratedFrame } from '@pairdraw/scene-graph/generated'\nimport { layoutSizing } from '@pairdraw/scene-graph/layout'\n\nimport { fitShapeWithTextFrame } from './layout/shape-with-text'\nimport { applyContentInsets, applyStrokeMargins, strokeRoom } from './layout/strokes'\nimport { estimateTextSize, getTextMeasurer, measureTextForLayout } from './layout/text-measurement'\nimport {\n applyMinMaxConstraints,\n applyLockedAspectRatio,\n configureAbsoluteChild,\n configureNonTextLeaf,\n createYogaNode,\n freeYogaTree,\n mapAlign,\n mapAlignSelf,\n mapGridTrack,\n mapJustify,\n parentStretchedAxis\n} from './layout/yoga-helpers'\n\nexport function computeLayout(graph: SceneGraph, frameId: string): void {\n graph.withLayoutMutations(() => computeLayoutInternal(graph, frameId))\n}\n\nfunction computeLayoutInternal(graph: SceneGraph, frameId: string): void {\n const frame = graph.getNode(frameId)\n if (!frame || frame.layoutMode === 'NONE') return\n // A shape with text takes its size from its label before laying the label out in it.\n fitShapeWithTextFrame(graph, frame)\n\n const rootDirection = resolveComputedLayoutDirection(graph, frame)\n const yogaDirection = rootDirection === 'RTL' ? Direction.RTL : Direction.LTR\n const yogaRoot =\n frame.layoutMode === 'GRID'\n ? buildGridTree(graph, frame, rootDirection)\n : buildYogaTree(graph, frame, rootDirection)\n yogaRoot.calculateLayout(undefined, undefined, yogaDirection)\n applyYogaLayout(graph, frame, yogaRoot, computeLayoutInternal)\n freeYogaTree(yogaRoot)\n}\nfunction resolveComputedLayoutDirection(\n graph: SceneGraph,\n node: Pick<SceneNode, 'layoutDirection' | 'parentId'>\n): 'LTR' | 'RTL' {\n const parent = node.parentId ? graph.getNode(node.parentId) : null\n const inheritedDirection = parent ? resolveComputedLayoutDirection(graph, parent) : 'LTR'\n return resolveNodeLayoutDirection(node, inheritedDirection)\n}\n\nexport function computeAllLayouts(graph: SceneGraph, scopeId?: string): void {\n graph.withLayoutMutations(() => {\n const rootId = scopeId ?? graph.rootId\n const visited = new Set<string>()\n computeLayoutsBottomUp(graph, rootId, visited)\n if (applyEffectiveGeneratedTextLayout(graph, rootId)) {\n computeLayoutsBottomUp(graph, rootId, new Set())\n }\n routeUnroutedConnectors(graph, rootId)\n })\n}\n\n/**\n * Routes each connector that has no route yet, as one read from a file that saved none, once its\n * label is measured, as FigJam routes such a connector when it opens. A saved route is kept.\n */\nexport function routeUnroutedConnectors(graph: SceneGraph, rootId: string): void {\n for (const { node } of graph.flattenTree(rootId)) {\n if (node.type !== 'CONNECTOR') continue\n const line = connectorSublayers(graph, node)?.line\n if (!line || (line.vectorNetwork?.vertices.length ?? 0) > 0) continue\n sizeAutoResizingText(graph, node.id)\n layoutConnector(graph, node)\n }\n}\n\n/**\n * Gives content an author wrote, such as design JSX, HTML, or a `.pen` file, the sizes and\n * positions its layout implies, which the source does not store, measuring its text first.\n * Documents that store their geometry, such as `.fig` files, keep theirs and do not come here.\n */\nexport function layoutAuthoredNodes(graph: SceneGraph, rootIds: Iterable<string>): void {\n const roots = [...rootIds]\n const pageIds = new Set<string>()\n let outsidePages = false\n for (const id of roots) {\n sizeAutoResizingText(graph, id)\n const page = graph.pageOf(id)\n if (page !== null) pageIds.add(page)\n else outsidePages = true\n }\n const layout = () => {\n if (outsidePages) computeAllLayouts(graph)\n else for (const pageId of pageIds) computeAllLayouts(graph, pageId)\n }\n layout()\n // Layout gives wrapping text its width, which its height follows.\n if (roots.map((id) => sizeAutoResizingText(graph, id, true)).some(Boolean)) layout()\n // Connectors authored with the layers they join route once those layers are in place.\n for (const id of roots) {\n for (const { node } of graph.flattenTree(id)) {\n if (node.type === 'CONNECTOR') layoutConnector(graph, node)\n }\n }\n}\n\nfunction computeLayoutsBottomUp(graph: SceneGraph, nodeId: string, visited: Set<string>): void {\n const node = graph.getNode(nodeId)\n if (!node || visited.has(nodeId)) return\n visited.add(nodeId)\n\n for (const childId of node.childIds) {\n computeLayoutsBottomUp(graph, childId, visited)\n }\n\n if (node.layoutMode !== 'NONE' && !preservesImportedInstanceLayout(node)) {\n computeLayout(graph, nodeId)\n }\n}\n\nfunction preservesImportedInstanceLayout(node: SceneNode): boolean {\n return node.type === 'INSTANCE' && node.source.format === 'fig'\n}\n\nfunction buildYogaTree(\n graph: SceneGraph,\n frame: SceneNode,\n inheritedDirection: 'LTR' | 'RTL'\n): YogaNode {\n const root = createYogaNode()\n const direction = resolveNodeLayoutDirection(frame, inheritedDirection)\n\n if (frame.primaryAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setWidth(frame.width)\n else root.setHeight(frame.height)\n }\n if (frame.counterAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setHeight(frame.height)\n else root.setWidth(frame.width)\n }\n // Laid out on its own, a frame its parent stretches keeps the size the parent gave it on\n // that axis, so its content aligns within that size rather than within a hug.\n const stretchedAxis = parentStretchedAxis(graph, frame)\n if (stretchedAxis === 'width') root.setWidth(frame.width)\n if (stretchedAxis === 'height') root.setHeight(frame.height)\n const heldAxis = heldHugAxis(graph, frame)\n if (heldAxis === 'width') root.setWidth(frame.width)\n if (heldAxis === 'height') root.setHeight(frame.height)\n\n configureFlexContainer(root, frame, direction)\n\n const children = graph.getChildren(frame.id).map((child) => asLaidOutIn(graph, child, frame))\n for (const child of children) {\n const yogaChild = createYogaNode()\n\n if (child.layoutPositioning === 'ABSOLUTE') {\n configureAbsoluteChild(yogaChild, child)\n } else if (!child.visible) {\n yogaChild.setDisplay(Display.None)\n } else if (child.layoutMode === 'GRID') {\n configureChildAsGrid(yogaChild, child, frame, graph, direction)\n } else if (child.layoutMode !== 'NONE') {\n configureChildAsAutoLayout(yogaChild, child, frame, graph, direction)\n } else {\n configureChildAsLeaf(yogaChild, child, frame, graph)\n }\n applyStrokeMargins(yogaChild, child, frame)\n\n root.insertChild(yogaChild, root.getChildCount())\n }\n\n return root\n}\n\nfunction configureFlexContainer(\n yogaNode: YogaNode,\n node: SceneNode,\n direction: Exclude<SceneNode['layoutDirection'], 'AUTO'>\n): void {\n yogaNode.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n yogaNode.setFlexDirection(\n node.layoutMode === 'HORIZONTAL' ? FlexDirection.Row : FlexDirection.Column\n )\n yogaNode.setFlexWrap(node.layoutWrap === 'WRAP' ? Wrap.Wrap : Wrap.NoWrap)\n yogaNode.setJustifyContent(mapJustify(node.primaryAxisAlign))\n yogaNode.setAlignItems(mapAlign(node.counterAxisAlign))\n if (node.clipsContent) yogaNode.setOverflow(Overflow.Hidden)\n\n if (node.layoutWrap === 'WRAP' && node.counterAxisAlignContent === 'SPACE_BETWEEN') {\n yogaNode.setAlignContent(Align.SpaceBetween)\n }\n\n applyContentInsets(yogaNode, node)\n\n // Space between takes the place of the gap in Figma's auto layout. A generated frame keeps it\n // as the least space between its sublayers, as a sticky note keeps its author clear of a long body.\n const primaryGap =\n node.primaryAxisAlign === 'SPACE_BETWEEN' && !isGeneratedFrame(node) ? 0 : node.itemSpacing\n yogaNode.setGap(\n Gutter.Column,\n node.layoutMode === 'HORIZONTAL' ? primaryGap : node.counterAxisSpacing\n )\n yogaNode.setGap(\n Gutter.Row,\n node.layoutMode === 'HORIZONTAL' ? node.counterAxisSpacing : primaryGap\n )\n\n applyMinMaxConstraints(yogaNode, node)\n}\n\nfunction configureChildAsGrid(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL'\n): void {\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n yogaChild.setDisplay(Display.Grid)\n yogaChild.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n\n if (child.gridTemplateColumns.length > 0) {\n yogaChild.setGridTemplateColumns(child.gridTemplateColumns.map(mapGridTrack))\n }\n if (child.gridTemplateRows.length > 0) {\n yogaChild.setGridTemplateRows(child.gridTemplateRows.map(mapGridTrack))\n }\n\n yogaChild.setGap(Gutter.Column, child.gridColumnGap)\n yogaChild.setGap(Gutter.Row, child.gridRowGap)\n\n applyContentInsets(yogaChild, child)\n\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n\n if (child.layoutGrow > 0) {\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n if (!stretchCross) {\n if (isParentRow) yogaChild.setHeight(child.height)\n else yogaChild.setWidth(child.width)\n }\n } else {\n if (isParentRow) {\n yogaChild.setWidth(child.width)\n if (!stretchCross) yogaChild.setHeight(child.height)\n } else {\n if (child.gridTemplateRows.length > 0) yogaChild.setHeight(child.height)\n if (!stretchCross) yogaChild.setWidth(child.width)\n }\n }\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n\n const grandchildren = graph.getChildren(child.id)\n for (const gc of grandchildren) {\n if (gc.layoutPositioning === 'ABSOLUTE') {\n const yogaGC = createYogaNode()\n configureAbsoluteChild(yogaGC, gc)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n } else {\n const yogaGC = createGridChildNode(graph, gc)\n applyStrokeMargins(yogaGC, gc, child)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n }\n }\n}\n\nfunction sizesFitParent(\n parent: SceneNode,\n children: readonly SceneNode[],\n sizes: Array<number | undefined>,\n axis: 'width' | 'height'\n): boolean {\n if (sizes.some((size) => size === undefined)) return false\n const padding =\n (axis === 'width'\n ? parent.paddingLeft + parent.paddingRight\n : parent.paddingTop + parent.paddingBottom) + strokeRoom(parent, children, axis)\n const gap =\n parent.primaryAxisAlign === 'SPACE_BETWEEN'\n ? 0\n : parent.itemSpacing * Math.max(0, children.length - 1)\n const available = axis === 'width' ? parent.width : parent.height\n const total = sizes.reduce<number>((sum, size) => sum + (size ?? 0), padding + gap)\n return Math.abs(total - available) < 0.001\n}\n\nfunction derivedMainAxisFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (!keepsSavedLayout(graph, parent)) return false\n const children = graph\n .getChildren(parent.id)\n .filter((candidate) => candidate.visible && candidate.layoutPositioning !== 'ABSOLUTE')\n if (children.length === 0) return false\n\n const sizes = children.map((candidate) => candidate.derivedLayout?.[axis])\n return sizesFitParent(parent, children, sizes, axis) && child.derivedLayout?.[axis] !== undefined\n}\n\nfunction configureAutoLayoutChildSizing(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n widthSizing: LayoutSizing,\n heightSizing: LayoutSizing\n): void {\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const fixedDerivedMainAxis = isParentRow\n ? derivedMainAxisFitsParent(graph, parent, child, 'width')\n : derivedMainAxisFitsParent(graph, parent, child, 'height')\n\n if (isParentRow) {\n if (fixedDerivedMainAxis) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else setMainAxisSizing(yogaChild, 'width', widthSizing, child.width, child.layoutGrow)\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'height')\n setCrossAxisSizing(yogaChild, 'height', heightSizing, child.height, keepsSize)\n return\n }\n\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'width')\n setCrossAxisSizing(yogaChild, 'width', widthSizing, child.width, keepsSize)\n if (fixedDerivedMainAxis) yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n else setMainAxisSizing(yogaChild, 'height', heightSizing, child.height, child.layoutGrow)\n}\n\nfunction configureChildAsAutoLayout(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL'\n): void {\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n const widthSizing = layoutSizing(graph, child, 'HORIZONTAL')\n const heightSizing = layoutSizing(graph, child, 'VERTICAL')\n\n configureAutoLayoutChildSizing(yogaChild, child, parent, graph, widthSizing, heightSizing)\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n applyLockedAspectRatio(yogaChild, child, parent)\n\n if (usesDetachedDerivedLayout(graph, child)) {\n // The imported size is what the child's own hug produced, whether or not it also fills.\n const derived = child.derivedLayout\n if (ownAxisSizing(child, 'width') === 'HUG') yogaChild.setWidth(derived?.width ?? child.width)\n if (ownAxisSizing(child, 'height') === 'HUG') {\n yogaChild.setHeight(derived?.height ?? child.height)\n }\n applyMinMaxConstraints(yogaChild, child)\n return\n }\n\n configureFlexContainer(yogaChild, child, direction)\n const heldAxis = heldHugAxis(graph, child)\n if (heldAxis === 'width' && widthSizing === 'HUG') yogaChild.setWidth(child.width)\n if (heldAxis === 'height' && heightSizing === 'HUG') yogaChild.setHeight(child.height)\n\n const grandchildren = graph.getChildren(child.id).map((gc) => asLaidOutIn(graph, gc, child))\n for (const gc of grandchildren) {\n const yogaGC = createYogaNode()\n if (gc.layoutPositioning === 'ABSOLUTE') {\n configureAbsoluteChild(yogaGC, gc)\n } else if (!gc.visible) {\n yogaGC.setDisplay(Display.None)\n } else if (gc.layoutMode === 'GRID') {\n configureChildAsGrid(yogaGC, gc, child, graph, direction)\n } else if (gc.layoutMode !== 'NONE') {\n configureChildAsAutoLayout(yogaGC, gc, child, graph, direction)\n } else {\n configureChildAsLeaf(yogaGC, gc, child, graph)\n }\n applyStrokeMargins(yogaGC, gc, child)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n }\n}\n\nfunction derivedGrowingLeafFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (child.type !== 'TEXT' || child.layoutGrow <= 0 || child.derivedLayout?.[axis] === undefined) {\n return false\n }\n const children = graph\n .getChildren(parent.id)\n .filter((candidate) => candidate.visible && candidate.layoutPositioning !== 'ABSOLUTE')\n const sizes = children.map((candidate) => {\n if (candidate.layoutGrow > 0) return candidate.derivedLayout?.[axis]\n return axis === 'width' ? candidate.width : candidate.height\n })\n return sizesFitParent(parent, children, sizes, axis)\n}\n\n/**\n * Fill text shares its parent's main axis like a fill frame: it grows and shrinks from a zero\n * basis, so its stored width (100px for new text) never decides its share. Returns whether\n * it fills the row's width, where its stored width must not constrain it either.\n */\nfunction configureGrowingText(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): boolean {\n if (child.layoutGrow <= 0 || fixedDerivedMainAxis) return false\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n return parent.layoutMode === 'HORIZONTAL'\n}\n\nfunction configureTextLeafWithoutMeasurer(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): void {\n const hasStoredSize =\n child.width > 0 && child.height > 0 && !(child.width === 100 && child.height === 100)\n\n if (child.textAutoResize === 'WIDTH_AND_HEIGHT') {\n if (hasStoredSize) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n } else {\n const estimated = estimateTextSize(child)\n yogaChild.setWidth(estimated.width)\n yogaChild.setHeight(estimated.height)\n }\n return\n }\n if (child.textAutoResize !== 'HEIGHT') return\n\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const measurementWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n const stretches =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n if (!(!isRow && stretches) && !fixedDerivedMainAxis && !growsWidth) {\n yogaChild.setWidth(child.width)\n }\n if (hasStoredSize) yogaChild.setHeight(child.height)\n else yogaChild.setHeight(estimateTextSize(child, measurementWidth).height)\n}\n\nfunction configureChildAsLeaf(\n yogaChild: YogaNode,\n node: SceneNode,\n parent: SceneNode,\n graph: SceneGraph\n): void {\n const child = asFlatLeaf(node, parent)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n\n const isText = child.type === 'TEXT'\n const textMeasurer = getTextMeasurer()\n const needsMeasureFunc = isText && textMeasurer && child.textAutoResize !== 'NONE'\n\n const fixedDerivedMainAxis = isRow\n ? derivedGrowingLeafFitsParent(graph, parent, child, 'width')\n : derivedGrowingLeafFitsParent(graph, parent, child, 'height')\n\n if (fixedDerivedMainAxis) {\n if (isRow) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n }\n\n if (needsMeasureFunc) {\n configureTextLeaf(yogaChild, child, parent, fixedDerivedMainAxis)\n } else if (isText && !textMeasurer && child.textAutoResize !== 'NONE') {\n configureTextLeafWithoutMeasurer(yogaChild, child, parent, fixedDerivedMainAxis)\n } else {\n configureNonTextLeaf(yogaChild, child, isRow, stretchCross)\n // Fixed text still contributes its box to a HUG cross axis. Without\n // an intrinsic minimum, stretch collapses the text to its siblings.\n if (isText && stretchCross && parent.counterAxisSizing === 'HUG') {\n if (isRow) yogaChild.setMinHeight(child.height)\n else yogaChild.setMinWidth(child.width)\n }\n }\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n}\n\nfunction configureTextLeaf(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis = false\n): void {\n const autoResize = child.textAutoResize\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const stretchesCross =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n // Layout sets the width of text that grows along a row or stretches across a column.\n const fillsWidth = (!isRow && stretchesCross) || growsWidth\n\n const cache = new Map<number, { width: number; height: number }>()\n const UNCONSTRAINED_KEY = -1\n\n if (autoResize === 'WIDTH_AND_HEIGHT') {\n const importedSize = child.derivedLayout\n if (importedSize?.width !== undefined && importedSize.height !== undefined) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n return\n }\n\n // Auto-width text keeps each line whole, as Figma's does, in a parent narrower than the text;\n // only a width that layout or a max width sets wraps it.\n const wraps = fillsWidth || child.maxWidth != null\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n const maxW = wraps && widthMode !== MeasureMode.Undefined ? width : undefined\n const cacheKey = maxW === undefined ? UNCONSTRAINED_KEY : Math.round(maxW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n const result = measureTextForLayout(child, maxW)\n cache.set(cacheKey, result)\n return result\n })\n } else if (autoResize === 'HEIGHT') {\n const fixedWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n // Let Yoga stretch or grow fill-width text instead of fixing its stored width.\n if (child.layoutGrow <= 0 && !fillsWidth) {\n yogaChild.setWidth(fixedWidth)\n }\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n let constraintW = fixedWidth\n if (fillsWidth) {\n if (widthMode !== MeasureMode.Undefined) constraintW = width\n } else if (widthMode !== MeasureMode.Undefined) {\n constraintW = Math.min(width, fixedWidth || width)\n }\n const cacheKey = Math.round(constraintW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n if (constraintW === child.width && (child.derivedTextGlyphs?.length ?? 0) > 0) {\n return { width: constraintW, height: child.height }\n }\n const result = { width: constraintW, height: measureTextForLayout(child, constraintW).height }\n cache.set(cacheKey, result)\n return result\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0DA,SAAgB,cAAc,OAAmB,SAAuB;CACtE,MAAM,0BAA0B,sBAAsB,OAAO,OAAO,CAAC;AACvE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,IAAI,UAAU,MAAM;GAC1B,OAAO;EACT,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"layout.js","names":[],"sources":["../src/layout.ts"],"sourcesContent":["import {\n Direction,\n Display,\n Gutter,\n MeasureMode,\n Overflow,\n type Node as YogaNode\n} from 'yoga-layout'\n\nimport { resolveNodeLayoutDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { applyYogaLayout } from './layout/apply'\nimport {\n asFlatLeaf,\n asLaidOutIn,\n fillKeepsSizeInHuggingParent,\n heldHugAxis,\n ownAxisSizing,\n setCrossAxisSizing,\n setMainAxisSizing\n} from './layout/axis-sizing'\nimport { keepsSavedLayout, usesDetachedDerivedLayout } from './layout/derived'\nimport { applyEffectiveGeneratedTextLayout } from './layout/effective-generated-text'\nimport { insertFlowBox, setFlexFlow, setFlowEdges } from './layout/flow-edges'\nimport { buildGridTree, createGridChildNode } from './layout/grid'\nimport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport { sizeAutoResizingText } from './layout/text-auto-resize'\nexport {\n estimateTextSize,\n getTextMeasurer,\n installTextMeasurer,\n setTextMeasurer,\n type TextMeasurer\n} from './layout/text-measurement'\nimport type { LayoutSizing, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { connectorSublayers, layoutConnector } from '@pairdraw/scene-graph/connectors'\nimport { layoutSizing } from '@pairdraw/scene-graph/layout'\n\nimport { fitShapeWithTextFrame } from './layout/shape-with-text'\nimport { applyContentInsets, applyStrokeMargins, strokeRoom } from './layout/strokes'\nimport {\n autoWidthWrapWidth,\n estimateTextSize,\n getTextMeasurer,\n measureAutoWidthText,\n measureTextForLayout\n} from './layout/text-measurement'\nimport {\n applyMinMaxConstraints,\n applyLockedAspectRatio,\n configureAbsoluteChild,\n configureNonTextLeaf,\n createYogaNode,\n freeYogaTree,\n mapAlignSelf,\n mapGridTrack,\n parentStretchedAxis\n} from './layout/yoga-helpers'\n\nexport function computeLayout(graph: SceneGraph, frameId: string): void {\n graph.withLayoutMutations(() => computeLayoutInternal(graph, frameId))\n}\n\n/**\n * The deepest chain of auto-layout frames one layout pass may build. Yoga lays a tree out by\n * recursing in its WebAssembly stack, which overruns at about 150 nested frames here; that throws\n * an out-of-bounds memory error and leaves the shared Yoga instance unusable for every later\n * layout. Refusing the pass before the call keeps the editor working.\n */\nconst MAX_LAYOUT_DEPTH = 128\n\nfunction computeLayoutInternal(graph: SceneGraph, frameId: string): void {\n const frame = graph.getNode(frameId)\n if (!frame || frame.layoutMode === 'NONE') return\n // A shape with text takes its size from its label before laying the label out in it.\n fitShapeWithTextFrame(graph, frame)\n\n const rootDirection = resolveComputedLayoutDirection(graph, frame)\n const yogaDirection = rootDirection === 'RTL' ? Direction.RTL : Direction.LTR\n const yogaRoot =\n frame.layoutMode === 'GRID'\n ? buildGridTree(graph, frame, rootDirection)\n : buildYogaTree(graph, frame, rootDirection)\n yogaRoot.calculateLayout(undefined, undefined, yogaDirection)\n applyYogaLayout(graph, frame, yogaRoot, computeLayoutInternal)\n freeYogaTree(yogaRoot)\n}\nfunction resolveComputedLayoutDirection(\n graph: SceneGraph,\n node: Pick<SceneNode, 'layoutDirection' | 'parentId'>\n): 'LTR' | 'RTL' {\n const parent = node.parentId ? graph.getNode(node.parentId) : null\n const inheritedDirection = parent ? resolveComputedLayoutDirection(graph, parent) : 'LTR'\n return resolveNodeLayoutDirection(node, inheritedDirection)\n}\n\nexport function computeAllLayouts(graph: SceneGraph, scopeId?: string): void {\n graph.withLayoutMutations(() => {\n const rootId = scopeId ?? graph.rootId\n const visited = new Set<string>()\n computeLayoutsBottomUp(graph, rootId, visited)\n if (applyEffectiveGeneratedTextLayout(graph, rootId)) {\n computeLayoutsBottomUp(graph, rootId, new Set())\n }\n routeUnroutedConnectors(graph, rootId)\n })\n}\n\n/**\n * Routes each connector that has no route yet, as one read from a file that saved none, once its\n * label is measured, as FigJam routes such a connector when it opens. A saved route is kept.\n */\nexport function routeUnroutedConnectors(graph: SceneGraph, rootId: string): void {\n for (const { node } of graph.flattenTree(rootId)) {\n if (node.type !== 'CONNECTOR') continue\n const line = connectorSublayers(graph, node)?.line\n if (!line || (line.vectorNetwork?.vertices.length ?? 0) > 0) continue\n sizeAutoResizingText(graph, node.id)\n layoutConnector(graph, node)\n }\n}\n\n/**\n * Gives content an author wrote, such as design JSX, HTML, or a `.pen` file, the sizes and\n * positions its layout implies, which the source does not store, measuring its text first.\n * Documents that store their geometry, such as `.fig` files, keep theirs and do not come here.\n */\nexport function layoutAuthoredNodes(graph: SceneGraph, rootIds: Iterable<string>): void {\n const roots = [...rootIds]\n const pageIds = new Set<string>()\n let outsidePages = false\n for (const id of roots) {\n sizeAutoResizingText(graph, id)\n const page = graph.pageOf(id)\n if (page !== null) pageIds.add(page)\n else outsidePages = true\n }\n const layout = () => {\n if (outsidePages) computeAllLayouts(graph)\n else for (const pageId of pageIds) computeAllLayouts(graph, pageId)\n }\n layout()\n // Layout gives wrapping text its width, which its height follows.\n if (roots.map((id) => sizeAutoResizingText(graph, id, true)).some(Boolean)) layout()\n // Connectors authored with the layers they join route once those layers are in place.\n for (const id of roots) {\n for (const { node } of graph.flattenTree(id)) {\n if (node.type === 'CONNECTOR') layoutConnector(graph, node)\n }\n }\n}\n\nfunction computeLayoutsBottomUp(graph: SceneGraph, nodeId: string, visited: Set<string>): void {\n const node = graph.getNode(nodeId)\n if (!node || visited.has(nodeId)) return\n visited.add(nodeId)\n\n for (const childId of node.childIds) {\n computeLayoutsBottomUp(graph, childId, visited)\n }\n\n if (node.layoutMode !== 'NONE' && !preservesImportedInstanceLayout(node)) {\n computeLayout(graph, nodeId)\n }\n}\n\nfunction preservesImportedInstanceLayout(node: SceneNode): boolean {\n return node.type === 'INSTANCE' && node.source.format === 'fig'\n}\n\nfunction buildYogaTree(\n graph: SceneGraph,\n frame: SceneNode,\n inheritedDirection: 'LTR' | 'RTL'\n): YogaNode {\n const root = createYogaNode()\n const direction = resolveNodeLayoutDirection(frame, inheritedDirection)\n\n if (frame.primaryAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setWidth(frame.width)\n else root.setHeight(frame.height)\n }\n if (frame.counterAxisSizing === 'FIXED') {\n if (frame.layoutMode === 'HORIZONTAL') root.setHeight(frame.height)\n else root.setWidth(frame.width)\n }\n // Laid out on its own, a frame its parent stretches keeps the size the parent gave it on\n // that axis, so its content aligns within that size rather than within a hug.\n const stretchedAxis = parentStretchedAxis(graph, frame)\n if (stretchedAxis === 'width') root.setWidth(frame.width)\n if (stretchedAxis === 'height') root.setHeight(frame.height)\n const heldAxis = heldHugAxis(graph, frame)\n if (heldAxis === 'width') root.setWidth(frame.width)\n if (heldAxis === 'height') root.setHeight(frame.height)\n\n configureFlexContainer(root, frame, direction)\n\n insertFlexChildren(root, frame, graph, direction, 1)\n\n return root\n}\n\nfunction configureFlexContainer(\n yogaNode: YogaNode,\n node: SceneNode,\n direction: Exclude<SceneNode['layoutDirection'], 'AUTO'>\n): void {\n yogaNode.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n setFlexFlow(yogaNode, node)\n if (node.clipsContent) yogaNode.setOverflow(Overflow.Hidden)\n applyContentInsets(yogaNode, node)\n\n applyMinMaxConstraints(yogaNode, node)\n}\n\nfunction configureChildAsGrid(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL'\n): void {\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n yogaChild.setDisplay(Display.Grid)\n yogaChild.setDirection(direction === 'RTL' ? Direction.RTL : Direction.LTR)\n\n if (child.gridTemplateColumns.length > 0) {\n yogaChild.setGridTemplateColumns(child.gridTemplateColumns.map(mapGridTrack))\n }\n if (child.gridTemplateRows.length > 0) {\n yogaChild.setGridTemplateRows(child.gridTemplateRows.map(mapGridTrack))\n }\n\n yogaChild.setGap(Gutter.Column, child.gridColumnGap)\n yogaChild.setGap(Gutter.Row, child.gridRowGap)\n\n applyContentInsets(yogaChild, child)\n\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n\n if (child.layoutGrow > 0) {\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n if (!stretchCross) {\n if (isParentRow) yogaChild.setHeight(child.height)\n else yogaChild.setWidth(child.width)\n }\n } else {\n if (isParentRow) {\n yogaChild.setWidth(child.width)\n if (!stretchCross) yogaChild.setHeight(child.height)\n } else {\n if (child.gridTemplateRows.length > 0) yogaChild.setHeight(child.height)\n if (!stretchCross) yogaChild.setWidth(child.width)\n }\n }\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n\n const grandchildren = graph.getChildren(child.id)\n for (const gc of grandchildren) {\n if (gc.layoutPositioning === 'ABSOLUTE') {\n const yogaGC = createYogaNode()\n configureAbsoluteChild(yogaGC, gc)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n } else {\n const yogaGC = createGridChildNode(graph, gc)\n applyStrokeMargins(yogaGC, gc, child)\n yogaChild.insertChild(yogaGC, yogaChild.getChildCount())\n }\n }\n}\n\nfunction sizesFitParent(\n parent: SceneNode,\n children: readonly SceneNode[],\n sizes: Array<number | undefined>,\n axis: 'width' | 'height'\n): boolean {\n if (sizes.some((size) => size === undefined)) return false\n const padding =\n (axis === 'width'\n ? parent.paddingLeft + parent.paddingRight\n : parent.paddingTop + parent.paddingBottom) + strokeRoom(parent, children, axis)\n const gap =\n parent.primaryAxisAlign === 'SPACE_BETWEEN'\n ? 0\n : parent.itemSpacing * Math.max(0, children.length - 1)\n const available = axis === 'width' ? parent.width : parent.height\n const total = sizes.reduce<number>((sum, size) => sum + (size ?? 0), padding + gap)\n return Math.abs(total - available) < 0.001\n}\n\nfunction derivedMainAxisFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (!keepsSavedLayout(graph, parent)) return false\n const children = graph\n .getChildren(parent.id)\n .filter((candidate) => candidate.visible && candidate.layoutPositioning !== 'ABSOLUTE')\n if (children.length === 0) return false\n\n const sizes = children.map((candidate) => candidate.derivedLayout?.[axis])\n return sizesFitParent(parent, children, sizes, axis) && child.derivedLayout?.[axis] !== undefined\n}\n\nfunction configureAutoLayoutChildSizing(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n widthSizing: LayoutSizing,\n heightSizing: LayoutSizing\n): void {\n const isParentRow = parent.layoutMode === 'HORIZONTAL'\n const fixedDerivedMainAxis = isParentRow\n ? derivedMainAxisFitsParent(graph, parent, child, 'width')\n : derivedMainAxisFitsParent(graph, parent, child, 'height')\n\n if (isParentRow) {\n if (fixedDerivedMainAxis) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else setMainAxisSizing(yogaChild, 'width', widthSizing, child.width, child.layoutGrow)\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'height')\n setCrossAxisSizing(yogaChild, 'height', heightSizing, child.height, keepsSize)\n return\n }\n\n const keepsSize = fillKeepsSizeInHuggingParent(child, parent, 'width')\n setCrossAxisSizing(yogaChild, 'width', widthSizing, child.width, keepsSize)\n if (fixedDerivedMainAxis) yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n else setMainAxisSizing(yogaChild, 'height', heightSizing, child.height, child.layoutGrow)\n}\n\nfunction configureChildAsAutoLayout(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n graph: SceneGraph,\n inheritedDirection: 'LTR' | 'RTL',\n depth: number\n): void {\n if (depth > MAX_LAYOUT_DEPTH) {\n throw new RangeError(\n `Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`\n )\n }\n const direction = resolveNodeLayoutDirection(child, inheritedDirection)\n const widthSizing = layoutSizing(graph, child, 'HORIZONTAL')\n const heightSizing = layoutSizing(graph, child, 'VERTICAL')\n\n configureAutoLayoutChildSizing(yogaChild, child, parent, graph, widthSizing, heightSizing)\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n applyLockedAspectRatio(yogaChild, child, parent)\n\n if (usesDetachedDerivedLayout(graph, child)) {\n // The imported size is what the child's own hug produced, whether or not it also fills.\n const derived = child.derivedLayout\n if (ownAxisSizing(child, 'width') === 'HUG') yogaChild.setWidth(derived?.width ?? child.width)\n if (ownAxisSizing(child, 'height') === 'HUG') {\n yogaChild.setHeight(derived?.height ?? child.height)\n }\n applyMinMaxConstraints(yogaChild, child)\n return\n }\n\n configureFlexContainer(yogaChild, child, direction)\n const heldAxis = heldHugAxis(graph, child)\n if (heldAxis === 'width' && widthSizing === 'HUG') yogaChild.setWidth(child.width)\n if (heldAxis === 'height' && heightSizing === 'HUG') yogaChild.setHeight(child.height)\n\n insertFlexChildren(yogaChild, child, graph, direction, depth + 1)\n}\n\n/** Puts a frame's children into its Yoga node, through the flow box a negative edge needs. */\nfunction insertFlexChildren(\n yogaParent: YogaNode,\n parent: SceneNode,\n graph: SceneGraph,\n direction: 'LTR' | 'RTL',\n depth: number\n): void {\n const box = insertFlowBox(yogaParent, parent)\n const flow: YogaNode[] = []\n for (const child of graph\n .getChildren(parent.id)\n .map((node) => asLaidOutIn(graph, node, parent))) {\n const yogaChild = createYogaNode()\n\n if (child.layoutPositioning === 'ABSOLUTE') {\n configureAbsoluteChild(yogaChild, child)\n } else if (!child.visible) {\n yogaChild.setDisplay(Display.None)\n } else {\n if (child.layoutMode === 'GRID') {\n configureChildAsGrid(yogaChild, child, parent, graph, direction)\n } else if (child.layoutMode !== 'NONE') {\n configureChildAsAutoLayout(yogaChild, child, parent, graph, direction, depth)\n } else {\n configureChildAsLeaf(yogaChild, child, parent, graph)\n }\n flow.push(yogaChild)\n }\n applyStrokeMargins(yogaChild, child, parent)\n\n box.insertChild(yogaChild, box.getChildCount())\n }\n setFlowEdges(yogaParent, box, parent, flow, direction)\n}\n\nfunction derivedGrowingLeafFitsParent(\n graph: SceneGraph,\n parent: SceneNode,\n child: SceneNode,\n axis: 'width' | 'height'\n): boolean {\n if (child.type !== 'TEXT' || child.layoutGrow <= 0 || child.derivedLayout?.[axis] === undefined) {\n return false\n }\n const children = graph\n .getChildren(parent.id)\n .filter((candidate) => candidate.visible && candidate.layoutPositioning !== 'ABSOLUTE')\n const sizes = children.map((candidate) => {\n if (candidate.layoutGrow > 0) return candidate.derivedLayout?.[axis]\n return axis === 'width' ? candidate.width : candidate.height\n })\n return sizesFitParent(parent, children, sizes, axis)\n}\n\n/**\n * Fill text shares its parent's main axis like a fill frame: it grows and shrinks from a zero\n * basis, so its stored width (100px for new text) never decides its share. Returns whether\n * it fills the row's width, where its stored width must not constrain it either.\n */\nfunction configureGrowingText(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): boolean {\n if (child.layoutGrow <= 0 || fixedDerivedMainAxis) return false\n yogaChild.setFlexGrow(child.layoutGrow)\n yogaChild.setFlexShrink(1)\n yogaChild.setFlexBasis(0)\n return parent.layoutMode === 'HORIZONTAL'\n}\n\nfunction configureTextLeafWithoutMeasurer(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis: boolean\n): void {\n const hasStoredSize =\n child.width > 0 && child.height > 0 && !(child.width === 100 && child.height === 100)\n\n if (child.textAutoResize === 'WIDTH_AND_HEIGHT') {\n if (hasStoredSize) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n } else {\n const estimated = estimateTextSize(child)\n yogaChild.setWidth(estimated.width)\n yogaChild.setHeight(estimated.height)\n }\n return\n }\n if (child.textAutoResize !== 'HEIGHT') return\n\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const measurementWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n const stretches =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n if (!(!isRow && stretches) && !fixedDerivedMainAxis && !growsWidth) {\n yogaChild.setWidth(child.width)\n }\n if (hasStoredSize) yogaChild.setHeight(child.height)\n else yogaChild.setHeight(estimateTextSize(child, measurementWidth).height)\n}\n\nfunction configureChildAsLeaf(\n yogaChild: YogaNode,\n node: SceneNode,\n parent: SceneNode,\n graph: SceneGraph\n): void {\n const child = asFlatLeaf(node, parent)\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const selfOverride = child.layoutAlignSelf !== 'AUTO'\n const stretchCross = selfOverride\n ? child.layoutAlignSelf === 'STRETCH'\n : parent.counterAxisAlign === 'STRETCH'\n\n const isText = child.type === 'TEXT'\n const textMeasurer = getTextMeasurer()\n const needsMeasureFunc = isText && textMeasurer && child.textAutoResize !== 'NONE'\n\n const fixedDerivedMainAxis = isRow\n ? derivedGrowingLeafFitsParent(graph, parent, child, 'width')\n : derivedGrowingLeafFitsParent(graph, parent, child, 'height')\n\n if (fixedDerivedMainAxis) {\n if (isRow) yogaChild.setWidth(child.derivedLayout?.width ?? child.width)\n else yogaChild.setHeight(child.derivedLayout?.height ?? child.height)\n }\n\n if (needsMeasureFunc) {\n configureTextLeaf(yogaChild, child, parent, fixedDerivedMainAxis)\n } else if (isText && !textMeasurer && child.textAutoResize !== 'NONE') {\n configureTextLeafWithoutMeasurer(yogaChild, child, parent, fixedDerivedMainAxis)\n } else {\n configureNonTextLeaf(yogaChild, child, isRow, stretchCross)\n // Fixed text still contributes its box to a HUG cross axis. Without\n // an intrinsic minimum, stretch collapses the text to its siblings.\n if (isText && stretchCross && parent.counterAxisSizing === 'HUG') {\n if (isRow) yogaChild.setMinHeight(child.height)\n else yogaChild.setMinWidth(child.width)\n }\n }\n\n const selfAlign = mapAlignSelf(child.layoutAlignSelf)\n if (selfAlign != null) yogaChild.setAlignSelf(selfAlign)\n\n applyLockedAspectRatio(yogaChild, child, parent)\n applyMinMaxConstraints(yogaChild, child)\n}\n\nfunction configureTextLeaf(\n yogaChild: YogaNode,\n child: SceneNode,\n parent: SceneNode,\n fixedDerivedMainAxis = false\n): void {\n const autoResize = child.textAutoResize\n const isRow = parent.layoutMode === 'HORIZONTAL'\n const growsWidth = configureGrowingText(yogaChild, child, parent, fixedDerivedMainAxis)\n const stretchesCross =\n child.layoutAlignSelf === 'STRETCH' ||\n (child.layoutAlignSelf === 'AUTO' && parent.counterAxisAlign === 'STRETCH')\n // Layout sets the width of text that grows along a row or stretches across a column.\n const fillsWidth = (!isRow && stretchesCross) || growsWidth\n\n const cache = new Map<number, { width: number; height: number }>()\n const UNCONSTRAINED_KEY = -1\n\n if (autoResize === 'WIDTH_AND_HEIGHT') {\n const importedSize = child.derivedLayout\n if (importedSize?.width !== undefined && importedSize.height !== undefined) {\n yogaChild.setWidth(child.width)\n yogaChild.setHeight(child.height)\n return\n }\n\n // Auto-width text keeps each line whole, as Figma's does, in a parent narrower than the text;\n // only a width that layout or a max width sets wraps it.\n const wraps = fillsWidth || child.maxWidth != null\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n const maxW = wraps && widthMode !== MeasureMode.Undefined ? width : undefined\n const cacheKey = maxW === undefined ? UNCONSTRAINED_KEY : Math.round(maxW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n const result = measureAutoWidthText(child, maxW ?? autoWidthWrapWidth(child))\n cache.set(cacheKey, result)\n return result\n })\n } else if (autoResize === 'HEIGHT') {\n const fixedWidth = fixedDerivedMainAxis\n ? (child.derivedLayout?.width ?? child.width)\n : child.width\n // Let Yoga stretch or grow fill-width text instead of fixing its stored width.\n if (child.layoutGrow <= 0 && !fillsWidth) {\n yogaChild.setWidth(fixedWidth)\n }\n yogaChild.setMeasureFunc((width, widthMode, _height, _heightMode) => {\n let constraintW = fixedWidth\n if (fillsWidth) {\n if (widthMode !== MeasureMode.Undefined) constraintW = width\n } else if (widthMode !== MeasureMode.Undefined) {\n constraintW = Math.min(width, fixedWidth || width)\n }\n const cacheKey = Math.round(constraintW)\n const cached = cache.get(cacheKey)\n if (cached) return cached\n\n if (constraintW === child.width && (child.derivedTextGlyphs?.length ?? 0) > 0) {\n return { width: constraintW, height: child.height }\n }\n const result = { width: constraintW, height: measureTextForLayout(child, constraintW).height }\n cache.set(cacheKey, result)\n return result\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2DA,SAAgB,cAAc,OAAmB,SAAuB;CACtE,MAAM,0BAA0B,sBAAsB,OAAO,OAAO,CAAC;AACvE;;;;;;;AAQA,MAAM,mBAAmB;AAEzB,SAAS,sBAAsB,OAAmB,SAAuB;CACvE,MAAM,QAAQ,MAAM,QAAQ,OAAO;CACnC,IAAI,CAAC,SAAS,MAAM,eAAe,QAAQ;CAE3C,sBAAsB,OAAO,KAAK;CAElC,MAAM,gBAAgB,+BAA+B,OAAO,KAAK;CACjE,MAAM,gBAAgB,kBAAkB,QAAQ,UAAU,MAAM,UAAU;CAC1E,MAAM,WACJ,MAAM,eAAe,SACjB,cAAc,OAAO,OAAO,aAAa,IACzC,cAAc,OAAO,OAAO,aAAa;CAC/C,SAAS,gBAAgB,KAAA,GAAW,KAAA,GAAW,aAAa;CAC5D,gBAAgB,OAAO,OAAO,UAAU,qBAAqB;CAC7D,aAAa,QAAQ;AACvB;AACA,SAAS,+BACP,OACA,MACe;CACf,MAAM,SAAS,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI;CAC9D,MAAM,qBAAqB,SAAS,+BAA+B,OAAO,MAAM,IAAI;CACpF,OAAO,2BAA2B,MAAM,kBAAkB;AAC5D;AAEA,SAAgB,kBAAkB,OAAmB,SAAwB;CAC3E,MAAM,0BAA0B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ceneGraph): Array<SceneNode & {
|
|
|
9
9
|
type: 'COMPONENT' | 'COMPONENT_SET';
|
|
10
10
|
}>;
|
|
11
11
|
/**
|
|
12
|
-
* The asset key a component already publishes under: its own key, or else the library key
|
|
13
|
-
*
|
|
12
|
+
* The asset key a component already publishes under: its own key, or else the library key or
|
|
13
|
+
* publish ID it was read with — the identity a revision gives the asset. A file node id is not one:
|
|
14
|
+
* it names the node in one file and does not survive into a publication.
|
|
14
15
|
*/
|
|
15
16
|
declare function existingAssetKey(node: SceneNode): string | null;
|
|
16
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-keys.d.ts","names":[],"sources":["../../src/library/asset-keys.ts"],"mappings":";;UAIiB;EACf;EACA;EACA;;iBAiBc,wBACd,OAAO,aACN,MAAM;EAAc
|
|
1
|
+
{"version":3,"file":"asset-keys.d.ts","names":[],"sources":["../../src/library/asset-keys.ts"],"mappings":";;UAIiB;EACf;EACA;EACA;;iBAiBc,wBACd,OAAO,aACN,MAAM;EAAc;;;;;;;iBAsBP,iBAAiB,MAAM;;;;;iBAQvB,uBACd,OAAO,YACP,0BACC;iBAwBa,0BAA0B,OAAO,aAAa"}
|
|
@@ -19,11 +19,12 @@ function publishedRoots(graph, assetNodeIds) {
|
|
|
19
19
|
return publishableLibraryRoots(graph).filter((node) => selected.has(node.id));
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* The asset key a component already publishes under: its own key, or else the library key
|
|
23
|
-
*
|
|
22
|
+
* The asset key a component already publishes under: its own key, or else the library key or
|
|
23
|
+
* publish ID it was read with — the identity a revision gives the asset. A file node id is not one:
|
|
24
|
+
* it names the node in one file and does not survive into a publication.
|
|
24
25
|
*/
|
|
25
26
|
function existingAssetKey(node) {
|
|
26
|
-
return node.componentKey ?? node.sourceLibraryKey ?? node.publishId
|
|
27
|
+
return node.componentKey ?? node.sourceLibraryKey ?? node.publishId;
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
30
|
* Gives each published component without an asset key one made from its name, distinct from every
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-keys.js","names":[],"sources":["../../src/library/asset-keys.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { isValidLibraryAssetKey } from './identity'\n\nexport interface AssetKeyAssignment {\n nodeId: string\n assetKey: string\n existing: boolean\n}\n\n/** The longest key a name gives, leaving room for the `-N` a namesake's key takes. */\nconst MAX_NAME_KEY_LENGTH = 240\n\n/** A valid asset key from a component's name: it starts with a letter or digit. */\nfunction normalizeAssetKey(name: string): string {\n const normalized = name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._:/-]+/g, '-')\n .replace(/^[^a-z0-9]+|-+$/g, '')\n .slice(0, MAX_NAME_KEY_LENGTH)\n return normalized || 'component'\n}\n\nexport function publishableLibraryRoots(\n graph: SceneGraph\n): Array<SceneNode & { type: 'COMPONENT' | 'COMPONENT_SET' }> {\n return [...graph.getAllNodes()].filter(\n (node): node is SceneNode & { type: 'COMPONENT' | 'COMPONENT_SET' } => {\n if (node.type !== 'COMPONENT' && node.type !== 'COMPONENT_SET') return false\n if (node.librarySource?.readOnly) return false\n const parent = node.parentId ? graph.getNode(node.parentId) : undefined\n return parent?.type !== 'COMPONENT_SET'\n }\n )\n}\n\nfunction publishedRoots(graph: SceneGraph, assetNodeIds?: string[]): SceneNode[] {\n if (!assetNodeIds) return publishableLibraryRoots(graph)\n const selected = new Set(assetNodeIds)\n return publishableLibraryRoots(graph).filter((node) => selected.has(node.id))\n}\n\n/**\n * The asset key a component already publishes under: its own key, or else the library key
|
|
1
|
+
{"version":3,"file":"asset-keys.js","names":[],"sources":["../../src/library/asset-keys.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { isValidLibraryAssetKey } from './identity'\n\nexport interface AssetKeyAssignment {\n nodeId: string\n assetKey: string\n existing: boolean\n}\n\n/** The longest key a name gives, leaving room for the `-N` a namesake's key takes. */\nconst MAX_NAME_KEY_LENGTH = 240\n\n/** A valid asset key from a component's name: it starts with a letter or digit. */\nfunction normalizeAssetKey(name: string): string {\n const normalized = name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._:/-]+/g, '-')\n .replace(/^[^a-z0-9]+|-+$/g, '')\n .slice(0, MAX_NAME_KEY_LENGTH)\n return normalized || 'component'\n}\n\nexport function publishableLibraryRoots(\n graph: SceneGraph\n): Array<SceneNode & { type: 'COMPONENT' | 'COMPONENT_SET' }> {\n return [...graph.getAllNodes()].filter(\n (node): node is SceneNode & { type: 'COMPONENT' | 'COMPONENT_SET' } => {\n if (node.type !== 'COMPONENT' && node.type !== 'COMPONENT_SET') return false\n if (node.librarySource?.readOnly) return false\n const parent = node.parentId ? graph.getNode(node.parentId) : undefined\n return parent?.type !== 'COMPONENT_SET'\n }\n )\n}\n\nfunction publishedRoots(graph: SceneGraph, assetNodeIds?: string[]): SceneNode[] {\n if (!assetNodeIds) return publishableLibraryRoots(graph)\n const selected = new Set(assetNodeIds)\n return publishableLibraryRoots(graph).filter((node) => selected.has(node.id))\n}\n\n/**\n * The asset key a component already publishes under: its own key, or else the library key or\n * publish ID it was read with — the identity a revision gives the asset. A file node id is not one:\n * it names the node in one file and does not survive into a publication.\n */\nexport function existingAssetKey(node: SceneNode): string | null {\n return node.componentKey ?? node.sourceLibraryKey ?? node.publishId\n}\n\n/**\n * Gives each published component without an asset key one made from its name, distinct from every\n * key the document already uses; a component keeps the identity it already publishes under.\n */\nexport function ensureLibraryAssetKeys(\n graph: SceneGraph,\n assetNodeIds?: string[]\n): AssetKeyAssignment[] {\n const roots = publishedRoots(graph, assetNodeIds)\n const used = new Set(\n [...graph.getAllNodes()].flatMap((node) => {\n const key =\n node.type === 'COMPONENT' || node.type === 'COMPONENT_SET' ? existingAssetKey(node) : null\n return key && isValidLibraryAssetKey(key) ? [key] : []\n })\n )\n return roots.map((node) => {\n const existing = existingAssetKey(node)\n if (existing && isValidLibraryAssetKey(existing)) {\n return { nodeId: node.id, assetKey: existing, existing: true }\n }\n const base = normalizeAssetKey(node.name)\n let assetKey = base\n let suffix = 2\n while (used.has(assetKey)) assetKey = `${base}-${suffix++}`\n used.add(assetKey)\n graph.updateNode(node.id, { componentKey: assetKey })\n return { nodeId: node.id, assetKey, existing: false }\n })\n}\n\nexport function duplicateLibraryAssetKeys(graph: SceneGraph): Map<string, string[]> {\n const byKey = new Map<string, string[]>()\n for (const node of graph.getAllNodes()) {\n if (node.type !== 'COMPONENT' && node.type !== 'COMPONENT_SET') continue\n if (!node.componentKey) continue\n const ids = byKey.get(node.componentKey) ?? []\n ids.push(node.id)\n byKey.set(node.componentKey, ids)\n }\n return new Map([...byKey].filter(([, ids]) => ids.length > 1))\n}\n"],"mappings":";;;AAWA,MAAM,sBAAsB;;AAG5B,SAAS,kBAAkB,MAAsB;CAO/C,OANmB,KAChB,KAAK,CAAC,CACN,YAAY,CAAC,CACb,QAAQ,oBAAoB,GAAG,CAAC,CAChC,QAAQ,oBAAoB,EAAE,CAAC,CAC/B,MAAM,GAAG,mBACI,KAAK;AACvB;AAEA,SAAgB,wBACd,OAC4D;CAC5D,OAAO,CAAC,GAAG,MAAM,YAAY,CAAC,CAAC,CAAC,QAC7B,SAAsE;EACrE,IAAI,KAAK,SAAS,eAAe,KAAK,SAAS,iBAAiB,OAAO;EACvE,IAAI,KAAK,eAAe,UAAU,OAAO;EAEzC,QADe,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI,KAAA,EAAA,EAC/C,SAAS;CAC1B,CACF;AACF;AAEA,SAAS,eAAe,OAAmB,cAAsC;CAC/E,IAAI,CAAC,cAAc,OAAO,wBAAwB,KAAK;CACvD,MAAM,WAAW,IAAI,IAAI,YAAY;CACrC,OAAO,wBAAwB,KAAK,CAAC,CAAC,QAAQ,SAAS,SAAS,IAAI,KAAK,EAAE,CAAC;AAC9E;;;;;;AAOA,SAAgB,iBAAiB,MAAgC;CAC/D,OAAO,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+1,18 @@
|
|
|
1
1
|
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
2
2
|
//#region src/library/copied-references.d.ts
|
|
3
|
+
/** Copies placed in another document, whose text links must follow the copy. */
|
|
4
|
+
interface CopiedReferenceOptions {
|
|
5
|
+
followTextLinks?: boolean;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
8
|
* Points the layers a library copy made at one another, as `prepareNodeTransfer` does for a
|
|
5
9
|
* paste: an instance's main component, the layers its overrides change and the components they
|
|
6
10
|
* swap in, and the components an instance-swap property defaults to or is set to. `mappedIds`
|
|
7
11
|
* maps each copied layer to its copy; a reference outside the copy stays as it is, and so do
|
|
8
|
-
* variable IDs, since the copies keep their source's variables.
|
|
12
|
+
* variable IDs, since the copies keep their source's variables. Text links follow the copy only
|
|
13
|
+
* with `followTextLinks`: duplicate and paste keep them on the original layers, as Figma does.
|
|
9
14
|
*/
|
|
10
|
-
declare function remapCopiedReferences(graph: SceneGraph, mappedIds: ReadonlyMap<string, string
|
|
15
|
+
declare function remapCopiedReferences(graph: SceneGraph, mappedIds: ReadonlyMap<string, string>, options?: CopiedReferenceOptions): void;
|
|
11
16
|
//#endregion
|
|
12
|
-
export { remapCopiedReferences };
|
|
17
|
+
export { CopiedReferenceOptions, remapCopiedReferences };
|
|
13
18
|
//# sourceMappingURL=copied-references.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copied-references.d.ts","names":[],"sources":["../../src/library/copied-references.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"copied-references.d.ts","names":[],"sources":["../../src/library/copied-references.ts"],"mappings":";;;UAOiB;EACf;;;;;;;;;;iBAqDc,sBACd,OAAO,YACP,WAAW,6BACX,UAAS"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { remapStyleRunReferences } from "@pairdraw/scene-graph/text";
|
|
2
|
+
import { isEqual, mapValues } from "es-toolkit";
|
|
2
3
|
import { remapInstanceOverrideState } from "@pairdraw/scene-graph/instances/overrides";
|
|
3
4
|
//#region src/library/copied-references.ts
|
|
4
|
-
function remappedReferences(node, mapped, swapProperties) {
|
|
5
|
+
function remappedReferences(node, mapped, swapProperties, followTextLinks) {
|
|
5
6
|
const changes = {};
|
|
6
7
|
if (node.componentId && mapped(node.componentId) !== node.componentId) changes.componentId = mapped(node.componentId);
|
|
7
8
|
const overrides = node.instanceOverrides;
|
|
@@ -14,6 +15,14 @@ function remappedReferences(node, mapped, swapProperties) {
|
|
|
14
15
|
defaultValue: mapped(definition.defaultValue)
|
|
15
16
|
} : definition);
|
|
16
17
|
if (Object.keys(node.componentPropertyAssignments).some((id) => swapProperties.has(id))) changes.componentPropertyAssignments = mapValues(node.componentPropertyAssignments, (value, id) => swapProperties.has(id) ? mapped(value) : value);
|
|
18
|
+
if (followTextLinks) {
|
|
19
|
+
const styleRuns = remapStyleRunReferences(node.styleRuns, {
|
|
20
|
+
variable: (id) => id,
|
|
21
|
+
style: (id) => id,
|
|
22
|
+
node: mapped
|
|
23
|
+
});
|
|
24
|
+
if (!isEqual(styleRuns, node.styleRuns)) changes.styleRuns = styleRuns;
|
|
25
|
+
}
|
|
17
26
|
return changes;
|
|
18
27
|
}
|
|
19
28
|
/**
|
|
@@ -21,14 +30,15 @@ function remappedReferences(node, mapped, swapProperties) {
|
|
|
21
30
|
* paste: an instance's main component, the layers its overrides change and the components they
|
|
22
31
|
* swap in, and the components an instance-swap property defaults to or is set to. `mappedIds`
|
|
23
32
|
* maps each copied layer to its copy; a reference outside the copy stays as it is, and so do
|
|
24
|
-
* variable IDs, since the copies keep their source's variables.
|
|
33
|
+
* variable IDs, since the copies keep their source's variables. Text links follow the copy only
|
|
34
|
+
* with `followTextLinks`: duplicate and paste keep them on the original layers, as Figma does.
|
|
25
35
|
*/
|
|
26
|
-
function remapCopiedReferences(graph, mappedIds) {
|
|
36
|
+
function remapCopiedReferences(graph, mappedIds, options = {}) {
|
|
27
37
|
const mapped = (id) => mappedIds.get(id) ?? id;
|
|
28
38
|
const copies = [...mappedIds.values()].flatMap((id) => graph.getNode(id) ?? []);
|
|
29
39
|
const swapProperties = new Set(copies.flatMap((node) => node.componentPropertyDefinitions.filter((definition) => definition.type === "INSTANCE_SWAP").map((definition) => definition.id)));
|
|
30
40
|
for (const node of copies) {
|
|
31
|
-
const changes = remappedReferences(node, mapped, swapProperties);
|
|
41
|
+
const changes = remappedReferences(node, mapped, swapProperties, options.followTextLinks === true);
|
|
32
42
|
if (Object.keys(changes).length > 0) graph.updateNode(node.id, changes);
|
|
33
43
|
}
|
|
34
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copied-references.js","names":[],"sources":["../../src/library/copied-references.ts"],"sourcesContent":["import { mapValues } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { remapInstanceOverrideState } from '@pairdraw/scene-graph/instances/overrides'\n\nfunction remappedReferences(\n node: SceneNode,\n mapped: (id: string) => string,\n swapProperties: ReadonlySet<string
|
|
1
|
+
{"version":3,"file":"copied-references.js","names":[],"sources":["../../src/library/copied-references.ts"],"sourcesContent":["import { isEqual, mapValues } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { remapInstanceOverrideState } from '@pairdraw/scene-graph/instances/overrides'\nimport { remapStyleRunReferences } from '@pairdraw/scene-graph/text'\n\n/** Copies placed in another document, whose text links must follow the copy. */\nexport interface CopiedReferenceOptions {\n followTextLinks?: boolean\n}\n\nfunction remappedReferences(\n node: SceneNode,\n mapped: (id: string) => string,\n swapProperties: ReadonlySet<string>,\n followTextLinks: boolean\n): Partial<SceneNode> {\n const changes: Partial<SceneNode> = {}\n if (node.componentId && mapped(node.componentId) !== node.componentId)\n changes.componentId = mapped(node.componentId)\n const overrides = node.instanceOverrides\n if (overrides.self.size > 0 || overrides.descendants.size > 0) {\n changes.instanceOverrides = remapInstanceOverrideState(overrides, {\n node: mapped,\n variable: (id) => id\n })\n }\n if (node.componentPropertyDefinitions.some((definition) => definition.type === 'INSTANCE_SWAP')) {\n changes.componentPropertyDefinitions = node.componentPropertyDefinitions.map((definition) =>\n definition.type === 'INSTANCE_SWAP' && definition.defaultValue\n ? { ...definition, defaultValue: mapped(definition.defaultValue) }\n : definition\n )\n }\n if (Object.keys(node.componentPropertyAssignments).some((id) => swapProperties.has(id))) {\n changes.componentPropertyAssignments = mapValues(\n node.componentPropertyAssignments,\n (value, id) => (swapProperties.has(id) ? mapped(value) : value)\n )\n }\n if (followTextLinks) {\n // A text link names a layer of the document it was copied from, which the receiving document\n // lacks; following the copy points it at the copy's layer.\n const styleRuns = remapStyleRunReferences(node.styleRuns, {\n variable: (id) => id,\n style: (id) => id,\n node: mapped\n })\n if (!isEqual(styleRuns, node.styleRuns)) changes.styleRuns = styleRuns\n }\n return changes\n}\n\n/**\n * Points the layers a library copy made at one another, as `prepareNodeTransfer` does for a\n * paste: an instance's main component, the layers its overrides change and the components they\n * swap in, and the components an instance-swap property defaults to or is set to. `mappedIds`\n * maps each copied layer to its copy; a reference outside the copy stays as it is, and so do\n * variable IDs, since the copies keep their source's variables. Text links follow the copy only\n * with `followTextLinks`: duplicate and paste keep them on the original layers, as Figma does.\n */\nexport function remapCopiedReferences(\n graph: SceneGraph,\n mappedIds: ReadonlyMap<string, string>,\n options: CopiedReferenceOptions = {}\n): void {\n const mapped = (id: string) => mappedIds.get(id) ?? id\n const copies = [...mappedIds.values()].flatMap((id) => graph.getNode(id) ?? [])\n const swapProperties = new Set(\n copies.flatMap((node) =>\n node.componentPropertyDefinitions\n .filter((definition) => definition.type === 'INSTANCE_SWAP')\n .map((definition) => definition.id)\n )\n )\n for (const node of copies) {\n const changes = remappedReferences(\n node,\n mapped,\n swapProperties,\n options.followTextLinks === true\n )\n if (Object.keys(changes).length > 0) graph.updateNode(node.id, changes)\n }\n}\n"],"mappings":";;;;AAWA,SAAS,mBACP,MACA,QACA,gBACA,iBACoB;CACpB,MAAM,UAA8B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QAAQ;EACzB,MAAM,UAAU,mBACd,MACA,QACA,gBACA,QAAQ,oBAAoB,IAC9B;EACA,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,WAAW,KAAK,IAAI,OAAO;CACxE;AACF"}
|
|
@@ -38,7 +38,7 @@ function copyLibraryTree(source, target, sourceId, parentId, mappedIds) {
|
|
|
38
38
|
}
|
|
39
39
|
function markDefinitions(graph, revision, mappedIds) {
|
|
40
40
|
const descriptorsBySourceId = new Map(revision.manifest.assets.map((asset) => [asset.sourceNodeId, asset]));
|
|
41
|
-
remapCopiedReferences(graph, mappedIds);
|
|
41
|
+
remapCopiedReferences(graph, mappedIds, { followTextLinks: true });
|
|
42
42
|
for (const [sourceId, targetId] of mappedIds) {
|
|
43
43
|
const target = graph.getNode(targetId);
|
|
44
44
|
if (!target) continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materialize.js","names":[],"sources":["../../src/library/materialize.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { libraryDefinitionsPage } from '@pairdraw/scene-graph/components'\nimport { cloneNodeProps } from '@pairdraw/scene-graph/copy'\n\nimport { remapCopiedReferences } from './copied-references'\nimport { findLibraryDefinition } from './definitions'\nimport { assertLibraryAssetKey, assertLibraryId, libraryAssetIdentityKey } from './identity'\nimport type { ComponentLibraryRevision, LibraryAssetDescriptor } from './types'\n\nexport interface MaterializedLibraryAsset {\n componentId: string\n componentSetId: string | null\n pageId: string\n created: boolean\n}\n\nexport function libraryDependencyRoots(\n revision: ComponentLibraryRevision,\n descriptor: LibraryAssetDescriptor\n): SceneNode[] {\n const root = revision.graph.getNode(descriptor.sourceNodeId)\n if (!root) throw new Error(`Library asset source is missing: ${descriptor.key}`)\n const roots = new Map([[root.id, root]])\n const visited = new Set<string>()\n const pending = [root.id]\n while (pending.length > 0) {\n const id = pending.pop()\n if (!id || visited.has(id)) continue\n visited.add(id)\n const node = revision.graph.getNode(id)\n if (!node) continue\n pending.push(...node.childIds)\n if (!node.componentId) continue\n const component = revision.graph.getNode(node.componentId)\n if (!component) continue\n let definitionRoot = component\n const parent = component.parentId ? revision.graph.getNode(component.parentId) : undefined\n if (parent?.type === 'COMPONENT_SET') definitionRoot = parent\n roots.set(definitionRoot.id, definitionRoot)\n pending.push(definitionRoot.id)\n }\n return [...roots.values()]\n}\n\nexport function copyLibraryTree(\n source: SceneGraph,\n target: SceneGraph,\n sourceId: string,\n parentId: string,\n mappedIds: Map<string, string>\n): void {\n if (mappedIds.has(sourceId)) return\n const node = source.getNode(sourceId)\n if (!node) return\n const created = target.createNode(node.type, parentId, cloneNodeProps(node, node.componentId))\n mappedIds.set(sourceId, created.id)\n for (const childId of node.childIds)\n copyLibraryTree(source, target, childId, created.id, mappedIds)\n}\n\nfunction markDefinitions(\n graph: SceneGraph,\n revision: ComponentLibraryRevision,\n mappedIds: Map<string, string>\n): void {\n const descriptorsBySourceId = new Map(\n revision.manifest.assets.map((asset) => [asset.sourceNodeId, asset])\n )\n remapCopiedReferences(graph, mappedIds)\n for (const [sourceId, targetId] of mappedIds) {\n const target = graph.getNode(targetId)\n if (!target) continue\n const descriptor = descriptorsBySourceId.get(sourceId)\n const source = revision.graph.getNode(sourceId)\n const sourceAssetKey =\n descriptor?.key ??\n (source?.type === 'COMPONENT' || source?.type === 'COMPONENT_SET'\n ? (source.componentKey ?? source.sourceLibraryKey ?? source.publishId)\n : null)\n graph.updateNode(targetId, {\n locked: true,\n librarySource: sourceAssetKey\n ? {\n identity: {\n libraryId: revision.manifest.libraryId,\n assetKey: sourceAssetKey,\n revisionId: revision.manifest.revisionId\n },\n sourceNodeId: sourceId,\n readOnly: true\n }\n : target.librarySource\n })\n }\n}\n\nfunction copyImages(source: SceneGraph, target: SceneGraph, mappedIds: Map<string, string>): void {\n const hashes = new Set<string>()\n for (const sourceId of mappedIds.keys()) {\n const node = source.getNode(sourceId)\n const fills = [\n ...(node?.fills ?? []),\n ...(node?.fillGeometry.flatMap((geometry) => geometry.fills ?? []) ?? [])\n ]\n for (const fill of fills) {\n if (fill.type === 'IMAGE' && fill.imageHash) hashes.add(fill.imageHash)\n }\n }\n for (const hash of hashes) {\n const image = source.images.get(hash)\n if (image) target.images.set(hash, new Uint8Array(image))\n }\n}\n\nfunction defaultComponent(graph: SceneGraph, root: SceneNode): SceneNode | undefined {\n if (root.type === 'COMPONENT') return root\n return root.childIds\n .flatMap((id) => {\n const child = graph.getNode(id)\n return child?.type === 'COMPONENT' ? [child] : []\n })\n .sort((left, right) => left.y - right.y || left.x - right.x)[0]\n}\n\nexport function materializeLibraryAsset(\n consumer: SceneGraph,\n revision: ComponentLibraryRevision,\n assetKey: string\n): MaterializedLibraryAsset {\n const { libraryId, revisionId } = revision.manifest\n assertLibraryId(libraryId)\n assertLibraryAssetKey(assetKey)\n consumer.enabledLibraries.set(libraryId, { libraryId, revisionId, enabled: true })\n const existing = findLibraryDefinition(consumer, libraryId, assetKey, revisionId)\n if (existing) {\n const component = defaultComponent(consumer, existing)\n if (!component) throw new Error(`Materialized asset has no component: ${assetKey}`)\n return {\n componentId: component.id,\n componentSetId: existing.type === 'COMPONENT_SET' ? existing.id : null,\n pageId: existing.parentId ?? consumer.rootId,\n created: false\n }\n }\n\n const descriptor = revision.manifest.assets.find((asset) => asset.key === assetKey)\n if (!descriptor)\n throw new Error(`Library asset not found: ${libraryAssetIdentityKey(libraryId, assetKey)}`)\n const page = libraryDefinitionsPage(consumer)\n const mappedIds = new Map<string, string>()\n for (const root of libraryDependencyRoots(revision, descriptor)) {\n copyLibraryTree(revision.graph, consumer, root.id, page.id, mappedIds)\n }\n markDefinitions(consumer, revision, mappedIds)\n copyImages(revision.graph, consumer, mappedIds)\n\n const rootId = mappedIds.get(descriptor.sourceNodeId)\n const root = rootId ? consumer.getNode(rootId) : undefined\n if (!root) throw new Error(`Failed to materialize library asset: ${assetKey}`)\n const component = defaultComponent(consumer, root)\n if (!component) throw new Error(`Library asset has no component: ${assetK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I,UAAU,QAAQ,EAAE;CAClC,KAAK,MAAM,WAAW,KAAK,UACzB,gBAAgB,QAAQ,QAAQ,SAAS,QAAQ,IAAI,SAAS;AAClE;AAEA,SAAS,gBACP,OACA,UACA,WACM;CACN,MAAM,wBAAwB,IAAI,IAChC,SAAS,SAAS,OAAO,KAAK,UAAU,CAAC,MAAM,cAAc,KAAK,CAAC,CACrE;CACA,sBAAsB,OAAO,
|
|
1
|
+
{"version":3,"file":"materialize.js","names":[],"sources":["../../src/library/materialize.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { libraryDefinitionsPage } from '@pairdraw/scene-graph/components'\nimport { cloneNodeProps } from '@pairdraw/scene-graph/copy'\n\nimport { remapCopiedReferences } from './copied-references'\nimport { findLibraryDefinition } from './definitions'\nimport { assertLibraryAssetKey, assertLibraryId, libraryAssetIdentityKey } from './identity'\nimport type { ComponentLibraryRevision, LibraryAssetDescriptor } from './types'\n\nexport interface MaterializedLibraryAsset {\n componentId: string\n componentSetId: string | null\n pageId: string\n created: boolean\n}\n\nexport function libraryDependencyRoots(\n revision: ComponentLibraryRevision,\n descriptor: LibraryAssetDescriptor\n): SceneNode[] {\n const root = revision.graph.getNode(descriptor.sourceNodeId)\n if (!root) throw new Error(`Library asset source is missing: ${descriptor.key}`)\n const roots = new Map([[root.id, root]])\n const visited = new Set<string>()\n const pending = [root.id]\n while (pending.length > 0) {\n const id = pending.pop()\n if (!id || visited.has(id)) continue\n visited.add(id)\n const node = revision.graph.getNode(id)\n if (!node) continue\n pending.push(...node.childIds)\n if (!node.componentId) continue\n const component = revision.graph.getNode(node.componentId)\n if (!component) continue\n let definitionRoot = component\n const parent = component.parentId ? revision.graph.getNode(component.parentId) : undefined\n if (parent?.type === 'COMPONENT_SET') definitionRoot = parent\n roots.set(definitionRoot.id, definitionRoot)\n pending.push(definitionRoot.id)\n }\n return [...roots.values()]\n}\n\nexport function copyLibraryTree(\n source: SceneGraph,\n target: SceneGraph,\n sourceId: string,\n parentId: string,\n mappedIds: Map<string, string>\n): void {\n if (mappedIds.has(sourceId)) return\n const node = source.getNode(sourceId)\n if (!node) return\n const created = target.createNode(node.type, parentId, cloneNodeProps(node, node.componentId))\n mappedIds.set(sourceId, created.id)\n for (const childId of node.childIds)\n copyLibraryTree(source, target, childId, created.id, mappedIds)\n}\n\nfunction markDefinitions(\n graph: SceneGraph,\n revision: ComponentLibraryRevision,\n mappedIds: Map<string, string>\n): void {\n const descriptorsBySourceId = new Map(\n revision.manifest.assets.map((asset) => [asset.sourceNodeId, asset])\n )\n remapCopiedReferences(graph, mappedIds, { followTextLinks: true })\n for (const [sourceId, targetId] of mappedIds) {\n const target = graph.getNode(targetId)\n if (!target) continue\n const descriptor = descriptorsBySourceId.get(sourceId)\n const source = revision.graph.getNode(sourceId)\n const sourceAssetKey =\n descriptor?.key ??\n (source?.type === 'COMPONENT' || source?.type === 'COMPONENT_SET'\n ? (source.componentKey ?? source.sourceLibraryKey ?? source.publishId)\n : null)\n graph.updateNode(targetId, {\n locked: true,\n librarySource: sourceAssetKey\n ? {\n identity: {\n libraryId: revision.manifest.libraryId,\n assetKey: sourceAssetKey,\n revisionId: revision.manifest.revisionId\n },\n sourceNodeId: sourceId,\n readOnly: true\n }\n : target.librarySource\n })\n }\n}\n\nfunction copyImages(source: SceneGraph, target: SceneGraph, mappedIds: Map<string, string>): void {\n const hashes = new Set<string>()\n for (const sourceId of mappedIds.keys()) {\n const node = source.getNode(sourceId)\n const fills = [\n ...(node?.fills ?? []),\n ...(node?.fillGeometry.flatMap((geometry) => geometry.fills ?? []) ?? [])\n ]\n for (const fill of fills) {\n if (fill.type === 'IMAGE' && fill.imageHash) hashes.add(fill.imageHash)\n }\n }\n for (const hash of hashes) {\n const image = source.images.get(hash)\n if (image) target.images.set(hash, new Uint8Array(image))\n }\n}\n\nfunction defaultComponent(graph: SceneGraph, root: SceneNode): SceneNode | undefined {\n if (root.type === 'COMPONENT') return root\n return root.childIds\n .flatMap((id) => {\n const child = graph.getNode(id)\n return child?.type === 'COMPONENT' ? [child] : []\n })\n .sort((left, right) => left.y - right.y || left.x - right.x)[0]\n}\n\nexport function materializeLibraryAsset(\n consumer: SceneGraph,\n revision: ComponentLibraryRevision,\n assetKey: string\n): MaterializedLibraryAsset {\n const { libraryId, revisionId } = revision.manifest\n assertLibraryId(libraryId)\n assertLibraryAssetKey(assetKey)\n consumer.enabledLibraries.set(libraryId, { libraryId, revisionId, enabled: true })\n const existing = findLibraryDefinition(consumer, libraryId, assetKey, revisionId)\n if (existing) {\n const component = defaultComponent(consumer, existing)\n if (!component) throw new Error(`Materialized asset has no component: ${assetKey}`)\n return {\n componentId: component.id,\n componentSetId: existing.type === 'COMPONENT_SET' ? existing.id : null,\n pageId: existing.parentId ?? consumer.rootId,\n created: false\n }\n }\n\n const descriptor = revision.manifest.assets.find((asset) => asset.key === assetKey)\n if (!descriptor)\n throw new Error(`Library asset not found: ${libraryAssetIdentityKey(libraryId, assetKey)}`)\n const page = libraryDefinitionsPage(consumer)\n const mappedIds = new Map<string, string>()\n for (const root of libraryDependencyRoots(revision, descriptor)) {\n copyLibraryTree(revision.graph, consumer, root.id, page.id, mappedIds)\n }\n markDefinitions(consumer, revision, mappedIds)\n copyImages(revision.graph, consumer, mappedIds)\n\n const rootId = mappedIds.get(descriptor.sourceNodeId)\n const root = rootId ? consumer.getNode(rootId) : undefined\n if (!root) throw new Error(`Failed to materialize library asset: ${assetKey}`)\n const component = defaultComponent(consumer, root)\n if (!component) throw new Error(`Library asset has no component: ${assetKey}`)\n return {\n componentId: component.id,\n componentSetId: root.type === 'COMPONENT_SET' ? root.id : null,\n pageId: page.id,\n created: true\n }\n}\n"],"mappings":";;;;;;AAgBA,SAAgB,uBACd,UACA,YACa;CACb,MAAM,OAAO,SAAS,MAAM,QAAQ,WAAW,YAAY;CAC3D,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,oCAAoC,WAAW,KAAK;CAC/E,MAAM,wBAAQ,IAAI,IAA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C,UAAU;CAC7E,OAAO;EACL,aAAa,UAAU;EACvB,gBAAgB,KAAK,SAAS,kBAAkB,KAAK,KAAK;EAC1D,QAAQ,KAAK;EACb,SAAS;CACX;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":[],"sources":["../../src/library/schema.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { SceneNode, Variable, VariableCollection } from '@pairdraw/scene-graph'\n\nimport { decodeStoredLibraryValue } from './serialization'\nimport type { SerializedComponentLibraryRevision } from './serialization'\nimport { COMPONENT_LIBRARY_SCHEMA_VERSION } from './types'\nimport type { LibrarySummary, StoredLibraryLatestManifest } from './types'\n\nconst serializedNodeShapeSchema = v.looseObject({\n id: v.string(),\n type: v.string(),\n parentId: v.nullable(v.string()),\n childIds: v.array(v.string()),\n //
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../src/library/schema.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { SceneNode, Variable, VariableCollection } from '@pairdraw/scene-graph'\n\nimport { decodeStoredLibraryValue } from './serialization'\nimport type { SerializedComponentLibraryRevision } from './serialization'\nimport { COMPONENT_LIBRARY_SCHEMA_VERSION } from './types'\nimport type { LibrarySummary, StoredLibraryLatestManifest } from './types'\n\nconst serializedNodeShapeSchema = v.looseObject({\n id: v.string(),\n type: v.string(),\n parentId: v.nullable(v.string()),\n childIds: v.array(v.string()),\n // Nodes carry their file source, which is null for nodes that never came from a file.\n source: v.looseObject({ id: v.nullable(v.string()) })\n})\n\nconst serializedVariableShapeSchema = v.looseObject({\n id: v.string(),\n collectionId: v.string(),\n valuesByMode: v.record(v.string(), v.unknown())\n})\n\nconst serializedCollectionShapeSchema = v.looseObject({\n id: v.string(),\n modes: v.array(v.unknown()),\n variableIds: v.array(v.string())\n})\n\n/**\n * Library revisions come from shared catalogs. Nodes, variables and collections are checked for\n * the fields deserialization and integrity validation dereference; the remaining fields pass\n * through, since a full SceneNode schema would duplicate the Scene Graph types.\n */\nconst serializedNodeSchema = v.custom<SceneNode>((value) => v.is(serializedNodeShapeSchema, value))\nconst serializedVariableSchema = v.custom<Variable>((value) =>\n v.is(serializedVariableShapeSchema, value)\n)\nconst serializedCollectionSchema = v.custom<VariableCollection>((value) =>\n v.is(serializedCollectionShapeSchema, value)\n)\n\nconst serializedBytesSchema = v.instance(Uint8Array)\n\nconst libraryAssetDescriptorSchema = v.object({\n key: v.string(),\n type: v.picklist(['COMPONENT', 'COMPONENT_SET']),\n name: v.string(),\n description: v.string(),\n sourceNodeId: v.string(),\n contentHash: v.string(),\n thumbnail: v.optional(serializedBytesSchema)\n})\n\nexport const serializedLibraryRevisionSchema = v.object({\n manifest: v.object({\n schemaVersion: v.literal(COMPONENT_LIBRARY_SCHEMA_VERSION),\n libraryId: v.string(),\n name: v.string(),\n revisionId: v.string(),\n previousRevisionId: v.nullable(v.string()),\n publishedAt: v.string(),\n description: v.string(),\n assets: v.array(libraryAssetDescriptorSchema)\n }),\n graph: v.object({\n rootId: v.string(),\n nodes: v.array(v.tuple([v.string(), serializedNodeSchema])),\n images: v.array(v.tuple([v.string(), serializedBytesSchema])),\n variables: v.array(v.tuple([v.string(), serializedVariableSchema])),\n variableCollections: v.array(v.tuple([v.string(), serializedCollectionSchema])),\n activeMode: v.array(v.tuple([v.string(), v.string()])),\n documentColorSpace: v.picklist(['srgb', 'display-p3'])\n })\n}) satisfies v.GenericSchema<unknown, SerializedComponentLibraryRevision>\n\n/** A revision as a catalog reads it back from JSON, decoded from `encodeStoredLibraryRevision`. */\nexport const storedLibraryRevisionSchema = v.pipe(\n v.unknown(),\n v.transform(decodeStoredLibraryValue),\n serializedLibraryRevisionSchema\n)\n\nexport const librarySummarySchema = v.object({\n libraryId: v.string(),\n name: v.string(),\n latestRevisionId: v.string(),\n publishedAt: v.string(),\n assetCount: v.pipe(v.number(), v.safeInteger(), v.minValue(0))\n}) satisfies v.GenericSchema<unknown, LibrarySummary>\n\nexport const storedLibraryLatestManifestSchema = v.object({\n schemaVersion: v.literal(COMPONENT_LIBRARY_SCHEMA_VERSION),\n summary: librarySummarySchema\n}) satisfies v.GenericSchema<unknown, StoredLibraryLatestManifest>\n"],"mappings":";;;;AASA,MAAM,4BAA4B,EAAE,YAAY;CAC9C,IAAI,EAAE,OAAO;CACb,MAAM,EAAE,OAAO;CACf,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CAC/B,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;CAE5B,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,gCAAgC,EAAE,YAAY;CAClD,IAAI,EAAE,OAAO;CACb,cAAc,EAAE,OAAO;CACvB,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;AAChD,CAAC;AAED,MAAM,kCAAkC,EAAE,YAAY;CACpD,IAAI,EAAE,OAAO;CACb,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;CAC1B,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC;AACjC,CAAC;;;;;;AAOD,MAAM,uBAAuB,EAAE,QAAmB,UAAU,EAAE,GAAG,2BAA2B,KAAK,CAAC;AAClG,MAAM,2BAA2B,EAAE,QAAkB,UACnD,EAAE,GAAG,+BAA+B,KAAK,CAC3C;AACA,MAAM,6BAA6B,EAAE,QAA4B,UAC/D,EAAE,GAAG,iCAAiC,KAAK,CAC7C;AAEA,MAAM,wBAAwB,EAAE,SAAS,UAAU;AAEnD,MAAM,+BAA+B,EAAE,OAAO;CAC5C,KAAK,EAAE,OAAO;CACd,MAAM,EAAE,SAAS,CAAC,aAAa,eAAe,CAAC;CAC/C,MAAM,EAAE,OAAO;CACf,aAAa,EAAE,OAAO;CACtB,cAAc,EAAE,OAAO;CACvB,aAAa,EAAE,OAAO;CACtB,WAAW,EAAE,SAAS,qBAAqB;AAC7C,CAAC;AAED,MAAa,kCAAkC,EAAE,OAAO;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|
|
1
|
-
{"version":3,"file":"snapshot.d.ts","names":[],"sources":["../../src/library/snapshot.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","names":[],"sources":["../../src/library/snapshot.ts"],"mappings":";;;iBA2EgB,uBACd,QAAQ,YACR,0BACC;iBA8Fa,qBACd,OAAO,YACP,MAAM,WACN,kBAAe;iBAkCK,uBACpB,UAAU,0BACT,QAAQ"}
|
package/dist/library/snapshot.js
CHANGED
|
@@ -26,6 +26,14 @@ function assetKey(node) {
|
|
|
26
26
|
assertLibraryAssetKey(key);
|
|
27
27
|
return key;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The asset a reference to a component publishes as. A variant is part of its set's asset, never an
|
|
31
|
+
* asset of its own, so an instance of a variant depends on the set, as a Figma library records it.
|
|
32
|
+
*/
|
|
33
|
+
function referencedAssetKey(graph, node) {
|
|
34
|
+
const parent = node.parentId ? graph.getNode(node.parentId) : void 0;
|
|
35
|
+
return assetKey(parent?.type === "COMPONENT_SET" && !existingAssetKey(node) ? parent : node);
|
|
36
|
+
}
|
|
29
37
|
function collectNodeClosure(graph, rootIds) {
|
|
30
38
|
const ids = /* @__PURE__ */ new Set();
|
|
31
39
|
const pending = [...rootIds];
|
|
@@ -61,7 +69,7 @@ function extractLibrarySnapshot(source, assetNodeIds) {
|
|
|
61
69
|
const closureRoots = [...closure].map((id) => source.getNode(id)).filter((node) => Boolean(node && (!node.parentId || !closure.has(node.parentId))));
|
|
62
70
|
for (const root of closureRoots) addSnapshotNode(source, snapshot, root.id, page.id, mappedIds);
|
|
63
71
|
for (const [sourceId, targetId] of mappedIds) if (sourceId === targetId) throw new Error("Snapshot IDs must be remapped");
|
|
64
|
-
remapCopiedReferences(snapshot, mappedIds);
|
|
72
|
+
remapCopiedReferences(snapshot, mappedIds, { followTextLinks: true });
|
|
65
73
|
for (const imageHash of new Set([...closure].flatMap((id) => {
|
|
66
74
|
const node = source.getNode(id);
|
|
67
75
|
return node ? node.fills.flatMap((paint) => paint.type === "IMAGE" && paint.imageHash ? [paint.imageHash] : []) : [];
|
|
@@ -109,7 +117,7 @@ function normalizedLibraryField(key, value) {
|
|
|
109
117
|
function canonicalLibraryNode(graph, node, dependencyStack = /* @__PURE__ */ new Set()) {
|
|
110
118
|
const visualFields = Object.fromEntries(Object.entries(node).filter(([key]) => !VOLATILE_NODE_FIELDS.has(key) && key !== "componentId" && key !== "instanceIndex" && key !== "name" && key !== "symbolDescription").map(([key, value]) => [key, libraryField(node, key, value)]));
|
|
111
119
|
const component = node.componentId ? graph.getNode(node.componentId) : void 0;
|
|
112
|
-
const dependencyKey = component?.type === "COMPONENT" || component?.type === "COMPONENT_SET" ?
|
|
120
|
+
const dependencyKey = component?.type === "COMPONENT" || component?.type === "COMPONENT_SET" ? referencedAssetKey(graph, component) : null;
|
|
113
121
|
const dependency = component && dependencyKey && !dependencyStack.has(component.id) ? canonicalLibraryNode(graph, component, /* @__PURE__ */ new Set([...dependencyStack, component.id])) : null;
|
|
114
122
|
return {
|
|
115
123
|
...visualFields,
|