@motionscript/core 0.1.0-alpha.3 → 0.1.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +220 -0
- package/LICENSE +201 -201
- package/NOTICE +48 -0
- package/README.md +93 -72
- package/dist/assets/asset-index.js.map +1 -1
- package/dist/assets/catalog.d.ts +9 -0
- package/dist/assets/catalog.d.ts.map +1 -1
- package/dist/assets/catalog.js +11 -0
- package/dist/assets/catalog.js.map +1 -1
- package/dist/assets/errors.d.ts.map +1 -1
- package/dist/assets/errors.js +8 -3
- package/dist/assets/errors.js.map +1 -1
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/manager.d.ts +26 -1
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/assets/manager.js +79 -4
- package/dist/assets/manager.js.map +1 -1
- package/dist/assets/manifest.js.map +1 -1
- package/dist/assets/record.js.map +1 -1
- package/dist/assets/scope.d.ts +3 -3
- package/dist/assets/scope.d.ts.map +1 -1
- package/dist/assets/scope.js.map +1 -1
- package/dist/attributes/audio/filters/chain.d.ts +1 -1
- package/dist/attributes/audio/filters/chain.js.map +1 -1
- package/dist/attributes/audio/filters/curve.d.ts +8 -8
- package/dist/attributes/audio/filters/curve.d.ts.map +1 -1
- package/dist/attributes/audio/filters/curve.js +20 -19
- package/dist/attributes/audio/filters/curve.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/echo.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/gain.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/highpass.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/lowpass.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/speed.d.ts +2 -2
- package/dist/attributes/audio/filters/implementations/speed.js.map +1 -1
- package/dist/attributes/audio/filters/implementations/tremolo.js.map +1 -1
- package/dist/attributes/audio/filters/index.d.ts +1 -1
- package/dist/attributes/audio/filters/index.d.ts.map +1 -1
- package/dist/attributes/audio/filters/index.js +1 -1
- package/dist/attributes/audio/filters/index.js.map +1 -1
- package/dist/attributes/audio/filters/registry.js.map +1 -1
- package/dist/attributes/audio/filters/union.js.map +1 -1
- package/dist/attributes/audio/request.d.ts +17 -2
- package/dist/attributes/audio/request.d.ts.map +1 -1
- package/dist/attributes/audio/request.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +4 -2
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js +15 -8
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/audio/sound.d.ts +4 -2
- package/dist/attributes/audio/sound.d.ts.map +1 -1
- package/dist/attributes/audio/sound.js +8 -4
- package/dist/attributes/audio/sound.js.map +1 -1
- package/dist/attributes/index.js.map +1 -1
- package/dist/attributes/layout/alignment.js +1 -1
- package/dist/attributes/layout/alignment.js.map +1 -1
- package/dist/attributes/layout/index.js.map +1 -1
- package/dist/attributes/layout/insets.js.map +1 -1
- package/dist/attributes/layout/matrix2d.js.map +1 -1
- package/dist/attributes/layout/size.js.map +1 -1
- package/dist/attributes/layout/transform3d.js.map +1 -1
- package/dist/attributes/layout/vector2.js.map +1 -1
- package/dist/attributes/layout/world-transform.js.map +1 -1
- package/dist/attributes/mask/boolean.js.map +1 -1
- package/dist/attributes/mask/mask.js.map +1 -1
- package/dist/attributes/properties/decorator.d.ts +3 -1
- package/dist/attributes/properties/decorator.d.ts.map +1 -1
- package/dist/attributes/properties/decorator.js.map +1 -1
- package/dist/attributes/properties/inputs.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +9 -2
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +15 -1
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/render3d/orbit.d.ts +8 -8
- package/dist/attributes/render3d/orbit.js +7 -7
- package/dist/attributes/render3d/orbit.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/corners/corner-style.js.map +1 -1
- package/dist/attributes/shape/corners/corners.js.map +1 -1
- package/dist/attributes/shape/corners/index.js.map +1 -1
- package/dist/attributes/shape/effects/backdrop.d.ts +4 -4
- package/dist/attributes/shape/effects/backdrop.d.ts.map +1 -1
- package/dist/attributes/shape/effects/backdrop.js.map +1 -1
- package/dist/attributes/shape/effects/chain.d.ts +28 -120
- package/dist/attributes/shape/effects/chain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/chain.js +16 -88
- package/dist/attributes/shape/effects/chain.js.map +1 -1
- package/dist/attributes/shape/effects/effect-data.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts +2 -2
- package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.d.ts +1 -1
- package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.d.ts +15 -24
- package/dist/attributes/shape/effects/implementations/glass.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.d.ts +1 -1
- package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.js +15 -8
- package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
- package/dist/attributes/shape/effects/index.d.ts +2 -6
- package/dist/attributes/shape/effects/index.d.ts.map +1 -1
- package/dist/attributes/shape/effects/index.js.map +1 -1
- package/dist/attributes/shape/effects/registry.d.ts +23 -6
- package/dist/attributes/shape/effects/registry.d.ts.map +1 -1
- package/dist/attributes/shape/effects/registry.js +44 -10
- package/dist/attributes/shape/effects/registry.js.map +1 -1
- package/dist/attributes/shape/effects/union.d.ts +2 -6
- package/dist/attributes/shape/effects/union.d.ts.map +1 -1
- package/dist/attributes/shape/effects/union.js.map +1 -1
- package/dist/attributes/shape/fill/blend.js.map +1 -1
- package/dist/attributes/shape/fill/chain.js.map +1 -1
- package/dist/attributes/shape/fill/coerce.js.map +1 -1
- package/dist/attributes/shape/fill/color/constants.js.map +1 -1
- package/dist/attributes/shape/fill/color/parser.d.ts.map +1 -1
- package/dist/attributes/shape/fill/color/parser.js +81 -44
- package/dist/attributes/shape/fill/color/parser.js.map +1 -1
- package/dist/attributes/shape/fill/gradient-stops.d.ts +16 -0
- package/dist/attributes/shape/fill/gradient-stops.d.ts.map +1 -0
- package/dist/attributes/shape/fill/gradient-stops.js +65 -0
- package/dist/attributes/shape/fill/gradient-stops.js.map +1 -0
- package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/color.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/conic-gradient.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/conic-gradient.js +2 -5
- package/dist/attributes/shape/fill/implementations/conic-gradient.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/dot-grid.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.js +2 -10
- package/dist/attributes/shape/fill/implementations/fractal-noise.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/grid.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/image.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/image.js +5 -4
- package/dist/attributes/shape/fill/implementations/image.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/linear-gradient.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/linear-gradient.js +2 -6
- package/dist/attributes/shape/fill/implementations/linear-gradient.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/noise.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/radial-gradient.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/radial-gradient.js +2 -5
- package/dist/attributes/shape/fill/implementations/radial-gradient.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/stripe.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/video.js +1 -1
- package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
- package/dist/attributes/shape/fill/index.js.map +1 -1
- package/dist/attributes/shape/fill/lerp.js.map +1 -1
- package/dist/attributes/shape/fill/media-preset.js.map +1 -1
- package/dist/attributes/shape/fill/registry.js.map +1 -1
- package/dist/attributes/shape/fill/union.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +4 -10
- package/dist/attributes/shape/filters/chain.d.ts.map +1 -1
- package/dist/attributes/shape/filters/chain.js +1 -13
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/alpha.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/blur.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-adjustment.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-matrix.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/echo.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/exposure.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/grayscale.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/posterize-time.js.map +1 -1
- package/dist/attributes/shape/filters/index.d.ts +1 -1
- package/dist/attributes/shape/filters/index.js.map +1 -1
- package/dist/attributes/shape/filters/registry.d.ts +2 -2
- package/dist/attributes/shape/filters/registry.js +3 -3
- package/dist/attributes/shape/filters/registry.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +6 -7
- package/dist/attributes/shape/filters/union.d.ts.map +1 -1
- package/dist/attributes/shape/filters/union.js.map +1 -1
- package/dist/attributes/shape/path/anchors.d.ts.map +1 -1
- package/dist/attributes/shape/path/anchors.js +12 -5
- package/dist/attributes/shape/path/anchors.js.map +1 -1
- package/dist/attributes/shape/path/bezier.js.map +1 -1
- package/dist/attributes/shape/path/index.js.map +1 -1
- package/dist/attributes/shape/path/measure.js.map +1 -1
- package/dist/attributes/shape/path/morph.d.ts.map +1 -1
- package/dist/attributes/shape/path/morph.js +16 -4
- package/dist/attributes/shape/path/morph.js.map +1 -1
- package/dist/attributes/shape/path/ops.js.map +1 -1
- package/dist/attributes/shape/path/types.js.map +1 -1
- package/dist/attributes/shape/path/walk.js.map +1 -1
- package/dist/attributes/shape/shaders/index.js.map +1 -1
- package/dist/attributes/shape/shaders/pack.js.map +1 -1
- package/dist/attributes/shape/shaders/resolve.js.map +1 -1
- package/dist/attributes/shape/shadow/index.js.map +1 -1
- package/dist/attributes/shape/shadow/shadow.js.map +1 -1
- package/dist/attributes/shape/stroke/index.d.ts +2 -2
- package/dist/attributes/shape/stroke/index.d.ts.map +1 -1
- package/dist/attributes/shape/stroke/index.js +1 -1
- package/dist/attributes/shape/stroke/index.js.map +1 -1
- package/dist/attributes/shape/stroke/stroke.d.ts +27 -6
- package/dist/attributes/shape/stroke/stroke.d.ts.map +1 -1
- package/dist/attributes/shape/stroke/stroke.js +22 -2
- package/dist/attributes/shape/stroke/stroke.js.map +1 -1
- package/dist/attributes/shared/operators.js.map +1 -1
- package/dist/attributes/text/index.js.map +1 -1
- package/dist/attributes/text/ops.d.ts +6 -0
- package/dist/attributes/text/ops.d.ts.map +1 -1
- package/dist/attributes/text/ops.js +1 -0
- package/dist/attributes/text/ops.js.map +1 -1
- package/dist/attributes/text/types.js.map +1 -1
- package/dist/browser/chunks/chunk-FUZVFT3W.js +18 -0
- package/dist/browser/chunks/chunk-FUZVFT3W.js.map +7 -0
- package/dist/browser/chunks/chunk-QG6C23IJ.js +3 -0
- package/dist/browser/chunks/chunk-QG6C23IJ.js.map +7 -0
- package/dist/browser/chunks/chunk-SFNJRPBV.js +2 -0
- package/dist/browser/chunks/chunk-SFNJRPBV.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/component.js.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/jsx-jsx-dev-runtime.js +1 -1
- package/dist/browser/jsx-jsx-runtime.js +1 -1
- package/dist/browser/manifest.json +3 -2
- package/dist/browser/sdk.js +1 -1
- package/dist/component.js.map +1 -1
- package/dist/document/audio.d.ts +1 -1
- package/dist/document/audio.js +4 -4
- package/dist/document/audio.js.map +1 -1
- package/dist/document/builtins.d.ts.map +1 -1
- package/dist/document/builtins.js +8 -14
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +1 -1
- package/dist/document/command-traits.js +13 -1
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/deny-globals.js.map +1 -1
- package/dist/document/diff.js.map +1 -1
- package/dist/document/doc-index.d.ts +2 -2
- package/dist/document/doc-index.d.ts.map +1 -1
- package/dist/document/doc-index.js.map +1 -1
- package/dist/document/expression/compile.d.ts.map +1 -1
- package/dist/document/expression/compile.js +8 -5
- package/dist/document/expression/compile.js.map +1 -1
- package/dist/document/expression/index.js.map +1 -1
- package/dist/document/expression/ops.js +1 -1
- package/dist/document/expression/ops.js.map +1 -1
- package/dist/document/expression/parse.d.ts.map +1 -1
- package/dist/document/expression/parse.js +15 -6
- package/dist/document/expression/parse.js.map +1 -1
- package/dist/document/expression/refs.d.ts +1 -1
- package/dist/document/expression/refs.js +1 -1
- package/dist/document/expression/refs.js.map +1 -1
- package/dist/document/expression/types.js.map +1 -1
- package/dist/document/expression/walk.d.ts.map +1 -1
- package/dist/document/expression/walk.js +2 -1
- package/dist/document/expression/walk.js.map +1 -1
- package/dist/document/index.d.ts +2 -0
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/index.js +2 -0
- package/dist/document/index.js.map +1 -1
- package/dist/document/node-decorator.js.map +1 -1
- package/dist/document/node-descriptor.d.ts +19 -0
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/placement.d.ts +70 -0
- package/dist/document/placement.d.ts.map +1 -0
- package/dist/document/placement.js +83 -0
- package/dist/document/placement.js.map +1 -0
- package/dist/document/project.d.ts +2 -2
- package/dist/document/project.d.ts.map +1 -1
- package/dist/document/project.js.map +1 -1
- package/dist/document/registry.d.ts +17 -0
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +29 -2
- package/dist/document/registry.js.map +1 -1
- package/dist/document/timeline-patch.js.map +1 -1
- package/dist/document/timeline.d.ts +73 -18
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +192 -40
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +12 -12
- package/dist/document/types.d.ts.map +1 -1
- package/dist/document/types.js +2 -2
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +2 -2
- package/dist/document/validate.d.ts.map +1 -1
- package/dist/document/validate.js +37 -31
- package/dist/document/validate.js.map +1 -1
- package/dist/document/withdraw.d.ts +28 -0
- package/dist/document/withdraw.d.ts.map +1 -0
- package/dist/document/withdraw.js +61 -0
- package/dist/document/withdraw.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx/jsx-runtime.d.ts +9 -1
- package/dist/jsx/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx/jsx-runtime.js +13 -3
- package/dist/jsx/jsx-runtime.js.map +1 -1
- package/dist/layout/bounds.d.ts +0 -1
- package/dist/layout/bounds.d.ts.map +1 -1
- package/dist/layout/bounds.js.map +1 -1
- package/dist/layout/constraints.js.map +1 -1
- package/dist/layout/flex.d.ts +4 -2
- package/dist/layout/flex.d.ts.map +1 -1
- package/dist/layout/flex.js +27 -11
- package/dist/layout/flex.js.map +1 -1
- package/dist/layout/freeform.js.map +1 -1
- package/dist/layout/grid.js.map +1 -1
- package/dist/layout/index.js.map +1 -1
- package/dist/layout/item.js.map +1 -1
- package/dist/layout/ops.d.ts +6 -0
- package/dist/layout/ops.d.ts.map +1 -1
- package/dist/layout/ops.js +6 -0
- package/dist/layout/ops.js.map +1 -1
- package/dist/layout/types.js.map +1 -1
- package/dist/nodes/2d/node-lifecycle.js.map +1 -1
- package/dist/nodes/2d/node-motion.js.map +1 -1
- package/dist/nodes/2d/node-render.d.ts +3 -3
- package/dist/nodes/2d/node-render.d.ts.map +1 -1
- package/dist/nodes/2d/node-render.js.map +1 -1
- package/dist/nodes/2d/node-transform.js.map +1 -1
- package/dist/nodes/2d/node2d.d.ts +115 -3
- package/dist/nodes/2d/node2d.d.ts.map +1 -1
- package/dist/nodes/2d/node2d.js +180 -28
- package/dist/nodes/2d/node2d.js.map +1 -1
- package/dist/nodes/2d/paint-node.d.ts +27 -0
- package/dist/nodes/2d/paint-node.d.ts.map +1 -1
- package/dist/nodes/2d/paint-node.js +42 -0
- package/dist/nodes/2d/paint-node.js.map +1 -1
- package/dist/nodes/audio/audio-bus.js.map +1 -1
- package/dist/nodes/audio/index.js.map +1 -1
- package/dist/nodes/audio/node-audio.js.map +1 -1
- package/dist/nodes/audio/sound-node.d.ts +2 -2
- package/dist/nodes/audio/sound-node.d.ts.map +1 -1
- package/dist/nodes/audio/sound-node.js +1 -1
- package/dist/nodes/audio/sound-node.js.map +1 -1
- package/dist/nodes/geometry/bounds-shape-node.d.ts +4 -4
- package/dist/nodes/geometry/bounds-shape-node.js +2 -2
- package/dist/nodes/geometry/bounds-shape-node.js.map +1 -1
- package/dist/nodes/geometry/box-path-node.d.ts +3 -3
- package/dist/nodes/geometry/box-path-node.js +2 -2
- package/dist/nodes/geometry/box-path-node.js.map +1 -1
- package/dist/nodes/geometry/ellipse-node.js.map +1 -1
- package/dist/nodes/geometry/group-bounds.d.ts +2 -2
- package/dist/nodes/geometry/group-bounds.d.ts.map +1 -1
- package/dist/nodes/geometry/group-bounds.js +1 -2
- package/dist/nodes/geometry/group-bounds.js.map +1 -1
- package/dist/nodes/geometry/path-node.d.ts.map +1 -1
- package/dist/nodes/geometry/path-node.js +6 -0
- package/dist/nodes/geometry/path-node.js.map +1 -1
- package/dist/nodes/geometry/polygon-node.js.map +1 -1
- package/dist/nodes/geometry/polygram-node.js.map +1 -1
- package/dist/nodes/geometry/rect-node.js.map +1 -1
- package/dist/nodes/geometry/shape-node.js.map +1 -1
- package/dist/nodes/geometry/shape-outline.d.ts +2 -2
- package/dist/nodes/geometry/shape-outline.d.ts.map +1 -1
- package/dist/nodes/geometry/shape-outline.js +2 -13
- package/dist/nodes/geometry/shape-outline.js.map +1 -1
- package/dist/nodes/index.d.ts +3 -8
- package/dist/nodes/index.d.ts.map +1 -1
- package/dist/nodes/index.js +3 -8
- package/dist/nodes/index.js.map +1 -1
- package/dist/nodes/layout/camera-node.d.ts +9 -0
- package/dist/nodes/layout/camera-node.d.ts.map +1 -1
- package/dist/nodes/layout/camera-node.js +38 -3
- package/dist/nodes/layout/camera-node.js.map +1 -1
- package/dist/nodes/layout/orbit-camera-node.d.ts +1 -1
- package/dist/nodes/layout/orbit-camera-node.js +1 -1
- package/dist/nodes/layout/orbit-camera-node.js.map +1 -1
- package/dist/nodes/layout/rotated-box.js.map +1 -1
- package/dist/nodes/media/video-node.d.ts.map +1 -1
- package/dist/nodes/media/video-node.js +2 -0
- package/dist/nodes/media/video-node.js.map +1 -1
- package/dist/nodes/node/declare-paints.js.map +1 -1
- package/dist/nodes/node/node-editor-state.js.map +1 -1
- package/dist/nodes/node/node-reactive.js.map +1 -1
- package/dist/nodes/node/node-time.d.ts +3 -3
- package/dist/nodes/node/node-time.d.ts.map +1 -1
- package/dist/nodes/node/node-time.js +1 -1
- package/dist/nodes/node/node-time.js.map +1 -1
- package/dist/nodes/node/node-walk.js.map +1 -1
- package/dist/nodes/node/node.d.ts +5 -3
- package/dist/nodes/node/node.d.ts.map +1 -1
- package/dist/nodes/node/node.js +44 -19
- package/dist/nodes/node/node.js.map +1 -1
- package/dist/nodes/node/text-defaults.d.ts +10 -12
- package/dist/nodes/node/text-defaults.d.ts.map +1 -1
- package/dist/nodes/node/text-defaults.js +10 -12
- package/dist/nodes/node/text-defaults.js.map +1 -1
- package/dist/nodes/{scene → root}/canvas2d-node.d.ts +2 -2
- package/dist/nodes/root/canvas2d-node.d.ts.map +1 -0
- package/dist/nodes/{scene → root}/canvas2d-node.js +2 -2
- package/dist/nodes/root/canvas2d-node.js.map +1 -0
- package/dist/nodes/root/provider-node.d.ts.map +1 -0
- package/dist/nodes/root/provider-node.js.map +1 -0
- package/dist/nodes/root/theme-provider-node.d.ts.map +1 -0
- package/dist/nodes/root/theme-provider-node.js.map +1 -0
- package/dist/nodes/text/default-text-style-node.d.ts +5 -2
- package/dist/nodes/text/default-text-style-node.d.ts.map +1 -1
- package/dist/nodes/text/default-text-style-node.js +10 -4
- package/dist/nodes/text/default-text-style-node.js.map +1 -1
- package/dist/nodes/text/number-format.d.ts +1 -1
- package/dist/nodes/text/number-format.js +1 -1
- package/dist/nodes/text/number-format.js.map +1 -1
- package/dist/nodes/text/number-node.js.map +1 -1
- package/dist/nodes/text/number-pattern.js.map +1 -1
- package/dist/nodes/text/richtext-node.js +1 -1
- package/dist/nodes/text/richtext-node.js.map +1 -1
- package/dist/nodes/text/text-base.d.ts.map +1 -1
- package/dist/nodes/text/text-base.js +1 -1
- package/dist/nodes/text/text-base.js.map +1 -1
- package/dist/nodes/text/text-node.js.map +1 -1
- package/dist/nodes/text/text-selection.js.map +1 -1
- package/dist/nodes/three/camera-nodes.d.ts +21 -3
- package/dist/nodes/three/camera-nodes.d.ts.map +1 -1
- package/dist/nodes/three/camera-nodes.js +42 -1
- package/dist/nodes/three/camera-nodes.js.map +1 -1
- package/dist/nodes/three/canvas3d-node.d.ts +29 -6
- package/dist/nodes/three/canvas3d-node.d.ts.map +1 -1
- package/dist/nodes/three/canvas3d-node.js +44 -2
- package/dist/nodes/three/canvas3d-node.js.map +1 -1
- package/dist/nodes/three/drawable-nodes.d.ts +25 -11
- package/dist/nodes/three/drawable-nodes.d.ts.map +1 -1
- package/dist/nodes/three/drawable-nodes.js +43 -13
- package/dist/nodes/three/drawable-nodes.js.map +1 -1
- package/dist/nodes/three/environment-nodes.d.ts +9 -3
- package/dist/nodes/three/environment-nodes.d.ts.map +1 -1
- package/dist/nodes/three/environment-nodes.js.map +1 -1
- package/dist/nodes/three/geometry-nodes.d.ts +2 -2
- package/dist/nodes/three/geometry-nodes.js +2 -2
- package/dist/nodes/three/geometry-nodes.js.map +1 -1
- package/dist/nodes/three/grid-geometry3d.js.map +1 -1
- package/dist/nodes/three/group3d.js.map +1 -1
- package/dist/nodes/three/light-nodes.d.ts.map +1 -1
- package/dist/nodes/three/light-nodes.js +3 -3
- package/dist/nodes/three/light-nodes.js.map +1 -1
- package/dist/nodes/three/mesh3d.js.map +1 -1
- package/dist/nodes/three/node3d.d.ts +48 -0
- package/dist/nodes/three/node3d.d.ts.map +1 -1
- package/dist/nodes/three/node3d.js +53 -3
- package/dist/nodes/three/node3d.js.map +1 -1
- package/dist/platform/audio-sink.d.ts +2 -2
- package/dist/platform/audio-sink.d.ts.map +1 -1
- package/dist/platform/audio-sink.js.map +1 -1
- package/dist/platform/exporter.d.ts +13 -8
- package/dist/platform/exporter.d.ts.map +1 -1
- package/dist/platform/exporter.js.map +1 -1
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/stepped-clock.js.map +1 -1
- package/dist/platform/storage-adapter.d.ts +12 -6
- package/dist/platform/storage-adapter.d.ts.map +1 -1
- package/dist/platform/storage-adapter.js +4 -0
- package/dist/platform/storage-adapter.js.map +1 -1
- package/dist/platform/ticker.d.ts +6 -0
- package/dist/platform/ticker.d.ts.map +1 -1
- package/dist/platform/ticker.js +6 -0
- package/dist/platform/ticker.js.map +1 -1
- package/dist/project/config.js.map +1 -1
- package/dist/project/index.js.map +1 -1
- package/dist/project/tree.d.ts +3 -3
- package/dist/project/tree.d.ts.map +1 -1
- package/dist/project/tree.js.map +1 -1
- package/dist/props/host.js.map +1 -1
- package/dist/props/index.js.map +1 -1
- package/dist/props/observer.js.map +1 -1
- package/dist/props/slot.js.map +1 -1
- package/dist/renamed-scene-names.d.ts +17 -0
- package/dist/renamed-scene-names.d.ts.map +1 -0
- package/dist/renamed-scene-names.js +9 -0
- package/dist/renamed-scene-names.js.map +1 -0
- package/dist/render/canvas-render-context2d.d.ts +2 -2
- package/dist/render/canvas-render-context2d.d.ts.map +1 -1
- package/dist/render/canvas-render-context2d.js.map +1 -1
- package/dist/render/clip-contains.js.map +1 -1
- package/dist/render/clip.js.map +1 -1
- package/dist/render/descriptors/ellipse.js.map +1 -1
- package/dist/render/descriptors/latex.js.map +1 -1
- package/dist/render/descriptors/line.js.map +1 -1
- package/dist/render/descriptors/path-builder.js.map +1 -1
- package/dist/render/descriptors/path.js.map +1 -1
- package/dist/render/descriptors/polygon.js.map +1 -1
- package/dist/render/descriptors/polygram.js.map +1 -1
- package/dist/render/descriptors/rect.js.map +1 -1
- package/dist/render/descriptors/richtext.js.map +1 -1
- package/dist/render/descriptors/shape.d.ts +12 -0
- package/dist/render/descriptors/shape.d.ts.map +1 -1
- package/dist/render/descriptors/shape.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +2 -2
- package/dist/render/descriptors/text.js +2 -2
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/descriptors/transform.d.ts +2 -2
- package/dist/render/descriptors/transform.d.ts.map +1 -1
- package/dist/render/descriptors/transform.js.map +1 -1
- package/dist/render/graphics2d.d.ts +3 -3
- package/dist/render/graphics2d.d.ts.map +1 -1
- package/dist/render/graphics2d.js +1 -1
- package/dist/render/graphics2d.js.map +1 -1
- package/dist/render/index.js.map +1 -1
- package/dist/render/measure-context.js.map +1 -1
- package/dist/render/null-render-context.js.map +1 -1
- package/dist/render/render-context2d.d.ts +2 -2
- package/dist/render/render-context2d.d.ts.map +1 -1
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render/surface.js.map +1 -1
- package/dist/render/text-defaults.js.map +1 -1
- package/dist/render/text-layout.js.map +1 -1
- package/dist/render3d/bounds3d.d.ts.map +1 -1
- package/dist/render3d/bounds3d.js +4 -2
- package/dist/render3d/bounds3d.js.map +1 -1
- package/dist/render3d/builders.js.map +1 -1
- package/dist/render3d/camera.d.ts +6 -0
- package/dist/render3d/camera.d.ts.map +1 -1
- package/dist/render3d/camera.js +5 -3
- package/dist/render3d/camera.js.map +1 -1
- package/dist/render3d/fill3d.d.ts +2 -9
- package/dist/render3d/fill3d.d.ts.map +1 -1
- package/dist/render3d/fill3d.js +2 -13
- package/dist/render3d/fill3d.js.map +1 -1
- package/dist/render3d/geometry.d.ts +8 -1
- package/dist/render3d/geometry.d.ts.map +1 -1
- package/dist/render3d/geometry.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts +8 -4
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +18 -10
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/render3d/index.d.ts +1 -1
- package/dist/render3d/index.js +1 -1
- package/dist/render3d/index.js.map +1 -1
- package/dist/render3d/inert.d.ts +14 -0
- package/dist/render3d/inert.d.ts.map +1 -0
- package/dist/render3d/inert.js +62 -0
- package/dist/render3d/inert.js.map +1 -0
- package/dist/render3d/light.js.map +1 -1
- package/dist/render3d/material.d.ts +10 -5
- package/dist/render3d/material.d.ts.map +1 -1
- package/dist/render3d/material.js.map +1 -1
- package/dist/render3d/matrix4.js.map +1 -1
- package/dist/render3d/render-context3d.js.map +1 -1
- package/dist/render3d/resources.js.map +1 -1
- package/dist/render3d/rounded-box.js.map +1 -1
- package/dist/render3d/scene-settings.d.ts +23 -4
- package/dist/render3d/scene-settings.d.ts.map +1 -1
- package/dist/render3d/scene-settings.js.map +1 -1
- package/dist/render3d/scene3d.d.ts +11 -0
- package/dist/render3d/scene3d.d.ts.map +1 -1
- package/dist/render3d/scene3d.js +39 -6
- package/dist/render3d/scene3d.js.map +1 -1
- package/dist/render3d/segments.js.map +1 -1
- package/dist/render3d/texture.d.ts +9 -0
- package/dist/render3d/texture.d.ts.map +1 -1
- package/dist/render3d/texture.js +13 -0
- package/dist/render3d/texture.js.map +1 -1
- package/dist/render3d/tracking.js.map +1 -1
- package/dist/render3d/transform.d.ts +1 -1
- package/dist/render3d/transform.js.map +1 -1
- package/dist/render3d/vector3.d.ts +18 -1
- package/dist/render3d/vector3.d.ts.map +1 -1
- package/dist/render3d/vector3.js +27 -0
- package/dist/render3d/vector3.js.map +1 -1
- package/dist/render3d/walk.d.ts +1 -1
- package/dist/render3d/walk.d.ts.map +1 -1
- package/dist/render3d/walk.js +5 -1
- package/dist/render3d/walk.js.map +1 -1
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-timeline.js.map +1 -1
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/audio-index.js.map +1 -1
- package/dist/runtime/builtin-context.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +5 -3
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +10 -6
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +9 -0
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +19 -0
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +5 -0
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +2 -0
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/frame-time.d.ts +31 -0
- package/dist/runtime/frame-time.d.ts.map +1 -0
- package/dist/runtime/frame-time.js +29 -0
- package/dist/runtime/frame-time.js.map +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/node-picking.d.ts +44 -3
- package/dist/runtime/node-picking.d.ts.map +1 -1
- package/dist/runtime/node-picking.js +118 -3
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +2 -1
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +5 -2
- package/dist/runtime/node-picking3d.js.map +1 -1
- package/dist/runtime/placement.d.ts.map +1 -1
- package/dist/runtime/placement.js +4 -5
- package/dist/runtime/placement.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts +31 -2
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +63 -6
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/playback.js.map +1 -1
- package/dist/runtime/precompisition.js.map +1 -1
- package/dist/runtime/project-assets.js.map +1 -1
- package/dist/runtime/session.d.ts +9 -7
- package/dist/runtime/session.d.ts.map +1 -1
- package/dist/runtime/session.js +12 -4
- package/dist/runtime/session.js.map +1 -1
- package/dist/runtime/settle.js.map +1 -1
- package/dist/runtime/state-evaluator.d.ts +1 -1
- package/dist/runtime/state-evaluator.d.ts.map +1 -1
- package/dist/runtime/state-evaluator.js +4 -3
- package/dist/runtime/state-evaluator.js.map +1 -1
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +19 -15
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +11 -6
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +2 -0
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/command.js.map +1 -1
- package/dist/tween/ease/constants.d.ts.map +1 -1
- package/dist/tween/ease/constants.js +8 -5
- package/dist/tween/ease/constants.js.map +1 -1
- package/dist/tween/ease/curve.d.ts.map +1 -1
- package/dist/tween/ease/curve.js +4 -3
- package/dist/tween/ease/curve.js.map +1 -1
- package/dist/tween/ease/describe.d.ts +15 -0
- package/dist/tween/ease/describe.d.ts.map +1 -0
- package/dist/tween/ease/describe.js +37 -0
- package/dist/tween/ease/describe.js.map +1 -0
- package/dist/tween/ease/type.js.map +1 -1
- package/dist/tween/index.js.map +1 -1
- package/dist/tween/inert.js.map +1 -1
- package/dist/tween/lerp.js.map +1 -1
- package/dist/tween/loop.js.map +1 -1
- package/dist/tween/prepare.d.ts +3 -3
- package/dist/tween/prepare.js +3 -3
- package/dist/tween/prepare.js.map +1 -1
- package/dist/tween/seekable.d.ts +1 -1
- package/dist/tween/seekable.js.map +1 -1
- package/dist/tween/stepper.js.map +1 -1
- package/dist/tween/to-command.js.map +1 -1
- package/dist/util/clamp.js.map +1 -1
- package/dist/util/context.js.map +1 -1
- package/dist/util/csv.js.map +1 -1
- package/dist/util/generateList.js.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/metrics.d.ts +1 -1
- package/dist/util/metrics.js +1 -1
- package/dist/util/metrics.js.map +1 -1
- package/dist/util/random.js.map +1 -1
- package/dist/util/reference.js.map +1 -1
- package/dist/util/scheduler.js.map +1 -1
- package/package.json +2 -1
- package/dist/attributes/shape/effects/implementations/displace.d.ts +0 -48
- package/dist/attributes/shape/effects/implementations/displace.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/displace.js +0 -30
- package/dist/attributes/shape/effects/implementations/displace.js.map +0 -1
- package/dist/attributes/shape/effects/implementations/god-rays.d.ts +0 -28
- package/dist/attributes/shape/effects/implementations/god-rays.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/god-rays.js +0 -26
- package/dist/attributes/shape/effects/implementations/god-rays.js.map +0 -1
- package/dist/attributes/shape/effects/implementations/texture.d.ts +0 -28
- package/dist/attributes/shape/effects/implementations/texture.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/texture.js +0 -25
- package/dist/attributes/shape/effects/implementations/texture.js.map +0 -1
- package/dist/attributes/shape/effects/implementations/trails.d.ts +0 -41
- package/dist/attributes/shape/effects/implementations/trails.d.ts.map +0 -1
- package/dist/attributes/shape/effects/implementations/trails.js +0 -22
- package/dist/attributes/shape/effects/implementations/trails.js.map +0 -1
- package/dist/browser/chunks/chunk-2T3HXSC2.js +0 -2
- package/dist/browser/chunks/chunk-2T3HXSC2.js.map +0 -7
- package/dist/browser/chunks/chunk-KJXGRHOL.js +0 -3
- package/dist/browser/chunks/chunk-KJXGRHOL.js.map +0 -7
- package/dist/browser/chunks/chunk-TGDX2SS2.js +0 -18
- package/dist/browser/chunks/chunk-TGDX2SS2.js.map +0 -7
- package/dist/nodes/geometry/dot-grid-node.d.ts +0 -105
- package/dist/nodes/geometry/dot-grid-node.d.ts.map +0 -1
- package/dist/nodes/geometry/dot-grid-node.js +0 -142
- package/dist/nodes/geometry/dot-grid-node.js.map +0 -1
- package/dist/nodes/geometry/grid-lines.d.ts +0 -101
- package/dist/nodes/geometry/grid-lines.d.ts.map +0 -1
- package/dist/nodes/geometry/grid-lines.js +0 -128
- package/dist/nodes/geometry/grid-lines.js.map +0 -1
- package/dist/nodes/geometry/grid-pattern-node.d.ts +0 -58
- package/dist/nodes/geometry/grid-pattern-node.d.ts.map +0 -1
- package/dist/nodes/geometry/grid-pattern-node.js +0 -172
- package/dist/nodes/geometry/grid-pattern-node.js.map +0 -1
- package/dist/nodes/geometry/line-grid-node.d.ts +0 -62
- package/dist/nodes/geometry/line-grid-node.d.ts.map +0 -1
- package/dist/nodes/geometry/line-grid-node.js +0 -127
- package/dist/nodes/geometry/line-grid-node.js.map +0 -1
- package/dist/nodes/geometry/line-node.d.ts +0 -58
- package/dist/nodes/geometry/line-node.d.ts.map +0 -1
- package/dist/nodes/geometry/line-node.js +0 -123
- package/dist/nodes/geometry/line-node.js.map +0 -1
- package/dist/nodes/geometry/viewport-pattern-node.d.ts +0 -39
- package/dist/nodes/geometry/viewport-pattern-node.d.ts.map +0 -1
- package/dist/nodes/geometry/viewport-pattern-node.js +0 -79
- package/dist/nodes/geometry/viewport-pattern-node.js.map +0 -1
- package/dist/nodes/scene/canvas2d-node.d.ts.map +0 -1
- package/dist/nodes/scene/canvas2d-node.js.map +0 -1
- package/dist/nodes/scene/provider-node.d.ts.map +0 -1
- package/dist/nodes/scene/provider-node.js.map +0 -1
- package/dist/nodes/scene/theme-provider-node.d.ts.map +0 -1
- package/dist/nodes/scene/theme-provider-node.js.map +0 -1
- /package/dist/nodes/{scene → root}/provider-node.d.ts +0 -0
- /package/dist/nodes/{scene → root}/provider-node.js +0 -0
- /package/dist/nodes/{scene → root}/theme-provider-node.d.ts +0 -0
- /package/dist/nodes/{scene → root}/theme-provider-node.js +0 -0
package/dist/tween/prepare.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ export declare function prepareNumericTween<T extends object>(target: T, to: Par
|
|
|
20
20
|
* directly to the backing {@link PropSlot}s.
|
|
21
21
|
*
|
|
22
22
|
* Skipping the setter avoids the mapper-lookup and `_writeProp` indirection on
|
|
23
|
-
* every frame step. Only valid for numeric
|
|
24
|
-
* is responsible for resolving the slots
|
|
25
|
-
* values before calling this.
|
|
23
|
+
* every frame step. Only valid for numeric properties whose `end` is already in
|
|
24
|
+
* stored space — the caller is responsible for resolving the slots, mapping the
|
|
25
|
+
* destination and capturing the `from`/`end` values before calling this.
|
|
26
26
|
*
|
|
27
27
|
* - `cells[i]` — the slot for the i-th animated property.
|
|
28
28
|
* - `from[i]` — start value for that property.
|
package/dist/tween/prepare.js
CHANGED
|
@@ -32,9 +32,9 @@ export function prepareNumericTween(target, to) {
|
|
|
32
32
|
* directly to the backing {@link PropSlot}s.
|
|
33
33
|
*
|
|
34
34
|
* Skipping the setter avoids the mapper-lookup and `_writeProp` indirection on
|
|
35
|
-
* every frame step. Only valid for numeric
|
|
36
|
-
* is responsible for resolving the slots
|
|
37
|
-
* values before calling this.
|
|
35
|
+
* every frame step. Only valid for numeric properties whose `end` is already in
|
|
36
|
+
* stored space — the caller is responsible for resolving the slots, mapping the
|
|
37
|
+
* destination and capturing the `from`/`end` values before calling this.
|
|
38
38
|
*
|
|
39
39
|
* - `cells[i]` — the slot for the i-th animated property.
|
|
40
40
|
* - `from[i]` — start value for that property.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/tween/prepare.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,gBAAgB;AAChB,MAAM,UAAU,mBAAmB,CAC/B,MAAS,EACT,EAAoC;IAEpC,MAAM,IAAI,GAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IACjF,MAAM,IAAI,GAAG,IAAI,KAAK,CAAS,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,IAAI,KAAK,CAAS,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,IAAI,CAAC,CAAC,CAAC,GAAI,MAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAW,CAAC;QAC7C,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAW,CAAC;IACnC,CAAC;IACD,OAAO,CAAC,CAAS,EAAE,EAAE;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,MAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChE,CAAC;IACL,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,gBAAgB;AAChB,MAAM,UAAU,uBAAuB,CACnC,KAAyB,EACzB,IAAc,EACd,GAAa;IAEb,OAAO,CAAC,CAAS,EAAE,EAAE;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACpC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACnD,CAAC;IACL,CAAC,CAAC;AACN,CAAC","sourcesContent":["import type { PropSlot } from \"@/props/slot\";\n\n/**\n * Snapshots the current numeric property values on `target` for the keys\n * present in `to`, then returns a lerp callback that writes interpolated values\n * back each frame.\n *\n * The snapshot is taken at call time, so invoke this immediately before the\n * animation starts (not lazily) to capture the correct `from` state.\n *\n * @param target - The object whose properties will be animated.\n * @param to - Desired end values keyed by property name. Keys with\n * `undefined` values are ignored.\n * @returns A function `(t: number) => void` that writes `lerp(from, to, t)`\n * for each key. `t` must already be eased by the caller.\n */\n/** @internal */\nexport function prepareNumericTween<T extends object>(\n target: T,\n to: Partial<Record<keyof T, number>>,\n): (t: number) => void {\n const keys = (Object.keys(to) as (keyof T)[]).filter((k) => to[k] !== undefined);\n const from = new Array<number>(keys.length);\n const end = new Array<number>(keys.length);\n for (let i = 0; i < keys.length; i++) {\n from[i] = (target as any)[keys[i]] as number;\n end[i] = to[keys[i]] as number;\n }\n return (t: number) => {\n for (let i = 0; i < keys.length; i++) {\n (target as any)[keys[i]] = from[i] + (end[i] - from[i]) * t;\n }\n };\n}\n\n/**\n * Like {@link prepareNumericTween}, but bypasses property setters and writes\n * directly to the backing {@link PropSlot}s.\n *\n * Skipping the setter avoids the mapper-lookup and `_writeProp` indirection on\n * every frame step. Only valid for numeric
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/tween/prepare.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,gBAAgB;AAChB,MAAM,UAAU,mBAAmB,CAC/B,MAAS,EACT,EAAoC;IAEpC,MAAM,IAAI,GAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IACjF,MAAM,IAAI,GAAG,IAAI,KAAK,CAAS,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,IAAI,KAAK,CAAS,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,IAAI,CAAC,CAAC,CAAC,GAAI,MAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAW,CAAC;QAC7C,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAW,CAAC;IACnC,CAAC;IACD,OAAO,CAAC,CAAS,EAAE,EAAE;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,MAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChE,CAAC;IACL,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,gBAAgB;AAChB,MAAM,UAAU,uBAAuB,CACnC,KAAyB,EACzB,IAAc,EACd,GAAa;IAEb,OAAO,CAAC,CAAS,EAAE,EAAE;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACpC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACnD,CAAC;IACL,CAAC,CAAC;AACN,CAAC","sourcesContent":["import type { PropSlot } from \"@/props/slot\";\r\n\r\n/**\r\n * Snapshots the current numeric property values on `target` for the keys\r\n * present in `to`, then returns a lerp callback that writes interpolated values\r\n * back each frame.\r\n *\r\n * The snapshot is taken at call time, so invoke this immediately before the\r\n * animation starts (not lazily) to capture the correct `from` state.\r\n *\r\n * @param target - The object whose properties will be animated.\r\n * @param to - Desired end values keyed by property name. Keys with\r\n * `undefined` values are ignored.\r\n * @returns A function `(t: number) => void` that writes `lerp(from, to, t)`\r\n * for each key. `t` must already be eased by the caller.\r\n */\r\n/** @internal */\r\nexport function prepareNumericTween<T extends object>(\r\n target: T,\r\n to: Partial<Record<keyof T, number>>,\r\n): (t: number) => void {\r\n const keys = (Object.keys(to) as (keyof T)[]).filter((k) => to[k] !== undefined);\r\n const from = new Array<number>(keys.length);\r\n const end = new Array<number>(keys.length);\r\n for (let i = 0; i < keys.length; i++) {\r\n from[i] = (target as any)[keys[i]] as number;\r\n end[i] = to[keys[i]] as number;\r\n }\r\n return (t: number) => {\r\n for (let i = 0; i < keys.length; i++) {\r\n (target as any)[keys[i]] = from[i] + (end[i] - from[i]) * t;\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Like {@link prepareNumericTween}, but bypasses property setters and writes\r\n * directly to the backing {@link PropSlot}s.\r\n *\r\n * Skipping the setter avoids the mapper-lookup and `_writeProp` indirection on\r\n * every frame step. Only valid for numeric properties whose `end` is already in\r\n * stored space — the caller is responsible for resolving the slots, mapping the\r\n * destination and capturing the `from`/`end` values before calling this.\r\n *\r\n * - `cells[i]` — the slot for the i-th animated property.\r\n * - `from[i]` — start value for that property.\r\n * - `end[i]` — end value for that property.\r\n *\r\n * The arrays are captured by the returned closure and reused each step, so the\r\n * per-frame cost is one `slot.set(number)` per property with no allocation.\r\n */\r\n/** @internal */\r\nexport function prepareNumericCellTween(\r\n cells: PropSlot<number>[],\r\n from: number[],\r\n end: number[],\r\n): (t: number) => void {\r\n return (t: number) => {\r\n for (let i = 0; i < cells.length; i++) {\r\n cells[i].set(from[i] + (end[i] - from[i]) * t);\r\n }\r\n };\r\n}\r\n"]}
|
package/dist/tween/seekable.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type { Steppable } from "./stepper.js";
|
|
|
14
14
|
* hands back something seekable, so a host can jump straight to a time.
|
|
15
15
|
*
|
|
16
16
|
* Each part writes to **its own node**, which is why this is not
|
|
17
|
-
* `commandSequence
|
|
17
|
+
* `commandSequence`: that composes one node's props by
|
|
18
18
|
* merging `Partial<P>`, and an axis entrance is a dozen nodes moving at once
|
|
19
19
|
* with nothing to merge. Composing steppers instead lets each part write where
|
|
20
20
|
* it already writes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seekable.js","sourceRoot":"","sources":["../../src/tween/seekable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,WAAW,CAAA;AAkCtD,0DAA0D;AAC1D,MAAM,UAAU,EAAE,CAAC,MAAc,EAAE,IAAc;IAC/C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,MAAM,WAAW,GAAG,GAAiB,EAAE;QACrC,IAAI,OAAO,GAAG,CAAC,CAAA;QACf,OAAO;YACL,IAAI,EAAE,CAAC,CAAS,E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QAAQ,EAAE,CAAC,CAAA;QACpD,IAAI,OAAO,GAAG,CAAC,CAAA;QAEf,MAAM,OAAO,GAAG,CAAC,OAAe,EAAQ,EAAE;YACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;gBACjC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;gBACpE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACzB,CAAC;QACH,CAAC,CAAA;QAED,OAAO;YACL,IAAI,EAAE,CAAC,OAAe,EAAE,EAAE;gBACxB,OAAO,GAAG,OAAO,CAAA;gBACjB,OAAO,CAAC,OAAO,CAAC,CAAA;YAClB,CAAC;YACD,OAAO,EAAE,CAAC,EAAU,EAAW,EAAE;gBAC/B,OAAO,IAAI,EAAE,CAAA;gBACb,OAAO,CAAC,OAAO,CAAC,CAAA;gBAChB,OAAO,OAAO,IAAI,QAAQ,CAAA;YAC5B,CAAC;SACF,CAAA;IACH,CAAC,CAAA;IAED,OAAO;QACL,QAAQ;QACR,QAAQ,EAAE,WAAW;KACtB,CAAA;AACH,CAAC","sourcesContent":["import { driveCommand, type Command } from \"./command\"\nimport type { Steppable, TweenStepper } from \"./stepper\"\n\n/**\n * Choreography that can be **asked** what it looks like at a time.\n *\n * A node's entrance is usually a stagger: markers landing one after another, a\n * caption following them, a legend after that. Written as a generator — `yield*\n * parallel(...)` over per-item `wait` + `to` — the offsets exist only while it\n * runs, so the only way to know what it looks like 0.4s in is to run it from\n * zero. That is what makes a chart scene fall back to replay-based scrubbing.\n *\n * The offsets are static, though. Nothing about a stagger needs to be discovered\n * by running it. {@link compose} keeps the same parts at the same offsets and\n * hands back something seekable, so a host can jump straight to a time.\n *\n * Each part writes to **its own node**, which is why this is not\n * `commandSequence` from motion-script: that composes one node's props by\n * merging `Partial<P>`, and an axis entrance is a dozen nodes moving at once\n * with nothing to merge. Composing steppers instead lets each part write where\n * it already writes.\n */\n\n/** Something seekable that knows how long it runs. */\nexport interface Seekable extends Steppable {\n readonly duration: number\n}\n\n/** A part, and how far into the composite it starts. */\nexport interface Placed {\n offset: number\n part: Seekable\n}\n\n/** Sugar for {@link compose}: `at(0.2, node.to(...))`. */\nexport function at(offset: number, part: Seekable): Placed {\n return { offset, part }\n}\n\n/**\n * A part that writes nothing for `seconds` — the seekable `wait`.\n *\n * What the no-op branch of a command returns. A command's duration is the slot\n * the timeline lays out for it and the length its parallel siblings are timed\n * against, so a call that happens to have nothing to do still has to take its\n * time; returning something shorter would pull the rest of the scene forward.\n */\nexport function hold(seconds: number): Seekable {\n const makeStepper = (): TweenStepper => {\n let elapsed = 0\n return {\n seek: (s: number) => {\n elapsed = s\n },\n advance: (dt: number): boolean => {\n elapsed += dt\n return elapsed >= seconds\n },\n }\n }\n\n return {\n duration: seconds,\n _stepper: makeStepper,\n }\n}\n\n/** Run `parts` end to end, each starting where the previous one finished. */\nexport function sequence(...parts: Seekable[]): Seekable {\n let cursor = 0\n return compose(\n parts.map((part) => {\n const placed = at(cursor, part)\n cursor += part.duration\n return placed\n })\n )\n}\n\n/** Run `parts` together, all starting at the composite's own start. */\nexport function together(...parts: Seekable[]): Seekable {\n return compose(parts.map((part) => at(0, part)))\n}\n\n/**\n * A seekable `tween`: calls `apply(t)` with `t` running 0 → 1 over `seconds`.\n *\n * The escape hatch for state a `to` cannot reach — a plain field, an array\n * element, anything that is not one of the node's own reactive props. That is\n * most of what the chart commands were using `tween()` for, and `tween()` is a\n * generator, so it was also most of what kept them un-drivable.\n *\n * `apply` **must be a pure function of `t`**. It is called for any `t`, in any\n * order, more than once for the same value, and — unlike a generator's body — it\n * is not run once per frame in sequence. Accumulating into what it writes (`x +=\n * …`) rather than assigning from `t` is the one way to misuse this, and it will\n * look right playing forwards and drift the moment anything scrubs.\n */\nexport function drive(\n seconds: number,\n apply: (t: number) => void\n): Seekable {\n const at = (elapsed: number): void => {\n apply(seconds > 0 ? Math.min(Math.max(elapsed / seconds, 0), 1) : 1)\n }\n\n const makeStepper = (): TweenStepper => {\n let elapsed = 0\n return {\n seek: (s: number) => {\n elapsed = s\n at(s)\n },\n advance: (dt: number): boolean => {\n elapsed += dt\n at(elapsed)\n return elapsed >= seconds\n },\n }\n }\n\n return {\n duration: seconds,\n _stepper: makeStepper,\n }\n}\n\n/**\n * `part` as the {@link Command} a `@command()` method returns, which is what a\n * document's timeline evaluates: a `Seekable` has no `at`.\n *\n * `duration` is the slot the command was given. A part that ends sooner holds its\n * last frame for the rest of it, and one that runs longer is played faster, so\n * the command's end is always the part's end — the state the next command on the\n * node is built against. The part is prepared here, when the command is built.\n */\nexport function asCommand(\n part: Seekable,\n duration: number = part.duration\n): Command<Record<string, never>> {\n const stepper = part._stepper()\n const span = Math.max(duration, part.duration)\n return driveCommand(duration, (t) => stepper.seek(t * span))\n}\n\n/**\n * Combine placed parts into one seekable whole.\n *\n * Every part is seeked on every evaluation, not just the ones that have started:\n * a part still ahead of the playhead is held at its own zero, which is the state\n * it was prepared against and therefore the state that should precede it.\n * Skipping it would leave whatever a *later* evaluation wrote sitting there when\n * the playhead came back.\n */\nexport function compose(parts: Placed[]): Seekable {\n const duration = parts.reduce(\n (max, p) => Math.max(max, p.offset + p.part.duration),\n 0\n )\n\n const makeStepper = (): TweenStepper => {\n // Prepared once. Preparing is what snapshots each part's `from` off its live\n // node, so doing it per seek would make the answer depend on where the\n // playhead came from rather than on the time asked for.\n const steppers = parts.map((p) => p.part._stepper())\n let elapsed = 0\n\n const applyAt = (seconds: number): void => {\n for (let i = 0; i < parts.length; i++) {\n const { offset, part } = parts[i]\n const local = Math.min(Math.max(seconds - offset, 0), part.duration)\n steppers[i].seek(local)\n }\n }\n\n return {\n seek: (seconds: number) => {\n elapsed = seconds\n applyAt(seconds)\n },\n advance: (dt: number): boolean => {\n elapsed += dt\n applyAt(elapsed)\n return elapsed >= duration\n },\n }\n }\n\n return {\n duration,\n _stepper: makeStepper,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"seekable.js","sourceRoot":"","sources":["../../src/tween/seekable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,WAAW,CAAA;AAkCtD,0DAA0D;AAC1D,MAAM,UAAU,EAAE,CAAC,MAAc,EAAE,IAAc;IAC/C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,MAAM,WAAW,GAAG,GAAiB,EAAE;QACrC,IAAI,OAAO,GAAG,CAAC,CAAA;QACf,OAAO;YACL,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE;gBAClB,OAAO,GAAG,CAAC,CAAA;YACb,CAAC;YACD,OAAO,EAAE,CAAC,EAAU,EAAW,EAAE;gBAC/B,OAAO,IAAI,EAAE,CAAA;gBACb,OAAO,OAAO,IAAI,OAAO,CAAA;YAC3B,CAAC;SACF,CAAA;IACH,CAAC,CAAA;IAED,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,QAAQ,EAAE,WAAW;KACtB,CAAA;AACH,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,QAAQ,CAAC,GAAG,KAAiB;IAC3C,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,OAAO,OAAO,CACZ,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACjB,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAC/B,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAA;QACvB,OAAO,MAAM,CAAA;IACf,CAAC,CAAC,CACH,CAAA;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AA;gBACjB,OAAO,CAAC,OAAO,CAAC,CAAA;YAClB,CAAC;YACD,OAAO,EAAE,CAAC,EAAU,EAAW,EAAE;gBAC/B,OAAO,IAAI,EAAE,CAAA;gBACb,OAAO,CAAC,OAAO,CAAC,CAAA;gBAChB,OAAO,OAAO,IAAI,QAAQ,CAAA;YAC5B,CAAC;SACF,CAAA;IACH,CAAC,CAAA;IAED,OAAO;QACL,QAAQ;QACR,QAAQ,EAAE,WAAW;KACtB,CAAA;AACH,CAAC","sourcesContent":["import { driveCommand, type Command } from \"./command\"\r\nimport type { Steppable, TweenStepper } from \"./stepper\"\r\n\r\n/**\r\n * Choreography that can be **asked** what it looks like at a time.\r\n *\r\n * A node's entrance is usually a stagger: markers landing one after another, a\r\n * caption following them, a legend after that. Written as a generator — `yield*\r\n * parallel(...)` over per-item `wait` + `to` — the offsets exist only while it\r\n * runs, so the only way to know what it looks like 0.4s in is to run it from\r\n * zero. That is what makes a chart scene fall back to replay-based scrubbing.\r\n *\r\n * The offsets are static, though. Nothing about a stagger needs to be discovered\r\n * by running it. {@link compose} keeps the same parts at the same offsets and\r\n * hands back something seekable, so a host can jump straight to a time.\r\n *\r\n * Each part writes to **its own node**, which is why this is not\r\n * `commandSequence`: that composes one node's props by\r\n * merging `Partial<P>`, and an axis entrance is a dozen nodes moving at once\r\n * with nothing to merge. Composing steppers instead lets each part write where\r\n * it already writes.\r\n */\r\n\r\n/** Something seekable that knows how long it runs. */\r\nexport interface Seekable extends Steppable {\r\n readonly duration: number\r\n}\r\n\r\n/** A part, and how far into the composite it starts. */\r\nexport interface Placed {\r\n offset: number\r\n part: Seekable\r\n}\r\n\r\n/** Sugar for {@link compose}: `at(0.2, node.to(...))`. */\r\nexport function at(offset: number, part: Seekable): Placed {\r\n return { offset, part }\r\n}\r\n\r\n/**\r\n * A part that writes nothing for `seconds` — the seekable `wait`.\r\n *\r\n * What the no-op branch of a command returns. A command's duration is the slot\r\n * the timeline lays out for it and the length its parallel siblings are timed\r\n * against, so a call that happens to have nothing to do still has to take its\r\n * time; returning something shorter would pull the rest of the scene forward.\r\n */\r\nexport function hold(seconds: number): Seekable {\r\n const makeStepper = (): TweenStepper => {\r\n let elapsed = 0\r\n return {\r\n seek: (s: number) => {\r\n elapsed = s\r\n },\r\n advance: (dt: number): boolean => {\r\n elapsed += dt\r\n return elapsed >= seconds\r\n },\r\n }\r\n }\r\n\r\n return {\r\n duration: seconds,\r\n _stepper: makeStepper,\r\n }\r\n}\r\n\r\n/** Run `parts` end to end, each starting where the previous one finished. */\r\nexport function sequence(...parts: Seekable[]): Seekable {\r\n let cursor = 0\r\n return compose(\r\n parts.map((part) => {\r\n const placed = at(cursor, part)\r\n cursor += part.duration\r\n return placed\r\n })\r\n )\r\n}\r\n\r\n/** Run `parts` together, all starting at the composite's own start. */\r\nexport function together(...parts: Seekable[]): Seekable {\r\n return compose(parts.map((part) => at(0, part)))\r\n}\r\n\r\n/**\r\n * A seekable `tween`: calls `apply(t)` with `t` running 0 → 1 over `seconds`.\r\n *\r\n * The escape hatch for state a `to` cannot reach — a plain field, an array\r\n * element, anything that is not one of the node's own reactive props. That is\r\n * most of what the chart commands were using `tween()` for, and `tween()` is a\r\n * generator, so it was also most of what kept them un-drivable.\r\n *\r\n * `apply` **must be a pure function of `t`**. It is called for any `t`, in any\r\n * order, more than once for the same value, and — unlike a generator's body — it\r\n * is not run once per frame in sequence. Accumulating into what it writes (`x +=\r\n * …`) rather than assigning from `t` is the one way to misuse this, and it will\r\n * look right playing forwards and drift the moment anything scrubs.\r\n */\r\nexport function drive(\r\n seconds: number,\r\n apply: (t: number) => void\r\n): Seekable {\r\n const at = (elapsed: number): void => {\r\n apply(seconds > 0 ? Math.min(Math.max(elapsed / seconds, 0), 1) : 1)\r\n }\r\n\r\n const makeStepper = (): TweenStepper => {\r\n let elapsed = 0\r\n return {\r\n seek: (s: number) => {\r\n elapsed = s\r\n at(s)\r\n },\r\n advance: (dt: number): boolean => {\r\n elapsed += dt\r\n at(elapsed)\r\n return elapsed >= seconds\r\n },\r\n }\r\n }\r\n\r\n return {\r\n duration: seconds,\r\n _stepper: makeStepper,\r\n }\r\n}\r\n\r\n/**\r\n * `part` as the {@link Command} a `@command()` method returns, which is what a\r\n * document's timeline evaluates: a `Seekable` has no `at`.\r\n *\r\n * `duration` is the slot the command was given. A part that ends sooner holds its\r\n * last frame for the rest of it, and one that runs longer is played faster, so\r\n * the command's end is always the part's end — the state the next command on the\r\n * node is built against. The part is prepared here, when the command is built.\r\n */\r\nexport function asCommand(\r\n part: Seekable,\r\n duration: number = part.duration\r\n): Command<Record<string, never>> {\r\n const stepper = part._stepper()\r\n const span = Math.max(duration, part.duration)\r\n return driveCommand(duration, (t) => stepper.seek(t * span))\r\n}\r\n\r\n/**\r\n * Combine placed parts into one seekable whole.\r\n *\r\n * Every part is seeked on every evaluation, not just the ones that have started:\r\n * a part still ahead of the playhead is held at its own zero, which is the state\r\n * it was prepared against and therefore the state that should precede it.\r\n * Skipping it would leave whatever a *later* evaluation wrote sitting there when\r\n * the playhead came back.\r\n */\r\nexport function compose(parts: Placed[]): Seekable {\r\n const duration = parts.reduce(\r\n (max, p) => Math.max(max, p.offset + p.part.duration),\r\n 0\r\n )\r\n\r\n const makeStepper = (): TweenStepper => {\r\n // Prepared once. Preparing is what snapshots each part's `from` off its live\r\n // node, so doing it per seek would make the answer depend on where the\r\n // playhead came from rather than on the time asked for.\r\n const steppers = parts.map((p) => p.part._stepper())\r\n let elapsed = 0\r\n\r\n const applyAt = (seconds: number): void => {\r\n for (let i = 0; i < parts.length; i++) {\r\n const { offset, part } = parts[i]\r\n const local = Math.min(Math.max(seconds - offset, 0), part.duration)\r\n steppers[i].seek(local)\r\n }\r\n }\r\n\r\n return {\r\n seek: (seconds: number) => {\r\n elapsed = seconds\r\n applyAt(seconds)\r\n },\r\n advance: (dt: number): boolean => {\r\n elapsed += dt\r\n applyAt(elapsed)\r\n return elapsed >= duration\r\n },\r\n }\r\n }\r\n\r\n return {\r\n duration,\r\n _stepper: makeStepper,\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stepper.js","sourceRoot":"","sources":["../../src/tween/stepper.ts"],"names":[],"mappings":"AAmCA,MAAM,UAAU,WAAW,CAAC,CAAU;IAClC,OAAO,OAAQ,CAAe,EAAE,QAAQ,KAAK,UAAU,CAAC;AAC5D,CAAC","sourcesContent":["/**\n * A flat animation driver. `advance(dt)` moves the animation forward by `dt`\n * seconds and returns `true` once it has completed (and applied its final\n * value). It must be primed at t=0 before the first `advance` so the starting\n * frame is correct — callers apply the initial value via `seek(0)`.\n *\n * `seek(elapsed)` is the absolute-time half, and is what a {@link Command}'s\n * `at` is built on: a stepper can be asked for any time, in any order, which is\n * what lets a timeline evaluate a frame without having played the ones before\n * it.\n */\n/** @internal */\nexport interface TweenStepper {\n /**\n * Jump to the value corresponding to `elapsed` seconds from the start.\n * Call with `0` to prime the stepper before the first {@link advance}.\n */\n seek(elapsed: number): void;\n /**\n * Advance the animation by `dt` seconds.\n * @returns `true` when the animation has finished and its final value has\n * been applied; `false` if it is still running.\n */\n advance(dt: number): boolean;\n}\n\n/**\n * Implemented by anything that can produce a {@link TweenStepper} — a\n * {@link Command}, and anything a host drives directly.\n */\nexport interface Steppable {\n /** Return a fresh stepper for a single playthrough of this animation. */\n _stepper(): TweenStepper;\n}\n\nexport function isSteppable(x: unknown): x is Steppable {\n return typeof (x as Steppable)?._stepper === \"function\";\n}\n"]}
|
|
1
|
+
{"version":3,"file":"stepper.js","sourceRoot":"","sources":["../../src/tween/stepper.ts"],"names":[],"mappings":"AAmCA,MAAM,UAAU,WAAW,CAAC,CAAU;IAClC,OAAO,OAAQ,CAAe,EAAE,QAAQ,KAAK,UAAU,CAAC;AAC5D,CAAC","sourcesContent":["/**\r\n * A flat animation driver. `advance(dt)` moves the animation forward by `dt`\r\n * seconds and returns `true` once it has completed (and applied its final\r\n * value). It must be primed at t=0 before the first `advance` so the starting\r\n * frame is correct — callers apply the initial value via `seek(0)`.\r\n *\r\n * `seek(elapsed)` is the absolute-time half, and is what a {@link Command}'s\r\n * `at` is built on: a stepper can be asked for any time, in any order, which is\r\n * what lets a timeline evaluate a frame without having played the ones before\r\n * it.\r\n */\r\n/** @internal */\r\nexport interface TweenStepper {\r\n /**\r\n * Jump to the value corresponding to `elapsed` seconds from the start.\r\n * Call with `0` to prime the stepper before the first {@link advance}.\r\n */\r\n seek(elapsed: number): void;\r\n /**\r\n * Advance the animation by `dt` seconds.\r\n * @returns `true` when the animation has finished and its final value has\r\n * been applied; `false` if it is still running.\r\n */\r\n advance(dt: number): boolean;\r\n}\r\n\r\n/**\r\n * Implemented by anything that can produce a {@link TweenStepper} — a\r\n * {@link Command}, and anything a host drives directly.\r\n */\r\nexport interface Steppable {\r\n /** Return a fresh stepper for a single playthrough of this animation. */\r\n _stepper(): TweenStepper;\r\n}\r\n\r\nexport function isSteppable(x: unknown): x is Steppable {\r\n return typeof (x as Steppable)?._stepper === \"function\";\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-command.js","sourceRoot":"","sources":["../../src/tween/to-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAgBvC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,SAAS;IAIU;IACA;IACR;IACQ;IANb,UAAU,GAAwB,IAAI,CAAC;IAE/C,YACqB,MAA0B,EAC1B,KAAiB,EACzB,QAAgB,EACR,MAAuB;QAHvB,WAAM,GAAN,MAAM,CAAoB;QAC1B,UAAK,GAAL,KAAK,CAAY;QACzB,aAAQ,GAAR,QAAQ,CAAQ;QACR,WAAM,GAAN,MAAM,CAAiB;IACxC,CAAC;IAEL;;;;;;OAMG;IACH,EAAE,CAAC,CAAS;QACR,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QACvD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,OAAO,EAAE,CAAC;IACd,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IAEO,OAAO;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACJ;AAED,wDAAwD;AACxD,MAAM,UAAU,SAAS,CACrB,MAA0B,EAC1B,KAAiB,EACjB,QAAgB,EAChB,MAAuB;IAEvB,OAAO,IAAI,SAAS,CAAI,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { clamp01 } from \"@/util/clamp\";\nimport { EasingFunction } from \"@/tween/ease/type\";\nimport { Steppable, TweenStepper } from \"@/tween/stepper\";\nimport { Command } from \"./command\";\n\n/**\n * Interface a node (or other host) implements to be driven by {@link toCommand}.\n *\n * `_prepareStep` resolves one tween into a flat, mutation-driving\n * {@link TweenStepper} — the same primitive both the flat `parallel` fast path\n * and the command's own evaluation are built from.\n */\nexport interface AnimationTarget<P> {\n _prepareStep(props: Partial<P>, duration: number, easing?: EasingFunction): TweenStepper;\n}\n\n/**\n * The {@link Command} `node.to(...)` returns: one tween on one target, and\n * nothing else.\n *\n * **Single, not chainable.** `to()` used to return a builder whose own `to()`\n * appended another step and returned `this`, so `node.to(a, 1).to(b, 1)` read as\n * a sequence. Sequencing is now a property of the timeline — a command carries\n * its own `at`, so \"after this one\" is `at + duration` — and one command shape\n * means a host reading a `Command` off a node knows exactly what it holds.\n *\n * Implements {@link Command} (a host can ask what it looks like at a time) and\n * {@link Steppable} (the flat driver).\n *\n * `at` and `_stepper` each keep their **own** prepared stepper: preparing is\n * what snapshots the tween's `from` (it reads the live target), so two drivers\n * must never fight over one mutable stepper.\n */\nclass ToCommand<P> implements Command<P>, Steppable {\n private atPrepared: TweenStepper | null = null;\n\n constructor(\n private readonly target: AnimationTarget<P>,\n private readonly props: Partial<P>,\n readonly duration: number,\n private readonly easing?: EasingFunction,\n ) { }\n\n /**\n * The props this command writes at normalized `t`. Applied as a side effect\n * (direct cell writes through the prepared stepper, exactly like\n * `driveCommand`) rather than returned — a tween may carry a custom tween\n * function or a mapped prop, and only the target's own `_prepareStep` knows\n * how to apply those correctly.\n */\n at(t: number): Partial<P> {\n if (!this.atPrepared) this.atPrepared = this.prepare();\n this.atPrepared.seek(clamp01(t) * this.duration);\n return {};\n }\n\n _stepper(): TweenStepper {\n return this.prepare();\n }\n\n private prepare(): TweenStepper {\n return this.target._prepareStep(this.props, this.duration, this.easing);\n }\n}\n\n/** Build the {@link Command} `node.to(...)` returns. */\nexport function toCommand<P>(\n target: AnimationTarget<P>,\n props: Partial<P>,\n duration: number,\n easing?: EasingFunction,\n): Command<P> {\n return new ToCommand<P>(target, props, duration, easing);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"to-command.js","sourceRoot":"","sources":["../../src/tween/to-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAgBvC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,SAAS;IAIU;IACA;IACR;IACQ;IANb,UAAU,GAAwB,IAAI,CAAC;IAE/C,YACqB,MAA0B,EAC1B,KAAiB,EACzB,QAAgB,EACR,MAAuB;QAHvB,WAAM,GAAN,MAAM,CAAoB;QAC1B,UAAK,GAAL,KAAK,CAAY;QACzB,aAAQ,GAAR,QAAQ,CAAQ;QACR,WAAM,GAAN,MAAM,CAAiB;IACxC,CAAC;IAEL;;;;;;OAMG;IACH,EAAE,CAAC,CAAS;QACR,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QACvD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjD,OAAO,EAAE,CAAC;IACd,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IAEO,OAAO;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACJ;AAED,wDAAwD;AACxD,MAAM,UAAU,SAAS,CACrB,MAA0B,EAC1B,KAAiB,EACjB,QAAgB,EAChB,MAAuB;IAEvB,OAAO,IAAI,SAAS,CAAI,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { clamp01 } from \"@/util/clamp\";\r\nimport { EasingFunction } from \"@/tween/ease/type\";\r\nimport { Steppable, TweenStepper } from \"@/tween/stepper\";\r\nimport { Command } from \"./command\";\r\n\r\n/**\r\n * Interface a node (or other host) implements to be driven by {@link toCommand}.\r\n *\r\n * `_prepareStep` resolves one tween into a flat, mutation-driving\r\n * {@link TweenStepper} — the same primitive both the flat `parallel` fast path\r\n * and the command's own evaluation are built from.\r\n */\r\nexport interface AnimationTarget<P> {\r\n _prepareStep(props: Partial<P>, duration: number, easing?: EasingFunction): TweenStepper;\r\n}\r\n\r\n/**\r\n * The {@link Command} `node.to(...)` returns: one tween on one target, and\r\n * nothing else.\r\n *\r\n * **Single, not chainable.** `to()` used to return a builder whose own `to()`\r\n * appended another step and returned `this`, so `node.to(a, 1).to(b, 1)` read as\r\n * a sequence. Sequencing is now a property of the timeline — a command carries\r\n * its own `at`, so \"after this one\" is `at + duration` — and one command shape\r\n * means a host reading a `Command` off a node knows exactly what it holds.\r\n *\r\n * Implements {@link Command} (a host can ask what it looks like at a time) and\r\n * {@link Steppable} (the flat driver).\r\n *\r\n * `at` and `_stepper` each keep their **own** prepared stepper: preparing is\r\n * what snapshots the tween's `from` (it reads the live target), so two drivers\r\n * must never fight over one mutable stepper.\r\n */\r\nclass ToCommand<P> implements Command<P>, Steppable {\r\n private atPrepared: TweenStepper | null = null;\r\n\r\n constructor(\r\n private readonly target: AnimationTarget<P>,\r\n private readonly props: Partial<P>,\r\n readonly duration: number,\r\n private readonly easing?: EasingFunction,\r\n ) { }\r\n\r\n /**\r\n * The props this command writes at normalized `t`. Applied as a side effect\r\n * (direct cell writes through the prepared stepper, exactly like\r\n * `driveCommand`) rather than returned — a tween may carry a custom tween\r\n * function or a mapped prop, and only the target's own `_prepareStep` knows\r\n * how to apply those correctly.\r\n */\r\n at(t: number): Partial<P> {\r\n if (!this.atPrepared) this.atPrepared = this.prepare();\r\n this.atPrepared.seek(clamp01(t) * this.duration);\r\n return {};\r\n }\r\n\r\n _stepper(): TweenStepper {\r\n return this.prepare();\r\n }\r\n\r\n private prepare(): TweenStepper {\r\n return this.target._prepareStep(this.props, this.duration, this.easing);\r\n }\r\n}\r\n\r\n/** Build the {@link Command} `node.to(...)` returns. */\r\nexport function toCommand<P>(\r\n target: AnimationTarget<P>,\r\n props: Partial<P>,\r\n duration: number,\r\n easing?: EasingFunction,\r\n): Command<P> {\r\n return new ToCommand<P>(target, props, duration, easing);\r\n}\r\n"]}
|
package/dist/util/clamp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../src/util/clamp.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,EAAU,EAAE;IACvE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,iFAAiF;AACjF,MAAM,UAAU,OAAO,CAAC,CAAS;IAC7B,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["/**\n * Clamps a number between a minimum and maximum value.\n *\n * @param value - The number to clamp.\n * @param min - The lower bound.\n * @param max - The upper bound.\n * @returns The clamped number.\n */\nexport const clamp = (value: number, min: number, max: number): number => {\n return Math.max(min, Math.min(value, max));\n};\n\n/** Shorthand for `clamp(t, 0, 1)`, commonly used to normalize tween progress. */\nexport function clamp01(t: number) {\n return clamp(t, 0, 1);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../src/util/clamp.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,EAAU,EAAE;IACvE,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,iFAAiF;AACjF,MAAM,UAAU,OAAO,CAAC,CAAS;IAC7B,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["/**\r\n * Clamps a number between a minimum and maximum value.\r\n *\r\n * @param value - The number to clamp.\r\n * @param min - The lower bound.\r\n * @param max - The upper bound.\r\n * @returns The clamped number.\r\n */\r\nexport const clamp = (value: number, min: number, max: number): number => {\r\n return Math.max(min, Math.min(value, max));\r\n};\r\n\r\n/** Shorthand for `clamp(t, 0, 1)`, commonly used to normalize tween progress. */\r\nexport function clamp01(t: number) {\r\n return clamp(t, 0, 1);\r\n}\r\n"]}
|
package/dist/util/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/util/context.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAI,YAAe,EAAE,IAAa;IAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,IAAI,IAAI,SAAS,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACkB;IAArC,YAAqC,OAAqC;QAArC,YAAO,GAAP,OAAO,CAA8B;IAAI,CAAC;IAE/E,+DAA+D;IAC/D,MAAM,CAAU,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IAElD,4EAA4E;IAC5E,IAAI,CAAI,GAAe,EAAE,KAAQ;QAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACxB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,qEAAqE;IACrE,GAAG,CAAI,GAAe;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAO,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC;IACzF,CAAC","sourcesContent":["/**\n * Typed context tokens for passing inherited data down the node tree —\n * analogous to React's `createContext` / `useContext`, but resolved over the\n * scene-node tree rather than a render tree.\n *\n * A {@link Context} is an opaque token carrying a phantom type `T` and a\n * default value. Providers attach a value for a token to the {@link ContextMap}\n * pushed to their descendants; a descendant reads the nearest ancestor's value\n * (or the token's default) via `node.useContext(token)`.\n *\n * Mirrors the {@link createRef} factory style: a small typed helper rather than\n * a class the author has to instantiate.\n */\nexport interface Context<T> {\n /** Identity used as the map key. Unique per `createContext` call. */\n readonly id: symbol;\n /** Value returned by `useContext` when no ancestor provides this token. */\n readonly defaultValue: T;\n /** Optional label, surfaced on the symbol for debugging. */\n readonly name?: string;\n}\n\n/**\n * Create a typed context token.\n *\n * @example\n * ```ts\n * const Money = createContext<number>(0, \"money\");\n * // provide: <Provider context={Money} value={500}>…</Provider>\n * // consume: init() { const m = this.useContext(Money); } // m: number\n * ```\n */\nexport function createContext<T>(defaultValue: T, name?: string): Context<T> {\n return { id: Symbol(name ?? \"context\"), defaultValue, name };\n}\n\n/**\n * An immutable, layered token→value map carried down the node tree. Each\n * provider derives a child map from its parent's via {@link with}, overriding a\n * single token — so a deeper provider naturally shadows a shallower one\n * (nearest-ancestor-wins) without any stack bookkeeping.\n */\nexport class ContextMap {\n private constructor(private readonly entries: ReadonlyMap<symbol, unknown>) { }\n\n /** The empty map — every token resolves to its own default. */\n static readonly EMPTY = new ContextMap(new Map());\n\n /** Return a new map identical to this one but with `ctx` set to `value`. */\n with<T>(ctx: Context<T>, value: T): ContextMap {\n const next = new Map(this.entries);\n next.set(ctx.id, value);\n return new ContextMap(next);\n }\n\n /** Resolve `ctx`'s value, falling back to its default when unset. */\n get<T>(ctx: Context<T>): T {\n return this.entries.has(ctx.id) ? (this.entries.get(ctx.id) as T) : ctx.defaultValue;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/util/context.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAI,YAAe,EAAE,IAAa;IAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,IAAI,IAAI,SAAS,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACkB;IAArC,YAAqC,OAAqC;QAArC,YAAO,GAAP,OAAO,CAA8B;IAAI,CAAC;IAE/E,+DAA+D;IAC/D,MAAM,CAAU,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;IAElD,4EAA4E;IAC5E,IAAI,CAAI,GAAe,EAAE,KAAQ;QAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACxB,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,qEAAqE;IACrE,GAAG,CAAI,GAAe;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAO,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC;IACzF,CAAC","sourcesContent":["/**\r\n * Typed context tokens for passing inherited data down the node tree —\r\n * analogous to React's `createContext` / `useContext`, but resolved over the\r\n * scene-node tree rather than a render tree.\r\n *\r\n * A {@link Context} is an opaque token carrying a phantom type `T` and a\r\n * default value. Providers attach a value for a token to the {@link ContextMap}\r\n * pushed to their descendants; a descendant reads the nearest ancestor's value\r\n * (or the token's default) via `node.useContext(token)`.\r\n *\r\n * Mirrors the {@link createRef} factory style: a small typed helper rather than\r\n * a class the author has to instantiate.\r\n */\r\nexport interface Context<T> {\r\n /** Identity used as the map key. Unique per `createContext` call. */\r\n readonly id: symbol;\r\n /** Value returned by `useContext` when no ancestor provides this token. */\r\n readonly defaultValue: T;\r\n /** Optional label, surfaced on the symbol for debugging. */\r\n readonly name?: string;\r\n}\r\n\r\n/**\r\n * Create a typed context token.\r\n *\r\n * @example\r\n * ```ts\r\n * const Money = createContext<number>(0, \"money\");\r\n * // provide: <Provider context={Money} value={500}>…</Provider>\r\n * // consume: init() { const m = this.useContext(Money); } // m: number\r\n * ```\r\n */\r\nexport function createContext<T>(defaultValue: T, name?: string): Context<T> {\r\n return { id: Symbol(name ?? \"context\"), defaultValue, name };\r\n}\r\n\r\n/**\r\n * An immutable, layered token→value map carried down the node tree. Each\r\n * provider derives a child map from its parent's via {@link with}, overriding a\r\n * single token — so a deeper provider naturally shadows a shallower one\r\n * (nearest-ancestor-wins) without any stack bookkeeping.\r\n */\r\nexport class ContextMap {\r\n private constructor(private readonly entries: ReadonlyMap<symbol, unknown>) { }\r\n\r\n /** The empty map — every token resolves to its own default. */\r\n static readonly EMPTY = new ContextMap(new Map());\r\n\r\n /** Return a new map identical to this one but with `ctx` set to `value`. */\r\n with<T>(ctx: Context<T>, value: T): ContextMap {\r\n const next = new Map(this.entries);\r\n next.set(ctx.id, value);\r\n return new ContextMap(next);\r\n }\r\n\r\n /** Resolve `ctx`'s value, falling back to its default when unset. */\r\n get<T>(ctx: Context<T>): T {\r\n return this.entries.has(ctx.id) ? (this.entries.get(ctx.id) as T) : ctx.defaultValue;\r\n }\r\n}\r\n"]}
|
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,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,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,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":"AA0BA;;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,CAAC","sourcesContent":["/** One parsed data record: column name → cell value (string, or number/boolean\r\n * when the column auto-coerces — see {@link ParseCSVOptions.numeric} and\r\n * {@link ParseCSVOptions.boolean}). */\r\nexport type DataRecord = Record<string, string | number | boolean>;\r\n\r\nexport interface ParseCSVOptions {\r\n /** Field separator. Default: ','. */\r\n delimiter?: string;\r\n /**\r\n * Which columns to coerce to `number`. An explicit list forces just those\r\n * columns; `false` disables coercion entirely (every cell stays a string).\r\n * Default (omitted/`true`): auto-detect — a column becomes numeric only if\r\n * every non-empty cell in it parses as a finite number, so a text column\r\n * that happens to contain a numeric-looking value here and there is left\r\n * alone rather than partially coerced.\r\n */\r\n numeric?: string[] | boolean;\r\n /**\r\n * Which columns to coerce to `boolean`, same shape/semantics as\r\n * {@link numeric}. Default (omitted/`true`): auto-detect — a column\r\n * becomes boolean only if every non-empty cell is exactly `\"true\"` or\r\n * `\"false\"`. Never applied to a column already coerced to numeric.\r\n */\r\n boolean?: string[] | boolean;\r\n}\r\n\r\n/**\r\n * Parse CSV text into an array of row records keyed by the header row.\r\n * Handles quoted fields (embedded delimiters, newlines, and `\"\"` escapes) and\r\n * both CRLF/LF line endings. Synchronous and dependency-free, so it's safe to\r\n * call at module-eval time on text pulled in via a `?raw` import.\r\n */\r\nexport function parseCSV(text: string, options: ParseCSVOptions = {}): DataRecord[] {\r\n const delimiter = options.delimiter ?? ',';\r\n const rows = splitRows(text, delimiter);\r\n if (rows.length === 0) return [];\r\n\r\n const header = rows[0].map(cell => cell.trim());\r\n const body = rows.slice(1);\r\n\r\n const records: Record<string, string>[] = body.map(row => {\r\n const record: Record<string, string> = {};\r\n header.forEach((key, i) => { record[key] = row[i] ?? ''; });\r\n return record;\r\n });\r\n\r\n const numericCols = resolveNumericColumns(header, records, options.numeric);\r\n const booleanCols = resolveBooleanColumns(header, records, numericCols, options.boolean);\r\n if (numericCols.length === 0 && booleanCols.length === 0) return records;\r\n\r\n return records.map(record => {\r\n const out: DataRecord = { ...record };\r\n for (const col of numericCols) {\r\n const raw = record[col];\r\n if (raw === '') continue;\r\n out[col] = Number(raw);\r\n }\r\n for (const col of booleanCols) {\r\n const raw = record[col];\r\n if (raw === '') continue;\r\n out[col] = raw === 'true';\r\n }\r\n return out;\r\n });\r\n}\r\n\r\n/**\r\n * `parseData` only ever runs as an inlined literal — the\r\n * `@motionscript/vite-plugin` build-time macro replaces\r\n * `parseData(\"file.csv\")` call sites with the already-parsed rows before this\r\n * body ever executes. This implementation exists purely so the call\r\n * type-checks and so an unresolved call site (missing plugin, or a\r\n * non-literal argument the macro couldn't statically inline) fails loudly\r\n * instead of silently returning nothing.\r\n */\r\nexport function parseData(file: string, _options?: ParseCSVOptions): DataRecord[] {\r\n throw new Error(\r\n `parseData(\"${file}\") must be called with a static string literal so the ` +\r\n `@motionscript/vite-plugin macro can inline it at build time. If you're seeing ` +\r\n `this error at runtime, either the plugin isn't installed/registered, or this ` +\r\n `call's argument isn't a plain string literal.`\r\n );\r\n}\r\n\r\n/** Decide which columns to coerce, per {@link ParseCSVOptions.numeric}. */\r\nfunction resolveNumericColumns(\r\n header: string[],\r\n records: Record<string, string>[],\r\n numeric: string[] | boolean | undefined,\r\n): string[] {\r\n if (numeric === false) return [];\r\n if (Array.isArray(numeric)) return numeric;\r\n\r\n return header.filter(col => {\r\n let sawValue = false;\r\n for (const record of records) {\r\n const raw = record[col];\r\n if (raw === '') continue;\r\n if (!Number.isFinite(Number(raw))) return false;\r\n sawValue = true;\r\n }\r\n return sawValue;\r\n });\r\n}\r\n\r\n/** Decide which columns to coerce, per {@link ParseCSVOptions.boolean}. */\r\nfunction resolveBooleanColumns(\r\n header: string[],\r\n records: Record<string, string>[],\r\n numericCols: string[],\r\n bool: string[] | boolean | undefined,\r\n): string[] {\r\n if (bool === false) return [];\r\n if (Array.isArray(bool)) return bool;\r\n\r\n const numericSet = new Set(numericCols);\r\n return header.filter(col => {\r\n if (numericSet.has(col)) return false;\r\n let sawValue = false;\r\n for (const record of records) {\r\n const raw = record[col];\r\n if (raw === '') continue;\r\n if (raw !== 'true' && raw !== 'false') return false;\r\n sawValue = true;\r\n }\r\n return sawValue;\r\n });\r\n}\r\n\r\n/**\r\n * Split raw CSV text into rows of raw (unquoted) string cells. A minimal\r\n * hand-rolled scanner rather than a `split(',')`/`split('\\n')` pair so quoted\r\n * fields can safely contain the delimiter, newlines, and escaped (`\"\"`) quotes.\r\n */\r\nfunction splitRows(text: string, delimiter: string): string[][] {\r\n const rows: string[][] = [];\r\n let row: string[] = [];\r\n let field = '';\r\n let inQuotes = false;\r\n let sawAnyField = false;\r\n\r\n const pushField = () => { row.push(field); field = ''; };\r\n const pushRow = () => { pushField(); rows.push(row); row = []; sawAnyField = false; };\r\n\r\n for (let i = 0; i < text.length; i++) {\r\n const ch = text[i];\r\n\r\n if (inQuotes) {\r\n if (ch === '\"') {\r\n if (text[i + 1] === '\"') { field += '\"'; i++; }\r\n else inQuotes = false;\r\n } else {\r\n field += ch;\r\n }\r\n continue;\r\n }\r\n\r\n if (ch === '\"') { inQuotes = true; sawAnyField = true; continue; }\r\n if (ch === delimiter) { sawAnyField = true; pushField(); continue; }\r\n if (ch === '\\r') continue;\r\n if (ch === '\\n') { if (sawAnyField || field) pushRow(); continue; }\r\n field += ch;\r\n sawAnyField = true;\r\n }\r\n // Flush a final row left over when the text has no trailing newline.\r\n if (sawAnyField || field) pushRow();\r\n\r\n return rows;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateList.js","sourceRoot":"","sources":["../../src/util/generateList.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,CAAS,EAAE,SAA+B,EAAO,EAAE;IACjF,gFAAgF;IAChF,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * Generates an array of size `n` populated by a generator function.\n * Mirrored after Dart's List.generate.\n */\nexport const generateList = <T>(n: number, generator: (index: number) => T): T[] => {\n // Use a traditional loop for maximum performance inside animation/render cycles\n const result = new Array(n);\n for (let i = 0; i < n; i++) {\n result[i] = generator(i);\n }\n return result;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"generateList.js","sourceRoot":"","sources":["../../src/util/generateList.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,CAAS,EAAE,SAA+B,EAAO,EAAE;IACjF,gFAAgF;IAChF,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\r\n * Generates an array of size `n` populated by a generator function.\r\n * Mirrored after Dart's List.generate.\r\n */\r\nexport const generateList = <T>(n: number, generator: (index: number) => T): T[] => {\r\n // Use a traditional loop for maximum performance inside animation/render cycles\r\n const result = new Array(n);\r\n for (let i = 0; i < n; i++) {\r\n result[i] = generator(i);\r\n }\r\n return result;\r\n};\r\n"]}
|
package/dist/util/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA","sourcesContent":["export * from './clamp'\nexport * from './context'\nexport * from './csv'\nexport * from './generateList'\nexport * from './metrics'\nexport * from './reference'\nexport * from './scheduler'\nexport { Random, SeedGenerator } from './random'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA","sourcesContent":["export * from './clamp'\r\nexport * from './context'\r\nexport * from './csv'\r\nexport * from './generateList'\r\nexport * from './metrics'\r\nexport * from './reference'\r\nexport * from './scheduler'\r\nexport { Random, SeedGenerator } from './random'\r\n"]}
|
package/dist/util/metrics.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function niceStep(raw: number): number;
|
|
|
17
17
|
* marker's* slide, and then added the stagger between them and a full-length
|
|
18
18
|
* caption move on the end — so `enter(0.8)` on a five-marker axis actually took
|
|
19
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:
|
|
20
|
+
* beats are whatever they turn out to be. It is not fine here: an editor lays a
|
|
21
21
|
* command out on the timeline at the duration it declares, times its parallel
|
|
22
22
|
* siblings against it, and sums those durations into the scene's length. A
|
|
23
23
|
* generator that overruns is a command that renders in the wrong place.
|
package/dist/util/metrics.js
CHANGED
|
@@ -24,7 +24,7 @@ export function niceStep(raw) {
|
|
|
24
24
|
* marker's* slide, and then added the stagger between them and a full-length
|
|
25
25
|
* caption move on the end — so `enter(0.8)` on a five-marker axis actually took
|
|
26
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:
|
|
27
|
+
* beats are whatever they turn out to be. It is not fine here: an editor lays a
|
|
28
28
|
* command out on the timeline at the duration it declares, times its parallel
|
|
29
29
|
* siblings against it, and sums those durations into the scene's length. A
|
|
30
30
|
* generator that overruns is a command that renders in the wrong place.
|
package/dist/util/metrics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/util/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,+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;;;;;;;;;;;;;;;;GAgBG;AACH,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":["/**\n * Two numbers a component ends up needing, neither of which belongs to any one\n * of them.\n *\n * Both were written for the chart family and are used well outside it — a\n * graph's plane rounds its ticks with one, a diagram divides its entrance with\n * the other. Leaving them there would make a package with nothing to do with\n * charts depend on charts for a page of arithmetic.\n */\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/**\n * How an axis's staggered entrance is divided up, so the whole thing fits inside\n * `duration` instead of running past it.\n *\n * The standalone components this family was ported from read `duration` as *one\n * marker's* slide, and then added the stagger between them and a full-length\n * caption move on the end — so `enter(0.8)` on a five-marker axis actually took\n * about 2.2 seconds. That's fine when a scene is a hand-written script whose\n * beats are whatever they turn out to be. It is not fine here:
|
|
1
|
+
{"version":3,"file":"metrics.js","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I,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":["/**\r\n * Two numbers a component ends up needing, neither of which belongs to any one\r\n * of them.\r\n *\r\n * Both were written for the chart family and are used well outside it — a\r\n * graph's plane rounds its ticks with one, a diagram divides its entrance with\r\n * the other. Leaving them there would make a package with nothing to do with\r\n * charts depend on charts for a page of arithmetic.\r\n */\r\n\r\n/** Round a raw step up to a tidy value (1/2/5 × 10ⁿ) so markers land round. */\r\nexport function niceStep(raw: number): number {\r\n if (raw <= 0) return 1\r\n const mag = Math.pow(10, Math.floor(Math.log10(raw)))\r\n const norm = raw / mag\r\n const nice = norm <= 1 ? 1 : norm <= 2 ? 2 : norm <= 5 ? 5 : 10\r\n return nice * mag\r\n}\r\n\r\n/**\r\n * How an axis's staggered entrance is divided up, so the whole thing fits inside\r\n * `duration` instead of running past it.\r\n *\r\n * The standalone components this family was ported from read `duration` as *one\r\n * marker's* slide, and then added the stagger between them and a full-length\r\n * caption move on the end — so `enter(0.8)` on a five-marker axis actually took\r\n * about 2.2 seconds. That's fine when a scene is a hand-written script whose\r\n * beats are whatever they turn out to be. It is not fine here: an editor lays a\r\n * command out on the timeline at the duration it declares, times its parallel\r\n * siblings against it, and sums those durations into the scene's length. A\r\n * generator that overruns is a command that renders in the wrong place.\r\n *\r\n * So the budget runs the other way: the caption takes a fixed share off the top,\r\n * and the markers' per-move duration is solved for from what's left, given the\r\n * stagger. Same shape of animation, honest arithmetic.\r\n */\r\nexport function enterBudget(\r\n duration: number,\r\n count: number,\r\n hasCaption: boolean,\r\n /** An explicit gap between markers; derived from `duration` when omitted. */\r\n stagger?: number\r\n): { step: number; per: number; caption: number } {\r\n // The caption lands *after* the last marker, so it needs its own slice.\r\n const caption = hasCaption ? duration * 0.3 : 0\r\n const markers = Math.max(0, duration - caption)\r\n const gaps = Math.max(0, count - 1)\r\n\r\n if (stagger !== undefined) {\r\n // An explicit gap wins; the per-marker move takes whatever is left, and\r\n // can't go negative on an axis with more markers than budget.\r\n return {\r\n step: stagger,\r\n per: Math.max(0, markers - stagger * gaps),\r\n caption,\r\n }\r\n }\r\n // Default rhythm: each gap is a fifth of a marker's own move, which is the\r\n // ratio the original used — solved for here rather than assumed.\r\n const per = markers / (1 + gaps / 5)\r\n return { step: per / 5, per, caption }\r\n}\r\n"]}
|
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;IACH,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,sDAAsD;IACtD,IAAI;QACA,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,UAAU,G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AS,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;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAwB,IAAI,CAAC,KAAK;QACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACK,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":["/**\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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,CAAC,GAAG,KAAK,CAAC;IAClC,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAwB,IAAI,CAAC,KAAK;QACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACK,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":["/**\r\n * Deterministic pseudo-random number generator based on the mulberry32 algorithm.\r\n * Produces the same sequence for the same seed, making animations reproducible.\r\n *\r\n * This is the low-level engine. Scene authors use the higher-level {@link Random}\r\n * facade (handed out by `stage.random(seed)`), which wraps a `SeedGenerator` and\r\n * adds typed draws (`nextFloat`/`nextInt`/`gauss`/arrays) plus seeded `noise`.\r\n */\r\nexport class SeedGenerator {\r\n private state: number = 0;\r\n\r\n constructor(seed: string | number) {\r\n this.setSeed(seed);\r\n }\r\n\r\n /**\r\n * Resets the generator to a new seed.\r\n * String seeds are hashed via djb2 into a 32-bit integer.\r\n */\r\n setSeed(seed: string | number) {\r\n this.state = typeof seed === 'string'\r\n ? seed.split('').reduce((a, b) => { a = ((a << 5) - a) + b.charCodeAt(0); return a & a; }, 0)\r\n : seed;\r\n }\r\n\r\n /** Returns the next pseudo-random float in [0, 1). */\r\n next() {\r\n this.state |= 0; this.state = this.state + 0x6D2B79F5 | 0;\r\n var t = Math.imul(this.state ^ this.state >>> 15, 1 | this.state);\r\n t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;\r\n return ((t ^ t >>> 14) >>> 0) / 4294967296;\r\n }\r\n}\r\n\r\n/** Upper bound of {@link Random.nextInt} / {@link Random.intArray} (2^32). */\r\nconst UINT32_RANGE = 4294967296;\r\n\r\n/**\r\n * A seeded random source handed to scene generators by `stage.random(seed)`.\r\n *\r\n * Wraps a {@link SeedGenerator} (mulberry32) and exposes the author-facing draw\r\n * surface. Because the seed lives on the `Random` instance, determinism is\r\n * scoped per source: two scenes can each `stage.random(\"name\")` and get their\r\n * own reproducible stream without touching a shared stage-level seed.\r\n *\r\n * const random = stage.random(\"sparkle\");\r\n * const xs = random.floatArray(40, -100, 100); // 40 reproducible offsets\r\n * const drift = random.noise(t, 6); // smooth field over time\r\n *\r\n * Two families live here, and they are NOT interchangeable:\r\n * - **Independent draws** — `nextFloat`/`nextInt`/`gauss` and their array\r\n * forms. Successive calls are uncorrelated; `gauss` only changes the\r\n * *distribution* (bell curve vs flat), not the independence.\r\n * - **Correlated field** — `noise(t)`. Nearby inputs return nearby values, so\r\n * it is the right tool for smooth motion over time/space (drift, shake,\r\n * waves). No distribution draw can reproduce that smoothness.\r\n */\r\nexport class Random {\r\n /** The seed this source rewinds to; reassign via {@link seed} or\r\n * {@link reset}. Set by {@link adopt} (definitely assigned via the\r\n * constructor's `adopt` call). */\r\n private _seed!: string | number;\r\n\r\n /** Numeric form of {@link _seed}, used to mix `noise`'s lattice. Kept in\r\n * lockstep with `_seed` through {@link adopt}. */\r\n private numericSeed!: number;\r\n\r\n private readonly gen: SeedGenerator;\r\n\r\n /** A spare gaussian sample from the last Box–Muller pair (see {@link gauss}). */\r\n private spareGauss: number | null = null;\r\n\r\n constructor(seed: string | number) {\r\n this.gen = new SeedGenerator(seed);\r\n this.adopt(seed);\r\n }\r\n\r\n /** The seed this source rewinds to. Assigning a new value re-anchors the\r\n * source (same effect as `reset(seed)`): the next draws reproduce the\r\n * sequence for that seed, and `noise`'s lattice shifts to match. */\r\n get seed(): string | number {\r\n return this._seed;\r\n }\r\n set seed(seed: string | number) {\r\n this.adopt(seed);\r\n }\r\n\r\n /** Numeric form of a seed: string seeds are hashed (the same djb2-style mix\r\n * the generator uses), numbers pass through. Shared so the constructor, the\r\n * {@link seed} setter, and {@link reset} all derive `numericSeed` identically. */\r\n private static toNumeric(seed: string | number): number {\r\n return typeof seed === 'string'\r\n ? seed.split('').reduce((a, b) => (a << 5) - a + b.charCodeAt(0), 0)\r\n : seed;\r\n }\r\n\r\n /** Take `seed` as the new origin and rewind to it: store it, recompute the\r\n * `noise` lattice anchor, reset the generator, and drop any spare gauss. The\r\n * single seed-adoption path behind the constructor, {@link seed}, and a\r\n * seeded {@link reset}. */\r\n private adopt(seed: string | number): void {\r\n this._seed = seed;\r\n this.numericSeed = Random.toNumeric(seed);\r\n this.gen.setSeed(seed);\r\n this.spareGauss = null;\r\n }\r\n\r\n /**\r\n * The next pseudo-random float in `[from, to)`. Defaults to `[0, 1)`.\r\n */\r\n nextFloat(from: number = 0, to: number = 1): number {\r\n return this.gen.next() * (to - from) + from;\r\n }\r\n\r\n /**\r\n * The next pseudo-random integer in `[from, to)`. Defaults to the full\r\n * unsigned 32-bit range `[0, 2^32)`.\r\n */\r\n nextInt(from: number = 0, to: number = UINT32_RANGE): number {\r\n return Math.floor(this.gen.next() * (to - from)) + from;\r\n }\r\n\r\n /** `size` independent floats in `[from, to)`. */\r\n floatArray(size: number, from: number = 0, to: number = 1): number[] {\r\n const out = new Array<number>(size);\r\n for (let i = 0; i < size; i++) out[i] = this.nextFloat(from, to);\r\n return out;\r\n }\r\n\r\n /** `size` independent integers in `[from, to)`. */\r\n intArray(size: number, from: number = 0, to: number = UINT32_RANGE): number[] {\r\n const out = new Array<number>(size);\r\n for (let i = 0; i < size; i++) out[i] = this.nextInt(from, to);\r\n return out;\r\n }\r\n\r\n /**\r\n * A normally-distributed sample with the given `mean` and `stdev` (default\r\n * standard normal). Values cluster near the mean and tail off — useful for\r\n * natural-looking scatter where most draws stay central with occasional\r\n * outliers.\r\n *\r\n * Uses the polar Box–Muller transform, which yields two independent normals\r\n * per pair of uniforms; the spare is cached and returned on the next call.\r\n */\r\n gauss(mean: number = 0, stdev: number = 1): number {\r\n if (this.spareGauss !== null) {\r\n const z = this.spareGauss;\r\n this.spareGauss = null;\r\n return mean + stdev * z;\r\n }\r\n // Rejection-sample a point in the unit circle, then map to two normals.\r\n let u: number, v: number, s: number;\r\n do {\r\n u = this.gen.next() * 2 - 1;\r\n v = this.gen.next() * 2 - 1;\r\n s = u * u + v * v;\r\n } while (s >= 1 || s === 0);\r\n const mul = Math.sqrt(-2 * Math.log(s) / s);\r\n this.spareGauss = v * mul;\r\n return mean + stdev * (u * mul);\r\n }\r\n\r\n /**\r\n * Smooth 1-D value noise in `[0, 1]`.\r\n *\r\n * Samples two adjacent lattice points around `time * frequency`, then\r\n * interpolates with a smoothstep curve (`3t² - 2t³`) to avoid the linear\r\n * kinks of plain lerp. Unlike {@link nextFloat}/{@link gauss}, nearby\r\n * `time` inputs return nearby values — this is the correlated field used for\r\n * organic, continuously varying motion (camera shake, drift, waves).\r\n *\r\n * @param time Sample position (e.g. normalized timeline `[0, 1]`, or a\r\n * spatial index).\r\n * @param frequency Scales `time` before sampling; higher = faster\r\n * oscillation / more crests across the same span.\r\n */\r\n noise(time: number, frequency: number = 1): number {\r\n const t = time * frequency;\r\n const i = Math.floor(t);\r\n const f = t - i;\r\n // Smoothstep: maps f through 3f²-2f³ to ease in/out between lattice points.\r\n const curve = f * f * (3 - 2 * f);\r\n const r1 = this.latticeValue(i);\r\n const r2 = this.latticeValue(i + 1);\r\n return r1 + (r2 - r1) * curve;\r\n }\r\n\r\n /**\r\n * Rewind this source so the next draws reproduce a sequence from the start.\r\n *\r\n * With no argument, rewinds to the current {@link seed} — what authors call to\r\n * repeat a sequence within a scene. Pass a `seed` to adopt it as the new origin\r\n * first (equivalent to assigning {@link seed}), so the source both re-seeds and\r\n * rewinds in one call — e.g. in a node's constructor to give it a distinct\r\n * reproducible stream.\r\n */\r\n reset(seed: string | number = this._seed): void {\r\n this.adopt(seed);\r\n }\r\n\r\n /**\r\n * Deterministic value in `[0, 1)` for a given integer lattice point `x`,\r\n * mixed with this source's seed via `sin`. Pure in `x` (no generator state),\r\n * so {@link noise} is stable regardless of how many draws preceded it.\r\n */\r\n private latticeValue(x: number): number {\r\n const h = Math.sin(x + this.numericSeed) * 10000;\r\n return h - Math.floor(h);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../src/util/reference.ts"],"names":[],"mappings":"AAiDA;;;GAGG;AACH,MAAM,UAAU,SAAS;IACrB,IAAI,OAAO,GAAa,IAAI,CAAC;IAI7B,SAAS,GAAG,CAAC,IAAe;QACxB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,OAAO,GAAG,IAAI,CAAC;QACnB,CAAC;aAAM,CAAC;YACJ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAClD,CAAC;YACD,OAAO,OAAO,CAAC;QACnB,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["/**\n * A callable reference that acts as both getter and setter.\n * - `ref()` → returns the current value (throws if not yet assigned)\n * - `ref(value)` → sets the current value\n */\nexport interface Reference<T> {\n (): T;\n (node: T | null): void;\n /**\n * Phantom — never assigned at runtime, and never called. It exists so that\n * `T` appears in a *contravariant* position, which is what makes\n * {@link RefTarget} safe. The call signatures alone can't decide it: the\n * zero-arg getter `(): T` is assignable to any `(x) => void`, so a slot\n * typed as just the setter would silently accept a `Reference` of an\n * unrelated node type.\n * @internal\n */\n readonly __accepts?: (node: T) => void;\n}\n\n/**\n * A slot that can *receive* a `T` — a `Reference<T>`, or one declared as any\n * **supertype** of `T`.\n *\n * This is the type a node's `ref` prop takes, and the widening is deliberate:\n * the framework only ever writes into a ref (`props.ref(this)` in the `Node2D`\n * constructor) and the author only ever reads, so handing a `Rect` to a\n * `Reference<ShapeNode>` is sound in both directions — the write stores a\n * subtype, the read yields the supertype the author asked for. That is what\n * lets one ref hold whichever shape a factory happened to build:\n *\n * ```tsx\n * const ref = createRef<ShapeNode>();\n * <Rect ref={ref} /> // ✔ Rect is a ShapeNode\n * <Ellipse ref={ref} /> // ✔ so is Ellipse\n * ```\n *\n * The opposite direction stays an error, because it is the unsound one: a\n * `Reference<Rect>` on a `<Text>` would be handed a `Text` at runtime while\n * still typing every read as a `Rect`.\n *\n * A plain setter function is accepted too, which makes React-style callback\n * refs (`ref={n => …}`) work without a separate type.\n */\nexport type RefTarget<T> = {\n (node: T | null): void;\n readonly __accepts?: (node: T) => void;\n};\n\n/**\n * Creates a typed reference holder — analogous to React's `createRef`,\n * but expressed as a single overloaded function rather than a `{ current }` object.\n */\nexport function createRef<T>(): Reference<T> {\n let current: T | null = null;\n\n function ref(): T;\n function ref(node: T | null): void;\n function ref(node?: T | null): T | void {\n if (node !== undefined) {\n current = node;\n } else {\n if (current === null) {\n throw new Error(\"Reference not assigned yet\");\n }\n return current;\n }\n }\n\n return ref;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../src/util/reference.ts"],"names":[],"mappings":"AAiDA;;;GAGG;AACH,MAAM,UAAU,SAAS;IACrB,IAAI,OAAO,GAAa,IAAI,CAAC;IAI7B,SAAS,GAAG,CAAC,IAAe;QACxB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,OAAO,GAAG,IAAI,CAAC;QACnB,CAAC;aAAM,CAAC;YACJ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAClD,CAAC;YACD,OAAO,OAAO,CAAC;QACnB,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["/**\r\n * A callable reference that acts as both getter and setter.\r\n * - `ref()` → returns the current value (throws if not yet assigned)\r\n * - `ref(value)` → sets the current value\r\n */\r\nexport interface Reference<T> {\r\n (): T;\r\n (node: T | null): void;\r\n /**\r\n * Phantom — never assigned at runtime, and never called. It exists so that\r\n * `T` appears in a *contravariant* position, which is what makes\r\n * {@link RefTarget} safe. The call signatures alone can't decide it: the\r\n * zero-arg getter `(): T` is assignable to any `(x) => void`, so a slot\r\n * typed as just the setter would silently accept a `Reference` of an\r\n * unrelated node type.\r\n * @internal\r\n */\r\n readonly __accepts?: (node: T) => void;\r\n}\r\n\r\n/**\r\n * A slot that can *receive* a `T` — a `Reference<T>`, or one declared as any\r\n * **supertype** of `T`.\r\n *\r\n * This is the type a node's `ref` prop takes, and the widening is deliberate:\r\n * the framework only ever writes into a ref (`props.ref(this)` in the `Node2D`\r\n * constructor) and the author only ever reads, so handing a `Rect` to a\r\n * `Reference<ShapeNode>` is sound in both directions — the write stores a\r\n * subtype, the read yields the supertype the author asked for. That is what\r\n * lets one ref hold whichever shape a factory happened to build:\r\n *\r\n * ```tsx\r\n * const ref = createRef<ShapeNode>();\r\n * <Rect ref={ref} /> // ✔ Rect is a ShapeNode\r\n * <Ellipse ref={ref} /> // ✔ so is Ellipse\r\n * ```\r\n *\r\n * The opposite direction stays an error, because it is the unsound one: a\r\n * `Reference<Rect>` on a `<Text>` would be handed a `Text` at runtime while\r\n * still typing every read as a `Rect`.\r\n *\r\n * A plain setter function is accepted too, which makes React-style callback\r\n * refs (`ref={n => …}`) work without a separate type.\r\n */\r\nexport type RefTarget<T> = {\r\n (node: T | null): void;\r\n readonly __accepts?: (node: T) => void;\r\n};\r\n\r\n/**\r\n * Creates a typed reference holder — analogous to React's `createRef`,\r\n * but expressed as a single overloaded function rather than a `{ current }` object.\r\n */\r\nexport function createRef<T>(): Reference<T> {\r\n let current: T | null = null;\r\n\r\n function ref(): T;\r\n function ref(node: T | null): void;\r\n function ref(node?: T | null): T | void {\r\n if (node !== undefined) {\r\n current = node;\r\n } else {\r\n if (current === null) {\r\n throw new Error(\"Reference not assigned yet\");\r\n }\r\n return current;\r\n }\r\n }\r\n\r\n return ref;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/util/scheduler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H,MAAM,UAAU,gBAAgB;IAC5B,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,IAAI,MAAM;QAAE,OAAO,MAAM,EAAE,CAAC;IAC5B,OAAO,mBAAmB,EAAE,IAAI,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AACzF,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,wBAAwB;IACpC,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,OAAO,GAAG,IAAI,CAAC;IACf,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Event-loop yielding, for work that must stay interruptible.\n *\n * A long synchronous loop on the main thread cannot be cancelled: nothing else\n * can run to *ask* it to stop. `StateEvaluator`'s backward-seek replay is\n * exactly that shape, so it yields periodically through {@link yieldToScheduler}\n * — which is what lets a newer seek supersede one already in flight.\n *\n * Core is backend-agnostic (no DOM), so every mechanism here is feature-detected\n * and the module works unchanged in a browser, in Node, and under vitest.\n */\n\n/** Monotonic-ish clock in milliseconds. `performance` is absent in some hosts. */\nexport function now(): number {\n return typeof performance !== \"undefined\" && typeof performance.now === \"function\"\n ? performance.now()\n : Date.now();\n}\n\ntype SchedulerWithYield = { yield?: () => Promise<void> };\n\n/** `scheduler.yield()` when the host has it (Chrome 129+), else undefined. */\nfunction nativeYield(): (() => Promise<void>) | undefined {\n const s = (globalThis as { scheduler?: SchedulerWithYield }).scheduler;\n return typeof s?.yield === \"function\" ? s.yield.bind(s) : undefined;\n}\n\n/**\n * A single shared `MessageChannel`, because a yield-per-channel would allocate\n * (and leak until GC) thousands of ports over one scrub. Callbacks queue in FIFO\n * order and each posted message drains exactly one, so resolution order matches\n * call order.\n */\nlet channel: MessageChannel | null = null;\nconst queue: (() => void)[] = [];\n\nfunction messageChannelYield(): Promise<void> | null {\n if (typeof MessageChannel !== \"function\") return null;\n if (!channel) {\n channel = new MessageChannel();\n channel.port1.onmessage = () => queue.shift()?.();\n // Node2D keeps the event loop alive for an open port, which would hang\n // vitest on exit. Browsers have no unref and don't need one.\n (channel.port1 as unknown as { unref?: () => void }).unref?.();\n (channel.port2 as unknown as { unref?: () => void }).unref?.();\n }\n return new Promise<void>(resolve => {\n queue.push(resolve);\n channel!.port2.postMessage(null);\n });\n}\n\n/**\n * Yield to the event loop, letting pending input, timers and rendering run\n * before the caller resumes.\n *\n * Deliberately a **macrotask**, not a microtask: `await Promise.resolve()`\n * drains within the same task and would starve exactly the work we're yielding\n * for. `requestAnimationFrame` is also wrong here — it caps throughput to the\n * display rate and stops entirely in a background tab, which would stall\n * headless export and tests.\n *\n * Preference order:\n * 1. `scheduler.yield()` — resumes at continuation priority, so a sliced task\n * isn't starved behind unrelated work queued while it was parked.\n * 2. `MessageChannel` — a true macrotask with no clamping, in browsers and\n * Node2D ≥ 15.\n * 3. `setTimeout(0)` — last resort; clamps to ~4 ms once nested, capping the\n * slice rate, but always available.\n */\nexport function yieldToScheduler(): Promise<void> {\n const native = nativeYield();\n if (native) return native();\n return messageChannelYield() ?? new Promise<void>(resolve => setTimeout(resolve, 0));\n}\n\n/** Drop the shared channel. Tests only — the next yield lazily rebuilds it. */\nexport function __resetSchedulerForTests(): void {\n channel?.port1.close();\n channel?.port2.close();\n channel = null;\n queue.length = 0;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/util/scheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,kFAAkF;AAClF,MAAM,UAAU,GAAG;IACf,OAAO,OAAO,WAAW,KAAK,WAAW,IAAI,OAAO,WAAW,CAAC,GAAG,KAAK,UAAU;QAC9E,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE;QACnB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AACrB,CAAC;AAID,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AC/E,MAAM,UAAU,wBAAwB;IACpC,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,OAAO,GAAG,IAAI,CAAC;IACf,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACrB,CAAC","sourcesContent":["/**\r\n * Event-loop yielding, for work that must stay interruptible.\r\n *\r\n * A long synchronous loop on the main thread cannot be cancelled: nothing else\r\n * can run to *ask* it to stop. `StateEvaluator`'s backward-seek replay is\r\n * exactly that shape, so it yields periodically through {@link yieldToScheduler}\r\n * — which is what lets a newer seek supersede one already in flight.\r\n *\r\n * Core is backend-agnostic (no DOM), so every mechanism here is feature-detected\r\n * and the module works unchanged in a browser, in Node, and under vitest.\r\n */\r\n\r\n/** Monotonic-ish clock in milliseconds. `performance` is absent in some hosts. */\r\nexport function now(): number {\r\n return typeof performance !== \"undefined\" && typeof performance.now === \"function\"\r\n ? performance.now()\r\n : Date.now();\r\n}\r\n\r\ntype SchedulerWithYield = { yield?: () => Promise<void> };\r\n\r\n/** `scheduler.yield()` when the host has it (Chrome 129+), else undefined. */\r\nfunction nativeYield(): (() => Promise<void>) | undefined {\r\n const s = (globalThis as { scheduler?: SchedulerWithYield }).scheduler;\r\n return typeof s?.yield === \"function\" ? s.yield.bind(s) : undefined;\r\n}\r\n\r\n/**\r\n * A single shared `MessageChannel`, because a yield-per-channel would allocate\r\n * (and leak until GC) thousands of ports over one scrub. Callbacks queue in FIFO\r\n * order and each posted message drains exactly one, so resolution order matches\r\n * call order.\r\n */\r\nlet channel: MessageChannel | null = null;\r\nconst queue: (() => void)[] = [];\r\n\r\nfunction messageChannelYield(): Promise<void> | null {\r\n if (typeof MessageChannel !== \"function\") return null;\r\n if (!channel) {\r\n channel = new MessageChannel();\r\n channel.port1.onmessage = () => queue.shift()?.();\r\n // Node2D keeps the event loop alive for an open port, which would hang\r\n // vitest on exit. Browsers have no unref and don't need one.\r\n (channel.port1 as unknown as { unref?: () => void }).unref?.();\r\n (channel.port2 as unknown as { unref?: () => void }).unref?.();\r\n }\r\n return new Promise<void>(resolve => {\r\n queue.push(resolve);\r\n channel!.port2.postMessage(null);\r\n });\r\n}\r\n\r\n/**\r\n * Yield to the event loop, letting pending input, timers and rendering run\r\n * before the caller resumes.\r\n *\r\n * Deliberately a **macrotask**, not a microtask: `await Promise.resolve()`\r\n * drains within the same task and would starve exactly the work we're yielding\r\n * for. `requestAnimationFrame` is also wrong here — it caps throughput to the\r\n * display rate and stops entirely in a background tab, which would stall\r\n * headless export and tests.\r\n *\r\n * Preference order:\r\n * 1. `scheduler.yield()` — resumes at continuation priority, so a sliced task\r\n * isn't starved behind unrelated work queued while it was parked.\r\n * 2. `MessageChannel` — a true macrotask with no clamping, in browsers and\r\n * Node2D ≥ 15.\r\n * 3. `setTimeout(0)` — last resort; clamps to ~4 ms once nested, capping the\r\n * slice rate, but always available.\r\n */\r\nexport function yieldToScheduler(): Promise<void> {\r\n const native = nativeYield();\r\n if (native) return native();\r\n return messageChannelYield() ?? new Promise<void>(resolve => setTimeout(resolve, 0));\r\n}\r\n\r\n/** Drop the shared channel. Tests only — the next yield lazily rebuilds it. */\r\nexport function __resetSchedulerForTests(): void {\r\n channel?.port1.close();\r\n channel?.port2.close();\r\n channel = null;\r\n queue.length = 0;\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motionscript/core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Engine-agnostic animation library for Motion Script: scenes, nodes, props, tweens, layout, and the JSX runtime.",
|
|
6
6
|
"repository": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"types": "dist/index.d.ts",
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"files": [
|
|
28
|
+
"NOTICE",
|
|
28
29
|
"dist",
|
|
29
30
|
"CHANGELOG.md",
|
|
30
31
|
"!dist/**/*.tsbuildinfo"
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { type Vector2 } from "../../../../attributes/layout/vector2.js";
|
|
2
|
-
import type { ModedEffect, EffectData } from "../effect-data.js";
|
|
3
|
-
/**
|
|
4
|
-
* Which part of the map drives the displacement.
|
|
5
|
-
*
|
|
6
|
-
* - `"rg"` — red moves pixels horizontally, green vertically. The convention
|
|
7
|
-
* every normal/flow map is authored to, and the only one that can push in two
|
|
8
|
-
* directions independently.
|
|
9
|
-
* - `"luminance"` — one value drives both axes. What a grayscale *bump* map
|
|
10
|
-
* means: the brighter the pixel, the further it is pushed along `amount`.
|
|
11
|
-
* - `"alpha"` — the map's alpha, for displacing from a cut-out shape.
|
|
12
|
-
*/
|
|
13
|
-
export type DisplaceChannel = "rg" | "luminance" | "alpha";
|
|
14
|
-
/**
|
|
15
|
-
* Displacement map — the content is resampled at a position pushed around by a
|
|
16
|
-
* second image, rather than having its colours changed.
|
|
17
|
-
*
|
|
18
|
-
* This is the general warp. `wave` and `twirl` are the two procedural cases
|
|
19
|
-
* worth spelling out; everything else — refraction, heat haze, water, cloth,
|
|
20
|
-
* dissolve — is this effect plus the right map. Point it at a normal map for
|
|
21
|
-
* glass, at a noise texture for haze, at a gradient for a directional smear.
|
|
22
|
-
*
|
|
23
|
-
* **In `mode: 'backdrop'` this is refraction.** The displacement runs on what is
|
|
24
|
-
* painted *beneath* the node and is clipped to the node's silhouette, so the
|
|
25
|
-
* scene bends as it passes through the shape while the shape's own edges stay
|
|
26
|
-
* sharp — the frosted/liquid-glass panel, from one effect.
|
|
27
|
-
*
|
|
28
|
-
* `midpoint` is what the map calls "no displacement". Signed data packed into
|
|
29
|
-
* unsigned bytes centres on 0.5 (the default, and what a normal map assumes); a
|
|
30
|
-
* mask-style map that should only ever push one way wants 0.
|
|
31
|
-
*/
|
|
32
|
-
export interface DisplaceEffect extends ModedEffect {
|
|
33
|
-
type: "displace";
|
|
34
|
-
/** Map image path, resolved like an image fill's `src`. */
|
|
35
|
-
src: string;
|
|
36
|
-
/** Displacement at full deflection, in px per axis. `{x: 0, y: n}` warps vertically only. */
|
|
37
|
-
amount: Vector2;
|
|
38
|
-
/** Which channels of the map are read. */
|
|
39
|
-
channel: DisplaceChannel;
|
|
40
|
-
/** The map value meaning "don't move" — 0.5 for signed data, 0 for a one-way mask. */
|
|
41
|
-
midpoint: number;
|
|
42
|
-
/** Map scale — 1 covers the node once, 2 tiles it at half size. */
|
|
43
|
-
scale: number;
|
|
44
|
-
/** Map rotation in degrees. */
|
|
45
|
-
angle: number;
|
|
46
|
-
}
|
|
47
|
-
export declare const displaceEffect: EffectData<DisplaceEffect>;
|
|
48
|
-
//# sourceMappingURL=displace.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"displace.d.ts","sourceRoot":"","sources":["../../../../../src/attributes/shape/effects/implementations/displace.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE9D;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC;AAE3D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,cAAe,SAAQ,WAAW;IAC/C,IAAI,EAAE,UAAU,CAAC;IACjB,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;IACZ,6FAA6F;IAC7F,MAAM,EAAE,OAAO,CAAC;IAChB,0CAA0C;IAC1C,OAAO,EAAE,eAAe,CAAC;IACzB,sFAAsF;IACtF,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,cAAc,EAAE,UAAU,CAAC,cAAc,CA2BrD,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { lerpNumber } from "../../../../tween/lerp.js";
|
|
2
|
-
import { lerpVector2 } from "../../../../attributes/layout/vector2.js";
|
|
3
|
-
export const displaceEffect = {
|
|
4
|
-
lerp: (from, to, t) => ({
|
|
5
|
-
type: "displace",
|
|
6
|
-
// The image is discrete — snap rather than cross-fade, which would need
|
|
7
|
-
// two maps bound at once (same reasoning as `texture`).
|
|
8
|
-
src: t < 0.5 ? from.src : to.src,
|
|
9
|
-
channel: t < 0.5 ? from.channel : to.channel,
|
|
10
|
-
amount: lerpVector2(from.amount, to.amount, t),
|
|
11
|
-
midpoint: lerpNumber(from.midpoint, to.midpoint, t),
|
|
12
|
-
scale: lerpNumber(from.scale, to.scale, t),
|
|
13
|
-
angle: lerpNumber(from.angle, to.angle, t),
|
|
14
|
-
mode: t < 0.5 ? from.mode : to.mode,
|
|
15
|
-
}),
|
|
16
|
-
equals: (a, b) => a.src === b.src &&
|
|
17
|
-
a.amount.x === b.amount.x &&
|
|
18
|
-
a.amount.y === b.amount.y &&
|
|
19
|
-
a.channel === b.channel &&
|
|
20
|
-
a.midpoint === b.midpoint &&
|
|
21
|
-
a.scale === b.scale &&
|
|
22
|
-
a.angle === b.angle &&
|
|
23
|
-
a.mode === b.mode,
|
|
24
|
-
// Resamples the source at a displaced position.
|
|
25
|
-
surface: "shader",
|
|
26
|
-
// Without this the map is never requested, the backend's synchronous lookup
|
|
27
|
-
// finds nothing, and the effect silently has nothing to displace by.
|
|
28
|
-
declare: (effect, assets) => assets.image(effect.src),
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=displace.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"displace.js","sourceRoot":"","sources":["../../../../../src/attributes/shape/effects/implementations/displace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EA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AAK,CAAC,CAAC,QAAQ;QACzB,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QACnB,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QACnB,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;IACrB,gDAAgD;IAChD,OAAO,EAAE,QAAQ;IACjB,4EAA4E;IAC5E,qEAAqE;IACrE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;CACxD,CAAC","sourcesContent":["import { lerpNumber } from \"@/tween/lerp\";\nimport { lerpVector2, type Vector2 } from \"@/attributes/layout/vector2\";\nimport type { ModedEffect, EffectData } from \"../effect-data\";\n\n/**\n * Which part of the map drives the displacement.\n *\n * - `\"rg\"` — red moves pixels horizontally, green vertically. The convention\n * every normal/flow map is authored to, and the only one that can push in two\n * directions independently.\n * - `\"luminance\"` — one value drives both axes. What a grayscale *bump* map\n * means: the brighter the pixel, the further it is pushed along `amount`.\n * - `\"alpha\"` — the map's alpha, for displacing from a cut-out shape.\n */\nexport type DisplaceChannel = \"rg\" | \"luminance\" | \"alpha\";\n\n/**\n * Displacement map — the content is resampled at a position pushed around by a\n * second image, rather than having its colours changed.\n *\n * This is the general warp. `wave` and `twirl` are the two procedural cases\n * worth spelling out; everything else — refraction, heat haze, water, cloth,\n * dissolve — is this effect plus the right map. Point it at a normal map for\n * glass, at a noise texture for haze, at a gradient for a directional smear.\n *\n * **In `mode: 'backdrop'` this is refraction.** The displacement runs on what is\n * painted *beneath* the node and is clipped to the node's silhouette, so the\n * scene bends as it passes through the shape while the shape's own edges stay\n * sharp — the frosted/liquid-glass panel, from one effect.\n *\n * `midpoint` is what the map calls \"no displacement\". Signed data packed into\n * unsigned bytes centres on 0.5 (the default, and what a normal map assumes); a\n * mask-style map that should only ever push one way wants 0.\n */\nexport interface DisplaceEffect extends ModedEffect {\n type: \"displace\";\n /** Map image path, resolved like an image fill's `src`. */\n src: string;\n /** Displacement at full deflection, in px per axis. `{x: 0, y: n}` warps vertically only. */\n amount: Vector2;\n /** Which channels of the map are read. */\n channel: DisplaceChannel;\n /** The map value meaning \"don't move\" — 0.5 for signed data, 0 for a one-way mask. */\n midpoint: number;\n /** Map scale — 1 covers the node once, 2 tiles it at half size. */\n scale: number;\n /** Map rotation in degrees. */\n angle: number;\n}\n\nexport const displaceEffect: EffectData<DisplaceEffect> = {\n lerp: (from, to, t) => ({\n type: \"displace\",\n // The image is discrete — snap rather than cross-fade, which would need\n // two maps bound at once (same reasoning as `texture`).\n src: t < 0.5 ? from.src : to.src,\n channel: t < 0.5 ? from.channel : to.channel,\n amount: lerpVector2(from.amount, to.amount, t),\n midpoint: lerpNumber(from.midpoint, to.midpoint, t),\n scale: lerpNumber(from.scale, to.scale, t),\n angle: lerpNumber(from.angle, to.angle, t),\n mode: t < 0.5 ? from.mode : to.mode,\n }),\n equals: (a, b) =>\n a.src === b.src &&\n a.amount.x === b.amount.x &&\n a.amount.y === b.amount.y &&\n a.channel === b.channel &&\n a.midpoint === b.midpoint &&\n a.scale === b.scale &&\n a.angle === b.angle &&\n a.mode === b.mode,\n // Resamples the source at a displaced position.\n surface: \"shader\",\n // Without this the map is never requested, the backend's synchronous lookup\n // finds nothing, and the effect silently has nothing to displace by.\n declare: (effect, assets) => assets.image(effect.src),\n};\n"]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Vector2 } from "../../../../attributes/layout/vector2.js";
|
|
2
|
-
import type { ModedEffect, EffectData } from "../effect-data.js";
|
|
3
|
-
/**
|
|
4
|
-
* Crepuscular rays — bright areas smeared *outward from a point* and added back
|
|
5
|
-
* over the source, so light appears to stream past whatever occludes it.
|
|
6
|
-
*
|
|
7
|
-
* Related to `radialBlur` in `'zoom'` style, but not the same effect and not
|
|
8
|
-
* expressible as one: radial blur smears *everything*, which softens the image.
|
|
9
|
-
* This smears only what is brighter than `threshold` and screens the result on
|
|
10
|
-
* top, so the occluder stays sharp and only the light travels.
|
|
11
|
-
*/
|
|
12
|
-
export interface GodRaysEffect extends ModedEffect {
|
|
13
|
-
type: "godRays";
|
|
14
|
-
/** Additive multiplier for the ray pass. 0 = off. */
|
|
15
|
-
intensity: number;
|
|
16
|
-
/** 0–1 luminance cutoff — only pixels brighter than this cast rays. */
|
|
17
|
-
threshold: number;
|
|
18
|
-
/** How far the rays reach, as a fraction of the distance to `center`. */
|
|
19
|
-
length: number;
|
|
20
|
-
/** Light source in 0–1 layer coords (default middle). */
|
|
21
|
-
center: Vector2;
|
|
22
|
-
/** Per-step falloff; below 1 the rays fade with distance. */
|
|
23
|
-
decay: number;
|
|
24
|
-
/** Taps marched per pixel; higher is smoother and slower. */
|
|
25
|
-
samples: number;
|
|
26
|
-
}
|
|
27
|
-
export declare const godRaysEffect: EffectData<GodRaysEffect>;
|
|
28
|
-
//# sourceMappingURL=god-rays.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"god-rays.d.ts","sourceRoot":"","sources":["../../../../../src/attributes/shape/effects/implementations/god-rays.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAc,SAAQ,WAAW;IAC9C,IAAI,EAAE,SAAS,CAAC;IAChB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,MAAM,EAAE,OAAO,CAAC;IAChB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,aAAa,EAAE,UAAU,CAAC,aAAa,CAuBnD,CAAC"}
|