@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glyphs.js","names":[],"sources":["../../../src/text/font/glyphs.ts"],"sourcesContent":["import type { FontVariation } from '@pairdraw/scene-graph'\n\nimport { fontManager } from '#core/text/font/manager'\n\nimport {\n fontInstance,\n glyphCommands,\n harfBuzzFont,\n isHarfBuzzLoaded,\n loadHarfBuzz,\n shapeText,\n type HarfBuzzFont,\n type OutlineCommand,\n type ShapingOptions\n} from './harfbuzz'\nimport { fontTableView } from './variation'\n\nexport type { OutlineCommand } from './harfbuzz'\n\nexport interface GlyphOutlineProbe {\n family: string\n style: string\n unitsPerEm: number\n commandCount: number\n firstGlyphCommandSample: OutlineCommand[]\n}\n\ninterface ParsedFontCacheEntry {\n bytes: ArrayBuffer\n font: HarfBuzzFont | null\n}\n\nconst parsedFontCache = new Map<string, ParsedFontCacheEntry>()\n\n/** Shards of a style, read only to tell which one maps a character. */\nconst shardFontCache = new WeakMap<ArrayBuffer, HarfBuzzFont | null>()\n\n/** Whether a shard of a style, one of `FontManager.shardData`'s files, maps `character`. */\nexport function shardCovers(data: ArrayBuffer, character: string): boolean {\n if (!isHarfBuzzLoaded()) return false\n const parsed = shardFont(data)\n return parsed !== null && glyphIndex(parsed, character) !== 0\n}\n\nfunction shardFont(data: ArrayBuffer): HarfBuzzFont | null {\n let parsed = shardFontCache.get(data)\n if (parsed === undefined) {\n parsed = harfBuzzFont(data)\n shardFontCache.set(data, parsed)\n }\n return parsed\n}\n\nfunction getParsedFont(family: string, style: string): HarfBuzzFont | null {\n if (!isHarfBuzzLoaded()) return null\n const key = `${family}|${style}`\n const bytes = fontManager.loadedData(family, style)\n if (!bytes) return null\n const cached = parsedFontCache.get(key)\n if (cached?.bytes === bytes) return cached.font\n const font = harfBuzzFont(bytes)\n parsedFontCache.set(key, { bytes, font })\n return font\n}\n\n/** The glyph the font maps a character to, 0 (`.notdef`) when it has none. */\nexport function glyphIndex(parsed: HarfBuzzFont, character: string): number {\n const codePoint = character.codePointAt(0)\n if (codePoint === undefined) return 0\n let glyph = parsed.glyphIds.get(codePoint)\n if (glyph === undefined) {\n glyph = parsed.font.glyph(codePoint) ?? 0\n parsed.glyphIds.set(codePoint, glyph)\n }\n return glyph\n}\n\n/** A glyph's advance in the font's default instance, in font units. */\nfunction glyphAdvanceUnits(parsed: HarfBuzzFont, glyphId: number): number {\n let advance = parsed.advances.get(glyphId)\n if (advance === undefined) {\n advance = parsed.font.glyphHAdvance(glyphId)\n parsed.advances.set(glyphId, advance)\n }\n return advance\n}\n\n/** A glyph's advance in the font's default instance, at `fontSize`. */\nfunction glyphAdvanceWidth(parsed: HarfBuzzFont, glyphId: number, fontSize: number): number {\n return (glyphAdvanceUnits(parsed, glyphId) * fontSize) / parsed.face.upem\n}\n\n/**\n * True when the font is available AND parseable for glyph-outline extraction —\n * i.e. getGlyphOutlineMetricsSync can produce outlines for it. Availability is\n * currently local (fontManager), but the contract is provider-agnostic so a\n * future remote source can satisfy it. Path-text editing needs this to reflow;\n * without it the text is a baked graphic.\n */\nexport function hasGlyphOutlines(family: string, style: string): boolean {\n return getParsedFont(family, style) !== null\n}\n\ninterface LineMetrics {\n ascender: number\n descender: number\n lineGap: number\n}\n\nconst lineMetricsCache = new WeakMap<HarfBuzzFont, LineMetrics>()\n\n/** The line metrics the font's `hhea` and `OS/2` tables declare, in font units, read once. */\nfunction lineMetrics(parsed: HarfBuzzFont): LineMetrics {\n const cached = lineMetricsCache.get(parsed)\n if (cached) return cached\n const hhea = fontTableView(parsed.bytes, 'hhea')\n const os2 = fontTableView(parsed.bytes, 'OS/2')\n const hasHhea = hhea !== null && hhea.byteLength >= 8\n const metrics = {\n ascender: hasHhea ? hhea.getInt16(4) : 0,\n descender: hasHhea ? hhea.getInt16(6) : 0,\n lineGap: os2 && os2.byteLength >= 74 ? os2.getInt16(72) : 0\n }\n lineMetricsCache.set(parsed, metrics)\n return metrics\n}\n\nexport function measureTextWithFont(\n text: string,\n fontSize: number,\n family: string,\n style: string,\n maxWidth?: number,\n lineHeight?: number\n): { width: number; height: number } | null {\n const parsed = getParsedFont(family, style)\n if (!parsed) return null\n\n const scale = fontSize / parsed.face.upem\n const { ascender, descender, lineGap } = lineMetrics(parsed)\n const lineH = lineHeight ?? Math.ceil((ascender - descender + lineGap) * scale)\n\n let units = 0\n for (const character of text) units += glyphAdvanceUnits(parsed, glyphIndex(parsed, character))\n const singleLineWidth = units * scale\n\n if (maxWidth && maxWidth > 0 && singleLineWidth > maxWidth) {\n const lines = Math.ceil(singleLineWidth / maxWidth)\n return { width: maxWidth, height: Math.ceil(lines * lineH) }\n }\n return { width: Math.ceil(singleLineWidth), height: lineH }\n}\n\n/**\n * Where a font draws its underline and strikethrough, in ems: each line's top edge below the\n * baseline (negative above it) and its thickness. Figma places an underline's top half its\n * thickness below the font's underline position, and a strikethrough's top at its strikeout\n * position.\n */\nexport interface FontDecorationMetrics {\n underlineTop: number\n underlineThickness: number\n strikethroughTop: number\n strikethroughThickness: number\n}\n\n/** The decoration metrics of a loaded font, or `null` when it is not loaded or lacks them. */\nexport function fontDecorationMetricsSync(\n family: string,\n style: string\n): FontDecorationMetrics | null {\n const parsed = getParsedFont(family, style)\n if (!parsed) return null\n const { MetricsTag } = parsed.hb\n const underlinePosition = parsed.font.getMetricPosition(MetricsTag.UNDERLINE_OFFSET)\n const underlineThickness = parsed.font.getMetricPosition(MetricsTag.UNDERLINE_SIZE)\n const strikeoutPosition = parsed.font.getMetricPosition(MetricsTag.STRIKEOUT_OFFSET)\n const strikeoutSize = parsed.font.getMetricPosition(MetricsTag.STRIKEOUT_SIZE)\n if (\n underlinePosition === undefined ||\n !underlineThickness ||\n strikeoutPosition === undefined ||\n !strikeoutSize\n )\n return null\n const em = parsed.face.upem\n return {\n underlineTop: (underlineThickness / 2 - underlinePosition) / em,\n underlineThickness: underlineThickness / em,\n strikethroughTop: -strikeoutPosition / em,\n strikethroughThickness: strikeoutSize / em\n }\n}\n\n/** How far a loaded font reaches above and below the baseline, in ems; null when not loaded. */\nexport function fontVerticalMetricsSync(\n family: string,\n style: string\n): { ascent: number; descent: number } | null {\n const parsed = getParsedFont(family, style)\n if (!parsed) return null\n const { ascender, descender } = lineMetrics(parsed)\n return { ascent: ascender / parsed.face.upem, descent: -descender / parsed.face.upem }\n}\n\n/** A shaped glyph: its outline relative to the pen at `x`, where shaping placed it, and its advance. */\nexport interface GlyphOutlineMetrics {\n commands: OutlineCommand[]\n x: number\n advance: number\n}\n\nexport type FontGlyphCoverage = 'has' | 'missing' | 'unknown'\n\nexport function fontGlyphCoverageSync(\n family: string,\n style: string,\n char: string\n): FontGlyphCoverage {\n const parsed = getParsedFont(family, style)\n if (!parsed) return 'unknown'\n return glyphIndex(parsed, char) !== 0 ? 'has' : 'missing'\n}\n\nexport function fontHasGlyphSync(family: string, style: string, char: string): boolean {\n return fontGlyphCoverageSync(family, style, char) === 'has'\n}\n\n/** Each glyph HarfBuzz shapes `text` into, with its outline, pen position, and advance. */\nexport function getGlyphOutlineMetricsSync(\n family: string,\n style: string,\n text: string,\n fontSize: number\n): GlyphOutlineMetrics[] | null {\n const parsed = getParsedFont(family, style)\n if (!parsed) return null\n const scale = fontSize / parsed.face.upem\n const instance = fontInstance(parsed, [])\n let pen = 0\n return shapeText(parsed, text).map((glyph) => {\n // Shaping moves some glyphs off the pen, such as marks onto their base letter.\n const offsetX = (glyph.xOffset ?? 0) * scale\n // y runs down; subtracting keeps an unmoved glyph's baseline 0 rather than -0.\n const baseline = 0 - (glyph.yOffset ?? 0) * scale\n const metrics = {\n commands: glyphCommands(parsed, instance, glyph.codepoint, fontSize, baseline, offsetX),\n x: pen,\n advance: (glyph.xAdvance ?? 0) * scale\n }\n pen += metrics.advance\n return metrics\n })\n}\n\n/** Outlines of one loaded font, addressed by the glyph IDs a shaper produced. */\n/** A glyph HarfBuzz shaped text into: its ID, the UTF-16 index it starts at, and its advance in em. */\nexport interface ShapedGlyph {\n id: number\n cluster: number\n advance: number\n /** How far HarfBuzz moved it from the pen, in em, such as a mark onto its base; y runs up. */\n xOffset: number\n yOffset: number\n}\n\n/** How a run is shaped, apart from the font and its axes. */\nexport type RunShaping = Omit<ShapingOptions, 'instance'>\n\nexport interface GlyphOutlineSource {\n /** Whether the font has a glyph for every code point, so a shaper used it rather than a fallback. */\n covers(text: string): boolean\n /** The glyph the font maps `character` to, to check a shaper's glyph IDs are this font's. */\n glyphOf(character: string): number\n /** The glyphs HarfBuzz shapes `text` into in this font, at its axes and as `shaping` asks. */\n shape(text: string, shaping: RunShaping): ShapedGlyph[]\n outline(glyphId: number, fontSize: number): OutlineCommand[] | null\n}\n\n/**\n * Glyph outlines by glyph ID for a loaded font, or `null` when it is not loaded or cannot be\n * parsed. A variable font draws the instance at `variations`, the axis values the shaper used.\n */\nexport function glyphOutlineSourceSync(\n family: string,\n style: string,\n variations: readonly FontVariation[] = []\n): GlyphOutlineSource | null {\n const parsed = getParsedFont(family, style)\n return parsed ? outlineSource(parsed, variations) : null\n}\n\n/**\n * Glyph outlines of each shard of a loaded style, the files `FontManager.shardData` lists for\n * the characters its own file lacks, at `variations`.\n */\nexport function shardOutlineSources(\n family: string,\n style: string,\n variations: readonly FontVariation[] = []\n): GlyphOutlineSource[] {\n if (!isHarfBuzzLoaded()) return []\n return fontManager.shardData(family, style).flatMap((data) => {\n const parsed = shardFont(data)\n return parsed ? [outlineSource(parsed, variations)] : []\n })\n}\n\nfunction outlineSource(\n parsed: HarfBuzzFont,\n variations: readonly FontVariation[]\n): GlyphOutlineSource {\n const instance = fontInstance(parsed, variations)\n return {\n covers: (text) => Array.from(text).every((char) => glyphIndex(parsed, char) !== 0),\n glyphOf: (character) => glyphIndex(parsed, character),\n shape: (text, shaping) =>\n shapeText(parsed, text, { ...shaping, instance }).map((glyph) => ({\n id: glyph.codepoint,\n cluster: glyph.cluster,\n advance: (glyph.xAdvance ?? 0) / parsed.face.upem,\n xOffset: (glyph.xOffset ?? 0) / parsed.face.upem,\n yOffset: (glyph.yOffset ?? 0) / parsed.face.upem\n })),\n outline: (glyphId, fontSize) =>\n glyphId < parsed.glyphCount ? glyphCommands(parsed, instance, glyphId, fontSize) : null\n }\n}\n\n/** The advance of glyph `glyphId` of a loaded font at `fontSize`, or `null` when it has none. */\nexport function glyphAdvanceSync(\n family: string,\n style: string,\n glyphId: number,\n fontSize: number\n): number | null {\n const parsed = getParsedFont(family, style)\n if (!parsed || glyphId >= parsed.glyphCount) return null\n return glyphAdvanceWidth(parsed, glyphId, fontSize)\n}\n\nexport async function probeGlyphOutlineCommands(\n family: string,\n style: string,\n text: string,\n fontSize: number\n): Promise<GlyphOutlineProbe | null> {\n const bytes = fontManager.loadedData(family, style)\n if (!bytes) return null\n await loadHarfBuzz()\n const parsed = harfBuzzFont(bytes)\n if (!parsed) return null\n const outlines = Array.from(text, (character) =>\n glyphCommands(parsed, fontInstance(parsed, []), glyphIndex(parsed, character), fontSize)\n )\n const first = outlines.find((commands) => commands.length > 0) ?? []\n\n return {\n family,\n style,\n unitsPerEm: parsed.face.upem,\n commandCount: first.length,\n firstGlyphCommandSample: first.slice(0, 12)\n }\n}\n"],"mappings":";;;;AAgCA,MAAM,kCAAkB,IAAI,IAAkC;;AAG9D,MAAM,iCAAiB,IAAI,QAA0C;;AAGrE,SAAgB,YAAY,MAAmB,WAA4B;CACzE,IAAI,CAAC,iBAAiB,GAAG,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AAS,aACjB,UAAU,OAAO,aAAa,cAAc,QAAQ,UAAU,SAAS,QAAQ,IAAI;CACvF;AACF;;AAGA,SAAgB,iBACd,QACA,OACA,SACA,UACe;CACf,MAAM,SAAS,cAAc,QAAQ,KAAK;CAC1C,IAAI,CAAC,UAAU,WAAW,OAAO,YAAY,OAAO;CACpD,OAAO,kBAAkB,QAAQ,SAAS,QAAQ;AACpD;AAEA,eAAsB,0BACpB,QACA,OACA,MACA,UACmC;CACnC,MAAM,QAAQ,YAAY,WAAW,QAAQ,KAAK;CAClD,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,aAAa;CACnB,MAAM,SAAS,aAAa,KAAK;CACjC,IAAI,CAAC,QAAQ,OAAO;CAIpB,MAAM,QAHW,MAAM,KAAK,OAAO,cACjC,cAAc,QAAQ,aAAa,QAAQ,CAAC,CAAC,GAAG,WAAW,QAAQ,SAAS,GAAG,QAAQ,CAEpE,CAAC,CAAC,MAAM,aAAa,SAAS,SAAS,CAAC,KAAK,CAAC;CAEnE,OAAO;EACL;EACA;EACA,YAAY,OAAO,KAAK;EACxB,cAAc,MAAM;EACpB,yBAAyB,MAAM,MAAM,GAAG,EAAE;CAC5C;AACF"}
|
|
1
|
+
{"version":3,"file":"glyphs.js","names":[],"sources":["../../../src/text/font/glyphs.ts"],"sourcesContent":["import type { FontVariation } from '@pairdraw/scene-graph'\n\nimport { fontManager } from '#core/text/font/manager'\n\nimport {\n fontInstance,\n glyphCommands,\n harfBuzzFont,\n isHarfBuzzLoaded,\n loadHarfBuzz,\n shapeText,\n type HarfBuzzFont,\n type OutlineCommand,\n type ShapingOptions\n} from './harfbuzz'\nimport { fontTableView } from './variation'\n\nexport type { OutlineCommand } from './harfbuzz'\n\nexport interface GlyphOutlineProbe {\n family: string\n style: string\n unitsPerEm: number\n commandCount: number\n firstGlyphCommandSample: OutlineCommand[]\n}\n\ninterface ParsedFontCacheEntry {\n bytes: ArrayBuffer\n font: HarfBuzzFont | null\n}\n\nconst parsedFontCache = new Map<string, ParsedFontCacheEntry>()\n\n/** Shards of a style, read only to tell which one maps a character. */\nconst shardFontCache = new WeakMap<ArrayBuffer, HarfBuzzFont | null>()\n\n/** Whether a shard of a style, one of `FontManager.shardData`'s files, maps `character`. */\nexport function shardCovers(data: ArrayBuffer, character: string): boolean {\n if (!isHarfBuzzLoaded()) return false\n const parsed = shardFont(data)\n return parsed !== null && glyphIndex(parsed, character) !== 0\n}\n\nfunction shardFont(data: ArrayBuffer): HarfBuzzFont | null {\n let parsed = shardFontCache.get(data)\n if (parsed === undefined) {\n parsed = harfBuzzFont(data)\n shardFontCache.set(data, parsed)\n }\n return parsed\n}\n\nfunction getParsedFont(family: string, style: string): HarfBuzzFont | null {\n if (!isHarfBuzzLoaded()) return null\n const key = `${family}|${style}`\n const bytes = fontManager.loadedData(family, style)\n if (!bytes) return null\n const cached = parsedFontCache.get(key)\n if (cached?.bytes === bytes) return cached.font\n const font = harfBuzzFont(bytes)\n parsedFontCache.set(key, { bytes, font })\n return font\n}\n\n/** The glyph the font maps a character to, 0 (`.notdef`) when it has none. */\nexport function glyphIndex(parsed: HarfBuzzFont, character: string): number {\n const codePoint = character.codePointAt(0)\n if (codePoint === undefined) return 0\n let glyph = parsed.glyphIds.get(codePoint)\n if (glyph === undefined) {\n glyph = parsed.font.glyph(codePoint) ?? 0\n parsed.glyphIds.set(codePoint, glyph)\n }\n return glyph\n}\n\n/** A glyph's advance in the font's default instance, in font units. */\nfunction glyphAdvanceUnits(parsed: HarfBuzzFont, glyphId: number): number {\n let advance = parsed.advances.get(glyphId)\n if (advance === undefined) {\n advance = parsed.font.glyphHAdvance(glyphId)\n parsed.advances.set(glyphId, advance)\n }\n return advance\n}\n\n/** A glyph's advance in the font's default instance, at `fontSize`. */\nfunction glyphAdvanceWidth(parsed: HarfBuzzFont, glyphId: number, fontSize: number): number {\n return (glyphAdvanceUnits(parsed, glyphId) * fontSize) / parsed.face.upem\n}\n\n/**\n * True when the font is available AND parseable for glyph-outline extraction —\n * i.e. getGlyphOutlineMetricsSync can produce outlines for it. Availability is\n * currently local (fontManager), but the contract is provider-agnostic so a\n * future remote source can satisfy it. Path-text editing needs this to reflow;\n * without it the text is a baked graphic.\n */\nexport function hasGlyphOutlines(family: string, style: string): boolean {\n return getParsedFont(family, style) !== null\n}\n\ninterface LineMetrics {\n ascender: number\n descender: number\n lineGap: number\n}\n\nconst lineMetricsCache = new WeakMap<HarfBuzzFont, LineMetrics>()\n\n/** The line metrics the font's `hhea` and `OS/2` tables declare, in font units, read once. */\nfunction lineMetrics(parsed: HarfBuzzFont): LineMetrics {\n const cached = lineMetricsCache.get(parsed)\n if (cached) return cached\n const hhea = fontTableView(parsed.bytes, 'hhea')\n const os2 = fontTableView(parsed.bytes, 'OS/2')\n const hasHhea = hhea !== null && hhea.byteLength >= 8\n const metrics = {\n ascender: hasHhea ? hhea.getInt16(4) : 0,\n descender: hasHhea ? hhea.getInt16(6) : 0,\n lineGap: os2 && os2.byteLength >= 74 ? os2.getInt16(72) : 0\n }\n lineMetricsCache.set(parsed, metrics)\n return metrics\n}\n\nexport function measureTextWithFont(\n text: string,\n fontSize: number,\n family: string,\n style: string,\n maxWidth?: number,\n lineHeight?: number\n): { width: number; height: number } | null {\n const parsed = getParsedFont(family, style)\n if (!parsed) return null\n\n const scale = fontSize / parsed.face.upem\n const { ascender, descender, lineGap } = lineMetrics(parsed)\n const lineH = lineHeight ?? Math.ceil((ascender - descender + lineGap) * scale)\n\n let units = 0\n for (const character of text) units += glyphAdvanceUnits(parsed, glyphIndex(parsed, character))\n const singleLineWidth = units * scale\n\n if (maxWidth && maxWidth > 0 && singleLineWidth > maxWidth) {\n const lines = Math.ceil(singleLineWidth / maxWidth)\n return { width: maxWidth, height: Math.ceil(lines * lineH) }\n }\n return { width: Math.ceil(singleLineWidth), height: lineH }\n}\n\n/**\n * Where a font draws its underline and strikethrough, in ems: each line's top edge below the\n * baseline (negative above it) and its thickness. Figma places an underline's top half its\n * thickness below the font's underline position, and a strikethrough's top at its strikeout\n * position.\n */\nexport interface FontDecorationMetrics {\n underlineTop: number\n underlineThickness: number\n strikethroughTop: number\n strikethroughThickness: number\n}\n\n/** The decoration metrics of a loaded font, or `null` when it is not loaded or lacks them. */\nexport function fontDecorationMetricsSync(\n family: string,\n style: string\n): FontDecorationMetrics | null {\n const parsed = getParsedFont(family, style)\n if (!parsed) return null\n const { MetricsTag } = parsed.hb\n const underlinePosition = parsed.font.getMetricPosition(MetricsTag.UNDERLINE_OFFSET)\n const underlineThickness = parsed.font.getMetricPosition(MetricsTag.UNDERLINE_SIZE)\n const strikeoutPosition = parsed.font.getMetricPosition(MetricsTag.STRIKEOUT_OFFSET)\n const strikeoutSize = parsed.font.getMetricPosition(MetricsTag.STRIKEOUT_SIZE)\n if (\n underlinePosition === undefined ||\n !underlineThickness ||\n strikeoutPosition === undefined ||\n !strikeoutSize\n )\n return null\n const em = parsed.face.upem\n return {\n underlineTop: (underlineThickness / 2 - underlinePosition) / em,\n underlineThickness: underlineThickness / em,\n strikethroughTop: -strikeoutPosition / em,\n strikethroughThickness: strikeoutSize / em\n }\n}\n\n/** How far a loaded font reaches above and below the baseline, in ems; null when not loaded. */\nexport function fontVerticalMetricsSync(\n family: string,\n style: string\n): { ascent: number; descent: number } | null {\n const parsed = getParsedFont(family, style)\n if (!parsed) return null\n const { ascender, descender } = lineMetrics(parsed)\n return { ascent: ascender / parsed.face.upem, descent: -descender / parsed.face.upem }\n}\n\n/** A shaped glyph: its outline relative to the pen at `x`, where shaping placed it, and its advance. */\nexport interface GlyphOutlineMetrics {\n commands: OutlineCommand[]\n x: number\n advance: number\n}\n\nexport type FontGlyphCoverage = 'has' | 'missing' | 'unknown'\n\nexport function fontGlyphCoverageSync(\n family: string,\n style: string,\n char: string\n): FontGlyphCoverage {\n const parsed = getParsedFont(family, style)\n if (!parsed) return 'unknown'\n return glyphIndex(parsed, char) !== 0 ? 'has' : 'missing'\n}\n\nexport function fontHasGlyphSync(family: string, style: string, char: string): boolean {\n return fontGlyphCoverageSync(family, style, char) === 'has'\n}\n\n/**\n * Each glyph HarfBuzz shapes `text` into, with its outline, pen position, and advance. A variable\n * font shapes and draws the instance at `variations`.\n */\nexport function getGlyphOutlineMetricsSync(\n family: string,\n style: string,\n text: string,\n fontSize: number,\n variations: readonly FontVariation[] = []\n): GlyphOutlineMetrics[] | null {\n const parsed = getParsedFont(family, style)\n if (!parsed) return null\n const scale = fontSize / parsed.face.upem\n const instance = fontInstance(parsed, variations)\n let pen = 0\n return shapeText(parsed, text, { instance }).map((glyph) => {\n // Shaping moves some glyphs off the pen, such as marks onto their base letter.\n const offsetX = (glyph.xOffset ?? 0) * scale\n // y runs down; subtracting keeps an unmoved glyph's baseline 0 rather than -0.\n const baseline = 0 - (glyph.yOffset ?? 0) * scale\n const metrics = {\n commands: glyphCommands(parsed, instance, glyph.codepoint, fontSize, baseline, offsetX),\n x: pen,\n advance: (glyph.xAdvance ?? 0) * scale\n }\n pen += metrics.advance\n return metrics\n })\n}\n\n/**\n * The advance of each glyph HarfBuzz shapes `text` into and the UTF-16 index it starts at, at\n * `fontSize` and, in a variable font, the instance at `variations`.\n */\nexport function shapedAdvancesSync(\n family: string,\n style: string,\n text: string,\n fontSize: number,\n variations: readonly FontVariation[] = []\n): { cluster: number; advance: number }[] | null {\n const parsed = getParsedFont(family, style)\n if (!parsed) return null\n const scale = fontSize / parsed.face.upem\n const instance = fontInstance(parsed, variations)\n return shapeText(parsed, text, { instance }).map((glyph) => ({\n cluster: glyph.cluster,\n advance: (glyph.xAdvance ?? 0) * scale\n }))\n}\n\n/** Outlines of one loaded font, addressed by the glyph IDs a shaper produced. */\n/** A glyph HarfBuzz shaped text into: its ID, the UTF-16 index it starts at, and its advance in em. */\nexport interface ShapedGlyph {\n id: number\n cluster: number\n advance: number\n /** How far HarfBuzz moved it from the pen, in em, such as a mark onto its base; y runs up. */\n xOffset: number\n yOffset: number\n}\n\n/** How a run is shaped, apart from the font and its axes. */\nexport type RunShaping = Omit<ShapingOptions, 'instance'>\n\nexport interface GlyphOutlineSource {\n /** Whether the font has a glyph for every code point, so a shaper used it rather than a fallback. */\n covers(text: string): boolean\n /** The glyph the font maps `character` to, to check a shaper's glyph IDs are this font's. */\n glyphOf(character: string): number\n /** The glyphs HarfBuzz shapes `text` into in this font, at its axes and as `shaping` asks. */\n shape(text: string, shaping: RunShaping): ShapedGlyph[]\n outline(glyphId: number, fontSize: number): OutlineCommand[] | null\n}\n\n/**\n * Glyph outlines by glyph ID for a loaded font, or `null` when it is not loaded or cannot be\n * parsed. A variable font draws the instance at `variations`, the axis values the shaper used.\n */\nexport function glyphOutlineSourceSync(\n family: string,\n style: string,\n variations: readonly FontVariation[] = []\n): GlyphOutlineSource | null {\n const parsed = getParsedFont(family, style)\n return parsed ? outlineSource(parsed, variations) : null\n}\n\n/**\n * Glyph outlines of each shard of a loaded style, the files `FontManager.shardData` lists for\n * the characters its own file lacks, at `variations`.\n */\nexport function shardOutlineSources(\n family: string,\n style: string,\n variations: readonly FontVariation[] = []\n): GlyphOutlineSource[] {\n if (!isHarfBuzzLoaded()) return []\n return fontManager.shardData(family, style).flatMap((data) => {\n const parsed = shardFont(data)\n return parsed ? [outlineSource(parsed, variations)] : []\n })\n}\n\nfunction outlineSource(\n parsed: HarfBuzzFont,\n variations: readonly FontVariation[]\n): GlyphOutlineSource {\n const instance = fontInstance(parsed, variations)\n return {\n covers: (text) => Array.from(text).every((char) => glyphIndex(parsed, char) !== 0),\n glyphOf: (character) => glyphIndex(parsed, character),\n shape: (text, shaping) =>\n shapeText(parsed, text, { ...shaping, instance }).map((glyph) => ({\n id: glyph.codepoint,\n cluster: glyph.cluster,\n advance: (glyph.xAdvance ?? 0) / parsed.face.upem,\n xOffset: (glyph.xOffset ?? 0) / parsed.face.upem,\n yOffset: (glyph.yOffset ?? 0) / parsed.face.upem\n })),\n outline: (glyphId, fontSize) =>\n glyphId < parsed.glyphCount ? glyphCommands(parsed, instance, glyphId, fontSize) : null\n }\n}\n\n/** The advance of glyph `glyphId` of a loaded font at `fontSize`, or `null` when it has none. */\nexport function glyphAdvanceSync(\n family: string,\n style: string,\n glyphId: number,\n fontSize: number\n): number | null {\n const parsed = getParsedFont(family, style)\n if (!parsed || glyphId >= parsed.glyphCount) return null\n return glyphAdvanceWidth(parsed, glyphId, fontSize)\n}\n\nexport async function probeGlyphOutlineCommands(\n family: string,\n style: string,\n text: string,\n fontSize: number\n): Promise<GlyphOutlineProbe | null> {\n const bytes = fontManager.loadedData(family, style)\n if (!bytes) return null\n await loadHarfBuzz()\n const parsed = harfBuzzFont(bytes)\n if (!parsed) return null\n const outlines = Array.from(text, (character) =>\n glyphCommands(parsed, fontInstance(parsed, []), glyphIndex(parsed, character), fontSize)\n )\n const first = outlines.find((commands) => commands.length > 0) ?? []\n\n return {\n family,\n style,\n unitsPerEm: parsed.face.upem,\n commandCount: first.length,\n firstGlyphCommandSample: first.slice(0, 12)\n }\n}\n"],"mappings":";;;;AAgCA,MAAM,kCAAkB,IAAI,IAAkC;;AAG9D,MAAM,iCAAiB,IAAI,QAA0C;;AAGrE,SAAgB,YAAY,MAAmB,WAA4B;CACzE,IAAI,CAAC,iBAAiB,GAAG,OAAO;CAChC,MAAM,SAAS,UAAU,IAAI;CAC7B,OAAO,WAAW,QAAQ,WAAW,QAAQ,SAAS,MAAM;AAC9D;AAEA,SAAS,UAAU,MAAwC;CACzD,IAAI,SAAS,eAAe,IAAI,IAAI;CACpC,IAAI,WAAW,KAAA,GAAW;EACxB,SAAS,aAAa,IAAI;EAC1B,eAAe,IAAI,MAAM,MAAM;CACjC;CACA,OAAO;AACT;AAEA,SAAS,cAAc,QAAgB,OAAoC;CACzE,IAAI,CAAC,iBAAiB,GAAG,OAAO;CAChC,MAAM,MAAM,GAAG,OAAO,GAAG;CACzB,MAAM,QAAQ,YAAY,WAAW,QAAQ,KAAK;CAClD,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,SAAS,gBAAgB,IAAI,GAAG;CACtC,IAAI,QAAQ,UAAU,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AS,cAAc,QAAQ,KAAK;CAC1C,IAAI,CAAC,UAAU,WAAW,OAAO,YAAY,OAAO;CACpD,OAAO,kBAAkB,QAAQ,SAAS,QAAQ;AACpD;AAEA,eAAsB,0BACpB,QACA,OACA,MACA,UACmC;CACnC,MAAM,QAAQ,YAAY,WAAW,QAAQ,KAAK;CAClD,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,aAAa;CACnB,MAAM,SAAS,aAAa,KAAK;CACjC,IAAI,CAAC,QAAQ,OAAO;CAIpB,MAAM,QAHW,MAAM,KAAK,OAAO,cACjC,cAAc,QAAQ,aAAa,QAAQ,CAAC,CAAC,GAAG,WAAW,QAAQ,SAAS,GAAG,QAAQ,CAEpE,CAAC,CAAC,MAAM,aAAa,SAAS,SAAS,CAAC,KAAK,CAAC;CAEnE,OAAO;EACL;EACA;EACA,YAAY,OAAO,KAAK;EACxB,cAAc,MAAM;EACpB,yBAAyB,MAAM,MAAM,GAAG,EAAE;CAC5C;AACF"}
|
package/dist/text/font/local.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IS_BROWSER } from "../../constants.js";
|
|
2
2
|
import { SharedReads } from "./reads.js";
|
|
3
|
-
import {
|
|
3
|
+
import { findLocalFont } from "./style.js";
|
|
4
4
|
//#region src/text/font/local.ts
|
|
5
5
|
/** The fonts installed in the browser's system, read through the Local Font Access API. */
|
|
6
6
|
var LocalFonts = class {
|
|
@@ -55,7 +55,7 @@ var LocalFonts = class {
|
|
|
55
55
|
try {
|
|
56
56
|
const fonts = await window.queryLocalFonts?.();
|
|
57
57
|
if (!fonts) return null;
|
|
58
|
-
const match =
|
|
58
|
+
const match = findLocalFont(fonts, family, style);
|
|
59
59
|
if (!match) return null;
|
|
60
60
|
return await (await match.blob()).arrayBuffer();
|
|
61
61
|
} catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","names":[],"sources":["../../../src/text/font/local.ts"],"sourcesContent":["import { IS_BROWSER } from '#core/constants'\nimport { SharedReads } from '#core/text/font/reads'\nimport type { FontInfo, LocalFontAccessState } from '#core/text/font/sources'\nimport {
|
|
1
|
+
{"version":3,"file":"local.js","names":[],"sources":["../../../src/text/font/local.ts"],"sourcesContent":["import { IS_BROWSER } from '#core/constants'\nimport { SharedReads } from '#core/text/font/reads'\nimport type { FontInfo, LocalFontAccessState } from '#core/text/font/sources'\nimport { findLocalFont } from '#core/text/font/style'\n\n/** The fonts installed in the browser's system, read through the Local Font Access API. */\nexport class LocalFonts {\n private fonts: FontInfo[] | null = null\n private state: LocalFontAccessState = IS_BROWSER ? 'prompt' : 'unsupported'\n private readonly requests = new SharedReads()\n\n accessState(): LocalFontAccessState {\n return this.state\n }\n\n /** The installed fonts, once access was asked for; `null` before. */\n list(): FontInfo[] | null {\n return this.fonts\n }\n\n /** Asks for access and lists the installed fonts, one entry per family and style. */\n async requestAccess(): Promise<FontInfo[]> {\n if (!IS_BROWSER || !window.queryLocalFonts) {\n this.state = 'unsupported'\n this.fonts = []\n return []\n }\n try {\n const fonts = await window.queryLocalFonts()\n const seen = new Set<string>()\n const result: FontInfo[] = []\n for (const f of fonts) {\n const key = `${f.family}|${f.style}`\n if (seen.has(key)) continue\n seen.add(key)\n result.push({\n family: f.family,\n fullName: f.fullName,\n style: f.style,\n postscriptName: f.postscriptName\n })\n }\n this.fonts = result\n this.state = 'granted'\n return result\n } catch {\n this.fonts = []\n this.state = 'denied'\n return []\n }\n }\n\n /** A face's bytes, once access is granted. */\n read(family: string, style?: string): Promise<ArrayBuffer | null> {\n if (!IS_BROWSER || !window.queryLocalFonts) return Promise.resolve(null)\n if (this.state !== 'granted') return Promise.resolve(null)\n // A query answers with a new blob, and so new bytes, every time; the face decides the match.\n return this.requests.read(`${family}|${style ?? ''}`, () => this.query(family, style))\n }\n\n private async query(family: string, style?: string): Promise<ArrayBuffer | null> {\n try {\n const fonts = await window.queryLocalFonts?.()\n if (!fonts) return null\n const match = findLocalFont(fonts, family, style)\n if (!match) return null\n const blob: Blob = await match.blob()\n return await blob.arrayBuffer()\n } catch (e) {\n console.warn(`Local font access failed for \"${family}\" ${style ?? ''}:`, e)\n return null\n }\n }\n}\n"],"mappings":";;;;;AAMA,IAAa,aAAb,MAAwB;CACtB,QAAmC;CACnC,QAAsC,aAAa,WAAW;CAC9D,WAA4B,IAAI,YAAY;CAE5C,cAAoC;EAClC,OAAO,KAAK;CACd;;CAGA,OAA0B;EACxB,OAAO,KAAK;CACd;;CAGA,MAAM,gBAAqC;EACzC,IAAI,CAAC,cAAc,CAAC,OAAO,iBAAiB;GAC1C,KAAK,QAAQ;GACb,KAAK,QAAQ,CAAC;GACd,OAAO,CAAC;EACV;EACA,IAAI;GACF,MAAM,QAAQ,MAAM,OAAO,gBAAgB;GAC3C,MAAM,uBAAO,IAAI,IAAY;GAC7B,MAAM,SAAqB,CAAC;GAC5B,KAAK,MAAM,KAAK,OAAO;IACrB,MAAM,MAAM,GAAG,EAAE,OAAO,GAAG,EAAE;IAC7B,IAAI,KAAK,IAAI,GAAG,GAAG;IACnB,KAAK,IAAI,GAAG;IACZ,OAAO,KAAK;KACV,QAAQ,EAAE;KACV,UAAU,EAAE;KACZ,OAAO,EAAE;KACT,gBAAgB,EAAE;IACpB,CAAC;GACH;GACA,KAAK,QAAQ;GACb,KAAK,QAAQ;GACb,OAAO;EACT,QAAQ;GACN,KAAK,QAAQ,CAAC;GACd,KAAK,QAAQ;GACb,OAAO,CAAC;EACV;CACF;;CAGA,KAAK,QAAgB,OAA6C;EAChE,IAAI,CAAC,cAAc,CAAC,OAAO,iBAAiB,OAAO,QAAQ,QAAQ,IAAI;EACvE,IAAI,KAAK,UAAU,WAAW,OAAO,QAAQ,QAAQ,IAAI;EAEzD,OAAO,KAAK,SAAS,KAAK,GAAG,OAAO,GAAG,SAAS,YAAY,KAAK,MAAM,QAAQ,KAAK,CAAC;CACvF;CAEA,MAAc,MAAM,QAAgB,OAA6C;EAC/E,IAAI;GACF,MAAM,QAAQ,MAAM,OAAO,kBAAkB;GAC7C,IAAI,CAAC,OAAO,OAAO;GACnB,MAAM,QAAQ,cAAc,OAAO,QAAQ,KAAK;GAChD,IAAI,CAAC,OAAO,OAAO;GAEnB,OAAO,OAAM,MADY,MAAM,KAAK,EAAA,CAClB,YAAY;EAChC,SAAS,GAAG;GACV,QAAQ,KAAK,iCAAiC,OAAO,IAAI,SAAS,GAAG,IAAI,CAAC;GAC1E,OAAO;EACT;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FontFallbackScript } from "../fallbacks.js";
|
|
1
|
+
import { FontFallbackScript, LetterFallbackScript } from "../fallbacks.js";
|
|
2
2
|
import { FamilyFace } from "./faces.js";
|
|
3
3
|
import { FontAxis, NamedInstance } from "./variation.js";
|
|
4
4
|
import { BundledFontLocator } from "./bundled.js";
|
|
@@ -10,6 +10,8 @@ import { FontVariation, SceneGraph } from "@pairdraw/scene-graph";
|
|
|
10
10
|
//#region src/text/font/manager.d.ts
|
|
11
11
|
declare class FontManager {
|
|
12
12
|
private loadedFamilies;
|
|
13
|
+
/** The families `loadedFamilies` has a face of, so asking needs no scan of its keys. */
|
|
14
|
+
private loadedFamilyNames;
|
|
13
15
|
private loadedFamilySources;
|
|
14
16
|
private unavailableFaces;
|
|
15
17
|
private supplementalFamilyData;
|
|
@@ -36,19 +38,32 @@ declare class FontManager {
|
|
|
36
38
|
private providerCanvasKits;
|
|
37
39
|
private registrationGeneration;
|
|
38
40
|
private providerRegistrations;
|
|
41
|
+
private readonly sharedProviders;
|
|
39
42
|
private downloadedFontCache;
|
|
40
43
|
private fallbackUserAgent;
|
|
41
44
|
private hostFontLoader;
|
|
42
45
|
private readonly hostFontRequests;
|
|
43
46
|
private webFonts;
|
|
44
47
|
private readonly faceListeners;
|
|
48
|
+
private readonly unblockListeners;
|
|
45
49
|
private readonly bundled;
|
|
46
50
|
private readonly localFonts;
|
|
47
51
|
private readonly faces;
|
|
48
52
|
private cjkFallbackFamilies;
|
|
49
53
|
private cjkFallbackPromise;
|
|
50
|
-
|
|
51
|
-
private
|
|
54
|
+
/** The fallbacks of each script written in letters: Arabic, Hebrew, Thai, Devanagari. */
|
|
55
|
+
private readonly letterFallbackFamilies;
|
|
56
|
+
private readonly letterFallbackPromises;
|
|
57
|
+
/**
|
|
58
|
+
* The provider every renderer and shaper of `canvasKit` draws from. They share one module's
|
|
59
|
+
* heap, and a provider holds its own copy of each font file, so a second provider would copy
|
|
60
|
+
* every face again: the scene and overlay canvases, and every CJK system font, alike. A provider
|
|
61
|
+
* already attached for `canvasKit` is shared too, so shaping draws the faces its caller
|
|
62
|
+
* registered, not a second copy. Each call is matched by {@link releaseProvider}; the last
|
|
63
|
+
* release deletes the provider.
|
|
64
|
+
*/
|
|
65
|
+
acquireProvider(canvasKit: CanvasKit): TypefaceFontProvider;
|
|
66
|
+
releaseProvider(provider: TypefaceFontProvider): void;
|
|
52
67
|
attachProvider(canvasKit: CanvasKit, provider: TypefaceFontProvider): void;
|
|
53
68
|
detachProvider(provider: TypefaceFontProvider): void;
|
|
54
69
|
provider(): TypefaceFontProvider | null;
|
|
@@ -57,6 +72,11 @@ declare class FontManager {
|
|
|
57
72
|
generation(): number;
|
|
58
73
|
blockNodesUntilFontsResolve(nodeIds: readonly string[]): void;
|
|
59
74
|
unblockNodes(nodeIds: readonly string[]): void;
|
|
75
|
+
/**
|
|
76
|
+
* Calls the listener with the layers whose block ended, which the canvas left out while blocked
|
|
77
|
+
* and draws again now.
|
|
78
|
+
*/
|
|
79
|
+
onNodesUnblocked(listener: (nodeIds: readonly string[]) => void): () => void;
|
|
60
80
|
isNodeBlocked(nodeId: string): boolean;
|
|
61
81
|
localAccessState(): LocalFontAccessState;
|
|
62
82
|
setDownloadedFontCache(cache: DownloadedFontCache | null): void;
|
|
@@ -76,6 +96,8 @@ declare class FontManager {
|
|
|
76
96
|
loadedFamilyFaces(family: string): FamilyFace[] | null | undefined;
|
|
77
97
|
/** Whether a family has this face, or nothing found so far says it has not. */
|
|
78
98
|
offersFace(family: string, weight: number, italic: boolean): boolean;
|
|
99
|
+
/** The families whose faces `familyFaces` has found so far. */
|
|
100
|
+
familiesWithFoundFaces(): string[];
|
|
79
101
|
/** Calls the listener whenever the faces found so far are forgotten. */
|
|
80
102
|
onFamilyFacesReset(listener: () => void): () => void;
|
|
81
103
|
/** The faces known for a family without asking a provider; see {@link FamilyFaceCatalog}. */
|
|
@@ -168,12 +190,34 @@ declare class FontManager {
|
|
|
168
190
|
ensureCJKFallback(): Promise<string[]>;
|
|
169
191
|
getCJKFallbackFamilies(): string[];
|
|
170
192
|
setCJKFallbackFamily(family: string): void;
|
|
171
|
-
|
|
193
|
+
private ensureLetterFallback;
|
|
194
|
+
private letterFamilies;
|
|
195
|
+
/** The list a script's fallback families are kept in. */
|
|
196
|
+
private fallbackTarget;
|
|
172
197
|
ensureFallbackPack(scripts?: FontFallbackScript[], characters?: string, signal?: AbortSignal): Promise<Partial<Record<FontFallbackScript, string[]>>>;
|
|
173
198
|
private loadFallbackPack;
|
|
174
|
-
|
|
175
|
-
|
|
199
|
+
/**
|
|
200
|
+
* The fallbacks for scripts written in letters, Arabic first, in the order the renderer tries
|
|
201
|
+
* them: each covers its own script, and all come before the CJK fallbacks.
|
|
202
|
+
*/
|
|
203
|
+
getLetterFallbackFamilies(): string[];
|
|
204
|
+
setLetterFallbackFamily(script: LetterFallbackScript, family: string): void;
|
|
205
|
+
/**
|
|
206
|
+
* Loads the fallback faces for `script`. The first installed one of its families comes in, and
|
|
207
|
+
* the next only for the characters of its writing system among `characters` that CanvasKit finds
|
|
208
|
+
* no glyph for in the fallbacks loaded: each is a whole system face, tens of megabytes for a CJK
|
|
209
|
+
* one, copied into CanvasKit. Web fonts come in, cut to the characters, when no installed face
|
|
210
|
+
* covers them.
|
|
211
|
+
*/
|
|
176
212
|
private ensureFallbackFamilies;
|
|
213
|
+
/** Loads `manifest`'s web families, cut to `characters`, into `targetFamilies`. */
|
|
214
|
+
private loadRemoteFallbackFamilies;
|
|
215
|
+
/**
|
|
216
|
+
* The characters CanvasKit finds no glyph for in `families`, shaped with the provider the
|
|
217
|
+
* canvas draws from. Without one, as in an export before any canvas or shaper holds it, it
|
|
218
|
+
* cannot tell and counts every character missing, so every family loads as it always did.
|
|
219
|
+
*/
|
|
220
|
+
private unresolvedCharacters;
|
|
177
221
|
private loadHostFont;
|
|
178
222
|
private readHostFont;
|
|
179
223
|
private readDownloadedFont;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","names":[],"sources":["../../../src/text/font/manager.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","names":[],"sources":["../../../src/text/font/manager.ts"],"mappings":";;;;;;;;;;cAsDa;UACH;;UAEA;UACA;UACA;UACA;;UAEA;;;;;;UAMA;;;;;;UAMA;UACA;UACA;UACA;UAIA;UACA;UACA;UACA;UACA;UACA;mBACS;UAIT;UACA;UACA;mBACS;UACT;mBACS;mBACA;mBACA;mBACA;mBACA;UAKT;UACA;;mBAES;mBAGA;;;;;;;;;EAUjB,gBAAgB,WAAW,YAAY;EAiBvC,gBAAgB,UAAU;EAY1B,eAAe,WAAW,WAAW,UAAU;EAgB/C,eAAe,UAAU;EASzB,YAAY;;EAKZ,YAAY,WAAW,YAAY;EAQnC;EAIA,4BAA4B;EAI5B,aAAa;;;;;EAUb,iBAAiB,WAAW;EAK5B,cAAc;EAId,oBAAoB;EAIpB,uBAAuB,OAAO;EAI9B,qBAAqB;EAIrB,kBAAkB,QAAQ;;EAM1B,sBAAsB,QAAQ;EAI9B,uBAAuB,UAAU,QAAQ,OAAO;;EAMhD,mBAAmB,gBAAgB;;;;;EAQnC,YAAY,iBAAiB,QAAQ;;EAKrC,kBAAkB,iBAAiB;;EAKnC,WAAW,gBAAgB,gBAAgB;;EAK3C;;EAKA,mBAAmB;;EAKnB,gBAAgB,iBAAiB;EAIjC,gBAAgB,SAAS;EAIzB,qBAAqB,iBAAiB;EAItC,8BAA8B;E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|
import { DEFAULT_FONT_FAMILY, IS_BROWSER } from "../../constants.js";
|
|
2
|
-
import { fontFallbackEntry } from "../fallbacks.js";
|
|
2
|
+
import { LETTER_FALLBACK_SCRIPTS, fallbackDrawsCharacter, fontFallbackEntry } from "../fallbacks.js";
|
|
3
3
|
import { BundledFonts } from "./bundled.js";
|
|
4
4
|
import { fontFaceRenderFamily } from "./faces.js";
|
|
5
5
|
import { FamilyFaceCatalog } from "./catalog.js";
|
|
6
|
+
import { resetFontCollection } from "./collection.js";
|
|
6
7
|
import { fontAxes, hasNamedInstance, namedInstanceVariations, namedInstances } from "./variation.js";
|
|
7
8
|
import { loadHarfBuzz } from "./harfbuzz.js";
|
|
8
9
|
import { SharedReads, sameFontFile, withHarfBuzz } from "./reads.js";
|
|
@@ -11,9 +12,12 @@ import { UnsupportedFontFormatError } from "./sources.js";
|
|
|
11
12
|
import { collectGraphFontKeys } from "../requirements/collect.js";
|
|
12
13
|
import { WebFontResolver, normalizedCoverageText } from "../web-font/resolver.js";
|
|
13
14
|
import { faceLoadKey, namesWeight, normalizeFontFamily, parseFontStyle, styleToWeight } from "@pairdraw/scene-graph/font-style";
|
|
15
|
+
import { uniq } from "es-toolkit";
|
|
14
16
|
//#region src/text/font/manager.ts
|
|
15
17
|
var FontManager = class {
|
|
16
18
|
loadedFamilies = /* @__PURE__ */ new Map();
|
|
19
|
+
/** The families `loadedFamilies` has a face of, so asking needs no scan of its keys. */
|
|
20
|
+
loadedFamilyNames = /* @__PURE__ */ new Set();
|
|
17
21
|
loadedFamilySources = /* @__PURE__ */ new Map();
|
|
18
22
|
unavailableFaces = /* @__PURE__ */ new Map();
|
|
19
23
|
supplementalFamilyData = /* @__PURE__ */ new Map();
|
|
@@ -40,12 +44,14 @@ var FontManager = class {
|
|
|
40
44
|
providerCanvasKits = /* @__PURE__ */ new WeakMap();
|
|
41
45
|
registrationGeneration = 0;
|
|
42
46
|
providerRegistrations = /* @__PURE__ */ new WeakMap();
|
|
47
|
+
sharedProviders = /* @__PURE__ */ new Map();
|
|
43
48
|
downloadedFontCache = null;
|
|
44
49
|
fallbackUserAgent;
|
|
45
50
|
hostFontLoader = null;
|
|
46
51
|
hostFontRequests = new SharedReads();
|
|
47
52
|
webFonts = new WebFontResolver();
|
|
48
53
|
faceListeners = /* @__PURE__ */ new Set();
|
|
54
|
+
unblockListeners = /* @__PURE__ */ new Set();
|
|
49
55
|
bundled = new BundledFonts();
|
|
50
56
|
localFonts = new LocalFonts();
|
|
51
57
|
faces = new FamilyFaceCatalog({
|
|
@@ -55,8 +61,50 @@ var FontManager = class {
|
|
|
55
61
|
});
|
|
56
62
|
cjkFallbackFamilies = [];
|
|
57
63
|
cjkFallbackPromise = null;
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
/** The fallbacks of each script written in letters: Arabic, Hebrew, Thai, Devanagari. */
|
|
65
|
+
letterFallbackFamilies = new Map(LETTER_FALLBACK_SCRIPTS.map((script) => [script, []]));
|
|
66
|
+
letterFallbackPromises = /* @__PURE__ */ new Map();
|
|
67
|
+
/**
|
|
68
|
+
* The provider every renderer and shaper of `canvasKit` draws from. They share one module's
|
|
69
|
+
* heap, and a provider holds its own copy of each font file, so a second provider would copy
|
|
70
|
+
* every face again: the scene and overlay canvases, and every CJK system font, alike. A provider
|
|
71
|
+
* already attached for `canvasKit` is shared too, so shaping draws the faces its caller
|
|
72
|
+
* registered, not a second copy. Each call is matched by {@link releaseProvider}; the last
|
|
73
|
+
* release deletes the provider.
|
|
74
|
+
*/
|
|
75
|
+
acquireProvider(canvasKit) {
|
|
76
|
+
const shared = this.sharedProviders.get(canvasKit);
|
|
77
|
+
if (shared) {
|
|
78
|
+
shared.users++;
|
|
79
|
+
return shared.provider;
|
|
80
|
+
}
|
|
81
|
+
const attached = this.providerFor(canvasKit);
|
|
82
|
+
if (attached) {
|
|
83
|
+
this.sharedProviders.set(canvasKit, {
|
|
84
|
+
provider: attached,
|
|
85
|
+
users: 1
|
|
86
|
+
});
|
|
87
|
+
return attached;
|
|
88
|
+
}
|
|
89
|
+
const provider = canvasKit.TypefaceFontProvider.Make();
|
|
90
|
+
this.sharedProviders.set(canvasKit, {
|
|
91
|
+
provider,
|
|
92
|
+
users: 1
|
|
93
|
+
});
|
|
94
|
+
this.attachProvider(canvasKit, provider);
|
|
95
|
+
return provider;
|
|
96
|
+
}
|
|
97
|
+
releaseProvider(provider) {
|
|
98
|
+
for (const [canvasKit, shared] of this.sharedProviders) {
|
|
99
|
+
if (shared.provider !== provider) continue;
|
|
100
|
+
if (--shared.users > 0) return;
|
|
101
|
+
this.sharedProviders.delete(canvasKit);
|
|
102
|
+
this.detachProvider(provider);
|
|
103
|
+
resetFontCollection(provider);
|
|
104
|
+
provider.delete();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
60
108
|
attachProvider(canvasKit, provider) {
|
|
61
109
|
this.fontProviders.add(provider);
|
|
62
110
|
this.providerCanvasKits.set(provider, canvasKit);
|
|
@@ -73,6 +121,7 @@ var FontManager = class {
|
|
|
73
121
|
detachProvider(provider) {
|
|
74
122
|
this.fontProviders.delete(provider);
|
|
75
123
|
this.providerRegistrations.delete(provider);
|
|
124
|
+
resetFontCollection(provider);
|
|
76
125
|
if (this.fontProvider === provider) this.fontProvider = Array.from(this.fontProviders).at(-1) ?? null;
|
|
77
126
|
}
|
|
78
127
|
provider() {
|
|
@@ -89,7 +138,17 @@ var FontManager = class {
|
|
|
89
138
|
for (const nodeId of nodeIds) this.blockedNodeIds.add(nodeId);
|
|
90
139
|
}
|
|
91
140
|
unblockNodes(nodeIds) {
|
|
92
|
-
|
|
141
|
+
const shown = [];
|
|
142
|
+
for (const nodeId of nodeIds) if (this.blockedNodeIds.delete(nodeId)) shown.push(nodeId);
|
|
143
|
+
if (shown.length > 0) for (const listener of this.unblockListeners) listener(shown);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Calls the listener with the layers whose block ended, which the canvas left out while blocked
|
|
147
|
+
* and draws again now.
|
|
148
|
+
*/
|
|
149
|
+
onNodesUnblocked(listener) {
|
|
150
|
+
this.unblockListeners.add(listener);
|
|
151
|
+
return () => this.unblockListeners.delete(listener);
|
|
93
152
|
}
|
|
94
153
|
isNodeBlocked(nodeId) {
|
|
95
154
|
return this.blockedNodeIds.has(nodeId);
|
|
@@ -134,6 +193,10 @@ var FontManager = class {
|
|
|
134
193
|
offersFace(family, weight, italic) {
|
|
135
194
|
return this.faces.offersFace(family, weight, italic);
|
|
136
195
|
}
|
|
196
|
+
/** The families whose faces `familyFaces` has found so far. */
|
|
197
|
+
familiesWithFoundFaces() {
|
|
198
|
+
return this.faces.foundFamilies();
|
|
199
|
+
}
|
|
137
200
|
/** Calls the listener whenever the faces found so far are forgotten. */
|
|
138
201
|
onFamilyFacesReset(listener) {
|
|
139
202
|
return this.faces.onReset(listener);
|
|
@@ -206,8 +269,8 @@ var FontManager = class {
|
|
|
206
269
|
family,
|
|
207
270
|
source: provider
|
|
208
271
|
});
|
|
209
|
-
for (const
|
|
210
|
-
family
|
|
272
|
+
for (const family of [...fonts.map((font) => font.family), ...this.faces.hostFamilies()]) byFamily.set(family, {
|
|
273
|
+
family,
|
|
211
274
|
source: "local"
|
|
212
275
|
});
|
|
213
276
|
for (const option of this.registeredFamilyOptions()) byFamily.set(option.family, option);
|
|
@@ -337,7 +400,7 @@ var FontManager = class {
|
|
|
337
400
|
return this.unavailableFaces.get(`${family}|${style}`) ?? null;
|
|
338
401
|
}
|
|
339
402
|
isLoaded(family) {
|
|
340
|
-
return
|
|
403
|
+
return this.loadedFamilyNames.has(family);
|
|
341
404
|
}
|
|
342
405
|
isStyleLoaded(family, style) {
|
|
343
406
|
return this.loadedFamilies.has(`${family}|${style}`);
|
|
@@ -457,11 +520,27 @@ var FontManager = class {
|
|
|
457
520
|
setCJKFallbackFamily(family) {
|
|
458
521
|
if (!this.cjkFallbackFamilies.includes(family)) this.cjkFallbackFamilies.push(family);
|
|
459
522
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
if (
|
|
463
|
-
|
|
464
|
-
|
|
523
|
+
ensureLetterFallback(script) {
|
|
524
|
+
const families = this.letterFamilies(script);
|
|
525
|
+
if (families.length > 0) return Promise.resolve(families);
|
|
526
|
+
let pending = this.letterFallbackPromises.get(script);
|
|
527
|
+
if (!pending) {
|
|
528
|
+
pending = this.ensureFallbackFamilies(script, families);
|
|
529
|
+
this.letterFallbackPromises.set(script, pending);
|
|
530
|
+
}
|
|
531
|
+
return pending;
|
|
532
|
+
}
|
|
533
|
+
letterFamilies(script) {
|
|
534
|
+
let families = this.letterFallbackFamilies.get(script);
|
|
535
|
+
if (!families) {
|
|
536
|
+
families = [];
|
|
537
|
+
this.letterFallbackFamilies.set(script, families);
|
|
538
|
+
}
|
|
539
|
+
return families;
|
|
540
|
+
}
|
|
541
|
+
/** The list a script's fallback families are kept in. */
|
|
542
|
+
fallbackTarget(script) {
|
|
543
|
+
return isLetterFallbackScript(script) ? this.letterFamilies(script) : this.cjkFallbackFamilies;
|
|
465
544
|
}
|
|
466
545
|
ensureFallbackPack(scripts = ["cjk", "arabic"], characters = "", signal) {
|
|
467
546
|
return withHarfBuzz(this.loadFallbackPack(scripts, characters, signal));
|
|
@@ -471,41 +550,94 @@ var FontManager = class {
|
|
|
471
550
|
const result = {};
|
|
472
551
|
await Promise.all(scripts.map(async (script) => {
|
|
473
552
|
signal?.throwIfAborted();
|
|
474
|
-
const target =
|
|
553
|
+
const target = this.fallbackTarget(script);
|
|
475
554
|
if (signal) result[script] = await this.ensureFallbackFamilies(script, target, characters, signal);
|
|
476
|
-
else if (script
|
|
555
|
+
else if (isLetterFallbackScript(script) && !characters) result[script] = await this.ensureLetterFallback(script);
|
|
477
556
|
else if (script === "cjk" && !characters) result[script] = await this.ensureCJKFallback();
|
|
478
557
|
else result[script] = await this.ensureFallbackFamilies(script, target, characters);
|
|
479
558
|
}));
|
|
480
559
|
signal?.throwIfAborted();
|
|
481
560
|
return result;
|
|
482
561
|
}
|
|
483
|
-
|
|
484
|
-
|
|
562
|
+
/**
|
|
563
|
+
* The fallbacks for scripts written in letters, Arabic first, in the order the renderer tries
|
|
564
|
+
* them: each covers its own script, and all come before the CJK fallbacks.
|
|
565
|
+
*/
|
|
566
|
+
getLetterFallbackFamilies() {
|
|
567
|
+
return uniq(LETTER_FALLBACK_SCRIPTS.flatMap((script) => this.letterFamilies(script)));
|
|
485
568
|
}
|
|
486
|
-
|
|
487
|
-
|
|
569
|
+
setLetterFallbackFamily(script, family) {
|
|
570
|
+
const families = this.letterFamilies(script);
|
|
571
|
+
if (!families.includes(family)) families.push(family);
|
|
488
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* Loads the fallback faces for `script`. The first installed one of its families comes in, and
|
|
575
|
+
* the next only for the characters of its writing system among `characters` that CanvasKit finds
|
|
576
|
+
* no glyph for in the fallbacks loaded: each is a whole system face, tens of megabytes for a CJK
|
|
577
|
+
* one, copied into CanvasKit. Web fonts come in, cut to the characters, when no installed face
|
|
578
|
+
* covers them.
|
|
579
|
+
*/
|
|
489
580
|
async ensureFallbackFamilies(script, targetFamilies, characters = "", signal) {
|
|
490
581
|
signal?.throwIfAborted();
|
|
491
582
|
const manifest = fontFallbackEntry(script, this.fallbackUserAgent);
|
|
583
|
+
let pending = uniq(Array.from(characters)).filter((character) => fallbackDrawsCharacter(script, character));
|
|
584
|
+
const missing = () => pending = this.unresolvedCharacters(targetFamilies, pending);
|
|
585
|
+
const loadAll = characters === "";
|
|
586
|
+
let installed = false;
|
|
492
587
|
for (const family of manifest.localFamilies) {
|
|
588
|
+
if (!loadAll && installed && missing().length === 0) break;
|
|
493
589
|
signal?.throwIfAborted();
|
|
494
590
|
const buffer = await this.loadHostFont(family, "Regular") ?? await this.localFonts.read(family);
|
|
495
591
|
signal?.throwIfAborted();
|
|
496
|
-
if (buffer && this.registerAndCache(family, "Regular", buffer, "fallback")
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
signal?.throwIfAborted();
|
|
501
|
-
const data = await this.loadRemoteFont(family, "Regular", characters, signal);
|
|
502
|
-
signal?.throwIfAborted();
|
|
503
|
-
return data ? family : null;
|
|
504
|
-
}));
|
|
505
|
-
for (const result of results) if (result.status === "fulfilled" && result.value && !targetFamilies.includes(result.value)) targetFamilies.push(result.value);
|
|
592
|
+
if (buffer && this.registerAndCache(family, "Regular", buffer, "fallback")) {
|
|
593
|
+
if (!targetFamilies.includes(family)) targetFamilies.push(family);
|
|
594
|
+
installed = true;
|
|
595
|
+
}
|
|
506
596
|
}
|
|
597
|
+
const remoteCharacters = loadAll || !installed ? characters : missing().join("");
|
|
598
|
+
if (loadAll ? targetFamilies.length === 0 : !installed || remoteCharacters) await this.loadRemoteFallbackFamilies(manifest, targetFamilies, remoteCharacters, signal);
|
|
507
599
|
return targetFamilies;
|
|
508
600
|
}
|
|
601
|
+
/** Loads `manifest`'s web families, cut to `characters`, into `targetFamilies`. */
|
|
602
|
+
async loadRemoteFallbackFamilies(manifest, targetFamilies, characters, signal) {
|
|
603
|
+
const results = await Promise.allSettled(manifest.remoteFamilies.map(async (family) => {
|
|
604
|
+
signal?.throwIfAborted();
|
|
605
|
+
const data = await this.loadRemoteFont(family, "Regular", characters, signal);
|
|
606
|
+
signal?.throwIfAborted();
|
|
607
|
+
return data ? family : null;
|
|
608
|
+
}));
|
|
609
|
+
for (const result of results) if (result.status === "fulfilled" && result.value && !targetFamilies.includes(result.value)) targetFamilies.push(result.value);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* The characters CanvasKit finds no glyph for in `families`, shaped with the provider the
|
|
613
|
+
* canvas draws from. Without one, as in an export before any canvas or shaper holds it, it
|
|
614
|
+
* cannot tell and counts every character missing, so every family loads as it always did.
|
|
615
|
+
*/
|
|
616
|
+
unresolvedCharacters(families, characters) {
|
|
617
|
+
if (characters.length === 0) return [];
|
|
618
|
+
if (families.length === 0) return characters;
|
|
619
|
+
const shared = this.sharedProviders.entries().next().value;
|
|
620
|
+
if (!shared) return characters;
|
|
621
|
+
const [canvasKit, { provider }] = shared;
|
|
622
|
+
const style = new canvasKit.ParagraphStyle({ textStyle: {
|
|
623
|
+
fontFamilies: [...families],
|
|
624
|
+
fontSize: 16
|
|
625
|
+
} });
|
|
626
|
+
const builder = canvasKit.ParagraphBuilder.MakeFromFontProvider(style, provider);
|
|
627
|
+
try {
|
|
628
|
+
builder.addText(characters.join(""));
|
|
629
|
+
const paragraph = builder.build();
|
|
630
|
+
try {
|
|
631
|
+
paragraph.layout(Number.MAX_SAFE_INTEGER);
|
|
632
|
+
const unresolved = new Set(paragraph.unresolvedCodepoints());
|
|
633
|
+
return characters.filter((character) => unresolved.has(character.codePointAt(0) ?? 0));
|
|
634
|
+
} finally {
|
|
635
|
+
paragraph.delete();
|
|
636
|
+
}
|
|
637
|
+
} finally {
|
|
638
|
+
builder.delete();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
509
641
|
loadHostFont(family, style) {
|
|
510
642
|
const loader = this.hostFontLoader;
|
|
511
643
|
if (!loader) return Promise.resolve(null);
|
|
@@ -546,7 +678,7 @@ var FontManager = class {
|
|
|
546
678
|
}
|
|
547
679
|
}
|
|
548
680
|
/** Adds `buffer` to the files of `style` after its own, returning the copy of it they keep. */
|
|
549
|
-
registerSupplemental(family, style, buffer) {
|
|
681
|
+
registerSupplemental(family, style, buffer, source) {
|
|
550
682
|
const key = `${family}|${style}`;
|
|
551
683
|
const supplemental = this.supplementalFamilyData.get(key) ?? [];
|
|
552
684
|
const kept = supplemental.find((file) => sameFontFile(file, buffer));
|
|
@@ -554,7 +686,7 @@ var FontManager = class {
|
|
|
554
686
|
supplemental.push(buffer);
|
|
555
687
|
this.supplementalFamilyData.set(key, supplemental);
|
|
556
688
|
this.registerFontInCanvasKit(family, buffer);
|
|
557
|
-
this.registerFontInBrowser(family, style, buffer);
|
|
689
|
+
if (!pageDrawsByName(source)) this.registerFontInBrowser(family, style, buffer);
|
|
558
690
|
return buffer;
|
|
559
691
|
}
|
|
560
692
|
registerAndCache(family, style, buffer, source) {
|
|
@@ -567,14 +699,15 @@ var FontManager = class {
|
|
|
567
699
|
}
|
|
568
700
|
if (existing) {
|
|
569
701
|
const replaced = this.replacedFileData.get(key) ?? /* @__PURE__ */ new Set();
|
|
570
|
-
replaced.add(this.registerSupplemental(family, style, existing));
|
|
702
|
+
replaced.add(this.registerSupplemental(family, style, existing, this.loadedFamilySources.get(key)));
|
|
571
703
|
this.replacedFileData.set(key, replaced);
|
|
572
704
|
this.replacedFamilies.add(family);
|
|
573
705
|
}
|
|
574
706
|
this.loadedFamilies.set(key, buffer);
|
|
707
|
+
this.loadedFamilyNames.add(family);
|
|
575
708
|
if (source) this.loadedFamilySources.set(key, source);
|
|
576
709
|
this.registerFontInCanvasKit(family, buffer);
|
|
577
|
-
this.registerFontInBrowser(family, style, buffer);
|
|
710
|
+
if (!pageDrawsByName(source)) this.registerFontInBrowser(family, style, buffer);
|
|
578
711
|
for (const listener of this.faceListeners) listener(family, style);
|
|
579
712
|
return buffer;
|
|
580
713
|
}
|
|
@@ -598,6 +731,7 @@ var FontManager = class {
|
|
|
598
731
|
if (registeredData?.has(data)) return true;
|
|
599
732
|
try {
|
|
600
733
|
provider.registerFont(data, family);
|
|
734
|
+
resetFontCollection(provider);
|
|
601
735
|
const familyRegistrations = registeredData ?? /* @__PURE__ */ new Set();
|
|
602
736
|
familyRegistrations.add(data);
|
|
603
737
|
registrations.set(family, familyRegistrations);
|
|
@@ -622,7 +756,19 @@ var FontManager = class {
|
|
|
622
756
|
});
|
|
623
757
|
}
|
|
624
758
|
};
|
|
759
|
+
/**
|
|
760
|
+
* Whether the page draws a face from `source` by itself: it draws installed fonts by name and
|
|
761
|
+
* falls back to the system's. A browser face would copy a whole system file, and one under an
|
|
762
|
+
* installed family's name stands in for all of that family's faces: WebView2 draws their bold
|
|
763
|
+
* and italic text in it.
|
|
764
|
+
*/
|
|
765
|
+
function pageDrawsByName(source) {
|
|
766
|
+
return source === "local" || source === "fallback";
|
|
767
|
+
}
|
|
625
768
|
const fontManager = new FontManager();
|
|
769
|
+
function isLetterFallbackScript(script) {
|
|
770
|
+
return LETTER_FALLBACK_SCRIPTS.some((letter) => letter === script);
|
|
771
|
+
}
|
|
626
772
|
//#endregion
|
|
627
773
|
export { FontManager, fontManager };
|
|
628
774
|
|