@motionscript/core 0.1.0-alpha.6 → 0.1.0-alpha.7
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/CHANGELOG.md +28 -0
- package/README.md +2 -4
- package/dist/assets/errors.js +4 -5
- package/dist/assets/errors.js.map +1 -1
- package/dist/assets/scope.d.ts +1 -1
- package/dist/assets/scope.d.ts.map +1 -1
- package/dist/assets/scope.js +1 -1
- package/dist/assets/scope.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +3 -18
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/index.d.ts +3 -5
- package/dist/attributes/index.d.ts.map +1 -1
- package/dist/attributes/index.js +2 -2
- package/dist/attributes/index.js.map +1 -1
- package/dist/attributes/layout/insets.d.ts +1 -1
- package/dist/attributes/layout/insets.js.map +1 -1
- package/dist/attributes/layout/size.d.ts +1 -1
- package/dist/attributes/layout/size.js +1 -1
- package/dist/attributes/layout/size.js.map +1 -1
- package/dist/attributes/properties/decorator.d.ts +44 -11
- package/dist/attributes/properties/decorator.d.ts.map +1 -1
- package/dist/attributes/properties/decorator.js +37 -9
- package/dist/attributes/properties/decorator.js.map +1 -1
- package/dist/attributes/properties/inputs.d.ts +1 -1
- package/dist/attributes/properties/inputs.js +1 -1
- package/dist/attributes/properties/inputs.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +19 -140
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +12 -108
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.d.ts +1 -1
- package/dist/attributes/shape/corners/corner-radius.js +1 -1
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/fill/color/parser.d.ts +1 -1
- package/dist/attributes/shape/fill/color/parser.js +1 -1
- package/dist/attributes/shape/fill/color/parser.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/canvas3d.d.ts +2 -2
- package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.d.ts +2 -2
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/video.d.ts +1 -1
- package/dist/attributes/shape/fill/implementations/video.js +1 -1
- package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
- package/dist/attributes/shape/fill/lerp.d.ts +1 -1
- package/dist/attributes/shape/fill/lerp.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +1 -1
- package/dist/attributes/shape/filters/chain.js +1 -1
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +4 -3
- package/dist/attributes/shape/filters/union.d.ts.map +1 -1
- package/dist/attributes/shape/filters/union.js.map +1 -1
- package/dist/attributes/shape/path/ops.d.ts +1 -2
- package/dist/attributes/shape/path/ops.d.ts.map +1 -1
- package/dist/attributes/shape/path/ops.js.map +1 -1
- package/dist/attributes/shared/operators.d.ts +2 -2
- package/dist/attributes/shared/operators.js.map +1 -1
- package/dist/attributes/text/types.d.ts +2 -3
- package/dist/attributes/text/types.d.ts.map +1 -1
- package/dist/attributes/text/types.js.map +1 -1
- package/dist/browser/chunks/chunk-D4FSTPML.js +14 -0
- package/dist/browser/chunks/chunk-D4FSTPML.js.map +7 -0
- package/dist/browser/chunks/chunk-LKUYVFU3.js +2 -0
- package/dist/browser/chunks/{chunk-DHB4COFY.js.map → chunk-LKUYVFU3.js.map} +4 -4
- package/dist/browser/chunks/chunk-RTNATFWX.js +5 -0
- package/dist/browser/chunks/chunk-RTNATFWX.js.map +7 -0
- package/dist/browser/chunks/chunk-ZRPZPWZU.js +3 -0
- package/dist/browser/chunks/chunk-ZRPZPWZU.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/component.js.map +4 -4
- package/dist/browser/experimental.js +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/manifest.json +2 -4
- package/dist/browser/sdk.js +1 -1
- package/dist/component.d.ts +10 -18
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +10 -17
- package/dist/component.js.map +1 -1
- package/dist/components/builtins/audio/audio.d.ts +53 -0
- package/dist/components/builtins/audio/audio.d.ts.map +1 -0
- package/dist/components/builtins/audio/audio.js +41 -0
- package/dist/components/builtins/audio/audio.js.map +1 -0
- package/dist/components/builtins/geometry/composite.d.ts +93 -0
- package/dist/components/builtins/geometry/composite.d.ts.map +1 -0
- package/dist/components/builtins/geometry/composite.js +25 -0
- package/dist/components/builtins/geometry/composite.js.map +1 -0
- package/dist/components/builtins/geometry/geometry.d.ts +921 -0
- package/dist/components/builtins/geometry/geometry.d.ts.map +1 -0
- package/dist/components/builtins/geometry/geometry.js +107 -0
- package/dist/components/builtins/geometry/geometry.js.map +1 -0
- package/dist/components/builtins/geometry/shape-outline.d.ts +93 -0
- package/dist/components/builtins/geometry/shape-outline.d.ts.map +1 -0
- package/dist/components/builtins/geometry/shape-outline.js +470 -0
- package/dist/components/builtins/geometry/shape-outline.js.map +1 -0
- package/dist/components/builtins/layout/layout.d.ts +186 -0
- package/dist/components/builtins/layout/layout.d.ts.map +1 -0
- package/dist/components/builtins/layout/layout.js +84 -0
- package/dist/components/builtins/layout/layout.js.map +1 -0
- package/dist/components/builtins/media/media.d.ts +240 -0
- package/dist/components/builtins/media/media.d.ts.map +1 -0
- package/dist/components/builtins/media/media.js +149 -0
- package/dist/components/builtins/media/media.js.map +1 -0
- package/dist/components/builtins/providers/providers.d.ts +47 -0
- package/dist/components/builtins/providers/providers.d.ts.map +1 -0
- package/dist/components/builtins/providers/providers.js +30 -0
- package/dist/components/builtins/providers/providers.js.map +1 -0
- package/dist/components/builtins/text/number-format.d.ts +66 -0
- package/dist/components/builtins/text/number-format.d.ts.map +1 -0
- package/dist/components/builtins/text/number-format.js +227 -0
- package/dist/components/builtins/text/number-format.js.map +1 -0
- package/dist/components/builtins/text/number-pattern.d.ts +51 -0
- package/dist/components/builtins/text/number-pattern.d.ts.map +1 -0
- package/dist/components/builtins/text/number-pattern.js +77 -0
- package/dist/components/builtins/text/number-pattern.js.map +1 -0
- package/dist/components/builtins/text/text-defaults.d.ts +32 -0
- package/dist/components/builtins/text/text-defaults.d.ts.map +1 -0
- package/dist/components/builtins/text/text-defaults.js +37 -0
- package/dist/components/builtins/text/text-defaults.js.map +1 -0
- package/dist/components/builtins/text/text-layout.d.ts +82 -0
- package/dist/components/builtins/text/text-layout.d.ts.map +1 -0
- package/dist/components/builtins/text/text-layout.js +331 -0
- package/dist/components/builtins/text/text-layout.js.map +1 -0
- package/dist/components/builtins/text/text.d.ts +409 -0
- package/dist/components/builtins/text/text.d.ts.map +1 -0
- package/dist/components/builtins/text/text.js +113 -0
- package/dist/components/builtins/text/text.js.map +1 -0
- package/dist/components/builtins/three/canvas3d.d.ts +245 -0
- package/dist/components/builtins/three/canvas3d.d.ts.map +1 -0
- package/dist/components/builtins/three/canvas3d.js +21 -0
- package/dist/components/builtins/three/canvas3d.js.map +1 -0
- package/dist/components/builtins/three/grid-geometry3d.d.ts +62 -0
- package/dist/components/builtins/three/grid-geometry3d.d.ts.map +1 -0
- package/dist/components/builtins/three/grid-geometry3d.js +114 -0
- package/dist/components/builtins/three/grid-geometry3d.js.map +1 -0
- package/dist/components/builtins/three/three.d.ts +1889 -0
- package/dist/components/builtins/three/three.d.ts.map +1 -0
- package/dist/components/builtins/three/three.js +305 -0
- package/dist/components/builtins/three/three.js.map +1 -0
- package/dist/components/factory/api.d.ts +516 -0
- package/dist/components/factory/api.d.ts.map +1 -0
- package/dist/components/factory/api.js +4 -0
- package/dist/components/factory/api.js.map +1 -0
- package/dist/components/factory/clip-of.d.ts +5 -0
- package/dist/components/factory/clip-of.d.ts.map +1 -0
- package/dist/components/factory/clip-of.js +33 -0
- package/dist/components/factory/clip-of.js.map +1 -0
- package/dist/components/factory/commands-for.d.ts +19 -0
- package/dist/components/factory/commands-for.d.ts.map +1 -0
- package/dist/components/factory/commands-for.js +5 -0
- package/dist/components/factory/commands-for.js.map +1 -0
- package/dist/components/factory/component-audio.d.ts +9 -0
- package/dist/components/factory/component-audio.d.ts.map +1 -0
- package/dist/components/factory/component-audio.js +18 -0
- package/dist/components/factory/component-audio.js.map +1 -0
- package/dist/components/factory/component2d.d.ts +8 -0
- package/dist/components/factory/component2d.d.ts.map +1 -0
- package/dist/components/factory/component2d.js +240 -0
- package/dist/components/factory/component2d.js.map +1 -0
- package/dist/components/factory/component3d.d.ts +9 -0
- package/dist/components/factory/component3d.d.ts.map +1 -0
- package/dist/components/factory/component3d.js +99 -0
- package/dist/components/factory/component3d.js.map +1 -0
- package/dist/components/factory/factory.d.ts +63 -0
- package/dist/components/factory/factory.d.ts.map +1 -0
- package/dist/components/factory/factory.js +313 -0
- package/dist/components/factory/factory.js.map +1 -0
- package/dist/components/factory/timeline.d.ts +22 -0
- package/dist/components/factory/timeline.d.ts.map +1 -0
- package/dist/components/factory/timeline.js +128 -0
- package/dist/components/factory/timeline.js.map +1 -0
- package/dist/components/factory/type-def.d.ts +26 -0
- package/dist/components/factory/type-def.d.ts.map +1 -0
- package/dist/components/factory/type-def.js +16 -0
- package/dist/components/factory/type-def.js.map +1 -0
- package/dist/components/factory/types.d.ts +91 -0
- package/dist/components/factory/types.d.ts.map +1 -0
- package/dist/components/factory/types.js +88 -0
- package/dist/components/factory/types.js.map +1 -0
- package/dist/components/factory/views.d.ts +121 -0
- package/dist/components/factory/views.d.ts.map +1 -0
- package/dist/components/factory/views.js +413 -0
- package/dist/components/factory/views.js.map +1 -0
- package/dist/components/modules/aim.d.ts +30 -0
- package/dist/components/modules/aim.d.ts.map +1 -0
- package/dist/components/modules/aim.js +39 -0
- package/dist/components/modules/aim.js.map +1 -0
- package/dist/components/modules/corners.d.ts +13 -0
- package/dist/components/modules/corners.d.ts.map +1 -0
- package/dist/components/modules/corners.js +12 -0
- package/dist/components/modules/corners.js.map +1 -0
- package/dist/components/modules/flow.d.ts +26 -0
- package/dist/components/modules/flow.d.ts.map +1 -0
- package/dist/components/modules/flow.js +57 -0
- package/dist/components/modules/flow.js.map +1 -0
- package/dist/components/modules/material.d.ts +40 -0
- package/dist/components/modules/material.d.ts.map +1 -0
- package/dist/components/modules/material.js +75 -0
- package/dist/components/modules/material.js.map +1 -0
- package/dist/components/modules/paint.d.ts +71 -0
- package/dist/components/modules/paint.d.ts.map +1 -0
- package/dist/components/modules/paint.js +106 -0
- package/dist/components/modules/paint.js.map +1 -0
- package/dist/components/modules/shapes.d.ts +31 -0
- package/dist/components/modules/shapes.d.ts.map +1 -0
- package/dist/components/modules/shapes.js +43 -0
- package/dist/components/modules/shapes.js.map +1 -0
- package/dist/components/modules/text-layout.d.ts +26 -0
- package/dist/components/modules/text-layout.d.ts.map +1 -0
- package/dist/components/modules/text-layout.js +57 -0
- package/dist/components/modules/text-layout.js.map +1 -0
- package/dist/components/modules/text-style.d.ts +48 -0
- package/dist/components/modules/text-style.d.ts.map +1 -0
- package/dist/components/modules/text-style.js +63 -0
- package/dist/components/modules/text-style.js.map +1 -0
- package/dist/components/modules/three-entries.d.ts +23 -0
- package/dist/components/modules/three-entries.d.ts.map +1 -0
- package/dist/components/modules/three-entries.js +41 -0
- package/dist/components/modules/three-entries.js.map +1 -0
- package/dist/components/modules/view3d.d.ts +59 -0
- package/dist/components/modules/view3d.d.ts.map +1 -0
- package/dist/components/modules/view3d.js +171 -0
- package/dist/components/modules/view3d.js.map +1 -0
- package/dist/components/trees/2d/group-bounds.d.ts +56 -0
- package/dist/components/trees/2d/group-bounds.d.ts.map +1 -0
- package/dist/components/trees/2d/group-bounds.js +87 -0
- package/dist/components/trees/2d/group-bounds.js.map +1 -0
- package/dist/components/trees/2d/node-lifecycle.d.ts +46 -0
- package/dist/components/trees/2d/node-lifecycle.d.ts.map +1 -0
- package/dist/components/trees/2d/node-lifecycle.js +264 -0
- package/dist/components/trees/2d/node-lifecycle.js.map +1 -0
- package/dist/components/trees/2d/node-motion.d.ts +56 -0
- package/dist/components/trees/2d/node-motion.d.ts.map +1 -0
- package/dist/components/trees/2d/node-motion.js +86 -0
- package/dist/components/trees/2d/node-motion.js.map +1 -0
- package/dist/components/trees/2d/node-render.d.ts +36 -0
- package/dist/components/trees/2d/node-render.d.ts.map +1 -0
- package/dist/components/trees/2d/node-render.js +67 -0
- package/dist/components/trees/2d/node-render.js.map +1 -0
- package/dist/components/trees/2d/node-space.d.ts +63 -0
- package/dist/components/trees/2d/node-space.d.ts.map +1 -0
- package/dist/components/trees/2d/node-space.js +131 -0
- package/dist/components/trees/2d/node-space.js.map +1 -0
- package/dist/components/trees/2d/node-transform.d.ts +55 -0
- package/dist/components/trees/2d/node-transform.d.ts.map +1 -0
- package/dist/components/trees/2d/node-transform.js +73 -0
- package/dist/components/trees/2d/node-transform.js.map +1 -0
- package/dist/components/trees/2d/node2d.d.ts +1020 -0
- package/dist/components/trees/2d/node2d.d.ts.map +1 -0
- package/dist/components/trees/2d/node2d.js +1481 -0
- package/dist/components/trees/2d/node2d.js.map +1 -0
- package/dist/components/trees/audio/index.d.ts +2 -0
- package/dist/components/trees/audio/index.d.ts.map +1 -0
- package/dist/components/trees/audio/index.js +2 -0
- package/dist/components/trees/audio/index.js.map +1 -0
- package/dist/components/trees/audio/node-audio.d.ts +109 -0
- package/dist/components/trees/audio/node-audio.d.ts.map +1 -0
- package/dist/components/trees/audio/node-audio.js +167 -0
- package/dist/components/trees/audio/node-audio.js.map +1 -0
- package/dist/components/trees/index.d.ts +10 -0
- package/dist/components/trees/index.d.ts.map +1 -0
- package/dist/components/trees/index.js +14 -0
- package/dist/components/trees/index.js.map +1 -0
- package/dist/components/trees/node/node-editor-state.d.ts +53 -0
- package/dist/components/trees/node/node-editor-state.d.ts.map +1 -0
- package/dist/components/trees/node/node-editor-state.js +23 -0
- package/dist/components/trees/node/node-editor-state.js.map +1 -0
- package/dist/components/trees/node/node-reactive.d.ts +89 -0
- package/dist/components/trees/node/node-reactive.d.ts.map +1 -0
- package/dist/components/trees/node/node-reactive.js +135 -0
- package/dist/components/trees/node/node-reactive.js.map +1 -0
- package/dist/components/trees/node/node-time.d.ts +39 -0
- package/dist/components/trees/node/node-time.d.ts.map +1 -0
- package/dist/components/trees/node/node-time.js +14 -0
- package/dist/components/trees/node/node-time.js.map +1 -0
- package/dist/components/trees/node/node-walk.d.ts +46 -0
- package/dist/components/trees/node/node-walk.d.ts.map +1 -0
- package/dist/components/trees/node/node-walk.js +74 -0
- package/dist/components/trees/node/node-walk.js.map +1 -0
- package/dist/components/trees/node/node.d.ts +401 -0
- package/dist/components/trees/node/node.d.ts.map +1 -0
- package/dist/components/trees/node/node.js +680 -0
- package/dist/components/trees/node/node.js.map +1 -0
- package/dist/components/trees/root/canvas2d-node.d.ts +163 -0
- package/dist/components/trees/root/canvas2d-node.d.ts.map +1 -0
- package/dist/components/trees/root/canvas2d-node.js +216 -0
- package/dist/components/trees/root/canvas2d-node.js.map +1 -0
- package/dist/components/trees/three/node3d.d.ts +222 -0
- package/dist/components/trees/three/node3d.d.ts.map +1 -0
- package/dist/components/trees/three/node3d.js +289 -0
- package/dist/components/trees/three/node3d.js.map +1 -0
- package/dist/document/builtins.js +13 -13
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +2 -2
- package/dist/document/command-traits.js +1 -1
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/deny-globals.d.ts +2 -2
- package/dist/document/deny-globals.js +2 -2
- package/dist/document/deny-globals.js.map +1 -1
- package/dist/document/expression/index.d.ts +1 -1
- package/dist/document/expression/index.js +1 -1
- package/dist/document/expression/index.js.map +1 -1
- package/dist/document/expression/ops.js +1 -1
- package/dist/document/expression/ops.js.map +1 -1
- package/dist/document/index.d.ts +1 -2
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/index.js +1 -2
- package/dist/document/index.js.map +1 -1
- package/dist/document/node-decorator.d.ts +14 -10
- package/dist/document/node-decorator.d.ts.map +1 -1
- package/dist/document/node-decorator.js +14 -10
- package/dist/document/node-decorator.js.map +1 -1
- package/dist/document/node-descriptor.d.ts +3 -3
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/registry.d.ts +23 -25
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +12 -18
- package/dist/document/registry.js.map +1 -1
- package/dist/document/timeline.d.ts +3 -3
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +2 -2
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +4 -4
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +1 -1
- package/dist/document/validate.js.map +1 -1
- package/dist/experimental.d.ts +19 -19
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +17 -17
- package/dist/experimental.js.map +1 -1
- package/dist/index.d.ts +10 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -11
- package/dist/index.js.map +1 -1
- package/dist/layout/types.d.ts +1 -1
- package/dist/layout/types.js.map +1 -1
- package/dist/props/host.d.ts +1 -1
- package/dist/props/host.js.map +1 -1
- package/dist/props/slot.d.ts +1 -1
- package/dist/props/slot.js +1 -1
- package/dist/props/slot.js.map +1 -1
- package/dist/render/clip.d.ts +1 -1
- package/dist/render/clip.js +1 -1
- package/dist/render/clip.js.map +1 -1
- package/dist/render/descriptors/rect.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +11 -5
- package/dist/render/descriptors/text.d.ts.map +1 -1
- package/dist/render/descriptors/text.js +7 -1
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/render-context2d.d.ts +2 -2
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render3d/builders.d.ts +1 -1
- package/dist/render3d/builders.js +1 -1
- package/dist/render3d/builders.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts +13 -19
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +13 -19
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/render3d/scene3d.d.ts +1 -1
- package/dist/render3d/scene3d.js +1 -1
- package/dist/render3d/scene3d.js.map +1 -1
- package/dist/render3d/texture.d.ts +2 -2
- package/dist/render3d/texture.d.ts.map +1 -1
- package/dist/render3d/texture.js.map +1 -1
- package/dist/render3d/vector3.d.ts +2 -2
- package/dist/render3d/vector3.js +2 -2
- package/dist/render3d/vector3.js.map +1 -1
- package/dist/runtime/asset-refine.d.ts +1 -1
- package/dist/runtime/asset-refine.d.ts.map +1 -1
- package/dist/runtime/asset-refine.js +1 -1
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-update.js +1 -1
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/audio-index.d.ts +0 -11
- package/dist/runtime/audio-index.d.ts.map +1 -1
- package/dist/runtime/audio-index.js +0 -25
- package/dist/runtime/audio-index.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +3 -3
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +4 -4
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +2 -3
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +17 -35
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +3 -3
- package/dist/runtime/engine.js +2 -2
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/node-picking.d.ts +2 -2
- package/dist/runtime/node-picking.d.ts.map +1 -1
- package/dist/runtime/node-picking.js +3 -3
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +2 -2
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +1 -1
- package/dist/runtime/node-picking3d.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts +2 -2
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +1 -1
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/state-evaluator.d.ts +2 -2
- package/dist/runtime/state-evaluator.d.ts.map +1 -1
- package/dist/runtime/state-evaluator.js.map +1 -1
- package/dist/runtime/text-geometry.d.ts +1 -1
- package/dist/runtime/text-geometry.d.ts.map +1 -1
- package/dist/runtime/text-geometry.js +4 -5
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +43 -39
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +24 -25
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +7 -9
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js +2 -2
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/command.d.ts +1 -1
- package/dist/tween/command.js.map +1 -1
- package/dist/tween/index.d.ts +2 -1
- package/dist/tween/index.d.ts.map +1 -1
- package/dist/tween/index.js +1 -1
- package/dist/tween/index.js.map +1 -1
- package/dist/tween/loop.d.ts +1 -1
- package/dist/tween/loop.js +1 -1
- package/dist/tween/loop.js.map +1 -1
- package/dist/util/reference.d.ts +6 -6
- package/dist/util/reference.js.map +1 -1
- package/package.json +2 -10
- package/dist/browser/chunks/chunk-2RIYH36X.js +0 -3
- package/dist/browser/chunks/chunk-2RIYH36X.js.map +0 -7
- package/dist/browser/chunks/chunk-DDJN3QII.js +0 -15
- package/dist/browser/chunks/chunk-DDJN3QII.js.map +0 -7
- package/dist/browser/chunks/chunk-DHB4COFY.js +0 -2
- package/dist/browser/chunks/chunk-EJDPYDQI.js +0 -5
- package/dist/browser/chunks/chunk-EJDPYDQI.js.map +0 -7
- package/dist/browser/chunks/chunk-SFNJRPBV.js +0 -2
- package/dist/browser/chunks/chunk-SFNJRPBV.js.map +0 -7
- package/dist/browser/chunks/chunk-XAWE4EAK.js +0 -2
- package/dist/browser/chunks/chunk-XAWE4EAK.js.map +0 -7
- package/dist/browser/jsx-jsx-dev-runtime.js +0 -2
- package/dist/browser/jsx-jsx-dev-runtime.js.map +0 -7
- package/dist/browser/jsx-jsx-runtime.js +0 -2
- package/dist/browser/jsx-jsx-runtime.js.map +0 -7
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Number node's format controls, resolved into the one pattern the app's
|
|
3
|
+
* formatter takes.
|
|
4
|
+
*
|
|
5
|
+
* There is already exactly one answer in this package to "how is a number
|
|
6
|
+
* written down" — `./number-format`, whose docblock has the grammar and
|
|
7
|
+
* the argument for it. This module adds no second one. What it adds is the
|
|
8
|
+
* *panel's* half: a figure on the canvas is set up by picking a format and
|
|
9
|
+
* saying how many decimals, where a chart axis is set up by picking a preset,
|
|
10
|
+
* and those two are the same statement typed differently.
|
|
11
|
+
*
|
|
12
|
+
* So the controls compose a pattern rather than being honoured beside one. A
|
|
13
|
+
* Number node showing `$1,234.50` and an axis labelled `$#,##0.00` go through
|
|
14
|
+
* the same parser and round the same way, which is the thing that would drift
|
|
15
|
+
* if the node reached for `Intl.NumberFormat` instead.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* How a Number node writes its figure.
|
|
19
|
+
*
|
|
20
|
+
* The chart's five minus `plain`, which exists there only to keep charts drawn
|
|
21
|
+
* before there were formats labelling themselves the way they always have. A
|
|
22
|
+
* node has no such history, and "plain" beside "number" is a distinction
|
|
23
|
+
* nobody browsing a dropdown can make.
|
|
24
|
+
*/
|
|
25
|
+
export declare const NUMBER_NODE_FORMATS: readonly ["number", "currency", "percent", "custom"];
|
|
26
|
+
export type NumberNodeFormat = (typeof NUMBER_NODE_FORMATS)[number];
|
|
27
|
+
/** The most decimals the panel will let a figure carry. */
|
|
28
|
+
export declare const MAX_FRACTION_DIGITS = 10;
|
|
29
|
+
/** The Number node's format controls, as the class holds them. */
|
|
30
|
+
export interface NumberFormatOptions {
|
|
31
|
+
/** How the figure is written — see {@link NumberNode.format}. */
|
|
32
|
+
format: string;
|
|
33
|
+
/** The pattern typed by hand — read only when the format is `custom`. */
|
|
34
|
+
customPattern: string;
|
|
35
|
+
fractionDigits: number;
|
|
36
|
+
grouped: boolean;
|
|
37
|
+
/** Printed before the figure when the format is `currency`. */
|
|
38
|
+
currencySymbol: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The pattern `options` names.
|
|
42
|
+
*
|
|
43
|
+
* `custom` hands the typed pattern straight to {@link patternFor}, which is what
|
|
44
|
+
* makes the escape hatch the *same* language the presets are written in rather
|
|
45
|
+
* than a second one. Every other format is composed here, because the three
|
|
46
|
+
* controls beside the dropdown — decimals, grouping, the symbol — are what a
|
|
47
|
+
* preset would otherwise have to be duplicated for (`#,##0.00` and `#,##0.000`
|
|
48
|
+
* and `0.00` and…).
|
|
49
|
+
*/
|
|
50
|
+
export declare function numberNodePattern(options: NumberFormatOptions): string;
|
|
51
|
+
//# sourceMappingURL=number-pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-pattern.d.ts","sourceRoot":"","sources":["../../../../src/components/builtins/text/number-pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,sDAKtB,CAAA;AAEV,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEnE,2DAA2D;AAC3D,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC,kEAAkE;AAClE,MAAM,WAAW,mBAAmB;IAClC,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAA;IACd,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,+DAA+D;IAC/D,cAAc,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAsBtE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Number node's format controls, resolved into the one pattern the app's
|
|
3
|
+
* formatter takes.
|
|
4
|
+
*
|
|
5
|
+
* There is already exactly one answer in this package to "how is a number
|
|
6
|
+
* written down" — `./number-format`, whose docblock has the grammar and
|
|
7
|
+
* the argument for it. This module adds no second one. What it adds is the
|
|
8
|
+
* *panel's* half: a figure on the canvas is set up by picking a format and
|
|
9
|
+
* saying how many decimals, where a chart axis is set up by picking a preset,
|
|
10
|
+
* and those two are the same statement typed differently.
|
|
11
|
+
*
|
|
12
|
+
* So the controls compose a pattern rather than being honoured beside one. A
|
|
13
|
+
* Number node showing `$1,234.50` and an axis labelled `$#,##0.00` go through
|
|
14
|
+
* the same parser and round the same way, which is the thing that would drift
|
|
15
|
+
* if the node reached for `Intl.NumberFormat` instead.
|
|
16
|
+
*/
|
|
17
|
+
import { patternFor } from "./number-format.js";
|
|
18
|
+
/**
|
|
19
|
+
* How a Number node writes its figure.
|
|
20
|
+
*
|
|
21
|
+
* The chart's five minus `plain`, which exists there only to keep charts drawn
|
|
22
|
+
* before there were formats labelling themselves the way they always have. A
|
|
23
|
+
* node has no such history, and "plain" beside "number" is a distinction
|
|
24
|
+
* nobody browsing a dropdown can make.
|
|
25
|
+
*/
|
|
26
|
+
export const NUMBER_NODE_FORMATS = [
|
|
27
|
+
"number",
|
|
28
|
+
"currency",
|
|
29
|
+
"percent",
|
|
30
|
+
"custom",
|
|
31
|
+
];
|
|
32
|
+
/** The most decimals the panel will let a figure carry. */
|
|
33
|
+
export const MAX_FRACTION_DIGITS = 10;
|
|
34
|
+
/**
|
|
35
|
+
* The pattern `options` names.
|
|
36
|
+
*
|
|
37
|
+
* `custom` hands the typed pattern straight to {@link patternFor}, which is what
|
|
38
|
+
* makes the escape hatch the *same* language the presets are written in rather
|
|
39
|
+
* than a second one. Every other format is composed here, because the three
|
|
40
|
+
* controls beside the dropdown — decimals, grouping, the symbol — are what a
|
|
41
|
+
* preset would otherwise have to be duplicated for (`#,##0.00` and `#,##0.000`
|
|
42
|
+
* and `0.00` and…).
|
|
43
|
+
*/
|
|
44
|
+
export function numberNodePattern(options) {
|
|
45
|
+
if (options.format === "custom") {
|
|
46
|
+
return patternFor("custom", options.customPattern);
|
|
47
|
+
}
|
|
48
|
+
const digits = Math.min(MAX_FRACTION_DIGITS, Math.max(0, Math.round(options.fractionDigits)));
|
|
49
|
+
const integer = options.grouped ? "#,##0" : "0";
|
|
50
|
+
const fraction = digits > 0 ? `.${"0".repeat(digits)}` : "";
|
|
51
|
+
const body = `${integer}${fraction}`;
|
|
52
|
+
if (options.format === "currency") {
|
|
53
|
+
return `${quoted(options.currencySymbol)}${body}`;
|
|
54
|
+
}
|
|
55
|
+
// Bare, so the parser reads it as the percent *operator* and scales by 100 —
|
|
56
|
+
// which is what makes a stored 0.42 read as "42%". A symbol an author wants
|
|
57
|
+
// printed over data that is already in percent points is a custom pattern
|
|
58
|
+
// with the sign quoted, exactly as it is on an axis.
|
|
59
|
+
if (options.format === "percent")
|
|
60
|
+
return `${body}%`;
|
|
61
|
+
return body;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* `symbol` as a pattern literal.
|
|
65
|
+
*
|
|
66
|
+
* Quoted rather than concatenated, because the two most likely symbols after `$`
|
|
67
|
+
* are `€` and `£` and the two after those are whatever an author types — and an
|
|
68
|
+
* unquoted `#`, `0`, `,`, `.` or `%` in there would be read as part of the
|
|
69
|
+
* number. The quote character itself is dropped rather than escaped: the grammar
|
|
70
|
+
* has no escape for it, and a currency symbol containing an apostrophe is not a
|
|
71
|
+
* thing anyone has.
|
|
72
|
+
*/
|
|
73
|
+
function quoted(symbol) {
|
|
74
|
+
const literal = symbol.replaceAll("'", "");
|
|
75
|
+
return literal === "" ? "" : `'${literal}'`;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=number-pattern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-pattern.js","sourceRoot":"","sources":["../../../../src/components/builtins/text/number-pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,QAAQ;IACR,UAAU;IACV,SAAS;IACT,QAAQ;CACA,CAAA;AAIV,2DAA2D;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAcrC;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA4B;IAC5D,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IACpD,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CACrB,mBAAmB,EACnB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAChD,CAAA;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA;IAC/C,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IAC3D,MAAM,IAAI,GAAG,GAAG,OAAO,GAAG,QAAQ,EAAE,CAAA;IAEpC,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAClC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,EAAE,CAAA;IACnD,CAAC;IACD,6EAA6E;IAC7E,4EAA4E;IAC5E,0EAA0E;IAC1E,qDAAqD;IACrD,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,GAAG,IAAI,GAAG,CAAA;IACnD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,MAAM,CAAC,MAAc;IAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IAC1C,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,CAAA;AAC7C,CAAC","sourcesContent":["/**\r\n * The Number node's format controls, resolved into the one pattern the app's\r\n * formatter takes.\r\n *\r\n * There is already exactly one answer in this package to \"how is a number\r\n * written down\" — `./number-format`, whose docblock has the grammar and\r\n * the argument for it. This module adds no second one. What it adds is the\r\n * *panel's* half: a figure on the canvas is set up by picking a format and\r\n * saying how many decimals, where a chart axis is set up by picking a preset,\r\n * and those two are the same statement typed differently.\r\n *\r\n * So the controls compose a pattern rather than being honoured beside one. A\r\n * Number node showing `$1,234.50` and an axis labelled `$#,##0.00` go through\r\n * the same parser and round the same way, which is the thing that would drift\r\n * if the node reached for `Intl.NumberFormat` instead.\r\n */\r\n\r\nimport { patternFor } from \"./number-format\";\r\n\r\n/**\r\n * How a Number node writes its figure.\r\n *\r\n * The chart's five minus `plain`, which exists there only to keep charts drawn\r\n * before there were formats labelling themselves the way they always have. A\r\n * node has no such history, and \"plain\" beside \"number\" is a distinction\r\n * nobody browsing a dropdown can make.\r\n */\r\nexport const NUMBER_NODE_FORMATS = [\r\n \"number\",\r\n \"currency\",\r\n \"percent\",\r\n \"custom\",\r\n] as const\r\n\r\nexport type NumberNodeFormat = (typeof NUMBER_NODE_FORMATS)[number]\r\n\r\n/** The most decimals the panel will let a figure carry. */\r\nexport const MAX_FRACTION_DIGITS = 10\r\n\r\n/** The Number node's format controls, as the class holds them. */\r\nexport interface NumberFormatOptions {\r\n /** How the figure is written — see {@link NumberNode.format}. */\r\n format: string\r\n /** The pattern typed by hand — read only when the format is `custom`. */\r\n customPattern: string\r\n fractionDigits: number\r\n grouped: boolean\r\n /** Printed before the figure when the format is `currency`. */\r\n currencySymbol: string\r\n}\r\n\r\n/**\r\n * The pattern `options` names.\r\n *\r\n * `custom` hands the typed pattern straight to {@link patternFor}, which is what\r\n * makes the escape hatch the *same* language the presets are written in rather\r\n * than a second one. Every other format is composed here, because the three\r\n * controls beside the dropdown — decimals, grouping, the symbol — are what a\r\n * preset would otherwise have to be duplicated for (`#,##0.00` and `#,##0.000`\r\n * and `0.00` and…).\r\n */\r\nexport function numberNodePattern(options: NumberFormatOptions): string {\r\n if (options.format === \"custom\") {\r\n return patternFor(\"custom\", options.customPattern)\r\n }\r\n\r\n const digits = Math.min(\r\n MAX_FRACTION_DIGITS,\r\n Math.max(0, Math.round(options.fractionDigits))\r\n )\r\n const integer = options.grouped ? \"#,##0\" : \"0\"\r\n const fraction = digits > 0 ? `.${\"0\".repeat(digits)}` : \"\"\r\n const body = `${integer}${fraction}`\r\n\r\n if (options.format === \"currency\") {\r\n return `${quoted(options.currencySymbol)}${body}`\r\n }\r\n // Bare, so the parser reads it as the percent *operator* and scales by 100 —\r\n // which is what makes a stored 0.42 read as \"42%\". A symbol an author wants\r\n // printed over data that is already in percent points is a custom pattern\r\n // with the sign quoted, exactly as it is on an axis.\r\n if (options.format === \"percent\") return `${body}%`\r\n return body\r\n}\r\n\r\n/**\r\n * `symbol` as a pattern literal.\r\n *\r\n * Quoted rather than concatenated, because the two most likely symbols after `$`\r\n * are `€` and `£` and the two after those are whatever an author types — and an\r\n * unquoted `#`, `0`, `,`, `.` or `%` in there would be read as part of the\r\n * number. The quote character itself is dropped rather than escaped: the grammar\r\n * has no escape for it, and a currency symbol containing an apostrophe is not a\r\n * thing anyone has.\r\n */\r\nfunction quoted(symbol: string): string {\r\n const literal = symbol.replaceAll(\"'\", \"\")\r\n return literal === \"\" ? \"\" : `'${literal}'`\r\n}\r\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family a component's text falls back to when the document names none.
|
|
3
|
+
*
|
|
4
|
+
* A node that draws a caption of its own — a button's label, a window's title —
|
|
5
|
+
* has to put *some* family on it, because the renderer's font provider holds
|
|
6
|
+
* only what the manifest registered and a family called `""` shapes against
|
|
7
|
+
* nothing and paints no glyphs. Which family that is, though, is a fact about
|
|
8
|
+
* the application: which fonts it vendored, which it licensed, what its UI is
|
|
9
|
+
* set in. A component shipped as its own package cannot know it, and the engine
|
|
10
|
+
* has no built-in family to offer in its place.
|
|
11
|
+
*
|
|
12
|
+
* So the answer is *supplied*, once, by the host application's composition
|
|
13
|
+
* root, through {@link setHostTextFamily}. Until a host does, the answer is
|
|
14
|
+
* `""`, and a host that ships a typeface says so instead of every node learning
|
|
15
|
+
* its name.
|
|
16
|
+
*
|
|
17
|
+
* This is deliberately **not** a prop. The prop is the node's own `fontFamily`,
|
|
18
|
+
* which a host's props mapping can fill in from here when the author has left
|
|
19
|
+
* it empty. What lives here is only the answer to "empty means what?", which is
|
|
20
|
+
* one answer for the whole application rather than one per node.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Declares the family this application's components fall back to.
|
|
24
|
+
*
|
|
25
|
+
* Called by the composition root before the first build. Left unset, components
|
|
26
|
+
* fall back to `""`, which paints no glyphs — a legible blank rather than a
|
|
27
|
+
* silently wrong typeface, and the same bargain an unregistered node type makes.
|
|
28
|
+
*/
|
|
29
|
+
export declare function setHostTextFamily(family: string): void;
|
|
30
|
+
/** The family to use where the document names none. */
|
|
31
|
+
export declare function hostTextFamily(): string;
|
|
32
|
+
//# sourceMappingURL=text-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-defaults.d.ts","sourceRoot":"","sources":["../../../../src/components/builtins/text/text-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED,uDAAuD;AACvD,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family a component's text falls back to when the document names none.
|
|
3
|
+
*
|
|
4
|
+
* A node that draws a caption of its own — a button's label, a window's title —
|
|
5
|
+
* has to put *some* family on it, because the renderer's font provider holds
|
|
6
|
+
* only what the manifest registered and a family called `""` shapes against
|
|
7
|
+
* nothing and paints no glyphs. Which family that is, though, is a fact about
|
|
8
|
+
* the application: which fonts it vendored, which it licensed, what its UI is
|
|
9
|
+
* set in. A component shipped as its own package cannot know it, and the engine
|
|
10
|
+
* has no built-in family to offer in its place.
|
|
11
|
+
*
|
|
12
|
+
* So the answer is *supplied*, once, by the host application's composition
|
|
13
|
+
* root, through {@link setHostTextFamily}. Until a host does, the answer is
|
|
14
|
+
* `""`, and a host that ships a typeface says so instead of every node learning
|
|
15
|
+
* its name.
|
|
16
|
+
*
|
|
17
|
+
* This is deliberately **not** a prop. The prop is the node's own `fontFamily`,
|
|
18
|
+
* which a host's props mapping can fill in from here when the author has left
|
|
19
|
+
* it empty. What lives here is only the answer to "empty means what?", which is
|
|
20
|
+
* one answer for the whole application rather than one per node.
|
|
21
|
+
*/
|
|
22
|
+
let fallbackFamily = "";
|
|
23
|
+
/**
|
|
24
|
+
* Declares the family this application's components fall back to.
|
|
25
|
+
*
|
|
26
|
+
* Called by the composition root before the first build. Left unset, components
|
|
27
|
+
* fall back to `""`, which paints no glyphs — a legible blank rather than a
|
|
28
|
+
* silently wrong typeface, and the same bargain an unregistered node type makes.
|
|
29
|
+
*/
|
|
30
|
+
export function setHostTextFamily(family) {
|
|
31
|
+
fallbackFamily = family;
|
|
32
|
+
}
|
|
33
|
+
/** The family to use where the document names none. */
|
|
34
|
+
export function hostTextFamily() {
|
|
35
|
+
return fallbackFamily;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=text-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-defaults.js","sourceRoot":"","sources":["../../../../src/components/builtins/text/text-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,IAAI,cAAc,GAAG,EAAE,CAAA;AAEvB;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,cAAc,GAAG,MAAM,CAAA;AACzB,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,cAAc;IAC5B,OAAO,cAAc,CAAA;AACvB,CAAC","sourcesContent":["/**\r\n * The family a component's text falls back to when the document names none.\r\n *\r\n * A node that draws a caption of its own — a button's label, a window's title —\r\n * has to put *some* family on it, because the renderer's font provider holds\r\n * only what the manifest registered and a family called `\"\"` shapes against\r\n * nothing and paints no glyphs. Which family that is, though, is a fact about\r\n * the application: which fonts it vendored, which it licensed, what its UI is\r\n * set in. A component shipped as its own package cannot know it, and the engine\r\n * has no built-in family to offer in its place.\r\n *\r\n * So the answer is *supplied*, once, by the host application's composition\r\n * root, through {@link setHostTextFamily}. Until a host does, the answer is\r\n * `\"\"`, and a host that ships a typeface says so instead of every node learning\r\n * its name.\r\n *\r\n * This is deliberately **not** a prop. The prop is the node's own `fontFamily`,\r\n * which a host's props mapping can fill in from here when the author has left\r\n * it empty. What lives here is only the answer to \"empty means what?\", which is\r\n * one answer for the whole application rather than one per node.\r\n */\r\n\r\nlet fallbackFamily = \"\"\r\n\r\n/**\r\n * Declares the family this application's components fall back to.\r\n *\r\n * Called by the composition root before the first build. Left unset, components\r\n * fall back to `\"\"`, which paints no glyphs — a legible blank rather than a\r\n * silently wrong typeface, and the same bargain an unregistered node type makes.\r\n */\r\nexport function setHostTextFamily(family: string): void {\r\n fallbackFamily = family\r\n}\r\n\r\n/** The family to use where the document names none. */\r\nexport function hostTextFamily(): string {\r\n return fallbackFamily\r\n}\r\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { AssetScope } from "../../../assets/scope.js";
|
|
2
|
+
import type { Size2D, SizeInput } from "../../../attributes/layout/size.js";
|
|
3
|
+
import type { FontStyle, ResolvedTextRun, ResolvedTextSpan, TextAlign, TextCase, TextDecoration, TextSpan, VerticalAlign } from "../../../attributes/text/types.js";
|
|
4
|
+
import type { RichTextState } from "../../../render/descriptors/richtext.js";
|
|
5
|
+
import type { SizeConstraints } from "../../../layout/constraints.js";
|
|
6
|
+
import type { PathData } from "../../../render/descriptors/path.js";
|
|
7
|
+
import type { TextSegment, TextState } from "../../../render/descriptors/text.js";
|
|
8
|
+
import type { MeasureContext2D } from "../../../render/measure-context.js";
|
|
9
|
+
/**
|
|
10
|
+
* Setting a string in a face: measuring the block, cutting it into styled
|
|
11
|
+
* pieces, and the descriptor it draws as. Plain functions over resolved values,
|
|
12
|
+
* behind the components' `TextLayout` module.
|
|
13
|
+
*/
|
|
14
|
+
/** The shaping fields a glyph node reads, resolved. */
|
|
15
|
+
export interface TextValues {
|
|
16
|
+
readonly fontFamily: string;
|
|
17
|
+
readonly fontSize: number | "autofit";
|
|
18
|
+
readonly fontWeight: number;
|
|
19
|
+
readonly fontStyle: FontStyle;
|
|
20
|
+
readonly letterSpacing: number;
|
|
21
|
+
readonly lineHeight: number;
|
|
22
|
+
readonly textAlign: TextAlign;
|
|
23
|
+
readonly verticalAlign: VerticalAlign;
|
|
24
|
+
readonly textDecoration: TextDecoration;
|
|
25
|
+
readonly textCase: TextCase;
|
|
26
|
+
readonly minFontSize: number;
|
|
27
|
+
readonly fill: unknown;
|
|
28
|
+
readonly stroke: unknown;
|
|
29
|
+
readonly start: number;
|
|
30
|
+
readonly end: number;
|
|
31
|
+
readonly width: SizeInput;
|
|
32
|
+
readonly height: SizeInput;
|
|
33
|
+
}
|
|
34
|
+
/** Where the string comes from, and what styles parts of it. */
|
|
35
|
+
export interface TextSource {
|
|
36
|
+
readonly text: string;
|
|
37
|
+
readonly wraps: boolean;
|
|
38
|
+
/** The path the glyphs ride, for text-on-path. */
|
|
39
|
+
readonly glyphPath: PathData | null;
|
|
40
|
+
/** Stretches a document styles apart from the node: `Text`'s `runs`. */
|
|
41
|
+
readonly runs: readonly ResolvedTextRun[];
|
|
42
|
+
}
|
|
43
|
+
export declare function casedText(s: TextValues, src: TextSource): string;
|
|
44
|
+
/** The block's size: hugged to its glyphs, filled across, and its own height even when it fills, so a hugging ancestor sees its content. */
|
|
45
|
+
export declare function measureGlyphs(s: TextValues, src: TextSource, constraints: SizeConstraints, scope: MeasureContext2D): Size2D;
|
|
46
|
+
/**
|
|
47
|
+
* The string cut at every style boundary, each piece styled by the runs over
|
|
48
|
+
* it, the later winning. Also folds in the Write On reveal window. `null` when neither is
|
|
49
|
+
* active, so rendering keeps its single-op path; and always `null` on a path,
|
|
50
|
+
* where the string is laid along it as one run.
|
|
51
|
+
*/
|
|
52
|
+
export declare function textSegments(s: TextValues, src: TextSource): TextSegment[] | null;
|
|
53
|
+
/** The descriptor the block draws as, in a box of `size`. Picking's caret geometry reads the same one. */
|
|
54
|
+
export declare function textState(s: TextValues, src: TextSource, size: Size2D | undefined): Partial<TextState>;
|
|
55
|
+
/**
|
|
56
|
+
* The node's own face, plus whatever a piece sets in another, and the pieces'
|
|
57
|
+
* paints. Naming a family here is what lets it load before layout, rather than
|
|
58
|
+
* being discovered by measuring against the fallback face.
|
|
59
|
+
*/
|
|
60
|
+
export declare function declareGlyphAssets(s: TextValues, src: TextSource, assets: Pick<AssetScope, "font" | "fill">): void;
|
|
61
|
+
/** What a rich-text node reads: spans, and the face they inherit from. */
|
|
62
|
+
export interface RichValues {
|
|
63
|
+
readonly spans: readonly TextSpan[];
|
|
64
|
+
readonly fontFamily: string;
|
|
65
|
+
readonly fontSize: number;
|
|
66
|
+
readonly fontWeight: number;
|
|
67
|
+
readonly fontStyle: FontStyle;
|
|
68
|
+
readonly letterSpacing: number;
|
|
69
|
+
readonly lineHeight: number;
|
|
70
|
+
readonly textAlign: TextAlign;
|
|
71
|
+
readonly fill: unknown;
|
|
72
|
+
readonly stroke: unknown;
|
|
73
|
+
readonly width: SizeInput;
|
|
74
|
+
readonly height: SizeInput;
|
|
75
|
+
}
|
|
76
|
+
/** Every span flattened to a run, each field it leaves unset taken from the node. */
|
|
77
|
+
export declare function richRuns(s: RichValues): ResolvedTextSpan[];
|
|
78
|
+
/** Lines broken only at `\n`, each as tall as its tallest run; an empty node keeps one line of its own size. */
|
|
79
|
+
export declare function measureRich(s: RichValues, constraints: SizeConstraints, scope: MeasureContext2D): Size2D;
|
|
80
|
+
export declare function richState(s: RichValues, size: Size2D | undefined): Partial<RichTextState>;
|
|
81
|
+
export declare function declareRichAssets(s: RichValues, assets: Pick<AssetScope, "font" | "fill">): void;
|
|
82
|
+
//# sourceMappingURL=text-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-layout.d.ts","sourceRoot":"","sources":["../../../../src/components/builtins/text/text-layout.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { pathOps } from "../../../attributes/shape/path/ops.js";
|
|
2
|
+
import { textOps } from "../../../attributes/text/ops.js";
|
|
3
|
+
import { AUTOFIT_PROBE_SIZE } from "../../../render/descriptors/text.js";
|
|
4
|
+
export function casedText(s, src) {
|
|
5
|
+
return textOps.applyCase(src.text, s.textCase);
|
|
6
|
+
}
|
|
7
|
+
/** The block's size: hugged to its glyphs, filled across, and its own height even when it fills, so a hugging ancestor sees its content. */
|
|
8
|
+
export function measureGlyphs(s, src, constraints, scope) {
|
|
9
|
+
// Text-on-path: the visual extent is the path's bounding box, not a text
|
|
10
|
+
// line box. Size the node to the path (node-local coords, like Path).
|
|
11
|
+
if (src.glyphPath != null) {
|
|
12
|
+
const { width, height } = pathOps.size(src.glyphPath);
|
|
13
|
+
const wm = s.width;
|
|
14
|
+
const hm = s.height;
|
|
15
|
+
return {
|
|
16
|
+
width: typeof wm === "number" ? wm : wm === "hug" ? width : (constraints.maxWidth ?? width),
|
|
17
|
+
height: typeof hm === "number" ? hm : hm === "hug" ? height : (constraints.maxHeight ?? height),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const measureFontSize = s.fontSize === "autofit" ? 16 : s.fontSize;
|
|
21
|
+
const paragraphs = casedText(s, src).split("\n");
|
|
22
|
+
// A styled run changes the box, which is why measuring cannot read the
|
|
23
|
+
// node's five font fields and stop there: one word set two sizes up makes
|
|
24
|
+
// the line taller and the block wider. So when runs are styled the
|
|
25
|
+
// intrinsic size is summed across the pieces, each in its own style.
|
|
26
|
+
const styled = textSegments(s, src);
|
|
27
|
+
const lineStyles = styled === null
|
|
28
|
+
? null
|
|
29
|
+
: measureStyledLines(styled, {
|
|
30
|
+
fontFamily: s.fontFamily,
|
|
31
|
+
fontSize: measureFontSize,
|
|
32
|
+
fontStyle: s.fontStyle,
|
|
33
|
+
fontWeight: s.fontWeight,
|
|
34
|
+
letterSpacing: s.letterSpacing,
|
|
35
|
+
});
|
|
36
|
+
const lineH = measureFontSize * s.lineHeight;
|
|
37
|
+
const intrinsicW = lineStyles
|
|
38
|
+
? Math.max(...lineStyles.map(line => line.runs.reduce((w, run) => w + scope.measureText(run.text, run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width, 0)))
|
|
39
|
+
: Math.max(...paragraphs.map(l => scope.measureText(l, measureFontSize, s.fontFamily, s.fontWeight, s.letterSpacing, s.fontStyle).width));
|
|
40
|
+
const wm = s.width;
|
|
41
|
+
const hm = s.height;
|
|
42
|
+
const resolvedW = typeof wm === "number" ? wm : wm === "hug" ? intrinsicW : constraints.maxWidth ?? 0;
|
|
43
|
+
// When wrap is on and the box has a finite width narrower than the text,
|
|
44
|
+
// height needs to account for the extra lines produced by wrapping. Each
|
|
45
|
+
// line is as tall as its tallest run.
|
|
46
|
+
const wraps = src.wraps && resolvedW > 0;
|
|
47
|
+
const lineSizes = lineStyles === null
|
|
48
|
+
? null
|
|
49
|
+
: wraps
|
|
50
|
+
? wrappedLineSizes(lineStyles, resolvedW, scope)
|
|
51
|
+
: lineStyles.map(line => Math.max(...line.runs.map(run => run.fontSize)));
|
|
52
|
+
const intrinsicH = lineSizes
|
|
53
|
+
? lineSizes.reduce((h, size) => h + size * s.lineHeight, 0)
|
|
54
|
+
: (wraps
|
|
55
|
+
? paragraphs.reduce((n, p) => n + countWrappedLines(p, resolvedW, measureFontSize, s.fontFamily, s.fontWeight, scope, s.letterSpacing, s.fontStyle), 0)
|
|
56
|
+
: paragraphs.length) * lineH;
|
|
57
|
+
return { width: resolvedW, height: typeof hm === "number" ? hm : intrinsicH };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The string cut at every style boundary, each piece styled by the runs over
|
|
61
|
+
* it, the later winning. Also folds in the Write On reveal window. `null` when neither is
|
|
62
|
+
* active, so rendering keeps its single-op path; and always `null` on a path,
|
|
63
|
+
* where the string is laid along it as one run.
|
|
64
|
+
*/
|
|
65
|
+
export function textSegments(s, src) {
|
|
66
|
+
if (src.glyphPath != null)
|
|
67
|
+
return null;
|
|
68
|
+
const runs = src.runs.filter(r => r.end > r.start);
|
|
69
|
+
const text = casedText(s, src);
|
|
70
|
+
if (text.length === 0)
|
|
71
|
+
return null;
|
|
72
|
+
// Write On: a glyph has no path to trim, so `start`/`end` are a
|
|
73
|
+
// character-reveal window instead: opacity over a range of characters.
|
|
74
|
+
const hasReveal = s.start > 0 || s.end < 1;
|
|
75
|
+
if (runs.length === 0 && !hasReveal)
|
|
76
|
+
return null;
|
|
77
|
+
// A hard cut at whole characters, one at a time, the way DaVinci's Write On does.
|
|
78
|
+
const revealStart = Math.round(s.start * text.length);
|
|
79
|
+
const revealEnd = Math.round(s.end * text.length);
|
|
80
|
+
// `'autofit'` settles on a size the block is measured into, which no single
|
|
81
|
+
// piece can be asked for, so pieces shape at the probe size.
|
|
82
|
+
const nodeFontSize = typeof s.fontSize === "number" ? s.fontSize : AUTOFIT_PROBE_SIZE;
|
|
83
|
+
const fill = s.fill;
|
|
84
|
+
const stroke = s.stroke;
|
|
85
|
+
const cuts = new Set([0, text.length]);
|
|
86
|
+
for (const run of runs) {
|
|
87
|
+
cuts.add(run.start);
|
|
88
|
+
cuts.add(run.end);
|
|
89
|
+
}
|
|
90
|
+
if (hasReveal) {
|
|
91
|
+
cuts.add(revealStart);
|
|
92
|
+
cuts.add(revealEnd);
|
|
93
|
+
}
|
|
94
|
+
const points = [...cuts].filter(c => c >= 0 && c <= text.length).sort((a, b) => a - b);
|
|
95
|
+
const segments = [];
|
|
96
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
97
|
+
const start = points[i];
|
|
98
|
+
const end = points[i + 1];
|
|
99
|
+
if (end <= start)
|
|
100
|
+
continue;
|
|
101
|
+
// Every shaping field is stated, so the paragraph builder and the caret
|
|
102
|
+
// read a piece the same way.
|
|
103
|
+
const seg = {
|
|
104
|
+
text: text.slice(start, end),
|
|
105
|
+
fontFamily: s.fontFamily,
|
|
106
|
+
fontSize: nodeFontSize,
|
|
107
|
+
fontStyle: s.fontStyle,
|
|
108
|
+
fontWeight: s.fontWeight,
|
|
109
|
+
letterSpacing: s.letterSpacing,
|
|
110
|
+
textDecoration: s.textDecoration,
|
|
111
|
+
opacity: 1,
|
|
112
|
+
x: 0,
|
|
113
|
+
y: 0,
|
|
114
|
+
scale: 1,
|
|
115
|
+
rotation: 0,
|
|
116
|
+
fill,
|
|
117
|
+
stroke,
|
|
118
|
+
};
|
|
119
|
+
for (const run of runs) {
|
|
120
|
+
if (start < run.start || end > run.end)
|
|
121
|
+
continue;
|
|
122
|
+
if (run.fontFamily !== undefined)
|
|
123
|
+
seg.fontFamily = run.fontFamily;
|
|
124
|
+
if (run.fontSize !== undefined)
|
|
125
|
+
seg.fontSize = run.fontSize;
|
|
126
|
+
if (run.fontStyle !== undefined)
|
|
127
|
+
seg.fontStyle = run.fontStyle;
|
|
128
|
+
if (run.fontWeight !== undefined)
|
|
129
|
+
seg.fontWeight = run.fontWeight;
|
|
130
|
+
if (run.letterSpacing !== undefined)
|
|
131
|
+
seg.letterSpacing = run.letterSpacing;
|
|
132
|
+
if (run.textDecoration !== undefined)
|
|
133
|
+
seg.textDecoration = run.textDecoration;
|
|
134
|
+
if (run.fill !== undefined)
|
|
135
|
+
seg.fill = run.fill;
|
|
136
|
+
if (run.stroke !== undefined)
|
|
137
|
+
seg.stroke = run.stroke;
|
|
138
|
+
}
|
|
139
|
+
if (hasReveal && !(start >= revealStart && end <= revealEnd))
|
|
140
|
+
seg.opacity = 0;
|
|
141
|
+
segments.push(seg);
|
|
142
|
+
}
|
|
143
|
+
return segments;
|
|
144
|
+
}
|
|
145
|
+
/** The descriptor the block draws as, in a box of `size`. Picking's caret geometry reads the same one. */
|
|
146
|
+
export function textState(s, src, size) {
|
|
147
|
+
return {
|
|
148
|
+
text: casedText(s, src),
|
|
149
|
+
fontSize: s.fontSize,
|
|
150
|
+
fontFamily: s.fontFamily,
|
|
151
|
+
fontWeight: s.fontWeight,
|
|
152
|
+
fontStyle: s.fontStyle,
|
|
153
|
+
letterSpacing: s.letterSpacing,
|
|
154
|
+
lineHeight: s.lineHeight,
|
|
155
|
+
textAlign: s.textAlign,
|
|
156
|
+
verticalAlign: s.verticalAlign,
|
|
157
|
+
textDecoration: s.textDecoration,
|
|
158
|
+
wrap: src.wraps,
|
|
159
|
+
minFontSize: s.minFontSize,
|
|
160
|
+
width: size?.width ?? 0,
|
|
161
|
+
height: size?.height ?? 0,
|
|
162
|
+
segments: textSegments(s, src) ?? undefined,
|
|
163
|
+
path: src.glyphPath,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The node's own face, plus whatever a piece sets in another, and the pieces'
|
|
168
|
+
* paints. Naming a family here is what lets it load before layout, rather than
|
|
169
|
+
* being discovered by measuring against the fallback face.
|
|
170
|
+
*/
|
|
171
|
+
export function declareGlyphAssets(s, src, assets) {
|
|
172
|
+
// Nothing may name a family at all; an `undefined` key is not a font to load.
|
|
173
|
+
if (s.fontFamily)
|
|
174
|
+
assets.font(s.fontFamily, s.fontWeight);
|
|
175
|
+
for (const segment of textSegments(s, src) ?? []) {
|
|
176
|
+
const family = segment.fontFamily ?? s.fontFamily;
|
|
177
|
+
if (family)
|
|
178
|
+
assets.font(family, segment.fontWeight);
|
|
179
|
+
assets.fill(segment.fill ?? []);
|
|
180
|
+
for (const stroke of segment.stroke ?? [])
|
|
181
|
+
assets.fill(stroke.fill);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** The segments as lines of runs, split at every newline; an empty line keeps the node's own face. */
|
|
185
|
+
function measureStyledLines(segments, fallback) {
|
|
186
|
+
const lines = [{ runs: [] }];
|
|
187
|
+
for (const segment of segments) {
|
|
188
|
+
const style = {
|
|
189
|
+
fontFamily: segment.fontFamily ?? fallback.fontFamily,
|
|
190
|
+
fontSize: segment.fontSize ?? fallback.fontSize,
|
|
191
|
+
fontStyle: segment.fontStyle ?? fallback.fontStyle,
|
|
192
|
+
fontWeight: segment.fontWeight,
|
|
193
|
+
letterSpacing: segment.letterSpacing,
|
|
194
|
+
};
|
|
195
|
+
const parts = segment.text.split("\n");
|
|
196
|
+
for (let i = 0; i < parts.length; i++) {
|
|
197
|
+
if (i > 0)
|
|
198
|
+
lines.push({ runs: [] });
|
|
199
|
+
lines[lines.length - 1].runs.push({ text: parts[i], ...style });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
for (const line of lines) {
|
|
203
|
+
if (line.runs.length === 0)
|
|
204
|
+
line.runs.push({ ...fallback, text: "" });
|
|
205
|
+
}
|
|
206
|
+
return lines;
|
|
207
|
+
}
|
|
208
|
+
/** Each wrapped line's tallest run, breaking at whitespace the way the paragraph builder does. */
|
|
209
|
+
function wrappedLineSizes(lines, maxWidth, scope) {
|
|
210
|
+
const sizes = [];
|
|
211
|
+
for (const line of lines) {
|
|
212
|
+
const tokens = [];
|
|
213
|
+
for (const run of line.runs) {
|
|
214
|
+
for (const part of run.text.split(/(\s+)/)) {
|
|
215
|
+
if (part.length === 0)
|
|
216
|
+
continue;
|
|
217
|
+
const space = /^\s+$/.test(part);
|
|
218
|
+
const width = scope.measureText(part, run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width;
|
|
219
|
+
const last = tokens[tokens.length - 1];
|
|
220
|
+
if (last && !last.space && !space) {
|
|
221
|
+
last.width += width;
|
|
222
|
+
last.size = Math.max(last.size, run.fontSize);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
tokens.push({ width, size: run.fontSize, space });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (tokens.length === 0) {
|
|
230
|
+
sizes.push(Math.max(...line.runs.map(run => run.fontSize)));
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
let lineW = tokens[0].width;
|
|
234
|
+
let size = tokens[0].size;
|
|
235
|
+
for (const token of tokens.slice(1)) {
|
|
236
|
+
if (lineW + token.width <= maxWidth) {
|
|
237
|
+
lineW += token.width;
|
|
238
|
+
size = Math.max(size, token.size);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
sizes.push(size);
|
|
242
|
+
lineW = token.space ? 0 : token.width;
|
|
243
|
+
size = token.space ? 0 : token.size;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
sizes.push(size > 0 ? size : Math.max(...line.runs.map(run => run.fontSize)));
|
|
247
|
+
}
|
|
248
|
+
return sizes;
|
|
249
|
+
}
|
|
250
|
+
function countWrappedLines(paragraph, maxWidth, fontSize, fontFamily, fontWeight, scope, letterSpacing = 0, fontStyle = "normal") {
|
|
251
|
+
if (paragraph.length === 0)
|
|
252
|
+
return 1;
|
|
253
|
+
if (scope.measureText(paragraph, fontSize, fontFamily, fontWeight, letterSpacing, fontStyle).width <= maxWidth)
|
|
254
|
+
return 1;
|
|
255
|
+
const words = paragraph.split(/(\s+)/).filter(w => w.length > 0);
|
|
256
|
+
let lines = 1;
|
|
257
|
+
let lineW = 0;
|
|
258
|
+
for (const word of words) {
|
|
259
|
+
const w = scope.measureText(word, fontSize, fontFamily, fontWeight, letterSpacing, fontStyle).width;
|
|
260
|
+
if (lineW === 0) {
|
|
261
|
+
lineW = w;
|
|
262
|
+
}
|
|
263
|
+
else if (lineW + w <= maxWidth) {
|
|
264
|
+
lineW += w;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
lines++;
|
|
268
|
+
lineW = /^\s+$/.test(word) ? 0 : w;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return lines;
|
|
272
|
+
}
|
|
273
|
+
/** Every span flattened to a run, each field it leaves unset taken from the node. */
|
|
274
|
+
export function richRuns(s) {
|
|
275
|
+
return textOps.flatten(s.spans, {
|
|
276
|
+
fontFamily: s.fontFamily,
|
|
277
|
+
fontSize: s.fontSize,
|
|
278
|
+
fontWeight: s.fontWeight,
|
|
279
|
+
fontStyle: s.fontStyle,
|
|
280
|
+
letterSpacing: s.letterSpacing,
|
|
281
|
+
fill: s.fill,
|
|
282
|
+
stroke: s.stroke,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/** Lines broken only at `\n`, each as tall as its tallest run; an empty node keeps one line of its own size. */
|
|
286
|
+
export function measureRich(s, constraints, scope) {
|
|
287
|
+
let lineW = 0;
|
|
288
|
+
let maxLineH = 0;
|
|
289
|
+
let totalW = 0;
|
|
290
|
+
let totalH = 0;
|
|
291
|
+
const finishLine = () => {
|
|
292
|
+
if (lineW > totalW)
|
|
293
|
+
totalW = lineW;
|
|
294
|
+
totalH += maxLineH;
|
|
295
|
+
lineW = 0;
|
|
296
|
+
maxLineH = 0;
|
|
297
|
+
};
|
|
298
|
+
for (const run of richRuns(s)) {
|
|
299
|
+
const lh = run.fontSize * s.lineHeight;
|
|
300
|
+
const segments = run.text.split("\n");
|
|
301
|
+
for (let i = 0; i < segments.length; i++) {
|
|
302
|
+
if (i > 0)
|
|
303
|
+
finishLine();
|
|
304
|
+
lineW += scope.measureText(segments[i], run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width;
|
|
305
|
+
if (lh > maxLineH)
|
|
306
|
+
maxLineH = lh;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
finishLine();
|
|
310
|
+
if (totalH === 0)
|
|
311
|
+
totalH = s.fontSize * s.lineHeight;
|
|
312
|
+
const wm = s.width;
|
|
313
|
+
const hm = s.height;
|
|
314
|
+
return {
|
|
315
|
+
width: typeof wm === "number" ? wm : wm === "hug" ? totalW : constraints.maxWidth ?? 0,
|
|
316
|
+
height: typeof hm === "number" ? hm : hm === "hug" ? totalH : constraints.maxHeight ?? 0,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
export function richState(s, size) {
|
|
320
|
+
return { spans: richRuns(s), lineHeight: s.lineHeight, textAlign: s.textAlign, width: size?.width ?? 0, height: size?.height ?? 0 };
|
|
321
|
+
}
|
|
322
|
+
export function declareRichAssets(s, assets) {
|
|
323
|
+
for (const run of richRuns(s)) {
|
|
324
|
+
if (run.fontFamily)
|
|
325
|
+
assets.font(run.fontFamily, run.fontWeight);
|
|
326
|
+
assets.fill(run.fill);
|
|
327
|
+
for (const stroke of run.stroke)
|
|
328
|
+
assets.fill(stroke.fill);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
//# sourceMappingURL=text-layout.js.map
|