@pairdraw/core 0.17.0 → 0.19.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/effects.d.ts +5 -11
- package/dist/canvas/effects.d.ts.map +1 -1
- package/dist/canvas/effects.js +25 -30
- package/dist/canvas/effects.js.map +1 -1
- package/dist/canvas/labels/hit-test.d.ts +5 -0
- package/dist/canvas/labels/hit-test.d.ts.map +1 -1
- package/dist/canvas/labels/hit-test.js +1 -1
- package/dist/canvas/labels/hit-test.js.map +1 -1
- package/dist/canvas/labels/paragraph-cache.d.ts.map +1 -1
- package/dist/canvas/labels/paragraph-cache.js +3 -2
- package/dist/canvas/labels/paragraph-cache.js.map +1 -1
- package/dist/canvas/labels/selection.js +3 -2
- package/dist/canvas/labels/selection.js.map +1 -1
- package/dist/canvas/labels/style.d.ts +1 -1
- package/dist/canvas/node-edit-overlay.js +2 -2
- package/dist/canvas/node-edit-overlay.js.map +1 -1
- package/dist/canvas/outline-stroke.d.ts.map +1 -1
- package/dist/canvas/outline-stroke.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/prototype.d.ts +2 -5
- package/dist/canvas/overlays/prototype.d.ts.map +1 -1
- package/dist/canvas/overlays/prototype.js +3 -19
- package/dist/canvas/overlays/prototype.js.map +1 -1
- 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 +25 -10
- 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 +26 -7
- package/dist/canvas/renderer.d.ts.map +1 -1
- package/dist/canvas/renderer.js +50 -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 +90 -54
- 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 +4 -3
- package/dist/canvas/text/font-families.d.ts.map +1 -1
- package/dist/canvas/text/font-families.js +13 -9
- 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 +2 -9
- 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 +18 -9
- 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 +3 -3
- package/dist/canvas/text/placed.js.map +1 -1
- package/dist/canvas/text/renderer.d.ts +2 -0
- package/dist/canvas/text/renderer.d.ts.map +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/design-jsx/renderer.d.ts.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/bridges/undo.d.ts +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 +18 -4
- 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 +63 -10
- package/dist/figma-api/index.d.ts.map +1 -1
- package/dist/figma-api/index.js +104 -17
- 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 +12 -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/connectors.js +2 -14
- package/dist/geometry/connectors.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 +3 -3
- package/dist/geometry/index.js +2 -2
- package/dist/geometry/scene.d.ts +3 -1
- package/dist/geometry/scene.d.ts.map +1 -1
- package/dist/geometry/scene.js +16 -1
- package/dist/geometry/scene.js.map +1 -1
- package/dist/geometry/types.d.ts +7 -1
- package/dist/geometry/types.d.ts.map +1 -1
- package/dist/icons/api.d.ts +3 -2
- package/dist/icons/api.d.ts.map +1 -1
- package/dist/icons/api.js +12 -12
- package/dist/icons/api.js.map +1 -1
- package/dist/icons/provider.d.ts +4 -3
- package/dist/icons/provider.d.ts.map +1 -1
- package/dist/icons/provider.js +6 -13
- package/dist/icons/provider.js.map +1 -1
- package/dist/icons/schema.d.ts +33 -1
- package/dist/icons/schema.d.ts.map +1 -1
- package/dist/icons/schema.js +30 -1
- package/dist/icons/schema.js.map +1 -1
- package/dist/icons/svg/presentation.d.ts +8 -1
- package/dist/icons/svg/presentation.d.ts.map +1 -1
- package/dist/icons/svg/presentation.js +21 -3
- package/dist/icons/svg/presentation.js.map +1 -1
- package/dist/icons/svg/text.js +1 -1
- package/dist/icons/svg/text.js.map +1 -1
- package/dist/icons/svg.d.ts +8 -3
- package/dist/icons/svg.d.ts.map +1 -1
- package/dist/icons/svg.js +15 -13
- package/dist/icons/svg.js.map +1 -1
- package/dist/icons/types.d.ts +1 -19
- package/dist/icons/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/io/formats/design-tokens/css/read.js +1 -1
- package/dist/io/formats/design-tokens/decode.js +1 -1
- package/dist/io/formats/design-tokens/plan/index.js +4 -2
- package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts +9 -1
- package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/plan/styles.js +23 -3
- package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/styles.d.ts +9 -1
- package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/styles.js +41 -4
- package/dist/io/formats/design-tokens/styles.js.map +1 -1
- package/dist/io/formats/design-tokens/types.d.ts +5 -0
- package/dist/io/formats/design-tokens/types.d.ts.map +1 -1
- package/dist/io/formats/design-tokens/types.js +1 -0
- package/dist/io/formats/design-tokens/types.js.map +1 -1
- package/dist/io/formats/drawio/export.d.ts.map +1 -1
- package/dist/io/formats/drawio/export.js +10 -0
- package/dist/io/formats/drawio/export.js.map +1 -1
- package/dist/io/formats/drawio/index.d.ts.map +1 -1
- package/dist/io/formats/drawio/index.js +32 -1
- package/dist/io/formats/drawio/index.js.map +1 -1
- package/dist/io/formats/drawio/shapes.d.ts +10 -5
- package/dist/io/formats/drawio/shapes.d.ts.map +1 -1
- package/dist/io/formats/drawio/shapes.js +10 -6
- package/dist/io/formats/drawio/shapes.js.map +1 -1
- package/dist/io/formats/drawio/warnings.d.ts +11 -0
- package/dist/io/formats/drawio/warnings.d.ts.map +1 -0
- package/dist/io/formats/drawio/warnings.js +23 -0
- package/dist/io/formats/drawio/warnings.js.map +1 -0
- 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 +10 -1
- package/dist/io/formats/pdf/dom.d.ts.map +1 -1
- package/dist/io/formats/pdf/dom.js +96 -2
- package/dist/io/formats/pdf/dom.js.map +1 -1
- package/dist/io/formats/pdf/export.js +3 -2
- package/dist/io/formats/pdf/export.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 +3 -3
- package/dist/io/formats/raster/headless.d.ts.map +1 -1
- package/dist/io/formats/raster/headless.js +25 -14
- 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 +8 -2
- package/dist/io/formats/raster/render.d.ts.map +1 -1
- package/dist/io/formats/raster/render.js +42 -8
- 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/formats.d.ts.map +1 -1
- package/dist/io/formats.js +3 -1
- package/dist/io/formats.js.map +1 -1
- package/dist/io/registry.d.ts +2 -0
- package/dist/io/registry.d.ts.map +1 -1
- package/dist/io/registry.js +5 -0
- package/dist/io/registry.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/io/types.d.ts +2 -0
- package/dist/io/types.d.ts.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 +11 -2
- package/dist/library/snapshot.js.map +1 -1
- package/dist/lint/linter.d.ts.map +1 -1
- package/dist/lint/linter.js +11 -2
- package/dist/lint/linter.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/rpc/variables-command.d.ts.map +1 -1
- package/dist/rpc/variables-command.js +4 -2
- package/dist/rpc/variables-command.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 +16 -14
- 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 +26 -3
- package/dist/text/fallbacks.d.ts.map +1 -1
- package/dist/text/fallbacks.js +135 -18
- 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 +50 -6
- package/dist/text/font/manager.d.ts.map +1 -1
- package/dist/text/font/manager.js +178 -32
- 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 +71 -71
- package/dist/text/outlines.js.map +1 -1
- package/dist/text/path/caret.d.ts +2 -4
- package/dist/text/path/caret.d.ts.map +1 -1
- package/dist/text/path/caret.js.map +1 -1
- package/dist/text/prepare.d.ts +5 -1
- package/dist/text/prepare.d.ts.map +1 -1
- package/dist/text/prepare.js +26 -3
- 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/text/web-font/assets.d.ts.map +1 -1
- package/dist/text/web-font/assets.js +13 -21
- package/dist/text/web-font/assets.js.map +1 -1
- package/dist/text/web-font/resolver.d.ts.map +1 -1
- package/dist/text/web-font/resolver.js +4 -1
- package/dist/text/web-font/resolver.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/components.d.ts +2 -1
- package/dist/tools/create/components.d.ts.map +1 -1
- package/dist/tools/create/components.js +27 -1
- package/dist/tools/create/components.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 +14 -6
- 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 +13 -10
- package/dist/tools/create/vector.js.map +1 -1
- package/dist/tools/create.d.ts +2 -2
- package/dist/tools/create.js +2 -2
- 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/effects.d.ts.map +1 -1
- package/dist/tools/modify/effects.js +5 -3
- package/dist/tools/modify/effects.js.map +1 -1
- package/dist/tools/modify/matching.d.ts.map +1 -1
- package/dist/tools/modify/matching.js +9 -6
- package/dist/tools/modify/matching.js.map +1 -1
- package/dist/tools/modify/paint.d.ts.map +1 -1
- package/dist/tools/modify/paint.js +7 -5
- package/dist/tools/modify/paint.js.map +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/text.d.ts.map +1 -1
- package/dist/tools/modify/text.js +28 -8
- package/dist/tools/modify/text.js.map +1 -1
- 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 +18 -4
- 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 +6 -1
- package/dist/tools/registry/extended.js.map +1 -1
- package/dist/tools/schema.d.ts +30 -5
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +125 -7
- 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 +86 -90
- package/dist/tools/structure/batch.js.map +1 -1
- package/dist/tools/variables/values.d.ts.map +1 -1
- package/dist/tools/variables/values.js +4 -2
- package/dist/tools/variables/values.js.map +1 -1
- package/dist/tools/vector/export.d.ts.map +1 -1
- package/dist/tools/vector/export.js +5 -2
- package/dist/tools/vector/export.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/outline-stroke.ts +2 -6
- package/src/canvas/overlays/index.ts +0 -1
- package/src/canvas/overlays/prototype.ts +5 -27
- 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 +42 -18
- 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 +43 -11
- package/src/canvas/rulers.ts +55 -26
- package/src/canvas/scene.ts +127 -77
- 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 +14 -7
- package/src/canvas/text/index.ts +3 -9
- 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 +19 -10
- package/src/canvas/text/paragraph/inputs.ts +4 -2
- package/src/canvas/text/placed.ts +2 -2
- package/src/canvas/text/renderer.ts +2 -0
- 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 +170 -19
- 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 +16 -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/connectors.ts +2 -12
- package/src/geometry/figma.ts +9 -0
- package/src/geometry/index.ts +2 -1
- package/src/geometry/scene.ts +19 -0
- package/src/geometry/types.ts +8 -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/drawio/export.ts +11 -0
- package/src/io/formats/drawio/index.ts +36 -1
- package/src/io/formats/drawio/shapes.ts +13 -9
- package/src/io/formats/drawio/warnings.ts +27 -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 +125 -3
- package/src/io/formats/pdf/export.ts +3 -2
- 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 +40 -14
- package/src/io/formats/raster/index.ts +3 -0
- package/src/io/formats/raster/render.ts +66 -8
- 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/formats.ts +3 -1
- package/src/io/registry.ts +12 -0
- package/src/io/subgraph.ts +3 -1
- package/src/io/types.ts +2 -0
- 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 +12 -2
- package/src/lint/linter.ts +12 -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/rpc/variables-command.ts +6 -5
- package/src/text/character-style.ts +29 -9
- package/src/text/coverage.ts +29 -15
- package/src/text/editor.ts +3 -8
- package/src/text/fallbacks.ts +163 -22
- 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 +220 -49
- package/src/text/font/style.ts +52 -3
- package/src/text/index.ts +1 -0
- package/src/text/outlines.ts +106 -90
- package/src/text/path/caret.ts +3 -4
- package/src/text/prepare.ts +51 -2
- package/src/text/style-runs.ts +43 -16
- package/src/text/web-font/assets.ts +11 -15
- package/src/text/web-font/resolver.ts +7 -1
- 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/components.ts +33 -0
- package/src/tools/create/html.ts +3 -1
- package/src/tools/create/icons.ts +16 -6
- 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 +20 -10
- package/src/tools/create.ts +1 -0
- package/src/tools/image-ai/generate.ts +3 -0
- package/src/tools/modify/effects.ts +11 -4
- package/src/tools/modify/matching.ts +10 -6
- package/src/tools/modify/paint.ts +13 -5
- package/src/tools/modify/reactions.ts +40 -0
- package/src/tools/modify/text.ts +53 -20
- 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 +24 -4
- package/src/tools/read/nodes.ts +47 -17
- package/src/tools/read/pages.ts +7 -3
- 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 +6 -0
- package/src/tools/schema.ts +166 -6
- package/src/tools/stock-photo/apply.ts +17 -5
- package/src/tools/structure/batch.ts +84 -98
- package/src/tools/variables/values.ts +6 -3
- package/src/tools/vector/export.ts +5 -1
- 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
|
@@ -41,11 +41,12 @@ interface LoadedFace extends FaceWeight {
|
|
|
41
41
|
declare function loadedFace(family: string, weight: number, italic: boolean, style?: string): LoadedFace | null;
|
|
42
42
|
/**
|
|
43
43
|
* The families a paragraph's text falls back through, by their own names: its family, the
|
|
44
|
-
* default family, the
|
|
44
|
+
* default family, the fallbacks of scripts written in letters (Arabic, Hebrew, Thai,
|
|
45
|
+
* Devanagari) and CJK, then emoji, so a character a script's font has
|
|
45
46
|
* stays in that font. Fonts are read by these names; CanvasKit is asked for them as
|
|
46
47
|
* {@link resolveParagraphFontFamilies} names them.
|
|
47
48
|
*/
|
|
48
|
-
declare function paragraphSourceFamilies(primary: string,
|
|
49
|
+
declare function paragraphSourceFamilies(primary: string, letterFallbacks?: readonly string[], cjkFallbacks?: readonly string[]): string[];
|
|
49
50
|
/**
|
|
50
51
|
* The paragraph's families as CanvasKit is asked for them: the family in the face it draws the
|
|
51
52
|
* face in, and its fallbacks, each by the names `renderFamilies` gives it.
|
|
@@ -54,7 +55,7 @@ declare function resolveParagraphFontFamilies(primary: string, face: {
|
|
|
54
55
|
weight: number;
|
|
55
56
|
italic: boolean;
|
|
56
57
|
style: string;
|
|
57
|
-
},
|
|
58
|
+
}, letterFallbacks?: readonly string[], cjkFallbacks?: readonly string[]): string[];
|
|
58
59
|
//#endregion
|
|
59
60
|
export { DrawnFontAxes, DrawnFontAxis, LoadedFace, drawnFontAxes, drawnFontVariations, loadedFace, paragraphSourceFamilies, resolveParagraphFontFamilies };
|
|
60
61
|
//# sourceMappingURL=font-families.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-families.d.ts","names":[],"sources":["../../../src/canvas/text/font-families.ts"],"mappings":";;;;;UAgBiB;EACf;EACA;EACA;;EAEA;EACA;;EAEA,qBAAqB;EACrB;;;;;;;iBAQc,oBAAoB,MAAM,gBAAgB;;
|
|
1
|
+
{"version":3,"file":"font-families.d.ts","names":[],"sources":["../../../src/canvas/text/font-families.ts"],"mappings":";;;;;UAgBiB;EACf;EACA;EACA;;EAEA;EACA;;EAEA,qBAAqB;EACrB;;;;;;;iBAQc,oBAAoB,MAAM,gBAAgB;;UAuBzC,sBAAsB;EACrC;;;;;;iBAOc,cAAc,MAAM,gBAAgB;;UAWnC,mBAAmB;EAClC;;;;;;;iBAQc,WACd,gBACA,gBACA,iBACA,iBACC;;;;;;;;iBAoBa,wBACd,iBACA,qCACA;;;;;iBAuBc,6BACd,iBACA;EAAQ;EAAgB;EAAiB;GACzC,qCACA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_FONT_FAMILY } from "../../constants.js";
|
|
2
2
|
import { ResourceCache } from "../../cache/resource.js";
|
|
3
|
+
import { EMOJI_METRICS_FAMILY } from "../../text/emoji.js";
|
|
3
4
|
import { fontWeightMatchOrder } from "../../text/font/style.js";
|
|
4
5
|
import { fontManager } from "../../text/font/manager.js";
|
|
5
|
-
import { EMOJI_METRICS_FAMILY } from "../../text/emoji.js";
|
|
6
6
|
import { faceLoadKey } from "@pairdraw/scene-graph/font-style";
|
|
7
7
|
import { uniq } from "es-toolkit/array";
|
|
8
8
|
//#region src/canvas/text/font-families.ts
|
|
@@ -19,7 +19,9 @@ function drawnFontVariations(font) {
|
|
|
19
19
|
axis: "opsz",
|
|
20
20
|
value: font.fontSize
|
|
21
21
|
}] : font.variations;
|
|
22
|
-
|
|
22
|
+
const axes = new Map([...named, ...set].map(({ axis, value }) => [axis, value]));
|
|
23
|
+
if (!axes.has("wght") && !loadedFace(font.family, font.weight, font.italic, font.style)) axes.set("wght", font.weight);
|
|
24
|
+
return [...axes].map(([axis, value]) => ({
|
|
23
25
|
axis,
|
|
24
26
|
value
|
|
25
27
|
}));
|
|
@@ -43,6 +45,7 @@ function drawnFontAxes(font) {
|
|
|
43
45
|
* `null` when the family has none loaded.
|
|
44
46
|
*/
|
|
45
47
|
function loadedFace(family, weight, italic, style = faceLoadKey(weight, italic)) {
|
|
48
|
+
if (!fontManager.isLoaded(family)) return null;
|
|
46
49
|
if (fontManager.isStyleLoaded(family, style)) return {
|
|
47
50
|
weight,
|
|
48
51
|
italic,
|
|
@@ -60,15 +63,16 @@ function loadedFace(family, weight, italic, style = faceLoadKey(weight, italic))
|
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
62
65
|
* The families a paragraph's text falls back through, by their own names: its family, the
|
|
63
|
-
* default family, the
|
|
66
|
+
* default family, the fallbacks of scripts written in letters (Arabic, Hebrew, Thai,
|
|
67
|
+
* Devanagari) and CJK, then emoji, so a character a script's font has
|
|
64
68
|
* stays in that font. Fonts are read by these names; CanvasKit is asked for them as
|
|
65
69
|
* {@link resolveParagraphFontFamilies} names them.
|
|
66
70
|
*/
|
|
67
|
-
function paragraphSourceFamilies(primary,
|
|
71
|
+
function paragraphSourceFamilies(primary, letterFallbacks = fontManager.getLetterFallbackFamilies(), cjkFallbacks = fontManager.getCJKFallbackFamilies()) {
|
|
68
72
|
return uniq([
|
|
69
73
|
primary,
|
|
70
74
|
...primary === "Inter" ? [] : [DEFAULT_FONT_FAMILY],
|
|
71
|
-
...
|
|
75
|
+
...letterFallbacks,
|
|
72
76
|
...cjkFallbacks,
|
|
73
77
|
EMOJI_METRICS_FAMILY
|
|
74
78
|
]);
|
|
@@ -81,15 +85,15 @@ function renderFamilies(family, style) {
|
|
|
81
85
|
* The paragraph's families as CanvasKit is asked for them: the family in the face it draws the
|
|
82
86
|
* face in, and its fallbacks, each by the names `renderFamilies` gives it.
|
|
83
87
|
*/
|
|
84
|
-
function resolveParagraphFontFamilies(primary, face,
|
|
88
|
+
function resolveParagraphFontFamilies(primary, face, letterFallbacks = fontManager.getLetterFallbackFamilies(), cjkFallbacks = fontManager.getCJKFallbackFamilies()) {
|
|
85
89
|
const renderPrimary = renderFamilies(primary, loadedFace(primary, face.weight, face.italic, face.style)?.style ?? face.style);
|
|
86
|
-
const
|
|
90
|
+
const renderLetterFallbacks = letterFallbacks.flatMap((family) => renderFamilies(family, "Regular"));
|
|
87
91
|
const renderCJKFallbacks = cjkFallbacks.flatMap((family) => renderFamilies(family, "Regular"));
|
|
88
92
|
const key = [
|
|
89
93
|
primary,
|
|
90
94
|
...renderPrimary,
|
|
91
95
|
"",
|
|
92
|
-
...
|
|
96
|
+
...renderLetterFallbacks,
|
|
93
97
|
"",
|
|
94
98
|
...renderCJKFallbacks
|
|
95
99
|
].join("\0");
|
|
@@ -98,7 +102,7 @@ function resolveParagraphFontFamilies(primary, face, arabicFallbacks = fontManag
|
|
|
98
102
|
const resolved = uniq([
|
|
99
103
|
...renderPrimary,
|
|
100
104
|
...primary === "Inter" ? [] : [DEFAULT_FONT_FAMILY],
|
|
101
|
-
...
|
|
105
|
+
...renderLetterFallbacks,
|
|
102
106
|
...renderCJKFallbacks,
|
|
103
107
|
EMOJI_METRICS_FAMILY
|
|
104
108
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font-families.js","names":[],"sources":["../../../src/canvas/text/font-families.ts"],"sourcesContent":["import { uniq } from 'es-toolkit/array'\n\nimport type { FontVariation } from '@pairdraw/scene-graph'\nimport { faceLoadKey } from '@pairdraw/scene-graph/font-style'\n\nimport { ResourceCache } from '#core/cache/resource'\nimport { DEFAULT_FONT_FAMILY } from '#core/constants'\nimport { EMOJI_METRICS_FAMILY } from '#core/text/emoji'\nimport type { FaceWeight } from '#core/text/font/faces'\nimport { fontManager } from '#core/text/font/manager'\nimport { fontWeightMatchOrder } from '#core/text/font/style'\nimport type { FontAxis } from '#core/text/font/variation'\n\nconst familiesCache = new ResourceCache<string, string[]>({ maxEntries: 256 })\n\n/** What decides the axis values of a variable font text is drawn in. */\nexport interface DrawnFontAxes {\n family: string\n weight: number\n italic: boolean\n /** The face's key, as {@link faceStyleKey} gives it; its weight's key when left out. */\n style?: string\n fontSize: number\n /** The axes the text sets. */\n variations: readonly FontVariation[]\n opticalSizeFromFontSize: boolean\n}\n\n/**\n * The axis values text is drawn at, as Figma draws a variable font: its style's named instance,\n * then the axes it sets. While the optical size follows the font size, `opsz` is the font size and\n * a stored `opsz` is ignored. Fonts without an axis ignore its value.\n */\nexport function drawnFontVariations(font: DrawnFontAxes): FontVariation[] {\n // A face named apart from its weight (\"Condensed Bold\") is the instance of that name.\n const weightKey = faceLoadKey(font.weight, font.italic)\n const named =\n fontManager.namedInstanceVariations(font.family, font.style ?? weightKey) ??\n fontManager.namedInstanceVariations(font.family, weightKey) ??\n []\n const set = font.opticalSizeFromFontSize\n ? [\n ...font.variations.filter((variation) => variation.axis !== 'opsz'),\n { axis: 'opsz', value: font.fontSize }\n ]\n : font.variations\n const axes = new Map([...named, ...set].map(({ axis, value }) => [axis, value]))\n return [...axes].map(([axis, value]) => ({ axis, value }))\n}\n\n/** An axis of the variable font text is drawn in, with the value it is drawn at. */\nexport interface DrawnFontAxis extends FontAxis {\n value: number\n}\n\n/**\n * The axes of the variable font text is drawn in, in the font's order, each at the value it is\n * drawn at, within its range. `null` when the family's loaded faces are static or it has none.\n */\nexport function drawnFontAxes(font: DrawnFontAxes): DrawnFontAxis[] | null {\n const variation = fontManager.familyVariation(font.family, font.italic)\n if (!variation) return null\n const drawn = new Map(drawnFontVariations(font).map(({ axis, value }) => [axis, value]))\n return variation.axes.map((axis) => ({\n ...axis,\n value: Math.min(axis.max, Math.max(axis.min, drawn.get(axis.tag) ?? axis.default))\n }))\n}\n\n/** A loaded face text is drawn in: its weight and slant, and the key it is loaded under. */\nexport interface LoadedFace extends FaceWeight {\n style: string\n}\n\n/**\n * The loaded face of a family that text asking for a face is drawn in: that face, by its key,\n * or the nearest loaded weight in the same slant, then the other, as font matching picks it;\n * `null` when the family has none loaded.\n */\nexport function loadedFace(\n family: string,\n weight: number,\n italic: boolean,\n style = faceLoadKey(weight, italic)\n): LoadedFace | null {\n if (fontManager.isStyleLoaded(family, style)) return { weight, italic, style }\n for (const slant of [italic, !italic]) {\n for (const candidate of fontWeightMatchOrder(weight)) {\n const key = faceLoadKey(candidate, slant)\n if (fontManager.isStyleLoaded(family, key))\n return { weight: candidate, italic: slant, style: key }\n }\n }\n return null\n}\n\n/**\n * The families a paragraph's text falls back through, by their own names: its family, the\n * default family, the Arabic and CJK
|
|
1
|
+
{"version":3,"file":"font-families.js","names":[],"sources":["../../../src/canvas/text/font-families.ts"],"sourcesContent":["import { uniq } from 'es-toolkit/array'\n\nimport type { FontVariation } from '@pairdraw/scene-graph'\nimport { faceLoadKey } from '@pairdraw/scene-graph/font-style'\n\nimport { ResourceCache } from '#core/cache/resource'\nimport { DEFAULT_FONT_FAMILY } from '#core/constants'\nimport { EMOJI_METRICS_FAMILY } from '#core/text/emoji'\nimport type { FaceWeight } from '#core/text/font/faces'\nimport { fontManager } from '#core/text/font/manager'\nimport { fontWeightMatchOrder } from '#core/text/font/style'\nimport type { FontAxis } from '#core/text/font/variation'\n\nconst familiesCache = new ResourceCache<string, string[]>({ maxEntries: 256 })\n\n/** What decides the axis values of a variable font text is drawn in. */\nexport interface DrawnFontAxes {\n family: string\n weight: number\n italic: boolean\n /** The face's key, as {@link faceStyleKey} gives it; its weight's key when left out. */\n style?: string\n fontSize: number\n /** The axes the text sets. */\n variations: readonly FontVariation[]\n opticalSizeFromFontSize: boolean\n}\n\n/**\n * The axis values text is drawn at, as Figma draws a variable font: its style's named instance,\n * then the axes it sets. While the optical size follows the font size, `opsz` is the font size and\n * a stored `opsz` is ignored. Fonts without an axis ignore its value.\n */\nexport function drawnFontVariations(font: DrawnFontAxes): FontVariation[] {\n // A face named apart from its weight (\"Condensed Bold\") is the instance of that name.\n const weightKey = faceLoadKey(font.weight, font.italic)\n const named =\n fontManager.namedInstanceVariations(font.family, font.style ?? weightKey) ??\n fontManager.namedInstanceVariations(font.family, weightKey) ??\n []\n const set = font.opticalSizeFromFontSize\n ? [\n ...font.variations.filter((variation) => variation.axis !== 'opsz'),\n { axis: 'opsz', value: font.fontSize }\n ]\n : font.variations\n const axes = new Map([...named, ...set].map(({ axis, value }) => [axis, value]))\n // A family with no face loaded is drawn in its fallbacks, and a variable fallback takes the\n // text's weight on its axis unless the text sets one, rather than emboldening its default one.\n if (!axes.has('wght') && !loadedFace(font.family, font.weight, font.italic, font.style)) {\n axes.set('wght', font.weight)\n }\n return [...axes].map(([axis, value]) => ({ axis, value }))\n}\n\n/** An axis of the variable font text is drawn in, with the value it is drawn at. */\nexport interface DrawnFontAxis extends FontAxis {\n value: number\n}\n\n/**\n * The axes of the variable font text is drawn in, in the font's order, each at the value it is\n * drawn at, within its range. `null` when the family's loaded faces are static or it has none.\n */\nexport function drawnFontAxes(font: DrawnFontAxes): DrawnFontAxis[] | null {\n const variation = fontManager.familyVariation(font.family, font.italic)\n if (!variation) return null\n const drawn = new Map(drawnFontVariations(font).map(({ axis, value }) => [axis, value]))\n return variation.axes.map((axis) => ({\n ...axis,\n value: Math.min(axis.max, Math.max(axis.min, drawn.get(axis.tag) ?? axis.default))\n }))\n}\n\n/** A loaded face text is drawn in: its weight and slant, and the key it is loaded under. */\nexport interface LoadedFace extends FaceWeight {\n style: string\n}\n\n/**\n * The loaded face of a family that text asking for a face is drawn in: that face, by its key,\n * or the nearest loaded weight in the same slant, then the other, as font matching picks it;\n * `null` when the family has none loaded.\n */\nexport function loadedFace(\n family: string,\n weight: number,\n italic: boolean,\n style = faceLoadKey(weight, italic)\n): LoadedFace | null {\n if (!fontManager.isLoaded(family)) return null\n if (fontManager.isStyleLoaded(family, style)) return { weight, italic, style }\n for (const slant of [italic, !italic]) {\n for (const candidate of fontWeightMatchOrder(weight)) {\n const key = faceLoadKey(candidate, slant)\n if (fontManager.isStyleLoaded(family, key))\n return { weight: candidate, italic: slant, style: key }\n }\n }\n return null\n}\n\n/**\n * The families a paragraph's text falls back through, by their own names: its family, the\n * default family, the fallbacks of scripts written in letters (Arabic, Hebrew, Thai,\n * Devanagari) and CJK, then emoji, so a character a script's font has\n * stays in that font. Fonts are read by these names; CanvasKit is asked for them as\n * {@link resolveParagraphFontFamilies} names them.\n */\nexport function paragraphSourceFamilies(\n primary: string,\n letterFallbacks: readonly string[] = fontManager.getLetterFallbackFamilies(),\n cjkFallbacks: readonly string[] = fontManager.getCJKFallbackFamilies()\n): string[] {\n return uniq([\n primary,\n ...(primary === DEFAULT_FONT_FAMILY ? [] : [DEFAULT_FONT_FAMILY]),\n ...letterFallbacks,\n ...cjkFallbacks,\n EMOJI_METRICS_FAMILY\n ])\n}\n\n/** `style` of `family` by the names CanvasKit draws it under: its own file, then its shards. */\nfunction renderFamilies(family: string, style: string): string[] {\n return [\n fontManager.renderFamily(family, style),\n ...fontManager.renderShardFamilies(family, style)\n ]\n}\n\n/**\n * The paragraph's families as CanvasKit is asked for them: the family in the face it draws the\n * face in, and its fallbacks, each by the names `renderFamilies` gives it.\n */\nexport function resolveParagraphFontFamilies(\n primary: string,\n face: { weight: number; italic: boolean; style: string },\n letterFallbacks: readonly string[] = fontManager.getLetterFallbackFamilies(),\n cjkFallbacks: readonly string[] = fontManager.getCJKFallbackFamilies()\n): string[] {\n // The face the family draws it in, which may be the nearest one loaded.\n const drawn = loadedFace(primary, face.weight, face.italic, face.style)\n const renderPrimary = renderFamilies(primary, drawn?.style ?? face.style)\n const renderLetterFallbacks = letterFallbacks.flatMap((family) =>\n renderFamilies(family, 'Regular')\n )\n const renderCJKFallbacks = cjkFallbacks.flatMap((family) => renderFamilies(family, 'Regular'))\n const key = [\n primary,\n ...renderPrimary,\n '',\n ...renderLetterFallbacks,\n '',\n ...renderCJKFallbacks\n ].join('\\0')\n const cached = familiesCache.peek(key)\n if (cached) return cached\n const resolved = uniq([\n ...renderPrimary,\n ...(primary === DEFAULT_FONT_FAMILY ? [] : [DEFAULT_FONT_FAMILY]),\n ...renderLetterFallbacks,\n ...renderCJKFallbacks,\n EMOJI_METRICS_FAMILY\n ])\n familiesCache.set(key, resolved)\n return resolved\n}\n"],"mappings":";;;;;;;;AAaA,MAAM,gBAAgB,IAAI,cAAgC,EAAE,YAAY,IAAI,CAAC;;;;;;AAoB7E,SAAgB,oBAAoB,MAAsC;CAExE,MAAM,YAAY,YAAY,KAAK,QAAQ,KAAK,MAAM;CACtD,MAAM,QACJ,YAAY,wBAAwB,KAAK,QAAQ,KAAK,SAAS,SAAS,KACxE,YAAY,wBAAwB,KAAK,QAAQ,SAAS,KAC1D,CAAC;CACH,MAAM,MAAM,KAAK,0BACb,CACE,GAAG,KAAK,WAAW,QAAQ,cAAc,UAAU,SAAS,MAAM,GAClE;EAAE,MAAM;EAAQ,OAAO,KAAK;CAAS,CACvC,IACA,KAAK;CACT,MAAM,OAAO,IAAI,IAAI,CAAC,GAAG,OAAO,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,YAAY,CAAC,MAAM,KAAK,CAAC,CAAC;CAG/E,IAAI,CAAC,KAAK,IAAI,MAAM,KAAK,CAAC,WAAW,KAAK,QAAQ,KAAK,QAAQ,KAAK,QAAQ,KAAK,KAAK,GACpF,KAAK,IAAI,QAAQ,KAAK,MAAM;CAE9B,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,YAAY;EAAE;EAAM;CAAM,EAAE;AAC3D;;;;;AAWA,SAAgB,cAAc,MAA6C;CACzE,MAAM,YAAY,YAAY,gBAAgB,KAAK,QAAQ,KAAK,MAAM;CACtE,IAAI,CAAC,WAAW,OAAO;CACvB,MAAM,QAAQ,IAAI,IAAI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KAAK;CACxE,MAAM,wBAAwB,gBAAgB,SAAS,WACrD,eAAe,QAAQ,SAAS,CAClC;CACA,MAAM,qBAAqB,aAAa,SAAS,WAAW,eAAe,QAAQ,SAAS,CAAC;CAC7F,MAAM,MAAM;EACV;EACA,GAAG;EACH;EACA,GAAG;EACH;EACA,GAAG;CACL,CAAC,CAAC,KAAK,IAAI;CACX,MAAM,SAAS,cAAc,KAAK,GAAG;CACrC,IAAI,QAAQ,OAAO;CACnB,MAAM,WAAW,KAAK;EACpB,GAAG;EACH,GAAI,YAAA,UAAkC,CAAC,IAAI,CAAC,mBAAmB;EAC/D,GAAG;EACH,GAAG;EACH;CACF,CAAC;CACD,cAAc,IAAI,KAAK,QAAQ;CAC/B,OAAO;AACT"}
|
|
@@ -14,8 +14,6 @@ declare function measureTextNode(r: TextRenderer, node: SceneNode, maxWidth?: nu
|
|
|
14
14
|
height: number;
|
|
15
15
|
} | null;
|
|
16
16
|
declare function buildTextPicture(r: TextRenderer, node: SceneNode): Uint8Array | null;
|
|
17
|
-
/** Offset that places laid-out text of `contentHeight` in the node box by vertical alignment. */
|
|
18
|
-
declare function textVerticalOffset(node: SceneNode, contentHeight: number): number;
|
|
19
17
|
//#endregion
|
|
20
|
-
export { NodeFontReadiness, type ParagraphBuildOptions, type TextLayout, buildParagraph, buildTextPicture, isNodeFontLoaded, measureTextNode, nodeFontReadiness, textFontFeatures, textFontVariations, textHeightBehaviorValue,
|
|
18
|
+
export { NodeFontReadiness, type ParagraphBuildOptions, type TextLayout, buildParagraph, buildTextPicture, isNodeFontLoaded, measureTextNode, nodeFontReadiness, textFontFeatures, textFontVariations, textHeightBehaviorValue, withTextParagraph };
|
|
21
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/canvas/text/index.ts"],"mappings":";;;;;;;;KA8DY;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/canvas/text/index.ts"],"mappings":";;;;;;;;KA8DY;iBA8GI,kBAAkB,GAAG,uBAAuB,MAAM,YAAY;iBAY9D,iBAAiB,GAAG,uBAAuB,MAAM;iBAKjD,gBACd,GAAG,cACH,MAAM,WACN;EACG;EAAe;;iBAyBJ,iBAAiB,GAAG,cAAc,MAAM,YAAY"}
|
|
@@ -104,7 +104,7 @@ function observedGlyphReadiness(r, node) {
|
|
|
104
104
|
fontResolver.demandForNode(demand, node.id, r.onFontResolutionSettled);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
if (pending) return "pending";
|
|
107
|
+
if (pending) return r.exportFontsSettled ? "substituted" : "pending";
|
|
108
108
|
return exhausted ? "substituted" : "ready";
|
|
109
109
|
}
|
|
110
110
|
function canObserveGlyphCoverage(r) {
|
|
@@ -161,14 +161,7 @@ function buildTextPicture(r, node) {
|
|
|
161
161
|
picture.delete();
|
|
162
162
|
return bytes ?? null;
|
|
163
163
|
}
|
|
164
|
-
/** Offset that places laid-out text of `contentHeight` in the node box by vertical alignment. */
|
|
165
|
-
function textVerticalOffset(node, contentHeight) {
|
|
166
|
-
const available = Math.max(0, node.height - contentHeight);
|
|
167
|
-
if (node.textAlignVertical === "CENTER") return available / 2;
|
|
168
|
-
if (node.textAlignVertical === "BOTTOM") return available;
|
|
169
|
-
return 0;
|
|
170
|
-
}
|
|
171
164
|
//#endregion
|
|
172
|
-
export { buildParagraph, buildTextPicture, isNodeFontLoaded, measureTextNode, nodeFontReadiness, textFontFeatures, textFontVariations, textHeightBehaviorValue,
|
|
165
|
+
export { buildParagraph, buildTextPicture, isNodeFontLoaded, measureTextNode, nodeFontReadiness, textFontFeatures, textFontVariations, textHeightBehaviorValue, withTextParagraph };
|
|
173
166
|
|
|
174
167
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/canvas/text/index.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { DEFAULT_FONT_FAMILY } from '#core/constants'\nimport { shownCharacters, shownText } from '#core/text/case'\nimport { fontManager } from '#core/text/font/manager'\nimport { textFontFace } from '#core/text/requirements/collect'\nimport {\n fontCoverageDemand,\n fontFaceDemand,\n fontRemoteCoverageDemand,\n fontResolver,\n missingGlyphOccurrences,\n missingGlyphsByScript\n} from '#core/text/resolver'\n\nimport { drawTextLayout } from './decorations'\nimport { buildParagraph } from './layout/build'\nimport { resolveParagraphLayoutWidth } from './paragraph'\nimport { withPreparedText } from './preparation'\nimport type { FontReadinessRenderer, TextRenderer } from './renderer'\n\nexport { buildParagraph } from './layout/build'\nexport type { TextLayout } from './layout'\nexport type { ParagraphBuildOptions } from './paint'\nexport { textFontFeatures, textFontVariations, textHeightBehaviorValue } from './paragraph'\nexport { withTextParagraph } from './preparation'\n\nfunction demandFace(\n r: FontReadinessRenderer,\n node: SceneNode,\n family: string,\n style: string\n): boolean {\n if (fontManager.isStyleLoaded(family, style)) return true\n const demand = fontFaceDemand(family, style, node.text)\n r.trackFontDemand?.(node, demand.key)\n void fontResolver.demandForNode(demand, node.id, r.onFontResolutionSettled)\n return false\n}\n\nfunction requiredNodeFaces(node: SceneNode): Array<{ family: string; style: string }> {\n const baseFamily = node.fontFamily || DEFAULT_FONT_FAMILY\n const faces = new Map<string, { family: string; style: string }>()\n const add = (family: string, style: string) => faces.set(`${family}\\0${style}`, { family, style })\n add(baseFamily, textFontFace(node).style)\n for (const run of node.styleRuns) {\n add(run.style.fontFamily ?? baseFamily, textFontFace(node, run.style).style)\n }\n return Array.from(faces.values())\n}\n\nfunction languageForCharacter(node: SceneNode, sourceIndex: number): string | null {\n const run = node.styleRuns.find(\n (item) => sourceIndex >= item.start && sourceIndex < item.start + item.length\n )\n return run?.style.textLanguage !== undefined ? run.style.textLanguage : node.textLanguage\n}\n\nfunction transformedSourceOffsets(node: SceneNode): number[] {\n return shownCharacters(node).map((shown) => shown.sourceIndex)\n}\n\nexport type NodeFontReadiness = 'ready' | 'substituted' | 'pending' | 'exhausted'\n\nfunction requiredFacesReadiness(r: FontReadinessRenderer, node: SceneNode): NodeFontReadiness {\n let pending = false\n let exhausted = false\n for (const { family, style } of requiredNodeFaces(node)) {\n if (fontManager.isStyleLoaded(family, style)) continue\n const demand = fontFaceDemand(family, style, node.text)\n const state = fontResolver.state(demand).state\n demandFace(r, node, family, style)\n if (state === 'failed' || state === 'exhausted') {\n // A missing face is drawn in another loaded face of the family, as Figma draws it, and\n // reported missing; the text stays visible when an exact face (Italic) is unavailable.\n if (fontManager.isLoaded(family)) continue\n exhausted = true\n } else {\n pending = true\n }\n }\n if (pending) return 'pending'\n if (exhausted && fontManager.isStyleLoaded(DEFAULT_FONT_FAMILY, 'Regular')) return 'substituted'\n return exhausted ? 'exhausted' : 'ready'\n}\n\nfunction demandRemoteCoverage(r: TextRenderer, node: SceneNode, characters: string[]): boolean {\n for (const { family, style } of requiredNodeFaces(node)) {\n if (!fontManager.remoteStyleNeedsCoverage(family, style, characters)) continue\n const demand = fontRemoteCoverageDemand(family, style, characters)\n const state = fontResolver.state(demand).state\n if (state === 'idle') {\n r.trackFontDemand?.(node, demand.key)\n void fontResolver.demandForNode(demand, node.id, r.onFontResolutionSettled)\n return true\n }\n if (state === 'loading') return true\n if (state === 'loaded') fontResolver.exhaust(demand)\n }\n return false\n}\n\nfunction observedGlyphReadiness(r: TextRenderer, node: SceneNode): NodeFontReadiness {\n if (\n r.fontProvider &&\n r.textPreparationCache?.hasGlyphCoverage(node, fontManager.generation(), r.fontProvider)\n )\n return 'ready'\n\n const missingOccurrences = withPreparedText(\n r,\n node,\n 'coverage',\n () => buildParagraph(r, node),\n (prepared) => {\n if (!prepared.missingGlyphs) {\n prepared.paragraph.layout(resolveParagraphLayoutWidth(node))\n prepared.missingGlyphs = missingGlyphOccurrences(\n shownText(node),\n prepared.paragraph.getShapedLines(),\n transformedSourceOffsets(node)\n )\n }\n return prepared.missingGlyphs\n }\n )\n if (missingOccurrences.length === 0) {\n r.textPreparationCache?.recordGlyphCoverage(node)\n return 'ready'\n }\n\n const charactersByScript = missingGlyphsByScript(missingOccurrences, (offset) =>\n languageForCharacter(node, offset)\n )\n\n let pending = false\n let exhausted = charactersByScript.size === 0\n for (const [script, characters] of charactersByScript) {\n if (demandRemoteCoverage(r, node, characters)) {\n pending = true\n continue\n }\n\n const demand = fontCoverageDemand(script, characters)\n const state = fontResolver.state(demand).state\n if (state === 'loaded') {\n fontResolver.exhaust(demand)\n exhausted = true\n continue\n }\n if (state === 'exhausted' || state === 'failed') {\n exhausted = true\n continue\n }\n pending = true\n if (state === 'idle') {\n r.trackFontDemand?.(node, demand.key)\n void fontResolver.demandForNode(demand, node.id, r.onFontResolutionSettled)\n }\n }\n if (pending) return 'pending'\n // Once no fallback is left for a character, the text draws with the fonts it has, the font's\n // missing-glyph box standing in for that character, rather than not at all.\n return exhausted ? 'substituted' : 'ready'\n}\n\nfunction canObserveGlyphCoverage(r: FontReadinessRenderer): r is TextRenderer {\n return r.ck !== undefined && r.fontProvider != null && r.fontsLoaded !== undefined\n}\n\nexport function nodeFontReadiness(r: FontReadinessRenderer, node: SceneNode): NodeFontReadiness {\n if (node.type !== 'TEXT') return 'ready'\n const faces = requiredFacesReadiness(r, node)\n if (faces === 'pending' || faces === 'exhausted') return faces\n if (!node.text || !canObserveGlyphCoverage(r)) return faces\n const glyphs = observedGlyphReadiness(r, node)\n // Substituted text still needs script fallbacks (for example CJK) for glyphs the substitute\n // lacks, but stays visible when none can be found.\n if (faces === 'substituted') return glyphs === 'pending' ? 'pending' : 'substituted'\n return glyphs\n}\n\nexport function isNodeFontLoaded(r: FontReadinessRenderer, node: SceneNode): boolean {\n const readiness = nodeFontReadiness(r, node)\n return readiness === 'ready' || readiness === 'substituted'\n}\n\nexport function measureTextNode(\n r: TextRenderer,\n node: SceneNode,\n maxWidth?: number\n): { width: number; height: number } | null {\n if (!r.fontsLoaded || !r.fontProvider || !isNodeFontLoaded(r, node)) return null\n if (node.type !== 'TEXT' || !node.text) return null\n\n const layoutWidth = resolveParagraphLayoutWidth(node, maxWidth)\n const measure = () => {\n const paragraph = buildParagraph(r, node)\n paragraph.layout(layoutWidth)\n const width = paragraph.getLongestLine()\n const height = paragraph.getHeight()\n paragraph.delete()\n return { width: Math.ceil(width), height: Math.ceil(height) }\n }\n // Layout asks for the same text at the same width many times per pass.\n return r.textPreparationCache\n ? r.textPreparationCache.measure(\n node,\n layoutWidth,\n fontManager.generation(),\n r.fontProvider,\n measure\n )\n : measure()\n}\n\nexport function buildTextPicture(r: TextRenderer, node: SceneNode): Uint8Array | null {\n if (!r.fontsLoaded || !r.fontProvider || !isNodeFontLoaded(r, node)) return null\n if (node.type !== 'TEXT' || !node.text) return null\n\n const ck = r.ck\n const recorder = new ck.PictureRecorder()\n const bounds = ck.LTRBRect(0, 0, node.width || 1e6, node.height || 1e6)\n const recCanvas = recorder.beginRecording(bounds)\n\n const layout = buildParagraph(r, node)\n const paint = new ck.Paint()\n try {\n drawTextLayout(ck, recCanvas, node, { paragraph: layout }, 0, paint)\n } finally {\n paint.delete()\n layout.delete()\n }\n\n const picture = recorder.finishRecordingAsPicture()\n recorder.delete()\n\n const bytes = picture.serialize()\n picture.delete()\n return bytes ?? null\n}\n\n/** Offset that places laid-out text of `contentHeight` in the node box by vertical alignment. */\nexport function textVerticalOffset(node: SceneNode, contentHeight: number): number {\n const available = Math.max(0, node.height - contentHeight)\n if (node.textAlignVertical === 'CENTER') return available / 2\n if (node.textAlignVertical === 'BOTTOM') return available\n return 0\n}\n"],"mappings":";;;;;;;;;;;AA2BA,SAAS,WACP,GACA,MACA,QACA,OACS;CACT,IAAI,YAAY,cAAc,QAAQ,KAAK,GAAG,OAAO;CACrD,MAAM,SAAS,eAAe,QAAQ,OAAO,KAAK,IAAI;CACtD,EAAE,kBAAkB,MAAM,OAAO,GAAG;CACpC,aAAkB,cAAc,QAAQ,KAAK,IAAI,EAAE,uBAAuB;CAC1E,OAAO;AACT;AAEA,SAAS,kBAAkB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,eAAe;EACvC,MAAM,SAAS,UAAU,UAAU;EACnC,UAAU,OAAO;EACjB,OAAO;GAAE,OAAO,KAAK,KAAK,KAAK;GAAG,QAAQ,KAAK,KAAK,MAAM;EAAE;CAC9D;CAEA,OAAO,EAAE,uBACL,EAAE,qBAAqB,QACrB,MACA,aACA,YAAY,WAAW,GACvB,EAAE,cACF,OACF,IACA,QAAQ;AACd;AAEA,SAAgB,iBAAiB,GAAiB,MAAoC;CACpF,IAAI,CAAC,EAAE,eAAe,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,GAAG,IAAI,GAAG,OAAO;CAC5E,IAAI,KAAK,SAAS,UAAU,CAAC,KAAK,MAAM,OAAO;CAE/C,MAAM,KAAK,EAAE;CACb,MAAM,WAAW,IAAI,GAAG,gBAAgB;CACxC,MAAM,SAAS,GAAG,SAAS,GAAG,GAAG,KAAK,SAAS,KAAK,KAAK,UAAU,GAAG;CACtE,MAAM,YAAY,SAAS,eAAe,MAAM;CAEhD,MAAM,SAAS,eAAe,GAAG,IAAI;CACrC,MAAM,QAAQ,IAAI,GAAG,MAAM;CAC3B,IAAI;EACF,eAAe,IAAI,WAAW,MAAM,EAAE,WAAW,OAAO,GAAG,GAAG,KAAK;CACrE,UAAU;EACR,MAAM,OAAO;EACb,OAAO,OAAO;CAChB;CAEA,MAAM,UAAU,SAAS,yBAAyB;CAClD,SAAS,OAAO;CAEhB,MAAM,QAAQ,QAAQ,UAAU;CAChC,QAAQ,OAAO;CACf,OAAO,SAAS;AAClB;;AAGA,SAAgB,mBAAmB,MAAiB,eAA+B;CACjF,MAAM,YAAY,KAAK,IAAI,GAAG,KAAK,SAAS,aAAa;CACzD,IAAI,KAAK,sBAAsB,UAAU,OAAO,YAAY;CAC5D,IAAI,KAAK,sBAAsB,UAAU,OAAO;CAChD,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/canvas/text/index.ts"],"sourcesContent":["import type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { DEFAULT_FONT_FAMILY } from '#core/constants'\nimport { shownCharacters, shownText } from '#core/text/case'\nimport { fontManager } from '#core/text/font/manager'\nimport { textFontFace } from '#core/text/requirements/collect'\nimport {\n fontCoverageDemand,\n fontFaceDemand,\n fontRemoteCoverageDemand,\n fontResolver,\n missingGlyphOccurrences,\n missingGlyphsByScript\n} from '#core/text/resolver'\n\nimport { drawTextLayout } from './decorations'\nimport { buildParagraph } from './layout/build'\nimport { resolveParagraphLayoutWidth } from './paragraph'\nimport { withPreparedText } from './preparation'\nimport type { FontReadinessRenderer, TextRenderer } from './renderer'\n\nexport { buildParagraph } from './layout/build'\nexport type { TextLayout } from './layout'\nexport type { ParagraphBuildOptions } from './paint'\nexport { textFontFeatures, textFontVariations, textHeightBehaviorValue } from './paragraph'\nexport { withTextParagraph } from './preparation'\n\nfunction demandFace(\n r: FontReadinessRenderer,\n node: SceneNode,\n family: string,\n style: string\n): boolean {\n if (fontManager.isStyleLoaded(family, style)) return true\n const demand = fontFaceDemand(family, style, node.text)\n r.trackFontDemand?.(node, demand.key)\n void fontResolver.demandForNode(demand, node.id, r.onFontResolutionSettled)\n return false\n}\n\nfunction requiredNodeFaces(node: SceneNode): Array<{ family: string; style: string }> {\n const baseFamily = node.fontFamily || DEFAULT_FONT_FAMILY\n const faces = new Map<string, { family: string; style: string }>()\n const add = (family: string, style: string) => faces.set(`${family}\\0${style}`, { family, style })\n add(baseFamily, textFontFace(node).style)\n for (const run of node.styleRuns) {\n add(run.style.fontFamily ?? baseFamily, textFontFace(node, run.style).style)\n }\n return Array.from(faces.values())\n}\n\nfunction languageForCharacter(node: SceneNode, sourceIndex: number): string | null {\n const run = node.styleRuns.find(\n (item) => sourceIndex >= item.start && sourceIndex < item.start + item.length\n )\n return run?.style.textLanguage !== undefined ? run.style.textLanguage : node.textLanguage\n}\n\nfunction transformedSourceOffsets(node: SceneNode): number[] {\n return shownCharacters(node).map((shown) => shown.sourceIndex)\n}\n\nexport type NodeFontReadiness = 'ready' | 'substituted' | 'pending' | 'exhausted'\n\nfunction requiredFacesReadiness(r: FontReadinessRenderer, node: SceneNode): NodeFontReadiness {\n let pending = false\n let exhausted = false\n for (const { family, style } of requiredNodeFaces(node)) {\n if (fontManager.isStyleLoaded(family, style)) continue\n const demand = fontFaceDemand(family, style, node.text)\n const state = fontResolver.state(demand).state\n demandFace(r, node, family, style)\n if (state === 'failed' || state === 'exhausted') {\n // A missing face is drawn in another loaded face of the family, as Figma draws it, and\n // reported missing; the text stays visible when an exact face (Italic) is unavailable.\n if (fontManager.isLoaded(family)) continue\n exhausted = true\n } else {\n pending = true\n }\n }\n if (pending) return 'pending'\n if (exhausted && fontManager.isStyleLoaded(DEFAULT_FONT_FAMILY, 'Regular')) return 'substituted'\n return exhausted ? 'exhausted' : 'ready'\n}\n\nfunction demandRemoteCoverage(r: TextRenderer, node: SceneNode, characters: string[]): boolean {\n for (const { family, style } of requiredNodeFaces(node)) {\n if (!fontManager.remoteStyleNeedsCoverage(family, style, characters)) continue\n const demand = fontRemoteCoverageDemand(family, style, characters)\n const state = fontResolver.state(demand).state\n if (state === 'idle') {\n r.trackFontDemand?.(node, demand.key)\n void fontResolver.demandForNode(demand, node.id, r.onFontResolutionSettled)\n return true\n }\n if (state === 'loading') return true\n if (state === 'loaded') fontResolver.exhaust(demand)\n }\n return false\n}\n\nfunction observedGlyphReadiness(r: TextRenderer, node: SceneNode): NodeFontReadiness {\n if (\n r.fontProvider &&\n r.textPreparationCache?.hasGlyphCoverage(node, fontManager.generation(), r.fontProvider)\n )\n return 'ready'\n\n const missingOccurrences = withPreparedText(\n r,\n node,\n 'coverage',\n () => buildParagraph(r, node),\n (prepared) => {\n if (!prepared.missingGlyphs) {\n prepared.paragraph.layout(resolveParagraphLayoutWidth(node))\n prepared.missingGlyphs = missingGlyphOccurrences(\n shownText(node),\n prepared.paragraph.getShapedLines(),\n transformedSourceOffsets(node)\n )\n }\n return prepared.missingGlyphs\n }\n )\n if (missingOccurrences.length === 0) {\n r.textPreparationCache?.recordGlyphCoverage(node)\n return 'ready'\n }\n\n const charactersByScript = missingGlyphsByScript(missingOccurrences, (offset) =>\n languageForCharacter(node, offset)\n )\n\n let pending = false\n let exhausted = charactersByScript.size === 0\n for (const [script, characters] of charactersByScript) {\n if (demandRemoteCoverage(r, node, characters)) {\n pending = true\n continue\n }\n\n const demand = fontCoverageDemand(script, characters)\n const state = fontResolver.state(demand).state\n if (state === 'loaded') {\n fontResolver.exhaust(demand)\n exhausted = true\n continue\n }\n if (state === 'exhausted' || state === 'failed') {\n exhausted = true\n continue\n }\n pending = true\n if (state === 'idle') {\n r.trackFontDemand?.(node, demand.key)\n void fontResolver.demandForNode(demand, node.id, r.onFontResolutionSettled)\n }\n }\n // An export draws once: a face that has not arrived by then is not coming, and the characters\n // it would have covered keep the text's own fonts rather than leaving the layer blank.\n if (pending) return r.exportFontsSettled ? 'substituted' : 'pending'\n // Once no fallback is left for a character, the text draws with the fonts it has, the font's\n // missing-glyph box standing in for that character, rather than not at all.\n return exhausted ? 'substituted' : 'ready'\n}\n\nfunction canObserveGlyphCoverage(r: FontReadinessRenderer): r is TextRenderer {\n return r.ck !== undefined && r.fontProvider != null && r.fontsLoaded !== undefined\n}\n\nexport function nodeFontReadiness(r: FontReadinessRenderer, node: SceneNode): NodeFontReadiness {\n if (node.type !== 'TEXT') return 'ready'\n const faces = requiredFacesReadiness(r, node)\n if (faces === 'pending' || faces === 'exhausted') return faces\n if (!node.text || !canObserveGlyphCoverage(r)) return faces\n const glyphs = observedGlyphReadiness(r, node)\n // Substituted text still needs script fallbacks (for example CJK) for glyphs the substitute\n // lacks, but stays visible when none can be found.\n if (faces === 'substituted') return glyphs === 'pending' ? 'pending' : 'substituted'\n return glyphs\n}\n\nexport function isNodeFontLoaded(r: FontReadinessRenderer, node: SceneNode): boolean {\n const readiness = nodeFontReadiness(r, node)\n return readiness === 'ready' || readiness === 'substituted'\n}\n\nexport function measureTextNode(\n r: TextRenderer,\n node: SceneNode,\n maxWidth?: number\n): { width: number; height: number } | null {\n if (!r.fontsLoaded || !r.fontProvider || !isNodeFontLoaded(r, node)) return null\n if (node.type !== 'TEXT' || !node.text) return null\n\n const layoutWidth = resolveParagraphLayoutWidth(node, maxWidth)\n const measure = () => {\n const paragraph = buildParagraph(r, node)\n paragraph.layout(layoutWidth)\n const width = paragraph.getLongestLine()\n const height = paragraph.getHeight()\n paragraph.delete()\n return { width: Math.ceil(width), height: Math.ceil(height) }\n }\n // Layout asks for the same text at the same width many times per pass.\n return r.textPreparationCache\n ? r.textPreparationCache.measure(\n node,\n layoutWidth,\n fontManager.generation(),\n r.fontProvider,\n measure\n )\n : measure()\n}\n\nexport function buildTextPicture(r: TextRenderer, node: SceneNode): Uint8Array | null {\n if (!r.fontsLoaded || !r.fontProvider || !isNodeFontLoaded(r, node)) return null\n if (node.type !== 'TEXT' || !node.text) return null\n\n const ck = r.ck\n const recorder = new ck.PictureRecorder()\n const bounds = ck.LTRBRect(0, 0, node.width || 1e6, node.height || 1e6)\n const recCanvas = recorder.beginRecording(bounds)\n\n const layout = buildParagraph(r, node)\n const paint = new ck.Paint()\n try {\n drawTextLayout(ck, recCanvas, node, { paragraph: layout }, 0, paint)\n } finally {\n paint.delete()\n layout.delete()\n }\n\n const picture = recorder.finishRecordingAsPicture()\n recorder.delete()\n\n const bytes = picture.serialize()\n picture.delete()\n return bytes ?? null\n}\n"],"mappings":";;;;;;;;;;;AA2BA,SAAS,WACP,GACA,MACA,QACA,OACS;CACT,IAAI,YAAY,cAAc,QAAQ,KAAK,GAAG,OAAO;CACrD,MAAM,SAAS,eAAe,QAAQ,OAAO,KAAK,IAAI;CACtD,EAAE,kBAAkB,MAAM,OAAO,GAAG;CACpC,aAAkB,cAAc,QAAQ,KAAK,IAAI,EAAE,uBAAuB;CAC1E,OAAO;AACT;AAEA,SAAS,kBAAkB,MAA2D;CACpF,MAAM,aAAa,KAAK,cAAA;CACxB,MAAM,wBAAQ,IAAI,IAA+C;CACjE,MAAM,OAAO,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;GAAE,OAAO,KAAK,KAAK,KAAK;GAAG,QAAQ,KAAK,KAAK,MAAM;EAAE;CAC9D;CAEA,OAAO,EAAE,uBACL,EAAE,qBAAqB,QACrB,MACA,aACA,YAAY,WAAW,GACvB,EAAE,cACF,OACF,IACA,QAAQ;AACd;AAEA,SAAgB,iBAAiB,GAAiB,MAAoC;CACpF,IAAI,CAAC,EAAE,eAAe,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,GAAG,IAAI,GAAG,OAAO;CAC5E,IAAI,KAAK,SAAS,UAAU,CAAC,KAAK,MAAM,OAAO;CAE/C,MAAM,KAAK,EAAE;CACb,MAAM,WAAW,IAAI,GAAG,gBAAgB;CACxC,MAAM,SAAS,GAAG,SAAS,GAAG,GAAG,KAAK,SAAS,KAAK,KAAK,UAAU,GAAG;CACtE,MAAM,YAAY,SAAS,eAAe,MAAM;CAEhD,MAAM,SAAS,eAAe,GAAG,IAAI;CACrC,MAAM,QAAQ,IAAI,GAAG,MAAM;CAC3B,IAAI;EACF,eAAe,IAAI,WAAW,MAAM,EAAE,WAAW,OAAO,GAAG,GAAG,KAAK;CACrE,UAAU;EACR,MAAM,OAAO;EACb,OAAO,OAAO;CAChB;CAEA,MAAM,UAAU,SAAS,yBAAyB;CAClD,SAAS,OAAO;CAEhB,MAAM,QAAQ,QAAQ,UAAU;CAChC,QAAQ,OAAO;CACf,OAAO,SAAS;AAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","names":[],"sources":["../../../../src/canvas/text/layout/build.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"build.d.ts","names":[],"sources":["../../../../src/canvas/text/layout/build.ts"],"mappings":";;;;;;iBAuYgB,eACd,GAAG,cACH,MAAM,eACN,QAAQ,cACR,UAAS,wBACR"}
|
|
@@ -2,10 +2,11 @@ import "../../../constants.js";
|
|
|
2
2
|
import { shownText } from "../../../text/case.js";
|
|
3
3
|
import { textFontFace } from "../../../text/requirements/collect.js";
|
|
4
4
|
import { glyphAdvanceSync } from "../../../text/font/glyphs.js";
|
|
5
|
+
import { autoWidthWrapWidth } from "../../../layout/text-measurement.js";
|
|
5
6
|
import { buildSkParagraph, buildTruncateOpts, resolveParagraphLayoutWidth } from "../paragraph/index.js";
|
|
6
7
|
import { utf8Length } from "../utf8.js";
|
|
7
8
|
import { TextLayout } from "./index.js";
|
|
8
|
-
import { hasParagraphSpacing, hasTextList, lineHeightPixels, paragraphSpacingAt, paragraphStyleAt, textListItems, textParagraphRanges, topLevelNumberDigits } from "@pairdraw/scene-graph/text";
|
|
9
|
+
import { hasParagraphSpacing, hasTextList, lineHeightPixels, lineStepPixels, paragraphSpacingAt, paragraphStyleAt, textListItems, textParagraphRanges, topLevelNumberDigits } from "@pairdraw/scene-graph/text";
|
|
9
10
|
import { rangeFontStyle } from "@pairdraw/scene-graph/shared-styles";
|
|
10
11
|
import { resolveNodeTextDirection } from "@pairdraw/scene-graph/text/direction";
|
|
11
12
|
//#region src/canvas/text/layout/build.ts
|
|
@@ -39,7 +40,8 @@ function sliceStyleRuns(runs, start, end) {
|
|
|
39
40
|
}
|
|
40
41
|
/** Line heights by paragraph index, `lead` places before the text: each run's, the text's elsewhere. */
|
|
41
42
|
function lineHeightRuns(node, lead) {
|
|
42
|
-
const
|
|
43
|
+
const step = (lineHeight, fontSize) => lineHeightPixels(lineHeight, fontSize) ? lineStepPixels(lineHeight, fontSize) : null;
|
|
44
|
+
const own = (fontSize = node.fontSize) => step(node.lineHeight, fontSize);
|
|
43
45
|
const runs = [];
|
|
44
46
|
const add = (start, end, lineHeight) => {
|
|
45
47
|
const last = runs.at(-1);
|
|
@@ -54,7 +56,7 @@ function lineHeightRuns(node, lead) {
|
|
|
54
56
|
for (const run of node.styleRuns) {
|
|
55
57
|
if (position < run.start) add(position + lead, run.start + lead, own());
|
|
56
58
|
const runSize = run.style.fontSize ?? node.fontSize;
|
|
57
|
-
const lineHeight = run.style.lineHeight !== void 0 ?
|
|
59
|
+
const lineHeight = run.style.lineHeight !== void 0 ? step(run.style.lineHeight, runSize) : own(runSize);
|
|
58
60
|
add(run.start + lead, run.start + run.length + lead, lineHeight);
|
|
59
61
|
position = run.start + run.length;
|
|
60
62
|
}
|
|
@@ -100,10 +102,22 @@ function needsParagraphLayout(node) {
|
|
|
100
102
|
return hasTextList(node) || node.paragraphSpacing !== 0 || node.paragraphIndent !== 0 || node.textParagraphs.some(hasParagraphSpacing);
|
|
101
103
|
}
|
|
102
104
|
function layoutForNode(layout, node) {
|
|
103
|
-
if (node.textAutoResize
|
|
104
|
-
layout.layout(
|
|
105
|
-
|
|
106
|
-
}
|
|
105
|
+
if (node.textAutoResize !== "WIDTH_AND_HEIGHT") {
|
|
106
|
+
layout.layout(resolveParagraphLayoutWidth(node));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const wrapWidth = resolveParagraphLayoutWidth(node);
|
|
110
|
+
if (truncatesAtMaxWidth(node)) {
|
|
111
|
+
layout.layout(Math.min(node.width || wrapWidth, wrapWidth));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
layout.layout(wrapWidth);
|
|
115
|
+
const widestLine = Math.ceil(layout.getLongestLine());
|
|
116
|
+
const width = Math.min(wrapWidth, Math.max(node.width || 1, widestLine));
|
|
117
|
+
if (width !== wrapWidth) layout.layout(width);
|
|
118
|
+
}
|
|
119
|
+
function truncatesAtMaxWidth(node) {
|
|
120
|
+
return node.textTruncation === "ENDING" && autoWidthWrapWidth(node) !== void 0;
|
|
107
121
|
}
|
|
108
122
|
function listStyle(node, firstCharacter) {
|
|
109
123
|
const override = styleAt(node.styleRuns, firstCharacter);
|
|
@@ -266,7 +280,9 @@ function buildMarker(r, node, item, list, color, options) {
|
|
|
266
280
|
};
|
|
267
281
|
}
|
|
268
282
|
function createTextLayout(r, node, color, options) {
|
|
269
|
-
|
|
283
|
+
if (needsParagraphLayout(node)) return buildBlocks(r, node, color, options);
|
|
284
|
+
const truncation = buildTruncateOpts(node);
|
|
285
|
+
return TextLayout.ofParagraph(r.ck, buildSkParagraph(r, node, color, options, truncation.ellipsis ? { truncation } : void 0), shownText(node).length, paragraphLines(r, node, color, options));
|
|
270
286
|
}
|
|
271
287
|
/** How many laid-out line boxes fit the fixed height, preserving the first line. */
|
|
272
288
|
function linesWithinHeight(layout, height) {
|
|
@@ -277,7 +293,7 @@ function linesWithinHeight(layout, height) {
|
|
|
277
293
|
/** Lay a text node out as the renderer draws it, at its own width. */
|
|
278
294
|
function buildParagraph(r, node, color, options = {}) {
|
|
279
295
|
const layout = createTextLayout(r, node, color, options);
|
|
280
|
-
const heightTruncation = node.textTruncation === "ENDING" && node.height > 0 && (node.maxLines == null || node.maxLines <= 0);
|
|
296
|
+
const heightTruncation = (node.textTruncation === "ENDING" || node.textAutoResize === "TRUNCATE") && node.height > 0 && (node.maxLines == null || node.maxLines <= 0);
|
|
281
297
|
let fittingLines;
|
|
282
298
|
try {
|
|
283
299
|
layoutForNode(layout, node);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","names":[],"sources":["../../../../src/canvas/text/layout/build.ts"],"sourcesContent":["import type { Paragraph } from 'canvaskit-wasm'\n\nimport type { CharacterStyleOverride, StyleRun } from '@pairdraw/scene-graph'\nimport { rangeFontStyle } from '@pairdraw/scene-graph/shared-styles'\nimport {\n hasParagraphSpacing,\n hasTextList,\n paragraphSpacingAt,\n paragraphStyleAt,\n textListItems,\n textParagraphRanges,\n lineHeightPixels,\n topLevelNumberDigits,\n type TextListItem,\n type TextParagraphRange\n} from '@pairdraw/scene-graph/text'\nimport { resolveNodeTextDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { TextLayout, type TextLayoutBlock, type TextLayoutMarker } from '#core/canvas/text/layout'\nimport type { LineHeightRun, TextLayoutBlockLines } from '#core/canvas/text/layout/lines'\nimport type { ParagraphBuildOptions } from '#core/canvas/text/paint'\nimport {\n buildSkParagraph,\n buildTruncateOpts,\n resolveParagraphLayoutWidth,\n type ParagraphBlockOptions\n} from '#core/canvas/text/paragraph'\nimport type { ParagraphNode } from '#core/canvas/text/paragraph/inputs'\nimport type { TextRenderer } from '#core/canvas/text/renderer'\nimport { utf8Length } from '#core/canvas/text/utf8'\nimport { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE } from '#core/constants'\nimport { shownText } from '#core/text/case'\nimport { glyphAdvanceSync } from '#core/text/font/glyphs'\nimport { textFontFace } from '#core/text/requirements/collect'\n\n/** A list item's indent per level, in ems of the list's first character. */\nconst LIST_INDENT_EMS = 1.5\n/**\n * Figma widens ordered lists by the advance of glyph 48 per extra digit: the character code of\n * \"0\" read as a glyph ID. Measured in live Figma for Inter, Roboto, DM Sans, and others.\n */\nconst LIST_DIGIT_GLYPH_ID = 48\n/** A digit's width, in ems, for a font whose glyphs cannot be read. */\nconst FALLBACK_DIGIT_EMS = 0.6\n/** The placeholder a first-line indent puts before the text takes one UTF-16 unit, three bytes. */\nconst PLACEHOLDER_UTF8_LENGTH = 3\n\nfunction styleAt(runs: readonly StyleRun[], index: number): CharacterStyleOverride | undefined {\n return runs.find((run) => index >= run.start && index < run.start + run.length)?.style\n}\n\n/** Style runs of `text[start, end)` in the slice's own indices. */\nfunction sliceStyleRuns(runs: readonly StyleRun[], start: number, end: number): StyleRun[] {\n const sliced: StyleRun[] = []\n for (const run of runs) {\n const from = Math.max(start, run.start)\n const to = Math.min(end, run.start + run.length)\n if (to > from) sliced.push({ start: from - start, length: to - from, style: run.style })\n }\n return sliced\n}\n\n/** Line heights by paragraph index, `lead` places before the text: each run's, the text's elsewhere. */\nfunction lineHeightRuns(node: ParagraphNode, lead: number): LineHeightRun[] {\n // A percent line height follows the font size of the characters it spaces.\n const own = (fontSize = node.fontSize) => lineHeightPixels(node.lineHeight, fontSize) || null\n const runs: LineHeightRun[] = []\n const add = (start: number, end: number, lineHeight: number | null) => {\n const last = runs.at(-1)\n // Runs at one line height measure as one, whatever else they style.\n if (last?.end === start && last.lineHeight === lineHeight) last.end = end\n else runs.push({ start, end, lineHeight })\n }\n let position = 0\n for (const run of node.styleRuns) {\n if (position < run.start) add(position + lead, run.start + lead, own())\n const runSize = run.style.fontSize ?? node.fontSize\n const lineHeight =\n run.style.lineHeight !== undefined\n ? lineHeightPixels(run.style.lineHeight, runSize) || null\n : own(runSize)\n add(run.start + lead, run.start + run.length + lead, lineHeight)\n position = run.start + run.length\n }\n if (position < node.text.length) add(position + lead, node.text.length + lead, own())\n return runs\n}\n\n/**\n * What placing a paragraph's lines as Figma does needs: its line heights, and its lines laid\n * out one by one from `node`'s text, the first after its indent and the last truncated as the\n * paragraph is.\n */\nfunction paragraphLines(\n r: TextRenderer,\n node: ParagraphNode,\n color: Float32Array | undefined,\n options: ParagraphBuildOptions,\n firstLineIndent = 0\n): TextLayoutBlockLines | undefined {\n // Lines are cut by character index, which the text's case must keep.\n if (shownText(node).length !== node.text.length) return undefined\n const lead = firstLineIndent > 0 ? 1 : 0\n const ellipsis = buildTruncateOpts(node).ellipsis\n // A justified line is stretched only with text after it: lines are laid out with the rest\n // of the paragraph and cut, as truncated last lines are.\n const justified = node.textAlignHorizontal === 'JUSTIFIED'\n const lineTruncation = (lines: number, truncated: boolean) => {\n if (truncated) return { maxLines: lines, ellipsis }\n return justified ? { maxLines: lines } : {}\n }\n return {\n heights: lineHeightRuns(node, lead),\n // A trimmed edge is laid out by where it stands in the paragraph.\n build:\n node.leadingTrim === 'CAP_HEIGHT'\n ? undefined\n : (start, end, lines, truncated) => {\n const from = Math.max(0, start - lead)\n const to = justified ? node.text.length : end - lead\n const line: ParagraphNode = {\n ...node,\n text: node.text.slice(from, to),\n styleRuns: sliceStyleRuns(node.styleRuns, from, to)\n }\n return buildSkParagraph(r, line, color, options, {\n firstLineIndent: start === 0 ? firstLineIndent : 0,\n truncation: lineTruncation(lines, truncated)\n })\n }\n }\n}\n\n/** Whether the text lays out paragraph by paragraph rather than as one native paragraph. */\nfunction needsParagraphLayout(node: ParagraphNode): boolean {\n return (\n hasTextList(node) ||\n node.paragraphSpacing !== 0 ||\n node.paragraphIndent !== 0 ||\n node.textParagraphs.some(hasParagraphSpacing)\n )\n}\n\nfunction layoutForNode(layout: TextLayout, node: ParagraphNode): void {\n if (node.textAutoResize === 'WIDTH_AND_HEIGHT') {\n layout.layout(1e6)\n layout.layout(Math.max(node.width || 1, Math.ceil(layout.getLongestLine())))\n } else {\n layout.layout(resolveParagraphLayoutWidth(node))\n }\n}\n\ninterface ListStyle {\n em: number\n family: string\n style: string\n /** The name of the first character's face, which its markers are drawn in. */\n faceName: string | null\n /** The list's first character's style, which its markers take. */\n override: CharacterStyleOverride | undefined\n}\n\nfunction listStyle(node: ParagraphNode, firstCharacter: number): ListStyle {\n const override = styleAt(node.styleRuns, firstCharacter)\n return {\n em: override?.fontSize ?? (node.fontSize || DEFAULT_FONT_SIZE),\n family: override?.fontFamily ?? (node.fontFamily || DEFAULT_FONT_FAMILY),\n style: textFontFace(node, override).style,\n faceName: rangeFontStyle(node, override ?? {}),\n override\n }\n}\n\n/** A marker in its list's style, without the text's decoration and with figures of one width. */\nfunction markerNode(node: ParagraphNode, item: TextListItem, style: ListStyle): ParagraphNode {\n const override = style.override\n const features = override?.fontFeatures ?? node.fontFeatures\n return {\n ...node,\n text: item.marker,\n fontSize: style.em,\n fontFamily: style.family,\n fontWeight: override?.fontWeight ?? node.fontWeight,\n italic: override?.italic ?? node.italic,\n fontStyle: style.faceName,\n letterSpacing: override?.letterSpacing ?? node.letterSpacing,\n lineHeight: override?.lineHeight !== undefined ? override.lineHeight : node.lineHeight,\n fontVariations: override?.fontVariations ?? node.fontVariations,\n opticalSizeFromFontSize: override?.opticalSizeFromFontSize ?? node.opticalSizeFromFontSize,\n fontFeatures:\n item.listType === 'ORDERED' ? [...features, { tag: 'TNUM', enabled: true }] : features,\n textLanguage: override?.textLanguage !== undefined ? override.textLanguage : node.textLanguage,\n styleRuns: override?.fills\n ? [{ start: 0, length: item.marker.length, style: { fills: override.fills } }]\n : [],\n textCase: 'ORIGINAL',\n textDecoration: 'NONE',\n textDirection: 'LTR',\n textAlignHorizontal: 'LEFT',\n textAutoResize: 'WIDTH_AND_HEIGHT',\n textTruncation: 'DISABLED',\n maxLines: null\n }\n}\n\n/**\n * Text with lists, paragraph spacing, or a first-line indent, laid out one paragraph per\n * native paragraph: Skia has no hanging indent, so each list item lays out at the width its\n * indent leaves, beside a marker of its own.\n */\nfunction buildBlocks(\n r: TextRenderer,\n node: ParagraphNode,\n color: Float32Array | undefined,\n options: ParagraphBuildOptions\n): TextLayout {\n const shown = shownText(node)\n const sources = textParagraphRanges(node.text)\n const shownRanges = textParagraphRanges(shown)\n const items = new Map(\n textListItems(node.text, node.textParagraphs).map((item) => [item.paragraph, item])\n )\n const digits = topLevelNumberDigits([...items.values()])\n const rtl = resolveNodeTextDirection(node) === 'RTL'\n const truncation = buildTruncateOpts(node)\n const maxLines = truncation.maxLines\n // Each paragraph starts one byte, its newline, after the one before it ends.\n const utf8Starts: number[] = []\n let utf8Offset = 0\n for (const range of shownRanges) {\n utf8Starts.push(utf8Offset)\n utf8Offset += utf8Length(shown.slice(range.start, range.end)) + 1\n }\n\n const blocks: TextLayoutBlock[] = []\n try {\n for (const [index, { start, end }] of sources.entries()) {\n blocks.push(buildBlock(index, start, end))\n }\n } catch (error) {\n // Native paragraphs built before the failure are not garbage collected.\n for (const block of blocks) {\n block.paragraph.delete()\n block.marker?.paragraph.delete()\n }\n throw error\n }\n return new TextLayout(r.ck, blocks, maxLines)\n\n function buildBlock(index: number, start: number, end: number): TextLayoutBlock {\n const shownRange: TextParagraphRange = shownRanges[index]\n const item = items.get(index)\n const paragraphStyle = paragraphStyleAt(node.textParagraphs, index)\n const empty = end === start\n const blockNode: ParagraphNode = {\n ...node,\n text: empty ? ' ' : node.text.slice(start, end),\n styleRuns: empty\n ? sliceStyleRuns(node.styleRuns, start, start + 1)\n : sliceStyleRuns(node.styleRuns, start, end)\n }\n const paragraphIndent = paragraphSpacingAt(node, index, 'paragraphIndent')\n const firstLineIndent =\n paragraphStyle.listType === 'NONE' && paragraphIndent > 0 ? paragraphIndent : 0\n const blockOptions = (lines?: number): ParagraphBlockOptions => ({\n firstLineIndent,\n truncation: lines === undefined ? {} : { maxLines: lines, ellipsis: truncation.ellipsis },\n edges: { first: index === 0, last: index === sources.length - 1 }\n })\n const betweenItems =\n index > 0 &&\n paragraphStyleAt(node.textParagraphs, index - 1).listType !== 'NONE' &&\n paragraphStyle.listType !== 'NONE'\n const list = item ? listStyle(node, sources[item.groupStart].start) : null\n const marker = item && list ? buildMarker(r, node, item, list, color, options) : null\n let paragraph: Paragraph\n try {\n paragraph = buildSkParagraph(r, blockNode, color, options, blockOptions(maxLines))\n } catch (error) {\n marker?.paragraph.delete()\n throw error\n }\n return {\n paragraph,\n rebuild:\n maxLines === undefined\n ? undefined\n : (lines) => buildSkParagraph(r, blockNode, color, options, blockOptions(lines)),\n start: shownRange.start,\n utf8Start: utf8Starts[index],\n length: shownRange.end - shownRange.start,\n lead: firstLineIndent > 0 ? 1 : 0,\n utf8Lead: firstLineIndent > 0 ? PLACEHOLDER_UTF8_LENGTH : 0,\n leadWidth: firstLineIndent,\n empty,\n inset: item && list ? listInset(node, item, list, digits) : 0,\n rtl,\n // The space after a paragraph is its own: the paragraph before sets the space before.\n spaceBefore:\n index === 0\n ? 0\n : paragraphSpacingAt(node, index - 1, betweenItems ? 'listSpacing' : 'paragraphSpacing'),\n marker,\n lines: paragraphLines(r, blockNode, color, options, firstLineIndent),\n x: 0,\n y: 0,\n visible: true\n }\n }\n}\n\n/**\n * How far a list item's text stands from the start edge: its level's indent, widened for\n * ordered items by the digits past the first of the largest top-level number. A hanging list\n * moves the items back by one level, so markers stand outside the text box.\n */\nfunction listInset(\n node: ParagraphNode,\n item: TextListItem,\n list: ListStyle,\n digits: number\n): number {\n const unit = list.em * LIST_INDENT_EMS\n let inset = item.level * unit\n if (item.listType === 'ORDERED' && digits > 1) {\n const digit = glyphAdvanceSync(list.family, list.style, LIST_DIGIT_GLYPH_ID, list.em)\n inset += (digits - 1) * (digit ?? list.em * FALLBACK_DIGIT_EMS)\n }\n return node.hangingList ? inset - unit : inset\n}\n\nfunction buildMarker(\n r: TextRenderer,\n node: ParagraphNode,\n item: TextListItem,\n list: ListStyle,\n color: Float32Array | undefined,\n options: ParagraphBuildOptions\n): TextLayoutMarker {\n const paragraph = buildSkParagraph(r, markerNode(node, item, list), color, options)\n paragraph.layout(1e6)\n return {\n paragraph,\n kind: item.listType === 'ORDERED' ? 'number' : 'bullet',\n em: list.em,\n face: { family: list.family, style: list.style },\n x: 0,\n y: 0,\n lineNumber: 0\n }\n}\n\nfunction createTextLayout(\n r: TextRenderer,\n node: ParagraphNode,\n color: Float32Array | undefined,\n options: ParagraphBuildOptions\n): TextLayout {\n return needsParagraphLayout(node)\n ? buildBlocks(r, node, color, options)\n : TextLayout.ofParagraph(\n r.ck,\n buildSkParagraph(r, node, color, options),\n shownText(node).length,\n paragraphLines(r, node, color, options)\n )\n}\n\n/** How many laid-out line boxes fit the fixed height, preserving the first line. */\nfunction linesWithinHeight(layout: TextLayout, height: number): number {\n const lines = layout.getLineMetrics()\n const firstOverflow = lines.findIndex((line) => line.baseline + line.descent > height)\n return Math.max(1, firstOverflow === -1 ? lines.length : firstOverflow)\n}\n\n/** Lay a text node out as the renderer draws it, at its own width. */\nexport function buildParagraph(\n r: TextRenderer,\n node: ParagraphNode,\n color?: Float32Array,\n options: ParagraphBuildOptions = {}\n): TextLayout {\n const layout = createTextLayout(r, node, color, options)\n const heightTruncation =\n node.textTruncation === 'ENDING' &&\n node.height > 0 &&\n (node.maxLines == null || node.maxLines <= 0)\n let fittingLines: number | undefined\n try {\n layoutForNode(layout, node)\n if (heightTruncation) fittingLines = linesWithinHeight(layout, node.height)\n } catch (error) {\n layout.delete()\n throw error\n }\n if (fittingLines !== undefined && fittingLines < layout.getLineMetrics().length) {\n layout.delete()\n return buildParagraph(r, { ...node, maxLines: fittingLines }, color, options)\n }\n return layout\n}\n"],"mappings":";;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MACb,KAAK,YAAY,QAAQ,KAAK,YAAY;CAC7C,IAAI;CACJ,IAAI;EACF,cAAc,QAAQ,IAAI;EAC1B,IAAI,kBAAkB,eAAe,kBAAkB,QAAQ,KAAK,MAAM;CAC5E,SAAS,OAAO;EACd,OAAO,OAAO;EACd,MAAM;CACR;CACA,IAAI,iBAAiB,KAAA,KAAa,eAAe,OAAO,eAAe,CAAC,CAAC,QAAQ;EAC/E,OAAO,OAAO;EACd,OAAO,eAAe,GAAG;GAAE,GAAG;GAAM,UAAU;EAAa,GAAG,OAAO,OAAO;CAC9E;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"build.js","names":[],"sources":["../../../../src/canvas/text/layout/build.ts"],"sourcesContent":["import type { Paragraph } from 'canvaskit-wasm'\n\nimport type { CharacterStyleOverride, StyleRun, TextLength } from '@pairdraw/scene-graph'\nimport { rangeFontStyle } from '@pairdraw/scene-graph/shared-styles'\nimport {\n hasParagraphSpacing,\n hasTextList,\n paragraphSpacingAt,\n paragraphStyleAt,\n textListItems,\n textParagraphRanges,\n lineHeightPixels,\n lineStepPixels,\n topLevelNumberDigits,\n type TextListItem,\n type TextParagraphRange\n} from '@pairdraw/scene-graph/text'\nimport { resolveNodeTextDirection } from '@pairdraw/scene-graph/text/direction'\n\nimport { TextLayout, type TextLayoutBlock, type TextLayoutMarker } from '#core/canvas/text/layout'\nimport type { LineHeightRun, TextLayoutBlockLines } from '#core/canvas/text/layout/lines'\nimport type { ParagraphBuildOptions } from '#core/canvas/text/paint'\nimport {\n buildSkParagraph,\n buildTruncateOpts,\n resolveParagraphLayoutWidth,\n type ParagraphBlockOptions\n} from '#core/canvas/text/paragraph'\nimport type { ParagraphNode } from '#core/canvas/text/paragraph/inputs'\nimport type { TextRenderer } from '#core/canvas/text/renderer'\nimport { utf8Length } from '#core/canvas/text/utf8'\nimport { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE } from '#core/constants'\nimport { autoWidthWrapWidth } from '#core/layout/text-measurement'\nimport { shownText } from '#core/text/case'\nimport { glyphAdvanceSync } from '#core/text/font/glyphs'\nimport { textFontFace } from '#core/text/requirements/collect'\n\n/** A list item's indent per level, in ems of the list's first character. */\nconst LIST_INDENT_EMS = 1.5\n/**\n * Figma widens ordered lists by the advance of glyph 48 per extra digit: the character code of\n * \"0\" read as a glyph ID. Measured in live Figma for Inter, Roboto, DM Sans, and others.\n */\nconst LIST_DIGIT_GLYPH_ID = 48\n/** A digit's width, in ems, for a font whose glyphs cannot be read. */\nconst FALLBACK_DIGIT_EMS = 0.6\n/** The placeholder a first-line indent puts before the text takes one UTF-16 unit, three bytes. */\nconst PLACEHOLDER_UTF8_LENGTH = 3\n\nfunction styleAt(runs: readonly StyleRun[], index: number): CharacterStyleOverride | undefined {\n return runs.find((run) => index >= run.start && index < run.start + run.length)?.style\n}\n\n/** Style runs of `text[start, end)` in the slice's own indices. */\nfunction sliceStyleRuns(runs: readonly StyleRun[], start: number, end: number): StyleRun[] {\n const sliced: StyleRun[] = []\n for (const run of runs) {\n const from = Math.max(start, run.start)\n const to = Math.min(end, run.start + run.length)\n if (to > from) sliced.push({ start: from - start, length: to - from, style: run.style })\n }\n return sliced\n}\n\n/** Line heights by paragraph index, `lead` places before the text: each run's, the text's elsewhere. */\nfunction lineHeightRuns(node: ParagraphNode, lead: number): LineHeightRun[] {\n // A line height of zero lays lines out as auto; a percent one under half a pixel steps them\n // by none, as Figma does.\n const step = (lineHeight: TextLength | null, fontSize: number) =>\n lineHeightPixels(lineHeight, fontSize) ? lineStepPixels(lineHeight, fontSize) : null\n // A percent line height follows the font size of the characters it spaces.\n const own = (fontSize = node.fontSize) => step(node.lineHeight, fontSize)\n const runs: LineHeightRun[] = []\n const add = (start: number, end: number, lineHeight: number | null) => {\n const last = runs.at(-1)\n // Runs at one line height measure as one, whatever else they style.\n if (last?.end === start && last.lineHeight === lineHeight) last.end = end\n else runs.push({ start, end, lineHeight })\n }\n let position = 0\n for (const run of node.styleRuns) {\n if (position < run.start) add(position + lead, run.start + lead, own())\n const runSize = run.style.fontSize ?? node.fontSize\n const lineHeight =\n run.style.lineHeight !== undefined ? step(run.style.lineHeight, runSize) : own(runSize)\n add(run.start + lead, run.start + run.length + lead, lineHeight)\n position = run.start + run.length\n }\n if (position < node.text.length) add(position + lead, node.text.length + lead, own())\n return runs\n}\n\n/**\n * What placing a paragraph's lines as Figma does needs: its line heights, and its lines laid\n * out one by one from `node`'s text, the first after its indent and the last truncated as the\n * paragraph is.\n */\nfunction paragraphLines(\n r: TextRenderer,\n node: ParagraphNode,\n color: Float32Array | undefined,\n options: ParagraphBuildOptions,\n firstLineIndent = 0\n): TextLayoutBlockLines | undefined {\n // Lines are cut by character index, which the text's case must keep.\n if (shownText(node).length !== node.text.length) return undefined\n const lead = firstLineIndent > 0 ? 1 : 0\n const ellipsis = buildTruncateOpts(node).ellipsis\n // A justified line is stretched only with text after it: lines are laid out with the rest\n // of the paragraph and cut, as truncated last lines are.\n const justified = node.textAlignHorizontal === 'JUSTIFIED'\n const lineTruncation = (lines: number, truncated: boolean) => {\n if (truncated) return { maxLines: lines, ellipsis }\n return justified ? { maxLines: lines } : {}\n }\n return {\n heights: lineHeightRuns(node, lead),\n // A trimmed edge is laid out by where it stands in the paragraph.\n build:\n node.leadingTrim === 'CAP_HEIGHT'\n ? undefined\n : (start, end, lines, truncated) => {\n const from = Math.max(0, start - lead)\n const to = justified ? node.text.length : end - lead\n const line: ParagraphNode = {\n ...node,\n text: node.text.slice(from, to),\n styleRuns: sliceStyleRuns(node.styleRuns, from, to)\n }\n return buildSkParagraph(r, line, color, options, {\n firstLineIndent: start === 0 ? firstLineIndent : 0,\n truncation: lineTruncation(lines, truncated)\n })\n }\n }\n}\n\n/** Whether the text lays out paragraph by paragraph rather than as one native paragraph. */\nfunction needsParagraphLayout(node: ParagraphNode): boolean {\n return (\n hasTextList(node) ||\n node.paragraphSpacing !== 0 ||\n node.paragraphIndent !== 0 ||\n node.textParagraphs.some(hasParagraphSpacing)\n )\n}\n\nfunction layoutForNode(layout: TextLayout, node: ParagraphNode): void {\n if (node.textAutoResize !== 'WIDTH_AND_HEIGHT') {\n layout.layout(resolveParagraphLayoutWidth(node))\n return\n }\n const wrapWidth = resolveParagraphLayoutWidth(node)\n if (truncatesAtMaxWidth(node)) {\n layout.layout(Math.min(node.width || wrapWidth, wrapWidth))\n return\n }\n layout.layout(wrapWidth)\n const widestLine = Math.ceil(layout.getLongestLine())\n const width = Math.min(wrapWidth, Math.max(node.width || 1, widestLine))\n if (width !== wrapWidth) layout.layout(width)\n}\n\nfunction truncatesAtMaxWidth(node: ParagraphNode): boolean {\n return node.textTruncation === 'ENDING' && autoWidthWrapWidth(node) !== undefined\n}\n\ninterface ListStyle {\n em: number\n family: string\n style: string\n /** The name of the first character's face, which its markers are drawn in. */\n faceName: string | null\n /** The list's first character's style, which its markers take. */\n override: CharacterStyleOverride | undefined\n}\n\nfunction listStyle(node: ParagraphNode, firstCharacter: number): ListStyle {\n const override = styleAt(node.styleRuns, firstCharacter)\n return {\n em: override?.fontSize ?? (node.fontSize || DEFAULT_FONT_SIZE),\n family: override?.fontFamily ?? (node.fontFamily || DEFAULT_FONT_FAMILY),\n style: textFontFace(node, override).style,\n faceName: rangeFontStyle(node, override ?? {}),\n override\n }\n}\n\n/** A marker in its list's style, without the text's decoration and with figures of one width. */\nfunction markerNode(node: ParagraphNode, item: TextListItem, style: ListStyle): ParagraphNode {\n const override = style.override\n const features = override?.fontFeatures ?? node.fontFeatures\n return {\n ...node,\n text: item.marker,\n fontSize: style.em,\n fontFamily: style.family,\n fontWeight: override?.fontWeight ?? node.fontWeight,\n italic: override?.italic ?? node.italic,\n fontStyle: style.faceName,\n letterSpacing: override?.letterSpacing ?? node.letterSpacing,\n lineHeight: override?.lineHeight !== undefined ? override.lineHeight : node.lineHeight,\n fontVariations: override?.fontVariations ?? node.fontVariations,\n opticalSizeFromFontSize: override?.opticalSizeFromFontSize ?? node.opticalSizeFromFontSize,\n fontFeatures:\n item.listType === 'ORDERED' ? [...features, { tag: 'TNUM', enabled: true }] : features,\n textLanguage: override?.textLanguage !== undefined ? override.textLanguage : node.textLanguage,\n styleRuns: override?.fills\n ? [{ start: 0, length: item.marker.length, style: { fills: override.fills } }]\n : [],\n textCase: 'ORIGINAL',\n textDecoration: 'NONE',\n textDirection: 'LTR',\n textAlignHorizontal: 'LEFT',\n textAutoResize: 'WIDTH_AND_HEIGHT',\n textTruncation: 'DISABLED',\n maxLines: null\n }\n}\n\n/**\n * Text with lists, paragraph spacing, or a first-line indent, laid out one paragraph per\n * native paragraph: Skia has no hanging indent, so each list item lays out at the width its\n * indent leaves, beside a marker of its own.\n */\nfunction buildBlocks(\n r: TextRenderer,\n node: ParagraphNode,\n color: Float32Array | undefined,\n options: ParagraphBuildOptions\n): TextLayout {\n const shown = shownText(node)\n const sources = textParagraphRanges(node.text)\n const shownRanges = textParagraphRanges(shown)\n const items = new Map(\n textListItems(node.text, node.textParagraphs).map((item) => [item.paragraph, item])\n )\n const digits = topLevelNumberDigits([...items.values()])\n const rtl = resolveNodeTextDirection(node) === 'RTL'\n const truncation = buildTruncateOpts(node)\n const maxLines = truncation.maxLines\n // Each paragraph starts one byte, its newline, after the one before it ends.\n const utf8Starts: number[] = []\n let utf8Offset = 0\n for (const range of shownRanges) {\n utf8Starts.push(utf8Offset)\n utf8Offset += utf8Length(shown.slice(range.start, range.end)) + 1\n }\n\n const blocks: TextLayoutBlock[] = []\n try {\n for (const [index, { start, end }] of sources.entries()) {\n blocks.push(buildBlock(index, start, end))\n }\n } catch (error) {\n // Native paragraphs built before the failure are not garbage collected.\n for (const block of blocks) {\n block.paragraph.delete()\n block.marker?.paragraph.delete()\n }\n throw error\n }\n return new TextLayout(r.ck, blocks, maxLines)\n\n function buildBlock(index: number, start: number, end: number): TextLayoutBlock {\n const shownRange: TextParagraphRange = shownRanges[index]\n const item = items.get(index)\n const paragraphStyle = paragraphStyleAt(node.textParagraphs, index)\n const empty = end === start\n const blockNode: ParagraphNode = {\n ...node,\n text: empty ? ' ' : node.text.slice(start, end),\n styleRuns: empty\n ? sliceStyleRuns(node.styleRuns, start, start + 1)\n : sliceStyleRuns(node.styleRuns, start, end)\n }\n const paragraphIndent = paragraphSpacingAt(node, index, 'paragraphIndent')\n const firstLineIndent =\n paragraphStyle.listType === 'NONE' && paragraphIndent > 0 ? paragraphIndent : 0\n const blockOptions = (lines?: number): ParagraphBlockOptions => ({\n firstLineIndent,\n truncation: lines === undefined ? {} : { maxLines: lines, ellipsis: truncation.ellipsis },\n edges: { first: index === 0, last: index === sources.length - 1 }\n })\n const betweenItems =\n index > 0 &&\n paragraphStyleAt(node.textParagraphs, index - 1).listType !== 'NONE' &&\n paragraphStyle.listType !== 'NONE'\n const list = item ? listStyle(node, sources[item.groupStart].start) : null\n const marker = item && list ? buildMarker(r, node, item, list, color, options) : null\n let paragraph: Paragraph\n try {\n paragraph = buildSkParagraph(r, blockNode, color, options, blockOptions(maxLines))\n } catch (error) {\n marker?.paragraph.delete()\n throw error\n }\n return {\n paragraph,\n rebuild:\n maxLines === undefined\n ? undefined\n : (lines) => buildSkParagraph(r, blockNode, color, options, blockOptions(lines)),\n start: shownRange.start,\n utf8Start: utf8Starts[index],\n length: shownRange.end - shownRange.start,\n lead: firstLineIndent > 0 ? 1 : 0,\n utf8Lead: firstLineIndent > 0 ? PLACEHOLDER_UTF8_LENGTH : 0,\n leadWidth: firstLineIndent,\n empty,\n inset: item && list ? listInset(node, item, list, digits) : 0,\n rtl,\n // The space after a paragraph is its own: the paragraph before sets the space before.\n spaceBefore:\n index === 0\n ? 0\n : paragraphSpacingAt(node, index - 1, betweenItems ? 'listSpacing' : 'paragraphSpacing'),\n marker,\n lines: paragraphLines(r, blockNode, color, options, firstLineIndent),\n x: 0,\n y: 0,\n visible: true\n }\n }\n}\n\n/**\n * How far a list item's text stands from the start edge: its level's indent, widened for\n * ordered items by the digits past the first of the largest top-level number. A hanging list\n * moves the items back by one level, so markers stand outside the text box.\n */\nfunction listInset(\n node: ParagraphNode,\n item: TextListItem,\n list: ListStyle,\n digits: number\n): number {\n const unit = list.em * LIST_INDENT_EMS\n let inset = item.level * unit\n if (item.listType === 'ORDERED' && digits > 1) {\n const digit = glyphAdvanceSync(list.family, list.style, LIST_DIGIT_GLYPH_ID, list.em)\n inset += (digits - 1) * (digit ?? list.em * FALLBACK_DIGIT_EMS)\n }\n return node.hangingList ? inset - unit : inset\n}\n\nfunction buildMarker(\n r: TextRenderer,\n node: ParagraphNode,\n item: TextListItem,\n list: ListStyle,\n color: Float32Array | undefined,\n options: ParagraphBuildOptions\n): TextLayoutMarker {\n const paragraph = buildSkParagraph(r, markerNode(node, item, list), color, options)\n paragraph.layout(1e6)\n return {\n paragraph,\n kind: item.listType === 'ORDERED' ? 'number' : 'bullet',\n em: list.em,\n face: { family: list.family, style: list.style },\n x: 0,\n y: 0,\n lineNumber: 0\n }\n}\n\nfunction createTextLayout(\n r: TextRenderer,\n node: ParagraphNode,\n color: Float32Array | undefined,\n options: ParagraphBuildOptions\n): TextLayout {\n if (needsParagraphLayout(node)) return buildBlocks(r, node, color, options)\n const truncation = buildTruncateOpts(node)\n return TextLayout.ofParagraph(\n r.ck,\n buildSkParagraph(r, node, color, options, truncation.ellipsis ? { truncation } : undefined),\n shownText(node).length,\n paragraphLines(r, node, color, options)\n )\n}\n\n/** How many laid-out line boxes fit the fixed height, preserving the first line. */\nfunction linesWithinHeight(layout: TextLayout, height: number): number {\n const lines = layout.getLineMetrics()\n const firstOverflow = lines.findIndex((line) => line.baseline + line.descent > height)\n return Math.max(1, firstOverflow === -1 ? lines.length : firstOverflow)\n}\n\n/** Lay a text node out as the renderer draws it, at its own width. */\nexport function buildParagraph(\n r: TextRenderer,\n node: ParagraphNode,\n color?: Float32Array,\n options: ParagraphBuildOptions = {}\n): TextLayout {\n const layout = createTextLayout(r, node, color, options)\n // A box set to truncate clips to the lines its height holds, which is the auto-resize mode a\n // panel offers; an imported text may instead truncate only where `textTruncation` says so.\n const heightTruncation =\n (node.textTruncation === 'ENDING' || node.textAutoResize === 'TRUNCATE') &&\n node.height > 0 &&\n (node.maxLines == null || node.maxLines <= 0)\n let fittingLines: number | undefined\n try {\n layoutForNode(layout, node)\n if (heightTruncation) fittingLines = linesWithinHeight(layout, node.height)\n } catch (error) {\n layout.delete()\n throw error\n }\n if (fittingLines !== undefined && fittingLines < layout.getLineMetrics().length) {\n layout.delete()\n return buildParagraph(r, { ...node, maxLines: fittingLines }, color, options)\n }\n return layout\n}\n"],"mappings":";;;;;;;;;;;;;AAsCA,MAAM,kBAAkB;;;;;AAKxB,MAAM,sBAAsB;;AAE5B,MAAM,qBAAqB;;AAE3B,MAAM,0BAA0B;AAEhC,SAAS,QAAQ,MAA2B,OAAmD;CAC7F,OAAO,KAAK,MAAM,QAAQ,SAAS,IAAI,SAAS,QAAQ,IAAI,QAAQ,IAAI,MAAM,CAAC,EAAE;AACnF;;AAGA,SAAS,eAAe,MAA2B,OAAe,KAAyB;CACzF,MAAM,SAAqB,CAAC;CAC5B,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,OAAO,KAAK,IAAI,OAAO,IAAI,KAAK;EACtC,MAAM,KAAK,KAAK,IAAI,KAAK,IAAI,QAAQ,IAAI,MAAM;EAC/C,IAAI,KAAK,MAAM,OAAO,KAAK;GAAE,OAAO,OAAO;GAAO,QAAQ,KAAK;GAAM,OAAO,IAAI;EAAM,CAAC;CACzF;CACA,OAAO;AACT;;AAGA,SAAS,eAAe,MAAqB,MAA+B;CAG1E,MAAM,QAAQ,YAA+B,aAC3C,iBAAiB,YAAY,QAAQ,IAAI,eAAe,YAAY,QAAQ,IAAI;CAElF,MAAM,OAAO,WAAW,KAAK,aAAa,KAAK,KAAK,YAAY,QAAQ;CACxE,MAAM,OAAwB,CAAC;CAC/B,MAAM,OAAO,OAAe,KAAa,eAA8B;EACrE,MAAM,OAAO,KAAK,GAAG,EAAE;EAEvB,IAAI,MAAM,QAAQ,SAAS,KAAK,eAAe,YAAY,KAAK,MAAM;O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d.ts","names":[],"sources":["../../../../src/canvas/text/layout/index.ts"],"mappings":";;;;UAoBiB;EACf,WAAW;EACX;;EAEA;;EAEA;IAAQ;IAAgB;;;EAExB;EACA;EACA;;;UAIe;EACf,WAAW;;EAEX,WAAW,qBAAqB;;EAEhC;EACA;;EAEA;;EAEA;EACA;EACA;;EAEA;;EAEA;EACA;;EAEA;EACA,QAAQ;;EAER,QAAQ;EACR;EACA;;EAEA;;UAGe;EACf;EACA;EACA;;;;;;;;cASW;mBAsCQ;WACR,QAAQ;;mBAEA;UAxCX;UACA;UACA;mBACS;;UAET;;SAGD,YACL,IAAI,WACJ,WAAW,WACX,gBACA,QAAQ,uBACP;EAwBgB,YAAA,IAAI,WACZ,QAAQ,mBAEA;;EAAA;;mBAIF;UAET;EAIR,OAAO;UAmCC;;;;;UAYA;;UAWA;;UAKA;UAQA;UAIA;UAsBA;UAIA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../../src/canvas/text/layout/index.ts"],"mappings":";;;;UAoBiB;EACf,WAAW;EACX;;EAEA;;EAEA;IAAQ;IAAgB;;;EAExB;EACA;EACA;;;UAIe;EACf,WAAW;;EAEX,WAAW,qBAAqB;;EAEhC;EACA;;EAEA;;EAEA;EACA;EACA;;EAEA;;EAEA;EACA;;EAEA;EACA,QAAQ;;EAER,QAAQ;EACR;EACA;;EAEA;;UAGe;EACf;EACA;EACA;;;;;;;;cASW;mBAsCQ;WACR,QAAQ;;mBAEA;UAxCX;UACA;UACA;mBACS;;UAET;;SAGD,YACL,IAAI,WACJ,WAAW,WACX,gBACA,QAAQ,uBACP;EAwBgB,YAAA,IAAI,WACZ,QAAQ,mBAEA;;EAAA;;mBAIF;UAET;EAIR,OAAO;UAmCC;;;;;UAYA;;UAWA;;UAKA;UAQA;UAIA;UAsBA;UAIA;EAgDR;EAMA;EASA;EAIA,kBAAkB;EAIlB,iBAAiB,qBAAqB;;UAK9B;EASR,gBAAgB;EAehB,6BAA6B,WAAW,YAAY;EAsBpD,iBACE,eACA,aACA,aAAa,iBACb,YAAY,iBACX;;;;;EA4BH,aAAa,eAAe,eAAe;;;;;UAoDnC;;;;;;EAgBR,kBAAkB;UA0CV;;EAKR,cAAc;EAMd,KAAK,QAAQ,QAAQ,WAAW;;UAaxB;EAcR;EAIA"}
|
|
@@ -141,10 +141,14 @@ var TextLayout = class TextLayout {
|
|
|
141
141
|
const metrics = block.paragraph.getLineMetrics();
|
|
142
142
|
const boxes = this.placements.get(block)?.boxes;
|
|
143
143
|
const blockEnd = block.start + block.length;
|
|
144
|
+
let previousEnd = block.start;
|
|
144
145
|
for (const [lineIndex, line] of metrics.entries()) {
|
|
145
146
|
const endsAtNewline = lineIndex === metrics.length - 1 && blockIndex < visible.length - 1;
|
|
146
147
|
const indent = lineIndex === 0 ? block.leadWidth : 0;
|
|
147
148
|
const box = boxes?.[lineIndex];
|
|
149
|
+
const startIndex = Math.max(previousEnd, this.toTextIndex(block, line.startIndex));
|
|
150
|
+
const endIncludingNewline = endsAtNewline ? blockEnd + 1 : this.toTextIndex(block, line.endIncludingNewline);
|
|
151
|
+
previousEnd = endIncludingNewline;
|
|
148
152
|
this.lines.push({
|
|
149
153
|
...line,
|
|
150
154
|
...box && {
|
|
@@ -152,10 +156,10 @@ var TextLayout = class TextLayout {
|
|
|
152
156
|
descent: box.height - box.ascent,
|
|
153
157
|
height: box.height
|
|
154
158
|
},
|
|
155
|
-
startIndex
|
|
156
|
-
endIndex: this.toTextIndex(block, line.endIndex),
|
|
157
|
-
endExcludingWhitespaces: this.toTextIndex(block, line.endExcludingWhitespaces),
|
|
158
|
-
endIncludingNewline
|
|
159
|
+
startIndex,
|
|
160
|
+
endIndex: Math.max(startIndex, this.toTextIndex(block, line.endIndex)),
|
|
161
|
+
endExcludingWhitespaces: Math.max(startIndex, this.toTextIndex(block, line.endExcludingWhitespaces)),
|
|
162
|
+
endIncludingNewline,
|
|
159
163
|
isHardBreak: endsAtNewline || line.isHardBreak,
|
|
160
164
|
width: block.empty ? 0 : line.width - indent,
|
|
161
165
|
left: line.left + block.x + (block.rtl ? 0 : indent),
|