@pairdraw/core 0.18.0 → 0.19.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/effects.d.ts +5 -11
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +25 -30
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/labels/hit-test.d.ts +5 -0
- package/dist/canvas/labels/hit-test.d.ts.map +1 -1
- package/dist/canvas/labels/hit-test.js +1 -1
- package/dist/canvas/labels/hit-test.js.map +1 -1
- package/dist/canvas/labels/paragraph-cache.d.ts.map +1 -1
- package/dist/canvas/labels/paragraph-cache.js +3 -2
- package/dist/canvas/labels/paragraph-cache.js.map +1 -1
- package/dist/canvas/labels/selection.js +3 -2
- package/dist/canvas/labels/selection.js.map +1 -1
- package/dist/canvas/labels/style.d.ts +1 -1
- package/dist/canvas/node-edit-overlay.js +2 -2
- package/dist/canvas/node-edit-overlay.js.map +1 -1
- package/dist/canvas/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/selection.d.ts +1 -2
- package/dist/canvas/overlays/selection.d.ts.map +1 -1
- package/dist/canvas/overlays/selection.js +4 -37
- package/dist/canvas/overlays/selection.js.map +1 -1
- package/dist/canvas/region-hatch.js +3 -2
- package/dist/canvas/region-hatch.js.map +1 -1
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +36 -18
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/font-waiters.d.ts +9 -0
- package/dist/canvas/renderer/font-waiters.d.ts.map +1 -0
- package/dist/canvas/renderer/font-waiters.js +26 -0
- package/dist/canvas/renderer/font-waiters.js.map +1 -0
- package/dist/canvas/renderer/fonts.d.ts +4 -2
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +23 -9
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -9
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +4 -5
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -4
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/paints.d.ts.map +1 -1
- package/dist/canvas/renderer/paints.js +0 -6
- package/dist/canvas/renderer/paints.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +20 -2
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/retained-backing.js +4 -4
- package/dist/canvas/renderer/retained-backing.js.map +1 -1
- package/dist/canvas/renderer/state.js +1 -1
- package/dist/canvas/renderer/state.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +2 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +8 -0
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.js +7 -5
- package/dist/canvas/renderer/visual-bounds.js.map +1 -1
- package/dist/canvas/renderer.d.ts +22 -7
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +46 -11
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/rulers.d.ts +8 -1
- package/dist/canvas/rulers.d.ts.map +1 -1
- package/dist/canvas/rulers.js +30 -5
- package/dist/canvas/rulers.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +30 -18
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/shape.js +1 -1
- package/dist/canvas/shadows/shape.js.map +1 -1
- package/dist/canvas/shadows/silhouette.d.ts.map +1 -1
- package/dist/canvas/shadows/silhouette.js +4 -2
- package/dist/canvas/shadows/silhouette.js.map +1 -1
- package/dist/canvas/shadows.d.ts.map +1 -1
- package/dist/canvas/shadows.js +3 -2
- package/dist/canvas/shadows.js.map +1 -1
- package/dist/canvas/text/derived.d.ts +1 -2
- package/dist/canvas/text/derived.d.ts.map +1 -1
- package/dist/canvas/text/derived.js +1 -7
- package/dist/canvas/text/derived.js.map +1 -1
- package/dist/canvas/text/emoji/index.js +1 -1
- package/dist/canvas/text/emoji/raster.d.ts.map +1 -1
- package/dist/canvas/text/emoji/raster.js +14 -10
- package/dist/canvas/text/emoji/raster.js.map +1 -1
- package/dist/canvas/text/font-families.d.ts.map +1 -1
- package/dist/canvas/text/font-families.js +5 -2
- package/dist/canvas/text/font-families.js.map +1 -1
- package/dist/canvas/text/index.d.ts +1 -3
- package/dist/canvas/text/index.d.ts.map +1 -1
- package/dist/canvas/text/index.js +1 -8
- package/dist/canvas/text/index.js.map +1 -1
- package/dist/canvas/text/layout/build.d.ts.map +1 -1
- package/dist/canvas/text/layout/build.js +25 -9
- package/dist/canvas/text/layout/build.js.map +1 -1
- package/dist/canvas/text/layout/index.d.ts.map +1 -1
- package/dist/canvas/text/layout/index.js +8 -4
- package/dist/canvas/text/layout/index.js.map +1 -1
- package/dist/canvas/text/layout/lines.js +5 -3
- package/dist/canvas/text/layout/lines.js.map +1 -1
- package/dist/canvas/text/paragraph/index.d.ts +5 -0
- package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/index.js +16 -7
- package/dist/canvas/text/paragraph/index.js.map +1 -1
- package/dist/canvas/text/paragraph/inputs.d.ts +1 -1
- package/dist/canvas/text/paragraph/inputs.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/inputs.js +9 -2
- package/dist/canvas/text/paragraph/inputs.js.map +1 -1
- package/dist/canvas/text/placed.js +1 -1
- package/dist/canvas/text/shape.d.ts +4 -3
- package/dist/canvas/text/shape.d.ts.map +1 -1
- package/dist/canvas/text/shape.js +9 -22
- package/dist/canvas/text/shape.js.map +1 -1
- package/dist/constants.d.ts +6 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -2
- package/dist/constants.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +1 -0
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/frames.d.ts +4 -3
- package/dist/editor/bridges/frames.d.ts.map +1 -1
- package/dist/editor/bridges/frames.js +6 -4
- package/dist/editor/bridges/frames.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -0
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/bridges/structure.js +1 -0
- package/dist/editor/bridges/structure.js.map +1 -1
- package/dist/editor/clipboard/detach.js +2 -2
- package/dist/editor/clipboard/detach.js.map +1 -1
- package/dist/editor/clipboard/paste/properties.js +1 -1
- package/dist/editor/clipboard/paste/target.js +2 -2
- package/dist/editor/clipboard/paste/target.js.map +1 -1
- package/dist/editor/clipboard/snapshot.d.ts +3 -0
- package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
- package/dist/editor/clipboard/snapshot.js +2 -0
- package/dist/editor/clipboard/snapshot.js.map +1 -1
- package/dist/editor/clipboard/variables.d.ts.map +1 -1
- package/dist/editor/clipboard/variables.js +14 -1
- package/dist/editor/clipboard/variables.js.map +1 -1
- package/dist/editor/clipboard.d.ts +1 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +122 -16
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/component-sync.d.ts +10 -1
- package/dist/editor/component-sync.d.ts.map +1 -1
- package/dist/editor/component-sync.js +25 -8
- package/dist/editor/component-sync.js.map +1 -1
- package/dist/editor/components/authoring/text-edit.d.ts.map +1 -1
- package/dist/editor/components/authoring/text-edit.js +11 -2
- package/dist/editor/components/authoring/text-edit.js.map +1 -1
- package/dist/editor/components/authoring/visibility-edit.d.ts.map +1 -1
- package/dist/editor/components/authoring/visibility-edit.js +7 -3
- package/dist/editor/components/authoring/visibility-edit.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +37 -7
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/properties.d.ts.map +1 -1
- package/dist/editor/components/properties.js +3 -0
- package/dist/editor/components/properties.js.map +1 -1
- package/dist/editor/components/slots/authoring.js +2 -1
- package/dist/editor/components/slots/authoring.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/create.d.ts +17 -3
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +43 -6
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/guides.d.ts.map +1 -1
- package/dist/editor/guides.js +20 -13
- package/dist/editor/guides.js.map +1 -1
- package/dist/editor/history/document-change.d.ts +19 -3
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +94 -8
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +56 -12
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/position.js +1 -4
- package/dist/editor/history/position.js.map +1 -1
- package/dist/editor/history/sources.d.ts +14 -0
- package/dist/editor/history/sources.d.ts.map +1 -0
- package/dist/editor/history/sources.js +24 -0
- package/dist/editor/history/sources.js.map +1 -0
- package/dist/editor/index.d.ts +2 -2
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +16 -1
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/node-preview.d.ts.map +1 -1
- package/dist/editor/node-preview.js +26 -7
- package/dist/editor/node-preview.js.map +1 -1
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +33 -10
- package/dist/editor/nodes.js.map +1 -1
- package/dist/editor/nudge.d.ts.map +1 -1
- package/dist/editor/nudge.js +12 -2
- package/dist/editor/nudge.js.map +1 -1
- package/dist/editor/pages.d.ts +2 -1
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +94 -15
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +0 -5
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +3 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/selection/hit-test.d.ts +2 -1
- package/dist/editor/selection/hit-test.d.ts.map +1 -1
- package/dist/editor/selection/hit-test.js +29 -4
- package/dist/editor/selection/hit-test.js.map +1 -1
- package/dist/editor/selection.d.ts +2 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/pen.js +6 -2
- package/dist/editor/shapes/pen.js.map +1 -1
- package/dist/editor/shapes.d.ts.map +1 -1
- package/dist/editor/shapes.js +2 -1
- package/dist/editor/shapes.js.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.d.ts.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.js +12 -0
- package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
- package/dist/editor/structure/boolean.js +1 -1
- package/dist/editor/structure/group/bounds.d.ts +4 -2
- package/dist/editor/structure/group/bounds.d.ts.map +1 -1
- package/dist/editor/structure/group/bounds.js +17 -4
- package/dist/editor/structure/group/bounds.js.map +1 -1
- package/dist/editor/structure/rename.d.ts +2 -3
- package/dist/editor/structure/rename.d.ts.map +1 -1
- package/dist/editor/structure/rename.js +2 -5
- package/dist/editor/structure/rename.js.map +1 -1
- package/dist/editor/structure/reorder.d.ts.map +1 -1
- package/dist/editor/structure/reorder.js +20 -9
- package/dist/editor/structure/reorder.js.map +1 -1
- package/dist/editor/structure/state.js +1 -1
- package/dist/editor/structure.d.ts +1 -0
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/structure.js +76 -20
- package/dist/editor/structure.js.map +1 -1
- package/dist/editor/text/hyperlink.d.ts.map +1 -1
- package/dist/editor/text/hyperlink.js +1 -1
- package/dist/editor/text/hyperlink.js.map +1 -1
- package/dist/editor/text/name.d.ts +13 -5
- package/dist/editor/text/name.d.ts.map +1 -1
- package/dist/editor/text/name.js +47 -17
- package/dist/editor/text/name.js.map +1 -1
- package/dist/editor/text/pending-layout.d.ts +2 -1
- package/dist/editor/text/pending-layout.d.ts.map +1 -1
- package/dist/editor/text/pending-layout.js +33 -6
- package/dist/editor/text/pending-layout.js.map +1 -1
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +16 -4
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/text.d.ts +5 -0
- package/dist/editor/text.d.ts.map +1 -1
- package/dist/editor/text.js +70 -3
- package/dist/editor/text.js.map +1 -1
- package/dist/editor/types.d.ts +18 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/undo.d.ts.map +1 -1
- package/dist/editor/undo.js +14 -2
- package/dist/editor/undo.js.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +21 -2
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/editor/variables.d.ts +1 -1
- package/dist/editor/variables.d.ts.map +1 -1
- package/dist/editor/variables.js +7 -8
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/viewport.d.ts +11 -2
- package/dist/editor/viewport.d.ts.map +1 -1
- package/dist/editor/viewport.js +61 -21
- package/dist/editor/viewport.js.map +1 -1
- package/dist/editor/views/actions.d.ts.map +1 -1
- package/dist/editor/views/actions.js +13 -5
- package/dist/editor/views/actions.js.map +1 -1
- package/dist/editor/views/present.d.ts +6 -4
- package/dist/editor/views/present.d.ts.map +1 -1
- package/dist/editor/views/present.js +12 -10
- package/dist/editor/views/present.js.map +1 -1
- package/dist/editor/views/types.d.ts +11 -5
- package/dist/editor/views/types.d.ts.map +1 -1
- package/dist/figma-api/accessor-utils.d.ts.map +1 -1
- package/dist/figma-api/accessor-utils.js +4 -1
- package/dist/figma-api/accessor-utils.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +41 -21
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/layout.d.ts.map +1 -1
- package/dist/figma-api/accessors/layout.js +37 -7
- package/dist/figma-api/accessors/layout.js.map +1 -1
- package/dist/figma-api/accessors/reactions.d.ts +11 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -0
- package/dist/figma-api/accessors/reactions.js +30 -0
- package/dist/figma-api/accessors/reactions.js.map +1 -0
- package/dist/figma-api/accessors/strokes.d.ts.map +1 -1
- package/dist/figma-api/accessors/strokes.js +12 -4
- package/dist/figma-api/accessors/strokes.js.map +1 -1
- package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
- package/dist/figma-api/accessors/text/index.js +3 -1
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +1 -1
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.d.ts +6 -5
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +20 -17
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +2 -1
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/finite.d.ts +27 -0
- package/dist/figma-api/finite.d.ts.map +1 -0
- package/dist/figma-api/finite.js +69 -0
- package/dist/figma-api/finite.js.map +1 -0
- package/dist/figma-api/fonts/list.d.ts +13 -0
- package/dist/figma-api/fonts/list.d.ts.map +1 -0
- package/dist/figma-api/fonts/list.js +25 -0
- package/dist/figma-api/fonts/list.js.map +1 -0
- package/dist/figma-api/index.d.ts +21 -3
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +58 -13
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +6 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +2 -2
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/pending-layout.d.ts +12 -2
- package/dist/figma-api/pending-layout.d.ts.map +1 -1
- package/dist/figma-api/pending-layout.js +41 -1
- package/dist/figma-api/pending-layout.js.map +1 -1
- package/dist/figma-api/pending-sync.d.ts +19 -0
- package/dist/figma-api/pending-sync.d.ts.map +1 -0
- package/dist/figma-api/pending-sync.js +52 -0
- package/dist/figma-api/pending-sync.js.map +1 -0
- package/dist/figma-api/proxy.d.ts +15 -2
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +23 -3
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +104 -0
- package/dist/figma-api/reactions.d.ts.map +1 -0
- package/dist/figma-api/reactions.js +157 -0
- package/dist/figma-api/reactions.js.map +1 -0
- package/dist/figma-api/render-bounds.d.ts.map +1 -1
- package/dist/figma-api/render-bounds.js +4 -4
- package/dist/figma-api/render-bounds.js.map +1 -1
- package/dist/figma-api/serialization.js +2 -2
- package/dist/figma-api/serialization.js.map +1 -1
- package/dist/figma-api/slots.d.ts +7 -1
- package/dist/figma-api/slots.d.ts.map +1 -1
- package/dist/figma-api/slots.js +12 -4
- package/dist/figma-api/slots.js.map +1 -1
- package/dist/figma-api/strokes.d.ts +5 -2
- package/dist/figma-api/strokes.d.ts.map +1 -1
- package/dist/figma-api/strokes.js +12 -19
- package/dist/figma-api/strokes.js.map +1 -1
- package/dist/figma-api/text/bindings.js +1 -1
- package/dist/figma-api/text/index.d.ts +2 -3
- package/dist/figma-api/text/index.d.ts.map +1 -1
- package/dist/figma-api/text/index.js +2 -12
- package/dist/figma-api/text/index.js.map +1 -1
- package/dist/figma-api/variables/bindings.js +1 -1
- package/dist/figma-api/variables/variable.d.ts.map +1 -1
- package/dist/figma-api/variables/variable.js +2 -2
- package/dist/figma-api/variables/variable.js.map +1 -1
- package/dist/geometry/figma.d.ts +6 -1
- package/dist/geometry/figma.d.ts.map +1 -1
- package/dist/geometry/figma.js +8 -1
- package/dist/geometry/figma.js.map +1 -1
- package/dist/geometry/index.d.ts +2 -2
- package/dist/geometry/index.js +2 -2
- package/dist/icons/api.d.ts +3 -2
- package/dist/icons/api.d.ts.map +1 -1
- package/dist/icons/api.js +12 -12
- package/dist/icons/api.js.map +1 -1
- package/dist/icons/provider.d.ts +4 -3
- package/dist/icons/provider.d.ts.map +1 -1
- package/dist/icons/provider.js +6 -13
- package/dist/icons/provider.js.map +1 -1
- package/dist/icons/schema.d.ts +33 -1
- package/dist/icons/schema.d.ts.map +1 -1
- package/dist/icons/schema.js +30 -1
- package/dist/icons/schema.js.map +1 -1
- package/dist/icons/svg/presentation.d.ts +8 -1
- package/dist/icons/svg/presentation.d.ts.map +1 -1
- package/dist/icons/svg/presentation.js +21 -3
- package/dist/icons/svg/presentation.js.map +1 -1
- package/dist/icons/svg/text.js +1 -1
- package/dist/icons/svg/text.js.map +1 -1
- package/dist/icons/svg.d.ts +8 -3
- package/dist/icons/svg.d.ts.map +1 -1
- package/dist/icons/svg.js +15 -13
- package/dist/icons/svg.js.map +1 -1
- package/dist/icons/types.d.ts +1 -19
- package/dist/icons/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/io/formats/design-tokens/css/read.js +1 -1
- package/dist/io/formats/design-tokens/decode.js +1 -1
- package/dist/io/formats/design-tokens/plan/index.js +4 -2
- package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts +9 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.js +23 -3
- package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts +9 -1
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js +41 -4
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/types.d.ts +5 -0
- package/dist/io/formats/design-tokens/types.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/types.js +1 -0
- package/dist/io/formats/design-tokens/types.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +8 -4
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
- package/dist/io/formats/fig/export/variables.js +2 -2
- package/dist/io/formats/fig/export/variables.js.map +1 -1
- package/dist/io/formats/fig/index.d.ts +2 -2
- package/dist/io/formats/fig/index.js +2 -2
- package/dist/io/formats/fig/read.d.ts +9 -2
- package/dist/io/formats/fig/read.d.ts.map +1 -1
- package/dist/io/formats/fig/read.js +44 -20
- package/dist/io/formats/fig/read.js.map +1 -1
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +2 -6
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +65 -1
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/prepare.js +1 -1
- package/dist/io/formats/pen/fonts.d.ts +14 -0
- package/dist/io/formats/pen/fonts.d.ts.map +1 -0
- package/dist/io/formats/pen/fonts.js +39 -0
- package/dist/io/formats/pen/fonts.js.map +1 -0
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +25 -6
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/raster/headless.d.ts +2 -2
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +24 -13
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/index.js +2 -2
- package/dist/io/formats/raster/render.d.ts +7 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +40 -6
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +28 -24
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/paths.d.ts +8 -2
- package/dist/io/formats/svg/paths.d.ts.map +1 -1
- package/dist/io/formats/svg/paths.js +11 -3
- package/dist/io/formats/svg/paths.js.map +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +2 -5
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/export.d.ts.map +1 -1
- package/dist/io/formats/svg/text/export.js +19 -1
- package/dist/io/formats/svg/text/export.js.map +1 -1
- package/dist/io/formats/svg/text/import.d.ts.map +1 -1
- package/dist/io/formats/svg/text/import.js +2 -1
- package/dist/io/formats/svg/text/import.js.map +1 -1
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +5 -2
- package/dist/io/subgraph.js.map +1 -1
- package/dist/kiwi/fig/population/client.d.ts.map +1 -1
- package/dist/kiwi/fig/population/client.js +63 -45
- package/dist/kiwi/fig/population/client.js.map +1 -1
- package/dist/kiwi/fig/population/delta.d.ts +34 -3
- package/dist/kiwi/fig/population/delta.d.ts.map +1 -1
- package/dist/kiwi/fig/population/delta.js +99 -16
- package/dist/kiwi/fig/population/delta.js.map +1 -1
- package/dist/kiwi/fig/population/edits.d.ts +51 -0
- package/dist/kiwi/fig/population/edits.d.ts.map +1 -0
- package/dist/kiwi/fig/population/edits.js +169 -0
- package/dist/kiwi/fig/population/edits.js.map +1 -0
- package/dist/kiwi/fig/session/archive/access.d.ts +3 -0
- package/dist/kiwi/fig/session/archive/access.d.ts.map +1 -1
- package/dist/kiwi/fig/session/archive/access.js +8 -1
- package/dist/kiwi/fig/session/archive/access.js.map +1 -1
- package/dist/kiwi/fig/session/archive/changes.d.ts +2 -1
- package/dist/kiwi/fig/session/archive/changes.d.ts.map +1 -1
- package/dist/kiwi/fig/session/archive/changes.js +12 -5
- package/dist/kiwi/fig/session/archive/changes.js.map +1 -1
- package/dist/kiwi/fig/session/document-state.d.ts +7 -1
- package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
- package/dist/kiwi/fig/session/document-state.js +16 -2
- package/dist/kiwi/fig/session/document-state.js.map +1 -1
- package/dist/kiwi/fig/session/protocol.d.ts +31 -3
- package/dist/kiwi/fig/session/protocol.d.ts.map +1 -1
- package/dist/kiwi/fig/session/worker.js +33 -8
- package/dist/kiwi/fig/session/worker.js.map +1 -1
- package/dist/layout/apply.d.ts +6 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +39 -14
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/arrange/boxes.d.ts.map +1 -1
- package/dist/layout/arrange/boxes.js +31 -0
- package/dist/layout/arrange/boxes.js.map +1 -1
- package/dist/layout/flow-edges.d.ts +26 -0
- package/dist/layout/flow-edges.d.ts.map +1 -0
- package/dist/layout/flow-edges.js +105 -0
- package/dist/layout/flow-edges.js.map +1 -0
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +9 -5
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/text-auto-resize.d.ts.map +1 -1
- package/dist/layout/text-auto-resize.js +9 -4
- package/dist/layout/text-auto-resize.js.map +1 -1
- package/dist/layout/text-measurement.d.ts +15 -1
- package/dist/layout/text-measurement.d.ts.map +1 -1
- package/dist/layout/text-measurement.js +40 -4
- package/dist/layout/text-measurement.js.map +1 -1
- package/dist/layout/variables.d.ts +1 -1
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +35 -35
- package/dist/layout.js.map +1 -1
- package/dist/library/asset-keys.d.ts +3 -2
- package/dist/library/asset-keys.d.ts.map +1 -1
- package/dist/library/asset-keys.js +4 -3
- package/dist/library/asset-keys.js.map +1 -1
- package/dist/library/copied-references.d.ts +8 -3
- package/dist/library/copied-references.d.ts.map +1 -1
- package/dist/library/copied-references.js +15 -5
- package/dist/library/copied-references.js.map +1 -1
- package/dist/library/materialize.js +1 -1
- package/dist/library/materialize.js.map +1 -1
- package/dist/library/schema.js.map +1 -1
- package/dist/library/snapshot.d.ts.map +1 -1
- package/dist/library/snapshot.js +10 -2
- package/dist/library/snapshot.js.map +1 -1
- package/dist/pairdraw-api/variables.d.ts.map +1 -1
- package/dist/pairdraw-api/variables.js +0 -2
- package/dist/pairdraw-api/variables.js.map +1 -1
- package/dist/profiler/hud-controller.d.ts +4 -3
- package/dist/profiler/hud-controller.d.ts.map +1 -1
- package/dist/profiler/hud-controller.js +7 -5
- package/dist/profiler/hud-controller.js.map +1 -1
- package/dist/profiler/hud-renderer.d.ts +5 -2
- package/dist/profiler/hud-renderer.d.ts.map +1 -1
- package/dist/profiler/hud-renderer.js +8 -5
- package/dist/profiler/hud-renderer.js.map +1 -1
- package/dist/profiler/render-profiler.d.ts +3 -2
- package/dist/profiler/render-profiler.d.ts.map +1 -1
- package/dist/profiler/render-profiler.js +3 -2
- package/dist/profiler/render-profiler.js.map +1 -1
- package/dist/text/character-style.d.ts +11 -1
- package/dist/text/character-style.d.ts.map +1 -1
- package/dist/text/character-style.js +27 -5
- package/dist/text/character-style.js.map +1 -1
- package/dist/text/coverage.d.ts.map +1 -1
- package/dist/text/coverage.js +15 -16
- package/dist/text/coverage.js.map +1 -1
- package/dist/text/editor.d.ts.map +1 -1
- package/dist/text/editor.js +3 -8
- package/dist/text/editor.js.map +1 -1
- package/dist/text/fallbacks.d.ts +19 -2
- package/dist/text/fallbacks.d.ts.map +1 -1
- package/dist/text/fallbacks.js +63 -12
- package/dist/text/fallbacks.js.map +1 -1
- package/dist/text/font/catalog.d.ts +4 -0
- package/dist/text/font/catalog.d.ts.map +1 -1
- package/dist/text/font/catalog.js +8 -0
- package/dist/text/font/catalog.js.map +1 -1
- package/dist/text/font/collection.d.ts +13 -0
- package/dist/text/font/collection.d.ts.map +1 -0
- package/dist/text/font/collection.js +51 -0
- package/dist/text/font/collection.js.map +1 -0
- package/dist/text/font/faces.d.ts +2 -1
- package/dist/text/font/faces.d.ts.map +1 -1
- package/dist/text/font/faces.js +9 -5
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/font/glyphs.d.ts +14 -3
- package/dist/text/font/glyphs.d.ts.map +1 -1
- package/dist/text/font/glyphs.js +22 -5
- package/dist/text/font/glyphs.js.map +1 -1
- package/dist/text/font/local.js +2 -2
- package/dist/text/font/local.js.map +1 -1
- package/dist/text/font/manager.d.ts +36 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +139 -19
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/font/style.d.ts +7 -2
- package/dist/text/font/style.d.ts.map +1 -1
- package/dist/text/font/style.js +31 -3
- package/dist/text/font/style.js.map +1 -1
- package/dist/text/index.d.ts +5 -4
- package/dist/text/index.js +5 -4
- package/dist/text/outlines.d.ts.map +1 -1
- package/dist/text/outlines.js +70 -70
- package/dist/text/outlines.js.map +1 -1
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +7 -1
- package/dist/text/prepare.js.map +1 -1
- package/dist/text/style-runs.d.ts +14 -2
- package/dist/text/style-runs.d.ts.map +1 -1
- package/dist/text/style-runs.js +22 -14
- package/dist/text/style-runs.js.map +1 -1
- package/dist/tools/analyze/overlaps/helpers.d.ts.map +1 -1
- package/dist/tools/analyze/overlaps/helpers.js +9 -1
- package/dist/tools/analyze/overlaps/helpers.js.map +1 -1
- package/dist/tools/analyze/overlaps/index.d.ts.map +1 -1
- package/dist/tools/analyze/overlaps/index.js +27 -5
- package/dist/tools/analyze/overlaps/index.js.map +1 -1
- package/dist/tools/codegen/component-map.js +3 -3
- package/dist/tools/codegen/component-map.js.map +1 -1
- package/dist/tools/create/basic.d.ts.map +1 -1
- package/dist/tools/create/basic.js +5 -4
- package/dist/tools/create/basic.js.map +1 -1
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +4 -2
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +3 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.d.ts.map +1 -1
- package/dist/tools/create/mermaid.js +2 -0
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.d.ts.map +1 -1
- package/dist/tools/create/render.js +2 -0
- package/dist/tools/create/render.js.map +1 -1
- package/dist/tools/create/script.js +3 -1
- package/dist/tools/create/script.js.map +1 -1
- package/dist/tools/create/svg.d.ts.map +1 -1
- package/dist/tools/create/svg.js +4 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.d.ts.map +1 -1
- package/dist/tools/create/vector.js +4 -4
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/image-ai/apply.js +1 -1
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -0
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/modify/matching.js +1 -1
- package/dist/tools/modify/reactions.d.ts +6 -0
- package/dist/tools/modify/reactions.d.ts.map +1 -0
- package/dist/tools/modify/reactions.js +35 -0
- package/dist/tools/modify/reactions.js.map +1 -0
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/read/components.js +20 -22
- package/dist/tools/read/components.js.map +1 -1
- package/dist/tools/read/fonts.js +1 -1
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.d.ts.map +1 -1
- package/dist/tools/read/libraries.js +2 -0
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js +38 -16
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/read/pages.d.ts.map +1 -1
- package/dist/tools/read/pages.js +4 -3
- package/dist/tools/read/pages.js.map +1 -1
- package/dist/tools/read/query.js +1 -0
- package/dist/tools/read/query.js.map +1 -1
- package/dist/tools/read/reactions.d.ts +6 -0
- package/dist/tools/read/reactions.d.ts.map +1 -0
- package/dist/tools/read/reactions.js +24 -0
- package/dist/tools/read/reactions.js.map +1 -0
- package/dist/tools/read/space.js +1 -1
- package/dist/tools/read.d.ts +2 -1
- package/dist/tools/read.js +2 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +4 -0
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +6 -0
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +53 -9
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/stock-photo/apply.js +8 -9
- package/dist/tools/stock-photo/apply.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +85 -90
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/vector/fill-geometry.d.ts +4 -1
- package/dist/vector/fill-geometry.d.ts.map +1 -1
- package/dist/vector/fill-geometry.js +8 -5
- package/dist/vector/fill-geometry.js.map +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/path-helpers.d.ts +1 -1
- package/dist/vector/path-helpers.d.ts.map +1 -1
- package/dist/vector/path-helpers.js +24 -7
- package/dist/vector/path-helpers.js.map +1 -1
- package/dist/vector/placement.js +1 -1
- package/dist/vector/placement.js.map +1 -1
- package/dist/vector/vectorize/preprocess.js +1 -1
- package/dist/vector/vectorize/preprocess.js.map +1 -1
- package/package.json +10 -10
- package/src/canvas/effects.ts +29 -33
- package/src/canvas/labels/hit-test.ts +6 -2
- package/src/canvas/labels/paragraph-cache.ts +2 -1
- package/src/canvas/labels/selection.ts +3 -3
- package/src/canvas/node-edit-overlay.ts +3 -2
- package/src/canvas/overlays/index.ts +0 -1
- package/src/canvas/overlays/selection.ts +4 -52
- package/src/canvas/region-hatch.ts +7 -2
- package/src/canvas/renderer/colors.ts +41 -26
- package/src/canvas/renderer/font-waiters.ts +25 -0
- package/src/canvas/renderer/fonts.ts +40 -17
- package/src/canvas/renderer/lifecycle.ts +8 -10
- package/src/canvas/renderer/methods.ts +9 -13
- package/src/canvas/renderer/paints.ts +0 -10
- package/src/canvas/renderer/pipeline.ts +29 -3
- package/src/canvas/renderer/retained-backing.ts +4 -4
- package/src/canvas/renderer/state.ts +1 -1
- package/src/canvas/renderer/tiles/controller.ts +8 -0
- package/src/canvas/renderer/tiles/surface-pool.ts +1 -1
- package/src/canvas/renderer/visual-bounds.ts +7 -6
- package/src/canvas/renderer.ts +39 -11
- package/src/canvas/rulers.ts +55 -26
- package/src/canvas/scene.ts +37 -16
- package/src/canvas/shadows/shape.ts +1 -1
- package/src/canvas/shadows/silhouette.ts +4 -2
- package/src/canvas/shadows.ts +4 -2
- package/src/canvas/text/derived.ts +0 -9
- package/src/canvas/text/emoji/raster.ts +14 -10
- package/src/canvas/text/font-families.ts +6 -0
- package/src/canvas/text/index.ts +0 -8
- package/src/canvas/text/layout/build.ts +35 -18
- package/src/canvas/text/layout/index.ts +15 -6
- package/src/canvas/text/layout/lines.ts +10 -4
- package/src/canvas/text/paragraph/index.ts +17 -8
- package/src/canvas/text/paragraph/inputs.ts +4 -2
- package/src/canvas/text/shape.ts +20 -31
- package/src/constants.ts +6 -1
- package/src/editor/bridges/clipboard.ts +1 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/bridges/frames.ts +6 -4
- package/src/editor/bridges/structure.ts +1 -0
- package/src/editor/clipboard/detach.ts +3 -3
- package/src/editor/clipboard/paste/target.ts +2 -2
- package/src/editor/clipboard/snapshot.ts +7 -0
- package/src/editor/clipboard/variables.ts +20 -0
- package/src/editor/clipboard.ts +133 -14
- package/src/editor/component-sync.ts +28 -7
- package/src/editor/components/authoring/text-edit.ts +15 -2
- package/src/editor/components/authoring/visibility-edit.ts +11 -3
- package/src/editor/components/instances.ts +61 -11
- package/src/editor/components/properties.ts +10 -0
- package/src/editor/components/slots/authoring.ts +4 -1
- package/src/editor/create.ts +58 -8
- package/src/editor/guides.ts +27 -12
- package/src/editor/history/document-change.ts +115 -7
- package/src/editor/history/edit.ts +62 -14
- package/src/editor/history/position.ts +1 -4
- package/src/editor/history/sources.ts +25 -0
- package/src/editor/index.ts +3 -1
- package/src/editor/layout-mode.ts +20 -1
- package/src/editor/node-preview.ts +44 -8
- package/src/editor/nodes.ts +52 -12
- package/src/editor/nudge.ts +16 -2
- package/src/editor/pages.ts +100 -17
- package/src/editor/play/states.ts +0 -7
- package/src/editor/read-only/actions.ts +4 -0
- package/src/editor/selection/hit-test.ts +37 -4
- package/src/editor/shapes/pen.ts +6 -3
- package/src/editor/shapes.ts +2 -1
- package/src/editor/structure/auto-layout-wrap.ts +26 -0
- package/src/editor/structure/group/bounds.ts +22 -4
- package/src/editor/structure/rename.ts +2 -6
- package/src/editor/structure/reorder.ts +26 -8
- package/src/editor/structure.ts +88 -24
- package/src/editor/text/hyperlink.ts +2 -1
- package/src/editor/text/name.ts +51 -15
- package/src/editor/text/pending-layout.ts +42 -4
- package/src/editor/text/selection-style.ts +17 -3
- package/src/editor/text.ts +86 -4
- package/src/editor/types.ts +19 -0
- package/src/editor/undo.ts +21 -2
- package/src/editor/variable-bindings.ts +22 -2
- package/src/editor/variables.ts +10 -6
- package/src/editor/viewport.ts +55 -21
- package/src/editor/views/actions.ts +17 -7
- package/src/editor/views/present.ts +20 -11
- package/src/editor/views/types.ts +11 -5
- package/src/figma-api/accessor-utils.ts +4 -1
- package/src/figma-api/accessors/basic.ts +54 -18
- package/src/figma-api/accessors/layout.ts +46 -7
- package/src/figma-api/accessors/reactions.ts +29 -0
- package/src/figma-api/accessors/strokes.ts +28 -8
- package/src/figma-api/accessors/text/index.ts +4 -0
- package/src/figma-api/accessors/vector.ts +3 -1
- package/src/figma-api/accessors/visual.ts +25 -28
- package/src/figma-api/components.ts +9 -7
- package/src/figma-api/finite.ts +102 -0
- package/src/figma-api/fonts/list.ts +24 -0
- package/src/figma-api/index.ts +82 -12
- package/src/figma-api/overrides.ts +1 -1
- package/src/figma-api/pending-layout.ts +50 -1
- package/src/figma-api/pending-sync.ts +61 -0
- package/src/figma-api/proxy.ts +35 -2
- package/src/figma-api/reactions.ts +212 -0
- package/src/figma-api/render-bounds.ts +13 -4
- package/src/figma-api/serialization.ts +2 -2
- package/src/figma-api/slots.ts +12 -3
- package/src/figma-api/strokes.ts +16 -12
- package/src/figma-api/text/index.ts +9 -15
- package/src/figma-api/variables/variable.ts +3 -2
- package/src/geometry/figma.ts +9 -0
- package/src/geometry/index.ts +1 -0
- package/src/global.d.ts +6 -0
- package/src/icons/api.ts +27 -16
- package/src/icons/provider.ts +9 -20
- package/src/icons/schema.ts +31 -0
- package/src/icons/svg/presentation.ts +27 -3
- package/src/icons/svg/text.ts +1 -1
- package/src/icons/svg.ts +21 -19
- package/src/icons/types.ts +0 -14
- package/src/io/formats/design-tokens/plan/index.ts +7 -1
- package/src/io/formats/design-tokens/plan/styles.ts +40 -4
- package/src/io/formats/design-tokens/styles.ts +60 -3
- package/src/io/formats/design-tokens/types.ts +3 -0
- package/src/io/formats/fig/export/setup.ts +16 -14
- package/src/io/formats/fig/export/variables.ts +7 -8
- package/src/io/formats/fig/index.ts +1 -0
- package/src/io/formats/fig/read.ts +66 -23
- package/src/io/formats/html/index.ts +2 -6
- package/src/io/formats/pdf/dom.ts +96 -3
- package/src/io/formats/pen/fonts.ts +45 -0
- package/src/io/formats/pen/index.ts +30 -6
- package/src/io/formats/raster/headless.ts +31 -12
- package/src/io/formats/raster/index.ts +3 -0
- package/src/io/formats/raster/render.ts +62 -6
- package/src/io/formats/svg/export.ts +24 -25
- package/src/io/formats/svg/paths.ts +11 -2
- package/src/io/formats/svg/strokes.ts +8 -2
- package/src/io/formats/svg/text/export.ts +23 -0
- package/src/io/formats/svg/text/import.ts +2 -1
- package/src/io/subgraph.ts +3 -1
- package/src/kiwi/fig/population/client.ts +77 -43
- package/src/kiwi/fig/population/delta.ts +141 -18
- package/src/kiwi/fig/population/edits.ts +235 -0
- package/src/kiwi/fig/session/archive/access.ts +15 -0
- package/src/kiwi/fig/session/archive/changes.ts +27 -6
- package/src/kiwi/fig/session/document-state.ts +23 -1
- package/src/kiwi/fig/session/protocol.ts +26 -1
- package/src/kiwi/fig/session/worker.ts +38 -11
- package/src/layout/apply.ts +52 -10
- package/src/layout/arrange/boxes.ts +36 -0
- package/src/layout/flow-edges.ts +139 -0
- package/src/layout/grid.ts +14 -4
- package/src/layout/text-auto-resize.ts +13 -4
- package/src/layout/text-measurement.ts +46 -3
- package/src/layout.ts +60 -66
- package/src/library/asset-keys.ts +4 -3
- package/src/library/copied-references.ts +29 -5
- package/src/library/materialize.ts +1 -1
- package/src/library/schema.ts +1 -1
- package/src/library/snapshot.ts +11 -2
- package/src/pairdraw-api/variables.ts +1 -3
- package/src/profiler/hud-controller.ts +8 -6
- package/src/profiler/hud-renderer.ts +9 -6
- package/src/profiler/render-profiler.ts +4 -3
- package/src/text/character-style.ts +29 -9
- package/src/text/coverage.ts +17 -18
- package/src/text/editor.ts +3 -8
- package/src/text/fallbacks.ts +82 -15
- package/src/text/font/catalog.ts +10 -0
- package/src/text/font/collection.ts +60 -0
- package/src/text/font/faces.ts +9 -5
- package/src/text/font/glyphs.ts +29 -4
- package/src/text/font/local.ts +2 -2
- package/src/text/font/manager.ts +170 -32
- package/src/text/font/style.ts +52 -3
- package/src/text/index.ts +1 -0
- package/src/text/outlines.ts +105 -89
- package/src/text/prepare.ts +17 -0
- package/src/text/style-runs.ts +43 -16
- package/src/tools/analyze/overlaps/helpers.ts +18 -1
- package/src/tools/analyze/overlaps/index.ts +37 -6
- package/src/tools/codegen/component-map.ts +3 -3
- package/src/tools/create/basic.ts +6 -4
- package/src/tools/create/html.ts +3 -1
- package/src/tools/create/icons.ts +3 -1
- package/src/tools/create/mermaid.ts +2 -0
- package/src/tools/create/render.ts +2 -0
- package/src/tools/create/script.ts +5 -1
- package/src/tools/create/svg.ts +4 -1
- package/src/tools/create/vector.ts +4 -4
- package/src/tools/image-ai/generate.ts +3 -0
- package/src/tools/modify/reactions.ts +40 -0
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/components.ts +28 -25
- package/src/tools/read/fonts.ts +1 -1
- package/src/tools/read/libraries.ts +3 -0
- package/src/tools/read/nodes.ts +47 -17
- package/src/tools/read/pages.ts +7 -4
- package/src/tools/read/query.ts +2 -0
- package/src/tools/read/reactions.ts +21 -0
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/extended.ts +4 -0
- package/src/tools/schema.ts +68 -12
- package/src/tools/stock-photo/apply.ts +17 -5
- package/src/tools/structure/batch.ts +82 -101
- package/src/vector/fill-geometry.ts +11 -5
- package/src/vector/index.ts +1 -1
- package/src/vector/path-helpers.ts +34 -8
- package/src/vector/placement.ts +1 -1
- package/src/vector/vectorize/preprocess.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","names":[],"sources":["../../../../src/io/formats/svg/paths.ts"],"mappings":";;;;iBAkBgB,MAAM,WAAW;iBASjB,sBAAsB,MAAM,YAAY;;iBAuDxC,mBAAmB,MAAM;iBAIzB,kBAAkB,MAAM;cAM3B,kBAAS;
|
|
1
|
+
{"version":3,"file":"paths.d.ts","names":[],"sources":["../../../../src/io/formats/svg/paths.ts"],"mappings":";;;;iBAkBgB,MAAM,WAAW;iBASjB,sBAAsB,MAAM,YAAY;;iBAuDxC,mBAAmB,MAAM;iBAIzB,kBAAkB,MAAM;cAM3B,kBAAS;cACT,yBAAgB;KAExB,kBAAkB,KACrB;iBAWc,gBAAgB,MAAM;iBAgCtB,QAAQ,MAAM,KAAK;;iBA6CnB,YAAY,kBAAkB;;;;;iBA8B9B,eAAe,MAAM,kBAAkB,KAAK;;KAKhD,cAAc,kBACxB,KACE;;;;;iBAUY,gBAAgB,MAAM;;iBAmBtB,yBACd,MAAM,KAAK;;;;;iBAeG,yBACd,MAAM,KAAK"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { traceSmoothRect } from "../../../canvas/paths/smooth-corners.js";
|
|
2
|
-
import { nodeHasRadius } from "../../../canvas/shapes.js";
|
|
2
|
+
import { nodeHasRadius, nodeHasSmoothCorners } from "../../../canvas/shapes.js";
|
|
3
3
|
import { polygonVertices } from "@pairdraw/scene-graph/geometry";
|
|
4
4
|
import { compact } from "es-toolkit/array";
|
|
5
5
|
import { outlineSVGPath, polygonOutline } from "@pairdraw/scene-graph/polygon";
|
|
@@ -73,6 +73,7 @@ function makePolygonPoints(node) {
|
|
|
73
73
|
return polygonVertices(node).map((point) => `${round(point.x)},${round(point.y)}`).join(" ");
|
|
74
74
|
}
|
|
75
75
|
const hasRadius = nodeHasRadius;
|
|
76
|
+
const hasSmoothCorners = nodeHasSmoothCorners;
|
|
76
77
|
function roundedRectPath(node) {
|
|
77
78
|
const w = node.width;
|
|
78
79
|
const h = node.height;
|
|
@@ -159,6 +160,13 @@ function smoothRectPath(node) {
|
|
|
159
160
|
};
|
|
160
161
|
return traceSmoothRect(sink, node, box) ? parts.join("") : roundedRectPath(node);
|
|
161
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* A box layer's outline as path data: its rectangle with its corner radii, smoothed as the canvas
|
|
165
|
+
* draws them. Frames, rectangles, and other box layers share it for fills, strokes, and clips.
|
|
166
|
+
*/
|
|
167
|
+
function boxOutlinePath(node) {
|
|
168
|
+
return node.cornerSmoothing > 0 ? smoothRectPath(node) : roundedRectPath(node);
|
|
169
|
+
}
|
|
162
170
|
const FULL_ELLIPSE = {
|
|
163
171
|
startingAngle: 0,
|
|
164
172
|
endingAngle: Math.PI * 2,
|
|
@@ -170,7 +178,7 @@ const FULL_ELLIPSE = {
|
|
|
170
178
|
*/
|
|
171
179
|
function nodeOutlinePath(node) {
|
|
172
180
|
switch (node.type) {
|
|
173
|
-
case "RECTANGLE": return
|
|
181
|
+
case "RECTANGLE": return boxOutlinePath(node);
|
|
174
182
|
case "ELLIPSE": return arcPath({
|
|
175
183
|
...node,
|
|
176
184
|
arcData: node.arcData ?? FULL_ELLIPSE
|
|
@@ -196,6 +204,6 @@ function shapeWithTextDetailsPath(node) {
|
|
|
196
204
|
return details.length > 0 ? outlineSVGPath(details, (value) => round(value)) : null;
|
|
197
205
|
}
|
|
198
206
|
//#endregion
|
|
199
|
-
export { arcPath, geometryBlobToSVGPath, hasRadius, makePolygonPoints, nodeOutlinePath, round, roundedPolygonPath, roundedRectPath, shapeWithTextDetailsPath, shapeWithTextOutlinePath, svgPathSink };
|
|
207
|
+
export { arcPath, boxOutlinePath, geometryBlobToSVGPath, hasRadius, hasSmoothCorners, makePolygonPoints, nodeOutlinePath, round, roundedPolygonPath, roundedRectPath, shapeWithTextDetailsPath, shapeWithTextOutlinePath, svgPathSink };
|
|
200
208
|
|
|
201
209
|
//# sourceMappingURL=paths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","names":[],"sources":["../../../../src/io/formats/svg/paths.ts"],"sourcesContent":["import { compact } from 'es-toolkit/array'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { polygonVertices } from '@pairdraw/scene-graph/geometry'\nimport { outlineSVGPath, polygonOutline } from '@pairdraw/scene-graph/polygon'\nimport { shapeWithTextGeometry } from '@pairdraw/scene-graph/shape-with-text'\nimport { vectorNetworkToSVGPaths } from '@pairdraw/scene-graph/vector-network'\n\nimport { traceSmoothRect, type SmoothCornerSink } from '#core/canvas/paths/smooth-corners'\nimport { nodeHasRadius } from '#core/canvas/shapes'\nimport type { PathSink } from '#core/vector/path-helpers'\n\nconst CMD_CLOSE = 0\nconst CMD_MOVE_TO = 1\nconst CMD_LINE_TO = 2\nconst CMD_QUAD_TO = 3\nconst CMD_CUBIC_TO = 4\n\nexport function round(n: number, decimals = 2): number {\n const factor = 10 ** decimals\n return Math.round(n * factor) / factor\n}\n\nfunction coordinate(value: number, decimals: number | null): number {\n return decimals === null ? value : round(value, decimals)\n}\n\nexport function geometryBlobToSVGPath(blob: Uint8Array, decimals: number | null = 2): string {\n if (blob.length === 0) return ''\n const dv = new DataView(blob.buffer, blob.byteOffset, blob.byteLength)\n let o = 0\n const parts: string[] = []\n\n while (o < blob.length) {\n const cmd = blob[o++]\n switch (cmd) {\n case CMD_CLOSE:\n parts.push('Z')\n break\n case CMD_MOVE_TO: {\n const x = coordinate(dv.getFloat32(o, true), decimals)\n const y = coordinate(dv.getFloat32(o + 4, true), decimals)\n o += 8\n parts.push(`M${x} ${y}`)\n break\n }\n case CMD_LINE_TO: {\n const x = coordinate(dv.getFloat32(o, true), decimals)\n const y = coordinate(dv.getFloat32(o + 4, true), decimals)\n o += 8\n parts.push(`L${x} ${y}`)\n break\n }\n case CMD_QUAD_TO: {\n const x1 = coordinate(dv.getFloat32(o, true), decimals)\n const y1 = coordinate(dv.getFloat32(o + 4, true), decimals)\n const x = coordinate(dv.getFloat32(o + 8, true), decimals)\n const y = coordinate(dv.getFloat32(o + 12, true), decimals)\n o += 16\n parts.push(`Q${x1} ${y1} ${x} ${y}`)\n break\n }\n case CMD_CUBIC_TO: {\n const x1 = coordinate(dv.getFloat32(o, true), decimals)\n const y1 = coordinate(dv.getFloat32(o + 4, true), decimals)\n const x2 = coordinate(dv.getFloat32(o + 8, true), decimals)\n const y2 = coordinate(dv.getFloat32(o + 12, true), decimals)\n const x = coordinate(dv.getFloat32(o + 16, true), decimals)\n const y = coordinate(dv.getFloat32(o + 20, true), decimals)\n o += 24\n parts.push(`C${x1} ${y1} ${x2} ${y2} ${x} ${y}`)\n break\n }\n default:\n return parts.join('')\n }\n }\n\n return parts.join('')\n}\n\n/** The outline of a polygon or star whose corners are rounded, as path data. */\nexport function roundedPolygonPath(node: SceneNode): string {\n return outlineSVGPath(polygonOutline(node), (value) => round(value))\n}\n\nexport function makePolygonPoints(node: SceneNode): string {\n return polygonVertices(node)\n .map((point) => `${round(point.x)},${round(point.y)}`)\n .join(' ')\n}\n\nexport const hasRadius = nodeHasRadius\n\ntype RectOutlineNode = Pick<\n SceneNode,\n | 'width'\n | 'height'\n | 'cornerRadius'\n | 'independentCorners'\n | 'topLeftRadius'\n | 'topRightRadius'\n | 'bottomRightRadius'\n | 'bottomLeftRadius'\n>\n\nexport function roundedRectPath(node: RectOutlineNode): string {\n const w = node.width\n const h = node.height\n let tl: number, tr: number, br: number, bl: number\n if (node.independentCorners) {\n tl = node.topLeftRadius\n tr = node.topRightRadius\n br = node.bottomRightRadius\n bl = node.bottomLeftRadius\n } else {\n tl = tr = br = bl = node.cornerRadius\n }\n\n tl = Math.min(tl, w / 2, h / 2)\n tr = Math.min(tr, w / 2, h / 2)\n br = Math.min(br, w / 2, h / 2)\n bl = Math.min(bl, w / 2, h / 2)\n\n return compact([\n `M${round(tl)} 0`,\n `L${round(w - tr)} 0`,\n tr > 0 ? `A${round(tr)} ${round(tr)} 0 0 1 ${round(w)} ${round(tr)}` : '',\n `L${round(w)} ${round(h - br)}`,\n br > 0 ? `A${round(br)} ${round(br)} 0 0 1 ${round(w - br)} ${round(h)}` : '',\n `L${round(bl)} ${round(h)}`,\n bl > 0 ? `A${round(bl)} ${round(bl)} 0 0 1 0 ${round(h - bl)}` : '',\n `L0 ${round(tl)}`,\n tl > 0 ? `A${round(tl)} ${round(tl)} 0 0 1 ${round(tl)} 0` : '',\n 'Z'\n ]).join('')\n}\n\nexport function arcPath(node: Pick<SceneNode, 'width' | 'height' | 'arcData'>): string {\n if (!node.arcData) return ''\n const { startingAngle, endingAngle, innerRadius } = node.arcData\n const cx = node.width / 2\n const cy = node.height / 2\n const rx = node.width / 2\n const ry = node.height / 2\n\n const fullCircle = Math.abs(endingAngle - startingAngle) >= Math.PI * 2 - 0.001\n const ring = (rx: number, ry: number, sweep: 0 | 1) =>\n `M${round(cx - rx)} ${round(cy)}A${round(rx)} ${round(ry)} 0 1 ${sweep} ${round(cx + rx)} ${round(cy)}A${round(rx)} ${round(ry)} 0 1 ${sweep} ${round(cx - rx)} ${round(cy)}Z`\n // A whole ring has no ends to join: it is its outer edge and, for a donut, its hole, wound\n // the other way so the default nonzero fill leaves the hole empty.\n if (fullCircle) {\n const outer = ring(rx, ry, 1)\n return innerRadius > 0 ? outer + ring(rx * innerRadius, ry * innerRadius, 0) : outer\n }\n\n const x1 = round(cx + rx * Math.cos(startingAngle))\n const y1 = round(cy + ry * Math.sin(startingAngle))\n const x2 = round(cx + rx * Math.cos(endingAngle))\n const y2 = round(cy + ry * Math.sin(endingAngle))\n const largeArc = Math.abs(endingAngle - startingAngle) > Math.PI ? 1 : 0\n const sweep = endingAngle > startingAngle ? 1 : 0\n\n const parts = [`M${x1} ${y1}`, `A${round(rx)} ${round(ry)} 0 ${largeArc} ${sweep} ${x2} ${y2}`]\n\n if (innerRadius > 0) {\n const irx = rx * innerRadius\n const iry = ry * innerRadius\n const ix1 = round(cx + irx * Math.cos(endingAngle))\n const iy1 = round(cy + iry * Math.sin(endingAngle))\n const ix2 = round(cx + irx * Math.cos(startingAngle))\n const iy2 = round(cy + iry * Math.sin(startingAngle))\n parts.push(`L${ix1} ${iy1}`)\n parts.push(`A${round(irx)} ${round(iry)} 0 ${largeArc} ${sweep === 1 ? 0 : 1} ${ix2} ${iy2}`)\n parts.push('Z')\n } else {\n parts.push(`L${round(cx)} ${round(cy)}Z`)\n }\n\n return parts.join('')\n}\n\n/** Path commands written as SVG path data into `parts`, as the canvas would build a path. */\nexport function svgPathSink(parts: string[]): PathSink {\n const point = (x: number, y: number) => `${round(x)} ${round(y)}`\n return {\n moveTo: (x, y) => parts.push(`M${point(x, y)}`),\n lineTo: (x, y) => parts.push(`L${point(x, y)}`),\n cubicTo: (x1, y1, x2, y2, x, y) =>\n parts.push(`C${point(x1, y1)} ${point(x2, y2)} ${point(x, y)}`),\n close: () => parts.push('Z')\n }\n}\n\n/** A rectangle with smoothed corners as path data, traced as the canvas draws it. */\nfunction smoothRectPath(node: RectOutlineNode & Pick<SceneNode, 'cornerSmoothing'>): string {\n const parts: string[] = []\n const point = (x: number, y: number) => `${round(x)} ${round(y)}`\n const sink: SmoothCornerSink = {\n ...svgPathSink(parts),\n arcToRotated: (rx, ry, rotation, useSmallArc, isCCW, x, y) =>\n parts.push(\n `A${round(rx)} ${round(ry)} ${rotation} ${useSmallArc ? 0 : 1} ${isCCW ? 0 : 1} ${point(x, y)}`\n )\n }\n const box = { left: 0, top: 0, right: node.width, bottom: node.height }\n return traceSmoothRect(sink, node, box) ? parts.join('') : roundedRectPath(node)\n}\n\n/** What a layer's outline is drawn from. */\nexport type OutlineNode = RectOutlineNode &\n Pick<\n SceneNode,\n 'type' | 'arcData' | 'pointCount' | 'starInnerRadius' | 'cornerSmoothing' | 'vectorNetwork'\n >\n\nconst FULL_ELLIPSE = { startingAngle: 0, endingAngle: Math.PI * 2, innerRadius: 0 }\n\n/**\n * A shape layer's outline in its own box as path data: a rectangle with its corners, an ellipse\n * or arc, a line, a polygon or star, or a vector's network. Null for other layers.\n */\nexport function nodeOutlinePath(node: OutlineNode): string | null {\n switch (node.type) {\n case 'RECTANGLE':\n return node.cornerSmoothing > 0 ? smoothRectPath(node) : roundedRectPath(node)\n case 'ELLIPSE':\n return arcPath({ ...node, arcData: node.arcData ?? FULL_ELLIPSE })\n case 'LINE':\n return `M0 0L${round(node.width)} ${round(node.height)}`\n case 'POLYGON':\n case 'STAR':\n return outlineSVGPath(polygonOutline(node), (value) => round(value))\n case 'VECTOR':\n return node.vectorNetwork ? vectorNetworkToSVGPaths(node.vectorNetwork).join('') : null\n default:\n return null\n }\n}\n\n/** A FigJam shape's outline in its own box as path data, with its corner radius. */\nexport function shapeWithTextOutlinePath(\n node: Pick<SceneNode, 'shapeWithTextType' | 'width' | 'height' | 'cornerRadius'>\n): string {\n const { outline } = shapeWithTextGeometry(\n node.shapeWithTextType,\n node.width,\n node.height,\n node.cornerRadius\n )\n return outlineSVGPath(outline, (value) => round(value))\n}\n\n/**\n * A FigJam shape's stroke-only inner lines, such as a database's front rim, as path data; null for\n * a shape without any.\n */\nexport function shapeWithTextDetailsPath(\n node: Pick<SceneNode, 'shapeWithTextType' | 'width' | 'height'>\n): string | null {\n const { details } = shapeWithTextGeometry(node.shapeWithTextType, node.width, node.height)\n return details.length > 0 ? outlineSVGPath(details, (value) => round(value)) : null\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,eAAe;AAErB,SAAgB,MAAM,GAAW,WAAW,GAAW;CACrD,MAAM,SAAS,MAAM;CACrB,OAAO,KAAK,MAAM,IAAI,MAAM,IAAI;AAClC;AAEA,SAAS,WAAW,OAAe,UAAiC;CAClE,OAAO,aAAa,OAAO,QAAQ,MAAM,OAAO,QAAQ;AAC1D;AAEA,SAAgB,sBAAsB,MAAkB,WAA0B,GAAW;CAC3F,IAAI,KAAK,WAAW,GAAG,OAAO;CAC9B,MAAM,KAAK,IAAI,SAAS,KAAK,QAAQ,KAAK,YAAY,KAAK,UAAU;CACrE,IAAI,IAAI;CACR,MAAM,QAAkB,CAAC;CAEzB,OAAO,IAAI,KAAK,QAEd,QADY,KAAK,MACjB;EACE,KAAK;GACH,MAAM,KAAK,GAAG;GACd;EACF,KAAK,aAAa;GAChB,MAAM,IAAI,WAAW,GAAG,WAAW,GAAG,IAAI,GAAG,QAAQ;GACrD,MAAM,IAAI,WAAW,GAAG,WAAW,IAAI,GAAG,IAAI,GAAG,QAAQ;GACzD,KA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EAAE,YAAY,sBAClB,KAAK,mBACL,KAAK,OACL,KAAK,QACL,KAAK,YACP;CACA,OAAO,eAAe,UAAU,UAAU,MAAM,KAAK,CAAC;AACxD;;;;;AAMA,SAAgB,yBACd,MACe;CACf,MAAM,EAAE,YAAY,sBAAsB,KAAK,mBAAmB,KAAK,OAAO,KAAK,MAAM;CACzF,OAAO,QAAQ,SAAS,IAAI,eAAe,UAAU,UAAU,MAAM,KAAK,CAAC,IAAI;AACjF"}
|
|
1
|
+
{"version":3,"file":"paths.js","names":[],"sources":["../../../../src/io/formats/svg/paths.ts"],"sourcesContent":["import { compact } from 'es-toolkit/array'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { polygonVertices } from '@pairdraw/scene-graph/geometry'\nimport { outlineSVGPath, polygonOutline } from '@pairdraw/scene-graph/polygon'\nimport { shapeWithTextGeometry } from '@pairdraw/scene-graph/shape-with-text'\nimport { vectorNetworkToSVGPaths } from '@pairdraw/scene-graph/vector-network'\n\nimport { traceSmoothRect, type SmoothCornerSink } from '#core/canvas/paths/smooth-corners'\nimport { nodeHasRadius, nodeHasSmoothCorners } from '#core/canvas/shapes'\nimport type { PathSink } from '#core/vector/path-helpers'\n\nconst CMD_CLOSE = 0\nconst CMD_MOVE_TO = 1\nconst CMD_LINE_TO = 2\nconst CMD_QUAD_TO = 3\nconst CMD_CUBIC_TO = 4\n\nexport function round(n: number, decimals = 2): number {\n const factor = 10 ** decimals\n return Math.round(n * factor) / factor\n}\n\nfunction coordinate(value: number, decimals: number | null): number {\n return decimals === null ? value : round(value, decimals)\n}\n\nexport function geometryBlobToSVGPath(blob: Uint8Array, decimals: number | null = 2): string {\n if (blob.length === 0) return ''\n const dv = new DataView(blob.buffer, blob.byteOffset, blob.byteLength)\n let o = 0\n const parts: string[] = []\n\n while (o < blob.length) {\n const cmd = blob[o++]\n switch (cmd) {\n case CMD_CLOSE:\n parts.push('Z')\n break\n case CMD_MOVE_TO: {\n const x = coordinate(dv.getFloat32(o, true), decimals)\n const y = coordinate(dv.getFloat32(o + 4, true), decimals)\n o += 8\n parts.push(`M${x} ${y}`)\n break\n }\n case CMD_LINE_TO: {\n const x = coordinate(dv.getFloat32(o, true), decimals)\n const y = coordinate(dv.getFloat32(o + 4, true), decimals)\n o += 8\n parts.push(`L${x} ${y}`)\n break\n }\n case CMD_QUAD_TO: {\n const x1 = coordinate(dv.getFloat32(o, true), decimals)\n const y1 = coordinate(dv.getFloat32(o + 4, true), decimals)\n const x = coordinate(dv.getFloat32(o + 8, true), decimals)\n const y = coordinate(dv.getFloat32(o + 12, true), decimals)\n o += 16\n parts.push(`Q${x1} ${y1} ${x} ${y}`)\n break\n }\n case CMD_CUBIC_TO: {\n const x1 = coordinate(dv.getFloat32(o, true), decimals)\n const y1 = coordinate(dv.getFloat32(o + 4, true), decimals)\n const x2 = coordinate(dv.getFloat32(o + 8, true), decimals)\n const y2 = coordinate(dv.getFloat32(o + 12, true), decimals)\n const x = coordinate(dv.getFloat32(o + 16, true), decimals)\n const y = coordinate(dv.getFloat32(o + 20, true), decimals)\n o += 24\n parts.push(`C${x1} ${y1} ${x2} ${y2} ${x} ${y}`)\n break\n }\n default:\n return parts.join('')\n }\n }\n\n return parts.join('')\n}\n\n/** The outline of a polygon or star whose corners are rounded, as path data. */\nexport function roundedPolygonPath(node: SceneNode): string {\n return outlineSVGPath(polygonOutline(node), (value) => round(value))\n}\n\nexport function makePolygonPoints(node: SceneNode): string {\n return polygonVertices(node)\n .map((point) => `${round(point.x)},${round(point.y)}`)\n .join(' ')\n}\n\nexport const hasRadius = nodeHasRadius\nexport const hasSmoothCorners = nodeHasSmoothCorners\n\ntype RectOutlineNode = Pick<\n SceneNode,\n | 'width'\n | 'height'\n | 'cornerRadius'\n | 'independentCorners'\n | 'topLeftRadius'\n | 'topRightRadius'\n | 'bottomRightRadius'\n | 'bottomLeftRadius'\n>\n\nexport function roundedRectPath(node: RectOutlineNode): string {\n const w = node.width\n const h = node.height\n let tl: number, tr: number, br: number, bl: number\n if (node.independentCorners) {\n tl = node.topLeftRadius\n tr = node.topRightRadius\n br = node.bottomRightRadius\n bl = node.bottomLeftRadius\n } else {\n tl = tr = br = bl = node.cornerRadius\n }\n\n tl = Math.min(tl, w / 2, h / 2)\n tr = Math.min(tr, w / 2, h / 2)\n br = Math.min(br, w / 2, h / 2)\n bl = Math.min(bl, w / 2, h / 2)\n\n return compact([\n `M${round(tl)} 0`,\n `L${round(w - tr)} 0`,\n tr > 0 ? `A${round(tr)} ${round(tr)} 0 0 1 ${round(w)} ${round(tr)}` : '',\n `L${round(w)} ${round(h - br)}`,\n br > 0 ? `A${round(br)} ${round(br)} 0 0 1 ${round(w - br)} ${round(h)}` : '',\n `L${round(bl)} ${round(h)}`,\n bl > 0 ? `A${round(bl)} ${round(bl)} 0 0 1 0 ${round(h - bl)}` : '',\n `L0 ${round(tl)}`,\n tl > 0 ? `A${round(tl)} ${round(tl)} 0 0 1 ${round(tl)} 0` : '',\n 'Z'\n ]).join('')\n}\n\nexport function arcPath(node: Pick<SceneNode, 'width' | 'height' | 'arcData'>): string {\n if (!node.arcData) return ''\n const { startingAngle, endingAngle, innerRadius } = node.arcData\n const cx = node.width / 2\n const cy = node.height / 2\n const rx = node.width / 2\n const ry = node.height / 2\n\n const fullCircle = Math.abs(endingAngle - startingAngle) >= Math.PI * 2 - 0.001\n const ring = (rx: number, ry: number, sweep: 0 | 1) =>\n `M${round(cx - rx)} ${round(cy)}A${round(rx)} ${round(ry)} 0 1 ${sweep} ${round(cx + rx)} ${round(cy)}A${round(rx)} ${round(ry)} 0 1 ${sweep} ${round(cx - rx)} ${round(cy)}Z`\n // A whole ring has no ends to join: it is its outer edge and, for a donut, its hole, wound\n // the other way so the default nonzero fill leaves the hole empty.\n if (fullCircle) {\n const outer = ring(rx, ry, 1)\n return innerRadius > 0 ? outer + ring(rx * innerRadius, ry * innerRadius, 0) : outer\n }\n\n const x1 = round(cx + rx * Math.cos(startingAngle))\n const y1 = round(cy + ry * Math.sin(startingAngle))\n const x2 = round(cx + rx * Math.cos(endingAngle))\n const y2 = round(cy + ry * Math.sin(endingAngle))\n const largeArc = Math.abs(endingAngle - startingAngle) > Math.PI ? 1 : 0\n const sweep = endingAngle > startingAngle ? 1 : 0\n\n const parts = [`M${x1} ${y1}`, `A${round(rx)} ${round(ry)} 0 ${largeArc} ${sweep} ${x2} ${y2}`]\n\n if (innerRadius > 0) {\n const irx = rx * innerRadius\n const iry = ry * innerRadius\n const ix1 = round(cx + irx * Math.cos(endingAngle))\n const iy1 = round(cy + iry * Math.sin(endingAngle))\n const ix2 = round(cx + irx * Math.cos(startingAngle))\n const iy2 = round(cy + iry * Math.sin(startingAngle))\n parts.push(`L${ix1} ${iy1}`)\n parts.push(`A${round(irx)} ${round(iry)} 0 ${largeArc} ${sweep === 1 ? 0 : 1} ${ix2} ${iy2}`)\n parts.push('Z')\n } else {\n parts.push(`L${round(cx)} ${round(cy)}Z`)\n }\n\n return parts.join('')\n}\n\n/** Path commands written as SVG path data into `parts`, as the canvas would build a path. */\nexport function svgPathSink(parts: string[]): PathSink {\n const point = (x: number, y: number) => `${round(x)} ${round(y)}`\n return {\n moveTo: (x, y) => parts.push(`M${point(x, y)}`),\n lineTo: (x, y) => parts.push(`L${point(x, y)}`),\n cubicTo: (x1, y1, x2, y2, x, y) =>\n parts.push(`C${point(x1, y1)} ${point(x2, y2)} ${point(x, y)}`),\n close: () => parts.push('Z')\n }\n}\n\n/** A rectangle with smoothed corners as path data, traced as the canvas draws it. */\nfunction smoothRectPath(node: RectOutlineNode & Pick<SceneNode, 'cornerSmoothing'>): string {\n const parts: string[] = []\n const point = (x: number, y: number) => `${round(x)} ${round(y)}`\n const sink: SmoothCornerSink = {\n ...svgPathSink(parts),\n arcToRotated: (rx, ry, rotation, useSmallArc, isCCW, x, y) =>\n parts.push(\n `A${round(rx)} ${round(ry)} ${rotation} ${useSmallArc ? 0 : 1} ${isCCW ? 0 : 1} ${point(x, y)}`\n )\n }\n const box = { left: 0, top: 0, right: node.width, bottom: node.height }\n return traceSmoothRect(sink, node, box) ? parts.join('') : roundedRectPath(node)\n}\n\n/**\n * A box layer's outline as path data: its rectangle with its corner radii, smoothed as the canvas\n * draws them. Frames, rectangles, and other box layers share it for fills, strokes, and clips.\n */\nexport function boxOutlinePath(node: RectOutlineNode & Pick<SceneNode, 'cornerSmoothing'>): string {\n return node.cornerSmoothing > 0 ? smoothRectPath(node) : roundedRectPath(node)\n}\n\n/** What a layer's outline is drawn from. */\nexport type OutlineNode = RectOutlineNode &\n Pick<\n SceneNode,\n 'type' | 'arcData' | 'pointCount' | 'starInnerRadius' | 'cornerSmoothing' | 'vectorNetwork'\n >\n\nconst FULL_ELLIPSE = { startingAngle: 0, endingAngle: Math.PI * 2, innerRadius: 0 }\n\n/**\n * A shape layer's outline in its own box as path data: a rectangle with its corners, an ellipse\n * or arc, a line, a polygon or star, or a vector's network. Null for other layers.\n */\nexport function nodeOutlinePath(node: OutlineNode): string | null {\n switch (node.type) {\n case 'RECTANGLE':\n return boxOutlinePath(node)\n case 'ELLIPSE':\n return arcPath({ ...node, arcData: node.arcData ?? FULL_ELLIPSE })\n case 'LINE':\n return `M0 0L${round(node.width)} ${round(node.height)}`\n case 'POLYGON':\n case 'STAR':\n return outlineSVGPath(polygonOutline(node), (value) => round(value))\n case 'VECTOR':\n return node.vectorNetwork ? vectorNetworkToSVGPaths(node.vectorNetwork).join('') : null\n default:\n return null\n }\n}\n\n/** A FigJam shape's outline in its own box as path data, with its corner radius. */\nexport function shapeWithTextOutlinePath(\n node: Pick<SceneNode, 'shapeWithTextType' | 'width' | 'height' | 'cornerRadius'>\n): string {\n const { outline } = shapeWithTextGeometry(\n node.shapeWithTextType,\n node.width,\n node.height,\n node.cornerRadius\n )\n return outlineSVGPath(outline, (value) => round(value))\n}\n\n/**\n * A FigJam shape's stroke-only inner lines, such as a database's front rim, as path data; null for\n * a shape without any.\n */\nexport function shapeWithTextDetailsPath(\n node: Pick<SceneNode, 'shapeWithTextType' | 'width' | 'height'>\n): string | null {\n const { details } = shapeWithTextGeometry(node.shapeWithTextType, node.width, node.height)\n return details.length > 0 ? outlineSVGPath(details, (value) => round(value)) : null\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,eAAe;AAErB,SAAgB,MAAM,GAAW,WAAW,GAAW;CACrD,MAAM,SAAS,MAAM;CACrB,OAAO,KAAK,MAAM,IAAI,MAAM,IAAI;AAClC;AAEA,SAAS,WAAW,OAAe,UAAiC;CAClE,OAAO,aAAa,OAAO,QAAQ,MAAM,OAAO,QAAQ;AAC1D;AAEA,SAAgB,sBAAsB,MAAkB,WAA0B,GAAW;CAC3F,IAAI,KAAK,WAAW,GAAG,OAAO;CAC9B,MAAM,KAAK,IAAI,SAAS,KAAK,QAAQ,KAAK,YAAY,KAAK,UAAU;CACrE,IAAI,IAAI;CACR,MAAM,QAAkB,CAAC;CAEzB,OAAO,IAAI,KAAK,QAEd,QADY,KAAK,MACjB;EACE,KAAK;GACH,MAAM,KAAK,GAAG;GACd;EACF,KAAK,aAAa;GAChB,MAAM,IAAI,WAAW,GAAG,WAAW,GAAG,IAAI,GAAG,QAAQ;GACrD,MAAM,IAAI,WAAW,GAAG,WAAW,IAAI,GAAG,IAAI,GAAG,QAAQ;GACzD,KAAK;GACL,MAAM,KAAK,IAAI,EAAE,GAAG,GAAG;GACvB;EACF;EACA,KAAK,aAAa;GAChB,MAAM,IAAI,WAAW,GAAG,WAAW,GAAG,IAAI,GAAG,QAAQ;GACrD,MAAM,IAAI,WAAW,GAAG,WAAW,IAAI,GAAG,IAAI,GAAG,QAAQ;GACzD,KAAK;GACL,MAAM,KAAK,IAAI,EAAE,GAAG,GAAG;GACvB;EACF;EACA,KAAK,aAAa;GAChB,MAAM,KAAK,WAAW,GAAG,WAAW,GAAG,IAAI,GAAG,QAAQ;GACtD,MAAM,KAAK,WAAW,GAAG,WAAW,IAAI,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@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strokes.d.ts","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"strokes.d.ts","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"mappings":";;;;KAaK,QAAQ;;iBA0BG,cAAc,MAAM,WAAW,QAAQ,qBAAqB;;;;;iBAS5D,qBACd,MAAM,WACN,QAAQ,QACR,aAAa,OACb,KAAK,mBACJ;;;;;iBAkCa,4BACd,MAAM,WACN,aAAa,OACb,KAAK,mBACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { svg } from "./node.js";
|
|
2
|
-
import { nodeOutlinePath, round, shapeWithTextDetailsPath, shapeWithTextOutlinePath } from "./paths.js";
|
|
2
|
+
import { boxOutlinePath, nodeOutlinePath, round, shapeWithTextDetailsPath, shapeWithTextOutlinePath } from "./paths.js";
|
|
3
3
|
import { nextDefId } from "./defs.js";
|
|
4
4
|
//#region src/io/formats/svg/strokes.ts
|
|
5
5
|
/**
|
|
@@ -16,10 +16,7 @@ function closedOutlinePath(node) {
|
|
|
16
16
|
case "ELLIPSE": return node.arcData ? null : nodeOutlinePath(node);
|
|
17
17
|
case "POLYGON":
|
|
18
18
|
case "STAR": return nodeOutlinePath(node);
|
|
19
|
-
default: return
|
|
20
|
-
...node,
|
|
21
|
-
type: "RECTANGLE"
|
|
22
|
-
});
|
|
19
|
+
default: return boxOutlinePath(node);
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
22
|
/** The stroke an aligned stroke paints, when it is inside or outside a closed outline. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strokes.js","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"sourcesContent":["import type { SceneNode, Stroke } from '@pairdraw/scene-graph'\n\nimport type { SVGExportContext } from './defs'\nimport { nextDefId } from './defs'\nimport { svg, type SVGNode } from './node'\nimport {
|
|
1
|
+
{"version":3,"file":"strokes.js","names":[],"sources":["../../../../src/io/formats/svg/strokes.ts"],"sourcesContent":["import type { SceneNode, Stroke } from '@pairdraw/scene-graph'\n\nimport type { SVGExportContext } from './defs'\nimport { nextDefId } from './defs'\nimport { svg, type SVGNode } from './node'\nimport {\n boxOutlinePath,\n nodeOutlinePath,\n round,\n shapeWithTextDetailsPath,\n shapeWithTextOutlinePath\n} from './paths'\n\ntype Attrs = Record<string, string | number | undefined>\n\n/**\n * The closed outline an aligned stroke follows, as path data in the layer's box: a FigJam shape's,\n * an ellipse, polygon or star, or a box with its corners for any other layer. Null for lines,\n * arcs, and vectors, whose strokes the canvas centres on their paths.\n */\nfunction closedOutlinePath(node: SceneNode): string | null {\n switch (node.type) {\n case 'LINE':\n case 'VECTOR':\n case 'BOOLEAN_OPERATION':\n return null\n case 'SHAPE_WITH_TEXT':\n return shapeWithTextOutlinePath(node)\n case 'ELLIPSE':\n return node.arcData ? null : nodeOutlinePath(node)\n case 'POLYGON':\n case 'STAR':\n return nodeOutlinePath(node)\n default:\n return boxOutlinePath(node)\n }\n}\n\n/** The stroke an aligned stroke paints, when it is inside or outside a closed outline. */\nexport function alignedStroke(node: SceneNode, stroke: Stroke | undefined): Stroke | null {\n if (!stroke || stroke.align === 'CENTER') return null\n return closedOutlinePath(node) === null ? null : stroke\n}\n\n/**\n * A stroke inside or outside the layer's outline, as the canvas draws it: centred at twice its\n * weight and clipped to the outline, or to everything around it.\n */\nexport function alignedStrokeElement(\n node: SceneNode,\n stroke: Stroke,\n strokeAttrs: Attrs,\n ctx: SVGExportContext\n): SVGNode[] {\n const outline = closedOutlinePath(node)\n if (outline === null) return []\n const clipId = nextDefId(ctx, 'clip')\n if (stroke.align === 'INSIDE') {\n ctx.defs.push(svg('clipPath', { id: clipId }, svg('path', { d: outline })))\n } else {\n // A box wide enough for the stroke, its mitred tips included, with the outline cut out of it.\n // The doubled stroke mitres out to its weight times the miter limit.\n const margin = stroke.weight * Math.max(2, node.strokeMiterLimit)\n const left = round(-margin)\n const top = round(-margin)\n const right = round(node.width + margin)\n const bottom = round(node.height + margin)\n const around = `M${left} ${top}H${right}V${bottom}H${left}Z`\n ctx.defs.push(\n svg('clipPath', { id: clipId }, svg('path', { d: around + outline, 'clip-rule': 'evenodd' }))\n )\n }\n return [\n svg('path', {\n d: outline,\n fill: 'none',\n ...strokeAttrs,\n 'stroke-width': round(stroke.weight * 2),\n 'clip-path': `url(#${clipId})`\n })\n ]\n}\n\n/**\n * A FigJam shape's inner lines, such as a database's front rim, stroked as the canvas strokes\n * them: at the stroke's own weight whatever its alignment, ending where the outline does.\n */\nexport function shapeWithTextDetailElements(\n node: SceneNode,\n strokeAttrs: Attrs,\n ctx: SVGExportContext\n): SVGNode[] {\n const details = strokeAttrs.stroke ? shapeWithTextDetailsPath(node) : null\n if (!details) return []\n const clipId = nextDefId(ctx, 'clip')\n ctx.defs.push(svg('clipPath', { id: clipId }, svg('path', { d: shapeWithTextOutlinePath(node) })))\n return [svg('path', { d: details, fill: 'none', ...strokeAttrs, 'clip-path': `url(#${clipId})` })]\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAS,kBAAkB,MAAgC;CACzD,QAAQ,KAAK,MAAb;EACE,KAAK;EACL,KAAK;EACL,KAAK,qBACH,OAAO;EACT,KAAK,mBACH,OAAO,yBAAyB,IAAI;EACtC,KAAK,WACH,OAAO,KAAK,UAAU,OAAO,gBAAgB,IAAI;EACnD,KAAK;EACL,KAAK,QACH,OAAO,gBAAgB,IAAI;EAC7B,SACE,OAAO,eAAe,IAAI;CAC9B;AACF;;AAGA,SAAgB,cAAc,MAAiB,QAA2C;CACxF,IAAI,CAAC,UAAU,OAAO,UAAU,UAAU,OAAO;CACjD,OAAO,kBAAkB,IAAI,MAAM,OAAO,OAAO;AACnD;;;;;AAMA,SAAgB,qBACd,MACA,QACA,aACA,KACW;CACX,MAAM,UAAU,kBAAkB,IAAI;CACtC,IAAI,YAAY,MAAM,OAAO,CAAC;CAC9B,MAAM,SAAS,UAAU,KAAK,MAAM;CACpC,IAAI,OAAO,UAAU,UACnB,IAAI,KAAK,KAAK,IAAI,YAAY,EAAE,IAAI,OAAO,GAAG,IAAI,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;MACrE;EAGL,MAAM,SAAS,OAAO,SAAS,KAAK,IAAI,GAAG,KAAK,gBAAgB;EAChE,MAAM,OAAO,MAAM,CAAC,MAAM;EAI1B,MAAM,SAAS,IAAI,KAAK,GAHZ,MAAM,CAAC,MAGU,EAAE,GAFjB,MAAM,KAAK,QAAQ,MAEK,EAAE,GADzB,MAAM,KAAK,SAAS,MACa,EAAE,GAAG,KAAK;EAC1D,IAAI,KAAK,KACP,IAAI,YAAY,EAAE,IAAI,OAAO,GAAG,IAAI,QAAQ;GAAE,GAAG,SAAS;GAAS,aAAa;EAAU,CAAC,CAAC,CAC9F;CACF;CACA,OAAO,CACL,IAAI,QAAQ;EACV,GAAG;EACH,MAAM;EACN,GAAG;EACH,gBAAgB,MAAM,OAAO,SAAS,CAAC;EACvC,aAAa,QAAQ,OAAO;CAC9B,CAAC,CACH;AACF;;;;;AAMA,SAAgB,4BACd,MACA,aACA,KACW;CACX,MAAM,UAAU,YAAY,SAAS,yBAAyB,IAAI,IAAI;CACtE,IAAI,CAAC,SAAS,OAAO,CAAC;CACtB,MAAM,SAAS,UAAU,KAAK,MAAM;CACpC,IAAI,KAAK,KAAK,IAAI,YAAY,EAAE,IAAI,OAAO,GAAG,IAAI,QAAQ,EAAE,GAAG,yBAAyB,IAAI,EAAE,CAAC,CAAC,CAAC;CACjG,OAAO,CAAC,IAAI,QAAQ;EAAE,GAAG;EAAS,MAAM;EAAQ,GAAG;EAAa,aAAa,QAAQ,OAAO;CAAG,CAAC,CAAC;AACnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","names":[],"sources":["../../../../../src/io/formats/svg/text/export.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"export.d.ts","names":[],"sources":["../../../../../src/io/formats/svg/text/export.ts"],"mappings":";;;;iBAsMgB,eACd,MAAM,WACN,yBACA,KAAK,kBACL,uBACC"}
|
|
@@ -3,7 +3,7 @@ import { textFontFace } from "../../../../text/requirements/collect.js";
|
|
|
3
3
|
import { drawnFontVariations } from "../../../../canvas/text/font-families.js";
|
|
4
4
|
import { svg } from "../node.js";
|
|
5
5
|
import { round } from "../paths.js";
|
|
6
|
-
import { formatColor } from "../defs.js";
|
|
6
|
+
import { formatColor, formatSolidColor } from "../defs.js";
|
|
7
7
|
import { explicitNewlineLines, laidOutTextSpans, textStyleSpans } from "./lines.js";
|
|
8
8
|
import { textLengthPixels } from "@pairdraw/scene-graph/text";
|
|
9
9
|
import { parseFontStyle } from "@pairdraw/scene-graph/font-style";
|
|
@@ -63,6 +63,23 @@ function spanFontAttrs(node, style, fallback, fontAlias) {
|
|
|
63
63
|
return fallback ? { "font-family": fallback.family } : {};
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
+
* A text layer's stroke, painted on the glyphs themselves. The canvas strokes an outside stroke at
|
|
67
|
+
* twice its weight and clips it to the outside of the glyphs; live text cannot be clipped in SVG,
|
|
68
|
+
* so the same band is painted behind the fill at twice the weight, which hides the inner half. An
|
|
69
|
+
* inside or centred stroke keeps its own weight over the fill.
|
|
70
|
+
*/
|
|
71
|
+
function textStrokeAttrs(node, colorSpace) {
|
|
72
|
+
const stroke = node.strokes.find((candidate) => candidate.visible);
|
|
73
|
+
if (!stroke) return {};
|
|
74
|
+
const attrs = {
|
|
75
|
+
stroke: formatSolidColor(stroke.color, 1, colorSpace),
|
|
76
|
+
"stroke-width": round(stroke.weight * (stroke.align === "OUTSIDE" ? 2 : 1))
|
|
77
|
+
};
|
|
78
|
+
if (stroke.opacity < 1) attrs["stroke-opacity"] = round(stroke.opacity);
|
|
79
|
+
if (stroke.align === "OUTSIDE") attrs["paint-order"] = "stroke";
|
|
80
|
+
return attrs;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
66
83
|
* The face a run of `node` is drawn in, or the fallback face that draws its characters instead,
|
|
67
84
|
* with the size and axes its instance follows. A fallback is drawn at the axes the run's own font
|
|
68
85
|
* is drawn at, as the paragraph draws every font it falls back to.
|
|
@@ -136,6 +153,7 @@ function renderTextNode(node, fillAttr, ctx, fillOpacity) {
|
|
|
136
153
|
"text-anchor": laidOut ? void 0 : textAnchorForNode(node, direction),
|
|
137
154
|
"text-decoration": textDecoration,
|
|
138
155
|
"letter-spacing": letterSpacing ? round(letterSpacing) : void 0,
|
|
156
|
+
...textStrokeAttrs(node, colorSpace),
|
|
139
157
|
...fontAlias ? aliasedFontAttrs(fontRequest(node), fontAlias) : {}
|
|
140
158
|
};
|
|
141
159
|
const spanAttrs = (style, fallback) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","names":[],"sources":["../../../../../src/io/formats/svg/text/export.ts"],"sourcesContent":["import type { CharacterStyleOverride, SceneNode } from '@pairdraw/scene-graph'\nimport { parseFontStyle } from '@pairdraw/scene-graph/font-style'\nimport { textLengthPixels } from '@pairdraw/scene-graph/text'\nimport { resolveNodeTextDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { drawnFontVariations } from '#core/canvas/text/font-families'\nimport {\n formatColor,\n type SVGExportContext,\n type SVGFontAlias,\n type SVGFontRequest\n} from '#core/io/formats/svg/defs'\nimport { svg, type SVGNode } from '#core/io/formats/svg/node'\nimport { round } from '#core/io/formats/svg/paths'\nimport {\n explicitNewlineLines,\n laidOutTextSpans,\n textStyleSpans,\n type SpanAttrs,\n type SVGFallbackFace\n} from '#core/io/formats/svg/text/lines'\nimport { shownText } from '#core/text/case'\nimport { textFontFace } from '#core/text/requirements/collect'\n\nfunction styleOverrideToTspanAttrs(\n style: CharacterStyleOverride,\n colorSpace: 'srgb' | 'display-p3',\n parentFillOpacity: number | undefined,\n node: Pick<SceneNode, 'fontSize' | 'letterSpacing'>\n): Record<string, string | number | undefined> {\n const attrs: Record<string, string | number | undefined> = {}\n if (style.fontFamily) attrs['font-family'] = style.fontFamily\n if (style.fontSize) attrs['font-size'] = style.fontSize\n if (style.fontWeight) attrs['font-weight'] = style.fontWeight\n if (style.italic) attrs['font-style'] = 'italic'\n // A run's own spacing is written even at zero, or it would inherit the layer's. A percent the\n // run inherits follows its own font size, so a larger or smaller run writes it again.\n const inherited =\n style.fontSize !== undefined &&\n node.letterSpacing.unit === 'PERCENT' &&\n node.letterSpacing.value !== 0\n ? node.letterSpacing\n : undefined\n const spacing = style.letterSpacing ?? inherited\n if (spacing) {\n attrs['letter-spacing'] = round(textLengthPixels(spacing, style.fontSize ?? node.fontSize))\n }\n if (style.textDecoration === 'UNDERLINE') attrs['text-decoration'] = 'underline'\n if (style.textDecoration === 'STRIKETHROUGH') attrs['text-decoration'] = 'line-through'\n if (style.fills) {\n const visibleFill = style.fills.find((f) => f.visible && f.type === 'SOLID')\n if (visibleFill) {\n // Paragraphs and saved glyphs draw a run at color.a * opacity. Shapes paint opacity alone.\n const alpha = round(visibleFill.color.a * visibleFill.opacity)\n if (colorSpace === 'display-p3') {\n attrs.fill = formatColor({ ...visibleFill.color, a: 1 }, alpha, colorSpace)\n } else {\n attrs.fill = formatColor(visibleFill.color, 1, colorSpace)\n if (alpha < 1) attrs['fill-opacity'] = alpha\n }\n // `fill-opacity` inherits, so an opaque run has to cover a translucent parent.\n if (alpha >= 1 && parentFillOpacity !== undefined) attrs['fill-opacity'] = 1\n }\n }\n return attrs\n}\n\n/**\n * Font attributes naming a face's alias, such as the family a PDF embeds its file under, or else\n * the face itself, so text inside an aliased parent does not inherit the alias.\n */\nfunction aliasedFontAttrs(\n face: SVGFontRequest,\n fontAlias: SVGFontAlias\n): Record<string, string | number> {\n const alias = fontAlias(face)\n if (alias) return { 'font-family': alias, 'font-weight': 'normal', 'font-style': 'normal' }\n return {\n 'font-family': face.family,\n 'font-weight': face.weight,\n 'font-style': face.italic ? 'italic' : 'normal'\n }\n}\n\n/**\n * The font attributes of a span: its face's alias where there is one, otherwise the family of the\n * fallback face that draws it, if any.\n */\nfunction spanFontAttrs(\n node: SceneNode,\n style: CharacterStyleOverride,\n fallback: SVGFallbackFace | undefined,\n fontAlias: SVGFontAlias | undefined\n): Record<string, string | number> {\n if (fontAlias) return aliasedFontAttrs(fontRequest(node, style, fallback), fontAlias)\n return fallback ? { 'font-family': fallback.family } : {}\n}\n\n/**\n * The face a run of `node` is drawn in, or the fallback face that draws its characters instead,\n * with the size and axes its instance follows. A fallback is drawn at the axes the run's own font\n * is drawn at, as the paragraph draws every font it falls back to.\n */\nfunction fontRequest(\n node: SceneNode,\n style: CharacterStyleOverride = {},\n fallback?: SVGFallbackFace\n): SVGFontRequest {\n const own: SVGFontRequest = {\n ...textFontFace(node, style),\n fontSize: style.fontSize ?? node.fontSize,\n variations: style.fontVariations ?? node.fontVariations,\n opticalSizeFromFontSize: style.opticalSizeFromFontSize ?? node.opticalSizeFromFontSize\n }\n if (!fallback) return own\n return {\n ...own,\n ...fallback,\n ...parseFontStyle(fallback.style),\n variations: drawnFontVariations(own),\n opticalSizeFromFontSize: false\n }\n}\n\nfunction isLogicalTextEnd(node: SceneNode, direction: 'LTR' | 'RTL'): boolean {\n return (\n (direction === 'LTR' && node.textAlignHorizontal === 'RIGHT') ||\n (direction === 'RTL' && node.textAlignHorizontal === 'LEFT')\n )\n}\n\nfunction textAnchorForNode(\n node: SceneNode,\n direction: 'LTR' | 'RTL'\n): 'middle' | 'end' | undefined {\n if (node.textAlignHorizontal === 'CENTER') return 'middle'\n if (isLogicalTextEnd(node, direction)) return 'end'\n return undefined\n}\n\nfunction textXForNode(node: SceneNode, direction: 'LTR' | 'RTL'): number {\n if (node.textAlignHorizontal === 'CENTER') return round(node.width / 2)\n if (isLogicalTextEnd(node, direction)) return round(node.width)\n return 0\n}\n\n/** Text with no measured layout: explicit newlines on their own baselines, otherwise one line. */\nfunction renderUnmeasuredText(\n node: SceneNode,\n attrs: Record<string, string | number | undefined>,\n spanAttrs: SpanAttrs,\n direction: 'LTR' | 'RTL'\n): SVGNode {\n const x = textXForNode(node, direction)\n const y = node.fontSize || 14\n // No measured wraps: an explicit newline still starts a line, on the same anchor as one line.\n const newlineLines = explicitNewlineLines(node, x, y)\n if (newlineLines) {\n return svg(\n 'text',\n { ...attrs, 'xml:space': 'preserve' },\n ...laidOutTextSpans(node, newlineLines, spanAttrs)\n )\n }\n\n if (node.styleRuns.length > 0) {\n return svg(\n 'text',\n { x, y, ...attrs, 'xml:space': 'preserve' },\n ...textStyleSpans(node, spanAttrs)\n )\n }\n\n return svg('text', { x, y, ...attrs }, shownText(node))\n}\n\nexport function renderTextNode(\n node: SceneNode,\n fillAttr: string | null,\n ctx: SVGExportContext,\n fillOpacity?: number\n): SVGNode {\n const { colorSpace, textLayout, fontAlias } = ctx\n const direction = resolveNodeTextDirection(node)\n const lines = textLayout ? textLayout(node) : null\n const laidOut = lines && lines.length > 0 ? lines : null\n\n let textDecoration: 'underline' | 'line-through' | undefined\n if (node.textDecoration === 'UNDERLINE') textDecoration = 'underline'\n else if (node.textDecoration === 'STRIKETHROUGH') textDecoration = 'line-through'\n const letterSpacing = textLengthPixels(node.letterSpacing, node.fontSize)\n\n const attrs: Record<string, string | number | undefined> = {\n 'font-family': node.fontFamily || undefined,\n 'font-size': node.fontSize || undefined,\n 'font-weight': node.fontWeight !== 400 ? node.fontWeight : undefined,\n 'font-style': node.italic ? 'italic' : undefined,\n fill: fillAttr ?? undefined,\n 'fill-opacity': fillOpacity,\n // Laid-out spans each start at their own left edge, so they take no direction or anchor.\n direction: direction === 'RTL' && !laidOut ? 'rtl' : undefined,\n 'text-anchor': laidOut ? undefined : textAnchorForNode(node, direction),\n 'text-decoration': textDecoration,\n 'letter-spacing': letterSpacing ? round(letterSpacing) : undefined,\n ...(fontAlias ? aliasedFontAttrs(fontRequest(node), fontAlias) : {})\n }\n const spanAttrs = (style: CharacterStyleOverride, fallback?: SVGFallbackFace) => ({\n ...styleOverrideToTspanAttrs(style, colorSpace, fillOpacity, node),\n ...spanFontAttrs(node, style, fallback, fontAlias)\n })\n\n if (laidOut) {\n // Laid-out spans sit where the editor draws them, which keeps every space it draws.\n return svg(\n 'text',\n { ...attrs, 'xml:space': 'preserve' },\n ...laidOutTextSpans(node, laidOut, spanAttrs)\n )\n }\n\n return renderUnmeasuredText(node, attrs, spanAttrs, direction)\n}\n"],"mappings":";;;;;;;;;;;AAwBA,SAAS,0BACP,OACA,YACA,mBACA,MAC6C;CAC7C,MAAM,QAAqD,CAAC;CAC5D,IAAI,MAAM,YAAY,MAAM,iBAAiB,MAAM;CACnD,IAAI,MAAM,UAAU,MAAM,eAAe,MAAM;CAC/C,IAAI,MAAM,YAAY,MAAM,iBAAiB,MAAM;CACnD,IAAI,MAAM,QAAQ,MAAM,gBAAgB;CAGxC,MAAM,YACJ,MAAM,aAAa,KAAA,KACnB,KAAK,cAAc,SAAS,aAC5B,KAAK,cAAc,UAAU,IACzB,KAAK,gBACL,KAAA;CACN,MAAM,UAAU,MAAM,iBAAiB;CACvC,IAAI,SACF,MAAM,oBAAoB,MAAM,iBAAiB,SAAS,MAAM,YAAY,KAAK,QAAQ,CAAC;CAE5F,IAAI,MAAM,mBAAmB,aAAa,MAAM,qBAAqB;CACrE,IAAI,MAAM,mBAAmB,iBAAiB,MAAM,qBAAqB;CACzE,IAAI,MAAM,OAAO;EACf,MAAM,cAAc,MAAM,MAAM,MAAM,MAAM,EAAE,WAAW,EAAE,SAAS,OAAO;EAC3E,IAAI,aAAa;GAEf,MAAM,QAAQ,MAAM,YAAY,MAAM,IAAI,YAAY,OAAO;GAC7D,IAAI,eAAe,cACjB,MAAM,OAAO,YAAY;IAAE,GAAG,YAAY;IAAO,GAAG;GAAE,GAAG,OAAO,UAAU;QACrE;IACL,MAAM,OAAO,YAAY,YAAY,OAAO,GAAG,UAAU;IACzD,IAAI,QAAQ,GAAG,MAAM,kBAAkB;GACzC;GAEA,IAAI,SAAS,KAAK,sBAAsB,KAAA,GAAW,MAAM,kBAAkB;EAC7E;C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cAAgC;EAChF,GAAG,0BAA0B,OAAO,YAAY,aAAa,IAAI;EACjE,GAAG,cAAc,MAAM,OAAO,UAAU,SAAS;CACnD;CAEA,IAAI,SAEF,OAAO,IACL,QACA;EAAE,GAAG;EAAO,aAAa;CAAW,GACpC,GAAG,iBAAiB,MAAM,SAAS,SAAS,CAC9C;CAGF,OAAO,qBAAqB,MAAM,OAAO,WAAW,SAAS;AAC/D"}
|
|
1
|
+
{"version":3,"file":"export.js","names":[],"sources":["../../../../../src/io/formats/svg/text/export.ts"],"sourcesContent":["import type { CharacterStyleOverride, SceneNode } from '@pairdraw/scene-graph'\nimport { parseFontStyle } from '@pairdraw/scene-graph/font-style'\nimport { textLengthPixels } from '@pairdraw/scene-graph/text'\nimport { resolveNodeTextDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { drawnFontVariations } from '#core/canvas/text/font-families'\nimport {\n formatColor,\n formatSolidColor,\n type SVGExportContext,\n type SVGFontAlias,\n type SVGFontRequest\n} from '#core/io/formats/svg/defs'\nimport { svg, type SVGNode } from '#core/io/formats/svg/node'\nimport { round } from '#core/io/formats/svg/paths'\nimport {\n explicitNewlineLines,\n laidOutTextSpans,\n textStyleSpans,\n type SpanAttrs,\n type SVGFallbackFace\n} from '#core/io/formats/svg/text/lines'\nimport { shownText } from '#core/text/case'\nimport { textFontFace } from '#core/text/requirements/collect'\n\nfunction styleOverrideToTspanAttrs(\n style: CharacterStyleOverride,\n colorSpace: 'srgb' | 'display-p3',\n parentFillOpacity: number | undefined,\n node: Pick<SceneNode, 'fontSize' | 'letterSpacing'>\n): Record<string, string | number | undefined> {\n const attrs: Record<string, string | number | undefined> = {}\n if (style.fontFamily) attrs['font-family'] = style.fontFamily\n if (style.fontSize) attrs['font-size'] = style.fontSize\n if (style.fontWeight) attrs['font-weight'] = style.fontWeight\n if (style.italic) attrs['font-style'] = 'italic'\n // A run's own spacing is written even at zero, or it would inherit the layer's. A percent the\n // run inherits follows its own font size, so a larger or smaller run writes it again.\n const inherited =\n style.fontSize !== undefined &&\n node.letterSpacing.unit === 'PERCENT' &&\n node.letterSpacing.value !== 0\n ? node.letterSpacing\n : undefined\n const spacing = style.letterSpacing ?? inherited\n if (spacing) {\n attrs['letter-spacing'] = round(textLengthPixels(spacing, style.fontSize ?? node.fontSize))\n }\n if (style.textDecoration === 'UNDERLINE') attrs['text-decoration'] = 'underline'\n if (style.textDecoration === 'STRIKETHROUGH') attrs['text-decoration'] = 'line-through'\n if (style.fills) {\n const visibleFill = style.fills.find((f) => f.visible && f.type === 'SOLID')\n if (visibleFill) {\n // Paragraphs and saved glyphs draw a run at color.a * opacity. Shapes paint opacity alone.\n const alpha = round(visibleFill.color.a * visibleFill.opacity)\n if (colorSpace === 'display-p3') {\n attrs.fill = formatColor({ ...visibleFill.color, a: 1 }, alpha, colorSpace)\n } else {\n attrs.fill = formatColor(visibleFill.color, 1, colorSpace)\n if (alpha < 1) attrs['fill-opacity'] = alpha\n }\n // `fill-opacity` inherits, so an opaque run has to cover a translucent parent.\n if (alpha >= 1 && parentFillOpacity !== undefined) attrs['fill-opacity'] = 1\n }\n }\n return attrs\n}\n\n/**\n * Font attributes naming a face's alias, such as the family a PDF embeds its file under, or else\n * the face itself, so text inside an aliased parent does not inherit the alias.\n */\nfunction aliasedFontAttrs(\n face: SVGFontRequest,\n fontAlias: SVGFontAlias\n): Record<string, string | number> {\n const alias = fontAlias(face)\n if (alias) return { 'font-family': alias, 'font-weight': 'normal', 'font-style': 'normal' }\n return {\n 'font-family': face.family,\n 'font-weight': face.weight,\n 'font-style': face.italic ? 'italic' : 'normal'\n }\n}\n\n/**\n * The font attributes of a span: its face's alias where there is one, otherwise the family of the\n * fallback face that draws it, if any.\n */\nfunction spanFontAttrs(\n node: SceneNode,\n style: CharacterStyleOverride,\n fallback: SVGFallbackFace | undefined,\n fontAlias: SVGFontAlias | undefined\n): Record<string, string | number> {\n if (fontAlias) return aliasedFontAttrs(fontRequest(node, style, fallback), fontAlias)\n return fallback ? { 'font-family': fallback.family } : {}\n}\n\n/**\n * A text layer's stroke, painted on the glyphs themselves. The canvas strokes an outside stroke at\n * twice its weight and clips it to the outside of the glyphs; live text cannot be clipped in SVG,\n * so the same band is painted behind the fill at twice the weight, which hides the inner half. An\n * inside or centred stroke keeps its own weight over the fill.\n */\nfunction textStrokeAttrs(\n node: SceneNode,\n colorSpace: 'srgb' | 'display-p3'\n): Record<string, string | number | undefined> {\n const stroke = node.strokes.find((candidate) => candidate.visible)\n if (!stroke) return {}\n const attrs: Record<string, string | number | undefined> = {\n stroke: formatSolidColor(stroke.color, 1, colorSpace),\n 'stroke-width': round(stroke.weight * (stroke.align === 'OUTSIDE' ? 2 : 1))\n }\n if (stroke.opacity < 1) attrs['stroke-opacity'] = round(stroke.opacity)\n if (stroke.align === 'OUTSIDE') attrs['paint-order'] = 'stroke'\n return attrs\n}\n\n/**\n * The face a run of `node` is drawn in, or the fallback face that draws its characters instead,\n * with the size and axes its instance follows. A fallback is drawn at the axes the run's own font\n * is drawn at, as the paragraph draws every font it falls back to.\n */\nfunction fontRequest(\n node: SceneNode,\n style: CharacterStyleOverride = {},\n fallback?: SVGFallbackFace\n): SVGFontRequest {\n const own: SVGFontRequest = {\n ...textFontFace(node, style),\n fontSize: style.fontSize ?? node.fontSize,\n variations: style.fontVariations ?? node.fontVariations,\n opticalSizeFromFontSize: style.opticalSizeFromFontSize ?? node.opticalSizeFromFontSize\n }\n if (!fallback) return own\n return {\n ...own,\n ...fallback,\n ...parseFontStyle(fallback.style),\n variations: drawnFontVariations(own),\n opticalSizeFromFontSize: false\n }\n}\n\nfunction isLogicalTextEnd(node: SceneNode, direction: 'LTR' | 'RTL'): boolean {\n return (\n (direction === 'LTR' && node.textAlignHorizontal === 'RIGHT') ||\n (direction === 'RTL' && node.textAlignHorizontal === 'LEFT')\n )\n}\n\nfunction textAnchorForNode(\n node: SceneNode,\n direction: 'LTR' | 'RTL'\n): 'middle' | 'end' | undefined {\n if (node.textAlignHorizontal === 'CENTER') return 'middle'\n if (isLogicalTextEnd(node, direction)) return 'end'\n return undefined\n}\n\nfunction textXForNode(node: SceneNode, direction: 'LTR' | 'RTL'): number {\n if (node.textAlignHorizontal === 'CENTER') return round(node.width / 2)\n if (isLogicalTextEnd(node, direction)) return round(node.width)\n return 0\n}\n\n/** Text with no measured layout: explicit newlines on their own baselines, otherwise one line. */\nfunction renderUnmeasuredText(\n node: SceneNode,\n attrs: Record<string, string | number | undefined>,\n spanAttrs: SpanAttrs,\n direction: 'LTR' | 'RTL'\n): SVGNode {\n const x = textXForNode(node, direction)\n const y = node.fontSize || 14\n // No measured wraps: an explicit newline still starts a line, on the same anchor as one line.\n const newlineLines = explicitNewlineLines(node, x, y)\n if (newlineLines) {\n return svg(\n 'text',\n { ...attrs, 'xml:space': 'preserve' },\n ...laidOutTextSpans(node, newlineLines, spanAttrs)\n )\n }\n\n if (node.styleRuns.length > 0) {\n return svg(\n 'text',\n { x, y, ...attrs, 'xml:space': 'preserve' },\n ...textStyleSpans(node, spanAttrs)\n )\n }\n\n return svg('text', { x, y, ...attrs }, shownText(node))\n}\n\nexport function renderTextNode(\n node: SceneNode,\n fillAttr: string | null,\n ctx: SVGExportContext,\n fillOpacity?: number\n): SVGNode {\n const { colorSpace, textLayout, fontAlias } = ctx\n const direction = resolveNodeTextDirection(node)\n const lines = textLayout ? textLayout(node) : null\n const laidOut = lines && lines.length > 0 ? lines : null\n\n let textDecoration: 'underline' | 'line-through' | undefined\n if (node.textDecoration === 'UNDERLINE') textDecoration = 'underline'\n else if (node.textDecoration === 'STRIKETHROUGH') textDecoration = 'line-through'\n const letterSpacing = textLengthPixels(node.letterSpacing, node.fontSize)\n\n const attrs: Record<string, string | number | undefined> = {\n 'font-family': node.fontFamily || undefined,\n 'font-size': node.fontSize || undefined,\n 'font-weight': node.fontWeight !== 400 ? node.fontWeight : undefined,\n 'font-style': node.italic ? 'italic' : undefined,\n fill: fillAttr ?? undefined,\n 'fill-opacity': fillOpacity,\n // Laid-out spans each start at their own left edge, so they take no direction or anchor.\n direction: direction === 'RTL' && !laidOut ? 'rtl' : undefined,\n 'text-anchor': laidOut ? undefined : textAnchorForNode(node, direction),\n 'text-decoration': textDecoration,\n 'letter-spacing': letterSpacing ? round(letterSpacing) : undefined,\n ...textStrokeAttrs(node, colorSpace),\n ...(fontAlias ? aliasedFontAttrs(fontRequest(node), fontAlias) : {})\n }\n const spanAttrs = (style: CharacterStyleOverride, fallback?: SVGFallbackFace) => ({\n ...styleOverrideToTspanAttrs(style, colorSpace, fillOpacity, node),\n ...spanFontAttrs(node, style, fallback, fontAlias)\n })\n\n if (laidOut) {\n // Laid-out spans sit where the editor draws them, which keeps every space it draws.\n return svg(\n 'text',\n { ...attrs, 'xml:space': 'preserve' },\n ...laidOutTextSpans(node, laidOut, spanAttrs)\n )\n }\n\n return renderUnmeasuredText(node, attrs, spanAttrs, direction)\n}\n"],"mappings":";;;;;;;;;;;AAyBA,SAAS,0BACP,OACA,YACA,mBACA,MAC6C;CAC7C,MAAM,QAAqD,CAAC;CAC5D,IAAI,MAAM,YAAY,MAAM,iBAAiB,MAAM;CACnD,IAAI,MAAM,UAAU,MAAM,eAAe,MAAM;CAC/C,IAAI,MAAM,YAAY,MAAM,iBAAiB,MAAM;CACnD,IAAI,MAAM,QAAQ,MAAM,gBAAgB;CAGxC,MAAM,YACJ,MAAM,aAAa,KAAA,KACnB,KAAK,cAAc,SAAS,aAC5B,KAAK,cAAc,UAAU,IACzB,KAAK,gBACL,KAAA;CACN,MAAM,UAAU,MAAM,iBAAiB;CACvC,IAAI,SACF,MAAM,oBAAoB,MAAM,iBAAiB,SAAS,MAAM,YAAY,KAAK,QAAQ,CAAC;CAE5F,IAAI,MAAM,mBAAmB,aAAa,MAAM,qBAAqB;CACrE,IAAI,MAAM,mBAAmB,iBAAiB,MAAM,qBAAqB;CACzE,IAAI,MAAM,OAAO;EACf,MAAM,cAAc,MAAM,MAAM,MAAM,MAAM,EAAE,WAAW,EAAE,SAAS,OAAO;EAC3E,IA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AyB,IAAI;CAC/C,MAAM,QAAQ,aAAa,WAAW,IAAI,IAAI;CAC9C,MAAM,UAAU,SAAS,MAAM,SAAS,IAAI,QAAQ;CAEpD,IAAI;CACJ,IAAI,KAAK,mBAAmB,aAAa,iBAAiB;MACrD,IAAI,KAAK,mBAAmB,iBAAiB,iBAAiB;CACnE,MAAM,gBAAgB,iBAAiB,KAAK,eAAe,KAAK,QAAQ;CAExE,MAAM,QAAqD;EACzD,eAAe,KAAK,cAAc,KAAA;EAClC,aAAa,KAAK,YAAY,KAAA;EAC9B,eAAe,KAAK,eAAe,MAAM,KAAK,aAAa,KAAA;EAC3D,cAAc,KAAK,SAAS,WAAW,KAAA;EACvC,MAAM,YAAY,KAAA;EAClB,gBAAgB;EAEhB,WAAW,cAAc,SAAS,CAAC,UAAU,QAAQ,KAAA;EACrD,eAAe,UAAU,KAAA,IAAY,kBAAkB,MAAM,SAAS;EACtE,mBAAmB;EACnB,kBAAkB,gBAAgB,MAAM,aAAa,IAAI,KAAA;EACzD,GAAG,gBAAgB,MAAM,UAAU;EACnC,GAAI,YAAY,iBAAiB,YAAY,IAAI,GAAG,SAAS,IAAI,CAAC;CACpE;CACA,MAAM,aAAa,OAA+B,cAAgC;EAChF,GAAG,0BAA0B,OAAO,YAAY,aAAa,IAAI;EACjE,GAAG,cAAc,MAAM,OAAO,UAAU,SAAS;CACnD;CAEA,IAAI,SAEF,OAAO,IACL,QACA;EAAE,GAAG;EAAO,aAAa;CAAW,GACpC,GAAG,iBAAiB,MAAM,SAAS,SAAS,CAC9C;CAGF,OAAO,qBAAqB,MAAM,OAAO,WAAW,SAAS;AAC/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","names":[],"sources":["../../../../../src/io/formats/svg/text/import.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"import.d.ts","names":[],"sources":["../../../../../src/io/formats/svg/text/import.ts"],"mappings":";;;;;iBA6GgB,cACd,OAAO,YACP,kBACA,MAAM,gBACN,SAAS,iBACT,cAAc,kBAAkB,OAAO,QAAQ;;iBAmBjC,eAAe,MAAM,KAAK,+BAA+B;EACvE;EACA;EACA"}
|
|
@@ -3,6 +3,7 @@ import { localTransformFromWorld } from "@pairdraw/scene-graph/coordinate";
|
|
|
3
3
|
import { pixelLength } from "@pairdraw/scene-graph/text";
|
|
4
4
|
import { faceLoadKey } from "@pairdraw/scene-graph/font-style";
|
|
5
5
|
import Matrix from "@pairdraw/scene-graph/matrix";
|
|
6
|
+
import { textLayerName } from "@pairdraw/scene-graph/node-defaults";
|
|
6
7
|
import { isEqual } from "es-toolkit/predicate";
|
|
7
8
|
//#region src/io/formats/svg/text/import.ts
|
|
8
9
|
const ALIGN = {
|
|
@@ -53,7 +54,7 @@ function createTextPiece(graph, parentId, piece, matrix, props) {
|
|
|
53
54
|
const scale = Math.hypot(matrix[0], matrix[3]) || 1;
|
|
54
55
|
const characters = piece.runs.map((run) => run.text).join("");
|
|
55
56
|
const node = graph.createNode("TEXT", parentId, {
|
|
56
|
-
name: characters,
|
|
57
|
+
name: textLayerName("TEXT", characters),
|
|
57
58
|
...props,
|
|
58
59
|
...runStyle(piece.runs[0], scale),
|
|
59
60
|
text: characters,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","names":[],"sources":["../../../../../src/io/formats/svg/text/import.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type { CharacterStyleOverride, SceneGraph, SceneNode, StyleRun } from '@pairdraw/scene-graph'\nimport { localTransformFromWorld } from '@pairdraw/scene-graph/coordinate'\nimport { faceLoadKey } from '@pairdraw/scene-graph/font-style'\nimport Matrix from '@pairdraw/scene-graph/matrix'\nimport { pixelLength } from '@pairdraw/scene-graph/text'\n\nimport type { SVGElementLayer } from '#core/icons/types'\nimport { measureTextForLayout } from '#core/layout/text-measurement'\nimport type {\n SVGVectorizeResult,\n VectorizedText,\n VectorizedTextPiece\n} from '#core/vector/vectorize/svg/to-vectors'\n\nconst ALIGN = { start: 'LEFT', middle: 'CENTER', end: 'RIGHT' } as const\n/** How much of its width a text anchored this way sits left of `x`. */\nconst ANCHOR_OFFSET = { start: 0, middle: 0.5, end: 1 } as const\n\ntype Run = VectorizedTextPiece['runs'][number]\n\n/** A run's style in the text's own units; `scale` takes SVG units to the import's. */\nfunction runStyle(\n run: Run,\n scale: number\n): Required<\n Pick<\n CharacterStyleOverride,\n | 'fontFamily'\n | 'fontSize'\n | 'fontWeight'\n | 'italic'\n | 'letterSpacing'\n | 'textDecoration'\n | 'fills'\n >\n> {\n return {\n // Figma imports SVG text in a font it does not know as Inter.\n fontFamily: run.fontFamily ?? 'Inter',\n fontSize: run.fontSize * scale,\n fontWeight: run.fontWeight,\n italic: run.italic,\n letterSpacing: pixelLength(run.letterSpacing * scale),\n textDecoration: run.textDecoration,\n fills: run.fills\n }\n}\n\n/** Later runs as style runs over the first run's style, which the layer takes. */\nfunction styleRuns(runs: Run[], scale: number): StyleRun[] {\n const base = runStyle(runs[0], scale)\n const result: StyleRun[] = []\n let start = 0\n for (const run of runs) {\n const style = runStyle(run, scale)\n const override = Object.fromEntries(\n Object.entries(style).filter(\n ([key, value]) => !isEqual(value, base[key as keyof typeof base])\n )\n ) as CharacterStyleOverride\n if (Object.keys(override).length > 0)\n result.push({ start, length: run.text.length, style: override })\n start += run.text.length\n }\n return result\n}\n\n/**\n * A text layer sized to its characters and placed as Figma places SVG text: its top a font size\n * above the baseline, its left, centre, or right edge on `x` by `text-anchor`.\n */\nfunction createTextPiece(\n graph: SceneGraph,\n parentId: string,\n piece: VectorizedTextPiece,\n matrix: VectorizedText['matrix'],\n props: Partial<SceneNode>\n): SceneNode {\n const scale = Math.hypot(matrix[0], matrix[3]) || 1\n const characters = piece.runs.map((run) => run.text).join('')\n const node = graph.createNode('TEXT', parentId, {\n name: characters,\n ...props,\n ...runStyle(piece.runs[0], scale),\n text: characters,\n styleRuns: styleRuns(piece.runs, scale),\n textAlignHorizontal: ALIGN[piece.anchor],\n textAutoResize: 'WIDTH_AND_HEIGHT',\n lineHeight: null,\n width: 0\n })\n const size = measureTextForLayout(node)\n const width = size.width / scale\n const left = width * ANCHOR_OFFSET[piece.anchor]\n const world = Matrix.multiply(\n matrix,\n Matrix.translated(piece.x - left, piece.y - piece.runs[0].fontSize),\n Matrix.scaled(1 / scale, 1 / scale)\n )\n const sized = { ...node, width: size.width, height: size.height }\n const place = localTransformFromWorld(sized, world, Matrix.identity())\n graph.updateNode(node.id, { width: size.width, height: size.height, ...place })\n return node\n}\n\n/** Text layers for a `<text>`; one with several pieces is a group of them, as in Figma. */\nexport function createSVGText(\n graph: SceneGraph,\n parentId: string,\n text: VectorizedText,\n element: SVGElementLayer,\n createGroup: (parentId: string, props: Partial<SceneNode>) => string\n): void {\n if (text.pieces.length === 1) {\n createTextPiece(graph, parentId, text.pieces[0], text.matrix, {\n ...(element.name ? { name: element.name } : {}),\n opacity: element.opacity,\n visible: element.visible\n })\n return\n }\n const groupId = createGroup(parentId, {\n name: element.name ?? 'Group',\n opacity: element.opacity,\n visible: element.visible\n })\n for (const piece of text.pieces) createTextPiece(graph, groupId, piece, text.matrix, {})\n}\n\n/** The fonts an import's text is drawn in, to load before it is measured and placed. */\nexport function svgImportFonts(data: Pick<SVGVectorizeResult, 'texts'>): Array<{\n family: string\n style: string\n characters: string\n}> {\n const fonts = new Map<string, { family: string; style: string; characters: string }>()\n for (const run of data.texts.flatMap((text) => text.pieces.flatMap((piece) => piece.runs))) {\n const family = run.fontFamily ?? 'Inter'\n const style = faceLoadKey(run.fontWeight, run.italic)\n const key = `${family}\\u0000${style}`\n const font = fonts.get(key) ?? { family, style, characters: '' }\n fonts.set(key, { ...font, characters: font.characters + run.text })\n }\n return [...fonts.values()]\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"import.js","names":[],"sources":["../../../../../src/io/formats/svg/text/import.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type { CharacterStyleOverride, SceneGraph, SceneNode, StyleRun } from '@pairdraw/scene-graph'\nimport { localTransformFromWorld } from '@pairdraw/scene-graph/coordinate'\nimport { faceLoadKey } from '@pairdraw/scene-graph/font-style'\nimport Matrix from '@pairdraw/scene-graph/matrix'\nimport { textLayerName } from '@pairdraw/scene-graph/node-defaults'\nimport { pixelLength } from '@pairdraw/scene-graph/text'\n\nimport type { SVGElementLayer } from '#core/icons/types'\nimport { measureTextForLayout } from '#core/layout/text-measurement'\nimport type {\n SVGVectorizeResult,\n VectorizedText,\n VectorizedTextPiece\n} from '#core/vector/vectorize/svg/to-vectors'\n\nconst ALIGN = { start: 'LEFT', middle: 'CENTER', end: 'RIGHT' } as const\n/** How much of its width a text anchored this way sits left of `x`. */\nconst ANCHOR_OFFSET = { start: 0, middle: 0.5, end: 1 } as const\n\ntype Run = VectorizedTextPiece['runs'][number]\n\n/** A run's style in the text's own units; `scale` takes SVG units to the import's. */\nfunction runStyle(\n run: Run,\n scale: number\n): Required<\n Pick<\n CharacterStyleOverride,\n | 'fontFamily'\n | 'fontSize'\n | 'fontWeight'\n | 'italic'\n | 'letterSpacing'\n | 'textDecoration'\n | 'fills'\n >\n> {\n return {\n // Figma imports SVG text in a font it does not know as Inter.\n fontFamily: run.fontFamily ?? 'Inter',\n fontSize: run.fontSize * scale,\n fontWeight: run.fontWeight,\n italic: run.italic,\n letterSpacing: pixelLength(run.letterSpacing * scale),\n textDecoration: run.textDecoration,\n fills: run.fills\n }\n}\n\n/** Later runs as style runs over the first run's style, which the layer takes. */\nfunction styleRuns(runs: Run[], scale: number): StyleRun[] {\n const base = runStyle(runs[0], scale)\n const result: StyleRun[] = []\n let start = 0\n for (const run of runs) {\n const style = runStyle(run, scale)\n const override = Object.fromEntries(\n Object.entries(style).filter(\n ([key, value]) => !isEqual(value, base[key as keyof typeof base])\n )\n ) as CharacterStyleOverride\n if (Object.keys(override).length > 0)\n result.push({ start, length: run.text.length, style: override })\n start += run.text.length\n }\n return result\n}\n\n/**\n * A text layer sized to its characters and placed as Figma places SVG text: its top a font size\n * above the baseline, its left, centre, or right edge on `x` by `text-anchor`.\n */\nfunction createTextPiece(\n graph: SceneGraph,\n parentId: string,\n piece: VectorizedTextPiece,\n matrix: VectorizedText['matrix'],\n props: Partial<SceneNode>\n): SceneNode {\n const scale = Math.hypot(matrix[0], matrix[3]) || 1\n const characters = piece.runs.map((run) => run.text).join('')\n const node = graph.createNode('TEXT', parentId, {\n name: textLayerName('TEXT', characters),\n ...props,\n ...runStyle(piece.runs[0], scale),\n text: characters,\n styleRuns: styleRuns(piece.runs, scale),\n textAlignHorizontal: ALIGN[piece.anchor],\n textAutoResize: 'WIDTH_AND_HEIGHT',\n lineHeight: null,\n width: 0\n })\n const size = measureTextForLayout(node)\n const width = size.width / scale\n const left = width * ANCHOR_OFFSET[piece.anchor]\n const world = Matrix.multiply(\n matrix,\n Matrix.translated(piece.x - left, piece.y - piece.runs[0].fontSize),\n Matrix.scaled(1 / scale, 1 / scale)\n )\n const sized = { ...node, width: size.width, height: size.height }\n const place = localTransformFromWorld(sized, world, Matrix.identity())\n graph.updateNode(node.id, { width: size.width, height: size.height, ...place })\n return node\n}\n\n/** Text layers for a `<text>`; one with several pieces is a group of them, as in Figma. */\nexport function createSVGText(\n graph: SceneGraph,\n parentId: string,\n text: VectorizedText,\n element: SVGElementLayer,\n createGroup: (parentId: string, props: Partial<SceneNode>) => string\n): void {\n if (text.pieces.length === 1) {\n createTextPiece(graph, parentId, text.pieces[0], text.matrix, {\n ...(element.name ? { name: element.name } : {}),\n opacity: element.opacity,\n visible: element.visible\n })\n return\n }\n const groupId = createGroup(parentId, {\n name: element.name ?? 'Group',\n opacity: element.opacity,\n visible: element.visible\n })\n for (const piece of text.pieces) createTextPiece(graph, groupId, piece, text.matrix, {})\n}\n\n/** The fonts an import's text is drawn in, to load before it is measured and placed. */\nexport function svgImportFonts(data: Pick<SVGVectorizeResult, 'texts'>): Array<{\n family: string\n style: string\n characters: string\n}> {\n const fonts = new Map<string, { family: string; style: string; characters: string }>()\n for (const run of data.texts.flatMap((text) => text.pieces.flatMap((piece) => piece.runs))) {\n const family = run.fontFamily ?? 'Inter'\n const style = faceLoadKey(run.fontWeight, run.italic)\n const key = `${family}\\u0000${style}`\n const font = fonts.get(key) ?? { family, style, characters: '' }\n fonts.set(key, { ...font, characters: font.characters + run.text })\n }\n return [...fonts.values()]\n}\n"],"mappings":";;;;;;;;AAiBA,MAAM,QAAQ;CAAE,OAAO;CAAQ,QAAQ;CAAU,KAAK;AAAQ;;AAE9D,MAAM,gBAAgB;CAAE,OAAO;CAAG,QAAQ;CAAK,KAAK;AAAE;;AAKtD,SAAS,SACP,KACA,OAYA;CACA,OAAO;EAEL,YAAY,IAAI,cAAc;EAC9B,UAAU,IAAI,WAAW;EACzB,YAAY,IAAI;EAChB,QAAQ,IAAI;EACZ,eAAe,YAAY,IAAI,gBAAgB,KAAK;EACpD,gBAAgB,IAAI;EACpB,OAAO,IAAI;CACb;AACF;;AAGA,SAAS,UAAU,MAAa,OAA2B;CACzD,MAAM,OAAO,SAAS,KAAK,IAAI,KAAK;CACpC,MAAM,SAAqB,CAAC;CAC5B,IAAI,QAAQ;CACZ,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,QAAQ,SAAS,KAAK,KAAK;EACjC,MAAM,WAAW,OAAO,YACtB,OAAO,QAAQ,KAAK,CAAC,CAAC,QACnB,CAAC,KAAK,WAAW,CAAC,QAAQ,OAAO,KAAK,IAAyB,CAClE,CACF;EACA,IAAI,OAAO,KAAK,QAAQ,CAAC,CAAC,SAAS,GACjC,OAAO,KAAK;GAAE;GAAO,QAAQ,IAAI,KAAK;GAAQ,OAAO;EAAS,CAAC;EACjE,SAAS,IAAI,KAAK;CACpB;CACA,OAAO;AACT;;;;;AAMA,SAAS,gBACP,OACA,UACA,OACA,QACA,OACW;CACX,MAAM,QAAQ,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,KAAK;CAClD,MAAM,aAAa,MAAM,KAAK,KAAK,QAAQ,I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AGA,SAAgB,eAAe,MAI5B;CACD,MAAM,wBAAQ,IAAI,IAAmE;CACrF,KAAK,MAAM,OAAO,KAAK,MAAM,SAAS,SAAS,KAAK,OAAO,SAAS,UAAU,MAAM,IAAI,CAAC,GAAG;EAC1F,MAAM,SAAS,IAAI,cAAc;EACjC,MAAM,QAAQ,YAAY,IAAI,YAAY,IAAI,MAAM;EACpD,MAAM,MAAM,GAAG,OAAO,QAAQ;EAC9B,MAAM,OAAO,MAAM,IAAI,GAAG,KAAK;GAAE;GAAQ;GAAO,YAAY;EAAG;EAC/D,MAAM,IAAI,KAAK;GAAE,GAAG;GAAM,YAAY,KAAK,aAAa,IAAI;EAAK,CAAC;CACpE;CACA,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC;AAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph.d.ts","names":[],"sources":["../../src/io/subgraph.ts"],"mappings":";;;UAMiB;;EAEf;;;;;EAKA;;UAGe;EACf,OAAO;EACP;EACA;;
|
|
1
|
+
{"version":3,"file":"subgraph.d.ts","names":[],"sources":["../../src/io/subgraph.ts"],"mappings":";;;UAMiB;;EAEf;;;;;EAKA;;UAGe;EACf,OAAO;EACP;EACA;;iBAuNc,WAAW,QAAQ,YAAY;;iBAY/B,gBAAgB,QAAQ,YAAY;;;;;iBAkEpC,mBACd,QAAQ,YACR,oCACA,4BACA,UAAS,iBACR;iBAMa,mBAAmB,QAAQ,YAAY,QAAQ,eAAe"}
|
package/dist/io/subgraph.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { resolvedVariableModes, variableValueReferences } from "@pairdraw/scene-graph/variables";
|
|
1
2
|
import { SceneGraph } from "@pairdraw/scene-graph";
|
|
2
3
|
import { styleRunReferences } from "@pairdraw/scene-graph/text";
|
|
3
|
-
import { variableValueReferences } from "@pairdraw/scene-graph/variables";
|
|
4
4
|
//#region src/io/subgraph.ts
|
|
5
5
|
function includeReferencedStyles(source, ids) {
|
|
6
6
|
const referencedStyleIds = /* @__PURE__ */ new Set();
|
|
@@ -60,7 +60,10 @@ function cloneIntoGraph(source, ids, { shareTables = false } = {}) {
|
|
|
60
60
|
if (id === source.rootId) continue;
|
|
61
61
|
const node = graph.getNode(id);
|
|
62
62
|
if (!node) continue;
|
|
63
|
-
if (!node.parentId || !ids.has(node.parentId))
|
|
63
|
+
if (!node.parentId || !ids.has(node.parentId)) {
|
|
64
|
+
node.parentId = source.rootId;
|
|
65
|
+
node.variableModes = resolvedVariableModes(source, id);
|
|
66
|
+
}
|
|
64
67
|
node.childIds = node.childIds.filter((childId) => ids.has(childId));
|
|
65
68
|
}
|
|
66
69
|
if (shareTables) {
|
package/dist/io/subgraph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph.js","names":[],"sources":["../../src/io/subgraph.ts"],"sourcesContent":["import { SceneGraph } from '@pairdraw/scene-graph'\nimport { styleRunReferences } from '@pairdraw/scene-graph/text'\nimport { variableValueReferences } from '@pairdraw/scene-graph/variables'\n\nimport type { ExportTarget } from './types'\n\nexport interface ExtractOptions {\n /** Every variant of an instance's set, not only its main component, so it can switch variant. */\n componentSets?: boolean\n /**\n * Use the source's variables, collections, and images instead of copies, for a read-only view\n * rebuilt often, such as preview's. A copy may change its tables without touching the source.\n */\n shareTables?: boolean\n}\n\nexport interface ExtractedGraph {\n graph: SceneGraph\n pageId: string | null\n nodeIds: string[]\n}\n\nfunction includeReferencedStyles(source: SceneGraph, ids: Set<string>): void {\n const referencedStyleIds = new Set<string>()\n for (const id of ids) {\n const node = source.getNode(id)\n if (!node) continue\n for (const styleId of [\n node.fillStyleId,\n node.strokeStyleId,\n node.textStyleId,\n node.effectStyleId,\n node.gridStyleId,\n ...styleRunReferences(node.styleRuns).styles\n ]) {\n if (styleId) referencedStyleIds.add(styleId)\n }\n }\n // Style definitions can sit anywhere in the document; only layers that use one need the search.\n if (referencedStyleIds.size === 0) return\n for (const node of source.getAllNodes()) {\n if (node.sharedStyleType && node.source.id && referencedStyleIds.has(node.source.id)) {\n ids.add(node.id)\n }\n }\n}\n\nfunction cloneIntoGraph(\n source: SceneGraph,\n ids: Set<string>,\n { shareTables = false }: ExtractOptions = {}\n): SceneGraph {\n const graph = new SceneGraph()\n graph.rootId = source.rootId\n graph.nodes = new Map()\n graph.images = new Map()\n graph.variables = new Map()\n graph.variableCollections = new Map()\n graph.activeMode = new Map(source.activeMode)\n graph.figKiwiVersion = source.figKiwiVersion\n graph.figSchemaDeflated = source.figSchemaDeflated\n graph.documentColorSpace = source.documentColorSpace\n graph.documentKind = source.documentKind\n\n includeReferencedStyles(source, ids)\n\n const sortedIds = [...ids].sort((a, b) => {\n if (a === source.rootId) return -1\n if (b === source.rootId) return 1\n const aNode = source.getNode(a)\n const bNode = source.getNode(b)\n const aDepth = depthOf(source, aNode)\n const bDepth = depthOf(source, bNode)\n return aDepth - bDepth\n })\n\n for (const id of sortedIds) {\n const node = source.getNode(id)\n if (!node) continue\n const copy = structuredClone(node)\n graph.nodes.set(id, copy)\n // Syncing and swapping find an instance through its component's index.\n if (copy.type === 'INSTANCE' && copy.componentId) {\n const instances = graph.instanceIndex.get(copy.componentId) ?? new Set<string>()\n instances.add(id)\n graph.instanceIndex.set(copy.componentId, instances)\n }\n if (copy.type === 'CONNECTOR') graph.connectorIds.add(id)\n }\n\n const rootClone = graph.getNode(source.rootId)\n if (rootClone) {\n rootClone.parentId = null\n rootClone.childIds = rootClone.childIds.filter((id) => ids.has(id))\n }\n\n for (const id of sortedIds) {\n if (id === source.rootId) continue\n const node = graph.getNode(id)\n if (!node) continue\n if (!node.parentId || !ids.has(node.parentId)) {\n node.parentId = source.rootId\n }\n node.childIds = node.childIds.filter((childId) => ids.has(childId))\n }\n\n if (shareTables) {\n graph.images = source.images\n graph.variables = source.variables\n graph.variableCollections = source.variableCollections\n } else copyReferencedTables(source, graph)\n\n graph.clearAbsPosCache()\n return graph\n}\n\n/** The images and variables the copied layers use, with their collections, copied in. */\nfunction copyReferencedTables(source: SceneGraph, graph: SceneGraph): void {\n const { imageHashes, variableIds } = collectReferencedResources(source, graph)\n\n for (const imageHash of imageHashes) {\n const image = source.images.get(imageHash)\n if (image) graph.images.set(imageHash, image)\n }\n\n for (const variableId of variableIds) {\n const variable = source.variables.get(variableId)\n if (!variable) continue\n graph.variables.set(variableId, structuredClone(variable))\n const collection = source.variableCollections.get(variable.collectionId)\n if (!collection) continue\n const existing = graph.variableCollections.get(collection.id)\n if (!existing) {\n graph.variableCollections.set(collection.id, {\n ...structuredClone(collection),\n variableIds: []\n })\n }\n graph.variableCollections.get(collection.id)?.variableIds.push(variableId)\n }\n}\n\nfunction collectReferencedResources(source: SceneGraph, graph: SceneGraph) {\n const imageHashes = new Set<string>()\n const variableIds = new Set<string>()\n for (const node of graph.nodes.values()) {\n for (const fill of node.fills) {\n if (fill.type === 'IMAGE' && fill.imageHash) imageHashes.add(fill.imageHash)\n }\n const bound = [\n ...Object.values(node.boundVariables),\n ...styleRunReferences(node.styleRuns).variables\n ]\n for (const variableId of bound) collectVariableClosure(source, variableId, variableIds)\n }\n return { imageHashes, variableIds }\n}\n\nfunction collectVariableClosure(source: SceneGraph, variableId: string, out: Set<string>) {\n if (out.has(variableId)) return\n const variable = source.variables.get(variableId)\n if (!variable) return\n out.add(variableId)\n for (const value of Object.values(variable.valuesByMode)) {\n for (const id of variableValueReferences(value)) collectVariableClosure(source, id, out)\n }\n}\n\nfunction depthOf(source: SceneGraph, node: ReturnType<SceneGraph['getNode']>): number {\n let depth = 0\n let current = node\n while (current?.parentId) {\n depth += 1\n current = source.getNode(current.parentId)\n }\n return depth\n}\n\nfunction collectDescendants(source: SceneGraph, id: string, out: Set<string>) {\n if (out.has(id)) return\n out.add(id)\n const node = source.getNode(id)\n if (!node) return\n for (const childId of node.childIds) {\n collectDescendants(source, childId, out)\n }\n}\n\nfunction collectAncestors(source: SceneGraph, id: string, out: Set<string>) {\n let current = source.getNode(id)\n while (current?.parentId) {\n out.add(current.parentId)\n current = source.getNode(current.parentId)\n }\n}\n\nfunction resolveInstanceComponentId(source: SceneGraph, componentId: string): string {\n const seen = new Set<string>()\n let currentId = componentId\n while (!seen.has(currentId)) {\n seen.add(currentId)\n const node = source.getNode(currentId)\n if (node?.type !== 'INSTANCE' || !node.componentId) return currentId\n currentId = node.componentId\n }\n return componentId\n}\n\nfunction collectComponentDependencies(\n source: SceneGraph,\n ids: Set<string>,\n { componentSets = false }: ExtractOptions = {}\n) {\n let changed = true\n while (changed) {\n changed = false\n for (const id of Array.from(ids)) {\n const node = source.getNode(id)\n if (node?.type !== 'INSTANCE' || !node.componentId) continue\n const componentId = resolveInstanceComponentId(source, node.componentId)\n const component = source.getNode(componentId)\n const set = component?.parentId ? source.getNode(component.parentId) : undefined\n const dependency = componentSets && set?.type === 'COMPONENT_SET' ? set.id : componentId\n if (ids.has(dependency)) continue\n const before = ids.size\n collectAncestors(source, dependency, ids)\n collectDescendants(source, dependency, ids)\n changed ||= ids.size !== before\n }\n }\n}\n\nexport function findPageId(source: SceneGraph, nodeId: string): string | null {\n let current = source.getNode(nodeId)\n while (current?.parentId) {\n const parent = source.getNode(current.parentId)\n if (!parent) return null\n if (parent.type === 'CANVAS') return parent.id\n current = parent\n }\n return current?.type === 'CANVAS' ? current.id : null\n}\n\n/** The page child containing `nodeId`, or the node itself when it is a page child. */\nexport function findPageChildId(source: SceneGraph, nodeId: string): string | null {\n let current = source.getNode(nodeId)\n while (current?.parentId) {\n const parent = source.getNode(current.parentId)\n if (parent?.type === 'CANVAS') return current.id\n current = parent\n }\n return null\n}\n\nfunction ancestorChain(source: SceneGraph, id: string): string[] {\n const chain: string[] = []\n let current = source.getNode(id)\n while (current?.parentId) {\n chain.push(current.parentId)\n current = source.getNode(current.parentId)\n }\n return chain.reverse()\n}\n\nfunction collectSelectionIds(\n source: SceneGraph,\n nodeIds: readonly string[],\n options: ExtractOptions = {}\n): Set<string> {\n const ids = new Set<string>([source.rootId])\n const pageIds = new Set<string>()\n\n for (const nodeId of nodeIds) {\n const node = source.getNode(nodeId)\n if (!node) continue\n for (const ancestorId of ancestorChain(source, nodeId)) {\n ids.add(ancestorId)\n const ancestor = source.getNode(ancestorId)\n if (ancestor?.type === 'CANVAS') pageIds.add(ancestorId)\n }\n collectDescendants(source, nodeId, ids)\n }\n\n for (const pageId of pageIds) {\n ids.add(pageId)\n }\n\n collectComponentDependencies(source, ids, options)\n return ids\n}\n\nfunction pageNodeIds(source: SceneGraph, pageId: string): Set<string> {\n const ids = new Set<string>([source.rootId])\n collectDescendants(source, pageId, ids)\n collectComponentDependencies(source, ids)\n return ids\n}\n\nfunction rootNodeIds(source: SceneGraph): Set<string> {\n const ids = new Set<string>()\n for (const node of source.nodes.values()) {\n ids.add(node.id)\n }\n return ids\n}\n\n/**\n * Clone `pageId`, or each of several pages, with only the subtrees of `nodeIds` (none keeps an\n * empty page) and their dependencies.\n */\nexport function extractPageContext(\n source: SceneGraph,\n pageId: string | readonly string[],\n nodeIds: readonly string[],\n options: ExtractOptions = {}\n): SceneGraph {\n const ids = collectSelectionIds(source, nodeIds, options)\n for (const id of typeof pageId === 'string' ? [pageId] : pageId) ids.add(id)\n return cloneIntoGraph(source, ids, options)\n}\n\nexport function extractExportGraph(source: SceneGraph, target: ExportTarget): ExtractedGraph {\n switch (target.scope) {\n case 'document': {\n const graph = cloneIntoGraph(source, rootNodeIds(source))\n return {\n graph,\n pageId: graph.getPages()[0]?.id ?? null,\n nodeIds: graph.getPages()[0]?.childIds ?? []\n }\n }\n case 'page': {\n const graph = cloneIntoGraph(source, pageNodeIds(source, target.pageId))\n const page = graph.getNode(target.pageId)\n return {\n graph,\n pageId: page?.id ?? null,\n nodeIds: page?.childIds ?? []\n }\n }\n case 'selection': {\n const graph = cloneIntoGraph(source, collectSelectionIds(source, target.nodeIds))\n const firstId = target.nodeIds[0]\n const first = firstId ? source.getNode(firstId) : undefined\n const pageId = first\n ? (ancestorChain(source, first.id).find((id) => source.getNode(id)?.type === 'CANVAS') ??\n null)\n : null\n return {\n graph,\n pageId,\n nodeIds: target.nodeIds.filter((id) => graph.getNode(id) !== undefined)\n }\n }\n case 'node':\n return extractExportGraph(source, { scope: 'selection', nodeIds: [target.nodeId] })\n default:\n return extractExportGraph(source, { scope: 'document' })\n }\n}\n"],"mappings":";;;;AAsBA,SAAS,wBAAwB,QAAoB,KAAwB;CAC3E,MAAM,qCAAqB,IAAI,IAAY;CAC3C,KAAK,MAAM,MAAM,KAAK;EACpB,MAAM,OAAO,OAAO,QAAQ,EAAE;EAC9B,IAAI,CAAC,MAAM;EACX,KAAK,MAAM,WAAW;GACpB,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,GAAG,mBAAmB,KAAK,SAAS,CAAC,CAAC;EACxC,GACE,IAAI,SAAS,mBAAmB,IAAI,OAAO;CAE/C;CAEA,IAAI,mBAAmB,SAAS,GAAG;CACnC,KAAK,MAAM,QAAQ,OAAO,YAAY,GACpC,IAAI,KAAK,mBAAmB,KAAK,OAAO,MAAM,mBAAmB,IAAI,KAAK,OAAO,EAAE,GACjF,IAAI,IAAI,KAAK,EAAE;AAGrB;AAEA,SAAS,eACP,QACA,KACA,EAAE,cAAc,UAA0B,CAAC,GAC/B;CACZ,MAAM,QAAQ,IAAI,WAAW;CAC7B,MAAM,SAAS,OAAO;CACtB,MAAM,wBAAQ,IAAI,IAAI;CACtB,MAAM,yBAAS,IAAI,IAAI;CACvB,MAAM,4BAAY,IAAI,IAAI;CAC1B,MAAM,sCAAsB,IAAI,IAAI;CACpC,MAAM,aAAa,IAAI,IAAI,OAAO,UAAU;CAC5C,MAAM,iBAAiB,OAAO;CAC9B,MAAM,oBAAoB,OAAO;CACjC,MAAM,qBAAqB,OAAO;CAClC,MAAM,eAAe,OAAO;CAE5B,wBAAwB,QAAQ,GAAG;CAEnC,MAAM,YAAY,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,MAAM;EACxC,IAAI,MAAM,OAAO,QAAQ,OAA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C7C;EACF;EACA,KAAK,QAAQ;GACX,MAAM,QAAQ,eAAe,QAAQ,YAAY,QAAQ,OAAO,MAAM,CAAC;GACvE,MAAM,OAAO,MAAM,QAAQ,OAAO,MAAM;GACxC,OAAO;IACL;IACA,QAAQ,MAAM,MAAM;IACpB,SAAS,MAAM,YAAY,CAAC;GAC9B;EACF;EACA,KAAK,aAAa;GAChB,MAAM,QAAQ,eAAe,QAAQ,oBAAoB,QAAQ,OAAO,OAAO,CAAC;GAChF,MAAM,UAAU,OAAO,QAAQ;GAC/B,MAAM,QAAQ,UAAU,OAAO,QAAQ,OAAO,IAAI,KAAA;GAKlD,OAAO;IACL;IACA,QANa,QACV,cAAc,QAAQ,MAAM,EAAE,CAAC,CAAC,MAAM,OAAO,OAAO,QAAQ,EAAE,CAAC,EAAE,SAAS,QAAQ,KACnF,OACA;IAIF,SAAS,OAAO,QAAQ,QAAQ,OAAO,MAAM,QAAQ,EAAE,MAAM,KAAA,CAAS;GACxE;EACF;EACA,KAAK,QACH,OAAO,mBAAmB,QAAQ;GAAE,OAAO;GAAa,SAAS,CAAC,OAAO,MAAM;EAAE,CAAC;EACpF,SACE,OAAO,mBAAmB,QAAQ,EAAE,OAAO,WAAW,CAAC;CAC3D;AACF"}
|
|
1
|
+
{"version":3,"file":"subgraph.js","names":[],"sources":["../../src/io/subgraph.ts"],"sourcesContent":["import { SceneGraph } from '@pairdraw/scene-graph'\nimport { styleRunReferences } from '@pairdraw/scene-graph/text'\nimport { resolvedVariableModes, variableValueReferences } from '@pairdraw/scene-graph/variables'\n\nimport type { ExportTarget } from './types'\n\nexport interface ExtractOptions {\n /** Every variant of an instance's set, not only its main component, so it can switch variant. */\n componentSets?: boolean\n /**\n * Use the source's variables, collections, and images instead of copies, for a read-only view\n * rebuilt often, such as preview's. A copy may change its tables without touching the source.\n */\n shareTables?: boolean\n}\n\nexport interface ExtractedGraph {\n graph: SceneGraph\n pageId: string | null\n nodeIds: string[]\n}\n\nfunction includeReferencedStyles(source: SceneGraph, ids: Set<string>): void {\n const referencedStyleIds = new Set<string>()\n for (const id of ids) {\n const node = source.getNode(id)\n if (!node) continue\n for (const styleId of [\n node.fillStyleId,\n node.strokeStyleId,\n node.textStyleId,\n node.effectStyleId,\n node.gridStyleId,\n ...styleRunReferences(node.styleRuns).styles\n ]) {\n if (styleId) referencedStyleIds.add(styleId)\n }\n }\n // Style definitions can sit anywhere in the document; only layers that use one need the search.\n if (referencedStyleIds.size === 0) return\n for (const node of source.getAllNodes()) {\n if (node.sharedStyleType && node.source.id && referencedStyleIds.has(node.source.id)) {\n ids.add(node.id)\n }\n }\n}\n\nfunction cloneIntoGraph(\n source: SceneGraph,\n ids: Set<string>,\n { shareTables = false }: ExtractOptions = {}\n): SceneGraph {\n const graph = new SceneGraph()\n graph.rootId = source.rootId\n graph.nodes = new Map()\n graph.images = new Map()\n graph.variables = new Map()\n graph.variableCollections = new Map()\n graph.activeMode = new Map(source.activeMode)\n graph.figKiwiVersion = source.figKiwiVersion\n graph.figSchemaDeflated = source.figSchemaDeflated\n graph.documentColorSpace = source.documentColorSpace\n graph.documentKind = source.documentKind\n\n includeReferencedStyles(source, ids)\n\n const sortedIds = [...ids].sort((a, b) => {\n if (a === source.rootId) return -1\n if (b === source.rootId) return 1\n const aNode = source.getNode(a)\n const bNode = source.getNode(b)\n const aDepth = depthOf(source, aNode)\n const bDepth = depthOf(source, bNode)\n return aDepth - bDepth\n })\n\n for (const id of sortedIds) {\n const node = source.getNode(id)\n if (!node) continue\n const copy = structuredClone(node)\n graph.nodes.set(id, copy)\n // Syncing and swapping find an instance through its component's index.\n if (copy.type === 'INSTANCE' && copy.componentId) {\n const instances = graph.instanceIndex.get(copy.componentId) ?? new Set<string>()\n instances.add(id)\n graph.instanceIndex.set(copy.componentId, instances)\n }\n if (copy.type === 'CONNECTOR') graph.connectorIds.add(id)\n }\n\n const rootClone = graph.getNode(source.rootId)\n if (rootClone) {\n rootClone.parentId = null\n rootClone.childIds = rootClone.childIds.filter((id) => ids.has(id))\n }\n\n for (const id of sortedIds) {\n if (id === source.rootId) continue\n const node = graph.getNode(id)\n if (!node) continue\n if (!node.parentId || !ids.has(node.parentId)) {\n node.parentId = source.rootId\n // The ancestor that set a mode is not in the copy, so the node keeps what it inherited.\n node.variableModes = resolvedVariableModes(source, id)\n }\n node.childIds = node.childIds.filter((childId) => ids.has(childId))\n }\n\n if (shareTables) {\n graph.images = source.images\n graph.variables = source.variables\n graph.variableCollections = source.variableCollections\n } else copyReferencedTables(source, graph)\n\n graph.clearAbsPosCache()\n return graph\n}\n\n/** The images and variables the copied layers use, with their collections, copied in. */\nfunction copyReferencedTables(source: SceneGraph, graph: SceneGraph): void {\n const { imageHashes, variableIds } = collectReferencedResources(source, graph)\n\n for (const imageHash of imageHashes) {\n const image = source.images.get(imageHash)\n if (image) graph.images.set(imageHash, image)\n }\n\n for (const variableId of variableIds) {\n const variable = source.variables.get(variableId)\n if (!variable) continue\n graph.variables.set(variableId, structuredClone(variable))\n const collection = source.variableCollections.get(variable.collectionId)\n if (!collection) continue\n const existing = graph.variableCollections.get(collection.id)\n if (!existing) {\n graph.variableCollections.set(collection.id, {\n ...structuredClone(collection),\n variableIds: []\n })\n }\n graph.variableCollections.get(collection.id)?.variableIds.push(variableId)\n }\n}\n\nfunction collectReferencedResources(source: SceneGraph, graph: SceneGraph) {\n const imageHashes = new Set<string>()\n const variableIds = new Set<string>()\n for (const node of graph.nodes.values()) {\n for (const fill of node.fills) {\n if (fill.type === 'IMAGE' && fill.imageHash) imageHashes.add(fill.imageHash)\n }\n const bound = [\n ...Object.values(node.boundVariables),\n ...styleRunReferences(node.styleRuns).variables\n ]\n for (const variableId of bound) collectVariableClosure(source, variableId, variableIds)\n }\n return { imageHashes, variableIds }\n}\n\nfunction collectVariableClosure(source: SceneGraph, variableId: string, out: Set<string>) {\n if (out.has(variableId)) return\n const variable = source.variables.get(variableId)\n if (!variable) return\n out.add(variableId)\n for (const value of Object.values(variable.valuesByMode)) {\n for (const id of variableValueReferences(value)) collectVariableClosure(source, id, out)\n }\n}\n\nfunction depthOf(source: SceneGraph, node: ReturnType<SceneGraph['getNode']>): number {\n let depth = 0\n let current = node\n while (current?.parentId) {\n depth += 1\n current = source.getNode(current.parentId)\n }\n return depth\n}\n\nfunction collectDescendants(source: SceneGraph, id: string, out: Set<string>) {\n if (out.has(id)) return\n out.add(id)\n const node = source.getNode(id)\n if (!node) return\n for (const childId of node.childIds) {\n collectDescendants(source, childId, out)\n }\n}\n\nfunction collectAncestors(source: SceneGraph, id: string, out: Set<string>) {\n let current = source.getNode(id)\n while (current?.parentId) {\n out.add(current.parentId)\n current = source.getNode(current.parentId)\n }\n}\n\nfunction resolveInstanceComponentId(source: SceneGraph, componentId: string): string {\n const seen = new Set<string>()\n let currentId = componentId\n while (!seen.has(currentId)) {\n seen.add(currentId)\n const node = source.getNode(currentId)\n if (node?.type !== 'INSTANCE' || !node.componentId) return currentId\n currentId = node.componentId\n }\n return componentId\n}\n\nfunction collectComponentDependencies(\n source: SceneGraph,\n ids: Set<string>,\n { componentSets = false }: ExtractOptions = {}\n) {\n let changed = true\n while (changed) {\n changed = false\n for (const id of Array.from(ids)) {\n const node = source.getNode(id)\n if (node?.type !== 'INSTANCE' || !node.componentId) continue\n const componentId = resolveInstanceComponentId(source, node.componentId)\n const component = source.getNode(componentId)\n const set = component?.parentId ? source.getNode(component.parentId) : undefined\n const dependency = componentSets && set?.type === 'COMPONENT_SET' ? set.id : componentId\n if (ids.has(dependency)) continue\n const before = ids.size\n collectAncestors(source, dependency, ids)\n collectDescendants(source, dependency, ids)\n changed ||= ids.size !== before\n }\n }\n}\n\nexport function findPageId(source: SceneGraph, nodeId: string): string | null {\n let current = source.getNode(nodeId)\n while (current?.parentId) {\n const parent = source.getNode(current.parentId)\n if (!parent) return null\n if (parent.type === 'CANVAS') return parent.id\n current = parent\n }\n return current?.type === 'CANVAS' ? current.id : null\n}\n\n/** The page child containing `nodeId`, or the node itself when it is a page child. */\nexport function findPageChildId(source: SceneGraph, nodeId: string): string | null {\n let current = source.getNode(nodeId)\n while (current?.parentId) {\n const parent = source.getNode(current.parentId)\n if (parent?.type === 'CANVAS') return current.id\n current = parent\n }\n return null\n}\n\nfunction ancestorChain(source: SceneGraph, id: string): string[] {\n const chain: string[] = []\n let current = source.getNode(id)\n while (current?.parentId) {\n chain.push(current.parentId)\n current = source.getNode(current.parentId)\n }\n return chain.reverse()\n}\n\nfunction collectSelectionIds(\n source: SceneGraph,\n nodeIds: readonly string[],\n options: ExtractOptions = {}\n): Set<string> {\n const ids = new Set<string>([source.rootId])\n const pageIds = new Set<string>()\n\n for (const nodeId of nodeIds) {\n const node = source.getNode(nodeId)\n if (!node) continue\n for (const ancestorId of ancestorChain(source, nodeId)) {\n ids.add(ancestorId)\n const ancestor = source.getNode(ancestorId)\n if (ancestor?.type === 'CANVAS') pageIds.add(ancestorId)\n }\n collectDescendants(source, nodeId, ids)\n }\n\n for (const pageId of pageIds) {\n ids.add(pageId)\n }\n\n collectComponentDependencies(source, ids, options)\n return ids\n}\n\nfunction pageNodeIds(source: SceneGraph, pageId: string): Set<string> {\n const ids = new Set<string>([source.rootId])\n collectDescendants(source, pageId, ids)\n collectComponentDependencies(source, ids)\n return ids\n}\n\nfunction rootNodeIds(source: SceneGraph): Set<string> {\n const ids = new Set<string>()\n for (const node of source.nodes.values()) {\n ids.add(node.id)\n }\n return ids\n}\n\n/**\n * Clone `pageId`, or each of several pages, with only the subtrees of `nodeIds` (none keeps an\n * empty page) and their dependencies.\n */\nexport function extractPageContext(\n source: SceneGraph,\n pageId: string | readonly string[],\n nodeIds: readonly string[],\n options: ExtractOptions = {}\n): SceneGraph {\n const ids = collectSelectionIds(source, nodeIds, options)\n for (const id of typeof pageId === 'string' ? [pageId] : pageId) ids.add(id)\n return cloneIntoGraph(source, ids, options)\n}\n\nexport function extractExportGraph(source: SceneGraph, target: ExportTarget): ExtractedGraph {\n switch (target.scope) {\n case 'document': {\n const graph = cloneIntoGraph(source, rootNodeIds(source))\n return {\n graph,\n pageId: graph.getPages()[0]?.id ?? null,\n nodeIds: graph.getPages()[0]?.childIds ?? []\n }\n }\n case 'page': {\n const graph = cloneIntoGraph(source, pageNodeIds(source, target.pageId))\n const page = graph.getNode(target.pageId)\n return {\n graph,\n pageId: page?.id ?? null,\n nodeIds: page?.childIds ?? []\n }\n }\n case 'selection': {\n const graph = cloneIntoGraph(source, collectSelectionIds(source, target.nodeIds))\n const firstId = target.nodeIds[0]\n const first = firstId ? source.getNode(firstId) : undefined\n const pageId = first\n ? (ancestorChain(source, first.id).find((id) => source.getNode(id)?.type === 'CANVAS') ??\n null)\n : null\n return {\n graph,\n pageId,\n nodeIds: target.nodeIds.filter((id) => graph.getNode(id) !== undefined)\n }\n }\n case 'node':\n return extractExportGraph(source, { scope: 'selection', nodeIds: [target.nodeId] })\n default:\n return extractExportGraph(source, { scope: 'document' })\n }\n}\n"],"mappings":";;;;AAsBA,SAAS,wBAAwB,QAAoB,KAAwB;CAC3E,MAAM,qCAAqB,IAAI,IAAY;CAC3C,KAAK,MAAM,MAAM,KAAK;EACpB,MAAM,OAAO,OAAO,QAAQ,EAAE;EAC9B,IAAI,CAAC,MAAM;EACX,KAAK,MAAM,WAAW;GACpB,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,GAAG,mBAAmB,KAAK,SAAS,CAAC,CAAC;EACxC,GACE,IAAI,SAAS,mBAAmB,IAAI,OAAO;CAE/C;CAEA,IAAI,mBAAmB,SAAS,GAAG;CACnC,KAAK,MAAM,QAAQ,OAAO,YAAY,GACpC,IAAI,KAAK,mBAAmB,KAAK,OAAO,MAAM,mBAAmB,IAAI,KAAK,OAAO,EAAE,GACjF,IAAI,IAAI,KAAK,EAAE;AAGrB;AAEA,SAAS,eACP,QACA,KACA,EAAE,cAAc,UAA0B,CAAC,GAC/B;CACZ,MAAM,QAAQ,IAAI,WAAW;CAC7B,MAAM,SAAS,OAAO;CACtB,MAAM,wBAAQ,IAAI,IAA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1
|
-
{"version":3,"file":"client.d.ts","names":[],"sources":["../../../../src/kiwi/fig/population/client.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../../../src/kiwi/fig/population/client.ts"],"mappings":";;UA+BiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;iBAQc,4BACd,OAAO,YACP,QAAQ,QACR,OAAO,aACP;iBAgBc,0BAA0B,OAAO;iBAIjC,+BACd,OAAO,YACP,eAAe,QAAQ;iBA2BH,uBAAuB,OAAO,aAAa,QAAQ;iBAUzD,2BAA2B,OAAO;UASjC;EACf,WAAW,gBAAgB,SAAS,gBAAgB;;;;;EAKpD;;iBAwBc,0BAA0B,OAAO,aAAa;;;;;;iBAU9C,6BACd,OAAO,YACP,QAAQ,KAAK,gEACb,OAAO,KAAK,+DACZ,0BACC"}
|