@pairdraw/core 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/effects.d.ts +5 -11
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +25 -30
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/labels/hit-test.d.ts +5 -0
- package/dist/canvas/labels/hit-test.d.ts.map +1 -1
- package/dist/canvas/labels/hit-test.js +1 -1
- package/dist/canvas/labels/hit-test.js.map +1 -1
- package/dist/canvas/labels/paragraph-cache.d.ts.map +1 -1
- package/dist/canvas/labels/paragraph-cache.js +3 -2
- package/dist/canvas/labels/paragraph-cache.js.map +1 -1
- package/dist/canvas/labels/selection.js +3 -2
- package/dist/canvas/labels/selection.js.map +1 -1
- package/dist/canvas/labels/style.d.ts +1 -1
- package/dist/canvas/node-edit-overlay.js +2 -2
- package/dist/canvas/node-edit-overlay.js.map +1 -1
- package/dist/canvas/overlays/index.d.ts +2 -2
- package/dist/canvas/overlays/index.js +2 -2
- package/dist/canvas/overlays/selection.d.ts +1 -2
- package/dist/canvas/overlays/selection.d.ts.map +1 -1
- package/dist/canvas/overlays/selection.js +4 -37
- package/dist/canvas/overlays/selection.js.map +1 -1
- package/dist/canvas/region-hatch.js +3 -2
- package/dist/canvas/region-hatch.js.map +1 -1
- package/dist/canvas/renderer/colors.d.ts.map +1 -1
- package/dist/canvas/renderer/colors.js +36 -18
- package/dist/canvas/renderer/colors.js.map +1 -1
- package/dist/canvas/renderer/font-waiters.d.ts +9 -0
- package/dist/canvas/renderer/font-waiters.d.ts.map +1 -0
- package/dist/canvas/renderer/font-waiters.js +26 -0
- package/dist/canvas/renderer/font-waiters.js.map +1 -0
- package/dist/canvas/renderer/fonts.d.ts +4 -2
- package/dist/canvas/renderer/fonts.d.ts.map +1 -1
- package/dist/canvas/renderer/fonts.js +23 -9
- package/dist/canvas/renderer/fonts.js.map +1 -1
- package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
- package/dist/canvas/renderer/lifecycle.js +6 -9
- package/dist/canvas/renderer/lifecycle.js.map +1 -1
- package/dist/canvas/renderer/methods.d.ts +4 -5
- package/dist/canvas/renderer/methods.d.ts.map +1 -1
- package/dist/canvas/renderer/methods.js +1 -4
- package/dist/canvas/renderer/methods.js.map +1 -1
- package/dist/canvas/renderer/paints.d.ts.map +1 -1
- package/dist/canvas/renderer/paints.js +0 -6
- package/dist/canvas/renderer/paints.js.map +1 -1
- package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
- package/dist/canvas/renderer/pipeline.js +20 -2
- package/dist/canvas/renderer/pipeline.js.map +1 -1
- package/dist/canvas/renderer/retained-backing.js +4 -4
- package/dist/canvas/renderer/retained-backing.js.map +1 -1
- package/dist/canvas/renderer/state.js +1 -1
- package/dist/canvas/renderer/state.js.map +1 -1
- package/dist/canvas/renderer/tiles/controller.d.ts +2 -0
- package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
- package/dist/canvas/renderer/tiles/controller.js +8 -0
- package/dist/canvas/renderer/tiles/controller.js.map +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js +1 -1
- package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
- package/dist/canvas/renderer/visual-bounds.d.ts.map +1 -1
- package/dist/canvas/renderer/visual-bounds.js +7 -5
- package/dist/canvas/renderer/visual-bounds.js.map +1 -1
- package/dist/canvas/renderer.d.ts +22 -7
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +46 -11
- package/dist/canvas/renderer.js.map +1 -1
- package/dist/canvas/rulers.d.ts +8 -1
- package/dist/canvas/rulers.d.ts.map +1 -1
- package/dist/canvas/rulers.js +30 -5
- package/dist/canvas/rulers.js.map +1 -1
- package/dist/canvas/scene.d.ts +2 -1
- package/dist/canvas/scene.d.ts.map +1 -1
- package/dist/canvas/scene.js +30 -18
- package/dist/canvas/scene.js.map +1 -1
- package/dist/canvas/shadows/shape.js +1 -1
- package/dist/canvas/shadows/shape.js.map +1 -1
- package/dist/canvas/shadows/silhouette.d.ts.map +1 -1
- package/dist/canvas/shadows/silhouette.js +4 -2
- package/dist/canvas/shadows/silhouette.js.map +1 -1
- package/dist/canvas/shadows.d.ts.map +1 -1
- package/dist/canvas/shadows.js +3 -2
- package/dist/canvas/shadows.js.map +1 -1
- package/dist/canvas/text/derived.d.ts +1 -2
- package/dist/canvas/text/derived.d.ts.map +1 -1
- package/dist/canvas/text/derived.js +1 -7
- package/dist/canvas/text/derived.js.map +1 -1
- package/dist/canvas/text/emoji/index.js +1 -1
- package/dist/canvas/text/emoji/raster.d.ts.map +1 -1
- package/dist/canvas/text/emoji/raster.js +14 -10
- package/dist/canvas/text/emoji/raster.js.map +1 -1
- package/dist/canvas/text/font-families.d.ts.map +1 -1
- package/dist/canvas/text/font-families.js +5 -2
- package/dist/canvas/text/font-families.js.map +1 -1
- package/dist/canvas/text/index.d.ts +1 -3
- package/dist/canvas/text/index.d.ts.map +1 -1
- package/dist/canvas/text/index.js +1 -8
- package/dist/canvas/text/index.js.map +1 -1
- package/dist/canvas/text/layout/build.d.ts.map +1 -1
- package/dist/canvas/text/layout/build.js +25 -9
- package/dist/canvas/text/layout/build.js.map +1 -1
- package/dist/canvas/text/layout/index.d.ts.map +1 -1
- package/dist/canvas/text/layout/index.js +8 -4
- package/dist/canvas/text/layout/index.js.map +1 -1
- package/dist/canvas/text/layout/lines.js +5 -3
- package/dist/canvas/text/layout/lines.js.map +1 -1
- package/dist/canvas/text/paragraph/index.d.ts +5 -0
- package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/index.js +16 -7
- package/dist/canvas/text/paragraph/index.js.map +1 -1
- package/dist/canvas/text/paragraph/inputs.d.ts +1 -1
- package/dist/canvas/text/paragraph/inputs.d.ts.map +1 -1
- package/dist/canvas/text/paragraph/inputs.js +9 -2
- package/dist/canvas/text/paragraph/inputs.js.map +1 -1
- package/dist/canvas/text/placed.js +1 -1
- package/dist/canvas/text/shape.d.ts +4 -3
- package/dist/canvas/text/shape.d.ts.map +1 -1
- package/dist/canvas/text/shape.js +9 -22
- package/dist/canvas/text/shape.js.map +1 -1
- package/dist/constants.d.ts +6 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -2
- package/dist/constants.js.map +1 -1
- package/dist/editor/bridges/clipboard.d.ts +1 -0
- package/dist/editor/bridges/clipboard.js +1 -0
- package/dist/editor/bridges/clipboard.js.map +1 -1
- package/dist/editor/bridges/components.d.ts +2 -0
- package/dist/editor/bridges/components.d.ts.map +1 -1
- package/dist/editor/bridges/components.js +2 -0
- package/dist/editor/bridges/components.js.map +1 -1
- package/dist/editor/bridges/frames.d.ts +4 -3
- package/dist/editor/bridges/frames.d.ts.map +1 -1
- package/dist/editor/bridges/frames.js +6 -4
- package/dist/editor/bridges/frames.js.map +1 -1
- package/dist/editor/bridges/structure.d.ts +1 -0
- package/dist/editor/bridges/structure.d.ts.map +1 -1
- package/dist/editor/bridges/structure.js +1 -0
- package/dist/editor/bridges/structure.js.map +1 -1
- package/dist/editor/clipboard/detach.js +2 -2
- package/dist/editor/clipboard/detach.js.map +1 -1
- package/dist/editor/clipboard/paste/properties.js +1 -1
- package/dist/editor/clipboard/paste/target.js +2 -2
- package/dist/editor/clipboard/paste/target.js.map +1 -1
- package/dist/editor/clipboard/snapshot.d.ts +3 -0
- package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
- package/dist/editor/clipboard/snapshot.js +2 -0
- package/dist/editor/clipboard/snapshot.js.map +1 -1
- package/dist/editor/clipboard/variables.d.ts.map +1 -1
- package/dist/editor/clipboard/variables.js +14 -1
- package/dist/editor/clipboard/variables.js.map +1 -1
- package/dist/editor/clipboard.d.ts +1 -0
- package/dist/editor/clipboard.d.ts.map +1 -1
- package/dist/editor/clipboard.js +122 -16
- package/dist/editor/clipboard.js.map +1 -1
- package/dist/editor/component-sync.d.ts +10 -1
- package/dist/editor/component-sync.d.ts.map +1 -1
- package/dist/editor/component-sync.js +25 -8
- package/dist/editor/component-sync.js.map +1 -1
- package/dist/editor/components/authoring/text-edit.d.ts.map +1 -1
- package/dist/editor/components/authoring/text-edit.js +11 -2
- package/dist/editor/components/authoring/text-edit.js.map +1 -1
- package/dist/editor/components/authoring/visibility-edit.d.ts.map +1 -1
- package/dist/editor/components/authoring/visibility-edit.js +7 -3
- package/dist/editor/components/authoring/visibility-edit.js.map +1 -1
- package/dist/editor/components/instances.d.ts +2 -0
- package/dist/editor/components/instances.d.ts.map +1 -1
- package/dist/editor/components/instances.js +37 -7
- package/dist/editor/components/instances.js.map +1 -1
- package/dist/editor/components/properties.d.ts.map +1 -1
- package/dist/editor/components/properties.js +3 -0
- package/dist/editor/components/properties.js.map +1 -1
- package/dist/editor/components/slots/authoring.js +2 -1
- package/dist/editor/components/slots/authoring.js.map +1 -1
- package/dist/editor/components.d.ts +2 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/create.d.ts +17 -3
- package/dist/editor/create.d.ts.map +1 -1
- package/dist/editor/create.js +43 -6
- package/dist/editor/create.js.map +1 -1
- package/dist/editor/guides.d.ts.map +1 -1
- package/dist/editor/guides.js +20 -13
- package/dist/editor/guides.js.map +1 -1
- package/dist/editor/history/document-change.d.ts +19 -3
- package/dist/editor/history/document-change.d.ts.map +1 -1
- package/dist/editor/history/document-change.js +94 -8
- package/dist/editor/history/document-change.js.map +1 -1
- package/dist/editor/history/edit.d.ts.map +1 -1
- package/dist/editor/history/edit.js +56 -12
- package/dist/editor/history/edit.js.map +1 -1
- package/dist/editor/history/position.js +1 -4
- package/dist/editor/history/position.js.map +1 -1
- package/dist/editor/history/sources.d.ts +14 -0
- package/dist/editor/history/sources.d.ts.map +1 -0
- package/dist/editor/history/sources.js +24 -0
- package/dist/editor/history/sources.js.map +1 -0
- package/dist/editor/index.d.ts +2 -2
- package/dist/editor/index.js +1 -1
- package/dist/editor/layout-mode.d.ts.map +1 -1
- package/dist/editor/layout-mode.js +16 -1
- package/dist/editor/layout-mode.js.map +1 -1
- package/dist/editor/node-preview.d.ts.map +1 -1
- package/dist/editor/node-preview.js +26 -7
- package/dist/editor/node-preview.js.map +1 -1
- package/dist/editor/nodes.d.ts.map +1 -1
- package/dist/editor/nodes.js +33 -10
- package/dist/editor/nodes.js.map +1 -1
- package/dist/editor/nudge.d.ts.map +1 -1
- package/dist/editor/nudge.js +12 -2
- package/dist/editor/nudge.js.map +1 -1
- package/dist/editor/pages.d.ts +2 -1
- package/dist/editor/pages.d.ts.map +1 -1
- package/dist/editor/pages.js +94 -15
- package/dist/editor/pages.js.map +1 -1
- package/dist/editor/play/states.d.ts.map +1 -1
- package/dist/editor/play/states.js +0 -5
- package/dist/editor/play/states.js.map +1 -1
- package/dist/editor/read-only/actions.js +3 -0
- package/dist/editor/read-only/actions.js.map +1 -1
- package/dist/editor/selection/hit-test.d.ts +2 -1
- package/dist/editor/selection/hit-test.d.ts.map +1 -1
- package/dist/editor/selection/hit-test.js +29 -4
- package/dist/editor/selection/hit-test.js.map +1 -1
- package/dist/editor/selection.d.ts +2 -2
- package/dist/editor/selection.d.ts.map +1 -1
- package/dist/editor/shapes/pen.js +6 -2
- package/dist/editor/shapes/pen.js.map +1 -1
- package/dist/editor/shapes.d.ts.map +1 -1
- package/dist/editor/shapes.js +2 -1
- package/dist/editor/shapes.js.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.d.ts.map +1 -1
- package/dist/editor/structure/auto-layout-wrap.js +12 -0
- package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
- package/dist/editor/structure/boolean.js +1 -1
- package/dist/editor/structure/group/bounds.d.ts +4 -2
- package/dist/editor/structure/group/bounds.d.ts.map +1 -1
- package/dist/editor/structure/group/bounds.js +17 -4
- package/dist/editor/structure/group/bounds.js.map +1 -1
- package/dist/editor/structure/rename.d.ts +2 -3
- package/dist/editor/structure/rename.d.ts.map +1 -1
- package/dist/editor/structure/rename.js +2 -5
- package/dist/editor/structure/rename.js.map +1 -1
- package/dist/editor/structure/reorder.d.ts.map +1 -1
- package/dist/editor/structure/reorder.js +20 -9
- package/dist/editor/structure/reorder.js.map +1 -1
- package/dist/editor/structure/state.js +1 -1
- package/dist/editor/structure.d.ts +1 -0
- package/dist/editor/structure.d.ts.map +1 -1
- package/dist/editor/structure.js +76 -20
- package/dist/editor/structure.js.map +1 -1
- package/dist/editor/text/hyperlink.d.ts.map +1 -1
- package/dist/editor/text/hyperlink.js +1 -1
- package/dist/editor/text/hyperlink.js.map +1 -1
- package/dist/editor/text/name.d.ts +13 -5
- package/dist/editor/text/name.d.ts.map +1 -1
- package/dist/editor/text/name.js +47 -17
- package/dist/editor/text/name.js.map +1 -1
- package/dist/editor/text/pending-layout.d.ts +2 -1
- package/dist/editor/text/pending-layout.d.ts.map +1 -1
- package/dist/editor/text/pending-layout.js +33 -6
- package/dist/editor/text/pending-layout.js.map +1 -1
- package/dist/editor/text/selection-style.d.ts +1 -0
- package/dist/editor/text/selection-style.d.ts.map +1 -1
- package/dist/editor/text/selection-style.js +16 -4
- package/dist/editor/text/selection-style.js.map +1 -1
- package/dist/editor/text.d.ts +5 -0
- package/dist/editor/text.d.ts.map +1 -1
- package/dist/editor/text.js +70 -3
- package/dist/editor/text.js.map +1 -1
- package/dist/editor/types.d.ts +18 -1
- package/dist/editor/types.d.ts.map +1 -1
- package/dist/editor/undo.d.ts.map +1 -1
- package/dist/editor/undo.js +14 -2
- package/dist/editor/undo.js.map +1 -1
- package/dist/editor/variable-bindings.d.ts.map +1 -1
- package/dist/editor/variable-bindings.js +21 -2
- package/dist/editor/variable-bindings.js.map +1 -1
- package/dist/editor/variables.d.ts +1 -1
- package/dist/editor/variables.d.ts.map +1 -1
- package/dist/editor/variables.js +7 -8
- package/dist/editor/variables.js.map +1 -1
- package/dist/editor/viewport.d.ts +11 -2
- package/dist/editor/viewport.d.ts.map +1 -1
- package/dist/editor/viewport.js +61 -21
- package/dist/editor/viewport.js.map +1 -1
- package/dist/editor/views/actions.d.ts.map +1 -1
- package/dist/editor/views/actions.js +13 -5
- package/dist/editor/views/actions.js.map +1 -1
- package/dist/editor/views/present.d.ts +6 -4
- package/dist/editor/views/present.d.ts.map +1 -1
- package/dist/editor/views/present.js +12 -10
- package/dist/editor/views/present.js.map +1 -1
- package/dist/editor/views/types.d.ts +11 -5
- package/dist/editor/views/types.d.ts.map +1 -1
- package/dist/figma-api/accessor-utils.d.ts.map +1 -1
- package/dist/figma-api/accessor-utils.js +4 -1
- package/dist/figma-api/accessor-utils.js.map +1 -1
- package/dist/figma-api/accessors/basic.d.ts.map +1 -1
- package/dist/figma-api/accessors/basic.js +41 -21
- package/dist/figma-api/accessors/basic.js.map +1 -1
- package/dist/figma-api/accessors/layout.d.ts.map +1 -1
- package/dist/figma-api/accessors/layout.js +37 -7
- package/dist/figma-api/accessors/layout.js.map +1 -1
- package/dist/figma-api/accessors/reactions.d.ts +11 -0
- package/dist/figma-api/accessors/reactions.d.ts.map +1 -0
- package/dist/figma-api/accessors/reactions.js +30 -0
- package/dist/figma-api/accessors/reactions.js.map +1 -0
- package/dist/figma-api/accessors/strokes.d.ts.map +1 -1
- package/dist/figma-api/accessors/strokes.js +12 -4
- package/dist/figma-api/accessors/strokes.js.map +1 -1
- package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
- package/dist/figma-api/accessors/text/index.js +3 -1
- package/dist/figma-api/accessors/text/index.js.map +1 -1
- package/dist/figma-api/accessors/vector.d.ts.map +1 -1
- package/dist/figma-api/accessors/vector.js +1 -1
- package/dist/figma-api/accessors/vector.js.map +1 -1
- package/dist/figma-api/accessors/visual.d.ts +6 -5
- package/dist/figma-api/accessors/visual.d.ts.map +1 -1
- package/dist/figma-api/accessors/visual.js +20 -17
- package/dist/figma-api/accessors/visual.js.map +1 -1
- package/dist/figma-api/components.d.ts.map +1 -1
- package/dist/figma-api/components.js +2 -1
- package/dist/figma-api/components.js.map +1 -1
- package/dist/figma-api/finite.d.ts +27 -0
- package/dist/figma-api/finite.d.ts.map +1 -0
- package/dist/figma-api/finite.js +69 -0
- package/dist/figma-api/finite.js.map +1 -0
- package/dist/figma-api/fonts/list.d.ts +13 -0
- package/dist/figma-api/fonts/list.d.ts.map +1 -0
- package/dist/figma-api/fonts/list.js +25 -0
- package/dist/figma-api/fonts/list.js.map +1 -0
- package/dist/figma-api/index.d.ts +21 -3
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +58 -13
- package/dist/figma-api/index.js.map +1 -1
- package/dist/figma-api/overrides.d.ts +6 -1
- package/dist/figma-api/overrides.d.ts.map +1 -1
- package/dist/figma-api/overrides.js +2 -2
- package/dist/figma-api/overrides.js.map +1 -1
- package/dist/figma-api/pending-layout.d.ts +12 -2
- package/dist/figma-api/pending-layout.d.ts.map +1 -1
- package/dist/figma-api/pending-layout.js +41 -1
- package/dist/figma-api/pending-layout.js.map +1 -1
- package/dist/figma-api/pending-sync.d.ts +19 -0
- package/dist/figma-api/pending-sync.d.ts.map +1 -0
- package/dist/figma-api/pending-sync.js +52 -0
- package/dist/figma-api/pending-sync.js.map +1 -0
- package/dist/figma-api/proxy.d.ts +15 -2
- package/dist/figma-api/proxy.d.ts.map +1 -1
- package/dist/figma-api/proxy.js +23 -3
- package/dist/figma-api/proxy.js.map +1 -1
- package/dist/figma-api/reactions.d.ts +104 -0
- package/dist/figma-api/reactions.d.ts.map +1 -0
- package/dist/figma-api/reactions.js +157 -0
- package/dist/figma-api/reactions.js.map +1 -0
- package/dist/figma-api/render-bounds.d.ts.map +1 -1
- package/dist/figma-api/render-bounds.js +4 -4
- package/dist/figma-api/render-bounds.js.map +1 -1
- package/dist/figma-api/serialization.js +2 -2
- package/dist/figma-api/serialization.js.map +1 -1
- package/dist/figma-api/slots.d.ts +7 -1
- package/dist/figma-api/slots.d.ts.map +1 -1
- package/dist/figma-api/slots.js +12 -4
- package/dist/figma-api/slots.js.map +1 -1
- package/dist/figma-api/strokes.d.ts +5 -2
- package/dist/figma-api/strokes.d.ts.map +1 -1
- package/dist/figma-api/strokes.js +12 -19
- package/dist/figma-api/strokes.js.map +1 -1
- package/dist/figma-api/text/bindings.js +1 -1
- package/dist/figma-api/text/index.d.ts +2 -3
- package/dist/figma-api/text/index.d.ts.map +1 -1
- package/dist/figma-api/text/index.js +2 -12
- package/dist/figma-api/text/index.js.map +1 -1
- package/dist/figma-api/variables/bindings.js +1 -1
- package/dist/figma-api/variables/variable.d.ts.map +1 -1
- package/dist/figma-api/variables/variable.js +2 -2
- package/dist/figma-api/variables/variable.js.map +1 -1
- package/dist/geometry/figma.d.ts +6 -1
- package/dist/geometry/figma.d.ts.map +1 -1
- package/dist/geometry/figma.js +8 -1
- package/dist/geometry/figma.js.map +1 -1
- package/dist/geometry/index.d.ts +2 -2
- package/dist/geometry/index.js +2 -2
- package/dist/icons/api.d.ts +3 -2
- package/dist/icons/api.d.ts.map +1 -1
- package/dist/icons/api.js +12 -12
- package/dist/icons/api.js.map +1 -1
- package/dist/icons/provider.d.ts +4 -3
- package/dist/icons/provider.d.ts.map +1 -1
- package/dist/icons/provider.js +6 -13
- package/dist/icons/provider.js.map +1 -1
- package/dist/icons/schema.d.ts +33 -1
- package/dist/icons/schema.d.ts.map +1 -1
- package/dist/icons/schema.js +30 -1
- package/dist/icons/schema.js.map +1 -1
- package/dist/icons/svg/presentation.d.ts +8 -1
- package/dist/icons/svg/presentation.d.ts.map +1 -1
- package/dist/icons/svg/presentation.js +21 -3
- package/dist/icons/svg/presentation.js.map +1 -1
- package/dist/icons/svg/text.js +1 -1
- package/dist/icons/svg/text.js.map +1 -1
- package/dist/icons/svg.d.ts +8 -3
- package/dist/icons/svg.d.ts.map +1 -1
- package/dist/icons/svg.js +15 -13
- package/dist/icons/svg.js.map +1 -1
- package/dist/icons/types.d.ts +1 -19
- package/dist/icons/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/io/formats/design-tokens/apply.d.ts +1 -1
- package/dist/io/formats/design-tokens/css/read.js +1 -1
- package/dist/io/formats/design-tokens/decode.js +1 -1
- package/dist/io/formats/design-tokens/plan/index.js +4 -2
- package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts +9 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.js +23 -3
- package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts +9 -1
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js +41 -4
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/types.d.ts +5 -0
- package/dist/io/formats/design-tokens/types.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/types.js +1 -0
- package/dist/io/formats/design-tokens/types.js.map +1 -1
- package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
- package/dist/io/formats/fig/export/setup.js +8 -4
- package/dist/io/formats/fig/export/setup.js.map +1 -1
- package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
- package/dist/io/formats/fig/export/variables.js +2 -2
- package/dist/io/formats/fig/export/variables.js.map +1 -1
- package/dist/io/formats/fig/index.d.ts +2 -2
- package/dist/io/formats/fig/index.js +2 -2
- package/dist/io/formats/fig/read.d.ts +9 -2
- package/dist/io/formats/fig/read.d.ts.map +1 -1
- package/dist/io/formats/fig/read.js +44 -20
- package/dist/io/formats/fig/read.js.map +1 -1
- package/dist/io/formats/html/index.d.ts.map +1 -1
- package/dist/io/formats/html/index.js +2 -6
- package/dist/io/formats/html/index.js.map +1 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +65 -1
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/prepare.js +1 -1
- package/dist/io/formats/pen/fonts.d.ts +14 -0
- package/dist/io/formats/pen/fonts.d.ts.map +1 -0
- package/dist/io/formats/pen/fonts.js +39 -0
- package/dist/io/formats/pen/fonts.js.map +1 -0
- package/dist/io/formats/pen/index.d.ts.map +1 -1
- package/dist/io/formats/pen/index.js +25 -6
- package/dist/io/formats/pen/index.js.map +1 -1
- package/dist/io/formats/raster/headless.d.ts +2 -2
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +24 -13
- package/dist/io/formats/raster/headless.js.map +1 -1
- package/dist/io/formats/raster/index.d.ts +2 -2
- package/dist/io/formats/raster/index.js +2 -2
- package/dist/io/formats/raster/render.d.ts +7 -1
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +40 -6
- package/dist/io/formats/raster/render.js.map +1 -1
- package/dist/io/formats/svg/export.d.ts.map +1 -1
- package/dist/io/formats/svg/export.js +28 -24
- package/dist/io/formats/svg/export.js.map +1 -1
- package/dist/io/formats/svg/paths.d.ts +8 -2
- package/dist/io/formats/svg/paths.d.ts.map +1 -1
- package/dist/io/formats/svg/paths.js +11 -3
- package/dist/io/formats/svg/paths.js.map +1 -1
- package/dist/io/formats/svg/strokes.d.ts.map +1 -1
- package/dist/io/formats/svg/strokes.js +2 -5
- package/dist/io/formats/svg/strokes.js.map +1 -1
- package/dist/io/formats/svg/text/export.d.ts.map +1 -1
- package/dist/io/formats/svg/text/export.js +19 -1
- package/dist/io/formats/svg/text/export.js.map +1 -1
- package/dist/io/formats/svg/text/import.d.ts.map +1 -1
- package/dist/io/formats/svg/text/import.js +2 -1
- package/dist/io/formats/svg/text/import.js.map +1 -1
- package/dist/io/subgraph.d.ts.map +1 -1
- package/dist/io/subgraph.js +5 -2
- package/dist/io/subgraph.js.map +1 -1
- package/dist/kiwi/fig/population/client.d.ts.map +1 -1
- package/dist/kiwi/fig/population/client.js +63 -45
- package/dist/kiwi/fig/population/client.js.map +1 -1
- package/dist/kiwi/fig/population/delta.d.ts +34 -3
- package/dist/kiwi/fig/population/delta.d.ts.map +1 -1
- package/dist/kiwi/fig/population/delta.js +99 -16
- package/dist/kiwi/fig/population/delta.js.map +1 -1
- package/dist/kiwi/fig/population/edits.d.ts +51 -0
- package/dist/kiwi/fig/population/edits.d.ts.map +1 -0
- package/dist/kiwi/fig/population/edits.js +169 -0
- package/dist/kiwi/fig/population/edits.js.map +1 -0
- package/dist/kiwi/fig/session/archive/access.d.ts +3 -0
- package/dist/kiwi/fig/session/archive/access.d.ts.map +1 -1
- package/dist/kiwi/fig/session/archive/access.js +8 -1
- package/dist/kiwi/fig/session/archive/access.js.map +1 -1
- package/dist/kiwi/fig/session/archive/changes.d.ts +2 -1
- package/dist/kiwi/fig/session/archive/changes.d.ts.map +1 -1
- package/dist/kiwi/fig/session/archive/changes.js +12 -5
- package/dist/kiwi/fig/session/archive/changes.js.map +1 -1
- package/dist/kiwi/fig/session/document-state.d.ts +7 -1
- package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
- package/dist/kiwi/fig/session/document-state.js +16 -2
- package/dist/kiwi/fig/session/document-state.js.map +1 -1
- package/dist/kiwi/fig/session/protocol.d.ts +31 -3
- package/dist/kiwi/fig/session/protocol.d.ts.map +1 -1
- package/dist/kiwi/fig/session/worker.js +33 -8
- package/dist/kiwi/fig/session/worker.js.map +1 -1
- package/dist/layout/apply.d.ts +6 -1
- package/dist/layout/apply.d.ts.map +1 -1
- package/dist/layout/apply.js +39 -14
- package/dist/layout/apply.js.map +1 -1
- package/dist/layout/arrange/boxes.d.ts.map +1 -1
- package/dist/layout/arrange/boxes.js +31 -0
- package/dist/layout/arrange/boxes.js.map +1 -1
- package/dist/layout/flow-edges.d.ts +26 -0
- package/dist/layout/flow-edges.d.ts.map +1 -0
- package/dist/layout/flow-edges.js +105 -0
- package/dist/layout/flow-edges.js.map +1 -0
- package/dist/layout/grid.d.ts.map +1 -1
- package/dist/layout/grid.js +9 -5
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/text-auto-resize.d.ts.map +1 -1
- package/dist/layout/text-auto-resize.js +9 -4
- package/dist/layout/text-auto-resize.js.map +1 -1
- package/dist/layout/text-measurement.d.ts +15 -1
- package/dist/layout/text-measurement.d.ts.map +1 -1
- package/dist/layout/text-measurement.js +40 -4
- package/dist/layout/text-measurement.js.map +1 -1
- package/dist/layout/variables.d.ts +1 -1
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +35 -35
- package/dist/layout.js.map +1 -1
- package/dist/library/asset-keys.d.ts +3 -2
- package/dist/library/asset-keys.d.ts.map +1 -1
- package/dist/library/asset-keys.js +4 -3
- package/dist/library/asset-keys.js.map +1 -1
- package/dist/library/copied-references.d.ts +8 -3
- package/dist/library/copied-references.d.ts.map +1 -1
- package/dist/library/copied-references.js +15 -5
- package/dist/library/copied-references.js.map +1 -1
- package/dist/library/materialize.js +1 -1
- package/dist/library/materialize.js.map +1 -1
- package/dist/library/schema.js.map +1 -1
- package/dist/library/snapshot.d.ts.map +1 -1
- package/dist/library/snapshot.js +10 -2
- package/dist/library/snapshot.js.map +1 -1
- package/dist/pairdraw-api/variables.d.ts.map +1 -1
- package/dist/pairdraw-api/variables.js +0 -2
- package/dist/pairdraw-api/variables.js.map +1 -1
- package/dist/profiler/hud-controller.d.ts +4 -3
- package/dist/profiler/hud-controller.d.ts.map +1 -1
- package/dist/profiler/hud-controller.js +7 -5
- package/dist/profiler/hud-controller.js.map +1 -1
- package/dist/profiler/hud-renderer.d.ts +5 -2
- package/dist/profiler/hud-renderer.d.ts.map +1 -1
- package/dist/profiler/hud-renderer.js +8 -5
- package/dist/profiler/hud-renderer.js.map +1 -1
- package/dist/profiler/render-profiler.d.ts +3 -2
- package/dist/profiler/render-profiler.d.ts.map +1 -1
- package/dist/profiler/render-profiler.js +3 -2
- package/dist/profiler/render-profiler.js.map +1 -1
- package/dist/text/character-style.d.ts +11 -1
- package/dist/text/character-style.d.ts.map +1 -1
- package/dist/text/character-style.js +27 -5
- package/dist/text/character-style.js.map +1 -1
- package/dist/text/coverage.d.ts.map +1 -1
- package/dist/text/coverage.js +15 -16
- package/dist/text/coverage.js.map +1 -1
- package/dist/text/editor.d.ts.map +1 -1
- package/dist/text/editor.js +3 -8
- package/dist/text/editor.js.map +1 -1
- package/dist/text/fallbacks.d.ts +19 -2
- package/dist/text/fallbacks.d.ts.map +1 -1
- package/dist/text/fallbacks.js +63 -12
- package/dist/text/fallbacks.js.map +1 -1
- package/dist/text/font/catalog.d.ts +4 -0
- package/dist/text/font/catalog.d.ts.map +1 -1
- package/dist/text/font/catalog.js +8 -0
- package/dist/text/font/catalog.js.map +1 -1
- package/dist/text/font/collection.d.ts +13 -0
- package/dist/text/font/collection.d.ts.map +1 -0
- package/dist/text/font/collection.js +51 -0
- package/dist/text/font/collection.js.map +1 -0
- package/dist/text/font/faces.d.ts +2 -1
- package/dist/text/font/faces.d.ts.map +1 -1
- package/dist/text/font/faces.js +9 -5
- package/dist/text/font/faces.js.map +1 -1
- package/dist/text/font/glyphs.d.ts +14 -3
- package/dist/text/font/glyphs.d.ts.map +1 -1
- package/dist/text/font/glyphs.js +22 -5
- package/dist/text/font/glyphs.js.map +1 -1
- package/dist/text/font/local.js +2 -2
- package/dist/text/font/local.js.map +1 -1
- package/dist/text/font/manager.d.ts +36 -0
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +139 -19
- package/dist/text/font/manager.js.map +1 -1
- package/dist/text/font/style.d.ts +7 -2
- package/dist/text/font/style.d.ts.map +1 -1
- package/dist/text/font/style.js +31 -3
- package/dist/text/font/style.js.map +1 -1
- package/dist/text/index.d.ts +5 -4
- package/dist/text/index.js +5 -4
- package/dist/text/outlines.d.ts.map +1 -1
- package/dist/text/outlines.js +70 -70
- package/dist/text/outlines.js.map +1 -1
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +7 -1
- package/dist/text/prepare.js.map +1 -1
- package/dist/text/style-runs.d.ts +14 -2
- package/dist/text/style-runs.d.ts.map +1 -1
- package/dist/text/style-runs.js +22 -14
- package/dist/text/style-runs.js.map +1 -1
- package/dist/tools/analyze/overlaps/helpers.d.ts.map +1 -1
- package/dist/tools/analyze/overlaps/helpers.js +9 -1
- package/dist/tools/analyze/overlaps/helpers.js.map +1 -1
- package/dist/tools/analyze/overlaps/index.d.ts.map +1 -1
- package/dist/tools/analyze/overlaps/index.js +27 -5
- package/dist/tools/analyze/overlaps/index.js.map +1 -1
- package/dist/tools/codegen/component-map.js +3 -3
- package/dist/tools/codegen/component-map.js.map +1 -1
- package/dist/tools/create/basic.d.ts.map +1 -1
- package/dist/tools/create/basic.js +5 -4
- package/dist/tools/create/basic.js.map +1 -1
- package/dist/tools/create/html.d.ts.map +1 -1
- package/dist/tools/create/html.js +4 -2
- package/dist/tools/create/html.js.map +1 -1
- package/dist/tools/create/icons.d.ts.map +1 -1
- package/dist/tools/create/icons.js +3 -1
- package/dist/tools/create/icons.js.map +1 -1
- package/dist/tools/create/mermaid.d.ts.map +1 -1
- package/dist/tools/create/mermaid.js +2 -0
- package/dist/tools/create/mermaid.js.map +1 -1
- package/dist/tools/create/render.d.ts.map +1 -1
- package/dist/tools/create/render.js +2 -0
- package/dist/tools/create/render.js.map +1 -1
- package/dist/tools/create/script.js +3 -1
- package/dist/tools/create/script.js.map +1 -1
- package/dist/tools/create/svg.d.ts.map +1 -1
- package/dist/tools/create/svg.js +4 -1
- package/dist/tools/create/svg.js.map +1 -1
- package/dist/tools/create/vector.d.ts.map +1 -1
- package/dist/tools/create/vector.js +4 -4
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/image-ai/apply.js +1 -1
- package/dist/tools/image-ai/generate.d.ts.map +1 -1
- package/dist/tools/image-ai/generate.js +3 -0
- package/dist/tools/image-ai/generate.js.map +1 -1
- package/dist/tools/modify/matching.js +1 -1
- package/dist/tools/modify/reactions.d.ts +6 -0
- package/dist/tools/modify/reactions.d.ts.map +1 -0
- package/dist/tools/modify/reactions.js +35 -0
- package/dist/tools/modify/reactions.js.map +1 -0
- package/dist/tools/modify.d.ts +2 -1
- package/dist/tools/modify.js +2 -1
- package/dist/tools/read/components.js +20 -22
- package/dist/tools/read/components.js.map +1 -1
- package/dist/tools/read/fonts.js +1 -1
- package/dist/tools/read/fonts.js.map +1 -1
- package/dist/tools/read/libraries.d.ts.map +1 -1
- package/dist/tools/read/libraries.js +2 -0
- package/dist/tools/read/libraries.js.map +1 -1
- package/dist/tools/read/nodes.d.ts.map +1 -1
- package/dist/tools/read/nodes.js +38 -16
- package/dist/tools/read/nodes.js.map +1 -1
- package/dist/tools/read/pages.d.ts.map +1 -1
- package/dist/tools/read/pages.js +4 -3
- package/dist/tools/read/pages.js.map +1 -1
- package/dist/tools/read/query.js +1 -0
- package/dist/tools/read/query.js.map +1 -1
- package/dist/tools/read/reactions.d.ts +6 -0
- package/dist/tools/read/reactions.d.ts.map +1 -0
- package/dist/tools/read/reactions.js +24 -0
- package/dist/tools/read/reactions.js.map +1 -0
- package/dist/tools/read/space.js +1 -1
- package/dist/tools/read.d.ts +2 -1
- package/dist/tools/read.js +2 -1
- package/dist/tools/registry/extended.d.ts.map +1 -1
- package/dist/tools/registry/extended.js +4 -0
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +6 -0
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +53 -9
- package/dist/tools/schema.js.map +1 -1
- package/dist/tools/stock-photo/apply.js +8 -9
- package/dist/tools/stock-photo/apply.js.map +1 -1
- package/dist/tools/structure/batch.d.ts.map +1 -1
- package/dist/tools/structure/batch.js +85 -90
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/vector/fill-geometry.d.ts +4 -1
- package/dist/vector/fill-geometry.d.ts.map +1 -1
- package/dist/vector/fill-geometry.js +8 -5
- package/dist/vector/fill-geometry.js.map +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/vector/index.js.map +1 -1
- package/dist/vector/path-helpers.d.ts +1 -1
- package/dist/vector/path-helpers.d.ts.map +1 -1
- package/dist/vector/path-helpers.js +24 -7
- package/dist/vector/path-helpers.js.map +1 -1
- package/dist/vector/placement.js +1 -1
- package/dist/vector/placement.js.map +1 -1
- package/dist/vector/vectorize/preprocess.js +1 -1
- package/dist/vector/vectorize/preprocess.js.map +1 -1
- package/package.json +10 -10
- package/src/canvas/effects.ts +29 -33
- package/src/canvas/labels/hit-test.ts +6 -2
- package/src/canvas/labels/paragraph-cache.ts +2 -1
- package/src/canvas/labels/selection.ts +3 -3
- package/src/canvas/node-edit-overlay.ts +3 -2
- package/src/canvas/overlays/index.ts +0 -1
- package/src/canvas/overlays/selection.ts +4 -52
- package/src/canvas/region-hatch.ts +7 -2
- package/src/canvas/renderer/colors.ts +41 -26
- package/src/canvas/renderer/font-waiters.ts +25 -0
- package/src/canvas/renderer/fonts.ts +40 -17
- package/src/canvas/renderer/lifecycle.ts +8 -10
- package/src/canvas/renderer/methods.ts +9 -13
- package/src/canvas/renderer/paints.ts +0 -10
- package/src/canvas/renderer/pipeline.ts +29 -3
- package/src/canvas/renderer/retained-backing.ts +4 -4
- package/src/canvas/renderer/state.ts +1 -1
- package/src/canvas/renderer/tiles/controller.ts +8 -0
- package/src/canvas/renderer/tiles/surface-pool.ts +1 -1
- package/src/canvas/renderer/visual-bounds.ts +7 -6
- package/src/canvas/renderer.ts +39 -11
- package/src/canvas/rulers.ts +55 -26
- package/src/canvas/scene.ts +37 -16
- package/src/canvas/shadows/shape.ts +1 -1
- package/src/canvas/shadows/silhouette.ts +4 -2
- package/src/canvas/shadows.ts +4 -2
- package/src/canvas/text/derived.ts +0 -9
- package/src/canvas/text/emoji/raster.ts +14 -10
- package/src/canvas/text/font-families.ts +6 -0
- package/src/canvas/text/index.ts +0 -8
- package/src/canvas/text/layout/build.ts +35 -18
- package/src/canvas/text/layout/index.ts +15 -6
- package/src/canvas/text/layout/lines.ts +10 -4
- package/src/canvas/text/paragraph/index.ts +17 -8
- package/src/canvas/text/paragraph/inputs.ts +4 -2
- package/src/canvas/text/shape.ts +20 -31
- package/src/constants.ts +6 -1
- package/src/editor/bridges/clipboard.ts +1 -0
- package/src/editor/bridges/components.ts +2 -0
- package/src/editor/bridges/frames.ts +6 -4
- package/src/editor/bridges/structure.ts +1 -0
- package/src/editor/clipboard/detach.ts +3 -3
- package/src/editor/clipboard/paste/target.ts +2 -2
- package/src/editor/clipboard/snapshot.ts +7 -0
- package/src/editor/clipboard/variables.ts +20 -0
- package/src/editor/clipboard.ts +133 -14
- package/src/editor/component-sync.ts +28 -7
- package/src/editor/components/authoring/text-edit.ts +15 -2
- package/src/editor/components/authoring/visibility-edit.ts +11 -3
- package/src/editor/components/instances.ts +61 -11
- package/src/editor/components/properties.ts +10 -0
- package/src/editor/components/slots/authoring.ts +4 -1
- package/src/editor/create.ts +58 -8
- package/src/editor/guides.ts +27 -12
- package/src/editor/history/document-change.ts +115 -7
- package/src/editor/history/edit.ts +62 -14
- package/src/editor/history/position.ts +1 -4
- package/src/editor/history/sources.ts +25 -0
- package/src/editor/index.ts +3 -1
- package/src/editor/layout-mode.ts +20 -1
- package/src/editor/node-preview.ts +44 -8
- package/src/editor/nodes.ts +52 -12
- package/src/editor/nudge.ts +16 -2
- package/src/editor/pages.ts +100 -17
- package/src/editor/play/states.ts +0 -7
- package/src/editor/read-only/actions.ts +4 -0
- package/src/editor/selection/hit-test.ts +37 -4
- package/src/editor/shapes/pen.ts +6 -3
- package/src/editor/shapes.ts +2 -1
- package/src/editor/structure/auto-layout-wrap.ts +26 -0
- package/src/editor/structure/group/bounds.ts +22 -4
- package/src/editor/structure/rename.ts +2 -6
- package/src/editor/structure/reorder.ts +26 -8
- package/src/editor/structure.ts +88 -24
- package/src/editor/text/hyperlink.ts +2 -1
- package/src/editor/text/name.ts +51 -15
- package/src/editor/text/pending-layout.ts +42 -4
- package/src/editor/text/selection-style.ts +17 -3
- package/src/editor/text.ts +86 -4
- package/src/editor/types.ts +19 -0
- package/src/editor/undo.ts +21 -2
- package/src/editor/variable-bindings.ts +22 -2
- package/src/editor/variables.ts +10 -6
- package/src/editor/viewport.ts +55 -21
- package/src/editor/views/actions.ts +17 -7
- package/src/editor/views/present.ts +20 -11
- package/src/editor/views/types.ts +11 -5
- package/src/figma-api/accessor-utils.ts +4 -1
- package/src/figma-api/accessors/basic.ts +54 -18
- package/src/figma-api/accessors/layout.ts +46 -7
- package/src/figma-api/accessors/reactions.ts +29 -0
- package/src/figma-api/accessors/strokes.ts +28 -8
- package/src/figma-api/accessors/text/index.ts +4 -0
- package/src/figma-api/accessors/vector.ts +3 -1
- package/src/figma-api/accessors/visual.ts +25 -28
- package/src/figma-api/components.ts +9 -7
- package/src/figma-api/finite.ts +102 -0
- package/src/figma-api/fonts/list.ts +24 -0
- package/src/figma-api/index.ts +82 -12
- package/src/figma-api/overrides.ts +1 -1
- package/src/figma-api/pending-layout.ts +50 -1
- package/src/figma-api/pending-sync.ts +61 -0
- package/src/figma-api/proxy.ts +35 -2
- package/src/figma-api/reactions.ts +212 -0
- package/src/figma-api/render-bounds.ts +13 -4
- package/src/figma-api/serialization.ts +2 -2
- package/src/figma-api/slots.ts +12 -3
- package/src/figma-api/strokes.ts +16 -12
- package/src/figma-api/text/index.ts +9 -15
- package/src/figma-api/variables/variable.ts +3 -2
- package/src/geometry/figma.ts +9 -0
- package/src/geometry/index.ts +1 -0
- package/src/global.d.ts +6 -0
- package/src/icons/api.ts +27 -16
- package/src/icons/provider.ts +9 -20
- package/src/icons/schema.ts +31 -0
- package/src/icons/svg/presentation.ts +27 -3
- package/src/icons/svg/text.ts +1 -1
- package/src/icons/svg.ts +21 -19
- package/src/icons/types.ts +0 -14
- package/src/io/formats/design-tokens/plan/index.ts +7 -1
- package/src/io/formats/design-tokens/plan/styles.ts +40 -4
- package/src/io/formats/design-tokens/styles.ts +60 -3
- package/src/io/formats/design-tokens/types.ts +3 -0
- package/src/io/formats/fig/export/setup.ts +16 -14
- package/src/io/formats/fig/export/variables.ts +7 -8
- package/src/io/formats/fig/index.ts +1 -0
- package/src/io/formats/fig/read.ts +66 -23
- package/src/io/formats/html/index.ts +2 -6
- package/src/io/formats/pdf/dom.ts +96 -3
- package/src/io/formats/pen/fonts.ts +45 -0
- package/src/io/formats/pen/index.ts +30 -6
- package/src/io/formats/raster/headless.ts +31 -12
- package/src/io/formats/raster/index.ts +3 -0
- package/src/io/formats/raster/render.ts +62 -6
- package/src/io/formats/svg/export.ts +24 -25
- package/src/io/formats/svg/paths.ts +11 -2
- package/src/io/formats/svg/strokes.ts +8 -2
- package/src/io/formats/svg/text/export.ts +23 -0
- package/src/io/formats/svg/text/import.ts +2 -1
- package/src/io/subgraph.ts +3 -1
- package/src/kiwi/fig/population/client.ts +77 -43
- package/src/kiwi/fig/population/delta.ts +141 -18
- package/src/kiwi/fig/population/edits.ts +235 -0
- package/src/kiwi/fig/session/archive/access.ts +15 -0
- package/src/kiwi/fig/session/archive/changes.ts +27 -6
- package/src/kiwi/fig/session/document-state.ts +23 -1
- package/src/kiwi/fig/session/protocol.ts +26 -1
- package/src/kiwi/fig/session/worker.ts +38 -11
- package/src/layout/apply.ts +52 -10
- package/src/layout/arrange/boxes.ts +36 -0
- package/src/layout/flow-edges.ts +139 -0
- package/src/layout/grid.ts +14 -4
- package/src/layout/text-auto-resize.ts +13 -4
- package/src/layout/text-measurement.ts +46 -3
- package/src/layout.ts +60 -66
- package/src/library/asset-keys.ts +4 -3
- package/src/library/copied-references.ts +29 -5
- package/src/library/materialize.ts +1 -1
- package/src/library/schema.ts +1 -1
- package/src/library/snapshot.ts +11 -2
- package/src/pairdraw-api/variables.ts +1 -3
- package/src/profiler/hud-controller.ts +8 -6
- package/src/profiler/hud-renderer.ts +9 -6
- package/src/profiler/render-profiler.ts +4 -3
- package/src/text/character-style.ts +29 -9
- package/src/text/coverage.ts +17 -18
- package/src/text/editor.ts +3 -8
- package/src/text/fallbacks.ts +82 -15
- package/src/text/font/catalog.ts +10 -0
- package/src/text/font/collection.ts +60 -0
- package/src/text/font/faces.ts +9 -5
- package/src/text/font/glyphs.ts +29 -4
- package/src/text/font/local.ts +2 -2
- package/src/text/font/manager.ts +170 -32
- package/src/text/font/style.ts +52 -3
- package/src/text/index.ts +1 -0
- package/src/text/outlines.ts +105 -89
- package/src/text/prepare.ts +17 -0
- package/src/text/style-runs.ts +43 -16
- package/src/tools/analyze/overlaps/helpers.ts +18 -1
- package/src/tools/analyze/overlaps/index.ts +37 -6
- package/src/tools/codegen/component-map.ts +3 -3
- package/src/tools/create/basic.ts +6 -4
- package/src/tools/create/html.ts +3 -1
- package/src/tools/create/icons.ts +3 -1
- package/src/tools/create/mermaid.ts +2 -0
- package/src/tools/create/render.ts +2 -0
- package/src/tools/create/script.ts +5 -1
- package/src/tools/create/svg.ts +4 -1
- package/src/tools/create/vector.ts +4 -4
- package/src/tools/image-ai/generate.ts +3 -0
- package/src/tools/modify/reactions.ts +40 -0
- package/src/tools/modify.ts +1 -0
- package/src/tools/read/components.ts +28 -25
- package/src/tools/read/fonts.ts +1 -1
- package/src/tools/read/libraries.ts +3 -0
- package/src/tools/read/nodes.ts +47 -17
- package/src/tools/read/pages.ts +7 -4
- package/src/tools/read/query.ts +2 -0
- package/src/tools/read/reactions.ts +21 -0
- package/src/tools/read.ts +1 -0
- package/src/tools/registry/extended.ts +4 -0
- package/src/tools/schema.ts +68 -12
- package/src/tools/stock-photo/apply.ts +17 -5
- package/src/tools/structure/batch.ts +82 -101
- package/src/vector/fill-geometry.ts +11 -5
- package/src/vector/index.ts +1 -1
- package/src/vector/path-helpers.ts +34 -8
- package/src/vector/placement.ts +1 -1
- package/src/vector/vectorize/preprocess.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/canvas/text/paragraph/index.ts"],"sourcesContent":["import type {\n CanvasKit,\n FontStyle,\n Paint,\n Paragraph,\n ParagraphBuilder,\n TextFontFeatures,\n TextFontVariations,\n TextHeightBehavior\n} from 'canvaskit-wasm'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { resolveRGBAForPreview } from '@pairdraw/scene-graph/color'\nimport { faceStyleKey, type NamedFace } from '@pairdraw/scene-graph/font-style'\nimport { rangeFontStyle } from '@pairdraw/scene-graph/shared-styles'\nimport { lineHeightPixels, textLengthPixels } from '@pairdraw/scene-graph/text'\nimport { resolveNodeTextDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport {\n drawnFontVariations,\n loadedFace,\n resolveParagraphFontFamilies\n} from '#core/canvas/text/font-families'\nimport { laidOutText } from '#core/canvas/text/keycap'\nimport {\n pushParagraphStyle,\n type ParagraphPaintStyle,\n type ParagraphBuildOptions\n} from '#core/canvas/text/paint'\nimport type { TextRenderer } from '#core/canvas/text/renderer'\nimport { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE } from '#core/constants'\nimport { shownTextSlice } from '#core/text/case'\nimport { ELLIPSIS } from '#core/text/ellipsis'\nimport { fontManager } from '#core/text/font/manager'\n\nimport type { ParagraphNode } from './inputs'\n\nexport function resolveParagraphLayoutWidth(node: ParagraphNode, maxWidth?: number): number {\n if (maxWidth !== undefined) return maxWidth\n if (node.textAutoResize === 'WIDTH_AND_HEIGHT') return 1e6\n return node.width || 1e6\n}\n\nexport function buildTruncateOpts(node: ParagraphNode): { maxLines?: number; ellipsis?: string } {\n if (node.textTruncation !== 'ENDING') return {}\n\n const opts: { maxLines?: number; ellipsis: string } = { ellipsis: ELLIPSIS }\n if (node.maxLines != null && node.maxLines > 0) {\n opts.maxLines = node.maxLines\n }\n return opts\n}\n\nfunction getParagraphTextAlign(\n ck: CanvasKit,\n node: Pick<SceneNode, 'textAlignHorizontal' | 'textDirection' | 'text'>\n) {\n const direction = resolveNodeTextDirection(node)\n switch (node.textAlignHorizontal) {\n case 'CENTER':\n return ck.TextAlign.Center\n case 'RIGHT':\n return direction === 'RTL' ? ck.TextAlign.Left : ck.TextAlign.Right\n case 'JUSTIFIED':\n return ck.TextAlign.Justify\n default:\n return direction === 'RTL' ? ck.TextAlign.Right : ck.TextAlign.Left\n }\n}\n\n/** Explicit axes win over the named-instance axes of a variable face (`implicit`). */\nexport function textFontVariations(\n variations: SceneNode['fontVariations'] | undefined,\n implicit: SceneNode['fontVariations'] | null = null\n): TextFontVariations[] | undefined {\n const explicitAxes = new Set(variations?.map((variation) => variation.axis))\n const merged = [\n ...(implicit ?? []).filter((variation) => !explicitAxes.has(variation.axis)),\n ...(variations ?? [])\n ]\n if (merged.length === 0) return undefined\n return merged.map((variation) => ({ axis: variation.axis, value: variation.value }))\n}\n\nexport function textFontFeatures(\n features: SceneNode['fontFeatures'] | undefined\n): TextFontFeatures[] | undefined {\n if (!features || features.length === 0) return undefined\n return features.map((feature) => ({\n name: feature.tag.toLowerCase(),\n value: feature.enabled ? 1 : 0\n }))\n}\n\nexport function textHeightBehaviorValue<T>(\n ck: { TextHeightBehavior: { DisableAll: T } },\n leadingTrim: SceneNode['leadingTrim']\n): T | undefined {\n return leadingTrim === 'CAP_HEIGHT' ? ck.TextHeightBehavior.DisableAll : undefined\n}\n\n/** Which edges of the text a paragraph is: leading trim only trims the text's own edges. */\nexport interface ParagraphEdges {\n first: boolean\n last: boolean\n}\n\nfunction blockHeightBehavior(\n ck: CanvasKit,\n leadingTrim: SceneNode['leadingTrim'],\n edges: ParagraphEdges | undefined\n): TextHeightBehavior | undefined {\n if (!edges) return textHeightBehaviorValue(ck, leadingTrim)\n const { first, last } = edges\n if (leadingTrim !== 'CAP_HEIGHT') return undefined\n if (first && last) return ck.TextHeightBehavior.DisableAll\n if (first) return ck.TextHeightBehavior.DisableFirstAscent\n if (last) return ck.TextHeightBehavior.DisableLastDescent\n return ck.TextHeightBehavior.All\n}\n\n/**\n * The style a paragraph asks CanvasKit for: the face of the family that is loaded. Asked for a\n * face it lacks, CanvasKit slants and emboldens another, which neither Figma, a browser, nor a\n * native text stack draws the same, so a missing face is drawn as the face that exists and\n * reported missing, as Figma does. A family with no face loaded asks for the style as given.\n */\nfunction drawnFontStyle(\n ck: CanvasKit,\n family: string,\n weight: number,\n italic: boolean,\n style: string\n): FontStyle {\n const face = loadedFace(family, weight, italic, style) ?? { weight, italic }\n return {\n weight: { value: face.weight },\n slant: face.italic ? ck.FontSlant.Italic : ck.FontSlant.Upright\n }\n}\n\n/** The colour a style run's text is drawn in: its first visible solid fill, or `baseColor`. */\nexport function styleRunColor(\n ck: CanvasKit,\n style: SceneNode['styleRuns'][number]['style'],\n baseColor: Float32Array\n): Float32Array {\n const visibleFill = style.fills?.find((fill) => fill.visible && fill.type === 'SOLID')\n if (!visibleFill) return baseColor\n const color = resolveRGBAForPreview(visibleFill.color).color\n return ck.Color4f(color.r, color.g, color.b, color.a * visibleFill.opacity)\n}\n\nfunction styleRunLanguage(\n style: SceneNode['styleRuns'][number]['style'],\n node: Pick<ParagraphNode, 'textLanguage'>\n): string | undefined {\n return (style.textLanguage !== undefined ? style.textLanguage : node.textLanguage) ?? undefined\n}\n\nfunction pushStyleRun(\n r: TextRenderer,\n builder: ParagraphBuilder,\n node: ParagraphNode,\n run: SceneNode['styleRuns'][number],\n baseColor: Float32Array,\n baseFontSize: number,\n fontFamilies: (primary: string, face: NamedFace) => string[],\n halfLeading: boolean,\n paintStyle?: ParagraphPaintStyle\n): void {\n const ck = r.ck\n const style = run.style\n const runFontSize = style.fontSize ?? baseFontSize\n // A percent follows the run's own font size, as in Figma.\n const runLineHeight = lineHeightPixels(\n style.lineHeight !== undefined ? style.lineHeight : node.lineHeight,\n runFontSize\n )\n const runFamily = style.fontFamily ?? (node.fontFamily || DEFAULT_FONT_FAMILY)\n const runWeight = style.fontWeight ?? node.fontWeight\n const runItalic = style.italic ?? node.italic\n const runFace = {\n fontWeight: runWeight,\n italic: runItalic,\n fontStyle: rangeFontStyle(node, style)\n }\n const runKey = faceStyleKey(runFace)\n\n const textStyle = new ck.TextStyle({\n color: styleRunColor(ck, style, baseColor),\n fontFamilies: fontFamilies(runFamily, runFace),\n fontSize: runFontSize,\n locale: styleRunLanguage(style, node),\n fontStyle: drawnFontStyle(ck, runFamily, runWeight, runItalic, runKey),\n fontVariations: textFontVariations(\n drawnFontVariations({\n family: runFamily,\n weight: runWeight,\n italic: runItalic,\n style: runKey,\n fontSize: runFontSize,\n variations: style.fontVariations ?? node.fontVariations,\n opticalSizeFromFontSize: style.opticalSizeFromFontSize ?? node.opticalSizeFromFontSize\n })\n ),\n fontFeatures: textFontFeatures(style.fontFeatures ?? node.fontFeatures),\n letterSpacing: textLengthPixels(style.letterSpacing ?? node.letterSpacing, runFontSize),\n heightMultiplier: runLineHeight ? runLineHeight / runFontSize : undefined,\n halfLeading\n })\n pushParagraphStyle(builder, textStyle, paintStyle)\n}\n\n/** `text[start, end)` in the case each of its characters has. */\nfunction addParagraphText(\n builder: ParagraphBuilder,\n node: ParagraphNode,\n start: number,\n end: number\n): void {\n builder.addText(laidOutText(shownTextSlice(node, start, end)))\n}\n\nfunction addStyledRuns(\n r: TextRenderer,\n builder: ParagraphBuilder,\n node: ParagraphNode,\n baseColor: Float32Array,\n baseFontSize: number,\n fontFamilies: (primary: string, face: NamedFace) => string[],\n halfLeading: boolean,\n paintStyle?: ParagraphPaintStyle\n): void {\n const text = node.text\n let pos = 0\n\n for (const run of node.styleRuns) {\n if (pos < run.start) addParagraphText(builder, node, pos, run.start)\n pushStyleRun(\n r,\n builder,\n node,\n run,\n baseColor,\n baseFontSize,\n fontFamilies,\n halfLeading,\n paintStyle\n )\n addParagraphText(builder, node, run.start, run.start + run.length)\n builder.pop()\n pos = run.start + run.length\n }\n\n if (pos < text.length) addParagraphText(builder, node, pos, text.length)\n}\n\n/** What a paragraph that is one block of a longer text needs beyond its node's own style. */\nexport interface ParagraphBlockOptions {\n /** Room before the first line, as a plain paragraph's first-line indent. */\n firstLineIndent?: number\n /** Truncation for this block in place of the node's. */\n truncation?: { maxLines?: number; ellipsis?: string }\n edges?: ParagraphEdges\n}\n\n/** Room before a paragraph's first line, as an empty placeholder on its baseline. */\nfunction addFirstLineIndent(ck: CanvasKit, builder: ParagraphBuilder, width: number): void {\n builder.addPlaceholder(width, 0, ck.PlaceholderAlignment.Baseline, ck.TextBaseline.Alphabetic, 0)\n}\n\n/**\n * A native paragraph for `node`'s text in its style runs, not yet laid out. A first-line\n * indent is a placeholder before the text, which takes the first character index.\n */\nexport function buildSkParagraph(\n r: TextRenderer,\n node: ParagraphNode,\n color?: Float32Array,\n { halfLeading = false, foregroundPaint }: ParagraphBuildOptions = {},\n block: ParagraphBlockOptions = {}\n): Paragraph {\n const ck = r.ck\n const baseColor = color ?? ck.BLACK\n const baseFontSize = node.fontSize || DEFAULT_FONT_SIZE\n const baseLineHeight = lineHeightPixels(node.lineHeight, baseFontSize)\n const cjkFallbacks = fontManager.getCJKFallbackFamilies()\n const letterFallbacks = fontManager.getLetterFallbackFamilies()\n const textDirection = resolveNodeTextDirection(node)\n\n const truncateOpts = block.truncation ?? buildTruncateOpts(node)\n\n const fontFamilies = (primary: string, face: NamedFace) =>\n resolveParagraphFontFamilies(\n primary,\n { weight: face.fontWeight, italic: face.italic, style: faceStyleKey(face) },\n letterFallbacks,\n cjkFallbacks\n )\n const nodeKey = faceStyleKey(node)\n\n const baseTextStyle = {\n color: baseColor,\n fontFamilies: fontFamilies(node.fontFamily || DEFAULT_FONT_FAMILY, node),\n fontSize: baseFontSize,\n locale: node.textLanguage ?? undefined,\n fontStyle: drawnFontStyle(\n ck,\n node.fontFamily || DEFAULT_FONT_FAMILY,\n node.fontWeight,\n node.italic,\n nodeKey\n ),\n fontVariations: textFontVariations(\n drawnFontVariations({\n family: node.fontFamily || DEFAULT_FONT_FAMILY,\n weight: node.fontWeight,\n italic: node.italic,\n style: nodeKey,\n fontSize: baseFontSize,\n variations: node.fontVariations,\n opticalSizeFromFontSize: node.opticalSizeFromFontSize\n })\n ),\n fontFeatures: textFontFeatures(node.fontFeatures),\n letterSpacing: textLengthPixels(node.letterSpacing, baseFontSize),\n heightMultiplier: baseLineHeight ? baseLineHeight / baseFontSize : undefined,\n halfLeading\n }\n const paraStyle = new ck.ParagraphStyle({\n textAlign: getParagraphTextAlign(ck, node),\n textDirection: textDirection === 'RTL' ? ck.TextDirection.RTL : ck.TextDirection.LTR,\n textHeightBehavior: blockHeightBehavior(ck, node.leadingTrim, block.edges),\n ...truncateOpts,\n textStyle: baseTextStyle\n })\n\n if (!r.fontProvider) throw new Error('Font provider not initialized')\n const builder = ck.ParagraphBuilder.MakeFromFontProvider(paraStyle, r.fontProvider)\n\n let background: Paint | undefined\n try {\n let paintStyle: ParagraphPaintStyle | undefined\n if (foregroundPaint) {\n background = new ck.Paint()\n background.setColor(ck.TRANSPARENT)\n paintStyle = { foreground: foregroundPaint, background }\n builder.pushPaintStyle(new ck.TextStyle(baseTextStyle), foregroundPaint, background)\n }\n if (block.firstLineIndent) addFirstLineIndent(ck, builder, block.firstLineIndent)\n if (node.styleRuns.length === 0) {\n addParagraphText(builder, node, 0, node.text.length)\n } else {\n addStyledRuns(\n r,\n builder,\n node,\n baseColor,\n baseFontSize,\n fontFamilies,\n halfLeading,\n paintStyle\n )\n }\n\n return builder.build()\n } finally {\n builder.delete()\n background?.delete()\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAqCA,SAAgB,4BAA4B,MAAqB,UAA2B;CAC1F,IAAI,aAAa,KAAA,GAAW,OAAO;CACnC,IAAI,KAAK,mBAAmB,oBAAoB,OAAO;CACvD,OAAO,KAAK,SAAS;AACvB;AAEA,SAAgB,kBAAkB,MAA+D;CAC/F,IAAI,KAAK,mBAAmB,UAAU,OAAO,CAAC;CAE9C,MAAM,OAAgD,EAAE,UAAA,IAAmB;CAC3E,IAAI,KAAK,YAAY,QAAQ,KAAK,WAAW,GAC3C,KAAK,WAAW,KAAK;CAEvB,OAAO;AACT;AAEA,SAAS,sBACP,IACA,MACA;CACA,MAAM,YAAY,yBAAyB,IAAI;CAC/C,QAAQ,KAAK,qBAAb;EACE,KAAK,UACH,OAAO,GAAG,UAAU;EACtB,KAAK,SACH,OAAO,cAAc,QAAQ,GAAG,UAAU,OAAO,GAAG,UAAU;EAChE,KAAK,aACH,OAAO,GAAG,UAAU;EACtB,SACE,OAAO,cAAc,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AM,eAAe;EAChF,IAAI,KAAK,UAAU,WAAW,GAC5B,iBAAiB,SAAS,MAAM,GAAG,KAAK,KAAK,MAAM;OAEnD,cACE,GACA,SACA,MACA,WACA,cACA,cACA,aACA,UACF;EAGF,OAAO,QAAQ,MAAM;CACvB,UAAU;EACR,QAAQ,OAAO;EACf,YAAY,OAAO;CACrB;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/canvas/text/paragraph/index.ts"],"sourcesContent":["import type {\n CanvasKit,\n FontStyle,\n Paint,\n Paragraph,\n ParagraphBuilder,\n TextFontFeatures,\n TextFontVariations,\n TextHeightBehavior\n} from 'canvaskit-wasm'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { resolveRGBAForPreview } from '@pairdraw/scene-graph/color'\nimport { faceStyleKey, type NamedFace } from '@pairdraw/scene-graph/font-style'\nimport { rangeFontStyle } from '@pairdraw/scene-graph/shared-styles'\nimport { lineHeightPixels, textLengthPixels } from '@pairdraw/scene-graph/text'\nimport { resolveNodeTextDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport {\n drawnFontVariations,\n loadedFace,\n resolveParagraphFontFamilies\n} from '#core/canvas/text/font-families'\nimport { laidOutText } from '#core/canvas/text/keycap'\nimport {\n pushParagraphStyle,\n type ParagraphPaintStyle,\n type ParagraphBuildOptions\n} from '#core/canvas/text/paint'\nimport type { TextRenderer } from '#core/canvas/text/renderer'\nimport { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE } from '#core/constants'\nimport { autoWidthWrapWidth } from '#core/layout/text-measurement'\nimport { shownTextSlice } from '#core/text/case'\nimport { ELLIPSIS } from '#core/text/ellipsis'\nimport { makeParagraphBuilder } from '#core/text/font/collection'\nimport { fontManager } from '#core/text/font/manager'\n\nimport type { ParagraphNode } from './inputs'\n\nexport function resolveParagraphLayoutWidth(node: ParagraphNode, maxWidth?: number): number {\n if (maxWidth !== undefined) return maxWidth\n if (node.textAutoResize === 'WIDTH_AND_HEIGHT') {\n return autoWidthWrapWidth(node) ?? 1e6\n }\n return node.width || 1e6\n}\n\n/**\n * The lines a truncating box shows: what `maxLines` allows, else as many as its height holds, as\n * Figma keeps the last and ends it with an ellipsis. A text box set to truncate truncates even\n * where nothing turned on `textTruncation`, which is how the auto-resize mode is chosen.\n */\nexport function buildTruncateOpts(node: ParagraphNode): { maxLines?: number; ellipsis?: string } {\n if (node.textTruncation !== 'ENDING' && node.textAutoResize !== 'TRUNCATE') return {}\n // A box that truncates only by its height is measured as it is, then capped by the lines that\n // fit and built again with that count.\n if (node.maxLines == null || node.maxLines <= 0) {\n return node.textAutoResize === 'TRUNCATE' ? {} : { ellipsis: ELLIPSIS }\n }\n return { maxLines: node.maxLines, ellipsis: ELLIPSIS }\n}\n\nfunction getParagraphTextAlign(\n ck: CanvasKit,\n node: Pick<SceneNode, 'textAlignHorizontal' | 'textDirection' | 'text'>\n) {\n const direction = resolveNodeTextDirection(node)\n switch (node.textAlignHorizontal) {\n case 'CENTER':\n return ck.TextAlign.Center\n case 'RIGHT':\n return direction === 'RTL' ? ck.TextAlign.Left : ck.TextAlign.Right\n case 'JUSTIFIED':\n return ck.TextAlign.Justify\n default:\n return direction === 'RTL' ? ck.TextAlign.Right : ck.TextAlign.Left\n }\n}\n\n/** Explicit axes win over the named-instance axes of a variable face (`implicit`). */\nexport function textFontVariations(\n variations: SceneNode['fontVariations'] | undefined,\n implicit: SceneNode['fontVariations'] | null = null\n): TextFontVariations[] | undefined {\n const explicitAxes = new Set(variations?.map((variation) => variation.axis))\n const merged = [\n ...(implicit ?? []).filter((variation) => !explicitAxes.has(variation.axis)),\n ...(variations ?? [])\n ]\n if (merged.length === 0) return undefined\n return merged.map((variation) => ({ axis: variation.axis, value: variation.value }))\n}\n\nexport function textFontFeatures(\n features: SceneNode['fontFeatures'] | undefined\n): TextFontFeatures[] | undefined {\n if (!features || features.length === 0) return undefined\n return features.map((feature) => ({\n name: feature.tag.toLowerCase(),\n value: feature.enabled ? 1 : 0\n }))\n}\n\nexport function textHeightBehaviorValue<T>(\n ck: { TextHeightBehavior: { DisableAll: T } },\n leadingTrim: SceneNode['leadingTrim']\n): T | undefined {\n return leadingTrim === 'CAP_HEIGHT' ? ck.TextHeightBehavior.DisableAll : undefined\n}\n\n/** Which edges of the text a paragraph is: leading trim only trims the text's own edges. */\nexport interface ParagraphEdges {\n first: boolean\n last: boolean\n}\n\nfunction blockHeightBehavior(\n ck: CanvasKit,\n leadingTrim: SceneNode['leadingTrim'],\n edges: ParagraphEdges | undefined\n): TextHeightBehavior | undefined {\n if (!edges) return textHeightBehaviorValue(ck, leadingTrim)\n const { first, last } = edges\n if (leadingTrim !== 'CAP_HEIGHT') return undefined\n if (first && last) return ck.TextHeightBehavior.DisableAll\n if (first) return ck.TextHeightBehavior.DisableFirstAscent\n if (last) return ck.TextHeightBehavior.DisableLastDescent\n return ck.TextHeightBehavior.All\n}\n\n/**\n * The style a paragraph asks CanvasKit for: the face of the family that is loaded. Asked for a\n * face it lacks, CanvasKit slants and emboldens another, which neither Figma, a browser, nor a\n * native text stack draws the same, so a missing face is drawn as the face that exists and\n * reported missing, as Figma does. A family with no face loaded asks for the style as given.\n */\nfunction drawnFontStyle(\n ck: CanvasKit,\n family: string,\n weight: number,\n italic: boolean,\n style: string\n): FontStyle {\n const face = loadedFace(family, weight, italic, style) ?? { weight, italic }\n return {\n weight: { value: face.weight },\n slant: face.italic ? ck.FontSlant.Italic : ck.FontSlant.Upright\n }\n}\n\n/** The colour a style run's text is drawn in: its first visible solid fill, or `baseColor`. */\nexport function styleRunColor(\n ck: CanvasKit,\n style: SceneNode['styleRuns'][number]['style'],\n baseColor: Float32Array\n): Float32Array {\n const visibleFill = style.fills?.find((fill) => fill.visible && fill.type === 'SOLID')\n if (!visibleFill) return baseColor\n const color = resolveRGBAForPreview(visibleFill.color).color\n return ck.Color4f(color.r, color.g, color.b, color.a * visibleFill.opacity)\n}\n\nfunction styleRunLanguage(\n style: SceneNode['styleRuns'][number]['style'],\n node: Pick<ParagraphNode, 'textLanguage'>\n): string | undefined {\n return (style.textLanguage !== undefined ? style.textLanguage : node.textLanguage) ?? undefined\n}\n\nfunction pushStyleRun(\n r: TextRenderer,\n builder: ParagraphBuilder,\n node: ParagraphNode,\n run: SceneNode['styleRuns'][number],\n baseColor: Float32Array,\n baseFontSize: number,\n fontFamilies: (primary: string, face: NamedFace) => string[],\n halfLeading: boolean,\n paintStyle?: ParagraphPaintStyle\n): void {\n const ck = r.ck\n const style = run.style\n const runFontSize = style.fontSize ?? baseFontSize\n // A percent follows the run's own font size, as in Figma.\n const runLineHeight = lineHeightPixels(\n style.lineHeight !== undefined ? style.lineHeight : node.lineHeight,\n runFontSize\n )\n const runFamily = style.fontFamily ?? (node.fontFamily || DEFAULT_FONT_FAMILY)\n const runWeight = style.fontWeight ?? node.fontWeight\n const runItalic = style.italic ?? node.italic\n const runFace = {\n fontWeight: runWeight,\n italic: runItalic,\n fontStyle: rangeFontStyle(node, style)\n }\n const runKey = faceStyleKey(runFace)\n\n const textStyle = new ck.TextStyle({\n color: styleRunColor(ck, style, baseColor),\n fontFamilies: fontFamilies(runFamily, runFace),\n fontSize: runFontSize,\n locale: styleRunLanguage(style, node),\n fontStyle: drawnFontStyle(ck, runFamily, runWeight, runItalic, runKey),\n fontVariations: textFontVariations(\n drawnFontVariations({\n family: runFamily,\n weight: runWeight,\n italic: runItalic,\n style: runKey,\n fontSize: runFontSize,\n variations: style.fontVariations ?? node.fontVariations,\n opticalSizeFromFontSize: style.opticalSizeFromFontSize ?? node.opticalSizeFromFontSize\n })\n ),\n fontFeatures: textFontFeatures(style.fontFeatures ?? node.fontFeatures),\n letterSpacing: textLengthPixels(style.letterSpacing ?? node.letterSpacing, runFontSize),\n heightMultiplier: runLineHeight ? runLineHeight / runFontSize : undefined,\n halfLeading\n })\n pushParagraphStyle(builder, textStyle, paintStyle)\n}\n\n/** `text[start, end)` in the case each of its characters has. */\nfunction addParagraphText(\n builder: ParagraphBuilder,\n node: ParagraphNode,\n start: number,\n end: number\n): void {\n builder.addText(laidOutText(shownTextSlice(node, start, end)))\n}\n\nfunction addStyledRuns(\n r: TextRenderer,\n builder: ParagraphBuilder,\n node: ParagraphNode,\n baseColor: Float32Array,\n baseFontSize: number,\n fontFamilies: (primary: string, face: NamedFace) => string[],\n halfLeading: boolean,\n paintStyle?: ParagraphPaintStyle\n): void {\n const text = node.text\n let pos = 0\n\n for (const run of node.styleRuns) {\n if (pos < run.start) addParagraphText(builder, node, pos, run.start)\n pushStyleRun(\n r,\n builder,\n node,\n run,\n baseColor,\n baseFontSize,\n fontFamilies,\n halfLeading,\n paintStyle\n )\n addParagraphText(builder, node, run.start, run.start + run.length)\n builder.pop()\n pos = run.start + run.length\n }\n\n if (pos < text.length) addParagraphText(builder, node, pos, text.length)\n}\n\n/** What a paragraph that is one block of a longer text needs beyond its node's own style. */\nexport interface ParagraphBlockOptions {\n /** Room before the first line, as a plain paragraph's first-line indent. */\n firstLineIndent?: number\n /** Truncation for this block in place of the node's. */\n truncation?: { maxLines?: number; ellipsis?: string }\n edges?: ParagraphEdges\n}\n\n/** Room before a paragraph's first line, as an empty placeholder on its baseline. */\nfunction addFirstLineIndent(ck: CanvasKit, builder: ParagraphBuilder, width: number): void {\n builder.addPlaceholder(width, 0, ck.PlaceholderAlignment.Baseline, ck.TextBaseline.Alphabetic, 0)\n}\n\n/**\n * A native paragraph for `node`'s text in its style runs, not yet laid out. A first-line\n * indent is a placeholder before the text, which takes the first character index.\n */\nexport function buildSkParagraph(\n r: TextRenderer,\n node: ParagraphNode,\n color?: Float32Array,\n { halfLeading = false, foregroundPaint }: ParagraphBuildOptions = {},\n block: ParagraphBlockOptions = {}\n): Paragraph {\n const ck = r.ck\n const baseColor = color ?? ck.BLACK\n const baseFontSize = node.fontSize || DEFAULT_FONT_SIZE\n const baseLineHeight = lineHeightPixels(node.lineHeight, baseFontSize)\n const cjkFallbacks = fontManager.getCJKFallbackFamilies()\n const letterFallbacks = fontManager.getLetterFallbackFamilies()\n const textDirection = resolveNodeTextDirection(node)\n\n const truncateOpts = block.truncation ?? buildTruncateOpts(node)\n\n const fontFamilies = (primary: string, face: NamedFace) =>\n resolveParagraphFontFamilies(\n primary,\n { weight: face.fontWeight, italic: face.italic, style: faceStyleKey(face) },\n letterFallbacks,\n cjkFallbacks\n )\n const nodeKey = faceStyleKey(node)\n\n const baseTextStyle = {\n color: baseColor,\n fontFamilies: fontFamilies(node.fontFamily || DEFAULT_FONT_FAMILY, node),\n fontSize: baseFontSize,\n locale: node.textLanguage ?? undefined,\n fontStyle: drawnFontStyle(\n ck,\n node.fontFamily || DEFAULT_FONT_FAMILY,\n node.fontWeight,\n node.italic,\n nodeKey\n ),\n fontVariations: textFontVariations(\n drawnFontVariations({\n family: node.fontFamily || DEFAULT_FONT_FAMILY,\n weight: node.fontWeight,\n italic: node.italic,\n style: nodeKey,\n fontSize: baseFontSize,\n variations: node.fontVariations,\n opticalSizeFromFontSize: node.opticalSizeFromFontSize\n })\n ),\n fontFeatures: textFontFeatures(node.fontFeatures),\n letterSpacing: textLengthPixels(node.letterSpacing, baseFontSize),\n heightMultiplier: baseLineHeight ? baseLineHeight / baseFontSize : undefined,\n halfLeading\n }\n const paraStyle = new ck.ParagraphStyle({\n textAlign: getParagraphTextAlign(ck, node),\n textDirection: textDirection === 'RTL' ? ck.TextDirection.RTL : ck.TextDirection.LTR,\n textHeightBehavior: blockHeightBehavior(ck, node.leadingTrim, block.edges),\n ...truncateOpts,\n textStyle: baseTextStyle\n })\n\n if (!r.fontProvider) throw new Error('Font provider not initialized')\n const builder = makeParagraphBuilder(ck, paraStyle, r.fontProvider)\n\n let background: Paint | undefined\n try {\n let paintStyle: ParagraphPaintStyle | undefined\n if (foregroundPaint) {\n background = new ck.Paint()\n background.setColor(ck.TRANSPARENT)\n paintStyle = { foreground: foregroundPaint, background }\n builder.pushPaintStyle(new ck.TextStyle(baseTextStyle), foregroundPaint, background)\n }\n if (block.firstLineIndent) addFirstLineIndent(ck, builder, block.firstLineIndent)\n if (node.styleRuns.length === 0) {\n addParagraphText(builder, node, 0, node.text.length)\n } else {\n addStyledRuns(\n r,\n builder,\n node,\n baseColor,\n baseFontSize,\n fontFamilies,\n halfLeading,\n paintStyle\n )\n }\n\n return builder.build()\n } finally {\n builder.delete()\n background?.delete()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,SAAgB,4BAA4B,MAAqB,UAA2B;CAC1F,IAAI,aAAa,KAAA,GAAW,OAAO;CACnC,IAAI,KAAK,mBAAmB,oBAC1B,OAAO,mBAAmB,IAAI,KAAK;CAErC,OAAO,KAAK,SAAS;AACvB;;;;;;AAOA,SAAgB,kBAAkB,MAA+D;CAC/F,IAAI,KAAK,mBAAmB,YAAY,KAAK,mBAAmB,YAAY,OAAO,CAAC;CAGpF,IAAI,KAAK,YAAY,QAAQ,KAAK,YAAY,GAC5C,OAAO,KAAK,mBAAmB,aAAa,CAAC,IAAI,EAAE,UAAA,IAAmB;CAExE,OAAO;EAAE,UAAU,KAAK;EAAU,UAAA;CAAmB;AACvD;AAEA,SAAS,sBACP,IACA,MACA;CACA,MAAM,YAAY,yBAAyB,IAAI;CAC/C,QAAQ,KAAK,qBAAb;EACE,KAAK,UACH,OAAO,GAAG,UAAU;EACtB,KAAK,SACH,OAAO,cAAc,QAAQ,GAAG,UAAU,OAAO,GAAG,UAAU;EAChE,KAAK,aACH,OAAO,GAAG,UAAU;EACtB,SACE,OAAO,cAAc,QAAQ,GAAG,UAAU,QAAQ,GAAG,UAAU;CACnE;AACF;;AAGA,SAAgB,mBACd,YACA,WAA+C,MACb;CAClC,MAAM,eAAe,IAAI,IAAI,YAAY,KAAK,cAAc,UAAU,IAAI,CAAC;CAC3E,MAAM,SAAS,CACb,IAAI,YAAY,CAAC,EAAA,CAAG,QAAQ,cAAc,CAAC,aAAa,IAAI,UAAU,IAAI,CAAC,GAC3E,GAAI,cAAc,CAAC,CACrB;CACA,IAAI,OAAO,WAAW,GAAG,OAAO,KAAA;C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KAAK,QACL,OACF;EACA,gBAAgB,mBACd,oBAAoB;GAClB,QAAQ,KAAK,cAAA;GACb,QAAQ,KAAK;GACb,QAAQ,KAAK;GACb,OAAO;GACP,UAAU;GACV,YAAY,KAAK;GACjB,yBAAyB,KAAK;EAChC,CAAC,CACH;EACA,cAAc,iBAAiB,KAAK,YAAY;EAChD,eAAe,iBAAiB,KAAK,eAAe,YAAY;EAChE,kBAAkB,iBAAiB,iBAAiB,eAAe,KAAA;EACnE;CACF;CACA,MAAM,YAAY,IAAI,GAAG,eAAe;EACtC,WAAW,sBAAsB,IAAI,IAAI;EACzC,eAAe,kBAAkB,QAAQ,GAAG,cAAc,MAAM,GAAG,cAAc;EACjF,oBAAoB,oBAAoB,IAAI,KAAK,aAAa,MAAM,KAAK;EACzE,GAAG;EACH,WAAW;CACb,CAAC;CAED,IAAI,CAAC,EAAE,cAAc,MAAM,IAAI,MAAM,+BAA+B;CACpE,MAAM,UAAU,qBAAqB,IAAI,WAAW,EAAE,YAAY;CAElE,IAAI;CACJ,IAAI;EACF,IAAI;EACJ,IAAI,iBAAiB;GACnB,aAAa,IAAI,GAAG,MAAM;GAC1B,WAAW,SAAS,GAAG,WAAW;GAClC,aAAa;IAAE,YAAY;IAAiB;GAAW;GACvD,QAAQ,eAAe,IAAI,GAAG,UAAU,aAAa,GAAG,iBAAiB,UAAU;EACrF;EACA,IAAI,MAAM,iBAAiB,mBAAmB,IAAI,SAAS,MAAM,eAAe;EAChF,IAAI,KAAK,UAAU,WAAW,GAC5B,iBAAiB,SAAS,MAAM,GAAG,KAAK,KAAK,MAAM;OAEnD,cACE,GACA,SACA,MACA,WACA,cACA,cACA,aACA,UACF;EAGF,OAAO,QAAQ,MAAM;CACvB,UAAU;EACR,QAAQ,OAAO;EACf,YAAY,OAAO;CACrB;AACF"}
|
|
@@ -4,7 +4,7 @@ import { SceneNode } from "@pairdraw/scene-graph";
|
|
|
4
4
|
* Paragraph construction is typed against this list, which also drives cache invalidation; the
|
|
5
5
|
* decoration fields keep the decorations a prepared text holds current with it.
|
|
6
6
|
*/
|
|
7
|
-
declare const PARAGRAPH_INPUT_KEYS: readonly ["text", "fontFamily", "fontSize", "fontWeight", "italic", "fontStyle", "styleRuns", "fontVariations", "opticalSizeFromFontSize", "fontFeatures", "textLanguage", "textDirection", "textCase", "letterSpacing", "lineHeight", "textAlignHorizontal", "leadingTrim", "textDecoration", "textDecorationStyle", "textDecorationThickness", "textDecorationFills", "textDecorationSkipInk", "textUnderlineOffset", "textTruncation", "maxLines", "textParagraphs", "listSpacing", "paragraphSpacing", "paragraphIndent", "hangingList", "textAutoResize", "width", "height"];
|
|
7
|
+
declare const PARAGRAPH_INPUT_KEYS: readonly ["text", "fontFamily", "fontSize", "fontWeight", "italic", "fontStyle", "styleRuns", "fontVariations", "opticalSizeFromFontSize", "fontFeatures", "textLanguage", "textDirection", "textCase", "letterSpacing", "lineHeight", "textAlignHorizontal", "leadingTrim", "textDecoration", "textDecorationStyle", "textDecorationThickness", "textDecorationFills", "textDecorationSkipInk", "textUnderlineOffset", "textTruncation", "maxLines", "textParagraphs", "listSpacing", "paragraphSpacing", "paragraphIndent", "hangingList", "textAutoResize", "width", "height", "minWidth", "maxWidth"];
|
|
8
8
|
type ParagraphNode = Pick<SceneNode, (typeof PARAGRAPH_INPUT_KEYS)[number]>;
|
|
9
9
|
/**
|
|
10
10
|
* The paragraph inputs that decide how text shapes: which glyphs it needs and how big it is at a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.d.ts","names":[],"sources":["../../../../src/canvas/text/paragraph/inputs.ts"],"mappings":";;;;;;cAMa;
|
|
1
|
+
{"version":3,"file":"inputs.d.ts","names":[],"sources":["../../../../src/canvas/text/paragraph/inputs.ts"],"mappings":";;;;;;cAMa;KAsCD,gBAAgB,KAAK,mBAAmB;;;;;;iBASpC,cAAc,MAAM,gBAAgB,oBAAoB;;iBAQxD,eAAe,sBAAsB"}
|
|
@@ -36,9 +36,16 @@ const PARAGRAPH_INPUT_KEYS = [
|
|
|
36
36
|
"hangingList",
|
|
37
37
|
"textAutoResize",
|
|
38
38
|
"width",
|
|
39
|
-
"height"
|
|
39
|
+
"height",
|
|
40
|
+
"minWidth",
|
|
41
|
+
"maxWidth"
|
|
40
42
|
];
|
|
41
|
-
const BOX_SIZE_KEYS = /* @__PURE__ */ new Set([
|
|
43
|
+
const BOX_SIZE_KEYS = /* @__PURE__ */ new Set([
|
|
44
|
+
"width",
|
|
45
|
+
"height",
|
|
46
|
+
"minWidth",
|
|
47
|
+
"maxWidth"
|
|
48
|
+
]);
|
|
42
49
|
/**
|
|
43
50
|
* The paragraph inputs that decide how text shapes: which glyphs it needs and how big it is at a
|
|
44
51
|
* given layout width. The box size only matters when the text is truncated, since it decides
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.js","names":[],"sources":["../../../../src/canvas/text/paragraph/inputs.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\n\n/**\n * Paragraph construction is typed against this list, which also drives cache invalidation; the\n * decoration fields keep the decorations a prepared text holds current with it.\n */\nexport const PARAGRAPH_INPUT_KEYS = [\n 'text',\n 'fontFamily',\n 'fontSize',\n 'fontWeight',\n 'italic',\n 'fontStyle',\n 'styleRuns',\n 'fontVariations',\n 'opticalSizeFromFontSize',\n 'fontFeatures',\n 'textLanguage',\n 'textDirection',\n 'textCase',\n 'letterSpacing',\n 'lineHeight',\n 'textAlignHorizontal',\n 'leadingTrim',\n 'textDecoration',\n 'textDecorationStyle',\n 'textDecorationThickness',\n 'textDecorationFills',\n 'textDecorationSkipInk',\n 'textUnderlineOffset',\n 'textTruncation',\n 'maxLines',\n 'textParagraphs',\n 'listSpacing',\n 'paragraphSpacing',\n 'paragraphIndent',\n 'hangingList',\n 'textAutoResize',\n 'width',\n 'height'\n] as const satisfies readonly (keyof SceneNode)[]\n\nexport type ParagraphNode = Pick<SceneNode, (typeof PARAGRAPH_INPUT_KEYS)[number]>\n\nconst BOX_SIZE_KEYS = new Set<keyof SceneNode>(['width', 'height'])\n\n/**\n * The paragraph inputs that decide how text shapes: which glyphs it needs and how big it is at a\n * given layout width. The box size only matters when the text is truncated, since it decides\n * which characters are shown; otherwise layout resizing the box leaves both as they were.\n */\nexport function shapingInputs(node: ParagraphNode): ParagraphNode[keyof ParagraphNode][] {\n const truncated = node.textTruncation === 'ENDING'\n return PARAGRAPH_INPUT_KEYS.filter((key) => truncated || !BOX_SIZE_KEYS.has(key)).map(\n (key) => node[key]\n )\n}\n\n/** Whether a change to `keys` can change shaping beyond what `shapingInputs` sees. */\nexport function changesShaping(keys: readonly (keyof SceneNode)[]): boolean {\n return keys.some(\n (key) => !BOX_SIZE_KEYS.has(key) && (PARAGRAPH_INPUT_KEYS as readonly string[]).includes(key)\n )\n}\n"],"mappings":";;;;;AAMA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,MAAM,gCAAgB,IAAI,IAAqB
|
|
1
|
+
{"version":3,"file":"inputs.js","names":[],"sources":["../../../../src/canvas/text/paragraph/inputs.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\n\n/**\n * Paragraph construction is typed against this list, which also drives cache invalidation; the\n * decoration fields keep the decorations a prepared text holds current with it.\n */\nexport const PARAGRAPH_INPUT_KEYS = [\n 'text',\n 'fontFamily',\n 'fontSize',\n 'fontWeight',\n 'italic',\n 'fontStyle',\n 'styleRuns',\n 'fontVariations',\n 'opticalSizeFromFontSize',\n 'fontFeatures',\n 'textLanguage',\n 'textDirection',\n 'textCase',\n 'letterSpacing',\n 'lineHeight',\n 'textAlignHorizontal',\n 'leadingTrim',\n 'textDecoration',\n 'textDecorationStyle',\n 'textDecorationThickness',\n 'textDecorationFills',\n 'textDecorationSkipInk',\n 'textUnderlineOffset',\n 'textTruncation',\n 'maxLines',\n 'textParagraphs',\n 'listSpacing',\n 'paragraphSpacing',\n 'paragraphIndent',\n 'hangingList',\n 'textAutoResize',\n 'width',\n 'height',\n 'minWidth',\n 'maxWidth'\n] as const satisfies readonly (keyof SceneNode)[]\n\nexport type ParagraphNode = Pick<SceneNode, (typeof PARAGRAPH_INPUT_KEYS)[number]>\n\nconst BOX_SIZE_KEYS = new Set<keyof SceneNode>(['width', 'height', 'minWidth', 'maxWidth'])\n\n/**\n * The paragraph inputs that decide how text shapes: which glyphs it needs and how big it is at a\n * given layout width. The box size only matters when the text is truncated, since it decides\n * which characters are shown; otherwise layout resizing the box leaves both as they were.\n */\nexport function shapingInputs(node: ParagraphNode): ParagraphNode[keyof ParagraphNode][] {\n const truncated = node.textTruncation === 'ENDING'\n return PARAGRAPH_INPUT_KEYS.filter((key) => truncated || !BOX_SIZE_KEYS.has(key)).map(\n (key) => node[key]\n )\n}\n\n/** Whether a change to `keys` can change shaping beyond what `shapingInputs` sees. */\nexport function changesShaping(keys: readonly (keyof SceneNode)[]): boolean {\n return keys.some(\n (key) => !BOX_SIZE_KEYS.has(key) && (PARAGRAPH_INPUT_KEYS as readonly string[]).includes(key)\n )\n}\n"],"mappings":";;;;;AAMA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,MAAM,gCAAgB,IAAI,IAAqB;CAAC;CAAS;CAAU;CAAY;AAAU,CAAC;;;;;;AAO1F,SAAgB,cAAc,MAA2D;CACvF,MAAM,YAAY,KAAK,mBAAmB;CAC1C,OAAO,qBAAqB,QAAQ,QAAQ,aAAa,CAAC,cAAc,IAAI,GAAG,CAAC,CAAC,CAAC,KAC/E,QAAQ,KAAK,IAChB;AACF;;AAGA,SAAgB,eAAe,MAA6C;CAC1E,OAAO,KAAK,MACT,QAAQ,CAAC,cAAc,IAAI,GAAG,KAAM,qBAA2C,SAAS,GAAG,CAC9F;AACF"}
|
|
@@ -2,9 +2,9 @@ import "../../constants.js";
|
|
|
2
2
|
import { shownCharacters } from "../../text/case.js";
|
|
3
3
|
import { textFontFace } from "../../text/requirements/collect.js";
|
|
4
4
|
import { fontManager } from "../../text/font/manager.js";
|
|
5
|
+
import { drawnFontVariations, loadedFace, paragraphSourceFamilies } from "./font-families.js";
|
|
5
6
|
import { glyphOutlineSourceSync, shardCovers, shardOutlineSources } from "../../text/font/glyphs.js";
|
|
6
7
|
import { laidOutText } from "./keycap.js";
|
|
7
|
-
import { drawnFontVariations, loadedFace, paragraphSourceFamilies } from "./font-families.js";
|
|
8
8
|
import "../../text/ellipsis.js";
|
|
9
9
|
import { utf16IndicesByUtf8 } from "./utf8.js";
|
|
10
10
|
import { textLengthPixels } from "@pairdraw/scene-graph/text";
|
|
@@ -12,9 +12,10 @@ import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
|
|
|
12
12
|
*/
|
|
13
13
|
declare function shapeText(ck: CanvasKit, fontProvider: TypefaceFontProvider, node: SceneNode): ShapedText | null;
|
|
14
14
|
/**
|
|
15
|
-
* Run `use` with text shaped as the canvas lays it out
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* Run `use` with text shaped as the canvas lays it out, from the font provider the canvas of
|
|
16
|
+
* `canvasKit` draws from, or one a caller attached and registered faces on for layout alone.
|
|
17
|
+
* Each call holds a share of that provider, so overlapping calls shape from the same one and the
|
|
18
|
+
* last to finish releases it; a provider with no share left is deleted.
|
|
18
19
|
*/
|
|
19
20
|
declare function withTextShaper<T>(canvasKit: CanvasKit, use: (shape: (node: SceneNode) => ShapedText | null) => Promise<T>): Promise<T>;
|
|
20
21
|
/** Run a `.fig` or Figma clipboard write with text shaping. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.d.ts","names":[],"sources":["../../../src/canvas/text/shape.ts"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"shape.d.ts","names":[],"sources":["../../../src/canvas/text/shape.ts"],"mappings":";;;;;;;;;;;;iBA6GgB,UACd,IAAI,WACJ,cAAc,sBACd,MAAM,YACL;;;;;;;iBA0FmB,eAAe,GACnC,WAAW,WACX,MAAM,QAAQ,MAAM,cAAc,sBAAsB,QAAQ,KAC/D,QAAQ;;iBAUW,qBAAqB,GACzC,OAAO,YACP,IAAI,uBACJ,QAAQ,SAAS,+BAA+B,QAAQ,KACvD,QAAQ"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { getCanvasKit } from "../../canvaskit.js";
|
|
2
|
+
import "../../text/emoji.js";
|
|
2
3
|
import { shownText } from "../../text/case.js";
|
|
3
4
|
import { fontManager } from "../../text/font/manager.js";
|
|
4
5
|
import { outlineInk, savedGlyphInk } from "./ink.js";
|
|
5
6
|
import { keycapFrame } from "./keycap.js";
|
|
6
|
-
import "../../text/emoji.js";
|
|
7
7
|
import { characterFamily, laidOutGlyphs } from "./placed.js";
|
|
8
8
|
import { textDecorationRects } from "./decorations.js";
|
|
9
9
|
import { buildParagraph } from "./layout/build.js";
|
|
10
|
-
import { textVerticalOffset } from "./index.js";
|
|
11
10
|
import { faceStyleName } from "../../text/font/names.js";
|
|
12
11
|
import { nextGraphemeBoundary } from "../../text/graphemes.js";
|
|
13
12
|
import { EMPTY_EXPORT_RUNTIME } from "@pairdraw/fig/node-change";
|
|
13
|
+
import { textVerticalOffset } from "@pairdraw/scene-graph/text";
|
|
14
14
|
//#region src/canvas/text/shape.ts
|
|
15
15
|
/**
|
|
16
16
|
* Whether saved glyphs could stand for this text: case changes that alter its length move
|
|
@@ -142,7 +142,7 @@ function shapeText(ck, fontProvider, node) {
|
|
|
142
142
|
...glyph,
|
|
143
143
|
commands: null
|
|
144
144
|
})),
|
|
145
|
-
baselines: metrics.map((line) => ({
|
|
145
|
+
baselines: metrics.filter((line, index) => index === 0 || line.startIndex < text.length).map((line) => ({
|
|
146
146
|
firstCharacter: line.startIndex,
|
|
147
147
|
endCharacter: Math.min(line.endIncludingNewline, text.length),
|
|
148
148
|
position: {
|
|
@@ -184,31 +184,18 @@ function needsShaping(graph) {
|
|
|
184
184
|
for (const node of graph.nodes.values()) if (node.type === "TEXT" && node.text && !node.derivedTextGlyphs?.length) return true;
|
|
185
185
|
return false;
|
|
186
186
|
}
|
|
187
|
-
/** How many shaping calls share each provider made for them; the last one to finish deletes it. */
|
|
188
|
-
const shaperProviderUsers = /* @__PURE__ */ new Map();
|
|
189
187
|
/**
|
|
190
|
-
* Run `use` with text shaped as the canvas lays it out
|
|
191
|
-
*
|
|
192
|
-
*
|
|
188
|
+
* Run `use` with text shaped as the canvas lays it out, from the font provider the canvas of
|
|
189
|
+
* `canvasKit` draws from, or one a caller attached and registered faces on for layout alone.
|
|
190
|
+
* Each call holds a share of that provider, so overlapping calls shape from the same one and the
|
|
191
|
+
* last to finish releases it; a provider with no share left is deleted.
|
|
193
192
|
*/
|
|
194
193
|
async function withTextShaper(canvasKit, use) {
|
|
195
|
-
const
|
|
196
|
-
const provider = attached ?? canvasKit.TypefaceFontProvider.Make();
|
|
197
|
-
if (!attached) fontManager.attachProvider(canvasKit, provider);
|
|
198
|
-
const shared = !attached || shaperProviderUsers.has(provider);
|
|
199
|
-
if (shared) shaperProviderUsers.set(provider, (shaperProviderUsers.get(provider) ?? 0) + 1);
|
|
194
|
+
const provider = fontManager.acquireProvider(canvasKit);
|
|
200
195
|
try {
|
|
201
196
|
return await use((node) => shapeText(canvasKit, provider, node));
|
|
202
197
|
} finally {
|
|
203
|
-
|
|
204
|
-
const users = (shaperProviderUsers.get(provider) ?? 1) - 1;
|
|
205
|
-
if (users > 0) shaperProviderUsers.set(provider, users);
|
|
206
|
-
else {
|
|
207
|
-
shaperProviderUsers.delete(provider);
|
|
208
|
-
fontManager.detachProvider(provider);
|
|
209
|
-
provider.delete();
|
|
210
|
-
}
|
|
211
|
-
}
|
|
198
|
+
fontManager.releaseProvider(provider);
|
|
212
199
|
}
|
|
213
200
|
}
|
|
214
201
|
/** Run a `.fig` or Figma clipboard write with text shaping. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.js","names":[],"sources":["../../../src/canvas/text/shape.ts"],"sourcesContent":["import type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'\n\nimport {\n EMPTY_EXPORT_RUNTIME,\n type FigNodeChangeExportRuntime,\n type PlacedTextGlyph,\n type ShapedText,\n type ShapedTextGlyph,\n type TextDecorationRecord\n} from '@pairdraw/fig/node-change'\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { buildParagraph, textVerticalOffset } from '#core/canvas/text'\nimport { textDecorationRects, type DecoratedGlyph } from '#core/canvas/text/decorations'\nimport { outlineInk, savedGlyphInk } from '#core/canvas/text/ink'\nimport { COMBINING_KEYCAP, keycapFrame } from '#core/canvas/text/keycap'\nimport { characterFamily, laidOutGlyphs, type LaidOutGlyph } from '#core/canvas/text/placed'\nimport { getCanvasKit } from '#core/canvaskit'\nimport { shownText } from '#core/text/case'\nimport { EMOJI_METRICS_FAMILY } from '#core/text/emoji'\nimport type { OutlineCommand } from '#core/text/font/glyphs'\nimport { fontManager } from '#core/text/font/manager'\nimport { faceStyleName } from '#core/text/font/names'\nimport { nextGraphemeBoundary } from '#core/text/graphemes'\n\n/**\n * Whether saved glyphs could stand for this text: case changes that alter its length move\n * glyphs off the characters they came from, and path text is placed along its path. Truncated\n * text saves the characters it shows and the ellipsis after them.\n */\nfunction canShape(node: SceneNode, text: string): boolean {\n return node.text.length > 0 && text.length === node.text.length && !node.textPathData\n}\n\n/** Characters inside a glyph cluster or without a glyph take the offset of the one before. */\nfunction completeCharacterOffsets(offsets: Array<number | undefined>): number[] {\n let previous = 0\n return offsets.map((offset) => {\n previous = offset ?? previous\n return previous\n })\n}\n\n/**\n * The square Figma saves for an emoji, in pixels at `size` with y down: 1 em wide, from 0.07 em\n * below the baseline, closed with a line back to its start as Figma writes it.\n */\nfunction emojiPlaceholder(size: number): OutlineCommand[] {\n const bottom = 0.07 * size\n const top = -0.93 * size\n return [\n { type: 'M', x: 0, y: bottom },\n { type: 'L', x: size, y: bottom },\n { type: 'L', x: size, y: top },\n { type: 'L', x: 0, y: top },\n { type: 'L', x: 0, y: bottom },\n { type: 'Z' }\n ]\n}\n\ninterface SavedEmoji {\n codePoints: number[]\n /** Where the emoji's characters end in the text. */\n end: number\n}\n\n/**\n * The emoji a glyph starts, as Figma saves it, when the layout gave it to the emoji metrics font:\n * its code points, an emoji that shows as text by default with the selector that asks for its\n * emoji form, as Figma saves ☺ as ☺️.\n */\nfunction savedEmoji(node: SceneNode, text: string, glyph: LaidOutGlyph): SavedEmoji | undefined {\n const start = glyph.firstCharacter\n if (start === undefined || characterFamily(node, text, start) !== EMOJI_METRICS_FAMILY)\n return undefined\n const end = nextGraphemeBoundary(text, start)\n const emoji = text.slice(start, end)\n const codePoints = Array.from(emoji, (character) => character.codePointAt(0) ?? 0)\n if (codePoints.length === 1 && !/\\p{Emoji_Presentation}/u.test(emoji)) codePoints.push(0xfe0f)\n return { codePoints, end }\n}\n\n/**\n * A glyph's saved outline: an emoji's placeholder, nothing inside one, a keycap's frame, or its\n * font's outline.\n */\nfunction savedOutline(\n glyph: LaidOutGlyph,\n text: string,\n emoji: SavedEmoji | undefined,\n insideEmoji: boolean\n): OutlineCommand[] | null {\n if (insideEmoji) return []\n if (emoji) return emojiPlaceholder(glyph.fontSize)\n const character = glyph.firstCharacter\n if (character !== undefined && text[character] === COMBINING_KEYCAP)\n return keycapFrame(glyph.fontSize)\n return glyph.source?.outline(glyph.id, glyph.fontSize) ?? null\n}\n\n/**\n * Lay a text node out as the renderer draws it and pair each shaped glyph with the outline of\n * the glyph ID CanvasKit chose, so ligatures and contextual forms keep their shapes. An emoji the\n * layout gives the emoji metrics font is saved as Figma saves one: a placeholder square with its\n * code points. When a run's font cannot be told, no glyph gets an outline: the layout still\n * stands and Pairdraw lays the text out again on reading, but Figma draws it blank.\n * Returns `null` for text saved glyphs cannot represent at all.\n */\nexport function shapeText(\n ck: CanvasKit,\n fontProvider: TypefaceFontProvider,\n node: SceneNode\n): ShapedText | null {\n const text = shownText(node)\n if (!canShape(node, text)) return null\n\n const paragraph = buildParagraph({ ck, fontProvider, fontsLoaded: true }, node, undefined, {\n halfLeading: true\n })\n try {\n const offsetY = textVerticalOffset(node, paragraph.getHeight())\n const placed = laidOutGlyphs(node, paragraph, text, offsetY)\n if (!placed) return null\n const metrics = paragraph.getLineMetrics()\n const characterOffsets: Array<number | undefined> = Array.from({ length: text.length })\n // A sequence the font does not join is several glyphs: the first stands for the emoji, and\n // the rest keep their place and draw nothing. Glyphs come in visual order, so in\n // right-to-left text a character before the emoji can follow it: the whole range counts.\n let emojiRange = { start: 0, end: 0 }\n const glyphs: ShapedTextGlyph[] = placed.map((glyph) => {\n const start = glyph.firstCharacter\n if (start !== undefined) characterOffsets[start] ??= glyph.x - glyph.lineLeft\n const insideEmoji = start !== undefined && start > emojiRange.start && start < emojiRange.end\n const emoji = insideEmoji ? undefined : savedEmoji(node, text, glyph)\n if (emoji && start !== undefined) emojiRange = { start, end: emoji.end }\n return {\n commands: savedOutline(glyph, text, emoji, insideEmoji),\n x: glyph.x,\n y: glyph.y,\n fontSize: glyph.fontSize,\n firstCharacter: start,\n advance: glyph.advance,\n emojiCodePoints: emoji?.codePoints\n }\n })\n // Outlines from some runs only would draw the text with characters missing.\n const outlined = glyphs.every((glyph) => glyph.commands)\n return {\n glyphs: outlined ? glyphs : glyphs.map((glyph) => ({ ...glyph, commands: null })),\n baselines: metrics.map((line) => ({\n firstCharacter: line.startIndex,\n endCharacter: Math.min(line.endIncludingNewline, text.length),\n position: { x: line.left, y: line.baseline + offsetY },\n width: line.width,\n lineY: line.baseline - line.ascent + offsetY,\n lineHeight: line.height,\n lineAscent: line.ascent\n })),\n logicalIndexToCharacterOffsetMap: completeCharacterOffsets(characterOffsets)\n }\n } finally {\n paragraph.delete()\n }\n}\n\nfunction decoratedGlyph(glyph: PlacedTextGlyph): DecoratedGlyph {\n const { commandsBlob, commands } = glyph\n return {\n ...glyph,\n ink: (top, bottom) => {\n if (commandsBlob) return savedGlyphInk(commandsBlob, glyph, top, bottom)\n return commands ? outlineInk(commands, glyph.x, glyph.y, top, bottom) : null\n }\n }\n}\n\n/** Decorations as Figma saves them, over glyphs saved or just shaped. */\nfunction textDecorations(\n node: SceneNode,\n glyphs: readonly PlacedTextGlyph[]\n): TextDecorationRecord[] {\n return textDecorationRects(node, glyphs.map(decoratedGlyph)).map(\n ({ firstCharacter, x, y, width, height }) => ({ firstCharacter, x, y, width, height })\n )\n}\n\nfunction needsShaping(graph: SceneGraph): boolean {\n for (const node of graph.nodes.values()) {\n if (node.type === 'TEXT' && node.text && !node.derivedTextGlyphs?.length) return true\n }\n return false\n}\n\n/** How many shaping calls share each provider made for them; the last one to finish deletes it. */\nconst shaperProviderUsers = new Map<TypefaceFontProvider, number>()\n\n/**\n * Run `use` with text shaped as the canvas lays it out. Unless the attached font provider belongs\n * to this CanvasKit, the loaded fonts are registered in one made for shaping, which calls that\n * overlap share and the last of them deletes.\n */\nexport async function withTextShaper<T>(\n canvasKit: CanvasKit,\n use: (shape: (node: SceneNode) => ShapedText | null) => Promise<T>\n): Promise<T> {\n const attached = fontManager.providerFor(canvasKit)\n const provider = attached ?? canvasKit.TypefaceFontProvider.Make()\n if (!attached) fontManager.attachProvider(canvasKit, provider)\n const shared = !attached || shaperProviderUsers.has(provider)\n if (shared) shaperProviderUsers.set(provider, (shaperProviderUsers.get(provider) ?? 0) + 1)\n try {\n return await use((node) => shapeText(canvasKit, provider, node))\n } finally {\n if (shared) {\n const users = (shaperProviderUsers.get(provider) ?? 1) - 1\n if (users > 0) {\n shaperProviderUsers.set(provider, users)\n } else {\n shaperProviderUsers.delete(provider)\n fontManager.detachProvider(provider)\n provider.delete()\n }\n }\n }\n}\n\n/** Run a `.fig` or Figma clipboard write with text shaping. */\nexport async function withFigExportRuntime<T>(\n graph: SceneGraph,\n ck: CanvasKit | undefined,\n write: (runtime: FigNodeChangeExportRuntime) => Promise<T>\n): Promise<T> {\n const named = { textDecorations, fontStyleName: faceStyleName }\n if (!needsShaping(graph)) return write({ ...EMPTY_EXPORT_RUNTIME, ...named })\n return withTextShaper(ck ?? (await getCanvasKit()), (shapeText) => write({ shapeText, ...named }))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,SAAS,SAAS,MAAiB,MAAuB;CACxD,OAAO,KAAK,KAAK,SAAS,KAAK,KAAK,WAAW,KAAK,KAAK,UAAU,CAAC,KAAK;AAC3E;;AAGA,SAAS,yBAAyB,SAA8C;CAC9E,IAAI,WAAW;CACf,OAAO,QAAQ,KAAK,WAAW;EAC7B,WAAW,UAAU;EACrB,OAAO;CACT,CAAC;AACH;;;;;AAMA,SAAS,iBAAiB,MAAgC;CACxD,MAAM,SAAS,MAAO;CACtB,MAAM,MAAM,OAAQ;CACpB,OAAO;EACL;GAAE,MAAM;GAAK,GAAG;GAAG,GAAG;EAAO;EAC7B;GAAE,MAAM;GAAK,GAAG;GAAM,GAAG;EAAO;EAChC;GAAE,MAAM;GAAK,GAAG;GAAM,GAAG;EAAI;EAC7B;GAAE,MAAM;GAAK,GAAG;GAAG,GAAG;EAAI;EAC1B;GAAE,MAAM;GAAK,GAAG;GAAG,GAAG;EAAO;EAC7B,EAAE,MAAM,IAAI;CACd;AACF;;;;;;AAaA,SAAS,WAAW,MAAiB,MAAc,OAA6C;CAC9F,MAAM,QAAQ,MAAM;CACpB,IAAI,UAAU,KAAA,KAAa,gBAAgB,MAAM,MAAM,KAAK,MAAA,0BAC1D,OAAO,KAAA;CACT,MAAM,MAAM,qBAAqB,MAAM,KAAK;CAC5C,MAAM,QAAQ,KAAK,MAAM,OAAO,GAAG;CACnC,MAAM,aAAa,MAAM,KAAK,QAAQ,cAAc,UAAU,YA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,QAAQ,OAAO;CAEnF,OAAO;AACT;;AAGA,MAAM,sCAAsB,IAAI,IAAkC;;;;;;AAOlE,eAAsB,eACpB,WACA,KACY;CACZ,MAAM,WAAW,YAAY,YAAY,SAAS;CAClD,MAAM,WAAW,YAAY,UAAU,qBAAqB,KAAK;CACjE,IAAI,CAAC,UAAU,YAAY,eAAe,WAAW,QAAQ;CAC7D,MAAM,SAAS,CAAC,YAAY,oBAAoB,IAAI,QAAQ;CAC5D,IAAI,QAAQ,oBAAoB,IAAI,WAAW,oBAAoB,IAAI,QAAQ,KAAK,KAAK,CAAC;CAC1F,IAAI;EACF,OAAO,MAAM,KAAK,SAAS,UAAU,WAAW,UAAU,IAAI,CAAC;CACjE,UAAU;EACR,IAAI,QAAQ;GACV,MAAM,SAAS,oBAAoB,IAAI,QAAQ,KAAK,KAAK;GACzD,IAAI,QAAQ,GACV,oBAAoB,IAAI,UAAU,KAAK;QAClC;IACL,oBAAoB,OAAO,QAAQ;IACnC,YAAY,eAAe,QAAQ;IACnC,SAAS,OAAO;GAClB;EACF;CACF;AACF;;AAGA,eAAsB,qBACpB,OACA,IACA,OACY;CACZ,MAAM,QAAQ;EAAE;EAAiB,eAAe;CAAc;CAC9D,IAAI,CAAC,aAAa,KAAK,GAAG,OAAO,MAAM;EAAE,GAAG;EAAsB,GAAG;CAAM,CAAC;CAC5E,OAAO,eAAe,MAAO,MAAM,aAAa,IAAK,cAAc,MAAM;EAAE;EAAW,GAAG;CAAM,CAAC,CAAC;AACnG"}
|
|
1
|
+
{"version":3,"file":"shape.js","names":[],"sources":["../../../src/canvas/text/shape.ts"],"sourcesContent":["import type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'\n\nimport {\n EMPTY_EXPORT_RUNTIME,\n type FigNodeChangeExportRuntime,\n type PlacedTextGlyph,\n type ShapedText,\n type ShapedTextGlyph,\n type TextDecorationRecord\n} from '@pairdraw/fig/node-change'\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { textVerticalOffset } from '@pairdraw/scene-graph/text'\n\nimport { buildParagraph } from '#core/canvas/text'\nimport { textDecorationRects, type DecoratedGlyph } from '#core/canvas/text/decorations'\nimport { outlineInk, savedGlyphInk } from '#core/canvas/text/ink'\nimport { COMBINING_KEYCAP, keycapFrame } from '#core/canvas/text/keycap'\nimport { characterFamily, laidOutGlyphs, type LaidOutGlyph } from '#core/canvas/text/placed'\nimport { getCanvasKit } from '#core/canvaskit'\nimport { shownText } from '#core/text/case'\nimport { EMOJI_METRICS_FAMILY } from '#core/text/emoji'\nimport type { OutlineCommand } from '#core/text/font/glyphs'\nimport { fontManager } from '#core/text/font/manager'\nimport { faceStyleName } from '#core/text/font/names'\nimport { nextGraphemeBoundary } from '#core/text/graphemes'\n\n/**\n * Whether saved glyphs could stand for this text: case changes that alter its length move\n * glyphs off the characters they came from, and path text is placed along its path. Truncated\n * text saves the characters it shows and the ellipsis after them.\n */\nfunction canShape(node: SceneNode, text: string): boolean {\n return node.text.length > 0 && text.length === node.text.length && !node.textPathData\n}\n\n/** Characters inside a glyph cluster or without a glyph take the offset of the one before. */\nfunction completeCharacterOffsets(offsets: Array<number | undefined>): number[] {\n let previous = 0\n return offsets.map((offset) => {\n previous = offset ?? previous\n return previous\n })\n}\n\n/**\n * The square Figma saves for an emoji, in pixels at `size` with y down: 1 em wide, from 0.07 em\n * below the baseline, closed with a line back to its start as Figma writes it.\n */\nfunction emojiPlaceholder(size: number): OutlineCommand[] {\n const bottom = 0.07 * size\n const top = -0.93 * size\n return [\n { type: 'M', x: 0, y: bottom },\n { type: 'L', x: size, y: bottom },\n { type: 'L', x: size, y: top },\n { type: 'L', x: 0, y: top },\n { type: 'L', x: 0, y: bottom },\n { type: 'Z' }\n ]\n}\n\ninterface SavedEmoji {\n codePoints: number[]\n /** Where the emoji's characters end in the text. */\n end: number\n}\n\n/**\n * The emoji a glyph starts, as Figma saves it, when the layout gave it to the emoji metrics font:\n * its code points, an emoji that shows as text by default with the selector that asks for its\n * emoji form, as Figma saves ☺ as ☺️.\n */\nfunction savedEmoji(node: SceneNode, text: string, glyph: LaidOutGlyph): SavedEmoji | undefined {\n const start = glyph.firstCharacter\n if (start === undefined || characterFamily(node, text, start) !== EMOJI_METRICS_FAMILY)\n return undefined\n const end = nextGraphemeBoundary(text, start)\n const emoji = text.slice(start, end)\n const codePoints = Array.from(emoji, (character) => character.codePointAt(0) ?? 0)\n if (codePoints.length === 1 && !/\\p{Emoji_Presentation}/u.test(emoji)) codePoints.push(0xfe0f)\n return { codePoints, end }\n}\n\n/**\n * A glyph's saved outline: an emoji's placeholder, nothing inside one, a keycap's frame, or its\n * font's outline.\n */\nfunction savedOutline(\n glyph: LaidOutGlyph,\n text: string,\n emoji: SavedEmoji | undefined,\n insideEmoji: boolean\n): OutlineCommand[] | null {\n if (insideEmoji) return []\n if (emoji) return emojiPlaceholder(glyph.fontSize)\n const character = glyph.firstCharacter\n if (character !== undefined && text[character] === COMBINING_KEYCAP)\n return keycapFrame(glyph.fontSize)\n return glyph.source?.outline(glyph.id, glyph.fontSize) ?? null\n}\n\n/**\n * Lay a text node out as the renderer draws it and pair each shaped glyph with the outline of\n * the glyph ID CanvasKit chose, so ligatures and contextual forms keep their shapes. An emoji the\n * layout gives the emoji metrics font is saved as Figma saves one: a placeholder square with its\n * code points. When a run's font cannot be told, no glyph gets an outline: the layout still\n * stands and Pairdraw lays the text out again on reading, but Figma draws it blank.\n * Returns `null` for text saved glyphs cannot represent at all.\n */\nexport function shapeText(\n ck: CanvasKit,\n fontProvider: TypefaceFontProvider,\n node: SceneNode\n): ShapedText | null {\n const text = shownText(node)\n if (!canShape(node, text)) return null\n\n const paragraph = buildParagraph({ ck, fontProvider, fontsLoaded: true }, node, undefined, {\n halfLeading: true\n })\n try {\n const offsetY = textVerticalOffset(node, paragraph.getHeight())\n const placed = laidOutGlyphs(node, paragraph, text, offsetY)\n if (!placed) return null\n const metrics = paragraph.getLineMetrics()\n const characterOffsets: Array<number | undefined> = Array.from({ length: text.length })\n // A sequence the font does not join is several glyphs: the first stands for the emoji, and\n // the rest keep their place and draw nothing. Glyphs come in visual order, so in\n // right-to-left text a character before the emoji can follow it: the whole range counts.\n let emojiRange = { start: 0, end: 0 }\n const glyphs: ShapedTextGlyph[] = placed.map((glyph) => {\n const start = glyph.firstCharacter\n if (start !== undefined) characterOffsets[start] ??= glyph.x - glyph.lineLeft\n const insideEmoji = start !== undefined && start > emojiRange.start && start < emojiRange.end\n const emoji = insideEmoji ? undefined : savedEmoji(node, text, glyph)\n if (emoji && start !== undefined) emojiRange = { start, end: emoji.end }\n return {\n commands: savedOutline(glyph, text, emoji, insideEmoji),\n x: glyph.x,\n y: glyph.y,\n fontSize: glyph.fontSize,\n firstCharacter: start,\n advance: glyph.advance,\n emojiCodePoints: emoji?.codePoints\n }\n })\n // Outlines from some runs only would draw the text with characters missing.\n const outlined = glyphs.every((glyph) => glyph.commands)\n return {\n glyphs: outlined ? glyphs : glyphs.map((glyph) => ({ ...glyph, commands: null })),\n // Figma saves no baseline for the empty line after a closing line break.\n baselines: metrics\n .filter((line, index) => index === 0 || line.startIndex < text.length)\n .map((line) => ({\n firstCharacter: line.startIndex,\n endCharacter: Math.min(line.endIncludingNewline, text.length),\n position: { x: line.left, y: line.baseline + offsetY },\n width: line.width,\n lineY: line.baseline - line.ascent + offsetY,\n lineHeight: line.height,\n lineAscent: line.ascent\n })),\n logicalIndexToCharacterOffsetMap: completeCharacterOffsets(characterOffsets)\n }\n } finally {\n paragraph.delete()\n }\n}\n\nfunction decoratedGlyph(glyph: PlacedTextGlyph): DecoratedGlyph {\n const { commandsBlob, commands } = glyph\n return {\n ...glyph,\n ink: (top, bottom) => {\n if (commandsBlob) return savedGlyphInk(commandsBlob, glyph, top, bottom)\n return commands ? outlineInk(commands, glyph.x, glyph.y, top, bottom) : null\n }\n }\n}\n\n/** Decorations as Figma saves them, over glyphs saved or just shaped. */\nfunction textDecorations(\n node: SceneNode,\n glyphs: readonly PlacedTextGlyph[]\n): TextDecorationRecord[] {\n return textDecorationRects(node, glyphs.map(decoratedGlyph)).map(\n ({ firstCharacter, x, y, width, height }) => ({ firstCharacter, x, y, width, height })\n )\n}\n\nfunction needsShaping(graph: SceneGraph): boolean {\n for (const node of graph.nodes.values()) {\n if (node.type === 'TEXT' && node.text && !node.derivedTextGlyphs?.length) return true\n }\n return false\n}\n\n/**\n * Run `use` with text shaped as the canvas lays it out, from the font provider the canvas of\n * `canvasKit` draws from, or one a caller attached and registered faces on for layout alone.\n * Each call holds a share of that provider, so overlapping calls shape from the same one and the\n * last to finish releases it; a provider with no share left is deleted.\n */\nexport async function withTextShaper<T>(\n canvasKit: CanvasKit,\n use: (shape: (node: SceneNode) => ShapedText | null) => Promise<T>\n): Promise<T> {\n const provider = fontManager.acquireProvider(canvasKit)\n try {\n return await use((node) => shapeText(canvasKit, provider, node))\n } finally {\n fontManager.releaseProvider(provider)\n }\n}\n\n/** Run a `.fig` or Figma clipboard write with text shaping. */\nexport async function withFigExportRuntime<T>(\n graph: SceneGraph,\n ck: CanvasKit | undefined,\n write: (runtime: FigNodeChangeExportRuntime) => Promise<T>\n): Promise<T> {\n const named = { textDecorations, fontStyleName: faceStyleName }\n if (!needsShaping(graph)) return write({ ...EMPTY_EXPORT_RUNTIME, ...named })\n return withTextShaper(ck ?? (await getCanvasKit()), (shapeText) => write({ shapeText, ...named }))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,SAAS,SAAS,MAAiB,MAAuB;CACxD,OAAO,KAAK,KAAK,SAAS,KAAK,KAAK,WAAW,KAAK,KAAK,UAAU,CAAC,KAAK;AAC3E;;AAGA,SAAS,yBAAyB,SAA8C;CAC9E,IAAI,WAAW;CACf,OAAO,QAAQ,KAAK,WAAW;EAC7B,WAAW,UAAU;EACrB,OAAO;CACT,CAAC;AACH;;;;;AAMA,SAAS,iBAAiB,MAAgC;CACxD,MAAM,SAAS,MAAO;CACtB,MAAM,MAAM,OAAQ;CACpB,OAAO;EACL;GAAE,MAAM;G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|
|
100
100
|
declare const PEN_PATH_STROKE_WIDTH = 2;
|
|
101
101
|
declare const PARENT_OUTLINE_ALPHA = 0.5;
|
|
102
|
-
declare const PARENT_OUTLINE_DASH = 4;
|
|
103
102
|
declare const DEFAULT_FONT_FAMILY = "Inter";
|
|
104
103
|
declare const DEFAULT_FONT_SIZE = 14;
|
|
105
104
|
declare const DEFAULT_STROKE_MITER_LIMIT = 4;
|
|
106
105
|
/** Figma's stroke weight for a node that has not been given one. */
|
|
107
106
|
declare const LABEL_FONT_SIZE = 11;
|
|
108
107
|
declare const SIZE_FONT_SIZE = 10;
|
|
108
|
+
declare const HUD_FONT_SIZE = 10;
|
|
109
109
|
declare const VALUE_FONT_SIZE = 11;
|
|
110
110
|
declare const HANDLE_HALF_SIZE = 3;
|
|
111
111
|
declare const LABEL_OFFSET_Y = 8;
|
|
@@ -287,10 +287,14 @@ declare const BOARD_PAGE_BACKGROUND: {
|
|
|
287
287
|
declare const SECTION_DEFAULT_FILLS: Record<InterfaceTheme, Fill>;
|
|
288
288
|
declare const SECTION_DEFAULT_STROKE: Stroke;
|
|
289
289
|
declare const SECTION_CORNER_RADIUS = 2;
|
|
290
|
+
/** Effect filters a renderer keeps: a slider drag would otherwise keep every value it passed. */
|
|
291
|
+
declare const EFFECT_FILTER_CACHE_ENTRIES = 64;
|
|
290
292
|
declare const ZOOM_DIVISOR = 50;
|
|
291
293
|
declare const ZOOM_SCALE_MIN = 0.75;
|
|
292
294
|
declare const ZOOM_SCALE_MAX = 1.25;
|
|
293
295
|
declare const PEN_CLOSE_THRESHOLD = 8;
|
|
296
|
+
/** Points a pen path needs before a press on its first point closes it: two make a closed shape, as in Figma. */
|
|
297
|
+
declare const PEN_CLOSE_MIN_POINTS = 2;
|
|
294
298
|
/**
|
|
295
299
|
* Screen pixels a pencil sample may stray from the line through its neighbours before the curve
|
|
296
300
|
* keeps it, so a stroke drawn zoomed in keeps more detail.
|
|
@@ -308,5 +312,5 @@ declare const DEFAULT_TEXT_HEIGHT = 24;
|
|
|
308
312
|
/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */
|
|
309
313
|
declare const DUPLICATE_FRAME_GAP = 40;
|
|
310
314
|
//#endregion
|
|
311
|
-
export { ACPAgentDef, ACPAgentID, ACP_AGENTS, AIProviderDef, AIProviderID, AI_AGENT_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_ENTER_DURATION_MS, AI_ENTER_MAX_DELAY_MS, AI_ENTER_STAGGER_MS, AI_PROVIDERS, AI_SHIMMER_BAND, AI_SHIMMER_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, InterfaceTheme, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, ModelOption, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA,
|
|
315
|
+
export { ACPAgentDef, ACPAgentID, ACP_AGENTS, AIProviderDef, AIProviderID, AI_AGENT_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_ENTER_DURATION_MS, AI_ENTER_MAX_DELAY_MS, AI_ENTER_STAGGER_MS, AI_PROVIDERS, AI_SHIMMER_BAND, AI_SHIMMER_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, EFFECT_FILTER_CACHE_ENTRIES, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, HUD_FONT_SIZE, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, InterfaceTheme, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, ModelOption, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA, PENCIL_STROKE_WEIGHT, PENCIL_TOLERANCE, PEN_ANCHOR_RADIUS, PEN_CLOSE_MIN_POINTS, PEN_CLOSE_RADIUS_BOOST, PEN_CLOSE_THRESHOLD, PEN_HANDLE_RADIUS, PEN_PATH_STROKE_WIDTH, PEN_VERTEX_RADIUS, REASONING_EFFORTS, ROTATION_HANDLE_DISTANCE, ROTATION_SNAP_DEGREES, RULER_BADGE_EXCLUSION, RULER_BADGE_HEIGHT, RULER_BADGE_PADDING, RULER_BADGE_RADIUS, RULER_BG_COLOR, RULER_HIGHLIGHT_ALPHA, RULER_MAJOR_TICK, RULER_MAJOR_TOLERANCE, RULER_MINOR_TICK, RULER_SIZE, RULER_TARGET_PIXEL_SPACING, RULER_TEXT_BASELINE, RULER_TEXT_COLOR, RULER_TICK_COLOR, ReasoningEffort, SECTION_CORNER_RADIUS, SECTION_DEFAULT_FILLS, SECTION_DEFAULT_STROKE, SECTION_HOVER_STROKE_WIDTH, SECTION_TITLE_FONT_FAMILY, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_FONT_URL, SECTION_TITLE_GAP, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X, SECTION_TITLE_RADIUS, SELECTION_COLOR, SELECTION_DASH_ALPHA, SIZE_FONT_SIZE, SIZE_PILL_HEIGHT, SIZE_PILL_PADDING_X, SIZE_PILL_PADDING_Y, SIZE_PILL_RADIUS, SIZE_PILL_TEXT_OFFSET_Y, SLOT_COLOR, SLOT_EMPTY_FILL_ALPHA, SNAP_COLOR, SNAP_THRESHOLD_SCREEN_PX, SPACING_GUIDE_CAP, TEXT_CARET_COLOR, TEXT_CARET_WIDTH, TEXT_SELECTION_ALPHA, TRANSPARENT, VALUE_FONT_SIZE, VERTEX_SNAP_COLOR, VERTEX_SNAP_GUIDE_ALPHA, VERTEX_SNAP_MARK_RADIUS, ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN };
|
|
312
316
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;;cAQa;cACA;cAEA,OAAO;cACP,aAAa;cACb,sBAAsB;cACtB;;;;;;;cAEA,yBAAyB,SAAS;cAIlC;;;;;;;cAEA;;;;;;cACA;cACA;;;;;;;cAEA;;;;;;cACA;cACA;;cAEA;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;cAEA;cAEA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;;cAQa;cACA;cAEA,OAAO;cACP,aAAa;cACb,sBAAsB;cACtB;;;;;;;cAEA,yBAAyB,SAAS;cAIlC;;;;;;;cAEA;;;;;;cACA;cACA;;;;;;;cAEA;;;;;;cACA;cACA;;cAEA;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;cAEA;cAEA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;;cAEA;cACA;cACA;cACA;cAEA;cAEA;cACA;cACA;cACA;cACA;cACA;cAEA;cACA;;cAEA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;;cAEA;cACA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;cACA;;;;;;cACA;;;;;;cACA;;;;;;cACA;;;;;;cAEA;;;;;;cACA;;;;;;cAEA;cACA;cACA;cACA;;;;;;cAMA;cACA;cACA;cACA;cAEA;cACA;cACA;;cAEA;cACA;cACA;cACA;cACA;cAEA;cACA;cAEA;cACA;cACA;cACA;cACA;cACA;cACA;cAEA;;;;;;cACA;;;;;;cACA;;;;;;cACA;cACA;;cAGA;;;;;cACA;;;;;cACA;;cAEA;;cAEA;;cAEA;;cAEA;;cAEA;;cAGA;;cAEA,kBAAgB;cAChB;cAEA;;;;;cAKA;;cAGA;;;;;cAMA;cAEA;cAEA;cASA;cAUA;cASA;;cAGA,oBAAoB;cAOpB,oBAAoB;;KAQrB;;cAGC,0BAA0B,OAAO,gBAAgB;;cAMjD;;;;;;;cAQA,uBAAuB,OAAO,gBAAgB;cAU9C,wBAAwB;cASxB;;cAGA;cAEA;cACA;cACA;cAEA;;cAEA;;;;;cAKA;;cAEA;cACA;cACA;;cAEA;cACA;cACA;cACA;;cAEA"}
|
package/dist/constants.js
CHANGED
|
@@ -115,13 +115,13 @@ const PEN_ANCHOR_RADIUS = 4;
|
|
|
115
115
|
const PEN_CLOSE_RADIUS_BOOST = 2;
|
|
116
116
|
const PEN_PATH_STROKE_WIDTH = 2;
|
|
117
117
|
const PARENT_OUTLINE_ALPHA = .5;
|
|
118
|
-
const PARENT_OUTLINE_DASH = 4;
|
|
119
118
|
const DEFAULT_FONT_FAMILY = "Inter";
|
|
120
119
|
const DEFAULT_FONT_SIZE = 14;
|
|
121
120
|
const DEFAULT_STROKE_MITER_LIMIT = 4;
|
|
122
121
|
/** Figma's stroke weight for a node that has not been given one. */
|
|
123
122
|
const LABEL_FONT_SIZE = 11;
|
|
124
123
|
const SIZE_FONT_SIZE = 10;
|
|
124
|
+
const HUD_FONT_SIZE = 10;
|
|
125
125
|
const VALUE_FONT_SIZE = 11;
|
|
126
126
|
const HANDLE_HALF_SIZE = 3;
|
|
127
127
|
const LABEL_OFFSET_Y = 8;
|
|
@@ -391,10 +391,14 @@ const SECTION_DEFAULT_STROKE = {
|
|
|
391
391
|
align: "INSIDE"
|
|
392
392
|
};
|
|
393
393
|
const SECTION_CORNER_RADIUS = 2;
|
|
394
|
+
/** Effect filters a renderer keeps: a slider drag would otherwise keep every value it passed. */
|
|
395
|
+
const EFFECT_FILTER_CACHE_ENTRIES = 64;
|
|
394
396
|
const ZOOM_DIVISOR = 50;
|
|
395
397
|
const ZOOM_SCALE_MIN = .75;
|
|
396
398
|
const ZOOM_SCALE_MAX = 1.25;
|
|
397
399
|
const PEN_CLOSE_THRESHOLD = 8;
|
|
400
|
+
/** Points a pen path needs before a press on its first point closes it: two make a closed shape, as in Figma. */
|
|
401
|
+
const PEN_CLOSE_MIN_POINTS = 2;
|
|
398
402
|
/**
|
|
399
403
|
* Screen pixels a pencil sample may stray from the line through its neighbours before the curve
|
|
400
404
|
* keeps it, so a stroke drawn zoomed in keeps more detail.
|
|
@@ -412,6 +416,6 @@ const DEFAULT_TEXT_HEIGHT = 24;
|
|
|
412
416
|
/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */
|
|
413
417
|
const DUPLICATE_FRAME_GAP = 40;
|
|
414
418
|
//#endregion
|
|
415
|
-
export { ACP_AGENTS, AI_AGENT_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_ENTER_DURATION_MS, AI_ENTER_MAX_DELAY_MS, AI_ENTER_STAGGER_MS, AI_PROVIDERS, AI_SHIMMER_BAND, AI_SHIMMER_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA,
|
|
419
|
+
export { ACP_AGENTS, AI_AGENT_COLOR, AI_DONE_COLOR, AI_DONE_DURATION_MS, AI_ENTER_DURATION_MS, AI_ENTER_MAX_DELAY_MS, AI_ENTER_STAGGER_MS, AI_PROVIDERS, AI_SHIMMER_BAND, AI_SHIMMER_PERIOD_MS, AUTOMATION_HTTP_PORT, AUTO_LAYOUT_HOVER_BLUE, AUTO_LAYOUT_HOVER_BLUE_FILL, AUTO_LAYOUT_HOVER_GAP_PILL, AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_MAGENTA, AUTO_LAYOUT_HOVER_MAGENTA_FILL, AUTO_LAYOUT_HOVER_PADDING_PILL, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_STRIPE_GAP, AUTO_LAYOUT_HOVER_STRIPE_WIDTH, AUTO_LAYOUT_HOVER_STROKE_WIDTH, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_LENGTH, AUTO_LAYOUT_HOVER_VALUE_OFFSET, AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT, AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X, AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X, AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y, BLACK, BOARD_GRID, BOARD_PAGE_BACKGROUND, CANVAS_BG_COLOR, CJK_FALLBACK_FAMILIES_LINUX, CJK_FALLBACK_FAMILIES_MACOS, CJK_FALLBACK_FAMILIES_WINDOWS, CJK_GOOGLE_FONTS, CODE_FOCUS_FILL_ALPHA, COMPONENT_COLOR, COMPONENT_LABEL_FONT_SIZE, COMPONENT_LABEL_GAP, COMPONENT_LABEL_ICON_GAP, COMPONENT_LABEL_ICON_SIZE, COMPONENT_SET_BORDER_WIDTH, COMPONENT_SET_DASH, COMPONENT_SET_DASH_GAP, COMPONENT_SET_OUTLINE_RADIUS, DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FRAME_FILL, DEFAULT_SELECTION_THEME, DEFAULT_SHADOW_COLOR, DEFAULT_SHAPE_FILL, DEFAULT_STROKE_MITER_LIMIT, DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH, DROP_HIGHLIGHT_ALPHA, DROP_HIGHLIGHT_STROKE, DUPLICATE_FRAME_GAP, EFFECT_FILTER_CACHE_ENTRIES, FLASH_ATTACK_MS, FLASH_HOLD_MS, FLASH_OVERSHOOT, FLASH_PADDING, FLASH_RADIUS, FLASH_RELEASE_MS, FLASH_STROKE_WIDTH, GOOGLE_FONTS_API_KEY, HANDLE_HALF_SIZE, HANDLE_HIT_RADIUS, HARNESS_PROVIDER_ID, HUD_FONT_SIZE, ISSUE_ERROR_COLOR, ISSUE_HIGHLIGHT_FILL_ALPHA, ISSUE_HIGHLIGHT_STROKE_WIDTH, ISSUE_INFO_COLOR, ISSUE_WARNING_COLOR, IS_BROWSER, IS_TAURI, LABEL_FONT_SIZE, LABEL_OFFSET_Y, LAYER_HIT_PAD, LAYOUT_INDICATOR_STROKE, LAYOUT_OUTLINE_DASH, LAYOUT_OUTLINE_GAP, MARQUEE_FILL_ALPHA, MCP_AGENT_HEADER, MCP_CHAT_HEADER, MEASUREMENT_COLOR, MEASUREMENT_PILL_HEIGHT, MEASUREMENT_PILL_PADDING_X, MEASUREMENT_PILL_RADIUS, MEASUREMENT_TEXT_BASELINE, PAGE_DEFAULT_BACKGROUNDS, PAIRDRAW_MCP_SERVER, PARENT_OUTLINE_ALPHA, PENCIL_STROKE_WEIGHT, PENCIL_TOLERANCE, PEN_ANCHOR_RADIUS, PEN_CLOSE_MIN_POINTS, PEN_CLOSE_RADIUS_BOOST, PEN_CLOSE_THRESHOLD, PEN_HANDLE_RADIUS, PEN_PATH_STROKE_WIDTH, PEN_VERTEX_RADIUS, REASONING_EFFORTS, ROTATION_HANDLE_DISTANCE, ROTATION_SNAP_DEGREES, RULER_BADGE_EXCLUSION, RULER_BADGE_HEIGHT, RULER_BADGE_PADDING, RULER_BADGE_RADIUS, RULER_BG_COLOR, RULER_HIGHLIGHT_ALPHA, RULER_MAJOR_TICK, RULER_MAJOR_TOLERANCE, RULER_MINOR_TICK, RULER_SIZE, RULER_TARGET_PIXEL_SPACING, RULER_TEXT_BASELINE, RULER_TEXT_COLOR, RULER_TICK_COLOR, SECTION_CORNER_RADIUS, SECTION_DEFAULT_FILLS, SECTION_DEFAULT_STROKE, SECTION_HOVER_STROKE_WIDTH, SECTION_TITLE_FONT_FAMILY, SECTION_TITLE_FONT_SIZE, SECTION_TITLE_FONT_URL, SECTION_TITLE_GAP, SECTION_TITLE_HEIGHT, SECTION_TITLE_PADDING_X, SECTION_TITLE_RADIUS, SELECTION_COLOR, SELECTION_DASH_ALPHA, SIZE_FONT_SIZE, SIZE_PILL_HEIGHT, SIZE_PILL_PADDING_X, SIZE_PILL_PADDING_Y, SIZE_PILL_RADIUS, SIZE_PILL_TEXT_OFFSET_Y, SLOT_COLOR, SLOT_EMPTY_FILL_ALPHA, SNAP_COLOR, SNAP_THRESHOLD_SCREEN_PX, SPACING_GUIDE_CAP, TEXT_CARET_COLOR, TEXT_CARET_WIDTH, TEXT_SELECTION_ALPHA, TRANSPARENT, VALUE_FONT_SIZE, VERTEX_SNAP_COLOR, VERTEX_SNAP_GUIDE_ALPHA, VERTEX_SNAP_MARK_RADIUS, ZOOM_DIVISOR, ZOOM_SCALE_MAX, ZOOM_SCALE_MIN };
|
|
416
420
|
|
|
417
421
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { Fill, Stroke } from '@pairdraw/scene-graph'\nimport { WHITE } from '@pairdraw/scene-graph/constants'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { SelectionTheme } from '#core/canvas/renderer/types'\n\nexport * from './ai/providers'\n\nexport const IS_BROWSER = typeof window !== 'undefined'\nexport const IS_TAURI = IS_BROWSER && '__TAURI_INTERNALS__' in window\n\nexport const BLACK: Color = { r: 0, g: 0, b: 0, a: 1 }\nexport const TRANSPARENT: Color = { r: 0, g: 0, b: 0, a: 0 }\nexport const DEFAULT_SHADOW_COLOR: Color = { r: 0, g: 0, b: 0, a: 0.25 }\nexport const SELECTION_COLOR = { r: 0.23, g: 0.51, b: 0.96, a: 1 } satisfies Color\n/** Selection chrome when the app sets no accent: the default blue with white text. */\nexport const DEFAULT_SELECTION_THEME: Readonly<SelectionTheme> = {\n color: SELECTION_COLOR,\n foreground: WHITE\n}\nexport const COMPONENT_COLOR = { r: 0.592, g: 0.278, b: 1, a: 1 } satisfies Color\n/** Slot frames and their outlines, `#f24bbc` like the app's `--color-slot`. */\nexport const SLOT_COLOR = { r: 0.949, g: 0.294, b: 0.737, a: 1 } satisfies Color\nexport const SLOT_EMPTY_FILL_ALPHA = 0.08\nexport const SNAP_COLOR = { r: 1.0, g: 0.0, b: 0.56, a: 1 } satisfies Color\n/** Guides through path vertices and their crosses, measured from Figma's pen and vector edit mode. */\nexport const VERTEX_SNAP_COLOR = { r: 0.81, g: 0.3, b: 0.18, a: 1 } satisfies Color\nexport const VERTEX_SNAP_GUIDE_ALPHA = 0.6\nexport const VERTEX_SNAP_MARK_RADIUS = 2.5\n/** Half the length of the ticks that end an equal-spacing indicator, in screen pixels. */\nexport const SPACING_GUIDE_CAP = 4\nexport const MEASUREMENT_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color\nexport const MEASUREMENT_PILL_PADDING_X = 5\nexport const MEASUREMENT_PILL_HEIGHT = 18\nexport const MEASUREMENT_PILL_RADIUS = 3\nexport const MEASUREMENT_TEXT_BASELINE = 4\nexport const CANVAS_BG_COLOR = { r: 0.96, g: 0.96, b: 0.96, a: 1 } satisfies Color\nexport const SNAP_THRESHOLD_SCREEN_PX = 5\n/** The grid a board's layers land on, as FigJam's dots every 16 units. */\nexport const BOARD_GRID = 16\n\nexport const RULER_SIZE = 20\nexport const RULER_BG_COLOR = { r: 0.14, g: 0.14, b: 0.14, a: 1 } satisfies Color\nexport const RULER_TICK_COLOR = { r: 0.4, g: 0.4, b: 0.4, a: 1 } satisfies Color\nexport const RULER_TEXT_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const RULER_BADGE_HEIGHT = 14\nexport const RULER_BADGE_PADDING = 3\nexport const RULER_BADGE_RADIUS = 2\nexport const RULER_BADGE_EXCLUSION = 30\nexport const RULER_TEXT_BASELINE = 0.65\nexport const RULER_MAJOR_TICK = 0.5\nexport const RULER_MINOR_TICK = 0.25\nexport const RULER_HIGHLIGHT_ALPHA = 0.3\n\nexport const PEN_HANDLE_RADIUS = 2.5\nexport const PEN_VERTEX_RADIUS = 3\nexport const PEN_ANCHOR_RADIUS = 4\nexport const PEN_CLOSE_RADIUS_BOOST = 2\nexport const PEN_PATH_STROKE_WIDTH = 2\nexport const PARENT_OUTLINE_ALPHA = 0.5\nexport const PARENT_OUTLINE_DASH = 4\nexport const DEFAULT_FONT_FAMILY = 'Inter'\nexport const DEFAULT_FONT_SIZE = 14\nexport const DEFAULT_STROKE_MITER_LIMIT = 4\n/** Figma's stroke weight for a node that has not been given one. */\nexport const LABEL_FONT_SIZE = 11\nexport const SIZE_FONT_SIZE = 10\nexport const VALUE_FONT_SIZE = 11\n\nexport const HANDLE_HALF_SIZE = 3\n\nexport const LABEL_OFFSET_Y = 8\nexport const SIZE_PILL_PADDING_X = 6\nexport const SIZE_PILL_PADDING_Y = 6\nexport const SIZE_PILL_HEIGHT = 18\nexport const SIZE_PILL_RADIUS = 4\nexport const SIZE_PILL_TEXT_OFFSET_Y = 13\n\nexport const MARQUEE_FILL_ALPHA = 0.08\nexport const SELECTION_DASH_ALPHA = 0.6\n/** Tint inside the layer of the code element around the cursor, under its hover outline. */\nexport const CODE_FOCUS_FILL_ALPHA = 0.1\nexport const DROP_HIGHLIGHT_ALPHA = 0.8\nexport const DROP_HIGHLIGHT_STROKE = 2\n\nexport const LAYOUT_INDICATOR_STROKE = 2\nexport const AUTO_LAYOUT_HOVER_TICK_LENGTH = 12\nexport const AUTO_LAYOUT_HOVER_STRIPE_GAP = 8\nexport const AUTO_LAYOUT_HOVER_STRIPE_WIDTH = 1\nexport const AUTO_LAYOUT_HOVER_STROKE_WIDTH = 1.5\n/** Dash and gap, in screen pixels, of the dotted outlines around auto layout children (Figma 126). */\nexport const LAYOUT_OUTLINE_DASH = 1.75\nexport const LAYOUT_OUTLINE_GAP = 1.25\nexport const AUTO_LAYOUT_HOVER_VALUE_OFFSET = 18\n// Measured on Figma desktop 126's padding and gap value pills.\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT = 16.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS = 2.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X = 4.5\nexport const AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE = 12\nexport const AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE = 8\nexport const AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE = 20\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X = 18\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y = 36\nexport const AUTO_LAYOUT_HOVER_BLUE = { r: 0.28, g: 0.64, b: 1, a: 0.82 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_BLUE_FILL = { r: 0.28, g: 0.64, b: 1, a: 0.1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA = { r: 1, g: 0.32, b: 0.68, a: 0.78 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA_FILL = { r: 1, g: 0.32, b: 0.68, a: 0.1 } satisfies Color\n// The value pills over a gap and a padding, sampled from Figma desktop 126.\nexport const AUTO_LAYOUT_HOVER_GAP_PILL = { r: 0.886, g: 0.271, b: 0.686, a: 1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_PADDING_PILL = { r: 0.271, g: 0.592, b: 0.973, a: 1 } satisfies Color\n\nexport const SECTION_TITLE_HEIGHT = 24\nexport const SECTION_TITLE_PADDING_X = 6\nexport const SECTION_TITLE_RADIUS = 5\nexport const SECTION_TITLE_FONT_SIZE = 11\n/**\n * The family section titles draw in: the bundled Inter SemiBold under a name of its own, on the\n * canvas and in the page, so renaming a title shows the same glyphs and document fonts named\n * Inter cannot replace them.\n */\nexport const SECTION_TITLE_FONT_FAMILY = 'Pairdraw Section Title'\nexport const SECTION_TITLE_FONT_URL = '/Inter-SemiBold.ttf'\nexport const SECTION_TITLE_GAP = 6\nexport const SECTION_HOVER_STROKE_WIDTH = 2\n\nexport const COMPONENT_SET_DASH = 6\nexport const COMPONENT_SET_DASH_GAP = 4\nexport const COMPONENT_SET_BORDER_WIDTH = 1.5\n/** Corners of the outline the editor draws around a component set with no strokes of its own. */\nexport const COMPONENT_SET_OUTLINE_RADIUS = 5\nexport const COMPONENT_LABEL_FONT_SIZE = 11\nexport const COMPONENT_LABEL_GAP = 6\nexport const COMPONENT_LABEL_ICON_SIZE = 10\nexport const COMPONENT_LABEL_ICON_GAP = 4\n\nexport const RULER_TARGET_PIXEL_SPACING = 100\nexport const RULER_MAJOR_TOLERANCE = 0.01\n\nexport const FLASH_ATTACK_MS = 200\nexport const FLASH_HOLD_MS = 400\nexport const FLASH_RELEASE_MS = 300\nexport const FLASH_STROKE_WIDTH = 2\nexport const FLASH_PADDING = 5\nexport const FLASH_OVERSHOOT = 30\nexport const FLASH_RADIUS = 4\n\nexport const ISSUE_ERROR_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color // #F24822\nexport const ISSUE_WARNING_COLOR = { r: 1, g: 0.702, b: 0.078, a: 1 } satisfies Color // #FFB314\nexport const ISSUE_INFO_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const ISSUE_HIGHLIGHT_STROKE_WIDTH = 1.5\nexport const ISSUE_HIGHLIGHT_FILL_ALPHA = 0.08\n\n/** The violet AI agents show in everywhere, the app's `--color-agent`. */\nexport const AI_AGENT_COLOR = { r: 0.486, g: 0.361, b: 1 }\nexport const AI_DONE_COLOR = { r: 0.16, g: 0.73, b: 0.36 }\nexport const AI_DONE_DURATION_MS = 800\n/** How long a layer an agent adds takes to trace in, once its turn comes. */\nexport const AI_ENTER_DURATION_MS = 480\n/** The pause between the layers of one edit, so they appear one after another. */\nexport const AI_ENTER_STAGGER_MS = 45\n/** The last layer of an edit starts within this, however many layers the edit adds. */\nexport const AI_ENTER_MAX_DELAY_MS = 900\n/** One sweep of the light over an area an agent is working in. */\nexport const AI_SHIMMER_PERIOD_MS = 1600\n/** Width of the sweeping light, in screen pixels. */\nexport const AI_SHIMMER_BAND = 120\n\n/** Opacity of the selection color behind selected text while editing. */\nexport const TEXT_SELECTION_ALPHA = 0.3\n/** The caret's colour where the text's fill gives it none, as Figma's. */\nexport const TEXT_CARET_COLOR = BLACK\nexport const TEXT_CARET_WIDTH = 1\n\nexport const AUTOMATION_HTTP_PORT = 7600\n/**\n * Request header the app's own ACP and Pi harness chats send to the MCP server, so their sessions\n * show as those agents rather than as an outside MCP client.\n */\nexport const MCP_AGENT_HEADER = 'x-pairdraw-agent'\n\n/** The name the app's chats give Pairdraw's MCP server in an agent's session. */\nexport const PAIRDRAW_MCP_SERVER = 'pairdraw'\n\n/**\n * Request header naming the app chat whose agent opens an MCP session, so the app can tell that\n * this chat's agent reached its tools before it sends the prompt.\n */\nexport const MCP_CHAT_HEADER = 'x-pairdraw-chat'\n\nexport const GOOGLE_FONTS_API_KEY = 'AIzaSyD1tYDR_dUEiV-Tw1vksEhZbUytgKW5pc8'\n\nexport const CJK_FALLBACK_FAMILIES_MACOS = [\n 'PingFang SC',\n 'PingFang TC',\n 'Hiragino Sans',\n 'Apple SD Gothic Neo',\n 'Heiti SC',\n 'Heiti TC'\n]\n\nexport const CJK_FALLBACK_FAMILIES_WINDOWS = [\n 'Microsoft YaHei',\n 'Microsoft YaHei UI',\n 'Microsoft JhengHei',\n 'Yu Gothic',\n 'Malgun Gothic',\n 'SimHei',\n 'SimSun'\n]\n\nexport const CJK_FALLBACK_FAMILIES_LINUX = [\n 'Noto Sans CJK SC',\n 'Noto Sans CJK TC',\n 'Noto Sans CJK JP',\n 'Noto Sans CJK KR',\n 'WenQuanYi Micro Hei',\n 'Droid Sans Fallback'\n]\n\nexport const CJK_GOOGLE_FONTS = ['Noto Sans SC', 'Noto Sans TC', 'Noto Sans JP', 'Noto Sans KR']\n\n/** Figma's #D9D9D9 for new shapes. */\nexport const DEFAULT_SHAPE_FILL: Fill = {\n type: 'SOLID',\n color: { r: 217 / 255, g: 217 / 255, b: 217 / 255, a: 1 },\n opacity: 1,\n visible: true\n}\n\nexport const DEFAULT_FRAME_FILL: Fill = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n opacity: 1,\n visible: true\n}\n\n/** The light or dark interface a new page or section takes its colors from, as in Figma. */\nexport type InterfaceTheme = 'light' | 'dark'\n\n/** A new page's background, which Figma picks from the interface theme it was made in. */\nexport const PAGE_DEFAULT_BACKGROUNDS: Record<InterfaceTheme, Color> = {\n light: CANVAS_BG_COLOR,\n dark: { r: 0x1e / 255, g: 0x1e / 255, b: 0x1e / 255, a: 1 }\n}\n\n/** A FigJam board's page, #F5F5F5 whatever the interface theme, as Figma saves it. */\nexport const BOARD_PAGE_BACKGROUND = {\n r: 245 / 255,\n g: 245 / 255,\n b: 245 / 255,\n a: 1\n} satisfies Color\n\n/** A new section's fill, which Figma picks from the interface theme it was made in. */\nexport const SECTION_DEFAULT_FILLS: Record<InterfaceTheme, Fill> = {\n light: { type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true },\n dark: {\n type: 'SOLID',\n color: { r: 0x44 / 255, g: 0x44 / 255, b: 0x44 / 255, a: 1 },\n opacity: 1,\n visible: true\n }\n}\n\nexport const SECTION_DEFAULT_STROKE: Stroke = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n weight: 1,\n opacity: 0.1,\n visible: true,\n align: 'INSIDE'\n}\n\nexport const SECTION_CORNER_RADIUS = 2\n\nexport const ZOOM_DIVISOR = 50\nexport const ZOOM_SCALE_MIN = 0.75\nexport const ZOOM_SCALE_MAX = 1.25\n\nexport const PEN_CLOSE_THRESHOLD = 8\n/**\n * Screen pixels a pencil sample may stray from the line through its neighbours before the curve\n * keeps it, so a stroke drawn zoomed in keeps more detail.\n */\nexport const PENCIL_TOLERANCE = 2.5\n/** A new pencil layer's stroke weight (Figma desktop 126). */\nexport const PENCIL_STROKE_WEIGHT = 2\nexport const ROTATION_SNAP_DEGREES = 15\nexport const HANDLE_HIT_RADIUS = 6\n/** How far outside a shape, in screen pixels, a click still selects it (Figma desktop 126). */\nexport const LAYER_HIT_PAD = 3.5\nexport const ROTATION_HANDLE_DISTANCE = 24\nexport const DEFAULT_TEXT_WIDTH = 200\nexport const DEFAULT_TEXT_HEIGHT = 24\n/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */\nexport const DUPLICATE_FRAME_GAP = 40\n"],"mappings":";;;AAQA,MAAa,aAAa,OAAO,WAAW;AAC5C,MAAa,WAAW,cAAc,yBAAyB;AAE/D,MAAa,QAAe;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AACrD,MAAa,cAAqB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AAC3D,MAAa,uBAA8B;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAK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C5B,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAE9B,MAAa,sBAAsB;;;;;AAKnC,MAAa,mBAAmB;;AAEhC,MAAa,uBAAuB;AACpC,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;;AAEjC,MAAa,gBAAgB;AAC7B,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;;AAEnC,MAAa,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type { Fill, Stroke } from '@pairdraw/scene-graph'\nimport { WHITE } from '@pairdraw/scene-graph/constants'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { SelectionTheme } from '#core/canvas/renderer/types'\n\nexport * from './ai/providers'\n\nexport const IS_BROWSER = typeof window !== 'undefined'\nexport const IS_TAURI = IS_BROWSER && '__TAURI_INTERNALS__' in window\n\nexport const BLACK: Color = { r: 0, g: 0, b: 0, a: 1 }\nexport const TRANSPARENT: Color = { r: 0, g: 0, b: 0, a: 0 }\nexport const DEFAULT_SHADOW_COLOR: Color = { r: 0, g: 0, b: 0, a: 0.25 }\nexport const SELECTION_COLOR = { r: 0.23, g: 0.51, b: 0.96, a: 1 } satisfies Color\n/** Selection chrome when the app sets no accent: the default blue with white text. */\nexport const DEFAULT_SELECTION_THEME: Readonly<SelectionTheme> = {\n color: SELECTION_COLOR,\n foreground: WHITE\n}\nexport const COMPONENT_COLOR = { r: 0.592, g: 0.278, b: 1, a: 1 } satisfies Color\n/** Slot frames and their outlines, `#f24bbc` like the app's `--color-slot`. */\nexport const SLOT_COLOR = { r: 0.949, g: 0.294, b: 0.737, a: 1 } satisfies Color\nexport const SLOT_EMPTY_FILL_ALPHA = 0.08\nexport const SNAP_COLOR = { r: 1.0, g: 0.0, b: 0.56, a: 1 } satisfies Color\n/** Guides through path vertices and their crosses, measured from Figma's pen and vector edit mode. */\nexport const VERTEX_SNAP_COLOR = { r: 0.81, g: 0.3, b: 0.18, a: 1 } satisfies Color\nexport const VERTEX_SNAP_GUIDE_ALPHA = 0.6\nexport const VERTEX_SNAP_MARK_RADIUS = 2.5\n/** Half the length of the ticks that end an equal-spacing indicator, in screen pixels. */\nexport const SPACING_GUIDE_CAP = 4\nexport const MEASUREMENT_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color\nexport const MEASUREMENT_PILL_PADDING_X = 5\nexport const MEASUREMENT_PILL_HEIGHT = 18\nexport const MEASUREMENT_PILL_RADIUS = 3\nexport const MEASUREMENT_TEXT_BASELINE = 4\nexport const CANVAS_BG_COLOR = { r: 0.96, g: 0.96, b: 0.96, a: 1 } satisfies Color\nexport const SNAP_THRESHOLD_SCREEN_PX = 5\n/** The grid a board's layers land on, as FigJam's dots every 16 units. */\nexport const BOARD_GRID = 16\n\nexport const RULER_SIZE = 20\nexport const RULER_BG_COLOR = { r: 0.14, g: 0.14, b: 0.14, a: 1 } satisfies Color\nexport const RULER_TICK_COLOR = { r: 0.4, g: 0.4, b: 0.4, a: 1 } satisfies Color\nexport const RULER_TEXT_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const RULER_BADGE_HEIGHT = 14\nexport const RULER_BADGE_PADDING = 3\nexport const RULER_BADGE_RADIUS = 2\nexport const RULER_BADGE_EXCLUSION = 30\nexport const RULER_TEXT_BASELINE = 0.65\nexport const RULER_MAJOR_TICK = 0.5\nexport const RULER_MINOR_TICK = 0.25\nexport const RULER_HIGHLIGHT_ALPHA = 0.3\n\nexport const PEN_HANDLE_RADIUS = 2.5\nexport const PEN_VERTEX_RADIUS = 3\nexport const PEN_ANCHOR_RADIUS = 4\nexport const PEN_CLOSE_RADIUS_BOOST = 2\nexport const PEN_PATH_STROKE_WIDTH = 2\nexport const PARENT_OUTLINE_ALPHA = 0.5\nexport const DEFAULT_FONT_FAMILY = 'Inter'\nexport const DEFAULT_FONT_SIZE = 14\nexport const DEFAULT_STROKE_MITER_LIMIT = 4\n/** Figma's stroke weight for a node that has not been given one. */\nexport const LABEL_FONT_SIZE = 11\nexport const SIZE_FONT_SIZE = 10\nexport const HUD_FONT_SIZE = 10\nexport const VALUE_FONT_SIZE = 11\n\nexport const HANDLE_HALF_SIZE = 3\n\nexport const LABEL_OFFSET_Y = 8\nexport const SIZE_PILL_PADDING_X = 6\nexport const SIZE_PILL_PADDING_Y = 6\nexport const SIZE_PILL_HEIGHT = 18\nexport const SIZE_PILL_RADIUS = 4\nexport const SIZE_PILL_TEXT_OFFSET_Y = 13\n\nexport const MARQUEE_FILL_ALPHA = 0.08\nexport const SELECTION_DASH_ALPHA = 0.6\n/** Tint inside the layer of the code element around the cursor, under its hover outline. */\nexport const CODE_FOCUS_FILL_ALPHA = 0.1\nexport const DROP_HIGHLIGHT_ALPHA = 0.8\nexport const DROP_HIGHLIGHT_STROKE = 2\n\nexport const LAYOUT_INDICATOR_STROKE = 2\nexport const AUTO_LAYOUT_HOVER_TICK_LENGTH = 12\nexport const AUTO_LAYOUT_HOVER_STRIPE_GAP = 8\nexport const AUTO_LAYOUT_HOVER_STRIPE_WIDTH = 1\nexport const AUTO_LAYOUT_HOVER_STROKE_WIDTH = 1.5\n/** Dash and gap, in screen pixels, of the dotted outlines around auto layout children (Figma 126). */\nexport const LAYOUT_OUTLINE_DASH = 1.75\nexport const LAYOUT_OUTLINE_GAP = 1.25\nexport const AUTO_LAYOUT_HOVER_VALUE_OFFSET = 18\n// Measured on Figma desktop 126's padding and gap value pills.\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_HEIGHT = 16.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_RADIUS = 2.5\nexport const AUTO_LAYOUT_HOVER_VALUE_PILL_PADDING_X = 4.5\nexport const AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE = 12\nexport const AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE = 8\nexport const AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE = 20\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_X = 18\nexport const AUTO_LAYOUT_PADDING_EDITOR_OFFSET_Y = 36\nexport const AUTO_LAYOUT_HOVER_BLUE = { r: 0.28, g: 0.64, b: 1, a: 0.82 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_BLUE_FILL = { r: 0.28, g: 0.64, b: 1, a: 0.1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA = { r: 1, g: 0.32, b: 0.68, a: 0.78 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_MAGENTA_FILL = { r: 1, g: 0.32, b: 0.68, a: 0.1 } satisfies Color\n// The value pills over a gap and a padding, sampled from Figma desktop 126.\nexport const AUTO_LAYOUT_HOVER_GAP_PILL = { r: 0.886, g: 0.271, b: 0.686, a: 1 } satisfies Color\nexport const AUTO_LAYOUT_HOVER_PADDING_PILL = { r: 0.271, g: 0.592, b: 0.973, a: 1 } satisfies Color\n\nexport const SECTION_TITLE_HEIGHT = 24\nexport const SECTION_TITLE_PADDING_X = 6\nexport const SECTION_TITLE_RADIUS = 5\nexport const SECTION_TITLE_FONT_SIZE = 11\n/**\n * The family section titles draw in: the bundled Inter SemiBold under a name of its own, on the\n * canvas and in the page, so renaming a title shows the same glyphs and document fonts named\n * Inter cannot replace them.\n */\nexport const SECTION_TITLE_FONT_FAMILY = 'Pairdraw Section Title'\nexport const SECTION_TITLE_FONT_URL = '/Inter-SemiBold.ttf'\nexport const SECTION_TITLE_GAP = 6\nexport const SECTION_HOVER_STROKE_WIDTH = 2\n\nexport const COMPONENT_SET_DASH = 6\nexport const COMPONENT_SET_DASH_GAP = 4\nexport const COMPONENT_SET_BORDER_WIDTH = 1.5\n/** Corners of the outline the editor draws around a component set with no strokes of its own. */\nexport const COMPONENT_SET_OUTLINE_RADIUS = 5\nexport const COMPONENT_LABEL_FONT_SIZE = 11\nexport const COMPONENT_LABEL_GAP = 6\nexport const COMPONENT_LABEL_ICON_SIZE = 10\nexport const COMPONENT_LABEL_ICON_GAP = 4\n\nexport const RULER_TARGET_PIXEL_SPACING = 100\nexport const RULER_MAJOR_TOLERANCE = 0.01\n\nexport const FLASH_ATTACK_MS = 200\nexport const FLASH_HOLD_MS = 400\nexport const FLASH_RELEASE_MS = 300\nexport const FLASH_STROKE_WIDTH = 2\nexport const FLASH_PADDING = 5\nexport const FLASH_OVERSHOOT = 30\nexport const FLASH_RADIUS = 4\n\nexport const ISSUE_ERROR_COLOR = { r: 0.949, g: 0.282, b: 0.133, a: 1 } satisfies Color // #F24822\nexport const ISSUE_WARNING_COLOR = { r: 1, g: 0.702, b: 0.078, a: 1 } satisfies Color // #FFB314\nexport const ISSUE_INFO_COLOR = { r: 0.55, g: 0.55, b: 0.55, a: 1 } satisfies Color\nexport const ISSUE_HIGHLIGHT_STROKE_WIDTH = 1.5\nexport const ISSUE_HIGHLIGHT_FILL_ALPHA = 0.08\n\n/** The violet AI agents show in everywhere, the app's `--color-agent`. */\nexport const AI_AGENT_COLOR = { r: 0.486, g: 0.361, b: 1 }\nexport const AI_DONE_COLOR = { r: 0.16, g: 0.73, b: 0.36 }\nexport const AI_DONE_DURATION_MS = 800\n/** How long a layer an agent adds takes to trace in, once its turn comes. */\nexport const AI_ENTER_DURATION_MS = 480\n/** The pause between the layers of one edit, so they appear one after another. */\nexport const AI_ENTER_STAGGER_MS = 45\n/** The last layer of an edit starts within this, however many layers the edit adds. */\nexport const AI_ENTER_MAX_DELAY_MS = 900\n/** One sweep of the light over an area an agent is working in. */\nexport const AI_SHIMMER_PERIOD_MS = 1600\n/** Width of the sweeping light, in screen pixels. */\nexport const AI_SHIMMER_BAND = 120\n\n/** Opacity of the selection color behind selected text while editing. */\nexport const TEXT_SELECTION_ALPHA = 0.3\n/** The caret's colour where the text's fill gives it none, as Figma's. */\nexport const TEXT_CARET_COLOR = BLACK\nexport const TEXT_CARET_WIDTH = 1\n\nexport const AUTOMATION_HTTP_PORT = 7600\n/**\n * Request header the app's own ACP and Pi harness chats send to the MCP server, so their sessions\n * show as those agents rather than as an outside MCP client.\n */\nexport const MCP_AGENT_HEADER = 'x-pairdraw-agent'\n\n/** The name the app's chats give Pairdraw's MCP server in an agent's session. */\nexport const PAIRDRAW_MCP_SERVER = 'pairdraw'\n\n/**\n * Request header naming the app chat whose agent opens an MCP session, so the app can tell that\n * this chat's agent reached its tools before it sends the prompt.\n */\nexport const MCP_CHAT_HEADER = 'x-pairdraw-chat'\n\nexport const GOOGLE_FONTS_API_KEY = 'AIzaSyD1tYDR_dUEiV-Tw1vksEhZbUytgKW5pc8'\n\nexport const CJK_FALLBACK_FAMILIES_MACOS = [\n 'PingFang SC',\n 'PingFang TC',\n 'Hiragino Sans',\n 'Apple SD Gothic Neo',\n 'Heiti SC',\n 'Heiti TC'\n]\n\nexport const CJK_FALLBACK_FAMILIES_WINDOWS = [\n 'Microsoft YaHei',\n 'Microsoft YaHei UI',\n 'Microsoft JhengHei',\n 'Yu Gothic',\n 'Malgun Gothic',\n 'SimHei',\n 'SimSun'\n]\n\nexport const CJK_FALLBACK_FAMILIES_LINUX = [\n 'Noto Sans CJK SC',\n 'Noto Sans CJK TC',\n 'Noto Sans CJK JP',\n 'Noto Sans CJK KR',\n 'WenQuanYi Micro Hei',\n 'Droid Sans Fallback'\n]\n\nexport const CJK_GOOGLE_FONTS = ['Noto Sans SC', 'Noto Sans TC', 'Noto Sans JP', 'Noto Sans KR']\n\n/** Figma's #D9D9D9 for new shapes. */\nexport const DEFAULT_SHAPE_FILL: Fill = {\n type: 'SOLID',\n color: { r: 217 / 255, g: 217 / 255, b: 217 / 255, a: 1 },\n opacity: 1,\n visible: true\n}\n\nexport const DEFAULT_FRAME_FILL: Fill = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n opacity: 1,\n visible: true\n}\n\n/** The light or dark interface a new page or section takes its colors from, as in Figma. */\nexport type InterfaceTheme = 'light' | 'dark'\n\n/** A new page's background, which Figma picks from the interface theme it was made in. */\nexport const PAGE_DEFAULT_BACKGROUNDS: Record<InterfaceTheme, Color> = {\n light: CANVAS_BG_COLOR,\n dark: { r: 0x1e / 255, g: 0x1e / 255, b: 0x1e / 255, a: 1 }\n}\n\n/** A FigJam board's page, #F5F5F5 whatever the interface theme, as Figma saves it. */\nexport const BOARD_PAGE_BACKGROUND = {\n r: 245 / 255,\n g: 245 / 255,\n b: 245 / 255,\n a: 1\n} satisfies Color\n\n/** A new section's fill, which Figma picks from the interface theme it was made in. */\nexport const SECTION_DEFAULT_FILLS: Record<InterfaceTheme, Fill> = {\n light: { type: 'SOLID', color: { r: 1, g: 1, b: 1, a: 1 }, opacity: 1, visible: true },\n dark: {\n type: 'SOLID',\n color: { r: 0x44 / 255, g: 0x44 / 255, b: 0x44 / 255, a: 1 },\n opacity: 1,\n visible: true\n }\n}\n\nexport const SECTION_DEFAULT_STROKE: Stroke = {\n type: 'SOLID',\n color: { r: 1, g: 1, b: 1, a: 1 },\n weight: 1,\n opacity: 0.1,\n visible: true,\n align: 'INSIDE'\n}\n\nexport const SECTION_CORNER_RADIUS = 2\n\n/** Effect filters a renderer keeps: a slider drag would otherwise keep every value it passed. */\nexport const EFFECT_FILTER_CACHE_ENTRIES = 64\n\nexport const ZOOM_DIVISOR = 50\nexport const ZOOM_SCALE_MIN = 0.75\nexport const ZOOM_SCALE_MAX = 1.25\n\nexport const PEN_CLOSE_THRESHOLD = 8\n/** Points a pen path needs before a press on its first point closes it: two make a closed shape, as in Figma. */\nexport const PEN_CLOSE_MIN_POINTS = 2\n/**\n * Screen pixels a pencil sample may stray from the line through its neighbours before the curve\n * keeps it, so a stroke drawn zoomed in keeps more detail.\n */\nexport const PENCIL_TOLERANCE = 2.5\n/** A new pencil layer's stroke weight (Figma desktop 126). */\nexport const PENCIL_STROKE_WEIGHT = 2\nexport const ROTATION_SNAP_DEGREES = 15\nexport const HANDLE_HIT_RADIUS = 6\n/** How far outside a shape, in screen pixels, a click still selects it (Figma desktop 126). */\nexport const LAYER_HIT_PAD = 3.5\nexport const ROTATION_HANDLE_DISTANCE = 24\nexport const DEFAULT_TEXT_WIDTH = 200\nexport const DEFAULT_TEXT_HEIGHT = 24\n/** Space Figma leaves between a duplicated top-level frame and the layers to its left. */\nexport const DUPLICATE_FRAME_GAP = 40\n"],"mappings":";;;AAQA,MAAa,aAAa,OAAO,WAAW;AAC5C,MAAa,WAAW,cAAc,yBAAyB;AAE/D,MAAa,QAAe;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AACrD,MAAa,cAAqB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;AAC3D,MAAa,uBAA8B;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;AAAK;AACvE,MAAa,kBAAkB;CAAE,GAAG;CAAM,GAAG;CAAM,GAAG;CAAM,GAAG;AAAE;;AAEjE,MAAa,0BAAoD;CAC/D,OAAO;CACP,YAAY;AACd;AACA,MAAa,kBAAkB;CAAE,GAAG;CAAO,GAAG;CAAO,GAAG;CAAG,GAAG;AAAE;;AAEhE,MAAa,aAAa;CAAE,GAAG;CAAO,GAAG;CAAO,GAAG;CAAO,GAAG;AAAE;AAC/D,MAAa,wBAAwB;AACrC,MAAa,aAAa;CAAE,GAAG;CAAK,GAAG;CAAK,GAAG;CAAM,GAAG;AAAE;;AAE1D,MAAa,oBAAoB;CAAE,GAAG;CAAM,GAAG;CAAK,GAAG;CAAM,GAAG;AAAE;AAClE,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;;AAEvC,MAAa,oBAAoB;AACjC,MAAa,oBAAoB;CAAE,GAAG;CAAO,GAAG;CAAO,GAAG;CAAO,GAAG;AAAE;AACtE,MAAa,6BAA6B;AAC1C,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;AACvC,MAAa,4BAA4B;AACzC,MAAa,kBAAkB;CAAE,GAAG;CAAM,GAAG;CAAM,GAAG;CAAM,GAAG;AAAE;AACjE,MAAa,2BAA2B;;AAExC,MAAa,aAAa;AAE1B,MAAa,a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AE,MAAM;EAAS,OAAO;GAAE,GAAG;GAAG,GAAG;GAAG,GAAG;GAAG,GAAG;EAAE;EAAG,SAAS;EAAG,SAAS;CAAK;CACrF,MAAM;EACJ,MAAM;EACN,OAAO;GAAE,GAAG,KAAO;GAAK,GAAG,KAAO;GAAK,GAAG,KAAO;GAAK,GAAG;EAAE;EAC3D,SAAS;EACT,SAAS;CACX;AACF;AAEA,MAAa,yBAAiC;CAC5C,MAAM;CACN,OAAO;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;CAAE;CAChC,QAAQ;CACR,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAa,wBAAwB;;AAGrC,MAAa,8BAA8B;AAE3C,MAAa,eAAe;AAC5B,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAE9B,MAAa,sBAAsB;;AAEnC,MAAa,uBAAuB;;;;;AAKpC,MAAa,mBAAmB;;AAEhC,MAAa,uBAAuB;AACpC,MAAa,wBAAwB;AACrC,MAAa,oBAAoB;;AAEjC,MAAa,gBAAgB;AAC7B,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;;AAEnC,MAAa,sBAAsB"}
|
|
@@ -22,6 +22,7 @@ declare function createClipboardBridge(clipboard: ClipboardActions, selection: S
|
|
|
22
22
|
replaceInInstance?: boolean;
|
|
23
23
|
dependencies?: ClipboardImportChoice;
|
|
24
24
|
}) => Promise<void>;
|
|
25
|
+
pastePlainText: (text: string, cx?: number, cy?: number) => Promise<boolean>;
|
|
25
26
|
deleteSelected: () => void;
|
|
26
27
|
storeImage: (bytes: Uint8Array) => string;
|
|
27
28
|
placeFiles: (files: File[], cx: number, cy: number) => Promise<void>;
|
|
@@ -6,6 +6,7 @@ function createClipboardBridge(clipboard, selection) {
|
|
|
6
6
|
prepareCopy: (options) => clipboard.prepareCopy(selection.getSelectedNodes(), options),
|
|
7
7
|
pasteSnapshot: clipboard.pasteSnapshot,
|
|
8
8
|
pasteFromHTML: clipboard.pasteFromHTML,
|
|
9
|
+
pastePlainText: clipboard.pastePlainText,
|
|
9
10
|
deleteSelected: clipboard.deleteSelected,
|
|
10
11
|
storeImage: clipboard.storeImage,
|
|
11
12
|
placeFiles: clipboard.placeFiles,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.js","names":[],"sources":["../../../src/editor/bridges/clipboard.ts"],"sourcesContent":["import type { createClipboardActions } from '#core/editor/clipboard'\nimport type { CopyOptions } from '#core/editor/clipboard/copy'\nimport type { createSelectionActions } from '#core/editor/selection'\n\ntype ClipboardActions = ReturnType<typeof createClipboardActions>\ntype SelectionActions = ReturnType<typeof createSelectionActions>\n\nexport function createClipboardBridge(clipboard: ClipboardActions, selection: SelectionActions) {\n return {\n duplicateSelected: () => clipboard.duplicateSelected(selection.getSelectedNodes()),\n duplicateNode: clipboard.duplicateNode,\n prepareCopy: (options?: CopyOptions) =>\n clipboard.prepareCopy(selection.getSelectedNodes(), options),\n pasteSnapshot: clipboard.pasteSnapshot,\n pasteFromHTML: clipboard.pasteFromHTML,\n deleteSelected: clipboard.deleteSelected,\n storeImage: clipboard.storeImage,\n placeFiles: clipboard.placeFiles,\n placeImageFiles: clipboard.placeImageFiles,\n pasteSVG: clipboard.pasteSVG,\n pasteMermaid: clipboard.pasteMermaid,\n pasteStyledDocument: clipboard.pasteStyledDocument,\n loadFontsForNodes: clipboard.loadFontsForNodes,\n copySelectionAsText: clipboard.copySelectionAsText,\n copySelectionAsSVG: clipboard.copySelectionAsSVG,\n copySelectionAsJSX: clipboard.copySelectionAsJSX,\n copySelectionAsHTML: clipboard.copySelectionAsHTML\n }\n}\n"],"mappings":";AAOA,SAAgB,sBAAsB,WAA6B,WAA6B;CAC9F,OAAO;EACL,yBAAyB,UAAU,kBAAkB,UAAU,iBAAiB,CAAC;EACjF,eAAe,UAAU;EACzB,cAAc,YACZ,UAAU,YAAY,UAAU,iBAAiB,GAAG,OAAO;EAC7D,eAAe,UAAU;EACzB,eAAe,UAAU;EACzB,gBAAgB,UAAU;EAC1B,YAAY,UAAU;EACtB,YAAY,UAAU;EACtB,iBAAiB,UAAU;EAC3B,UAAU,UAAU;EACpB,cAAc,UAAU;EACxB,qBAAqB,UAAU;EAC/B,mBAAmB,UAAU;EAC7B,qBAAqB,UAAU;EAC/B,oBAAoB,UAAU;EAC9B,oBAAoB,UAAU;EAC9B,qBAAqB,UAAU;CACjC;AACF"}
|
|
1
|
+
{"version":3,"file":"clipboard.js","names":[],"sources":["../../../src/editor/bridges/clipboard.ts"],"sourcesContent":["import type { createClipboardActions } from '#core/editor/clipboard'\nimport type { CopyOptions } from '#core/editor/clipboard/copy'\nimport type { createSelectionActions } from '#core/editor/selection'\n\ntype ClipboardActions = ReturnType<typeof createClipboardActions>\ntype SelectionActions = ReturnType<typeof createSelectionActions>\n\nexport function createClipboardBridge(clipboard: ClipboardActions, selection: SelectionActions) {\n return {\n duplicateSelected: () => clipboard.duplicateSelected(selection.getSelectedNodes()),\n duplicateNode: clipboard.duplicateNode,\n prepareCopy: (options?: CopyOptions) =>\n clipboard.prepareCopy(selection.getSelectedNodes(), options),\n pasteSnapshot: clipboard.pasteSnapshot,\n pasteFromHTML: clipboard.pasteFromHTML,\n pastePlainText: clipboard.pastePlainText,\n deleteSelected: clipboard.deleteSelected,\n storeImage: clipboard.storeImage,\n placeFiles: clipboard.placeFiles,\n placeImageFiles: clipboard.placeImageFiles,\n pasteSVG: clipboard.pasteSVG,\n pasteMermaid: clipboard.pasteMermaid,\n pasteStyledDocument: clipboard.pasteStyledDocument,\n loadFontsForNodes: clipboard.loadFontsForNodes,\n copySelectionAsText: clipboard.copySelectionAsText,\n copySelectionAsSVG: clipboard.copySelectionAsSVG,\n copySelectionAsJSX: clipboard.copySelectionAsJSX,\n copySelectionAsHTML: clipboard.copySelectionAsHTML\n }\n}\n"],"mappings":";AAOA,SAAgB,sBAAsB,WAA6B,WAA6B;CAC9F,OAAO;EACL,yBAAyB,UAAU,kBAAkB,UAAU,iBAAiB,CAAC;EACjF,eAAe,UAAU;EACzB,cAAc,YACZ,UAAU,YAAY,UAAU,iBAAiB,GAAG,OAAO;EAC7D,eAAe,UAAU;EACzB,eAAe,UAAU;EACzB,gBAAgB,UAAU;EAC1B,gBAAgB,UAAU;EAC1B,YAAY,UAAU;EACtB,YAAY,UAAU;EACtB,iBAAiB,UAAU;EAC3B,UAAU,UAAU;EACpB,cAAc,UAAU;EACxB,qBAAqB,UAAU;EAC/B,mBAAmB,UAAU;EAC7B,qBAAqB,UAAU;EAC/B,oBAAoB,UAAU;EAC9B,oBAAoB,UAAU;EAC9B,qBAAqB,UAAU;CACjC;AACF"}
|
|
@@ -16,6 +16,8 @@ declare function createComponentBridge(components: ComponentActions, selection:
|
|
|
16
16
|
createComponentSetFromComponents: () => void;
|
|
17
17
|
createInstanceFromComponent: (componentId: string, x?: number, y?: number, parentId?: string) => string | null;
|
|
18
18
|
detachInstance: () => void;
|
|
19
|
+
instanceHasOverrides: (id: string) => boolean;
|
|
20
|
+
resetInstanceOverrides: (id: string) => void;
|
|
19
21
|
canConvertToFrame: (componentId: string) => boolean;
|
|
20
22
|
componentInstanceCount: (componentId: string) => number;
|
|
21
23
|
requestComponentToFrame: (componentId: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","names":[],"sources":["../../../src/editor/bridges/components.ts"],"mappings":";;;;;;;;;KAKK,mBAAmB,kBAAkB;KACrC,cAAc,kBAAkB;KAChC,mBAAmB,kBAAkB;KACrC,mBAAmB,kBAAkB;iBAE1B,sBACd,YAAY,kBACZ,WAAW,kBACX,WAAW,kBACX,OAAO
|
|
1
|
+
{"version":3,"file":"components.d.ts","names":[],"sources":["../../../src/editor/bridges/components.ts"],"mappings":";;;;;;;;;KAKK,mBAAmB,kBAAkB;KACrC,cAAc,kBAAkB;KAChC,mBAAmB,kBAAkB;KACrC,mBAAmB,kBAAkB;iBAE1B,sBACd,YAAY,kBACZ,WAAW,kBACX,WAAW,kBACX,OAAO;;;;;;EAgBwB,yBAAA;;;;;EAKC,iBAAA,wBAAM"}
|
|
@@ -5,6 +5,8 @@ function createComponentBridge(components, selection, structure, pages) {
|
|
|
5
5
|
createComponentSetFromComponents: () => components.createComponentSetFromComponents(selection.getSelectedNodes(), structure.wrapSelectionInContainer),
|
|
6
6
|
createInstanceFromComponent: components.createInstanceFromComponent,
|
|
7
7
|
detachInstance: () => components.detachInstance(selection.getSelectedNode()),
|
|
8
|
+
instanceHasOverrides: components.instanceHasOverrides,
|
|
9
|
+
resetInstanceOverrides: (id) => components.resetInstanceOverrides(id),
|
|
8
10
|
canConvertToFrame: components.canConvertToFrame,
|
|
9
11
|
componentInstanceCount: components.componentInstanceCount,
|
|
10
12
|
requestComponentToFrame: components.requestComponentToFrame,
|