@motionscript/core 0.1.0-alpha.9 → 0.1.1-alpha.0
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 +29 -0
- package/dist/assets/asset-index.d.ts +1 -8
- package/dist/assets/asset-index.d.ts.map +1 -1
- package/dist/assets/asset-index.js +1 -8
- package/dist/assets/asset-index.js.map +1 -1
- package/dist/assets/catalog.d.ts +10 -72
- package/dist/assets/catalog.d.ts.map +1 -1
- package/dist/assets/catalog.js +3 -29
- package/dist/assets/catalog.js.map +1 -1
- package/dist/assets/errors.d.ts +8 -20
- package/dist/assets/errors.d.ts.map +1 -1
- package/dist/assets/errors.js +8 -20
- package/dist/assets/errors.js.map +1 -1
- package/dist/assets/index.d.ts.map +1 -1
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/manager.d.ts +9 -51
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/assets/manager.js +13 -78
- package/dist/assets/manager.js.map +1 -1
- package/dist/assets/record.d.ts +2 -18
- package/dist/assets/record.d.ts.map +1 -1
- package/dist/assets/record.js.map +1 -1
- package/dist/assets/scope.d.ts +3 -18
- package/dist/assets/scope.d.ts.map +1 -1
- package/dist/assets/scope.js +2 -11
- package/dist/assets/scope.js.map +1 -1
- package/dist/attributes/audio/effects/chain.d.ts +2 -12
- package/dist/attributes/audio/effects/chain.d.ts.map +1 -1
- package/dist/attributes/audio/effects/chain.js +1 -7
- package/dist/attributes/audio/effects/chain.js.map +1 -1
- package/dist/attributes/audio/effects/registry.d.ts +3 -18
- package/dist/attributes/audio/effects/registry.d.ts.map +1 -1
- package/dist/attributes/audio/effects/registry.js +4 -23
- package/dist/attributes/audio/effects/registry.js.map +1 -1
- package/dist/attributes/audio/ramp.d.ts +5 -38
- package/dist/attributes/audio/ramp.d.ts.map +1 -1
- package/dist/attributes/audio/ramp.js +3 -28
- package/dist/attributes/audio/ramp.js.map +1 -1
- package/dist/attributes/audio/request.d.ts +10 -80
- package/dist/attributes/audio/request.d.ts.map +1 -1
- package/dist/attributes/audio/request.js +1 -4
- package/dist/attributes/audio/request.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +2 -12
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js +2 -11
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/audio/sound.d.ts +2 -26
- package/dist/attributes/audio/sound.d.ts.map +1 -1
- package/dist/attributes/audio/sound.js +1 -9
- package/dist/attributes/audio/sound.js.map +1 -1
- package/dist/attributes/audio/transition.d.ts +1 -8
- package/dist/attributes/audio/transition.d.ts.map +1 -1
- package/dist/attributes/audio/transition.js.map +1 -1
- package/dist/attributes/layout/alignment.d.ts +6 -38
- package/dist/attributes/layout/alignment.d.ts.map +1 -1
- package/dist/attributes/layout/alignment.js.map +1 -1
- package/dist/attributes/layout/insets.d.ts +2 -27
- package/dist/attributes/layout/insets.d.ts.map +1 -1
- package/dist/attributes/layout/insets.js.map +1 -1
- package/dist/attributes/layout/matrix2d.d.ts +29 -114
- package/dist/attributes/layout/matrix2d.d.ts.map +1 -1
- package/dist/attributes/layout/matrix2d.js +26 -110
- package/dist/attributes/layout/matrix2d.js.map +1 -1
- package/dist/attributes/layout/size.d.ts +3 -25
- package/dist/attributes/layout/size.d.ts.map +1 -1
- package/dist/attributes/layout/size.js +2 -18
- package/dist/attributes/layout/size.js.map +1 -1
- package/dist/attributes/layout/space3d.d.ts +16 -79
- package/dist/attributes/layout/space3d.d.ts.map +1 -1
- package/dist/attributes/layout/space3d.js +17 -81
- package/dist/attributes/layout/space3d.js.map +1 -1
- package/dist/attributes/layout/transform3d.d.ts +2 -23
- package/dist/attributes/layout/transform3d.d.ts.map +1 -1
- package/dist/attributes/layout/transform3d.js +1 -7
- package/dist/attributes/layout/transform3d.js.map +1 -1
- package/dist/attributes/layout/world-transform.d.ts +2 -16
- package/dist/attributes/layout/world-transform.d.ts.map +1 -1
- package/dist/attributes/layout/world-transform.js.map +1 -1
- package/dist/attributes/properties/decorator.d.ts +13 -73
- package/dist/attributes/properties/decorator.d.ts.map +1 -1
- package/dist/attributes/properties/decorator.js +9 -40
- package/dist/attributes/properties/decorator.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +6 -45
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +6 -37
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/render3d/orbit.d.ts +11 -83
- package/dist/attributes/render3d/orbit.d.ts.map +1 -1
- package/dist/attributes/render3d/orbit.js +10 -73
- package/dist/attributes/render3d/orbit.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.d.ts +1 -6
- package/dist/attributes/shape/corners/corner-radius.d.ts.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/corners/corner-style.d.ts +4 -25
- package/dist/attributes/shape/corners/corner-style.d.ts.map +1 -1
- package/dist/attributes/shape/corners/corner-style.js +2 -12
- package/dist/attributes/shape/corners/corner-style.js.map +1 -1
- package/dist/attributes/shape/corners/corners.d.ts +2 -21
- package/dist/attributes/shape/corners/corners.d.ts.map +1 -1
- package/dist/attributes/shape/corners/corners.js +2 -12
- package/dist/attributes/shape/corners/corners.js.map +1 -1
- package/dist/attributes/shape/effects/backdrop.d.ts +2 -18
- package/dist/attributes/shape/effects/backdrop.d.ts.map +1 -1
- package/dist/attributes/shape/effects/backdrop.js +3 -26
- package/dist/attributes/shape/effects/backdrop.js.map +1 -1
- package/dist/attributes/shape/effects/chain.d.ts +36 -328
- package/dist/attributes/shape/effects/chain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/chain.js +24 -242
- package/dist/attributes/shape/effects/chain.js.map +1 -1
- package/dist/attributes/shape/effects/effect-data.d.ts +19 -127
- package/dist/attributes/shape/effects/effect-data.d.ts.map +1 -1
- package/dist/attributes/shape/effects/effect-data.js +6 -33
- package/dist/attributes/shape/effects/effect-data.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.d.ts +6 -26
- package/dist/attributes/shape/effects/implementations/ascii.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.js +0 -3
- package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.d.ts +2 -21
- package/dist/attributes/shape/effects/implementations/bit-crush.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.js +0 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.d.ts +1 -14
- package/dist/attributes/shape/effects/implementations/block-displace.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.js +0 -1
- package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/bloom.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.js +0 -1
- package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.js +0 -1
- package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/bulge.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.js +0 -1
- package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js +0 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts +1 -12
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.js +0 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.d.ts +1 -11
- package/dist/attributes/shape/effects/implementations/curves.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.js +1 -6
- package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.js +0 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.d.ts +4 -35
- package/dist/attributes/shape/effects/implementations/dither.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.js +1 -7
- package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +1 -22
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js +0 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.d.ts +1 -9
- package/dist/attributes/shape/effects/implementations/duotone.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.js +0 -1
- package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.d.ts +2 -15
- package/dist/attributes/shape/effects/implementations/edges.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.js +0 -1
- package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.d.ts +1 -14
- package/dist/attributes/shape/effects/implementations/glass.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.js +0 -1
- package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.d.ts +7 -47
- package/dist/attributes/shape/effects/implementations/glow.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.js +1 -9
- package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.d.ts +1 -14
- package/dist/attributes/shape/effects/implementations/grain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.js +0 -1
- package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/grayscale.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.js +0 -1
- package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.d.ts +5 -29
- package/dist/attributes/shape/effects/implementations/halftone.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.js +0 -1
- package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.d.ts +3 -12
- package/dist/attributes/shape/effects/implementations/invert.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.js +0 -1
- package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts +2 -19
- package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js +1 -5
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.d.ts +11 -36
- package/dist/attributes/shape/effects/implementations/lut.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.js +2 -8
- package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/magnify.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.js +0 -1
- package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.d.ts +3 -17
- package/dist/attributes/shape/effects/implementations/motion-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.js +2 -11
- package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.d.ts +1 -12
- package/dist/attributes/shape/effects/implementations/oil-paint.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.js +0 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.d.ts +2 -14
- package/dist/attributes/shape/effects/implementations/outline.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.js +0 -1
- package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.d.ts +1 -15
- package/dist/attributes/shape/effects/implementations/pixelate.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.js +0 -1
- package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.d.ts +1 -10
- package/dist/attributes/shape/effects/implementations/posterize.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.js +0 -1
- package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts +3 -26
- package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.js +1 -2
- package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.d.ts +2 -16
- package/dist/attributes/shape/effects/implementations/radial-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.js +0 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts +1 -13
- package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.js +0 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.d.ts +1 -8
- package/dist/attributes/shape/effects/implementations/scanlines.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.js +0 -1
- package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/scatter.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.js +0 -1
- package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.d.ts +10 -53
- package/dist/attributes/shape/effects/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.js +2 -9
- package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.d.ts +1 -12
- package/dist/attributes/shape/effects/implementations/sharpen.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.js +0 -1
- package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.d.ts +1 -8
- package/dist/attributes/shape/effects/implementations/streak.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.js +0 -1
- package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.d.ts +1 -9
- package/dist/attributes/shape/effects/implementations/threshold.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.js +0 -1
- package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.d.ts +1 -13
- package/dist/attributes/shape/effects/implementations/twirl.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.js +0 -1
- package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.d.ts +1 -9
- package/dist/attributes/shape/effects/implementations/vignette.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.js +0 -1
- package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/vintage.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.js +0 -1
- package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.d.ts +3 -24
- package/dist/attributes/shape/effects/implementations/wave.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.js +1 -5
- package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
- package/dist/attributes/shape/effects/registry.d.ts +6 -41
- package/dist/attributes/shape/effects/registry.d.ts.map +1 -1
- package/dist/attributes/shape/effects/registry.js +7 -45
- package/dist/attributes/shape/effects/registry.js.map +1 -1
- package/dist/attributes/shape/effects/spec.d.ts +6 -30
- package/dist/attributes/shape/effects/spec.d.ts.map +1 -1
- package/dist/attributes/shape/effects/spec.js +3 -9
- package/dist/attributes/shape/effects/spec.js.map +1 -1
- package/dist/attributes/shape/fill/blend.d.ts +1 -17
- package/dist/attributes/shape/fill/blend.d.ts.map +1 -1
- package/dist/attributes/shape/fill/blend.js +2 -15
- package/dist/attributes/shape/fill/blend.js.map +1 -1
- package/dist/attributes/shape/fill/chain.d.ts +17 -125
- package/dist/attributes/shape/fill/chain.d.ts.map +1 -1
- package/dist/attributes/shape/fill/chain.js +22 -109
- package/dist/attributes/shape/fill/chain.js.map +1 -1
- package/dist/attributes/shape/fill/coerce.d.ts +10 -35
- package/dist/attributes/shape/fill/coerce.d.ts.map +1 -1
- package/dist/attributes/shape/fill/coerce.js +12 -47
- package/dist/attributes/shape/fill/coerce.js.map +1 -1
- package/dist/attributes/shape/fill/color/parser.d.ts +10 -44
- package/dist/attributes/shape/fill/color/parser.d.ts.map +1 -1
- package/dist/attributes/shape/fill/color/parser.js +35 -96
- package/dist/attributes/shape/fill/color/parser.js.map +1 -1
- package/dist/attributes/shape/fill/gradient-stops.d.ts +1 -8
- package/dist/attributes/shape/fill/gradient-stops.d.ts.map +1 -1
- package/dist/attributes/shape/fill/gradient-stops.js +2 -13
- package/dist/attributes/shape/fill/gradient-stops.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/canvas3d.d.ts +2 -24
- package/dist/attributes/shape/fill/implementations/canvas3d.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/canvas3d.js +2 -9
- package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/dot-grid.d.ts +1 -14
- package/dist/attributes/shape/fill/implementations/dot-grid.d.ts.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 +5 -28
- package/dist/attributes/shape/fill/implementations/fractal-noise.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.js +0 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/grid.d.ts +8 -21
- package/dist/attributes/shape/fill/implementations/grid.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/grid.js +2 -8
- package/dist/attributes/shape/fill/implementations/grid.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/image.d.ts +13 -79
- package/dist/attributes/shape/fill/implementations/image.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/image.js +6 -23
- package/dist/attributes/shape/fill/implementations/image.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/noise.d.ts +2 -15
- package/dist/attributes/shape/fill/implementations/noise.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/noise.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.d.ts +11 -45
- package/dist/attributes/shape/fill/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.js +5 -17
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/video.d.ts +12 -64
- package/dist/attributes/shape/fill/implementations/video.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/video.js +12 -50
- package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
- package/dist/attributes/shape/fill/lerp.d.ts +2 -13
- package/dist/attributes/shape/fill/lerp.d.ts.map +1 -1
- package/dist/attributes/shape/fill/lerp.js +2 -9
- package/dist/attributes/shape/fill/lerp.js.map +1 -1
- package/dist/attributes/shape/fill/media-preset.d.ts +8 -49
- package/dist/attributes/shape/fill/media-preset.d.ts.map +1 -1
- package/dist/attributes/shape/fill/media-preset.js +8 -35
- package/dist/attributes/shape/fill/media-preset.js.map +1 -1
- package/dist/attributes/shape/fill/registry.d.ts +2 -26
- package/dist/attributes/shape/fill/registry.d.ts.map +1 -1
- package/dist/attributes/shape/fill/registry.js +5 -40
- package/dist/attributes/shape/fill/registry.js.map +1 -1
- package/dist/attributes/shape/fill/union.d.ts +6 -30
- package/dist/attributes/shape/fill/union.d.ts.map +1 -1
- package/dist/attributes/shape/fill/union.js +1 -9
- package/dist/attributes/shape/fill/union.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +15 -168
- package/dist/attributes/shape/filters/chain.d.ts.map +1 -1
- package/dist/attributes/shape/filters/chain.js +8 -132
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-matrix.d.ts +1 -7
- package/dist/attributes/shape/filters/implementations/color-matrix.d.ts.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-matrix.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/curves.d.ts +1 -7
- package/dist/attributes/shape/filters/implementations/curves.d.ts.map +1 -1
- package/dist/attributes/shape/filters/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/echo.d.ts +1 -11
- package/dist/attributes/shape/filters/implementations/echo.d.ts.map +1 -1
- package/dist/attributes/shape/filters/implementations/echo.js.map +1 -1
- package/dist/attributes/shape/filters/index.d.ts +1 -6
- package/dist/attributes/shape/filters/index.d.ts.map +1 -1
- package/dist/attributes/shape/filters/index.js +0 -2
- package/dist/attributes/shape/filters/index.js.map +1 -1
- package/dist/attributes/shape/filters/registry.d.ts +5 -35
- package/dist/attributes/shape/filters/registry.d.ts.map +1 -1
- package/dist/attributes/shape/filters/registry.js +7 -50
- package/dist/attributes/shape/filters/registry.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +10 -51
- 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 +18 -106
- package/dist/attributes/shape/path/anchors.d.ts.map +1 -1
- package/dist/attributes/shape/path/anchors.js +15 -124
- package/dist/attributes/shape/path/anchors.js.map +1 -1
- package/dist/attributes/shape/path/bezier.d.ts +6 -54
- package/dist/attributes/shape/path/bezier.d.ts.map +1 -1
- package/dist/attributes/shape/path/bezier.js +10 -98
- package/dist/attributes/shape/path/bezier.js.map +1 -1
- package/dist/attributes/shape/path/index.d.ts +1 -11
- package/dist/attributes/shape/path/index.d.ts.map +1 -1
- package/dist/attributes/shape/path/index.js +1 -11
- package/dist/attributes/shape/path/index.js.map +1 -1
- package/dist/attributes/shape/path/measure.d.ts +5 -41
- package/dist/attributes/shape/path/measure.d.ts.map +1 -1
- package/dist/attributes/shape/path/measure.js +8 -57
- package/dist/attributes/shape/path/measure.js.map +1 -1
- package/dist/attributes/shape/path/morph.d.ts +4 -41
- package/dist/attributes/shape/path/morph.d.ts.map +1 -1
- package/dist/attributes/shape/path/morph.js +17 -117
- package/dist/attributes/shape/path/morph.js.map +1 -1
- package/dist/attributes/shape/path/ops.d.ts +5 -19
- package/dist/attributes/shape/path/ops.d.ts.map +1 -1
- package/dist/attributes/shape/path/ops.js.map +1 -1
- package/dist/attributes/shape/path/types.d.ts +10 -67
- package/dist/attributes/shape/path/types.d.ts.map +1 -1
- package/dist/attributes/shape/path/types.js +0 -1
- package/dist/attributes/shape/path/types.js.map +1 -1
- package/dist/attributes/shape/path/walk.d.ts +9 -63
- package/dist/attributes/shape/path/walk.d.ts.map +1 -1
- package/dist/attributes/shape/path/walk.js +21 -100
- package/dist/attributes/shape/path/walk.js.map +1 -1
- package/dist/attributes/shape/shaders/language.d.ts +2 -14
- package/dist/attributes/shape/shaders/language.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/language.js +1 -8
- package/dist/attributes/shape/shaders/language.js.map +1 -1
- package/dist/attributes/shape/shaders/pack.d.ts +13 -78
- package/dist/attributes/shape/shaders/pack.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/pack.js +1 -10
- package/dist/attributes/shape/shaders/pack.js.map +1 -1
- package/dist/attributes/shape/shaders/resolve.d.ts +1 -11
- package/dist/attributes/shape/shaders/resolve.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/resolve.js +3 -28
- package/dist/attributes/shape/shaders/resolve.js.map +1 -1
- package/dist/attributes/shape/shaders/uniforms.d.ts +3 -24
- package/dist/attributes/shape/shaders/uniforms.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/uniforms.js +0 -0
- package/dist/attributes/shape/shaders/uniforms.js.map +1 -1
- package/dist/attributes/shape/shadow/shadow.d.ts +3 -20
- package/dist/attributes/shape/shadow/shadow.d.ts.map +1 -1
- package/dist/attributes/shape/shadow/shadow.js +0 -3
- package/dist/attributes/shape/shadow/shadow.js.map +1 -1
- package/dist/attributes/shape/stroke/stroke.d.ts +9 -58
- package/dist/attributes/shape/stroke/stroke.d.ts.map +1 -1
- package/dist/attributes/shape/stroke/stroke.js +0 -6
- package/dist/attributes/shape/stroke/stroke.js.map +1 -1
- package/dist/attributes/shared/operators.d.ts +1 -8
- package/dist/attributes/shared/operators.d.ts.map +1 -1
- package/dist/attributes/shared/operators.js.map +1 -1
- package/dist/attributes/text/index.d.ts +1 -11
- package/dist/attributes/text/index.d.ts.map +1 -1
- package/dist/attributes/text/index.js +1 -11
- package/dist/attributes/text/index.js.map +1 -1
- package/dist/attributes/text/ops.d.ts +4 -30
- package/dist/attributes/text/ops.d.ts.map +1 -1
- package/dist/attributes/text/ops.js +7 -23
- package/dist/attributes/text/ops.js.map +1 -1
- package/dist/attributes/text/types.d.ts +5 -28
- package/dist/attributes/text/types.d.ts.map +1 -1
- package/dist/attributes/text/types.js.map +1 -1
- package/dist/browser/chunks/chunk-3ZIUZZC7.js +13 -0
- package/dist/browser/chunks/chunk-3ZIUZZC7.js.map +7 -0
- package/dist/browser/chunks/chunk-5TDMGUXQ.js +3 -0
- package/dist/browser/chunks/chunk-5TDMGUXQ.js.map +7 -0
- package/dist/browser/chunks/chunk-7YOYMMXK.js +6 -0
- package/dist/browser/chunks/chunk-7YOYMMXK.js.map +7 -0
- package/dist/browser/chunks/{chunk-4BDLFEOC.js → chunk-GEJEQQER.js} +1 -1
- package/dist/browser/chunks/chunk-GEJEQQER.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/experimental.js +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/sdk.js +1 -1
- package/dist/component.d.ts +3 -10
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +3 -10
- package/dist/component.js.map +1 -1
- package/dist/components/builtins/geometry/geometry.d.ts +15 -62
- package/dist/components/builtins/geometry/geometry.d.ts.map +1 -1
- package/dist/components/builtins/geometry/geometry.js.map +1 -1
- package/dist/components/builtins/geometry/shape-outline.d.ts +12 -61
- package/dist/components/builtins/geometry/shape-outline.d.ts.map +1 -1
- package/dist/components/builtins/geometry/shape-outline.js +29 -168
- package/dist/components/builtins/geometry/shape-outline.js.map +1 -1
- package/dist/components/builtins/layout/layout.d.ts +1 -14
- package/dist/components/builtins/layout/layout.d.ts.map +1 -1
- package/dist/components/builtins/layout/layout.js.map +1 -1
- package/dist/components/builtins/media/media.d.ts +11 -51
- package/dist/components/builtins/media/media.d.ts.map +1 -1
- package/dist/components/builtins/media/media.js +3 -7
- package/dist/components/builtins/media/media.js.map +1 -1
- package/dist/components/builtins/text/number-format.d.ts +14 -47
- package/dist/components/builtins/text/number-format.d.ts.map +1 -1
- package/dist/components/builtins/text/number-format.js +19 -69
- package/dist/components/builtins/text/number-format.js.map +1 -1
- package/dist/components/builtins/text/number-pattern.d.ts +3 -37
- package/dist/components/builtins/text/number-pattern.d.ts.map +1 -1
- package/dist/components/builtins/text/number-pattern.js +6 -48
- package/dist/components/builtins/text/number-pattern.js.map +1 -1
- package/dist/components/builtins/text/text-defaults.d.ts +7 -25
- package/dist/components/builtins/text/text-defaults.d.ts.map +1 -1
- package/dist/components/builtins/text/text-defaults.js +7 -25
- package/dist/components/builtins/text/text-defaults.js.map +1 -1
- package/dist/components/builtins/text/text-layout.d.ts +2 -11
- package/dist/components/builtins/text/text-layout.d.ts.map +1 -1
- package/dist/components/builtins/text/text-layout.js +7 -22
- package/dist/components/builtins/text/text-layout.js.map +1 -1
- package/dist/components/builtins/text/text.d.ts +8 -46
- package/dist/components/builtins/text/text.d.ts.map +1 -1
- package/dist/components/builtins/text/text.js.map +1 -1
- package/dist/components/builtins/three/canvas3d.d.ts +6 -51
- package/dist/components/builtins/three/canvas3d.d.ts.map +1 -1
- package/dist/components/builtins/three/canvas3d.js.map +1 -1
- package/dist/components/builtins/three/grid-geometry3d.d.ts +3 -39
- package/dist/components/builtins/three/grid-geometry3d.d.ts.map +1 -1
- package/dist/components/builtins/three/grid-geometry3d.js +8 -46
- package/dist/components/builtins/three/grid-geometry3d.js.map +1 -1
- package/dist/components/builtins/three/three.d.ts +22 -117
- package/dist/components/builtins/three/three.d.ts.map +1 -1
- package/dist/components/builtins/three/three.js +5 -17
- package/dist/components/builtins/three/three.js.map +1 -1
- package/dist/components/factory/api.d.ts.map +1 -1
- package/dist/components/factory/api.js.map +1 -1
- package/dist/components/factory/views.d.ts.map +1 -1
- package/dist/components/factory/views.js +41 -3
- package/dist/components/factory/views.js.map +1 -1
- package/dist/components/trees/2d/group-bounds.d.ts +12 -41
- package/dist/components/trees/2d/group-bounds.d.ts.map +1 -1
- package/dist/components/trees/2d/group-bounds.js +3 -22
- package/dist/components/trees/2d/group-bounds.js.map +1 -1
- package/dist/components/trees/2d/node-lifecycle.d.ts +8 -36
- package/dist/components/trees/2d/node-lifecycle.d.ts.map +1 -1
- package/dist/components/trees/2d/node-lifecycle.js +35 -127
- package/dist/components/trees/2d/node-lifecycle.js.map +1 -1
- package/dist/components/trees/2d/node-motion.d.ts +4 -36
- package/dist/components/trees/2d/node-motion.d.ts.map +1 -1
- package/dist/components/trees/2d/node-motion.js +3 -31
- package/dist/components/trees/2d/node-motion.js.map +1 -1
- package/dist/components/trees/2d/node-render.d.ts +3 -20
- package/dist/components/trees/2d/node-render.d.ts.map +1 -1
- package/dist/components/trees/2d/node-render.js +4 -23
- package/dist/components/trees/2d/node-render.js.map +1 -1
- package/dist/components/trees/2d/node-space.d.ts +4 -23
- package/dist/components/trees/2d/node-space.d.ts.map +1 -1
- package/dist/components/trees/2d/node-space.js +3 -17
- package/dist/components/trees/2d/node-space.js.map +1 -1
- package/dist/components/trees/2d/node-transform.d.ts +4 -33
- package/dist/components/trees/2d/node-transform.d.ts.map +1 -1
- package/dist/components/trees/2d/node-transform.js +4 -33
- package/dist/components/trees/2d/node-transform.js.map +1 -1
- package/dist/components/trees/2d/node2d.d.ts +112 -622
- package/dist/components/trees/2d/node2d.d.ts.map +1 -1
- package/dist/components/trees/2d/node2d.js +131 -605
- package/dist/components/trees/2d/node2d.js.map +1 -1
- package/dist/components/trees/audio/node-audio.d.ts +17 -65
- package/dist/components/trees/audio/node-audio.d.ts.map +1 -1
- package/dist/components/trees/audio/node-audio.js +18 -68
- package/dist/components/trees/audio/node-audio.js.map +1 -1
- package/dist/components/trees/node/node-editor-state.d.ts +5 -45
- package/dist/components/trees/node/node-editor-state.d.ts.map +1 -1
- package/dist/components/trees/node/node-editor-state.js +1 -13
- package/dist/components/trees/node/node-editor-state.js.map +1 -1
- package/dist/components/trees/node/node-reactive.d.ts +6 -54
- package/dist/components/trees/node/node-reactive.d.ts.map +1 -1
- package/dist/components/trees/node/node-reactive.js +13 -39
- package/dist/components/trees/node/node-reactive.js.map +1 -1
- package/dist/components/trees/node/node-time.d.ts +2 -15
- package/dist/components/trees/node/node-time.d.ts.map +1 -1
- package/dist/components/trees/node/node-time.js.map +1 -1
- package/dist/components/trees/node/node-walk.d.ts +7 -32
- package/dist/components/trees/node/node-walk.d.ts.map +1 -1
- package/dist/components/trees/node/node-walk.js +7 -32
- package/dist/components/trees/node/node-walk.js.map +1 -1
- package/dist/components/trees/node/node.d.ts +43 -248
- package/dist/components/trees/node/node.d.ts.map +1 -1
- package/dist/components/trees/node/node.js +51 -229
- package/dist/components/trees/node/node.js.map +1 -1
- package/dist/components/trees/root/canvas2d-node.d.ts +7 -60
- package/dist/components/trees/root/canvas2d-node.d.ts.map +1 -1
- package/dist/components/trees/root/canvas2d-node.js +7 -47
- package/dist/components/trees/root/canvas2d-node.js.map +1 -1
- package/dist/components/trees/three/node3d.d.ts +24 -112
- package/dist/components/trees/three/node3d.d.ts.map +1 -1
- package/dist/components/trees/three/node3d.js +22 -104
- package/dist/components/trees/three/node3d.js.map +1 -1
- package/dist/document/audio.d.ts +9 -21
- package/dist/document/audio.d.ts.map +1 -1
- package/dist/document/audio.js +13 -28
- package/dist/document/audio.js.map +1 -1
- package/dist/document/builtins.d.ts +3 -9
- package/dist/document/builtins.d.ts.map +1 -1
- package/dist/document/builtins.js +43 -89
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +15 -30
- package/dist/document/command-traits.d.ts.map +1 -1
- package/dist/document/command-traits.js +31 -31
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/deny-globals.d.ts +9 -43
- package/dist/document/deny-globals.d.ts.map +1 -1
- package/dist/document/deny-globals.js +18 -58
- package/dist/document/deny-globals.js.map +1 -1
- package/dist/document/diff.d.ts +6 -16
- package/dist/document/diff.d.ts.map +1 -1
- package/dist/document/diff.js +5 -11
- package/dist/document/diff.js.map +1 -1
- package/dist/document/doc-index.d.ts +5 -13
- package/dist/document/doc-index.d.ts.map +1 -1
- package/dist/document/doc-index.js +0 -2
- package/dist/document/doc-index.js.map +1 -1
- package/dist/document/expression/compile.d.ts +2 -2
- package/dist/document/expression/compile.d.ts.map +1 -1
- package/dist/document/expression/compile.js +8 -18
- package/dist/document/expression/compile.js.map +1 -1
- package/dist/document/expression/index.d.ts +11 -41
- package/dist/document/expression/index.d.ts.map +1 -1
- package/dist/document/expression/index.js +11 -41
- package/dist/document/expression/index.js.map +1 -1
- package/dist/document/expression/ops.d.ts +3 -12
- package/dist/document/expression/ops.d.ts.map +1 -1
- package/dist/document/expression/ops.js +4 -20
- package/dist/document/expression/ops.js.map +1 -1
- package/dist/document/expression/parse.d.ts +4 -14
- package/dist/document/expression/parse.d.ts.map +1 -1
- package/dist/document/expression/parse.js +34 -55
- package/dist/document/expression/parse.js.map +1 -1
- package/dist/document/expression/refs.d.ts +2 -8
- package/dist/document/expression/refs.d.ts.map +1 -1
- package/dist/document/expression/refs.js +2 -6
- package/dist/document/expression/refs.js.map +1 -1
- package/dist/document/expression/types.d.ts +18 -63
- package/dist/document/expression/types.d.ts.map +1 -1
- package/dist/document/expression/types.js +4 -15
- package/dist/document/expression/types.js.map +1 -1
- package/dist/document/expression/walk.d.ts +6 -20
- package/dist/document/expression/walk.d.ts.map +1 -1
- package/dist/document/expression/walk.js +18 -44
- package/dist/document/expression/walk.js.map +1 -1
- package/dist/document/index.js +2 -3
- package/dist/document/index.js.map +1 -1
- package/dist/document/migrate.d.ts +7 -22
- package/dist/document/migrate.d.ts.map +1 -1
- package/dist/document/migrate.js +44 -15
- package/dist/document/migrate.js.map +1 -1
- package/dist/document/missing-node.d.ts +4 -11
- package/dist/document/missing-node.d.ts.map +1 -1
- package/dist/document/missing-node.js +2 -5
- package/dist/document/missing-node.js.map +1 -1
- package/dist/document/node-decorator.d.ts +12 -53
- package/dist/document/node-decorator.d.ts.map +1 -1
- package/dist/document/node-decorator.js +16 -57
- package/dist/document/node-decorator.js.map +1 -1
- package/dist/document/node-descriptor.d.ts +25 -62
- 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 +18 -41
- package/dist/document/placement.d.ts.map +1 -1
- package/dist/document/placement.js +4 -11
- package/dist/document/placement.js.map +1 -1
- package/dist/document/project.d.ts +19 -52
- package/dist/document/project.d.ts.map +1 -1
- package/dist/document/project.js +2 -6
- package/dist/document/project.js.map +1 -1
- package/dist/document/prop-evolution.d.ts +10 -20
- package/dist/document/prop-evolution.d.ts.map +1 -1
- package/dist/document/prop-evolution.js +3 -7
- package/dist/document/prop-evolution.js.map +1 -1
- package/dist/document/registry.d.ts +80 -318
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +43 -147
- package/dist/document/registry.js.map +1 -1
- package/dist/document/settled-index.d.ts +12 -18
- package/dist/document/settled-index.d.ts.map +1 -1
- package/dist/document/settled-index.js +29 -31
- package/dist/document/settled-index.js.map +1 -1
- package/dist/document/timeline-patch.d.ts +6 -15
- package/dist/document/timeline-patch.d.ts.map +1 -1
- package/dist/document/timeline-patch.js +12 -21
- package/dist/document/timeline-patch.js.map +1 -1
- package/dist/document/timeline.d.ts +56 -263
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +97 -281
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +90 -264
- package/dist/document/types.d.ts.map +1 -1
- package/dist/document/types.js +13 -30
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +10 -40
- package/dist/document/validate.d.ts.map +1 -1
- package/dist/document/validate.js +72 -137
- package/dist/document/validate.js.map +1 -1
- package/dist/document/vocabulary.d.ts +4 -7
- package/dist/document/vocabulary.d.ts.map +1 -1
- package/dist/document/vocabulary.js +0 -1
- package/dist/document/vocabulary.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/bounds.d.ts +1 -11
- package/dist/layout/bounds.d.ts.map +1 -1
- package/dist/layout/bounds.js.map +1 -1
- package/dist/layout/flex.d.ts +6 -20
- package/dist/layout/flex.d.ts.map +1 -1
- package/dist/layout/flex.js +7 -28
- package/dist/layout/flex.js.map +1 -1
- package/dist/layout/ops.d.ts +2 -11
- package/dist/layout/ops.d.ts.map +1 -1
- package/dist/layout/ops.js +2 -22
- package/dist/layout/ops.js.map +1 -1
- package/dist/layout/types.d.ts +11 -55
- package/dist/layout/types.d.ts.map +1 -1
- package/dist/layout/types.js.map +1 -1
- package/dist/platform/audio-sink.d.ts +7 -43
- package/dist/platform/audio-sink.d.ts.map +1 -1
- package/dist/platform/audio-sink.js +4 -29
- package/dist/platform/audio-sink.js.map +1 -1
- package/dist/platform/exporter.d.ts +5 -31
- package/dist/platform/exporter.d.ts.map +1 -1
- package/dist/platform/exporter.js.map +1 -1
- package/dist/platform/stepped-clock.d.ts +1 -16
- package/dist/platform/stepped-clock.d.ts.map +1 -1
- package/dist/platform/stepped-clock.js +1 -16
- package/dist/platform/stepped-clock.js.map +1 -1
- package/dist/platform/storage-adapter.d.ts +8 -68
- package/dist/platform/storage-adapter.d.ts.map +1 -1
- package/dist/platform/storage-adapter.js +8 -60
- package/dist/platform/storage-adapter.js.map +1 -1
- package/dist/platform/ticker.d.ts +11 -45
- package/dist/platform/ticker.d.ts.map +1 -1
- package/dist/platform/ticker.js +10 -37
- package/dist/platform/ticker.js.map +1 -1
- package/dist/project/config.d.ts +4 -14
- package/dist/project/config.d.ts.map +1 -1
- package/dist/project/config.js.map +1 -1
- package/dist/project/tree.d.ts +6 -35
- package/dist/project/tree.d.ts.map +1 -1
- package/dist/project/tree.js +1 -8
- package/dist/project/tree.js.map +1 -1
- package/dist/props/host.d.ts +7 -13
- package/dist/props/host.d.ts.map +1 -1
- package/dist/props/host.js +3 -1
- package/dist/props/host.js.map +1 -1
- package/dist/props/layout.d.ts +18 -0
- package/dist/props/layout.d.ts.map +1 -0
- package/dist/props/layout.js +73 -0
- package/dist/props/layout.js.map +1 -0
- package/dist/props/observer.d.ts +1 -7
- package/dist/props/observer.d.ts.map +1 -1
- package/dist/props/observer.js.map +1 -1
- package/dist/props/slot.d.ts +6 -19
- package/dist/props/slot.d.ts.map +1 -1
- package/dist/props/slot.js +5 -14
- package/dist/props/slot.js.map +1 -1
- package/dist/render/canvas-render-context2d.d.ts +8 -68
- package/dist/render/canvas-render-context2d.d.ts.map +1 -1
- package/dist/render/canvas-render-context2d.js +8 -69
- package/dist/render/canvas-render-context2d.js.map +1 -1
- package/dist/render/clip-contains.d.ts +2 -16
- package/dist/render/clip-contains.d.ts.map +1 -1
- package/dist/render/clip-contains.js +21 -82
- package/dist/render/clip-contains.js.map +1 -1
- package/dist/render/clip.d.ts +7 -25
- package/dist/render/clip.d.ts.map +1 -1
- package/dist/render/clip.js +5 -17
- package/dist/render/clip.js.map +1 -1
- package/dist/render/descriptors/ellipse.d.ts.map +1 -1
- package/dist/render/descriptors/ellipse.js +0 -1
- package/dist/render/descriptors/ellipse.js.map +1 -1
- package/dist/render/descriptors/line.d.ts.map +1 -1
- package/dist/render/descriptors/line.js +0 -1
- package/dist/render/descriptors/line.js.map +1 -1
- package/dist/render/descriptors/path-builder.d.ts +4 -32
- package/dist/render/descriptors/path-builder.d.ts.map +1 -1
- package/dist/render/descriptors/path-builder.js +3 -25
- package/dist/render/descriptors/path-builder.js.map +1 -1
- package/dist/render/descriptors/path.d.ts +1 -11
- package/dist/render/descriptors/path.d.ts.map +1 -1
- package/dist/render/descriptors/path.js +0 -1
- package/dist/render/descriptors/path.js.map +1 -1
- package/dist/render/descriptors/polygon.d.ts.map +1 -1
- package/dist/render/descriptors/polygon.js +0 -1
- package/dist/render/descriptors/polygon.js.map +1 -1
- package/dist/render/descriptors/polygram.d.ts.map +1 -1
- package/dist/render/descriptors/polygram.js +0 -1
- package/dist/render/descriptors/polygram.js.map +1 -1
- package/dist/render/descriptors/rect.d.ts.map +1 -1
- package/dist/render/descriptors/rect.js +0 -1
- package/dist/render/descriptors/rect.js.map +1 -1
- package/dist/render/descriptors/richtext.d.ts.map +1 -1
- package/dist/render/descriptors/richtext.js +0 -1
- package/dist/render/descriptors/richtext.js.map +1 -1
- package/dist/render/descriptors/shape.d.ts +17 -77
- package/dist/render/descriptors/shape.d.ts.map +1 -1
- package/dist/render/descriptors/shape.js +13 -47
- package/dist/render/descriptors/shape.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +15 -94
- package/dist/render/descriptors/text.d.ts.map +1 -1
- package/dist/render/descriptors/text.js +8 -50
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/descriptors/transform.d.ts +5 -16
- package/dist/render/descriptors/transform.d.ts.map +1 -1
- package/dist/render/descriptors/transform.js +1 -17
- package/dist/render/descriptors/transform.js.map +1 -1
- package/dist/render/graphics2d.d.ts +24 -116
- package/dist/render/graphics2d.d.ts.map +1 -1
- package/dist/render/graphics2d.js +23 -108
- package/dist/render/graphics2d.js.map +1 -1
- package/dist/render/measure-context.d.ts +5 -29
- package/dist/render/measure-context.d.ts.map +1 -1
- package/dist/render/measure-context.js.map +1 -1
- package/dist/render/null-render-context.d.ts +2 -20
- package/dist/render/null-render-context.d.ts.map +1 -1
- package/dist/render/null-render-context.js +2 -20
- package/dist/render/null-render-context.js.map +1 -1
- package/dist/render/render-context2d.d.ts +52 -208
- package/dist/render/render-context2d.d.ts.map +1 -1
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render/surface.d.ts +2 -19
- package/dist/render/surface.d.ts.map +1 -1
- package/dist/render/surface.js.map +1 -1
- package/dist/render/text-defaults.d.ts +1 -17
- package/dist/render/text-defaults.d.ts.map +1 -1
- package/dist/render/text-defaults.js +6 -40
- package/dist/render/text-defaults.js.map +1 -1
- package/dist/render/text-layout.d.ts +12 -55
- package/dist/render/text-layout.d.ts.map +1 -1
- package/dist/render/text-layout.js +2 -16
- package/dist/render/text-layout.js.map +1 -1
- package/dist/render3d/bounds3d.d.ts +10 -32
- package/dist/render3d/bounds3d.d.ts.map +1 -1
- package/dist/render3d/bounds3d.js +2 -12
- package/dist/render3d/bounds3d.js.map +1 -1
- package/dist/render3d/builders.d.ts +8 -35
- package/dist/render3d/builders.d.ts.map +1 -1
- package/dist/render3d/builders.js +8 -35
- package/dist/render3d/builders.js.map +1 -1
- package/dist/render3d/camera.d.ts +10 -57
- package/dist/render3d/camera.d.ts.map +1 -1
- package/dist/render3d/camera.js +4 -26
- package/dist/render3d/camera.js.map +1 -1
- package/dist/render3d/fill3d.d.ts +7 -45
- package/dist/render3d/fill3d.d.ts.map +1 -1
- package/dist/render3d/fill3d.js +15 -85
- package/dist/render3d/fill3d.js.map +1 -1
- package/dist/render3d/geometry.d.ts +18 -106
- package/dist/render3d/geometry.d.ts.map +1 -1
- package/dist/render3d/geometry.js +2 -20
- package/dist/render3d/geometry.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts +29 -133
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +23 -110
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/render3d/index.d.ts +1 -16
- package/dist/render3d/index.d.ts.map +1 -1
- package/dist/render3d/index.js +1 -16
- package/dist/render3d/index.js.map +1 -1
- package/dist/render3d/inert.d.ts.map +1 -1
- package/dist/render3d/inert.js +1 -14
- package/dist/render3d/inert.js.map +1 -1
- package/dist/render3d/light.d.ts +3 -26
- package/dist/render3d/light.d.ts.map +1 -1
- package/dist/render3d/light.js.map +1 -1
- package/dist/render3d/material.d.ts +13 -87
- package/dist/render3d/material.d.ts.map +1 -1
- package/dist/render3d/material.js +2 -16
- package/dist/render3d/material.js.map +1 -1
- package/dist/render3d/matrix4.d.ts +14 -68
- package/dist/render3d/matrix4.d.ts.map +1 -1
- package/dist/render3d/matrix4.js +11 -60
- package/dist/render3d/matrix4.js.map +1 -1
- package/dist/render3d/render-context3d.d.ts +13 -51
- package/dist/render3d/render-context3d.d.ts.map +1 -1
- package/dist/render3d/render-context3d.js +9 -21
- package/dist/render3d/render-context3d.js.map +1 -1
- package/dist/render3d/resources.d.ts +9 -53
- package/dist/render3d/resources.d.ts.map +1 -1
- package/dist/render3d/resources.js +8 -48
- package/dist/render3d/resources.js.map +1 -1
- package/dist/render3d/rounded-box.d.ts +7 -21
- package/dist/render3d/rounded-box.d.ts.map +1 -1
- package/dist/render3d/rounded-box.js +7 -46
- package/dist/render3d/rounded-box.js.map +1 -1
- package/dist/render3d/scene-settings.d.ts +20 -78
- 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 -53
- package/dist/render3d/scene3d.d.ts.map +1 -1
- package/dist/render3d/scene3d.js +12 -59
- package/dist/render3d/scene3d.js.map +1 -1
- package/dist/render3d/segments.d.ts +2 -25
- package/dist/render3d/segments.d.ts.map +1 -1
- package/dist/render3d/segments.js +1 -11
- package/dist/render3d/segments.js.map +1 -1
- package/dist/render3d/texture.d.ts +25 -112
- package/dist/render3d/texture.d.ts.map +1 -1
- package/dist/render3d/texture.js +3 -27
- package/dist/render3d/texture.js.map +1 -1
- package/dist/render3d/tracking.d.ts +2 -19
- package/dist/render3d/tracking.d.ts.map +1 -1
- package/dist/render3d/tracking.js +2 -19
- package/dist/render3d/tracking.js.map +1 -1
- package/dist/render3d/transform.d.ts +14 -60
- package/dist/render3d/transform.d.ts.map +1 -1
- package/dist/render3d/transform.js +0 -2
- package/dist/render3d/transform.js.map +1 -1
- package/dist/render3d/vector3.d.ts +6 -48
- package/dist/render3d/vector3.d.ts.map +1 -1
- package/dist/render3d/vector3.js +4 -38
- package/dist/render3d/vector3.js.map +1 -1
- package/dist/render3d/walk.d.ts +3 -27
- package/dist/render3d/walk.d.ts.map +1 -1
- package/dist/render3d/walk.js +5 -33
- package/dist/render3d/walk.js.map +1 -1
- package/dist/runtime/asset-refine.d.ts +34 -20
- package/dist/runtime/asset-refine.d.ts.map +1 -1
- package/dist/runtime/asset-refine.js +127 -31
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-timeline.d.ts +14 -53
- package/dist/runtime/asset-timeline.d.ts.map +1 -1
- package/dist/runtime/asset-timeline.js +6 -27
- package/dist/runtime/asset-timeline.js.map +1 -1
- package/dist/runtime/asset-update.d.ts +7 -26
- package/dist/runtime/asset-update.d.ts.map +1 -1
- package/dist/runtime/asset-update.js +6 -18
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/audio-index.d.ts +0 -2
- package/dist/runtime/audio-index.d.ts.map +1 -1
- package/dist/runtime/audio-index.js +0 -2
- package/dist/runtime/audio-index.js.map +1 -1
- package/dist/runtime/builtin-context.d.ts +3 -9
- package/dist/runtime/builtin-context.d.ts.map +1 -1
- package/dist/runtime/builtin-context.js +3 -9
- package/dist/runtime/builtin-context.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +12 -39
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +21 -45
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +26 -68
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +47 -81
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +31 -85
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +16 -49
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/frame-time.d.ts +4 -15
- package/dist/runtime/frame-time.d.ts.map +1 -1
- package/dist/runtime/frame-time.js +5 -12
- package/dist/runtime/frame-time.js.map +1 -1
- package/dist/runtime/index.d.ts +0 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +0 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/node-picking.d.ts +59 -139
- package/dist/runtime/node-picking.d.ts.map +1 -1
- package/dist/runtime/node-picking.js +87 -157
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +39 -96
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +98 -141
- package/dist/runtime/node-picking3d.js.map +1 -1
- package/dist/runtime/placement.d.ts +8 -17
- package/dist/runtime/placement.d.ts.map +1 -1
- package/dist/runtime/placement.js +7 -16
- package/dist/runtime/placement.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts +78 -207
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +111 -226
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/playback.d.ts +6 -14
- package/dist/runtime/playback.d.ts.map +1 -1
- package/dist/runtime/playback.js +6 -14
- package/dist/runtime/playback.js.map +1 -1
- package/dist/runtime/project-assets.d.ts +6 -14
- package/dist/runtime/project-assets.d.ts.map +1 -1
- package/dist/runtime/project-assets.js +7 -16
- package/dist/runtime/project-assets.js.map +1 -1
- package/dist/runtime/session.d.ts +22 -45
- package/dist/runtime/session.d.ts.map +1 -1
- package/dist/runtime/session.js +26 -46
- package/dist/runtime/session.js.map +1 -1
- package/dist/runtime/settle.d.ts +4 -10
- package/dist/runtime/settle.d.ts.map +1 -1
- package/dist/runtime/settle.js +4 -10
- package/dist/runtime/settle.js.map +1 -1
- package/dist/runtime/state-evaluator.d.ts +15 -37
- package/dist/runtime/state-evaluator.d.ts.map +1 -1
- package/dist/runtime/state-evaluator.js +27 -44
- package/dist/runtime/state-evaluator.js.map +1 -1
- package/dist/runtime/text-geometry.d.ts +18 -47
- package/dist/runtime/text-geometry.d.ts.map +1 -1
- package/dist/runtime/text-geometry.js +13 -27
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +1 -7
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +30 -138
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +6 -26
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js +1 -6
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/command.d.ts +6 -53
- package/dist/tween/command.d.ts.map +1 -1
- package/dist/tween/command.js +5 -40
- package/dist/tween/command.js.map +1 -1
- package/dist/tween/ease/curve.d.ts +2 -17
- package/dist/tween/ease/curve.d.ts.map +1 -1
- package/dist/tween/ease/curve.js +1 -6
- package/dist/tween/ease/curve.js.map +1 -1
- package/dist/tween/ease/describe.d.ts +0 -11
- package/dist/tween/ease/describe.d.ts.map +1 -1
- package/dist/tween/ease/describe.js +0 -23
- package/dist/tween/ease/describe.js.map +1 -1
- package/dist/tween/ease/spec.d.ts +2 -18
- package/dist/tween/ease/spec.d.ts.map +1 -1
- package/dist/tween/ease/spec.js.map +1 -1
- package/dist/tween/inert.d.ts +1 -14
- package/dist/tween/inert.d.ts.map +1 -1
- package/dist/tween/inert.js +1 -14
- package/dist/tween/inert.js.map +1 -1
- package/dist/tween/lerp.d.ts +2 -26
- package/dist/tween/lerp.d.ts.map +1 -1
- package/dist/tween/lerp.js +2 -26
- package/dist/tween/lerp.js.map +1 -1
- package/dist/tween/loop.d.ts +9 -50
- package/dist/tween/loop.d.ts.map +1 -1
- package/dist/tween/loop.js +6 -31
- package/dist/tween/loop.js.map +1 -1
- package/dist/tween/prepare.d.ts +2 -30
- package/dist/tween/prepare.d.ts.map +1 -1
- package/dist/tween/prepare.js +2 -30
- package/dist/tween/prepare.js.map +1 -1
- package/dist/tween/stepper.d.ts +4 -25
- package/dist/tween/stepper.d.ts.map +1 -1
- package/dist/tween/stepper.js.map +1 -1
- package/dist/tween/to-command.d.ts +1 -8
- package/dist/tween/to-command.d.ts.map +1 -1
- package/dist/tween/to-command.js +2 -25
- package/dist/tween/to-command.js.map +1 -1
- package/dist/util/context.d.ts +4 -29
- package/dist/util/context.d.ts.map +1 -1
- package/dist/util/context.js +3 -15
- package/dist/util/context.js.map +1 -1
- package/dist/util/csv.d.ts +4 -29
- package/dist/util/csv.d.ts.map +1 -1
- package/dist/util/csv.js +3 -22
- package/dist/util/csv.js.map +1 -1
- package/dist/util/metrics.d.ts +2 -26
- package/dist/util/metrics.d.ts.map +1 -1
- package/dist/util/metrics.js +2 -26
- package/dist/util/metrics.js.map +1 -1
- package/dist/util/random.d.ts +20 -87
- package/dist/util/random.d.ts.map +1 -1
- package/dist/util/random.js +20 -87
- package/dist/util/random.js.map +1 -1
- package/dist/util/reference.d.ts +6 -35
- package/dist/util/reference.d.ts.map +1 -1
- package/dist/util/reference.js +1 -4
- package/dist/util/reference.js.map +1 -1
- package/dist/util/scheduler.d.ts +6 -27
- package/dist/util/scheduler.d.ts.map +1 -1
- package/dist/util/scheduler.js +8 -35
- package/dist/util/scheduler.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser/chunks/chunk-4BDLFEOC.js.map +0 -7
- package/dist/browser/chunks/chunk-7DB6BI27.js +0 -6
- package/dist/browser/chunks/chunk-7DB6BI27.js.map +0 -7
- package/dist/browser/chunks/chunk-IX53IFBD.js +0 -13
- package/dist/browser/chunks/chunk-IX53IFBD.js.map +0 -7
- package/dist/browser/chunks/chunk-Q55UPA3E.js +0 -3
- package/dist/browser/chunks/chunk-Q55UPA3E.js.map +0 -7
- package/dist/renamed-scene-names.d.ts +0 -17
- package/dist/renamed-scene-names.d.ts.map +0 -1
- package/dist/renamed-scene-names.js +0 -9
- package/dist/renamed-scene-names.js.map +0 -1
- package/dist/runtime/precompisition.d.ts +0 -24
- package/dist/runtime/precompisition.d.ts.map +0 -1
- package/dist/runtime/precompisition.js +0 -7
- package/dist/runtime/precompisition.js.map +0 -1
package/dist/util/csv.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parse CSV text into an array of row records keyed by the header row.
|
|
3
|
-
* Handles quoted fields (embedded delimiters, newlines, and `""` escapes) and
|
|
4
|
-
* both CRLF/LF line endings. Synchronous and dependency-free, so it's safe to
|
|
5
|
-
* call at module-eval time on text pulled in via a `?raw` import.
|
|
6
|
-
*/
|
|
1
|
+
/** Parses CSV text into row records keyed by the header row. Handles quoted fields (embedded delimiters, newlines, `""` escapes) and CRLF/LF. Synchronous and dependency-free, so safe at module-eval time on `?raw` text. */
|
|
7
2
|
export function parseCSV(text, options = {}) {
|
|
8
3
|
const delimiter = options.delimiter ?? ',';
|
|
9
4
|
const rows = splitRows(text, delimiter);
|
|
@@ -37,22 +32,13 @@ export function parseCSV(text, options = {}) {
|
|
|
37
32
|
return out;
|
|
38
33
|
});
|
|
39
34
|
}
|
|
40
|
-
/**
|
|
41
|
-
* `parseData` only ever runs as an inlined literal — the
|
|
42
|
-
* `@motionscript/vite-plugin` build-time macro replaces
|
|
43
|
-
* `parseData("file.csv")` call sites with the already-parsed rows before this
|
|
44
|
-
* body ever executes. This implementation exists purely so the call
|
|
45
|
-
* type-checks and so an unresolved call site (missing plugin, or a
|
|
46
|
-
* non-literal argument the macro couldn't statically inline) fails loudly
|
|
47
|
-
* instead of silently returning nothing.
|
|
48
|
-
*/
|
|
35
|
+
/** Only ever an inlined literal: the `@motionscript/vite-plugin` macro replaces `parseData("file.csv")` call sites with the parsed rows before this runs. This body exists so the call type-checks and an unresolved call site (no plugin, non-literal argument) fails loudly instead of returning nothing. */
|
|
49
36
|
export function parseData(file, _options) {
|
|
50
37
|
throw new Error(`parseData("${file}") must be called with a static string literal so the ` +
|
|
51
38
|
`@motionscript/vite-plugin macro can inline it at build time. If you're seeing ` +
|
|
52
39
|
`this error at runtime, either the plugin isn't installed/registered, or this ` +
|
|
53
40
|
`call's argument isn't a plain string literal.`);
|
|
54
41
|
}
|
|
55
|
-
/** Decide which columns to coerce, per {@link ParseCSVOptions.numeric}. */
|
|
56
42
|
function resolveNumericColumns(header, records, numeric) {
|
|
57
43
|
if (numeric === false)
|
|
58
44
|
return [];
|
|
@@ -71,7 +57,6 @@ function resolveNumericColumns(header, records, numeric) {
|
|
|
71
57
|
return sawValue;
|
|
72
58
|
});
|
|
73
59
|
}
|
|
74
|
-
/** Decide which columns to coerce, per {@link ParseCSVOptions.boolean}. */
|
|
75
60
|
function resolveBooleanColumns(header, records, numericCols, bool) {
|
|
76
61
|
if (bool === false)
|
|
77
62
|
return [];
|
|
@@ -93,11 +78,7 @@ function resolveBooleanColumns(header, records, numericCols, bool) {
|
|
|
93
78
|
return sawValue;
|
|
94
79
|
});
|
|
95
80
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Split raw CSV text into rows of raw (unquoted) string cells. A minimal
|
|
98
|
-
* hand-rolled scanner rather than a `split(',')`/`split('\n')` pair so quoted
|
|
99
|
-
* fields can safely contain the delimiter, newlines, and escaped (`""`) quotes.
|
|
100
|
-
*/
|
|
81
|
+
/** Splits raw CSV text into rows of unquoted cells. A hand-rolled scanner, not `split(',')`, so quoted fields can contain the delimiter, newlines and `""` escapes. */
|
|
101
82
|
function splitRows(text, delimiter) {
|
|
102
83
|
const rows = [];
|
|
103
84
|
let row = [];
|
package/dist/util/csv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.js","sourceRoot":"","sources":["../../src/util/csv.ts"],"names":[],"mappings":"AA0BA;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,UAA2B,EAAE;IAChE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,GAAG,CAAC;IAC3C,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEjC,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,E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C;YACX,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;gBACb,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;oBAAC,KAAK,IAAI,GAAG,CAAC;oBAAC,CAAC,EAAE,CAAC;gBAAC,CAAC;;oBAC1C,QAAQ,GAAG,KAAK,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACJ,KAAK,IAAI,EAAE,CAAC;YAChB,CAAC;YACD,SAAS;QACb,CAAC;QAED,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YAAC,QAAQ,GAAG,IAAI,CAAC;YAAC,WAAW,GAAG,IAAI,CAAC;YAAC,SAAS;QAAC,CAAC;QAClE,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YAAC,WAAW,GAAG,IAAI,CAAC;YAAC,SAAS,EAAE,CAAC;YAAC,SAAS;QAAC,CAAC;QACpE,IAAI,EAAE,KAAK,IAAI;YAAE,SAAS;QAC1B,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;YAAC,IAAI,WAAW,IAAI,KAAK;gBAAE,OAAO,EAAE,CAAC;YAAC,SAAS;QAAC,CAAC;QACnE,KAAK,IAAI,EAAE,CAAC;QACZ,WAAW,GAAG,IAAI,CAAC;IACvB,CAAC;IACD,qEAAqE;IACrE,IAAI,WAAW,IAAI,KAAK;QAAE,OAAO,EAAE,CAAC;IAEpC,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/** One parsed data record: column name → cell value (string, or number/boolean\n * when the column auto-coerces — see {@link ParseCSVOptions.numeric} and\n * {@link ParseCSVOptions.boolean}). */\nexport type DataRecord = Record<string, string | number | boolean>;\n\nexport interface ParseCSVOptions {\n /** Field separator. Default: ','. */\n delimiter?: string;\n /**\n * Which columns to coerce to `number`. An explicit list forces just those\n * columns; `false` disables coercion entirely (every cell stays a string).\n * Default (omitted/`true`): auto-detect — a column becomes numeric only if\n * every non-empty cell in it parses as a finite number, so a text column\n * that happens to contain a numeric-looking value here and there is left\n * alone rather than partially coerced.\n */\n numeric?: string[] | boolean;\n /**\n * Which columns to coerce to `boolean`, same shape/semantics as\n * {@link numeric}. Default (omitted/`true`): auto-detect — a column\n * becomes boolean only if every non-empty cell is exactly `\"true\"` or\n * `\"false\"`. Never applied to a column already coerced to numeric.\n */\n boolean?: string[] | boolean;\n}\n\n/**\n * Parse CSV text into an array of row records keyed by the header row.\n * Handles quoted fields (embedded delimiters, newlines, and `\"\"` escapes) and\n * both CRLF/LF line endings. Synchronous and dependency-free, so it's safe to\n * call at module-eval time on text pulled in via a `?raw` import.\n */\nexport function parseCSV(text: string, options: ParseCSVOptions = {}): DataRecord[] {\n const delimiter = options.delimiter ?? ',';\n const rows = splitRows(text, delimiter);\n if (rows.length === 0) return [];\n\n const header = rows[0].map(cell => cell.trim());\n const body = rows.slice(1);\n\n const records: Record<string, string>[] = body.map(row => {\n const record: Record<string, string> = {};\n header.forEach((key, i) => { record[key] = row[i] ?? ''; });\n return record;\n });\n\n const numericCols = resolveNumericColumns(header, records, options.numeric);\n const booleanCols = resolveBooleanColumns(header, records, numericCols, options.boolean);\n if (numericCols.length === 0 && booleanCols.length === 0) return records;\n\n return records.map(record => {\n const out: DataRecord = { ...record };\n for (const col of numericCols) {\n const raw = record[col];\n if (raw === '') continue;\n out[col] = Number(raw);\n }\n for (const col of booleanCols) {\n const raw = record[col];\n if (raw === '') continue;\n out[col] = raw === 'true';\n }\n return out;\n });\n}\n\n/**\n * `parseData` only ever runs as an inlined literal — the\n * `@motionscript/vite-plugin` build-time macro replaces\n * `parseData(\"file.csv\")` call sites with the already-parsed rows before this\n * body ever executes. This implementation exists purely so the call\n * type-checks and so an unresolved call site (missing plugin, or a\n * non-literal argument the macro couldn't statically inline) fails loudly\n * instead of silently returning nothing.\n */\nexport function parseData(file: string, _options?: ParseCSVOptions): DataRecord[] {\n throw new Error(\n `parseData(\"${file}\") must be called with a static string literal so the ` +\n `@motionscript/vite-plugin macro can inline it at build time. If you're seeing ` +\n `this error at runtime, either the plugin isn't installed/registered, or this ` +\n `call's argument isn't a plain string literal.`\n );\n}\n\n/** Decide which columns to coerce, per {@link ParseCSVOptions.numeric}. */\nfunction resolveNumericColumns(\n header: string[],\n records: Record<string, string>[],\n numeric: string[] | boolean | undefined,\n): string[] {\n if (numeric === false) return [];\n if (Array.isArray(numeric)) return numeric;\n\n return header.filter(col => {\n let sawValue = false;\n for (const record of records) {\n const raw = record[col];\n if (raw === '') continue;\n if (!Number.isFinite(Number(raw))) return false;\n sawValue = true;\n }\n return sawValue;\n });\n}\n\n/** Decide which columns to coerce, per {@link ParseCSVOptions.boolean}. */\nfunction resolveBooleanColumns(\n header: string[],\n records: Record<string, string>[],\n numericCols: string[],\n bool: string[] | boolean | undefined,\n): string[] {\n if (bool === false) return [];\n if (Array.isArray(bool)) return bool;\n\n const numericSet = new Set(numericCols);\n return header.filter(col => {\n if (numericSet.has(col)) return false;\n let sawValue = false;\n for (const record of records) {\n const raw = record[col];\n if (raw === '') continue;\n if (raw !== 'true' && raw !== 'false') return false;\n sawValue = true;\n }\n return sawValue;\n });\n}\n\n/**\n * Split raw CSV text into rows of raw (unquoted) string cells. A minimal\n * hand-rolled scanner rather than a `split(',')`/`split('\\n')` pair so quoted\n * fields can safely contain the delimiter, newlines, and escaped (`\"\"`) quotes.\n */\nfunction splitRows(text: string, delimiter: string): string[][] {\n const rows: string[][] = [];\n let row: string[] = [];\n let field = '';\n let inQuotes = false;\n let sawAnyField = false;\n\n const pushField = () => { row.push(field); field = ''; };\n const pushRow = () => { pushField(); rows.push(row); row = []; sawAnyField = false; };\n\n for (let i = 0; i < text.length; i++) {\n const ch = text[i];\n\n if (inQuotes) {\n if (ch === '\"') {\n if (text[i + 1] === '\"') { field += '\"'; i++; }\n else inQuotes = false;\n } else {\n field += ch;\n }\n continue;\n }\n\n if (ch === '\"') { inQuotes = true; sawAnyField = true; continue; }\n if (ch === delimiter) { sawAnyField = true; pushField(); continue; }\n if (ch === '\\r') continue;\n if (ch === '\\n') { if (sawAnyField || field) pushRow(); continue; }\n field += ch;\n sawAnyField = true;\n }\n // Flush a final row left over when the text has no trailing newline.\n if (sawAnyField || field) pushRow();\n\n return rows;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"csv.js","sourceRoot":"","sources":["../../src/util/csv.ts"],"names":[],"mappings":"AAcA,8NAA8N;AAC9N,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,UAA2B,EAAE;IAChE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,GAAG,CAAC;IAC3C,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEjC,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3B,MAAM,OAAO,GAA6B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACrD,MAAM,MAAM,GAA2B,EAAE,CAAC;QAC1C,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5E,MAAM,WAAW,GAAG,qBAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACzF,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,IA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,CAAC;QACnE,KAAK,IAAI,EAAE,CAAC;QACZ,WAAW,GAAG,IAAI,CAAC;IACvB,CAAC;IACD,qEAAqE;IACrE,IAAI,WAAW,IAAI,KAAK;QAAE,OAAO,EAAE,CAAC;IAEpC,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/** One parsed data record: column name → cell value (string, or number/boolean\n * when the column auto-coerces — see {@link ParseCSVOptions.numeric} and\n * {@link ParseCSVOptions.boolean}). */\nexport type DataRecord = Record<string, string | number | boolean>;\n\nexport interface ParseCSVOptions {\n /** Field separator. Default: ','. */\n delimiter?: string;\n /** Columns to coerce to `number`: an explicit list forces just those, `false` disables coercion, and the default auto-detects (numeric only if every non-empty cell parses as a finite number, so a text column with a stray numeric-looking value isn't partially coerced). */\n numeric?: string[] | boolean;\n /** Columns to coerce to `boolean`, as {@link numeric}; auto-detect makes a column boolean only if every non-empty cell is exactly `\"true\"` or `\"false\"`. Never applied to a column already numeric. */\n boolean?: string[] | boolean;\n}\n\n/** Parses CSV text into row records keyed by the header row. Handles quoted fields (embedded delimiters, newlines, `\"\"` escapes) and CRLF/LF. Synchronous and dependency-free, so safe at module-eval time on `?raw` text. */\nexport function parseCSV(text: string, options: ParseCSVOptions = {}): DataRecord[] {\n const delimiter = options.delimiter ?? ',';\n const rows = splitRows(text, delimiter);\n if (rows.length === 0) return [];\n\n const header = rows[0].map(cell => cell.trim());\n const body = rows.slice(1);\n\n const records: Record<string, string>[] = body.map(row => {\n const record: Record<string, string> = {};\n header.forEach((key, i) => { record[key] = row[i] ?? ''; });\n return record;\n });\n\n const numericCols = resolveNumericColumns(header, records, options.numeric);\n const booleanCols = resolveBooleanColumns(header, records, numericCols, options.boolean);\n if (numericCols.length === 0 && booleanCols.length === 0) return records;\n\n return records.map(record => {\n const out: DataRecord = { ...record };\n for (const col of numericCols) {\n const raw = record[col];\n if (raw === '') continue;\n out[col] = Number(raw);\n }\n for (const col of booleanCols) {\n const raw = record[col];\n if (raw === '') continue;\n out[col] = raw === 'true';\n }\n return out;\n });\n}\n\n/** Only ever an inlined literal: the `@motionscript/vite-plugin` macro replaces `parseData(\"file.csv\")` call sites with the parsed rows before this runs. This body exists so the call type-checks and an unresolved call site (no plugin, non-literal argument) fails loudly instead of returning nothing. */\nexport function parseData(file: string, _options?: ParseCSVOptions): DataRecord[] {\n throw new Error(\n `parseData(\"${file}\") must be called with a static string literal so the ` +\n `@motionscript/vite-plugin macro can inline it at build time. If you're seeing ` +\n `this error at runtime, either the plugin isn't installed/registered, or this ` +\n `call's argument isn't a plain string literal.`\n );\n}\n\nfunction resolveNumericColumns(\n header: string[],\n records: Record<string, string>[],\n numeric: string[] | boolean | undefined,\n): string[] {\n if (numeric === false) return [];\n if (Array.isArray(numeric)) return numeric;\n\n return header.filter(col => {\n let sawValue = false;\n for (const record of records) {\n const raw = record[col];\n if (raw === '') continue;\n if (!Number.isFinite(Number(raw))) return false;\n sawValue = true;\n }\n return sawValue;\n });\n}\n\nfunction resolveBooleanColumns(\n header: string[],\n records: Record<string, string>[],\n numericCols: string[],\n bool: string[] | boolean | undefined,\n): string[] {\n if (bool === false) return [];\n if (Array.isArray(bool)) return bool;\n\n const numericSet = new Set(numericCols);\n return header.filter(col => {\n if (numericSet.has(col)) return false;\n let sawValue = false;\n for (const record of records) {\n const raw = record[col];\n if (raw === '') continue;\n if (raw !== 'true' && raw !== 'false') return false;\n sawValue = true;\n }\n return sawValue;\n });\n}\n\n/** Splits raw CSV text into rows of unquoted cells. A hand-rolled scanner, not `split(',')`, so quoted fields can contain the delimiter, newlines and `\"\"` escapes. */\nfunction splitRows(text: string, delimiter: string): string[][] {\n const rows: string[][] = [];\n let row: string[] = [];\n let field = '';\n let inQuotes = false;\n let sawAnyField = false;\n\n const pushField = () => { row.push(field); field = ''; };\n const pushRow = () => { pushField(); rows.push(row); row = []; sawAnyField = false; };\n\n for (let i = 0; i < text.length; i++) {\n const ch = text[i];\n\n if (inQuotes) {\n if (ch === '\"') {\n if (text[i + 1] === '\"') { field += '\"'; i++; }\n else inQuotes = false;\n } else {\n field += ch;\n }\n continue;\n }\n\n if (ch === '\"') { inQuotes = true; sawAnyField = true; continue; }\n if (ch === delimiter) { sawAnyField = true; pushField(); continue; }\n if (ch === '\\r') continue;\n if (ch === '\\n') { if (sawAnyField || field) pushRow(); continue; }\n field += ch;\n sawAnyField = true;\n }\n // Flush a final row left over when the text has no trailing newline.\n if (sawAnyField || field) pushRow();\n\n return rows;\n}\n"]}
|
package/dist/util/metrics.d.ts
CHANGED
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Two numbers a component ends up needing, neither of which belongs to any one
|
|
3
|
-
* of them.
|
|
4
|
-
*
|
|
5
|
-
* Both were written for the chart family and are used well outside it — a
|
|
6
|
-
* graph's plane rounds its ticks with one, a diagram divides its entrance with
|
|
7
|
-
* the other. Leaving them there would make a package with nothing to do with
|
|
8
|
-
* charts depend on charts for a page of arithmetic.
|
|
9
|
-
*/
|
|
1
|
+
/** Two numbers a component needs that belong to none of them: written for the chart family but used well outside it (a graph rounds ticks with one, a diagram divides its entrance with the other), so keeping them there would make a non-chart package depend on charts. */
|
|
10
2
|
/** Round a raw step up to a tidy value (1/2/5 × 10ⁿ) so markers land round. */
|
|
11
3
|
export declare function niceStep(raw: number): number;
|
|
12
|
-
/**
|
|
13
|
-
* How an axis's staggered entrance is divided up, so the whole thing fits inside
|
|
14
|
-
* `duration` instead of running past it.
|
|
15
|
-
*
|
|
16
|
-
* The standalone components this family was ported from read `duration` as *one
|
|
17
|
-
* marker's* slide, and then added the stagger between them and a full-length
|
|
18
|
-
* caption move on the end — so `enter(0.8)` on a five-marker axis actually took
|
|
19
|
-
* about 2.2 seconds. That's fine when a scene is a hand-written script whose
|
|
20
|
-
* beats are whatever they turn out to be. It is not fine here: an editor lays a
|
|
21
|
-
* command out on the timeline at the duration it declares, times its parallel
|
|
22
|
-
* siblings against it, and sums those durations into the scene's length. A
|
|
23
|
-
* generator that overruns is a command that renders in the wrong place.
|
|
24
|
-
*
|
|
25
|
-
* So the budget runs the other way: the caption takes a fixed share off the top,
|
|
26
|
-
* and the markers' per-move duration is solved for from what's left, given the
|
|
27
|
-
* stagger. Same shape of animation, honest arithmetic.
|
|
28
|
-
*/
|
|
4
|
+
/** Divides an axis's staggered entrance so the whole thing fits inside `duration`. The ported components read `duration` as one marker's slide and then added stagger and a caption move, so `enter(0.8)` on five markers took ~2.2 s; an editor lays a command at its declared duration and sums those into the scene's length, so an overrun renders in the wrong place. The caption takes a fixed share off the top and the per-marker move is solved from what's left, given the stagger. */
|
|
29
5
|
export declare function enterBudget(duration: number, count: number, hasCaption: boolean,
|
|
30
6
|
/** An explicit gap between markers; derived from `duration` when omitted. */
|
|
31
7
|
stagger?: number): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/util/metrics.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/util/metrics.ts"],"names":[],"mappings":"AAAA,8QAA8Q;AAE9Q,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM5C;AAED,ieAAie;AACje,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,OAAO;AACnB,6EAA6E;AAC7E,OAAO,CAAC,EAAE,MAAM,GACf;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAmBhD"}
|
package/dist/util/metrics.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Two numbers a component ends up needing, neither of which belongs to any one
|
|
3
|
-
* of them.
|
|
4
|
-
*
|
|
5
|
-
* Both were written for the chart family and are used well outside it — a
|
|
6
|
-
* graph's plane rounds its ticks with one, a diagram divides its entrance with
|
|
7
|
-
* the other. Leaving them there would make a package with nothing to do with
|
|
8
|
-
* charts depend on charts for a page of arithmetic.
|
|
9
|
-
*/
|
|
1
|
+
/** Two numbers a component needs that belong to none of them: written for the chart family but used well outside it (a graph rounds ticks with one, a diagram divides its entrance with the other), so keeping them there would make a non-chart package depend on charts. */
|
|
10
2
|
/** Round a raw step up to a tidy value (1/2/5 × 10ⁿ) so markers land round. */
|
|
11
3
|
export function niceStep(raw) {
|
|
12
4
|
if (raw <= 0)
|
|
@@ -16,23 +8,7 @@ export function niceStep(raw) {
|
|
|
16
8
|
const nice = norm <= 1 ? 1 : norm <= 2 ? 2 : norm <= 5 ? 5 : 10;
|
|
17
9
|
return nice * mag;
|
|
18
10
|
}
|
|
19
|
-
/**
|
|
20
|
-
* How an axis's staggered entrance is divided up, so the whole thing fits inside
|
|
21
|
-
* `duration` instead of running past it.
|
|
22
|
-
*
|
|
23
|
-
* The standalone components this family was ported from read `duration` as *one
|
|
24
|
-
* marker's* slide, and then added the stagger between them and a full-length
|
|
25
|
-
* caption move on the end — so `enter(0.8)` on a five-marker axis actually took
|
|
26
|
-
* about 2.2 seconds. That's fine when a scene is a hand-written script whose
|
|
27
|
-
* beats are whatever they turn out to be. It is not fine here: an editor lays a
|
|
28
|
-
* command out on the timeline at the duration it declares, times its parallel
|
|
29
|
-
* siblings against it, and sums those durations into the scene's length. A
|
|
30
|
-
* generator that overruns is a command that renders in the wrong place.
|
|
31
|
-
*
|
|
32
|
-
* So the budget runs the other way: the caption takes a fixed share off the top,
|
|
33
|
-
* and the markers' per-move duration is solved for from what's left, given the
|
|
34
|
-
* stagger. Same shape of animation, honest arithmetic.
|
|
35
|
-
*/
|
|
11
|
+
/** Divides an axis's staggered entrance so the whole thing fits inside `duration`. The ported components read `duration` as one marker's slide and then added stagger and a caption move, so `enter(0.8)` on five markers took ~2.2 s; an editor lays a command at its declared duration and sums those into the scene's length, so an overrun renders in the wrong place. The caption takes a fixed share off the top and the per-marker move is solved from what's left, given the stagger. */
|
|
36
12
|
export function enterBudget(duration, count, hasCaption,
|
|
37
13
|
/** An explicit gap between markers; derived from `duration` when omitted. */
|
|
38
14
|
stagger) {
|
package/dist/util/metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/util/metrics.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/util/metrics.ts"],"names":[],"mappings":"AAAA,8QAA8Q;AAE9Q,+EAA+E;AAC/E,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,IAAI,GAAG,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IACtB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IACrD,MAAM,IAAI,GAAG,GAAG,GAAG,GAAG,CAAA;IACtB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/D,OAAO,IAAI,GAAG,GAAG,CAAA;AACnB,CAAC;AAED,ieAAie;AACje,MAAM,UAAU,WAAW,CACzB,QAAgB,EAChB,KAAa,EACb,UAAmB;AACnB,6EAA6E;AAC7E,OAAgB;IAEhB,wEAAwE;IACxE,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAA;IAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;IAEnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,wEAAwE;QACxE,8DAA8D;QAC9D,OAAO;YACL,IAAI,EAAE,OAAO;YACb,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;YAC1C,OAAO;SACR,CAAA;IACH,CAAC;IACD,2EAA2E;IAC3E,iEAAiE;IACjE,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAA;IACpC,OAAO,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAA;AACxC,CAAC","sourcesContent":["/** Two numbers a component needs that belong to none of them: written for the chart family but used well outside it (a graph rounds ticks with one, a diagram divides its entrance with the other), so keeping them there would make a non-chart package depend on charts. */\n\n/** Round a raw step up to a tidy value (1/2/5 × 10ⁿ) so markers land round. */\nexport function niceStep(raw: number): number {\n if (raw <= 0) return 1\n const mag = Math.pow(10, Math.floor(Math.log10(raw)))\n const norm = raw / mag\n const nice = norm <= 1 ? 1 : norm <= 2 ? 2 : norm <= 5 ? 5 : 10\n return nice * mag\n}\n\n/** Divides an axis's staggered entrance so the whole thing fits inside `duration`. The ported components read `duration` as one marker's slide and then added stagger and a caption move, so `enter(0.8)` on five markers took ~2.2 s; an editor lays a command at its declared duration and sums those into the scene's length, so an overrun renders in the wrong place. The caption takes a fixed share off the top and the per-marker move is solved from what's left, given the stagger. */\nexport function enterBudget(\n duration: number,\n count: number,\n hasCaption: boolean,\n /** An explicit gap between markers; derived from `duration` when omitted. */\n stagger?: number\n): { step: number; per: number; caption: number } {\n // The caption lands *after* the last marker, so it needs its own slice.\n const caption = hasCaption ? duration * 0.3 : 0\n const markers = Math.max(0, duration - caption)\n const gaps = Math.max(0, count - 1)\n\n if (stagger !== undefined) {\n // An explicit gap wins; the per-marker move takes whatever is left, and\n // can't go negative on an axis with more markers than budget.\n return {\n step: stagger,\n per: Math.max(0, markers - stagger * gaps),\n caption,\n }\n }\n // Default rhythm: each gap is a fifth of a marker's own move, which is the\n // ratio the original used — solved for here rather than assumed.\n const per = markers / (1 + gaps / 5)\n return { step: per / 5, per, caption }\n}\n"]}
|
package/dist/util/random.d.ts
CHANGED
|
@@ -1,121 +1,54 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deterministic pseudo-random number generator based on the mulberry32 algorithm.
|
|
3
|
-
* Produces the same sequence for the same seed, making animations reproducible.
|
|
4
|
-
*
|
|
5
|
-
* This is the low-level engine. Scene authors use the higher-level {@link Random}
|
|
6
|
-
* facade (handed out by `stage.random(seed)`), which wraps a `SeedGenerator` and
|
|
7
|
-
* adds typed draws (`nextFloat`/`nextInt`/`gauss`/arrays) plus seeded `noise`.
|
|
8
|
-
*/
|
|
1
|
+
/** Deterministic mulberry32 PRNG: the same seed gives the same sequence. Scene authors use the {@link Random} facade from `stage.random(seed)`, which wraps this. */
|
|
9
2
|
export declare class SeedGenerator {
|
|
10
3
|
private state;
|
|
11
4
|
constructor(seed: string | number);
|
|
12
|
-
/**
|
|
13
|
-
* Resets the generator to a new seed.
|
|
14
|
-
* String seeds are hashed via djb2 into a 32-bit integer.
|
|
15
|
-
*/
|
|
5
|
+
/** String seeds are hashed via djb2 into a 32-bit integer. */
|
|
16
6
|
setSeed(seed: string | number): void;
|
|
17
|
-
/** Returns the next pseudo-random float in [0, 1). */
|
|
18
7
|
next(): number;
|
|
19
8
|
}
|
|
20
9
|
/**
|
|
21
|
-
* A seeded random source handed
|
|
10
|
+
* A seeded random source handed out by `stage.random(seed)`; wraps a {@link SeedGenerator} (mulberry32). Determinism
|
|
11
|
+
* is scoped per source: scenes each get their own reproducible stream without a shared stage-level seed.
|
|
22
12
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* own reproducible stream without touching a shared stage-level seed.
|
|
27
|
-
*
|
|
28
|
-
* const random = stage.random("sparkle");
|
|
29
|
-
* const xs = random.floatArray(40, -100, 100); // 40 reproducible offsets
|
|
30
|
-
* const drift = random.noise(t, 6); // smooth field over time
|
|
31
|
-
*
|
|
32
|
-
* Two families live here, and they are NOT interchangeable:
|
|
33
|
-
* - **Independent draws** — `nextFloat`/`nextInt`/`gauss` and their array
|
|
34
|
-
* forms. Successive calls are uncorrelated; `gauss` only changes the
|
|
35
|
-
* *distribution* (bell curve vs flat), not the independence.
|
|
36
|
-
* - **Correlated field** — `noise(t)`. Nearby inputs return nearby values, so
|
|
37
|
-
* it is the right tool for smooth motion over time/space (drift, shake,
|
|
38
|
-
* waves). No distribution draw can reproduce that smoothness.
|
|
13
|
+
* Two families that are NOT interchangeable: **independent draws** (`nextFloat`/`nextInt`/`gauss` and array forms,
|
|
14
|
+
* uncorrelated; `gauss` changes only the distribution) and the **correlated field** `noise(t)`, where nearby inputs
|
|
15
|
+
* give nearby values, the right tool for smooth motion (drift, shake, waves).
|
|
39
16
|
*/
|
|
40
17
|
export declare class Random {
|
|
41
|
-
/** The seed this source rewinds to;
|
|
42
|
-
* {@link reset}. Set by {@link adopt} (definitely assigned via the
|
|
43
|
-
* constructor's `adopt` call). */
|
|
18
|
+
/** The seed this source rewinds to; set by {@link adopt}. */
|
|
44
19
|
private _seed;
|
|
45
|
-
/** Numeric form of {@link _seed}, used to mix `noise`'s lattice
|
|
46
|
-
* lockstep with `_seed` through {@link adopt}. */
|
|
20
|
+
/** Numeric form of {@link _seed}, used to mix `noise`'s lattice; kept in lockstep through {@link adopt}. */
|
|
47
21
|
private numericSeed;
|
|
48
22
|
private readonly gen;
|
|
49
23
|
/** A spare gaussian sample from the last Box–Muller pair (see {@link gauss}). */
|
|
50
24
|
private spareGauss;
|
|
51
25
|
constructor(seed: string | number);
|
|
52
|
-
/** The seed this source rewinds to. Assigning
|
|
53
|
-
* source (same effect as `reset(seed)`): the next draws reproduce the
|
|
54
|
-
* sequence for that seed, and `noise`'s lattice shifts to match. */
|
|
26
|
+
/** The seed this source rewinds to. Assigning re-anchors the source (as `reset(seed)`): draws reproduce that seed's sequence and `noise`'s lattice shifts to match. */
|
|
55
27
|
get seed(): string | number;
|
|
56
28
|
set seed(seed: string | number);
|
|
57
|
-
/** Numeric form of a seed
|
|
58
|
-
* the generator uses), numbers pass through. Shared so the constructor, the
|
|
59
|
-
* {@link seed} setter, and {@link reset} all derive `numericSeed` identically. */
|
|
29
|
+
/** Numeric form of a seed (strings hashed djb2-style), shared so the constructor, setter and {@link reset} derive `numericSeed` identically. */
|
|
60
30
|
private static toNumeric;
|
|
61
|
-
/**
|
|
62
|
-
* `noise` lattice anchor, reset the generator, and drop any spare gauss. The
|
|
63
|
-
* single seed-adoption path behind the constructor, {@link seed}, and a
|
|
64
|
-
* seeded {@link reset}. */
|
|
31
|
+
/** Takes `seed` as the new origin and rewinds to it; the single seed-adoption path behind the constructor, {@link seed} and a seeded {@link reset}. */
|
|
65
32
|
private adopt;
|
|
66
|
-
/**
|
|
67
|
-
* The next pseudo-random float in `[from, to)`. Defaults to `[0, 1)`.
|
|
68
|
-
*/
|
|
33
|
+
/** The next float in `[from, to)`, default `[0, 1)`. */
|
|
69
34
|
nextFloat(from?: number, to?: number): number;
|
|
70
|
-
/**
|
|
71
|
-
* The next pseudo-random integer in `[from, to)`. Defaults to the full
|
|
72
|
-
* unsigned 32-bit range `[0, 2^32)`.
|
|
73
|
-
*/
|
|
35
|
+
/** The next integer in `[from, to)`, default the full unsigned 32-bit range. */
|
|
74
36
|
nextInt(from?: number, to?: number): number;
|
|
75
37
|
/** `size` independent floats in `[from, to)`. */
|
|
76
38
|
floatArray(size: number, from?: number, to?: number): number[];
|
|
77
39
|
/** `size` independent integers in `[from, to)`. */
|
|
78
40
|
intArray(size: number, from?: number, to?: number): number[];
|
|
79
|
-
/**
|
|
80
|
-
* A normally-distributed sample with the given `mean` and `stdev` (default
|
|
81
|
-
* standard normal). Values cluster near the mean and tail off — useful for
|
|
82
|
-
* natural-looking scatter where most draws stay central with occasional
|
|
83
|
-
* outliers.
|
|
84
|
-
*
|
|
85
|
-
* Uses the polar Box–Muller transform, which yields two independent normals
|
|
86
|
-
* per pair of uniforms; the spare is cached and returned on the next call.
|
|
87
|
-
*/
|
|
41
|
+
/** A normal sample (default standard). Uses the polar Box–Muller transform, which yields two normals per pair of uniforms; the spare is cached for the next call. */
|
|
88
42
|
gauss(mean?: number, stdev?: number): number;
|
|
89
43
|
/**
|
|
90
|
-
* Smooth 1-D value noise in `[0, 1]
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* interpolates with a smoothstep curve (`3t² - 2t³`) to avoid the linear
|
|
94
|
-
* kinks of plain lerp. Unlike {@link nextFloat}/{@link gauss}, nearby
|
|
95
|
-
* `time` inputs return nearby values — this is the correlated field used for
|
|
96
|
-
* organic, continuously varying motion (camera shake, drift, waves).
|
|
97
|
-
*
|
|
98
|
-
* @param time Sample position (e.g. normalized timeline `[0, 1]`, or a
|
|
99
|
-
* spatial index).
|
|
100
|
-
* @param frequency Scales `time` before sampling; higher = faster
|
|
101
|
-
* oscillation / more crests across the same span.
|
|
44
|
+
* Smooth 1-D value noise in `[0, 1]`: lattice points around `time * frequency` interpolated with a smoothstep.
|
|
45
|
+
* Unlike {@link nextFloat}/{@link gauss}, nearby `time` inputs give nearby values (camera shake, drift, waves).
|
|
46
|
+
* Higher `frequency` means more crests across the same span.
|
|
102
47
|
*/
|
|
103
48
|
noise(time: number, frequency?: number): number;
|
|
104
|
-
/**
|
|
105
|
-
* Rewind this source so the next draws reproduce a sequence from the start.
|
|
106
|
-
*
|
|
107
|
-
* With no argument, rewinds to the current {@link seed} — what authors call to
|
|
108
|
-
* repeat a sequence within a scene. Pass a `seed` to adopt it as the new origin
|
|
109
|
-
* first (equivalent to assigning {@link seed}), so the source both re-seeds and
|
|
110
|
-
* rewinds in one call — e.g. in a node's constructor to give it a distinct
|
|
111
|
-
* reproducible stream.
|
|
112
|
-
*/
|
|
49
|
+
/** Rewinds so the next draws reproduce a sequence from the start. With a `seed`, adopts it as the new origin first (equivalent to assigning {@link seed}), e.g. in a node's constructor for a distinct stream. */
|
|
113
50
|
reset(seed?: string | number): void;
|
|
114
|
-
/**
|
|
115
|
-
* Deterministic value in `[0, 1)` for a given integer lattice point `x`,
|
|
116
|
-
* mixed with this source's seed via `sin`. Pure in `x` (no generator state),
|
|
117
|
-
* so {@link noise} is stable regardless of how many draws preceded it.
|
|
118
|
-
*/
|
|
51
|
+
/** Deterministic value in `[0, 1)` for lattice point `x`, mixed with the seed via `sin`. Pure in `x`, so {@link noise} is stable regardless of preceding draws. */
|
|
119
52
|
private latticeValue;
|
|
120
53
|
}
|
|
121
54
|
//# sourceMappingURL=random.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/util/random.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/util/random.ts"],"names":[],"mappings":"AAAA,qKAAqK;AACrK,qBAAa,aAAa;IACtB,OAAO,CAAC,KAAK,CAAa;gBAEd,IAAI,EAAE,MAAM,GAAG,MAAM;IAIjC,8DAA8D;IAC9D,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAM7B,IAAI;CAMP;AAKD;;;;;;;GAOG;AACH,qBAAa,MAAM;IACf,6DAA6D;IAC7D,OAAO,CAAC,KAAK,CAAmB;IAEhC,4GAA4G;IAC5G,OAAO,CAAC,WAAW,CAAU;IAE7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IAEpC,iFAAiF;IACjF,OAAO,CAAC,UAAU,CAAuB;gBAE7B,IAAI,EAAE,MAAM,GAAG,MAAM;IAKjC,uKAAuK;IACvK,IAAI,IAAI,IAAI,MAAM,GAAG,MAAM,CAE1B;IACD,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAE7B;IAED,gJAAgJ;IAChJ,OAAO,CAAC,MAAM,CAAC,SAAS;IAMxB,uJAAuJ;IACvJ,OAAO,CAAC,KAAK;IAOb,wDAAwD;IACxD,SAAS,CAAC,IAAI,GAAE,MAAU,EAAE,EAAE,GAAE,MAAU,GAAG,MAAM;IAInD,gFAAgF;IAChF,OAAO,CAAC,IAAI,GAAE,MAAU,EAAE,EAAE,GAAE,MAAqB,GAAG,MAAM;IAI5D,iDAAiD;IACjD,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,EAAE,EAAE,GAAE,MAAU,GAAG,MAAM,EAAE;IAMpE,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,EAAE,EAAE,GAAE,MAAqB,GAAG,MAAM,EAAE;IAM7E,qKAAqK;IACrK,KAAK,CAAC,IAAI,GAAE,MAAU,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM;IAkBlD;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAU,GAAG,MAAM;IAWlD,kNAAkN;IAClN,KAAK,CAAC,IAAI,GAAE,MAAM,GAAG,MAAmB,GAAG,IAAI;IAI/C,mKAAmK;IACnK,OAAO,CAAC,YAAY;CAIvB"}
|
package/dist/util/random.js
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deterministic pseudo-random number generator based on the mulberry32 algorithm.
|
|
3
|
-
* Produces the same sequence for the same seed, making animations reproducible.
|
|
4
|
-
*
|
|
5
|
-
* This is the low-level engine. Scene authors use the higher-level {@link Random}
|
|
6
|
-
* facade (handed out by `stage.random(seed)`), which wraps a `SeedGenerator` and
|
|
7
|
-
* adds typed draws (`nextFloat`/`nextInt`/`gauss`/arrays) plus seeded `noise`.
|
|
8
|
-
*/
|
|
1
|
+
/** Deterministic mulberry32 PRNG: the same seed gives the same sequence. Scene authors use the {@link Random} facade from `stage.random(seed)`, which wraps this. */
|
|
9
2
|
export class SeedGenerator {
|
|
10
3
|
state = 0;
|
|
11
4
|
constructor(seed) {
|
|
12
5
|
this.setSeed(seed);
|
|
13
6
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Resets the generator to a new seed.
|
|
16
|
-
* String seeds are hashed via djb2 into a 32-bit integer.
|
|
17
|
-
*/
|
|
7
|
+
/** String seeds are hashed via djb2 into a 32-bit integer. */
|
|
18
8
|
setSeed(seed) {
|
|
19
9
|
this.state = typeof seed === 'string'
|
|
20
10
|
? seed.split('').reduce((a, b) => { a = ((a << 5) - a) + b.charCodeAt(0); return a & a; }, 0)
|
|
21
11
|
: seed;
|
|
22
12
|
}
|
|
23
|
-
/** Returns the next pseudo-random float in [0, 1). */
|
|
24
13
|
next() {
|
|
25
14
|
this.state |= 0;
|
|
26
15
|
this.state = this.state + 0x6D2B79F5 | 0;
|
|
@@ -32,32 +21,17 @@ export class SeedGenerator {
|
|
|
32
21
|
/** Upper bound of {@link Random.nextInt} / {@link Random.intArray} (2^32). */
|
|
33
22
|
const UINT32_RANGE = 4294967296;
|
|
34
23
|
/**
|
|
35
|
-
* A seeded random source handed
|
|
24
|
+
* A seeded random source handed out by `stage.random(seed)`; wraps a {@link SeedGenerator} (mulberry32). Determinism
|
|
25
|
+
* is scoped per source: scenes each get their own reproducible stream without a shared stage-level seed.
|
|
36
26
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* own reproducible stream without touching a shared stage-level seed.
|
|
41
|
-
*
|
|
42
|
-
* const random = stage.random("sparkle");
|
|
43
|
-
* const xs = random.floatArray(40, -100, 100); // 40 reproducible offsets
|
|
44
|
-
* const drift = random.noise(t, 6); // smooth field over time
|
|
45
|
-
*
|
|
46
|
-
* Two families live here, and they are NOT interchangeable:
|
|
47
|
-
* - **Independent draws** — `nextFloat`/`nextInt`/`gauss` and their array
|
|
48
|
-
* forms. Successive calls are uncorrelated; `gauss` only changes the
|
|
49
|
-
* *distribution* (bell curve vs flat), not the independence.
|
|
50
|
-
* - **Correlated field** — `noise(t)`. Nearby inputs return nearby values, so
|
|
51
|
-
* it is the right tool for smooth motion over time/space (drift, shake,
|
|
52
|
-
* waves). No distribution draw can reproduce that smoothness.
|
|
27
|
+
* Two families that are NOT interchangeable: **independent draws** (`nextFloat`/`nextInt`/`gauss` and array forms,
|
|
28
|
+
* uncorrelated; `gauss` changes only the distribution) and the **correlated field** `noise(t)`, where nearby inputs
|
|
29
|
+
* give nearby values, the right tool for smooth motion (drift, shake, waves).
|
|
53
30
|
*/
|
|
54
31
|
export class Random {
|
|
55
|
-
/** The seed this source rewinds to;
|
|
56
|
-
* {@link reset}. Set by {@link adopt} (definitely assigned via the
|
|
57
|
-
* constructor's `adopt` call). */
|
|
32
|
+
/** The seed this source rewinds to; set by {@link adopt}. */
|
|
58
33
|
_seed;
|
|
59
|
-
/** Numeric form of {@link _seed}, used to mix `noise`'s lattice
|
|
60
|
-
* lockstep with `_seed` through {@link adopt}. */
|
|
34
|
+
/** Numeric form of {@link _seed}, used to mix `noise`'s lattice; kept in lockstep through {@link adopt}. */
|
|
61
35
|
numericSeed;
|
|
62
36
|
gen;
|
|
63
37
|
/** A spare gaussian sample from the last Box–Muller pair (see {@link gauss}). */
|
|
@@ -66,43 +40,31 @@ export class Random {
|
|
|
66
40
|
this.gen = new SeedGenerator(seed);
|
|
67
41
|
this.adopt(seed);
|
|
68
42
|
}
|
|
69
|
-
/** The seed this source rewinds to. Assigning
|
|
70
|
-
* source (same effect as `reset(seed)`): the next draws reproduce the
|
|
71
|
-
* sequence for that seed, and `noise`'s lattice shifts to match. */
|
|
43
|
+
/** The seed this source rewinds to. Assigning re-anchors the source (as `reset(seed)`): draws reproduce that seed's sequence and `noise`'s lattice shifts to match. */
|
|
72
44
|
get seed() {
|
|
73
45
|
return this._seed;
|
|
74
46
|
}
|
|
75
47
|
set seed(seed) {
|
|
76
48
|
this.adopt(seed);
|
|
77
49
|
}
|
|
78
|
-
/** Numeric form of a seed
|
|
79
|
-
* the generator uses), numbers pass through. Shared so the constructor, the
|
|
80
|
-
* {@link seed} setter, and {@link reset} all derive `numericSeed` identically. */
|
|
50
|
+
/** Numeric form of a seed (strings hashed djb2-style), shared so the constructor, setter and {@link reset} derive `numericSeed` identically. */
|
|
81
51
|
static toNumeric(seed) {
|
|
82
52
|
return typeof seed === 'string'
|
|
83
53
|
? seed.split('').reduce((a, b) => (a << 5) - a + b.charCodeAt(0), 0)
|
|
84
54
|
: seed;
|
|
85
55
|
}
|
|
86
|
-
/**
|
|
87
|
-
* `noise` lattice anchor, reset the generator, and drop any spare gauss. The
|
|
88
|
-
* single seed-adoption path behind the constructor, {@link seed}, and a
|
|
89
|
-
* seeded {@link reset}. */
|
|
56
|
+
/** Takes `seed` as the new origin and rewinds to it; the single seed-adoption path behind the constructor, {@link seed} and a seeded {@link reset}. */
|
|
90
57
|
adopt(seed) {
|
|
91
58
|
this._seed = seed;
|
|
92
59
|
this.numericSeed = Random.toNumeric(seed);
|
|
93
60
|
this.gen.setSeed(seed);
|
|
94
61
|
this.spareGauss = null;
|
|
95
62
|
}
|
|
96
|
-
/**
|
|
97
|
-
* The next pseudo-random float in `[from, to)`. Defaults to `[0, 1)`.
|
|
98
|
-
*/
|
|
63
|
+
/** The next float in `[from, to)`, default `[0, 1)`. */
|
|
99
64
|
nextFloat(from = 0, to = 1) {
|
|
100
65
|
return this.gen.next() * (to - from) + from;
|
|
101
66
|
}
|
|
102
|
-
/**
|
|
103
|
-
* The next pseudo-random integer in `[from, to)`. Defaults to the full
|
|
104
|
-
* unsigned 32-bit range `[0, 2^32)`.
|
|
105
|
-
*/
|
|
67
|
+
/** The next integer in `[from, to)`, default the full unsigned 32-bit range. */
|
|
106
68
|
nextInt(from = 0, to = UINT32_RANGE) {
|
|
107
69
|
return Math.floor(this.gen.next() * (to - from)) + from;
|
|
108
70
|
}
|
|
@@ -120,15 +82,7 @@ export class Random {
|
|
|
120
82
|
out[i] = this.nextInt(from, to);
|
|
121
83
|
return out;
|
|
122
84
|
}
|
|
123
|
-
/**
|
|
124
|
-
* A normally-distributed sample with the given `mean` and `stdev` (default
|
|
125
|
-
* standard normal). Values cluster near the mean and tail off — useful for
|
|
126
|
-
* natural-looking scatter where most draws stay central with occasional
|
|
127
|
-
* outliers.
|
|
128
|
-
*
|
|
129
|
-
* Uses the polar Box–Muller transform, which yields two independent normals
|
|
130
|
-
* per pair of uniforms; the spare is cached and returned on the next call.
|
|
131
|
-
*/
|
|
85
|
+
/** A normal sample (default standard). Uses the polar Box–Muller transform, which yields two normals per pair of uniforms; the spare is cached for the next call. */
|
|
132
86
|
gauss(mean = 0, stdev = 1) {
|
|
133
87
|
if (this.spareGauss !== null) {
|
|
134
88
|
const z = this.spareGauss;
|
|
@@ -147,18 +101,9 @@ export class Random {
|
|
|
147
101
|
return mean + stdev * (u * mul);
|
|
148
102
|
}
|
|
149
103
|
/**
|
|
150
|
-
* Smooth 1-D value noise in `[0, 1]
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* interpolates with a smoothstep curve (`3t² - 2t³`) to avoid the linear
|
|
154
|
-
* kinks of plain lerp. Unlike {@link nextFloat}/{@link gauss}, nearby
|
|
155
|
-
* `time` inputs return nearby values — this is the correlated field used for
|
|
156
|
-
* organic, continuously varying motion (camera shake, drift, waves).
|
|
157
|
-
*
|
|
158
|
-
* @param time Sample position (e.g. normalized timeline `[0, 1]`, or a
|
|
159
|
-
* spatial index).
|
|
160
|
-
* @param frequency Scales `time` before sampling; higher = faster
|
|
161
|
-
* oscillation / more crests across the same span.
|
|
104
|
+
* Smooth 1-D value noise in `[0, 1]`: lattice points around `time * frequency` interpolated with a smoothstep.
|
|
105
|
+
* Unlike {@link nextFloat}/{@link gauss}, nearby `time` inputs give nearby values (camera shake, drift, waves).
|
|
106
|
+
* Higher `frequency` means more crests across the same span.
|
|
162
107
|
*/
|
|
163
108
|
noise(time, frequency = 1) {
|
|
164
109
|
const t = time * frequency;
|
|
@@ -170,23 +115,11 @@ export class Random {
|
|
|
170
115
|
const r2 = this.latticeValue(i + 1);
|
|
171
116
|
return r1 + (r2 - r1) * curve;
|
|
172
117
|
}
|
|
173
|
-
/**
|
|
174
|
-
* Rewind this source so the next draws reproduce a sequence from the start.
|
|
175
|
-
*
|
|
176
|
-
* With no argument, rewinds to the current {@link seed} — what authors call to
|
|
177
|
-
* repeat a sequence within a scene. Pass a `seed` to adopt it as the new origin
|
|
178
|
-
* first (equivalent to assigning {@link seed}), so the source both re-seeds and
|
|
179
|
-
* rewinds in one call — e.g. in a node's constructor to give it a distinct
|
|
180
|
-
* reproducible stream.
|
|
181
|
-
*/
|
|
118
|
+
/** Rewinds so the next draws reproduce a sequence from the start. With a `seed`, adopts it as the new origin first (equivalent to assigning {@link seed}), e.g. in a node's constructor for a distinct stream. */
|
|
182
119
|
reset(seed = this._seed) {
|
|
183
120
|
this.adopt(seed);
|
|
184
121
|
}
|
|
185
|
-
/**
|
|
186
|
-
* Deterministic value in `[0, 1)` for a given integer lattice point `x`,
|
|
187
|
-
* mixed with this source's seed via `sin`. Pure in `x` (no generator state),
|
|
188
|
-
* so {@link noise} is stable regardless of how many draws preceded it.
|
|
189
|
-
*/
|
|
122
|
+
/** Deterministic value in `[0, 1)` for lattice point `x`, mixed with the seed via `sin`. Pure in `x`, so {@link noise} is stable regardless of preceding draws. */
|
|
190
123
|
latticeValue(x) {
|
|
191
124
|
const h = Math.sin(x + this.numericSeed) * 10000;
|
|
192
125
|
return h - Math.floor(h);
|
package/dist/util/random.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/util/random.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IACd,KAAK,GAAW,CAAC,CAAC;IAE1B,YAAY,IAAqB;QAC7B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED;;;OAGG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AAI,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;QACjD,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["/**\n * Deterministic pseudo-random number generator based on the mulberry32 algorithm.\n * Produces the same sequence for the same seed, making animations reproducible.\n *\n * This is the low-level engine. Scene authors use the higher-level {@link Random}\n * facade (handed out by `stage.random(seed)`), which wraps a `SeedGenerator` and\n * adds typed draws (`nextFloat`/`nextInt`/`gauss`/arrays) plus seeded `noise`.\n */\nexport class SeedGenerator {\n private state: number = 0;\n\n constructor(seed: string | number) {\n this.setSeed(seed);\n }\n\n /**\n * Resets the generator to a new seed.\n * String seeds are hashed via djb2 into a 32-bit integer.\n */\n setSeed(seed: string | number) {\n this.state = typeof seed === 'string'\n ? seed.split('').reduce((a, b) => { a = ((a << 5) - a) + b.charCodeAt(0); return a & a; }, 0)\n : seed;\n }\n\n /** Returns the next pseudo-random float in [0, 1). */\n next() {\n this.state |= 0; this.state = this.state + 0x6D2B79F5 | 0;\n var t = Math.imul(this.state ^ this.state >>> 15, 1 | this.state);\n t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;\n return ((t ^ t >>> 14) >>> 0) / 4294967296;\n }\n}\n\n/** Upper bound of {@link Random.nextInt} / {@link Random.intArray} (2^32). */\nconst UINT32_RANGE = 4294967296;\n\n/**\n * A seeded random source handed to scene generators by `stage.random(seed)`.\n *\n * Wraps a {@link SeedGenerator} (mulberry32) and exposes the author-facing draw\n * surface. Because the seed lives on the `Random` instance, determinism is\n * scoped per source: two scenes can each `stage.random(\"name\")` and get their\n * own reproducible stream without touching a shared stage-level seed.\n *\n * const random = stage.random(\"sparkle\");\n * const xs = random.floatArray(40, -100, 100); // 40 reproducible offsets\n * const drift = random.noise(t, 6); // smooth field over time\n *\n * Two families live here, and they are NOT interchangeable:\n * - **Independent draws** — `nextFloat`/`nextInt`/`gauss` and their array\n * forms. Successive calls are uncorrelated; `gauss` only changes the\n * *distribution* (bell curve vs flat), not the independence.\n * - **Correlated field** — `noise(t)`. Nearby inputs return nearby values, so\n * it is the right tool for smooth motion over time/space (drift, shake,\n * waves). No distribution draw can reproduce that smoothness.\n */\nexport class Random {\n /** The seed this source rewinds to; reassign via {@link seed} or\n * {@link reset}. Set by {@link adopt} (definitely assigned via the\n * constructor's `adopt` call). */\n private _seed!: string | number;\n\n /** Numeric form of {@link _seed}, used to mix `noise`'s lattice. Kept in\n * lockstep with `_seed` through {@link adopt}. */\n private numericSeed!: number;\n\n private readonly gen: SeedGenerator;\n\n /** A spare gaussian sample from the last Box–Muller pair (see {@link gauss}). */\n private spareGauss: number | null = null;\n\n constructor(seed: string | number) {\n this.gen = new SeedGenerator(seed);\n this.adopt(seed);\n }\n\n /** The seed this source rewinds to. Assigning a new value re-anchors the\n * source (same effect as `reset(seed)`): the next draws reproduce the\n * sequence for that seed, and `noise`'s lattice shifts to match. */\n get seed(): string | number {\n return this._seed;\n }\n set seed(seed: string | number) {\n this.adopt(seed);\n }\n\n /** Numeric form of a seed: string seeds are hashed (the same djb2-style mix\n * the generator uses), numbers pass through. Shared so the constructor, the\n * {@link seed} setter, and {@link reset} all derive `numericSeed` identically. */\n private static toNumeric(seed: string | number): number {\n return typeof seed === 'string'\n ? seed.split('').reduce((a, b) => (a << 5) - a + b.charCodeAt(0), 0)\n : seed;\n }\n\n /** Take `seed` as the new origin and rewind to it: store it, recompute the\n * `noise` lattice anchor, reset the generator, and drop any spare gauss. The\n * single seed-adoption path behind the constructor, {@link seed}, and a\n * seeded {@link reset}. */\n private adopt(seed: string | number): void {\n this._seed = seed;\n this.numericSeed = Random.toNumeric(seed);\n this.gen.setSeed(seed);\n this.spareGauss = null;\n }\n\n /**\n * The next pseudo-random float in `[from, to)`. Defaults to `[0, 1)`.\n */\n nextFloat(from: number = 0, to: number = 1): number {\n return this.gen.next() * (to - from) + from;\n }\n\n /**\n * The next pseudo-random integer in `[from, to)`. Defaults to the full\n * unsigned 32-bit range `[0, 2^32)`.\n */\n nextInt(from: number = 0, to: number = UINT32_RANGE): number {\n return Math.floor(this.gen.next() * (to - from)) + from;\n }\n\n /** `size` independent floats in `[from, to)`. */\n floatArray(size: number, from: number = 0, to: number = 1): number[] {\n const out = new Array<number>(size);\n for (let i = 0; i < size; i++) out[i] = this.nextFloat(from, to);\n return out;\n }\n\n /** `size` independent integers in `[from, to)`. */\n intArray(size: number, from: number = 0, to: number = UINT32_RANGE): number[] {\n const out = new Array<number>(size);\n for (let i = 0; i < size; i++) out[i] = this.nextInt(from, to);\n return out;\n }\n\n /**\n * A normally-distributed sample with the given `mean` and `stdev` (default\n * standard normal). Values cluster near the mean and tail off — useful for\n * natural-looking scatter where most draws stay central with occasional\n * outliers.\n *\n * Uses the polar Box–Muller transform, which yields two independent normals\n * per pair of uniforms; the spare is cached and returned on the next call.\n */\n gauss(mean: number = 0, stdev: number = 1): number {\n if (this.spareGauss !== null) {\n const z = this.spareGauss;\n this.spareGauss = null;\n return mean + stdev * z;\n }\n // Rejection-sample a point in the unit circle, then map to two normals.\n let u: number, v: number, s: number;\n do {\n u = this.gen.next() * 2 - 1;\n v = this.gen.next() * 2 - 1;\n s = u * u + v * v;\n } while (s >= 1 || s === 0);\n const mul = Math.sqrt(-2 * Math.log(s) / s);\n this.spareGauss = v * mul;\n return mean + stdev * (u * mul);\n }\n\n /**\n * Smooth 1-D value noise in `[0, 1]`.\n *\n * Samples two adjacent lattice points around `time * frequency`, then\n * interpolates with a smoothstep curve (`3t² - 2t³`) to avoid the linear\n * kinks of plain lerp. Unlike {@link nextFloat}/{@link gauss}, nearby\n * `time` inputs return nearby values — this is the correlated field used for\n * organic, continuously varying motion (camera shake, drift, waves).\n *\n * @param time Sample position (e.g. normalized timeline `[0, 1]`, or a\n * spatial index).\n * @param frequency Scales `time` before sampling; higher = faster\n * oscillation / more crests across the same span.\n */\n noise(time: number, frequency: number = 1): number {\n const t = time * frequency;\n const i = Math.floor(t);\n const f = t - i;\n // Smoothstep: maps f through 3f²-2f³ to ease in/out between lattice points.\n const curve = f * f * (3 - 2 * f);\n const r1 = this.latticeValue(i);\n const r2 = this.latticeValue(i + 1);\n return r1 + (r2 - r1) * curve;\n }\n\n /**\n * Rewind this source so the next draws reproduce a sequence from the start.\n *\n * With no argument, rewinds to the current {@link seed} — what authors call to\n * repeat a sequence within a scene. Pass a `seed` to adopt it as the new origin\n * first (equivalent to assigning {@link seed}), so the source both re-seeds and\n * rewinds in one call — e.g. in a node's constructor to give it a distinct\n * reproducible stream.\n */\n reset(seed: string | number = this._seed): void {\n this.adopt(seed);\n }\n\n /**\n * Deterministic value in `[0, 1)` for a given integer lattice point `x`,\n * mixed with this source's seed via `sin`. Pure in `x` (no generator state),\n * so {@link noise} is stable regardless of how many draws preceded it.\n */\n private latticeValue(x: number): number {\n const h = Math.sin(x + this.numericSeed) * 10000;\n return h - Math.floor(h);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/util/random.ts"],"names":[],"mappings":"AAAA,qKAAqK;AACrK,MAAM,OAAO,aAAa;IACd,KAAK,GAAW,CAAC,CAAC;IAE1B,YAAY,IAAqB;QAC7B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,8DAA8D;IAC9D,OAAO,CAAC,IAAqB;QACzB,IAAI,CAAC,KAAK,GAAG,OAAO,IAAI,KAAK,QAAQ;YACjC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC7F,CAAC,CAAC,IAAI,CAAC;IACf,CAAC;IAED,IAAI;Q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AAC,IAAY,EAAE,YAAoB,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;QAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChB,4EAA4E;QAC5E,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAClC,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACpC,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;IAClC,CAAC;IAED,kNAAkN;IAClN,KAAK,CAAC,OAAwB,IAAI,CAAC,KAAK;QACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,mKAAmK;IAC3J,YAAY,CAAC,CAAS;QAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;QACjD,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["/** Deterministic mulberry32 PRNG: the same seed gives the same sequence. Scene authors use the {@link Random} facade from `stage.random(seed)`, which wraps this. */\nexport class SeedGenerator {\n private state: number = 0;\n\n constructor(seed: string | number) {\n this.setSeed(seed);\n }\n\n /** String seeds are hashed via djb2 into a 32-bit integer. */\n setSeed(seed: string | number) {\n this.state = typeof seed === 'string'\n ? seed.split('').reduce((a, b) => { a = ((a << 5) - a) + b.charCodeAt(0); return a & a; }, 0)\n : seed;\n }\n\n next() {\n this.state |= 0; this.state = this.state + 0x6D2B79F5 | 0;\n var t = Math.imul(this.state ^ this.state >>> 15, 1 | this.state);\n t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;\n return ((t ^ t >>> 14) >>> 0) / 4294967296;\n }\n}\n\n/** Upper bound of {@link Random.nextInt} / {@link Random.intArray} (2^32). */\nconst UINT32_RANGE = 4294967296;\n\n/**\n * A seeded random source handed out by `stage.random(seed)`; wraps a {@link SeedGenerator} (mulberry32). Determinism\n * is scoped per source: scenes each get their own reproducible stream without a shared stage-level seed.\n *\n * Two families that are NOT interchangeable: **independent draws** (`nextFloat`/`nextInt`/`gauss` and array forms,\n * uncorrelated; `gauss` changes only the distribution) and the **correlated field** `noise(t)`, where nearby inputs\n * give nearby values, the right tool for smooth motion (drift, shake, waves).\n */\nexport class Random {\n /** The seed this source rewinds to; set by {@link adopt}. */\n private _seed!: string | number;\n\n /** Numeric form of {@link _seed}, used to mix `noise`'s lattice; kept in lockstep through {@link adopt}. */\n private numericSeed!: number;\n\n private readonly gen: SeedGenerator;\n\n /** A spare gaussian sample from the last Box–Muller pair (see {@link gauss}). */\n private spareGauss: number | null = null;\n\n constructor(seed: string | number) {\n this.gen = new SeedGenerator(seed);\n this.adopt(seed);\n }\n\n /** The seed this source rewinds to. Assigning re-anchors the source (as `reset(seed)`): draws reproduce that seed's sequence and `noise`'s lattice shifts to match. */\n get seed(): string | number {\n return this._seed;\n }\n set seed(seed: string | number) {\n this.adopt(seed);\n }\n\n /** Numeric form of a seed (strings hashed djb2-style), shared so the constructor, setter and {@link reset} derive `numericSeed` identically. */\n private static toNumeric(seed: string | number): number {\n return typeof seed === 'string'\n ? seed.split('').reduce((a, b) => (a << 5) - a + b.charCodeAt(0), 0)\n : seed;\n }\n\n /** Takes `seed` as the new origin and rewinds to it; the single seed-adoption path behind the constructor, {@link seed} and a seeded {@link reset}. */\n private adopt(seed: string | number): void {\n this._seed = seed;\n this.numericSeed = Random.toNumeric(seed);\n this.gen.setSeed(seed);\n this.spareGauss = null;\n }\n\n /** The next float in `[from, to)`, default `[0, 1)`. */\n nextFloat(from: number = 0, to: number = 1): number {\n return this.gen.next() * (to - from) + from;\n }\n\n /** The next integer in `[from, to)`, default the full unsigned 32-bit range. */\n nextInt(from: number = 0, to: number = UINT32_RANGE): number {\n return Math.floor(this.gen.next() * (to - from)) + from;\n }\n\n /** `size` independent floats in `[from, to)`. */\n floatArray(size: number, from: number = 0, to: number = 1): number[] {\n const out = new Array<number>(size);\n for (let i = 0; i < size; i++) out[i] = this.nextFloat(from, to);\n return out;\n }\n\n /** `size` independent integers in `[from, to)`. */\n intArray(size: number, from: number = 0, to: number = UINT32_RANGE): number[] {\n const out = new Array<number>(size);\n for (let i = 0; i < size; i++) out[i] = this.nextInt(from, to);\n return out;\n }\n\n /** A normal sample (default standard). Uses the polar Box–Muller transform, which yields two normals per pair of uniforms; the spare is cached for the next call. */\n gauss(mean: number = 0, stdev: number = 1): number {\n if (this.spareGauss !== null) {\n const z = this.spareGauss;\n this.spareGauss = null;\n return mean + stdev * z;\n }\n // Rejection-sample a point in the unit circle, then map to two normals.\n let u: number, v: number, s: number;\n do {\n u = this.gen.next() * 2 - 1;\n v = this.gen.next() * 2 - 1;\n s = u * u + v * v;\n } while (s >= 1 || s === 0);\n const mul = Math.sqrt(-2 * Math.log(s) / s);\n this.spareGauss = v * mul;\n return mean + stdev * (u * mul);\n }\n\n /**\n * Smooth 1-D value noise in `[0, 1]`: lattice points around `time * frequency` interpolated with a smoothstep.\n * Unlike {@link nextFloat}/{@link gauss}, nearby `time` inputs give nearby values (camera shake, drift, waves).\n * Higher `frequency` means more crests across the same span.\n */\n noise(time: number, frequency: number = 1): number {\n const t = time * frequency;\n const i = Math.floor(t);\n const f = t - i;\n // Smoothstep: maps f through 3f²-2f³ to ease in/out between lattice points.\n const curve = f * f * (3 - 2 * f);\n const r1 = this.latticeValue(i);\n const r2 = this.latticeValue(i + 1);\n return r1 + (r2 - r1) * curve;\n }\n\n /** Rewinds so the next draws reproduce a sequence from the start. With a `seed`, adopts it as the new origin first (equivalent to assigning {@link seed}), e.g. in a node's constructor for a distinct stream. */\n reset(seed: string | number = this._seed): void {\n this.adopt(seed);\n }\n\n /** Deterministic value in `[0, 1)` for lattice point `x`, mixed with the seed via `sin`. Pure in `x`, so {@link noise} is stable regardless of preceding draws. */\n private latticeValue(x: number): number {\n const h = Math.sin(x + this.numericSeed) * 10000;\n return h - Math.floor(h);\n }\n}\n"]}
|