@motionscript/core 0.1.0-alpha.0 → 0.1.0-alpha.5
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 +282 -0
- package/LICENSE +201 -201
- package/NOTICE +48 -0
- package/README.md +93 -72
- package/dist/assets/asset-index.js.map +1 -1
- package/dist/assets/catalog.d.ts +9 -0
- package/dist/assets/catalog.d.ts.map +1 -1
- package/dist/assets/catalog.js +11 -0
- package/dist/assets/catalog.js.map +1 -1
- package/dist/assets/errors.d.ts.map +1 -1
- package/dist/assets/errors.js +8 -3
- package/dist/assets/errors.js.map +1 -1
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/manager.d.ts +26 -1
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/assets/manager.js +93 -11
- package/dist/assets/manager.js.map +1 -1
- package/dist/assets/manifest.js.map +1 -1
- package/dist/assets/record.js.map +1 -1
- package/dist/assets/scope.d.ts +3 -3
- package/dist/assets/scope.d.ts.map +1 -1
- package/dist/assets/scope.js.map +1 -1
- package/dist/attributes/audio/filters/chain.d.ts +1 -1
- package/dist/attributes/audio/filters/chain.js.map +1 -1
- package/dist/attributes/audio/filters/curve.d.ts +8 -8
- package/dist/attributes/audio/filters/curve.d.ts.map +1 -1
- package/dist/attributes/audio/filters/curve.js +20 -19
- package/dist/attributes/audio/filters/curve.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/echo.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/gain.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/highpass.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/lowpass.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/speed.d.ts +2 -2
- package/dist/attributes/audio/filters/implementations/speed.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/tremolo.js.map +1 -1
- package/dist/attributes/audio/filters/index.d.ts +1 -1
- package/dist/attributes/audio/filters/index.d.ts.map +1 -1
- package/dist/attributes/audio/filters/index.js +1 -1
- package/dist/attributes/audio/filters/index.js.map +1 -1
- package/dist/attributes/audio/filters/registry.js.map +1 -1
- package/dist/attributes/audio/filters/union.js.map +1 -1
- package/dist/attributes/audio/request.d.ts +32 -4
- package/dist/attributes/audio/request.d.ts.map +1 -1
- package/dist/attributes/audio/request.js +9 -1
- package/dist/attributes/audio/request.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +11 -2
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js +15 -8
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/audio/sound.d.ts +4 -2
- package/dist/attributes/audio/sound.d.ts.map +1 -1
- package/dist/attributes/audio/sound.js +8 -4
- package/dist/attributes/audio/sound.js.map +1 -1
- package/dist/attributes/index.d.ts +1 -0
- package/dist/attributes/index.d.ts.map +1 -1
- package/dist/attributes/index.js +1 -0
- package/dist/attributes/index.js.map +1 -1
- package/dist/attributes/layout/alignment.js +1 -1
- package/dist/attributes/layout/alignment.js.map +1 -1
- package/dist/attributes/layout/index.js.map +1 -1
- package/dist/attributes/layout/insets.js.map +1 -1
- package/dist/attributes/layout/matrix2d.js.map +1 -1
- package/dist/attributes/layout/size.js.map +1 -1
- package/dist/attributes/layout/transform3d.js.map +1 -1
- package/dist/attributes/layout/vector2.js.map +1 -1
- package/dist/attributes/layout/world-transform.js.map +1 -1
- package/dist/attributes/mask/boolean.js.map +1 -1
- package/dist/attributes/mask/mask.js.map +1 -1
- package/dist/attributes/properties/decorator.d.ts +17 -6
- package/dist/attributes/properties/decorator.d.ts.map +1 -1
- package/dist/attributes/properties/decorator.js +26 -14
- package/dist/attributes/properties/decorator.js.map +1 -1
- package/dist/attributes/properties/inputs.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +9 -2
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +15 -1
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/render3d/orbit.d.ts +8 -8
- package/dist/attributes/render3d/orbit.js +7 -7
- package/dist/attributes/render3d/orbit.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/corners/corner-style.js.map +1 -1
- package/dist/attributes/shape/corners/corners.js.map +1 -1
- package/dist/attributes/shape/corners/index.js.map +1 -1
- package/dist/attributes/shape/effects/backdrop.d.ts +4 -4
- package/dist/attributes/shape/effects/backdrop.d.ts.map +1 -1
- package/dist/attributes/shape/effects/backdrop.js.map +1 -1
- package/dist/attributes/shape/effects/chain.d.ts +28 -120
- package/dist/attributes/shape/effects/chain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/chain.js +16 -88
- package/dist/attributes/shape/effects/chain.js.map +1 -1
- package/dist/attributes/shape/effects/effect-data.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts +2 -2
- package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.d.ts +1 -1
- package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.d.ts +15 -24
- package/dist/attributes/shape/effects/implementations/glass.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.d.ts +1 -1
- package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.js +15 -8
- package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
- package/dist/attributes/shape/effects/index.d.ts +2 -6
- package/dist/attributes/shape/effects/index.d.ts.map +1 -1
- package/dist/attributes/shape/effects/index.js.map +1 -1
- package/dist/attributes/shape/effects/registry.d.ts +23 -6
- package/dist/attributes/shape/effects/registry.d.ts.map +1 -1
- package/dist/attributes/shape/effects/registry.js +44 -10
- package/dist/attributes/shape/effects/registry.js.map +1 -1
- package/dist/attributes/shape/effects/union.d.ts +2 -6
- package/dist/attributes/shape/effects/union.d.ts.map +1 -1
- package/dist/attributes/shape/effects/union.js.map +1 -1
- package/dist/attributes/shape/fill/blend.js.map +1 -1
- package/dist/attributes/shape/fill/chain.js.map +1 -1
- package/dist/attributes/shape/fill/coerce.js.map +1 -1
- package/dist/attributes/shape/fill/color/constants.js.map +1 -1
- package/dist/attributes/shape/fill/color/parser.d.ts.map +1 -1
- package/dist/attributes/shape/fill/color/parser.js +81 -44
- package/dist/attributes/shape/fill/color/parser.js.map +1 -1
- package/dist/attributes/shape/fill/gradient-stops.d.ts +16 -0
- package/dist/attributes/shape/fill/gradient-stops.d.ts.map +1 -0
- package/dist/attributes/shape/fill/gradient-stops.js +65 -0
- package/dist/attributes/shape/fill/gradient-stops.js.map +1 -0
- package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/color.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/conic-gradient.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/conic-gradient.js +2 -5
- package/dist/attributes/shape/fill/implementations/conic-gradient.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/dot-grid.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.js +2 -10
- package/dist/attributes/shape/fill/implementations/fractal-noise.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/grid.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/image.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/image.js +5 -4
- package/dist/attributes/shape/fill/implementations/image.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/linear-gradient.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/linear-gradient.js +2 -6
- package/dist/attributes/shape/fill/implementations/linear-gradient.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/noise.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/radial-gradient.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/radial-gradient.js +2 -5
- package/dist/attributes/shape/fill/implementations/radial-gradient.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/stripe.js.map +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/index.js.map +1 -1
- package/dist/attributes/shape/fill/lerp.d.ts +9 -1
- package/dist/attributes/shape/fill/lerp.d.ts.map +1 -1
- package/dist/attributes/shape/fill/lerp.js +12 -1
- package/dist/attributes/shape/fill/lerp.js.map +1 -1
- package/dist/attributes/shape/fill/media-preset.js.map +1 -1
- package/dist/attributes/shape/fill/registry.js.map +1 -1
- package/dist/attributes/shape/fill/union.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +4 -10
- package/dist/attributes/shape/filters/chain.d.ts.map +1 -1
- package/dist/attributes/shape/filters/chain.js +1 -13
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/alpha.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/blur.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-adjustment.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-matrix.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/echo.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/exposure.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/grayscale.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/posterize-time.js.map +1 -1
- package/dist/attributes/shape/filters/index.d.ts +1 -1
- package/dist/attributes/shape/filters/index.js.map +1 -1
- package/dist/attributes/shape/filters/registry.d.ts +2 -2
- package/dist/attributes/shape/filters/registry.js +3 -3
- package/dist/attributes/shape/filters/registry.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +6 -7
- 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/anchors.d.ts.map +1 -1
- package/dist/attributes/shape/path/anchors.js +12 -5
- package/dist/attributes/shape/path/anchors.js.map +1 -1
- package/dist/attributes/shape/path/bezier.js.map +1 -1
- package/dist/attributes/shape/path/index.js.map +1 -1
- package/dist/attributes/shape/path/measure.js.map +1 -1
- package/dist/attributes/shape/path/morph.d.ts.map +1 -1
- package/dist/attributes/shape/path/morph.js +16 -4
- package/dist/attributes/shape/path/morph.js.map +1 -1
- package/dist/attributes/shape/path/ops.js.map +1 -1
- package/dist/attributes/shape/path/types.js.map +1 -1
- package/dist/attributes/shape/path/walk.js.map +1 -1
- package/dist/attributes/shape/shaders/index.js.map +1 -1
- package/dist/attributes/shape/shaders/pack.js.map +1 -1
- package/dist/attributes/shape/shaders/resolve.js.map +1 -1
- package/dist/attributes/shape/shadow/index.js.map +1 -1
- package/dist/attributes/shape/shadow/shadow.js.map +1 -1
- package/dist/attributes/shape/stroke/index.d.ts +2 -2
- package/dist/attributes/shape/stroke/index.d.ts.map +1 -1
- package/dist/attributes/shape/stroke/index.js +1 -1
- package/dist/attributes/shape/stroke/index.js.map +1 -1
- package/dist/attributes/shape/stroke/stroke.d.ts +27 -6
- package/dist/attributes/shape/stroke/stroke.d.ts.map +1 -1
- package/dist/attributes/shape/stroke/stroke.js +22 -2
- package/dist/attributes/shape/stroke/stroke.js.map +1 -1
- package/dist/attributes/shared/operators.js.map +1 -1
- package/dist/attributes/text/index.js.map +1 -1
- package/dist/attributes/text/ops.d.ts +6 -0
- package/dist/attributes/text/ops.d.ts.map +1 -1
- package/dist/attributes/text/ops.js +1 -0
- package/dist/attributes/text/ops.js.map +1 -1
- package/dist/attributes/text/types.js.map +1 -1
- package/dist/browser/chunks/chunk-FUZVFT3W.js +18 -0
- package/dist/browser/chunks/chunk-FUZVFT3W.js.map +7 -0
- package/dist/browser/chunks/chunk-QG6C23IJ.js +3 -0
- package/dist/browser/chunks/chunk-QG6C23IJ.js.map +7 -0
- package/dist/browser/chunks/chunk-SFNJRPBV.js +2 -0
- package/dist/browser/chunks/chunk-SFNJRPBV.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/component.js.map +3 -3
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/jsx-jsx-dev-runtime.js +1 -1
- package/dist/browser/jsx-jsx-runtime.js +1 -1
- package/dist/browser/manifest.json +3 -2
- package/dist/browser/sdk.js +1 -1
- package/dist/component.js.map +1 -1
- package/dist/document/audio.d.ts +1 -1
- package/dist/document/audio.js +4 -4
- package/dist/document/audio.js.map +1 -1
- package/dist/document/builtins.d.ts.map +1 -1
- package/dist/document/builtins.js +8 -14
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +1 -1
- package/dist/document/command-traits.d.ts.map +1 -1
- package/dist/document/command-traits.js +17 -3
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/deny-globals.js.map +1 -1
- package/dist/document/diff.js.map +1 -1
- package/dist/document/doc-index.d.ts +2 -2
- package/dist/document/doc-index.d.ts.map +1 -1
- package/dist/document/doc-index.js.map +1 -1
- package/dist/document/expression/compile.d.ts.map +1 -1
- package/dist/document/expression/compile.js +8 -5
- package/dist/document/expression/compile.js.map +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/expression/parse.d.ts.map +1 -1
- package/dist/document/expression/parse.js +15 -6
- package/dist/document/expression/parse.js.map +1 -1
- package/dist/document/expression/refs.d.ts +1 -1
- package/dist/document/expression/refs.js +1 -1
- package/dist/document/expression/refs.js.map +1 -1
- package/dist/document/expression/types.js.map +1 -1
- package/dist/document/expression/walk.d.ts.map +1 -1
- package/dist/document/expression/walk.js +2 -1
- package/dist/document/expression/walk.js.map +1 -1
- package/dist/document/index.d.ts +2 -0
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/index.js +2 -0
- package/dist/document/index.js.map +1 -1
- package/dist/document/node-decorator.js.map +1 -1
- package/dist/document/node-descriptor.d.ts +19 -0
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/placement.d.ts +70 -0
- package/dist/document/placement.d.ts.map +1 -0
- package/dist/document/placement.js +83 -0
- package/dist/document/placement.js.map +1 -0
- package/dist/document/project.d.ts +2 -2
- package/dist/document/project.d.ts.map +1 -1
- package/dist/document/project.js.map +1 -1
- package/dist/document/registry.d.ts +34 -16
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +51 -12
- package/dist/document/registry.js.map +1 -1
- package/dist/document/timeline-patch.js.map +1 -1
- package/dist/document/timeline.d.ts +73 -18
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +192 -40
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +12 -12
- package/dist/document/types.d.ts.map +1 -1
- package/dist/document/types.js +2 -2
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +2 -2
- package/dist/document/validate.d.ts.map +1 -1
- package/dist/document/validate.js +37 -31
- package/dist/document/validate.js.map +1 -1
- package/dist/document/withdraw.d.ts +28 -0
- package/dist/document/withdraw.d.ts.map +1 -0
- package/dist/document/withdraw.js +61 -0
- package/dist/document/withdraw.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx/jsx-runtime.d.ts +9 -1
- package/dist/jsx/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx/jsx-runtime.js +13 -3
- package/dist/jsx/jsx-runtime.js.map +1 -1
- package/dist/layout/bounds.d.ts +0 -1
- package/dist/layout/bounds.d.ts.map +1 -1
- package/dist/layout/bounds.js.map +1 -1
- package/dist/layout/constraints.js.map +1 -1
- package/dist/layout/flex.d.ts +4 -2
- package/dist/layout/flex.d.ts.map +1 -1
- package/dist/layout/flex.js +27 -11
- package/dist/layout/flex.js.map +1 -1
- package/dist/layout/freeform.js.map +1 -1
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/index.js.map +1 -1
- package/dist/layout/item.js.map +1 -1
- package/dist/layout/ops.d.ts +6 -0
- package/dist/layout/ops.d.ts.map +1 -1
- package/dist/layout/ops.js +6 -0
- package/dist/layout/ops.js.map +1 -1
- package/dist/layout/types.js.map +1 -1
- package/dist/nodes/2d/node-lifecycle.js.map +1 -1
- package/dist/nodes/2d/node-motion.js.map +1 -1
- package/dist/nodes/2d/node-render.d.ts +3 -3
- package/dist/nodes/2d/node-render.d.ts.map +1 -1
- package/dist/nodes/2d/node-render.js.map +1 -1
- package/dist/nodes/2d/node-transform.js.map +1 -1
- package/dist/nodes/2d/node2d.d.ts +115 -3
- package/dist/nodes/2d/node2d.d.ts.map +1 -1
- package/dist/nodes/2d/node2d.js +188 -32
- package/dist/nodes/2d/node2d.js.map +1 -1
- package/dist/nodes/2d/paint-node.d.ts +27 -0
- package/dist/nodes/2d/paint-node.d.ts.map +1 -1
- package/dist/nodes/2d/paint-node.js +42 -0
- package/dist/nodes/2d/paint-node.js.map +1 -1
- package/dist/nodes/audio/audio-bus.js.map +1 -1
- package/dist/nodes/audio/index.js.map +1 -1
- package/dist/nodes/audio/node-audio.d.ts +3 -2
- package/dist/nodes/audio/node-audio.d.ts.map +1 -1
- package/dist/nodes/audio/node-audio.js +8 -5
- package/dist/nodes/audio/node-audio.js.map +1 -1
- package/dist/nodes/audio/sound-node.d.ts +2 -2
- package/dist/nodes/audio/sound-node.d.ts.map +1 -1
- package/dist/nodes/audio/sound-node.js +2 -2
- package/dist/nodes/audio/sound-node.js.map +1 -1
- package/dist/nodes/geometry/bounds-shape-node.d.ts +4 -4
- package/dist/nodes/geometry/bounds-shape-node.js +2 -2
- package/dist/nodes/geometry/bounds-shape-node.js.map +1 -1
- package/dist/nodes/geometry/box-path-node.d.ts +3 -3
- package/dist/nodes/geometry/box-path-node.js +2 -2
- package/dist/nodes/geometry/box-path-node.js.map +1 -1
- package/dist/nodes/geometry/ellipse-node.js.map +1 -1
- package/dist/nodes/geometry/group-bounds.d.ts +2 -2
- package/dist/nodes/geometry/group-bounds.d.ts.map +1 -1
- package/dist/nodes/geometry/group-bounds.js +1 -2
- package/dist/nodes/geometry/group-bounds.js.map +1 -1
- package/dist/nodes/geometry/path-node.d.ts.map +1 -1
- package/dist/nodes/geometry/path-node.js +6 -0
- package/dist/nodes/geometry/path-node.js.map +1 -1
- package/dist/nodes/geometry/polygon-node.js.map +1 -1
- package/dist/nodes/geometry/polygram-node.js.map +1 -1
- package/dist/nodes/geometry/rect-node.js.map +1 -1
- package/dist/nodes/geometry/shape-node.js.map +1 -1
- package/dist/nodes/geometry/shape-outline.d.ts +2 -2
- package/dist/nodes/geometry/shape-outline.d.ts.map +1 -1
- package/dist/nodes/geometry/shape-outline.js +2 -13
- package/dist/nodes/geometry/shape-outline.js.map +1 -1
- package/dist/nodes/index.d.ts +3 -8
- package/dist/nodes/index.d.ts.map +1 -1
- package/dist/nodes/index.js +3 -8
- package/dist/nodes/index.js.map +1 -1
- package/dist/nodes/layout/camera-node.d.ts +9 -0
- package/dist/nodes/layout/camera-node.d.ts.map +1 -1
- package/dist/nodes/layout/camera-node.js +38 -3
- package/dist/nodes/layout/camera-node.js.map +1 -1
- package/dist/nodes/layout/orbit-camera-node.d.ts +1 -1
- package/dist/nodes/layout/orbit-camera-node.js +1 -1
- package/dist/nodes/layout/orbit-camera-node.js.map +1 -1
- package/dist/nodes/layout/rotated-box.js.map +1 -1
- package/dist/nodes/media/video-node.d.ts.map +1 -1
- package/dist/nodes/media/video-node.js +5 -3
- package/dist/nodes/media/video-node.js.map +1 -1
- package/dist/nodes/node/declare-paints.js.map +1 -1
- package/dist/nodes/node/node-editor-state.js.map +1 -1
- package/dist/nodes/node/node-reactive.js.map +1 -1
- package/dist/nodes/node/node-time.d.ts +3 -3
- package/dist/nodes/node/node-time.d.ts.map +1 -1
- package/dist/nodes/node/node-time.js +1 -1
- package/dist/nodes/node/node-time.js.map +1 -1
- package/dist/nodes/node/node-walk.js.map +1 -1
- package/dist/nodes/node/node.d.ts +5 -3
- package/dist/nodes/node/node.d.ts.map +1 -1
- package/dist/nodes/node/node.js +44 -19
- package/dist/nodes/node/node.js.map +1 -1
- package/dist/nodes/node/text-defaults.d.ts +10 -12
- package/dist/nodes/node/text-defaults.d.ts.map +1 -1
- package/dist/nodes/node/text-defaults.js +10 -12
- package/dist/nodes/node/text-defaults.js.map +1 -1
- package/dist/nodes/{scene → root}/canvas2d-node.d.ts +2 -2
- package/dist/nodes/root/canvas2d-node.d.ts.map +1 -0
- package/dist/nodes/{scene → root}/canvas2d-node.js +2 -2
- package/dist/nodes/root/canvas2d-node.js.map +1 -0
- package/dist/nodes/root/provider-node.d.ts.map +1 -0
- package/dist/nodes/root/provider-node.js.map +1 -0
- package/dist/nodes/root/theme-provider-node.d.ts.map +1 -0
- package/dist/nodes/root/theme-provider-node.js.map +1 -0
- package/dist/nodes/text/default-text-style-node.d.ts +5 -2
- package/dist/nodes/text/default-text-style-node.d.ts.map +1 -1
- package/dist/nodes/text/default-text-style-node.js +10 -4
- package/dist/nodes/text/default-text-style-node.js.map +1 -1
- package/dist/nodes/text/number-format.d.ts +1 -1
- package/dist/nodes/text/number-format.js +1 -1
- package/dist/nodes/text/number-format.js.map +1 -1
- package/dist/nodes/text/number-node.js.map +1 -1
- package/dist/nodes/text/number-pattern.js.map +1 -1
- package/dist/nodes/text/richtext-node.js +1 -1
- package/dist/nodes/text/richtext-node.js.map +1 -1
- package/dist/nodes/text/text-base.d.ts.map +1 -1
- package/dist/nodes/text/text-base.js +1 -1
- package/dist/nodes/text/text-base.js.map +1 -1
- package/dist/nodes/text/text-node.js.map +1 -1
- package/dist/nodes/text/text-selection.js.map +1 -1
- package/dist/nodes/three/camera-nodes.d.ts +21 -3
- package/dist/nodes/three/camera-nodes.d.ts.map +1 -1
- package/dist/nodes/three/camera-nodes.js +42 -1
- package/dist/nodes/three/camera-nodes.js.map +1 -1
- package/dist/nodes/three/canvas3d-node.d.ts +29 -6
- package/dist/nodes/three/canvas3d-node.d.ts.map +1 -1
- package/dist/nodes/three/canvas3d-node.js +44 -2
- package/dist/nodes/three/canvas3d-node.js.map +1 -1
- package/dist/nodes/three/drawable-nodes.d.ts +25 -11
- package/dist/nodes/three/drawable-nodes.d.ts.map +1 -1
- package/dist/nodes/three/drawable-nodes.js +43 -13
- package/dist/nodes/three/drawable-nodes.js.map +1 -1
- package/dist/nodes/three/environment-nodes.d.ts +9 -3
- package/dist/nodes/three/environment-nodes.d.ts.map +1 -1
- package/dist/nodes/three/environment-nodes.js.map +1 -1
- package/dist/nodes/three/geometry-nodes.d.ts +2 -2
- package/dist/nodes/three/geometry-nodes.js +2 -2
- package/dist/nodes/three/geometry-nodes.js.map +1 -1
- package/dist/nodes/three/grid-geometry3d.js.map +1 -1
- package/dist/nodes/three/group3d.js.map +1 -1
- package/dist/nodes/three/light-nodes.d.ts.map +1 -1
- package/dist/nodes/three/light-nodes.js +3 -3
- package/dist/nodes/three/light-nodes.js.map +1 -1
- package/dist/nodes/three/mesh3d.js.map +1 -1
- package/dist/nodes/three/node3d.d.ts +48 -0
- package/dist/nodes/three/node3d.d.ts.map +1 -1
- package/dist/nodes/three/node3d.js +53 -3
- package/dist/nodes/three/node3d.js.map +1 -1
- package/dist/platform/audio-sink.d.ts +2 -2
- package/dist/platform/audio-sink.d.ts.map +1 -1
- package/dist/platform/audio-sink.js.map +1 -1
- package/dist/platform/exporter.d.ts +13 -8
- package/dist/platform/exporter.d.ts.map +1 -1
- package/dist/platform/exporter.js.map +1 -1
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/stepped-clock.js.map +1 -1
- package/dist/platform/storage-adapter.d.ts +12 -6
- package/dist/platform/storage-adapter.d.ts.map +1 -1
- package/dist/platform/storage-adapter.js +4 -0
- package/dist/platform/storage-adapter.js.map +1 -1
- package/dist/platform/ticker.d.ts +6 -0
- package/dist/platform/ticker.d.ts.map +1 -1
- package/dist/platform/ticker.js +6 -0
- package/dist/platform/ticker.js.map +1 -1
- package/dist/project/config.js.map +1 -1
- package/dist/project/index.js.map +1 -1
- package/dist/project/tree.d.ts +3 -3
- package/dist/project/tree.d.ts.map +1 -1
- package/dist/project/tree.js.map +1 -1
- package/dist/props/host.js.map +1 -1
- package/dist/props/index.js.map +1 -1
- package/dist/props/observer.js.map +1 -1
- package/dist/props/slot.js.map +1 -1
- package/dist/renamed-scene-names.d.ts +17 -0
- package/dist/renamed-scene-names.d.ts.map +1 -0
- package/dist/renamed-scene-names.js +9 -0
- package/dist/renamed-scene-names.js.map +1 -0
- package/dist/render/canvas-render-context2d.d.ts +10 -3
- package/dist/render/canvas-render-context2d.d.ts.map +1 -1
- package/dist/render/canvas-render-context2d.js +10 -0
- package/dist/render/canvas-render-context2d.js.map +1 -1
- package/dist/render/clip-contains.js.map +1 -1
- package/dist/render/clip.js.map +1 -1
- package/dist/render/descriptors/ellipse.js.map +1 -1
- package/dist/render/descriptors/latex.js.map +1 -1
- package/dist/render/descriptors/line.js.map +1 -1
- package/dist/render/descriptors/path-builder.js.map +1 -1
- package/dist/render/descriptors/path.js.map +1 -1
- package/dist/render/descriptors/polygon.js.map +1 -1
- package/dist/render/descriptors/polygram.js.map +1 -1
- package/dist/render/descriptors/rect.js.map +1 -1
- package/dist/render/descriptors/richtext.js.map +1 -1
- package/dist/render/descriptors/shape.d.ts +12 -0
- package/dist/render/descriptors/shape.d.ts.map +1 -1
- package/dist/render/descriptors/shape.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +2 -2
- package/dist/render/descriptors/text.js +2 -2
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/descriptors/transform.d.ts +2 -2
- package/dist/render/descriptors/transform.d.ts.map +1 -1
- package/dist/render/descriptors/transform.js.map +1 -1
- package/dist/render/graphics2d.d.ts +3 -3
- package/dist/render/graphics2d.d.ts.map +1 -1
- package/dist/render/graphics2d.js +1 -1
- package/dist/render/graphics2d.js.map +1 -1
- package/dist/render/index.js.map +1 -1
- package/dist/render/measure-context.js.map +1 -1
- package/dist/render/null-render-context.js.map +1 -1
- package/dist/render/render-context2d.d.ts +5 -5
- package/dist/render/render-context2d.d.ts.map +1 -1
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render/surface.js.map +1 -1
- package/dist/render/text-defaults.js.map +1 -1
- package/dist/render/text-layout.js.map +1 -1
- package/dist/render3d/bounds3d.d.ts.map +1 -1
- package/dist/render3d/bounds3d.js +4 -2
- package/dist/render3d/bounds3d.js.map +1 -1
- package/dist/render3d/builders.js.map +1 -1
- package/dist/render3d/camera.d.ts +6 -0
- package/dist/render3d/camera.d.ts.map +1 -1
- package/dist/render3d/camera.js +5 -3
- package/dist/render3d/camera.js.map +1 -1
- package/dist/render3d/fill3d.d.ts +2 -9
- package/dist/render3d/fill3d.d.ts.map +1 -1
- package/dist/render3d/fill3d.js +2 -13
- package/dist/render3d/fill3d.js.map +1 -1
- package/dist/render3d/geometry.d.ts +8 -1
- package/dist/render3d/geometry.d.ts.map +1 -1
- package/dist/render3d/geometry.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts +8 -4
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +18 -10
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/render3d/index.d.ts +1 -1
- package/dist/render3d/index.js +1 -1
- package/dist/render3d/index.js.map +1 -1
- package/dist/render3d/inert.d.ts +14 -0
- package/dist/render3d/inert.d.ts.map +1 -0
- package/dist/render3d/inert.js +62 -0
- package/dist/render3d/inert.js.map +1 -0
- package/dist/render3d/light.js.map +1 -1
- package/dist/render3d/material.d.ts +10 -5
- package/dist/render3d/material.d.ts.map +1 -1
- package/dist/render3d/material.js.map +1 -1
- package/dist/render3d/matrix4.js.map +1 -1
- package/dist/render3d/render-context3d.js.map +1 -1
- package/dist/render3d/resources.d.ts +2 -2
- package/dist/render3d/resources.js +2 -2
- package/dist/render3d/resources.js.map +1 -1
- package/dist/render3d/rounded-box.js.map +1 -1
- package/dist/render3d/scene-settings.d.ts +23 -4
- package/dist/render3d/scene-settings.d.ts.map +1 -1
- package/dist/render3d/scene-settings.js.map +1 -1
- package/dist/render3d/scene3d.d.ts +11 -0
- package/dist/render3d/scene3d.d.ts.map +1 -1
- package/dist/render3d/scene3d.js +39 -6
- package/dist/render3d/scene3d.js.map +1 -1
- package/dist/render3d/segments.js.map +1 -1
- package/dist/render3d/texture.d.ts +9 -0
- package/dist/render3d/texture.d.ts.map +1 -1
- package/dist/render3d/texture.js +13 -0
- package/dist/render3d/texture.js.map +1 -1
- package/dist/render3d/tracking.js.map +1 -1
- package/dist/render3d/transform.d.ts +1 -1
- package/dist/render3d/transform.js.map +1 -1
- package/dist/render3d/vector3.d.ts +18 -1
- package/dist/render3d/vector3.d.ts.map +1 -1
- package/dist/render3d/vector3.js +27 -0
- package/dist/render3d/vector3.js.map +1 -1
- package/dist/render3d/walk.d.ts +1 -1
- package/dist/render3d/walk.d.ts.map +1 -1
- package/dist/render3d/walk.js +5 -1
- package/dist/render3d/walk.js.map +1 -1
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-timeline.js.map +1 -1
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/audio-index.d.ts +2 -2
- package/dist/runtime/audio-index.d.ts.map +1 -1
- package/dist/runtime/audio-index.js +8 -2
- package/dist/runtime/audio-index.js.map +1 -1
- package/dist/runtime/builtin-context.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +5 -3
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +10 -6
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +9 -0
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +33 -3
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +5 -0
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +2 -0
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/frame-time.d.ts +31 -0
- package/dist/runtime/frame-time.d.ts.map +1 -0
- package/dist/runtime/frame-time.js +29 -0
- package/dist/runtime/frame-time.js.map +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/node-picking.d.ts +44 -3
- package/dist/runtime/node-picking.d.ts.map +1 -1
- package/dist/runtime/node-picking.js +118 -3
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +2 -1
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +5 -2
- package/dist/runtime/node-picking3d.js.map +1 -1
- package/dist/runtime/placement.d.ts.map +1 -1
- package/dist/runtime/placement.js +4 -5
- package/dist/runtime/placement.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts +31 -2
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +63 -6
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/playback.js.map +1 -1
- package/dist/runtime/precompisition.js.map +1 -1
- package/dist/runtime/project-assets.js.map +1 -1
- package/dist/runtime/session.d.ts +9 -7
- package/dist/runtime/session.d.ts.map +1 -1
- package/dist/runtime/session.js +12 -4
- package/dist/runtime/session.js.map +1 -1
- package/dist/runtime/settle.js.map +1 -1
- package/dist/runtime/state-evaluator.d.ts +1 -1
- package/dist/runtime/state-evaluator.d.ts.map +1 -1
- package/dist/runtime/state-evaluator.js +4 -3
- package/dist/runtime/state-evaluator.js.map +1 -1
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +27 -22
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +23 -9
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +12 -4
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js +10 -22
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/command.js.map +1 -1
- package/dist/tween/ease/constants.d.ts.map +1 -1
- package/dist/tween/ease/constants.js +8 -5
- package/dist/tween/ease/constants.js.map +1 -1
- package/dist/tween/ease/curve.d.ts.map +1 -1
- package/dist/tween/ease/curve.js +4 -3
- package/dist/tween/ease/curve.js.map +1 -1
- package/dist/tween/ease/describe.d.ts +15 -0
- package/dist/tween/ease/describe.d.ts.map +1 -0
- package/dist/tween/ease/describe.js +37 -0
- package/dist/tween/ease/describe.js.map +1 -0
- package/dist/tween/ease/type.js.map +1 -1
- package/dist/tween/index.js.map +1 -1
- package/dist/tween/inert.js.map +1 -1
- package/dist/tween/lerp.js.map +1 -1
- package/dist/tween/loop.js.map +1 -1
- package/dist/tween/prepare.d.ts +3 -3
- package/dist/tween/prepare.js +3 -3
- package/dist/tween/prepare.js.map +1 -1
- package/dist/tween/seekable.d.ts +12 -1
- package/dist/tween/seekable.d.ts.map +1 -1
- package/dist/tween/seekable.js +15 -0
- package/dist/tween/seekable.js.map +1 -1
- package/dist/tween/stepper.js.map +1 -1
- package/dist/tween/to-command.js.map +1 -1
- package/dist/util/clamp.js.map +1 -1
- package/dist/util/context.js.map +1 -1
- package/dist/util/csv.js.map +1 -1
- package/dist/util/generateList.js.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/metrics.d.ts +1 -1
- package/dist/util/metrics.js +1 -1
- package/dist/util/metrics.js.map +1 -1
- package/dist/util/random.js.map +1 -1
- package/dist/util/reference.js.map +1 -1
- package/dist/util/scheduler.js.map +1 -1
- package/package.json +2 -1
- package/dist/attributes/shape/effects/implementations/displace.d.ts +0 -48
- package/dist/attributes/shape/effects/implementations/displace.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/displace.js +0 -30
- package/dist/attributes/shape/effects/implementations/displace.js.map +0 -1
- package/dist/attributes/shape/effects/implementations/god-rays.d.ts +0 -28
- package/dist/attributes/shape/effects/implementations/god-rays.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/god-rays.js +0 -26
- package/dist/attributes/shape/effects/implementations/god-rays.js.map +0 -1
- package/dist/attributes/shape/effects/implementations/texture.d.ts +0 -28
- package/dist/attributes/shape/effects/implementations/texture.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/texture.js +0 -25
- package/dist/attributes/shape/effects/implementations/texture.js.map +0 -1
- package/dist/attributes/shape/effects/implementations/trails.d.ts +0 -41
- package/dist/attributes/shape/effects/implementations/trails.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/trails.js +0 -22
- package/dist/attributes/shape/effects/implementations/trails.js.map +0 -1
- package/dist/browser/chunks/chunk-2T3HXSC2.js +0 -2
- package/dist/browser/chunks/chunk-2T3HXSC2.js.map +0 -7
- package/dist/browser/chunks/chunk-P3XQCHDW.js +0 -16
- package/dist/browser/chunks/chunk-P3XQCHDW.js.map +0 -7
- package/dist/browser/chunks/chunk-VJQMKHGQ.js +0 -3
- package/dist/browser/chunks/chunk-VJQMKHGQ.js.map +0 -7
- package/dist/nodes/geometry/dot-grid-node.d.ts +0 -105
- package/dist/nodes/geometry/dot-grid-node.d.ts.map +0 -1
- package/dist/nodes/geometry/dot-grid-node.js +0 -142
- package/dist/nodes/geometry/dot-grid-node.js.map +0 -1
- package/dist/nodes/geometry/grid-lines.d.ts +0 -101
- package/dist/nodes/geometry/grid-lines.d.ts.map +0 -1
- package/dist/nodes/geometry/grid-lines.js +0 -128
- package/dist/nodes/geometry/grid-lines.js.map +0 -1
- package/dist/nodes/geometry/grid-pattern-node.d.ts +0 -58
- package/dist/nodes/geometry/grid-pattern-node.d.ts.map +0 -1
- package/dist/nodes/geometry/grid-pattern-node.js +0 -172
- package/dist/nodes/geometry/grid-pattern-node.js.map +0 -1
- package/dist/nodes/geometry/line-grid-node.d.ts +0 -62
- package/dist/nodes/geometry/line-grid-node.d.ts.map +0 -1
- package/dist/nodes/geometry/line-grid-node.js +0 -127
- package/dist/nodes/geometry/line-grid-node.js.map +0 -1
- package/dist/nodes/geometry/line-node.d.ts +0 -58
- package/dist/nodes/geometry/line-node.d.ts.map +0 -1
- package/dist/nodes/geometry/line-node.js +0 -123
- package/dist/nodes/geometry/line-node.js.map +0 -1
- package/dist/nodes/geometry/viewport-pattern-node.d.ts +0 -39
- package/dist/nodes/geometry/viewport-pattern-node.d.ts.map +0 -1
- package/dist/nodes/geometry/viewport-pattern-node.js +0 -79
- package/dist/nodes/geometry/viewport-pattern-node.js.map +0 -1
- package/dist/nodes/scene/canvas2d-node.d.ts.map +0 -1
- package/dist/nodes/scene/canvas2d-node.js.map +0 -1
- package/dist/nodes/scene/provider-node.d.ts.map +0 -1
- package/dist/nodes/scene/provider-node.js.map +0 -1
- package/dist/nodes/scene/theme-provider-node.d.ts.map +0 -1
- package/dist/nodes/scene/theme-provider-node.js.map +0 -1
- /package/dist/nodes/{scene → root}/provider-node.d.ts +0 -0
- /package/dist/nodes/{scene → root}/provider-node.js +0 -0
- /package/dist/nodes/{scene → root}/theme-provider-node.d.ts +0 -0
- /package/dist/nodes/{scene → root}/theme-provider-node.js +0 -0
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* | `0` | `1235` | `0` |
|
|
18
18
|
* | `$#,##0.00` | `$1,234.50` | `$0.07` |
|
|
19
19
|
* | `0.#%` | `123450%` | `7%` |
|
|
20
|
-
* | `#,##0 kg` | `1,
|
|
20
|
+
* | `#,##0 kg` | `1,235 kg` | `0 kg` |
|
|
21
21
|
*
|
|
22
22
|
* - `0` is a digit that is always written, `#` one that is written only when
|
|
23
23
|
* the number needs it. So `0.00` pads to two decimals and `0.##` trims.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* | `0` | `1235` | `0` |
|
|
18
18
|
* | `$#,##0.00` | `$1,234.50` | `$0.07` |
|
|
19
19
|
* | `0.#%` | `123450%` | `7%` |
|
|
20
|
-
* | `#,##0 kg` | `1,
|
|
20
|
+
* | `#,##0 kg` | `1,235 kg` | `0 kg` |
|
|
21
21
|
*
|
|
22
22
|
* - `0` is a digit that is always written, `#` one that is written only when
|
|
23
23
|
* the number needs it. So `0.00` pads to two decimals and `0.##` trims.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-format.js","sourceRoot":"","sources":["../../../src/nodes/text/number-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAKH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwD;IAClF,0EAA0E;IAC1E,4EAA4E;IAC5E,qEAAqE;IACrE,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,UAAU;IAClB,QAAQ,EAAE,WAAW;IACrB,OAAO,EAAE,UAAU;CACpB,CAAA;AAiBD,8EAA8E;AAC9E,MAAM,cAAc,GAAkB;IACpC,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,KAAK;CACf,CAAA;AAED,iFAAiF;AACjF,SAAS,IAAI,CAAC,IAAY,EAAE,KAA4C;IACtE,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,KAAK,MAAM,EAAE,IAAI,IAAI,E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AG,CAAC,CAAA;IAEZ,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChD,yEAAyE;IACzE,IAAI,IAAI,GAAG,OAAO,CAAA;IAClB,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAE9E,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IAClF,MAAM,IAAI,GAAG,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IACzD,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,CAAA;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,MAAoC,EACpC,MAA0B;IAE1B,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QACpC,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;IACzD,CAAC;IACD,OAAO,eAAe,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,eAAe,CAAC,KAAK,CAAA;AACpE,CAAC","sourcesContent":["/**\n * How a chart writes a number down.\n *\n * One formatter, driven by a **pattern**, and the named formats are patterns\n * too — `currency` is `$#,##0.00` and nothing more. That is the whole design:\n * a dropdown of four presets and a free-text pattern are otherwise two features\n * that drift, one of them gaining a thousands separator or a negative sign the\n * other never hears about. Here the preset *is* the custom case with the\n * pattern filled in, so there is one set of rules to get right.\n *\n * The grammar is the spreadsheet one, because that is where the numbers come\n * from and what an author already knows:\n *\n * | Pattern | 1234.5 | 0.07 |\n * | ------------ | --------- | ------ |\n * | `#,##0.##` | `1,234.5` | `0.07` |\n * | `0` | `1235` | `0` |\n * | `$#,##0.00` | `$1,234.50` | `$0.07` |\n * | `0.#%` | `123450%` | `7%` |\n * | `#,##0 kg` | `1,234 kg` | `0 kg` |\n *\n * - `0` is a digit that is always written, `#` one that is written only when\n * the number needs it. So `0.00` pads to two decimals and `0.##` trims.\n * - A `,` anywhere in the integer run turns grouping on; where it sits doesn't\n * matter, since `#,##0` and `#,###,##0` mean the same thing to everyone who\n * writes them.\n * - `%` scales by 100 as well as printing — that is what makes it a percent\n * rather than a suffix, and it is why `0.07` under `0.#%` is `7%`. A column\n * that is *already* in percent points wants `#,##0'%'`: quoted, so the sign\n * is printed and nothing is scaled.\n * - Anything else is literal, before the digits or after them. Quote it to be\n * sure — `'#'#,##0` prints a leading hash.\n *\n * Deliberately **not** `Intl.NumberFormat`. Its output is locale-dependent, and\n * a chart is a picture with a fixed layout: the same project rendering\n * `1,234.50` on the author's machine and `1.234,50` on the export box is a\n * silently different image, and the wider string can reflow an axis. What an\n * author wants here is the format they *typed*.\n */\n\n/** The named formats the inspector offers, plus the escape hatch. */\nexport type NumberFormatName = \"plain\" | \"number\" | \"currency\" | \"percent\" | \"custom\"\n\n/**\n * The pattern behind each named format.\n *\n * `plain` is the historic behaviour — integers bare, everything else to one\n * decimal — kept as the default so no existing chart re-labels itself. The rest\n * are the three formats a chart of money, counts or shares actually needs.\n */\nexport const NUMBER_PATTERNS: Record<Exclude<NumberFormatName, \"custom\">, string> = {\n // Ungrouped on purpose: this is what `formatMarker` did before there were\n // formats at all, and it is the default, so every chart already drawn keeps\n // the labels it has. Grouping is what the reader picks `number` for.\n plain: \"#.#\",\n number: \"#,##0.##\",\n currency: \"$#,##0.00\",\n percent: \"#,##0.#%\",\n}\n\n/** A pattern taken apart once, so formatting a tick is not a parse. */\ninterface ParsedPattern {\n prefix: string\n suffix: string\n grouped: boolean\n /** Digits always written left of the point — the count of `0`s there. */\n minInt: number\n /** Digits always written right of it. */\n minFrac: number\n /** The most that may be written right of it. */\n maxFrac: number\n /** Scale by 100 and print a `%`. */\n percent: boolean\n}\n\n/** What a pattern with no digits in it falls back to: the `plain` reading. */\nconst DEFAULT_PARSED: ParsedPattern = {\n prefix: \"\",\n suffix: \"\",\n grouped: false,\n minInt: 1,\n minFrac: 0,\n maxFrac: 1,\n percent: false,\n}\n\n/** Walk `text`, calling `visit` with each character and whether it is quoted. */\nfunction scan(text: string, visit: (ch: string, quoted: boolean) => void): void {\n let quoted = false\n for (const ch of text) {\n if (ch === \"'\") {\n quoted = !quoted\n continue\n }\n visit(ch, quoted)\n }\n}\n\n/** Does `text` hold `ch` outside quotes? */\nfunction hasBare(text: string, ch: string): boolean {\n let found = false\n scan(text, (c, quoted) => {\n if (c === ch && !quoted) found = true\n })\n return found\n}\n\n/** `text` with every unquoted `ch` dropped, quoting preserved. */\nfunction removeBare(text: string, ch: string): string {\n let out = \"\"\n let quoted = false\n for (const c of text) {\n if (c === \"'\") {\n quoted = !quoted\n out += c\n continue\n }\n if (c === ch && !quoted) continue\n out += c\n }\n return out\n}\n\n/** `text` with its quotes taken off — what actually gets printed. */\nfunction literal(text: string): string {\n let out = \"\"\n scan(text, (ch) => {\n out += ch\n })\n return out\n}\n\n/**\n * The `[start, end)` of the pattern's digit run — the first stretch of `#0,.`\n * outside quotes.\n *\n * Quote-aware, so `'#'#,##0` reads its leading hash as text and its run as the\n * three characters after it. Without that, a quoted `#` would be taken for the\n * number and the real digits for a suffix.\n */\nfunction digitRun(pattern: string): [number, number] | null {\n let quoted = false\n let start = -1\n for (let i = 0; i < pattern.length; i++) {\n const ch = pattern[i]\n if (ch === \"'\") {\n quoted = !quoted\n if (start >= 0) return [start, i]\n continue\n }\n const isDigit = !quoted && \"#0,.\".includes(ch)\n if (isDigit && start < 0) start = i\n else if (!isDigit && start >= 0) return [start, i]\n }\n return start < 0 ? null : [start, pattern.length]\n}\n\n/**\n * Split `pattern` into its literal edges and its digit run.\n *\n * Everything before the run is a prefix and everything after it a suffix, which\n * is what lets `$#,##0.00`, `#,##0 kg` and `€ #,##0` all work without the\n * language needing a quoting rule for the parts that are only ever text.\n */\nfunction parsePattern(pattern: string): ParsedPattern {\n const run = digitRun(pattern)\n if (!run) {\n // No digits at all is not a number format. Fall back rather than print the\n // literal for every tick, which would read as an axis of identical labels.\n return DEFAULT_PARSED\n }\n\n const digits = pattern.slice(run[0], run[1])\n const rawPrefix = pattern.slice(0, run[0])\n const rawSuffix = pattern.slice(run[1])\n\n // An **unquoted** `%` is the percent operator; a quoted one is a sign the\n // author wants printed over data that is already in percent points.\n const percent = hasBare(rawPrefix, \"%\") || hasBare(rawSuffix, \"%\")\n const prefix = literal(percent ? removeBare(rawPrefix, \"%\") : rawPrefix)\n const suffix = literal(percent ? removeBare(rawSuffix, \"%\") : rawSuffix)\n\n const point = digits.indexOf(\".\")\n const intPart = point < 0 ? digits : digits.slice(0, point)\n const fracPart = point < 0 ? \"\" : digits.slice(point + 1)\n\n const count = (s: string, ch: string) => s.split(ch).length - 1\n\n return {\n prefix,\n suffix: percent ? `${suffix}%` : suffix,\n grouped: intPart.includes(\",\"),\n minInt: Math.max(1, count(intPart, \"0\")),\n minFrac: count(fracPart, \"0\"),\n maxFrac: fracPart.length,\n percent,\n }\n}\n\n/** Parsed patterns are reused across every tick of every frame. */\nconst cache = new Map<string, ParsedPattern>()\n\nfunction parsed(pattern: string): ParsedPattern {\n const held = cache.get(pattern)\n if (held) return held\n const next = parsePattern(pattern)\n cache.set(pattern, next)\n return next\n}\n\n/** `1234567` → `1,234,567`. Only the integer run is grouped. */\nfunction group(digits: string): string {\n return digits.replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\")\n}\n\n/**\n * `value` written the way `pattern` says.\n *\n * A non-finite value prints empty rather than `NaN`: a tick with no number\n * behind it is a tick that shouldn't caption itself, and `NaN` on an axis reads\n * as a broken chart rather than as missing data.\n */\nexport function formatNumber(value: number, pattern: string): string {\n if (!Number.isFinite(value)) return \"\"\n const p = parsed(pattern)\n\n const scaled = p.percent ? value * 100 : value\n const rounded = scaled.toFixed(p.maxFrac)\n // Rounding is what decides the sign, not the input: -0.001 at two decimals is\n // \"0.00\", and printing it as \"-0.00\" puts a minus sign on an axis's zero.\n const negative = rounded.startsWith(\"-\")\n const [rawInt = \"0\", rawFrac = \"\"] = (\n negative ? rounded.slice(1) : rounded\n ).split(\".\")\n\n const intDigits = rawInt.padStart(p.minInt, \"0\")\n // `#` trims, `0` pads: drop trailing zeros down to the required minimum.\n let frac = rawFrac\n while (frac.length > p.minFrac && frac.endsWith(\"0\")) frac = frac.slice(0, -1)\n\n const body = (p.grouped ? group(intDigits) : intDigits) + (frac ? `.${frac}` : \"\")\n const sign = negative && Number(rounded) !== 0 ? \"-\" : \"\"\n return `${sign}${p.prefix}${body}${p.suffix}`\n}\n\n/**\n * The pattern a `(format, custom)` pair names.\n *\n * A blank custom pattern falls back to the plain one rather than to the empty\n * string, so an axis switched to Custom is readable while it is being typed\n * into rather than a column of nothing.\n */\nexport function patternFor(\n format: NumberFormatName | undefined,\n custom: string | undefined\n): string {\n if (format === \"custom\") {\n const trimmed = custom?.trim() ?? \"\"\n return trimmed === \"\" ? NUMBER_PATTERNS.plain : trimmed\n }\n return NUMBER_PATTERNS[format ?? \"plain\"] ?? NUMBER_PATTERNS.plain\n}\n"]}
|
|
1
|
+
{"version":3,"file":"number-format.js","sourceRoot":"","sources":["../../../src/nodes/text/number-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAKH;;;;;;GAMG;AACH,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G,CAAC,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,CAAA;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,MAAoC,EACpC,MAA0B;IAE1B,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxB,MAAM,OAAO,GAAG,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QACpC,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;IACzD,CAAC;IACD,OAAO,eAAe,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,eAAe,CAAC,KAAK,CAAA;AACpE,CAAC","sourcesContent":["/**\r\n * How a chart writes a number down.\r\n *\r\n * One formatter, driven by a **pattern**, and the named formats are patterns\r\n * too — `currency` is `$#,##0.00` and nothing more. That is the whole design:\r\n * a dropdown of four presets and a free-text pattern are otherwise two features\r\n * that drift, one of them gaining a thousands separator or a negative sign the\r\n * other never hears about. Here the preset *is* the custom case with the\r\n * pattern filled in, so there is one set of rules to get right.\r\n *\r\n * The grammar is the spreadsheet one, because that is where the numbers come\r\n * from and what an author already knows:\r\n *\r\n * | Pattern | 1234.5 | 0.07 |\r\n * | ------------ | --------- | ------ |\r\n * | `#,##0.##` | `1,234.5` | `0.07` |\r\n * | `0` | `1235` | `0` |\r\n * | `$#,##0.00` | `$1,234.50` | `$0.07` |\r\n * | `0.#%` | `123450%` | `7%` |\r\n * | `#,##0 kg` | `1,235 kg` | `0 kg` |\r\n *\r\n * - `0` is a digit that is always written, `#` one that is written only when\r\n * the number needs it. So `0.00` pads to two decimals and `0.##` trims.\r\n * - A `,` anywhere in the integer run turns grouping on; where it sits doesn't\r\n * matter, since `#,##0` and `#,###,##0` mean the same thing to everyone who\r\n * writes them.\r\n * - `%` scales by 100 as well as printing — that is what makes it a percent\r\n * rather than a suffix, and it is why `0.07` under `0.#%` is `7%`. A column\r\n * that is *already* in percent points wants `#,##0'%'`: quoted, so the sign\r\n * is printed and nothing is scaled.\r\n * - Anything else is literal, before the digits or after them. Quote it to be\r\n * sure — `'#'#,##0` prints a leading hash.\r\n *\r\n * Deliberately **not** `Intl.NumberFormat`. Its output is locale-dependent, and\r\n * a chart is a picture with a fixed layout: the same project rendering\r\n * `1,234.50` on the author's machine and `1.234,50` on the export box is a\r\n * silently different image, and the wider string can reflow an axis. What an\r\n * author wants here is the format they *typed*.\r\n */\r\n\r\n/** The named formats the inspector offers, plus the escape hatch. */\r\nexport type NumberFormatName = \"plain\" | \"number\" | \"currency\" | \"percent\" | \"custom\"\r\n\r\n/**\r\n * The pattern behind each named format.\r\n *\r\n * `plain` is the historic behaviour — integers bare, everything else to one\r\n * decimal — kept as the default so no existing chart re-labels itself. The rest\r\n * are the three formats a chart of money, counts or shares actually needs.\r\n */\r\nexport const NUMBER_PATTERNS: Record<Exclude<NumberFormatName, \"custom\">, string> = {\r\n // Ungrouped on purpose: this is what `formatMarker` did before there were\r\n // formats at all, and it is the default, so every chart already drawn keeps\r\n // the labels it has. Grouping is what the reader picks `number` for.\r\n plain: \"#.#\",\r\n number: \"#,##0.##\",\r\n currency: \"$#,##0.00\",\r\n percent: \"#,##0.#%\",\r\n}\r\n\r\n/** A pattern taken apart once, so formatting a tick is not a parse. */\r\ninterface ParsedPattern {\r\n prefix: string\r\n suffix: string\r\n grouped: boolean\r\n /** Digits always written left of the point — the count of `0`s there. */\r\n minInt: number\r\n /** Digits always written right of it. */\r\n minFrac: number\r\n /** The most that may be written right of it. */\r\n maxFrac: number\r\n /** Scale by 100 and print a `%`. */\r\n percent: boolean\r\n}\r\n\r\n/** What a pattern with no digits in it falls back to: the `plain` reading. */\r\nconst DEFAULT_PARSED: ParsedPattern = {\r\n prefix: \"\",\r\n suffix: \"\",\r\n grouped: false,\r\n minInt: 1,\r\n minFrac: 0,\r\n maxFrac: 1,\r\n percent: false,\r\n}\r\n\r\n/** Walk `text`, calling `visit` with each character and whether it is quoted. */\r\nfunction scan(text: string, visit: (ch: string, quoted: boolean) => void): void {\r\n let quoted = false\r\n for (const ch of text) {\r\n if (ch === \"'\") {\r\n quoted = !quoted\r\n continue\r\n }\r\n visit(ch, quoted)\r\n }\r\n}\r\n\r\n/** Does `text` hold `ch` outside quotes? */\r\nfunction hasBare(text: string, ch: string): boolean {\r\n let found = false\r\n scan(text, (c, quoted) => {\r\n if (c === ch && !quoted) found = true\r\n })\r\n return found\r\n}\r\n\r\n/** `text` with every unquoted `ch` dropped, quoting preserved. */\r\nfunction removeBare(text: string, ch: string): string {\r\n let out = \"\"\r\n let quoted = false\r\n for (const c of text) {\r\n if (c === \"'\") {\r\n quoted = !quoted\r\n out += c\r\n continue\r\n }\r\n if (c === ch && !quoted) continue\r\n out += c\r\n }\r\n return out\r\n}\r\n\r\n/** `text` with its quotes taken off — what actually gets printed. */\r\nfunction literal(text: string): string {\r\n let out = \"\"\r\n scan(text, (ch) => {\r\n out += ch\r\n })\r\n return out\r\n}\r\n\r\n/**\r\n * The `[start, end)` of the pattern's digit run — the first stretch of `#0,.`\r\n * outside quotes.\r\n *\r\n * Quote-aware, so `'#'#,##0` reads its leading hash as text and its run as the\r\n * three characters after it. Without that, a quoted `#` would be taken for the\r\n * number and the real digits for a suffix.\r\n */\r\nfunction digitRun(pattern: string): [number, number] | null {\r\n let quoted = false\r\n let start = -1\r\n for (let i = 0; i < pattern.length; i++) {\r\n const ch = pattern[i]\r\n if (ch === \"'\") {\r\n quoted = !quoted\r\n if (start >= 0) return [start, i]\r\n continue\r\n }\r\n const isDigit = !quoted && \"#0,.\".includes(ch)\r\n if (isDigit && start < 0) start = i\r\n else if (!isDigit && start >= 0) return [start, i]\r\n }\r\n return start < 0 ? null : [start, pattern.length]\r\n}\r\n\r\n/**\r\n * Split `pattern` into its literal edges and its digit run.\r\n *\r\n * Everything before the run is a prefix and everything after it a suffix, which\r\n * is what lets `$#,##0.00`, `#,##0 kg` and `€ #,##0` all work without the\r\n * language needing a quoting rule for the parts that are only ever text.\r\n */\r\nfunction parsePattern(pattern: string): ParsedPattern {\r\n const run = digitRun(pattern)\r\n if (!run) {\r\n // No digits at all is not a number format. Fall back rather than print the\r\n // literal for every tick, which would read as an axis of identical labels.\r\n return DEFAULT_PARSED\r\n }\r\n\r\n const digits = pattern.slice(run[0], run[1])\r\n const rawPrefix = pattern.slice(0, run[0])\r\n const rawSuffix = pattern.slice(run[1])\r\n\r\n // An **unquoted** `%` is the percent operator; a quoted one is a sign the\r\n // author wants printed over data that is already in percent points.\r\n const percent = hasBare(rawPrefix, \"%\") || hasBare(rawSuffix, \"%\")\r\n const prefix = literal(percent ? removeBare(rawPrefix, \"%\") : rawPrefix)\r\n const suffix = literal(percent ? removeBare(rawSuffix, \"%\") : rawSuffix)\r\n\r\n const point = digits.indexOf(\".\")\r\n const intPart = point < 0 ? digits : digits.slice(0, point)\r\n const fracPart = point < 0 ? \"\" : digits.slice(point + 1)\r\n\r\n const count = (s: string, ch: string) => s.split(ch).length - 1\r\n\r\n return {\r\n prefix,\r\n suffix: percent ? `${suffix}%` : suffix,\r\n grouped: intPart.includes(\",\"),\r\n minInt: Math.max(1, count(intPart, \"0\")),\r\n minFrac: count(fracPart, \"0\"),\r\n maxFrac: fracPart.length,\r\n percent,\r\n }\r\n}\r\n\r\n/** Parsed patterns are reused across every tick of every frame. */\r\nconst cache = new Map<string, ParsedPattern>()\r\n\r\nfunction parsed(pattern: string): ParsedPattern {\r\n const held = cache.get(pattern)\r\n if (held) return held\r\n const next = parsePattern(pattern)\r\n cache.set(pattern, next)\r\n return next\r\n}\r\n\r\n/** `1234567` → `1,234,567`. Only the integer run is grouped. */\r\nfunction group(digits: string): string {\r\n return digits.replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\")\r\n}\r\n\r\n/**\r\n * `value` written the way `pattern` says.\r\n *\r\n * A non-finite value prints empty rather than `NaN`: a tick with no number\r\n * behind it is a tick that shouldn't caption itself, and `NaN` on an axis reads\r\n * as a broken chart rather than as missing data.\r\n */\r\nexport function formatNumber(value: number, pattern: string): string {\r\n if (!Number.isFinite(value)) return \"\"\r\n const p = parsed(pattern)\r\n\r\n const scaled = p.percent ? value * 100 : value\r\n const rounded = scaled.toFixed(p.maxFrac)\r\n // Rounding is what decides the sign, not the input: -0.001 at two decimals is\r\n // \"0.00\", and printing it as \"-0.00\" puts a minus sign on an axis's zero.\r\n const negative = rounded.startsWith(\"-\")\r\n const [rawInt = \"0\", rawFrac = \"\"] = (\r\n negative ? rounded.slice(1) : rounded\r\n ).split(\".\")\r\n\r\n const intDigits = rawInt.padStart(p.minInt, \"0\")\r\n // `#` trims, `0` pads: drop trailing zeros down to the required minimum.\r\n let frac = rawFrac\r\n while (frac.length > p.minFrac && frac.endsWith(\"0\")) frac = frac.slice(0, -1)\r\n\r\n const body = (p.grouped ? group(intDigits) : intDigits) + (frac ? `.${frac}` : \"\")\r\n const sign = negative && Number(rounded) !== 0 ? \"-\" : \"\"\r\n return `${sign}${p.prefix}${body}${p.suffix}`\r\n}\r\n\r\n/**\r\n * The pattern a `(format, custom)` pair names.\r\n *\r\n * A blank custom pattern falls back to the plain one rather than to the empty\r\n * string, so an axis switched to Custom is readable while it is being typed\r\n * into rather than a column of nothing.\r\n */\r\nexport function patternFor(\r\n format: NumberFormatName | undefined,\r\n custom: string | undefined\r\n): string {\r\n if (format === \"custom\") {\r\n const trimmed = custom?.trim() ?? \"\"\r\n return trimmed === \"\" ? NUMBER_PATTERNS.plain : trimmed\r\n }\r\n return NUMBER_PATTERNS[format ?? \"plain\"] ?? NUMBER_PATTERNS.plain\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-node.js","sourceRoot":"","sources":["../../../src/nodes/text/number-node.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YA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AI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;yCAGrD","sourcesContent":["import { property } from \"@/attributes/properties/decorator\";\nimport { NodeConfig } from \"@/nodes/2d/node2d\";\nimport { TextBase, TextBaseProps } from \"./text-base\";\nimport { formatNumber } from \"./number-format\";\nimport { numberNodePattern } from \"./number-pattern\";\nimport { type Command, type CommandArgs } from \"@/tween/command\";\nimport { command } from \"@/tween/command-decorator\";\n\n\n/**\n * How a {@link NumberNode}'s value is written down.\n *\n * `'custom'` hands the pattern over verbatim through\n * {@link NumberProps.customPattern}; the other three compose one from\n * {@link NumberProps.fractionDigits} and {@link NumberProps.grouped}.\n */\nexport type NumberFormat = \"currency\" | \"percent\" | \"number\" | \"custom\";\n\n\nexport interface NumberProps extends TextBaseProps {\n /** The numeric value to display. Tweenable — `to({ value })` counts. */\n value: number;\n /**\n * How the figure is written:\n * - `'number'` — plain decimal (the default)\n * - `'currency'` — money, prefixed with {@link NumberProps.currencySymbol}\n * - `'percent'` — multiplies by 100 and appends `%` (so `0.42` → `42%`)\n * - `'custom'` — {@link NumberProps.customPattern}, verbatim\n */\n format: NumberFormat;\n /**\n * The pattern, when {@link NumberProps.format} is `'custom'` — the same\n * grammar `formatNumber` takes (`#,##0.00`, `0.0%`, `$#,##0`).\n */\n customPattern: string;\n /**\n * Fixed number of decimal places. Always exactly this many, which is what\n * keeps a counting animation from flickering trailing digits as the value\n * crosses an integer boundary.\n */\n fractionDigits: number;\n /** Group digits in threes — `1,000` rather than `1000`. */\n grouped: boolean;\n /** The symbol a `'currency'` figure is prefixed with. */\n currencySymbol: string;\n}\n\n\n/**\n * Renders a number through this package's own formatter, so the string is a\n * function of the props alone.\n *\n * **Deliberately not `Intl.NumberFormat`.** A scene is a picture with a fixed\n * layout, and `Intl` reads the *host* locale — so the same project renders\n * `1,234.50` on the author's machine and `1.234,50` on an export box, which is\n * a silently different image, and a wider string reflows the shot around it.\n * The same formatter draws a chart axis (`formatNumber`), so a figure and an\n * axis label in one scene agree about grouping, rounding, and the sign on a\n * value that rounds to zero.\n *\n * **A sibling of {@link Text}, not a subclass of it.** Both extend\n * {@link TextBase} and so share every font, fill, layout and measurement\n * behaviour — but a figure is not copy. It has no `text` prop to type into, no\n * `append`/`prepend`, no `find`/`word`/`line` selections and no wrapping,\n * because none of those are operations anyone performs on a quantity; what it\n * draws is derived from {@link value} and the five format props and nothing\n * else can write it. `start`/`end` are still the Write On reveal window every\n * glyph node reinterprets them as.\n *\n * Because {@link value} is a plain numeric prop, `to({ value })` interpolates\n * it like any other number, giving a counting / rolling animation for free.\n *\n * @example\n * const price = createRef<NumberNode>();\n * <NumberNode ref={price} value={0} format={'currency'} fractionDigits={2} />\n * price().to({ value: 1299.99 }, 1.5); // counts up to \"$1,299.99\"\n */\nexport class NumberNode extends TextBase<NumberProps> {\n\n @property({ default: 0 }) declare readonly value: number;\n @property({ default: \"number\" }) declare readonly format: NumberFormat;\n @property({ default: \"\" }) declare readonly customPattern: string;\n @property({ default: 0 }) declare readonly fractionDigits: number;\n @property({ default: true }) declare readonly grouped: boolean;\n @property({ default: \"$\" }) declare readonly currencySymbol: string;\n\n constructor(props: NodeConfig<NumberNode, NumberProps>) {\n super(props);\n }\n\n /**\n * The figure as the format props write it.\n *\n * {@link TextBase} calls this wherever it needs the string — measuring,\n * declaring fonts, drawing — so the six props are read fresh every frame:\n * changing a format, or tweening the value, reformats and redraws without\n * this class owning a binding of its own.\n */\n override displayText(): string {\n return this.formatted();\n }\n\n /** The figure as the format props write it. The public name for {@link displayText}. */\n formatted(): string {\n return formatNumber(this.value, numberNodePattern(this));\n }\n\n /** Animate {@link value}, counting through the formatted display. */\n @command({ args: [{ key: \"value\", kind: \"number\" }] })\n countTo(args: CommandArgs<{ value: number }> & { duration: number }): Command<NumberProps> {\n return this.to({ data: args.data as Partial<NumberProps>, duration: args.duration, easing: args.easing });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"number-node.js","sourceRoot":"","sources":["../../../src/nodes/text/number-node.ts"],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5C,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;kDAAyC;AAyBpE;IADC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;yCAGrD","sourcesContent":["import { property } from \"@/attributes/properties/decorator\";\r\nimport { NodeConfig } from \"@/nodes/2d/node2d\";\r\nimport { TextBase, TextBaseProps } from \"./text-base\";\r\nimport { formatNumber } from \"./number-format\";\r\nimport { numberNodePattern } from \"./number-pattern\";\r\nimport { type Command, type CommandArgs } from \"@/tween/command\";\r\nimport { command } from \"@/tween/command-decorator\";\r\n\r\n\r\n/**\r\n * How a {@link NumberNode}'s value is written down.\r\n *\r\n * `'custom'` hands the pattern over verbatim through\r\n * {@link NumberProps.customPattern}; the other three compose one from\r\n * {@link NumberProps.fractionDigits} and {@link NumberProps.grouped}.\r\n */\r\nexport type NumberFormat = \"currency\" | \"percent\" | \"number\" | \"custom\";\r\n\r\n\r\nexport interface NumberProps extends TextBaseProps {\r\n /** The numeric value to display. Tweenable — `to({ value })` counts. */\r\n value: number;\r\n /**\r\n * How the figure is written:\r\n * - `'number'` — plain decimal (the default)\r\n * - `'currency'` — money, prefixed with {@link NumberProps.currencySymbol}\r\n * - `'percent'` — multiplies by 100 and appends `%` (so `0.42` → `42%`)\r\n * - `'custom'` — {@link NumberProps.customPattern}, verbatim\r\n */\r\n format: NumberFormat;\r\n /**\r\n * The pattern, when {@link NumberProps.format} is `'custom'` — the same\r\n * grammar `formatNumber` takes (`#,##0.00`, `0.0%`, `$#,##0`).\r\n */\r\n customPattern: string;\r\n /**\r\n * Fixed number of decimal places. Always exactly this many, which is what\r\n * keeps a counting animation from flickering trailing digits as the value\r\n * crosses an integer boundary.\r\n */\r\n fractionDigits: number;\r\n /** Group digits in threes — `1,000` rather than `1000`. */\r\n grouped: boolean;\r\n /** The symbol a `'currency'` figure is prefixed with. */\r\n currencySymbol: string;\r\n}\r\n\r\n\r\n/**\r\n * Renders a number through this package's own formatter, so the string is a\r\n * function of the props alone.\r\n *\r\n * **Deliberately not `Intl.NumberFormat`.** A scene is a picture with a fixed\r\n * layout, and `Intl` reads the *host* locale — so the same project renders\r\n * `1,234.50` on the author's machine and `1.234,50` on an export box, which is\r\n * a silently different image, and a wider string reflows the shot around it.\r\n * The same formatter draws a chart axis (`formatNumber`), so a figure and an\r\n * axis label in one scene agree about grouping, rounding, and the sign on a\r\n * value that rounds to zero.\r\n *\r\n * **A sibling of {@link Text}, not a subclass of it.** Both extend\r\n * {@link TextBase} and so share every font, fill, layout and measurement\r\n * behaviour — but a figure is not copy. It has no `text` prop to type into, no\r\n * `append`/`prepend`, no `find`/`word`/`line` selections and no wrapping,\r\n * because none of those are operations anyone performs on a quantity; what it\r\n * draws is derived from {@link value} and the five format props and nothing\r\n * else can write it. `start`/`end` are still the Write On reveal window every\r\n * glyph node reinterprets them as.\r\n *\r\n * Because {@link value} is a plain numeric prop, `to({ value })` interpolates\r\n * it like any other number, giving a counting / rolling animation for free.\r\n *\r\n * @example\r\n * const price = createRef<NumberNode>();\r\n * <NumberNode ref={price} value={0} format={'currency'} fractionDigits={2} />\r\n * price().to({ value: 1299.99 }, 1.5); // counts up to \"$1,299.99\"\r\n */\r\nexport class NumberNode extends TextBase<NumberProps> {\r\n\r\n @property({ default: 0 }) declare readonly value: number;\r\n @property({ default: \"number\" }) declare readonly format: NumberFormat;\r\n @property({ default: \"\" }) declare readonly customPattern: string;\r\n @property({ default: 0 }) declare readonly fractionDigits: number;\r\n @property({ default: true }) declare readonly grouped: boolean;\r\n @property({ default: \"$\" }) declare readonly currencySymbol: string;\r\n\r\n constructor(props: NodeConfig<NumberNode, NumberProps>) {\r\n super(props);\r\n }\r\n\r\n /**\r\n * The figure as the format props write it.\r\n *\r\n * {@link TextBase} calls this wherever it needs the string — measuring,\r\n * declaring fonts, drawing — so the six props are read fresh every frame:\r\n * changing a format, or tweening the value, reformats and redraws without\r\n * this class owning a binding of its own.\r\n */\r\n override displayText(): string {\r\n return this.formatted();\r\n }\r\n\r\n /** The figure as the format props write it. The public name for {@link displayText}. */\r\n formatted(): string {\r\n return formatNumber(this.value, numberNodePattern(this));\r\n }\r\n\r\n /** Animate {@link value}, counting through the formatted display. */\r\n @command({ args: [{ key: \"value\", kind: \"number\" }] })\r\n countTo(args: CommandArgs<{ value: number }> & { duration: number }): Command<NumberProps> {\r\n return this.to({ data: args.data as Partial<NumberProps>, duration: args.duration, easing: args.easing });\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-pattern.js","sourceRoot":"","sources":["../../../src/nodes/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":["/**\n * The Number node's format controls, resolved into the one pattern the app's\n * formatter takes.\n *\n * There is already exactly one answer in this package to \"how is a number\n * written down\" — `./number-format`, whose docblock has the grammar and\n * the argument for it. This module adds no second one. What it adds is the\n * *panel's* half: a figure on the canvas is set up by picking a format and\n * saying how many decimals, where a chart axis is set up by picking a preset,\n * and those two are the same statement typed differently.\n *\n * So the controls compose a pattern rather than being honoured beside one. A\n * Number node showing `$1,234.50` and an axis labelled `$#,##0.00` go through\n * the same parser and round the same way, which is the thing that would drift\n * if the node reached for `Intl.NumberFormat` instead.\n */\n\nimport { patternFor } from \"./number-format\";\n\n/**\n * How a Number node writes its figure.\n *\n * The chart's five minus `plain`, which exists there only to keep charts drawn\n * before there were formats labelling themselves the way they always have. A\n * node has no such history, and \"plain\" beside \"number\" is a distinction\n * nobody browsing a dropdown can make.\n */\nexport const NUMBER_NODE_FORMATS = [\n \"number\",\n \"currency\",\n \"percent\",\n \"custom\",\n] as const\n\nexport type NumberNodeFormat = (typeof NUMBER_NODE_FORMATS)[number]\n\n/** The most decimals the panel will let a figure carry. */\nexport const MAX_FRACTION_DIGITS = 10\n\n/** The Number node's format controls, as the class holds them. */\nexport interface NumberFormatOptions {\n /** How the figure is written — see {@link NumberNode.format}. */\n format: string\n /** The pattern typed by hand — read only when the format is `custom`. */\n customPattern: string\n fractionDigits: number\n grouped: boolean\n /** Printed before the figure when the format is `currency`. */\n currencySymbol: string\n}\n\n/**\n * The pattern `options` names.\n *\n * `custom` hands the typed pattern straight to {@link patternFor}, which is what\n * makes the escape hatch the *same* language the presets are written in rather\n * than a second one. Every other format is composed here, because the three\n * controls beside the dropdown — decimals, grouping, the symbol — are what a\n * preset would otherwise have to be duplicated for (`#,##0.00` and `#,##0.000`\n * and `0.00` and…).\n */\nexport function numberNodePattern(options: NumberFormatOptions): string {\n if (options.format === \"custom\") {\n return patternFor(\"custom\", options.customPattern)\n }\n\n const digits = Math.min(\n MAX_FRACTION_DIGITS,\n Math.max(0, Math.round(options.fractionDigits))\n )\n const integer = options.grouped ? \"#,##0\" : \"0\"\n const fraction = digits > 0 ? `.${\"0\".repeat(digits)}` : \"\"\n const body = `${integer}${fraction}`\n\n if (options.format === \"currency\") {\n return `${quoted(options.currencySymbol)}${body}`\n }\n // Bare, so the parser reads it as the percent *operator* and scales by 100 —\n // which is what makes a stored 0.42 read as \"42%\". A symbol an author wants\n // printed over data that is already in percent points is a custom pattern\n // with the sign quoted, exactly as it is on an axis.\n if (options.format === \"percent\") return `${body}%`\n return body\n}\n\n/**\n * `symbol` as a pattern literal.\n *\n * Quoted rather than concatenated, because the two most likely symbols after `$`\n * are `€` and `£` and the two after those are whatever an author types — and an\n * unquoted `#`, `0`, `,`, `.` or `%` in there would be read as part of the\n * number. The quote character itself is dropped rather than escaped: the grammar\n * has no escape for it, and a currency symbol containing an apostrophe is not a\n * thing anyone has.\n */\nfunction quoted(symbol: string): string {\n const literal = symbol.replaceAll(\"'\", \"\")\n return literal === \"\" ? \"\" : `'${literal}'`\n}\n"]}
|
|
1
|
+
{"version":3,"file":"number-pattern.js","sourceRoot":"","sources":["../../../src/nodes/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"]}
|
|
@@ -18,7 +18,7 @@ export class RichText extends PaintNode {
|
|
|
18
18
|
// into each span. Context-value application (spans are fixed structure), so it
|
|
19
19
|
// lives in resolveContext — runs once after the tree + context exist. See Text.
|
|
20
20
|
resolveContext(ctx) {
|
|
21
|
-
applyTextDefaults(this, this._props);
|
|
21
|
+
applyTextDefaults(this, this._props, { autofit: false });
|
|
22
22
|
}
|
|
23
23
|
// RichText always sizes to its own laid-out spans — it has no children
|
|
24
24
|
// to hug — so it ignores the base has-children default and always hugs.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"richtext-node.js","sourceRoot":"","sources":["../../../src/nodes/text/richtext-node.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAOjD,OAAO,EAAE,SAAS,EAAc,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAI7D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA2B9D,MAAM,OAAO,QAAS,SAAQ,SAAwB;IA8BlD,YAAY,KAA0C;QAClD,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,+EAA+E;IAC/E,+EAA+E;IAC/E,+EAA+E;IAC/E,kFAAkF;IAC/D,cAAc,CAAC,GAAe;QAC7C,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,MAA6C,CAAC,CAAC;IAChF,CAAC;IAED,yEAAyE;IACzE,0EAA0E;IACvD,gBAAgB,CAAC,KAA2C;QAC3E,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE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;IAA5C,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;4CAAqC;AACd;IAAjD,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;2CAAuC;AACpB;IAAlD,QAAQ,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;yCAAmC","sourcesContent":["import { RenderContext2D } from \"@/render/render-context2d\";\nimport { Graphics2D } from \"@/render/graphics2d\";\nimport { SizeConstraints } from \"@/layout/constraints\";\nimport { MeasureContext2D } from \"@/render/measure-context\";\nimport { FillResolved } from \"@/attributes/shape/fill/union\";\nimport type { AssetScope } from \"@/assets/scope\";\nimport { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport { Size2D } from \"@/attributes/layout/size\";\nimport { PaintNode, PaintProps } from \"@/nodes/2d/paint-node\";\nimport { property } from \"@/attributes/properties/decorator\";\nimport { NodeConfig } from \"@/nodes/2d/node2d\";\nimport { ContextMap } from \"@/util/context\";\nimport type { FontStyle, ResolvedTextSpan, TextAlign, TextSpan } from \"@/attributes/text/types\";\nimport { textOps } from \"@/attributes/text/ops\";\nimport { applyTextDefaults } from \"./default-text-style-node\";\n\n\nexport interface RichTextProps extends PaintProps {\n spans: TextSpan | TextSpan[];\n /** Default font family inherited by spans that don't set one. */\n fontFamily: string;\n /** Default font size inherited by spans that don't set one. */\n fontSize: number;\n /** Default font weight inherited by spans that don't set one. */\n fontWeight: number;\n /** Default font style inherited by spans that don't set one. */\n fontStyle: FontStyle;\n /** Default letter spacing inherited by spans that don't set one. */\n letterSpacing: number;\n /** Line height multiplier applied to each run's font size. */\n lineHeight: number;\n textAlign: TextAlign;\n /**\n * Name of a typography preset from `theme.typography` (e.g. `\"body\"`).\n * Supplies any node-level default (fontSize, fontWeight, …) not set\n * explicitly here, which `runs()` then folds into each span. An explicit prop\n * wins over the preset; the preset wins over an inherited `<DefaultTextStyle>`.\n */\n variant: string;\n}\n\nexport class RichText extends PaintNode<RichTextProps> {\n\n\n\n @property({\n default: [],\n mapper: (v: TextSpan | TextSpan[] | undefined): TextSpan[] =>\n v == null ? [] : Array.isArray(v) ? v : [v],\n }) declare readonly spans: TextSpan[];\n /**\n * The family this text is set in. **No default** — it comes from the cascade\n * in `applyTextDefaults`: what the author passed, else a `variant` preset,\n * else the nearest enclosing `<DefaultTextStyle>`, else the theme's `default`\n * typography preset.\n *\n * A literal default here would sit *under* all four and quietly win whenever\n * every one of them was silent, which is precisely the case worth hearing\n * about: text set in a face nobody chose is text whose font was never\n * declared and so never loaded. Left unset, the renderer says so instead —\n * see `requireFontFamily`.\n */\n @property() declare readonly fontFamily: string;\n @property({ default: 48 }) declare readonly fontSize: number;\n @property({ default: 400 }) declare readonly fontWeight: number;\n @property({ default: 'normal' }) declare readonly fontStyle: FontStyle;\n @property({ default: 0 }) declare readonly letterSpacing: number;\n @property({ default: 1.2 }) declare readonly lineHeight: number;\n @property({ default: 'center' }) declare readonly textAlign: TextAlign;\n @property({ default: undefined }) declare readonly variant?: string;\n\n constructor(props: NodeConfig<RichText, RichTextProps>) {\n super(props);\n }\n\n // Inherit text-style defaults from the nearest ancestor <DefaultTextStyle> for\n // any default the author didn't set; these node-level defaults are then folded\n // into each span. Context-value application (spans are fixed structure), so it\n // lives in resolveContext — runs once after the tree + context exist. See Text.\n protected override resolveContext(ctx: ContextMap): void {\n applyTextDefaults(this, this._props as Record<string, unknown> | undefined);\n }\n\n // RichText always sizes to its own laid-out spans — it has no children\n // to hug — so it ignores the base has-children default and always hugs.\n protected override applyDefaultSize(props?: NodeConfig<RichText, RichTextProps>): void {\n this.applyProp(\"height\", props?.height ?? \"hug\");\n this.applyProp(\"width\", props?.width ?? \"hug\");\n }\n\n /**\n * Flatten the nested span tree against this node's defaults, returning\n * leaf runs in document order. Children inherit any style fields the\n * parent set; explicit fields on a child override them.\n */\n runs(): ResolvedTextSpan[] {\n return textOps.flatten(this.spans, {\n fontFamily: this.fontFamily,\n fontSize: this.fontSize,\n fontWeight: this.fontWeight,\n fontStyle: this.fontStyle,\n letterSpacing: this.letterSpacing,\n fill: this.fill as FillResolved[],\n stroke: this.stroke as StrokeResolved[],\n });\n }\n\n /**\n * Every run's face and paint — a span may name either where the node doesn't.\n * {@link runs} is the flattening {@link measure} and the render use too, which\n * keeps the declaration and the draw from naming different families.\n */\n override declareAssets(assets: AssetScope): void {\n super.declareAssets(assets);\n for (const run of this.runs()) {\n if (run.fontFamily) assets.font(run.fontFamily, run.fontWeight);\n assets.fill(run.fill);\n for (const stroke of run.stroke) assets.fill(stroke.fill);\n }\n }\n\n measure(constraints: SizeConstraints, scope: MeasureContext2D): Partial<Size2D> {\n const runs = this.runs();\n let lineW = 0;\n let maxLineH = 0;\n let totalW = 0;\n let totalH = 0;\n\n const finishLine = () => {\n if (lineW > totalW) totalW = lineW;\n totalH += maxLineH;\n lineW = 0;\n maxLineH = 0;\n };\n\n for (const run of runs) {\n const lh = run.fontSize * this.lineHeight;\n const segments = run.text.split(\"\\n\");\n for (let i = 0; i < segments.length; i++) {\n if (i > 0) finishLine();\n // Called unconditionally (even for an empty segment, where\n // measureTextCached short-circuits to 0) so an empty run still\n // contributes its line height.\n lineW += scope.measureText(segments[i], run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width;\n if (lh > maxLineH) maxLineH = lh;\n }\n }\n finishLine();\n\n if (totalH === 0) totalH = this.fontSize * this.lineHeight;\n\n const wm = this.width;\n const hm = this.height;\n\n const resolvedW = typeof wm === \"number\"\n ? wm\n : wm === \"hug\"\n ? totalW\n : constraints.maxWidth ?? 0;\n\n const resolvedH = typeof hm === \"number\"\n ? hm\n : hm === \"hug\"\n ? totalH\n : constraints.maxHeight ?? 0;\n\n return { width: resolvedW, height: resolvedH };\n }\n\n protected override renderSelf(ctx: RenderContext2D): void {\n ctx.draw(new Graphics2D().richText({\n spans: this.runs(),\n lineHeight: this.lineHeight,\n textAlign: this.textAlign,\n width: this.layoutBounds?.width ?? 0,\n height: this.layoutBounds?.height ?? 0,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/B,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE;YAClB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC;YACpC,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;SACzC,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AAjIuB;IAJnB,QAAQ,CAAC;QACN,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,CAAC,CAAoC,EAAc,EAAE,CACzD,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAClD,CAAC;uCAAoC;AAaT;IAA5B,QAAQ,EAAE;4CAAqC;AACJ;IAA3C,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;0CAAmC;AAChB;IAA5C,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;4CAAqC;AACd;IAAjD,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;2CAAuC;AAC5B;IAA1C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;+CAAwC;AACpB;IAA5C,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;4CAAqC;AACd;IAAjD,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;2CAAuC;AACpB;IAAlD,QAAQ,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;yCAAmC","sourcesContent":["import { RenderContext2D } from \"@/render/render-context2d\";\r\nimport { Graphics2D } from \"@/render/graphics2d\";\r\nimport { SizeConstraints } from \"@/layout/constraints\";\r\nimport { MeasureContext2D } from \"@/render/measure-context\";\r\nimport { FillResolved } from \"@/attributes/shape/fill/union\";\r\nimport type { AssetScope } from \"@/assets/scope\";\r\nimport { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\r\nimport { Size2D } from \"@/attributes/layout/size\";\r\nimport { PaintNode, PaintProps } from \"@/nodes/2d/paint-node\";\r\nimport { property } from \"@/attributes/properties/decorator\";\r\nimport { NodeConfig } from \"@/nodes/2d/node2d\";\r\nimport { ContextMap } from \"@/util/context\";\r\nimport type { FontStyle, ResolvedTextSpan, TextAlign, TextSpan } from \"@/attributes/text/types\";\r\nimport { textOps } from \"@/attributes/text/ops\";\r\nimport { applyTextDefaults } from \"./default-text-style-node\";\r\n\r\n\r\nexport interface RichTextProps extends PaintProps {\r\n spans: TextSpan | TextSpan[];\r\n /** Default font family inherited by spans that don't set one. */\r\n fontFamily: string;\r\n /** Default font size inherited by spans that don't set one. */\r\n fontSize: number;\r\n /** Default font weight inherited by spans that don't set one. */\r\n fontWeight: number;\r\n /** Default font style inherited by spans that don't set one. */\r\n fontStyle: FontStyle;\r\n /** Default letter spacing inherited by spans that don't set one. */\r\n letterSpacing: number;\r\n /** Line height multiplier applied to each run's font size. */\r\n lineHeight: number;\r\n textAlign: TextAlign;\r\n /**\r\n * Name of a typography preset from `theme.typography` (e.g. `\"body\"`).\r\n * Supplies any node-level default (fontSize, fontWeight, …) not set\r\n * explicitly here, which `runs()` then folds into each span. An explicit prop\r\n * wins over the preset; the preset wins over an inherited `<DefaultTextStyle>`.\r\n */\r\n variant: string;\r\n}\r\n\r\nexport class RichText extends PaintNode<RichTextProps> {\r\n\r\n\r\n\r\n @property({\r\n default: [],\r\n mapper: (v: TextSpan | TextSpan[] | undefined): TextSpan[] =>\r\n v == null ? [] : Array.isArray(v) ? v : [v],\r\n }) declare readonly spans: TextSpan[];\r\n /**\r\n * The family this text is set in. **No default** — it comes from the cascade\r\n * in `applyTextDefaults`: what the author passed, else a `variant` preset,\r\n * else the nearest enclosing `<DefaultTextStyle>`, else the theme's `default`\r\n * typography preset.\r\n *\r\n * A literal default here would sit *under* all four and quietly win whenever\r\n * every one of them was silent, which is precisely the case worth hearing\r\n * about: text set in a face nobody chose is text whose font was never\r\n * declared and so never loaded. Left unset, the renderer says so instead —\r\n * see `requireFontFamily`.\r\n */\r\n @property() declare readonly fontFamily: string;\r\n @property({ default: 48 }) declare readonly fontSize: number;\r\n @property({ default: 400 }) declare readonly fontWeight: number;\r\n @property({ default: 'normal' }) declare readonly fontStyle: FontStyle;\r\n @property({ default: 0 }) declare readonly letterSpacing: number;\r\n @property({ default: 1.2 }) declare readonly lineHeight: number;\r\n @property({ default: 'center' }) declare readonly textAlign: TextAlign;\r\n @property({ default: undefined }) declare readonly variant?: string;\r\n\r\n constructor(props: NodeConfig<RichText, RichTextProps>) {\r\n super(props);\r\n }\r\n\r\n // Inherit text-style defaults from the nearest ancestor <DefaultTextStyle> for\r\n // any default the author didn't set; these node-level defaults are then folded\r\n // into each span. Context-value application (spans are fixed structure), so it\r\n // lives in resolveContext — runs once after the tree + context exist. See Text.\r\n protected override resolveContext(ctx: ContextMap): void {\r\n applyTextDefaults(this, this._props as Record<string, unknown> | undefined, { autofit: false });\r\n }\r\n\r\n // RichText always sizes to its own laid-out spans — it has no children\r\n // to hug — so it ignores the base has-children default and always hugs.\r\n protected override applyDefaultSize(props?: NodeConfig<RichText, RichTextProps>): void {\r\n this.applyProp(\"height\", props?.height ?? \"hug\");\r\n this.applyProp(\"width\", props?.width ?? \"hug\");\r\n }\r\n\r\n /**\r\n * Flatten the nested span tree against this node's defaults, returning\r\n * leaf runs in document order. Children inherit any style fields the\r\n * parent set; explicit fields on a child override them.\r\n */\r\n runs(): ResolvedTextSpan[] {\r\n return textOps.flatten(this.spans, {\r\n fontFamily: this.fontFamily,\r\n fontSize: this.fontSize,\r\n fontWeight: this.fontWeight,\r\n fontStyle: this.fontStyle,\r\n letterSpacing: this.letterSpacing,\r\n fill: this.fill as FillResolved[],\r\n stroke: this.stroke as StrokeResolved[],\r\n });\r\n }\r\n\r\n /**\r\n * Every run's face and paint — a span may name either where the node doesn't.\r\n * {@link runs} is the flattening {@link measure} and the render use too, which\r\n * keeps the declaration and the draw from naming different families.\r\n */\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n for (const run of this.runs()) {\r\n if (run.fontFamily) assets.font(run.fontFamily, run.fontWeight);\r\n assets.fill(run.fill);\r\n for (const stroke of run.stroke) assets.fill(stroke.fill);\r\n }\r\n }\r\n\r\n measure(constraints: SizeConstraints, scope: MeasureContext2D): Partial<Size2D> {\r\n const runs = this.runs();\r\n let lineW = 0;\r\n let maxLineH = 0;\r\n let totalW = 0;\r\n let totalH = 0;\r\n\r\n const finishLine = () => {\r\n if (lineW > totalW) totalW = lineW;\r\n totalH += maxLineH;\r\n lineW = 0;\r\n maxLineH = 0;\r\n };\r\n\r\n for (const run of runs) {\r\n const lh = run.fontSize * this.lineHeight;\r\n const segments = run.text.split(\"\\n\");\r\n for (let i = 0; i < segments.length; i++) {\r\n if (i > 0) finishLine();\r\n // Called unconditionally (even for an empty segment, where\r\n // measureTextCached short-circuits to 0) so an empty run still\r\n // contributes its line height.\r\n lineW += scope.measureText(segments[i], run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width;\r\n if (lh > maxLineH) maxLineH = lh;\r\n }\r\n }\r\n finishLine();\r\n\r\n if (totalH === 0) totalH = this.fontSize * this.lineHeight;\r\n\r\n const wm = this.width;\r\n const hm = this.height;\r\n\r\n const resolvedW = typeof wm === \"number\"\r\n ? wm\r\n : wm === \"hug\"\r\n ? totalW\r\n : constraints.maxWidth ?? 0;\r\n\r\n const resolvedH = typeof hm === \"number\"\r\n ? hm\r\n : hm === \"hug\"\r\n ? totalH\r\n : constraints.maxHeight ?? 0;\r\n\r\n return { width: resolvedW, height: resolvedH };\r\n }\r\n\r\n protected override renderSelf(ctx: RenderContext2D): void {\r\n ctx.draw(new Graphics2D().richText({\r\n spans: this.runs(),\r\n lineHeight: this.lineHeight,\r\n textAlign: this.textAlign,\r\n width: this.layoutBounds?.width ?? 0,\r\n height: this.layoutBounds?.height ?? 0,\r\n }));\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-base.d.ts","sourceRoot":"","sources":["../../../src/nodes/text/text-base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE9H,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAI1E,wFAAwF;AACxF,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC7C,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,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AI,SAAS,aAAa,EAAE;IAEhD,+EAA+E;IAC/E,SAAS,CAAC,SAAS,IAAI,SAAS,eAAe,EAAE;cAQ9B,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;cAOrC,gBAAgB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI;IAMrE,OAAO,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IA+E/E;;;;;;;;;;OAUG;IACH,SAAS,CAAC,aAAa,IAAI,WAAW,EAAE,GAAG,IAAI;IAsH/C;;;;OAIG;IACM,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAahD;;;;;;;OAOG;IACH,gBAAgB;IAChB,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;IA4BhC,OAAO,CAAC,cAAc;cAKH,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;cAgBtC,YAAY,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IAQ3D,OAAO,CAAC,UAAU;CAGrB"}
|
|
@@ -365,7 +365,7 @@ __decorate([
|
|
|
365
365
|
property()
|
|
366
366
|
], TextBase.prototype, "fontFamily", void 0);
|
|
367
367
|
__decorate([
|
|
368
|
-
property({ default: 48 })
|
|
368
|
+
property({ default: 48, tween: textOps.lerpFontSize })
|
|
369
369
|
], TextBase.prototype, "fontSize", void 0);
|
|
370
370
|
__decorate([
|
|
371
371
|
property({ default: 400 })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-base.js","sourceRoot":"","sources":["../../../src/nodes/text/text-base.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAc,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAO7D,OAAO,EAAE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AO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjE,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC;QACpG,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACd,KAAK,GAAG,CAAC,CAAC;QACd,CAAC;aAAM,IAAI,KAAK,GAAG,CAAC,IAAI,QAAQ,EAAE,CAAC;YAC/B,KAAK,IAAI,CAAC,CAAC;QACf,CAAC;aAAM,CAAC;YACJ,KAAK,EAAE,CAAC;YACR,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import type { FontStyle, ResolvedTextRun, TextAlign, TextCase, TextDecoration, VerticalAlign } from \"@/attributes/text/types\";\nimport { textOps } from \"@/attributes/text/ops\";\nimport { PaintNode, PaintProps } from \"@/nodes/2d/paint-node\";\nimport { property } from \"@/attributes/properties/decorator\";\nimport { NodeConfig } from \"@/nodes/2d/node2d\";\nimport { ContextMap } from \"@/util/context\";\nimport { SizeConstraints } from \"@/layout/constraints\";\nimport { MeasureContext2D } from \"@/render/measure-context\";\nimport { Size2D } from \"@/attributes/layout/size\";\nimport { RenderContext2D } from \"@/render/render-context2d\";\nimport { Graphics2D } from \"@/render/graphics2d\";\nimport { TextSegment, TextState } from \"@/render/descriptors/text\";\nimport { FillResolved } from \"@/attributes/shape/fill/union\";\nimport type { AssetScope } from \"@/assets/scope\";\nimport { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport { PathData } from \"@/render/descriptors/path\";\nimport { pathOps } from \"@/attributes/shape/path/ops\";\nimport { AUTOFIT_PROBE_SIZE, type TextSelection } from \"./text-selection\";\nimport { applyTextDefaults } from \"./default-text-style-node\";\n\n\n/** The fields a string is shaped and set by, shared by every node that draws glyphs. */\nexport interface TextBaseProps extends PaintProps {\n fontSize: number | 'autofit';\n fontFamily: string;\n fontWeight: number;\n fontStyle: FontStyle;\n letterSpacing: number;\n lineHeight: number;\n textAlign: TextAlign;\n verticalAlign: VerticalAlign;\n textDecoration: TextDecoration;\n textCase: TextCase;\n minFontSize: number;\n /**\n * Name of a typography preset from `theme.typography` (e.g. `\"header\"`).\n * Supplies any text-style prop (fontSize, fontWeight, …) not set explicitly\n * here. An explicit prop always wins over the preset; the preset wins over an\n * inherited `<DefaultTextStyle>`.\n */\n variant: string;\n}\n\n\n/**\n * **A node whose box is the box of some shaped glyphs.**\n *\n * Everything about setting a string in a face — the shaping props, the\n * cascade that fills them in, measuring the block, declaring the fonts it needs\n * and drawing it — and nothing about *where the string comes from*, which is\n * {@link displayText}'s and is the only thing its subclasses disagree about.\n * {@link Text} is handed one and lets an author edit it; {@link NumberNode}\n * derives one from a number and a format.\n *\n * That seam is the reason this class exists rather than `NumberNode extends\n * Text`. A figure is not a string: `append`, `prepend`, `find`, `word`,\n * `wrap` and the `text` prop itself are all operations on copy somebody typed,\n * and a number inheriting them offered an editor a Content field over a value it\n * could not write to and a \"Append Text\" command over a quantity. What the two\n * genuinely share is glyphs, and that is what is here.\n *\n * **Not `Intl`, anywhere below this.** A scene is a picture with a fixed layout;\n * see {@link NumberNode} for the argument.\n */\nexport abstract class TextBase<P extends TextBaseProps = TextBaseProps> extends PaintNode<P> {\n\n /**\n * The family this text is set in. **No default** — it comes from the cascade\n * in `applyTextDefaults`: what the author passed, else a `variant` preset,\n * else the nearest enclosing `<DefaultTextStyle>`, else the theme's `default`\n * typography preset.\n *\n * A literal default here would sit *under* all four and quietly win whenever\n * every one of them was silent, which is precisely the case worth hearing\n * about: text set in a face nobody chose is text whose font was never\n * declared and so never loaded. Left unset, the renderer says so instead —\n * see `requireFontFamily`.\n */\n @property() declare readonly fontFamily: string;\n @property({ default: 48 }) declare readonly fontSize: number | 'autofit';\n @property({ default: 400 }) declare readonly fontWeight: number;\n @property({ default: 'normal' }) declare readonly fontStyle: FontStyle;\n @property({ default: 0 }) declare readonly letterSpacing: number;\n @property({ default: 1.2 }) declare readonly lineHeight: number;\n @property({ default: 'center' }) declare readonly textAlign: TextAlign;\n @property({ default: 'center', kind: 'enum', options: ['top', 'center', 'bottom'] satisfies VerticalAlign[] })\n declare readonly verticalAlign: VerticalAlign;\n @property({ default: 'none', kind: 'enum', options: ['none', 'underline', 'line-through'] satisfies TextDecoration[] })\n declare readonly textDecoration: TextDecoration;\n @property({ default: 'none', kind: 'enum', options: ['none', 'upper', 'lower', 'title'] satisfies TextCase[] })\n declare readonly textCase: TextCase;\n @property({ default: 12 }) declare readonly minFontSize: number;\n @property({ default: undefined }) declare readonly variant?: string;\n\n /**\n * The string this node draws, this frame.\n *\n * Read fresh everywhere below rather than cached into a prop, so a subclass\n * deriving it from other props — a figure from its value and its format —\n * reformats and redraws without owning a binding of its own.\n */\n abstract displayText(): string;\n\n /** Whether long lines break — a single-line figure never does. */\n protected get wrapsText(): boolean { return false; }\n\n /** The path the glyphs ride, for a type that offers text-on-path. */\n protected get glyphPath(): PathData | null { return null; }\n\n /**\n * Live per-range style overrides — {@link Text}'s selections. A derived\n * string has no ranges anyone could have selected, so the base answers with\n * none and {@link buildSegments} keeps only the reveal window.\n */\n protected styledRuns(): readonly TextSelection[] { return []; }\n\n /** Stretches a document styles apart from the node — {@link Text}'s `runs`. */\n protected styleRuns(): readonly ResolvedTextRun[] { return []; }\n\n // Inherit text-style defaults from the nearest ancestor <DefaultTextStyle>\n // for any style prop the author didn't set. This is context-value application\n // (structure is fixed — a glyph node has no children), so it belongs in\n // resolveContext, which runs once after the tree + context exist. Writing\n // through _writeProp applies each field's own mapper (e.g. `fill`'s color\n // resolver) once.\n protected override resolveContext(ctx: ContextMap): void {\n applyTextDefaults(this, this._props as Record<string, unknown> | undefined);\n }\n\n // Glyphs don't hug/fill based on children (there are none) — they hug their\n // own glyph box by default, filling only when the box has to be resolved\n // externally: `autofit` measures glyphs against the allotted box.\n protected override applyDefaultSize(props?: NodeConfig<any, P>): void {\n const autofit = props?.fontSize === 'autofit';\n this.applyProp(\"height\", props?.height ?? (autofit ? \"fill\" : \"hug\"));\n this.applyProp(\"width\", props?.width ?? (autofit ? \"fill\" : \"hug\"));\n }\n\n measure(constraints: SizeConstraints, scope: MeasureContext2D): Partial<Size2D> {\n // Text-on-path: the visual extent is the path's bounding box, not a text\n // line box. Size the node to the path (node-local coords, like Path).\n const glyphPath = this.glyphPath;\n if (glyphPath != null) {\n const { width, height } = pathOps.size(glyphPath);\n const wm = this.width;\n const hm = this.height;\n return {\n width: typeof wm === \"number\" ? wm : wm === \"hug\" ? width : (constraints.maxWidth ?? width),\n height: typeof hm === \"number\" ? hm : hm === \"hug\" ? height : (constraints.maxHeight ?? height),\n };\n }\n\n const measureFontSize = this.fontSize === 'autofit' ? 16 : this.fontSize;\n const paragraphs = this._casedText().split(\"\\n\");\n\n // A styled run changes the box, which is why measuring cannot read the\n // node's five font fields and stop there: one word set two sizes up makes\n // the line taller and the block wider, and a node that hugs its glyphs\n // would hug a box measured for text nobody is looking at. So when\n // selections are live the intrinsic size is summed across the *pieces*,\n // each in its own style - see {@link measureStyledLines}.\n const styled = this.buildSegments();\n const lineStyles = styled === null\n ? null\n : measureStyledLines(styled, {\n fontFamily: this.fontFamily,\n fontSize: measureFontSize,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n letterSpacing: this.letterSpacing,\n });\n\n const lineH = measureFontSize * this.lineHeight;\n const intrinsicW = lineStyles\n ? Math.max(...lineStyles.map(line => line.runs.reduce(\n (w, run) => w + scope.measureText(run.text, run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width,\n 0,\n )))\n : Math.max(...paragraphs.map(l => scope.measureText(l, measureFontSize, this.fontFamily, this.fontWeight, this.letterSpacing, this.fontStyle).width));\n\n const wm = this.width;\n const hm = this.height;\n\n const resolvedW = typeof wm === \"number\"\n ? wm\n : wm === \"hug\"\n ? intrinsicW\n : constraints.maxWidth ?? 0;\n\n // When wrap is on and the box has a finite width narrower than the text,\n // height needs to account for the extra lines produced by wrapping.\n const wraps = this.wrapsText && resolvedW > 0;\n // Each line is as tall as its tallest run, so raising one word's size\n // opens the leading around it rather than letting it overprint the line\n // above.\n const lineSizes = lineStyles === null\n ? null\n : wraps\n ? wrappedLineSizes(lineStyles, resolvedW, scope)\n : lineStyles.map(line => Math.max(...line.runs.map(run => run.fontSize)));\n const intrinsicH = lineSizes\n ? lineSizes.reduce((h, size) => h + size * this.lineHeight, 0)\n : (wraps\n ? paragraphs.reduce((n, p) => n + countWrappedLines(p, resolvedW, measureFontSize, this.fontFamily, this.fontWeight, scope, this.letterSpacing, this.fontStyle), 0)\n : paragraphs.length) * lineH;\n\n // \"fill\" still reports the intrinsic wrapped height when measuring —\n // it's layout (not measure) that stretches a fill child to its final\n // box. This lets a hug ancestor see the text's real content height\n // instead of an arbitrary borrowed constraint.\n const resolvedH = typeof hm === \"number\"\n ? hm\n : intrinsicH;\n\n return { width: resolvedW, height: resolvedH };\n }\n\n /**\n * Split the string into contiguous pieces at every style boundary, resolving\n * each piece's effective overrides per the overlap rule: later-created\n * selections win for transform/paint/font; opacity multiplies across all\n * selections covering the piece. Also folds in the Write On reveal window\n * (see below). Returns null when neither is active, so rendering keeps its\n * single-op path.\n *\n * Text-on-path has no pieces in v1 — the string is laid along the path as\n * one run — so a node with a path is answered `null` before anything else.\n */\n protected buildSegments(): TextSegment[] | null {\n if (this.glyphPath != null) return null;\n const active = this.styledRuns().filter(s => s.ranges.length > 0 && !s.isIdentity);\n const runs = this.styleRuns().filter(r => r.end > r.start);\n const text = this._casedText();\n if (text.length === 0) return null;\n\n // Write On: `start`/`end` are PaintNode's outline-trim fractions\n // everywhere else, but a glyph has no path to trim geometrically — this\n // CanvasKit build can't get glyph outlines at all (see\n // drawTextUnionStroke in the skia-render stroke handler). Glyph nodes\n // reinterpret the same pair as a character-reveal window instead:\n // opacity over a character range rather than a geometric trim.\n const hasReveal = this.start > 0 || this.end < 1;\n // The fast path survives both: a node with no live selection and no\n // reveal window renders as one string, exactly as it did before either\n // existed.\n if (active.length === 0 && runs.length === 0 && !hasReveal) return null;\n\n // Rounded to the nearest whole character — a hard cut, not a fade. Write\n // On reveals one character at a time, the way DaVinci's does; a fractional\n // in-between character read as an opinionated flourish nobody asked for.\n const revealStart = Math.round(this.start * text.length);\n const revealEnd = Math.round(this.end * text.length);\n\n // The size every piece starts from. `'autofit'` settles on a size the\n // *block* is measured into, which no single piece can be asked for, so\n // the segmented path shapes at the same probe size a selection's\n // `fontSize` override starts from - one number, stated in one place.\n const nodeFontSize = typeof this.fontSize === \"number\"\n ? this.fontSize\n : AUTOFIT_PROBE_SIZE;\n\n // Boundaries at every range edge so each piece is covered uniformly.\n const cuts = new Set<number>([0, text.length]);\n for (const run of runs) { cuts.add(run.start); cuts.add(run.end); }\n for (const sel of active) {\n for (const r of sel.ranges) { cuts.add(r.start); cuts.add(r.end); }\n }\n if (hasReveal) {\n cuts.add(revealStart);\n cuts.add(revealEnd);\n }\n const points = [...cuts].filter(c => c >= 0 && c <= text.length).sort((a, b) => a - b);\n\n const segments: TextSegment[] = [];\n for (let i = 0; i < points.length - 1; i++) {\n const start = points[i];\n const end = points[i + 1];\n if (end <= start) continue;\n\n const seg: TextSegment = {\n text: text.slice(start, end),\n // Every shaping field is stated, not left for the renderer to\n // fill in: a piece whose family or size differs from the node's\n // is the point of the model, and a segment that says nothing\n // about one of them would be a piece the paragraph builder\n // styles from the node while the caret measures from the\n // segment. See {@link TextSegment}.\n fontFamily: this.fontFamily,\n fontSize: nodeFontSize,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n letterSpacing: this.letterSpacing,\n textDecoration: this.textDecoration,\n opacity: 1,\n x: 0,\n y: 0,\n scale: 1,\n rotation: 0,\n // Default to the node's paint; selections override below. Each\n // segment is self-contained so the renderer draws runs eagerly.\n fill: this.fill as FillResolved[],\n stroke: this.stroke as StrokeResolved[],\n };\n\n // The document's styling first, so a selection animates *from* it.\n for (const run of runs) {\n if (start < run.start || end > run.end) continue;\n if (run.fontFamily !== undefined) seg.fontFamily = run.fontFamily;\n if (run.fontSize !== undefined) seg.fontSize = run.fontSize;\n if (run.fontStyle !== undefined) seg.fontStyle = run.fontStyle;\n if (run.fontWeight !== undefined) seg.fontWeight = run.fontWeight;\n if (run.letterSpacing !== undefined) seg.letterSpacing = run.letterSpacing;\n if (run.textDecoration !== undefined) seg.textDecoration = run.textDecoration;\n if (run.fill !== undefined) seg.fill = run.fill;\n if (run.stroke !== undefined) seg.stroke = run.stroke;\n }\n\n // Apply in creation order: opacity multiplies, others last-wins. A\n // shaping field a selection still holds at the node's own value is\n // one it never touched, and must not undo a run's.\n for (const sel of active) {\n if (!sel.ranges.some(r => start >= r.start && end <= r.end)) continue;\n const o = sel.overrides;\n seg.opacity *= o.opacity;\n seg.x = o.x;\n seg.y = o.y;\n seg.scale = o.scale;\n seg.rotation = o.rotation;\n if (o.fontFamily !== this.fontFamily) seg.fontFamily = o.fontFamily;\n if (o.fontSize !== nodeFontSize) seg.fontSize = o.fontSize;\n if (o.fontStyle !== this.fontStyle) seg.fontStyle = o.fontStyle;\n if (o.fontWeight !== this.fontWeight) seg.fontWeight = o.fontWeight;\n if (o.letterSpacing !== this.letterSpacing) seg.letterSpacing = o.letterSpacing;\n if (o.fill !== null) seg.fill = o.fill;\n if (o.stroke !== null) seg.stroke = o.stroke;\n }\n\n if (hasReveal && !(start >= revealStart && end <= revealEnd)) {\n seg.opacity = 0;\n }\n\n segments.push(seg);\n }\n return segments;\n }\n\n /**\n * The node's own face and paint, plus whatever a selection puts on part of the\n * string. Naming a family here is what lets it load *before* layout, rather\n * than being discovered by measuring text against the fallback face.\n */\n override declareAssets(assets: AssetScope): void {\n super.declareAssets(assets);\n // Nothing may name a family at all, and the renderer then shapes with\n // whatever is registered; an `undefined` key is not a font to load.\n if (this.fontFamily) assets.font(this.fontFamily, this.fontWeight);\n for (const segment of this.buildSegments() ?? []) {\n const family = segment.fontFamily ?? this.fontFamily;\n if (family) assets.font(family, segment.fontWeight);\n assets.fill(segment.fill ?? []);\n for (const stroke of segment.stroke ?? []) assets.fill(stroke.fill);\n }\n }\n\n /**\n * The descriptor this node draws itself as, at the current frame.\n *\n * `@internal` — split out of {@link textOpGraphics} so `node-picking`'s\n * caret geometry can be measured from *the same* state that gets painted.\n * Deriving the two separately is how a caret ends up half a pixel — or, once\n * `'autofit'` or wrapping is in play, half a line — away from its glyph.\n */\n /** @internal */\n _textState(): Partial<TextState> {\n return {\n text: this._casedText(),\n fontSize: this.fontSize,\n fontFamily: this.fontFamily,\n fontWeight: this.fontWeight,\n fontStyle: this.fontStyle,\n letterSpacing: this.letterSpacing,\n lineHeight: this.lineHeight,\n textAlign: this.textAlign,\n verticalAlign: this.verticalAlign,\n textDecoration: this.textDecoration,\n wrap: this.wrapsText,\n minFontSize: this.minFontSize,\n width: this.layoutBounds?.width ?? 0,\n height: this.layoutBounds?.height ?? 0,\n // Text-on-path and selection segments are mutually exclusive in v1:\n // `buildSegments` answers null while a path is set, and the single\n // string is laid out along it instead.\n segments: this.buildSegments() ?? undefined,\n path: this.glyphPath,\n };\n }\n\n // The bare text op as a Graphics2D (no paint), plus whether selection segments\n // are active. Glyphs have no single fillable silhouette path, so the generic\n // PaintNode.shapeGraphics() stays null and these nodes drive their own stroke\n // pass off this builder instead.\n private textOpGraphics(): { g: Graphics2D; segments: boolean } {\n const state = this._textState();\n return { g: new Graphics2D().text(state), segments: state.segments != null };\n }\n\n protected override renderSelf(ctx: RenderContext2D): void {\n const { g, segments } = this.textOpGraphics();\n g.shadow(this.shadow);\n // With segments the renderer paints each run eagerly with the segment's\n // own fill/stroke (so per-selection overrides apply), so the node-level\n // fill/stroke ops are omitted to avoid double-painting. Text-on-path uses\n // the normal deferred path, so its node-level fill applies here; its stroke\n // is deferred to renderStroke.\n if (!segments) {\n g.fill(this.fill);\n }\n ctx.draw(g);\n }\n\n // The stroke only applies to the non-segment / text-on-path case; the\n // segmented branch paints its own fill/stroke per run in renderSelf.\n protected override renderStroke(ctx: RenderContext2D): void {\n const stroke = this.stroke as StrokeResolved[];\n if (stroke.length === 0) return;\n const { g, segments } = this.textOpGraphics();\n if (segments) return;\n ctx.draw(g.stroke(stroke));\n }\n\n private _casedText(): string {\n return textOps.applyCase(this.displayText(), this.textCase);\n }\n}\n\n/**\n * One shaped piece of a line, as {@link TextBase.measure} needs it: its text and\n * the five fields a measurement is taken against.\n */\ninterface StyledRun {\n text: string;\n fontFamily: string;\n fontSize: number;\n fontStyle: FontStyle;\n fontWeight: number;\n letterSpacing: number;\n}\n\n/**\n * Split `segments` into lines at every `\\n`, resolving each piece against\n * `fallback` for the fields it leaves unstated.\n *\n * A segment can span a line break - the cuts are made at *selection* edges, and\n * a selection over two lines is one range - so the break has to be found inside\n * the piece rather than between pieces. The newline itself joins neither line,\n * which is what makes an empty line come back as a run of `\"\"` (in the node's\n * own style) rather than disappearing from the count.\n */\nfunction measureStyledLines(\n segments: TextSegment[],\n fallback: Omit<StyledRun, \"text\">,\n): { runs: StyledRun[] }[] {\n const lines: { runs: StyledRun[] }[] = [{ runs: [] }];\n for (const segment of segments) {\n const style: Omit<StyledRun, \"text\"> = {\n fontFamily: segment.fontFamily ?? fallback.fontFamily,\n fontSize: segment.fontSize ?? fallback.fontSize,\n fontStyle: segment.fontStyle ?? fallback.fontStyle,\n fontWeight: segment.fontWeight,\n letterSpacing: segment.letterSpacing,\n };\n const parts = segment.text.split(\"\\n\");\n for (let i = 0; i < parts.length; i++) {\n if (i > 0) lines.push({ runs: [] });\n lines[lines.length - 1].runs.push({ text: parts[i], ...style });\n }\n }\n // A line the loop above never wrote a run onto still has to be measured\n // against something, and the node's own style is the only honest answer.\n for (const line of lines) {\n if (line.runs.length === 0) line.runs.push({ ...fallback, text: \"\" });\n }\n return lines;\n}\n\n/**\n * The size each line of `lines` is set at once wrapped to `maxWidth`: the\n * greedy whitespace break {@link countWrappedLines} makes, but with every piece\n * measured in its own style. A word split across two styles is still one word.\n */\nfunction wrappedLineSizes(\n lines: { runs: StyledRun[] }[],\n maxWidth: number,\n scope: MeasureContext2D,\n): number[] {\n const sizes: number[] = [];\n for (const line of lines) {\n const tokens: { width: number; size: number; space: boolean }[] = [];\n for (const run of line.runs) {\n for (const part of run.text.split(/(\\s+)/)) {\n if (part.length === 0) continue;\n const space = /^\\s+$/.test(part);\n const width = scope.measureText(part, run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width;\n const last = tokens[tokens.length - 1];\n if (last && !last.space && !space) {\n last.width += width;\n last.size = Math.max(last.size, run.fontSize);\n } else {\n tokens.push({ width, size: run.fontSize, space });\n }\n }\n }\n if (tokens.length === 0) {\n sizes.push(Math.max(...line.runs.map(run => run.fontSize)));\n continue;\n }\n let lineW = tokens[0].width;\n let size = tokens[0].size;\n for (const token of tokens.slice(1)) {\n if (lineW + token.width <= maxWidth) {\n lineW += token.width;\n size = Math.max(size, token.size);\n } else {\n sizes.push(size);\n lineW = token.space ? 0 : token.width;\n size = token.space ? 0 : token.size;\n }\n }\n sizes.push(size > 0 ? size : Math.max(...line.runs.map(run => run.fontSize)));\n }\n return sizes;\n}\n\nfunction countWrappedLines(\n paragraph: string,\n maxWidth: number,\n fontSize: number,\n fontFamily: string,\n fontWeight: number,\n scope: MeasureContext2D,\n letterSpacing: number = 0,\n fontStyle: FontStyle = 'normal',\n): number {\n if (paragraph.length === 0) return 1;\n if (scope.measureText(paragraph, fontSize, fontFamily, fontWeight, letterSpacing, fontStyle).width <= maxWidth) return 1;\n\n const words = paragraph.split(/(\\s+)/).filter(s => s.length > 0);\n let lines = 1;\n let lineW = 0;\n for (const word of words) {\n const w = scope.measureText(word, fontSize, fontFamily, fontWeight, letterSpacing, fontStyle).width;\n if (lineW === 0) {\n lineW = w;\n } else if (lineW + w <= maxWidth) {\n lineW += w;\n } else {\n lines++;\n lineW = /^\\s+$/.test(word) ? 0 : w;\n }\n }\n return lines;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"text-base.js","sourceRoot":"","sources":["../../../src/nodes/text/text-base.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAc,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAO7D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMjD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAsB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA0B9D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAgB,QAAkD,SAAQ,SAAY;IAyCxF,kEAAkE;IAClE,IAAc,SAAS,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAEpD,qEAAqE;IACrE,IAAc,SAAS,KAAsB,OAAO,IAAI,CAAC,CAAC,CAAC;IAE3D;;;;OAIG;IACO,UAAU,KAA+B,OAAO,EAAE,CAAC,CAAC,CAAC;IAE/D,+EAA+E;IACrE,SAAS,KAAiC,OAAO,EAAE,CAAC,CAAC,CAAC;IAEhE,2EAA2E;IAC3E,8EAA8E;IAC9E,wEAAwE;IACxE,0EAA0E;IAC1E,0EAA0E;IAC1E,kBAAkB;IACC,cAAc,CAAC,GAAe;QAC7C,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,MAA6C,CAAC,CAAC;IAChF,CAAC;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D,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import type { FontStyle, ResolvedTextRun, TextAlign, TextCase, TextDecoration, VerticalAlign } from \"@/attributes/text/types\";\r\nimport { textOps } from \"@/attributes/text/ops\";\r\nimport { PaintNode, PaintProps } from \"@/nodes/2d/paint-node\";\r\nimport { property } from \"@/attributes/properties/decorator\";\r\nimport { NodeConfig } from \"@/nodes/2d/node2d\";\r\nimport { ContextMap } from \"@/util/context\";\r\nimport { SizeConstraints } from \"@/layout/constraints\";\r\nimport { MeasureContext2D } from \"@/render/measure-context\";\r\nimport { Size2D } from \"@/attributes/layout/size\";\r\nimport { RenderContext2D } from \"@/render/render-context2d\";\r\nimport { Graphics2D } from \"@/render/graphics2d\";\r\nimport { TextSegment, TextState } from \"@/render/descriptors/text\";\r\nimport { FillResolved } from \"@/attributes/shape/fill/union\";\r\nimport type { AssetScope } from \"@/assets/scope\";\r\nimport { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\r\nimport { PathData } from \"@/render/descriptors/path\";\r\nimport { pathOps } from \"@/attributes/shape/path/ops\";\r\nimport { AUTOFIT_PROBE_SIZE, type TextSelection } from \"./text-selection\";\r\nimport { applyTextDefaults } from \"./default-text-style-node\";\r\n\r\n\r\n/** The fields a string is shaped and set by, shared by every node that draws glyphs. */\r\nexport interface TextBaseProps extends PaintProps {\r\n fontSize: number | 'autofit';\r\n fontFamily: string;\r\n fontWeight: number;\r\n fontStyle: FontStyle;\r\n letterSpacing: number;\r\n lineHeight: number;\r\n textAlign: TextAlign;\r\n verticalAlign: VerticalAlign;\r\n textDecoration: TextDecoration;\r\n textCase: TextCase;\r\n minFontSize: number;\r\n /**\r\n * Name of a typography preset from `theme.typography` (e.g. `\"header\"`).\r\n * Supplies any text-style prop (fontSize, fontWeight, …) not set explicitly\r\n * here. An explicit prop always wins over the preset; the preset wins over an\r\n * inherited `<DefaultTextStyle>`.\r\n */\r\n variant: string;\r\n}\r\n\r\n\r\n/**\r\n * **A node whose box is the box of some shaped glyphs.**\r\n *\r\n * Everything about setting a string in a face — the shaping props, the\r\n * cascade that fills them in, measuring the block, declaring the fonts it needs\r\n * and drawing it — and nothing about *where the string comes from*, which is\r\n * {@link displayText}'s and is the only thing its subclasses disagree about.\r\n * {@link Text} is handed one and lets an author edit it; {@link NumberNode}\r\n * derives one from a number and a format.\r\n *\r\n * That seam is the reason this class exists rather than `NumberNode extends\r\n * Text`. A figure is not a string: `append`, `prepend`, `find`, `word`,\r\n * `wrap` and the `text` prop itself are all operations on copy somebody typed,\r\n * and a number inheriting them offered an editor a Content field over a value it\r\n * could not write to and a \"Append Text\" command over a quantity. What the two\r\n * genuinely share is glyphs, and that is what is here.\r\n *\r\n * **Not `Intl`, anywhere below this.** A scene is a picture with a fixed layout;\r\n * see {@link NumberNode} for the argument.\r\n */\r\nexport abstract class TextBase<P extends TextBaseProps = TextBaseProps> extends PaintNode<P> {\r\n\r\n /**\r\n * The family this text is set in. **No default** — it comes from the cascade\r\n * in `applyTextDefaults`: what the author passed, else a `variant` preset,\r\n * else the nearest enclosing `<DefaultTextStyle>`, else the theme's `default`\r\n * typography preset.\r\n *\r\n * A literal default here would sit *under* all four and quietly win whenever\r\n * every one of them was silent, which is precisely the case worth hearing\r\n * about: text set in a face nobody chose is text whose font was never\r\n * declared and so never loaded. Left unset, the renderer says so instead —\r\n * see `requireFontFamily`.\r\n */\r\n @property() declare readonly fontFamily: string;\r\n // `'autofit'` is a mode, not a magnitude: the shared rule steps it at the\r\n // midpoint, where the numeric cell tween would compute `'autofit' + …` = NaN.\r\n @property({ default: 48, tween: textOps.lerpFontSize }) declare readonly fontSize: number | 'autofit';\r\n @property({ default: 400 }) declare readonly fontWeight: number;\r\n @property({ default: 'normal' }) declare readonly fontStyle: FontStyle;\r\n @property({ default: 0 }) declare readonly letterSpacing: number;\r\n @property({ default: 1.2 }) declare readonly lineHeight: number;\r\n @property({ default: 'center' }) declare readonly textAlign: TextAlign;\r\n @property({ default: 'center', kind: 'enum', options: ['top', 'center', 'bottom'] satisfies VerticalAlign[] })\r\n declare readonly verticalAlign: VerticalAlign;\r\n @property({ default: 'none', kind: 'enum', options: ['none', 'underline', 'line-through'] satisfies TextDecoration[] })\r\n declare readonly textDecoration: TextDecoration;\r\n @property({ default: 'none', kind: 'enum', options: ['none', 'upper', 'lower', 'title'] satisfies TextCase[] })\r\n declare readonly textCase: TextCase;\r\n @property({ default: 12 }) declare readonly minFontSize: number;\r\n @property({ default: undefined }) declare readonly variant?: string;\r\n\r\n /**\r\n * The string this node draws, this frame.\r\n *\r\n * Read fresh everywhere below rather than cached into a prop, so a subclass\r\n * deriving it from other props — a figure from its value and its format —\r\n * reformats and redraws without owning a binding of its own.\r\n */\r\n abstract displayText(): string;\r\n\r\n /** Whether long lines break — a single-line figure never does. */\r\n protected get wrapsText(): boolean { return false; }\r\n\r\n /** The path the glyphs ride, for a type that offers text-on-path. */\r\n protected get glyphPath(): PathData | null { return null; }\r\n\r\n /**\r\n * Live per-range style overrides — {@link Text}'s selections. A derived\r\n * string has no ranges anyone could have selected, so the base answers with\r\n * none and {@link buildSegments} keeps only the reveal window.\r\n */\r\n protected styledRuns(): readonly TextSelection[] { return []; }\r\n\r\n /** Stretches a document styles apart from the node — {@link Text}'s `runs`. */\r\n protected styleRuns(): readonly ResolvedTextRun[] { return []; }\r\n\r\n // Inherit text-style defaults from the nearest ancestor <DefaultTextStyle>\r\n // for any style prop the author didn't set. This is context-value application\r\n // (structure is fixed — a glyph node has no children), so it belongs in\r\n // resolveContext, which runs once after the tree + context exist. Writing\r\n // through _writeProp applies each field's own mapper (e.g. `fill`'s color\r\n // resolver) once.\r\n protected override resolveContext(ctx: ContextMap): void {\r\n applyTextDefaults(this, this._props as Record<string, unknown> | undefined);\r\n }\r\n\r\n // Glyphs don't hug/fill based on children (there are none) — they hug their\r\n // own glyph box by default, filling only when the box has to be resolved\r\n // externally: `autofit` measures glyphs against the allotted box.\r\n protected override applyDefaultSize(props?: NodeConfig<any, P>): void {\r\n const autofit = props?.fontSize === 'autofit';\r\n this.applyProp(\"height\", props?.height ?? (autofit ? \"fill\" : \"hug\"));\r\n this.applyProp(\"width\", props?.width ?? (autofit ? \"fill\" : \"hug\"));\r\n }\r\n\r\n measure(constraints: SizeConstraints, scope: MeasureContext2D): Partial<Size2D> {\r\n // Text-on-path: the visual extent is the path's bounding box, not a text\r\n // line box. Size the node to the path (node-local coords, like Path).\r\n const glyphPath = this.glyphPath;\r\n if (glyphPath != null) {\r\n const { width, height } = pathOps.size(glyphPath);\r\n const wm = this.width;\r\n const hm = this.height;\r\n return {\r\n width: typeof wm === \"number\" ? wm : wm === \"hug\" ? width : (constraints.maxWidth ?? width),\r\n height: typeof hm === \"number\" ? hm : hm === \"hug\" ? height : (constraints.maxHeight ?? height),\r\n };\r\n }\r\n\r\n const measureFontSize = this.fontSize === 'autofit' ? 16 : this.fontSize;\r\n const paragraphs = this._casedText().split(\"\\n\");\r\n\r\n // A styled run changes the box, which is why measuring cannot read the\r\n // node's five font fields and stop there: one word set two sizes up makes\r\n // the line taller and the block wider, and a node that hugs its glyphs\r\n // would hug a box measured for text nobody is looking at. So when\r\n // selections are live the intrinsic size is summed across the *pieces*,\r\n // each in its own style - see {@link measureStyledLines}.\r\n const styled = this.buildSegments();\r\n const lineStyles = styled === null\r\n ? null\r\n : measureStyledLines(styled, {\r\n fontFamily: this.fontFamily,\r\n fontSize: measureFontSize,\r\n fontStyle: this.fontStyle,\r\n fontWeight: this.fontWeight,\r\n letterSpacing: this.letterSpacing,\r\n });\r\n\r\n const lineH = measureFontSize * this.lineHeight;\r\n const intrinsicW = lineStyles\r\n ? Math.max(...lineStyles.map(line => line.runs.reduce(\r\n (w, run) => w + scope.measureText(run.text, run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width,\r\n 0,\r\n )))\r\n : Math.max(...paragraphs.map(l => scope.measureText(l, measureFontSize, this.fontFamily, this.fontWeight, this.letterSpacing, this.fontStyle).width));\r\n\r\n const wm = this.width;\r\n const hm = this.height;\r\n\r\n const resolvedW = typeof wm === \"number\"\r\n ? wm\r\n : wm === \"hug\"\r\n ? intrinsicW\r\n : constraints.maxWidth ?? 0;\r\n\r\n // When wrap is on and the box has a finite width narrower than the text,\r\n // height needs to account for the extra lines produced by wrapping.\r\n const wraps = this.wrapsText && resolvedW > 0;\r\n // Each line is as tall as its tallest run, so raising one word's size\r\n // opens the leading around it rather than letting it overprint the line\r\n // above.\r\n const lineSizes = lineStyles === null\r\n ? null\r\n : wraps\r\n ? wrappedLineSizes(lineStyles, resolvedW, scope)\r\n : lineStyles.map(line => Math.max(...line.runs.map(run => run.fontSize)));\r\n const intrinsicH = lineSizes\r\n ? lineSizes.reduce((h, size) => h + size * this.lineHeight, 0)\r\n : (wraps\r\n ? paragraphs.reduce((n, p) => n + countWrappedLines(p, resolvedW, measureFontSize, this.fontFamily, this.fontWeight, scope, this.letterSpacing, this.fontStyle), 0)\r\n : paragraphs.length) * lineH;\r\n\r\n // \"fill\" still reports the intrinsic wrapped height when measuring —\r\n // it's layout (not measure) that stretches a fill child to its final\r\n // box. This lets a hug ancestor see the text's real content height\r\n // instead of an arbitrary borrowed constraint.\r\n const resolvedH = typeof hm === \"number\"\r\n ? hm\r\n : intrinsicH;\r\n\r\n return { width: resolvedW, height: resolvedH };\r\n }\r\n\r\n /**\r\n * Split the string into contiguous pieces at every style boundary, resolving\r\n * each piece's effective overrides per the overlap rule: later-created\r\n * selections win for transform/paint/font; opacity multiplies across all\r\n * selections covering the piece. Also folds in the Write On reveal window\r\n * (see below). Returns null when neither is active, so rendering keeps its\r\n * single-op path.\r\n *\r\n * Text-on-path has no pieces in v1 — the string is laid along the path as\r\n * one run — so a node with a path is answered `null` before anything else.\r\n */\r\n protected buildSegments(): TextSegment[] | null {\r\n if (this.glyphPath != null) return null;\r\n const active = this.styledRuns().filter(s => s.ranges.length > 0 && !s.isIdentity);\r\n const runs = this.styleRuns().filter(r => r.end > r.start);\r\n const text = this._casedText();\r\n if (text.length === 0) return null;\r\n\r\n // Write On: `start`/`end` are PaintNode's outline-trim fractions\r\n // everywhere else, but a glyph has no path to trim geometrically — this\r\n // CanvasKit build can't get glyph outlines at all (see\r\n // drawTextUnionStroke in the skia-render stroke handler). Glyph nodes\r\n // reinterpret the same pair as a character-reveal window instead:\r\n // opacity over a character range rather than a geometric trim.\r\n const hasReveal = this.start > 0 || this.end < 1;\r\n // The fast path survives both: a node with no live selection and no\r\n // reveal window renders as one string, exactly as it did before either\r\n // existed.\r\n if (active.length === 0 && runs.length === 0 && !hasReveal) return null;\r\n\r\n // Rounded to the nearest whole character — a hard cut, not a fade. Write\r\n // On reveals one character at a time, the way DaVinci's does; a fractional\r\n // in-between character read as an opinionated flourish nobody asked for.\r\n const revealStart = Math.round(this.start * text.length);\r\n const revealEnd = Math.round(this.end * text.length);\r\n\r\n // The size every piece starts from. `'autofit'` settles on a size the\r\n // *block* is measured into, which no single piece can be asked for, so\r\n // the segmented path shapes at the same probe size a selection's\r\n // `fontSize` override starts from - one number, stated in one place.\r\n const nodeFontSize = typeof this.fontSize === \"number\"\r\n ? this.fontSize\r\n : AUTOFIT_PROBE_SIZE;\r\n\r\n // Boundaries at every range edge so each piece is covered uniformly.\r\n const cuts = new Set<number>([0, text.length]);\r\n for (const run of runs) { cuts.add(run.start); cuts.add(run.end); }\r\n for (const sel of active) {\r\n for (const r of sel.ranges) { cuts.add(r.start); cuts.add(r.end); }\r\n }\r\n if (hasReveal) {\r\n cuts.add(revealStart);\r\n cuts.add(revealEnd);\r\n }\r\n const points = [...cuts].filter(c => c >= 0 && c <= text.length).sort((a, b) => a - b);\r\n\r\n const segments: TextSegment[] = [];\r\n for (let i = 0; i < points.length - 1; i++) {\r\n const start = points[i];\r\n const end = points[i + 1];\r\n if (end <= start) continue;\r\n\r\n const seg: TextSegment = {\r\n text: text.slice(start, end),\r\n // Every shaping field is stated, not left for the renderer to\r\n // fill in: a piece whose family or size differs from the node's\r\n // is the point of the model, and a segment that says nothing\r\n // about one of them would be a piece the paragraph builder\r\n // styles from the node while the caret measures from the\r\n // segment. See {@link TextSegment}.\r\n fontFamily: this.fontFamily,\r\n fontSize: nodeFontSize,\r\n fontStyle: this.fontStyle,\r\n fontWeight: this.fontWeight,\r\n letterSpacing: this.letterSpacing,\r\n textDecoration: this.textDecoration,\r\n opacity: 1,\r\n x: 0,\r\n y: 0,\r\n scale: 1,\r\n rotation: 0,\r\n // Default to the node's paint; selections override below. Each\r\n // segment is self-contained so the renderer draws runs eagerly.\r\n fill: this.fill as FillResolved[],\r\n stroke: this.stroke as StrokeResolved[],\r\n };\r\n\r\n // The document's styling first, so a selection animates *from* it.\r\n for (const run of runs) {\r\n if (start < run.start || end > run.end) continue;\r\n if (run.fontFamily !== undefined) seg.fontFamily = run.fontFamily;\r\n if (run.fontSize !== undefined) seg.fontSize = run.fontSize;\r\n if (run.fontStyle !== undefined) seg.fontStyle = run.fontStyle;\r\n if (run.fontWeight !== undefined) seg.fontWeight = run.fontWeight;\r\n if (run.letterSpacing !== undefined) seg.letterSpacing = run.letterSpacing;\r\n if (run.textDecoration !== undefined) seg.textDecoration = run.textDecoration;\r\n if (run.fill !== undefined) seg.fill = run.fill;\r\n if (run.stroke !== undefined) seg.stroke = run.stroke;\r\n }\r\n\r\n // Apply in creation order: opacity multiplies, others last-wins. A\r\n // shaping field a selection still holds at the node's own value is\r\n // one it never touched, and must not undo a run's.\r\n for (const sel of active) {\r\n if (!sel.ranges.some(r => start >= r.start && end <= r.end)) continue;\r\n const o = sel.overrides;\r\n seg.opacity *= o.opacity;\r\n seg.x = o.x;\r\n seg.y = o.y;\r\n seg.scale = o.scale;\r\n seg.rotation = o.rotation;\r\n if (o.fontFamily !== this.fontFamily) seg.fontFamily = o.fontFamily;\r\n if (o.fontSize !== nodeFontSize) seg.fontSize = o.fontSize;\r\n if (o.fontStyle !== this.fontStyle) seg.fontStyle = o.fontStyle;\r\n if (o.fontWeight !== this.fontWeight) seg.fontWeight = o.fontWeight;\r\n if (o.letterSpacing !== this.letterSpacing) seg.letterSpacing = o.letterSpacing;\r\n if (o.fill !== null) seg.fill = o.fill;\r\n if (o.stroke !== null) seg.stroke = o.stroke;\r\n }\r\n\r\n if (hasReveal && !(start >= revealStart && end <= revealEnd)) {\r\n seg.opacity = 0;\r\n }\r\n\r\n segments.push(seg);\r\n }\r\n return segments;\r\n }\r\n\r\n /**\r\n * The node's own face and paint, plus whatever a selection puts on part of the\r\n * string. Naming a family here is what lets it load *before* layout, rather\r\n * than being discovered by measuring text against the fallback face.\r\n */\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n // Nothing may name a family at all, and the renderer then shapes with\r\n // whatever is registered; an `undefined` key is not a font to load.\r\n if (this.fontFamily) assets.font(this.fontFamily, this.fontWeight);\r\n for (const segment of this.buildSegments() ?? []) {\r\n const family = segment.fontFamily ?? this.fontFamily;\r\n if (family) assets.font(family, segment.fontWeight);\r\n assets.fill(segment.fill ?? []);\r\n for (const stroke of segment.stroke ?? []) assets.fill(stroke.fill);\r\n }\r\n }\r\n\r\n /**\r\n * The descriptor this node draws itself as, at the current frame.\r\n *\r\n * `@internal` — split out of {@link textOpGraphics} so `node-picking`'s\r\n * caret geometry can be measured from *the same* state that gets painted.\r\n * Deriving the two separately is how a caret ends up half a pixel — or, once\r\n * `'autofit'` or wrapping is in play, half a line — away from its glyph.\r\n */\r\n /** @internal */\r\n _textState(): Partial<TextState> {\r\n return {\r\n text: this._casedText(),\r\n fontSize: this.fontSize,\r\n fontFamily: this.fontFamily,\r\n fontWeight: this.fontWeight,\r\n fontStyle: this.fontStyle,\r\n letterSpacing: this.letterSpacing,\r\n lineHeight: this.lineHeight,\r\n textAlign: this.textAlign,\r\n verticalAlign: this.verticalAlign,\r\n textDecoration: this.textDecoration,\r\n wrap: this.wrapsText,\r\n minFontSize: this.minFontSize,\r\n width: this.layoutBounds?.width ?? 0,\r\n height: this.layoutBounds?.height ?? 0,\r\n // Text-on-path and selection segments are mutually exclusive in v1:\r\n // `buildSegments` answers null while a path is set, and the single\r\n // string is laid out along it instead.\r\n segments: this.buildSegments() ?? undefined,\r\n path: this.glyphPath,\r\n };\r\n }\r\n\r\n // The bare text op as a Graphics2D (no paint), plus whether selection segments\r\n // are active. Glyphs have no single fillable silhouette path, so the generic\r\n // PaintNode.shapeGraphics() stays null and these nodes drive their own stroke\r\n // pass off this builder instead.\r\n private textOpGraphics(): { g: Graphics2D; segments: boolean } {\r\n const state = this._textState();\r\n return { g: new Graphics2D().text(state), segments: state.segments != null };\r\n }\r\n\r\n protected override renderSelf(ctx: RenderContext2D): void {\r\n const { g, segments } = this.textOpGraphics();\r\n g.shadow(this.shadow);\r\n // With segments the renderer paints each run eagerly with the segment's\r\n // own fill/stroke (so per-selection overrides apply), so the node-level\r\n // fill/stroke ops are omitted to avoid double-painting. Text-on-path uses\r\n // the normal deferred path, so its node-level fill applies here; its stroke\r\n // is deferred to renderStroke.\r\n if (!segments) {\r\n g.fill(this.fill);\r\n }\r\n ctx.draw(g);\r\n }\r\n\r\n // The stroke only applies to the non-segment / text-on-path case; the\r\n // segmented branch paints its own fill/stroke per run in renderSelf.\r\n protected override renderStroke(ctx: RenderContext2D): void {\r\n const stroke = this.stroke as StrokeResolved[];\r\n if (stroke.length === 0) return;\r\n const { g, segments } = this.textOpGraphics();\r\n if (segments) return;\r\n ctx.draw(g.stroke(stroke));\r\n }\r\n\r\n private _casedText(): string {\r\n return textOps.applyCase(this.displayText(), this.textCase);\r\n }\r\n}\r\n\r\n/**\r\n * One shaped piece of a line, as {@link TextBase.measure} needs it: its text and\r\n * the five fields a measurement is taken against.\r\n */\r\ninterface StyledRun {\r\n text: string;\r\n fontFamily: string;\r\n fontSize: number;\r\n fontStyle: FontStyle;\r\n fontWeight: number;\r\n letterSpacing: number;\r\n}\r\n\r\n/**\r\n * Split `segments` into lines at every `\\n`, resolving each piece against\r\n * `fallback` for the fields it leaves unstated.\r\n *\r\n * A segment can span a line break - the cuts are made at *selection* edges, and\r\n * a selection over two lines is one range - so the break has to be found inside\r\n * the piece rather than between pieces. The newline itself joins neither line,\r\n * which is what makes an empty line come back as a run of `\"\"` (in the node's\r\n * own style) rather than disappearing from the count.\r\n */\r\nfunction measureStyledLines(\r\n segments: TextSegment[],\r\n fallback: Omit<StyledRun, \"text\">,\r\n): { runs: StyledRun[] }[] {\r\n const lines: { runs: StyledRun[] }[] = [{ runs: [] }];\r\n for (const segment of segments) {\r\n const style: Omit<StyledRun, \"text\"> = {\r\n fontFamily: segment.fontFamily ?? fallback.fontFamily,\r\n fontSize: segment.fontSize ?? fallback.fontSize,\r\n fontStyle: segment.fontStyle ?? fallback.fontStyle,\r\n fontWeight: segment.fontWeight,\r\n letterSpacing: segment.letterSpacing,\r\n };\r\n const parts = segment.text.split(\"\\n\");\r\n for (let i = 0; i < parts.length; i++) {\r\n if (i > 0) lines.push({ runs: [] });\r\n lines[lines.length - 1].runs.push({ text: parts[i], ...style });\r\n }\r\n }\r\n // A line the loop above never wrote a run onto still has to be measured\r\n // against something, and the node's own style is the only honest answer.\r\n for (const line of lines) {\r\n if (line.runs.length === 0) line.runs.push({ ...fallback, text: \"\" });\r\n }\r\n return lines;\r\n}\r\n\r\n/**\r\n * The size each line of `lines` is set at once wrapped to `maxWidth`: the\r\n * greedy whitespace break {@link countWrappedLines} makes, but with every piece\r\n * measured in its own style. A word split across two styles is still one word.\r\n */\r\nfunction wrappedLineSizes(\r\n lines: { runs: StyledRun[] }[],\r\n maxWidth: number,\r\n scope: MeasureContext2D,\r\n): number[] {\r\n const sizes: number[] = [];\r\n for (const line of lines) {\r\n const tokens: { width: number; size: number; space: boolean }[] = [];\r\n for (const run of line.runs) {\r\n for (const part of run.text.split(/(\\s+)/)) {\r\n if (part.length === 0) continue;\r\n const space = /^\\s+$/.test(part);\r\n const width = scope.measureText(part, run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width;\r\n const last = tokens[tokens.length - 1];\r\n if (last && !last.space && !space) {\r\n last.width += width;\r\n last.size = Math.max(last.size, run.fontSize);\r\n } else {\r\n tokens.push({ width, size: run.fontSize, space });\r\n }\r\n }\r\n }\r\n if (tokens.length === 0) {\r\n sizes.push(Math.max(...line.runs.map(run => run.fontSize)));\r\n continue;\r\n }\r\n let lineW = tokens[0].width;\r\n let size = tokens[0].size;\r\n for (const token of tokens.slice(1)) {\r\n if (lineW + token.width <= maxWidth) {\r\n lineW += token.width;\r\n size = Math.max(size, token.size);\r\n } else {\r\n sizes.push(size);\r\n lineW = token.space ? 0 : token.width;\r\n size = token.space ? 0 : token.size;\r\n }\r\n }\r\n sizes.push(size > 0 ? size : Math.max(...line.runs.map(run => run.fontSize)));\r\n }\r\n return sizes;\r\n}\r\n\r\nfunction countWrappedLines(\r\n paragraph: string,\r\n maxWidth: number,\r\n fontSize: number,\r\n fontFamily: string,\r\n fontWeight: number,\r\n scope: MeasureContext2D,\r\n letterSpacing: number = 0,\r\n fontStyle: FontStyle = 'normal',\r\n): number {\r\n if (paragraph.length === 0) return 1;\r\n if (scope.measureText(paragraph, fontSize, fontFamily, fontWeight, letterSpacing, fontStyle).width <= maxWidth) return 1;\r\n\r\n const words = paragraph.split(/(\\s+)/).filter(s => s.length > 0);\r\n let lines = 1;\r\n let lineW = 0;\r\n for (const word of words) {\r\n const w = scope.measureText(word, fontSize, fontFamily, fontWeight, letterSpacing, fontStyle).width;\r\n if (lineW === 0) {\r\n lineW = w;\r\n } else if (lineW + w <= maxWidth) {\r\n lineW += w;\r\n } else {\r\n lines++;\r\n lineW = /^\\s+$/.test(word) ? 0 : w;\r\n }\r\n }\r\n return lines;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-node.js","sourceRoot":"","sources":["../../../src/nodes/text/text-node.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,SAAS,E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AC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;mCAIhF","sourcesContent":["import { textProperty } from \"@/attributes/properties/typed\";\nimport type { ResolvedTextRun, TextRun } from \"@/attributes/text/types\";\nimport { fillOps } from \"@/attributes/shape/fill/registry\";\nimport { strokeOps } from \"@/attributes/shape/stroke/stroke\";\nimport { property } from \"@/attributes/properties/decorator\";\nimport { NodeConfig } from \"@/nodes/2d/node2d\";\nimport { PathData } from \"@/render/descriptors/path\";\nimport { PathBuilder } from \"@/render/descriptors/path-builder\";\nimport { TextRange, TextSelection } from \"./text-selection\";\nimport { TextBase, TextBaseProps } from \"./text-base\";\nimport { type Command, type CommandArgs } from \"@/tween/command\";\nimport { command } from \"@/tween/command-decorator\";\n\n\nexport interface TextProps extends TextBaseProps {\n text: string;\n /** Wrap onto more lines once the text runs out of width. */\n wrap: boolean;\n /**\n * Wrap the text around a path (text-on-path). Accepts the same value shapes\n * as the {@link Path} node's `d`: an SVG path string, a `PathCommand[]`, or a\n * {@link PathBuilder}. When set, `wrap` and multi-line (`\\n`) are ignored\n * (single line), and text selections are not applied.\n */\n path: PathData | PathBuilder;\n /**\n * Stretches of `text` styled apart from the node — see {@link TextRun}.\n * Where two overlap the later one wins; offsets past the end of the string\n * style nothing. Ignored on a `path`, like selections.\n */\n runs: TextRun[];\n}\n\n/** Coerce the loosely-typed `path` input into stored {@link PathData} (or null). */\nfunction resolveTextPath(value: PathData | PathBuilder | null | undefined): PathData | null {\n if (value == null) return null;\n return value instanceof PathBuilder ? value.toCommands() : value;\n}\n\nfunction resolveTextRuns(value: TextRun[] | null | undefined): ResolvedTextRun[] {\n if (!Array.isArray(value)) return [];\n return value.map(({ fill, stroke, ...run }) => ({\n ...run,\n ...(fill === undefined ? {} : { fill: fillOps.resolve(fill) }),\n ...(stroke === undefined ? {} : { stroke: strokeOps.resolve(stroke) }),\n }));\n}\n\n\n/**\n * Copy somebody typed, set in a face.\n *\n * The shaping, measuring and drawing are {@link TextBase}'s, shared with every\n * other node that puts glyphs on the canvas. What is here is what belongs to a\n * string an *author owns*: the string itself, whether its lines break, the path\n * it can be wrapped around, the two commands that add to it, and the selection\n * API that styles part of it.\n */\nexport class Text extends TextBase<TextProps> {\n\n @textProperty() declare readonly text: string;\n @property({ default: false }) declare readonly wrap: boolean;\n @property({ default: null, mapper: resolveTextPath })\n declare readonly path: PathData | null;\n @property({ default: [], mapper: resolveTextRuns, animatable: false })\n declare readonly runs: ResolvedTextRun[];\n\n constructor(props: NodeConfig<Text, TextProps>) {\n super(props);\n }\n\n override displayText(): string {\n return this.text;\n }\n\n protected override get wrapsText(): boolean {\n return this.wrap;\n }\n\n protected override get glyphPath(): PathData | null {\n return this.path;\n }\n\n protected override styledRuns(): readonly TextSelection[] {\n return this._selections;\n }\n\n protected override styleRuns(): readonly ResolvedTextRun[] {\n return this.runs;\n }\n\n // Text fills rather than hugs on the axis something else has to settle:\n // `autofit` measures glyphs against the allotted box (the base's rule), and\n // `wrap` needs a width to break lines against.\n protected override applyDefaultSize(props?: NodeConfig<Text, TextProps>): void {\n const autofit = props?.fontSize === 'autofit';\n this.applyProp(\"height\", props?.height ?? (autofit ? \"fill\" : \"hug\"));\n this.applyProp(\"width\", props?.width ?? (autofit || props?.wrap ? \"fill\" : \"hug\"));\n }\n\n @command({ args: [{ key: \"text\", kind: \"text\", default: \"\", multiline: true }] })\n append(args: CommandArgs<{ text: string }> & { duration: number }): Command<TextProps> {\n const text = (args.data as { text: string }).text;\n return this.to({ data: { text: this.text + text }, duration: args.duration, easing: args.easing });\n }\n\n @command({ args: [{ key: \"text\", kind: \"text\", default: \"\", multiline: true }] })\n prepend(args: CommandArgs<{ text: string }> & { duration: number }): Command<TextProps> {\n const text = (args.data as { text: string }).text;\n return this.to({ data: { text: text + this.text }, duration: args.duration, easing: args.easing });\n }\n\n // ---- Text selection ---------------------------------------------------\n\n /** Live selections in creation order. Later ones win on overlapping glyphs. */\n private _selections: TextSelection[] = [];\n\n /** @internal Called by {@link TextSelection} on construction. */\n _registerSelection(selection: TextSelection): void {\n this._selections.push(selection);\n }\n\n /**\n * Select an occurrence of `text`. By default the first occurrence; pass\n * `{ index }` to target the nth (0-based).\n *\n * @example title().find(\"hello\").to({ opacity: 0.5 }, 1);\n */\n find(text: string, opts?: { index?: number }): TextSelection {\n const source = this.text;\n const ranges: TextRange[] = [];\n if (text.length > 0) {\n let from = 0;\n let i: number;\n while ((i = source.indexOf(text, from)) !== -1) {\n ranges.push({ start: i, end: i + text.length });\n from = i + text.length;\n }\n }\n const index = opts?.index ?? 0;\n const picked = ranges[index] ? [ranges[index]] : [];\n return new TextSelection(this, picked);\n }\n\n /** Select every match of `regex`. A non-global regex matches once. */\n match(regex: RegExp): TextSelection {\n const flags = regex.flags.includes(\"g\") ? regex.flags : regex.flags + \"g\";\n const re = new RegExp(regex.source, flags);\n const ranges: TextRange[] = [];\n let m: RegExpExecArray | null;\n while ((m = re.exec(this.text)) !== null) {\n if (m[0].length === 0) { re.lastIndex++; continue; }\n ranges.push({ start: m.index, end: m.index + m[0].length });\n }\n return new TextSelection(this, ranges);\n }\n\n /** Select the nth `\\n`-delimited line (0-based), excluding the newline. */\n line(n: number): TextSelection {\n const lines = this.text.split(\"\\n\");\n let cursor = 0;\n for (let i = 0; i < lines.length; i++) {\n const len = lines[i].length;\n if (i === n) return new TextSelection(this, [{ start: cursor, end: cursor + len }]);\n cursor += len + 1; // + the consumed \"\\n\"\n }\n return new TextSelection(this, []);\n }\n\n /** Select every whitespace-delimited word. */\n words(): TextSelection {\n return new TextSelection(this, this._wordRanges());\n }\n\n /** Select the nth whitespace-delimited word (0-based). */\n word(n: number): TextSelection {\n const r = this._wordRanges()[n];\n return new TextSelection(this, r ? [r] : []);\n }\n\n /** Select the raw character range `[start, end)`. */\n slice(start: number, end: number): TextSelection {\n return new TextSelection(this, [{ start, end }]);\n }\n\n /** Select characters for which `predicate` returns true; adjacent hits merge. */\n filter(predicate: (char: string, index: number) => boolean): TextSelection {\n const ranges: TextRange[] = [];\n let runStart = -1;\n for (let i = 0; i < this.text.length; i++) {\n if (predicate(this.text[i], i)) {\n if (runStart === -1) runStart = i;\n } else if (runStart !== -1) {\n ranges.push({ start: runStart, end: i });\n runStart = -1;\n }\n }\n if (runStart !== -1) ranges.push({ start: runStart, end: this.text.length });\n return new TextSelection(this, ranges);\n }\n\n private _wordRanges(): TextRange[] {\n const ranges: TextRange[] = [];\n const re = /\\S+/g;\n let m: RegExpExecArray | null;\n while ((m = re.exec(this.text)) !== null) {\n ranges.push({ start: m.index, end: m.index + m[0].length });\n }\n return ranges;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"text-node.js","sourceRoot":"","sources":["../../../src/nodes/text/text-node.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAG7D,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAa,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAsBpD,oFAAoF;AACpF,SAAS,eAAe,CAAC,KAAgD;IACrE,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,OAAO,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACrE,CAAC;AAED,SAAS,eAAe,CAAC,KAAmC;IACxD,IAAI,CAAC,KAAK,CAAC,OAAO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,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAtJoC;IAAhC,YAAY,EAAE;kCAA+B;AACC;IAA9C,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;kCAAgC;AAE5C;IADhB,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;kCACd;AAEtB;IADhB,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;kCAC7B;AAoCzC;IADC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;kCAIhF;AAGD;IADC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;mCAIhF","sourcesContent":["import { textProperty } from \"@/attributes/properties/typed\";\r\nimport type { ResolvedTextRun, TextRun } from \"@/attributes/text/types\";\r\nimport { fillOps } from \"@/attributes/shape/fill/registry\";\r\nimport { strokeOps } from \"@/attributes/shape/stroke/stroke\";\r\nimport { property } from \"@/attributes/properties/decorator\";\r\nimport { NodeConfig } from \"@/nodes/2d/node2d\";\r\nimport { PathData } from \"@/render/descriptors/path\";\r\nimport { PathBuilder } from \"@/render/descriptors/path-builder\";\r\nimport { TextRange, TextSelection } from \"./text-selection\";\r\nimport { TextBase, TextBaseProps } from \"./text-base\";\r\nimport { type Command, type CommandArgs } from \"@/tween/command\";\r\nimport { command } from \"@/tween/command-decorator\";\r\n\r\n\r\nexport interface TextProps extends TextBaseProps {\r\n text: string;\r\n /** Wrap onto more lines once the text runs out of width. */\r\n wrap: boolean;\r\n /**\r\n * Wrap the text around a path (text-on-path). Accepts the same value shapes\r\n * as the {@link Path} node's `d`: an SVG path string, a `PathCommand[]`, or a\r\n * {@link PathBuilder}. When set, `wrap` and multi-line (`\\n`) are ignored\r\n * (single line), and text selections are not applied.\r\n */\r\n path: PathData | PathBuilder;\r\n /**\r\n * Stretches of `text` styled apart from the node — see {@link TextRun}.\r\n * Where two overlap the later one wins; offsets past the end of the string\r\n * style nothing. Ignored on a `path`, like selections.\r\n */\r\n runs: TextRun[];\r\n}\r\n\r\n/** Coerce the loosely-typed `path` input into stored {@link PathData} (or null). */\r\nfunction resolveTextPath(value: PathData | PathBuilder | null | undefined): PathData | null {\r\n if (value == null) return null;\r\n return value instanceof PathBuilder ? value.toCommands() : value;\r\n}\r\n\r\nfunction resolveTextRuns(value: TextRun[] | null | undefined): ResolvedTextRun[] {\r\n if (!Array.isArray(value)) return [];\r\n return value.map(({ fill, stroke, ...run }) => ({\r\n ...run,\r\n ...(fill === undefined ? {} : { fill: fillOps.resolve(fill) }),\r\n ...(stroke === undefined ? {} : { stroke: strokeOps.resolve(stroke) }),\r\n }));\r\n}\r\n\r\n\r\n/**\r\n * Copy somebody typed, set in a face.\r\n *\r\n * The shaping, measuring and drawing are {@link TextBase}'s, shared with every\r\n * other node that puts glyphs on the canvas. What is here is what belongs to a\r\n * string an *author owns*: the string itself, whether its lines break, the path\r\n * it can be wrapped around, the two commands that add to it, and the selection\r\n * API that styles part of it.\r\n */\r\nexport class Text extends TextBase<TextProps> {\r\n\r\n @textProperty() declare readonly text: string;\r\n @property({ default: false }) declare readonly wrap: boolean;\r\n @property({ default: null, mapper: resolveTextPath })\r\n declare readonly path: PathData | null;\r\n @property({ default: [], mapper: resolveTextRuns, animatable: false })\r\n declare readonly runs: ResolvedTextRun[];\r\n\r\n constructor(props: NodeConfig<Text, TextProps>) {\r\n super(props);\r\n }\r\n\r\n override displayText(): string {\r\n return this.text;\r\n }\r\n\r\n protected override get wrapsText(): boolean {\r\n return this.wrap;\r\n }\r\n\r\n protected override get glyphPath(): PathData | null {\r\n return this.path;\r\n }\r\n\r\n protected override styledRuns(): readonly TextSelection[] {\r\n return this._selections;\r\n }\r\n\r\n protected override styleRuns(): readonly ResolvedTextRun[] {\r\n return this.runs;\r\n }\r\n\r\n // Text fills rather than hugs on the axis something else has to settle:\r\n // `autofit` measures glyphs against the allotted box (the base's rule), and\r\n // `wrap` needs a width to break lines against.\r\n protected override applyDefaultSize(props?: NodeConfig<Text, TextProps>): void {\r\n const autofit = props?.fontSize === 'autofit';\r\n this.applyProp(\"height\", props?.height ?? (autofit ? \"fill\" : \"hug\"));\r\n this.applyProp(\"width\", props?.width ?? (autofit || props?.wrap ? \"fill\" : \"hug\"));\r\n }\r\n\r\n @command({ args: [{ key: \"text\", kind: \"text\", default: \"\", multiline: true }] })\r\n append(args: CommandArgs<{ text: string }> & { duration: number }): Command<TextProps> {\r\n const text = (args.data as { text: string }).text;\r\n return this.to({ data: { text: this.text + text }, duration: args.duration, easing: args.easing });\r\n }\r\n\r\n @command({ args: [{ key: \"text\", kind: \"text\", default: \"\", multiline: true }] })\r\n prepend(args: CommandArgs<{ text: string }> & { duration: number }): Command<TextProps> {\r\n const text = (args.data as { text: string }).text;\r\n return this.to({ data: { text: text + this.text }, duration: args.duration, easing: args.easing });\r\n }\r\n\r\n // ---- Text selection ---------------------------------------------------\r\n\r\n /** Live selections in creation order. Later ones win on overlapping glyphs. */\r\n private _selections: TextSelection[] = [];\r\n\r\n /** @internal Called by {@link TextSelection} on construction. */\r\n _registerSelection(selection: TextSelection): void {\r\n this._selections.push(selection);\r\n }\r\n\r\n /**\r\n * Select an occurrence of `text`. By default the first occurrence; pass\r\n * `{ index }` to target the nth (0-based).\r\n *\r\n * @example title().find(\"hello\").to({ opacity: 0.5 }, 1);\r\n */\r\n find(text: string, opts?: { index?: number }): TextSelection {\r\n const source = this.text;\r\n const ranges: TextRange[] = [];\r\n if (text.length > 0) {\r\n let from = 0;\r\n let i: number;\r\n while ((i = source.indexOf(text, from)) !== -1) {\r\n ranges.push({ start: i, end: i + text.length });\r\n from = i + text.length;\r\n }\r\n }\r\n const index = opts?.index ?? 0;\r\n const picked = ranges[index] ? [ranges[index]] : [];\r\n return new TextSelection(this, picked);\r\n }\r\n\r\n /** Select every match of `regex`. A non-global regex matches once. */\r\n match(regex: RegExp): TextSelection {\r\n const flags = regex.flags.includes(\"g\") ? regex.flags : regex.flags + \"g\";\r\n const re = new RegExp(regex.source, flags);\r\n const ranges: TextRange[] = [];\r\n let m: RegExpExecArray | null;\r\n while ((m = re.exec(this.text)) !== null) {\r\n if (m[0].length === 0) { re.lastIndex++; continue; }\r\n ranges.push({ start: m.index, end: m.index + m[0].length });\r\n }\r\n return new TextSelection(this, ranges);\r\n }\r\n\r\n /** Select the nth `\\n`-delimited line (0-based), excluding the newline. */\r\n line(n: number): TextSelection {\r\n const lines = this.text.split(\"\\n\");\r\n let cursor = 0;\r\n for (let i = 0; i < lines.length; i++) {\r\n const len = lines[i].length;\r\n if (i === n) return new TextSelection(this, [{ start: cursor, end: cursor + len }]);\r\n cursor += len + 1; // + the consumed \"\\n\"\r\n }\r\n return new TextSelection(this, []);\r\n }\r\n\r\n /** Select every whitespace-delimited word. */\r\n words(): TextSelection {\r\n return new TextSelection(this, this._wordRanges());\r\n }\r\n\r\n /** Select the nth whitespace-delimited word (0-based). */\r\n word(n: number): TextSelection {\r\n const r = this._wordRanges()[n];\r\n return new TextSelection(this, r ? [r] : []);\r\n }\r\n\r\n /** Select the raw character range `[start, end)`. */\r\n slice(start: number, end: number): TextSelection {\r\n return new TextSelection(this, [{ start, end }]);\r\n }\r\n\r\n /** Select characters for which `predicate` returns true; adjacent hits merge. */\r\n filter(predicate: (char: string, index: number) => boolean): TextSelection {\r\n const ranges: TextRange[] = [];\r\n let runStart = -1;\r\n for (let i = 0; i < this.text.length; i++) {\r\n if (predicate(this.text[i], i)) {\r\n if (runStart === -1) runStart = i;\r\n } else if (runStart !== -1) {\r\n ranges.push({ start: runStart, end: i });\r\n runStart = -1;\r\n }\r\n }\r\n if (runStart !== -1) ranges.push({ start: runStart, end: this.text.length });\r\n return new TextSelection(this, ranges);\r\n }\r\n\r\n private _wordRanges(): TextRange[] {\r\n const ranges: TextRange[] = [];\r\n const re = /\\S+/g;\r\n let m: RegExpExecArray | null;\r\n while ((m = re.exec(this.text)) !== null) {\r\n ranges.push({ start: m.index, end: m.index + m[0].length });\r\n }\r\n return ranges;\r\n }\r\n}\r\n"]}
|