@motionscript/core 0.1.0-alpha.3 → 0.1.0-alpha.6
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 +247 -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 +79 -4
- 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 +17 -2
- package/dist/attributes/audio/request.d.ts.map +1 -1
- package/dist/attributes/audio/request.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +4 -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.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 +3 -1
- package/dist/attributes/properties/decorator.d.ts.map +1 -1
- 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.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-2RIYH36X.js +3 -0
- package/dist/browser/chunks/chunk-2RIYH36X.js.map +7 -0
- package/dist/browser/chunks/chunk-DDJN3QII.js +15 -0
- package/dist/browser/chunks/chunk-DDJN3QII.js.map +7 -0
- package/dist/browser/chunks/chunk-DHB4COFY.js +2 -0
- package/dist/browser/chunks/chunk-DHB4COFY.js.map +7 -0
- package/dist/browser/chunks/chunk-EJDPYDQI.js +5 -0
- package/dist/browser/chunks/chunk-EJDPYDQI.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/chunks/chunk-XAWE4EAK.js +2 -0
- package/dist/browser/chunks/chunk-XAWE4EAK.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/component.js.map +4 -4
- package/dist/browser/experimental.js +2 -0
- package/dist/browser/experimental.js.map +7 -0
- 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 +4 -2
- package/dist/browser/sdk.js +1 -1
- package/dist/component/api.d.ts +508 -0
- package/dist/component/api.d.ts.map +1 -0
- package/dist/component/api.js +4 -0
- package/dist/component/api.js.map +1 -0
- package/dist/component/builtins/audio.d.ts +26 -0
- package/dist/component/builtins/audio.d.ts.map +1 -0
- package/dist/component/builtins/audio.js +41 -0
- package/dist/component/builtins/audio.js.map +1 -0
- package/dist/component/builtins/canvas3d.d.ts +98 -0
- package/dist/component/builtins/canvas3d.d.ts.map +1 -0
- package/dist/component/builtins/canvas3d.js +21 -0
- package/dist/component/builtins/canvas3d.js.map +1 -0
- package/dist/component/builtins/composite.d.ts +56 -0
- package/dist/component/builtins/composite.d.ts.map +1 -0
- package/dist/component/builtins/composite.js +25 -0
- package/dist/component/builtins/composite.js.map +1 -0
- package/dist/component/builtins/geometry.d.ts +505 -0
- package/dist/component/builtins/geometry.d.ts.map +1 -0
- package/dist/component/builtins/geometry.js +107 -0
- package/dist/component/builtins/geometry.js.map +1 -0
- package/dist/component/builtins/layout.d.ts +88 -0
- package/dist/component/builtins/layout.d.ts.map +1 -0
- package/dist/component/builtins/layout.js +84 -0
- package/dist/component/builtins/layout.js.map +1 -0
- package/dist/component/builtins/media.d.ts +95 -0
- package/dist/component/builtins/media.d.ts.map +1 -0
- package/dist/component/builtins/media.js +149 -0
- package/dist/component/builtins/media.js.map +1 -0
- package/dist/component/builtins/providers.d.ts +23 -0
- package/dist/component/builtins/providers.d.ts.map +1 -0
- package/dist/component/builtins/providers.js +30 -0
- package/dist/component/builtins/providers.js.map +1 -0
- package/dist/component/builtins/text.d.ts +193 -0
- package/dist/component/builtins/text.d.ts.map +1 -0
- package/dist/component/builtins/text.js +113 -0
- package/dist/component/builtins/text.js.map +1 -0
- package/dist/component/builtins/three.d.ts +1085 -0
- package/dist/component/builtins/three.d.ts.map +1 -0
- package/dist/component/builtins/three.js +265 -0
- package/dist/component/builtins/three.js.map +1 -0
- package/dist/component/clip-of.d.ts +5 -0
- package/dist/component/clip-of.d.ts.map +1 -0
- package/dist/component/clip-of.js +33 -0
- package/dist/component/clip-of.js.map +1 -0
- package/dist/component/commands-for.d.ts +19 -0
- package/dist/component/commands-for.d.ts.map +1 -0
- package/dist/component/commands-for.js +5 -0
- package/dist/component/commands-for.js.map +1 -0
- package/dist/component/component-audio.d.ts +9 -0
- package/dist/component/component-audio.d.ts.map +1 -0
- package/dist/component/component-audio.js +18 -0
- package/dist/component/component-audio.js.map +1 -0
- package/dist/component/component2d.d.ts +9 -0
- package/dist/component/component2d.d.ts.map +1 -0
- package/dist/component/component2d.js +239 -0
- package/dist/component/component2d.js.map +1 -0
- package/dist/component/component3d.d.ts +9 -0
- package/dist/component/component3d.d.ts.map +1 -0
- package/dist/component/component3d.js +99 -0
- package/dist/component/component3d.js.map +1 -0
- package/dist/component/factory.d.ts +63 -0
- package/dist/component/factory.d.ts.map +1 -0
- package/dist/component/factory.js +313 -0
- package/dist/component/factory.js.map +1 -0
- package/dist/component/modules/aim.d.ts +30 -0
- package/dist/component/modules/aim.d.ts.map +1 -0
- package/dist/component/modules/aim.js +39 -0
- package/dist/component/modules/aim.js.map +1 -0
- package/dist/component/modules/corners.d.ts +13 -0
- package/dist/component/modules/corners.d.ts.map +1 -0
- package/dist/component/modules/corners.js +12 -0
- package/dist/component/modules/corners.js.map +1 -0
- package/dist/component/modules/flow.d.ts +26 -0
- package/dist/component/modules/flow.d.ts.map +1 -0
- package/dist/component/modules/flow.js +55 -0
- package/dist/component/modules/flow.js.map +1 -0
- package/dist/component/modules/material.d.ts +40 -0
- package/dist/component/modules/material.d.ts.map +1 -0
- package/dist/component/modules/material.js +75 -0
- package/dist/component/modules/material.js.map +1 -0
- package/dist/component/modules/paint.d.ts +71 -0
- package/dist/component/modules/paint.d.ts.map +1 -0
- package/dist/component/modules/paint.js +106 -0
- package/dist/component/modules/paint.js.map +1 -0
- package/dist/component/modules/shapes.d.ts +31 -0
- package/dist/component/modules/shapes.d.ts.map +1 -0
- package/dist/component/modules/shapes.js +43 -0
- package/dist/component/modules/shapes.js.map +1 -0
- package/dist/component/modules/text-layout.d.ts +26 -0
- package/dist/component/modules/text-layout.d.ts.map +1 -0
- package/dist/component/modules/text-layout.js +57 -0
- package/dist/component/modules/text-layout.js.map +1 -0
- package/dist/component/modules/text-style.d.ts +48 -0
- package/dist/component/modules/text-style.d.ts.map +1 -0
- package/dist/component/modules/text-style.js +63 -0
- package/dist/component/modules/text-style.js.map +1 -0
- package/dist/component/modules/three-entries.d.ts +23 -0
- package/dist/component/modules/three-entries.d.ts.map +1 -0
- package/dist/component/modules/three-entries.js +41 -0
- package/dist/component/modules/three-entries.js.map +1 -0
- package/dist/component/modules/view3d.d.ts +55 -0
- package/dist/component/modules/view3d.d.ts.map +1 -0
- package/dist/component/modules/view3d.js +160 -0
- package/dist/component/modules/view3d.js.map +1 -0
- package/dist/component/timeline.d.ts +22 -0
- package/dist/component/timeline.d.ts.map +1 -0
- package/dist/component/timeline.js +128 -0
- package/dist/component/timeline.js.map +1 -0
- package/dist/component/type-def.d.ts +26 -0
- package/dist/component/type-def.d.ts.map +1 -0
- package/dist/component/type-def.js +16 -0
- package/dist/component/type-def.js.map +1 -0
- package/dist/component/types.d.ts +91 -0
- package/dist/component/types.d.ts.map +1 -0
- package/dist/component/types.js +88 -0
- package/dist/component/types.js.map +1 -0
- package/dist/component/views.d.ts +121 -0
- package/dist/component/views.d.ts.map +1 -0
- package/dist/component/views.js +413 -0
- package/dist/component/views.js.map +1 -0
- package/dist/component.d.ts +4 -5
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +3 -5
- package/dist/component.js.map +1 -1
- package/dist/document/audio.d.ts +10 -2
- package/dist/document/audio.d.ts.map +1 -1
- package/dist/document/audio.js +45 -4
- package/dist/document/audio.js.map +1 -1
- package/dist/document/builtins.d.ts.map +1 -1
- package/dist/document/builtins.js +15 -39
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +1 -1
- package/dist/document/command-traits.js +16 -1
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/deny-globals.js.map +1 -1
- package/dist/document/diff.d.ts.map +1 -1
- package/dist/document/diff.js +3 -3
- 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 +3 -3
- 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 +25 -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 +23 -11
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +46 -19
- package/dist/document/registry.js.map +1 -1
- package/dist/document/settled-index.d.ts +49 -0
- package/dist/document/settled-index.d.ts.map +1 -0
- package/dist/document/settled-index.js +247 -0
- package/dist/document/settled-index.js.map +1 -0
- package/dist/document/timeline-patch.js.map +1 -1
- package/dist/document/timeline.d.ts +100 -19
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +290 -42
- 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/experimental.d.ts +22 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +20 -0
- package/dist/experimental.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -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 +180 -28
- 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.d.ts +2 -2
- package/dist/nodes/audio/index.d.ts.map +1 -1
- package/dist/nodes/audio/index.js +0 -2
- package/dist/nodes/audio/index.js.map +1 -1
- package/dist/nodes/audio/node-audio.js.map +1 -1
- package/dist/nodes/audio/sound-node.d.ts +4 -3
- package/dist/nodes/audio/sound-node.d.ts.map +1 -1
- package/dist/nodes/audio/sound-node.js +4 -1
- 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 +40 -33
- package/dist/nodes/index.d.ts.map +1 -1
- package/dist/nodes/index.js +17 -36
- 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 +2 -0
- 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 +12 -4
- package/dist/nodes/node/node.d.ts.map +1 -1
- package/dist/nodes/node/node.js +67 -27
- 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 +4 -3
- package/dist/nodes/root/canvas2d-node.d.ts.map +1 -0
- package/dist/nodes/{scene → root}/canvas2d-node.js +5 -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.d.ts +0 -5
- package/dist/nodes/text/richtext-node.d.ts.map +1 -1
- package/dist/nodes/text/richtext-node.js +6 -72
- package/dist/nodes/text/richtext-node.js.map +1 -1
- package/dist/nodes/text/text-base.d.ts +5 -22
- package/dist/nodes/text/text-base.d.ts.map +1 -1
- package/dist/nodes/text/text-base.js +13 -364
- package/dist/nodes/text/text-base.js.map +1 -1
- package/dist/nodes/text/text-layout.d.ts +87 -0
- package/dist/nodes/text/text-layout.d.ts.map +1 -0
- package/dist/nodes/text/text-layout.js +368 -0
- package/dist/nodes/text/text-layout.js.map +1 -0
- 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 +32 -7
- package/dist/nodes/three/canvas3d-node.d.ts.map +1 -1
- package/dist/nodes/three/canvas3d-node.js +50 -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 +2 -2
- package/dist/render/canvas-render-context2d.d.ts.map +1 -1
- 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 +2 -2
- 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.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.js.map +1 -1
- package/dist/runtime/builtin-context.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +9 -4
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +27 -9
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +18 -0
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +97 -0
- 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 +124 -10
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +13 -5
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +10 -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.d.ts.map +1 -1
- package/dist/runtime/text-geometry.js +7 -3
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +50 -25
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +52 -42
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +2 -0
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/command.d.ts +12 -0
- package/dist/tween/command.d.ts.map +1 -1
- package/dist/tween/command.js +14 -0
- 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 +1 -1
- 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 +7 -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-KJXGRHOL.js +0 -3
- package/dist/browser/chunks/chunk-KJXGRHOL.js.map +0 -7
- package/dist/browser/chunks/chunk-TGDX2SS2.js +0 -18
- package/dist/browser/chunks/chunk-TGDX2SS2.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 +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AAE,SAAS;QACzC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3B,4EAA4E;QAC5E,qFAAqF;QACrF,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACjD,CAAC;AACL,CAAC","sourcesContent":["import { Node2D, NodeConfig, Node2DProps } from \"@/nodes/2d/node2d\";\nimport { property } from \"@/attributes/properties/decorator\";\nimport { ContextMap } from \"@/util/context\";\nimport { TextStyleToken } from \"@/runtime/builtin-context\";\nimport { EMPTY_TEXT_STYLE, TEXT_STYLE_KEYS, textOps } from \"@/attributes/text/ops\";\nimport type { FontStyle, TextAlign, TextStyle } from \"@/attributes/text/types\";\nimport { Fill } from \"@/attributes/shape/fill/chain\";\nimport { type Stroke } from \"@/attributes/shape/stroke/stroke\";\nimport { type Shadow } from \"@/attributes/shape/shadow/shadow\";\nimport { type RenderPass2D } from \"@/render/render-context2d\";\n\nexport interface DefaultTextStyleProps extends Node2DProps {\n fontFamily: string;\n fontSize: number | 'autofit';\n fontWeight: number;\n fontStyle: FontStyle;\n letterSpacing: number;\n lineHeight: number;\n textAlign: TextAlign;\n fill: Fill;\n stroke: Stroke;\n shadow: Shadow;\n}\n\n/**\n * Sets default text styling for everything drawn below it — the {@link Text} /\n * {@link RichText} nodes *and* the raw `Graphics2D` `text`/`richText` ops a custom\n * node draws. A descendant inherits each style prop it didn't set itself, from\n * the nearest ancestor `DefaultTextStyle` that did — author-set props always win\n * over inherited ones. Nesting accumulates per key (an inner `fontSize` and an\n * outer `fontFamily` both apply).\n *\n * Two channels carry that, because a node and a drawing have nothing else in\n * common:\n *\n * - **Nodes**, through context. Built on the same machinery as {@link Provider}:\n * it contributes the built-in {@link TextStyleToken}, merging only the keys the\n * author explicitly passed onto any ancestor's defaults. It contributes the\n * author's *raw* prop values (not resolved cell values), so each consumer\n * resolves them once through its own mapper — e.g. `fill='red'` is resolved by\n * `Text`'s fill mapper, not pre-resolved here. {@link applyTextDefaults} is the\n * consuming end.\n * - **Graphics2D**, through the render context ({@link RenderContext2D.pushTextStyle}),\n * pushed around this node's children for the duration of their draw and folded\n * into each under-specified text op. A `Graphics2D` isn't in the tree and has no\n * bind step, so the draw scope is the only place it can inherit from.\n *\n * Only the *shaping* keys reach a drawn op — `fill`/`stroke`/`shadow` are\n * group-scoped paint ops in a `Graphics2D`, not per-shape slots, so defaulting\n * them would change which shapes a group's paint covers. See\n * {@link TEXT_SHAPING_KEYS}.\n *\n * A node that owns its typography opts out of the second channel with\n * `ctx.pushTextStyle(null)`; `@motionscript/code`'s `Code` does exactly that.\n *\n * Layout-transparent like {@link Provider} — carries style, not appearance.\n */\nexport class DefaultTextStyle extends Node2D<DefaultTextStyleProps> {\n @property({ default: undefined }) declare readonly fontFamily?: string;\n @property({ default: undefined }) declare readonly fontSize?: number | 'autofit';\n @property({ default: undefined }) declare readonly fontWeight?: number;\n @property({ default: undefined }) declare readonly fontStyle?: FontStyle;\n @property({ default: undefined }) declare readonly letterSpacing?: number;\n @property({ default: undefined }) declare readonly lineHeight?: number;\n @property({ default: undefined }) declare readonly textAlign?: TextAlign;\n @property({ default: undefined }) declare readonly fill?: Fill;\n @property({ default: undefined }) declare readonly stroke?: Stroke;\n @property({ default: undefined }) declare readonly shadow?: Shadow;\n\n constructor(props: NodeConfig<DefaultTextStyle, DefaultTextStyleProps>) {\n super(props);\n }\n\n protected override provideContext(parent: ContextMap): ContextMap {\n const inherited = parent.get(TextStyleToken);\n const merged = textOps.mergeStyle(inherited, this._props as TextStyle | undefined);\n return merged === inherited ? parent : parent.with(TextStyleToken, merged);\n }\n\n /**\n * Open the render-context text-style scope around this node's children, so\n * the `Graphics2D` they draw inherit the same defaults their `Text` nodes do.\n *\n * `super.renderContent` is what renders those children, so the scope has to\n * wrap it — and be closed in a `finally`, since the stack outlives this node\n * and a leaked frame would restyle every sibling drawn after it.\n */\n protected override renderContent(ctx: RenderPass2D): void {\n ctx.pushTextStyle(this.currentStyle());\n try {\n super.renderContent(ctx);\n } finally {\n ctx.popTextStyle();\n }\n }\n\n /**\n * The keys this node currently sets, at their resolved values.\n *\n * Read off the properties rather than out of `_props` (which\n * {@link provideContext} uses): a prop can be a callback or mid-tween, and a\n * drawn op needs this frame's *value*. An unset prop defaults to `undefined`,\n * which is the same \"didn't set it\" signal the context channel reads.\n */\n private currentStyle(): TextStyle {\n return textOps.mergeStyle(EMPTY_TEXT_STYLE, this);\n }\n}\n\n/**\n * Apply text-style defaults to a `Text`/`RichText` node, for each style key the\n * author didn't pass — the node end of {@link DefaultTextStyle}'s context\n * channel, run once from the node's `resolveContext`.\n *\n * Precedence per key, highest to lowest: the author's own prop; the node's\n * `variant` preset; the nearest enclosing `<DefaultTextStyle>`; the theme's\n * `default` preset; and last the node's `@property` default, which its\n * constructor already applied. Each value is written through the property\n * setter, so a preset's `fill: 'brand-500'` is resolved exactly as if the author\n * had written it.\n *\n * @internal\n */\nexport function applyTextDefaults(node: Node2D, props?: Record<string, unknown>): void {\n const variant = props?.variant as string | undefined;\n const cascade = textOps.mergeStyle(\n textOps.mergeStyle(textOps.preset(\"default\"), node.useContext(TextStyleToken)),\n variant ? textOps.preset(variant) : undefined,\n );\n const target = node as unknown as Record<string, unknown>;\n for (const key of TEXT_STYLE_KEYS) {\n if (props?.[key] !== undefined) continue;\n const value = cascade[key];\n // An unset `fontFamily` is legitimate: the renderer resolves it against the\n // faces actually loaded, which core cannot see (`paragraph-layout.ts`'s `familyOf`).\n if (value !== undefined) target[key] = value;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"default-text-style-node.js","sourceRoot":"","sources":["../../../src/nodes/text/default-text-style-node.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAA2B,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,gBA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AE,SAAS;QAC1E,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACxB,CAAC;AACL,CAAC","sourcesContent":["import { Node2D, NodeConfig, Node2DProps } from \"@/nodes/2d/node2d\";\r\nimport { property } from \"@/attributes/properties/decorator\";\r\nimport { ContextMap } from \"@/util/context\";\r\nimport { TextStyleToken } from \"@/runtime/builtin-context\";\r\nimport { EMPTY_TEXT_STYLE, TEXT_STYLE_KEYS, textOps } from \"@/attributes/text/ops\";\r\nimport type { FontStyle, TextAlign, TextStyle } from \"@/attributes/text/types\";\r\nimport { Fill } from \"@/attributes/shape/fill/chain\";\r\nimport { type Stroke } from \"@/attributes/shape/stroke/stroke\";\r\nimport { type Shadow } from \"@/attributes/shape/shadow/shadow\";\r\nimport { type RenderPass2D } from \"@/render/render-context2d\";\r\n\r\nexport interface DefaultTextStyleProps extends Node2DProps {\r\n fontFamily: string;\r\n fontSize: number | 'autofit';\r\n fontWeight: number;\r\n fontStyle: FontStyle;\r\n letterSpacing: number;\r\n lineHeight: number;\r\n textAlign: TextAlign;\r\n fill: Fill;\r\n stroke: Stroke;\r\n shadow: Shadow;\r\n}\r\n\r\n/**\r\n * Sets default text styling for everything drawn below it — the {@link Text} /\r\n * {@link RichText} nodes *and* the raw `Graphics2D` `text`/`richText` ops a custom\r\n * node draws. A descendant inherits each style prop it didn't set itself, from\r\n * the nearest ancestor `DefaultTextStyle` that did — author-set props always win\r\n * over inherited ones. Nesting accumulates per key (an inner `fontSize` and an\r\n * outer `fontFamily` both apply).\r\n *\r\n * Two channels carry that, because a node and a drawing have nothing else in\r\n * common:\r\n *\r\n * - **Nodes**, through context. Built on the same machinery as {@link Provider}:\r\n * it contributes the built-in {@link TextStyleToken}, merging only the keys the\r\n * author explicitly passed onto any ancestor's defaults. It contributes the\r\n * author's *raw* prop values (not resolved cell values), so each consumer\r\n * resolves them once through its own mapper — e.g. `fill='red'` is resolved by\r\n * `Text`'s fill mapper, not pre-resolved here. {@link applyTextDefaults} is the\r\n * consuming end.\r\n * - **Graphics2D**, through the render context ({@link RenderContext2D.pushTextStyle}),\r\n * pushed around this node's children for the duration of their draw and folded\r\n * into each under-specified text op. A `Graphics2D` isn't in the tree and has no\r\n * bind step, so the draw scope is the only place it can inherit from.\r\n *\r\n * Only the *shaping* keys reach a drawn op — `fill`/`stroke`/`shadow` are\r\n * group-scoped paint ops in a `Graphics2D`, not per-shape slots, so defaulting\r\n * them would change which shapes a group's paint covers. See\r\n * {@link TEXT_SHAPING_KEYS}.\r\n *\r\n * A node that owns its typography opts out of the second channel with\r\n * `ctx.pushTextStyle(null)`; `@motionscript/code`'s `Code` does exactly that.\r\n *\r\n * Layout-transparent like {@link Provider} — carries style, not appearance.\r\n */\r\nexport class DefaultTextStyle extends Node2D<DefaultTextStyleProps> {\r\n @property({ default: undefined }) declare readonly fontFamily?: string;\r\n @property({ default: undefined }) declare readonly fontSize?: number | 'autofit';\r\n @property({ default: undefined }) declare readonly fontWeight?: number;\r\n @property({ default: undefined }) declare readonly fontStyle?: FontStyle;\r\n @property({ default: undefined }) declare readonly letterSpacing?: number;\r\n @property({ default: undefined }) declare readonly lineHeight?: number;\r\n @property({ default: undefined }) declare readonly textAlign?: TextAlign;\r\n @property({ default: undefined }) declare readonly fill?: Fill;\r\n @property({ default: undefined }) declare readonly stroke?: Stroke;\r\n @property({ default: undefined }) declare readonly shadow?: Shadow;\r\n\r\n constructor(props: NodeConfig<DefaultTextStyle, DefaultTextStyleProps>) {\r\n super(props);\r\n }\r\n\r\n protected override provideContext(parent: ContextMap): ContextMap {\r\n const inherited = parent.get(TextStyleToken);\r\n const merged = textOps.mergeStyle(inherited, this._props as TextStyle | undefined);\r\n return merged === inherited ? parent : parent.with(TextStyleToken, merged);\r\n }\r\n\r\n /**\r\n * Open the render-context text-style scope around this node's children, so\r\n * the `Graphics2D` they draw inherit the same defaults their `Text` nodes do.\r\n *\r\n * `super.renderContent` is what renders those children, so the scope has to\r\n * wrap it — and be closed in a `finally`, since the stack outlives this node\r\n * and a leaked frame would restyle every sibling drawn after it.\r\n */\r\n protected override renderContent(ctx: RenderPass2D): void {\r\n ctx.pushTextStyle(this.currentStyle());\r\n try {\r\n super.renderContent(ctx);\r\n } finally {\r\n ctx.popTextStyle();\r\n }\r\n }\r\n\r\n /**\r\n * The keys this node currently sets, at their resolved values.\r\n *\r\n * Read off the properties rather than out of `_props` (which\r\n * {@link provideContext} uses): a prop can be a callback or mid-tween, and a\r\n * drawn op needs this frame's *value*. An unset prop defaults to `undefined`,\r\n * which is the same \"didn't set it\" signal the context channel reads.\r\n */\r\n private currentStyle(): TextStyle {\r\n return textOps.mergeStyle(EMPTY_TEXT_STYLE, this);\r\n }\r\n}\r\n\r\n/**\r\n * Apply text-style defaults to a `Text`/`RichText` node, for each style key the\r\n * author didn't pass — the node end of {@link DefaultTextStyle}'s context\r\n * channel, run once from the node's `resolveContext`.\r\n *\r\n * Precedence per key, highest to lowest: the author's own prop; the node's\r\n * `variant` preset; the nearest enclosing `<DefaultTextStyle>`; the theme's\r\n * `default` preset; and last the node's `@property` default, which its\r\n * constructor already applied. Each value is written through the property\r\n * setter, so a preset's `fill: 'brand-500'` is resolved exactly as if the author\r\n * had written it. A node with no `'autofit'` size (`modes.autofit` false)\r\n * skips an inherited `'autofit'`, keeping its own size.\r\n *\r\n * @internal\r\n */\r\nexport function applyTextDefaults(\r\n node: Node2D,\r\n props?: Record<string, unknown>,\r\n modes: { autofit: boolean } = { autofit: true },\r\n): void {\r\n const variant = props?.variant as string | undefined;\r\n const cascade = textOps.mergeStyle(\r\n textOps.mergeStyle(textOps.preset(\"default\"), node.useContext(TextStyleToken)),\r\n variant ? textOps.preset(variant) : undefined,\r\n );\r\n const target = node as unknown as Record<string, unknown>;\r\n for (const key of TEXT_STYLE_KEYS) {\r\n if (props?.[key] !== undefined) continue;\r\n const value = cascade[key];\r\n // An unset `fontFamily` is legitimate: the renderer resolves it against the\r\n // faces actually loaded, which core cannot see (`paragraph-layout.ts`'s `familyOf`).\r\n if (value === undefined) continue;\r\n // A block of runs has no autofit mode (it is sized by its box), so an\r\n // inherited `'autofit'` stays out, as `patchSpans` leaves it out of a span.\r\n if (key === \"fontSize\" && value === \"autofit\" && !modes.autofit) continue;\r\n target[key] = value;\r\n }\r\n}\r\n"]}
|
|
@@ -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,GAAk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E,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,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,EAAE,CAAC;QACtB,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACf,MAAM,GAAG,CAAC,MAAM,CAAA;YAChB,SAAQ;QACV,CAAC;QACD,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;IACnB,CAAC;AACH,CAAC;AAED,4CAA4C;AAC5C,SAAS,OAAO,CAAC,IAAY,EAAE,EAAU;IACvC,IAAI,KAAK,GAAG,KAAK,CAAA;IACjB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QACvB,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM;YAAE,KA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AAC,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":["/**\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,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AA0CpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,UAAW,SAAQ,QAAqB;IASjD,YAAY,KAA0C;QAClD,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;;;;;;OAOG;IACM,WAAW;QAChB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC5B,CAAC;IAED,wFAAwF;IACxF,SAAS;QACL,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,qEAAqE;IAErE,OAAO,CAAC,IAA2D;QAC/D,OAAO,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAA4B,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9G,CAAC;CACJ;AAjC8C;IAA1C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;yCAAgC;AACP;IAAjD,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;0CAAuC;AAC3B;IAA3C,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;iDAAwC;AACvB;IAA1C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;kDAAyC;AACpB;IAA7C,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAmC;AAClB;IAA5C,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\";\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"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAiB,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AA0CpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,UAAW,SAAQ,QAAqB;IASjD,YAAY,KAA0C;QAClD,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;;;;;;OAOG;IACM,WAAW;QAChB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC5B,CAAC;IAED,wFAAwF;IACxF,SAAS;QACL,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,qEAAqE;IAErE,OAAO,CAAC,IAA2D;QAC/D,OAAO,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAA4B,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9G,CAAC;CACJ;AAjC8C;IAA1C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;yCAAgC;AACP;IAAjD,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;0CAAuC;AAC3B;IAA3C,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;iDAAwC;AACvB;IAA1C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;kDAAyC;AACpB;IAA7C,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAmC;AAClB;IAA5C,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"]}
|
|
@@ -61,11 +61,6 @@ export declare class RichText extends PaintNode<RichTextProps> {
|
|
|
61
61
|
* parent set; explicit fields on a child override them.
|
|
62
62
|
*/
|
|
63
63
|
runs(): ResolvedTextSpan[];
|
|
64
|
-
/**
|
|
65
|
-
* Every run's face and paint — a span may name either where the node doesn't.
|
|
66
|
-
* {@link runs} is the flattening {@link measure} and the render use too, which
|
|
67
|
-
* keeps the declaration and the draw from naming different families.
|
|
68
|
-
*/
|
|
69
64
|
declareAssets(assets: AssetScope): void;
|
|
70
65
|
measure(constraints: SizeConstraints, scope: MeasureContext2D): Partial<Size2D>;
|
|
71
66
|
protected renderSelf(ctx: RenderContext2D): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"richtext-node.d.ts","sourceRoot":"","sources":["../../../src/nodes/text/richtext-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"richtext-node.d.ts","sourceRoot":"","sources":["../../../src/nodes/text/richtext-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,eAAe,EA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AAC;IAChE,SAAkD,SAAS,EAAE,SAAS,CAAC;IACvE,SAAmD,OAAO,CAAC,EAAE,MAAM,CAAC;gBAExD,KAAK,EAAE,UAAU,CAAC,QAAQ,EAAE,aAAa,CAAC;cAQnC,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;cAMrC,gBAAgB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,IAAI;IAKtF;;;;OAIG;IACH,IAAI,IAAI,gBAAgB,EAAE;IAIjB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAKhD,OAAO,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;cAI5D,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;CAG5D"}
|
|
@@ -7,8 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Graphics2D } from "../../render/graphics2d.js";
|
|
8
8
|
import { PaintNode } from "../../nodes/2d/paint-node.js";
|
|
9
9
|
import { property } from "../../attributes/properties/decorator.js";
|
|
10
|
-
import { textOps } from "../../attributes/text/ops.js";
|
|
11
10
|
import { applyTextDefaults } from "./default-text-style-node.js";
|
|
11
|
+
import { declareRichAssets, measureRich, richRuns, richState } from "./text-layout.js";
|
|
12
12
|
export class RichText extends PaintNode {
|
|
13
13
|
constructor(props) {
|
|
14
14
|
super(props);
|
|
@@ -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.
|
|
@@ -32,83 +32,17 @@ export class RichText extends PaintNode {
|
|
|
32
32
|
* parent set; explicit fields on a child override them.
|
|
33
33
|
*/
|
|
34
34
|
runs() {
|
|
35
|
-
return
|
|
36
|
-
fontFamily: this.fontFamily,
|
|
37
|
-
fontSize: this.fontSize,
|
|
38
|
-
fontWeight: this.fontWeight,
|
|
39
|
-
fontStyle: this.fontStyle,
|
|
40
|
-
letterSpacing: this.letterSpacing,
|
|
41
|
-
fill: this.fill,
|
|
42
|
-
stroke: this.stroke,
|
|
43
|
-
});
|
|
35
|
+
return richRuns(this);
|
|
44
36
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Every run's face and paint — a span may name either where the node doesn't.
|
|
47
|
-
* {@link runs} is the flattening {@link measure} and the render use too, which
|
|
48
|
-
* keeps the declaration and the draw from naming different families.
|
|
49
|
-
*/
|
|
50
37
|
declareAssets(assets) {
|
|
51
38
|
super.declareAssets(assets);
|
|
52
|
-
|
|
53
|
-
if (run.fontFamily)
|
|
54
|
-
assets.font(run.fontFamily, run.fontWeight);
|
|
55
|
-
assets.fill(run.fill);
|
|
56
|
-
for (const stroke of run.stroke)
|
|
57
|
-
assets.fill(stroke.fill);
|
|
58
|
-
}
|
|
39
|
+
declareRichAssets(this, assets);
|
|
59
40
|
}
|
|
60
41
|
measure(constraints, scope) {
|
|
61
|
-
|
|
62
|
-
let lineW = 0;
|
|
63
|
-
let maxLineH = 0;
|
|
64
|
-
let totalW = 0;
|
|
65
|
-
let totalH = 0;
|
|
66
|
-
const finishLine = () => {
|
|
67
|
-
if (lineW > totalW)
|
|
68
|
-
totalW = lineW;
|
|
69
|
-
totalH += maxLineH;
|
|
70
|
-
lineW = 0;
|
|
71
|
-
maxLineH = 0;
|
|
72
|
-
};
|
|
73
|
-
for (const run of runs) {
|
|
74
|
-
const lh = run.fontSize * this.lineHeight;
|
|
75
|
-
const segments = run.text.split("\n");
|
|
76
|
-
for (let i = 0; i < segments.length; i++) {
|
|
77
|
-
if (i > 0)
|
|
78
|
-
finishLine();
|
|
79
|
-
// Called unconditionally (even for an empty segment, where
|
|
80
|
-
// measureTextCached short-circuits to 0) so an empty run still
|
|
81
|
-
// contributes its line height.
|
|
82
|
-
lineW += scope.measureText(segments[i], run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width;
|
|
83
|
-
if (lh > maxLineH)
|
|
84
|
-
maxLineH = lh;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
finishLine();
|
|
88
|
-
if (totalH === 0)
|
|
89
|
-
totalH = this.fontSize * this.lineHeight;
|
|
90
|
-
const wm = this.width;
|
|
91
|
-
const hm = this.height;
|
|
92
|
-
const resolvedW = typeof wm === "number"
|
|
93
|
-
? wm
|
|
94
|
-
: wm === "hug"
|
|
95
|
-
? totalW
|
|
96
|
-
: constraints.maxWidth ?? 0;
|
|
97
|
-
const resolvedH = typeof hm === "number"
|
|
98
|
-
? hm
|
|
99
|
-
: hm === "hug"
|
|
100
|
-
? totalH
|
|
101
|
-
: constraints.maxHeight ?? 0;
|
|
102
|
-
return { width: resolvedW, height: resolvedH };
|
|
42
|
+
return measureRich(this, constraints, scope);
|
|
103
43
|
}
|
|
104
44
|
renderSelf(ctx) {
|
|
105
|
-
ctx.draw(new Graphics2D().richText(
|
|
106
|
-
spans: this.runs(),
|
|
107
|
-
lineHeight: this.lineHeight,
|
|
108
|
-
textAlign: this.textAlign,
|
|
109
|
-
width: this.layoutBounds?.width ?? 0,
|
|
110
|
-
height: this.layoutBounds?.height ?? 0,
|
|
111
|
-
}));
|
|
45
|
+
ctx.draw(new Graphics2D().richText(richState(this, this.layoutBounds)));
|
|
112
46
|
}
|
|
113
47
|
}
|
|
114
48
|
__decorate([
|
|
@@ -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;AA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C,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\";\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,\n }));\n }\n}\n"]}
|
|
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;AAKjD,OAAO,EAAE,SAAS,EAAc,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAI7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AA2BpF,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,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;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 type { AssetScope } from \"@/assets/scope\";\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 { applyTextDefaults } from \"./default-text-style-node\";\r\nimport { declareRichAssets, measureRich, richRuns, richState } from \"./text-layout\";\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 richRuns(this);\r\n }\r\n\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets);\r\n declareRichAssets(this, assets);\r\n }\r\n\r\n measure(constraints: SizeConstraints, scope: MeasureContext2D): Partial<Size2D> {\r\n return measureRich(this, constraints, scope);\r\n }\r\n\r\n protected override renderSelf(ctx: RenderContext2D): void {\r\n ctx.draw(new Graphics2D().richText(richState(this, this.layoutBounds)));\r\n }\r\n}\r\n"]}
|
|
@@ -9,7 +9,7 @@ import { RenderContext2D } from "../../render/render-context2d.js";
|
|
|
9
9
|
import { TextSegment, TextState } from "../../render/descriptors/text.js";
|
|
10
10
|
import type { AssetScope } from "../../assets/scope.js";
|
|
11
11
|
import { PathData } from "../../render/descriptors/path.js";
|
|
12
|
-
import {
|
|
12
|
+
import type { TextSelection } from "./text-selection.js";
|
|
13
13
|
/** The fields a string is shaped and set by, shared by every node that draws glyphs. */
|
|
14
14
|
export interface TextBaseProps extends PaintProps {
|
|
15
15
|
fontSize: number | 'autofit';
|
|
@@ -99,37 +99,20 @@ export declare abstract class TextBase<P extends TextBaseProps = TextBaseProps>
|
|
|
99
99
|
protected resolveContext(ctx: ContextMap): void;
|
|
100
100
|
protected applyDefaultSize(props?: NodeConfig<any, P>): void;
|
|
101
101
|
measure(constraints: SizeConstraints, scope: MeasureContext2D): Partial<Size2D>;
|
|
102
|
-
/**
|
|
103
|
-
* Split the string into contiguous pieces at every style boundary, resolving
|
|
104
|
-
* each piece's effective overrides per the overlap rule: later-created
|
|
105
|
-
* selections win for transform/paint/font; opacity multiplies across all
|
|
106
|
-
* selections covering the piece. Also folds in the Write On reveal window
|
|
107
|
-
* (see below). Returns null when neither is active, so rendering keeps its
|
|
108
|
-
* single-op path.
|
|
109
|
-
*
|
|
110
|
-
* Text-on-path has no pieces in v1 — the string is laid along the path as
|
|
111
|
-
* one run — so a node with a path is answered `null` before anything else.
|
|
112
|
-
*/
|
|
102
|
+
/** The string cut at every style boundary — see {@link textSegments}. */
|
|
113
103
|
protected buildSegments(): TextSegment[] | null;
|
|
114
|
-
/**
|
|
115
|
-
* The node's own face and paint, plus whatever a selection puts on part of the
|
|
116
|
-
* string. Naming a family here is what lets it load *before* layout, rather
|
|
117
|
-
* than being discovered by measuring text against the fallback face.
|
|
118
|
-
*/
|
|
119
104
|
declareAssets(assets: AssetScope): void;
|
|
120
105
|
/**
|
|
121
106
|
* The descriptor this node draws itself as, at the current frame.
|
|
122
107
|
*
|
|
123
|
-
* `@internal` — split out
|
|
124
|
-
*
|
|
125
|
-
* Deriving the two separately is how a caret ends up half a pixel — or, once
|
|
126
|
-
* `'autofit'` or wrapping is in play, half a line — away from its glyph.
|
|
108
|
+
* `@internal` — split out so `node-picking`'s caret geometry is measured
|
|
109
|
+
* from the same state that gets painted.
|
|
127
110
|
*/
|
|
128
111
|
/** @internal */
|
|
129
112
|
_textState(): Partial<TextState>;
|
|
130
113
|
private textOpGraphics;
|
|
131
114
|
protected renderSelf(ctx: RenderContext2D): void;
|
|
132
115
|
protected renderStroke(ctx: RenderContext2D): void;
|
|
133
|
-
private
|
|
116
|
+
private _source;
|
|
134
117
|
}
|
|
135
118
|
//# sourceMappingURL=text-base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-base.d.ts","sourceRoot":"","sources":["../../../src/nodes/text/text-base.ts"],"names":[],"mappings":"AAAA,OAA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