@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":"style.js","names":[],"sources":["../../../src/text/font/style.ts"],"sourcesContent":["import {\n FONT_WEIGHT_NAMES,\n namesWeight,\n normalizeFontFamily,\n type FontFamilyStyle,\n parseFontStyle\n} from '@pairdraw/scene-graph/font-style'\n\nconst FONT_WEIGHTS = Object.keys(FONT_WEIGHT_NAMES)\n .map(Number)\n .toSorted((a, b) => a - b)\n\n/**\n * Font weights in the order CSS font matching tries them for `weight`, as Skia picks a face\n * from a family: heavier first above 500, lighter first below 400, and from 400 to 500 the\n * weights up to 500, then lighter, then heavier.\n */\nexport function fontWeightMatchOrder(weight: number): number[] {\n const lighter = FONT_WEIGHTS.filter((candidate) => candidate < weight).toReversed()\n const heavier = FONT_WEIGHTS.filter((candidate) => candidate > weight)\n const own = FONT_WEIGHTS.includes(weight) ? [weight] : []\n if (weight > 500) return [...own, ...heavier, ...lighter]\n if (weight < 400) return [...own, ...lighter, ...heavier]\n const upTo500 = heavier.filter((candidate) => candidate <= 500)\n return [...own, ...upTo500, ...lighter, ...heavier.filter((candidate) => candidate > 500)]\n}\n\n/**\n * A local font for a family and style. A style asked for is matched exactly, by name or by\n * weight and slant, since the face is registered as that style; without one, the face CSS\n * font matching would pick for the regular style.\n */\nexport function chooseLocalFontMatch<T extends FontFamilyStyle>(\n fonts: T[],\n family: string,\n style?: string\n): T | undefined {\n const families = [family]\n const normalized = normalizeFontFamily(family)\n if (normalized !== family) families.push(normalized)\n const requested = parseFontStyle(style)\n\n for (const candidateFamily of families) {\n const exact = style\n ? fonts.find((font) => font.family === candidateFamily && font.style === style)\n : undefined\n if (exact) return exact\n // A face named apart from its weight is that face or none, never another of its weight.\n if (style && !namesWeight(style)) continue\n\n const candidates = fonts.filter((font) => font.family === candidateFamily)\n const sameStyle = candidates.find((font) => {\n const parsed = parseFontStyle(font.style)\n return parsed.weight === requested.weight && parsed.italic === requested.italic\n })\n if (sameStyle) return sameStyle\n if (style) continue\n\n for (const italic of [requested.italic, !requested.italic]) {\n for (const weight of fontWeightMatchOrder(requested.weight)) {\n const match = candidates.find((font) => {\n const parsed = parseFontStyle(font.style)\n return parsed.weight === weight && parsed.italic === italic\n })\n if (match) return match\n }\n }\n if (candidates.length > 0) return candidates[0]\n }\n\n return undefined\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"style.js","names":[],"sources":["../../../src/text/font/style.ts"],"sourcesContent":["import { partition, uniq } from 'es-toolkit'\n\nimport {\n FONT_WEIGHT_NAMES,\n namesWeight,\n namesWidth,\n normalizeFontFamily,\n type FontFamilyStyle,\n parseFontStyle,\n styleSpelling\n} from '@pairdraw/scene-graph/font-style'\n\nconst FONT_WEIGHTS = Object.keys(FONT_WEIGHT_NAMES)\n .map(Number)\n .toSorted((a, b) => a - b)\n\n/**\n * Font weights in the order CSS font matching tries them for `weight`, as Skia picks a face\n * from a family: heavier first above 500, lighter first below 400, and from 400 to 500 the\n * weights up to 500, then lighter, then heavier.\n */\nexport function fontWeightMatchOrder(weight: number): readonly number[] {\n let order = matchOrders.get(weight)\n if (!order) {\n order = matchOrder(weight)\n matchOrders.set(weight, order)\n }\n return order\n}\n\nconst matchOrders = new Map<number, readonly number[]>()\n\nfunction matchOrder(weight: number): number[] {\n const lighter = FONT_WEIGHTS.filter((candidate) => candidate < weight).toReversed()\n const heavier = FONT_WEIGHTS.filter((candidate) => candidate > weight)\n const own = FONT_WEIGHTS.includes(weight) ? [weight] : []\n if (weight > 500) return [...own, ...heavier, ...lighter]\n if (weight < 400) return [...own, ...lighter, ...heavier]\n const upTo500 = heavier.filter((candidate) => candidate <= 500)\n return [...own, ...upTo500, ...lighter, ...heavier.filter((candidate) => candidate > 500)]\n}\n\n/**\n * A local font for a family and style. A style asked for is matched exactly, by name or by\n * weight and slant, since the face is registered as that style; without one, the face CSS\n * font matching would pick for the regular style.\n */\nexport function chooseLocalFontMatch<T extends FontFamilyStyle>(\n fonts: T[],\n family: string,\n style?: string\n): T | undefined {\n const families = [family]\n const normalized = normalizeFontFamily(family)\n if (normalized !== family) families.push(normalized)\n const requested = parseFontStyle(style)\n\n for (const candidateFamily of families) {\n const exact = style\n ? fonts.find((font) => font.family === candidateFamily && font.style === style)\n : undefined\n if (exact) return exact\n // A face named apart from its weight is that face or none, never another of its weight.\n if (style && !namesWeight(style)) continue\n\n const candidates = normalWidthFirst(fonts.filter((font) => font.family === candidateFamily))\n const sameStyle = candidates.find((font) => {\n const parsed = parseFontStyle(font.style)\n return parsed.weight === requested.weight && parsed.italic === requested.italic\n })\n if (sameStyle) return sameStyle\n if (style) continue\n\n for (const italic of [requested.italic, !requested.italic]) {\n for (const weight of fontWeightMatchOrder(requested.weight)) {\n const match = candidates.find((font) => {\n const parsed = parseFontStyle(font.style)\n return parsed.weight === weight && parsed.italic === italic\n })\n if (match) return match\n }\n }\n if (candidates.length > 0) return candidates[0]\n }\n\n return undefined\n}\n\nfunction normalWidthFirst<T extends FontFamilyStyle>(fonts: T[]): T[] {\n const [normalWidth, otherWidth] = partition(fonts, (font) => !namesWidth(font.style))\n return [...normalWidth, ...otherWidth]\n}\n\nexport interface NamedLocalFont extends FontFamilyStyle {\n fullName: string\n}\n\nfunction fontByFullName<T extends NamedLocalFont>(fonts: readonly T[], fullName: string) {\n const wanted = styleSpelling(fullName)\n return fonts.find((font) => styleSpelling(font.fullName) === wanted)\n}\n\n/** Windows lists a face beyond regular, bold, and italic as a family of its own, by its full name. */\nexport function findLocalFont<T extends NamedLocalFont>(\n fonts: T[],\n family: string,\n style?: string\n): T | undefined {\n const listed = chooseLocalFontMatch(fonts, family, style)\n if (listed || !style) {\n return listed\n }\n const families = uniq([family, normalizeFontFamily(family)])\n for (const named of families) {\n const font = fontByFullName(fonts, `${named} ${style}`)\n if (font) {\n return font\n }\n }\n return undefined\n}\n"],"mappings":";;;AAYA,MAAM,eAAe,OAAO,KAAK,iBAAiB,CAAC,CAChD,IAAI,MAAM,CAAC,CACX,UAAU,GAAG,MAAM,IAAI,CAAC;;;;;;AAO3B,SAAgB,qBAAqB,QAAmC;CACtE,IAAI,QAAQ,YAAY,IAAI,MAAM;CAClC,IAAI,CAAC,OAAO;EACV,QAAQ,WAAW,MAAM;EACzB,YAAY,IAAI,QAAQ,KAAK;CAC/B;CACA,OAAO;AACT;AAEA,MAAM,8BAAc,IAAI,IAA+B;AAEvD,SAAS,WAAW,QAA0B;CAC5C,MAAM,UAAU,aAAa,QAAQ,cAAc,YAAY,MAAM,CAAC,CAAC,WAAW;CAClF,M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AAO,WAAW,UAAU,OAAO,WAAW;GACvD,CAAC;GACD,IAAI,OAAO,OAAO;EACpB;EAEF,IAAI,WAAW,SAAS,GAAG,OAAO,WAAW;CAC/C;AAGF;AAEA,SAAS,iBAA4C,OAAiB;CACpE,MAAM,CAAC,aAAa,cAAc,UAAU,QAAQ,SAAS,CAAC,WAAW,KAAK,KAAK,CAAC;CACpF,OAAO,CAAC,GAAG,aAAa,GAAG,UAAU;AACvC;AAMA,SAAS,eAAyC,OAAqB,UAAkB;CACvF,MAAM,SAAS,cAAc,QAAQ;CACrC,OAAO,MAAM,MAAM,SAAS,cAAc,KAAK,QAAQ,MAAM,MAAM;AACrE;;AAGA,SAAgB,cACd,OACA,QACA,OACe;CACf,MAAM,SAAS,qBAAqB,OAAO,QAAQ,KAAK;CACxD,IAAI,UAAU,CAAC,OACb,OAAO;CAET,MAAM,WAAW,KAAK,CAAC,QAAQ,oBAAoB,MAAM,CAAC,CAAC;CAC3D,KAAK,MAAM,SAAS,UAAU;EAC5B,MAAM,OAAO,eAAe,OAAO,GAAG,MAAM,GAAG,OAAO;EACtD,IAAI,MACF,OAAO;CAEX;AAEF"}
|
package/dist/text/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { fitTextPathBoxToGlyphs } from "./path/fitting.js";
|
|
|
3
3
|
import { PathTextLayout, calibratePathTextLayout, layoutPathTextFromAdvances, reflowPathTextGlyphs } from "./path/layout.js";
|
|
4
4
|
import { PathPoint, SampledPath, nearestArcPoint, pointAtArc, sampleTextPath, textPathStartArc, textPathStartDistance } from "./path/sampling.js";
|
|
5
5
|
import { getTextPathData } from "./path/index.js";
|
|
6
|
-
import { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, DEVANAGARI_CHARACTER, FontFallbackManifestEntry, FontFallbackScript, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, LetterFallbackScript, THAI_CHARACTER,
|
|
6
|
+
import { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, CJK_CHARACTER, CJK_FALLBACK_CHARACTER, DEVANAGARI_CHARACTER, FontFallbackManifestEntry, FontFallbackScript, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, LetterFallbackScript, THAI_CHARACTER, cjkFallbackScriptForLanguage, cjkLocalFallbackFamilies, fallbackDrawsCharacter, fontFallbackEntry, fontFallbackManifest, fontFallbackScriptForCharacter, isTraditionalOnlyHan } from "./fallbacks.js";
|
|
7
7
|
import { FontCandidateSource, FontResolutionCandidate, FontResolutionDemand, FontResolutionEvent, FontResolutionListener, FontResolutionLoader, FontResolutionSettled, FontResolutionSnapshot, FontResolutionState } from "./resolver/types.js";
|
|
8
8
|
import { FontResolver } from "./resolver/resolver.js";
|
|
9
9
|
import { MissingGlyphOccurrence, ObservedShapedLine, missingGlyphCharacters, missingGlyphOccurrences, missingGlyphScripts, missingGlyphsByScript } from "./resolver/coverage.js";
|
|
@@ -13,6 +13,7 @@ import { FontAxis, NamedInstance, fontAxes, fontTableView, hasNamedInstance, has
|
|
|
13
13
|
import { TextCaret, TextEditor, TextEditorState } from "./editor.js";
|
|
14
14
|
import { HarfBuzzSubsetLocator, OutlineCommand, setHarfBuzzSubsetLocator } from "./font/harfbuzz.js";
|
|
15
15
|
import { GlyphOutlineProbe, probeGlyphOutlineCommands } from "./font/glyphs.js";
|
|
16
|
+
import { InsertStyleSource, adjustRunsForDelete, applyStyleToRange, getStyleAt, insertRunsWithStyle, insertedStyleAt, removeStyleFromRange, runsAfterTyping, selectionHasStyle, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange } from "./style-runs.js";
|
|
16
17
|
import { HyperlinkRunOptions, HyperlinkSpan, hyperlinkInRange, hyperlinkSpanAt, hyperlinkSpans, isOpenableLinkURL, normalizeLinkURL, styleRunsWithHyperlink } from "./hyperlink.js";
|
|
17
18
|
import { BundledFontLocator } from "./font/bundled.js";
|
|
18
19
|
import { DEFAULT_WEB_FONT_PROVIDER_SETTINGS, ResolvedWebFont, WEB_FONT_PROVIDER_IDS, WEB_FONT_PROVIDER_LABELS, WebFontFetch, WebFontProviderId, WebFontResolver, normalizedCoverageText, webFontSubsetsForText } from "./web-font/resolver.js";
|
|
@@ -22,12 +23,12 @@ import { FontManager, fontManager } from "./font/manager.js";
|
|
|
22
23
|
import { DocumentFontFaceStatus, DocumentFontStatus, FontFaceStatus, documentFontStatus } from "./font/status.js";
|
|
23
24
|
import { DocumentFontEntry, DocumentFontInput, documentFontData, documentFontsOf, isDocumentFontFileName, mergeArchiveFonts, prepareDocumentFonts, registerDocumentFonts } from "./font/document.js";
|
|
24
25
|
import { TextCaseSegment, shownCharacters, shownText, shownTextSlice, textCaseSegments, transformTextCase } from "./case.js";
|
|
26
|
+
import { layerTextStyleChanges, shownTextStyle } from "./character-style.js";
|
|
25
27
|
import { textFallbackScriptsWithoutCoverage, textHasFallbackScript, textNeededFallbackScripts, textNeedsFallbackScript } from "./coverage.js";
|
|
26
28
|
import { TextFace, collectNamedNodeFontFaces, faceForStyle, faceStyleName, textFaceName, textStyleName } from "./font/names.js";
|
|
27
|
-
import { chooseLocalFontMatch, fontWeightMatchOrder } from "./font/style.js";
|
|
29
|
+
import { NamedLocalFont, chooseLocalFontMatch, findLocalFont, fontWeightMatchOrder } from "./font/style.js";
|
|
28
30
|
import { isWOFF2, sfntFont } from "./font/woff2.js";
|
|
29
|
-
import { adjustRunsForDelete, adjustRunsForInsert, applyStyleToRange, getStyleAt, insertRunsWithStyle, removeStyleFromRange, selectionHasStyle, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange } from "./style-runs.js";
|
|
30
31
|
import { GraphFontRequirements, collectGraphFontKeys, collectGraphFontRequirements, collectNodeFontFaces, textFontFace } from "./requirements/collect.js";
|
|
31
32
|
import { MissingGraphFontScriptsOptions, missingGraphFontScripts } from "./requirements/resolved.js";
|
|
32
33
|
import { prepareGraphFonts } from "./prepare.js";
|
|
33
|
-
export { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, type BundledFontLocator, DEFAULT_WEB_FONT_PROVIDER_SETTINGS, DEVANAGARI_CHARACTER, DocumentFontEntry, DocumentFontFaceStatus, DocumentFontInput, DocumentFontStatus, DownloadedFontCache, FaceWeight, FamilyFace, FontAxis, FontCandidateSource, FontFaceRef, FontFaceStatus, FontFallbackManifestEntry, FontFallbackScript, FontFamilyOption, FontFamilySource, FontInfo, FontLoadedSource, FontManager, FontResolutionCandidate, FontResolutionDemand, FontResolutionEvent, FontResolutionListener, FontResolutionLoader, FontResolutionSettled, FontResolutionSnapshot, FontResolutionState, FontResolver, FontUnavailableReason, type GlyphOutlineProbe, GraphFontRequirements, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, type HarfBuzzSubsetLocator, type HostFontFamily, HostFontLoader, HyperlinkRunOptions, HyperlinkSpan, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, LetterFallbackScript, LocalFontAccessState, MissingGlyphOccurrence, MissingGraphFontScriptsOptions, NamedInstance, ObservedShapedLine, type OutlineCommand, PathPoint, PathTextCaret, PathTextLayout, PathTextLineMetrics, ResolvedWebFont, SampledPath, THAI_CHARACTER,
|
|
34
|
+
export { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, type BundledFontLocator, CJK_CHARACTER, CJK_FALLBACK_CHARACTER, DEFAULT_WEB_FONT_PROVIDER_SETTINGS, DEVANAGARI_CHARACTER, DocumentFontEntry, DocumentFontFaceStatus, DocumentFontInput, DocumentFontStatus, DownloadedFontCache, FaceWeight, FamilyFace, FontAxis, FontCandidateSource, FontFaceRef, FontFaceStatus, FontFallbackManifestEntry, FontFallbackScript, FontFamilyOption, FontFamilySource, FontInfo, FontLoadedSource, FontManager, FontResolutionCandidate, FontResolutionDemand, FontResolutionEvent, FontResolutionListener, FontResolutionLoader, FontResolutionSettled, FontResolutionSnapshot, FontResolutionState, FontResolver, FontUnavailableReason, type GlyphOutlineProbe, GraphFontRequirements, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, type HarfBuzzSubsetLocator, type HostFontFamily, HostFontLoader, HyperlinkRunOptions, HyperlinkSpan, InsertStyleSource, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, LetterFallbackScript, LocalFontAccessState, MissingGlyphOccurrence, MissingGraphFontScriptsOptions, NamedInstance, NamedLocalFont, ObservedShapedLine, type OutlineCommand, PathPoint, PathTextCaret, PathTextLayout, PathTextLineMetrics, ResolvedWebFont, SampledPath, THAI_CHARACTER, TextCaret, TextCaseSegment, TextEditor, TextEditorState, TextFace, UnsupportedFontFormatError, WEB_FONT_PROVIDER_IDS, WEB_FONT_PROVIDER_LABELS, WebFontFetch, WebFontProviderId, WebFontResolver, adjustRunsForDelete, applyStyleToRange, calibratePathTextLayout, chooseLocalFontMatch, cjkFallbackScriptForLanguage, cjkLocalFallbackFamilies, collectGraphFontKeys, collectGraphFontRequirements, collectNamedNodeFontFaces, collectNodeFontFaces, documentFontData, documentFontStatus, documentFontsOf, faceForStyle, faceStyleName, facesFromStyles, fallbackDrawsCharacter, findLocalFont, fitTextPathBoxToGlyphs, fontAxes, fontCoverageDemand, fontFaceDemand, fontFaceFromFigmaFontName, fontFaceRenderFamily, fontFallbackEntry, fontFallbackManifest, fontFallbackScriptForCharacter, fontManager, fontRemoteCoverageDemand, fontResolver, fontTableView, fontWeightMatchOrder, getStyleAt, getTextPathData, hasFamilyFace, hasNamedInstance, hasTrueTypeOutlines, hyperlinkInRange, hyperlinkSpanAt, hyperlinkSpans, insertRunsWithStyle, insertedStyleAt, isDocumentFontFileName, isOpenableLinkURL, isTraditionalOnlyHan, isVariableFont, isWOFF2, layerTextStyleChanges, layoutPathTextFromAdvances, mergeArchiveFonts, missingGlyphCharacters, missingGlyphOccurrences, missingGlyphScripts, missingGlyphsByScript, missingGraphFontScripts, namedInstanceVariations, namedInstances, nearestArcPoint, nearestFamilyFace, normalizeLinkURL, normalizedCoverageText, pathTextCaret, pathTextIndexAt, pathTextSelectionQuads, pointAtArc, prepareDocumentFonts, prepareGraphFonts, probeGlyphOutlineCommands, reflowPathTextGlyphs, registerDocumentFonts, removeStyleFromRange, runsAfterTyping, sampleTextPath, selectionHasStyle, setHarfBuzzSubsetLocator, sfntFamilyNames, sfntFont, sfntFontName, shownCharacters, shownText, shownTextSlice, shownTextStyle, standardFace, standardFaces, styleRunsWithHyperlink, textCaseSegments, textFaceName, textFallbackScriptsWithoutCoverage, textFontFace, textHasFallbackScript, textNeededFallbackScripts, textNeedsFallbackScript, textPathStartArc, textPathStartDistance, textStyleName, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange, transformTextCase, webFontSubsetsForText };
|
package/dist/text/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, DEVANAGARI_CHARACTER, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, THAI_CHARACTER,
|
|
1
|
+
import { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, CJK_CHARACTER, CJK_FALLBACK_CHARACTER, DEVANAGARI_CHARACTER, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, THAI_CHARACTER, cjkFallbackScriptForLanguage, cjkLocalFallbackFamilies, fallbackDrawsCharacter, fontFallbackEntry, fontFallbackManifest, fontFallbackScriptForCharacter, isTraditionalOnlyHan } from "./fallbacks.js";
|
|
2
2
|
import { facesFromStyles, fontFaceFromFigmaFontName, fontFaceRenderFamily, hasFamilyFace, nearestFamilyFace, standardFace, standardFaces } from "./font/faces.js";
|
|
3
3
|
import { fontAxes, fontTableView, hasNamedInstance, hasTrueTypeOutlines, isVariableFont, namedInstanceVariations, namedInstances, sfntFamilyNames, sfntFontName } from "./font/variation.js";
|
|
4
4
|
import { setHarfBuzzSubsetLocator } from "./font/harfbuzz.js";
|
|
5
|
-
import { chooseLocalFontMatch, fontWeightMatchOrder } from "./font/style.js";
|
|
5
|
+
import { chooseLocalFontMatch, findLocalFont, fontWeightMatchOrder } from "./font/style.js";
|
|
6
6
|
import { UnsupportedFontFormatError } from "./font/sources.js";
|
|
7
7
|
import { shownCharacters, shownText, shownTextSlice, textCaseSegments, transformTextCase } from "./case.js";
|
|
8
8
|
import { collectGraphFontKeys, collectGraphFontRequirements, collectNodeFontFaces, textFontFace } from "./requirements/collect.js";
|
|
@@ -18,6 +18,7 @@ import { getTextPathData } from "./path/index.js";
|
|
|
18
18
|
import { FontResolver } from "./resolver/resolver.js";
|
|
19
19
|
import { missingGlyphCharacters, missingGlyphOccurrences, missingGlyphScripts, missingGlyphsByScript } from "./resolver/coverage.js";
|
|
20
20
|
import { fontCoverageDemand, fontFaceDemand, fontRemoteCoverageDemand, fontResolver } from "./resolver/index.js";
|
|
21
|
+
import { layerTextStyleChanges, shownTextStyle } from "./character-style.js";
|
|
21
22
|
import { collectNamedNodeFontFaces, faceForStyle, faceStyleName, textFaceName, textStyleName } from "./font/names.js";
|
|
22
23
|
import { textFallbackScriptsWithoutCoverage, textHasFallbackScript, textNeededFallbackScripts, textNeedsFallbackScript } from "./coverage.js";
|
|
23
24
|
import { missingGraphFontScripts } from "./requirements/resolved.js";
|
|
@@ -25,6 +26,6 @@ import { documentFontStatus } from "./font/status.js";
|
|
|
25
26
|
import { prepareGraphFonts } from "./prepare.js";
|
|
26
27
|
import { documentFontData, documentFontsOf, isDocumentFontFileName, mergeArchiveFonts, prepareDocumentFonts, registerDocumentFonts } from "./font/document.js";
|
|
27
28
|
import { TextEditor } from "./editor.js";
|
|
28
|
-
import { adjustRunsForDelete,
|
|
29
|
+
import { adjustRunsForDelete, applyStyleToRange, getStyleAt, insertRunsWithStyle, insertedStyleAt, removeStyleFromRange, runsAfterTyping, selectionHasStyle, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange } from "./style-runs.js";
|
|
29
30
|
import { hyperlinkInRange, hyperlinkSpanAt, hyperlinkSpans, isOpenableLinkURL, normalizeLinkURL, styleRunsWithHyperlink } from "./hyperlink.js";
|
|
30
|
-
export { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, DEFAULT_WEB_FONT_PROVIDER_SETTINGS, DEVANAGARI_CHARACTER, FontManager, FontResolver, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, THAI_CHARACTER,
|
|
31
|
+
export { ARABIC_CHARACTER, ARABIC_LOCAL_FALLBACK_FAMILIES, ARABIC_REMOTE_FALLBACK_FAMILIES, CJK_CHARACTER, CJK_FALLBACK_CHARACTER, DEFAULT_WEB_FONT_PROVIDER_SETTINGS, DEVANAGARI_CHARACTER, FontManager, FontResolver, HANGUL_CHARACTER, HAN_CHARACTER, HEBREW_CHARACTER, KANA_CHARACTER, LETTER_FALLBACK_SCRIPTS, THAI_CHARACTER, TextEditor, UnsupportedFontFormatError, WEB_FONT_PROVIDER_IDS, WEB_FONT_PROVIDER_LABELS, WebFontResolver, adjustRunsForDelete, applyStyleToRange, calibratePathTextLayout, chooseLocalFontMatch, cjkFallbackScriptForLanguage, cjkLocalFallbackFamilies, collectGraphFontKeys, collectGraphFontRequirements, collectNamedNodeFontFaces, collectNodeFontFaces, documentFontData, documentFontStatus, documentFontsOf, faceForStyle, faceStyleName, facesFromStyles, fallbackDrawsCharacter, findLocalFont, fitTextPathBoxToGlyphs, fontAxes, fontCoverageDemand, fontFaceDemand, fontFaceFromFigmaFontName, fontFaceRenderFamily, fontFallbackEntry, fontFallbackManifest, fontFallbackScriptForCharacter, fontManager, fontRemoteCoverageDemand, fontResolver, fontTableView, fontWeightMatchOrder, getStyleAt, getTextPathData, hasFamilyFace, hasNamedInstance, hasTrueTypeOutlines, hyperlinkInRange, hyperlinkSpanAt, hyperlinkSpans, insertRunsWithStyle, insertedStyleAt, isDocumentFontFileName, isOpenableLinkURL, isTraditionalOnlyHan, isVariableFont, isWOFF2, layerTextStyleChanges, layoutPathTextFromAdvances, mergeArchiveFonts, missingGlyphCharacters, missingGlyphOccurrences, missingGlyphScripts, missingGlyphsByScript, missingGraphFontScripts, namedInstanceVariations, namedInstances, nearestArcPoint, nearestFamilyFace, normalizeLinkURL, normalizedCoverageText, pathTextCaret, pathTextIndexAt, pathTextSelectionQuads, pointAtArc, prepareDocumentFonts, prepareGraphFonts, probeGlyphOutlineCommands, reflowPathTextGlyphs, registerDocumentFonts, removeStyleFromRange, runsAfterTyping, sampleTextPath, selectionHasStyle, setHarfBuzzSubsetLocator, sfntFamilyNames, sfntFont, sfntFontName, shownCharacters, shownText, shownTextSlice, shownTextStyle, standardFace, standardFaces, styleRunsWithHyperlink, textCaseSegments, textFaceName, textFallbackScriptsWithoutCoverage, textFontFace, textHasFallbackScript, textNeededFallbackScripts, textNeedsFallbackScript, textPathStartArc, textPathStartDistance, textStyleName, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange, transformTextCase, webFontSubsetsForText };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outlines.d.ts","names":[],"sources":["../../src/text/outlines.ts"],"mappings":";;;;KAcY;KAOA;EACN;;EACA;EAAkB,QAAQ;;UAEf;EACf,UAAU;EACV;EACA;;UAGe;EACf,QAAQ;EACR;EACA;;
|
|
1
|
+
{"version":3,"file":"outlines.d.ts","names":[],"sources":["../../src/text/outlines.ts"],"mappings":";;;;KAcY;KAOA;EACN;;EACA;EAAkB,QAAQ;;UAEf;EACf,UAAU;EACV;EACA;;UAGe;EACf,QAAQ;EACR;EACA;;iBAuGc,sBAAsB,MAAM,YAAY;iBA0JxC,wBAAwB,MAAM,YAAY"}
|
package/dist/text/outlines.js
CHANGED
|
@@ -1,37 +1,51 @@
|
|
|
1
1
|
import { fontManager } from "./font/manager.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { drawnFontVariations } from "../canvas/text/font-families.js";
|
|
3
|
+
import { fontHasGlyphSync, getGlyphOutlineMetricsSync, shapedAdvancesSync } from "./font/glyphs.js";
|
|
4
|
+
import { lineHeightPixels, textLengthPixels, textVerticalOffset } from "@pairdraw/scene-graph/text";
|
|
5
5
|
import { faceStyleKey } from "@pairdraw/scene-graph/font-style";
|
|
6
6
|
import { rangeFontStyle } from "@pairdraw/scene-graph/shared-styles";
|
|
7
7
|
//#region src/text/outlines.ts
|
|
8
8
|
const COMPLEX_SCRIPT_PATTERN = /[\u0590-\u08ff\u0900-\u0dff\ufb1d-\ufdff\ufe70-\ufeff]/;
|
|
9
|
-
function
|
|
9
|
+
function withVariations(style, variations, opticalSizeFromFontSize) {
|
|
10
10
|
return {
|
|
11
|
+
...style,
|
|
12
|
+
variations: drawnFontVariations({
|
|
13
|
+
family: style.fontFamily,
|
|
14
|
+
weight: style.fontWeight,
|
|
15
|
+
italic: style.italic,
|
|
16
|
+
style: faceStyleKey(style),
|
|
17
|
+
fontSize: style.fontSize,
|
|
18
|
+
variations,
|
|
19
|
+
opticalSizeFromFontSize
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function baseTextStyle(node) {
|
|
24
|
+
return withVariations({
|
|
11
25
|
fontFamily: node.fontFamily,
|
|
12
26
|
fontSize: node.fontSize,
|
|
13
27
|
fontWeight: node.fontWeight,
|
|
14
28
|
italic: node.italic,
|
|
15
29
|
fontStyle: node.fontStyle,
|
|
16
30
|
letterSpacing: node.letterSpacing
|
|
17
|
-
};
|
|
31
|
+
}, node.fontVariations, node.opticalSizeFromFontSize);
|
|
18
32
|
}
|
|
19
33
|
function styleKey(style) {
|
|
20
34
|
const spacing = textLengthPixels(style.letterSpacing, style.fontSize);
|
|
21
|
-
|
|
35
|
+
const axes = style.variations.map(({ axis, value }) => `${axis}=${value}`).join(",");
|
|
36
|
+
return `${style.fontFamily}|${faceStyleKey(style)}|${style.fontSize}|${spacing}|${axes}`;
|
|
22
37
|
}
|
|
23
38
|
function textStyleAt(node, index) {
|
|
24
|
-
const base = baseTextStyle(node);
|
|
25
39
|
const run = node.styleRuns.find((item) => index >= item.start && index < item.start + item.length);
|
|
26
|
-
if (!run) return
|
|
27
|
-
return {
|
|
28
|
-
fontFamily: run.style.fontFamily ??
|
|
29
|
-
fontSize: run.style.fontSize ??
|
|
30
|
-
fontWeight: run.style.fontWeight ??
|
|
31
|
-
italic: run.style.italic ??
|
|
40
|
+
if (!run) return baseTextStyle(node);
|
|
41
|
+
return withVariations({
|
|
42
|
+
fontFamily: run.style.fontFamily ?? node.fontFamily,
|
|
43
|
+
fontSize: run.style.fontSize ?? node.fontSize,
|
|
44
|
+
fontWeight: run.style.fontWeight ?? node.fontWeight,
|
|
45
|
+
italic: run.style.italic ?? node.italic,
|
|
32
46
|
fontStyle: rangeFontStyle(node, run.style),
|
|
33
|
-
letterSpacing: run.style.letterSpacing ??
|
|
34
|
-
};
|
|
47
|
+
letterSpacing: run.style.letterSpacing ?? node.letterSpacing
|
|
48
|
+
}, run.style.fontVariations ?? node.fontVariations, run.style.opticalSizeFromFontSize ?? node.opticalSizeFromFontSize);
|
|
35
49
|
}
|
|
36
50
|
function resolvedGlyphStyle(style, char) {
|
|
37
51
|
if (fontHasGlyphSync(style.fontFamily, faceStyleKey(style), char)) return style;
|
|
@@ -103,23 +117,48 @@ function hardTextLines(text) {
|
|
|
103
117
|
}
|
|
104
118
|
return lines;
|
|
105
119
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
/** `line` split where the style its characters are drawn in changes, or `null` when one has none. */
|
|
121
|
+
function styleSegments(node, line) {
|
|
122
|
+
const segments = [];
|
|
123
|
+
for (let index = 0; index < line.text.length; index++) {
|
|
124
|
+
const style = resolvedGlyphStyle(textStyleAt(node, line.start + index), line.text[index]);
|
|
125
|
+
if (!style) return null;
|
|
126
|
+
const last = segments.at(-1);
|
|
127
|
+
if (last && styleKey(last.style) === styleKey(style)) last.end = index + 1;
|
|
128
|
+
else segments.push({
|
|
129
|
+
start: index,
|
|
130
|
+
end: index + 1,
|
|
131
|
+
style
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return segments;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The width each character of `line` adds as its segments are shaped and drawn, kerning and
|
|
138
|
+
* ligatures included: a glyph's advance and spacing go to the character it starts at.
|
|
139
|
+
*/
|
|
140
|
+
function characterAdvances(node, line) {
|
|
141
|
+
const segments = styleSegments(node, line);
|
|
142
|
+
if (!segments) return null;
|
|
143
|
+
const advances = Array.from({ length: line.text.length }).fill(0);
|
|
144
|
+
for (const { start, end, style } of segments) {
|
|
145
|
+
const glyphs = shapedAdvancesSync(style.fontFamily, faceStyleKey(style), line.text.slice(start, end), style.fontSize, style.variations);
|
|
146
|
+
if (!glyphs) return null;
|
|
147
|
+
const spacing = textLengthPixels(style.letterSpacing, style.fontSize);
|
|
148
|
+
for (const glyph of glyphs) advances[start + glyph.cluster] += glyph.advance + spacing;
|
|
149
|
+
}
|
|
150
|
+
return advances;
|
|
112
151
|
}
|
|
113
|
-
function
|
|
152
|
+
function wrapLine(node, line) {
|
|
114
153
|
if (!line.text || node.width <= 0) return [line];
|
|
154
|
+
const advances = characterAdvances(node, line);
|
|
155
|
+
if (!advances) return [line];
|
|
115
156
|
const result = [];
|
|
116
157
|
let lineStart = 0;
|
|
117
158
|
let cursor = 0;
|
|
118
159
|
let lastBreak = -1;
|
|
119
160
|
for (let index = 0; index < line.text.length; index++) {
|
|
120
|
-
|
|
121
|
-
if (advance == null) return [line];
|
|
122
|
-
cursor += advance;
|
|
161
|
+
cursor += advances[index];
|
|
123
162
|
if (/\s/.test(line.text[index])) lastBreak = index + 1;
|
|
124
163
|
if (cursor <= node.width || index === lineStart) continue;
|
|
125
164
|
const breakIndex = lastBreak > lineStart ? lastBreak : index;
|
|
@@ -141,29 +180,7 @@ function wrapStyledLine(node, line) {
|
|
|
141
180
|
function textLines(node) {
|
|
142
181
|
const hardLines = hardTextLines(node.text);
|
|
143
182
|
if (node.textAutoResize === "WIDTH_AND_HEIGHT") return hardLines;
|
|
144
|
-
|
|
145
|
-
const result = [];
|
|
146
|
-
for (const hardLine of hardLines) {
|
|
147
|
-
if (!hardLine.text) {
|
|
148
|
-
result.push(hardLine);
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
try {
|
|
152
|
-
const prepared = prepareWithSegments(hardLine.text, `${node.fontSize}px ${node.fontFamily}`);
|
|
153
|
-
const layout = layoutWithLines(prepared, node.width, lineHeight(node));
|
|
154
|
-
let start = hardLine.start;
|
|
155
|
-
for (const line of layout.lines) {
|
|
156
|
-
result.push({
|
|
157
|
-
text: line.text,
|
|
158
|
-
start
|
|
159
|
-
});
|
|
160
|
-
start += line.text.length;
|
|
161
|
-
}
|
|
162
|
-
} catch {
|
|
163
|
-
result.push(hardLine);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return result;
|
|
183
|
+
return hardLines.flatMap((line) => wrapLine(node, line));
|
|
167
184
|
}
|
|
168
185
|
function lineOffsetX(node, width) {
|
|
169
186
|
switch (node.textAlignHorizontal) {
|
|
@@ -172,29 +189,13 @@ function lineOffsetX(node, width) {
|
|
|
172
189
|
default: return 0;
|
|
173
190
|
}
|
|
174
191
|
}
|
|
175
|
-
function verticalOffset(node, contentHeight) {
|
|
176
|
-
switch (node.textAlignVertical) {
|
|
177
|
-
case "CENTER": return Math.max(0, (node.height - contentHeight) / 2);
|
|
178
|
-
case "BOTTOM": return Math.max(0, node.height - contentHeight);
|
|
179
|
-
default: return 0;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
192
|
function lineGlyphs(node, line, baseline, xOffset) {
|
|
193
|
+
const segments = styleSegments(node, line);
|
|
194
|
+
if (!segments) return null;
|
|
183
195
|
const glyphs = [];
|
|
184
196
|
let cursorX = xOffset;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const style = resolvedGlyphStyle(textStyleAt(node, line.start + index), line.text[index]);
|
|
188
|
-
if (!style) return null;
|
|
189
|
-
const key = styleKey(style);
|
|
190
|
-
let end = index + 1;
|
|
191
|
-
while (end < line.text.length) {
|
|
192
|
-
const nextStyle = resolvedGlyphStyle(textStyleAt(node, line.start + end), line.text[end]);
|
|
193
|
-
if (!nextStyle || styleKey(nextStyle) !== key) break;
|
|
194
|
-
end++;
|
|
195
|
-
}
|
|
196
|
-
const segment = line.text.slice(index, end);
|
|
197
|
-
const metrics = getGlyphOutlineMetricsSync(style.fontFamily, faceStyleKey(style), segment, style.fontSize);
|
|
197
|
+
for (const { start, end, style } of segments) {
|
|
198
|
+
const metrics = getGlyphOutlineMetricsSync(style.fontFamily, faceStyleKey(style), line.text.slice(start, end), style.fontSize, style.variations);
|
|
198
199
|
if (!metrics) return null;
|
|
199
200
|
for (const glyph of metrics) {
|
|
200
201
|
glyphs.push({
|
|
@@ -204,7 +205,6 @@ function lineGlyphs(node, line, baseline, xOffset) {
|
|
|
204
205
|
});
|
|
205
206
|
cursorX += glyph.advance + textLengthPixels(style.letterSpacing, style.fontSize);
|
|
206
207
|
}
|
|
207
|
-
index = end;
|
|
208
208
|
}
|
|
209
209
|
return {
|
|
210
210
|
glyphs,
|
|
@@ -216,7 +216,7 @@ function textNodeToOutlineLayout(node) {
|
|
|
216
216
|
const lines = textLines(node);
|
|
217
217
|
const lineH = lineHeight(node);
|
|
218
218
|
const contentHeight = lines.length * lineH;
|
|
219
|
-
const yOffset =
|
|
219
|
+
const yOffset = textVerticalOffset(node, contentHeight);
|
|
220
220
|
const glyphs = [];
|
|
221
221
|
let maxWidth = 0;
|
|
222
222
|
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outlines.js","names":[],"sources":["../../src/text/outlines.ts"],"sourcesContent":["import { prepareWithSegments, layoutWithLines } from '@chenglou/pretext'\n\nimport type { CharacterStyleOverride, SceneNode } from '@pairdraw/scene-graph'\nimport { faceStyleKey } from '@pairdraw/scene-graph/font-style'\nimport { rangeFontStyle } from '@pairdraw/scene-graph/shared-styles'\nimport { lineHeightPixels, textLengthPixels } from '@pairdraw/scene-graph/text'\n\nimport {\n fontHasGlyphSync,\n getGlyphOutlineMetricsSync,\n type OutlineCommand\n} from '#core/text/font/glyphs'\nimport { fontManager } from '#core/text/font/manager'\n\nexport type TextOutlineUnsupportedReason =\n | 'not-text'\n | 'empty-text'\n | 'missing-font'\n | 'missing-glyph'\n | 'complex-script'\n\nexport type TextOutlineSupport =\n | { supported: true }\n | { supported: false; reason: TextOutlineUnsupportedReason }\n\nexport interface TextOutlineGlyph {\n commands: OutlineCommand[]\n x: number\n y: number\n}\n\nexport interface TextOutlineLayout {\n glyphs: TextOutlineGlyph[]\n width: number\n height: number\n}\n\nconst COMPLEX_SCRIPT_PATTERN = /[\\u0590-\\u08ff\\u0900-\\u0dff\\ufb1d-\\ufdff\\ufe70-\\ufeff]/\n\ntype TextStyle = Required<\n Pick<\n CharacterStyleOverride,\n 'fontFamily' | 'fontSize' | 'fontWeight' | 'italic' | 'fontStyle' | 'letterSpacing'\n >\n>\n\nfunction baseTextStyle(node: SceneNode): TextStyle {\n return {\n fontFamily: node.fontFamily,\n fontSize: node.fontSize,\n fontWeight: node.fontWeight,\n italic: node.italic,\n fontStyle: node.fontStyle,\n letterSpacing: node.letterSpacing\n }\n}\n\nfunction styleKey(style: TextStyle): string {\n const spacing = textLengthPixels(style.letterSpacing, style.fontSize)\n return `${style.fontFamily}|${faceStyleKey(style)}|${style.fontSize}|${spacing}`\n}\n\nfunction textStyleAt(node: SceneNode, index: number): TextStyle {\n const base = baseTextStyle(node)\n const run = node.styleRuns.find((item) => index >= item.start && index < item.start + item.length)\n if (!run) return base\n return {\n fontFamily: run.style.fontFamily ?? base.fontFamily,\n fontSize: run.style.fontSize ?? base.fontSize,\n fontWeight: run.style.fontWeight ?? base.fontWeight,\n italic: run.style.italic ?? base.italic,\n fontStyle: rangeFontStyle(node, run.style),\n letterSpacing: run.style.letterSpacing ?? base.letterSpacing\n }\n}\n\nfunction resolvedGlyphStyle(style: TextStyle, char: string): TextStyle | null {\n if (fontHasGlyphSync(style.fontFamily, faceStyleKey(style), char)) return style\n const family = fallbackFamilies().find((candidate) => {\n const next = fallbackStyle(style, candidate)\n return (\n fontManager.loadedData(next.fontFamily, faceStyleKey(next)) &&\n fontHasGlyphSync(next.fontFamily, faceStyleKey(next), char)\n )\n })\n return family ? fallbackStyle(style, family) : null\n}\n\nfunction fallbackFamilies(): string[] {\n return [...fontManager.getCJKFallbackFamilies(), ...fontManager.getLetterFallbackFamilies()]\n}\n\n/** `style` in a script fallback family, which has none of the text family's named faces. */\nfunction fallbackStyle(style: TextStyle, family: string): TextStyle {\n return { ...style, fontFamily: family, fontStyle: null }\n}\n\nfunction textStyles(node: SceneNode): TextStyle[] {\n if (node.styleRuns.length === 0) return [baseTextStyle(node)]\n const styles = new Map<string, TextStyle>()\n for (let index = 0; index < node.text.length; index++) {\n const style = textStyleAt(node, index)\n styles.set(styleKey(style), style)\n }\n return [...styles.values()]\n}\n\nexport function getTextOutlineSupport(node: SceneNode): TextOutlineSupport {\n if (node.type !== 'TEXT') return { supported: false, reason: 'not-text' }\n if (!node.text) return { supported: false, reason: 'empty-text' }\n if (COMPLEX_SCRIPT_PATTERN.test(node.text)) return { supported: false, reason: 'complex-script' }\n for (const style of textStyles(node)) {\n if (!fontManager.loadedData(style.fontFamily, faceStyleKey(style))) {\n return { supported: false, reason: 'missing-font' }\n }\n }\n for (let index = 0; index < node.text.length; index++) {\n const char = node.text[index]\n if (char === '\\n') continue\n const style = textStyleAt(node, index)\n if (!resolvedGlyphStyle(style, char)) return { supported: false, reason: 'missing-glyph' }\n }\n return { supported: true }\n}\n\nfunction lineHeight(node: SceneNode): number {\n return lineHeightPixels(node.lineHeight, node.fontSize) ?? Math.ceil(node.fontSize * 1.2)\n}\n\ninterface TextLine {\n text: string\n start: number\n}\n\nfunction hardTextLines(text: string): TextLine[] {\n const lines: TextLine[] = []\n let start = 0\n for (const line of text.split('\\n')) {\n lines.push({ text: line, start })\n start += line.length + 1\n }\n return lines\n}\n\nfunction glyphAdvance(node: SceneNode, absoluteIndex: number): number | null {\n const char = node.text[absoluteIndex]\n const style = resolvedGlyphStyle(textStyleAt(node, absoluteIndex), char)\n if (!style) return null\n const metrics = getGlyphOutlineMetricsSync(\n style.fontFamily,\n faceStyleKey(style),\n char,\n style.fontSize\n )\n const glyph = metrics?.[0]\n return glyph ? glyph.advance + textLengthPixels(style.letterSpacing, style.fontSize) : null\n}\n\nfunction wrapStyledLine(node: SceneNode, line: TextLine): TextLine[] {\n if (!line.text || node.width <= 0) return [line]\n const result: TextLine[] = []\n let lineStart = 0\n let cursor = 0\n let lastBreak = -1\n\n for (let index = 0; index < line.text.length; index++) {\n const advance = glyphAdvance(node, line.start + index)\n if (advance == null) return [line]\n cursor += advance\n if (/\\s/.test(line.text[index])) {\n lastBreak = index + 1\n }\n if (cursor <= node.width || index === lineStart) continue\n\n const breakIndex = lastBreak > lineStart ? lastBreak : index\n result.push({ text: line.text.slice(lineStart, breakIndex), start: line.start + lineStart })\n lineStart = breakIndex\n index = breakIndex - 1\n cursor = 0\n lastBreak = -1\n }\n\n result.push({ text: line.text.slice(lineStart), start: line.start + lineStart })\n return result\n}\n\nfunction textLines(node: SceneNode): TextLine[] {\n const hardLines = hardTextLines(node.text)\n if (node.textAutoResize === 'WIDTH_AND_HEIGHT') return hardLines\n if (node.styleRuns.length > 0) return hardLines.flatMap((line) => wrapStyledLine(node, line))\n\n const result: TextLine[] = []\n for (const hardLine of hardLines) {\n if (!hardLine.text) {\n result.push(hardLine)\n continue\n }\n try {\n const prepared = prepareWithSegments(hardLine.text, `${node.fontSize}px ${node.fontFamily}`)\n const layout = layoutWithLines(prepared, node.width, lineHeight(node))\n let start = hardLine.start\n for (const line of layout.lines) {\n result.push({ text: line.text, start })\n start += line.text.length\n }\n } catch {\n result.push(hardLine)\n }\n }\n return result\n}\n\nfunction lineOffsetX(node: SceneNode, width: number): number {\n switch (node.textAlignHorizontal) {\n case 'CENTER':\n return Math.max(0, (node.width - width) / 2)\n case 'RIGHT':\n return Math.max(0, node.width - width)\n default:\n return 0\n }\n}\n\nfunction verticalOffset(node: SceneNode, contentHeight: number): number {\n switch (node.textAlignVertical) {\n case 'CENTER':\n return Math.max(0, (node.height - contentHeight) / 2)\n case 'BOTTOM':\n return Math.max(0, node.height - contentHeight)\n default:\n return 0\n }\n}\n\nfunction lineGlyphs(\n node: SceneNode,\n line: TextLine,\n baseline: number,\n xOffset: number\n): { glyphs: TextOutlineGlyph[]; width: number } | null {\n const glyphs: TextOutlineGlyph[] = []\n let cursorX = xOffset\n let index = 0\n\n while (index < line.text.length) {\n const absoluteIndex = line.start + index\n const style = resolvedGlyphStyle(textStyleAt(node, absoluteIndex), line.text[index])\n if (!style) return null\n const key = styleKey(style)\n let end = index + 1\n while (end < line.text.length) {\n const nextStyle = resolvedGlyphStyle(textStyleAt(node, line.start + end), line.text[end])\n if (!nextStyle || styleKey(nextStyle) !== key) break\n end++\n }\n\n const segment = line.text.slice(index, end)\n const metrics = getGlyphOutlineMetricsSync(\n style.fontFamily,\n faceStyleKey(style),\n segment,\n style.fontSize\n )\n if (!metrics) return null\n\n for (const glyph of metrics) {\n glyphs.push({ commands: glyph.commands, x: cursorX, y: baseline })\n cursorX += glyph.advance + textLengthPixels(style.letterSpacing, style.fontSize)\n }\n index = end\n }\n\n return { glyphs, width: cursorX - xOffset }\n}\n\nexport function textNodeToOutlineLayout(node: SceneNode): TextOutlineLayout | null {\n if (!getTextOutlineSupport(node).supported) return null\n\n const lines = textLines(node)\n const lineH = lineHeight(node)\n const contentHeight = lines.length * lineH\n const yOffset = verticalOffset(node, contentHeight)\n const glyphs: TextOutlineGlyph[] = []\n let maxWidth = 0\n\n for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {\n const baseline = yOffset + lineIndex * lineH + lineH\n const measured = lineGlyphs(node, lines[lineIndex], baseline, 0)\n if (!measured) return null\n const xOffset = lineOffsetX(node, measured.width)\n maxWidth = Math.max(maxWidth, measured.width)\n const placed =\n xOffset === 0\n ? measured.glyphs\n : measured.glyphs.map((glyph) => ({ ...glyph, x: glyph.x + xOffset }))\n glyphs.push(...placed)\n }\n\n return { glyphs, width: maxWidth, height: contentHeight }\n}\n"],"mappings":";;;;;;;AAqCA,MAAM,yBAAyB;AAS/B,SAAS,cAAc,MAA4B;CACjD,OAAO;EACL,YAAY,KAAK;EACjB,UAAU,KAAK;EACf,YAAY,KAAK;EACjB,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,eAAe,KAAK;CACtB;AACF;AAEA,SAAS,SAAS,OAA0B;CAC1C,MAAM,UAAU,iBAAiB,MAAM,eAAe,MAAM,QAAQ;CACpE,OAAO,GAAG,MAAM,WAAW,GAAG,aAAa,KAAK,EAAE,GAAG,MAAM,SAAS,GAAG;AACzE;AAEA,SAAS,YAAY,MAAiB,OAA0B;CAC9D,MAAM,OAAO,cAAc,IAAI;CAC/B,MAAM,MAAM,KAAK,UAAU,MAAM,SAAS,SAAS,KAAK,SAAS,QAAQ,KAAK,QAAQ,KAAK,MAAM;CACjG,IAAI,CAAC,KAAK,OAAO;CACjB,OAAO;EACL,YAAY,IAAI,MAAM,cAAc,KAAK;EACzC,UAAU,IAAI,MAAM,YAAY,KAAK;EACrC,YAAY,IAAI,MAAM,cAAc,KAAK;EACzC,QAAQ,IAAI,MAAM,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AAQ;CACV;CAEA,OAAO;EAAE;EAAQ,OAAO,UAAU;CAAQ;AAC5C;AAEA,SAAgB,wBAAwB,MAA2C;CACjF,IAAI,CAAC,sBAAsB,IAAI,CAAC,CAAC,WAAW,OAAO;CAEnD,MAAM,QAAQ,UAAU,IAAI;CAC5B,MAAM,QAAQ,WAAW,IAAI;CAC7B,MAAM,gBAAgB,MAAM,SAAS;CACrC,MAAM,UAAU,eAAe,MAAM,aAAa;CAClD,MAAM,SAA6B,CAAC;CACpC,IAAI,WAAW;CAEf,KAAK,IAAI,YAAY,GAAG,YAAY,MAAM,QAAQ,aAAa;EAC7D,MAAM,WAAW,UAAU,YAAY,QAAQ;EAC/C,MAAM,WAAW,WAAW,MAAM,MAAM,YAAY,UAAU,CAAC;EAC/D,IAAI,CAAC,UAAU,OAAO;EACtB,MAAM,UAAU,YAAY,MAAM,SAAS,KAAK;EAChD,WAAW,KAAK,IAAI,UAAU,SAAS,KAAK;EAC5C,MAAM,SACJ,YAAY,IACR,SAAS,SACT,SAAS,OAAO,KAAK,WAAW;GAAE,GAAG;GAAO,GAAG,MAAM,IAAI;EAAQ,EAAE;EACzE,OAAO,KAAK,GAAG,MAAM;CACvB;CAEA,OAAO;EAAE;EAAQ,OAAO;EAAU,QAAQ;CAAc;AAC1D"}
|
|
1
|
+
{"version":3,"file":"outlines.js","names":[],"sources":["../../src/text/outlines.ts"],"sourcesContent":["import type { CharacterStyleOverride, FontVariation, SceneNode } from '@pairdraw/scene-graph'\nimport { faceStyleKey } from '@pairdraw/scene-graph/font-style'\nimport { rangeFontStyle } from '@pairdraw/scene-graph/shared-styles'\nimport { lineHeightPixels, textLengthPixels, textVerticalOffset } from '@pairdraw/scene-graph/text'\n\nimport { drawnFontVariations } from '#core/canvas/text/font-families'\nimport {\n fontHasGlyphSync,\n getGlyphOutlineMetricsSync,\n shapedAdvancesSync,\n type OutlineCommand\n} from '#core/text/font/glyphs'\nimport { fontManager } from '#core/text/font/manager'\n\nexport type TextOutlineUnsupportedReason =\n | 'not-text'\n | 'empty-text'\n | 'missing-font'\n | 'missing-glyph'\n | 'complex-script'\n\nexport type TextOutlineSupport =\n | { supported: true }\n | { supported: false; reason: TextOutlineUnsupportedReason }\n\nexport interface TextOutlineGlyph {\n commands: OutlineCommand[]\n x: number\n y: number\n}\n\nexport interface TextOutlineLayout {\n glyphs: TextOutlineGlyph[]\n width: number\n height: number\n}\n\nconst COMPLEX_SCRIPT_PATTERN = /[\\u0590-\\u08ff\\u0900-\\u0dff\\ufb1d-\\ufdff\\ufe70-\\ufeff]/\n\ntype TextStyle = Required<\n Pick<\n CharacterStyleOverride,\n 'fontFamily' | 'fontSize' | 'fontWeight' | 'italic' | 'fontStyle' | 'letterSpacing'\n >\n> & {\n /** The axes a variable font draws the text at; a script fallback draws at the text font's. */\n variations: FontVariation[]\n}\n\nfunction withVariations(\n style: Omit<TextStyle, 'variations'>,\n variations: FontVariation[],\n opticalSizeFromFontSize: boolean\n): TextStyle {\n return {\n ...style,\n variations: drawnFontVariations({\n family: style.fontFamily,\n weight: style.fontWeight,\n italic: style.italic,\n style: faceStyleKey(style),\n fontSize: style.fontSize,\n variations,\n opticalSizeFromFontSize\n })\n }\n}\n\nfunction baseTextStyle(node: SceneNode): TextStyle {\n return withVariations(\n {\n fontFamily: node.fontFamily,\n fontSize: node.fontSize,\n fontWeight: node.fontWeight,\n italic: node.italic,\n fontStyle: node.fontStyle,\n letterSpacing: node.letterSpacing\n },\n node.fontVariations,\n node.opticalSizeFromFontSize\n )\n}\n\nfunction styleKey(style: TextStyle): string {\n const spacing = textLengthPixels(style.letterSpacing, style.fontSize)\n const axes = style.variations.map(({ axis, value }) => `${axis}=${value}`).join(',')\n return `${style.fontFamily}|${faceStyleKey(style)}|${style.fontSize}|${spacing}|${axes}`\n}\n\nfunction textStyleAt(node: SceneNode, index: number): TextStyle {\n const run = node.styleRuns.find((item) => index >= item.start && index < item.start + item.length)\n if (!run) return baseTextStyle(node)\n return withVariations(\n {\n fontFamily: run.style.fontFamily ?? node.fontFamily,\n fontSize: run.style.fontSize ?? node.fontSize,\n fontWeight: run.style.fontWeight ?? node.fontWeight,\n italic: run.style.italic ?? node.italic,\n fontStyle: rangeFontStyle(node, run.style),\n letterSpacing: run.style.letterSpacing ?? node.letterSpacing\n },\n run.style.fontVariations ?? node.fontVariations,\n run.style.opticalSizeFromFontSize ?? node.opticalSizeFromFontSize\n )\n}\n\nfunction resolvedGlyphStyle(style: TextStyle, char: string): TextStyle | null {\n if (fontHasGlyphSync(style.fontFamily, faceStyleKey(style), char)) return style\n const family = fallbackFamilies().find((candidate) => {\n const next = fallbackStyle(style, candidate)\n return (\n fontManager.loadedData(next.fontFamily, faceStyleKey(next)) &&\n fontHasGlyphSync(next.fontFamily, faceStyleKey(next), char)\n )\n })\n return family ? fallbackStyle(style, family) : null\n}\n\nfunction fallbackFamilies(): string[] {\n return [...fontManager.getCJKFallbackFamilies(), ...fontManager.getLetterFallbackFamilies()]\n}\n\n/** `style` in a script fallback family, which has none of the text family's named faces. */\nfunction fallbackStyle(style: TextStyle, family: string): TextStyle {\n return { ...style, fontFamily: family, fontStyle: null }\n}\n\nfunction textStyles(node: SceneNode): TextStyle[] {\n if (node.styleRuns.length === 0) return [baseTextStyle(node)]\n const styles = new Map<string, TextStyle>()\n for (let index = 0; index < node.text.length; index++) {\n const style = textStyleAt(node, index)\n styles.set(styleKey(style), style)\n }\n return [...styles.values()]\n}\n\nexport function getTextOutlineSupport(node: SceneNode): TextOutlineSupport {\n if (node.type !== 'TEXT') return { supported: false, reason: 'not-text' }\n if (!node.text) return { supported: false, reason: 'empty-text' }\n if (COMPLEX_SCRIPT_PATTERN.test(node.text)) return { supported: false, reason: 'complex-script' }\n for (const style of textStyles(node)) {\n if (!fontManager.loadedData(style.fontFamily, faceStyleKey(style))) {\n return { supported: false, reason: 'missing-font' }\n }\n }\n for (let index = 0; index < node.text.length; index++) {\n const char = node.text[index]\n if (char === '\\n') continue\n const style = textStyleAt(node, index)\n if (!resolvedGlyphStyle(style, char)) return { supported: false, reason: 'missing-glyph' }\n }\n return { supported: true }\n}\n\nfunction lineHeight(node: SceneNode): number {\n return lineHeightPixels(node.lineHeight, node.fontSize) ?? Math.ceil(node.fontSize * 1.2)\n}\n\ninterface TextLine {\n text: string\n start: number\n}\n\nfunction hardTextLines(text: string): TextLine[] {\n const lines: TextLine[] = []\n let start = 0\n for (const line of text.split('\\n')) {\n lines.push({ text: line, start })\n start += line.length + 1\n }\n return lines\n}\n\ninterface StyleSegment {\n start: number\n end: number\n style: TextStyle\n}\n\n/** `line` split where the style its characters are drawn in changes, or `null` when one has none. */\nfunction styleSegments(node: SceneNode, line: TextLine): StyleSegment[] | null {\n const segments: StyleSegment[] = []\n for (let index = 0; index < line.text.length; index++) {\n const style = resolvedGlyphStyle(textStyleAt(node, line.start + index), line.text[index])\n if (!style) return null\n const last = segments.at(-1)\n if (last && styleKey(last.style) === styleKey(style)) last.end = index + 1\n else segments.push({ start: index, end: index + 1, style })\n }\n return segments\n}\n\n/**\n * The width each character of `line` adds as its segments are shaped and drawn, kerning and\n * ligatures included: a glyph's advance and spacing go to the character it starts at.\n */\nfunction characterAdvances(node: SceneNode, line: TextLine): number[] | null {\n const segments = styleSegments(node, line)\n if (!segments) return null\n const advances = Array.from<number>({ length: line.text.length }).fill(0)\n for (const { start, end, style } of segments) {\n const glyphs = shapedAdvancesSync(\n style.fontFamily,\n faceStyleKey(style),\n line.text.slice(start, end),\n style.fontSize,\n style.variations\n )\n if (!glyphs) return null\n const spacing = textLengthPixels(style.letterSpacing, style.fontSize)\n for (const glyph of glyphs) advances[start + glyph.cluster] += glyph.advance + spacing\n }\n return advances\n}\n\nfunction wrapLine(node: SceneNode, line: TextLine): TextLine[] {\n if (!line.text || node.width <= 0) return [line]\n const advances = characterAdvances(node, line)\n if (!advances) return [line]\n const result: TextLine[] = []\n let lineStart = 0\n let cursor = 0\n let lastBreak = -1\n\n for (let index = 0; index < line.text.length; index++) {\n cursor += advances[index]\n if (/\\s/.test(line.text[index])) {\n lastBreak = index + 1\n }\n if (cursor <= node.width || index === lineStart) continue\n\n const breakIndex = lastBreak > lineStart ? lastBreak : index\n result.push({ text: line.text.slice(lineStart, breakIndex), start: line.start + lineStart })\n lineStart = breakIndex\n index = breakIndex - 1\n cursor = 0\n lastBreak = -1\n }\n\n result.push({ text: line.text.slice(lineStart), start: line.start + lineStart })\n return result\n}\n\nfunction textLines(node: SceneNode): TextLine[] {\n const hardLines = hardTextLines(node.text)\n if (node.textAutoResize === 'WIDTH_AND_HEIGHT') return hardLines\n return hardLines.flatMap((line) => wrapLine(node, line))\n}\n\nfunction lineOffsetX(node: SceneNode, width: number): number {\n switch (node.textAlignHorizontal) {\n case 'CENTER':\n return Math.max(0, (node.width - width) / 2)\n case 'RIGHT':\n return Math.max(0, node.width - width)\n default:\n return 0\n }\n}\n\nfunction lineGlyphs(\n node: SceneNode,\n line: TextLine,\n baseline: number,\n xOffset: number\n): { glyphs: TextOutlineGlyph[]; width: number } | null {\n const segments = styleSegments(node, line)\n if (!segments) return null\n const glyphs: TextOutlineGlyph[] = []\n let cursorX = xOffset\n\n for (const { start, end, style } of segments) {\n const metrics = getGlyphOutlineMetricsSync(\n style.fontFamily,\n faceStyleKey(style),\n line.text.slice(start, end),\n style.fontSize,\n style.variations\n )\n if (!metrics) return null\n\n for (const glyph of metrics) {\n glyphs.push({ commands: glyph.commands, x: cursorX, y: baseline })\n cursorX += glyph.advance + textLengthPixels(style.letterSpacing, style.fontSize)\n }\n }\n\n return { glyphs, width: cursorX - xOffset }\n}\n\nexport function textNodeToOutlineLayout(node: SceneNode): TextOutlineLayout | null {\n if (!getTextOutlineSupport(node).supported) return null\n\n const lines = textLines(node)\n const lineH = lineHeight(node)\n const contentHeight = lines.length * lineH\n const yOffset = textVerticalOffset(node, contentHeight)\n const glyphs: TextOutlineGlyph[] = []\n let maxWidth = 0\n\n for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {\n const baseline = yOffset + lineIndex * lineH + lineH\n const measured = lineGlyphs(node, lines[lineIndex], baseline, 0)\n if (!measured) return null\n const xOffset = lineOffsetX(node, measured.width)\n maxWidth = Math.max(maxWidth, measured.width)\n const placed =\n xOffset === 0\n ? measured.glyphs\n : measured.glyphs.map((glyph) => ({ ...glyph, x: glyph.x + xOffset }))\n glyphs.push(...placed)\n }\n\n return { glyphs, width: maxWidth, height: contentHeight }\n}\n"],"mappings":";;;;;;;AAqCA,MAAM,yBAAyB;AAY/B,SAAS,eACP,OACA,YACA,yBACW;CACX,OAAO;EACL,GAAG;EACH,YAAY,oBAAoB;GAC9B,QAAQ,MAAM;GACd,QAAQ,MAAM;GACd,QAAQ,MAAM;GACd,OAAO,aAAa,KAAK;GACzB,UAAU,MAAM;GAChB;GACA;EACF,CAAC;CACH;AACF;AAEA,SAAS,cAAc,MAA4B;CACjD,OAAO,eACL;EACE,YAAY,KAAK;EACjB,UAAU,KAAK;EACf,YAAY,KAAK;EACjB,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,eAAe,KAAK;CACtB,GACA,KAAK,gBACL,KAAK,uBACP;AACF;AAEA,SAAS,SAAS,OAA0B;CAC1C,MAAM,UAAU,iBAAiB,MAAM,eAAe,MAAM,QAAQ;CACpE,MAAM,OAAO,MAAM,WAAW,KAAK,EAAE,MAAM,YAAY,GAAG,KAAK,GAAG,OAAO,CAAC,CAAC,KAAK,GAAG;CACnF,OAAO,GAAG,MAAM,WAAW,GAAG,aAAa,KAAK,EAAE,GAAG,MAAM,SAAS,GAAG,QAAQ,GAAG;AACpF;AAEA,SAAS,YAAY,MAAiB,OAA0B;CAC9D,MAAM,MAAM,KAAK,UAAU,MAAM,SAAS,SAAS,KAAK,SAAS,QAAQ,KAAK,QAAQ,KAAK,MAAM;CACjG,IAAI,CAAC,KAAK,OAAO,cAAc,IAAI;CACnC,OAAO,eACL;EACE,YAAY,IAAI,MAAM,cAAc,KAAK;EACzC,UAAU,IAAI,MAAM,YAAY,KAAK;EACrC,YAAY,IAAI,MAA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,MAAM,UAAU,mBAAmB,MAAM,aAAa;CACtD,MAAM,SAA6B,CAAC;CACpC,IAAI,WAAW;CAEf,KAAK,IAAI,YAAY,GAAG,YAAY,MAAM,QAAQ,aAAa;EAC7D,MAAM,WAAW,UAAU,YAAY,QAAQ;EAC/C,MAAM,WAAW,WAAW,MAAM,MAAM,YAAY,UAAU,CAAC;EAC/D,IAAI,CAAC,UAAU,OAAO;EACtB,MAAM,UAAU,YAAY,MAAM,SAAS,KAAK;EAChD,WAAW,KAAK,IAAI,UAAU,SAAS,KAAK;EAC5C,MAAM,SACJ,YAAY,IACR,SAAS,SACT,SAAS,OAAO,KAAK,WAAW;GAAE,GAAG;GAAO,GAAG,MAAM,IAAI;EAAQ,EAAE;EACzE,OAAO,KAAK,GAAG,MAAM;CACvB;CAEA,OAAO;EAAE;EAAQ,OAAO;EAAU,QAAQ;CAAc;AAC1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.d.ts","names":[],"sources":["../../src/text/prepare.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"prepare.d.ts","names":[],"sources":["../../src/text/prepare.ts"],"mappings":";;;iBA6DsB,kBACpB,OAAO,YACP,4BAEA;;AAAA;;EAEE;EAA+B;IAChC,QAAQ"}
|
package/dist/text/prepare.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { DEFAULT_FONT_FAMILY } from "../constants.js";
|
|
2
|
+
import { NOTO_COLOR_EMOJI_FAMILY, canDrawPlatformEmoji, mayHoldEmoji, savedEmojiCharacters } from "./emoji.js";
|
|
2
3
|
import { collectGraphFontRequirements, collectNodeFontFaces } from "./requirements/collect.js";
|
|
3
4
|
import { fontManager } from "./font/manager.js";
|
|
4
5
|
import { fontGlyphCoverageSync } from "./font/glyphs.js";
|
|
5
6
|
import { fontFaceDemand, fontResolver } from "./resolver/index.js";
|
|
6
|
-
import { NOTO_COLOR_EMOJI_FAMILY, canDrawPlatformEmoji, mayHoldEmoji, savedEmojiCharacters } from "./emoji.js";
|
|
7
7
|
import { missingGraphFontScripts } from "./requirements/resolved.js";
|
|
8
8
|
import { documentFontStatus } from "./font/status.js";
|
|
9
|
+
import { faceLoadKey, parseFontStyle } from "@pairdraw/scene-graph/font-style";
|
|
9
10
|
import { uniq } from "es-toolkit";
|
|
10
11
|
//#region src/text/prepare.ts
|
|
11
12
|
/**
|
|
@@ -51,6 +52,11 @@ async function prepareGraphFonts(graph, nodeIds, extraCharacters = "", { settleU
|
|
|
51
52
|
} : collected;
|
|
52
53
|
const faces = requirements.nodes.flatMap(collectNodeFontFaces);
|
|
53
54
|
await Promise.all(faces.map(({ family, style }) => fontManager.loadFont(family, style, requirements.characters)));
|
|
55
|
+
const defaultStyles = uniq(faces.flatMap(({ family, style }) => {
|
|
56
|
+
const { weight, italic } = parseFontStyle(style);
|
|
57
|
+
return family === "Inter" || fontManager.isLoaded(family) ? [] : [faceLoadKey(weight, italic)];
|
|
58
|
+
}));
|
|
59
|
+
await Promise.all(defaultStyles.map((style) => fontManager.loadFont(DEFAULT_FONT_FAMILY, style, requirements.characters)));
|
|
54
60
|
await fontManager.ensureFallbackPack(missingGraphFontScripts(requirements), requirements.characters);
|
|
55
61
|
if (settleUnavailable) await settleUnavailableFonts(faces, requirements.characters);
|
|
56
62
|
const unavailable = faces.filter(({ family, style }) => !fontManager.isStyleLoaded(family, style));
|
package/dist/text/prepare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.js","names":[],"sources":["../../src/text/prepare.ts"],"sourcesContent":["import { uniq } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { DEFAULT_FONT_FAMILY } from '#core/constants'\nimport {\n canDrawPlatformEmoji,\n mayHoldEmoji,\n NOTO_COLOR_EMOJI_FAMILY,\n savedEmojiCharacters\n} from '#core/text/emoji'\nimport { fontGlyphCoverageSync } from '#core/text/font/glyphs'\nimport { fontManager } from '#core/text/font/manager'\nimport { collectGraphFontRequirements, collectNodeFontFaces } from '#core/text/requirements/collect'\nimport { missingGraphFontScripts } from '#core/text/requirements/resolved'\nimport { fontFaceDemand, fontResolver } from '#core/text/resolver'\n\nimport { documentFontStatus, type DocumentFontStatus } from './font/status'\n\n/**\n * The characters of a text its layout falls back to the emoji metrics font for: ones that may be\n * emoji and that none of the faces it draws in, nor the fallbacks after them, has. A face not\n * loaded cannot tell, and leaves the character to it.\n */\nfunction laidOutEmojiCharacters(node: SceneNode): string {\n if (node.type !== 'TEXT' || !mayHoldEmoji(node.text)) return ''\n const faces = [\n ...collectNodeFontFaces(node),\n { family: DEFAULT_FONT_FAMILY, style: 'Regular' },\n ...[...fontManager.getLetterFallbackFamilies(), ...fontManager.getCJKFallbackFamilies()].map(\n (family) => ({ family, style: 'Regular' })\n )\n ]\n let characters = ''\n for (const character of node.text) {\n if (!mayHoldEmoji(character)) continue\n const drawnByText = faces.some(\n ({ family, style }) => fontGlyphCoverageSync(family, style, character) !== 'missing'\n )\n if (!drawnByText) characters += character\n }\n return characters\n}\n\n/**\n * A one-shot output cannot wait for a face no source has. Loading the substitute face and settling\n * those demands is what lets the text draw in it instead of leaving the layer empty.\n */\nasync function settleUnavailableFonts(\n faces: readonly { family: string; style: string }[],\n characters: string\n): Promise<void> {\n const unavailable = faces.filter(({ family, style }) => !fontManager.isStyleLoaded(family, style))\n if (unavailable.length === 0) return\n await fontManager.loadFont(DEFAULT_FONT_FAMILY, 'Regular', characters)\n for (const { family, style } of unavailable) {\n fontResolver.exhaust(fontFaceDemand(family, style, characters))\n }\n}\n\nexport async function prepareGraphFonts(\n graph: SceneGraph,\n nodeIds: readonly string[],\n /** Characters a writer draws besides the text's own, which the fonts must map too. */\n extraCharacters = '',\n /** An output that draws once and cannot wait for a face to arrive; see `settleUnavailableFonts`. */\n { settleUnavailable = false }: { settleUnavailable?: boolean } = {}\n): Promise<DocumentFontStatus> {\n const collected = collectGraphFontRequirements(graph, nodeIds)\n const requirements = extraCharacters\n ? {\n ...collected,\n characters: uniq(Array.from(collected.characters + extraCharacters)).join('')\n }\n : collected\n const faces = requirements.nodes.flatMap(collectNodeFontFaces)\n await Promise.all(\n faces.map(({ family, style }) => fontManager.loadFont(family, style, requirements.characters))\n )\n await fontManager.ensureFallbackPack(\n missingGraphFontScripts(requirements),\n requirements.characters\n )\n if (settleUnavailable) await settleUnavailableFonts(faces, requirements.characters)\n // A face the document asks for and no source has cannot draw; the text is drawn in the default\n // face and the script fallbacks after it, so that face has to be loaded to keep the text\n // visible instead of leaving the layer blank.\n const unavailable = faces.filter(({ family, style }) => !fontManager.isStyleLoaded(family, style))\n if (unavailable.length > 0) {\n await fontManager.loadFont(DEFAULT_FONT_FAMILY, 'Regular', requirements.characters)\n // Nothing else will load these faces in this export, so the render must not wait for them:\n // settling them here is what turns the text into the substituted face it is drawn in.\n for (const { family, style } of unavailable) {\n fontResolver.exhaust(fontFaceDemand(family, style, requirements.characters))\n }\n }\n // Without a platform that draws emoji, emoji are drawn with Noto, loaded for just these: the\n // saved ones, and the ones the layout leaves to the emoji metrics font.\n const emoji =\n requirements.nodes.map(savedEmojiCharacters).join('') +\n requirements.nodes.map(laidOutEmojiCharacters).join('')\n if (emoji && !canDrawPlatformEmoji())\n await fontManager.loadRemoteFont(NOTO_COLOR_EMOJI_FAMILY, 'Regular', emoji)\n return documentFontStatus(graph, nodeIds)\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepare.js","names":[],"sources":["../../src/text/prepare.ts"],"sourcesContent":["import { uniq } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { faceLoadKey, parseFontStyle } from '@pairdraw/scene-graph/font-style'\n\nimport { DEFAULT_FONT_FAMILY } from '#core/constants'\nimport {\n canDrawPlatformEmoji,\n mayHoldEmoji,\n NOTO_COLOR_EMOJI_FAMILY,\n savedEmojiCharacters\n} from '#core/text/emoji'\nimport { fontGlyphCoverageSync } from '#core/text/font/glyphs'\nimport { fontManager } from '#core/text/font/manager'\nimport { collectGraphFontRequirements, collectNodeFontFaces } from '#core/text/requirements/collect'\nimport { missingGraphFontScripts } from '#core/text/requirements/resolved'\nimport { fontFaceDemand, fontResolver } from '#core/text/resolver'\n\nimport { documentFontStatus, type DocumentFontStatus } from './font/status'\n\n/**\n * The characters of a text its layout falls back to the emoji metrics font for: ones that may be\n * emoji and that none of the faces it draws in, nor the fallbacks after them, has. A face not\n * loaded cannot tell, and leaves the character to it.\n */\nfunction laidOutEmojiCharacters(node: SceneNode): string {\n if (node.type !== 'TEXT' || !mayHoldEmoji(node.text)) return ''\n const faces = [\n ...collectNodeFontFaces(node),\n { family: DEFAULT_FONT_FAMILY, style: 'Regular' },\n ...[...fontManager.getLetterFallbackFamilies(), ...fontManager.getCJKFallbackFamilies()].map(\n (family) => ({ family, style: 'Regular' })\n )\n ]\n let characters = ''\n for (const character of node.text) {\n if (!mayHoldEmoji(character)) continue\n const drawnByText = faces.some(\n ({ family, style }) => fontGlyphCoverageSync(family, style, character) !== 'missing'\n )\n if (!drawnByText) characters += character\n }\n return characters\n}\n\n/**\n * A one-shot output cannot wait for a face no source has. Loading the substitute face and settling\n * those demands is what lets the text draw in it instead of leaving the layer empty.\n */\nasync function settleUnavailableFonts(\n faces: readonly { family: string; style: string }[],\n characters: string\n): Promise<void> {\n const unavailable = faces.filter(({ family, style }) => !fontManager.isStyleLoaded(family, style))\n if (unavailable.length === 0) return\n await fontManager.loadFont(DEFAULT_FONT_FAMILY, 'Regular', characters)\n for (const { family, style } of unavailable) {\n fontResolver.exhaust(fontFaceDemand(family, style, characters))\n }\n}\n\nexport async function prepareGraphFonts(\n graph: SceneGraph,\n nodeIds: readonly string[],\n /** Characters a writer draws besides the text's own, which the fonts must map too. */\n extraCharacters = '',\n /** An output that draws once and cannot wait for a face to arrive; see `settleUnavailableFonts`. */\n { settleUnavailable = false }: { settleUnavailable?: boolean } = {}\n): Promise<DocumentFontStatus> {\n const collected = collectGraphFontRequirements(graph, nodeIds)\n const requirements = extraCharacters\n ? {\n ...collected,\n characters: uniq(Array.from(collected.characters + extraCharacters)).join('')\n }\n : collected\n const faces = requirements.nodes.flatMap(collectNodeFontFaces)\n await Promise.all(\n faces.map(({ family, style }) => fontManager.loadFont(family, style, requirements.characters))\n )\n // A family found nowhere draws in the default family, and CanvasKit slants the default family's\n // upright face for an italic it lacks. Its face of the same weight and slant is loaded instead,\n // so the canvas draws a real italic and the saved outlines read that face.\n const defaultStyles = uniq(\n faces.flatMap(({ family, style }) => {\n const { weight, italic } = parseFontStyle(style)\n return family === DEFAULT_FONT_FAMILY || fontManager.isLoaded(family)\n ? []\n : [faceLoadKey(weight, italic)]\n })\n )\n await Promise.all(\n defaultStyles.map((style) =>\n fontManager.loadFont(DEFAULT_FONT_FAMILY, style, requirements.characters)\n )\n )\n await fontManager.ensureFallbackPack(\n missingGraphFontScripts(requirements),\n requirements.characters\n )\n if (settleUnavailable) await settleUnavailableFonts(faces, requirements.characters)\n // A face the document asks for and no source has cannot draw; the text is drawn in the default\n // face and the script fallbacks after it, so that face has to be loaded to keep the text\n // visible instead of leaving the layer blank.\n const unavailable = faces.filter(({ family, style }) => !fontManager.isStyleLoaded(family, style))\n if (unavailable.length > 0) {\n await fontManager.loadFont(DEFAULT_FONT_FAMILY, 'Regular', requirements.characters)\n // Nothing else will load these faces in this export, so the render must not wait for them:\n // settling them here is what turns the text into the substituted face it is drawn in.\n for (const { family, style } of unavailable) {\n fontResolver.exhaust(fontFaceDemand(family, style, requirements.characters))\n }\n }\n // Without a platform that draws emoji, emoji are drawn with Noto, loaded for just these: the\n // saved ones, and the ones the layout leaves to the emoji metrics font.\n const emoji =\n requirements.nodes.map(savedEmojiCharacters).join('') +\n requirements.nodes.map(laidOutEmojiCharacters).join('')\n if (emoji && !canDrawPlatformEmoji())\n await fontManager.loadRemoteFont(NOTO_COLOR_EMOJI_FAMILY, 'Regular', emoji)\n return documentFontStatus(graph, nodeIds)\n}\n"],"mappings":";;;;;;;;;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A,MAAM,gBAAgB,KACpB,MAAM,SAAS,EAAE,QAAQ,YAAY;EACnC,MAAM,EAAE,QAAQ,WAAW,eAAe,KAAK;EAC/C,OAAO,WAAA,WAAkC,YAAY,SAAS,MAAM,IAChE,CAAC,IACD,CAAC,YAAY,QAAQ,MAAM,CAAC;CAClC,CAAC,CACH;CACA,MAAM,QAAQ,IACZ,cAAc,KAAK,UACjB,YAAY,SAAS,qBAAqB,OAAO,aAAa,UAAU,CAC1E,CACF;CACA,MAAM,YAAY,mBAChB,wBAAwB,YAAY,GACpC,aAAa,UACf;CACA,IAAI,mBAAmB,MAAM,uBAAuB,OAAO,aAAa,UAAU;CAIlF,MAAM,cAAc,MAAM,QAAQ,EAAE,QAAQ,YAAY,CAAC,YAAY,cAAc,QAAQ,KAAK,CAAC;CACjG,IAAI,YAAY,SAAS,GAAG;EAC1B,MAAM,YAAY,SAAS,qBAAqB,WAAW,aAAa,UAAU;EAGlF,KAAK,MAAM,EAAE,QAAQ,WAAW,aAC9B,aAAa,QAAQ,eAAe,QAAQ,OAAO,aAAa,UAAU,CAAC;CAE/E;CAGA,MAAM,QACJ,aAAa,MAAM,IAAI,oBAAoB,CAAC,CAAC,KAAK,EAAE,IACpD,aAAa,MAAM,IAAI,sBAAsB,CAAC,CAAC,KAAK,EAAE;CACxD,IAAI,SAAS,CAAC,qBAAqB,GACjC,MAAM,YAAY,eAAe,yBAAyB,WAAW,KAAK;CAC5E,OAAO,mBAAmB,OAAO,OAAO;AAC1C"}
|
|
@@ -4,7 +4,13 @@ declare function getStyleAt(runs: StyleRun[], index: number): CharacterStyleOver
|
|
|
4
4
|
declare function applyStyleToRange(runs: StyleRun[], start: number, end: number, patch: CharacterStyleOverride, textLength: number): StyleRun[];
|
|
5
5
|
declare function removeStyleFromRange(runs: StyleRun[], start: number, end: number, keys: (keyof CharacterStyleOverride)[], textLength: number): StyleRun[];
|
|
6
6
|
declare function selectionHasStyle(runs: StyleRun[], start: number, end: number, key: keyof CharacterStyleOverride, value: unknown): boolean;
|
|
7
|
-
|
|
7
|
+
/** Which neighbour inserted characters copy their style from, as Figma's `insertCharacters` takes it. */
|
|
8
|
+
type InsertStyleSource = 'BEFORE' | 'AFTER';
|
|
9
|
+
/**
|
|
10
|
+
* The style inserted characters take, as Figma gives it: the preceding character's for `BEFORE`
|
|
11
|
+
* and the following one's for `AFTER`, or the closest character's at either end of the text.
|
|
12
|
+
*/
|
|
13
|
+
declare function insertedStyleAt(runs: StyleRun[], textLength: number, start: number, useStyle: InsertStyleSource): CharacterStyleOverride;
|
|
8
14
|
/**
|
|
9
15
|
* The runs after `length` characters are inserted at `pos`, the new characters all in `style`
|
|
10
16
|
* and every other character keeping its own. Works on the runs, not on each character, so a
|
|
@@ -12,6 +18,12 @@ declare function adjustRunsForInsert(runs: StyleRun[], pos: number, insertLength
|
|
|
12
18
|
*/
|
|
13
19
|
declare function insertRunsWithStyle(runs: StyleRun[], pos: number, length: number, style: CharacterStyleOverride): StyleRun[];
|
|
14
20
|
declare function adjustRunsForDelete(runs: StyleRun[], start: number, deleteLength: number): StyleRun[];
|
|
21
|
+
/**
|
|
22
|
+
* The runs after `typedLength` characters replace `[start, end)`. A typed character takes the
|
|
23
|
+
* style of the character before the caret, the first character's at the start of the text, and
|
|
24
|
+
* the first selected character's over a selection, as Figma's `insertCharacters` does.
|
|
25
|
+
*/
|
|
26
|
+
declare function runsAfterTyping(runs: StyleRun[], textLength: number, start: number, end: number, typedLength: number): StyleRun[];
|
|
15
27
|
declare function toggleBoldInRange(runs: StyleRun[], start: number, end: number, nodeWeight: number, textLength: number): {
|
|
16
28
|
runs: StyleRun[];
|
|
17
29
|
newWeight: number;
|
|
@@ -25,5 +37,5 @@ declare function toggleDecorationInRange(runs: StyleRun[], start: number, end: n
|
|
|
25
37
|
newDeco: TextDecoration;
|
|
26
38
|
};
|
|
27
39
|
//#endregion
|
|
28
|
-
export {
|
|
40
|
+
export { InsertStyleSource, adjustRunsForDelete, applyStyleToRange, getStyleAt, insertRunsWithStyle, insertedStyleAt, removeStyleFromRange, runsAfterTyping, selectionHasStyle, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange };
|
|
29
41
|
//# sourceMappingURL=style-runs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-runs.d.ts","names":[],"sources":["../../src/text/style-runs.ts"],"mappings":";;iBAKgB,WAAW,MAAM,YAAY,gBAAgB;iBAsB7C,kBACd,MAAM,YACN,eACA,aACA,OAAO,wBACP,qBACC;iBAUa,qBACd,MAAM,YACN,eACA,aACA,aAAa,2BACb,qBACC;iBAea,kBACd,MAAM,YACN,eACA,aACA,WAAW,wBACX
|
|
1
|
+
{"version":3,"file":"style-runs.d.ts","names":[],"sources":["../../src/text/style-runs.ts"],"mappings":";;iBAKgB,WAAW,MAAM,YAAY,gBAAgB;iBAsB7C,kBACd,MAAM,YACN,eACA,aACA,OAAO,wBACP,qBACC;iBAUa,qBACd,MAAM,YACN,eACA,aACA,aAAa,2BACb,qBACC;iBAea,kBACd,MAAM,YACN,eACA,aACA,WAAW,wBACX;;KAkCU;;;;;iBAMI,gBACd,MAAM,YACN,oBACA,eACA,UAAU,oBACT;;;;;;iBAYa,oBACd,MAAM,YACN,aACA,gBACA,OAAO,yBACN;iBA+Ba,oBACd,MAAM,YACN,eACA,uBACC;;;;;;iBA+Ba,gBACd,MAAM,YACN,oBACA,eACA,aACA,sBACC;iBAOa,kBACd,MAAM,YACN,eACA,aACA,oBACA;EACG,MAAM;EAAY;;iBAuBP,oBACd,MAAM,YACN,eACA,aACA,qBACA;EACG,MAAM;EAAY;;iBAqBP,wBACd,MAAM,YACN,eACA,aACA,MAAM,gBACN,UAAU,gBACV;EACG,MAAM;EAAY,SAAS"}
|
package/dist/text/style-runs.js
CHANGED
|
@@ -61,18 +61,14 @@ function compactRuns(chars) {
|
|
|
61
61
|
}
|
|
62
62
|
return result;
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
length: run.length + insertLength
|
|
73
|
-
};
|
|
74
|
-
return run;
|
|
75
|
-
});
|
|
64
|
+
/**
|
|
65
|
+
* The style inserted characters take, as Figma gives it: the preceding character's for `BEFORE`
|
|
66
|
+
* and the following one's for `AFTER`, or the closest character's at either end of the text.
|
|
67
|
+
*/
|
|
68
|
+
function insertedStyleAt(runs, textLength, start, useStyle) {
|
|
69
|
+
if (textLength === 0) return {};
|
|
70
|
+
const preferred = useStyle === "BEFORE" ? start - 1 : start;
|
|
71
|
+
return getStyleAt(runs, Math.min(Math.max(preferred, 0), textLength - 1));
|
|
76
72
|
}
|
|
77
73
|
/**
|
|
78
74
|
* The runs after `length` characters are inserted at `pos`, the new characters all in `style`
|
|
@@ -106,10 +102,12 @@ function insertRunsWithStyle(runs, pos, length, style) {
|
|
|
106
102
|
style: { ...style }
|
|
107
103
|
});
|
|
108
104
|
moved.sort((first, second) => first.start - second.start);
|
|
105
|
+
const insertEdges = /* @__PURE__ */ new Set([pos, pos + length]);
|
|
109
106
|
const merged = [];
|
|
110
107
|
for (const run of moved) {
|
|
111
108
|
const last = merged.at(-1);
|
|
112
|
-
|
|
109
|
+
const meetsAtInsertEdge = last !== void 0 && last.start + last.length === run.start && insertEdges.has(run.start);
|
|
110
|
+
if (last && meetsAtInsertEdge && isEqual(last.style, run.style)) merged[merged.length - 1] = {
|
|
113
111
|
...last,
|
|
114
112
|
length: last.length + run.length
|
|
115
113
|
};
|
|
@@ -140,6 +138,16 @@ function adjustRunsForDelete(runs, start, deleteLength) {
|
|
|
140
138
|
}
|
|
141
139
|
return result;
|
|
142
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* The runs after `typedLength` characters replace `[start, end)`. A typed character takes the
|
|
143
|
+
* style of the character before the caret, the first character's at the start of the text, and
|
|
144
|
+
* the first selected character's over a selection, as Figma's `insertCharacters` does.
|
|
145
|
+
*/
|
|
146
|
+
function runsAfterTyping(runs, textLength, start, end, typedLength) {
|
|
147
|
+
const replacesSelection = end > start;
|
|
148
|
+
const style = insertedStyleAt(runs, textLength, start, replacesSelection ? "AFTER" : "BEFORE");
|
|
149
|
+
return insertRunsWithStyle(replacesSelection ? adjustRunsForDelete(runs, start, end - start) : runs, start, typedLength, style);
|
|
150
|
+
}
|
|
143
151
|
function toggleBoldInRange(runs, start, end, nodeWeight, textLength) {
|
|
144
152
|
const allBold = selectionAllBold(runs, start, end, nodeWeight);
|
|
145
153
|
const targetWeight = allBold ? 400 : 700;
|
|
@@ -175,6 +183,6 @@ function selectionAllHasDecoration(runs, start, end, deco, nodeDeco) {
|
|
|
175
183
|
return true;
|
|
176
184
|
}
|
|
177
185
|
//#endregion
|
|
178
|
-
export { adjustRunsForDelete,
|
|
186
|
+
export { adjustRunsForDelete, applyStyleToRange, getStyleAt, insertRunsWithStyle, insertedStyleAt, removeStyleFromRange, runsAfterTyping, selectionHasStyle, toggleBoldInRange, toggleDecorationInRange, toggleItalicInRange };
|
|
179
187
|
|
|
180
188
|
//# sourceMappingURL=style-runs.js.map
|